Events: AI use in tokens, not rand (for 2.3.0); contracts: token fields on the AI status

Site settings → AI, the usage tables and the 80% email show input/output
tokens and the percentage; the rand amounts from the Hub are dropped on
arrival. AiCall stores each call's tokens (migration ai_tokens). v2
/ai/status and /ai/usage carry tokens instead of cents. Needs Hub 2.0.1
for the token figures; older Hubs show the percentage only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-17 10:59:36 +02:00
co-authored by Claude Opus 5.5
parent e8853cf0c8
commit 38ebce24ab
17 changed files with 725 additions and 169 deletions
@@ -0,0 +1,3 @@
-- 2.3.0: tokens per AI call, which is what the site shows (the rand amount is the Hub's business).
ALTER TABLE "AiCall" ADD COLUMN "inputTokens" INTEGER NOT NULL DEFAULT 0;
ALTER TABLE "AiCall" ADD COLUMN "outputTokens" INTEGER NOT NULL DEFAULT 0;
+5 -1
View File
@@ -2341,8 +2341,12 @@ model AiCall {
helper String
// ok, refused, incomplete, failed, cap_reached, unavailable
outcome String
// What the church was charged, in cents (fractions of a cent).
// What the church was charged, in cents (fractions of a cent). Kept for the record; the site
// shows tokens (2.3.0), and only the Hub shows rand.
chargedCents Float @default(0)
// Tokens the call used (2.3.0): input counts cached prompt tokens. 0 when the call failed.
inputTokens Int @default(0)
outputTokens Int @default(0)
createdAt DateTime @default(now())
user User? @relation(fields: [userId], references: [id], onDelete: SetNull)