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:
@@ -0,0 +1,35 @@
|
||||
-- CreateEnum
|
||||
CREATE TYPE "AiUsageStatus" AS ENUM ('reserved', 'done', 'failed');
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "Licence" ADD COLUMN "aiMarkupPercent" INTEGER;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "AiUsage" (
|
||||
"id" TEXT NOT NULL,
|
||||
"installId" TEXT NOT NULL,
|
||||
"helper" TEXT NOT NULL,
|
||||
"model" TEXT NOT NULL,
|
||||
"month" TEXT NOT NULL,
|
||||
"status" "AiUsageStatus" NOT NULL DEFAULT 'reserved',
|
||||
"inputTokens" INTEGER NOT NULL DEFAULT 0,
|
||||
"outputTokens" INTEGER NOT NULL DEFAULT 0,
|
||||
"cacheReadTokens" INTEGER NOT NULL DEFAULT 0,
|
||||
"cacheWriteTokens" INTEGER NOT NULL DEFAULT 0,
|
||||
"realMillicents" INTEGER NOT NULL DEFAULT 0,
|
||||
"chargedMillicents" INTEGER NOT NULL DEFAULT 0,
|
||||
"markupPercent" INTEGER NOT NULL,
|
||||
"usdZar" DOUBLE PRECISION NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
|
||||
CONSTRAINT "AiUsage_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "AiUsage_installId_month_idx" ON "AiUsage"("installId", "month");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "AiUsage_month_idx" ON "AiUsage"("month");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "AiUsage" ADD CONSTRAINT "AiUsage_installId_fkey" FOREIGN KEY ("installId") REFERENCES "Install"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
Reference in New Issue
Block a user