| type JsonRecord = Record<string, unknown>;
|
|
|
| |
| |
| |
| |
| |
|
|
| export const CLAUDE_FAST_MODE_DEFAULT_MODELS = [
|
| "claude-opus-4-8",
|
| "claude-opus-4-7",
|
| "claude-opus-4-6",
|
| ] as const;
|
|
|
| function asRecord(value: unknown): JsonRecord {
|
| return value && typeof value === "object" && !Array.isArray(value) ? (value as JsonRecord) : {};
|
| }
|
|
|
| function asStringArray(value: unknown): string[] | null {
|
| if (!Array.isArray(value)) return null;
|
| const out: string[] = [];
|
| for (const item of value) {
|
| if (typeof item === "string" && item.trim().length > 0) out.push(item.trim());
|
| }
|
| return out;
|
| }
|
|
|
| |
| |
| |
| |
| |
| |
| |
|
|
| export function isClaudeFastModeEnabled(settings: unknown): boolean {
|
| const record = asRecord(settings);
|
| const claudeFastMode = record.claudeFastMode;
|
| if (typeof claudeFastMode === "boolean") return claudeFastMode;
|
| const claudeFastModeRecord = asRecord(claudeFastMode);
|
| return claudeFastModeRecord.enabled === true;
|
| }
|
|
|
| |
| |
| |
|
|
| export function getClaudeFastModeSupportedModels(settings: unknown): string[] {
|
| const record = asRecord(settings);
|
| const claudeFastMode = asRecord(record.claudeFastMode);
|
| const fromSettings = asStringArray(claudeFastMode.supportedModels);
|
| if (fromSettings && fromSettings.length > 0) return fromSettings;
|
| return [...CLAUDE_FAST_MODE_DEFAULT_MODELS];
|
| }
|
|
|
| |
| |
| |
|
|
| export function shouldRequestClaudeFastMode(
|
| settings: unknown,
|
| modelId: string | null | undefined
|
| ): boolean {
|
| if (!isClaudeFastModeEnabled(settings)) return false;
|
| if (typeof modelId !== "string" || modelId.length === 0) return false;
|
| const supported = getClaudeFastModeSupportedModels(settings);
|
| return supported.some((m) => modelId === m || modelId.startsWith(`${m}-`));
|
| }
|
|
|
| |
| |
| |
|
|
| export const CPA_FORCE_FAST_MODE_HEADER = "X-CPA-Force-Fast-Mode";
|
|
|