caelum0x ff11f7754e feat(lepton): nanopayment modules + production settlement spine
Lepton Agents Hackathon (Canteen × Circle × Arc): agent-native nanopayments
on Arc, built on the existing SettleKit platform.

Hackathon modules (demo-ready, RFB-aligned):
- @settlekit/agent: autonomous paying agent (Claude tool-use loop) — RFB 1/3
- @settlekit/citation-toll: per-access content + recursive royalty splits — RFB 6
- @settlekit/streaming: per-second continuous-authorization settlement — RFB 4
- @settlekit/x402-client: x402 pay-and-retry + pluggable settler (local/Circle)
- @settlekit/agent-economy: closed-loop traction harness + CLI
- apps/api /v1/lepton: public live demo surface

Production settlement spine (Phase 1):
- @settlekit/settlement-core: configurable Gateway/Circle/local providers,
  idempotency, batch accumulator, on-chain reconciliation, nonce + receipt stores
- @settlekit/wallet-fleet: registry, spending caps + kill-switch, balances,
  Circle provisioning
- x402-client: provider-settler adapter + Arc-indexer on-chain verifier
- lepton DB schema (12 tables) + persistence Pg stores (settlements, nonces,
  sources, royalty legs, wallets, streams, payees)
- apps/worker jobs: lepton-settlement-reconcile, lepton-payout-sweep,
  lepton-stream-refund (no-op until the settlement spine is wired)

First real-world traction sidecar (Phase 2):
- @settlekit/payee-registry: identity→wallet payout rule (in-memory + Pg)
- services/sidecars/rsshub-citation-toll: ingest RSS items as priced citeable
  sources, x402-gated, settle per-citation royalties via settlement-core
- shared sweepPendingRoyalties used by the worker job and the sidecar
- services/sidecars/* wired as a TS workspace area (pnpm + vitest)

Docs: LEPTON.md, LEPTON_PRODUCTION_PLAN.md. All green: full typecheck + 870 tests.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-18 14:37:38 +03:00
..

@settlekit/agent

An autonomous paying agent for nanopayment marketplaces (Lepton RFB 1 & 3).

It discovers x402-priced services, decides which are worth paying for under a hard spend policy, settles the toll via @settlekit/x402-client, consumes the result, and rates the service. The decision engine is pluggable:

  • ClaudeDecisionEngine — the real brain. Exposes the capability surface as tools to Claude (claude-opus-4-8) through the official Anthropic SDK tool runner; the model drives the trajectory. Requires ANTHROPIC_API_KEY.
  • HeuristicDecisionEngine — deterministic fallback for offline runs, CI, and the closed-loop harness.

Every spend guardrail (total budget, per-call cap, reputation floor, purchase limit) is enforced inside the capability layer, so no engine can exceed the policy regardless of what it decides.

import { PayingAgent, ClaudeDecisionEngine } from "@settlekit/agent";

const agent = new PayingAgent({
  services, reputation, fetcher, settler, from: "0xagent",
  policy: { totalBudgetUsdc: "0.01", maxPriceUsdc: "0.002", maxPurchases: 5, minReputation: 3 },
});

const result = await agent.run(
  { objective: "Gather grounded sources on Arc settlement within budget." },
  new ClaudeDecisionEngine(), // or omit to auto-pick by ANTHROPIC_API_KEY
);
// result.purchases, result.totalSpent, result.remaining, result.log