Database-native infrastructure for crash-proof AI agents. State lives in CockroachDB, not memory. Workers can die anytime — agents resume exactly where they left off.
import { x404r } from '@shalwin04/x404r-sdk';
// Initialize the crash-proof runtime
const runtime = await new x404r({
connectionString: process.env.DATABASE_URL, // CockroachDB
ai: { provider: 'gemini', apiKey: process.env.GEMINI_API_KEY }
}).ready();
// Define a workflow with checkpoints
const workflow = runtime.workflow('analyze-code', {
steps: [{
name: 'process',
handler: async (ctx) => {
// Resume from checkpoint if we crashed
let step = ctx.state.step || 0;
for (let i = step; i < items.length; i++) {
const result = await ctx.ai.generate(`Analyze: ${items[i]}`);
// THE MAGIC LINE - state saved to CockroachDB
await ctx.checkpoint({ step: i + 1, results: [...] });
// Worker dies here? No problem. Next worker resumes.
}
return { done: true };
}
}]
});
// Run with crash recovery
const result = await workflow.run({ items }, { wait: true });Same 5-step task. Same crash at step 3. Real Gemini API calls.
Vanilla wasted 2 AI calls and restarted from scratch.
x404-r resumed from checkpoint with zero wasted work.
Published on npm. 78 tests passing. TypeScript-first.
npm install @shalwin04/x404r-sdk
const runtime = await new x404r({
connectionString: process.env.DATABASE_URL,
ai: { provider: 'gemini', apiKey: '...' }
}).ready();ctx.checkpoint(state)Save state atomically to CockroachDB. Survives any crash.
ctx.stateAccess last checkpoint. Resume from where you left off.
ctx.ai.generate(prompt)Call AI with automatic token tracking and cost calculation.
runtime.workflow(name, config)Define multi-step workflows with dependencies (DAG).
runtime.worker(options)Create stateless workers with configurable concurrency.
workflow.run(input, options)Execute workflow with optional wait for completion.
Your CockroachDB, your workers, full control.
const runtime = new x404r({
mode: 'embedded',
connectionString: process.env.DATABASE_URL,
ai: { provider: 'gemini', apiKey: '...' }
});
const worker = runtime.worker({ concurrency: 5 });
await worker.start();Submit jobs via API, Lambda handles execution.
const runtime = new x404r({
mode: 'cloud',
apiKey: 'x404r_live_...',
baseUrl: 'https://www.npmjs.com/package/@shalwin04/x404r-sdk'
});
// Lambda workers execute automatically
const result = await runtime.submit('workflow', data);x404-r uses API keys to authenticate requests. Each key is scoped to your organization and provides secure access to your workflows and data.
X404R_API_KEY=af_...const runtime = await new x404r({
connectionString: process.env.DATABASE_URL,
apiKey: process.env.X404R_API_KEY,
}).ready();Keep your API key secure
Never commit API keys to version control. Use environment variables or a secrets manager. Keys are hashed (SHA-256) and cannot be recovered if lost.
We believe in transparency. Here's exactly what data we store and how we use it.
Each organization's data is completely isolated using CockroachDB's row-level security. Your workflows, checkpoints, and AI outputs are never accessible by other tenants. All data is scoped by your unique tenant ID and enforced at the database level.
Built on CockroachDB's distributed architecture. Deploy with AWS Lambda.
Save progress to CockroachDB at any point. Workers can crash, restart, or scale — agents resume exactly where they left off.
Replay any workflow from any checkpoint. Debug failures by rewinding time. Test different inputs without re-running entire workflows.
Track exactly what you're spending on AI. See per-task token usage, cost breakdowns, and how much crash recovery saves you.
Built-in failure injection for testing. Simulate crashes, timeouts, OOM, and rate limits. Verify your agents handle failures gracefully.
Built-in tenant isolation, API key auth, usage tracking, and priority scheduling. Enterprise customers get processed first.
Use Claude, Titan, or Llama via AWS Bedrock. Also supports Gemini, OpenAI, and Anthropic directly. One config to switch providers.
Distributed SQL
Serverless Workers
Type-safe SDK
DAG Visualization
Try the live demo or explore the SDK documentation.