+36
![github-actions[bot]](/assets/img/avatar_default.png)








Julius Marminge
maria-rcks
Bilal Bakr
shivam
Vitalii Yehorov
Jake Leventhal
Claude Opus 5
Alex Southwell
github-actions[bot]
Nicholas Wasmiller
PB
Exotic
Yash Singh
Devin
Theo Browne
Gabriel De Andrade
Dara Adedeji
scratchyone
Dominic Roy
chukfinley
Primož Ajdišek
benthecarman
NaveDanan
aaditagrawal
Aditya Garud
Nick Anisimov
MacKinley Smith
Yordis Prieto
t3-code[bot]
AKolenda
Guillermo Casanova
Otavio Salvador
Shirish Pothi
Ishaan Kothari
Bob Fowler
Anton Bezdenezhnykh
ValeraZSD
Ephraim
Ryan Ilano
Alex
maco
Cursor
Tristan Knight
PR Batch Tester
oliver
kamkm
de34391427
Co-authored-by: maria-rcks <[email protected]> Co-authored-by: Bilal Bakr <[email protected]> Co-authored-by: shivam <[email protected]> Co-authored-by: Vitalii Yehorov <[email protected]> Co-authored-by: Jake Leventhal <[email protected]> Co-authored-by: Claude Opus 5 (1M context) <[email protected]> Co-authored-by: Alex Southwell <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Nicholas Wasmiller <[email protected]> Co-authored-by: PB <[email protected]> Co-authored-by: Exotic <[email protected]> Co-authored-by: Yash Singh <[email protected]> Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Theo Browne <[email protected]> Co-authored-by: Gabriel De Andrade <[email protected]> Co-authored-by: Dara Adedeji <[email protected]> Co-authored-by: scratchyone <[email protected]> Co-authored-by: Dominic Roy <[email protected]> Co-authored-by: chukfinley <[email protected]> Co-authored-by: Primož Ajdišek <[email protected]> Co-authored-by: benthecarman <[email protected]> Co-authored-by: NaveDanan <[email protected]> Co-authored-by: aaditagrawal <[email protected]> Co-authored-by: Aditya Garud <[email protected]> Co-authored-by: Nick Anisimov <[email protected]> Co-authored-by: MacKinley Smith <[email protected]> Co-authored-by: Yordis Prieto <[email protected]> Co-authored-by: t3-code[bot] <269035359+t3-code[bot]@users.noreply.github.com> Co-authored-by: AKolenda <[email protected]> Co-authored-by: Guillermo Casanova <[email protected]> Co-authored-by: Otavio Salvador <[email protected]> Co-authored-by: Shirish Pothi <[email protected]> Co-authored-by: Ishaan Kothari <[email protected]> Co-authored-by: Bob Fowler <[email protected]> Co-authored-by: Anton Bezdenezhnykh <[email protected]> Co-authored-by: ValeraZSD <[email protected]> Co-authored-by: Ephraim <[email protected]> Co-authored-by: Ryan Ilano <[email protected]> Co-authored-by: Alex <[email protected]> Co-authored-by: maco <[email protected]> Co-authored-by: Cursor <[email protected]> Co-authored-by: Tristan Knight <[email protected]> Co-authored-by: PR Batch Tester <[email protected]> Co-authored-by: oliver <[email protected]> Co-authored-by: kamkm <[email protected]> Signed-off-by: Yordis Prieto <[email protected]>
305 lines
9.6 KiB
TypeScript
305 lines
9.6 KiB
TypeScript
import { describe, expect, it } from "vite-plus/test";
|
|
import { ProviderDriverKind, ProviderInstanceId, type ModelCapabilities } from "@t3tools/contracts";
|
|
|
|
import {
|
|
applyClaudePromptEffortPrefix,
|
|
buildExplicitProviderOptionSelectionsFromDescriptors,
|
|
buildProviderOptionSelectionsFromDescriptors,
|
|
createModelCapabilities,
|
|
createModelSelection,
|
|
formatCodexModelName,
|
|
formatModelSlugName,
|
|
getModelSelectionBooleanOptionValue,
|
|
getModelSelectionStringOptionValue,
|
|
getProviderOptionDescriptors,
|
|
readCustomModelEntries,
|
|
toCustomModelSetting,
|
|
getProviderOptionBooleanSelectionValue,
|
|
getProviderOptionStringSelectionValue,
|
|
normalizeCustomModelSlug,
|
|
normalizeModelSlug,
|
|
modelSelectionsEqual,
|
|
} from "./model.ts";
|
|
|
|
it("keeps the Codex catalog display formatting", () => {
|
|
expect(formatCodexModelName("gpt-5.3-codex-spark")).toBe("GPT-5.3-Codex-Spark");
|
|
expect(formatCodexModelName("GPT Test")).toBe("GPT Test");
|
|
});
|
|
|
|
it.each([
|
|
["gpt-5.4", "GPT-5.4"],
|
|
["claude-opus-4-6", "Claude Opus 4.6"],
|
|
["claude-sonnet-4-20250514", "Claude Sonnet 4 20250514"],
|
|
["claude-opus-4-6[1m]", "Claude Opus 4.6[1m]"],
|
|
["openai/gpt-5.4-mini", "openai/GPT-5.4-Mini"],
|
|
["gemini-2.5-pro-preview-06-05", "Gemini 2.5 Pro Preview 06 05"],
|
|
["custom/model-v2", "custom/model-v2"],
|
|
["gpt-proxy", "gpt-proxy"],
|
|
["My Custom Model", "My Custom Model"],
|
|
])("formats a known model ID without losing its qualifiers: %s", (slug, expected) => {
|
|
expect(formatModelSlugName(slug)).toBe(expected);
|
|
});
|
|
|
|
const codexCaps: ModelCapabilities = createModelCapabilities({
|
|
optionDescriptors: [
|
|
{
|
|
id: "reasoningEffort",
|
|
label: "Reasoning",
|
|
type: "select",
|
|
options: [
|
|
{ id: "xhigh", label: "Extra High" },
|
|
{ id: "high", label: "High", isDefault: true },
|
|
],
|
|
currentValue: "high",
|
|
},
|
|
{
|
|
id: "fastMode",
|
|
label: "Fast Mode",
|
|
type: "boolean",
|
|
},
|
|
],
|
|
});
|
|
|
|
describe("model slug normalization", () => {
|
|
it("preserves exact custom slugs instead of expanding provider aliases", () => {
|
|
// Claude aliases now resolve through the model catalog (#9084), so the
|
|
// provider alias table passes unknown slugs through unchanged.
|
|
const claude = ProviderDriverKind.make("claudeAgent");
|
|
|
|
expect(normalizeModelSlug("opus", claude)).toBe("opus");
|
|
expect(normalizeCustomModelSlug(" opus ")).toBe("opus");
|
|
});
|
|
});
|
|
|
|
const claudeCaps: ModelCapabilities = createModelCapabilities({
|
|
optionDescriptors: [
|
|
{
|
|
id: "effort",
|
|
label: "Reasoning",
|
|
type: "select",
|
|
options: [
|
|
{ id: "medium", label: "Medium" },
|
|
{ id: "high", label: "High", isDefault: true },
|
|
{ id: "ultrathink", label: "Ultrathink" },
|
|
],
|
|
currentValue: "high",
|
|
promptInjectedValues: ["ultrathink"],
|
|
},
|
|
{
|
|
id: "contextWindow",
|
|
label: "Context Window",
|
|
type: "select",
|
|
options: [
|
|
{ id: "200k", label: "200k" },
|
|
{ id: "1m", label: "1M", isDefault: true },
|
|
],
|
|
currentValue: "1m",
|
|
},
|
|
],
|
|
});
|
|
|
|
describe("descriptor helpers", () => {
|
|
it("applies selection values to capability descriptors", () => {
|
|
expect(
|
|
getProviderOptionDescriptors({
|
|
caps: claudeCaps,
|
|
selections: [
|
|
{ id: "effort", value: "medium" },
|
|
{ id: "contextWindow", value: "200k" },
|
|
],
|
|
}),
|
|
).toEqual([
|
|
{
|
|
id: "effort",
|
|
label: "Reasoning",
|
|
type: "select",
|
|
options: [
|
|
{ id: "medium", label: "Medium" },
|
|
{ id: "high", label: "High", isDefault: true },
|
|
{ id: "ultrathink", label: "Ultrathink" },
|
|
],
|
|
currentValue: "medium",
|
|
promptInjectedValues: ["ultrathink"],
|
|
},
|
|
{
|
|
id: "contextWindow",
|
|
label: "Context Window",
|
|
type: "select",
|
|
options: [
|
|
{ id: "200k", label: "200k" },
|
|
{ id: "1m", label: "1M", isDefault: true },
|
|
],
|
|
currentValue: "200k",
|
|
},
|
|
]);
|
|
});
|
|
|
|
it("builds wire-format option selections from descriptors", () => {
|
|
const descriptors = getProviderOptionDescriptors({
|
|
caps: codexCaps,
|
|
selections: [
|
|
{ id: "reasoningEffort", value: "high" },
|
|
{ id: "fastMode", value: true },
|
|
],
|
|
});
|
|
|
|
expect(buildProviderOptionSelectionsFromDescriptors(descriptors)).toEqual([
|
|
{ id: "reasoningEffort", value: "high" },
|
|
{ id: "fastMode", value: true },
|
|
]);
|
|
});
|
|
|
|
it("builds dispatch options only from explicit selections", () => {
|
|
const descriptors = getProviderOptionDescriptors({
|
|
caps: codexCaps,
|
|
selections: [{ id: "fastMode", value: true }],
|
|
});
|
|
|
|
expect(buildExplicitProviderOptionSelectionsFromDescriptors(descriptors, undefined)).toBe(
|
|
undefined,
|
|
);
|
|
expect(
|
|
buildExplicitProviderOptionSelectionsFromDescriptors(descriptors, [
|
|
{ id: "fastMode", value: true },
|
|
]),
|
|
).toEqual([{ id: "fastMode", value: true }]);
|
|
});
|
|
|
|
it("stores option selection arrays in model selections", () => {
|
|
expect(
|
|
createModelSelection(ProviderInstanceId.make("codex"), "gpt-5.4", [
|
|
{ id: "reasoningEffort", value: "high" },
|
|
{ id: "fastMode", value: true },
|
|
]),
|
|
).toEqual({
|
|
instanceId: "codex",
|
|
model: "gpt-5.4",
|
|
options: [
|
|
{ id: "reasoningEffort", value: "high" },
|
|
{ id: "fastMode", value: true },
|
|
],
|
|
});
|
|
});
|
|
|
|
it("reads typed option selection values", () => {
|
|
const selection = createModelSelection(ProviderInstanceId.make("codex"), "gpt-5.4", [
|
|
{ id: "reasoningEffort", value: "high" },
|
|
{ id: "fastMode", value: true },
|
|
]);
|
|
|
|
expect(getProviderOptionStringSelectionValue(selection.options, "reasoningEffort")).toBe(
|
|
"high",
|
|
);
|
|
expect(getProviderOptionStringSelectionValue(selection.options, "fastMode")).toBeUndefined();
|
|
expect(getProviderOptionBooleanSelectionValue(selection.options, "fastMode")).toBe(true);
|
|
expect(
|
|
getProviderOptionBooleanSelectionValue(selection.options, "reasoningEffort"),
|
|
).toBeUndefined();
|
|
expect(getModelSelectionStringOptionValue(selection, "reasoningEffort")).toBe("high");
|
|
expect(getModelSelectionBooleanOptionValue(selection, "fastMode")).toBe(true);
|
|
});
|
|
|
|
it("compares complete model selections independent of option ordering", () => {
|
|
const left = createModelSelection(ProviderInstanceId.make("codex"), "gpt-5.4", [
|
|
{ id: "reasoningEffort", value: "high" },
|
|
{ id: "fastMode", value: true },
|
|
]);
|
|
const reordered = createModelSelection(ProviderInstanceId.make("codex"), "gpt-5.4", [
|
|
{ id: "fastMode", value: true },
|
|
{ id: "reasoningEffort", value: "high" },
|
|
]);
|
|
|
|
expect(modelSelectionsEqual(left, reordered)).toBe(true);
|
|
expect(
|
|
modelSelectionsEqual(left, {
|
|
...reordered,
|
|
options: [
|
|
{ id: "fastMode", value: true },
|
|
{ id: "reasoningEffort", value: "medium" },
|
|
],
|
|
}),
|
|
).toBe(false);
|
|
expect(modelSelectionsEqual(left, { ...reordered, model: "gpt-5.5" })).toBe(false);
|
|
});
|
|
});
|
|
|
|
describe("applyClaudePromptEffortPrefix", () => {
|
|
it("keeps slash commands intact when ultrathink is selected", () => {
|
|
expect(applyClaudePromptEffortPrefix("/compact", "ultrathink")).toBe("/compact");
|
|
expect(applyClaudePromptEffortPrefix(" /compact keep recent errors ", "ultrathink")).toBe(
|
|
"/compact keep recent errors",
|
|
);
|
|
expect(applyClaudePromptEffortPrefix(" /review src/model.ts ", "ultrathink")).toBe(
|
|
"/review src/model.ts",
|
|
);
|
|
expect(applyClaudePromptEffortPrefix("/security-review", "ultrathink")).toBe(
|
|
"/security-review",
|
|
);
|
|
expect(applyClaudePromptEffortPrefix("/plugin:skill run", "ultrathink")).toBe(
|
|
"/plugin:skill run",
|
|
);
|
|
expect(applyClaudePromptEffortPrefix("/deploy.prod to staging", "ultrathink")).toBe(
|
|
"/deploy.prod to staging",
|
|
);
|
|
});
|
|
|
|
it("still adds the ultrathink prefix to ordinary prompts", () => {
|
|
expect(applyClaudePromptEffortPrefix("Investigate this failure", "ultrathink")).toBe(
|
|
"Ultrathink:\nInvestigate this failure",
|
|
);
|
|
expect(applyClaudePromptEffortPrefix("/home/theo/app.ts crashed on load", "ultrathink")).toBe(
|
|
"Ultrathink:\n/home/theo/app.ts crashed on load",
|
|
);
|
|
});
|
|
});
|
|
|
|
describe("readCustomModelEntries", () => {
|
|
const capabilities: ModelCapabilities = {
|
|
optionDescriptors: [
|
|
{
|
|
id: "effort",
|
|
label: "Reasoning",
|
|
type: "select",
|
|
options: [{ id: "high", label: "High", isDefault: true }],
|
|
currentValue: "high",
|
|
},
|
|
],
|
|
};
|
|
|
|
it("resolves bare slugs and entries, trimming and deduplicating on slug", () => {
|
|
expect(
|
|
readCustomModelEntries([
|
|
" bare ",
|
|
{ slug: "named", name: " Named ", capabilities },
|
|
"bare",
|
|
{ slug: "named", name: "Second" },
|
|
"",
|
|
{ name: "no slug" },
|
|
42,
|
|
]),
|
|
).toEqual([
|
|
{ slug: "bare", name: "bare", capabilities: null },
|
|
{ slug: "named", name: "Named", capabilities },
|
|
]);
|
|
});
|
|
|
|
it("drops unparseable capabilities but keeps the entry", () => {
|
|
expect(
|
|
readCustomModelEntries([{ slug: "x", capabilities: { optionDescriptors: "nope" } }]),
|
|
).toEqual([{ slug: "x", name: "x", capabilities: null }]);
|
|
expect(readCustomModelEntries("not a list")).toEqual([]);
|
|
});
|
|
|
|
it("writes the compact stored shape back", () => {
|
|
expect(toCustomModelSetting({ slug: "x", name: "x", capabilities: null })).toBe("x");
|
|
expect(
|
|
toCustomModelSetting({ slug: "x", name: "x", capabilities: { optionDescriptors: [] } }),
|
|
).toBe("x");
|
|
expect(toCustomModelSetting({ slug: "x", name: "X", capabilities })).toEqual({
|
|
slug: "x",
|
|
name: "X",
|
|
capabilities,
|
|
});
|
|
});
|
|
});
|