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