TL;DR
- Pay x402 → get a Cloudflare Sandbox provisioned per-Stacks-address, ticking down a sats-denominated credit bucket per second of wall-clock uptime.
- sBTC is the primary settlement token (1:1 sats, no oracle). STX/USDCx supported via a multi-source price oracle. Bucket holds one unit: sats.
- AIBTC-gated at create/extend via
aibtc-genesis-gate: caller proves control of both BTC + Stacks keys (Bitcoin signature + SIP-018), and aibtc.com confirms the pair is registered at level ≥ 2 (Genesis).
- Settlement rides
x402-sponsor-relay; receipts use @aibtc/tx-schemas PAYMENT_STATES. No inline x402 settle.
- Lifecycle:
alive → grace (60s, receipt-extending, 10min hard cap) → reaped. DO state and ledger persist across reaps; only the Cloudflare sandbox handle dies.
Why this fits in x402-api
This repo is increasingly the agent-survival service — inference, storage, hashing, stacks tools — all priced in sats, all paid from the agent's own wallet. Sandbox-on-demand closes the loop: an agent inside a sandbox can pay for its own downstream services from the same address that funded the sandbox. A single Stacks wallet bootstraps a self-sustaining agent.
Inspiration: conway.tech (pay-as-you-go compute, USD-denominated) and agentslovebitcoin.com (per-AIBTC-agent service pattern). We diverge from conway by denominating in sats, not cents.
Proposed phasing
- Phase 0 — Spike. Throwaway worker exercising
@cloudflare/sandbox@0.9.2 directly. Output: real numbers for idle/active $/min, cold start, destroy() semantics, OOM behavior, native-supervisor presence. Drives the sats_per_second rate. (1-day target.)
- Phase 1 —
SandboxDO + create / extend / status / reap. Wall-clock metering, manual tick verification, sBTC + STX payments, settlement via relay.
- Phase 2 — Proxy.
/sandbox/proxy/* forwards into the sandbox; per-call x402 from external clients.
- Phase 3 — Self-paying agent. Boot template with encrypted-wallet-on-disk + treasury caps; sample agent calls our inference endpoints from inside.
- Phase 4 — AIBTC integration. Resolve
aibtc.com agent handle → Stacks address → sandbox; one-click "wake my agent" UX.
- Phase 5 — CPU/request metering, full multi-token rate oracle, refund policy, dispute log.
Three open work streams (good first issues for collaborators)
- Stream 1 — Phase 0 spike. Throwaway worker,
@cloudflare/sandbox@0.9.2, measure real numbers. Deliverable: phase-0-findings.md. Blocks Phase 1.
- Stream 2 — Image deep-dive. Compare
aibtcdev/agent-runtime vs aibtcdev/loop-starter-kit on size, dep graph, MCP integration, wallet-pattern fit, cold-start contribution. Picks the curated default boot image. Independent of Stream 1.
- Stream 3 —
aibtc-genesis-gate org migration. Move arc0btc/aibtc-genesis-gate under aibtcdev/, set up OIDC publish workflow, cut v0.1.0 on npm. Async coordination work. Phase 1 pins to github SHA in the meantime; only the npm dep swap blocks on this.
Asks for reviewers
- Sanity-check the sats-only bucket thesis. Multi-token only at ingress; everything internal in sats. Aggressive simplification — flag if it breaks something I didn't see.
- Sanity-check the identity gating (BTC sig + SIP-018 + genesis-gate pair check at level ≥ 2). Strictly stronger than "match x402 payer to gate stxAddress" but more complex — worth it?
- Reaper grace policy (60s default, payment-receipt extension, 10min hard cap) — is the cap right? Too lenient? Too tight?
- Identity check at create/extend only (Q4c) — comfortable with progression-only assumption, or should every status check re-verify?
- MCP exposure (Q20) — happy with surfacing the broader x402-api tool suite as first-class MCP tools alongside the new sandbox ones?
Full design
All 20 open questions resolved 2026-04-29. Full doc (565 lines, schema, lifecycle, settlement, oracle, SpaceX five-step audit, etc.) lives as a gist:
https://gist.github.com/whoabuddy/183304ebeb7779e008cfab6333b45d69
(Local copy is at .planning/2026-04-28-sandbox-on-demand/DESIGN.md, which is gitignored.)
TL;DR
aibtc-genesis-gate: caller proves control of both BTC + Stacks keys (Bitcoin signature + SIP-018), and aibtc.com confirms the pair is registered at level ≥ 2 (Genesis).x402-sponsor-relay; receipts use@aibtc/tx-schemasPAYMENT_STATES. No inline x402 settle.alive → grace (60s, receipt-extending, 10min hard cap) → reaped. DO state and ledger persist across reaps; only the Cloudflare sandbox handle dies.Why this fits in
x402-apiThis repo is increasingly the agent-survival service — inference, storage, hashing, stacks tools — all priced in sats, all paid from the agent's own wallet. Sandbox-on-demand closes the loop: an agent inside a sandbox can pay for its own downstream services from the same address that funded the sandbox. A single Stacks wallet bootstraps a self-sustaining agent.
Inspiration: conway.tech (pay-as-you-go compute, USD-denominated) and agentslovebitcoin.com (per-AIBTC-agent service pattern). We diverge from conway by denominating in sats, not cents.
Proposed phasing
@cloudflare/sandbox@0.9.2directly. Output: real numbers for idle/active $/min, cold start,destroy()semantics, OOM behavior, native-supervisor presence. Drives thesats_per_secondrate. (1-day target.)SandboxDO+ create / extend / status / reap. Wall-clock metering, manual tick verification, sBTC + STX payments, settlement via relay./sandbox/proxy/*forwards into the sandbox; per-call x402 from external clients.aibtc.comagent handle → Stacks address → sandbox; one-click "wake my agent" UX.Three open work streams (good first issues for collaborators)
@cloudflare/sandbox@0.9.2, measure real numbers. Deliverable:phase-0-findings.md. Blocks Phase 1.aibtcdev/agent-runtimevsaibtcdev/loop-starter-kiton size, dep graph, MCP integration, wallet-pattern fit, cold-start contribution. Picks the curated default boot image. Independent of Stream 1.aibtc-genesis-gateorg migration. Movearc0btc/aibtc-genesis-gateunderaibtcdev/, set up OIDC publish workflow, cut v0.1.0 on npm. Async coordination work. Phase 1 pins to github SHA in the meantime; only the npm dep swap blocks on this.Asks for reviewers
Full design
All 20 open questions resolved 2026-04-29. Full doc (565 lines, schema, lifecycle, settlement, oracle, SpaceX five-step audit, etc.) lives as a gist:
https://gist.github.com/whoabuddy/183304ebeb7779e008cfab6333b45d69
(Local copy is at
.planning/2026-04-28-sandbox-on-demand/DESIGN.md, which is gitignored.)