{"_id":"@auxdynamics/mastguard-sdk","_rev":"2-c755286ea00a633024944c98aaa500fe","name":"@auxdynamics/mastguard-sdk","dist-tags":{"latest":"0.1.1"},"versions":{"0.1.0":{"name":"@auxdynamics/mastguard-sdk","version":"0.1.0","keywords":["ai-governance","mastguard","ai-agents","hitl","compliance"],"author":{"url":"https://mastguard.io","name":"AuxDynamics Inc.","email":"mastguard@auxdynamics.com"},"license":"MIT","_id":"@auxdynamics/mastguard-sdk@0.1.0","maintainers":[{"name":"auxdynamics","email":"info@auxdynamics.com"}],"homepage":"https://mastguard.io","bugs":{"url":"https://github.com/mastguard/mastguard/issues","email":"mastguard@auxdynamics.com"},"dist":{"shasum":"e09fe25632882a16e11169e59c96ffda6e8e252a","tarball":"https://registry.npmjs.org/@auxdynamics/mastguard-sdk/-/mastguard-sdk-0.1.0.tgz","fileCount":9,"integrity":"sha512-q5uZrFsaXISUAp6Uf1zwYzUHbed2KbI7OFcY+vIv7E/0hjVO8kHBJSoD0eSBsxXRrMWwfXF6g25n6ImjgTP+jA==","signatures":[{"sig":"MEQCIFcSnshijzlTNEmoyUHqAWeo7UFCzuygIpKZO32OvY//AiBT/lK5xeHVZZlVkER+Vj3UCqq7DGIX5MadB3KM90J4fQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":168759},"main":"dist/index.js","types":"dist/index.d.ts","module":"dist/index.mjs","engines":{"node":">=18"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"gitHead":"4ccca11d6b8092079c8e8dcbe08c9cc4a82a68aa","scripts":{"test":"vitest run","build":"tsup","clean":"rm -rf dist","typecheck":"tsc --noEmit","prepublishOnly":"npm run build && npx vitest run"},"_npmUser":{"name":"auxdynamics","email":"info@auxdynamics.com"},"repository":{"url":"git+https://github.com/mastguard/mastguard.git","type":"git","directory":"packages/sdk-typescript"},"_npmVersion":"11.12.1","description":"TypeScript SDK for the MastGuard AI Governance Platform — instrument AI agents with real-time governance, MAST failure detection, and HITL review.","directories":{},"sideEffects":false,"_nodeVersion":"25.9.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","vitest":"^1.6.0","typescript":"^5.4.0","@types/node":"^20.11.0"},"_npmOperationalInternal":{"tmp":"tmp/mastguard-sdk_0.1.0_1778528331317_0.11382011408475123","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@auxdynamics/mastguard-sdk","version":"0.1.1","description":"TypeScript SDK for the MastGuard AI Governance Platform — instrument AI agents with real-time governance, MAST failure detection, and HITL review.","license":"MIT","author":{"name":"AuxDynamics Inc.","email":"mastguard@auxdynamics.com","url":"https://mastguard.io"},"homepage":"https://mastguard.io","repository":{"type":"git","url":"git+https://github.com/mastguard/mastguard.git","directory":"packages/sdk-typescript"},"bugs":{"url":"https://github.com/mastguard/mastguard/issues","email":"mastguard@auxdynamics.com"},"keywords":["ai-governance","mastguard","ai-agents","hitl","compliance"],"main":"dist/index.js","module":"dist/index.mjs","types":"dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"publishConfig":{"access":"public"},"sideEffects":false,"engines":{"node":">=18"},"scripts":{"build":"tsup","test":"vitest run","typecheck":"tsc --noEmit","clean":"rm -rf dist","prepublishOnly":"npm run build && npx vitest run"},"devDependencies":{"@types/node":"^20.11.0","tsup":"^8.0.0","typescript":"^5.4.0","vitest":"^1.6.0"},"gitHead":"7a14b85430ec1973876c905d26775ce7ee39f940","_id":"@auxdynamics/mastguard-sdk@0.1.1","_nodeVersion":"25.9.0","_npmVersion":"11.12.1","dist":{"integrity":"sha512-f/FuInZmp32bWMXB8CNS4ieftMV/eBamHYSz0UUrGTI0vDewOYmvcoYBPLwnfhL5egbibmhXoSKJxS5Wu3O+1A==","shasum":"6b3190a59d95e2a468e2bb6b21c750a67dcab718","tarball":"https://registry.npmjs.org/@auxdynamics/mastguard-sdk/-/mastguard-sdk-0.1.1.tgz","fileCount":9,"unpackedSize":168891,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCHoavBNolENTHUzXWDpF71B1Cm8TqD2B107pvxLfPNSwIhAOG6Lo+iaZ+5fcZ2N8MCLcbxeUkdHMHZbDc5JUXOx3w5"}]},"_npmUser":{"name":"auxdynamics","email":"info@auxdynamics.com"},"directories":{},"maintainers":[{"name":"auxdynamics","email":"info@auxdynamics.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/mastguard-sdk_0.1.1_1778529285477_0.1320330236516638"},"_hasShrinkwrap":false}},"time":{"created":"2026-05-11T19:38:51.197Z","modified":"2026-05-11T19:54:45.769Z","0.1.0":"2026-05-11T19:38:51.489Z","0.1.1":"2026-05-11T19:54:45.671Z"},"bugs":{"url":"https://github.com/mastguard/mastguard/issues","email":"mastguard@auxdynamics.com"},"author":{"name":"AuxDynamics Inc.","email":"mastguard@auxdynamics.com","url":"https://mastguard.io"},"license":"MIT","homepage":"https://mastguard.io","keywords":["ai-governance","mastguard","ai-agents","hitl","compliance"],"repository":{"type":"git","url":"git+https://github.com/mastguard/mastguard.git","directory":"packages/sdk-typescript"},"description":"TypeScript SDK for the MastGuard AI Governance Platform — instrument AI agents with real-time governance, MAST failure detection, and HITL review.","maintainers":[{"name":"auxdynamics","email":"info@auxdynamics.com"}],"readme":"# @auxdynamics/mastguard-sdk\n\nOfficial TypeScript SDK for the [MastGuard](https://mastguard.io) AI Governance Platform.\n\nWrap the MastGuard REST API in a clean, fully-typed, zero-dependency client.\n\n## Installation\n\n```bash\nnpm install @auxdynamics/mastguard-sdk\n```\n\n## Quick Start\n\n```ts\nimport { MastGuardClient } from \"@auxdynamics/mastguard-sdk\";\n\nconst client = new MastGuardClient({ apiKey: process.env.MASTGUARD_API_KEY! });\n\nconst decision = await client.governance.ingest({\n  agentId: \"trade-agent-01\",\n  actionType: \"PAYMENT_APPROVE\",\n  payload: { symbol: \"AAPL\", quantity: 100 },\n});\n\nif (decision.decision === \"BLOCK\") {\n  throw new Error(\"Action blocked by governance policy\");\n}\n```\n\n## Authentication\n\nIssue an API key from your MastGuard dashboard → **Developer** page. The SDK\nsends it as the `X-API-Key` header on every request.\n\n## Configuration\n\n| Option       | Default                       | Description                                     |\n| ------------ | ----------------------------- | ----------------------------------------------- |\n| `apiKey`     | (required)                    | Your MastGuard API key.                         |\n| `baseUrl`    | `https://api.mastguard.io`    | Override for self-hosted / staging environments.|\n| `timeout`    | `30000`                       | Per-request timeout in milliseconds.            |\n| `retries`    | `3`                           | Retry attempts for 429 / 5xx / network errors.  |\n| `retryDelay` | `1000`                        | Base delay for exponential backoff.             |\n| `onError`    | `undefined`                   | Hook fired on every error (including retries).  |\n| `fetch`      | `globalThis.fetch`            | Inject a custom fetch (mostly for tests).       |\n\n## Resources\n\n```ts\nclient.governance.ingest({...})        // POST /api/v1/governance/ingest\nclient.governance.getDashboard()       // GET  /api/v1/governance/dashboard\nclient.governance.getAgents()          // GET  /api/v1/governance/agents\nclient.governance.getPolicies()        // GET  /api/v1/governance/policies\n\nclient.hitl.getQueue({ status, page, limit })           // GET  /api/v1/hitl/queue\nclient.hitl.getTask(taskId)                             // GET  /api/v1/hitl/queue/:id\nclient.hitl.approve(taskId, { rationale })              // POST /api/v1/hitl/queue/:id/approve\nclient.hitl.reject(taskId, { rationale })               // POST /api/v1/hitl/queue/:id/reject\nclient.hitl.getAuditLog({ agentId, decision, ... })     // GET  /api/v1/hitl/audit\n\nclient.webhooks.list()\nclient.webhooks.create({ name, url, eventTypes })\nclient.webhooks.delete(webhookId)\n```\n\n## Webhook Signature Verification\n\nMastGuard signs every outbound webhook with HMAC-SHA256 in the\n`X-MastGuard-Signature` header (format: `sha256=<hex>`).\n\n```ts\nimport { MastGuardWebhooks } from \"@auxdynamics/mastguard-sdk\";\n\nconst valid = await MastGuardWebhooks.verifySignature(\n  rawBody,                         // raw request body (string or Uint8Array)\n  request.headers[\"x-mastguard-signature\"],\n  process.env.WEBHOOK_SIGNING_SECRET!,\n);\nif (!valid) return new Response(\"invalid signature\", { status: 401 });\n```\n\nWorks in Node.js 18+ and Edge runtimes (Cloudflare Workers, Vercel Edge).\n\n## Error Handling\n\nAll errors extend `MastGuardError`. Catch the base class for blanket handling\nor use `instanceof` for specific responses.\n\n```ts\nimport { ConflictError, RateLimitError } from \"@auxdynamics/mastguard-sdk\";\n\ntry {\n  await client.hitl.approve(id, { rationale: \"Verified by treasury.\" });\n} catch (err) {\n  if (err instanceof ConflictError) {\n    // Already approved, expired, or in a non-actionable state.\n  } else if (err instanceof RateLimitError) {\n    // Honour err.retryAfterSeconds.\n  } else {\n    throw err;\n  }\n}\n```\n\n| HTTP status | Class                 |\n| ----------- | --------------------- |\n| 401         | `AuthenticationError` |\n| 403         | `AuthorizationError`  |\n| 404         | `NotFoundError`       |\n| 409         | `ConflictError`       |\n| 422         | `ValidationError`     |\n| 429         | `RateLimitError`      |\n| 5xx         | `ServerError`         |\n| (network)   | `NetworkError`        |\n| (timeout)   | `TimeoutError`        |\n\n## Requirements\n\n- Node.js 18+ (uses native `fetch`).\n- For Node 16, install a `fetch` polyfill (e.g. `undici`) and pass it via the\n  `fetch` config option.\n\n## TypeScript\n\nFull TypeScript support is included — no `@types` package needed. CJS and ESM\nbuilds are both shipped.\n\n## License\n\nMIT © MAST Guard Inc.\n","readmeFilename":"README.md"}