niyam-sdk
v0.1.0
Published
The unified Niyam SDK: embed the centrally-governed AI action gate in your own agent code
Readme
niyam-sdk (Node.js SDK)
The unified Niyam SDK for Node.js. Embed the centrally-governed AI action gate in
your own agent code: enroll once, then wrap dispatch around your tool-dispatch
layer. Enforcement is deterministic and in-process (no per-call network hop);
policy is pulled from the control plane and can never be overridden locally.
const { GovernedGate, Gateway, inspectToken } = require('niyam-sdk')
// Enroll to the control plane (like a data-plane node): pulls the compiled policy,
// the capability-token issuer, and the revocation set, and builds an in-process
// gate over its own post-quantum audit chain.
const gate = GovernedGate.enroll(
'http://127.0.0.1:9090', // control plane
'enrollment-token', // bootstrap token
'billing-agent' // this instance's name in the registry
)
// Wrap your tool dispatch once. `capabilityToken` was minted centrally for the agent.
const decision = gate.dispatch(capabilityToken, 'tools.email.send', 'mailbox/support')
if (decision.allowed) {
sendEmail() // every decision is signed into the audit chain
} else {
throw new Error(decision.reason)
}
// Route model calls through a governed gateway so model traffic + safety + budgets
// are enforced centrally (never re-implemented per app).
const gw = new Gateway('http://gateway.internal:8080', clientKey)
// openai.baseURL = gw.openaiBaseUrl()Build
npm install
npm run build # @napi-rs/cli -> platform-tagged .node addonEverything is post-quantum from day one (ML-DSA-65 hybrid with Ed25519), matching the rest of Niyam. The SDK never authors policy; it only pulls and enforces.
