WIP Hub 1.6.0: AI proxy for Cross Events 2.0

Signed /installs/ai/status and /installs/ai/complete (protocol 3b):
the Hub holds the Claude key, holds each call's worst case against the
licence's monthly cap in a locked transaction, calls Claude Haiku 5.5
and meters real cost and charged amount (markup) in rand. Settings ->
AI, licence markup override, AI use on the install page.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-30 09:16:04 +02:00
co-authored by Claude Opus 5.5
parent 0f4d1c360a
commit 49f62aeb75
20 changed files with 1041 additions and 27 deletions
+3
View File
@@ -23,3 +23,6 @@ export function bytes(n: number | null | undefined) {
}
export const rand = (cents: number) => `R${(cents / 100).toFixed(2)}`;
/** AI amounts are fractions of a cent per call: show R0.0042 rather than R0.00. */
export const randFine = (cents: number) => (cents !== 0 && Math.abs(cents) < 100 ? `R${(cents / 100).toFixed(4)}` : rand(cents));
+8 -1
View File
@@ -23,6 +23,7 @@ export type Licence = {
expiresAt: string | null;
graceDays: number;
aiMonthlyCapCents: number;
aiMarkupPercent: number | null;
notes: string | null;
createdAt: string;
install?: { id: string; name: string; url: string; lastHeartbeatAt: string | null } | null;
@@ -65,7 +66,13 @@ export type Stats = {
export type InstallEvent = { id: string; type: string; level: Problem["level"]; message: string; createdAt: string; resolvedAt: string | null; install?: { id: string; name: string; url: string } };
export type Release = { id: string; version: string; notes: string; urgent: boolean; releasedAt: string; installs: number };
// AI (Cross Events 2.0). Amounts are in cents (rand), with fractions.
export type AiStatus = { enabled: boolean; capReached: boolean; capCents: number; usedCents: number; usedPercent: number; renewsOn: string };
export type AiMonth = { month: string; calls: number; inputTokens: number; outputTokens: number; realCents: number; chargedCents: number; profitCents: number };
export type AiHelperUse = { helper: string; calls: number; chargedCents: number };
export type AiInstallUse = { installId: string; name: string; url: string; capCents: number; calls: number; realCents: number; chargedCents: number; profitCents: number };
export type Release ={ id: string; version: string; notes: string; urgent: boolean; releasedAt: string; installs: number };
export type NoticeLevel = "info" | "maintenance" | "warning";
export type Notice = {