zen: restrict alpha models to admin workspaces
This commit is contained in:
@@ -34,6 +34,7 @@ import { createDataDumper } from "./dataDumper"
|
|||||||
import { createTrialLimiter } from "./trialLimiter"
|
import { createTrialLimiter } from "./trialLimiter"
|
||||||
import { createStickyTracker } from "./stickyProviderTracker"
|
import { createStickyTracker } from "./stickyProviderTracker"
|
||||||
import { LiteData } from "@opencode-ai/console-core/lite.js"
|
import { LiteData } from "@opencode-ai/console-core/lite.js"
|
||||||
|
import { Resource } from "@opencode-ai/console-resource"
|
||||||
|
|
||||||
type ZenData = Awaited<ReturnType<typeof ZenData.list>>
|
type ZenData = Awaited<ReturnType<typeof ZenData.list>>
|
||||||
type RetryOptions = {
|
type RetryOptions = {
|
||||||
@@ -59,7 +60,7 @@ export async function handler(
|
|||||||
|
|
||||||
const MAX_FAILOVER_RETRIES = 3
|
const MAX_FAILOVER_RETRIES = 3
|
||||||
const MAX_429_RETRIES = 3
|
const MAX_429_RETRIES = 3
|
||||||
const FREE_WORKSPACES = [
|
const ADMIN_WORKSPACES = [
|
||||||
"wrk_01K46JDFR0E75SG2Q8K172KF3Y", // frank
|
"wrk_01K46JDFR0E75SG2Q8K172KF3Y", // frank
|
||||||
"wrk_01K6W1A3VE0KMNVSCQT43BG2SX", // opencode bench
|
"wrk_01K6W1A3VE0KMNVSCQT43BG2SX", // opencode bench
|
||||||
]
|
]
|
||||||
@@ -520,6 +521,13 @@ export async function handler(
|
|||||||
)
|
)
|
||||||
|
|
||||||
if (!data) throw new AuthError("Invalid API key.")
|
if (!data) throw new AuthError("Invalid API key.")
|
||||||
|
if (
|
||||||
|
modelInfo.id.startsWith("alpha-") &&
|
||||||
|
Resource.App.stage === "production" &&
|
||||||
|
!ADMIN_WORKSPACES.includes(data.workspaceID)
|
||||||
|
)
|
||||||
|
throw new AuthError(`Model ${modelInfo.id} not supported`)
|
||||||
|
|
||||||
logger.metric({
|
logger.metric({
|
||||||
api_key: data.apiKey,
|
api_key: data.apiKey,
|
||||||
workspace: data.workspaceID,
|
workspace: data.workspaceID,
|
||||||
@@ -546,7 +554,7 @@ export async function handler(
|
|||||||
black: data.black,
|
black: data.black,
|
||||||
lite: data.lite,
|
lite: data.lite,
|
||||||
provider: data.provider,
|
provider: data.provider,
|
||||||
isFree: FREE_WORKSPACES.includes(data.workspaceID),
|
isFree: ADMIN_WORKSPACES.includes(data.workspaceID),
|
||||||
isDisabled: !!data.timeDisabled,
|
isDisabled: !!data.timeDisabled,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user