mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-02 10:20:23 +08:00
* feat(codex): persist managed reasoning effort overrides * fix(codex): protect managed catalog refresh state * feat(codex): allow user reasoning overrides Expose only owner-scoped managed Codex model metadata and validate updates against provider-supported reasoning levels. Add ordinary-user settings controls without granting model catalog or provider administration access. * fix(codex): bind reasoning overrides to OAuth account Persist only a one-way account binding on managed Codex profiles. Hide and reject stale or legacy-unbound reasoning controls until a successful catalog refresh, and do not carry overrides across account switches. * fix(codex): reject stale cross-account overrides * fix(codex): isolate account switches at runtime
49 lines
1.5 KiB
TypeScript
49 lines
1.5 KiB
TypeScript
import type {
|
|
CatalogProfile,
|
|
ProviderOption,
|
|
ServiceName,
|
|
} from "./SettingsContext";
|
|
|
|
/** The tag the backend stamps on the profile its Codex OAuth service owns. */
|
|
export const CODEX_MANAGED_BY = "openai_codex_oauth";
|
|
|
|
/** Profiles written by the Codex OAuth service are read-only in the settings form. */
|
|
export function isManagedCodexProfile(
|
|
profile: Pick<CatalogProfile, "managed_by"> | null | undefined,
|
|
): boolean {
|
|
return profile?.managed_by === CODEX_MANAGED_BY;
|
|
}
|
|
|
|
/** A managed profile may accept reasoning overrides only after an account-bound refresh. */
|
|
export function isBoundManagedCodexProfile(
|
|
profile:
|
|
| Pick<CatalogProfile, "managed_by" | "codex_account_binding">
|
|
| null
|
|
| undefined,
|
|
): boolean {
|
|
return (
|
|
isManagedCodexProfile(profile) &&
|
|
typeof profile?.codex_account_binding === "string" &&
|
|
Boolean(profile.codex_account_binding.trim())
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Whether a profile authenticates through Codex OAuth instead of typed credentials.
|
|
*
|
|
* A managed profile qualifies even before the provider list has loaded, so a
|
|
* reload can never briefly render API-key fields over an OAuth-only profile.
|
|
*/
|
|
export function isCodexOAuthProfile(
|
|
service: ServiceName,
|
|
providerValue: string,
|
|
providerOption: Pick<ProviderOption, "auth_mode"> | undefined,
|
|
profile: Pick<CatalogProfile, "managed_by"> | null | undefined,
|
|
): boolean {
|
|
return (
|
|
service === "llm" &&
|
|
providerValue === "openai_codex" &&
|
|
(providerOption?.auth_mode === "oauth" || isManagedCodexProfile(profile))
|
|
);
|
|
}
|