Skip to content

TypeScript SDK

Full reference for @sovr/sdk.

Installation

bash
npm install @sovr/sdk

Client

typescript
import { SovrClient } from '@sovr/sdk';

const sovr = new SovrClient({
  tenantId: string,
  apiKey: string,
  baseUrl?: string,
  timeout?: number,
  retries?: number,
});

Gate

check()

typescript
const result = await sovr.gate.check({
  action: string,
  context?: Record<string, any>,
});

// Returns: { decision, reason, riskScore, approvalId?, plan? }

risk()

typescript
const assessment = await sovr.gate.risk({
  action: string,
  context?: Record<string, any>,
});

// Returns: { score, factors }

Approvals

typescript
// List
const approvals = await sovr.approvals.list({ status?: string });

// Approve
await sovr.approvals.approve(id, { approverId, comment? });

// Reject
await sovr.approvals.reject(id, { approverId, reason });

Audit

typescript
// Get chain
const logs = await sovr.audit.chain({ limit?, offset? });

// Verify
const result = await sovr.audit.verify({ startDate?, endDate? });

// Log
await sovr.audit.log({ eventType, data, userId?, metadata? });

Kill Switch

typescript
// Status
const status = await sovr.killswitch.status();

// Trigger
await sovr.killswitch.trigger({ level, reason, triggeredBy });

// Recover
await sovr.killswitch.recover({ recoveredBy, comment? });

Evidence

typescript
// Export bundle
const bundle = await sovr.evidence.bundle(decisionId);

// Verify bundle
const result = await sovr.evidence.verify(bundle);

Error Handling

typescript
import { SovrError, RateLimitError } from '@sovr/sdk';

try {
  await sovr.gate.check({ action: '...' });
} catch (error) {
  if (error instanceof RateLimitError) {
    await sleep(error.retryAfter);
  }
}

The AI Responsibility Layer