Files
orangecat/docs/api
c50840a34a feat: Cat spend caps + machine-payable v1 payments (agent buy loop) (#512)
* feat(cat): enforce BTC spend caps — per-action cap + daily budget

max_btc_per_action existed since baseline but was never read; every Cat
payment ignored it. Now enforced in CatPermissionService.checkSpendCaps
(stricter of specific-action and category caps wins), checked early in
executeAction and re-checked as a backstop in performAction so the
confirm-later path can't bypass a cap that changed after proposal.

- New max_btc_per_day column: daily BTC budget derived from
  cat_action_log.amount_btc (executing+completed rows; no new state)
- API: maxSatsPerAction renamed maxBtcPerAction — old name validated
  .int() but stored raw into the BTC column (a '100 sats' cap would have
  stored 100 BTC); caps now omitted=keep, null=clear so grant toggles
  no longer wipe limits
- Spending caps editor on the payments category row (semantic tokens,
  fiat equivalent via useDisplayCurrency)
- 12 new tests: pure cap-combination, service checks, executor wiring

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* feat(api): machine-payable v1 payments — the agent buy loop

Closes the discover → quote → pay → verify loop under the /api/v1
contract. Discovery (entity list/get, /v1/search) already accepted
integration keys; payment creation and settlement polling did not.

- POST /api/v1/payments: dual-auth (ock_ keys with payments.write scope,
  or session), per-key rate bucket, wraps initiatePayment. Key callers
  are gated on the entity being anonymously visible so service-role
  writes can't reach non-public listings
- GET /api/v1/payments/{id}: settlement status (payments.read) —
  'paid' is verified against the receiving wallet, not claimed
- OpenAPI: payments paths registered, including the previously
  unregistered anonymous /payments/public flow; scopes + endpoints
  added to the public-api SSOT (discovery + key-minting UI pick them up)
- docs/api/AGENTS.md: the whole loop with curl examples; v1 README table
- knownPaymentErrors extracted (shared by internal + v1 routes)
- 8 tests: auth/scope/visibility gates + spec-generation pin

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: Georgy Butaev <41178744+g-but@users.noreply.github.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-07-31 10:36:32 +02:00
..