24 Commits

Author SHA1 Message Date
c14d0ab735 feat: team roles with invitations and enforced API key scopes (G9)
Security fix plus team access. Before this change any valid API key,
including access keys the delivery system hands to BUYERS, authenticated
as the merchant on the whole management API, and GET /v1/api-keys listed
every organization's keys. Now only platform keys (issued at sign-up or
via POST /v1/api-keys/platform, marked with the platform product id) can
call the API, and each request needs its resource scope
(<resource>:read|write, write implies read; platform:admin or * for
full access), answered with 403 and details.requiredScope otherwise.
Keys cannot mint broader keys, customer keys cannot carry management
scopes, key listing is tenant-scoped and keys can be revoked by id.

Dashboard sessions get team roles (owner, admin, developer, support,
viewer) mapped to scopes. /v1/team manages members and email
invitations (packages/invitations, token hash only, 7-day expiry);
/v1/auth/invitations/accept joins the org and creates the account. The
last owner is protected and only owners grant owner. Dashboard: Team
page, invite accept page, and an API keys page that creates restricted
keys and shows the secret once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 06:09:06 +03:00
22c3208b60 feat: merchant accounting exports with Xero and QuickBooks imports (G5)
New tenant-scoped /v1/exports routes: payments, refunds, invoices and
payouts CSVs, a full USDC ledger, and bank statement files that Xero
(DD/MM/YYYY statement import) and QuickBooks Online (three-column bank
upload) import directly, with optional date ranges. packages/exports
gains a formula-injection guard (opt-in, admin unchanged) and the
accounting formatters. The dashboard Payments page links every export
through a session-authenticated download route.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 04:35:58 +03:00
e0caf4bace feat: monthly platform fee statements with plan limits after grace (G1)
SettleKit's advertised per-payment fee was never collected because buyers
pay merchants' wallets directly. When PLATFORM_BILLING_ORG_ID is set, the
API now issues each merchant a monthly statement (confirmed payments x the
fee schedule) as an invoice from SettleKit's own org, paid through the
hosted checkout on the G2 payable-invoice path. Totals below the minimum
carry forward, test accounts are skipped, runs are idempotent and happen
automatically every six hours (or via POST /v1/billing/statements/run).
A statement unpaid past due + grace restricts new products to the free
plan limit from packages/pricing (402 with the pay link). Merchants see
accrued fees, statements and a Pay button on the Balances page.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 03:50:08 +03:00
2b2c8b471d chore: merge Tameion operator into main alongside multi-chain SettleKit
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 22:43:33 +03:00
e169731b42 chore: merge feat/solana-colosseum into feat/x402-multichain
Brings in packages/routing, packages/hyperliquid (hypercore network), checkout
AnyTokenPay/HyperCorePay, Node 22 pins, tenant-ownership guards and the zcash
tag lock. Only conflict: drizzle _journal.json (kept 0010_onchain_billing and
0011_coupons_organization in order).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 20:39:32 +03:00
7ee993e478 feat(api): onchain subscription, escrow and per-network refund routes
/v1/onchain-billing: networks, subscription intents (what the buyer
signs or sends per network), grant submission with immediate first
charge and entitlement grant, cancel with revoke actions, Base escrow
authorize/capture/void/reclaim, and owner refunds recorded in
@settlekit/refunds and dispatched per network.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 20:19:15 +03:00
2b9172e384 feat(api): HyperCore verifier, Tempo requireMemo sessions and routed-fill bindings
- HYPERCORE_* config; the registry registers a hypercore SettlementVerifier
  (payee ledger via @settlekit/hyperliquid) only when enabled
- checkout sessions accept requireMemo (Tempo only); confirmations then need
  transferWithMemo(keccak256(session id))
- a route provider's stored destination fill skips only the payer and memo
  bindings; hypercore joins the observable networks
