Built for CockroachDB x AWS Hackathon

The runtime where
context is never lost

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.

Create Agent
crash-proof-agent.ts
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 });

Real Benchmark Results

Same 5-step task. Same crash at step 3. Real Gemini API calls.

x404-r SDK
Vanilla
Total AI Calls
5
7
Wasted AI Calls
0
2
Total Tokens
12,609
19,469
Wasted Tokens
250
3,889
Total Cost
$0.00352
$0.00558
Total Time
90.2s
184.9s
29%
Fewer AI calls
35%
Tokens saved
2x
Faster recovery

Vanilla wasted 2 AI calls and restarted from scratch.

x404-r resumed from checkpoint with zero wasted work.

SDK

@shalwin04/x404r-sdk

Published on npm. 78 tests passing. TypeScript-first.

📦 Installation

npm install @shalwin04/x404r-sdk

🔧 Initialize

const runtime = await new x404r({
  connectionString: process.env.DATABASE_URL,
  ai: { provider: 'gemini', apiKey: '...' }
}).ready();

🛠️ Core APIs

ctx.checkpoint(state)

Save state atomically to CockroachDB. Survives any crash.

ctx.state

Access 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.

🏠 Embedded Mode

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();

☁️ Cloud Mode

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);
AUTHENTICATION

Secure API Key Authentication

x404-r uses API keys to authenticate requests. Each key is scoped to your organization and provides secure access to your workflows and data.

1Get Your API Key

  1. →Go to Settings in the dashboard
  2. →Click "Create Key" and give it a name
  3. →Copy and securely store your key (shown only once)
  4. →Add to your environment: X404R_API_KEY=af_...

2Use in Your Code

config.ts
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.

DATA POLICY

Your Data, Your Control

We believe in transparency. Here's exactly what data we store and how we use it.

What We Store

  • ✓Workflow state & checkpoints
  • ✓Task inputs & outputs
  • ✓Token usage metrics
  • ✓Error logs for debugging

How We Use It

  • →Resume workflows after crashes
  • →Time-travel debugging
  • →Usage billing & analytics
  • →Service improvement

What We Don't Do

  • ✗Sell your data to third parties
  • ✗Train AI models on your data
  • ✗Share data across tenants
  • ✗Retain data after deletion

Complete Tenant Isolation

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.

Everything you need for crash-proof agents

Built on CockroachDB's distributed architecture. Deploy with AWS Lambda.

Crash-Proof Checkpoints

Save progress to CockroachDB at any point. Workers can crash, restart, or scale — agents resume exactly where they left off.

Time Travel Debugging

Replay any workflow from any checkpoint. Debug failures by rewinding time. Test different inputs without re-running entire workflows.

Cost Transparency

Track exactly what you're spending on AI. See per-task token usage, cost breakdowns, and how much crash recovery saves you.

Chaos Engineering

Built-in failure injection for testing. Simulate crashes, timeouts, OOM, and rate limits. Verify your agents handle failures gracefully.

Multi-Tenant SaaS

Built-in tenant isolation, API key auth, usage tracking, and priority scheduling. Enterprise customers get processed first.

AWS Bedrock Ready

Use Claude, Titan, or Llama via AWS Bedrock. Also supports Gemini, OpenAI, and Anthropic directly. One config to switch providers.

Built on battle-tested infrastructure

CR

CockroachDB

Distributed SQL

λ

AWS Lambda

Serverless Workers

TS

TypeScript

Type-safe SDK

RF

React Flow

DAG Visualization

Ready to build crash-proof agents?

Try the live demo or explore the SDK documentation.