The open source coding agent.
TypeScript
wip: black
Frank23fc675ad513
diff --git a/infra/console.ts b/infra/console.tsindex 578546fc6b0..2ad577fc691 100644--- a/infra/console.ts+++ b/infra/console.ts@@ -119,6 +119,7 @@ const ZEN_MODELS = [new sst.Secret("ZEN_MODELS6"),new sst.Secret("ZEN_MODELS7"),]+const ZEN_BLACK = new sst.Secret("ZEN_BLACK")const STRIPE_SECRET_KEY = new sst.Secret("STRIPE_SECRET_KEY")const AUTH_API_URL = new sst.Linkable("AUTH_API_URL", {properties: { value: auth.url.apply((url) => url!) },@@ -160,6 +161,7 @@ new sst.cloudflare.x.SolidStart("Console", {EMAILOCTOPUS_API_KEY,AWS_SES_ACCESS_KEY_ID,AWS_SES_SECRET_ACCESS_KEY,+ ZEN_BLACK,...ZEN_MODELS,...($dev? [diff --git a/packages/console/app/src/routes/workspace/[id]/billing/black-section.module.css b/packages/console/app/src/routes/workspace/[id]/billing/black-section.module.cssnew file mode 100644index 00000000000..c3a2af6391c--- /dev/null+++ b/packages/console/app/src/routes/workspace/[id]/billing/black-section.module.css@@ -0,0 +1,2 @@+.root {+}diff --git a/packages/console/app/src/routes/workspace/[id]/billing/black-section.tsx b/packages/console/app/src/routes/workspace/[id]/billing/black-section.tsxnew file mode 100644index 00000000000..d4876b242ec--- /dev/null+++ b/packages/console/app/src/routes/workspace/[id]/billing/black-section.tsx@@ -0,0 +1,12 @@+import styles from "./black-section.module.css"++export function BlackSection() {+ return (+ <section class={styles.root}>+ <div data-slot="section-title">+ <h2>Black</h2>+ <p>You are subscribed to Black.</p>+ </div>+ </section>+ )+}diff --git a/packages/console/app/src/routes/workspace/[id]/billing/index.tsx b/packages/console/app/src/routes/workspace/[id]/billing/index.tsxindex feb646514de..16e16df7ae6 100644--- a/packages/console/app/src/routes/workspace/[id]/billing/index.tsx+++ b/packages/console/app/src/routes/workspace/[id]/billing/index.tsx@@ -2,19 +2,23 @@ import { MonthlyLimitSection } from "./monthly-limit-section"import { BillingSection } from "./billing-section"import { ReloadSection } from "./reload-section"import { PaymentSection } from "./payment-section"+import { BlackSection } from "./black-section"import { Show } from "solid-js"import { createAsync, useParams } from "@solidjs/router"import { queryBillingInfo, querySessionInfo } from "../../common"export default function () {const params = useParams()- const userInfo = createAsync(() => querySessionInfo(params.id!))+ const sessionInfo = createAsync(() => querySessionInfo(params.id!))const billingInfo = createAsync(() => queryBillingInfo(params.id!))return (<div data-page="workspace-[id]"><div data-slot="sections">- <Show when={userInfo()?.isAdmin}>+ <Show when={sessionInfo()?.isAdmin}>+ <Show when={sessionInfo()?.isBeta && billingInfo()?.subscriptionID}>+ <BlackSection />+ </Show><BillingSection /><Show when={billingInfo()?.customerID}><ReloadSection />diff --git a/packages/console/app/src/routes/workspace/[id]/usage-section.tsx b/packages/console/app/src/routes/workspace/[id]/usage-section.tsxindex 8ba5dfdbd16..662b2227b43 100644--- a/packages/console/app/src/routes/workspace/[id]/usage-section.tsx+++ b/packages/console/app/src/routes/workspace/[id]/usage-section.tsx@@ -169,7 +169,9 @@ export function UsageSection() {</Show></div></td>- <td data-slot="usage-cost">${((usage.cost ?? 0) / 100000000).toFixed(4)}</td>+ <td data-slot="usage-cost">+ ${usage.enrichment?.plan === "sub" ? "0.0000" : ((usage.cost ?? 0) / 100000000).toFixed(4)}+ </td></tr>)}}diff --git a/packages/console/app/src/routes/zen/util/error.ts b/packages/console/app/src/routes/zen/util/error.tsindex f1e1314683c..b97b7343074 100644--- a/packages/console/app/src/routes/zen/util/error.ts+++ b/packages/console/app/src/routes/zen/util/error.ts@@ -1,6 +1,13 @@export class AuthError extends Error {}export class CreditsError extends Error {}export class MonthlyLimitError extends Error {}+export class SubscriptionError extends Error {+ retryAfter?: number+ constructor(message: string, retryAfter?: number) {+ super(message)+ this.retryAfter = retryAfter+ }+}export class UserLimitError extends Error {}export class ModelError extends Error {}export class RateLimitError extends Error {}diff --git a/packages/console/app/src/routes/zen/util/handler.ts b/packages/console/app/src/routes/zen/util/handler.tsindex 8981ecac25e..60e9ad468f8 100644--- a/packages/console/app/src/routes/zen/util/handler.ts+++ b/packages/console/app/src/routes/zen/util/handler.ts@@ -8,11 +8,20 @@ import { Billing } from "@opencode-ai/console-core/billing.js"import { Actor } from "@opencode-ai/console-core/actor.js"import { WorkspaceTable } from "@opencode-ai/console-core/schema/workspace.sql.js"import { ZenData } from "@opencode-ai/console-core/model.js"+import { BlackData } from "@opencode-ai/console-core/black.js"import { UserTable } from "@opencode-ai/console-core/schema/user.sql.js"import { ModelTable } from "@opencode-ai/console-core/schema/model.sql.js"import { ProviderTable } from "@opencode-ai/console-core/schema/provider.sql.js"import { logger } from "./logger"-import { AuthError, CreditsError, MonthlyLimitError, UserLimitError, ModelError, RateLimitError } from "./error"+import {+ AuthError,+ CreditsError,+ MonthlyLimitError,+ SubscriptionError,+ UserLimitError,+ ModelError,+ RateLimitError,+} from "./error"import { createBodyConverter, createStreamPartConverter, createResponseConverter, UsageInfo } from "./provider/provider"import { anthropicHelper } from "./provider/anthropic"import { googleHelper } from "./provider/google"@@ -73,9 +82,9 @@ export async function handler(await rateLimiter?.check()const stickyTracker = createStickyTracker(modelInfo.stickyProvider ?? false, sessionId)const stickyProvider = await stickyTracker?.get()+ const authInfo = await authenticate(modelInfo)const retriableRequest = async (retry: RetryOptions = { excludeProviders: [], retryCount: 0 }) => {- const authInfo = await authenticate(modelInfo)const providerInfo = selectProvider(zenData,authInfo,@@ -135,10 +144,10 @@ export async function handler(})}- return { providerInfo, authInfo, reqBody, res, startTimestamp }+ return { providerInfo, reqBody, res, startTimestamp }}- const { providerInfo, authInfo, reqBody, res, startTimestamp } = await retriableRequest()+ const { providerInfo, reqBody, res, startTimestamp } = await retriableRequest()// Store model requestdataDumper?.provideModel(providerInfo.storeModel)@@ -279,14 +288,19 @@ export async function handler({ status: 401 },)- if (error instanceof RateLimitError)+ if (error instanceof RateLimitError || error instanceof SubscriptionError) {+ const headers = new Headers()+ if (error instanceof SubscriptionError && error.retryAfter) {+ headers.set("retry-after", String(error.retryAfter))+ }return new Response(JSON.stringify({type: "error",error: { type: error.constructor.name, message: error.message },}),- { status: 429 },+ { status: 429, headers },)+ }return new Response(JSON.stringify({@@ -400,6 +414,13 @@ export async function handler(monthlyUsage: UserTable.monthlyUsage,timeMonthlyUsageUpdated: UserTable.timeMonthlyUsageUpdated,},+ subscription: {+ timeSubscribed: UserTable.timeSubscribed,+ subIntervalUsage: UserTable.subIntervalUsage,+ subMonthlyUsage: UserTable.subMonthlyUsage,+ timeSubIntervalUsageUpdated: UserTable.timeSubIntervalUsageUpdated,+ timeSubMonthlyUsageUpdated: UserTable.timeSubMonthlyUsageUpdated,+ },provider: {credentials: ProviderTable.credentials,},@@ -427,6 +448,7 @@ export async function handler(logger.metric({api_key: data.apiKey,workspace: data.workspaceID,+ isSubscription: data.subscription.timeSubscribed ? true : false,})return {@@ -434,6 +456,7 @@ export async function handler(workspaceID: data.workspaceID,billing: data.billing,user: data.user,+ subscription: data.subscription.timeSubscribed ? data.subscription : undefined,provider: data.provider,isFree: FREE_WORKSPACES.includes(data.workspaceID),isDisabled: !!data.timeDisabled,@@ -446,6 +469,45 @@ export async function handler(if (authInfo.isFree) returnif (modelInfo.allowAnonymous) return+ // Validate subscription billing+ if (authInfo.subscription) {+ const black = BlackData.get()+ const sub = authInfo.subscription+ const now = new Date()++ // Check monthly limit+ if (+ sub.subMonthlyUsage &&+ sub.timeSubMonthlyUsageUpdated &&+ sub.subMonthlyUsage >= centsToMicroCents(black.monthlyLimit * 100) &&+ now.getUTCFullYear() === sub.timeSubMonthlyUsageUpdated.getUTCFullYear() &&+ now.getUTCMonth() === sub.timeSubMonthlyUsageUpdated.getUTCMonth()+ ) {+ const nextMonth = new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth() + 1, 1))+ throw new SubscriptionError(+ `Rate limit exceeded. Please try again later.`,+ Math.ceil((nextMonth.getTime() - now.getTime()) / 1000),+ )+ }++ // Check interval limit+ const intervalMs = black.intervalLength * 86400 * 1000+ if (sub.subIntervalUsage && sub.timeSubIntervalUsageUpdated) {+ const currentInterval = Math.floor(now.getTime() / intervalMs)+ const usageInterval = Math.floor(sub.timeSubIntervalUsageUpdated.getTime() / intervalMs)+ if (currentInterval === usageInterval && sub.subIntervalUsage >= centsToMicroCents(black.intervalLimit * 100)) {+ const nextInterval = (currentInterval + 1) * intervalMs+ throw new SubscriptionError(+ `Rate limit exceeded. Please try again later.`,+ Math.ceil((nextInterval - now.getTime()) / 1000),+ )+ }+ }++ return+ }++ // Validate pay as you go billingconst billing = authInfo.billingif (!billing.paymentMethodID)throw new CreditsError(@@ -463,29 +525,25 @@ export async function handler(billing.monthlyLimit &&billing.monthlyUsage &&billing.timeMonthlyUsageUpdated &&- billing.monthlyUsage >= centsToMicroCents(billing.monthlyLimit * 100)- ) {- const dateYear = billing.timeMonthlyUsageUpdated.getUTCFullYear()- const dateMonth = billing.timeMonthlyUsageUpdated.getUTCMonth()- if (currentYear === dateYear && currentMonth === dateMonth)- throw new MonthlyLimitError(- `Your workspace has reached its monthly spending limit of $${billing.monthlyLimit}. Manage your limits here: https://opencode.ai/workspace/${authInfo.workspaceID}/billing`,- )- }+ billing.monthlyUsage >= centsToMicroCents(billing.monthlyLimit * 100) &&+ currentYear === billing.timeMonthlyUsageUpdated.getUTCFullYear() &&+ currentMonth === billing.timeMonthlyUsageUpdated.getUTCMonth()+ )+ throw new MonthlyLimitError(+ `Your workspace has reached its monthly spending limit of $${billing.monthlyLimit}. Manage your limits here: https://opencode.ai/workspace/${authInfo.workspaceID}/billing`,+ )if (authInfo.user.monthlyLimit &&authInfo.user.monthlyUsage &&authInfo.user.timeMonthlyUsageUpdated &&- authInfo.user.monthlyUsage >= centsToMicroCents(authInfo.user.monthlyLimit * 100)- ) {- const dateYear = authInfo.user.timeMonthlyUsageUpdated.getUTCFullYear()- const dateMonth = authInfo.user.timeMonthlyUsageUpdated.getUTCMonth()- if (currentYear === dateYear && currentMonth === dateMonth)- throw new UserLimitError(- `You have reached your monthly spending limit of $${authInfo.user.monthlyLimit}. Manage your limits here: https://opencode.ai/workspace/${authInfo.workspaceID}/members`,- )- }+ authInfo.user.monthlyUsage >= centsToMicroCents(authInfo.user.monthlyLimit * 100) &&+ currentYear === authInfo.user.timeMonthlyUsageUpdated.getUTCFullYear() &&+ currentMonth === authInfo.user.timeMonthlyUsageUpdated.getUTCMonth()+ )+ throw new UserLimitError(+ `You have reached your monthly spending limit of $${authInfo.user.monthlyLimit}. Manage your limits here: https://opencode.ai/workspace/${authInfo.workspaceID}/members`,+ )}function validateModelSettings(authInfo: AuthInfo) {@@ -560,7 +618,7 @@ export async function handler(if (!authInfo) return- const cost = authInfo.isFree || authInfo.provider?.credentials ? 0 : centsToMicroCents(totalCostInCent)+ const cost = authInfo.provider?.credentials ? 0 : centsToMicroCents(totalCostInCent)await Database.use((db) =>Promise.all([db.insert(UsageTable).values({@@ -576,36 +634,63 @@ export async function handler(cacheWrite1hTokens,cost,keyID: authInfo.apiKeyId,+ enrichment: authInfo.subscription ? { plan: "sub" } : undefined,}),db- .update(BillingTable)- .set({- balance: sql`${BillingTable.balance} - ${cost}`,- monthlyUsage: sql`+ .update(KeyTable)+ .set({ timeUsed: sql`now()` })+ .where(and(eq(KeyTable.workspaceID, authInfo.workspaceID), eq(KeyTable.id, authInfo.apiKeyId))),+ ...(authInfo.subscription+ ? [+ db+ .update(UserTable)+ .set({+ subMonthlyUsage: sql`+ CASE+ WHEN MONTH(${UserTable.timeSubMonthlyUsageUpdated}) = MONTH(now()) AND YEAR(${UserTable.timeSubMonthlyUsageUpdated}) = YEAR(now()) THEN ${UserTable.subMonthlyUsage} + ${cost}+ ELSE ${cost}+ END+ `,+ timeSubMonthlyUsageUpdated: sql`now()`,+ subIntervalUsage: sql`+ CASE+ WHEN FLOOR(UNIX_TIMESTAMP(${UserTable.timeSubIntervalUsageUpdated}) / (${BlackData.get().intervalLength} * 86400)) = FLOOR(UNIX_TIMESTAMP(now()) / (${BlackData.get().intervalLength} * 86400)) THEN ${UserTable.subIntervalUsage} + ${cost}+ ELSE ${cost}+ END+ `,+ timeSubIntervalUsageUpdated: sql`now()`,+ })+ .where(and(eq(UserTable.workspaceID, authInfo.workspaceID), eq(UserTable.id, authInfo.user.id))),+ ]+ : [+ db+ .update(BillingTable)+ .set({+ balance: authInfo.isFree+ ? sql`${BillingTable.balance} - ${0}`+ : sql`${BillingTable.balance} - ${cost}`,+ monthlyUsage: sql`CASEWHEN MONTH(${BillingTable.timeMonthlyUsageUpdated}) = MONTH(now()) AND YEAR(${BillingTable.timeMonthlyUsageUpdated}) = YEAR(now()) THEN ${BillingTable.monthlyUsage} + ${cost}ELSE ${cost}END`,- timeMonthlyUsageUpdated: sql`now()`,- })- .where(eq(BillingTable.workspaceID, authInfo.workspaceID)),- db- .update(UserTable)- .set({- monthlyUsage: sql`+ timeMonthlyUsageUpdated: sql`now()`,+ })+ .where(eq(BillingTable.workspaceID, authInfo.workspaceID)),+ db+ .update(UserTable)+ .set({+ monthlyUsage: sql`CASEWHEN MONTH(${UserTable.timeMonthlyUsageUpdated}) = MONTH(now()) AND YEAR(${UserTable.timeMonthlyUsageUpdated}) = YEAR(now()) THEN ${UserTable.monthlyUsage} + ${cost}ELSE ${cost}END`,- timeMonthlyUsageUpdated: sql`now()`,- })- .where(and(eq(UserTable.workspaceID, authInfo.workspaceID), eq(UserTable.id, authInfo.user.id))),- db- .update(KeyTable)- .set({ timeUsed: sql`now()` })- .where(and(eq(KeyTable.workspaceID, authInfo.workspaceID), eq(KeyTable.id, authInfo.apiKeyId))),+ timeMonthlyUsageUpdated: sql`now()`,+ })+ .where(and(eq(UserTable.workspaceID, authInfo.workspaceID), eq(UserTable.id, authInfo.user.id))),+ ]),]),)@@ -616,6 +701,7 @@ export async function handler(if (!authInfo) returnif (authInfo.isFree) returnif (authInfo.provider?.credentials) return+ if (authInfo.subscription) returnif (!costInfo) returndiff --git a/packages/console/core/migrations/0043_lame_calypso.sql b/packages/console/core/migrations/0043_lame_calypso.sqlnew file mode 100644index 00000000000..9a2facbc4fe--- /dev/null+++ b/packages/console/core/migrations/0043_lame_calypso.sql@@ -0,0 +1,2 @@+ALTER TABLE `user` RENAME COLUMN `sub_recent_usage` TO `sub_interval_usage`;--> statement-breakpoint+ALTER TABLE `user` RENAME COLUMN `sub_time_recent_usage_updated` TO `sub_time_interval_usage_updated`;\ No newline at end of filediff --git a/packages/console/core/migrations/0044_tiny_captain_midlands.sql b/packages/console/core/migrations/0044_tiny_captain_midlands.sqlnew file mode 100644index 00000000000..07163dd6524--- /dev/null+++ b/packages/console/core/migrations/0044_tiny_captain_midlands.sql@@ -0,0 +1 @@+ALTER TABLE `usage` RENAME COLUMN `data` TO `enrichment`;\ No newline at end of filediff --git a/packages/console/core/migrations/meta/0043_snapshot.json b/packages/console/core/migrations/meta/0043_snapshot.jsonnew file mode 100644index 00000000000..6f7d8cfa82e--- /dev/null+++ b/packages/console/core/migrations/meta/0043_snapshot.json@@ -0,0 +1,1213 @@+{+ "version": "5",+ "dialect": "mysql",+ "id": "3ff862f3-eeb6-4b10-8c78-254de3778ab3",+ "prevId": "4775571c-ad9c-4104-a202-2374b1963cfe",+ "tables": {+ "account": {+ "name": "account",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "time_created": {+ "name": "time_created",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "time_updated": {+ "name": "time_updated",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)"+ },+ "time_deleted": {+ "name": "time_deleted",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "account_id_pk": {+ "name": "account_id_pk",+ "columns": [+ "id"+ ]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "auth": {+ "name": "auth",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "time_created": {+ "name": "time_created",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "time_updated": {+ "name": "time_updated",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)"+ },+ "time_deleted": {+ "name": "time_deleted",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "provider": {+ "name": "provider",+ "type": "enum('email','github','google')",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "subject": {+ "name": "subject",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "account_id": {+ "name": "account_id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {+ "provider": {+ "name": "provider",+ "columns": [+ "provider",+ "subject"+ ],+ "isUnique": true+ },+ "account_id": {+ "name": "account_id",+ "columns": [+ "account_id"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "auth_id_pk": {+ "name": "auth_id_pk",+ "columns": [+ "id"+ ]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "benchmark": {+ "name": "benchmark",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "time_created": {+ "name": "time_created",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "time_updated": {+ "name": "time_updated",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)"+ },+ "time_deleted": {+ "name": "time_deleted",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "model": {+ "name": "model",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "agent": {+ "name": "agent",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "result": {+ "name": "result",+ "type": "mediumtext",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {+ "time_created": {+ "name": "time_created",+ "columns": [+ "time_created"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "benchmark_id_pk": {+ "name": "benchmark_id_pk",+ "columns": [+ "id"+ ]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "billing": {+ "name": "billing",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "time_created": {+ "name": "time_created",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "time_updated": {+ "name": "time_updated",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)"+ },+ "time_deleted": {+ "name": "time_deleted",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "customer_id": {+ "name": "customer_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "payment_method_id": {+ "name": "payment_method_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "payment_method_type": {+ "name": "payment_method_type",+ "type": "varchar(32)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "payment_method_last4": {+ "name": "payment_method_last4",+ "type": "varchar(4)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "balance": {+ "name": "balance",+ "type": "bigint",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "monthly_limit": {+ "name": "monthly_limit",+ "type": "int",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "monthly_usage": {+ "name": "monthly_usage",+ "type": "bigint",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "time_monthly_usage_updated": {+ "name": "time_monthly_usage_updated",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "reload": {+ "name": "reload",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "reload_trigger": {+ "name": "reload_trigger",+ "type": "int",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "reload_amount": {+ "name": "reload_amount",+ "type": "int",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "reload_error": {+ "name": "reload_error",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "time_reload_error": {+ "name": "time_reload_error",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "time_reload_locked_till": {+ "name": "time_reload_locked_till",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "subscription_id": {+ "name": "subscription_id",+ "type": "varchar(28)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {+ "global_customer_id": {+ "name": "global_customer_id",+ "columns": [+ "customer_id"+ ],+ "isUnique": true+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "billing_workspace_id_id_pk": {+ "name": "billing_workspace_id_id_pk",+ "columns": [+ "workspace_id",+ "id"+ ]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "payment": {+ "name": "payment",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "time_created": {+ "name": "time_created",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "time_updated": {+ "name": "time_updated",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)"+ },+ "time_deleted": {+ "name": "time_deleted",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "customer_id": {+ "name": "customer_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "invoice_id": {+ "name": "invoice_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "payment_id": {+ "name": "payment_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "amount": {+ "name": "amount",+ "type": "bigint",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "time_refunded": {+ "name": "time_refunded",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "payment_workspace_id_id_pk": {+ "name": "payment_workspace_id_id_pk",+ "columns": [+ "workspace_id",+ "id"+ ]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "usage": {+ "name": "usage",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "time_created": {+ "name": "time_created",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "time_updated": {+ "name": "time_updated",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)"+ },+ "time_deleted": {+ "name": "time_deleted",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "model": {+ "name": "model",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "provider": {+ "name": "provider",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "input_tokens": {+ "name": "input_tokens",+ "type": "int",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "output_tokens": {+ "name": "output_tokens",+ "type": "int",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "reasoning_tokens": {+ "name": "reasoning_tokens",+ "type": "int",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "cache_read_tokens": {+ "name": "cache_read_tokens",+ "type": "int",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "cache_write_5m_tokens": {+ "name": "cache_write_5m_tokens",+ "type": "int",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "cache_write_1h_tokens": {+ "name": "cache_write_1h_tokens",+ "type": "int",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "cost": {+ "name": "cost",+ "type": "bigint",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "key_id": {+ "name": "key_id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "data": {+ "name": "data",+ "type": "json",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {+ "usage_time_created": {+ "name": "usage_time_created",+ "columns": [+ "workspace_id",+ "time_created"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "usage_workspace_id_id_pk": {+ "name": "usage_workspace_id_id_pk",+ "columns": [+ "workspace_id",+ "id"+ ]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "ip_rate_limit": {+ "name": "ip_rate_limit",+ "columns": {+ "ip": {+ "name": "ip",+ "type": "varchar(45)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "interval": {+ "name": "interval",+ "type": "varchar(10)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "count": {+ "name": "count",+ "type": "int",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "ip_rate_limit_ip_interval_pk": {+ "name": "ip_rate_limit_ip_interval_pk",+ "columns": [+ "ip",+ "interval"+ ]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "ip": {+ "name": "ip",+ "columns": {+ "ip": {+ "name": "ip",+ "type": "varchar(45)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "time_created": {+ "name": "time_created",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "time_updated": {+ "name": "time_updated",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)"+ },+ "time_deleted": {+ "name": "time_deleted",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "usage": {+ "name": "usage",+ "type": "int",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "ip_ip_pk": {+ "name": "ip_ip_pk",+ "columns": [+ "ip"+ ]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "key": {+ "name": "key",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "time_created": {+ "name": "time_created",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "time_updated": {+ "name": "time_updated",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)"+ },+ "time_deleted": {+ "name": "time_deleted",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "key": {+ "name": "key",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "user_id": {+ "name": "user_id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "time_used": {+ "name": "time_used",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {+ "global_key": {+ "name": "global_key",+ "columns": [+ "key"+ ],+ "isUnique": true+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "key_workspace_id_id_pk": {+ "name": "key_workspace_id_id_pk",+ "columns": [+ "workspace_id",+ "id"+ ]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "model": {+ "name": "model",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "time_created": {+ "name": "time_created",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "time_updated": {+ "name": "time_updated",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)"+ },+ "time_deleted": {+ "name": "time_deleted",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "model": {+ "name": "model",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {+ "model_workspace_model": {+ "name": "model_workspace_model",+ "columns": [+ "workspace_id",+ "model"+ ],+ "isUnique": true+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "model_workspace_id_id_pk": {+ "name": "model_workspace_id_id_pk",+ "columns": [+ "workspace_id",+ "id"+ ]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "provider": {+ "name": "provider",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "time_created": {+ "name": "time_created",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "time_updated": {+ "name": "time_updated",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)"+ },+ "time_deleted": {+ "name": "time_deleted",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "provider": {+ "name": "provider",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "credentials": {+ "name": "credentials",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {+ "workspace_provider": {+ "name": "workspace_provider",+ "columns": [+ "workspace_id",+ "provider"+ ],+ "isUnique": true+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "provider_workspace_id_id_pk": {+ "name": "provider_workspace_id_id_pk",+ "columns": [+ "workspace_id",+ "id"+ ]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "user": {+ "name": "user",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "time_created": {+ "name": "time_created",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "time_updated": {+ "name": "time_updated",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)"+ },+ "time_deleted": {+ "name": "time_deleted",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "account_id": {+ "name": "account_id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "email": {+ "name": "email",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "time_seen": {+ "name": "time_seen",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "color": {+ "name": "color",+ "type": "int",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "role": {+ "name": "role",+ "type": "enum('admin','member')",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "monthly_limit": {+ "name": "monthly_limit",+ "type": "int",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "monthly_usage": {+ "name": "monthly_usage",+ "type": "bigint",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "time_monthly_usage_updated": {+ "name": "time_monthly_usage_updated",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "time_subscribed": {+ "name": "time_subscribed",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "sub_interval_usage": {+ "name": "sub_interval_usage",+ "type": "bigint",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "sub_monthly_usage": {+ "name": "sub_monthly_usage",+ "type": "bigint",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "sub_time_interval_usage_updated": {+ "name": "sub_time_interval_usage_updated",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "sub_time_monthly_usage_updated": {+ "name": "sub_time_monthly_usage_updated",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {+ "user_account_id": {+ "name": "user_account_id",+ "columns": [+ "workspace_id",+ "account_id"+ ],+ "isUnique": true+ },+ "user_email": {+ "name": "user_email",+ "columns": [+ "workspace_id",+ "email"+ ],+ "isUnique": true+ },+ "global_account_id": {+ "name": "global_account_id",+ "columns": [+ "account_id"+ ],+ "isUnique": false+ },+ "global_email": {+ "name": "global_email",+ "columns": [+ "email"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "user_workspace_id_id_pk": {+ "name": "user_workspace_id_id_pk",+ "columns": [+ "workspace_id",+ "id"+ ]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "workspace": {+ "name": "workspace",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "slug": {+ "name": "slug",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "time_created": {+ "name": "time_created",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "time_updated": {+ "name": "time_updated",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)"+ },+ "time_deleted": {+ "name": "time_deleted",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {+ "slug": {+ "name": "slug",+ "columns": [+ "slug"+ ],+ "isUnique": true+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "workspace_id": {+ "name": "workspace_id",+ "columns": [+ "id"+ ]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ }+ },+ "views": {},+ "_meta": {+ "schemas": {},+ "tables": {},+ "columns": {+ "\"user\".\"sub_recent_usage\"": "\"user\".\"sub_interval_usage\"",+ "\"user\".\"sub_time_recent_usage_updated\"": "\"user\".\"sub_time_interval_usage_updated\""+ }+ },+ "internal": {+ "tables": {},+ "indexes": {}+ }+}\ No newline at end of filediff --git a/packages/console/core/migrations/meta/0044_snapshot.json b/packages/console/core/migrations/meta/0044_snapshot.jsonnew file mode 100644index 00000000000..8468eeb2b92--- /dev/null+++ b/packages/console/core/migrations/meta/0044_snapshot.json@@ -0,0 +1,1212 @@+{+ "version": "5",+ "dialect": "mysql",+ "id": "70394850-2c28-4012-a3d5-69357e3348b6",+ "prevId": "3ff862f3-eeb6-4b10-8c78-254de3778ab3",+ "tables": {+ "account": {+ "name": "account",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "time_created": {+ "name": "time_created",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "time_updated": {+ "name": "time_updated",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)"+ },+ "time_deleted": {+ "name": "time_deleted",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "account_id_pk": {+ "name": "account_id_pk",+ "columns": [+ "id"+ ]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "auth": {+ "name": "auth",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "time_created": {+ "name": "time_created",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "time_updated": {+ "name": "time_updated",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)"+ },+ "time_deleted": {+ "name": "time_deleted",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "provider": {+ "name": "provider",+ "type": "enum('email','github','google')",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "subject": {+ "name": "subject",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "account_id": {+ "name": "account_id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {+ "provider": {+ "name": "provider",+ "columns": [+ "provider",+ "subject"+ ],+ "isUnique": true+ },+ "account_id": {+ "name": "account_id",+ "columns": [+ "account_id"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "auth_id_pk": {+ "name": "auth_id_pk",+ "columns": [+ "id"+ ]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "benchmark": {+ "name": "benchmark",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "time_created": {+ "name": "time_created",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "time_updated": {+ "name": "time_updated",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)"+ },+ "time_deleted": {+ "name": "time_deleted",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "model": {+ "name": "model",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "agent": {+ "name": "agent",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "result": {+ "name": "result",+ "type": "mediumtext",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {+ "time_created": {+ "name": "time_created",+ "columns": [+ "time_created"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "benchmark_id_pk": {+ "name": "benchmark_id_pk",+ "columns": [+ "id"+ ]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "billing": {+ "name": "billing",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "time_created": {+ "name": "time_created",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "time_updated": {+ "name": "time_updated",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)"+ },+ "time_deleted": {+ "name": "time_deleted",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "customer_id": {+ "name": "customer_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "payment_method_id": {+ "name": "payment_method_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "payment_method_type": {+ "name": "payment_method_type",+ "type": "varchar(32)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "payment_method_last4": {+ "name": "payment_method_last4",+ "type": "varchar(4)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "balance": {+ "name": "balance",+ "type": "bigint",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "monthly_limit": {+ "name": "monthly_limit",+ "type": "int",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "monthly_usage": {+ "name": "monthly_usage",+ "type": "bigint",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "time_monthly_usage_updated": {+ "name": "time_monthly_usage_updated",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "reload": {+ "name": "reload",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "reload_trigger": {+ "name": "reload_trigger",+ "type": "int",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "reload_amount": {+ "name": "reload_amount",+ "type": "int",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "reload_error": {+ "name": "reload_error",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "time_reload_error": {+ "name": "time_reload_error",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "time_reload_locked_till": {+ "name": "time_reload_locked_till",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "subscription_id": {+ "name": "subscription_id",+ "type": "varchar(28)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {+ "global_customer_id": {+ "name": "global_customer_id",+ "columns": [+ "customer_id"+ ],+ "isUnique": true+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "billing_workspace_id_id_pk": {+ "name": "billing_workspace_id_id_pk",+ "columns": [+ "workspace_id",+ "id"+ ]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "payment": {+ "name": "payment",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "time_created": {+ "name": "time_created",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "time_updated": {+ "name": "time_updated",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)"+ },+ "time_deleted": {+ "name": "time_deleted",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "customer_id": {+ "name": "customer_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "invoice_id": {+ "name": "invoice_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "payment_id": {+ "name": "payment_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "amount": {+ "name": "amount",+ "type": "bigint",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "time_refunded": {+ "name": "time_refunded",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "payment_workspace_id_id_pk": {+ "name": "payment_workspace_id_id_pk",+ "columns": [+ "workspace_id",+ "id"+ ]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "usage": {+ "name": "usage",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "time_created": {+ "name": "time_created",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "time_updated": {+ "name": "time_updated",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)"+ },+ "time_deleted": {+ "name": "time_deleted",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "model": {+ "name": "model",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "provider": {+ "name": "provider",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "input_tokens": {+ "name": "input_tokens",+ "type": "int",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "output_tokens": {+ "name": "output_tokens",+ "type": "int",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "reasoning_tokens": {+ "name": "reasoning_tokens",+ "type": "int",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "cache_read_tokens": {+ "name": "cache_read_tokens",+ "type": "int",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "cache_write_5m_tokens": {+ "name": "cache_write_5m_tokens",+ "type": "int",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "cache_write_1h_tokens": {+ "name": "cache_write_1h_tokens",+ "type": "int",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "cost": {+ "name": "cost",+ "type": "bigint",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "key_id": {+ "name": "key_id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "enrichment": {+ "name": "enrichment",+ "type": "json",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {+ "usage_time_created": {+ "name": "usage_time_created",+ "columns": [+ "workspace_id",+ "time_created"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "usage_workspace_id_id_pk": {+ "name": "usage_workspace_id_id_pk",+ "columns": [+ "workspace_id",+ "id"+ ]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "ip_rate_limit": {+ "name": "ip_rate_limit",+ "columns": {+ "ip": {+ "name": "ip",+ "type": "varchar(45)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "interval": {+ "name": "interval",+ "type": "varchar(10)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "count": {+ "name": "count",+ "type": "int",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "ip_rate_limit_ip_interval_pk": {+ "name": "ip_rate_limit_ip_interval_pk",+ "columns": [+ "ip",+ "interval"+ ]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "ip": {+ "name": "ip",+ "columns": {+ "ip": {+ "name": "ip",+ "type": "varchar(45)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "time_created": {+ "name": "time_created",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "time_updated": {+ "name": "time_updated",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)"+ },+ "time_deleted": {+ "name": "time_deleted",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "usage": {+ "name": "usage",+ "type": "int",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "ip_ip_pk": {+ "name": "ip_ip_pk",+ "columns": [+ "ip"+ ]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "key": {+ "name": "key",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "time_created": {+ "name": "time_created",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "time_updated": {+ "name": "time_updated",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)"+ },+ "time_deleted": {+ "name": "time_deleted",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "key": {+ "name": "key",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "user_id": {+ "name": "user_id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "time_used": {+ "name": "time_used",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {+ "global_key": {+ "name": "global_key",+ "columns": [+ "key"+ ],+ "isUnique": true+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "key_workspace_id_id_pk": {+ "name": "key_workspace_id_id_pk",+ "columns": [+ "workspace_id",+ "id"+ ]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "model": {+ "name": "model",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "time_created": {+ "name": "time_created",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "time_updated": {+ "name": "time_updated",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)"+ },+ "time_deleted": {+ "name": "time_deleted",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "model": {+ "name": "model",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {+ "model_workspace_model": {+ "name": "model_workspace_model",+ "columns": [+ "workspace_id",+ "model"+ ],+ "isUnique": true+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "model_workspace_id_id_pk": {+ "name": "model_workspace_id_id_pk",+ "columns": [+ "workspace_id",+ "id"+ ]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "provider": {+ "name": "provider",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "time_created": {+ "name": "time_created",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "time_updated": {+ "name": "time_updated",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)"+ },+ "time_deleted": {+ "name": "time_deleted",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "provider": {+ "name": "provider",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "credentials": {+ "name": "credentials",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {+ "workspace_provider": {+ "name": "workspace_provider",+ "columns": [+ "workspace_id",+ "provider"+ ],+ "isUnique": true+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "provider_workspace_id_id_pk": {+ "name": "provider_workspace_id_id_pk",+ "columns": [+ "workspace_id",+ "id"+ ]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "user": {+ "name": "user",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "time_created": {+ "name": "time_created",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "time_updated": {+ "name": "time_updated",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)"+ },+ "time_deleted": {+ "name": "time_deleted",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "account_id": {+ "name": "account_id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "email": {+ "name": "email",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "time_seen": {+ "name": "time_seen",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "color": {+ "name": "color",+ "type": "int",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "role": {+ "name": "role",+ "type": "enum('admin','member')",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "monthly_limit": {+ "name": "monthly_limit",+ "type": "int",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "monthly_usage": {+ "name": "monthly_usage",+ "type": "bigint",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "time_monthly_usage_updated": {+ "name": "time_monthly_usage_updated",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "time_subscribed": {+ "name": "time_subscribed",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "sub_interval_usage": {+ "name": "sub_interval_usage",+ "type": "bigint",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "sub_monthly_usage": {+ "name": "sub_monthly_usage",+ "type": "bigint",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "sub_time_interval_usage_updated": {+ "name": "sub_time_interval_usage_updated",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "sub_time_monthly_usage_updated": {+ "name": "sub_time_monthly_usage_updated",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {+ "user_account_id": {+ "name": "user_account_id",+ "columns": [+ "workspace_id",+ "account_id"+ ],+ "isUnique": true+ },+ "user_email": {+ "name": "user_email",+ "columns": [+ "workspace_id",+ "email"+ ],+ "isUnique": true+ },+ "global_account_id": {+ "name": "global_account_id",+ "columns": [+ "account_id"+ ],+ "isUnique": false+ },+ "global_email": {+ "name": "global_email",+ "columns": [+ "email"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "user_workspace_id_id_pk": {+ "name": "user_workspace_id_id_pk",+ "columns": [+ "workspace_id",+ "id"+ ]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "workspace": {+ "name": "workspace",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "slug": {+ "name": "slug",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "time_created": {+ "name": "time_created",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "time_updated": {+ "name": "time_updated",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)"+ },+ "time_deleted": {+ "name": "time_deleted",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {+ "slug": {+ "name": "slug",+ "columns": [+ "slug"+ ],+ "isUnique": true+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "workspace_id": {+ "name": "workspace_id",+ "columns": [+ "id"+ ]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ }+ },+ "views": {},+ "_meta": {+ "schemas": {},+ "tables": {},+ "columns": {+ "\"usage\".\"data\"": "\"usage\".\"enrichment\""+ }+ },+ "internal": {+ "tables": {},+ "indexes": {}+ }+}\ No newline at end of filediff --git a/packages/console/core/migrations/meta/_journal.json b/packages/console/core/migrations/meta/_journal.jsonindex 6cf20359c89..f30e8635109 100644--- a/packages/console/core/migrations/meta/_journal.json+++ b/packages/console/core/migrations/meta/_journal.json@@ -302,6 +302,20 @@"when": 1767744077346,"tag": "0042_flat_nightmare","breakpoints": true+ },+ {+ "idx": 43,+ "version": "5",+ "when": 1767752636118,+ "tag": "0043_lame_calypso",+ "breakpoints": true+ },+ {+ "idx": 44,+ "version": "5",+ "when": 1767759322451,+ "tag": "0044_tiny_captain_midlands",+ "breakpoints": true}]-}+}\ No newline at end of filediff --git a/packages/console/core/package.json b/packages/console/core/package.jsonindex c22276bf055..5cb532e3954 100644--- a/packages/console/core/package.json+++ b/packages/console/core/package.json@@ -32,6 +32,9 @@"promote-models-to-dev": "script/promote-models.ts dev","promote-models-to-prod": "script/promote-models.ts production","pull-models-from-dev": "script/pull-models.ts dev",+ "update-black": "script/update-black.ts",+ "promote-black-to-dev": "script/promote-black.ts dev",+ "promote-black-to-prod": "script/promote-black.ts production","typecheck": "tsgo --noEmit"},"devDependencies": {diff --git a/packages/console/core/script/promote-black.ts b/packages/console/core/script/promote-black.tsnew file mode 100755index 00000000000..bb3dcc6f7b6--- /dev/null+++ b/packages/console/core/script/promote-black.ts@@ -0,0 +1,22 @@+#!/usr/bin/env bun++import { $ } from "bun"+import path from "path"+import { BlackData } from "../src/black"++const stage = process.argv[2]+if (!stage) throw new Error("Stage is required")++const root = path.resolve(process.cwd(), "..", "..", "..")++// read the secret+const ret = await $`bun sst secret list`.cwd(root).text()+const lines = ret.split("\n")+const value = lines.find((line) => line.startsWith("ZEN_BLACK"))?.split("=")[1]+if (!value) throw new Error("ZEN_BLACK not found")++// validate value+BlackData.validate(JSON.parse(value))++// update the secret+await $`bun sst secret set ZEN_BLACK ${value} --stage ${stage}`diff --git a/packages/console/core/script/update-black.ts b/packages/console/core/script/update-black.tsnew file mode 100755index 00000000000..58923b457dd--- /dev/null+++ b/packages/console/core/script/update-black.ts@@ -0,0 +1,28 @@+#!/usr/bin/env bun++import { $ } from "bun"+import path from "path"+import os from "os"+import { BlackData } from "../src/black"++const root = path.resolve(process.cwd(), "..", "..", "..")+const secrets = await $`bun sst secret list`.cwd(root).text()++// read the line starting with "ZEN_BLACK"+const lines = secrets.split("\n")+const oldValue = lines.find((line) => line.startsWith("ZEN_BLACK"))?.split("=")[1]+if (!oldValue) throw new Error("ZEN_BLACK not found")++// store the prettified json to a temp file+const filename = `black-${Date.now()}.json`+const tempFile = Bun.file(path.join(os.tmpdir(), filename))+await tempFile.write(JSON.stringify(JSON.parse(oldValue), null, 2))+console.log("tempFile", tempFile.name)++// open temp file in vim and read the file on close+await $`vim ${tempFile.name}`+const newValue = JSON.stringify(JSON.parse(await tempFile.text()))+BlackData.validate(JSON.parse(newValue))++// update the secret+await $`bun sst secret set ZEN_BLACK ${newValue}`diff --git a/packages/console/core/src/billing.ts b/packages/console/core/src/billing.tsindex c14df11ae7d..c97dfff1ba1 100644--- a/packages/console/core/src/billing.ts+++ b/packages/console/core/src/billing.ts@@ -27,6 +27,7 @@ export namespace Billing {tx.select({customerID: BillingTable.customerID,+ subscriptionID: BillingTable.subscriptionID,paymentMethodID: BillingTable.paymentMethodID,paymentMethodType: BillingTable.paymentMethodType,paymentMethodLast4: BillingTable.paymentMethodLast4,diff --git a/packages/console/core/src/black.ts b/packages/console/core/src/black.tsnew file mode 100644index 00000000000..a4c44aea56e--- /dev/null+++ b/packages/console/core/src/black.ts@@ -0,0 +1,20 @@+import { z } from "zod"+import { fn } from "./util/fn"+import { Resource } from "@opencode-ai/console-resource"++export namespace BlackData {+ const Schema = z.object({+ monthlyLimit: z.number().int(),+ intervalLimit: z.number().int(),+ intervalLength: z.number().int(),+ })++ export const validate = fn(Schema, (input) => {+ return input+ })++ export const get = fn(z.void(), () => {+ const json = JSON.parse(Resource.ZEN_BLACK.value)+ return Schema.parse(json)+ })+}diff --git a/packages/console/core/src/schema/billing.sql.ts b/packages/console/core/src/schema/billing.sql.tsindex 52de18f6420..8210bc15294 100644--- a/packages/console/core/src/schema/billing.sql.ts+++ b/packages/console/core/src/schema/billing.sql.ts@@ -55,7 +55,7 @@ export const UsageTable = mysqlTable(cacheWrite1hTokens: int("cache_write_1h_tokens"),cost: bigint("cost", { mode: "number" }).notNull(),keyID: ulid("key_id"),- enrichment: json("data").$type<{+ enrichment: json("enrichment").$type<{plan: "sub"}>(),},diff --git a/packages/console/core/src/schema/user.sql.ts b/packages/console/core/src/schema/user.sql.tsindex e2b8784b229..46d02c4a857 100644--- a/packages/console/core/src/schema/user.sql.ts+++ b/packages/console/core/src/schema/user.sql.ts@@ -20,9 +20,9 @@ export const UserTable = mysqlTable(timeMonthlyUsageUpdated: utc("time_monthly_usage_updated"),// subscriptiontimeSubscribed: utc("time_subscribed"),- subRecentUsage: bigint("sub_recent_usage", { mode: "number" }),+ subIntervalUsage: bigint("sub_interval_usage", { mode: "number" }),subMonthlyUsage: bigint("sub_monthly_usage", { mode: "number" }),- timeSubRecentUsageUpdated: utc("sub_time_recent_usage_updated"),+ timeSubIntervalUsageUpdated: utc("sub_time_interval_usage_updated"),timeSubMonthlyUsageUpdated: utc("sub_time_monthly_usage_updated"),},(table) => [diff --git a/packages/console/core/sst-env.d.ts b/packages/console/core/sst-env.d.tsindex 27cc0914520..4450c6cb691 100644--- a/packages/console/core/sst-env.d.ts+++ b/packages/console/core/sst-env.d.ts@@ -98,6 +98,10 @@ declare module "sst" {"type": "sst.cloudflare.StaticSite""url": string}+ "ZEN_BLACK": {+ "type": "sst.sst.Secret"+ "value": string+ }"ZEN_MODELS1": {"type": "sst.sst.Secret""value": stringdiff --git a/packages/console/function/sst-env.d.ts b/packages/console/function/sst-env.d.tsindex 27cc0914520..4450c6cb691 100644--- a/packages/console/function/sst-env.d.ts+++ b/packages/console/function/sst-env.d.ts@@ -98,6 +98,10 @@ declare module "sst" {"type": "sst.cloudflare.StaticSite""url": string}+ "ZEN_BLACK": {+ "type": "sst.sst.Secret"+ "value": string+ }"ZEN_MODELS1": {"type": "sst.sst.Secret""value": stringdiff --git a/packages/console/resource/sst-env.d.ts b/packages/console/resource/sst-env.d.tsindex 27cc0914520..4450c6cb691 100644--- a/packages/console/resource/sst-env.d.ts+++ b/packages/console/resource/sst-env.d.ts@@ -98,6 +98,10 @@ declare module "sst" {"type": "sst.cloudflare.StaticSite""url": string}+ "ZEN_BLACK": {+ "type": "sst.sst.Secret"+ "value": string+ }"ZEN_MODELS1": {"type": "sst.sst.Secret""value": stringdiff --git a/packages/enterprise/sst-env.d.ts b/packages/enterprise/sst-env.d.tsindex 27cc0914520..4450c6cb691 100644--- a/packages/enterprise/sst-env.d.ts+++ b/packages/enterprise/sst-env.d.ts@@ -98,6 +98,10 @@ declare module "sst" {"type": "sst.cloudflare.StaticSite""url": string}+ "ZEN_BLACK": {+ "type": "sst.sst.Secret"+ "value": string+ }"ZEN_MODELS1": {"type": "sst.sst.Secret""value": stringdiff --git a/packages/function/sst-env.d.ts b/packages/function/sst-env.d.tsindex 27cc0914520..4450c6cb691 100644--- a/packages/function/sst-env.d.ts+++ b/packages/function/sst-env.d.ts@@ -98,6 +98,10 @@ declare module "sst" {"type": "sst.cloudflare.StaticSite""url": string}+ "ZEN_BLACK": {+ "type": "sst.sst.Secret"+ "value": string+ }"ZEN_MODELS1": {"type": "sst.sst.Secret""value": stringdiff --git a/sst-env.d.ts b/sst-env.d.tsindex 18e2d40d657..6e8b8e67e6a 100644--- a/sst-env.d.ts+++ b/sst-env.d.ts@@ -124,6 +124,10 @@ declare module "sst" {"type": "sst.cloudflare.StaticSite""url": string}+ "ZEN_BLACK": {+ "type": "sst.sst.Secret"+ "value": string+ }"ZEN_MODELS1": {"type": "sst.sst.Secret""value": string