Follow-up split from #32 (PR #43). The platform-paid env.AI calls are not written to ai_usage, so platform spend is invisible in-app.
Instrument the platform call sites to ledger with provider="platform" + a CF Workers-AI neuron cost estimate (label it an estimate):
agent-storage.ts embeddings (@cf/baai/bge-base-en-v1.5, ~line 345) and conversation summary (~line 988) — needs the acting/owner userId threaded into the DO storage engine (getStorageEngine).
routes/instances-translation.ts platform path (has session.uid; the CF .run returns no token usage → estimate tokens from text length).
- Add a CF-neuron estimator to
lib/ai-pricing.ts so platform CF rows carry non-zero cost (BYOK-CF stays estimate-free — user pays CF directly).
Once done, /v1/admin/spending platformPaid.metered flips true and the split in aggregateAdminUsage (already provider-aware, PLATFORM_PROVIDER) populates automatically.
Part of the PAGS Admin Portal epic (#27). Depends on #28.
Follow-up split from #32 (PR #43). The platform-paid
env.AIcalls are not written toai_usage, so platform spend is invisible in-app.Instrument the platform call sites to ledger with
provider="platform"+ a CF Workers-AI neuron cost estimate (label it an estimate):agent-storage.tsembeddings (@cf/baai/bge-base-en-v1.5, ~line 345) and conversation summary (~line 988) — needs the acting/owneruserIdthreaded into the DO storage engine (getStorageEngine).routes/instances-translation.tsplatform path (hassession.uid; the CF.runreturns no token usage → estimate tokens from text length).lib/ai-pricing.tsso platform CF rows carry non-zero cost (BYOK-CF stays estimate-free — user pays CF directly).Once done,
/v1/admin/spendingplatformPaid.meteredflips true and the split inaggregateAdminUsage(already provider-aware,PLATFORM_PROVIDER) populates automatically.Part of the PAGS Admin Portal epic (#27). Depends on #28.