model: restore Claude catalogs on sibling stack
Co-authored-by: codex <[email protected]>
This commit is contained in:
1 parent
7613142c48
commit
6e6083ca2f
3 files changed
+75
-39
No files matched your search
@@ -1,4 +1,5 @@
|
||||
import { Schema } from "effect";
|
||||
import type { ProviderKind } from "./orchestration";
|
||||
|
||||
export const CURSOR_REASONING_OPTIONS = ["low", "normal", "high", "xhigh"] as const;
|
||||
export type CursorReasoningOption = (typeof CURSOR_REASONING_OPTIONS)[number];
|
||||
@@ -63,6 +64,11 @@ export const MODEL_OPTIONS_BY_PROVIDER = {
|
||||
{ slug: "gpt-5.2-codex", name: "GPT-5.2 Codex" },
|
||||
{ slug: "gpt-5.2", name: "GPT-5.2" },
|
||||
],
|
||||
claudeCode: [
|
||||
{ slug: "claude-opus-4-6", name: "Claude Opus 4.6" },
|
||||
{ slug: "claude-sonnet-4-6", name: "Claude Sonnet 4.6" },
|
||||
{ slug: "claude-haiku-4-5", name: "Claude Haiku 4.5" },
|
||||
],
|
||||
cursor: [
|
||||
{ slug: "auto", name: "Auto" },
|
||||
{ slug: "composer-1.5", name: "Composer 1.5" },
|
||||
@@ -84,23 +90,23 @@ export const MODEL_OPTIONS_BY_PROVIDER = {
|
||||
{ slug: "sonnet-4.6-thinking", name: "Claude 4.6 Sonnet (Thinking)" },
|
||||
{ slug: "gemini-3.1-pro", name: "Gemini 3.1 Pro" },
|
||||
],
|
||||
} as const satisfies Record<"codex" | "cursor", readonly ModelOption[]>;
|
||||
} as const satisfies Record<ProviderKind, readonly ModelOption[]>;
|
||||
|
||||
type BuiltInModelSlug =
|
||||
(typeof MODEL_OPTIONS_BY_PROVIDER)[keyof typeof MODEL_OPTIONS_BY_PROVIDER][number]["slug"];
|
||||
type BuiltInModelSlug = (typeof MODEL_OPTIONS_BY_PROVIDER)[ProviderKind][number]["slug"];
|
||||
export type ModelSlug = BuiltInModelSlug | (string & {});
|
||||
export type CursorModelSlug = (typeof MODEL_OPTIONS_BY_PROVIDER)["cursor"][number]["slug"];
|
||||
|
||||
export const DEFAULT_MODEL_BY_PROVIDER = {
|
||||
export const DEFAULT_MODEL_BY_PROVIDER: Record<ProviderKind, ModelSlug> = {
|
||||
codex: "gpt-5.3-codex",
|
||||
claudeCode: "claude-sonnet-4-6",
|
||||
cursor: "opus-4.6-thinking",
|
||||
} as const satisfies Record<keyof typeof MODEL_OPTIONS_BY_PROVIDER, ModelSlug>;
|
||||
};
|
||||
|
||||
// Backward compatibility for existing Codex-only call sites.
|
||||
export const MODEL_OPTIONS = MODEL_OPTIONS_BY_PROVIDER.codex;
|
||||
export const DEFAULT_MODEL = DEFAULT_MODEL_BY_PROVIDER.codex;
|
||||
|
||||
export const MODEL_SLUG_ALIASES_BY_PROVIDER = {
|
||||
export const MODEL_SLUG_ALIASES_BY_PROVIDER: Record<ProviderKind, Record<string, ModelSlug>> = {
|
||||
codex: {
|
||||
"5.4": "gpt-5.4",
|
||||
"5.3": "gpt-5.3-codex",
|
||||
@@ -108,6 +114,20 @@ export const MODEL_SLUG_ALIASES_BY_PROVIDER = {
|
||||
"5.3-spark": "gpt-5.3-codex-spark",
|
||||
"gpt-5.3-spark": "gpt-5.3-codex-spark",
|
||||
},
|
||||
claudeCode: {
|
||||
opus: "claude-opus-4-6",
|
||||
"opus-4.6": "claude-opus-4-6",
|
||||
"claude-opus-4.6": "claude-opus-4-6",
|
||||
"claude-opus-4-6-20251117": "claude-opus-4-6",
|
||||
sonnet: "claude-sonnet-4-6",
|
||||
"sonnet-4.6": "claude-sonnet-4-6",
|
||||
"claude-sonnet-4.6": "claude-sonnet-4-6",
|
||||
"claude-sonnet-4-6-20251117": "claude-sonnet-4-6",
|
||||
haiku: "claude-haiku-4-5",
|
||||
"haiku-4.5": "claude-haiku-4-5",
|
||||
"claude-haiku-4.5": "claude-haiku-4-5",
|
||||
"claude-haiku-4-5-20251001": "claude-haiku-4-5",
|
||||
},
|
||||
cursor: {
|
||||
composer: "composer-1.5",
|
||||
"composer-1.5": "composer-1.5",
|
||||
@@ -122,17 +142,16 @@ export const MODEL_SLUG_ALIASES_BY_PROVIDER = {
|
||||
"opus-4.6-thinking": "opus-4.6-thinking",
|
||||
"opus-4.5-thinking": "opus-4.5-thinking",
|
||||
},
|
||||
} as const satisfies Record<keyof typeof MODEL_OPTIONS_BY_PROVIDER, Record<string, ModelSlug>>;
|
||||
};
|
||||
|
||||
export const REASONING_EFFORT_OPTIONS_BY_PROVIDER = {
|
||||
codex: CODEX_REASONING_EFFORT_OPTIONS,
|
||||
claudeCode: [],
|
||||
cursor: [],
|
||||
} as const satisfies Record<
|
||||
keyof typeof MODEL_OPTIONS_BY_PROVIDER,
|
||||
readonly CodexReasoningEffort[]
|
||||
>;
|
||||
} as const satisfies Record<ProviderKind, readonly CodexReasoningEffort[]>;
|
||||
|
||||
export const DEFAULT_REASONING_EFFORT_BY_PROVIDER = {
|
||||
codex: "high",
|
||||
claudeCode: null,
|
||||
cursor: null,
|
||||
} as const satisfies Record<keyof typeof MODEL_OPTIONS_BY_PROVIDER, CodexReasoningEffort | null>;
|
||||
} as const satisfies Record<ProviderKind, CodexReasoningEffort | null>;
|
||||
@@ -4,8 +4,10 @@ import {
|
||||
CURSOR_REASONING_OPTIONS,
|
||||
DEFAULT_MODEL,
|
||||
DEFAULT_MODEL_BY_PROVIDER,
|
||||
DEFAULT_REASONING_EFFORT_BY_PROVIDER,
|
||||
MODEL_OPTIONS,
|
||||
MODEL_OPTIONS_BY_PROVIDER,
|
||||
REASONING_EFFORT_OPTIONS_BY_PROVIDER,
|
||||
} from "../../contracts/src";
|
||||
|
||||
import {
|
||||
@@ -40,6 +42,11 @@ describe("normalizeModelSlug", () => {
|
||||
});
|
||||
|
||||
it("uses provider-specific aliases", () => {
|
||||
expect(normalizeModelSlug("sonnet", "claudeCode")).toBe("claude-sonnet-4-6");
|
||||
expect(normalizeModelSlug("opus-4.6", "claudeCode")).toBe("claude-opus-4-6");
|
||||
expect(normalizeModelSlug("claude-haiku-4-5-20251001", "claudeCode")).toBe(
|
||||
"claude-haiku-4-5",
|
||||
);
|
||||
expect(normalizeModelSlug("composer", "cursor")).toBe("composer-1.5");
|
||||
expect(normalizeModelSlug("gpt-5.3-codex-spark", "cursor")).toBe(
|
||||
"gpt-5.3-codex-spark-preview",
|
||||
@@ -69,6 +76,13 @@ describe("resolveModelSlug", () => {
|
||||
});
|
||||
|
||||
it("supports provider-aware resolution", () => {
|
||||
expect(resolveModelSlugForProvider("claudeCode", undefined)).toBe(
|
||||
DEFAULT_MODEL_BY_PROVIDER.claudeCode,
|
||||
);
|
||||
expect(resolveModelSlugForProvider("claudeCode", "sonnet")).toBe("claude-sonnet-4-6");
|
||||
expect(resolveModelSlugForProvider("claudeCode", "gpt-5.3-codex")).toBe(
|
||||
DEFAULT_MODEL_BY_PROVIDER.claudeCode,
|
||||
);
|
||||
expect(resolveModelSlugForProvider("cursor", undefined)).toBe(
|
||||
DEFAULT_MODEL_BY_PROVIDER.cursor,
|
||||
);
|
||||
@@ -84,6 +98,7 @@ describe("resolveModelSlug", () => {
|
||||
it("keeps codex defaults for backward compatibility", () => {
|
||||
expect(getDefaultModel()).toBe(DEFAULT_MODEL);
|
||||
expect(getModelOptions()).toEqual(MODEL_OPTIONS);
|
||||
expect(getModelOptions("claudeCode")).toEqual(MODEL_OPTIONS_BY_PROVIDER.claudeCode);
|
||||
expect(getModelOptions("cursor")).toEqual(MODEL_OPTIONS_BY_PROVIDER.cursor);
|
||||
expect(getCursorModelFamilyOptions()).toEqual(CURSOR_MODEL_FAMILY_OPTIONS);
|
||||
});
|
||||
@@ -136,7 +151,13 @@ describe("cursor model selection", () => {
|
||||
|
||||
describe("getReasoningEffortOptions", () => {
|
||||
it("returns codex reasoning options for codex", () => {
|
||||
expect(getReasoningEffortOptions("codex")).toEqual(["xhigh", "high", "medium", "low"]);
|
||||
expect(getReasoningEffortOptions("codex")).toEqual(
|
||||
REASONING_EFFORT_OPTIONS_BY_PROVIDER.codex,
|
||||
);
|
||||
});
|
||||
|
||||
it("returns no reasoning options for claudeCode", () => {
|
||||
expect(getReasoningEffortOptions("claudeCode")).toEqual([]);
|
||||
});
|
||||
|
||||
it("returns no reasoning options for cursor", () => {
|
||||
@@ -146,7 +167,14 @@ describe("getReasoningEffortOptions", () => {
|
||||
|
||||
describe("getDefaultReasoningEffort", () => {
|
||||
it("returns provider-scoped defaults", () => {
|
||||
expect(getDefaultReasoningEffort("codex")).toBe("high");
|
||||
expect(getDefaultReasoningEffort("cursor")).toBeNull();
|
||||
expect(getDefaultReasoningEffort("codex")).toBe(
|
||||
DEFAULT_REASONING_EFFORT_BY_PROVIDER.codex,
|
||||
);
|
||||
expect(getDefaultReasoningEffort("claudeCode")).toBe(
|
||||
DEFAULT_REASONING_EFFORT_BY_PROVIDER.claudeCode,
|
||||
);
|
||||
expect(getDefaultReasoningEffort("cursor")).toBe(
|
||||
DEFAULT_REASONING_EFFORT_BY_PROVIDER.cursor,
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -2,10 +2,11 @@ import {
|
||||
CODEX_REASONING_EFFORT_OPTIONS,
|
||||
CURSOR_MODEL_FAMILY_OPTIONS,
|
||||
CURSOR_REASONING_OPTIONS,
|
||||
DEFAULT_MODEL,
|
||||
DEFAULT_MODEL_BY_PROVIDER,
|
||||
DEFAULT_REASONING_EFFORT_BY_PROVIDER,
|
||||
MODEL_OPTIONS_BY_PROVIDER,
|
||||
MODEL_SLUG_ALIASES_BY_PROVIDER,
|
||||
REASONING_EFFORT_OPTIONS_BY_PROVIDER,
|
||||
type CodexReasoningEffort,
|
||||
type CursorModelFamily,
|
||||
type CursorModelSlug,
|
||||
@@ -14,8 +15,6 @@ import {
|
||||
type ProviderKind,
|
||||
} from "../../contracts/src";
|
||||
|
||||
type CatalogProvider = keyof typeof MODEL_OPTIONS_BY_PROVIDER;
|
||||
|
||||
type CursorModelCapability = {
|
||||
readonly supportsReasoning: boolean;
|
||||
readonly supportsFast: boolean;
|
||||
@@ -90,11 +89,8 @@ const CURSOR_MODEL_CAPABILITY_BY_FAMILY: Record<CursorModelFamily, CursorModelCa
|
||||
},
|
||||
};
|
||||
|
||||
function hasModelCatalog(provider: ProviderKind): provider is CatalogProvider {
|
||||
return Object.hasOwn(MODEL_OPTIONS_BY_PROVIDER, provider);
|
||||
}
|
||||
|
||||
const MODEL_SLUG_SET_BY_PROVIDER: Record<CatalogProvider, ReadonlySet<ModelSlug>> = {
|
||||
const MODEL_SLUG_SET_BY_PROVIDER: Record<ProviderKind, ReadonlySet<ModelSlug>> = {
|
||||
claudeCode: new Set(MODEL_OPTIONS_BY_PROVIDER.claudeCode.map((option) => option.slug)),
|
||||
codex: new Set(MODEL_OPTIONS_BY_PROVIDER.codex.map((option) => option.slug)),
|
||||
cursor: new Set(MODEL_OPTIONS_BY_PROVIDER.cursor.map((option) => option.slug)),
|
||||
};
|
||||
@@ -111,7 +107,7 @@ export interface CursorModelSelection {
|
||||
}
|
||||
|
||||
export function getModelOptions(provider: ProviderKind = "codex") {
|
||||
return hasModelCatalog(provider) ? MODEL_OPTIONS_BY_PROVIDER[provider] : [];
|
||||
return MODEL_OPTIONS_BY_PROVIDER[provider];
|
||||
}
|
||||
|
||||
export function getCursorModelFamilyOptions() {
|
||||
@@ -227,7 +223,7 @@ export function resolveCursorModelFromSelection(input: {
|
||||
}
|
||||
|
||||
export function getDefaultModel(provider: ProviderKind = "codex"): ModelSlug {
|
||||
return hasModelCatalog(provider) ? DEFAULT_MODEL_BY_PROVIDER[provider] : DEFAULT_MODEL;
|
||||
return DEFAULT_MODEL_BY_PROVIDER[provider];
|
||||
}
|
||||
|
||||
export function normalizeModelSlug(
|
||||
@@ -243,12 +239,7 @@ export function normalizeModelSlug(
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!hasModelCatalog(provider)) {
|
||||
return trimmed as ModelSlug;
|
||||
}
|
||||
|
||||
const aliases = MODEL_SLUG_ALIASES_BY_PROVIDER[provider] as Record<string, ModelSlug>;
|
||||
return aliases[trimmed] ?? (trimmed as ModelSlug);
|
||||
return MODEL_SLUG_ALIASES_BY_PROVIDER[provider][trimmed] ?? (trimmed as ModelSlug);
|
||||
}
|
||||
|
||||
export function resolveModelSlug(
|
||||
@@ -257,14 +248,12 @@ export function resolveModelSlug(
|
||||
): ModelSlug {
|
||||
const normalized = normalizeModelSlug(model, provider);
|
||||
if (!normalized) {
|
||||
return getDefaultModel(provider);
|
||||
return DEFAULT_MODEL_BY_PROVIDER[provider];
|
||||
}
|
||||
|
||||
if (!hasModelCatalog(provider)) {
|
||||
return getDefaultModel(provider);
|
||||
}
|
||||
|
||||
return MODEL_SLUG_SET_BY_PROVIDER[provider].has(normalized) ? normalized : getDefaultModel(provider);
|
||||
return MODEL_SLUG_SET_BY_PROVIDER[provider].has(normalized)
|
||||
? normalized
|
||||
: DEFAULT_MODEL_BY_PROVIDER[provider];
|
||||
}
|
||||
|
||||
export function resolveModelSlugForProvider(
|
||||
@@ -277,7 +266,7 @@ export function resolveModelSlugForProvider(
|
||||
export function getReasoningEffortOptions(
|
||||
provider: ProviderKind = "codex",
|
||||
): ReadonlyArray<CodexReasoningEffort> {
|
||||
return provider === "codex" ? CODEX_REASONING_EFFORT_OPTIONS : [];
|
||||
return REASONING_EFFORT_OPTIONS_BY_PROVIDER[provider];
|
||||
}
|
||||
|
||||
export function getDefaultReasoningEffort(provider: "codex"): CodexReasoningEffort;
|
||||
@@ -285,7 +274,7 @@ export function getDefaultReasoningEffort(provider: ProviderKind): CodexReasonin
|
||||
export function getDefaultReasoningEffort(
|
||||
provider: ProviderKind = "codex",
|
||||
): CodexReasoningEffort | null {
|
||||
return provider === "codex" ? "high" : null;
|
||||
return DEFAULT_REASONING_EFFORT_BY_PROVIDER[provider];
|
||||
}
|
||||
|
||||
export { CODEX_REASONING_EFFORT_OPTIONS };
|
||||
Reference in new issue
Block a user