This commit is contained in:
Frank
2026-08-18 23:11:12 -04:00
parent 64b4f7df4c
commit 72824fe65d
9 changed files with 3268 additions and 22 deletions
+2 -2
View File
@@ -673,8 +673,8 @@ export const dict = {
'Select "OpenCode Go" as the provider in your opencode configuration to use Go models.',
"workspace.lite.providers.title": "Providers",
"workspace.lite.providers.description": "Control which providers are used for routing.",
"workspace.lite.providers.allowNonZdr": "Enable models without zero data retention",
"workspace.lite.providers.useChina": "Enable models hosted in China",
"workspace.lite.providers.allowTraining": "Allow models that train on request data",
"workspace.lite.providers.useChina": "Allow models hosted in China",
"workspace.lite.black.message":
"You're currently subscribed to OpenCode Black or on the waitlist. Please unsubscribe first if you'd like to switch to Go.",
"workspace.lite.other.message":
@@ -39,7 +39,7 @@ export const queryLiteSubscription = query(async (workspaceID: string) => {
timeCreated: LiteTable.timeCreated,
lite: BillingTable.lite,
region: WorkspaceTable.region,
allowNonZdr: WorkspaceTable.allow_non_zdr,
allowTraining: WorkspaceTable.allow_training,
})
.from(BillingTable)
.innerJoin(LiteTable, eq(LiteTable.workspaceID, BillingTable.workspaceID))
@@ -55,7 +55,7 @@ export const queryLiteSubscription = query(async (workspaceID: string) => {
return {
mine,
useBalance: row.lite?.useBalance ?? false,
allowNonZdr: row.allowNonZdr ?? false,
allowTraining: row.allowTraining ?? false,
region:
row.region ?? (await Workspace.setDefaultRegion({ country: countryFromRequest(getRequestEvent()?.request) })),
rollingUsage: Subscription.analyzeRollingUsage({
@@ -156,23 +156,23 @@ const setGoProviderRouting = action(async (form: FormData) => {
)
}, "go.providerRouting.set")
const setGoAllowNonZdr = action(async (form: FormData) => {
const setGoAllowTraining = action(async (form: FormData) => {
"use server"
const workspaceID = form.get("workspaceID") as string | null
if (!workspaceID) return { error: formError.workspaceRequired }
const allowNonZdr = (form.get("allowNonZdr") as string | null) === "true"
const allowTraining = (form.get("allowTraining") as string | null) === "true"
return json(
await withActor(
() =>
Workspace.update({ allow_non_zdr: allowNonZdr })
Workspace.update({ allow_training: allowTraining })
.then(() => ({ error: undefined }))
.catch((e) => ({ error: e.message as string })),
workspaceID,
),
{ revalidate: queryLiteSubscription.key },
)
}, "go.allowNonZdr.set")
}, "go.allowTraining.set")
function LiteUsageItem(props: { label: string; usage: { usagePercent: number; resetInSec: number } }) {
const i18n = useI18n()
@@ -206,7 +206,7 @@ export function LiteSection(props: { lite: LiteSubscription | undefined }) {
const checkoutSubmission = useSubmission(createLiteCheckoutUrl)
const useBalanceSubmission = useSubmission(setLiteUseBalance)
const providerRoutingSubmission = useSubmission(setGoProviderRouting)
const allowNonZdrSubmission = useSubmission(setGoAllowNonZdr)
const allowTrainingSubmission = useSubmission(setGoAllowTraining)
const [store, setStore] = createStore({
loading: undefined as undefined | "session" | "checkout" | "alipay" | "upi",
showModal: false,
@@ -285,15 +285,15 @@ export function LiteSection(props: { lite: LiteSubscription | undefined }) {
<h3>{i18n.t("workspace.lite.providers.title")}</h3>
<p>{i18n.t("workspace.lite.providers.description")}</p>
</div>
<form action={setGoAllowNonZdr} method="post" data-slot="setting-row">
<p>{i18n.t("workspace.lite.providers.allowNonZdr")}</p>
<form action={setGoAllowTraining} method="post" data-slot="setting-row">
<p>{i18n.t("workspace.lite.providers.allowTraining")}</p>
<input type="hidden" name="workspaceID" value={params.id} />
<input type="hidden" name="allowNonZdr" value={sub().allowNonZdr ? "false" : "true"} />
<input type="hidden" name="allowTraining" value={sub().allowTraining ? "false" : "true"} />
<label data-slot="toggle-label">
<input
type="checkbox"
checked={sub().allowNonZdr}
disabled={allowNonZdrSubmission.pending}
checked={sub().allowTraining}
disabled={allowTrainingSubmission.pending}
onChange={(e) => e.currentTarget.form?.requestSubmit()}
/>
<span></span>
@@ -129,7 +129,7 @@ export async function handler(
: createKeyRateLimiter(modelInfo.id, modelInfo.rateLimit, zenApiKey, input.request)
await rateLimiter?.check()
const authInfo = await authenticate(modelInfo, zenApiKey)
if (authInfo && opts.modelList === "lite" && modelInfo.id === "muse-spark-1.2" && !authInfo.allowNonZdr)
if (authInfo && opts.modelList === "lite" && modelInfo.id === "muse-spark-1.2" && !authInfo.allowTraining)
throw new DataPolicyError(
t("zen.api.error.nonZdrNotAllowed", {
consoleGoUrl: `https://opencode.ai/workspace/${authInfo.workspaceID}/go`,
@@ -715,7 +715,7 @@ export async function handler(
workspace: {
id: WorkspaceTable.id,
region: WorkspaceTable.region,
allowNonZdr: WorkspaceTable.allow_non_zdr,
allowTraining: WorkspaceTable.allow_training,
isBlocked: WorkspaceTable.is_blocked,
isFlaggedByAnthropic: WorkspaceTable.is_flagged_by_anthropic,
isFlaggedByOpenAI: WorkspaceTable.is_flagged_by_openai,
@@ -828,7 +828,7 @@ export async function handler(
apiKeyId: data.apiKey,
workspaceID: data.workspace.id,
region: data.workspace.region,
allowNonZdr: data.workspace.allowNonZdr ?? false,
allowTraining: data.workspace.allowTraining ?? false,
billing: data.billing,
user: data.user,
black: data.black,
@@ -1 +1 @@
ALTER TABLE `workspace` ADD `allow_non_zdr` boolean;
ALTER TABLE `workspace` ADD `allow_non_zdr` boolean;
@@ -3242,4 +3242,4 @@
}
],
"renames": []
}
}
@@ -0,0 +1 @@
ALTER TABLE `workspace` RENAME COLUMN `allow_non_zdr` TO `allow_training`;
File diff suppressed because it is too large Load Diff
@@ -8,7 +8,7 @@ export const WorkspaceTable = mysqlTable(
slug: varchar("slug", { length: 255 }),
name: varchar("name", { length: 255 }).notNull(),
region: json("region").$type<("us" | "eu" | "sg" | "cn")[]>(),
allow_non_zdr: boolean(),
allow_training: boolean(),
is_blocked: boolean(),
is_flagged_by_anthropic: boolean(),
is_flagged_by_openai: boolean(),
+2 -2
View File
@@ -62,7 +62,7 @@ export namespace Workspace {
z.object({
name: z.string().min(1).max(255).optional(),
region: z.array(Region).min(1).optional(),
allow_non_zdr: z.boolean().optional(),
allow_training: z.boolean().optional(),
}),
async (input) => {
Actor.assertAdmin()
@@ -73,7 +73,7 @@ export namespace Workspace {
.set({
...("name" in input ? { name: input.name } : {}),
...("region" in input ? { region: input.region } : {}),
...("allow_non_zdr" in input ? { allow_non_zdr: input.allow_non_zdr } : {}),
...("allow_training" in input ? { allow_training: input.allow_training } : {}),
})
.where(eq(WorkspaceTable.id, workspaceID)),
)