caelum0x 598cd03f05 feat: implement all 8 SettleKit apps + fix x402 nonce round-trip
apps:
- api: Hono REST server, all §26 endpoints, 14 tests
- worker: delivery runner + payment-confirm + access-sync + renewal + webhook-retry jobs wired to real package clients
- dashboard: Next.js merchant dashboard, full §16/§27 sections + §28 product builder
- checkout: Next.js hosted USDC checkout with real delivery materialization
- marketplace: Next.js public marketplace + agent metadata.json route
- admin: Next.js risk/ops console wired to @settlekit/risk + database
- docs: Next.js docs site (9 static routes)
- examples: 5 runnable end-to-end examples

fix(x402): support pinned config.nonce so a stateless verifier can confirm
the challenge nonce round-trips (default stays random; package tests intact).

Full workspace: 590 tests passing (122 files), tsc green for all packages +
api/worker/examples, all 5 Next apps typecheck clean, docs next build green.
2026-06-15 10:49:14 +03:00

2.3 KiB

SettleKit Worker

Background worker for delivery execution, payment confirmation, access sync, renewals, and webhook retries (plan §17). A real Node ESM service that drives the @settlekit/* domain packages on interval-based schedules with graceful shutdown.

Jobs

Job Cadence env What it does
delivery-runner WORKER_DELIVERY_INTERVAL_MS Executes pending delivery runs through @settlekit/delivery DeliveryRunner with the concrete wired clients; retries failed runs.
payment-confirm WORKER_PAYMENT_INTERVAL_MS Polls @settlekit/arc verifyUsdcTransfer / getConfirmations, confirms payments via @settlekit/payments, and enqueues delivery.
access-sync WORKER_ACCESS_SYNC_INTERVAL_MS Reconciles GitHub (syncAccess) + Discord (syncDiscordAccess) grants; expires due entitlements (@settlekit/entitlements expireDue).
renewal-sweep WORKER_RENEWAL_INTERVAL_MS Advances subscriptions, enters grace, and expires via @settlekit/payments.
webhook-retry WORKER_WEBHOOK_RETRY_INTERVAL_MS Redelivers failed webhooks via @settlekit/webhooks deliverWithRetry.

Wiring

src/wiring/delivery-clients.ts builds the concrete adapters that implement the delivery package's client interfaces, each backed by a REAL package call:

  • GithubAccessClient → @settlekit/github
  • DiscordRoleClient → @settlekit/discord
  • LicenseIssuer → @settlekit/license-keys
  • ApiKeyIssuer → @settlekit/api-keys
  • FileGrantor → @settlekit/file-delivery
  • SaasEntitler → @settlekit/saas
  • WebhookSender → @settlekit/webhooks
  • EmailSender → @settlekit/notifications

The GitHub/Discord transports, Arc RPC, email transport, and webhook HTTP sender are injectable, so the wiring test exercises the exact production assembly path against in-memory doubles.

Run

pnpm --filter @settlekit/worker build
pnpm --filter @settlekit/worker start

Required env vars are validated at boot (src/config.ts); missing secrets fail fast.