Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5bd797e791 | ||
|
|
7b9eef7ac2 | ||
|
|
9d66b104fe | ||
|
|
51ea084c87 | ||
|
|
0615fd7df1 |
No files matched your search
@@ -607,6 +607,7 @@ export const make = Effect.gen(function* () {
|
||||
const backendExposure = yield* serverExposure.backendConfig;
|
||||
const persistedSettings = yield* settings.get;
|
||||
const shared = yield* sharedInputs;
|
||||
yield* wslEnvironment.preWarm(persistedSettings.wslDistro);
|
||||
return yield* resolveWslStartConfig({
|
||||
...shared,
|
||||
port: backendExposure.port,
|
||||
|
||||
@@ -193,6 +193,36 @@ const BUILT_IN_MODELS: ReadonlyArray<ServerProviderModel> = [
|
||||
],
|
||||
}),
|
||||
},
|
||||
{
|
||||
slug: "claude-sonnet-5",
|
||||
name: "Claude Sonnet 5",
|
||||
isCustom: false,
|
||||
capabilities: createModelCapabilities({
|
||||
optionDescriptors: [
|
||||
buildSelectOptionDescriptor({
|
||||
id: "effort",
|
||||
label: "Reasoning",
|
||||
options: [
|
||||
{ value: "low", label: "Low" },
|
||||
{ value: "medium", label: "Medium" },
|
||||
{ value: "high", label: "High", isDefault: true },
|
||||
{ value: "xhigh", label: "Extra High" },
|
||||
{ value: "max", label: "Max" },
|
||||
{ value: "ultrathink", label: "Ultrathink" },
|
||||
],
|
||||
promptInjectedValues: ["ultrathink"],
|
||||
}),
|
||||
buildSelectOptionDescriptor({
|
||||
id: "contextWindow",
|
||||
label: "Context Window",
|
||||
options: [
|
||||
{ value: "200k", label: "200k", isDefault: true },
|
||||
{ value: "1m", label: "1M" },
|
||||
],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
},
|
||||
{
|
||||
slug: "claude-sonnet-4-6",
|
||||
name: "Claude Sonnet 4.6",
|
||||
@@ -322,7 +352,12 @@ export function normalizeClaudeCliEffort(
|
||||
if (effort === "ultracode") {
|
||||
return "xhigh";
|
||||
}
|
||||
if (effort === "xhigh" && model !== "claude-fable-5" && model !== "claude-opus-4-8") {
|
||||
if (
|
||||
effort === "xhigh" &&
|
||||
model !== "claude-fable-5" &&
|
||||
model !== "claude-opus-4-8" &&
|
||||
model !== "claude-sonnet-5"
|
||||
) {
|
||||
return "max";
|
||||
}
|
||||
if (effort === "max" && model === "claude-sonnet-4-6") {
|
||||
|
||||
@@ -331,6 +331,19 @@ export function RightPanelTabs(props: RightPanelTabsProps) {
|
||||
},
|
||||
[props],
|
||||
);
|
||||
const handleTabMouseDown = useCallback((event: ReactMouseEvent) => {
|
||||
if (event.button !== 1) return;
|
||||
event.preventDefault();
|
||||
}, []);
|
||||
const handleTabAuxClick = useCallback(
|
||||
(event: ReactMouseEvent, surface: RightPanelSurface) => {
|
||||
if (event.button !== 1) return;
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
props.onCloseSurface(surface);
|
||||
},
|
||||
[props],
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
const activeTab = tabListRef.current?.querySelector<HTMLElement>("[data-active-tab='true']");
|
||||
@@ -367,6 +380,8 @@ export function RightPanelTabs(props: RightPanelTabsProps) {
|
||||
<div
|
||||
key={surface.id}
|
||||
data-active-tab={active}
|
||||
onMouseDown={handleTabMouseDown}
|
||||
onAuxClick={(event) => handleTabAuxClick(event, surface)}
|
||||
onContextMenu={(event) => void handleTabContextMenu(event, surface)}
|
||||
className={cn(
|
||||
"group flex h-7 min-w-25 max-w-44 shrink-0 items-center gap-1.5 rounded-md px-2 text-sm",
|
||||
|
||||
@@ -5,18 +5,7 @@ import {
|
||||
} from "@t3tools/contracts";
|
||||
import { resolveSelectableModel } from "@t3tools/shared/model";
|
||||
import { LegendList, type LegendListRef } from "@legendapp/list/react";
|
||||
import {
|
||||
type ChangeEvent,
|
||||
type KeyboardEvent as ReactKeyboardEvent,
|
||||
memo,
|
||||
useMemo,
|
||||
useState,
|
||||
useCallback,
|
||||
useEffect,
|
||||
useLayoutEffect,
|
||||
useRef,
|
||||
type RefObject,
|
||||
} from "react";
|
||||
import { memo, useMemo, useState, useCallback, useEffect, useLayoutEffect, useRef } from "react";
|
||||
import { SearchIcon } from "lucide-react";
|
||||
import { ModelListRow } from "./ModelListRow";
|
||||
import { ModelPickerSidebar } from "./ModelPickerSidebar";
|
||||
@@ -54,7 +43,9 @@ type ModelPickerItem = {
|
||||
|
||||
const EMPTY_MODEL_JUMP_LABELS = new Map<string, string>();
|
||||
|
||||
const normalizeModelSearchQuery = (value: string): string => value.trim();
|
||||
function normalizeModelPickerSearchQuery(value: string): string {
|
||||
return value.trim();
|
||||
}
|
||||
|
||||
// Split a `${instanceId}:${slug}` combobox key back into its pieces. Slugs
|
||||
// can contain colons (e.g. some vendor model ids), so we only split on the
|
||||
@@ -70,52 +61,74 @@ function splitInstanceModelKey(key: string): { instanceId: ProviderInstanceId; s
|
||||
};
|
||||
}
|
||||
|
||||
const ModelPickerSearchInput = memo(function ModelPickerSearchInput(props: {
|
||||
inputRef: RefObject<HTMLInputElement | null>;
|
||||
onSearchQueryChange: (query: string) => void;
|
||||
onRequestClose?: () => void;
|
||||
onSubmitHighlightedModel: () => boolean;
|
||||
function useModelPickerJumpShortcuts(input: {
|
||||
readonly keybindings: ResolvedKeybindingsConfig;
|
||||
readonly modelJumpModelKeys: ReadonlyArray<string>;
|
||||
readonly modelJumpShortcutContext: {
|
||||
readonly terminalFocus: false;
|
||||
readonly terminalOpen: boolean;
|
||||
readonly modelPickerOpen: true;
|
||||
};
|
||||
readonly onModelSelect: (modelSlug: string, instanceId: ProviderInstanceId) => void;
|
||||
}) {
|
||||
const { inputRef, onRequestClose, onSearchQueryChange, onSubmitHighlightedModel } = props;
|
||||
const [inputValue, setInputValue] = useState("");
|
||||
const lastNormalizedQueryRef = useRef("");
|
||||
const { keybindings, modelJumpModelKeys, modelJumpShortcutContext, onModelSelect } = input;
|
||||
|
||||
const handleChange = useCallback(
|
||||
(event: ChangeEvent<HTMLInputElement>) => {
|
||||
const nextValue = event.target.value;
|
||||
const nextNormalizedQuery = normalizeModelSearchQuery(nextValue);
|
||||
setInputValue(nextValue);
|
||||
if (lastNormalizedQueryRef.current === nextNormalizedQuery) {
|
||||
useEffect(() => {
|
||||
const onWindowKeyDown = (event: globalThis.KeyboardEvent) => {
|
||||
if (event.defaultPrevented || event.repeat) {
|
||||
return;
|
||||
}
|
||||
lastNormalizedQueryRef.current = nextNormalizedQuery;
|
||||
onSearchQueryChange(nextNormalizedQuery);
|
||||
},
|
||||
[onSearchQueryChange],
|
||||
);
|
||||
|
||||
const handleKeyDown = useCallback(
|
||||
(event: ReactKeyboardEvent<HTMLInputElement>) => {
|
||||
if (event.key === "Escape") {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
onRequestClose?.();
|
||||
const command = resolveShortcutCommand(event, keybindings, {
|
||||
platform: navigator.platform,
|
||||
context: modelJumpShortcutContext,
|
||||
});
|
||||
const jumpIndex = modelPickerJumpIndexFromCommand(command ?? "");
|
||||
if (jumpIndex === null) {
|
||||
return;
|
||||
}
|
||||
if (event.key === "Enter" && onSubmitHighlightedModel()) {
|
||||
(event as typeof event & { preventBaseUIHandler?: () => void }).preventBaseUIHandler?.();
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
const targetModelKey = modelJumpModelKeys[jumpIndex];
|
||||
if (!targetModelKey) {
|
||||
return;
|
||||
}
|
||||
const { instanceId, slug } = splitInstanceModelKey(targetModelKey);
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
},
|
||||
[onRequestClose, onSubmitHighlightedModel],
|
||||
);
|
||||
onModelSelect(slug, instanceId);
|
||||
};
|
||||
|
||||
window.addEventListener("keydown", onWindowKeyDown, true);
|
||||
|
||||
return () => {
|
||||
window.removeEventListener("keydown", onWindowKeyDown, true);
|
||||
};
|
||||
}, [keybindings, modelJumpModelKeys, modelJumpShortcutContext, onModelSelect]);
|
||||
}
|
||||
|
||||
function ModelPickerSearchInput(props: {
|
||||
readonly focusRequest: number;
|
||||
readonly onSearchQueryChange: (query: string) => void;
|
||||
readonly onRequestClose: (() => void) | undefined;
|
||||
readonly onHighlightedModelSelect: () => boolean;
|
||||
}) {
|
||||
const [rawSearchQuery, setRawSearchQuery] = useState("");
|
||||
const searchInputRef = useRef<HTMLInputElement>(null);
|
||||
const normalizedSearchQueryRef = useRef("");
|
||||
|
||||
useLayoutEffect(() => {
|
||||
searchInputRef.current?.focus({ preventScroll: true });
|
||||
const frame = window.requestAnimationFrame(() => {
|
||||
searchInputRef.current?.focus({ preventScroll: true });
|
||||
});
|
||||
return () => {
|
||||
window.cancelAnimationFrame(frame);
|
||||
};
|
||||
}, [props.focusRequest]);
|
||||
|
||||
return (
|
||||
<ComboboxInput
|
||||
ref={inputRef}
|
||||
ref={searchInputRef}
|
||||
className="[&_input]:h-6.5 [&_input]:font-sans [&_input]:leading-6.5"
|
||||
inputClassName="rounded-none bg-transparent text-sm"
|
||||
placeholder="Search models..."
|
||||
@@ -123,16 +136,39 @@ const ModelPickerSearchInput = memo(function ModelPickerSearchInput(props: {
|
||||
startAddon={
|
||||
<SearchIcon className="-translate-x-0.5 size-4 shrink-0 text-muted-foreground/55" />
|
||||
}
|
||||
value={inputValue}
|
||||
onChange={handleChange}
|
||||
onKeyDown={handleKeyDown}
|
||||
value={rawSearchQuery}
|
||||
onChange={(event) => {
|
||||
const nextRawSearchQuery = event.target.value;
|
||||
setRawSearchQuery(nextRawSearchQuery);
|
||||
const nextNormalizedSearchQuery = normalizeModelPickerSearchQuery(nextRawSearchQuery);
|
||||
if (nextNormalizedSearchQuery === normalizedSearchQueryRef.current) {
|
||||
return;
|
||||
}
|
||||
normalizedSearchQueryRef.current = nextNormalizedSearchQuery;
|
||||
props.onSearchQueryChange(nextNormalizedSearchQuery);
|
||||
}}
|
||||
onKeyDown={(event) => {
|
||||
if (event.key === "Escape") {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
props.onRequestClose?.();
|
||||
return;
|
||||
}
|
||||
if (event.key === "Enter" && props.onHighlightedModelSelect()) {
|
||||
(event as typeof event & { preventBaseUIHandler?: () => void }).preventBaseUIHandler?.();
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
return;
|
||||
}
|
||||
event.stopPropagation();
|
||||
}}
|
||||
onMouseDown={(event) => event.stopPropagation()}
|
||||
onTouchStart={(event) => event.stopPropagation()}
|
||||
size="sm"
|
||||
unstyled
|
||||
/>
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
export const ModelPickerContent = memo(function ModelPickerContent(props: {
|
||||
/** The instance currently selected in the composer (combobox "value"). */
|
||||
@@ -176,7 +212,7 @@ export const ModelPickerContent = memo(function ModelPickerContent(props: {
|
||||
const [searchQuery, setSearchQuery] = useState("");
|
||||
const [showTopScrollFade, setShowTopScrollFade] = useState(false);
|
||||
const [showBottomScrollFade, setShowBottomScrollFade] = useState(false);
|
||||
const searchInputRef = useRef<HTMLInputElement>(null);
|
||||
const [searchFocusRequest, setSearchFocusRequest] = useState(0);
|
||||
const modelListRef = useRef<LegendListRef | null>(null);
|
||||
const highlightedModelKeyRef = useRef<string | null>(null);
|
||||
const favorites = useClientSettings((s) => s.favorites ?? []);
|
||||
@@ -196,33 +232,10 @@ export const ModelPickerContent = memo(function ModelPickerContent(props: {
|
||||
);
|
||||
const updateSettings = useUpdateClientSettings();
|
||||
|
||||
const focusSearchInput = useCallback(() => {
|
||||
searchInputRef.current?.focus({ preventScroll: true });
|
||||
}, []);
|
||||
|
||||
const handleSelectInstance = useCallback(
|
||||
(instanceId: ProviderInstanceId | "favorites") => {
|
||||
setSelectedInstanceId(instanceId);
|
||||
window.requestAnimationFrame(() => {
|
||||
focusSearchInput();
|
||||
});
|
||||
},
|
||||
[focusSearchInput],
|
||||
);
|
||||
|
||||
useLayoutEffect(() => {
|
||||
focusSearchInput();
|
||||
const frame = window.requestAnimationFrame(() => {
|
||||
focusSearchInput();
|
||||
});
|
||||
const timeout = window.setTimeout(() => {
|
||||
focusSearchInput();
|
||||
}, 0);
|
||||
return () => {
|
||||
window.cancelAnimationFrame(frame);
|
||||
window.clearTimeout(timeout);
|
||||
};
|
||||
}, [focusSearchInput]);
|
||||
const handleSelectInstance = (instanceId: ProviderInstanceId | "favorites") => {
|
||||
setSelectedInstanceId(instanceId);
|
||||
setSearchFocusRequest((request) => request + 1);
|
||||
};
|
||||
|
||||
// Create a Set for efficient lookup. Favorites are keyed by
|
||||
// `${instanceId}:${slug}`; the storage schema widened from ProviderDriverKind
|
||||
@@ -298,7 +311,7 @@ export const ModelPickerContent = memo(function ModelPickerContent(props: {
|
||||
}, [modelOptionsByInstance, entryByInstanceId, readyInstanceSet]);
|
||||
|
||||
const isLocked = props.lockedProvider !== null;
|
||||
const isSearching = searchQuery.trim().length > 0;
|
||||
const isSearching = searchQuery.length > 0;
|
||||
const lockedDisabledInstanceIds = useMemo(() => {
|
||||
if (!isLocked) {
|
||||
return undefined;
|
||||
@@ -338,7 +351,7 @@ export const ModelPickerContent = memo(function ModelPickerContent(props: {
|
||||
let result = flatModels;
|
||||
|
||||
// Apply tokenized fuzzy search across the combined provider/model search fields.
|
||||
if (searchQuery.trim()) {
|
||||
if (searchQuery) {
|
||||
const rankedMatches = result
|
||||
.map((model) => ({
|
||||
model,
|
||||
@@ -462,6 +475,15 @@ export const ModelPickerContent = memo(function ModelPickerContent(props: {
|
||||
},
|
||||
[entryByInstanceId, getModelDisabledReason, modelOptionsByInstance, onInstanceModelChange],
|
||||
);
|
||||
const selectHighlightedModel = () => {
|
||||
const highlightedModelKey = highlightedModelKeyRef.current;
|
||||
if (!highlightedModelKey) {
|
||||
return false;
|
||||
}
|
||||
const { instanceId, slug } = splitInstanceModelKey(highlightedModelKey);
|
||||
handleModelSelect(slug, instanceId);
|
||||
return true;
|
||||
};
|
||||
|
||||
const toggleFavorite = useCallback(
|
||||
(instanceId: ProviderInstanceId, model: string) => {
|
||||
@@ -549,41 +571,14 @@ export const ModelPickerContent = memo(function ModelPickerContent(props: {
|
||||
return mapping.size > 0 ? mapping : EMPTY_MODEL_JUMP_LABELS;
|
||||
}, [keybindings, modelJumpCommandByKey, modelJumpShortcutContext]);
|
||||
|
||||
useEffect(() => {
|
||||
const onWindowKeyDown = (event: globalThis.KeyboardEvent) => {
|
||||
if (event.defaultPrevented || event.repeat) {
|
||||
return;
|
||||
}
|
||||
|
||||
const command = resolveShortcutCommand(event, keybindings, {
|
||||
platform: navigator.platform,
|
||||
context: modelJumpShortcutContext,
|
||||
});
|
||||
const jumpIndex = modelPickerJumpIndexFromCommand(command ?? "");
|
||||
if (jumpIndex === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
const targetModelKey = modelJumpModelKeys[jumpIndex];
|
||||
if (!targetModelKey) {
|
||||
return;
|
||||
}
|
||||
const { instanceId, slug } = splitInstanceModelKey(targetModelKey);
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
handleModelSelect(slug, instanceId);
|
||||
};
|
||||
|
||||
window.addEventListener("keydown", onWindowKeyDown, true);
|
||||
|
||||
return () => {
|
||||
window.removeEventListener("keydown", onWindowKeyDown, true);
|
||||
};
|
||||
}, [handleModelSelect, keybindings, modelJumpModelKeys, modelJumpShortcutContext]);
|
||||
useModelPickerJumpShortcuts({
|
||||
keybindings,
|
||||
modelJumpModelKeys,
|
||||
modelJumpShortcutContext,
|
||||
onModelSelect: handleModelSelect,
|
||||
});
|
||||
|
||||
useLayoutEffect(() => {
|
||||
setShowTopScrollFade(false);
|
||||
setShowBottomScrollFade(filteredModelKeys.length > 5);
|
||||
let nestedFrame = 0;
|
||||
const frame = window.requestAnimationFrame(() => {
|
||||
updateModelListScrollFades();
|
||||
@@ -595,15 +590,6 @@ export const ModelPickerContent = memo(function ModelPickerContent(props: {
|
||||
};
|
||||
}, [filteredModelKeys, updateModelListScrollFades]);
|
||||
|
||||
const submitHighlightedModel = useCallback(() => {
|
||||
if (!highlightedModelKeyRef.current) {
|
||||
return false;
|
||||
}
|
||||
const { instanceId, slug } = splitInstanceModelKey(highlightedModelKeyRef.current);
|
||||
handleModelSelect(slug, instanceId);
|
||||
return true;
|
||||
}, [handleModelSelect]);
|
||||
|
||||
return (
|
||||
<TooltipProvider delay={0}>
|
||||
<div
|
||||
@@ -664,10 +650,10 @@ export const ModelPickerContent = memo(function ModelPickerContent(props: {
|
||||
<div className="px-4 pt-2.5">
|
||||
<div className="-translate-y-px border-b border-border/70 pb-2.5 transition-colors focus-within:border-ring">
|
||||
<ModelPickerSearchInput
|
||||
inputRef={searchInputRef}
|
||||
focusRequest={searchFocusRequest}
|
||||
onSearchQueryChange={setSearchQuery}
|
||||
onSubmitHighlightedModel={submitHighlightedModel}
|
||||
{...(props.onRequestClose ? { onRequestClose: props.onRequestClose } : {})}
|
||||
onRequestClose={props.onRequestClose}
|
||||
onHighlightedModelSelect={selectHighlightedModel}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -32,7 +32,7 @@ import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
|
||||
*/
|
||||
const CUSTOM_MODEL_PLACEHOLDER_BY_KIND: Partial<Record<ProviderDriverKind, string>> = {
|
||||
[ProviderDriverKind.make("codex")]: "gpt-6.7-codex-ultra-preview",
|
||||
[ProviderDriverKind.make("claudeAgent")]: "claude-sonnet-5-0",
|
||||
[ProviderDriverKind.make("claudeAgent")]: "claude-sonnet-5",
|
||||
[ProviderDriverKind.make("cursor")]: "claude-sonnet-4-6",
|
||||
[ProviderDriverKind.make("opencode")]: "openai/gpt-5",
|
||||
};
|
||||
|
||||
@@ -812,12 +812,35 @@ label:has(> select#reasoning-effort) select {
|
||||
#ec4899 90%,
|
||||
#ff6b6b 100%
|
||||
);
|
||||
position: relative;
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.ultrathink-frame::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
border-radius: inherit;
|
||||
padding: 2px;
|
||||
background-image: var(--ultrathink-spectrum);
|
||||
background-size: 220% 220%;
|
||||
pointer-events: none;
|
||||
filter: saturate(0.82) brightness(0.92);
|
||||
-webkit-mask:
|
||||
linear-gradient(#000 0 0) content-box,
|
||||
linear-gradient(#000 0 0);
|
||||
-webkit-mask-composite: xor;
|
||||
mask:
|
||||
linear-gradient(#000 0 0) content-box,
|
||||
linear-gradient(#000 0 0);
|
||||
mask-composite: exclude;
|
||||
animation: ultrathink-rainbow 10s linear infinite;
|
||||
}
|
||||
|
||||
.ultrathink-frame > * {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.ultrathink-chroma {
|
||||
animation: ultrathink-chroma-shift 10s linear infinite;
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ export const DEFAULT_GIT_TEXT_GENERATION_MODEL = "gpt-5.4-mini";
|
||||
|
||||
export const DEFAULT_MODEL_BY_PROVIDER: Partial<Record<ProviderDriverKind, string>> = {
|
||||
[CODEX_DRIVER_KIND]: DEFAULT_MODEL,
|
||||
[CLAUDE_DRIVER_KIND]: "claude-sonnet-4-6",
|
||||
[CLAUDE_DRIVER_KIND]: "claude-sonnet-5",
|
||||
[CURSOR_DRIVER_KIND]: "auto",
|
||||
[GROK_DRIVER_KIND]: "grok-build",
|
||||
[OPENCODE_DRIVER_KIND]: "openai/gpt-5",
|
||||
@@ -174,7 +174,10 @@ export const MODEL_SLUG_ALIASES_BY_PROVIDER: Partial<
|
||||
"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: "claude-sonnet-5",
|
||||
"sonnet-5": "claude-sonnet-5",
|
||||
"claude-sonnet-5.0": "claude-sonnet-5",
|
||||
"claude-sonnet-5-0": "claude-sonnet-5",
|
||||
"sonnet-4.6": "claude-sonnet-4-6",
|
||||
"claude-sonnet-4.6": "claude-sonnet-4-6",
|
||||
"claude-sonnet-4-6-20251117": "claude-sonnet-4-6",
|
||||
|
||||
@@ -1,13 +1,7 @@
|
||||
import { describe, expect, it } from "vite-plus/test";
|
||||
import {
|
||||
DEFAULT_MODEL,
|
||||
ProviderDriverKind,
|
||||
ProviderInstanceId,
|
||||
type ModelCapabilities,
|
||||
} from "@t3tools/contracts";
|
||||
import { ProviderInstanceId, type ModelCapabilities } from "@t3tools/contracts";
|
||||
|
||||
import {
|
||||
applyClaudePromptEffortPrefix,
|
||||
buildProviderOptionSelectionsFromDescriptors,
|
||||
createModelCapabilities,
|
||||
createModelSelection,
|
||||
@@ -16,11 +10,6 @@ import {
|
||||
getProviderOptionDescriptors,
|
||||
getProviderOptionBooleanSelectionValue,
|
||||
getProviderOptionStringSelectionValue,
|
||||
isClaudeUltrathinkPrompt,
|
||||
normalizeModelSlug,
|
||||
resolveModelSlugForProvider,
|
||||
resolveSelectableModel,
|
||||
trimOrNull,
|
||||
} from "./model.ts";
|
||||
|
||||
const codexCaps: ModelCapabilities = createModelCapabilities({
|
||||
@@ -70,82 +59,6 @@ const claudeCaps: ModelCapabilities = createModelCapabilities({
|
||||
],
|
||||
});
|
||||
|
||||
describe("normalizeModelSlug", () => {
|
||||
it("maps known aliases to canonical slugs", () => {
|
||||
const claude = ProviderDriverKind.make("claudeAgent");
|
||||
expect(normalizeModelSlug("gpt-5-codex")).toBe("gpt-5.4");
|
||||
expect(normalizeModelSlug("5.3")).toBe("gpt-5.3-codex");
|
||||
expect(normalizeModelSlug("sonnet", claude)).toBe("claude-sonnet-4-6");
|
||||
});
|
||||
|
||||
it("returns null for empty or missing values", () => {
|
||||
expect(normalizeModelSlug("")).toBeNull();
|
||||
expect(normalizeModelSlug(" ")).toBeNull();
|
||||
expect(normalizeModelSlug(null)).toBeNull();
|
||||
expect(normalizeModelSlug(undefined)).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe("resolveModelSlugForProvider", () => {
|
||||
it("returns defaults when the model is missing", () => {
|
||||
expect(resolveModelSlugForProvider(ProviderDriverKind.make("codex"), undefined)).toBe(
|
||||
DEFAULT_MODEL,
|
||||
);
|
||||
expect(resolveModelSlugForProvider(ProviderDriverKind.make("ollama"), undefined)).toBe(
|
||||
DEFAULT_MODEL,
|
||||
);
|
||||
expect(resolveModelSlugForProvider(ProviderDriverKind.make("grok"), undefined)).toBe(
|
||||
"grok-build",
|
||||
);
|
||||
});
|
||||
|
||||
it("preserves normalized unknown models", () => {
|
||||
expect(
|
||||
resolveModelSlugForProvider(ProviderDriverKind.make("codex"), "custom/internal-model"),
|
||||
).toBe("custom/internal-model");
|
||||
});
|
||||
});
|
||||
|
||||
describe("resolveSelectableModel", () => {
|
||||
it("resolves exact slugs, labels, and aliases", () => {
|
||||
const options = [
|
||||
{ slug: "gpt-5.3-codex", name: "GPT-5.3 Codex" },
|
||||
{ slug: "claude-sonnet-4-6", name: "Claude Sonnet 4.6" },
|
||||
];
|
||||
expect(resolveSelectableModel(ProviderDriverKind.make("codex"), "gpt-5.3-codex", options)).toBe(
|
||||
"gpt-5.3-codex",
|
||||
);
|
||||
expect(resolveSelectableModel(ProviderDriverKind.make("codex"), "gpt-5.3 codex", options)).toBe(
|
||||
"gpt-5.3-codex",
|
||||
);
|
||||
expect(resolveSelectableModel(ProviderDriverKind.make("claudeAgent"), "sonnet", options)).toBe(
|
||||
"claude-sonnet-4-6",
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("misc helpers", () => {
|
||||
it("detects ultrathink prompts", () => {
|
||||
expect(isClaudeUltrathinkPrompt("Please ultrathink about this")).toBe(true);
|
||||
expect(isClaudeUltrathinkPrompt("Ultrathink:\nInvestigate")).toBe(true);
|
||||
expect(isClaudeUltrathinkPrompt("Investigate")).toBe(false);
|
||||
});
|
||||
|
||||
it("prefixes ultrathink prompts once", () => {
|
||||
expect(applyClaudePromptEffortPrefix("Investigate", "ultrathink")).toBe(
|
||||
"Ultrathink:\nInvestigate",
|
||||
);
|
||||
expect(applyClaudePromptEffortPrefix("Ultrathink:\nInvestigate", "ultrathink")).toBe(
|
||||
"Ultrathink:\nInvestigate",
|
||||
);
|
||||
});
|
||||
|
||||
it("trims strings to null", () => {
|
||||
expect(trimOrNull(" hi ")).toBe("hi");
|
||||
expect(trimOrNull(" ")).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe("descriptor helpers", () => {
|
||||
it("applies selection values to capability descriptors", () => {
|
||||
expect(
|
||||
|
||||
Reference in new issue
Block a user