feat(quota): use official OpenCode Go usage API (#12124)

Migra o quota fetcher do OpenCode Go para a API oficial de uso, com refactor substancial que remove ~1850 linhas de código legado e atualiza a suíte de testes existente inteira para o novo contrato. Validado no worktree combinado (typecheck limpo, testes focados verdes). Obrigado!
This commit is contained in:
Dohyun Jung
2026-08-30 23:11:46 +09:00
committed by GitHub
parent 908c1b823d
commit a2c5d8a2f5
17 changed files with 614 additions and 1842 deletions

View File

@@ -275,10 +275,6 @@ export default function EditConnectionModal({
const existingOpenRouterPreset = stringField(connection.providerSpecificData?.preset);
const existingCx = stringField(connection.providerSpecificData?.cx);
const existingAccountId = stringField(connection.providerSpecificData?.accountId);
const existingOpenCodeGoWorkspaceId =
stringField(connection.providerSpecificData?.opencodeGoWorkspaceId) ||
stringField(connection.providerSpecificData?.openCodeGoWorkspaceId) ||
stringField(connection.providerSpecificData?.workspaceId);
const existingGlmOrganizationId =
stringField(connection.providerSpecificData?.glmOrganizationId) ||
stringField(connection.providerSpecificData?.bigmodelOrganization) ||
@@ -369,8 +365,6 @@ export default function EditConnectionModal({
quotaPerUnit: existingQuotaPerUnit,
glmOrganizationId: existingGlmOrganizationId,
glmProjectId: existingGlmProjectId,
opencodeGoWorkspaceId: existingOpenCodeGoWorkspaceId,
opencodeGoAuthCookie: "",
ollamaCloudUsageCookie: "",
alibabaConsoleCookie: stringField(connection.providerSpecificData?.alibabaConsoleCookie),
qwenCloudCookie: stringField(connection.providerSpecificData?.qwenCloudCookie),

View File

@@ -29,45 +29,6 @@ export default function QuotaScrapingFields({
t,
editMode = false,
}: QuotaScrapingFieldsProps) {
if (provider === "opencode-go") {
return (
<div className="flex flex-col gap-3 rounded-lg border border-border/50 bg-surface/20 p-4">
<Input
label={providerText(t, "opencodeGoWorkspaceIdLabel", "OpenCode Go workspace ID")}
name="opencodeGoWorkspaceId"
value={values.opencodeGoWorkspaceId}
onChange={(e) => onChange({ opencodeGoWorkspaceId: e.target.value })}
placeholder="workspace_..."
hint={providerText(
t,
"opencodeGoWorkspaceIdHint",
"Required for quota scraping. Copy it from the OpenCode Go workspace URL."
)}
autoComplete="off"
spellCheck={false}
/>
<Input
label={providerText(t, "opencodeGoAuthCookieLabel", "OpenCode Go auth cookie")}
name="opencodeGoAuthCookie"
type="password"
value={values.opencodeGoAuthCookie}
onChange={(e) => onChange({ opencodeGoAuthCookie: e.target.value })}
placeholder="auth=..."
hint={providerText(
t,
"opencodeGoAuthCookieHint",
editMode
? "Leave blank to keep the stored cookie. Paste auth=... or only the cookie value to replace it."
: "Paste the auth cookie value from opencode.ai. The auth= prefix is accepted."
)}
autoComplete="off"
spellCheck={false}
autoCapitalize="off"
/>
</div>
);
}
if (provider === "ollama-cloud") {
return (
<div className="flex flex-col gap-3 rounded-lg border border-border/50 bg-surface/20 p-4">

View File

@@ -1,7 +1,5 @@
/**
* quotaScrapingFieldValues.ts — form-state shape + persistence rules for the
* quota-scraping credential fields (cookies / workspace ids) rendered by
* QuotaScrapingFields.tsx.
* quota-scraping credential fields rendered by QuotaScrapingFields.tsx.
*
* Kept in a UI-free module on purpose: importing the .tsx pulls in
* `@/shared/components`, whose barrel reaches untranspiled ESM deps
@@ -13,8 +11,6 @@
export const QWEN_TOKEN_PLAN_PROVIDERS = new Set(["qwen-cloud-token-plan", "bailian-coding-plan"]);
export type QuotaScrapingFieldValues = {
opencodeGoWorkspaceId: string;
opencodeGoAuthCookie: string;
ollamaCloudUsageCookie: string;
alibabaConsoleCookie: string;
alibabaConsoleSecToken: string;
@@ -23,8 +19,6 @@ export type QuotaScrapingFieldValues = {
};
export const EMPTY_QUOTA_SCRAPING_FIELDS: QuotaScrapingFieldValues = {
opencodeGoWorkspaceId: "",
opencodeGoAuthCookie: "",
ollamaCloudUsageCookie: "",
alibabaConsoleCookie: "",
alibabaConsoleSecToken: "",
@@ -37,12 +31,7 @@ export function assignQuotaScrapingProviderData(
values: QuotaScrapingFieldValues,
target: Record<string, unknown>
) {
if (provider === "opencode-go") {
target.opencodeGoWorkspaceId = values.opencodeGoWorkspaceId.trim() || undefined;
if (values.opencodeGoAuthCookie.trim()) {
target.opencodeGoAuthCookie = values.opencodeGoAuthCookie.trim();
}
} else if (provider === "ollama-cloud" && values.ollamaCloudUsageCookie.trim()) {
if (provider === "ollama-cloud" && values.ollamaCloudUsageCookie.trim()) {
target.ollamaCloudUsageCookie = values.ollamaCloudUsageCookie.trim();
} else if (
(provider === "alibaba" || provider === "alibaba-cn") &&