refactor: move cursor provider surface out of core\n\nCo-authored-by: codex <[email protected]>
This commit is contained in:
1 parent
7d5b896962
commit
daf4b31fbf
28 files changed
+46
-1010
No files matched your search
@@ -188,7 +188,7 @@ export interface OrchestrationIntegrationHarness {
|
||||
}
|
||||
|
||||
interface MakeOrchestrationIntegrationHarnessOptions {
|
||||
readonly provider?: "codex" | "cursor";
|
||||
readonly provider?: "codex";
|
||||
readonly realCodex?: boolean;
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ export interface TestTurnResponse {
|
||||
export type FixtureProviderRuntimeEvent = {
|
||||
readonly type: string;
|
||||
readonly eventId: EventId;
|
||||
readonly provider: "codex" | "cursor";
|
||||
readonly provider: "codex";
|
||||
readonly createdAt: string;
|
||||
readonly threadId: string;
|
||||
readonly turnId?: string | undefined;
|
||||
@@ -178,7 +178,7 @@ function normalizeFixtureEvent(rawEvent: Record<string, unknown>): ProviderRunti
|
||||
|
||||
export interface TestProviderAdapterHarness {
|
||||
readonly adapter: ProviderAdapterShape<ProviderAdapterError>;
|
||||
readonly provider: "codex" | "cursor";
|
||||
readonly provider: "codex";
|
||||
readonly queueTurnResponse: (
|
||||
threadId: ThreadId,
|
||||
response: TestTurnResponse,
|
||||
@@ -198,7 +198,7 @@ export interface TestProviderAdapterHarness {
|
||||
}
|
||||
|
||||
interface MakeTestProviderAdapterHarnessOptions {
|
||||
readonly provider?: "codex" | "cursor";
|
||||
readonly provider?: "codex";
|
||||
}
|
||||
|
||||
function nowIso(): string {
|
||||
@@ -206,7 +206,7 @@ function nowIso(): string {
|
||||
}
|
||||
|
||||
function sessionNotFound(
|
||||
provider: "codex" | "cursor",
|
||||
provider: "codex",
|
||||
threadId: ThreadId,
|
||||
): ProviderAdapterSessionNotFoundError {
|
||||
return new ProviderAdapterSessionNotFoundError({
|
||||
@@ -216,7 +216,7 @@ function sessionNotFound(
|
||||
}
|
||||
|
||||
function missingSessionEffect(
|
||||
provider: "codex" | "cursor",
|
||||
provider: "codex",
|
||||
threadId: ThreadId,
|
||||
): Effect.Effect<never, ProviderAdapterError> {
|
||||
return Effect.fail(sessionNotFound(provider, threadId));
|
||||
|
||||
@@ -32,7 +32,7 @@ const PROJECT_ID = asProjectId("project-1");
|
||||
const THREAD_ID = ThreadId.makeUnsafe("thread-1");
|
||||
const FIXTURE_TURN_ID = "fixture-turn";
|
||||
const APPROVAL_REQUEST_ID = asApprovalRequestId("req-approval-1");
|
||||
type IntegrationProvider = "codex" | "cursor";
|
||||
type IntegrationProvider = "codex";
|
||||
|
||||
function nowIso() {
|
||||
return new Date().toISOString();
|
||||
|
||||
@@ -43,7 +43,7 @@ const asTurnId = (value: string): TurnId => TurnId.makeUnsafe(value);
|
||||
type LegacyProviderRuntimeEvent = {
|
||||
readonly type: string;
|
||||
readonly eventId: EventId;
|
||||
readonly provider: "codex" | "cursor";
|
||||
readonly provider: "codex";
|
||||
readonly createdAt: string;
|
||||
readonly threadId: ThreadId;
|
||||
readonly turnId?: string | undefined;
|
||||
|
||||
@@ -93,8 +93,7 @@ describe("ProviderCommandReactor", () => {
|
||||
typeof input === "object" &&
|
||||
input !== null &&
|
||||
"provider" in input &&
|
||||
(input.provider === "codex" ||
|
||||
input.provider === "cursor")
|
||||
input.provider === "codex"
|
||||
? input.provider
|
||||
: "codex";
|
||||
const resumeCursor =
|
||||
@@ -186,7 +185,7 @@ describe("ProviderCommandReactor", () => {
|
||||
listSessions: () => Effect.succeed(runtimeSessions),
|
||||
getCapabilities: (provider) =>
|
||||
Effect.succeed({
|
||||
sessionModelSwitch: provider === "cursor" ? "unsupported" : "in-session",
|
||||
sessionModelSwitch: provider === "codex" ? "in-session" : "in-session",
|
||||
}),
|
||||
rollbackConversation: () => unsupported(),
|
||||
stopAll: () => Effect.void,
|
||||
@@ -384,43 +383,6 @@ describe("ProviderCommandReactor", () => {
|
||||
});
|
||||
});
|
||||
|
||||
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",
|
||||
interactionMode: DEFAULT_PROVIDER_INTERACTION_MODE,
|
||||
runtimeMode: "approval-required",
|
||||
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",
|
||||
runtimeMode: "approval-required",
|
||||
});
|
||||
|
||||
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?.threadId).toBe("thread-1");
|
||||
});
|
||||
|
||||
it("reuses the same provider session when runtime mode is unchanged", async () => {
|
||||
const harness = await createHarness();
|
||||
const now = new Date().toISOString();
|
||||
@@ -467,111 +429,6 @@ describe("ProviderCommandReactor", () => {
|
||||
expect(harness.stopSession.mock.calls.length).toBe(0);
|
||||
});
|
||||
|
||||
it("reuses the same cursor session when requested model is unchanged", 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-cursor-model-same-1"),
|
||||
threadId: ThreadId.makeUnsafe("thread-1"),
|
||||
message: {
|
||||
messageId: asMessageId("user-message-cursor-model-same-1"),
|
||||
role: "user",
|
||||
text: "first",
|
||||
attachments: [],
|
||||
},
|
||||
provider: "cursor",
|
||||
model: "composer-1.5",
|
||||
interactionMode: DEFAULT_PROVIDER_INTERACTION_MODE,
|
||||
runtimeMode: "approval-required",
|
||||
createdAt: now,
|
||||
}),
|
||||
);
|
||||
|
||||
await waitFor(() => harness.startSession.mock.calls.length === 1);
|
||||
await waitFor(() => harness.sendTurn.mock.calls.length === 1);
|
||||
|
||||
await Effect.runPromise(
|
||||
harness.engine.dispatch({
|
||||
type: "thread.turn.start",
|
||||
commandId: CommandId.makeUnsafe("cmd-turn-start-cursor-model-same-2"),
|
||||
threadId: ThreadId.makeUnsafe("thread-1"),
|
||||
message: {
|
||||
messageId: asMessageId("user-message-cursor-model-same-2"),
|
||||
role: "user",
|
||||
text: "second",
|
||||
attachments: [],
|
||||
},
|
||||
provider: "cursor",
|
||||
model: "composer-1.5",
|
||||
interactionMode: DEFAULT_PROVIDER_INTERACTION_MODE,
|
||||
runtimeMode: "approval-required",
|
||||
createdAt: now,
|
||||
}),
|
||||
);
|
||||
|
||||
await waitFor(() => harness.sendTurn.mock.calls.length === 2);
|
||||
expect(harness.startSession.mock.calls.length).toBe(1);
|
||||
expect(harness.stopSession.mock.calls.length).toBe(0);
|
||||
});
|
||||
|
||||
it("keeps cursor session/model when model change is unsupported", 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-cursor-model-change-1"),
|
||||
threadId: ThreadId.makeUnsafe("thread-1"),
|
||||
message: {
|
||||
messageId: asMessageId("user-message-cursor-model-change-1"),
|
||||
role: "user",
|
||||
text: "first",
|
||||
attachments: [],
|
||||
},
|
||||
provider: "cursor",
|
||||
model: "gpt-5.3-codex",
|
||||
interactionMode: DEFAULT_PROVIDER_INTERACTION_MODE,
|
||||
runtimeMode: "approval-required",
|
||||
createdAt: now,
|
||||
}),
|
||||
);
|
||||
|
||||
await waitFor(() => harness.startSession.mock.calls.length === 1);
|
||||
await waitFor(() => harness.sendTurn.mock.calls.length === 1);
|
||||
|
||||
await Effect.runPromise(
|
||||
harness.engine.dispatch({
|
||||
type: "thread.turn.start",
|
||||
commandId: CommandId.makeUnsafe("cmd-turn-start-cursor-model-change-2"),
|
||||
threadId: ThreadId.makeUnsafe("thread-1"),
|
||||
message: {
|
||||
messageId: asMessageId("user-message-cursor-model-change-2"),
|
||||
role: "user",
|
||||
text: "second",
|
||||
attachments: [],
|
||||
},
|
||||
provider: "cursor",
|
||||
model: "composer-1.5",
|
||||
interactionMode: DEFAULT_PROVIDER_INTERACTION_MODE,
|
||||
runtimeMode: "approval-required",
|
||||
createdAt: now,
|
||||
}),
|
||||
);
|
||||
|
||||
await waitFor(() => harness.sendTurn.mock.calls.length === 2);
|
||||
|
||||
expect(harness.stopSession.mock.calls.length).toBe(0);
|
||||
expect(harness.startSession.mock.calls.length).toBe(1);
|
||||
expect(harness.sendTurn.mock.calls[1]?.[0]).toMatchObject({
|
||||
threadId: ThreadId.makeUnsafe("thread-1"),
|
||||
model: "gpt-5.3-codex",
|
||||
});
|
||||
});
|
||||
|
||||
it("restarts the provider session when runtime mode is updated on the thread", async () => {
|
||||
const harness = await createHarness();
|
||||
const now = new Date().toISOString();
|
||||
@@ -852,7 +709,7 @@ describe("ProviderCommandReactor", () => {
|
||||
harness.respondToRequest.mockImplementation(() =>
|
||||
Effect.fail(
|
||||
new ProviderAdapterRequestError({
|
||||
provider: "cursor",
|
||||
provider: "codex",
|
||||
method: "session/request_permission",
|
||||
detail: "Unknown pending permission request: approval-request-1",
|
||||
}),
|
||||
@@ -867,7 +724,7 @@ describe("ProviderCommandReactor", () => {
|
||||
session: {
|
||||
threadId: ThreadId.makeUnsafe("thread-1"),
|
||||
status: "running",
|
||||
providerName: "cursor",
|
||||
providerName: "codex",
|
||||
runtimeMode: "approval-required",
|
||||
activeTurnId: null,
|
||||
lastError: null,
|
||||
|
||||
@@ -211,10 +211,7 @@ const make = Effect.gen(function* () {
|
||||
|
||||
const desiredRuntimeMode = thread.runtimeMode;
|
||||
const currentProvider: ProviderKind | undefined =
|
||||
thread.session?.providerName === "codex" ||
|
||||
thread.session?.providerName === "cursor"
|
||||
? thread.session.providerName
|
||||
: undefined;
|
||||
thread.session?.providerName === "codex" ? thread.session.providerName : undefined;
|
||||
const preferredProvider: ProviderKind | undefined = options?.provider ?? currentProvider;
|
||||
const desiredModel = options?.model ?? thread.model;
|
||||
const effectiveCwd = resolveThreadWorkspaceCwd({
|
||||
|
||||
@@ -41,7 +41,7 @@ const asTurnId = (value: string): TurnId => TurnId.makeUnsafe(value);
|
||||
type LegacyProviderRuntimeEvent = {
|
||||
readonly type: string;
|
||||
readonly eventId: EventId;
|
||||
readonly provider: "codex" | "cursor";
|
||||
readonly provider: "codex";
|
||||
readonly createdAt: string;
|
||||
readonly threadId: ThreadId;
|
||||
readonly turnId?: string | undefined;
|
||||
|
||||
@@ -157,30 +157,6 @@ const validationLayer = it.layer(
|
||||
);
|
||||
|
||||
validationLayer("CodexAdapterLive validation", (it) => {
|
||||
it.effect("returns validation error for non-codex provider on startSession", () =>
|
||||
Effect.gen(function* () {
|
||||
const adapter = yield* CodexAdapter;
|
||||
const result = yield* adapter
|
||||
.startSession({
|
||||
provider: "cursor",
|
||||
threadId: asThreadId("thread-1"),
|
||||
runtimeMode: "full-access",
|
||||
})
|
||||
.pipe(Effect.result);
|
||||
|
||||
assert.equal(result._tag, "Failure");
|
||||
assert.deepStrictEqual(
|
||||
result.failure,
|
||||
new ProviderAdapterValidationError({
|
||||
provider: "codex",
|
||||
operation: "startSession",
|
||||
issue: "Expected provider 'codex' but received 'cursor'.",
|
||||
}),
|
||||
);
|
||||
assert.equal(validationManager.startSessionImpl.mock.calls.length, 0);
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("maps codex model options before starting a session", () =>
|
||||
Effect.gen(function* () {
|
||||
validationManager.startSessionImpl.mockClear();
|
||||
|
||||
@@ -51,7 +51,7 @@ const asTurnId = (value: string): TurnId => TurnId.makeUnsafe(value);
|
||||
type LegacyProviderRuntimeEvent = {
|
||||
readonly type: string;
|
||||
readonly eventId: EventId;
|
||||
readonly provider: "codex" | "cursor";
|
||||
readonly provider: "codex";
|
||||
readonly createdAt: string;
|
||||
readonly threadId: ThreadId;
|
||||
readonly turnId?: string | undefined;
|
||||
|
||||
@@ -174,26 +174,4 @@ 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 threadId = ThreadId.makeUnsafe("thread-cursor");
|
||||
|
||||
yield* directory.upsert({
|
||||
provider: "cursor",
|
||||
threadId,
|
||||
});
|
||||
|
||||
const provider = yield* directory.getProvider(threadId);
|
||||
assert.equal(provider, "cursor");
|
||||
const resolvedBinding = yield* directory.getBinding(threadId);
|
||||
assertSome(resolvedBinding, {
|
||||
threadId,
|
||||
provider: "cursor",
|
||||
});
|
||||
if (Option.isSome(resolvedBinding)) {
|
||||
assert.equal(resolvedBinding.value.threadId, threadId);
|
||||
}
|
||||
}));
|
||||
});
|
||||
@@ -25,7 +25,7 @@ function decodeProviderKind(
|
||||
providerName: string,
|
||||
operation: string,
|
||||
): Effect.Effect<ProviderKind, ProviderSessionDirectoryPersistenceError> {
|
||||
if (providerName === "codex" || providerName === "cursor") {
|
||||
if (providerName === "codex") {
|
||||
return Effect.succeed(providerName);
|
||||
}
|
||||
return Effect.fail(
|
||||
|
||||
@@ -15,13 +15,6 @@ describe("normalizeCustomModelSlugs", () => {
|
||||
]),
|
||||
).toEqual(["custom/internal-model"]);
|
||||
});
|
||||
|
||||
it("normalizes provider-specific aliases for cursor", () => {
|
||||
expect(normalizeCustomModelSlugs(["composer"], "cursor")).toEqual([]);
|
||||
expect(normalizeCustomModelSlugs(["cursor/custom-model"], "cursor")).toEqual([
|
||||
"cursor/custom-model",
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("getAppModelOptions", () => {
|
||||
@@ -47,14 +40,6 @@ describe("getAppModelOptions", () => {
|
||||
isCustom: true,
|
||||
});
|
||||
});
|
||||
|
||||
it("keeps a saved custom provider model available as an exact slug option", () => {
|
||||
const options = getAppModelOptions("cursor", ["cursor/custom-model"], "cursor/custom-model");
|
||||
|
||||
expect(options.some((option) => option.slug === "cursor/custom-model" && option.isCustom)).toBe(
|
||||
true,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("getSlashModelOptions", () => {
|
||||
@@ -79,10 +64,4 @@ describe("getSlashModelOptions", () => {
|
||||
|
||||
expect(options.map((option) => option.slug)).toEqual(["openai/gpt-oss-120b"]);
|
||||
});
|
||||
|
||||
it("includes provider-specific custom slugs in non-codex model lists", () => {
|
||||
const cursorOptions = getAppModelOptions("cursor", ["cursor/custom-model"]);
|
||||
|
||||
expect(cursorOptions.some((option) => option.slug === "cursor/custom-model")).toBe(true);
|
||||
});
|
||||
});
|
||||
@@ -8,7 +8,6 @@ const MAX_CUSTOM_MODEL_COUNT = 32;
|
||||
export const MAX_CUSTOM_MODEL_LENGTH = 256;
|
||||
const BUILT_IN_MODEL_SLUGS_BY_PROVIDER: Record<ProviderKind, ReadonlySet<string>> = {
|
||||
codex: new Set(getModelOptions("codex").map((option) => option.slug)),
|
||||
cursor: new Set(getModelOptions("cursor").map((option) => option.slug)),
|
||||
};
|
||||
|
||||
const AppSettingsSchema = Schema.Struct({
|
||||
@@ -25,9 +24,6 @@ const AppSettingsSchema = Schema.Struct({
|
||||
customCodexModels: Schema.Array(Schema.String).pipe(
|
||||
Schema.withConstructorDefault(() => Option.some([])),
|
||||
),
|
||||
customCursorModels: Schema.Array(Schema.String).pipe(
|
||||
Schema.withConstructorDefault(() => Option.some([])),
|
||||
),
|
||||
});
|
||||
export type AppSettings = typeof AppSettingsSchema.Type;
|
||||
export interface AppModelOption {
|
||||
@@ -75,7 +71,6 @@ function normalizeAppSettings(settings: AppSettings): AppSettings {
|
||||
return {
|
||||
...settings,
|
||||
customCodexModels: normalizeCustomModelSlugs(settings.customCodexModels, "codex"),
|
||||
customCursorModels: normalizeCustomModelSlugs(settings.customCursorModels, "cursor"),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
import {
|
||||
type ApprovalRequestId,
|
||||
CURSOR_REASONING_OPTIONS,
|
||||
DEFAULT_MODEL,
|
||||
EDITORS,
|
||||
type EditorId,
|
||||
type KeybindingCommand,
|
||||
type CodexReasoningEffort,
|
||||
type CursorReasoningOption,
|
||||
type MessageId,
|
||||
type ProjectId,
|
||||
type ProjectEntry,
|
||||
@@ -27,12 +25,8 @@ import {
|
||||
import {
|
||||
getDefaultModel,
|
||||
getDefaultReasoningEffort,
|
||||
getCursorModelCapabilities,
|
||||
getCursorModelFamilyOptions,
|
||||
getReasoningEffortOptions,
|
||||
normalizeModelSlug,
|
||||
parseCursorModelSelection,
|
||||
resolveCursorModelFromSelection,
|
||||
resolveModelSlugForProvider,
|
||||
} from "@t3tools/shared/model";
|
||||
import {
|
||||
@@ -761,10 +755,6 @@ export default function ChatView({ threadId }: ChatViewProps) {
|
||||
? (sessionProvider ?? selectedProviderByThreadId ?? null)
|
||||
: null;
|
||||
const selectedProvider: ProviderKind = lockedProvider ?? selectedProviderByThreadId ?? "codex";
|
||||
const cursorModelSelectionLockedReason =
|
||||
hasThreadStarted && selectedProvider === "cursor"
|
||||
? "Cursor currently does not support changing models after the first message in a thread."
|
||||
: null;
|
||||
const baseThreadModel = resolveModelSlugForProvider(
|
||||
selectedProvider,
|
||||
activeThread?.model ??
|
||||
@@ -811,40 +801,16 @@ export default function ChatView({ threadId }: ChatViewProps) {
|
||||
};
|
||||
return Object.keys(codexOptions).length > 0 ? { codex: codexOptions } : undefined;
|
||||
}, [selectedCodexFastModeEnabled, selectedEffort, selectedProvider, supportsReasoningEffort]);
|
||||
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 selectedModelForPicker = selectedModel;
|
||||
const modelOptionsByProvider = useMemo(
|
||||
() => getCustomModelOptionsByProvider(settings),
|
||||
[settings],
|
||||
);
|
||||
const selectedModelForPickerWithCustomFallback = useMemo(() => {
|
||||
if (selectedProvider !== "cursor") {
|
||||
const currentOptions = modelOptionsByProvider[selectedProvider];
|
||||
return currentOptions.some((option) => option.slug === selectedModelForPicker)
|
||||
? selectedModelForPicker
|
||||
: (normalizeModelSlug(selectedModelForPicker, selectedProvider) ?? selectedModelForPicker);
|
||||
}
|
||||
|
||||
const currentOptions = modelOptionsByProvider.cursor;
|
||||
const currentOptions = modelOptionsByProvider[selectedProvider];
|
||||
return currentOptions.some((option) => option.slug === selectedModelForPicker)
|
||||
? selectedModelForPicker
|
||||
: selectedModelForPicker;
|
||||
: (normalizeModelSlug(selectedModelForPicker, selectedProvider) ?? selectedModelForPicker);
|
||||
}, [modelOptionsByProvider, selectedModelForPicker, selectedProvider]);
|
||||
const searchableModelOptions = useMemo(
|
||||
() =>
|
||||
@@ -3009,73 +2975,23 @@ export default function ChatView({ threadId }: ChatViewProps) {
|
||||
const onProviderModelSelect = useCallback(
|
||||
(provider: ProviderKind, model: ModelSlug) => {
|
||||
if (!activeThread) return;
|
||||
if (cursorModelSelectionLockedReason !== null && provider === "cursor") {
|
||||
scheduleComposerFocus();
|
||||
return;
|
||||
}
|
||||
if (lockedProvider !== null && provider !== lockedProvider) {
|
||||
scheduleComposerFocus();
|
||||
return;
|
||||
}
|
||||
const resolvedModel =
|
||||
provider === "cursor"
|
||||
? resolveCursorModelFromSelection(parseCursorModelSelection(model))
|
||||
: resolveModelSlugForProvider(provider, model);
|
||||
const resolvedModel = resolveModelSlugForProvider(provider, model);
|
||||
setComposerDraftProvider(activeThread.id, provider);
|
||||
setComposerDraftModel(activeThread.id, resolvedModel);
|
||||
scheduleComposerFocus();
|
||||
},
|
||||
[
|
||||
activeThread,
|
||||
cursorModelSelectionLockedReason,
|
||||
lockedProvider,
|
||||
scheduleComposerFocus,
|
||||
setComposerDraftModel,
|
||||
setComposerDraftProvider,
|
||||
],
|
||||
);
|
||||
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: CodexReasoningEffort) => {
|
||||
setComposerDraftEffort(threadId, effort);
|
||||
@@ -3594,82 +3510,15 @@ export default function ChatView({ threadId }: ChatViewProps) {
|
||||
<div className="flex flex-wrap items-center justify-between gap-2 px-2.5 pb-2.5 sm:flex-nowrap sm:gap-0 sm:px-3 sm:pb-3">
|
||||
<div className="flex min-w-0 flex-1 items-center gap-1 overflow-x-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden sm:min-w-max sm:overflow-visible">
|
||||
{/* Provider/model picker */}
|
||||
{cursorModelSelectionLockedReason ? (
|
||||
<Tooltip>
|
||||
<TooltipTrigger
|
||||
render={
|
||||
<span className="inline-flex">
|
||||
<ProviderModelPicker
|
||||
provider={selectedProvider}
|
||||
model={selectedModelForPickerWithCustomFallback}
|
||||
lockedProvider={lockedProvider}
|
||||
modelOptionsByProvider={modelOptionsByProvider}
|
||||
disabled
|
||||
onProviderModelChange={onProviderModelSelect}
|
||||
/>
|
||||
</span>
|
||||
}
|
||||
/>
|
||||
<TooltipPopup side="top" className="max-w-72 whitespace-normal leading-tight">
|
||||
{cursorModelSelectionLockedReason}
|
||||
</TooltipPopup>
|
||||
</Tooltip>
|
||||
) : (
|
||||
<ProviderModelPicker
|
||||
provider={selectedProvider}
|
||||
model={selectedModelForPickerWithCustomFallback}
|
||||
lockedProvider={lockedProvider}
|
||||
modelOptionsByProvider={modelOptionsByProvider}
|
||||
onProviderModelChange={onProviderModelSelect}
|
||||
/>
|
||||
)}
|
||||
<ProviderModelPicker
|
||||
provider={selectedProvider}
|
||||
model={selectedModelForPickerWithCustomFallback}
|
||||
lockedProvider={lockedProvider}
|
||||
modelOptionsByProvider={modelOptionsByProvider}
|
||||
onProviderModelChange={onProviderModelSelect}
|
||||
/>
|
||||
|
||||
{selectedProvider === "cursor" ? (
|
||||
<>
|
||||
{hasSelectedCursorTraits && (
|
||||
<Separator orientation="vertical" className="mx-0.5 hidden h-4 sm:block" />
|
||||
)}
|
||||
|
||||
{selectedCursorModel &&
|
||||
selectedCursorModelCapabilities &&
|
||||
hasSelectedCursorTraits && (
|
||||
<>
|
||||
{cursorModelSelectionLockedReason ? (
|
||||
<Tooltip>
|
||||
<TooltipTrigger
|
||||
render={
|
||||
<span className="inline-flex">
|
||||
<CursorTraitsPicker
|
||||
selection={selectedCursorModel}
|
||||
capabilities={selectedCursorModelCapabilities}
|
||||
disabled
|
||||
onReasoningChange={onCursorReasoningSelect}
|
||||
onFastModeChange={onCursorFastModeChange}
|
||||
onThinkingModeChange={onCursorThinkingModeChange}
|
||||
/>
|
||||
</span>
|
||||
}
|
||||
/>
|
||||
<TooltipPopup
|
||||
side="top"
|
||||
className="max-w-72 whitespace-normal leading-tight"
|
||||
>
|
||||
{cursorModelSelectionLockedReason}
|
||||
</TooltipPopup>
|
||||
</Tooltip>
|
||||
) : (
|
||||
<CursorTraitsPicker
|
||||
selection={selectedCursorModel}
|
||||
capabilities={selectedCursorModelCapabilities}
|
||||
onReasoningChange={onCursorReasoningSelect}
|
||||
onFastModeChange={onCursorFastModeChange}
|
||||
onThinkingModeChange={onCursorThinkingModeChange}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
) : selectedProvider === "codex" && selectedEffort != null ? (
|
||||
{selectedProvider === "codex" && selectedEffort != null ? (
|
||||
<>
|
||||
<Separator orientation="vertical" className="mx-0.5 hidden h-4 sm:block" />
|
||||
<CodexTraitsPicker
|
||||
@@ -5297,18 +5146,9 @@ const COMING_SOON_PROVIDER_OPTIONS = [
|
||||
|
||||
function getCustomModelOptionsByProvider(settings: {
|
||||
customCodexModels: readonly string[];
|
||||
customCursorModels: readonly string[];
|
||||
}): Record<ProviderKind, ReadonlyArray<{ slug: string; name: string }>> {
|
||||
const cursorFamilyOptions = getCursorModelFamilyOptions();
|
||||
return {
|
||||
codex: getAppModelOptions("codex", settings.customCodexModels),
|
||||
cursor: [
|
||||
...cursorFamilyOptions,
|
||||
...getAppModelOptions("cursor", settings.customCursorModels).filter(
|
||||
(option) =>
|
||||
option.isCustom && !cursorFamilyOptions.some((family) => family.slug === option.slug),
|
||||
),
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
@@ -5348,10 +5188,6 @@ function resolveModelForProviderPicker(
|
||||
return resolved.slug;
|
||||
}
|
||||
|
||||
if (provider === "cursor") {
|
||||
return parseCursorModelSelection(normalized).family;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -5562,117 +5398,6 @@ const CodexTraitsPicker = memo(function CodexTraitsPicker(props: {
|
||||
);
|
||||
});
|
||||
|
||||
const CursorTraitsPicker = memo(function CursorTraitsPicker(props: {
|
||||
selection: ReturnType<typeof parseCursorModelSelection>;
|
||||
capabilities: ReturnType<typeof getCursorModelCapabilities>;
|
||||
disabled?: boolean;
|
||||
onReasoningChange: (reasoning: CursorReasoningOption) => void;
|
||||
onFastModeChange: (enabled: boolean) => void;
|
||||
onThinkingModeChange: (enabled: boolean) => void;
|
||||
}) {
|
||||
const [isMenuOpen, setIsMenuOpen] = useState(false);
|
||||
const reasoningLabelByOption: Record<CursorReasoningOption, string> = {
|
||||
low: "Low",
|
||||
normal: "Normal",
|
||||
high: "High",
|
||||
xhigh: "Extra High",
|
||||
};
|
||||
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
|
||||
open={isMenuOpen}
|
||||
onOpenChange={(open) => {
|
||||
if (props.disabled) {
|
||||
setIsMenuOpen(false);
|
||||
return;
|
||||
}
|
||||
setIsMenuOpen(open);
|
||||
}}
|
||||
>
|
||||
<MenuTrigger
|
||||
render={
|
||||
<Button
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
className="shrink-0 whitespace-nowrap px-2 text-muted-foreground/70 hover:text-foreground/80 sm:px-3"
|
||||
disabled={props.disabled}
|
||||
/>
|
||||
}
|
||||
>
|
||||
<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 (props.disabled) return;
|
||||
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) => {
|
||||
if (props.disabled) return;
|
||||
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) => {
|
||||
if (props.disabled) return;
|
||||
props.onThinkingModeChange(value === "on");
|
||||
}}
|
||||
>
|
||||
<MenuRadioItem value="off">off</MenuRadioItem>
|
||||
<MenuRadioItem value="on">on</MenuRadioItem>
|
||||
</MenuRadioGroup>
|
||||
</MenuGroup>
|
||||
)}
|
||||
</MenuPopup>
|
||||
</Menu>
|
||||
);
|
||||
});
|
||||
|
||||
const OpenInPicker = memo(function OpenInPicker({
|
||||
keybindings,
|
||||
availableEditors,
|
||||
|
||||
@@ -394,15 +394,15 @@ describe("composerDraftStore setProvider", () => {
|
||||
it("persists provider-only selection even when prompt/model are empty", () => {
|
||||
const store = useComposerDraftStore.getState();
|
||||
|
||||
store.setProvider(threadId, "cursor");
|
||||
store.setProvider(threadId, "codex");
|
||||
|
||||
expect(useComposerDraftStore.getState().draftsByThreadId[threadId]?.provider).toBe("cursor");
|
||||
expect(useComposerDraftStore.getState().draftsByThreadId[threadId]?.provider).toBe("codex");
|
||||
});
|
||||
|
||||
it("removes empty provider-only draft when provider is reset", () => {
|
||||
const store = useComposerDraftStore.getState();
|
||||
|
||||
store.setProvider(threadId, "cursor");
|
||||
store.setProvider(threadId, "codex");
|
||||
store.setProvider(threadId, null);
|
||||
|
||||
expect(useComposerDraftStore.getState().draftsByThreadId[threadId]).toBeUndefined();
|
||||
|
||||
@@ -208,7 +208,7 @@ function shouldRemoveDraft(draft: ComposerThreadDraftState): boolean {
|
||||
}
|
||||
|
||||
function normalizeProviderKind(value: unknown): ProviderKind | null {
|
||||
return value === "codex" || value === "cursor" ? value : null;
|
||||
return value === "codex" ? value : null;
|
||||
}
|
||||
|
||||
function revokeObjectPreviewUrl(previewUrl: string): void {
|
||||
|
||||
@@ -54,8 +54,6 @@ function getCustomModelsForProvider(
|
||||
provider: ProviderKind,
|
||||
) {
|
||||
switch (provider) {
|
||||
case "cursor":
|
||||
return settings.customCursorModels;
|
||||
case "codex":
|
||||
default:
|
||||
return settings.customCodexModels;
|
||||
@@ -67,8 +65,6 @@ function getDefaultCustomModelsForProvider(
|
||||
provider: ProviderKind,
|
||||
) {
|
||||
switch (provider) {
|
||||
case "cursor":
|
||||
return defaults.customCursorModels;
|
||||
case "codex":
|
||||
default:
|
||||
return defaults.customCodexModels;
|
||||
@@ -77,8 +73,6 @@ function getDefaultCustomModelsForProvider(
|
||||
|
||||
function patchCustomModels(provider: ProviderKind, models: string[]) {
|
||||
switch (provider) {
|
||||
case "cursor":
|
||||
return { customCursorModels: models };
|
||||
case "codex":
|
||||
default:
|
||||
return { customCodexModels: models };
|
||||
@@ -95,7 +89,6 @@ function SettingsRouteView() {
|
||||
Record<ProviderKind, string>
|
||||
>({
|
||||
codex: "",
|
||||
cursor: "",
|
||||
});
|
||||
const [customModelErrorByProvider, setCustomModelErrorByProvider] = useState<
|
||||
Partial<Record<ProviderKind, string | null>>
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
|
||||
import type { ChatMessage, ProposedPlan, SessionPhase, ThreadSession, TurnDiffSummary } from "./types";
|
||||
|
||||
export type ProviderPickerKind = ProviderKind | "claudeCode";
|
||||
export type ProviderPickerKind = ProviderKind | "claudeCode" | "cursor";
|
||||
|
||||
export const PROVIDER_OPTIONS: Array<{
|
||||
value: ProviderPickerKind;
|
||||
|
||||
@@ -141,27 +141,4 @@ describe("store read model sync", () => {
|
||||
|
||||
expect(next.threads[0]?.model).toBe("gpt-5.3-codex");
|
||||
});
|
||||
|
||||
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",
|
||||
runtimeMode: "approval-required",
|
||||
activeTurnId: null,
|
||||
lastError: null,
|
||||
updatedAt: "2026-02-27T00:00:00.000Z",
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
const next = syncServerReadModel(initialState, readModel);
|
||||
|
||||
expect(next.threads[0]?.model).toBe("composer-1.5");
|
||||
expect(next.threads[0]?.session?.provider).toBe("cursor");
|
||||
});
|
||||
});
|
||||
+2
-20
@@ -145,43 +145,25 @@ function toLegacySessionStatus(
|
||||
}
|
||||
|
||||
function toLegacyProvider(providerName: string | null): ProviderKind {
|
||||
if (providerName === "codex" || providerName === "cursor") {
|
||||
if (providerName === "codex") {
|
||||
return providerName;
|
||||
}
|
||||
return "codex";
|
||||
}
|
||||
|
||||
const CODEX_MODEL_SLUGS = new Set<string>(getModelOptions("codex").map((option) => option.slug));
|
||||
const CURSOR_MODEL_SLUGS = new Set<string>(getModelOptions("cursor").map((option) => option.slug));
|
||||
const CURSOR_DISTINCT_MODEL_SLUGS = new Set(
|
||||
[...CURSOR_MODEL_SLUGS].filter((slug) => !CODEX_MODEL_SLUGS.has(slug)),
|
||||
);
|
||||
|
||||
function inferProviderForThreadModel(input: {
|
||||
readonly model: string;
|
||||
readonly sessionProviderName: string | null;
|
||||
}): ProviderKind {
|
||||
if (
|
||||
input.sessionProviderName === "codex" ||
|
||||
input.sessionProviderName === "cursor"
|
||||
) {
|
||||
if (input.sessionProviderName === "codex") {
|
||||
return input.sessionProviderName;
|
||||
}
|
||||
const normalizedCursor = normalizeModelSlug(input.model, "cursor");
|
||||
if (normalizedCursor && CURSOR_DISTINCT_MODEL_SLUGS.has(normalizedCursor)) {
|
||||
return "cursor";
|
||||
}
|
||||
const normalizedCodex = normalizeModelSlug(input.model, "codex");
|
||||
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 "codex";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
import { Schema } from "effect";
|
||||
|
||||
export const CURSOR_REASONING_OPTIONS = ["low", "normal", "high", "xhigh"] as const;
|
||||
export type CursorReasoningOption = (typeof CURSOR_REASONING_OPTIONS)[number];
|
||||
|
||||
export const CODEX_REASONING_EFFORT_OPTIONS = ["xhigh", "high", "medium", "low"] as const;
|
||||
export type CodexReasoningEffort = (typeof CODEX_REASONING_EFFORT_OPTIONS)[number];
|
||||
|
||||
@@ -12,16 +9,8 @@ export const CodexModelOptions = Schema.Struct({
|
||||
});
|
||||
export type CodexModelOptions = typeof CodexModelOptions.Type;
|
||||
|
||||
export const CursorModelOptions = Schema.Struct({
|
||||
reasoning: Schema.optional(Schema.Literals(CURSOR_REASONING_OPTIONS)),
|
||||
fastMode: Schema.optional(Schema.Boolean),
|
||||
thinking: Schema.optional(Schema.Boolean),
|
||||
});
|
||||
export type CursorModelOptions = typeof CursorModelOptions.Type;
|
||||
|
||||
export const ProviderModelOptions = Schema.Struct({
|
||||
codex: Schema.optional(CodexModelOptions),
|
||||
cursor: Schema.optional(CursorModelOptions),
|
||||
});
|
||||
export type ProviderModelOptions = typeof ProviderModelOptions.Type;
|
||||
|
||||
@@ -30,25 +19,6 @@ type ModelOption = {
|
||||
readonly name: string;
|
||||
};
|
||||
|
||||
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: "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: "gemini-3.1-pro", name: "Gemini 3.1 Pro" },
|
||||
] 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.4", name: "GPT-5.4" },
|
||||
@@ -57,37 +27,14 @@ export const MODEL_OPTIONS_BY_PROVIDER = {
|
||||
{ slug: "gpt-5.2-codex", name: "GPT-5.2 Codex" },
|
||||
{ slug: "gpt-5.2", name: "GPT-5.2" },
|
||||
],
|
||||
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: "opus-4.6", name: "Claude 4.6 Opus" },
|
||||
{ slug: "opus-4.6-thinking", name: "Claude 4.6 Opus (Thinking)" },
|
||||
{ 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: "sonnet-4.6-thinking", name: "Claude 4.6 Sonnet (Thinking)" },
|
||||
{ slug: "gemini-3.1-pro", name: "Gemini 3.1 Pro" },
|
||||
],
|
||||
} as const satisfies Record<"codex" | "cursor", readonly ModelOption[]>;
|
||||
} as const satisfies Record<"codex", readonly ModelOption[]>;
|
||||
|
||||
type BuiltInModelSlug =
|
||||
(typeof MODEL_OPTIONS_BY_PROVIDER)[keyof typeof MODEL_OPTIONS_BY_PROVIDER][number]["slug"];
|
||||
export type ModelSlug = BuiltInModelSlug | (string & {});
|
||||
export type CursorModelSlug = (typeof MODEL_OPTIONS_BY_PROVIDER)["cursor"][number]["slug"];
|
||||
|
||||
export const DEFAULT_MODEL_BY_PROVIDER = {
|
||||
codex: "gpt-5.3-codex",
|
||||
cursor: "opus-4.6-thinking",
|
||||
} as const satisfies Record<keyof typeof MODEL_OPTIONS_BY_PROVIDER, ModelSlug>;
|
||||
|
||||
// Backward compatibility for existing Codex-only call sites.
|
||||
@@ -102,25 +49,10 @@ export const MODEL_SLUG_ALIASES_BY_PROVIDER = {
|
||||
"5.3-spark": "gpt-5.3-codex-spark",
|
||||
"gpt-5.3-spark": "gpt-5.3-codex-spark",
|
||||
},
|
||||
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",
|
||||
"gemini-3.1-pro": "gemini-3.1-pro",
|
||||
"claude-4.6-sonnet-thinking": "sonnet-4.6-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",
|
||||
"opus-4.6-thinking": "opus-4.6-thinking",
|
||||
"opus-4.5-thinking": "opus-4.5-thinking",
|
||||
},
|
||||
} as const satisfies Record<keyof typeof MODEL_OPTIONS_BY_PROVIDER, Record<string, ModelSlug>>;
|
||||
|
||||
export const REASONING_EFFORT_OPTIONS_BY_PROVIDER = {
|
||||
codex: CODEX_REASONING_EFFORT_OPTIONS,
|
||||
cursor: [],
|
||||
} as const satisfies Record<
|
||||
keyof typeof MODEL_OPTIONS_BY_PROVIDER,
|
||||
readonly CodexReasoningEffort[]
|
||||
@@ -128,5 +60,4 @@ export const REASONING_EFFORT_OPTIONS_BY_PROVIDER = {
|
||||
|
||||
export const DEFAULT_REASONING_EFFORT_BY_PROVIDER = {
|
||||
codex: "high",
|
||||
cursor: null,
|
||||
} as const satisfies Record<keyof typeof MODEL_OPTIONS_BY_PROVIDER, CodexReasoningEffort | null>;
|
||||
@@ -128,11 +128,11 @@ it.effect("preserves explicit provider and runtime mode in thread.turn.start", (
|
||||
text: "hello",
|
||||
attachments: [],
|
||||
},
|
||||
provider: "cursor",
|
||||
provider: "codex",
|
||||
runtimeMode: "full-access",
|
||||
createdAt: "2026-01-01T00:00:00.000Z",
|
||||
});
|
||||
assert.strictEqual(parsed.provider, "cursor");
|
||||
assert.strictEqual(parsed.provider, "codex");
|
||||
assert.strictEqual(parsed.runtimeMode, "full-access");
|
||||
assert.strictEqual(parsed.interactionMode, DEFAULT_PROVIDER_INTERACTION_MODE);
|
||||
}),
|
||||
@@ -166,26 +166,6 @@ it.effect("accepts provider-scoped model options 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");
|
||||
assert.strictEqual(parsed.interactionMode, DEFAULT_PROVIDER_INTERACTION_MODE);
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect(
|
||||
"decodes thread.turn-start-requested defaults for provider, runtime mode, and interaction mode",
|
||||
() =>
|
||||
|
||||
@@ -27,7 +27,7 @@ export const ORCHESTRATION_WS_CHANNELS = {
|
||||
domainEvent: "orchestration.domainEvent",
|
||||
} as const;
|
||||
|
||||
export const ProviderKind = Schema.Literals(["codex", "cursor"]);
|
||||
export const ProviderKind = Schema.Literal("codex");
|
||||
export type ProviderKind = typeof ProviderKind.Type;
|
||||
export const DEFAULT_PROVIDER_KIND: ProviderKind = "codex";
|
||||
export const RuntimeMode = Schema.Literals(["approval-required", "full-access"]);
|
||||
|
||||
@@ -42,31 +42,6 @@ describe("ProviderSessionStartInput", () => {
|
||||
}),
|
||||
).toThrow();
|
||||
});
|
||||
|
||||
it("accepts cursor provider payloads", () => {
|
||||
const parsed = decodeProviderSessionStartInput({
|
||||
threadId: "thread-1",
|
||||
provider: "cursor",
|
||||
cwd: "/tmp/workspace",
|
||||
model: "composer-1.5",
|
||||
modelOptions: {
|
||||
cursor: {
|
||||
thinking: true,
|
||||
},
|
||||
},
|
||||
providerOptions: {
|
||||
cursor: {
|
||||
binaryPath: "/usr/local/bin/agent",
|
||||
},
|
||||
},
|
||||
runtimeMode: "approval-required",
|
||||
});
|
||||
expect(parsed.provider).toBe("cursor");
|
||||
expect(parsed.model).toBe("composer-1.5");
|
||||
expect(parsed.modelOptions?.cursor?.thinking).toBe(true);
|
||||
expect(parsed.providerOptions?.cursor?.binaryPath).toBe("/usr/local/bin/agent");
|
||||
expect(parsed.runtimeMode).toBe("approval-required");
|
||||
});
|
||||
});
|
||||
|
||||
describe("ProviderSendTurnInput", () => {
|
||||
|
||||
@@ -50,13 +50,8 @@ const CodexProviderStartOptions = Schema.Struct({
|
||||
homePath: Schema.optional(TrimmedNonEmptyStringSchema),
|
||||
});
|
||||
|
||||
const CursorProviderStartOptions = Schema.Struct({
|
||||
binaryPath: Schema.optional(TrimmedNonEmptyStringSchema),
|
||||
});
|
||||
|
||||
const ProviderStartOptions = Schema.Struct({
|
||||
codex: Schema.optional(CodexProviderStartOptions),
|
||||
cursor: Schema.optional(CursorProviderStartOptions),
|
||||
});
|
||||
|
||||
export const ProviderSessionStartInput = Schema.Struct({
|
||||
|
||||
@@ -20,9 +20,6 @@ const RuntimeEventRawSource = Schema.Literals([
|
||||
"codex.app-server.request",
|
||||
"codex.eventmsg",
|
||||
"codex.sdk.thread-event",
|
||||
"cursor.acp.notification",
|
||||
"cursor.acp.request",
|
||||
"cursor.acp.response",
|
||||
]);
|
||||
export type RuntimeEventRawSource = typeof RuntimeEventRawSource.Type;
|
||||
|
||||
|
||||
@@ -1,24 +1,13 @@
|
||||
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,
|
||||
} from "../../contracts/src";
|
||||
import { DEFAULT_MODEL, MODEL_OPTIONS } from "@t3tools/contracts";
|
||||
|
||||
import {
|
||||
getDefaultModel,
|
||||
getDefaultReasoningEffort,
|
||||
getCursorModelFamilyOptions,
|
||||
getModelOptions,
|
||||
getReasoningEffortOptions,
|
||||
normalizeModelSlug,
|
||||
parseCursorModelSelection,
|
||||
resolveCursorModelFromSelection,
|
||||
resolveModelSlug,
|
||||
resolveModelSlugForProvider,
|
||||
} from "./model";
|
||||
|
||||
describe("normalizeModelSlug", () => {
|
||||
@@ -38,17 +27,6 @@ describe("normalizeModelSlug", () => {
|
||||
expect(normalizeModelSlug("gpt-5.2")).toBe("gpt-5.2");
|
||||
expect(normalizeModelSlug("gpt-5.2-codex")).toBe("gpt-5.2-codex");
|
||||
});
|
||||
|
||||
it("uses provider-specific aliases", () => {
|
||||
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");
|
||||
expect(normalizeModelSlug("claude-4.6-sonnet-thinking", "cursor")).toBe(
|
||||
"sonnet-4.6-thinking",
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("resolveModelSlug", () => {
|
||||
@@ -67,70 +45,9 @@ describe("resolveModelSlug", () => {
|
||||
expect(resolveModelSlug(model.slug)).toBe(model.slug);
|
||||
}
|
||||
});
|
||||
|
||||
it("supports provider-aware resolution", () => {
|
||||
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("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(
|
||||
parseCursorModelSelection(DEFAULT_MODEL_BY_PROVIDER.cursor),
|
||||
);
|
||||
});
|
||||
|
||||
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.3-codex",
|
||||
reasoning: "xhigh",
|
||||
fast: true,
|
||||
}),
|
||||
).toBe("gpt-5.3-codex-xhigh-fast");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -138,15 +55,10 @@ describe("getReasoningEffortOptions", () => {
|
||||
it("returns codex reasoning options for codex", () => {
|
||||
expect(getReasoningEffortOptions("codex")).toEqual(["xhigh", "high", "medium", "low"]);
|
||||
});
|
||||
|
||||
it("returns no reasoning options for cursor", () => {
|
||||
expect(getReasoningEffortOptions("cursor")).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("getDefaultReasoningEffort", () => {
|
||||
it("returns provider-scoped defaults", () => {
|
||||
expect(getDefaultReasoningEffort("codex")).toBe("high");
|
||||
expect(getDefaultReasoningEffort("cursor")).toBeNull();
|
||||
});
|
||||
});
|
||||
@@ -1,233 +1,26 @@
|
||||
import {
|
||||
CODEX_REASONING_EFFORT_OPTIONS,
|
||||
CURSOR_MODEL_FAMILY_OPTIONS,
|
||||
CURSOR_REASONING_OPTIONS,
|
||||
DEFAULT_MODEL,
|
||||
DEFAULT_MODEL_BY_PROVIDER,
|
||||
MODEL_OPTIONS_BY_PROVIDER,
|
||||
MODEL_SLUG_ALIASES_BY_PROVIDER,
|
||||
type CodexReasoningEffort,
|
||||
type CursorModelFamily,
|
||||
type CursorModelSlug,
|
||||
type CursorReasoningOption,
|
||||
type ModelSlug,
|
||||
type ProviderKind,
|
||||
} from "../../contracts/src";
|
||||
} from "@t3tools/contracts";
|
||||
|
||||
type CatalogProvider = keyof typeof MODEL_OPTIONS_BY_PROVIDER;
|
||||
|
||||
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,
|
||||
},
|
||||
"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,
|
||||
},
|
||||
"gemini-3.1-pro": {
|
||||
supportsReasoning: false,
|
||||
supportsFast: false,
|
||||
supportsThinking: false,
|
||||
defaultReasoning: "normal",
|
||||
defaultThinking: false,
|
||||
},
|
||||
};
|
||||
|
||||
function hasModelCatalog(provider: ProviderKind): provider is CatalogProvider {
|
||||
return Object.hasOwn(MODEL_OPTIONS_BY_PROVIDER, provider);
|
||||
}
|
||||
|
||||
const MODEL_SLUG_SET_BY_PROVIDER: Record<CatalogProvider, ReadonlySet<ModelSlug>> = {
|
||||
codex: new Set(MODEL_OPTIONS_BY_PROVIDER.codex.map((option) => option.slug)),
|
||||
cursor: new Set(MODEL_OPTIONS_BY_PROVIDER.cursor.map((option) => option.slug)),
|
||||
};
|
||||
|
||||
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 function getModelOptions(provider: ProviderKind = "codex") {
|
||||
return hasModelCatalog(provider) ? 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 === "sonnet-4.6-thinking") {
|
||||
return "sonnet-4.6";
|
||||
}
|
||||
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;
|
||||
return MODEL_OPTIONS_BY_PROVIDER[provider];
|
||||
}
|
||||
|
||||
export function getDefaultModel(provider: ProviderKind = "codex"): ModelSlug {
|
||||
return hasModelCatalog(provider) ? DEFAULT_MODEL_BY_PROVIDER[provider] : DEFAULT_MODEL;
|
||||
return DEFAULT_MODEL_BY_PROVIDER[provider] ?? DEFAULT_MODEL;
|
||||
}
|
||||
|
||||
export function normalizeModelSlug(
|
||||
@@ -243,10 +36,6 @@ export function normalizeModelSlug(
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!hasModelCatalog(provider)) {
|
||||
return trimmed as ModelSlug;
|
||||
}
|
||||
|
||||
const aliases = MODEL_SLUG_ALIASES_BY_PROVIDER[provider] as Record<string, ModelSlug>;
|
||||
return aliases[trimmed] ?? (trimmed as ModelSlug);
|
||||
}
|
||||
@@ -260,11 +49,9 @@ export function resolveModelSlug(
|
||||
return getDefaultModel(provider);
|
||||
}
|
||||
|
||||
if (!hasModelCatalog(provider)) {
|
||||
return getDefaultModel(provider);
|
||||
}
|
||||
|
||||
return MODEL_SLUG_SET_BY_PROVIDER[provider].has(normalized) ? normalized : getDefaultModel(provider);
|
||||
return MODEL_SLUG_SET_BY_PROVIDER[provider].has(normalized)
|
||||
? normalized
|
||||
: getDefaultModel(provider);
|
||||
}
|
||||
|
||||
export function resolveModelSlugForProvider(
|
||||
|
||||
Reference in new issue
Block a user