- drop the unused @settlekit/routing dependency from the API

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 18:48:20 +03:00
68a9070a75 feat(hyperliquid): HyperCore usdSend typed data, submission and ledger verification
New @settlekit/hyperliquid on @nktkas/hyperliquid (MIT): EIP-712 usdSend
typed data pinned by golden vectors against the SDK signer, submission of
buyer-signed actions, and fail-closed verification through the payee's
userNonFundingLedgerUpdates (destination == payTo, USDC >= expected, time >=
session creation, payer binding). HYPERCORE_ENABLED / NETWORK / API_URL env.
Registers the workspace packages in the lockfile (filtered install; unrelated
peer rewrites reverted).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 17:56:14 +03:00
88e842f39d chore(deps): add x402-foundation @x402/* 2.27 and mppx for agent payments
@x402/core, evm, svm, hono, fetch 2.27 (Apache-2.0) and mppx 0.11 (MIT)
for x402 v2 on every chain and MPP on Tempo. Scaffolds the
@settlekit/x402-facilitator package manifest. Lockfile peer churn in
unrelated importers (checkout, app-kit-viem) reverted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 17:55:31 +03:00
2134532ba3 fix: drop Solana from the Tameion branch while keeping fail-closed confirmation
The cherry-picked fail-closed payment fixes imported @settlekit/solana, which
does not exist on this branch, breaking tsc -b and the api/worker suites.
Solana verification, env and session references are removed; arc/base/
ethereum keep the per-network verifier registry and the worker keeps
payTo-bound verification. A solana network is now rejected as unsupported
(400 on checkout/observe, unsupported in the worker). Also adds the missing
packages/circle project reference to the api, points the api/worker test
scripts at the root vitest config, and removes the operator's
vitest.apps.config.ts workaround.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 16:55:28 +03:00
015899f2c3 feat(chains): add multi-chain registry and fail-closed EVM verifier
@settlekit/chains carries the verified EVM registry (Ethereum, Base,
Arbitrum, Robinhood Chain, HyperEVM, Tempo, Arc; mainnet + testnet), a
generic stablecoin verifier over the arc EvmRpc seam (chain-id assertion,
receipt status, token/payTo/amount, confirmations, block time vs session,
payer binding, Tempo TIP-20 memo), CAIP-2 ids, network-aware tx-hash and
payTo rules, env loaders (SETTLEKIT_CHAIN_ENV, ENABLED_EVM_CHAINS, per-chain
overrides, Zcash) and the settlement-verifier contract. Tests replay
receipts recorded from each chain's public RPC.

PaymentNetwork widens to solana|base|arc|ethereum|arbitrum|robinhood|
hyperevm|tempo|zcash and CheckoutSession gains settlementQuote,
payerAddress, acceptedNetworks and payToByNetwork. The hosted checkout
fails closed on the new networks until its wave-2 UI lands.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 15:52:34 +03:00
8c1d704a96 feat: add Claude operator agent, tools and decision service
OperatorAgent drives the Anthropic SDK tool runner (betaZodTool) over read
tools (treasury state, open bills, counterparty risk, payment history, x402
quotes) and policy-checked action tools that require rationale,
alternatives and confidence. claude-sonnet-5 handles revenue and ticks,
claude-opus-5-5 bills, refunds and disputes; at most 12 iterations, with
HeuristicOperator fallback when no key is set or the API fails.

OperatorService turns each event into one hash-chained DecisionRecord with
the tool trace, verdict, usage cost and outcome. The vault anchors a
pre-execution commitment hash of the reasoning; owner approvals, rejections
and 72h expiries are recorded as decisions too. Invoice and customer text
is passed as escaped untrusted data.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 15:41:33 +03:00
ca4567dea6 feat: add @settlekit/solana package
Solana USDC settlement mirroring @settlekit/arc's injectable RPC seam:
- clusters: mainnet/devnet USDC mints, CAIP-2 ids, public RPCs
- rpc: SolanaRpc interface + createKitSolanaRpc over @solana/kit 5.5.1
- verify: verifySplTransfer balance-delta rules (mint+owner, bigint,
  meta.err, reference in account keys, payer detection)
- pay-url: Solana Pay transfer/transaction request encode + parse
- reference / find-reference: Solana Pay reference keys and lookup
- tx-builder: unsigned v0 buyer-pays tx (idempotent ATA create,
  optional memo, TransferChecked with read-only reference)
- settlement-provider: hot-wallet SolanaSettlementProvider with
  reserve/release idempotency; settlement-core gains the "solana"
  provider name and an injected-provider config variant (no dep cycle)
- x402-verifier: PaymentVerifier adapter enforcing session references

API and worker declare the dependency (filtered lockfile update).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 06:15:50 +03:00
pextacy
71e89bdfd8 feat(lepton): attribution package (RFB 6.01) + creator-dashboard
Adds @settlekit/attribution — reuse-detection, weighted provenance lineage,
and HMAC-signed proofs-of-citation — wired live into the rsshub-citation-toll
sidecar (POST /attribution/{detect,proof,verify}) and persisted via
PgLineageStore/PgProofStore over new lepton_lineage_edges + lepton_citation_proofs
tables.

Adds apps/creator-dashboard — a Next.js earnings view in the Statement
greenbar-ledger design system, driven by real domain logic (createSource +
computeRoyaltyDistribution + detectReuse, not mocks). Statement / Sources /
Payouts / Reuse & proofs (interactive) / Wallet. next build green.

Also bundles in-progress settlement hardening: settlement-core idempotency
concurrency, api env validation, bundles + contracts/worker tweaks.

Verified: 943 vitest tests, 27 Foundry tests, next build all green.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-20 01:19:22 +03:00
pextacy
1d9c55d131 feat(oss-fund): fund maintainers your dependency tree leans on
Add @settlekit/oss-fund: read package.json / requirements.txt (+ optional
lockfile), map the (transitive) dependency graph to maintainer wallets, and
split a small monthly budget across them — settled over the existing
nanopayment spine (payee-registry, x402 Settler, RecursiveSplitDistributor).

The allocation is the core: an engine weighs four signals per package —
directness, reach (criticality), usage, and maintainer underfunding — and the
capability layer converts a proposed weighting into a conserved integer
allocation (legs sum to the budget exactly, only resolvable wallets paid,
unregistered maintainers earmarked to escrow). Two engines, mirroring the paying
agent: a deterministic heuristic (default/CI) and a Claude (claude-opus-4-8)
tool-use brain that proposes weights under the same enforced policy.

- packages/oss-fund: manifest/lockfile parsing, graph + reach, signals,
  resolver, conserved allocation, heuristic + Claude engines, settlement +
  on-chain distributor calldata, realistic seed, CLI, tests (12 passing).
- apps/api: public PUBLIC routes GET /v1/fund/demo and POST /v1/fund/plan.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-19 13:11:38 +03:00
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
3a52b61096 adas 2026-06-17 03:02:36 +03:00
3853551433 asad 2026-06-17 02:09:36 +03:00
32b89f0515 firstof 2026-06-16 02:51:34 +03:00
bd3c2a85e5 feat: full-product round 3 — commerce engines wired + worker comms
- apps/api: /v1/refunds, /v1/dunning, /v1/disputes, /v1/payouts routes + context
  services + mounts (refunds/dunning/disputes/payouts engines).
- apps/dashboard: refunds/dunning/disputes/payouts pages + nav + api client + types.
- apps/worker: 9 scheduled jobs incl. receipt, renewal-reminder, dunning, and
  access-granted email jobs via @settlekit/notifications (idempotent, injectable transport).

Full build 0 TS errors; dashboard typecheck clean; 591 tests pass.
2026-06-15 17:25:34 +03:00
5cb0f48db7 feat: full-product round 2 — auth end-to-end + commerce engines
- apps/api: public /v1/auth routes (register/login/magic-link/session/logout) via
  @settlekit/auth, AuthService in context, signed sk_session cookie; existing
  api-key guard untouched (14 api tests intact).
- apps/dashboard + apps/portal: real login/signup UIs (password + magic-link),
  httpOnly session cookie via route handlers, server session helpers, sign-out.
- packages: fleshed refunds, dunning (retry schedules), disputes (state machine),
  payouts (settlement + available-balance) into real engines with stores+services.

Verified: full build 0 TS errors; 591 tests pass; live auth flow
(register->login->session->magic-link->bad-login 401) confirmed end-to-end.
2026-06-15 17:06:29 +03:00
3220b85c57 feat: product expansion — marketing site, customer portal, coupons + invoices
- apps/web: public marketing site (Next.js) — hero/§34, what-you-can-sell grid,
  how-it-works, dev tools, marketplace teaser, /pricing (§32 tiers), /use-cases (§29).
- apps/portal: customer portal (Next.js, §31) — per-customer overview, purchases/
  receipts, license keys, api keys, github/discord access (+re-check), subscriptions,
  downloads; anchored on the universal entitlements layer.
- packages/coupons: real discount engine (percent/amount/free-trial, window, expiry,
  max + per-customer redemptions, min-subtotal, product scoping), bigint USDC math,
  CouponStore + service.
- packages/invoices: real invoicing (line items, discount, @settlekit/tax, statuses,
  HTML/text render), fixed float bug, InvoiceStore + service.
- apps/api: /v1/coupons + /v1/invoices routes wired into context + app.
- apps/dashboard: Coupons + Invoices pages + nav + client methods.

All package + backend builds 0 TS errors; web/portal/dashboard typecheck clean;
590 tests pass (two redesigned coupon/invoice tests updated to the new API).
2026-06-15 12:25:58 +03:00
286b1d4adc feat(api): Postgres persistence + real integration/secrets wiring
Persistence (selected by DATABASE_URL; in-memory fallback otherwise):
- document-projection pattern (codec): canonical entity in metadata.__doc,
  typed columns projected for querying — lossless round-trip despite schema drift.
- async EntityStore<T> (in-memory + Postgres) for products/prices/customers/
  delivery-runs/webhooks/github+discord records.
- Pg adapters for packaged stores: checkout/payment/subscription repositories,
  entitlements, license keys, api keys, saas plans, bundles, agent services.
- seedDefaults() upserts the default org+merchant to satisfy merchant_id FKs.
- context.ts selects Pg vs in-memory; routes awaited end-to-end.
- drizzle migration 0000_init.sql (48 tables) + db:generate/migrate scripts.

Integrations (config/env.ts + config/integrations.ts + wiring/delivery-clients.ts):
- env-driven secrets for Arc/Circle/GitHub/Discord/Resend/S3, partial-group
  validation via ConfigError.
- real delivery clients + Arc x402 verifier when configured; in-memory fallback.

Verified: full purchase->entitlement flow run against a live Postgres 16
(rows persisted + documents round-trip); 590 in-memory tests still pass; 0 TS errors.

x402: pinned-nonce support already added earlier enables stateless verify.
2026-06-15 11:50:50 +03:00
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