Package Exports
- @hybridb/sdk
- @hybridb/sdk/react
Readme
@hybridb/sdk
Official TypeScript SDK for the Stellrai governed execution runtime.
Stellrai doesn't care how you built your app. It governs how it executes.
Build with any framework, any database, any stack. Route governed actions through @hybridb/sdk — and every critical operation becomes decided, audited, and reversible by default.
What this SDK does
When your app needs to perform a governed action — an AI decision, a payment, identity resolution, an external provider call, or any audit-required state change — you route it through this SDK. Everything else in your app stays exactly as it was.
| Governed (use SDK) | Not governed (use any tool) |
|---|---|
| AI decisions and inferences | UI rendering |
| Payments and financial operations | Local database reads/writes |
| Identity resolution and auth | In-memory computation |
| External provider calls (Stripe, KYC, etc.) | Draft content and UI state |
| Audit-required state changes | Application configuration |
Installation
npm install @hybridb/sdk
# or
pnpm add @hybridb/sdk
# or
yarn add @hybridb/sdkQuick start
1. Get an API key
Sign up at stellrai.com — free tier, no credit card required. Your API key is shown once at registration.
2. Initialise the client
import { HybriDBClient } from '@hybridb/sdk';
const hdb = new HybriDBClient({
baseUrl: 'https://hybridb.stellrai.com',
apiKey: process.env.HYBRIDB_API_KEY!,
});3. Trigger a governed pipeline
const execution = await hdb.triggerPipeline({
pipelineId: 'process-payment',
input: { userId: 'u_123', amount: 15000, currency: 'USD' },
idempotencyKey: crypto.randomUUID(),
});
console.log(execution.id); // exec_xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
console.log(execution.status); // 'completed'4. Rollback a failed execution
if (execution.status === 'failed') {
const result = await hdb.reversibility.rollback(execution.id, {
rollbackType: 'full',
reason: 'Payment processor returned 422',
});
console.log(result.outcome); // 'success'
console.log(result.stepsRolledBack); // ['charge', 'reserve', 'notify']
console.log(result.durationMs); // 2840
}5. Replay from a checkpoint
const checkpoints = await hdb.reversibility.getCheckpoints(execution.id);
const replay = await hdb.reversibility.replay(execution.id, {
fromCheckpoint: checkpoints[1].id, // resume after step 2 — not from step zero
reason: 'Retry notification step after rate limit',
});
console.log(replay.newExecutionId); // new child execution
console.log(replay.parentExecutionId); // original executionAPI reference
HybriDBClient
const hdb = new HybriDBClient({
baseUrl: string, // required — e.g. 'https://hybridb.stellrai.com'
apiKey: string, // required — your Stellrai API key
timeout?: number, // ms, default 10000
retries?: number, // default 3
retryDelay?: number, // ms, default 500
});Pipelines
hdb.triggerPipeline(input) // trigger a governed pipeline
hdb.getPipelineExecution(executionId) // get execution statusReversibility
hdb.reversibility.rollback(executionId, input) // rollback full / selective / to checkpoint
hdb.reversibility.replay(executionId, input) // replay from a specific checkpoint
hdb.reversibility.getCheckpoints(executionId) // list all checkpoints
hdb.reversibility.getCheckpoint(executionId, id) // get checkpoint (checksum-verified)
hdb.reversibility.getRollbackLog(executionId) // audit log of rollback operations
hdb.reversibility.getCircuitBreaker(pipelineId) // get circuit breaker status
hdb.reversibility.setCircuitBreaker(pipelineId, input) // open / close circuit breakerDecisions
hdb.requestDecision(request) // policy-governed decision
hdb.getDecision(decisionId) // retrieve a past decisionIdentity & Auth
hdb.authenticate(input) // email + password → token pair
hdb.refreshToken(refreshToken) // refresh an access token
hdb.revokeSession() // invalidate current session
hdb.verifyToken(token) // local JWT verification via JWKS (requires jose)
hdb.actors.createApiKey(actorId, input)
hdb.actors.revokeApiKey(actorId, keyId)
hdb.actors.createMapping(actorId, input)
hdb.orgs.addMember(orgId, input)
hdb.orgs.updateMemberRole(orgId, actorId, role)
hdb.orgs.revokeMember(orgId, actorId)
hdb.orgs.listMembers(orgId)Events & Audit
hdb.publishEvent(input) // publish a business event
hdb.queryAuditLog(params) // query the immutable audit log
hdb.health() // check API statusReact context (optional)
import { HybriDBProvider, useHybriDBClient } from '@hybridb/sdk/react';
// Wrap at app root
<HybriDBProvider client={hdb}>
{children}
</HybriDBProvider>
// Use in any component
const { client } = useHybriDBClient();Error handling
All SDK methods throw HybriDBError on failure. Never swallow these — they represent governance failures, not application errors.
import { HybriDBClient, HybriDBError } from '@hybridb/sdk';
try {
const execution = await hdb.triggerPipeline({ ... });
} catch (err) {
if (err instanceof HybriDBError) {
console.error(err.code); // e.g. 'POLICY_BLOCKED', 'RATE_LIMITED'
console.error(err.message); // human-readable description
console.error(err.details); // structured detail object (when present)
}
throw err; // let errors propagate — don't hide governance failures
}Requirements
- Node.js 18+
- TypeScript 5+ (optional but recommended)
jose^5.0 (only required if you usehdb.verifyToken()— auto-installed as dependency)- React 18+ (only required for
@hybridb/sdk/react— optional peer dependency)
Links
- Dashboard: stellrai.com/dashboard
- API Reference: hybridb.stellrai.com/docs
- OpenAPI spec: hybridb.stellrai.com/openapi.json
- Status: hybridb.stellrai.com/health
- Issues: github.com/3pplea-Holdings/stellrai/issues
License
MIT © 3PPLEA Holdings LLC