Add Cursor provider support across backend, contracts, and UI
- Accept `cursor` as a first-class provider in orchestration, persistence, and session directory flows - Update model/provider inference and normalization to handle Cursor model aliases - Revamp chat provider/model picker with Cursor-specific trait controls and add coverage in tests
This commit is contained in:
1 parent
f265f56cb5
commit
87c797b16b
16 files changed
+1150
-87
No files matched your search
@@ -79,7 +79,9 @@ describe("ProviderCommandReactor", () => {
|
||||
typeof input === "object" &&
|
||||
input !== null &&
|
||||
"provider" in input &&
|
||||
(input.provider === "codex" || input.provider === "claudeCode")
|
||||
(input.provider === "codex" ||
|
||||
input.provider === "claudeCode" ||
|
||||
input.provider === "cursor")
|
||||
? input.provider
|
||||
: "codex";
|
||||
const resumeCursor =
|
||||
@@ -263,6 +265,44 @@ describe("ProviderCommandReactor", () => {
|
||||
expect(thread?.session?.providerSessionId).toBe("sess-1");
|
||||
});
|
||||
|
||||
it("starts first turn with cursor provider when provider is specified", async () => {
|
||||
const harness = await createHarness();
|
||||
const now = new Date().toISOString();
|
||||
|
||||
await Effect.runPromise(
|
||||
harness.engine.dispatch({
|
||||
type: "thread.turn.start",
|
||||
commandId: CommandId.makeUnsafe("cmd-turn-start-provider-cursor"),
|
||||
threadId: ThreadId.makeUnsafe("thread-1"),
|
||||
message: {
|
||||
messageId: asMessageId("user-message-provider-cursor"),
|
||||
role: "user",
|
||||
text: "hello cursor",
|
||||
attachments: [],
|
||||
},
|
||||
provider: "cursor",
|
||||
approvalPolicy: "on-request",
|
||||
sandboxMode: "workspace-write",
|
||||
createdAt: now,
|
||||
}),
|
||||
);
|
||||
|
||||
await waitFor(() => harness.startSession.mock.calls.length === 1);
|
||||
await waitFor(() => harness.sendTurn.mock.calls.length === 1);
|
||||
expect(harness.startSession.mock.calls[0]?.[1]).toMatchObject({
|
||||
provider: "cursor",
|
||||
cwd: "/tmp/provider-project",
|
||||
model: "gpt-5-codex",
|
||||
approvalPolicy: "on-request",
|
||||
sandboxMode: "workspace-write",
|
||||
});
|
||||
|
||||
const readModel = await Effect.runPromise(harness.engine.getReadModel());
|
||||
const thread = readModel.threads.find((entry) => entry.id === ThreadId.makeUnsafe("thread-1"));
|
||||
expect(thread?.session?.providerName).toBe("cursor");
|
||||
expect(thread?.session?.providerSessionId).toBe("sess-1");
|
||||
});
|
||||
|
||||
it("reuses the same provider session when runtime mode is unchanged", async () => {
|
||||
const harness = await createHarness();
|
||||
const now = new Date().toISOString();
|
||||
|
||||
@@ -151,7 +151,9 @@ const make = Effect.gen(function* () {
|
||||
const desiredSandboxMode =
|
||||
options?.sandboxMode ?? thread.session?.sandboxMode ?? DEFAULT_SANDBOX_MODE;
|
||||
const currentProvider: ProviderKind | undefined =
|
||||
thread.session?.providerName === "codex" || thread.session?.providerName === "claudeCode"
|
||||
thread.session?.providerName === "codex" ||
|
||||
thread.session?.providerName === "claudeCode" ||
|
||||
thread.session?.providerName === "cursor"
|
||||
? thread.session.providerName
|
||||
: undefined;
|
||||
const preferredProvider: ProviderKind | undefined = options?.provider ?? currentProvider;
|
||||
|
||||
@@ -13,7 +13,7 @@ import {
|
||||
type ProviderSessionRepositoryShape,
|
||||
} from "../Services/ProviderSessions.ts";
|
||||
|
||||
const ProviderKind = Schema.Literals(["codex", "claudeCode"]);
|
||||
const ProviderKind = Schema.Literals(["codex", "claudeCode", "cursor"]);
|
||||
|
||||
const ProviderSessionRowSchema = Schema.Struct({
|
||||
sessionId: ProviderSessionId,
|
||||
|
||||
@@ -225,4 +225,22 @@ it.layer(makeDirectoryLayer(SqlitePersistenceMemory))("ProviderSessionDirectoryL
|
||||
|
||||
fs.rmSync(tempDir, { recursive: true, force: true });
|
||||
}));
|
||||
|
||||
it("accepts cursor provider bindings", () =>
|
||||
Effect.gen(function* () {
|
||||
const directory = yield* ProviderSessionDirectory;
|
||||
const sessionId = ProviderSessionId.makeUnsafe("sess-cursor");
|
||||
const threadId = ThreadId.makeUnsafe("thread-cursor");
|
||||
|
||||
yield* directory.upsert({
|
||||
sessionId,
|
||||
provider: "cursor",
|
||||
threadId,
|
||||
});
|
||||
|
||||
const provider = yield* directory.getProvider(sessionId);
|
||||
assert.equal(provider, "cursor");
|
||||
const resolvedThreadId = yield* directory.getThreadId(sessionId);
|
||||
assertSome(resolvedThreadId, threadId);
|
||||
}));
|
||||
});
|
||||
@@ -26,7 +26,7 @@ function decodeProviderKind(
|
||||
providerName: string,
|
||||
operation: string,
|
||||
): Effect.Effect<ProviderKind, ProviderSessionDirectoryPersistenceError> {
|
||||
if (providerName === "codex" || providerName === "claudeCode") {
|
||||
if (providerName === "codex" || providerName === "claudeCode" || providerName === "cursor") {
|
||||
return Effect.succeed(providerName);
|
||||
}
|
||||
return Effect.fail(
|
||||
|
||||
@@ -1,18 +1,23 @@
|
||||
import {
|
||||
type ApprovalRequestId,
|
||||
CURSOR_REASONING_OPTIONS,
|
||||
DEFAULT_MODEL,
|
||||
DEFAULT_REASONING,
|
||||
EDITORS,
|
||||
type EditorId,
|
||||
type KeybindingCommand,
|
||||
type CursorReasoningOption,
|
||||
type MessageId,
|
||||
getDefaultModel,
|
||||
getCursorModelCapabilities,
|
||||
getCursorModelFamilyOptions,
|
||||
getModelOptions,
|
||||
getReasoningOptions,
|
||||
type ProjectId,
|
||||
type ProjectEntry,
|
||||
type ProjectScript,
|
||||
ModelSlug,
|
||||
type ModelSlug,
|
||||
parseCursorModelSelection,
|
||||
PROVIDER_SEND_TURN_MAX_ATTACHMENTS,
|
||||
PROVIDER_SEND_TURN_MAX_IMAGE_BYTES,
|
||||
type ReasoningEffort,
|
||||
@@ -21,6 +26,8 @@ import {
|
||||
type ProviderKind,
|
||||
type ThreadId,
|
||||
type TurnId,
|
||||
normalizeModelSlug,
|
||||
resolveCursorModelFromSelection,
|
||||
resolveModelSlugForProvider,
|
||||
} from "@t3tools/contracts";
|
||||
import { memo, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
||||
@@ -95,8 +102,6 @@ import {
|
||||
import { Button } from "./ui/button";
|
||||
import {
|
||||
Select,
|
||||
SelectGroup,
|
||||
SelectGroupLabel,
|
||||
SelectItem,
|
||||
SelectPopup,
|
||||
SelectTrigger,
|
||||
@@ -104,8 +109,21 @@ import {
|
||||
} from "./ui/select";
|
||||
import { Separator } from "./ui/separator";
|
||||
import { Group, GroupSeparator } from "./ui/group";
|
||||
import { Menu, MenuItem, MenuPopup, MenuShortcut, MenuTrigger } from "./ui/menu";
|
||||
import { ClaudeAI, CursorIcon, Icon, OpenAI } from "./Icons";
|
||||
import {
|
||||
Menu,
|
||||
MenuGroup,
|
||||
MenuItem,
|
||||
MenuPopup,
|
||||
MenuRadioGroup,
|
||||
MenuRadioItem,
|
||||
MenuSeparator as MenuDivider,
|
||||
MenuSub,
|
||||
MenuSubPopup,
|
||||
MenuSubTrigger,
|
||||
MenuShortcut,
|
||||
MenuTrigger,
|
||||
} from "./ui/menu";
|
||||
import { ClaudeAI, CursorIcon, Gemini, Icon, OpenAI, OpenCodeIcon } from "./Icons";
|
||||
import { cn, isMacPlatform, isWindowsPlatform } from "~/lib/utils";
|
||||
import { Badge } from "./ui/badge";
|
||||
import { Tooltip, TooltipPopup, TooltipTrigger } from "./ui/tooltip";
|
||||
@@ -393,6 +411,9 @@ export default function ChatView({ threadId }: ChatViewProps) {
|
||||
const [selectedProviderByThread, setSelectedProviderByThread] = useState<
|
||||
Partial<Record<ThreadId, ProviderKind>>
|
||||
>({});
|
||||
const [selectedModelByThread, setSelectedModelByThread] = useState<
|
||||
Partial<Record<ThreadId, ModelSlug>>
|
||||
>({});
|
||||
const [isSwitchingRuntimeMode, setIsSwitchingRuntimeMode] = useState(false);
|
||||
const [respondingRequestIds, setRespondingRequestIds] = useState<ApprovalRequestId[]>([]);
|
||||
const [expandedWorkGroups, setExpandedWorkGroups] = useState<Record<string, boolean>>({});
|
||||
@@ -451,14 +472,35 @@ export default function ChatView({ threadId }: ChatViewProps) {
|
||||
"codex";
|
||||
const selectedModel = resolveModelSlugForProvider(
|
||||
selectedProvider,
|
||||
activeThread?.model ?? activeProject?.model ?? getDefaultModel(selectedProvider) ?? DEFAULT_MODEL,
|
||||
(activeThread?.id ? selectedModelByThread[activeThread.id] : undefined) ??
|
||||
activeThread?.model ??
|
||||
activeProject?.model ??
|
||||
getDefaultModel(selectedProvider) ??
|
||||
DEFAULT_MODEL,
|
||||
);
|
||||
const reasoningOptions = getReasoningOptions(selectedProvider);
|
||||
const supportsReasoningEffort = reasoningOptions.length > 0;
|
||||
const selectedCursorModel = useMemo(
|
||||
() => (selectedProvider === "cursor" ? parseCursorModelSelection(selectedModel) : null),
|
||||
[selectedModel, selectedProvider],
|
||||
);
|
||||
const selectedCursorModelCapabilities = useMemo(
|
||||
() =>
|
||||
selectedCursorModel ? getCursorModelCapabilities(selectedCursorModel.family) : null,
|
||||
[selectedCursorModel],
|
||||
);
|
||||
const hasSelectedCursorTraits = Boolean(
|
||||
selectedCursorModelCapabilities &&
|
||||
(selectedCursorModelCapabilities.supportsReasoning ||
|
||||
selectedCursorModelCapabilities.supportsFast ||
|
||||
selectedCursorModelCapabilities.supportsThinking),
|
||||
);
|
||||
const selectedModelForPicker =
|
||||
selectedProvider === "cursor" && selectedCursorModel ? selectedCursorModel.family : selectedModel;
|
||||
const searchableModelOptions = useMemo(
|
||||
() =>
|
||||
PROVIDER_OPTIONS.filter((option) => option.available).flatMap((option) =>
|
||||
getModelOptions(option.value).map(({ slug, name }) => ({
|
||||
getProviderModelPickerOptions(option.value).map(({ slug, name }) => ({
|
||||
provider: option.value,
|
||||
providerLabel: option.label,
|
||||
slug,
|
||||
@@ -477,6 +519,22 @@ export default function ChatView({ threadId }: ChatViewProps) {
|
||||
return { ...existing, [activeThread.id]: sessionProvider };
|
||||
});
|
||||
}, [activeThread?.id, sessionProvider]);
|
||||
useEffect(() => {
|
||||
if (!activeThread?.id) return;
|
||||
setSelectedModelByThread((existing) => {
|
||||
if (existing[activeThread.id]) return existing;
|
||||
return {
|
||||
...existing,
|
||||
[activeThread.id]: resolveModelSlugForProvider(
|
||||
selectedProvider,
|
||||
activeThread.model ??
|
||||
activeProject?.model ??
|
||||
getDefaultModel(selectedProvider) ??
|
||||
DEFAULT_MODEL,
|
||||
),
|
||||
};
|
||||
});
|
||||
}, [activeProject?.model, activeThread?.id, activeThread?.model, selectedProvider]);
|
||||
const phase = derivePhase(activeThread?.session ?? null);
|
||||
const isSendBusy = sendPhase !== "idle";
|
||||
const isPreparingWorktree = sendPhase === "preparing-worktree";
|
||||
@@ -1704,22 +1762,72 @@ export default function ChatView({ threadId }: ChatViewProps) {
|
||||
(provider: ProviderKind, model: ModelSlug) => {
|
||||
const api = readNativeApi();
|
||||
if (!activeThread) return;
|
||||
const resolvedModel =
|
||||
provider === "cursor"
|
||||
? resolveCursorModelFromSelection(parseCursorModelSelection(model))
|
||||
: resolveModelSlugForProvider(provider, model);
|
||||
setSelectedProviderByThread((existing) => ({
|
||||
...existing,
|
||||
[activeThread.id]: provider,
|
||||
}));
|
||||
setSelectedModelByThread((existing) => ({
|
||||
...existing,
|
||||
[activeThread.id]: resolvedModel,
|
||||
}));
|
||||
if (api) {
|
||||
void api.orchestration.dispatchCommand({
|
||||
type: "thread.meta.update",
|
||||
commandId: newCommandId(),
|
||||
threadId: activeThread.id,
|
||||
model: resolveModelSlugForProvider(provider, model),
|
||||
model: resolvedModel,
|
||||
});
|
||||
}
|
||||
scheduleComposerFocus();
|
||||
},
|
||||
[activeThread, scheduleComposerFocus],
|
||||
);
|
||||
const onCursorReasoningSelect = useCallback(
|
||||
(reasoning: CursorReasoningOption) => {
|
||||
if (selectedProvider !== "cursor") return;
|
||||
const cursorSelection = parseCursorModelSelection(selectedModel);
|
||||
const nextModel = resolveCursorModelFromSelection({
|
||||
family: cursorSelection.family,
|
||||
reasoning,
|
||||
fast: cursorSelection.fast,
|
||||
thinking: cursorSelection.thinking,
|
||||
});
|
||||
onProviderModelSelect("cursor", nextModel);
|
||||
},
|
||||
[onProviderModelSelect, selectedModel, selectedProvider],
|
||||
);
|
||||
const onCursorFastModeChange = useCallback(
|
||||
(enabled: boolean) => {
|
||||
if (selectedProvider !== "cursor") return;
|
||||
const cursorSelection = parseCursorModelSelection(selectedModel);
|
||||
const nextModel = resolveCursorModelFromSelection({
|
||||
family: cursorSelection.family,
|
||||
reasoning: cursorSelection.reasoning,
|
||||
fast: enabled,
|
||||
thinking: cursorSelection.thinking,
|
||||
});
|
||||
onProviderModelSelect("cursor", nextModel);
|
||||
},
|
||||
[onProviderModelSelect, selectedModel, selectedProvider],
|
||||
);
|
||||
const onCursorThinkingModeChange = useCallback(
|
||||
(enabled: boolean) => {
|
||||
if (selectedProvider !== "cursor") return;
|
||||
const cursorSelection = parseCursorModelSelection(selectedModel);
|
||||
const nextModel = resolveCursorModelFromSelection({
|
||||
family: cursorSelection.family,
|
||||
reasoning: cursorSelection.reasoning,
|
||||
fast: cursorSelection.fast,
|
||||
thinking: enabled,
|
||||
});
|
||||
onProviderModelSelect("cursor", nextModel);
|
||||
},
|
||||
[onProviderModelSelect, selectedModel, selectedProvider],
|
||||
);
|
||||
const onEffortSelect = useCallback(
|
||||
(effort: ReasoningEffort) => {
|
||||
setSelectedEffort(effort);
|
||||
@@ -2059,26 +2167,43 @@ export default function ChatView({ threadId }: ChatViewProps) {
|
||||
{/* Provider/model picker */}
|
||||
<ProviderModelPicker
|
||||
provider={selectedProvider}
|
||||
model={selectedModel}
|
||||
model={selectedModelForPicker}
|
||||
onProviderModelChange={onProviderModelSelect}
|
||||
/>
|
||||
|
||||
{/* Divider */}
|
||||
<Separator orientation="vertical" className="mx-0.5 hidden h-4 sm:block" />
|
||||
|
||||
{/* Reasoning effort */}
|
||||
{supportsReasoningEffort ? (
|
||||
{selectedProvider === "cursor" ? (
|
||||
<>
|
||||
{hasSelectedCursorTraits && (
|
||||
<Separator orientation="vertical" className="mx-0.5 hidden h-4 sm:block" />
|
||||
)}
|
||||
|
||||
{selectedCursorModel && selectedCursorModelCapabilities && hasSelectedCursorTraits && (
|
||||
<CursorTraitsPicker
|
||||
selection={selectedCursorModel}
|
||||
capabilities={selectedCursorModelCapabilities}
|
||||
onReasoningChange={onCursorReasoningSelect}
|
||||
onFastModeChange={onCursorFastModeChange}
|
||||
onThinkingModeChange={onCursorThinkingModeChange}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
) : supportsReasoningEffort ? (
|
||||
<>
|
||||
{/* Divider */}
|
||||
<Separator orientation="vertical" className="mx-0.5 hidden h-4 sm:block" />
|
||||
|
||||
{/* Reasoning effort */}
|
||||
<ReasoningEffortPicker
|
||||
effort={selectedEffort}
|
||||
options={reasoningOptions}
|
||||
onEffortChange={onEffortSelect}
|
||||
/>
|
||||
{/* Divider */}
|
||||
<Separator orientation="vertical" className="mx-0.5 hidden h-4 sm:block" />
|
||||
</>
|
||||
) : null}
|
||||
|
||||
{/* Divider */}
|
||||
<Separator orientation="vertical" className="mx-0.5 hidden h-4 sm:block" />
|
||||
|
||||
{/* Runtime mode toggle */}
|
||||
<Button
|
||||
variant="ghost"
|
||||
@@ -2967,87 +3092,141 @@ const MessagesTimeline = memo(function MessagesTimeline({
|
||||
);
|
||||
});
|
||||
|
||||
const PROVIDER_MODEL_GROUPS: ReadonlyArray<{
|
||||
readonly provider: ProviderKind;
|
||||
readonly label: string;
|
||||
readonly options: ReadonlyArray<{ readonly slug: ModelSlug; readonly name: string }>;
|
||||
}> = PROVIDER_OPTIONS.filter((option) => option.available).map((option) => ({
|
||||
provider: option.value,
|
||||
label: option.label,
|
||||
options: getModelOptions(option.value),
|
||||
}));
|
||||
const AVAILABLE_PROVIDER_OPTIONS = PROVIDER_OPTIONS.filter((option) => option.available);
|
||||
const COMING_SOON_PROVIDER_OPTIONS = [
|
||||
{ id: "opencode", label: "OpenCode", icon: OpenCodeIcon },
|
||||
{ id: "gemini", label: "Gemini", icon: Gemini },
|
||||
] as const;
|
||||
|
||||
function getProviderModelPickerOptions(provider: ProviderKind) {
|
||||
if (provider === "cursor") {
|
||||
return getCursorModelFamilyOptions();
|
||||
}
|
||||
return getModelOptions(provider);
|
||||
}
|
||||
|
||||
const PROVIDER_ICON_BY_PROVIDER: Record<ProviderKind, Icon> = {
|
||||
codex: OpenAI,
|
||||
claudeCode: ClaudeAI,
|
||||
cursor: CursorIcon,
|
||||
};
|
||||
|
||||
function resolveModelForProviderPicker(
|
||||
provider: ProviderKind,
|
||||
value: string,
|
||||
): ModelSlug | null {
|
||||
const trimmedValue = value.trim();
|
||||
if (!trimmedValue) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const options = getProviderModelPickerOptions(provider);
|
||||
const direct = options.find((option) => option.slug === trimmedValue);
|
||||
if (direct) {
|
||||
return direct.slug;
|
||||
}
|
||||
|
||||
const byName = options.find((option) => option.name.toLowerCase() === trimmedValue.toLowerCase());
|
||||
if (byName) {
|
||||
return byName.slug;
|
||||
}
|
||||
|
||||
const normalized = normalizeModelSlug(trimmedValue, provider);
|
||||
if (!normalized) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const resolved = options.find((option) => option.slug === normalized);
|
||||
if (resolved) {
|
||||
return resolved.slug;
|
||||
}
|
||||
|
||||
if (provider === "cursor") {
|
||||
return parseCursorModelSelection(normalized).family;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
const ProviderModelPicker = memo(function ProviderModelPicker(props: {
|
||||
provider: ProviderKind;
|
||||
model: ModelSlug;
|
||||
onProviderModelChange: (provider: ProviderKind, model: ModelSlug) => void;
|
||||
}) {
|
||||
const items = PROVIDER_MODEL_GROUPS.flatMap(({ provider, label, options }) =>
|
||||
options.map(({ slug, name }) => ({
|
||||
label: `${label} · ${name}`,
|
||||
value: `${provider}:${slug}`,
|
||||
})),
|
||||
);
|
||||
const [isMenuOpen, setIsMenuOpen] = useState(false);
|
||||
const selectedProviderOptions = getProviderModelPickerOptions(props.provider);
|
||||
const selectedModelLabel =
|
||||
PROVIDER_MODEL_GROUPS.find((group) => group.provider === props.provider)?.options.find(
|
||||
(option) => option.slug === props.model,
|
||||
)?.name ?? props.model;
|
||||
selectedProviderOptions.find((option) => option.slug === props.model)?.name ?? props.model;
|
||||
const ProviderIcon = PROVIDER_ICON_BY_PROVIDER[props.provider];
|
||||
|
||||
return (
|
||||
<Select
|
||||
items={items}
|
||||
value={`${props.provider}:${props.model}`}
|
||||
onValueChange={(value) =>
|
||||
value
|
||||
? (() => {
|
||||
if (value.startsWith("codex:")) {
|
||||
props.onProviderModelChange(
|
||||
"codex",
|
||||
resolveModelSlugForProvider("codex", value.slice("codex:".length)),
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (value.startsWith("claudeCode:")) {
|
||||
props.onProviderModelChange(
|
||||
"claudeCode",
|
||||
resolveModelSlugForProvider("claudeCode", value.slice("claudeCode:".length)),
|
||||
);
|
||||
}
|
||||
})()
|
||||
: undefined
|
||||
}
|
||||
>
|
||||
<SelectTrigger size="sm" variant="ghost">
|
||||
<Menu open={isMenuOpen} onOpenChange={setIsMenuOpen}>
|
||||
<MenuTrigger
|
||||
render={<Button size="sm" variant="ghost" className="shrink-0 whitespace-nowrap px-2 sm:px-3" />}
|
||||
>
|
||||
<span className="flex min-w-0 items-center gap-2">
|
||||
<ProviderIcon
|
||||
aria-hidden="true"
|
||||
className={cn(
|
||||
"size-4 shrink-0",
|
||||
props.provider === "claudeCode" ? "" : "text-foreground/85",
|
||||
props.provider === "claudeCode" ? "" : "text-foreground/80",
|
||||
)}
|
||||
/>
|
||||
<span className="truncate">{selectedModelLabel}</span>
|
||||
<ChevronDownIcon aria-hidden="true" className="size-3 opacity-60" />
|
||||
</span>
|
||||
</SelectTrigger>
|
||||
<SelectPopup alignItemWithTrigger={false}>
|
||||
{PROVIDER_MODEL_GROUPS.map(({ provider, label, options }) => (
|
||||
<SelectGroup key={provider}>
|
||||
<SelectGroupLabel>{label}</SelectGroupLabel>
|
||||
{options.map(({ slug, name }) => (
|
||||
<SelectItem key={`${provider}:${slug}`} value={`${provider}:${slug}`}>
|
||||
{name}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectGroup>
|
||||
))}
|
||||
</SelectPopup>
|
||||
</Select>
|
||||
</MenuTrigger>
|
||||
<MenuPopup align="start">
|
||||
{AVAILABLE_PROVIDER_OPTIONS.map((option) => {
|
||||
const OptionIcon = PROVIDER_ICON_BY_PROVIDER[option.value];
|
||||
return (
|
||||
<MenuSub key={option.value}>
|
||||
<MenuSubTrigger>
|
||||
<OptionIcon aria-hidden="true" className="size-4 shrink-0 text-muted-foreground/85" />
|
||||
{option.label}
|
||||
</MenuSubTrigger>
|
||||
<MenuSubPopup className="[--available-height:min(24rem,70vh)]">
|
||||
<MenuGroup>
|
||||
<MenuRadioGroup
|
||||
value={props.provider === option.value ? props.model : ""}
|
||||
onValueChange={(value) => {
|
||||
if (!value) return;
|
||||
const resolvedModel = resolveModelForProviderPicker(option.value, value);
|
||||
if (!resolvedModel) return;
|
||||
props.onProviderModelChange(option.value, resolvedModel);
|
||||
setIsMenuOpen(false);
|
||||
}}
|
||||
>
|
||||
{getProviderModelPickerOptions(option.value).map((modelOption) => (
|
||||
<MenuRadioItem
|
||||
key={`${option.value}:${modelOption.slug}`}
|
||||
value={modelOption.slug}
|
||||
onClick={() => setIsMenuOpen(false)}
|
||||
>
|
||||
{modelOption.name}
|
||||
</MenuRadioItem>
|
||||
))}
|
||||
</MenuRadioGroup>
|
||||
</MenuGroup>
|
||||
</MenuSubPopup>
|
||||
</MenuSub>
|
||||
);
|
||||
})}
|
||||
<MenuDivider />
|
||||
{COMING_SOON_PROVIDER_OPTIONS.map((option) => {
|
||||
const OptionIcon = option.icon;
|
||||
return (
|
||||
<MenuItem key={option.id} disabled>
|
||||
<OptionIcon aria-hidden="true" className="size-4 shrink-0 opacity-80" />
|
||||
<span>{option.label}</span>
|
||||
<span className="ms-auto text-[11px] text-muted-foreground/80 uppercase tracking-[0.08em]">
|
||||
Coming soon
|
||||
</span>
|
||||
</MenuItem>
|
||||
);
|
||||
})}
|
||||
</MenuPopup>
|
||||
</Menu>
|
||||
);
|
||||
});
|
||||
|
||||
@@ -3076,6 +3255,90 @@ const ReasoningEffortPicker = memo(function ReasoningEffortPicker(props: {
|
||||
);
|
||||
});
|
||||
|
||||
const CursorTraitsPicker = memo(function CursorTraitsPicker(props: {
|
||||
selection: ReturnType<typeof parseCursorModelSelection>;
|
||||
capabilities: ReturnType<typeof getCursorModelCapabilities>;
|
||||
onReasoningChange: (reasoning: CursorReasoningOption) => void;
|
||||
onFastModeChange: (enabled: boolean) => void;
|
||||
onThinkingModeChange: (enabled: boolean) => void;
|
||||
}) {
|
||||
const reasoningLabelByOption: Record<CursorReasoningOption, string> = {
|
||||
low: "Low",
|
||||
normal: "Normal",
|
||||
high: "High",
|
||||
xhigh: "XHigh",
|
||||
};
|
||||
const traitSummary = [
|
||||
...(props.capabilities.supportsReasoning
|
||||
? [reasoningLabelByOption[props.selection.reasoning]]
|
||||
: []),
|
||||
...(props.capabilities.supportsFast && props.selection.fast ? ["Fast"] : []),
|
||||
...(props.capabilities.supportsThinking && props.selection.thinking ? ["Thinking"] : []),
|
||||
];
|
||||
const triggerLabel = traitSummary.length > 0 ? traitSummary.join(" · ") : "Traits";
|
||||
|
||||
return (
|
||||
<Menu>
|
||||
<MenuTrigger
|
||||
render={<Button size="sm" variant="ghost" className="shrink-0 whitespace-nowrap px-2 sm:px-3" />}
|
||||
>
|
||||
<span>{triggerLabel}</span>
|
||||
<ChevronDownIcon aria-hidden="true" className="size-3 opacity-60" />
|
||||
</MenuTrigger>
|
||||
<MenuPopup align="start">
|
||||
{props.capabilities.supportsReasoning && (
|
||||
<MenuGroup>
|
||||
<div className="px-2 py-1.5 font-medium text-muted-foreground text-xs">Reasoning</div>
|
||||
<MenuRadioGroup
|
||||
value={props.selection.reasoning}
|
||||
onValueChange={(value) => {
|
||||
if (!value) return;
|
||||
const nextReasoning = CURSOR_REASONING_OPTIONS.find((option) => option === value);
|
||||
if (!nextReasoning) return;
|
||||
props.onReasoningChange(nextReasoning);
|
||||
}}
|
||||
>
|
||||
{CURSOR_REASONING_OPTIONS.map((reasoning) => (
|
||||
<MenuRadioItem key={reasoning} value={reasoning}>
|
||||
{reasoning}
|
||||
{reasoning === "normal" ? " (default)" : ""}
|
||||
</MenuRadioItem>
|
||||
))}
|
||||
</MenuRadioGroup>
|
||||
</MenuGroup>
|
||||
)}
|
||||
{props.capabilities.supportsReasoning &&
|
||||
(props.capabilities.supportsFast || props.capabilities.supportsThinking) && <MenuDivider />}
|
||||
{props.capabilities.supportsFast && (
|
||||
<MenuGroup>
|
||||
<div className="px-2 py-1.5 font-medium text-muted-foreground text-xs">Fast Mode</div>
|
||||
<MenuRadioGroup
|
||||
value={props.selection.fast ? "on" : "off"}
|
||||
onValueChange={(value) => props.onFastModeChange(value === "on")}
|
||||
>
|
||||
<MenuRadioItem value="off">off</MenuRadioItem>
|
||||
<MenuRadioItem value="on">on</MenuRadioItem>
|
||||
</MenuRadioGroup>
|
||||
</MenuGroup>
|
||||
)}
|
||||
{props.capabilities.supportsFast && props.capabilities.supportsThinking && <MenuDivider />}
|
||||
{props.capabilities.supportsThinking && (
|
||||
<MenuGroup>
|
||||
<div className="px-2 py-1.5 font-medium text-muted-foreground text-xs">Thinking</div>
|
||||
<MenuRadioGroup
|
||||
value={props.selection.thinking ? "on" : "off"}
|
||||
onValueChange={(value) => props.onThinkingModeChange(value === "on")}
|
||||
>
|
||||
<MenuRadioItem value="off">off</MenuRadioItem>
|
||||
<MenuRadioItem value="on">on</MenuRadioItem>
|
||||
</MenuRadioGroup>
|
||||
</MenuGroup>
|
||||
)}
|
||||
</MenuPopup>
|
||||
</Menu>
|
||||
);
|
||||
});
|
||||
|
||||
const OpenInPicker = memo(function OpenInPicker({
|
||||
keybindings,
|
||||
activeThreadId,
|
||||
|
||||
@@ -34,3 +34,185 @@ export const ClaudeAI: Icon = (props) => (
|
||||
/>
|
||||
</svg>
|
||||
);
|
||||
|
||||
export const Gemini: Icon = (props) => (
|
||||
<svg {...props} viewBox="0 0 296 298" fill="none">
|
||||
<mask
|
||||
id="gemini__a"
|
||||
width="296"
|
||||
height="298"
|
||||
x="0"
|
||||
y="0"
|
||||
maskUnits="userSpaceOnUse"
|
||||
style={{ maskType: "alpha" }}
|
||||
>
|
||||
<path
|
||||
fill="#3186FF"
|
||||
d="M141.201 4.886c2.282-6.17 11.042-6.071 13.184.148l5.985 17.37a184.004 184.004 0 0 0 111.257 113.049l19.304 6.997c6.143 2.227 6.156 10.91.02 13.155l-19.35 7.082a184.001 184.001 0 0 0-109.495 109.385l-7.573 20.629c-2.241 6.105-10.869 6.121-13.133.025l-7.908-21.296a184 184 0 0 0-109.02-108.658l-19.698-7.239c-6.102-2.243-6.118-10.867-.025-13.132l20.083-7.467A183.998 183.998 0 0 0 133.291 26.28l7.91-21.394Z"
|
||||
/>
|
||||
</mask>
|
||||
<g mask="url(#gemini__a)">
|
||||
<g filter="url(#gemini__b)">
|
||||
<ellipse cx="163" cy="149" fill="#3689FF" rx="196" ry="159" />
|
||||
</g>
|
||||
<g filter="url(#gemini__c)">
|
||||
<ellipse cx="33.5" cy="142.5" fill="#F6C013" rx="68.5" ry="72.5" />
|
||||
</g>
|
||||
<g filter="url(#gemini__d)">
|
||||
<ellipse cx="19.5" cy="148.5" fill="#F6C013" rx="68.5" ry="72.5" />
|
||||
</g>
|
||||
<g filter="url(#gemini__e)">
|
||||
<path
|
||||
fill="#FA4340"
|
||||
d="M194 10.5C172 82.5 65.5 134.333 22.5 135L144-66l50 76.5Z"
|
||||
/>
|
||||
</g>
|
||||
<g filter="url(#gemini__f)">
|
||||
<path
|
||||
fill="#FA4340"
|
||||
d="M190.5-12.5C168.5 59.5 62 111.333 19 112L140.5-89l50 76.5Z"
|
||||
/>
|
||||
</g>
|
||||
<g filter="url(#gemini__g)">
|
||||
<path
|
||||
fill="#14BB69"
|
||||
d="M194.5 279.5C172.5 207.5 66 155.667 23 155l121.5 201 50-76.5Z"
|
||||
/>
|
||||
</g>
|
||||
<g filter="url(#gemini__h)">
|
||||
<path
|
||||
fill="#14BB69"
|
||||
d="M196.5 320.5C174.5 248.5 68 196.667 25 196l121.5 201 50-76.5Z"
|
||||
/>
|
||||
</g>
|
||||
</g>
|
||||
<defs>
|
||||
<filter
|
||||
id="gemini__b"
|
||||
width="464"
|
||||
height="390"
|
||||
x="-69"
|
||||
y="-46"
|
||||
colorInterpolationFilters="sRGB"
|
||||
filterUnits="userSpaceOnUse"
|
||||
>
|
||||
<feFlood floodOpacity="0" result="BackgroundImageFix" />
|
||||
<feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape" />
|
||||
<feGaussianBlur
|
||||
result="effect1_foregroundBlur_69_17998"
|
||||
stdDeviation="18"
|
||||
/>
|
||||
</filter>
|
||||
<filter
|
||||
id="gemini__c"
|
||||
width="265"
|
||||
height="273"
|
||||
x="-99"
|
||||
y="6"
|
||||
colorInterpolationFilters="sRGB"
|
||||
filterUnits="userSpaceOnUse"
|
||||
>
|
||||
<feFlood floodOpacity="0" result="BackgroundImageFix" />
|
||||
<feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape" />
|
||||
<feGaussianBlur
|
||||
result="effect1_foregroundBlur_69_17998"
|
||||
stdDeviation="32"
|
||||
/>
|
||||
</filter>
|
||||
<filter
|
||||
id="gemini__d"
|
||||
width="265"
|
||||
height="273"
|
||||
x="-113"
|
||||
y="12"
|
||||
colorInterpolationFilters="sRGB"
|
||||
filterUnits="userSpaceOnUse"
|
||||
>
|
||||
<feFlood floodOpacity="0" result="BackgroundImageFix" />
|
||||
<feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape" />
|
||||
<feGaussianBlur
|
||||
result="effect1_foregroundBlur_69_17998"
|
||||
stdDeviation="32"
|
||||
/>
|
||||
</filter>
|
||||
<filter
|
||||
id="gemini__e"
|
||||
width="299.5"
|
||||
height="329"
|
||||
x="-41.5"
|
||||
y="-130"
|
||||
colorInterpolationFilters="sRGB"
|
||||
filterUnits="userSpaceOnUse"
|
||||
>
|
||||
<feFlood floodOpacity="0" result="BackgroundImageFix" />
|
||||
<feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape" />
|
||||
<feGaussianBlur
|
||||
result="effect1_foregroundBlur_69_17998"
|
||||
stdDeviation="32"
|
||||
/>
|
||||
</filter>
|
||||
<filter
|
||||
id="gemini__f"
|
||||
width="299.5"
|
||||
height="329"
|
||||
x="-45"
|
||||
y="-153"
|
||||
colorInterpolationFilters="sRGB"
|
||||
filterUnits="userSpaceOnUse"
|
||||
>
|
||||
<feFlood floodOpacity="0" result="BackgroundImageFix" />
|
||||
<feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape" />
|
||||
<feGaussianBlur
|
||||
result="effect1_foregroundBlur_69_17998"
|
||||
stdDeviation="32"
|
||||
/>
|
||||
</filter>
|
||||
<filter
|
||||
id="gemini__g"
|
||||
width="299.5"
|
||||
height="329"
|
||||
x="-41"
|
||||
y="91"
|
||||
colorInterpolationFilters="sRGB"
|
||||
filterUnits="userSpaceOnUse"
|
||||
>
|
||||
<feFlood floodOpacity="0" result="BackgroundImageFix" />
|
||||
<feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape" />
|
||||
<feGaussianBlur
|
||||
result="effect1_foregroundBlur_69_17998"
|
||||
stdDeviation="32"
|
||||
/>
|
||||
</filter>
|
||||
<filter
|
||||
id="gemini__h"
|
||||
width="299.5"
|
||||
height="329"
|
||||
x="-39"
|
||||
y="132"
|
||||
colorInterpolationFilters="sRGB"
|
||||
filterUnits="userSpaceOnUse"
|
||||
>
|
||||
<feFlood floodOpacity="0" result="BackgroundImageFix" />
|
||||
<feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape" />
|
||||
<feGaussianBlur
|
||||
result="effect1_foregroundBlur_69_17998"
|
||||
stdDeviation="32"
|
||||
/>
|
||||
</filter>
|
||||
</defs>
|
||||
</svg>
|
||||
);
|
||||
|
||||
export const OpenCodeIcon: Icon = (props) => (
|
||||
<svg {...props} viewBox="0 0 32 40" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g clipPath="url(#opencode__clip0_1311_94969)">
|
||||
<path d="M24 32H8V16H24V32Z" fill="#BCBBBB" />
|
||||
<path d="M24 8H8V32H24V8ZM32 40H0V0H32V40Z" fill="#211E1E" />
|
||||
</g>
|
||||
<defs>
|
||||
<clipPath id="opencode__clip0_1311_94969">
|
||||
<rect width="32" height="40" fill="white" />
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
||||
);
|
||||
@@ -235,4 +235,13 @@ describe("PROVIDER_OPTIONS", () => {
|
||||
available: true,
|
||||
});
|
||||
});
|
||||
|
||||
it("marks cursor as available", () => {
|
||||
const cursor = PROVIDER_OPTIONS.find((option) => option.value === "cursor");
|
||||
expect(cursor).toEqual({
|
||||
value: "cursor",
|
||||
label: "Cursor Agent",
|
||||
available: true,
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -15,6 +15,7 @@ export const PROVIDER_OPTIONS: Array<{
|
||||
}> = [
|
||||
{ value: "codex", label: "Codex", available: true },
|
||||
{ value: "claudeCode", label: "Claude Code", available: true },
|
||||
{ value: "cursor", label: "Cursor Agent", available: true },
|
||||
];
|
||||
|
||||
export interface WorkLogEntry {
|
||||
|
||||
@@ -244,4 +244,33 @@ describe("store read model sync", () => {
|
||||
|
||||
expect(next.threads[0]?.model).toBe("claude-sonnet-4-6");
|
||||
});
|
||||
|
||||
it("resolves cursor aliases when session provider is cursor", () => {
|
||||
const initialState = makeState(makeThread());
|
||||
const readModel = makeReadModel(
|
||||
makeReadModelThread({
|
||||
model: "composer",
|
||||
session: {
|
||||
threadId: ThreadId.makeUnsafe("thread-1"),
|
||||
status: "ready",
|
||||
providerName: "cursor",
|
||||
providerSessionId: null,
|
||||
providerThreadId: null,
|
||||
approvalPolicy: "on-request",
|
||||
sandboxMode: "workspace-write",
|
||||
activeTurnId: null,
|
||||
lastError: null,
|
||||
updatedAt: "2026-02-27T00:00:00.000Z",
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
const next = reducer(initialState, {
|
||||
type: "SYNC_SERVER_READ_MODEL",
|
||||
readModel,
|
||||
});
|
||||
|
||||
expect(next.threads[0]?.model).toBe("composer-1.5");
|
||||
expect(next.threads[0]?.session?.provider).toBe("cursor");
|
||||
});
|
||||
});
|
||||
+29
-4
@@ -12,6 +12,7 @@ import {
|
||||
DEFAULT_MODEL,
|
||||
getModelOptions,
|
||||
normalizeModelSlug,
|
||||
type ProviderKind,
|
||||
ProviderSessionId,
|
||||
ThreadId,
|
||||
type OrchestrationReadModel,
|
||||
@@ -191,20 +192,37 @@ function toLegacySessionStatus(
|
||||
}
|
||||
}
|
||||
|
||||
function toLegacyProvider(providerName: string | null): "codex" | "claudeCode" {
|
||||
return providerName === "claudeCode" ? "claudeCode" : "codex";
|
||||
function toLegacyProvider(providerName: string | null): ProviderKind {
|
||||
if (providerName === "codex" || providerName === "claudeCode" || providerName === "cursor") {
|
||||
return providerName;
|
||||
}
|
||||
return "codex";
|
||||
}
|
||||
|
||||
const CODEX_MODEL_SLUGS = new Set(getModelOptions("codex").map((option) => option.slug));
|
||||
const CLAUDE_MODEL_SLUGS = new Set(getModelOptions("claudeCode").map((option) => option.slug));
|
||||
const CURSOR_MODEL_SLUGS = new Set(getModelOptions("cursor").map((option) => option.slug));
|
||||
const CURSOR_DISTINCT_MODEL_SLUGS = new Set(
|
||||
[...CURSOR_MODEL_SLUGS].filter(
|
||||
(slug) => !CODEX_MODEL_SLUGS.has(slug) && !CLAUDE_MODEL_SLUGS.has(slug),
|
||||
),
|
||||
);
|
||||
|
||||
function inferProviderForThreadModel(input: {
|
||||
readonly model: string;
|
||||
readonly sessionProviderName: string | null;
|
||||
}): "codex" | "claudeCode" {
|
||||
if (input.sessionProviderName === "codex" || input.sessionProviderName === "claudeCode") {
|
||||
}): ProviderKind {
|
||||
if (
|
||||
input.sessionProviderName === "codex" ||
|
||||
input.sessionProviderName === "claudeCode" ||
|
||||
input.sessionProviderName === "cursor"
|
||||
) {
|
||||
return input.sessionProviderName;
|
||||
}
|
||||
const normalizedCursor = normalizeModelSlug(input.model, "cursor");
|
||||
if (normalizedCursor && CURSOR_DISTINCT_MODEL_SLUGS.has(normalizedCursor)) {
|
||||
return "cursor";
|
||||
}
|
||||
const normalizedClaude = normalizeModelSlug(input.model, "claudeCode");
|
||||
if (normalizedClaude && CLAUDE_MODEL_SLUGS.has(normalizedClaude)) {
|
||||
return "claudeCode";
|
||||
@@ -213,6 +231,13 @@ function inferProviderForThreadModel(input: {
|
||||
if (normalizedCodex && CODEX_MODEL_SLUGS.has(normalizedCodex)) {
|
||||
return "codex";
|
||||
}
|
||||
if (
|
||||
input.model.trim().startsWith("composer-") ||
|
||||
input.model.trim().startsWith("gemini-") ||
|
||||
input.model.trim().endsWith("-thinking")
|
||||
) {
|
||||
return "cursor";
|
||||
}
|
||||
return input.model.trim().startsWith("claude-") ? "claudeCode" : "codex";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,15 +1,20 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import {
|
||||
CURSOR_MODEL_FAMILY_OPTIONS,
|
||||
CURSOR_REASONING_OPTIONS,
|
||||
DEFAULT_MODEL,
|
||||
DEFAULT_MODEL_BY_PROVIDER,
|
||||
MODEL_OPTIONS,
|
||||
MODEL_OPTIONS_BY_PROVIDER,
|
||||
getDefaultModel,
|
||||
getCursorModelFamilyOptions,
|
||||
getModelOptions,
|
||||
getReasoningOptions,
|
||||
normalizeModelSlug,
|
||||
REASONING_OPTIONS,
|
||||
parseCursorModelSelection,
|
||||
resolveCursorModelFromSelection,
|
||||
resolveModelSlug,
|
||||
resolveModelSlugForProvider,
|
||||
} from "./model";
|
||||
@@ -38,6 +43,14 @@ describe("normalizeModelSlug", () => {
|
||||
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",
|
||||
);
|
||||
expect(normalizeModelSlug("gemini-3.1", "cursor")).toBe("gemini-3.1-pro");
|
||||
expect(normalizeModelSlug("claude-4.6-sonnet-thinking", "cursor")).toBe(
|
||||
"sonnet-4.6-thinking",
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -61,12 +74,72 @@ describe("resolveModelSlug", () => {
|
||||
expect(resolveModelSlugForProvider("claudeCode", "gpt-5.3-codex")).toBe(
|
||||
DEFAULT_MODEL_BY_PROVIDER.claudeCode,
|
||||
);
|
||||
expect(resolveModelSlugForProvider("cursor", undefined)).toBe(
|
||||
DEFAULT_MODEL_BY_PROVIDER.cursor,
|
||||
);
|
||||
expect(resolveModelSlugForProvider("cursor", "composer")).toBe("composer-1.5");
|
||||
expect(resolveModelSlugForProvider("cursor", "gpt-5.3-codex-high-fast")).toBe(
|
||||
"gpt-5.3-codex-high-fast",
|
||||
);
|
||||
expect(resolveModelSlugForProvider("cursor", "claude-sonnet-4-6")).toBe(
|
||||
DEFAULT_MODEL_BY_PROVIDER.cursor,
|
||||
);
|
||||
});
|
||||
|
||||
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);
|
||||
});
|
||||
});
|
||||
|
||||
describe("cursor model selection", () => {
|
||||
it("includes the expected cursor reasoning levels and families", () => {
|
||||
expect(CURSOR_REASONING_OPTIONS).toEqual(["low", "normal", "high", "xhigh"]);
|
||||
expect(getCursorModelFamilyOptions().map((option) => option.slug)).toContain("gpt-5.3-codex");
|
||||
expect(getCursorModelFamilyOptions().map((option) => option.slug)).toContain("opus-4.6");
|
||||
});
|
||||
|
||||
it("parses codex reasoning and fast mode variants", () => {
|
||||
expect(parseCursorModelSelection("gpt-5.3-codex-high-fast")).toEqual({
|
||||
family: "gpt-5.3-codex",
|
||||
reasoning: "high",
|
||||
fast: true,
|
||||
thinking: false,
|
||||
});
|
||||
expect(parseCursorModelSelection("gpt-5.2-codex")).toEqual({
|
||||
family: "gpt-5.2-codex",
|
||||
reasoning: "normal",
|
||||
fast: false,
|
||||
thinking: false,
|
||||
});
|
||||
});
|
||||
|
||||
it("parses and resolves thinking variants", () => {
|
||||
expect(parseCursorModelSelection("sonnet-4.6-thinking")).toEqual({
|
||||
family: "sonnet-4.6",
|
||||
reasoning: "normal",
|
||||
fast: false,
|
||||
thinking: true,
|
||||
});
|
||||
expect(
|
||||
resolveCursorModelFromSelection({
|
||||
family: "sonnet-4.6",
|
||||
thinking: true,
|
||||
}),
|
||||
).toBe("sonnet-4.6-thinking");
|
||||
});
|
||||
|
||||
it("resolves codex family selections into concrete model ids", () => {
|
||||
expect(
|
||||
resolveCursorModelFromSelection({
|
||||
family: "gpt-5.2-codex",
|
||||
reasoning: "xhigh",
|
||||
fast: true,
|
||||
}),
|
||||
).toBe("gpt-5.2-codex-xhigh-fast");
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -5,6 +5,39 @@ type ModelOption = {
|
||||
readonly name: string;
|
||||
};
|
||||
|
||||
export const CURSOR_REASONING_OPTIONS = ["low", "normal", "high", "xhigh"] as const;
|
||||
export type CursorReasoningOption = (typeof CURSOR_REASONING_OPTIONS)[number];
|
||||
|
||||
type CursorModelFamilyOption = {
|
||||
readonly slug: string;
|
||||
readonly name: string;
|
||||
};
|
||||
|
||||
export const CURSOR_MODEL_FAMILY_OPTIONS = [
|
||||
{ slug: "auto", name: "Auto" },
|
||||
{ slug: "composer-1.5", name: "Composer 1.5" },
|
||||
{ slug: "composer-1", name: "Composer 1" },
|
||||
{ slug: "gpt-5.3-codex", name: "GPT-5.3 Codex" },
|
||||
{ slug: "gpt-5.3-codex-spark-preview", name: "GPT-5.3 Codex Spark" },
|
||||
{ slug: "gpt-5.2-codex", name: "GPT-5.2 Codex" },
|
||||
{ slug: "gpt-5.2", name: "GPT-5.2" },
|
||||
{ slug: "gpt-5.2-high", name: "GPT-5.2 High" },
|
||||
{ slug: "gpt-5.1-codex-max", name: "GPT-5.1 Codex Max" },
|
||||
{ slug: "gpt-5.1-codex-mini", name: "GPT-5.1 Codex Mini" },
|
||||
{ slug: "gpt-5.1-high", name: "GPT-5.1 High" },
|
||||
{ slug: "opus-4.6", name: "Claude 4.6 Opus" },
|
||||
{ slug: "opus-4.5", name: "Claude 4.5 Opus" },
|
||||
{ slug: "sonnet-4.6", name: "Claude 4.6 Sonnet" },
|
||||
{ slug: "sonnet-4.5", name: "Claude 4.5 Sonnet" },
|
||||
{ slug: "gemini-3.1-pro", name: "Gemini 3.1 Pro" },
|
||||
{ slug: "gemini-3-pro", name: "Gemini 3 Pro" },
|
||||
{ slug: "gemini-3-flash", name: "Gemini 3 Flash" },
|
||||
{ slug: "grok", name: "Grok" },
|
||||
{ slug: "kimi-k2.5", name: "Kimi K2.5" },
|
||||
] as const satisfies readonly CursorModelFamilyOption[];
|
||||
|
||||
export type CursorModelFamily = (typeof CURSOR_MODEL_FAMILY_OPTIONS)[number]["slug"];
|
||||
|
||||
export const MODEL_OPTIONS_BY_PROVIDER = {
|
||||
codex: [
|
||||
{ slug: "gpt-5.3-codex", name: "GPT-5.3 Codex" },
|
||||
@@ -17,13 +50,218 @@ export const MODEL_OPTIONS_BY_PROVIDER = {
|
||||
{ slug: "claude-opus-4-6", name: "Claude Opus 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" },
|
||||
{ slug: "composer-1", name: "Composer 1" },
|
||||
{ slug: "gpt-5.3-codex-low", name: "GPT-5.3 Codex Low" },
|
||||
{ slug: "gpt-5.3-codex-low-fast", name: "GPT-5.3 Codex Low Fast" },
|
||||
{ slug: "gpt-5.3-codex", name: "GPT-5.3 Codex" },
|
||||
{ slug: "gpt-5.3-codex-fast", name: "GPT-5.3 Codex Fast" },
|
||||
{ slug: "gpt-5.3-codex-high", name: "GPT-5.3 Codex High" },
|
||||
{ slug: "gpt-5.3-codex-high-fast", name: "GPT-5.3 Codex High Fast" },
|
||||
{ slug: "gpt-5.3-codex-xhigh", name: "GPT-5.3 Codex Extra High" },
|
||||
{ slug: "gpt-5.3-codex-xhigh-fast", name: "GPT-5.3 Codex Extra High Fast" },
|
||||
{ slug: "gpt-5.3-codex-spark-preview", name: "GPT-5.3 Codex Spark" },
|
||||
{ slug: "gpt-5.2", name: "GPT-5.2" },
|
||||
{ slug: "gpt-5.2-codex-low", name: "GPT-5.2 Codex Low" },
|
||||
{ slug: "gpt-5.2-codex-low-fast", name: "GPT-5.2 Codex Low Fast" },
|
||||
{ slug: "gpt-5.2-codex", name: "GPT-5.2 Codex" },
|
||||
{ slug: "gpt-5.2-codex-fast", name: "GPT-5.2 Codex Fast" },
|
||||
{ slug: "gpt-5.2-codex-high", name: "GPT-5.2 Codex High" },
|
||||
{ slug: "gpt-5.2-codex-high-fast", name: "GPT-5.2 Codex High Fast" },
|
||||
{ slug: "gpt-5.2-codex-xhigh", name: "GPT-5.2 Codex Extra High" },
|
||||
{ slug: "gpt-5.2-codex-xhigh-fast", name: "GPT-5.2 Codex Extra High Fast" },
|
||||
{ slug: "gpt-5.1-codex-max", name: "GPT-5.1 Codex Max" },
|
||||
{ slug: "gpt-5.1-codex-max-high", name: "GPT-5.1 Codex Max High" },
|
||||
{ slug: "gpt-5.2-high", name: "GPT-5.2 High" },
|
||||
{ slug: "gpt-5.1-high", name: "GPT-5.1 High" },
|
||||
{ slug: "gpt-5.1-codex-mini", name: "GPT-5.1 Codex Mini" },
|
||||
{ slug: "opus-4.6-thinking", name: "Claude 4.6 Opus (Thinking)" },
|
||||
{ slug: "opus-4.6", name: "Claude 4.6 Opus" },
|
||||
{ slug: "opus-4.5", name: "Claude 4.5 Opus" },
|
||||
{ slug: "opus-4.5-thinking", name: "Claude 4.5 Opus (Thinking)" },
|
||||
{ slug: "sonnet-4.6", name: "Claude 4.6 Sonnet" },
|
||||
{ slug: "gemini-3.1-pro", name: "Gemini 3.1 Pro" },
|
||||
{ slug: "gemini-3-pro", name: "Gemini 3 Pro" },
|
||||
{ slug: "sonnet-4.6-thinking", name: "Claude 4.6 Sonnet (Thinking)" },
|
||||
{ slug: "sonnet-4.5", name: "Claude 4.5 Sonnet" },
|
||||
{ slug: "sonnet-4.5-thinking", name: "Claude 4.5 Sonnet (Thinking)" },
|
||||
{ slug: "gemini-3-flash", name: "Gemini 3 Flash" },
|
||||
{ slug: "grok", name: "Grok" },
|
||||
{ slug: "kimi-k2.5", name: "Kimi K2.5" },
|
||||
],
|
||||
} as const satisfies Record<ProviderKind, readonly ModelOption[]>;
|
||||
|
||||
export type ModelSlug = (typeof MODEL_OPTIONS_BY_PROVIDER)[ProviderKind][number]["slug"];
|
||||
export type CursorModelSlug = (typeof MODEL_OPTIONS_BY_PROVIDER)["cursor"][number]["slug"];
|
||||
|
||||
type CursorModelCapability = {
|
||||
readonly supportsReasoning: boolean;
|
||||
readonly supportsFast: boolean;
|
||||
readonly supportsThinking: boolean;
|
||||
readonly defaultReasoning: CursorReasoningOption;
|
||||
readonly defaultThinking: boolean;
|
||||
};
|
||||
|
||||
const CURSOR_MODEL_CAPABILITY_BY_FAMILY: Record<CursorModelFamily, CursorModelCapability> = {
|
||||
auto: {
|
||||
supportsReasoning: false,
|
||||
supportsFast: false,
|
||||
supportsThinking: false,
|
||||
defaultReasoning: "normal",
|
||||
defaultThinking: false,
|
||||
},
|
||||
"composer-1.5": {
|
||||
supportsReasoning: false,
|
||||
supportsFast: false,
|
||||
supportsThinking: false,
|
||||
defaultReasoning: "normal",
|
||||
defaultThinking: false,
|
||||
},
|
||||
"composer-1": {
|
||||
supportsReasoning: false,
|
||||
supportsFast: false,
|
||||
supportsThinking: false,
|
||||
defaultReasoning: "normal",
|
||||
defaultThinking: false,
|
||||
},
|
||||
"gpt-5.3-codex": {
|
||||
supportsReasoning: true,
|
||||
supportsFast: true,
|
||||
supportsThinking: false,
|
||||
defaultReasoning: "normal",
|
||||
defaultThinking: false,
|
||||
},
|
||||
"gpt-5.3-codex-spark-preview": {
|
||||
supportsReasoning: false,
|
||||
supportsFast: false,
|
||||
supportsThinking: false,
|
||||
defaultReasoning: "normal",
|
||||
defaultThinking: false,
|
||||
},
|
||||
"gpt-5.2-codex": {
|
||||
supportsReasoning: true,
|
||||
supportsFast: true,
|
||||
supportsThinking: false,
|
||||
defaultReasoning: "normal",
|
||||
defaultThinking: false,
|
||||
},
|
||||
"gpt-5.2": {
|
||||
supportsReasoning: false,
|
||||
supportsFast: false,
|
||||
supportsThinking: false,
|
||||
defaultReasoning: "normal",
|
||||
defaultThinking: false,
|
||||
},
|
||||
"gpt-5.2-high": {
|
||||
supportsReasoning: false,
|
||||
supportsFast: false,
|
||||
supportsThinking: false,
|
||||
defaultReasoning: "normal",
|
||||
defaultThinking: false,
|
||||
},
|
||||
"gpt-5.1-codex-max": {
|
||||
supportsReasoning: false,
|
||||
supportsFast: false,
|
||||
supportsThinking: false,
|
||||
defaultReasoning: "normal",
|
||||
defaultThinking: false,
|
||||
},
|
||||
"gpt-5.1-codex-mini": {
|
||||
supportsReasoning: false,
|
||||
supportsFast: false,
|
||||
supportsThinking: false,
|
||||
defaultReasoning: "normal",
|
||||
defaultThinking: false,
|
||||
},
|
||||
"gpt-5.1-high": {
|
||||
supportsReasoning: false,
|
||||
supportsFast: false,
|
||||
supportsThinking: false,
|
||||
defaultReasoning: "normal",
|
||||
defaultThinking: false,
|
||||
},
|
||||
"opus-4.6": {
|
||||
supportsReasoning: false,
|
||||
supportsFast: false,
|
||||
supportsThinking: true,
|
||||
defaultReasoning: "normal",
|
||||
defaultThinking: true,
|
||||
},
|
||||
"opus-4.5": {
|
||||
supportsReasoning: false,
|
||||
supportsFast: false,
|
||||
supportsThinking: true,
|
||||
defaultReasoning: "normal",
|
||||
defaultThinking: true,
|
||||
},
|
||||
"sonnet-4.6": {
|
||||
supportsReasoning: false,
|
||||
supportsFast: false,
|
||||
supportsThinking: true,
|
||||
defaultReasoning: "normal",
|
||||
defaultThinking: true,
|
||||
},
|
||||
"sonnet-4.5": {
|
||||
supportsReasoning: false,
|
||||
supportsFast: false,
|
||||
supportsThinking: true,
|
||||
defaultReasoning: "normal",
|
||||
defaultThinking: true,
|
||||
},
|
||||
"gemini-3.1-pro": {
|
||||
supportsReasoning: false,
|
||||
supportsFast: false,
|
||||
supportsThinking: false,
|
||||
defaultReasoning: "normal",
|
||||
defaultThinking: false,
|
||||
},
|
||||
"gemini-3-pro": {
|
||||
supportsReasoning: false,
|
||||
supportsFast: false,
|
||||
supportsThinking: false,
|
||||
defaultReasoning: "normal",
|
||||
defaultThinking: false,
|
||||
},
|
||||
"gemini-3-flash": {
|
||||
supportsReasoning: false,
|
||||
supportsFast: false,
|
||||
supportsThinking: false,
|
||||
defaultReasoning: "normal",
|
||||
defaultThinking: false,
|
||||
},
|
||||
grok: {
|
||||
supportsReasoning: false,
|
||||
supportsFast: false,
|
||||
supportsThinking: false,
|
||||
defaultReasoning: "normal",
|
||||
defaultThinking: false,
|
||||
},
|
||||
"kimi-k2.5": {
|
||||
supportsReasoning: false,
|
||||
supportsFast: false,
|
||||
supportsThinking: false,
|
||||
defaultReasoning: "normal",
|
||||
defaultThinking: false,
|
||||
},
|
||||
};
|
||||
|
||||
const CURSOR_MODEL_FAMILY_SET = new Set<CursorModelFamily>(
|
||||
CURSOR_MODEL_FAMILY_OPTIONS.map((option) => option.slug),
|
||||
);
|
||||
|
||||
export interface CursorModelSelection {
|
||||
readonly family: CursorModelFamily;
|
||||
readonly reasoning: CursorReasoningOption;
|
||||
readonly fast: boolean;
|
||||
readonly thinking: boolean;
|
||||
}
|
||||
|
||||
export const DEFAULT_MODEL_BY_PROVIDER: Record<ProviderKind, ModelSlug> = {
|
||||
codex: "gpt-5.3-codex",
|
||||
claudeCode: "claude-sonnet-4-6",
|
||||
cursor: "opus-4.6-thinking",
|
||||
};
|
||||
|
||||
// Backward compatibility for existing Codex-only call sites.
|
||||
@@ -38,30 +276,180 @@ export const MODEL_SLUG_ALIASES_BY_PROVIDER: Record<ProviderKind, Record<string,
|
||||
"gpt-5.3-spark": "gpt-5.3-codex-spark",
|
||||
},
|
||||
claudeCode: {
|
||||
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",
|
||||
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",
|
||||
"composer-1": "composer-1",
|
||||
"gpt-5.3-codex": "gpt-5.3-codex",
|
||||
"gpt-5.3-codex-spark": "gpt-5.3-codex-spark-preview",
|
||||
"gpt-5.2-codex": "gpt-5.2-codex",
|
||||
"gpt-5.1-codex-max-high": "gpt-5.1-codex-max-high",
|
||||
"gpt-5.1-codex-mini": "gpt-5.1-codex-mini",
|
||||
"gemini-3.1": "gemini-3.1-pro",
|
||||
"gemini-3.1-pro": "gemini-3.1-pro",
|
||||
"gemini-3-pro": "gemini-3-pro",
|
||||
"claude-4.6-sonnet-thinking": "sonnet-4.6-thinking",
|
||||
"claude-4.5-sonnet-thinking": "sonnet-4.5-thinking",
|
||||
"claude-4.6-opus-thinking": "opus-4.6-thinking",
|
||||
"claude-4.5-opus-thinking": "opus-4.5-thinking",
|
||||
"sonnet-4.6-thinking": "sonnet-4.6-thinking",
|
||||
"sonnet-4.5-thinking": "sonnet-4.5-thinking",
|
||||
"opus-4.6-thinking": "opus-4.6-thinking",
|
||||
"opus-4.5-thinking": "opus-4.5-thinking",
|
||||
},
|
||||
};
|
||||
|
||||
const MODEL_SLUG_SET_BY_PROVIDER: Record<ProviderKind, ReadonlySet<ModelSlug>> = {
|
||||
codex: new Set(MODEL_OPTIONS_BY_PROVIDER.codex.map((option) => option.slug)),
|
||||
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)),
|
||||
};
|
||||
|
||||
export function getModelOptions(provider: ProviderKind = "codex") {
|
||||
return MODEL_OPTIONS_BY_PROVIDER[provider];
|
||||
}
|
||||
|
||||
export function getCursorModelFamilyOptions() {
|
||||
return CURSOR_MODEL_FAMILY_OPTIONS;
|
||||
}
|
||||
|
||||
export function getCursorModelCapabilities(family: CursorModelFamily) {
|
||||
return CURSOR_MODEL_CAPABILITY_BY_FAMILY[family];
|
||||
}
|
||||
|
||||
function fallbackCursorModelFamily(): CursorModelFamily {
|
||||
const fallback = parseCursorModelSelection(DEFAULT_MODEL_BY_PROVIDER.cursor);
|
||||
return fallback.family;
|
||||
}
|
||||
|
||||
function resolveCursorModelFamily(model: string | null | undefined): CursorModelFamily {
|
||||
const normalized = normalizeModelSlug(model, "cursor");
|
||||
if (!normalized) {
|
||||
return fallbackCursorModelFamily();
|
||||
}
|
||||
|
||||
if (
|
||||
normalized === "gpt-5.3-codex" ||
|
||||
normalized === "gpt-5.3-codex-fast" ||
|
||||
normalized === "gpt-5.3-codex-low" ||
|
||||
normalized === "gpt-5.3-codex-low-fast" ||
|
||||
normalized === "gpt-5.3-codex-high" ||
|
||||
normalized === "gpt-5.3-codex-high-fast" ||
|
||||
normalized === "gpt-5.3-codex-xhigh" ||
|
||||
normalized === "gpt-5.3-codex-xhigh-fast"
|
||||
) {
|
||||
return "gpt-5.3-codex";
|
||||
}
|
||||
|
||||
if (
|
||||
normalized === "gpt-5.2-codex" ||
|
||||
normalized === "gpt-5.2-codex-fast" ||
|
||||
normalized === "gpt-5.2-codex-low" ||
|
||||
normalized === "gpt-5.2-codex-low-fast" ||
|
||||
normalized === "gpt-5.2-codex-high" ||
|
||||
normalized === "gpt-5.2-codex-high-fast" ||
|
||||
normalized === "gpt-5.2-codex-xhigh" ||
|
||||
normalized === "gpt-5.2-codex-xhigh-fast"
|
||||
) {
|
||||
return "gpt-5.2-codex";
|
||||
}
|
||||
|
||||
if (normalized === "sonnet-4.6-thinking") {
|
||||
return "sonnet-4.6";
|
||||
}
|
||||
if (normalized === "sonnet-4.5-thinking") {
|
||||
return "sonnet-4.5";
|
||||
}
|
||||
if (normalized === "opus-4.6-thinking") {
|
||||
return "opus-4.6";
|
||||
}
|
||||
if (normalized === "opus-4.5-thinking") {
|
||||
return "opus-4.5";
|
||||
}
|
||||
|
||||
return CURSOR_MODEL_FAMILY_SET.has(normalized as CursorModelFamily)
|
||||
? (normalized as CursorModelFamily)
|
||||
: fallbackCursorModelFamily();
|
||||
}
|
||||
|
||||
function resolveCursorReasoning(model: CursorModelSlug): CursorReasoningOption {
|
||||
if (model.includes("-xhigh")) return "xhigh";
|
||||
if (model.includes("-high")) return "high";
|
||||
if (model.includes("-low")) return "low";
|
||||
return "normal";
|
||||
}
|
||||
|
||||
export function parseCursorModelSelection(model: string | null | undefined): CursorModelSelection {
|
||||
const family = resolveCursorModelFamily(model);
|
||||
const capability = CURSOR_MODEL_CAPABILITY_BY_FAMILY[family];
|
||||
const normalized = resolveModelSlugForProvider("cursor", model) as CursorModelSlug;
|
||||
|
||||
if (capability.supportsReasoning) {
|
||||
return {
|
||||
family,
|
||||
reasoning: resolveCursorReasoning(normalized),
|
||||
fast: normalized.endsWith("-fast"),
|
||||
thinking: false,
|
||||
};
|
||||
}
|
||||
|
||||
if (capability.supportsThinking) {
|
||||
return {
|
||||
family,
|
||||
reasoning: capability.defaultReasoning,
|
||||
fast: false,
|
||||
thinking: normalized.endsWith("-thinking"),
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
family,
|
||||
reasoning: capability.defaultReasoning,
|
||||
fast: false,
|
||||
thinking: capability.defaultThinking,
|
||||
};
|
||||
}
|
||||
|
||||
export function resolveCursorModelFromSelection(input: {
|
||||
readonly family: CursorModelFamily;
|
||||
readonly reasoning?: CursorReasoningOption | null;
|
||||
readonly fast?: boolean;
|
||||
readonly thinking?: boolean;
|
||||
}): CursorModelSlug {
|
||||
const family = resolveCursorModelFamily(input.family);
|
||||
const capability = CURSOR_MODEL_CAPABILITY_BY_FAMILY[family];
|
||||
|
||||
if (capability.supportsReasoning) {
|
||||
const reasoning = CURSOR_REASONING_OPTIONS.includes(input.reasoning ?? "normal")
|
||||
? (input.reasoning ?? "normal")
|
||||
: capability.defaultReasoning;
|
||||
const reasoningSuffix = reasoning === "normal" ? "" : `-${reasoning}`;
|
||||
const fastSuffix = input.fast ? "-fast" : "";
|
||||
const candidate = `${family}${reasoningSuffix}${fastSuffix}`;
|
||||
return resolveModelSlugForProvider("cursor", candidate) as CursorModelSlug;
|
||||
}
|
||||
|
||||
if (capability.supportsThinking) {
|
||||
const candidate = input.thinking ? `${family}-thinking` : family;
|
||||
return resolveModelSlugForProvider("cursor", candidate) as CursorModelSlug;
|
||||
}
|
||||
|
||||
return resolveModelSlugForProvider("cursor", family) as CursorModelSlug;
|
||||
}
|
||||
|
||||
export function getDefaultModel(provider: ProviderKind = "codex"): ModelSlug {
|
||||
return DEFAULT_MODEL_BY_PROVIDER[provider];
|
||||
}
|
||||
|
||||
@@ -138,6 +138,25 @@ it.effect("preserves explicit provider and runtime mode in thread.turn.start", (
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("accepts cursor provider in thread.turn.start", () =>
|
||||
Effect.gen(function* () {
|
||||
const parsed = yield* decodeThreadTurnStartCommand({
|
||||
type: "thread.turn.start",
|
||||
commandId: "cmd-turn-cursor",
|
||||
threadId: "thread-1",
|
||||
message: {
|
||||
messageId: "msg-3",
|
||||
role: "user",
|
||||
text: "hello",
|
||||
attachments: [],
|
||||
},
|
||||
provider: "cursor",
|
||||
createdAt: "2026-01-01T00:00:00.000Z",
|
||||
});
|
||||
assert.strictEqual(parsed.provider, "cursor");
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("decodes thread.turn-start-requested defaults for provider and runtime mode", () =>
|
||||
Effect.gen(function* () {
|
||||
const parsed = yield* decodeThreadTurnStartRequestedPayload({
|
||||
|
||||
@@ -29,7 +29,7 @@ export const ORCHESTRATION_WS_CHANNELS = {
|
||||
domainEvent: "orchestration.domainEvent",
|
||||
} as const;
|
||||
|
||||
export const ProviderKind = Schema.Literals(["codex", "claudeCode"]);
|
||||
export const ProviderKind = Schema.Literals(["codex", "claudeCode", "cursor"]);
|
||||
export type ProviderKind = typeof ProviderKind.Type;
|
||||
export const DEFAULT_PROVIDER_KIND: ProviderKind = "codex";
|
||||
export const ProviderApprovalPolicy = Schema.Literals([
|
||||
|
||||
@@ -46,4 +46,18 @@ describe("ProviderSessionStartInput", () => {
|
||||
expect(parsed.approvalPolicy).toBe("never");
|
||||
expect(parsed.sandboxMode).toBe("danger-full-access");
|
||||
});
|
||||
|
||||
it("accepts cursor provider payloads", () => {
|
||||
const parsed = decodeProviderSessionStartInput({
|
||||
provider: "cursor",
|
||||
cwd: "/tmp/workspace",
|
||||
model: "composer-1.5",
|
||||
approvalPolicy: "on-request",
|
||||
sandboxMode: "workspace-write",
|
||||
});
|
||||
expect(parsed.provider).toBe("cursor");
|
||||
expect(parsed.model).toBe("composer-1.5");
|
||||
expect(parsed.approvalPolicy).toBe("on-request");
|
||||
expect(parsed.sandboxMode).toBe("workspace-write");
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user