@scrubbe/sdk
v1.0.0
Published
Official TypeScript/JavaScript SDK for the Scrubbe Operational Intelligence Platform
Maintainers
Readme
@scrubbe/sdk — TypeScript / JavaScript
Official TypeScript SDK for the Scrubbe Operational Intelligence Platform. Works in Node.js ≥ 18 (CJS + ESM), Deno, and Cloudflare Workers.
Installation
npm install @scrubbe/sdk
# or
yarn add @scrubbe/sdk
# or
pnpm add @scrubbe/sdkQuick start
import { Scrubbe } from '@scrubbe/sdk';
const client = new Scrubbe({ apiKey: process.env.SCRUBBE_API_KEY });
// Create an incident
const incident = await client.incident.create({
title: 'Payment gateway degraded',
severity: 'P1',
service: 'payment-api',
});
console.log(incident.incident_id); // SI-000042
// List all open incidents (lazy pagination)
for await (const inc of client.incident.list({ state: 'INVESTIGATING' })) {
console.log(inc.title);
}
// Stream live events
for await (const event of client.incident.subscribe(incident.incident_id)) {
console.log(event.type, event.data);
}Authentication
// 1. API key (simplest)
const client = new Scrubbe({ apiKey: 'sk-...' });
// 2. OAuth2 client credentials
const client = new Scrubbe({ clientId: '...', clientSecret: '...' });
// 3. Env vars (SCRUBBE_API_KEY or SCRUBBE_CLIENT_ID + SCRUBBE_CLIENT_SECRET)
const client = new Scrubbe(); // auto-resolved
// 4. Credentials file ~/.scrubbe/credentials
// { "default": { "api_key": "sk-..." } }
const client = new Scrubbe({ profile: 'production' });Configuration
const client = new Scrubbe({
apiKey: '...',
baseUrl: 'https://api.scrubbe.com', // default
timeout: { connect: 5_000, read: 30_000 },
retry: { maxAttempts: 3, baseDelayMs: 500, maxDelayMs: 30_000 },
});Error handling
import {
UnauthenticatedError,
GovernanceApprovalRequiredError,
RateLimitedError,
} from '@scrubbe/sdk';
try {
await client.playbook.run('PB-0001', { incident_id: 'SI-000042' });
} catch (err) {
if (err instanceof GovernanceApprovalRequiredError) {
console.log('Pending approval:', err.approvalId);
} else if (err instanceof RateLimitedError) {
console.log(`Retry after ${err.retryAfterMs}ms`);
} else if (err instanceof UnauthenticatedError) {
console.log('Check your API key');
}
}Modules
| Module | Description |
|--------|-------------|
| client.incident | Incident lifecycle (create, update, resolve, enrich) |
| client.service | Service registry and health |
| client.event | Signal ingestion |
| client.timeline | Incident timeline entries |
| client.knowledge | KIE knowledge base search |
| client.handover | Shift handover and notes |
| client.playbook | Playbook execution and governance |
| client.workbench | AI workbench steps |
| client.postmortem | Post-mortem management |
| client.agent | AI agent operations (investigate, correlate, etc.) |
| client.mcp | Model Context Protocol queries |
| client.approval | Governance approval requests |
| client.audit | Audit log |
Development
npm install
npm run typecheck # tsc --noEmit
npm run lint # eslint
npm run format # prettier
npm test # vitest
npm run build # tsup → dist/ (CJS + ESM + .d.ts)