API Reference
Complete reference for governance-sdk v0.5.0. All functions are TypeScript-native. Zero runtime dependencies. Start with the quickstart if you haven't set up governance yet.
Core
import ... from 'governance-sdk'Primary API. Create governance instances, register agents, enforce policies.
createGovernancev0.1.0+corecreateGovernance(config: GovernanceConfig): GovernanceCreates a new governance instance with the provided configuration. The instance is the central object for all policy enforcement, agent registration, and audit logging.
| name | type | description |
|---|---|---|
config.rules | PolicyRule[] | Array of policy rules to evaluate on every enforce() call. |
config.storage | StorageAdapter | Storage backend. Defaults to in-memory. Use postgresStorage() for persistence. |
config.signingKey | string | HMAC signing key for tamper-evident audit chains. |
Governance— Governance instance with register(), enforce(), kill(), and on() methods.gov.registerv0.1.0+coregov.register(agent: AgentRegistration): Promise<RegisteredAgent>Registers an agent with the governance system. Computes a 7-dimension governance score (0–100) and assigns a governance level (L0–L4). Call once per agent at startup.
| name | type | description |
|---|---|---|
agent.namerequired | string | Unique identifier for the agent. |
agent.framework | 'mastra' | 'vercel-ai' | 'langchain' | 'openai' | Framework the agent uses. |
agent.tools | string[] | List of tool names the agent can access. |
agent.hasAuth | boolean | Whether the agent has authentication enabled. |
agent.hasGuardrails | boolean | Whether the agent has guardrails configured. |
Promise<RegisteredAgent>— Registered agent with id, score, level, status, and assessment fields.gov.enforcev0.1.0+coreenforcementgov.enforce(agentId: string, action: Action): Promise<EnforceResult>Evaluates all policies against the proposed action before execution. Returns allow or block with the matching rule. Automatically writes to audit trail.
| name | type | description |
|---|---|---|
agentIdrequired | string | ID of the agent requesting the action (from gov.register()). |
action.toolrequired | string | Name of the tool being called. |
action.params | Record<string, unknown> | Tool parameters, logged to audit trail. |
Promise<EnforceResult>— { outcome: 'allow' | 'block', rule?: string, reason?: string, latencyMs: number }createKillSwitchv0.2.0+kill-switchcreateKillSwitch(gov: Governance): KillSwitchCreates a kill switch instance bound to a governance engine. Use ks.kill() to halt a specific agent, ks.killAll() for fleet-wide emergency. Priority 999 overrides all other policies.
| name | type | description |
|---|---|---|
govrequired | Governance | Governance instance from createGovernance(). |
KillSwitch— Kill switch with kill(), killAll(), revive(), reviveAll(), isKilled(), and getKillRecords() methods.Injection Detection
import ... from 'governance-sdk'64+-pattern prompt injection scanner. Run on all user-sourced strings before agent processing.
detectInjectionv0.2.0+securitydetectInjection(input: string): InjectionResultSynchronously scans a string for prompt injection patterns across 7 categories. Returns detection status, category, matched pattern, and confidence score.
| name | type | description |
|---|---|---|
inputrequired | string | User-provided string to scan. |
InjectionResult— { detected: boolean, category?: string, pattern?: string, score: number }Audit Integrity
import ... from 'governance-sdk/audit-integrity'HMAC-SHA256 hash-chained audit trail. Tamper detection with exact broken-link location.
createIntegrityChainv0.3.0+auditsecuritycreateIntegrityChain(config: ChainConfig): IntegrityChainCreates an HMAC-SHA256 hash-chained audit log. Each event includes the hash of the previous, making any modification detectable via chain.verify().
| name | type | description |
|---|---|---|
config.signingKeyrequired | string | Secret key for HMAC computation. Keep in environment variables. |
config.storage | StorageAdapter | Where to persist events. Defaults to in-memory. |
IntegrityChain— Chain with append(), verify(), and export() methods.EU AI Act Compliance
import ... from 'governance-sdk/compliance'Article-by-article EU AI Act coverage assessment. Tracks 6 articles across Articles 9, 11, 12, 14, 15, and 50.
assessCompliancev0.3.0+complianceassessCompliance(config: ComplianceConfig): ComplianceResultEvaluates your governance configuration against 6 EU AI Act articles and returns a compliance score with covered/gap breakdown.
| name | type | description |
|---|---|---|
config.hasPolicies | boolean | Whether policy rules are configured (Article 9, 15). |
config.hasAuditTrail | boolean | Whether HMAC audit chain is enabled (Article 12). |
config.hasRequireApproval | boolean | Whether human oversight gates are active (Article 14). |
config.registeredAgents | number | Number of agents registered via gov.register() (Article 11). |
ComplianceResult— { score: number, covered: string[], gaps: string[], articles: ArticleStatus[] }Enterprise
import ... from '@lua-ai-global/governance-enterprise'Multi-tenant governance, RBAC, org-level analytics, and policy templates. Enterprise plan required.
bootstrapEnterpriseTenantv0.5.0+enterprisebootstrapEnterpriseTenant(config: BootstrapConfig): Promise<EnterpriseTenant>Creates a fully wired enterprise tenant with multi-tenancy, RBAC, analytics, compliance, health monitor, approval queue, and more — all from a single call.
| name | type | description |
|---|---|---|
config.namerequired | string | Organization name. |
config.slugrequired | string | URL-safe identifier for the tenant. |
config.planrequired | 'pro' | 'enterprise' | Licensing plan. |
config.ownerIdrequired | string | Owner user ID. |
config.frameworks | string[] | Compliance frameworks to pre-load (e.g., ['hipaa', 'soc2']). |
Promise<EnterpriseTenant>— Enterprise tenant with gov, analytics, compliance, healthMonitor, events, and more.8-step setup guide with adapter examples and policy templates.