You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(worker): premium webhook watches (price + status, signed POST delivery)
Agents can now register watches that fire HMAC-signed webhooks when a
model price crosses a threshold or a provider's status changes. Phase 1
of the recurring/event-driven billing path.
Endpoints (under /api/premium/watches):
POST register a watch (1 credit). Body: { spec, callback_url, secret?, fire_cap? }
GET list watches owned by the bearer token (free)
GET /{id} read one watch + fire metadata (free, owner-only)
DELETE /{id} remove a watch (free, owner-only)
Watch types in v1:
price { model, field: inputPrice|outputPrice|blended, op: lt|gt|changes, threshold? }
status { provider, op: becomes|changes, value? }
Predicates fire only on edge transitions (debounced) so a watch on
"Opus 4.7 inputPrice < $10" fires once when the price crosses, not on
every poll while the price stays below. Watches live 90 days, fire up
to fire_cap times (default 100), capped at 25 active watches per token.
Delivery: signed POST to callback_url with X-TensorFeed-Signature
(HMAC-SHA256 over the body using the watch's secret) and
X-TensorFeed-Watch-Id headers. Fire-and-forget with 8-second timeout.
Basic SSRF guard rejects http://, localhost, RFC1918, link-local, and
loopback addresses.
Cron integration:
- Status dispatch hooks into pollStatusPages (every 5 min) using the
same transition detection the incident detector already runs on.
- Price dispatch runs daily after updateCatalog via runPriceWatchCycle,
diffing the freshly-merged pricing payload against a watch-owned
previous snapshot at watch:prev:pricing.
Storage layout (TENSORFEED_CACHE):
watch:{id} full Watch record (90-day TTL)
watch:index:price string[] of watch IDs (single-key lookup per cron)
watch:index:status string[]
watch:byToken:{token} string[] for owner listing
watch:prev:pricing last seen pricing payload for diff baseline
Tests: 30 new vitest cases covering URL validation (SSRF), spec
validation, predicate edge transitions, transition computation,
HMAC determinism, CRUD lifecycle, ownership enforcement, and
end-to-end dispatch with stubbed fetch. Total worker tests: 63.
Updated /api/meta, public/llms.txt, /developers/agent-payments,
and CLAUDE.md to advertise the new endpoints.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@@ -195,6 +198,9 @@ All mounted under `https://tensorfeed.ai/api/*` via the Worker.
195
198
-`/api/premium/history/benchmarks/series?model=&benchmark=&from=&to=`: Tier 1, 1 credit. Score evolution for a single benchmark on one model. Returns delta in percentage points.
196
199
-`/api/premium/history/status/uptime?provider=&from=&to=`: Tier 1, 1 credit. Daily uptime % for one provider (degraded counts as half) with incident-day list. Missing-data days excluded from denominator.
197
200
-`/api/premium/history/compare?from=&to=&type=pricing|benchmarks`: Tier 1, 1 credit. Diff two daily snapshots: added, removed, changed entries with deltas.
201
+
-`/api/premium/watches` (POST): Tier 1, 1 credit per registration. Body `{ spec, callback_url, secret?, fire_cap? }`. Spec is `{ type: "price"|"status", ... }`. Watch lives 90 days, default fire cap 100. Fires deliver HMAC-signed POST to callback URL.
202
+
-`/api/premium/watches` (GET): List watches owned by the bearer token. Free.
203
+
-`/api/premium/watches/{id}` (GET|DELETE): Read or remove an owned watch. Free.
-`worker/src/history.ts`: daily snapshot capture (the data moat)
317
+
-`worker/src/history-series.ts`: premium aggregated views (series, uptime, compare) over the daily snapshots
318
+
-`worker/src/watches.ts`: premium webhook watches; status dispatch hooks into `pollStatusPages` (every 5 min), price dispatch runs daily after `updateCatalog`
311
319
312
320
SDKs:
313
321
- Python: `sdk/python/` (1.2.0). `pip install tensorfeed[web3]` enables `tf.purchase_credits()` for one-call sign-and-send. See `sdk/python/PUBLISHING.md` for the PyPI release flow.
Copy file name to clipboardExpand all lines: public/llms.txt
+1Lines changed: 1 addition & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -53,6 +53,7 @@ TensorFeed accepts USDC on Base as the sole payment method for premium endpoints
53
53
- [Premium Benchmark Series](https://tensorfeed.ai/api/premium/history/benchmarks/series): Tier 1, 1 credit per call. Score evolution for a single benchmark (e.g. swe_bench, mmlu_pro, gpqa_diamond, math, human_eval) on one model. Params: `?model=&benchmark=&from=&to=`. Range capped at 90 days.
54
54
- [Premium Status Uptime](https://tensorfeed.ai/api/premium/history/status/uptime): Tier 1, 1 credit per call. Daily status rollup for one provider with operational/degraded/down day counts, uptime % (degraded counts as half), and incident-day list. Params: `?provider=&from=&to=`.
55
55
- [Premium History Compare](https://tensorfeed.ai/api/premium/history/compare): Tier 1, 1 credit per call. Diff between two daily snapshots: added, removed, and changed entries with deltas. Params: `?from=YYYY-MM-DD&to=YYYY-MM-DD&type=pricing|benchmarks`.
56
+
- [Premium Watches](https://tensorfeed.ai/api/premium/watches): Tier 1, 1 credit per registration. Webhook alerts for price changes (`{ type: "price", model, field: "inputPrice"|"outputPrice"|"blended", op: "lt"|"gt"|"changes", threshold? }`) or service status transitions (`{ type: "status", provider, op: "becomes"|"changes", value? }`). POST `{ spec, callback_url, secret? }` to register, GET to list, GET/DELETE on `/api/premium/watches/{id}` for individual control. Each watch lives 90 days, fires up to 100 times by default, delivers a signed POST to the callback URL with `X-TensorFeed-Signature: sha256=<hex>` and an `X-TensorFeed-Watch-Id` header. Listing and per-watch read/delete require the bearer token but cost no credits.
56
57
57
58
**Recommended flow:** POST `/api/payment/buy-credits`, send USDC, POST `/api/payment/confirm`, then use the returned token for all premium calls. **Fallback (x402):** call any `/api/premium/*` endpoint without auth to receive a 402 response with payment instructions; send USDC and retry with `X-Payment-Tx: <txHash>` header.
'Register a webhook watch on a price change or service status transition. Each watch lives 90 days and fires up to 100 times by default. Deliveries POST to your callback URL with an HMAC-SHA256 signature header (X-TensorFeed-Signature: sha256=...). Per-token cap of 25 active watches. Listing and per-watch read/delete are free for the owning bearer token.',
0 commit comments