Normalize provider model IDs and Cursor options
- Canonicalize Claude and Cursor dispatch model slugs - Update provider model selection, defaults, and tests
This commit is contained in:
1 parent
a07ad3a632
commit
87668ec2b7
22 files changed
+778
-2113
No files matched your search
@@ -0,0 +1,315 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* Minimal NDJSON JSON-RPC "agent" for ACP client tests.
|
||||
* Reads stdin lines; writes responses/notifications to stdout.
|
||||
*/
|
||||
import * as readline from "node:readline";
|
||||
import { appendFileSync } from "node:fs";
|
||||
|
||||
const rl = readline.createInterface({ input: process.stdin, crlfDelay: Infinity });
|
||||
const requestLogPath = process.env.T3_ACP_REQUEST_LOG_PATH;
|
||||
const emitToolCalls = process.env.T3_ACP_EMIT_TOOL_CALLS === "1";
|
||||
const sessionId = "mock-session-1";
|
||||
let currentModeId = "ask";
|
||||
let currentModelId = "default";
|
||||
let nextRequestId = 1;
|
||||
|
||||
function configOptions() {
|
||||
return [
|
||||
{
|
||||
id: "model",
|
||||
name: "Model",
|
||||
category: "model",
|
||||
type: "select",
|
||||
currentValue: currentModelId,
|
||||
options: [
|
||||
{ value: "default", name: "Auto" },
|
||||
{ value: "composer-2", name: "Composer 2" },
|
||||
{ value: "composer-2[fast=true]", name: "Composer 2 Fast" },
|
||||
{ value: "gpt-5.3-codex[reasoning=medium,fast=false]", name: "Codex 5.3" },
|
||||
],
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
const availableModes = [
|
||||
{
|
||||
id: "ask",
|
||||
name: "Ask",
|
||||
description: "Request permission before making any changes",
|
||||
},
|
||||
{
|
||||
id: "architect",
|
||||
name: "Architect",
|
||||
description: "Design and plan software systems without implementation",
|
||||
},
|
||||
{
|
||||
id: "code",
|
||||
name: "Code",
|
||||
description: "Write and modify code with full tool access",
|
||||
},
|
||||
];
|
||||
const pendingPermissionRequests = new Map();
|
||||
|
||||
function send(obj) {
|
||||
process.stdout.write(`${JSON.stringify(obj)}\n`);
|
||||
}
|
||||
|
||||
function modeState() {
|
||||
return {
|
||||
currentModeId,
|
||||
availableModes,
|
||||
};
|
||||
}
|
||||
|
||||
function sendSessionUpdate(update, session = sessionId) {
|
||||
send({
|
||||
jsonrpc: "2.0",
|
||||
method: "session/update",
|
||||
params: {
|
||||
sessionId: session,
|
||||
update,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
rl.on("line", (line) => {
|
||||
const trimmed = line.trim();
|
||||
if (!trimmed) return;
|
||||
let msg;
|
||||
try {
|
||||
msg = JSON.parse(trimmed);
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
if (!msg || typeof msg !== "object") return;
|
||||
if (requestLogPath) {
|
||||
appendFileSync(requestLogPath, `${JSON.stringify(msg)}\n`, "utf8");
|
||||
}
|
||||
|
||||
const id = msg.id;
|
||||
const method = msg.method;
|
||||
|
||||
if (method === undefined && id !== undefined && pendingPermissionRequests.has(id)) {
|
||||
const pending = pendingPermissionRequests.get(id);
|
||||
pendingPermissionRequests.delete(id);
|
||||
sendSessionUpdate(
|
||||
{
|
||||
sessionUpdate: "tool_call_update",
|
||||
toolCallId: pending.toolCallId,
|
||||
title: "Terminal",
|
||||
kind: "execute",
|
||||
status: "completed",
|
||||
rawOutput: {
|
||||
exitCode: 0,
|
||||
stdout: '{ "name": "t3" }',
|
||||
stderr: "",
|
||||
},
|
||||
},
|
||||
pending.sessionId,
|
||||
);
|
||||
sendSessionUpdate(
|
||||
{
|
||||
sessionUpdate: "agent_message_chunk",
|
||||
content: { type: "text", text: "hello from mock" },
|
||||
},
|
||||
pending.sessionId,
|
||||
);
|
||||
send({
|
||||
jsonrpc: "2.0",
|
||||
id: pending.promptRequestId,
|
||||
result: { stopReason: "end_turn" },
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (method === "initialize" && id !== undefined) {
|
||||
send({
|
||||
jsonrpc: "2.0",
|
||||
id,
|
||||
result: {
|
||||
protocolVersion: 1,
|
||||
agentCapabilities: { loadSession: true },
|
||||
},
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (method === "authenticate" && id !== undefined) {
|
||||
send({ jsonrpc: "2.0", id, result: { authenticated: true } });
|
||||
return;
|
||||
}
|
||||
|
||||
if (method === "session/new" && id !== undefined) {
|
||||
send({
|
||||
jsonrpc: "2.0",
|
||||
id,
|
||||
result: {
|
||||
sessionId,
|
||||
modes: modeState(),
|
||||
configOptions: configOptions(),
|
||||
},
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (method === "session/load" && id !== undefined) {
|
||||
const requestedSessionId = msg.params?.sessionId ?? sessionId;
|
||||
sendSessionUpdate(
|
||||
{
|
||||
sessionUpdate: "user_message_chunk",
|
||||
content: { type: "text", text: "replay" },
|
||||
},
|
||||
requestedSessionId,
|
||||
);
|
||||
send({
|
||||
jsonrpc: "2.0",
|
||||
id,
|
||||
result: {
|
||||
modes: modeState(),
|
||||
configOptions: configOptions(),
|
||||
},
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (method === "session/set_config_option" && id !== undefined) {
|
||||
const configId = msg.params?.configId;
|
||||
const value = msg.params?.value;
|
||||
if (configId === "model" && typeof value === "string") {
|
||||
currentModelId = value;
|
||||
}
|
||||
send({
|
||||
jsonrpc: "2.0",
|
||||
id,
|
||||
result: { configOptions: configOptions() },
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (method === "session/prompt" && id !== undefined) {
|
||||
const requestedSessionId = msg.params?.sessionId ?? sessionId;
|
||||
if (emitToolCalls) {
|
||||
const toolCallId = "tool-call-1";
|
||||
const permissionRequestId = nextRequestId++;
|
||||
sendSessionUpdate(
|
||||
{
|
||||
sessionUpdate: "tool_call",
|
||||
toolCallId,
|
||||
title: "Terminal",
|
||||
kind: "execute",
|
||||
status: "pending",
|
||||
rawInput: {
|
||||
command: ["cat", "server/package.json"],
|
||||
},
|
||||
},
|
||||
requestedSessionId,
|
||||
);
|
||||
sendSessionUpdate(
|
||||
{
|
||||
sessionUpdate: "tool_call_update",
|
||||
toolCallId,
|
||||
status: "in_progress",
|
||||
},
|
||||
requestedSessionId,
|
||||
);
|
||||
pendingPermissionRequests.set(permissionRequestId, {
|
||||
promptRequestId: id,
|
||||
sessionId: requestedSessionId,
|
||||
toolCallId,
|
||||
});
|
||||
send({
|
||||
jsonrpc: "2.0",
|
||||
id: permissionRequestId,
|
||||
method: "session/request_permission",
|
||||
params: {
|
||||
sessionId: requestedSessionId,
|
||||
toolCall: {
|
||||
toolCallId,
|
||||
title: "`cat server/package.json`",
|
||||
kind: "execute",
|
||||
status: "pending",
|
||||
content: [
|
||||
{
|
||||
type: "content",
|
||||
content: {
|
||||
type: "text",
|
||||
text: "Not in allowlist: cat server/package.json",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
options: [
|
||||
{ optionId: "allow-once", name: "Allow once", kind: "allow_once" },
|
||||
{ optionId: "allow-always", name: "Allow always", kind: "allow_always" },
|
||||
{ optionId: "reject-once", name: "Reject", kind: "reject_once" },
|
||||
],
|
||||
},
|
||||
});
|
||||
return;
|
||||
}
|
||||
sendSessionUpdate(
|
||||
{
|
||||
sessionUpdate: "plan",
|
||||
explanation: `Mock plan while in ${currentModeId}`,
|
||||
entries: [
|
||||
{
|
||||
content: "Inspect mock ACP state",
|
||||
priority: "high",
|
||||
status: "completed",
|
||||
},
|
||||
{
|
||||
content: "Implement the requested change",
|
||||
priority: "high",
|
||||
status: "in_progress",
|
||||
},
|
||||
],
|
||||
},
|
||||
requestedSessionId,
|
||||
);
|
||||
sendSessionUpdate(
|
||||
{
|
||||
sessionUpdate: "agent_message_chunk",
|
||||
content: { type: "text", text: "hello from mock" },
|
||||
},
|
||||
requestedSessionId,
|
||||
);
|
||||
send({
|
||||
jsonrpc: "2.0",
|
||||
id,
|
||||
result: { stopReason: "end_turn" },
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if ((method === "session/set_mode" || method === "session/mode/set") && id !== undefined) {
|
||||
const nextModeId =
|
||||
typeof msg.params?.modeId === "string"
|
||||
? msg.params.modeId
|
||||
: typeof msg.params?.mode === "string"
|
||||
? msg.params.mode
|
||||
: undefined;
|
||||
if (typeof nextModeId === "string" && nextModeId.trim()) {
|
||||
currentModeId = nextModeId.trim();
|
||||
sendSessionUpdate({
|
||||
sessionUpdate: "current_mode_update",
|
||||
currentModeId,
|
||||
});
|
||||
}
|
||||
send({ jsonrpc: "2.0", id, result: null });
|
||||
return;
|
||||
}
|
||||
|
||||
if (method === "session/cancel" && id !== undefined) {
|
||||
send({ jsonrpc: "2.0", id, result: null });
|
||||
return;
|
||||
}
|
||||
|
||||
if (id !== undefined) {
|
||||
send({
|
||||
jsonrpc: "2.0",
|
||||
id,
|
||||
error: { code: -32601, message: `Unhandled method: ${String(method)}` },
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -28,8 +28,8 @@ import {
|
||||
sanitizeThreadTitle,
|
||||
toJsonSchemaObject,
|
||||
} from "../Utils.ts";
|
||||
import { normalizeClaudeModelOptionsWithCapabilities } from "@t3tools/shared/model";
|
||||
import { resolveClaudeApiModelId } from "../../provider/Layers/ClaudeProvider.ts";
|
||||
import { resolveClaudeApiModelId } from "../../provider/Layers/ClaudeModelId.ts";
|
||||
import { normalizeClaudeModelOptions } from "../../provider/Layers/ClaudeProvider.ts";
|
||||
import { ServerSettingsService } from "../../serverSettings.ts";
|
||||
import { getClaudeModelCapabilities } from "../../provider/Layers/ClaudeProvider.ts";
|
||||
|
||||
@@ -100,26 +100,27 @@ const makeClaudeTextGeneration = Effect.gen(function* () {
|
||||
(settings) => settings.providers.claudeAgent,
|
||||
).pipe(Effect.catch(() => Effect.undefined));
|
||||
|
||||
const runClaudeCommand = Effect.fn("runClaudeJson.runClaudeCommand")(function* () {
|
||||
const command = ChildProcess.make(
|
||||
claudeSettings?.binaryPath || "claude",
|
||||
[
|
||||
"-p",
|
||||
"--output-format",
|
||||
"json",
|
||||
"--json-schema",
|
||||
jsonSchemaStr,
|
||||
"--model",
|
||||
resolveClaudeApiModelId(modelSelection),
|
||||
...(normalizedOptions?.effort ? ["--effort", normalizedOptions.effort] : []),
|
||||
...(Object.keys(settings).length > 0 ? ["--settings", JSON.stringify(settings)] : []),
|
||||
"--dangerously-skip-permissions",
|
||||
],
|
||||
{
|
||||
cwd,
|
||||
shell: process.platform === "win32",
|
||||
stdin: {
|
||||
stream: Stream.encodeText(Stream.make(prompt)),
|
||||
const runClaudeCommand = Effect.gen(function* () {
|
||||
const command = ChildProcess.make(
|
||||
claudeSettings?.binaryPath || "claude",
|
||||
[
|
||||
"-p",
|
||||
"--output-format",
|
||||
"json",
|
||||
"--json-schema",
|
||||
jsonSchemaStr,
|
||||
"--model",
|
||||
resolveClaudeApiModelId(modelSelection),
|
||||
...(normalizedOptions?.effort ? ["--effort", normalizedOptions.effort] : []),
|
||||
...(Object.keys(settings).length > 0 ? ["--settings", JSON.stringify(settings)] : []),
|
||||
"--dangerously-skip-permissions",
|
||||
],
|
||||
{
|
||||
cwd,
|
||||
shell: process.platform === "win32",
|
||||
stdin: {
|
||||
stream: Stream.encodeText(Stream.make(prompt)),
|
||||
},
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
@@ -1104,7 +1104,11 @@ describe("ProviderCommandReactor", () => {
|
||||
text: "second cursor turn",
|
||||
attachments: [],
|
||||
},
|
||||
modelSelection: { provider: "cursor", model: "composer-2-fast" },
|
||||
modelSelection: {
|
||||
provider: "cursor",
|
||||
model: "composer-2",
|
||||
options: { fastMode: true },
|
||||
},
|
||||
interactionMode: DEFAULT_PROVIDER_INTERACTION_MODE,
|
||||
runtimeMode: "approval-required",
|
||||
createdAt: now,
|
||||
@@ -1115,7 +1119,7 @@ describe("ProviderCommandReactor", () => {
|
||||
|
||||
expect(harness.startSession.mock.calls.length).toBe(1);
|
||||
expect(harness.sendTurn.mock.calls[1]?.[0]).toMatchObject({
|
||||
modelSelection: { provider: "cursor", model: "composer-2-fast" },
|
||||
modelSelection: { provider: "cursor", model: "composer-2", options: { fastMode: true } },
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -61,7 +61,8 @@ import {
|
||||
import { resolveAttachmentPath } from "../../attachmentStore.ts";
|
||||
import { ServerConfig } from "../../config.ts";
|
||||
import { ServerSettingsService } from "../../serverSettings.ts";
|
||||
import { getClaudeModelCapabilities, resolveClaudeApiModelId } from "./ClaudeProvider.ts";
|
||||
import { getClaudeModelCapabilities } from "./ClaudeProvider.ts";
|
||||
import { resolveClaudeApiModelId } from "./ClaudeModelId.ts";
|
||||
import {
|
||||
ProviderAdapterProcessError,
|
||||
ProviderAdapterRequestError,
|
||||
@@ -1235,10 +1236,167 @@ const makeClaudeAdapter = Effect.fn("makeClaudeAdapter")(function* (
|
||||
entry.block.fallbackText = text;
|
||||
}
|
||||
|
||||
if (entry.block.streamClosed && !entry.block.completionEmitted) {
|
||||
yield* completeAssistantTextBlock(context, entry.block, {
|
||||
rawMethod: "claude/assistant",
|
||||
rawPayload: message,
|
||||
const requestedStamp = yield* makeEventStamp();
|
||||
yield* offerRuntimeEvent({
|
||||
type: "request.opened",
|
||||
eventId: requestedStamp.eventId,
|
||||
provider: PROVIDER,
|
||||
createdAt: requestedStamp.createdAt,
|
||||
threadId: context.session.threadId,
|
||||
...(context.turnState
|
||||
? { turnId: asCanonicalTurnId(context.turnState.turnId) }
|
||||
: {}),
|
||||
requestId: asRuntimeRequestId(requestId),
|
||||
payload: {
|
||||
requestType,
|
||||
detail,
|
||||
args: {
|
||||
toolName,
|
||||
input: toolInput,
|
||||
...(callbackOptions.toolUseID ? { toolUseId: callbackOptions.toolUseID } : {}),
|
||||
},
|
||||
},
|
||||
providerRefs: nativeProviderRefs(context, {
|
||||
providerItemId: callbackOptions.toolUseID,
|
||||
}),
|
||||
raw: {
|
||||
source: "claude.sdk.permission",
|
||||
method: "canUseTool/request",
|
||||
payload: {
|
||||
toolName,
|
||||
input: toolInput,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
pendingApprovals.set(requestId, pendingApproval);
|
||||
|
||||
const onAbort = () => {
|
||||
if (!pendingApprovals.has(requestId)) {
|
||||
return;
|
||||
}
|
||||
pendingApprovals.delete(requestId);
|
||||
Effect.runFork(Deferred.succeed(decisionDeferred, "cancel"));
|
||||
};
|
||||
|
||||
callbackOptions.signal.addEventListener("abort", onAbort, {
|
||||
once: true,
|
||||
});
|
||||
|
||||
const decision = yield* Deferred.await(decisionDeferred);
|
||||
pendingApprovals.delete(requestId);
|
||||
|
||||
const resolvedStamp = yield* makeEventStamp();
|
||||
yield* offerRuntimeEvent({
|
||||
type: "request.resolved",
|
||||
eventId: resolvedStamp.eventId,
|
||||
provider: PROVIDER,
|
||||
createdAt: resolvedStamp.createdAt,
|
||||
threadId: context.session.threadId,
|
||||
...(context.turnState
|
||||
? { turnId: asCanonicalTurnId(context.turnState.turnId) }
|
||||
: {}),
|
||||
requestId: asRuntimeRequestId(requestId),
|
||||
payload: {
|
||||
requestType,
|
||||
decision,
|
||||
},
|
||||
providerRefs: nativeProviderRefs(context, {
|
||||
providerItemId: callbackOptions.toolUseID,
|
||||
}),
|
||||
raw: {
|
||||
source: "claude.sdk.permission",
|
||||
method: "canUseTool/decision",
|
||||
payload: {
|
||||
decision,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
if (decision === "accept" || decision === "acceptForSession") {
|
||||
return {
|
||||
behavior: "allow",
|
||||
updatedInput: toolInput,
|
||||
...(decision === "acceptForSession" && pendingApproval.suggestions
|
||||
? { updatedPermissions: [...pendingApproval.suggestions] }
|
||||
: {}),
|
||||
} satisfies PermissionResult;
|
||||
}
|
||||
|
||||
return {
|
||||
behavior: "deny",
|
||||
message:
|
||||
decision === "cancel"
|
||||
? "User cancelled tool execution."
|
||||
: "User declined tool execution.",
|
||||
} satisfies PermissionResult;
|
||||
}),
|
||||
);
|
||||
|
||||
const claudeSettings = yield* serverSettingsService.getSettings.pipe(
|
||||
Effect.map((settings) => settings.providers.claudeAgent),
|
||||
Effect.mapError(
|
||||
(error) =>
|
||||
new ProviderAdapterProcessError({
|
||||
provider: PROVIDER,
|
||||
threadId: input.threadId,
|
||||
detail: error.message,
|
||||
cause: error,
|
||||
}),
|
||||
),
|
||||
);
|
||||
const claudeBinaryPath = claudeSettings.binaryPath;
|
||||
const modelSelection =
|
||||
input.modelSelection?.provider === "claudeAgent" ? input.modelSelection : undefined;
|
||||
const caps = getClaudeModelCapabilities(modelSelection?.model);
|
||||
const apiModelId = modelSelection ? resolveClaudeApiModelId(modelSelection) : undefined;
|
||||
const effort = (resolveEffort(caps, modelSelection?.options?.effort) ??
|
||||
null) as ClaudeCodeEffort | null;
|
||||
const fastMode = modelSelection?.options?.fastMode === true && caps.supportsFastMode;
|
||||
const thinking =
|
||||
typeof modelSelection?.options?.thinking === "boolean" && caps.supportsThinkingToggle
|
||||
? modelSelection.options.thinking
|
||||
: undefined;
|
||||
const effectiveEffort = getEffectiveClaudeCodeEffort(effort);
|
||||
const permissionMode =
|
||||
input.runtimeMode === "full-access" ? "bypassPermissions" : undefined;
|
||||
const settings = {
|
||||
...(typeof thinking === "boolean" ? { alwaysThinkingEnabled: thinking } : {}),
|
||||
...(fastMode ? { fastMode: true } : {}),
|
||||
};
|
||||
|
||||
const queryOptions: ClaudeQueryOptions = {
|
||||
...(input.cwd ? { cwd: input.cwd } : {}),
|
||||
...(apiModelId ? { model: apiModelId } : {}),
|
||||
pathToClaudeCodeExecutable: claudeBinaryPath,
|
||||
settingSources: [...CLAUDE_SETTING_SOURCES],
|
||||
...(effectiveEffort ? { effort: effectiveEffort } : {}),
|
||||
...(permissionMode ? { permissionMode } : {}),
|
||||
...(permissionMode === "bypassPermissions"
|
||||
? { allowDangerouslySkipPermissions: true }
|
||||
: {}),
|
||||
...(Object.keys(settings).length > 0 ? { settings } : {}),
|
||||
...(existingResumeSessionId ? { resume: existingResumeSessionId } : {}),
|
||||
...(newSessionId ? { sessionId: newSessionId } : {}),
|
||||
includePartialMessages: true,
|
||||
canUseTool,
|
||||
env: process.env,
|
||||
...(input.cwd ? { additionalDirectories: [input.cwd] } : {}),
|
||||
};
|
||||
|
||||
const queryRuntime = yield* Effect.try({
|
||||
try: () =>
|
||||
createQuery({
|
||||
prompt,
|
||||
options: queryOptions,
|
||||
}),
|
||||
catch: (cause) =>
|
||||
new ProviderAdapterProcessError({
|
||||
provider: PROVIDER,
|
||||
threadId,
|
||||
detail: toMessage(cause, "Failed to start Claude runtime session."),
|
||||
cause,
|
||||
}),
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1711,11 +1869,61 @@ const makeClaudeAdapter = Effect.fn("makeClaudeAdapter")(function* (
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.type === "content_block_start") {
|
||||
const { index, content_block: block } = event;
|
||||
if (block.type === "text") {
|
||||
yield* ensureAssistantTextBlock(context, index, {
|
||||
fallbackText: extractContentBlockText(block),
|
||||
if (modelSelection?.model) {
|
||||
const apiModelId = resolveClaudeApiModelId(modelSelection);
|
||||
yield* Effect.tryPromise({
|
||||
try: () => context.query.setModel(apiModelId),
|
||||
catch: (cause) => toRequestError(input.threadId, "turn/setModel", cause),
|
||||
});
|
||||
}
|
||||
|
||||
// Apply interaction mode by switching the SDK's permission mode.
|
||||
// "plan" maps directly to the SDK's "plan" permission mode;
|
||||
// "default" restores the session's original permission mode.
|
||||
// When interactionMode is absent we leave the current mode unchanged.
|
||||
if (input.interactionMode === "plan") {
|
||||
yield* Effect.tryPromise({
|
||||
try: () => context.query.setPermissionMode("plan"),
|
||||
catch: (cause) => toRequestError(input.threadId, "turn/setPermissionMode", cause),
|
||||
});
|
||||
} else if (input.interactionMode === "default") {
|
||||
yield* Effect.tryPromise({
|
||||
try: () =>
|
||||
context.query.setPermissionMode(context.basePermissionMode ?? "bypassPermissions"),
|
||||
catch: (cause) => toRequestError(input.threadId, "turn/setPermissionMode", cause),
|
||||
});
|
||||
}
|
||||
|
||||
const turnId = TurnId.makeUnsafe(yield* Random.nextUUIDv4);
|
||||
const turnState: ClaudeTurnState = {
|
||||
turnId,
|
||||
startedAt: yield* nowIso,
|
||||
items: [],
|
||||
assistantTextBlocks: new Map(),
|
||||
assistantTextBlockOrder: [],
|
||||
capturedProposedPlanKeys: new Set(),
|
||||
nextSyntheticAssistantBlockIndex: -1,
|
||||
};
|
||||
|
||||
const updatedAt = yield* nowIso;
|
||||
context.turnState = turnState;
|
||||
context.session = {
|
||||
...context.session,
|
||||
status: "running",
|
||||
activeTurnId: turnId,
|
||||
updatedAt,
|
||||
};
|
||||
|
||||
const turnStartedStamp = yield* makeEventStamp();
|
||||
yield* offerRuntimeEvent({
|
||||
type: "turn.started",
|
||||
eventId: turnStartedStamp.eventId,
|
||||
provider: PROVIDER,
|
||||
createdAt: turnStartedStamp.createdAt,
|
||||
threadId: context.session.threadId,
|
||||
turnId,
|
||||
payload: modelSelection?.model ? { model: modelSelection.model } : {},
|
||||
providerRefs: {},
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { resolveClaudeApiModelId } from "./ClaudeModelId.ts";
|
||||
|
||||
describe("resolveClaudeApiModelId", () => {
|
||||
it("appends [1m] for 1m context window", () => {
|
||||
expect(
|
||||
resolveClaudeApiModelId({
|
||||
provider: "claudeAgent",
|
||||
model: "claude-opus-4-6",
|
||||
options: { contextWindow: "1m" },
|
||||
}),
|
||||
).toBe("claude-opus-4-6[1m]");
|
||||
});
|
||||
|
||||
it("returns the canonical slug for default context windows", () => {
|
||||
expect(
|
||||
resolveClaudeApiModelId({
|
||||
provider: "claudeAgent",
|
||||
model: "claude-opus-4-6",
|
||||
options: { contextWindow: "200k" },
|
||||
}),
|
||||
).toBe("claude-opus-4-6");
|
||||
expect(resolveClaudeApiModelId({ provider: "claudeAgent", model: "claude-opus-4-6" })).toBe(
|
||||
"claude-opus-4-6",
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,10 @@
|
||||
import type { ClaudeModelSelection } from "@t3tools/contracts";
|
||||
|
||||
export function resolveClaudeApiModelId(modelSelection: ClaudeModelSelection): string {
|
||||
switch (modelSelection.options?.contextWindow) {
|
||||
case "1m":
|
||||
return `${modelSelection.model}[1m]`;
|
||||
default:
|
||||
return modelSelection.model;
|
||||
}
|
||||
}
|
||||
@@ -8,12 +8,12 @@ import { assert, it } from "@effect/vitest";
|
||||
import { Deferred, Effect, Fiber, Layer, Stream } from "effect";
|
||||
|
||||
import { ApprovalRequestId, type ProviderRuntimeEvent, ThreadId } from "@t3tools/contracts";
|
||||
import { resolveCursorDispatchModel } from "@t3tools/shared/model";
|
||||
|
||||
import { ServerConfig } from "../../config.ts";
|
||||
import { ServerSettingsService } from "../../serverSettings.ts";
|
||||
import { CursorAdapter } from "../Services/CursorAdapter.ts";
|
||||
import { makeCursorAdapterLive } from "./CursorAdapter.ts";
|
||||
import { resolveCursorDispatchModel } from "./CursorProvider.ts";
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
const mockAgentPath = path.join(__dirname, "../../../scripts/acp-mock-agent.mjs");
|
||||
@@ -465,7 +465,7 @@ cursorAdapterTestLayer("CursorAdapterLive", (it) => {
|
||||
|
||||
const argvRuns = yield* Effect.promise(() => readArgvLog(argvLogPath));
|
||||
assert.lengthOf(argvRuns, 1, "session should not restart — only one spawn");
|
||||
assert.deepStrictEqual(argvRuns[0], ["--model", "composer-2", "acp"]);
|
||||
assert.deepStrictEqual(argvRuns[0], ["--model", "composer-2[fast=false]", "acp"]);
|
||||
|
||||
const requests = yield* Effect.promise(() => readJsonLines(requestLogPath));
|
||||
const setConfigRequests = requests.filter(
|
||||
@@ -473,7 +473,10 @@ cursorAdapterTestLayer("CursorAdapterLive", (it) => {
|
||||
);
|
||||
assert.isAbove(setConfigRequests.length, 0, "should call session/set_config_option");
|
||||
const lastSetConfig = setConfigRequests[setConfigRequests.length - 1];
|
||||
assert.equal((lastSetConfig?.params as Record<string, unknown>)?.value, "composer-2-fast");
|
||||
assert.equal(
|
||||
(lastSetConfig?.params as Record<string, unknown>)?.value,
|
||||
"composer-2[fast=true]",
|
||||
);
|
||||
|
||||
yield* adapter.stopSession(threadId);
|
||||
}),
|
||||
|
||||
@@ -22,7 +22,6 @@ import {
|
||||
TurnId,
|
||||
type UserInputQuestion,
|
||||
} from "@t3tools/contracts";
|
||||
import { resolveCursorDispatchModel } from "@t3tools/shared/model";
|
||||
import {
|
||||
Cause,
|
||||
DateTime,
|
||||
@@ -57,6 +56,7 @@ import {
|
||||
import type { AcpInboundMessage } from "../acp/AcpTypes.ts";
|
||||
import { AcpProcessExitedError, AcpRpcError, type AcpError } from "../acp/AcpErrors.ts";
|
||||
import { CursorAdapter, type CursorAdapterShape } from "../Services/CursorAdapter.ts";
|
||||
import { resolveCursorDispatchModel } from "./CursorProvider.ts";
|
||||
import { type EventNdjsonLogger, makeEventNdjsonLogger } from "./EventNdjsonLogger.ts";
|
||||
|
||||
const PROVIDER = "cursor" as const;
|
||||
|
||||
@@ -1,687 +1,47 @@
|
||||
import * as path from "node:path";
|
||||
import * as os from "node:os";
|
||||
import { chmod, mkdtemp, readFile, writeFile } from "node:fs/promises";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
import * as NodeServices from "@effect/platform-node/NodeServices";
|
||||
import { Effect } from "effect";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import type * as EffectAcpSchema from "effect-acp/schema";
|
||||
import type { CursorSettings, ServerProviderModel } from "@t3tools/contracts";
|
||||
|
||||
import {
|
||||
buildCursorProviderSnapshot,
|
||||
buildCursorCapabilitiesFromConfigOptions,
|
||||
buildCursorDiscoveredModelsFromConfigOptions,
|
||||
discoverCursorModelCapabilitiesViaAcp,
|
||||
discoverCursorModelsViaAcp,
|
||||
getCursorFallbackModels,
|
||||
getCursorParameterizedModelPickerUnsupportedMessage,
|
||||
parseCursorAboutOutput,
|
||||
parseCursorCliConfigChannel,
|
||||
parseCursorVersionDate,
|
||||
resolveCursorAcpBaseModelId,
|
||||
resolveCursorAcpConfigUpdates,
|
||||
} from "./CursorProvider.ts";
|
||||
import { getCursorModelCapabilities, resolveCursorDispatchModel } from "./CursorProvider.ts";
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
const mockAgentPath = path.join(__dirname, "../../../scripts/acp-mock-agent.ts");
|
||||
|
||||
async function makeMockAgentWrapper(extraEnv?: Record<string, string>) {
|
||||
const dir = await mkdtemp(path.join(os.tmpdir(), "cursor-provider-mock-"));
|
||||
const wrapperPath = path.join(dir, "fake-agent.sh");
|
||||
const envExports = Object.entries(extraEnv ?? {})
|
||||
.map(([key, value]) => `export ${key}=${JSON.stringify(value)}`)
|
||||
.join("\n");
|
||||
const script = `#!/bin/sh
|
||||
${envExports}
|
||||
exec ${JSON.stringify("bun")} ${JSON.stringify(mockAgentPath)} "$@"
|
||||
`;
|
||||
await writeFile(wrapperPath, script, "utf8");
|
||||
await chmod(wrapperPath, 0o755);
|
||||
return wrapperPath;
|
||||
}
|
||||
|
||||
async function waitForFileContent(filePath: string, attempts = 40): Promise<string> {
|
||||
for (let attempt = 0; attempt < attempts; attempt += 1) {
|
||||
try {
|
||||
const content = await readFile(filePath, "utf8");
|
||||
if (content.trim().length > 0) {
|
||||
return content;
|
||||
}
|
||||
} catch {}
|
||||
await new Promise((resolve) => setTimeout(resolve, 50));
|
||||
}
|
||||
throw new Error(`Timed out waiting for file content at ${filePath}`);
|
||||
}
|
||||
|
||||
const parameterizedGpt54ConfigOptions = [
|
||||
{
|
||||
type: "select",
|
||||
currentValue: "gpt-5.4-medium-fast",
|
||||
options: [{ name: "GPT-5.4", value: "gpt-5.4-medium-fast" }],
|
||||
category: "model",
|
||||
id: "model",
|
||||
name: "Model",
|
||||
},
|
||||
{
|
||||
type: "select",
|
||||
currentValue: "medium",
|
||||
options: [
|
||||
{ name: "None", value: "none" },
|
||||
{ name: "Low", value: "low" },
|
||||
{ name: "Medium", value: "medium" },
|
||||
{ name: "High", value: "high" },
|
||||
{ name: "Extra High", value: "extra-high" },
|
||||
],
|
||||
category: "thought_level",
|
||||
id: "reasoning",
|
||||
name: "Reasoning",
|
||||
},
|
||||
{
|
||||
type: "select",
|
||||
currentValue: "272k",
|
||||
options: [
|
||||
{ name: "272K", value: "272k" },
|
||||
{ name: "1M", value: "1m" },
|
||||
],
|
||||
category: "model_config",
|
||||
id: "context",
|
||||
name: "Context",
|
||||
},
|
||||
{
|
||||
type: "select",
|
||||
currentValue: "false",
|
||||
options: [
|
||||
{ name: "Off", value: "false" },
|
||||
{ name: "Fast", value: "true" },
|
||||
],
|
||||
category: "model_config",
|
||||
id: "fast",
|
||||
name: "Fast",
|
||||
},
|
||||
] satisfies ReadonlyArray<EffectAcpSchema.SessionConfigOption>;
|
||||
|
||||
const parameterizedClaudeConfigOptions = [
|
||||
{
|
||||
type: "select",
|
||||
currentValue: "claude-4.6-opus-high-thinking",
|
||||
options: [{ name: "Opus 4.6", value: "claude-4.6-opus-high-thinking" }],
|
||||
category: "model",
|
||||
id: "model",
|
||||
name: "Model",
|
||||
},
|
||||
{
|
||||
type: "select",
|
||||
currentValue: "high",
|
||||
options: [
|
||||
{ name: "Low", value: "low" },
|
||||
{ name: "Medium", value: "medium" },
|
||||
{ name: "High", value: "high" },
|
||||
],
|
||||
category: "thought_level",
|
||||
id: "reasoning",
|
||||
name: "Reasoning",
|
||||
},
|
||||
{
|
||||
type: "boolean",
|
||||
currentValue: true,
|
||||
category: "model_config",
|
||||
id: "thinking",
|
||||
name: "Thinking",
|
||||
},
|
||||
] satisfies ReadonlyArray<EffectAcpSchema.SessionConfigOption>;
|
||||
|
||||
const parameterizedClaudeModelOptionConfigOptions = [
|
||||
{
|
||||
type: "select",
|
||||
currentValue: "claude-opus-4-6",
|
||||
options: [{ name: "Opus 4.6", value: "claude-opus-4-6" }],
|
||||
category: "model",
|
||||
id: "model",
|
||||
name: "Model",
|
||||
},
|
||||
{
|
||||
type: "select",
|
||||
currentValue: "high",
|
||||
options: [
|
||||
{ name: "Low", value: "low" },
|
||||
{ name: "Medium", value: "medium" },
|
||||
{ name: "High", value: "high" },
|
||||
],
|
||||
category: "thought_level",
|
||||
id: "reasoning",
|
||||
name: "Reasoning",
|
||||
},
|
||||
{
|
||||
type: "select",
|
||||
currentValue: "max",
|
||||
options: [
|
||||
{ name: "Low", value: "low" },
|
||||
{ name: "Medium", value: "medium" },
|
||||
{ name: "High", value: "high" },
|
||||
{ name: "Max", value: "max" },
|
||||
],
|
||||
category: "model_option",
|
||||
id: "effort",
|
||||
name: "Effort",
|
||||
},
|
||||
{
|
||||
type: "select",
|
||||
currentValue: "true",
|
||||
options: [
|
||||
{ name: "Off", value: "false" },
|
||||
{ name: "Fast", value: "true" },
|
||||
],
|
||||
category: "model_config",
|
||||
id: "fast",
|
||||
name: "Fast",
|
||||
},
|
||||
{
|
||||
type: "select",
|
||||
currentValue: "true",
|
||||
options: [
|
||||
{ name: "Off", value: "false" },
|
||||
{ name: ":icon-brain:", value: "true" },
|
||||
],
|
||||
category: "model_config",
|
||||
id: "thinking",
|
||||
name: "Thinking",
|
||||
},
|
||||
] satisfies ReadonlyArray<EffectAcpSchema.SessionConfigOption>;
|
||||
|
||||
const sessionNewCursorConfigOptions = [
|
||||
{
|
||||
type: "select",
|
||||
currentValue: "agent",
|
||||
options: [
|
||||
{ name: "Agent", value: "agent", description: "Full agent capabilities with tool access" },
|
||||
],
|
||||
category: "mode",
|
||||
id: "mode",
|
||||
name: "Mode",
|
||||
description: "Controls how the agent executes tasks",
|
||||
},
|
||||
{
|
||||
type: "select",
|
||||
currentValue: "composer-2",
|
||||
options: [
|
||||
{ name: "Auto", value: "default" },
|
||||
{ name: "Composer 2", value: "composer-2" },
|
||||
{ name: "GPT-5.4", value: "gpt-5.4" },
|
||||
{ name: "Sonnet 4.6", value: "claude-sonnet-4-6" },
|
||||
{ name: "Opus 4.6", value: "claude-opus-4-6" },
|
||||
{ name: "Codex 5.3 Spark", value: "gpt-5.3-codex-spark" },
|
||||
],
|
||||
category: "model",
|
||||
id: "model",
|
||||
name: "Model",
|
||||
description: "Controls which model is used for responses",
|
||||
},
|
||||
{
|
||||
type: "select",
|
||||
currentValue: "true",
|
||||
options: [
|
||||
{ name: "Off", value: "false" },
|
||||
{ name: "Fast", value: "true" },
|
||||
],
|
||||
category: "model_config",
|
||||
id: "fast",
|
||||
name: "Fast",
|
||||
description: "Faster speeds.",
|
||||
},
|
||||
] satisfies ReadonlyArray<EffectAcpSchema.SessionConfigOption>;
|
||||
|
||||
const baseCursorSettings: CursorSettings = {
|
||||
enabled: true,
|
||||
binaryPath: "agent",
|
||||
apiEndpoint: "",
|
||||
customModels: [],
|
||||
};
|
||||
|
||||
const emptyCapabilities = {
|
||||
reasoningEffortLevels: [],
|
||||
supportsFastMode: false,
|
||||
supportsThinkingToggle: false,
|
||||
contextWindowOptions: [],
|
||||
promptInjectedEffortLevels: [],
|
||||
} as const;
|
||||
|
||||
describe("getCursorFallbackModels", () => {
|
||||
it("does not publish any built-in cursor models before ACP discovery", () => {
|
||||
expect(
|
||||
getCursorFallbackModels({
|
||||
customModels: ["internal/cursor-model"],
|
||||
}).map((model) => model.slug),
|
||||
).toEqual(["internal/cursor-model"]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("buildCursorProviderSnapshot", () => {
|
||||
it("downgrades ready status to warning when ACP model discovery times out", () => {
|
||||
expect(
|
||||
buildCursorProviderSnapshot({
|
||||
checkedAt: "2026-01-01T00:00:00.000Z",
|
||||
cursorSettings: baseCursorSettings,
|
||||
parsed: {
|
||||
version: "2026.04.09-f2b0fcd",
|
||||
status: "ready",
|
||||
auth: { status: "authenticated", type: "Team", label: "Cursor Team Subscription" },
|
||||
},
|
||||
discoveryWarning: "Cursor ACP model discovery timed out after 15000ms.",
|
||||
}),
|
||||
).toMatchObject({
|
||||
status: "warning",
|
||||
message: "Cursor ACP model discovery timed out after 15000ms.",
|
||||
models: [],
|
||||
});
|
||||
});
|
||||
|
||||
it("preserves provider error state while appending discovery warnings", () => {
|
||||
expect(
|
||||
buildCursorProviderSnapshot({
|
||||
checkedAt: "2026-01-01T00:00:00.000Z",
|
||||
cursorSettings: {
|
||||
...baseCursorSettings,
|
||||
customModels: ["claude-sonnet-4-6"],
|
||||
},
|
||||
parsed: {
|
||||
version: "2026.04.09-f2b0fcd",
|
||||
status: "error",
|
||||
auth: { status: "unauthenticated" },
|
||||
message: "Cursor Agent is not authenticated. Run `agent login` and try again.",
|
||||
},
|
||||
discoveryWarning: "Cursor ACP model discovery failed. Check server logs for details.",
|
||||
}),
|
||||
).toMatchObject({
|
||||
status: "error",
|
||||
message:
|
||||
"Cursor Agent is not authenticated. Run `agent login` and try again. Cursor ACP model discovery failed. Check server logs for details.",
|
||||
models: [
|
||||
{
|
||||
slug: "claude-sonnet-4-6",
|
||||
isCustom: true,
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("buildCursorCapabilitiesFromConfigOptions", () => {
|
||||
it("derives model capabilities from parameterized Cursor ACP config options", () => {
|
||||
expect(buildCursorCapabilitiesFromConfigOptions(parameterizedGpt54ConfigOptions)).toEqual({
|
||||
reasoningEffortLevels: [
|
||||
{ value: "low", label: "Low" },
|
||||
{ value: "medium", label: "Medium", isDefault: true },
|
||||
{ value: "high", label: "High" },
|
||||
{ value: "xhigh", label: "Extra High" },
|
||||
],
|
||||
supportsFastMode: true,
|
||||
supportsThinkingToggle: false,
|
||||
contextWindowOptions: [
|
||||
{ value: "272k", label: "272K", isDefault: true },
|
||||
{ value: "1m", label: "1M" },
|
||||
],
|
||||
promptInjectedEffortLevels: [],
|
||||
});
|
||||
});
|
||||
|
||||
it("detects boolean thinking toggles from model_config options", () => {
|
||||
expect(buildCursorCapabilitiesFromConfigOptions(parameterizedClaudeConfigOptions)).toEqual({
|
||||
reasoningEffortLevels: [
|
||||
{ value: "low", label: "Low" },
|
||||
{ value: "medium", label: "Medium" },
|
||||
{ value: "high", label: "High", isDefault: true },
|
||||
],
|
||||
supportsFastMode: false,
|
||||
supportsThinkingToggle: true,
|
||||
contextWindowOptions: [],
|
||||
promptInjectedEffortLevels: [],
|
||||
});
|
||||
});
|
||||
|
||||
it("prefers the newer model_option effort control over legacy thought_level", () => {
|
||||
expect(
|
||||
buildCursorCapabilitiesFromConfigOptions(parameterizedClaudeModelOptionConfigOptions),
|
||||
).toEqual({
|
||||
reasoningEffortLevels: [
|
||||
{ value: "low", label: "Low" },
|
||||
{ value: "medium", label: "Medium" },
|
||||
{ value: "high", label: "High" },
|
||||
{ value: "max", label: "Max", isDefault: true },
|
||||
],
|
||||
supportsFastMode: true,
|
||||
supportsThinkingToggle: true,
|
||||
contextWindowOptions: [],
|
||||
promptInjectedEffortLevels: [],
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("buildCursorDiscoveredModelsFromConfigOptions", () => {
|
||||
it("publishes ACP model choices immediately from session/new config options", () => {
|
||||
expect(buildCursorDiscoveredModelsFromConfigOptions(sessionNewCursorConfigOptions)).toEqual([
|
||||
{
|
||||
slug: "default",
|
||||
name: "Auto",
|
||||
isCustom: false,
|
||||
capabilities: {
|
||||
reasoningEffortLevels: [],
|
||||
supportsFastMode: false,
|
||||
supportsThinkingToggle: false,
|
||||
contextWindowOptions: [],
|
||||
promptInjectedEffortLevels: [],
|
||||
},
|
||||
},
|
||||
{
|
||||
slug: "composer-2",
|
||||
name: "Composer 2",
|
||||
isCustom: false,
|
||||
capabilities: {
|
||||
reasoningEffortLevels: [],
|
||||
supportsFastMode: true,
|
||||
supportsThinkingToggle: false,
|
||||
contextWindowOptions: [],
|
||||
promptInjectedEffortLevels: [],
|
||||
},
|
||||
},
|
||||
{
|
||||
slug: "gpt-5.4",
|
||||
name: "GPT-5.4",
|
||||
isCustom: false,
|
||||
capabilities: {
|
||||
reasoningEffortLevels: [],
|
||||
supportsFastMode: false,
|
||||
supportsThinkingToggle: false,
|
||||
contextWindowOptions: [],
|
||||
promptInjectedEffortLevels: [],
|
||||
},
|
||||
},
|
||||
{
|
||||
slug: "claude-sonnet-4-6",
|
||||
name: "Sonnet 4.6",
|
||||
isCustom: false,
|
||||
capabilities: {
|
||||
reasoningEffortLevels: [],
|
||||
supportsFastMode: false,
|
||||
supportsThinkingToggle: false,
|
||||
contextWindowOptions: [],
|
||||
promptInjectedEffortLevels: [],
|
||||
},
|
||||
},
|
||||
{
|
||||
slug: "claude-opus-4-6",
|
||||
name: "Opus 4.6",
|
||||
isCustom: false,
|
||||
capabilities: {
|
||||
reasoningEffortLevels: [],
|
||||
supportsFastMode: false,
|
||||
supportsThinkingToggle: false,
|
||||
contextWindowOptions: [],
|
||||
promptInjectedEffortLevels: [],
|
||||
},
|
||||
},
|
||||
{
|
||||
slug: "gpt-5.3-codex-spark",
|
||||
name: "Codex 5.3 Spark",
|
||||
isCustom: false,
|
||||
capabilities: {
|
||||
reasoningEffortLevels: [],
|
||||
supportsFastMode: false,
|
||||
supportsThinkingToggle: false,
|
||||
contextWindowOptions: [],
|
||||
promptInjectedEffortLevels: [],
|
||||
},
|
||||
},
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("discoverCursorModelsViaAcp", () => {
|
||||
it("keeps the ACP probe runtime alive long enough to discover models", async () => {
|
||||
const wrapperPath = await makeMockAgentWrapper();
|
||||
|
||||
const models = await Effect.runPromise(
|
||||
discoverCursorModelsViaAcp({
|
||||
enabled: true,
|
||||
binaryPath: wrapperPath,
|
||||
apiEndpoint: "",
|
||||
customModels: [],
|
||||
}).pipe(Effect.provide(NodeServices.layer), Effect.scoped),
|
||||
describe("resolveCursorDispatchModel", () => {
|
||||
it("builds bracket notation from canonical base slugs and capabilities", () => {
|
||||
expect(resolveCursorDispatchModel("composer-2", { fastMode: true })).toBe(
|
||||
"composer-2[fast=true]",
|
||||
);
|
||||
|
||||
expect(models.map((model) => model.slug)).toEqual([
|
||||
"default",
|
||||
"composer-2",
|
||||
"gpt-5.4",
|
||||
"claude-opus-4-6",
|
||||
]);
|
||||
});
|
||||
|
||||
it("closes the ACP probe runtime after discovery completes", async () => {
|
||||
const tempDir = await mkdtemp(path.join(os.tmpdir(), "cursor-provider-exit-log-"));
|
||||
const exitLogPath = path.join(tempDir, "exit.log");
|
||||
const wrapperPath = await makeMockAgentWrapper({
|
||||
T3_ACP_EXIT_LOG_PATH: exitLogPath,
|
||||
});
|
||||
|
||||
await Effect.runPromise(
|
||||
discoverCursorModelsViaAcp({
|
||||
enabled: true,
|
||||
binaryPath: wrapperPath,
|
||||
apiEndpoint: "",
|
||||
customModels: [],
|
||||
}).pipe(Effect.provide(NodeServices.layer)),
|
||||
expect(resolveCursorDispatchModel("gpt-5.4", undefined)).toBe(
|
||||
"gpt-5.4[reasoning=medium,context=272k,fast=false]",
|
||||
);
|
||||
|
||||
const exitLog = await waitForFileContent(exitLogPath);
|
||||
expect(exitLog).toContain("SIGTERM");
|
||||
});
|
||||
});
|
||||
|
||||
describe("discoverCursorModelCapabilitiesViaAcp", () => {
|
||||
it("closes all ACP probe runtimes after capability enrichment completes", async () => {
|
||||
const tempDir = await mkdtemp(path.join(os.tmpdir(), "cursor-capabilities-exit-log-"));
|
||||
const exitLogPath = path.join(tempDir, "exit.log");
|
||||
const wrapperPath = await makeMockAgentWrapper({
|
||||
T3_ACP_EXIT_LOG_PATH: exitLogPath,
|
||||
});
|
||||
const existingModels: ReadonlyArray<ServerProviderModel> = [
|
||||
{ slug: "default", name: "Auto", isCustom: false, capabilities: emptyCapabilities },
|
||||
{ slug: "composer-2", name: "Composer 2", isCustom: false, capabilities: emptyCapabilities },
|
||||
{ slug: "gpt-5.4", name: "GPT-5.4", isCustom: false, capabilities: emptyCapabilities },
|
||||
{
|
||||
slug: "claude-opus-4-6",
|
||||
name: "Opus 4.6",
|
||||
isCustom: false,
|
||||
capabilities: emptyCapabilities,
|
||||
},
|
||||
];
|
||||
|
||||
const models = await Effect.runPromise(
|
||||
discoverCursorModelCapabilitiesViaAcp(
|
||||
{
|
||||
enabled: true,
|
||||
binaryPath: wrapperPath,
|
||||
apiEndpoint: "",
|
||||
customModels: [],
|
||||
},
|
||||
existingModels,
|
||||
).pipe(Effect.provide(NodeServices.layer)),
|
||||
);
|
||||
|
||||
expect(models.map((model) => model.slug)).toEqual([
|
||||
"default",
|
||||
"composer-2",
|
||||
"gpt-5.4",
|
||||
"claude-opus-4-6",
|
||||
]);
|
||||
|
||||
const exitLog = await waitForFileContent(exitLogPath);
|
||||
expect(exitLog.match(/SIGTERM/g)?.length ?? 0).toBe(4);
|
||||
});
|
||||
});
|
||||
|
||||
describe("parseCursorAboutOutput", () => {
|
||||
it("parses json about output and forwards subscription metadata", () => {
|
||||
expect(
|
||||
parseCursorAboutOutput({
|
||||
code: 0,
|
||||
stdout: JSON.stringify({
|
||||
cliVersion: "2026.04.09-f2b0fcd",
|
||||
subscriptionTier: "Team",
|
||||
userEmail: "[email protected]",
|
||||
}),
|
||||
stderr: "",
|
||||
}),
|
||||
).toEqual({
|
||||
version: "2026.04.09-f2b0fcd",
|
||||
status: "ready",
|
||||
auth: {
|
||||
status: "authenticated",
|
||||
type: "Team",
|
||||
label: "Cursor Team Subscription",
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it("treats json about output with a logged-out email as unauthenticated", () => {
|
||||
expect(
|
||||
parseCursorAboutOutput({
|
||||
code: 0,
|
||||
stdout: JSON.stringify({
|
||||
cliVersion: "2026.04.09-f2b0fcd",
|
||||
subscriptionTier: "Team",
|
||||
userEmail: "Not logged in",
|
||||
}),
|
||||
stderr: "",
|
||||
}),
|
||||
).toEqual({
|
||||
version: "2026.04.09-f2b0fcd",
|
||||
status: "error",
|
||||
auth: {
|
||||
status: "unauthenticated",
|
||||
},
|
||||
message: "Cursor Agent is not authenticated. Run `agent login` and try again.",
|
||||
});
|
||||
});
|
||||
|
||||
it("treats json about output with a null email as unauthenticated", () => {
|
||||
expect(
|
||||
parseCursorAboutOutput({
|
||||
code: 0,
|
||||
stdout: JSON.stringify({
|
||||
cliVersion: "2026.04.09-f2b0fcd",
|
||||
subscriptionTier: null,
|
||||
userEmail: null,
|
||||
}),
|
||||
stderr: "",
|
||||
}),
|
||||
).toEqual({
|
||||
version: "2026.04.09-f2b0fcd",
|
||||
status: "error",
|
||||
auth: {
|
||||
status: "unauthenticated",
|
||||
},
|
||||
message: "Cursor Agent is not authenticated. Run `agent login` and try again.",
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("Cursor parameterized model picker preview gating", () => {
|
||||
it("parses Cursor CLI version dates from build versions", () => {
|
||||
expect(parseCursorVersionDate("2026.04.08-c4e73a3")).toBe(20260408);
|
||||
expect(parseCursorVersionDate("2026.04.09")).toBe(20260409);
|
||||
expect(parseCursorVersionDate("not-a-version")).toBeUndefined();
|
||||
});
|
||||
|
||||
it("parses the Cursor CLI channel from cli-config.json", () => {
|
||||
expect(parseCursorCliConfigChannel('{ "channel": "lab" }')).toBe("lab");
|
||||
expect(parseCursorCliConfigChannel('{ "channel": "stable" }')).toBe("stable");
|
||||
expect(parseCursorCliConfigChannel('{ "version": 1 }')).toBeUndefined();
|
||||
expect(parseCursorCliConfigChannel("not-json")).toBeUndefined();
|
||||
});
|
||||
|
||||
it("returns no warning when the preview requirements are met", () => {
|
||||
expect(
|
||||
getCursorParameterizedModelPickerUnsupportedMessage({
|
||||
version: "2026.04.08-c4e73a3",
|
||||
channel: "lab",
|
||||
}),
|
||||
).toBeUndefined();
|
||||
});
|
||||
|
||||
it("explains when the Cursor Agent version is too old", () => {
|
||||
expect(
|
||||
getCursorParameterizedModelPickerUnsupportedMessage({
|
||||
version: "2026.04.07-c4e73a3",
|
||||
channel: "lab",
|
||||
}),
|
||||
).toContain("too old");
|
||||
});
|
||||
|
||||
it("explains when the Cursor Agent channel is not lab", () => {
|
||||
expect(
|
||||
getCursorParameterizedModelPickerUnsupportedMessage({
|
||||
version: "2026.04.08-c4e73a3",
|
||||
channel: "stable",
|
||||
}),
|
||||
).toContain("lab channel");
|
||||
});
|
||||
});
|
||||
|
||||
describe("resolveCursorAcpBaseModelId", () => {
|
||||
it("drops bracket traits without rewriting raw ACP model ids", () => {
|
||||
expect(resolveCursorAcpBaseModelId("gpt-5.4[reasoning=medium,context=272k]")).toBe("gpt-5.4");
|
||||
expect(resolveCursorAcpBaseModelId("gpt-5.4-medium-fast")).toBe("gpt-5.4-medium-fast");
|
||||
expect(resolveCursorAcpBaseModelId("claude-4.6-opus-high-thinking")).toBe(
|
||||
"claude-4.6-opus-high-thinking",
|
||||
);
|
||||
expect(resolveCursorAcpBaseModelId("composer-2")).toBe("composer-2");
|
||||
expect(resolveCursorAcpBaseModelId("auto")).toBe("auto");
|
||||
});
|
||||
});
|
||||
|
||||
describe("resolveCursorAcpConfigUpdates", () => {
|
||||
it("maps Cursor model options onto separate ACP config option updates", () => {
|
||||
expect(
|
||||
resolveCursorAcpConfigUpdates(parameterizedGpt54ConfigOptions, {
|
||||
reasoning: "xhigh",
|
||||
fastMode: true,
|
||||
resolveCursorDispatchModel("claude-opus-4-6", {
|
||||
reasoning: "high",
|
||||
thinking: true,
|
||||
contextWindow: "1m",
|
||||
}),
|
||||
).toEqual([
|
||||
{ configId: "reasoning", value: "extra-high" },
|
||||
{ configId: "context", value: "1m" },
|
||||
{ configId: "fast", value: "true" },
|
||||
]);
|
||||
).toBe("claude-opus-4-6[effort=high,thinking=true,context=1m]");
|
||||
});
|
||||
|
||||
it("maps boolean thinking toggles when the model exposes them separately", () => {
|
||||
expect(
|
||||
resolveCursorAcpConfigUpdates(parameterizedClaudeConfigOptions, {
|
||||
thinking: false,
|
||||
}),
|
||||
).toEqual([{ configId: "thinking", value: false }]);
|
||||
it("maps legacy cursor aliases onto the canonical base slug", () => {
|
||||
expect(resolveCursorDispatchModel("gpt-5.4-1m", undefined)).toBe(
|
||||
"gpt-5.4[reasoning=medium,context=272k,fast=false]",
|
||||
);
|
||||
expect(resolveCursorDispatchModel("auto", undefined)).toBe("default[]");
|
||||
expect(resolveCursorDispatchModel("claude-4.6-opus", undefined)).toBe(
|
||||
"claude-opus-4-6[effort=high,thinking=true,context=200k]",
|
||||
);
|
||||
});
|
||||
|
||||
it("maps explicit fastMode: false so the adapter can clear a prior fast selection", () => {
|
||||
expect(
|
||||
resolveCursorAcpConfigUpdates(parameterizedGpt54ConfigOptions, {
|
||||
fastMode: false,
|
||||
}),
|
||||
).toEqual([{ configId: "fast", value: "false" }]);
|
||||
});
|
||||
|
||||
it("writes Cursor effort changes through the newer model_option config when available", () => {
|
||||
expect(
|
||||
resolveCursorAcpConfigUpdates(parameterizedClaudeModelOptionConfigOptions, {
|
||||
reasoning: "max",
|
||||
thinking: false,
|
||||
}),
|
||||
).toEqual([
|
||||
{ configId: "effort", value: "max" },
|
||||
{ configId: "thinking", value: "false" },
|
||||
]);
|
||||
it("passes custom models through unchanged", () => {
|
||||
expect(resolveCursorDispatchModel("custom/internal-model", undefined)).toBe(
|
||||
"custom/internal-model[]",
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("getCursorModelCapabilities", () => {
|
||||
it("resolves capabilities from canonical cursor base slugs", () => {
|
||||
expect(getCursorModelCapabilities("gpt-5.4").contextWindowOptions).toEqual([
|
||||
{ value: "272k", label: "272k", isDefault: true },
|
||||
{ value: "1m", label: "1M" },
|
||||
]);
|
||||
expect(getCursorModelCapabilities("claude-opus-4-6").supportsThinkingToggle).toBe(true);
|
||||
});
|
||||
});
|
||||
@@ -1,4 +1,5 @@
|
||||
import type {
|
||||
CursorModelOptions,
|
||||
CursorSettings,
|
||||
ModelCapabilities,
|
||||
ServerProvider,
|
||||
@@ -6,6 +7,7 @@ import type {
|
||||
ServerProviderAuthStatus,
|
||||
ServerProviderState,
|
||||
} from "@t3tools/contracts";
|
||||
import { normalizeModelSlug, resolveContextWindow, resolveEffort } from "@t3tools/shared/model";
|
||||
import { Effect, Equal, Layer, Option, Result, Stream } from "effect";
|
||||
import { ChildProcess, ChildProcessSpawner } from "effect/unstable/process";
|
||||
|
||||
@@ -21,9 +23,16 @@ import { CursorProvider } from "../Services/CursorProvider";
|
||||
import { ServerSettingsError, ServerSettingsService } from "../../serverSettings";
|
||||
|
||||
const PROVIDER = "cursor" as const;
|
||||
const EMPTY_CAPABILITIES: ModelCapabilities = {
|
||||
reasoningEffortLevels: [],
|
||||
supportsFastMode: false,
|
||||
supportsThinkingToggle: false,
|
||||
contextWindowOptions: [],
|
||||
promptInjectedEffortLevels: [],
|
||||
};
|
||||
const BUILT_IN_MODELS: ReadonlyArray<ServerProviderModel> = [
|
||||
{
|
||||
slug: "auto",
|
||||
slug: "default",
|
||||
name: "Auto",
|
||||
isCustom: false,
|
||||
capabilities: {
|
||||
@@ -62,7 +71,7 @@ const BUILT_IN_MODELS: ReadonlyArray<ServerProviderModel> = [
|
||||
capabilities: {
|
||||
reasoningEffortLevels: [
|
||||
{ value: "low", label: "Low" },
|
||||
{ value: "normal", label: "Normal", isDefault: true },
|
||||
{ value: "medium", label: "Medium", isDefault: true },
|
||||
{ value: "high", label: "High" },
|
||||
{ value: "xhigh", label: "Extra High" },
|
||||
],
|
||||
@@ -72,13 +81,13 @@ const BUILT_IN_MODELS: ReadonlyArray<ServerProviderModel> = [
|
||||
},
|
||||
},
|
||||
{
|
||||
slug: "gpt-5.3-codex-spark-preview",
|
||||
slug: "gpt-5.3-codex-spark",
|
||||
name: "Codex 5.3 Spark",
|
||||
isCustom: false,
|
||||
capabilities: {
|
||||
reasoningEffortLevels: [
|
||||
{ value: "low", label: "Low" },
|
||||
{ value: "normal", label: "Normal", isDefault: true },
|
||||
{ value: "medium", label: "Medium", isDefault: true },
|
||||
{ value: "high", label: "High" },
|
||||
{ value: "xhigh", label: "Extra High" },
|
||||
],
|
||||
@@ -88,38 +97,54 @@ const BUILT_IN_MODELS: ReadonlyArray<ServerProviderModel> = [
|
||||
},
|
||||
},
|
||||
{
|
||||
slug: "gpt-5.4-1m",
|
||||
name: "GPT 5.4",
|
||||
slug: "gpt-5.4",
|
||||
name: "GPT-5.4",
|
||||
isCustom: false,
|
||||
capabilities: {
|
||||
reasoningEffortLevels: [
|
||||
{ value: "low", label: "Low" },
|
||||
{ value: "normal", label: "Normal", isDefault: true },
|
||||
{ value: "medium", label: "Medium", isDefault: true },
|
||||
{ value: "high", label: "High" },
|
||||
{ value: "xhigh", label: "Extra High" },
|
||||
],
|
||||
supportsFastMode: true,
|
||||
supportsThinkingToggle: false,
|
||||
contextWindowOptions: [
|
||||
{ value: "272k", label: "272k", isDefault: true },
|
||||
{ value: "1m", label: "1M" },
|
||||
],
|
||||
promptInjectedEffortLevels: [],
|
||||
},
|
||||
},
|
||||
{
|
||||
slug: "claude-4.6-opus",
|
||||
name: "Claude Opus 4.6",
|
||||
slug: "claude-opus-4-6",
|
||||
name: "Opus 4.6",
|
||||
isCustom: false,
|
||||
capabilities: {
|
||||
reasoningEffortLevels: [],
|
||||
reasoningEffortLevels: [
|
||||
{ value: "low", label: "Low" },
|
||||
{ value: "medium", label: "Medium" },
|
||||
{ value: "high", label: "High", isDefault: true },
|
||||
],
|
||||
supportsFastMode: false,
|
||||
supportsThinkingToggle: true,
|
||||
contextWindowOptions: [
|
||||
{ value: "200k", label: "200k", isDefault: true },
|
||||
{ value: "1m", label: "1M" },
|
||||
],
|
||||
promptInjectedEffortLevels: [],
|
||||
},
|
||||
},
|
||||
{
|
||||
slug: "claude-4.6-sonnet",
|
||||
name: "Claude Sonnet 4.6",
|
||||
slug: "claude-sonnet-4-6",
|
||||
name: "Sonnet 4.6",
|
||||
isCustom: false,
|
||||
capabilities: {
|
||||
reasoningEffortLevels: [],
|
||||
reasoningEffortLevels: [
|
||||
{ value: "low", label: "Low" },
|
||||
{ value: "medium", label: "Medium", isDefault: true },
|
||||
{ value: "high", label: "High" },
|
||||
],
|
||||
supportsFastMode: false,
|
||||
supportsThinkingToggle: true,
|
||||
promptInjectedEffortLevels: [],
|
||||
@@ -139,17 +164,49 @@ const BUILT_IN_MODELS: ReadonlyArray<ServerProviderModel> = [
|
||||
];
|
||||
|
||||
export function getCursorModelCapabilities(model: string | null | undefined): ModelCapabilities {
|
||||
const slug = model?.trim();
|
||||
const slug = normalizeModelSlug(model, "cursor");
|
||||
return (
|
||||
BUILT_IN_MODELS.find((candidate) => candidate.slug === slug)?.capabilities ?? {
|
||||
reasoningEffortLevels: [],
|
||||
supportsFastMode: false,
|
||||
supportsThinkingToggle: false,
|
||||
promptInjectedEffortLevels: [],
|
||||
}
|
||||
BUILT_IN_MODELS.find((candidate) => candidate.slug === slug)?.capabilities ?? EMPTY_CAPABILITIES
|
||||
);
|
||||
}
|
||||
|
||||
export function resolveCursorDispatchModel(
|
||||
model: string | null | undefined,
|
||||
modelOptions: CursorModelOptions | null | undefined,
|
||||
): string {
|
||||
const slug = normalizeModelSlug(model, "cursor") ?? "default";
|
||||
if (slug.includes("[") && slug.endsWith("]")) {
|
||||
return slug;
|
||||
}
|
||||
const caps = getCursorModelCapabilities(slug);
|
||||
const isBuiltIn = BUILT_IN_MODELS.some((candidate) => candidate.slug === slug);
|
||||
if (!isBuiltIn) {
|
||||
return `${slug}[]`;
|
||||
}
|
||||
|
||||
const traits: string[] = [];
|
||||
const reasoning = resolveEffort(caps, modelOptions?.reasoning);
|
||||
if (reasoning) {
|
||||
traits.push(`${slug.startsWith("claude-") ? "effort" : "reasoning"}=${reasoning}`);
|
||||
}
|
||||
|
||||
const thinking = caps.supportsThinkingToggle ? (modelOptions?.thinking ?? true) : undefined;
|
||||
if (thinking !== undefined) {
|
||||
traits.push(`thinking=${thinking}`);
|
||||
}
|
||||
|
||||
const contextWindow = resolveContextWindow(caps, modelOptions?.contextWindow);
|
||||
if (contextWindow) {
|
||||
traits.push(`context=${contextWindow}`);
|
||||
}
|
||||
|
||||
if (caps.supportsFastMode) {
|
||||
traits.push(`fast=${modelOptions?.fastMode === true}`);
|
||||
}
|
||||
|
||||
return `${slug}[${traits.join(",")}]`;
|
||||
}
|
||||
|
||||
/** Timeout for `agent about` — it's slower than a simple `--version` probe. */
|
||||
const ABOUT_TIMEOUT_MS = 8_000;
|
||||
|
||||
@@ -215,7 +272,6 @@ export function parseCursorAboutOutput(result: CommandResult): CursorAboutResult
|
||||
}
|
||||
|
||||
const plain = stripAnsi(combined);
|
||||
console.log("plain:", plain);
|
||||
const version = extractAboutField(plain, "CLI Version") ?? null;
|
||||
const userEmail = extractAboutField(plain, "User Email");
|
||||
|
||||
|
||||
@@ -122,7 +122,7 @@ async function mountMenu(props?: { modelSelection?: ModelSelection; prompt?: str
|
||||
capabilities: {
|
||||
reasoningEffortLevels: [
|
||||
{ value: "low", label: "Low" },
|
||||
{ value: "normal", label: "Normal", isDefault: true },
|
||||
{ value: "medium", label: "Medium", isDefault: true },
|
||||
{ value: "high", label: "High" },
|
||||
{ value: "xhigh", label: "Extra high" },
|
||||
],
|
||||
|
||||
@@ -140,7 +140,7 @@ const TEST_PROVIDERS: ReadonlyArray<ServerProvider> = [
|
||||
capabilities: {
|
||||
reasoningEffortLevels: [
|
||||
effort("low"),
|
||||
effort("normal", true),
|
||||
effort("medium", true),
|
||||
effort("high"),
|
||||
effort("xhigh"),
|
||||
],
|
||||
@@ -151,7 +151,7 @@ const TEST_PROVIDERS: ReadonlyArray<ServerProvider> = [
|
||||
},
|
||||
},
|
||||
{
|
||||
slug: "claude-4.6-opus",
|
||||
slug: "claude-opus-4-6",
|
||||
name: "Claude Opus 4.6",
|
||||
isCustom: false,
|
||||
capabilities: {
|
||||
@@ -314,10 +314,10 @@ describe("ProviderModelPicker", () => {
|
||||
}
|
||||
});
|
||||
|
||||
it("maps concrete Cursor slugs onto the server-provided model options", async () => {
|
||||
it("uses canonical Cursor slugs from the server-provided model options", async () => {
|
||||
const mounted = await mountPicker({
|
||||
provider: "cursor",
|
||||
model: "claude-4.6-opus-high-thinking",
|
||||
model: "claude-opus-4-6",
|
||||
lockedProvider: "cursor",
|
||||
});
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ const CURSOR_MODELS: ReadonlyArray<ServerProviderModel> = [
|
||||
capabilities: {
|
||||
reasoningEffortLevels: [
|
||||
{ value: "low", label: "Low" },
|
||||
{ value: "normal", label: "Normal", isDefault: true },
|
||||
{ value: "medium", label: "Medium", isDefault: true },
|
||||
{ value: "high", label: "High" },
|
||||
{ value: "xhigh", label: "Extra high" },
|
||||
],
|
||||
@@ -413,13 +413,13 @@ describe("getComposerProviderState", () => {
|
||||
models: CURSOR_MODELS,
|
||||
prompt: "",
|
||||
modelOptions: {
|
||||
cursor: { reasoning: "normal" },
|
||||
cursor: { reasoning: "medium" },
|
||||
},
|
||||
});
|
||||
|
||||
expect(state).toEqual({
|
||||
provider: "cursor",
|
||||
promptEffort: "normal",
|
||||
promptEffort: "medium",
|
||||
modelOptionsForDispatch: undefined,
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import {
|
||||
CODEX_REASONING_EFFORT_OPTIONS,
|
||||
CURSOR_REASONING_OPTIONS,
|
||||
DEFAULT_MODEL_BY_PROVIDER,
|
||||
type ClaudeCodeEffort,
|
||||
type CodexReasoningEffort,
|
||||
type CursorModelOptions,
|
||||
@@ -621,23 +622,13 @@ function normalizeProviderModelOptions(
|
||||
: undefined;
|
||||
const cursorFastMode = cursorCandidate?.fastMode === true;
|
||||
const cursorThinkingFalse = cursorCandidate?.thinking === false;
|
||||
const cursorClaudeOpusTierRaw = cursorCandidate?.claudeOpusTier;
|
||||
const cursorClaudeOpusTier =
|
||||
cursorClaudeOpusTierRaw === "max" || cursorClaudeOpusTierRaw === "high"
|
||||
? cursorClaudeOpusTierRaw
|
||||
: undefined;
|
||||
const defaultCursorReasoning =
|
||||
DEFAULT_REASONING_EFFORT_BY_PROVIDER.cursor as CursorReasoningOption;
|
||||
|
||||
const cursor: CursorModelOptions | undefined =
|
||||
cursorCandidate !== null
|
||||
? {
|
||||
...(cursorReasoning && cursorReasoning !== defaultCursorReasoning
|
||||
? { reasoning: cursorReasoning }
|
||||
: {}),
|
||||
...(cursorReasoning ? { reasoning: cursorReasoning } : {}),
|
||||
...(cursorFastMode ? { fastMode: true } : {}),
|
||||
...(cursorThinkingFalse ? { thinking: false } : {}),
|
||||
...(cursorClaudeOpusTier === "max" ? { claudeOpusTier: "max" } : {}),
|
||||
}
|
||||
: undefined;
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ const PROVIDER_CUSTOM_MODEL_CONFIG: Record<ProviderKind, ProviderCustomModelConf
|
||||
title: "Cursor",
|
||||
description: "Save additional Cursor model slugs for the picker and `/model` command.",
|
||||
placeholder: "your-cursor-model-slug",
|
||||
example: "claude-4.6-sonnet-medium-thinking",
|
||||
example: "claude-sonnet-4-6",
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -108,12 +108,10 @@ export function normalizeCursorModelOptionsWithCapabilities(
|
||||
const fastMode = caps.supportsFastMode && modelOptions?.fastMode === true ? true : undefined;
|
||||
const thinking =
|
||||
caps.supportsThinkingToggle && modelOptions?.thinking === false ? false : undefined;
|
||||
const claudeOpusTier = modelOptions?.claudeOpusTier ?? undefined;
|
||||
const nextOptions: CursorModelOptions = {
|
||||
...(reasoningValue ? { reasoning: reasoningValue } : {}),
|
||||
...(fastMode ? { fastMode: true } : {}),
|
||||
...(thinking === false ? { thinking: false } : {}),
|
||||
...(claudeOpusTier ? { claudeOpusTier } : {}),
|
||||
};
|
||||
return Object.keys(nextOptions).length > 0 ? nextOptions : undefined;
|
||||
}
|
||||
|
||||
@@ -1257,7 +1257,7 @@ function SettingsRouteView() {
|
||||
providerCard.provider === "codex"
|
||||
? "gpt-6.7-codex-ultra-preview"
|
||||
: providerCard.provider === "cursor"
|
||||
? "claude-4.6-sonnet-medium-thinking"
|
||||
? "claude-sonnet-4-6"
|
||||
: "claude-sonnet-5-0"
|
||||
}
|
||||
spellCheck={false}
|
||||
|
||||
@@ -1,343 +0,0 @@
|
||||
{
|
||||
"probeCommand": "agent models",
|
||||
"generatedAt": "2026-03-24T01:37:58.372Z",
|
||||
"agentVersion": "2026.02.27-e7d2ef6",
|
||||
"models": [
|
||||
{
|
||||
"id": "auto",
|
||||
"label": "Auto"
|
||||
},
|
||||
{
|
||||
"id": "composer-2-fast",
|
||||
"label": "Composer 2 Fast"
|
||||
},
|
||||
{
|
||||
"id": "composer-2",
|
||||
"label": "Composer 2"
|
||||
},
|
||||
{
|
||||
"id": "composer-1.5",
|
||||
"label": "Composer 1.5"
|
||||
},
|
||||
{
|
||||
"id": "gpt-5.3-codex-low",
|
||||
"label": "GPT-5.3 Codex Low"
|
||||
},
|
||||
{
|
||||
"id": "gpt-5.3-codex-low-fast",
|
||||
"label": "GPT-5.3 Codex Low Fast"
|
||||
},
|
||||
{
|
||||
"id": "gpt-5.3-codex",
|
||||
"label": "GPT-5.3 Codex"
|
||||
},
|
||||
{
|
||||
"id": "gpt-5.3-codex-fast",
|
||||
"label": "GPT-5.3 Codex Fast"
|
||||
},
|
||||
{
|
||||
"id": "gpt-5.3-codex-high",
|
||||
"label": "GPT-5.3 Codex High"
|
||||
},
|
||||
{
|
||||
"id": "gpt-5.3-codex-high-fast",
|
||||
"label": "GPT-5.3 Codex High Fast"
|
||||
},
|
||||
{
|
||||
"id": "gpt-5.3-codex-xhigh",
|
||||
"label": "GPT-5.3 Codex Extra High"
|
||||
},
|
||||
{
|
||||
"id": "gpt-5.3-codex-xhigh-fast",
|
||||
"label": "GPT-5.3 Codex Extra High Fast"
|
||||
},
|
||||
{
|
||||
"id": "gpt-5.2",
|
||||
"label": "GPT-5.2"
|
||||
},
|
||||
{
|
||||
"id": "gpt-5.3-codex-spark-preview-low",
|
||||
"label": "GPT-5.3 Codex Spark Low"
|
||||
},
|
||||
{
|
||||
"id": "gpt-5.3-codex-spark-preview",
|
||||
"label": "GPT-5.3 Codex Spark"
|
||||
},
|
||||
{
|
||||
"id": "gpt-5.3-codex-spark-preview-high",
|
||||
"label": "GPT-5.3 Codex Spark High"
|
||||
},
|
||||
{
|
||||
"id": "gpt-5.3-codex-spark-preview-xhigh",
|
||||
"label": "GPT-5.3 Codex Spark Extra High"
|
||||
},
|
||||
{
|
||||
"id": "gpt-5.2-codex-low",
|
||||
"label": "GPT-5.2 Codex Low"
|
||||
},
|
||||
{
|
||||
"id": "gpt-5.2-codex-low-fast",
|
||||
"label": "GPT-5.2 Codex Low Fast"
|
||||
},
|
||||
{
|
||||
"id": "gpt-5.2-codex",
|
||||
"label": "GPT-5.2 Codex"
|
||||
},
|
||||
{
|
||||
"id": "gpt-5.2-codex-fast",
|
||||
"label": "GPT-5.2 Codex Fast"
|
||||
},
|
||||
{
|
||||
"id": "gpt-5.2-codex-high",
|
||||
"label": "GPT-5.2 Codex High"
|
||||
},
|
||||
{
|
||||
"id": "gpt-5.2-codex-high-fast",
|
||||
"label": "GPT-5.2 Codex High Fast"
|
||||
},
|
||||
{
|
||||
"id": "gpt-5.2-codex-xhigh",
|
||||
"label": "GPT-5.2 Codex Extra High"
|
||||
},
|
||||
{
|
||||
"id": "gpt-5.2-codex-xhigh-fast",
|
||||
"label": "GPT-5.2 Codex Extra High Fast"
|
||||
},
|
||||
{
|
||||
"id": "gpt-5.1-codex-max-low",
|
||||
"label": "GPT-5.1 Codex Max Low"
|
||||
},
|
||||
{
|
||||
"id": "gpt-5.1-codex-max-low-fast",
|
||||
"label": "GPT-5.1 Codex Max Low Fast"
|
||||
},
|
||||
{
|
||||
"id": "gpt-5.1-codex-max-medium",
|
||||
"label": "GPT-5.1 Codex Max"
|
||||
},
|
||||
{
|
||||
"id": "gpt-5.1-codex-max-medium-fast",
|
||||
"label": "GPT-5.1 Codex Max Medium Fast"
|
||||
},
|
||||
{
|
||||
"id": "gpt-5.1-codex-max-high",
|
||||
"label": "GPT-5.1 Codex Max High"
|
||||
},
|
||||
{
|
||||
"id": "gpt-5.1-codex-max-high-fast",
|
||||
"label": "GPT-5.1 Codex Max High Fast"
|
||||
},
|
||||
{
|
||||
"id": "gpt-5.1-codex-max-xhigh",
|
||||
"label": "GPT-5.1 Codex Max Extra High"
|
||||
},
|
||||
{
|
||||
"id": "gpt-5.1-codex-max-xhigh-fast",
|
||||
"label": "GPT-5.1 Codex Max Extra High Fast"
|
||||
},
|
||||
{
|
||||
"id": "gpt-5.4-high",
|
||||
"label": "GPT-5.4 1M High"
|
||||
},
|
||||
{
|
||||
"id": "gpt-5.4-high-fast",
|
||||
"label": "GPT-5.4 High Fast"
|
||||
},
|
||||
{
|
||||
"id": "gpt-5.4-xhigh-fast",
|
||||
"label": "GPT-5.4 Extra High Fast"
|
||||
},
|
||||
{
|
||||
"id": "claude-4.6-opus-high-thinking",
|
||||
"label": "Opus 4.6 1M Thinking"
|
||||
},
|
||||
{
|
||||
"id": "gpt-5.4-low",
|
||||
"label": "GPT-5.4 1M Low"
|
||||
},
|
||||
{
|
||||
"id": "gpt-5.4-medium",
|
||||
"label": "GPT-5.4 1M"
|
||||
},
|
||||
{
|
||||
"id": "gpt-5.4-medium-fast",
|
||||
"label": "GPT-5.4 Fast"
|
||||
},
|
||||
{
|
||||
"id": "gpt-5.4-xhigh",
|
||||
"label": "GPT-5.4 1M Extra High"
|
||||
},
|
||||
{
|
||||
"id": "claude-4.6-sonnet-medium",
|
||||
"label": "Sonnet 4.6 1M"
|
||||
},
|
||||
{
|
||||
"id": "claude-4.6-sonnet-medium-thinking",
|
||||
"label": "Sonnet 4.6 1M Thinking"
|
||||
},
|
||||
{
|
||||
"id": "claude-4.6-opus-high",
|
||||
"label": "Opus 4.6 1M"
|
||||
},
|
||||
{
|
||||
"id": "claude-4.6-opus-max",
|
||||
"label": "Opus 4.6 1M Max"
|
||||
},
|
||||
{
|
||||
"id": "claude-4.6-opus-max-thinking",
|
||||
"label": "Opus 4.6 1M Max Thinking"
|
||||
},
|
||||
{
|
||||
"id": "claude-4.5-opus-high",
|
||||
"label": "Opus 4.5"
|
||||
},
|
||||
{
|
||||
"id": "claude-4.5-opus-high-thinking",
|
||||
"label": "Opus 4.5 Thinking"
|
||||
},
|
||||
{
|
||||
"id": "gpt-5.2-low",
|
||||
"label": "GPT-5.2 Low"
|
||||
},
|
||||
{
|
||||
"id": "gpt-5.2-low-fast",
|
||||
"label": "GPT-5.2 Low Fast"
|
||||
},
|
||||
{
|
||||
"id": "gpt-5.2-fast",
|
||||
"label": "GPT-5.2 Fast"
|
||||
},
|
||||
{
|
||||
"id": "gpt-5.2-high",
|
||||
"label": "GPT-5.2 High"
|
||||
},
|
||||
{
|
||||
"id": "gpt-5.2-high-fast",
|
||||
"label": "GPT-5.2 High Fast"
|
||||
},
|
||||
{
|
||||
"id": "gpt-5.2-xhigh",
|
||||
"label": "GPT-5.2 Extra High"
|
||||
},
|
||||
{
|
||||
"id": "gpt-5.2-xhigh-fast",
|
||||
"label": "GPT-5.2 Extra High Fast"
|
||||
},
|
||||
{
|
||||
"id": "gemini-3.1-pro",
|
||||
"label": "Gemini 3.1 Pro"
|
||||
},
|
||||
{
|
||||
"id": "gpt-5.4-mini-none",
|
||||
"label": "GPT-5.4 Mini None"
|
||||
},
|
||||
{
|
||||
"id": "gpt-5.4-mini-low",
|
||||
"label": "GPT-5.4 Mini Low"
|
||||
},
|
||||
{
|
||||
"id": "gpt-5.4-mini-medium",
|
||||
"label": "GPT-5.4 Mini"
|
||||
},
|
||||
{
|
||||
"id": "gpt-5.4-mini-high",
|
||||
"label": "GPT-5.4 Mini High"
|
||||
},
|
||||
{
|
||||
"id": "gpt-5.4-mini-xhigh",
|
||||
"label": "GPT-5.4 Mini Extra High"
|
||||
},
|
||||
{
|
||||
"id": "gpt-5.4-nano-none",
|
||||
"label": "GPT-5.4 Nano None"
|
||||
},
|
||||
{
|
||||
"id": "gpt-5.4-nano-low",
|
||||
"label": "GPT-5.4 Nano Low"
|
||||
},
|
||||
{
|
||||
"id": "gpt-5.4-nano-medium",
|
||||
"label": "GPT-5.4 Nano"
|
||||
},
|
||||
{
|
||||
"id": "gpt-5.4-nano-high",
|
||||
"label": "GPT-5.4 Nano High"
|
||||
},
|
||||
{
|
||||
"id": "gpt-5.4-nano-xhigh",
|
||||
"label": "GPT-5.4 Nano Extra High"
|
||||
},
|
||||
{
|
||||
"id": "grok-4-20",
|
||||
"label": "Grok 4.20"
|
||||
},
|
||||
{
|
||||
"id": "grok-4-20-thinking",
|
||||
"label": "Grok 4.20 Thinking"
|
||||
},
|
||||
{
|
||||
"id": "claude-4.5-sonnet",
|
||||
"label": "Sonnet 4.5 1M"
|
||||
},
|
||||
{
|
||||
"id": "claude-4.5-sonnet-thinking",
|
||||
"label": "Sonnet 4.5 1M Thinking"
|
||||
},
|
||||
{
|
||||
"id": "gpt-5.1-low",
|
||||
"label": "GPT-5.1 Low"
|
||||
},
|
||||
{
|
||||
"id": "gpt-5.1",
|
||||
"label": "GPT-5.1"
|
||||
},
|
||||
{
|
||||
"id": "gpt-5.1-high",
|
||||
"label": "GPT-5.1 High"
|
||||
},
|
||||
{
|
||||
"id": "gemini-3-pro",
|
||||
"label": "Gemini 3 Pro"
|
||||
},
|
||||
{
|
||||
"id": "gemini-3-flash",
|
||||
"label": "Gemini 3 Flash"
|
||||
},
|
||||
{
|
||||
"id": "gpt-5.1-codex-mini-low",
|
||||
"label": "GPT-5.1 Codex Mini Low"
|
||||
},
|
||||
{
|
||||
"id": "gpt-5.1-codex-mini",
|
||||
"label": "GPT-5.1 Codex Mini"
|
||||
},
|
||||
{
|
||||
"id": "gpt-5.1-codex-mini-high",
|
||||
"label": "GPT-5.1 Codex Mini High"
|
||||
},
|
||||
{
|
||||
"id": "claude-4-sonnet",
|
||||
"label": "Sonnet 4"
|
||||
},
|
||||
{
|
||||
"id": "claude-4-sonnet-1m",
|
||||
"label": "Sonnet 4 1M"
|
||||
},
|
||||
{
|
||||
"id": "claude-4-sonnet-thinking",
|
||||
"label": "Sonnet 4 Thinking"
|
||||
},
|
||||
{
|
||||
"id": "claude-4-sonnet-1m-thinking",
|
||||
"label": "Sonnet 4 1M Thinking"
|
||||
},
|
||||
{
|
||||
"id": "gpt-5-mini",
|
||||
"label": "GPT-5 Mini"
|
||||
},
|
||||
{
|
||||
"id": "kimi-k2.5",
|
||||
"label": "Kimi K2.5"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,15 +1,12 @@
|
||||
import { Schema } from "effect";
|
||||
import { TrimmedNonEmptyString } from "./baseSchemas";
|
||||
import type { ProviderKind } from "./orchestration";
|
||||
import cursorCliModels from "./cursorCliModels.json" with { type: "json" };
|
||||
|
||||
export const CODEX_REASONING_EFFORT_OPTIONS = ["xhigh", "high", "medium", "low"] as const;
|
||||
export type CodexReasoningEffort = (typeof CODEX_REASONING_EFFORT_OPTIONS)[number];
|
||||
export const CLAUDE_CODE_EFFORT_OPTIONS = ["low", "medium", "high", "max", "ultrathink"] as const;
|
||||
export type ClaudeCodeEffort = (typeof CLAUDE_CODE_EFFORT_OPTIONS)[number];
|
||||
|
||||
/** Cursor “reasoning” tier for GPT‑5.3 Codex–style families (encoded in model slug). */
|
||||
export const CURSOR_REASONING_OPTIONS = ["low", "normal", "high", "xhigh"] as const;
|
||||
export const CURSOR_REASONING_OPTIONS = ["low", "medium", "high", "xhigh"] as const;
|
||||
export type CursorReasoningOption = (typeof CURSOR_REASONING_OPTIONS)[number];
|
||||
|
||||
export type ProviderReasoningEffort =
|
||||
@@ -31,14 +28,11 @@ export const ClaudeModelOptions = Schema.Struct({
|
||||
});
|
||||
export type ClaudeModelOptions = typeof ClaudeModelOptions.Type;
|
||||
|
||||
export const CURSOR_CLAUDE_OPUS_TIER_OPTIONS = ["high", "max"] as const;
|
||||
export type CursorClaudeOpusTier = (typeof CURSOR_CLAUDE_OPUS_TIER_OPTIONS)[number];
|
||||
|
||||
export const CursorModelOptions = Schema.Struct({
|
||||
reasoning: Schema.optional(Schema.Literals(CURSOR_REASONING_OPTIONS)),
|
||||
fastMode: Schema.optional(Schema.Boolean),
|
||||
thinking: Schema.optional(Schema.Boolean),
|
||||
claudeOpusTier: Schema.optional(Schema.Literals(CURSOR_CLAUDE_OPUS_TIER_OPTIONS)),
|
||||
contextWindow: Schema.optional(Schema.String),
|
||||
});
|
||||
export type CursorModelOptions = typeof CursorModelOptions.Type;
|
||||
|
||||
@@ -74,41 +68,10 @@ export const ModelCapabilities = Schema.Struct({
|
||||
});
|
||||
export type ModelCapabilities = typeof ModelCapabilities.Type;
|
||||
|
||||
export type ModelOption = {
|
||||
readonly slug: string;
|
||||
readonly name: string;
|
||||
};
|
||||
|
||||
export const MODEL_OPTIONS_BY_PROVIDER = {
|
||||
codex: [
|
||||
{ slug: "gpt-5.4", name: "GPT-5.4" },
|
||||
{ slug: "gpt-5.4-mini", name: "GPT-5.4 Mini" },
|
||||
{ slug: "gpt-5.3-codex", name: "GPT-5.3 Codex" },
|
||||
{ slug: "gpt-5.3-codex-spark", name: "GPT-5.3 Codex Spark" },
|
||||
{ slug: "gpt-5.2-codex", name: "GPT-5.2 Codex" },
|
||||
{ slug: "gpt-5.2", name: "GPT-5.2" },
|
||||
],
|
||||
claudeAgent: [
|
||||
{ slug: "claude-opus-4-6", name: "Claude Opus 4.6" },
|
||||
{ slug: "claude-sonnet-4-6", name: "Claude Sonnet 4.6" },
|
||||
{ slug: "claude-haiku-4-5", name: "Claude Haiku 4.5" },
|
||||
],
|
||||
cursor: cursorCliModels.models.map((m) => ({
|
||||
slug: m.id,
|
||||
name: m.label,
|
||||
})) satisfies ReadonlyArray<ModelOption>,
|
||||
} as const satisfies Record<ProviderKind, readonly ModelOption[]>;
|
||||
export type ModelOptionsByProvider = typeof MODEL_OPTIONS_BY_PROVIDER;
|
||||
|
||||
export type ModelSlug = string & {};
|
||||
|
||||
/** Any built-in id returned by the Cursor CLI for `--model` (see `cursorCliModels.json`). */
|
||||
export type CursorModelSlug = (typeof MODEL_OPTIONS_BY_PROVIDER)["cursor"][number]["slug"];
|
||||
|
||||
export const DEFAULT_MODEL_BY_PROVIDER: Record<ProviderKind, ModelSlug> = {
|
||||
export const DEFAULT_MODEL_BY_PROVIDER: Record<ProviderKind, string> = {
|
||||
codex: "gpt-5.4",
|
||||
claudeAgent: "claude-sonnet-4-6",
|
||||
cursor: "claude-4.6-opus-high-thinking",
|
||||
cursor: "auto",
|
||||
};
|
||||
|
||||
export const DEFAULT_MODEL = DEFAULT_MODEL_BY_PROVIDER.codex;
|
||||
@@ -117,7 +80,7 @@ export const DEFAULT_MODEL = DEFAULT_MODEL_BY_PROVIDER.codex;
|
||||
export const DEFAULT_GIT_TEXT_GENERATION_MODEL_BY_PROVIDER: Record<ProviderKind, string> = {
|
||||
codex: "gpt-5.4-mini",
|
||||
claudeAgent: "claude-haiku-4-5",
|
||||
cursor: "composer-2-fast",
|
||||
cursor: "composer-2",
|
||||
};
|
||||
|
||||
export const MODEL_SLUG_ALIASES_BY_PROVIDER: Record<ProviderKind, Record<string, string>> = {
|
||||
@@ -146,23 +109,23 @@ export const MODEL_SLUG_ALIASES_BY_PROVIDER: Record<ProviderKind, Record<string,
|
||||
"claude-haiku-4-5-20251001": "claude-haiku-4-5",
|
||||
},
|
||||
cursor: {
|
||||
composer: "composer-1.5",
|
||||
auto: "default",
|
||||
composer: "composer-2",
|
||||
"composer-1.5": "composer-1.5",
|
||||
/** Legacy picker id; CLI exposes `composer-1.5` / `composer-2` only. */
|
||||
"composer-1": "composer-1.5",
|
||||
"gpt-5.3-codex": "gpt-5.3-codex",
|
||||
"gpt-5.3-codex-spark": "gpt-5.3-codex-spark-preview",
|
||||
"gpt-5.3-codex-spark": "gpt-5.3-codex-spark",
|
||||
"gemini-3.1-pro": "gemini-3.1-pro",
|
||||
/** @deprecated Pre–CLI-slug aliases used by older T3 builds. */
|
||||
"opus-4.6-thinking": "claude-4.6-opus-high-thinking",
|
||||
"opus-4.6": "claude-4.6-opus-high",
|
||||
"sonnet-4.6-thinking": "claude-4.6-sonnet-medium-thinking",
|
||||
"sonnet-4.6": "claude-4.6-sonnet-medium",
|
||||
"opus-4.5-thinking": "claude-4.5-opus-high-thinking",
|
||||
"opus-4.5": "claude-4.5-opus-high",
|
||||
/** @deprecated Legacy default label; maps to the current Cursor CLI default. */
|
||||
default: "claude-4.6-opus-high-thinking",
|
||||
auto: "auto",
|
||||
"gpt-5.4-1m": "gpt-5.4",
|
||||
"claude-4.6-opus": "claude-opus-4-6",
|
||||
"claude-4.6-sonnet": "claude-sonnet-4-6",
|
||||
"claude-4.5-opus": "claude-opus-4-5",
|
||||
"opus-4.6-thinking": "claude-opus-4-6",
|
||||
"opus-4.6": "claude-opus-4-6",
|
||||
"sonnet-4.6-thinking": "claude-sonnet-4-6",
|
||||
"sonnet-4.6": "claude-sonnet-4-6",
|
||||
"opus-4.5-thinking": "claude-opus-4-5",
|
||||
"opus-4.5": "claude-opus-4-5",
|
||||
},
|
||||
};
|
||||
|
||||
@@ -173,15 +136,3 @@ export const PROVIDER_DISPLAY_NAMES: Record<ProviderKind, string> = {
|
||||
claudeAgent: "Claude",
|
||||
cursor: "Cursor",
|
||||
};
|
||||
|
||||
export const REASONING_EFFORT_OPTIONS_BY_PROVIDER = {
|
||||
codex: CODEX_REASONING_EFFORT_OPTIONS,
|
||||
claudeAgent: CLAUDE_CODE_EFFORT_OPTIONS,
|
||||
cursor: CURSOR_REASONING_OPTIONS,
|
||||
} as const satisfies Record<ProviderKind, readonly ProviderReasoningEffort[]>;
|
||||
|
||||
export const DEFAULT_REASONING_EFFORT_BY_PROVIDER = {
|
||||
codex: "high",
|
||||
claudeAgent: "high",
|
||||
cursor: "normal",
|
||||
} as const satisfies Record<ProviderKind, ProviderReasoningEffort>;
|
||||
@@ -176,7 +176,7 @@ const CursorModelOptionsPatch = Schema.Struct({
|
||||
reasoning: Schema.optionalKey(CursorModelOptions.fields.reasoning),
|
||||
fastMode: Schema.optionalKey(CursorModelOptions.fields.fastMode),
|
||||
thinking: Schema.optionalKey(CursorModelOptions.fields.thinking),
|
||||
claudeOpusTier: Schema.optionalKey(CursorModelOptions.fields.claudeOpusTier),
|
||||
contextWindow: Schema.optionalKey(CursorModelOptions.fields.contextWindow),
|
||||
});
|
||||
|
||||
const ModelSelectionPatch = Schema.Union([
|
||||
|
||||
@@ -1,35 +1,18 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
DEFAULT_MODEL,
|
||||
DEFAULT_MODEL_BY_PROVIDER,
|
||||
DEFAULT_REASONING_EFFORT_BY_PROVIDER,
|
||||
type ModelCapabilities,
|
||||
} from "@t3tools/contracts";
|
||||
import { DEFAULT_MODEL_BY_PROVIDER, type ModelCapabilities } from "@t3tools/contracts";
|
||||
|
||||
import {
|
||||
applyClaudePromptEffortPrefix,
|
||||
getDefaultContextWindow,
|
||||
getDefaultEffort,
|
||||
getDefaultReasoningEffort,
|
||||
getEffectiveClaudeCodeEffort,
|
||||
hasContextWindowOption,
|
||||
hasEffortLevel,
|
||||
inferProviderForModel,
|
||||
isClaudeUltrathinkPrompt,
|
||||
normalizeClaudeModelOptions,
|
||||
normalizeCodexModelOptions,
|
||||
normalizeModelSlug,
|
||||
parseCursorModelSelection,
|
||||
resolveCursorDispatchModel,
|
||||
resolveCursorModelFromSelection,
|
||||
resolveModelSlug,
|
||||
resolveContextWindow,
|
||||
resolveEffort,
|
||||
resolveModelSlugForProvider,
|
||||
resolveReasoningEffortForProvider,
|
||||
resolveSelectableModel,
|
||||
supportsClaudeAdaptiveReasoning,
|
||||
supportsClaudeFastMode,
|
||||
supportsClaudeMaxEffort,
|
||||
supportsClaudeThinkingToggle,
|
||||
supportsClaudeUltrathinkKeyword,
|
||||
trimOrNull,
|
||||
} from "./model.ts";
|
||||
|
||||
@@ -99,22 +82,6 @@ describe("resolveSelectableModel", () => {
|
||||
expect(resolveSelectableModel("codex", "gpt-5.3 codex", options)).toBe("gpt-5.3-codex");
|
||||
expect(resolveSelectableModel("claudeAgent", "sonnet", options)).toBe("claude-sonnet-4-6");
|
||||
});
|
||||
|
||||
it("maps concrete slugs back to the closest selectable family option", () => {
|
||||
const cursorOptions = [
|
||||
{ slug: "composer-2", name: "Composer 2" },
|
||||
{ slug: "gpt-5.3-codex", name: "Codex 5.3" },
|
||||
{ slug: "claude-4.6-opus", name: "Claude Opus 4.6" },
|
||||
];
|
||||
|
||||
expect(resolveSelectableModel("cursor", "composer-2-fast", cursorOptions)).toBe("composer-2");
|
||||
expect(resolveSelectableModel("cursor", "gpt-5.3-codex-high-fast", cursorOptions)).toBe(
|
||||
"gpt-5.3-codex",
|
||||
);
|
||||
expect(resolveSelectableModel("cursor", "claude-4.6-opus-high-thinking", cursorOptions)).toBe(
|
||||
"claude-4.6-opus",
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("capability helpers", () => {
|
||||
@@ -129,201 +96,39 @@ describe("capability helpers", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("inferProviderForModel", () => {
|
||||
it("detects known provider model slugs", () => {
|
||||
expect(inferProviderForModel("gpt-5.3-codex")).toBe("codex");
|
||||
expect(inferProviderForModel("claude-sonnet-4-6")).toBe("claudeAgent");
|
||||
expect(inferProviderForModel("sonnet")).toBe("claudeAgent");
|
||||
describe("resolveEffort", () => {
|
||||
it("returns the explicit value when supported and not prompt-injected", () => {
|
||||
expect(resolveEffort(codexCaps, "xhigh")).toBe("xhigh");
|
||||
expect(resolveEffort(codexCaps, "high")).toBe("high");
|
||||
expect(resolveEffort(claudeCaps, "medium")).toBe("medium");
|
||||
});
|
||||
|
||||
it("falls back when the model is unknown", () => {
|
||||
expect(inferProviderForModel("custom/internal-model")).toBe("codex");
|
||||
expect(inferProviderForModel("custom/internal-model", "claudeAgent")).toBe("claudeAgent");
|
||||
it("falls back to default when value is unsupported", () => {
|
||||
expect(resolveEffort(codexCaps, "bogus")).toBe("high");
|
||||
expect(resolveEffort(claudeCaps, "bogus")).toBe("high");
|
||||
});
|
||||
|
||||
it("treats claude-prefixed custom slugs as claude", () => {
|
||||
expect(inferProviderForModel("claude-custom-internal")).toBe("claudeAgent");
|
||||
it("returns the default when no value is provided", () => {
|
||||
expect(resolveEffort(codexCaps, undefined)).toBe("high");
|
||||
expect(resolveEffort(codexCaps, null)).toBe("high");
|
||||
expect(resolveEffort(codexCaps, "")).toBe("high");
|
||||
expect(resolveEffort(codexCaps, " ")).toBe("high");
|
||||
});
|
||||
|
||||
it("infers cursor from Cursor-only slugs", () => {
|
||||
expect(inferProviderForModel("claude-4.6-opus-high-thinking")).toBe("cursor");
|
||||
expect(inferProviderForModel("composer-1.5")).toBe("cursor");
|
||||
it("excludes prompt-injected efforts and falls back to default", () => {
|
||||
expect(resolveEffort(claudeCaps, "ultrathink")).toBe("high");
|
||||
});
|
||||
|
||||
it("infers cursor from family slugs", () => {
|
||||
expect(inferProviderForModel("composer-2")).toBe("cursor");
|
||||
expect(inferProviderForModel("gpt-5.4-1m")).toBe("cursor");
|
||||
expect(inferProviderForModel("claude-4.6-opus")).toBe("cursor");
|
||||
expect(inferProviderForModel("claude-4.6-sonnet")).toBe("cursor");
|
||||
expect(inferProviderForModel("auto")).toBe("cursor");
|
||||
});
|
||||
});
|
||||
|
||||
describe("cursor model selection helpers", () => {
|
||||
it("parses GPT-5.3 Codex reasoning and fast suffixes from slugs", () => {
|
||||
expect(parseCursorModelSelection("gpt-5.3-codex-high-fast")).toMatchObject({
|
||||
family: "gpt-5.3-codex",
|
||||
reasoning: "high",
|
||||
fast: true,
|
||||
thinking: false,
|
||||
});
|
||||
});
|
||||
|
||||
it("merges persisted cursor modelOptions over the family model key", () => {
|
||||
expect(parseCursorModelSelection("composer-2", { fastMode: true })).toMatchObject({
|
||||
family: "composer-2",
|
||||
fast: true,
|
||||
});
|
||||
expect(resolveCursorDispatchModel("composer-2", { fastMode: true })).toBe("composer-2-fast");
|
||||
expect(resolveCursorDispatchModel("composer-2", undefined)).toBe("composer-2");
|
||||
});
|
||||
|
||||
it("parses and resolves Claude Opus 4.6 tiers and thinking from CLI slugs", () => {
|
||||
expect(parseCursorModelSelection("claude-4.6-opus-high-thinking")).toMatchObject({
|
||||
family: "claude-4.6-opus",
|
||||
thinking: true,
|
||||
claudeOpusTier: "high",
|
||||
});
|
||||
expect(parseCursorModelSelection("claude-4.6-opus-max")).toMatchObject({
|
||||
claudeOpusTier: "max",
|
||||
thinking: false,
|
||||
});
|
||||
expect(
|
||||
resolveCursorModelFromSelection({
|
||||
family: "claude-4.6-opus",
|
||||
thinking: true,
|
||||
claudeOpusTier: "high",
|
||||
}),
|
||||
).toBe("claude-4.6-opus-high-thinking");
|
||||
expect(
|
||||
resolveCursorModelFromSelection({
|
||||
family: "claude-4.6-opus",
|
||||
thinking: false,
|
||||
claudeOpusTier: "max",
|
||||
}),
|
||||
).toBe("claude-4.6-opus-max");
|
||||
});
|
||||
});
|
||||
|
||||
describe("getDefaultReasoningEffort", () => {
|
||||
it("returns provider-scoped defaults", () => {
|
||||
expect(getDefaultReasoningEffort("codex")).toBe(DEFAULT_REASONING_EFFORT_BY_PROVIDER.codex);
|
||||
expect(getDefaultReasoningEffort("claudeAgent")).toBe(
|
||||
DEFAULT_REASONING_EFFORT_BY_PROVIDER.claudeAgent,
|
||||
);
|
||||
expect(getDefaultReasoningEffort("cursor")).toBe(DEFAULT_REASONING_EFFORT_BY_PROVIDER.cursor);
|
||||
});
|
||||
});
|
||||
|
||||
describe("resolveReasoningEffortForProvider", () => {
|
||||
it("accepts provider-scoped effort values", () => {
|
||||
expect(resolveReasoningEffortForProvider("codex", "xhigh")).toBe("xhigh");
|
||||
expect(resolveReasoningEffortForProvider("claudeAgent", "ultrathink")).toBe("ultrathink");
|
||||
});
|
||||
|
||||
it("rejects effort values from the wrong provider", () => {
|
||||
expect(resolveReasoningEffortForProvider("codex", "max")).toBeNull();
|
||||
expect(resolveReasoningEffortForProvider("claudeAgent", "xhigh")).toBeNull();
|
||||
});
|
||||
|
||||
it("accepts cursor reasoning tiers", () => {
|
||||
expect(resolveReasoningEffortForProvider("cursor", "normal")).toBe("normal");
|
||||
expect(resolveReasoningEffortForProvider("cursor", "xhigh")).toBe("xhigh");
|
||||
});
|
||||
});
|
||||
|
||||
describe("getEffectiveClaudeCodeEffort", () => {
|
||||
it("does not persist ultrathink into Claude runtime configuration", () => {
|
||||
expect(getEffectiveClaudeCodeEffort("ultrathink")).toBeNull();
|
||||
expect(getEffectiveClaudeCodeEffort("high")).toBe("high");
|
||||
});
|
||||
|
||||
it("returns null when no claude effort is selected", () => {
|
||||
expect(getEffectiveClaudeCodeEffort(null)).toBeNull();
|
||||
expect(getEffectiveClaudeCodeEffort(undefined)).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe("normalizeCodexModelOptions", () => {
|
||||
it("drops default-only codex options", () => {
|
||||
expect(
|
||||
normalizeCodexModelOptions({ reasoningEffort: "high", fastMode: false }),
|
||||
).toBeUndefined();
|
||||
});
|
||||
|
||||
it("preserves non-default codex options", () => {
|
||||
expect(normalizeCodexModelOptions({ reasoningEffort: "xhigh", fastMode: true })).toEqual({
|
||||
reasoningEffort: "xhigh",
|
||||
fastMode: true,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("normalizeClaudeModelOptions", () => {
|
||||
it("drops unsupported fast mode and max effort for Sonnet", () => {
|
||||
expect(
|
||||
normalizeClaudeModelOptions("claude-sonnet-4-6", {
|
||||
effort: "max",
|
||||
fastMode: true,
|
||||
}),
|
||||
).toBeUndefined();
|
||||
});
|
||||
|
||||
it("keeps the Haiku thinking toggle and removes unsupported effort", () => {
|
||||
expect(
|
||||
normalizeClaudeModelOptions("claude-haiku-4-5", {
|
||||
thinking: false,
|
||||
effort: "high",
|
||||
}),
|
||||
).toEqual({
|
||||
thinking: false,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("supportsClaudeAdaptiveReasoning", () => {
|
||||
it("only enables adaptive reasoning for Opus 4.6 and Sonnet 4.6", () => {
|
||||
expect(supportsClaudeAdaptiveReasoning("claude-opus-4-6")).toBe(true);
|
||||
expect(supportsClaudeAdaptiveReasoning("claude-sonnet-4-6")).toBe(true);
|
||||
expect(supportsClaudeAdaptiveReasoning("claude-haiku-4-5")).toBe(false);
|
||||
expect(supportsClaudeAdaptiveReasoning(undefined)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("supportsClaudeMaxEffort", () => {
|
||||
it("only enables max effort for Opus 4.6", () => {
|
||||
expect(supportsClaudeMaxEffort("claude-opus-4-6")).toBe(true);
|
||||
expect(supportsClaudeMaxEffort("claude-sonnet-4-6")).toBe(false);
|
||||
expect(supportsClaudeMaxEffort("claude-haiku-4-5")).toBe(false);
|
||||
expect(supportsClaudeMaxEffort(undefined)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("supportsClaudeFastMode", () => {
|
||||
it("only enables Claude fast mode for Opus 4.6", () => {
|
||||
expect(supportsClaudeFastMode("claude-opus-4-6")).toBe(true);
|
||||
expect(supportsClaudeFastMode("opus")).toBe(true);
|
||||
expect(supportsClaudeFastMode("claude-sonnet-4-6")).toBe(false);
|
||||
expect(supportsClaudeFastMode("claude-haiku-4-5")).toBe(false);
|
||||
expect(supportsClaudeFastMode(undefined)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("supportsClaudeUltrathinkKeyword", () => {
|
||||
it("only enables ultrathink keyword handling for Opus 4.6 and Sonnet 4.6", () => {
|
||||
expect(supportsClaudeUltrathinkKeyword("claude-opus-4-6")).toBe(true);
|
||||
expect(supportsClaudeUltrathinkKeyword("claude-sonnet-4-6")).toBe(true);
|
||||
expect(supportsClaudeUltrathinkKeyword("claude-haiku-4-5")).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("supportsClaudeThinkingToggle", () => {
|
||||
it("only enables the Claude thinking toggle for Haiku 4.5", () => {
|
||||
expect(supportsClaudeThinkingToggle("claude-opus-4-6")).toBe(false);
|
||||
expect(supportsClaudeThinkingToggle("claude-sonnet-4-6")).toBe(false);
|
||||
expect(supportsClaudeThinkingToggle("claude-haiku-4-5")).toBe(true);
|
||||
expect(supportsClaudeThinkingToggle("haiku")).toBe(true);
|
||||
expect(supportsClaudeThinkingToggle(undefined)).toBe(false);
|
||||
it("returns undefined for models with no effort levels", () => {
|
||||
const noCaps: ModelCapabilities = {
|
||||
reasoningEffortLevels: [],
|
||||
supportsFastMode: false,
|
||||
supportsThinkingToggle: false,
|
||||
contextWindowOptions: [],
|
||||
promptInjectedEffortLevels: [],
|
||||
};
|
||||
expect(resolveEffort(noCaps, undefined)).toBeUndefined();
|
||||
expect(resolveEffort(noCaps, "high")).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -387,57 +192,3 @@ describe("resolveContextWindow", () => {
|
||||
expect(resolveContextWindow(codexCaps, "1m")).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe("normalize*ModelOptionsWithCapabilities", () => {
|
||||
it("preserves explicit false codex fast mode", () => {
|
||||
expect(
|
||||
normalizeCodexModelOptionsWithCapabilities(codexCaps, {
|
||||
reasoningEffort: "high",
|
||||
fastMode: false,
|
||||
}),
|
||||
).toEqual({
|
||||
reasoningEffort: "high",
|
||||
fastMode: false,
|
||||
});
|
||||
});
|
||||
|
||||
it("preserves the default Claude context window explicitly", () => {
|
||||
expect(
|
||||
normalizeClaudeModelOptionsWithCapabilities(
|
||||
{
|
||||
...claudeCaps,
|
||||
contextWindowOptions: [
|
||||
{ value: "200k", label: "200k", isDefault: true },
|
||||
{ value: "1m", label: "1M" },
|
||||
],
|
||||
},
|
||||
{
|
||||
effort: "high",
|
||||
contextWindow: "200k",
|
||||
},
|
||||
),
|
||||
).toEqual({
|
||||
effort: "high",
|
||||
contextWindow: "200k",
|
||||
});
|
||||
});
|
||||
|
||||
it("omits unsupported Claude context window options", () => {
|
||||
expect(
|
||||
normalizeClaudeModelOptionsWithCapabilities(
|
||||
{
|
||||
...claudeCaps,
|
||||
reasoningEffortLevels: [],
|
||||
supportsThinkingToggle: true,
|
||||
contextWindowOptions: [],
|
||||
},
|
||||
{
|
||||
thinking: true,
|
||||
contextWindow: "1m",
|
||||
},
|
||||
),
|
||||
).toEqual({
|
||||
thinking: true,
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,494 +1,11 @@
|
||||
import {
|
||||
CURSOR_REASONING_OPTIONS,
|
||||
DEFAULT_MODEL_BY_PROVIDER,
|
||||
DEFAULT_REASONING_EFFORT_BY_PROVIDER,
|
||||
MODEL_OPTIONS_BY_PROVIDER,
|
||||
MODEL_SLUG_ALIASES_BY_PROVIDER,
|
||||
REASONING_EFFORT_OPTIONS_BY_PROVIDER,
|
||||
type ClaudeCodeEffort,
|
||||
type ClaudeModelOptions,
|
||||
type CodexModelOptions,
|
||||
type CodexReasoningEffort,
|
||||
type CursorClaudeOpusTier,
|
||||
type CursorModelOptions,
|
||||
type CursorModelSlug,
|
||||
type CursorReasoningOption,
|
||||
type ModelCapabilities,
|
||||
type ModelSelection,
|
||||
type OpenCodeModelOptions,
|
||||
type ProviderKind,
|
||||
type ProviderReasoningEffort,
|
||||
} from "@t3tools/contracts";
|
||||
|
||||
const MODEL_SLUG_SET_BY_PROVIDER: Record<ProviderKind, ReadonlySet<ModelSlug>> = {
|
||||
claudeAgent: new Set(MODEL_OPTIONS_BY_PROVIDER.claudeAgent.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)),
|
||||
};
|
||||
|
||||
const CURSOR_MODEL_FAMILY_OPTIONS = [
|
||||
{ slug: "auto", name: "Auto" },
|
||||
{ slug: "composer-2", name: "Composer 2" },
|
||||
{ slug: "composer-1.5", name: "Composer 1.5" },
|
||||
{ slug: "gpt-5.3-codex", name: "Codex 5.3" },
|
||||
{ slug: "gpt-5.3-codex-spark-preview", name: "Codex 5.3 Spark" },
|
||||
{ slug: "gpt-5.4-1m", name: "GPT 5.4" },
|
||||
{ slug: "claude-4.6-opus", name: "Claude Opus 4.6" },
|
||||
{ slug: "claude-4.6-sonnet", name: "Claude Sonnet 4.6" },
|
||||
{ slug: "gemini-3.1-pro", name: "Gemini 3.1 Pro" },
|
||||
] as const;
|
||||
|
||||
export type CursorModelFamily = (typeof CURSOR_MODEL_FAMILY_OPTIONS)[number]["slug"];
|
||||
|
||||
type CursorModelCapability = {
|
||||
readonly supportsReasoning: boolean;
|
||||
readonly supportsFast: boolean;
|
||||
readonly supportsThinking: boolean;
|
||||
readonly supportsClaudeOpusTier: boolean;
|
||||
readonly defaultReasoning: CursorReasoningOption;
|
||||
readonly defaultThinking: boolean;
|
||||
readonly defaultClaudeOpusTier: CursorClaudeOpusTier;
|
||||
};
|
||||
|
||||
const CURSOR_MODEL_CAPABILITY_BY_FAMILY: Record<CursorModelFamily, CursorModelCapability> = {
|
||||
auto: {
|
||||
supportsReasoning: false,
|
||||
supportsFast: false,
|
||||
supportsThinking: false,
|
||||
supportsClaudeOpusTier: false,
|
||||
defaultReasoning: "normal",
|
||||
defaultThinking: false,
|
||||
defaultClaudeOpusTier: "high",
|
||||
},
|
||||
"composer-2": {
|
||||
supportsReasoning: false,
|
||||
supportsFast: true,
|
||||
supportsThinking: false,
|
||||
supportsClaudeOpusTier: false,
|
||||
defaultReasoning: "normal",
|
||||
defaultThinking: false,
|
||||
defaultClaudeOpusTier: "high",
|
||||
},
|
||||
"composer-1.5": {
|
||||
supportsReasoning: false,
|
||||
supportsFast: false,
|
||||
supportsThinking: false,
|
||||
supportsClaudeOpusTier: false,
|
||||
defaultReasoning: "normal",
|
||||
defaultThinking: false,
|
||||
defaultClaudeOpusTier: "high",
|
||||
},
|
||||
"gpt-5.3-codex": {
|
||||
supportsReasoning: true,
|
||||
supportsFast: true,
|
||||
supportsThinking: false,
|
||||
supportsClaudeOpusTier: false,
|
||||
defaultReasoning: "normal",
|
||||
defaultThinking: false,
|
||||
defaultClaudeOpusTier: "high",
|
||||
},
|
||||
"gpt-5.3-codex-spark-preview": {
|
||||
supportsReasoning: true,
|
||||
supportsFast: false,
|
||||
supportsThinking: false,
|
||||
supportsClaudeOpusTier: false,
|
||||
defaultReasoning: "normal",
|
||||
defaultThinking: false,
|
||||
defaultClaudeOpusTier: "high",
|
||||
},
|
||||
"gpt-5.4-1m": {
|
||||
supportsReasoning: true,
|
||||
supportsFast: true,
|
||||
supportsThinking: false,
|
||||
supportsClaudeOpusTier: false,
|
||||
defaultReasoning: "normal",
|
||||
defaultThinking: false,
|
||||
defaultClaudeOpusTier: "high",
|
||||
},
|
||||
"claude-4.6-opus": {
|
||||
supportsReasoning: false,
|
||||
supportsFast: false,
|
||||
supportsThinking: true,
|
||||
supportsClaudeOpusTier: true,
|
||||
defaultReasoning: "normal",
|
||||
defaultThinking: true,
|
||||
defaultClaudeOpusTier: "high",
|
||||
},
|
||||
"claude-4.6-sonnet": {
|
||||
supportsReasoning: false,
|
||||
supportsFast: false,
|
||||
supportsThinking: true,
|
||||
supportsClaudeOpusTier: false,
|
||||
defaultReasoning: "normal",
|
||||
defaultThinking: false,
|
||||
defaultClaudeOpusTier: "high",
|
||||
},
|
||||
"gemini-3.1-pro": {
|
||||
supportsReasoning: false,
|
||||
supportsFast: false,
|
||||
supportsThinking: false,
|
||||
supportsClaudeOpusTier: false,
|
||||
defaultReasoning: "normal",
|
||||
defaultThinking: false,
|
||||
defaultClaudeOpusTier: "high",
|
||||
},
|
||||
};
|
||||
|
||||
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;
|
||||
readonly claudeOpusTier: CursorClaudeOpusTier;
|
||||
}
|
||||
|
||||
export function getCursorModelCapabilities(family: CursorModelFamily) {
|
||||
return CURSOR_MODEL_CAPABILITY_BY_FAMILY[family];
|
||||
}
|
||||
|
||||
/** Fast toggles are absent for some GPT‑5.4 1M + reasoning combinations in the live CLI model list. */
|
||||
export function cursorFamilySupportsFastWithReasoning(
|
||||
family: CursorModelFamily,
|
||||
reasoning: CursorReasoningOption,
|
||||
): boolean {
|
||||
if (!getCursorModelCapabilities(family).supportsFast) return false;
|
||||
if (family === "gpt-5.4-1m" && reasoning === "low") return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
function fallbackCursorModelFamily(): CursorModelFamily {
|
||||
return parseCursorModelSelection(DEFAULT_MODEL_BY_PROVIDER.cursor).family;
|
||||
}
|
||||
|
||||
function resolveCursorModelFamily(model: string | null | undefined): CursorModelFamily {
|
||||
const normalized = normalizeModelSlug(model, "cursor");
|
||||
if (!normalized) {
|
||||
return fallbackCursorModelFamily();
|
||||
}
|
||||
|
||||
if (normalized === "auto") {
|
||||
return "auto";
|
||||
}
|
||||
|
||||
if (normalized === "composer-2" || normalized === "composer-2-fast") {
|
||||
return "composer-2";
|
||||
}
|
||||
|
||||
if (normalized === "composer-1.5") {
|
||||
return "composer-1.5";
|
||||
}
|
||||
|
||||
if (normalized.startsWith("gpt-5.3-codex-spark-preview")) {
|
||||
return "gpt-5.3-codex-spark-preview";
|
||||
}
|
||||
|
||||
if (normalized.startsWith("gpt-5.3-codex")) {
|
||||
return "gpt-5.3-codex";
|
||||
}
|
||||
|
||||
if (
|
||||
normalized === "gpt-5.4-low" ||
|
||||
normalized === "gpt-5.4-medium" ||
|
||||
normalized === "gpt-5.4-medium-fast" ||
|
||||
normalized === "gpt-5.4-high" ||
|
||||
normalized === "gpt-5.4-high-fast" ||
|
||||
normalized === "gpt-5.4-xhigh" ||
|
||||
normalized === "gpt-5.4-xhigh-fast"
|
||||
) {
|
||||
return "gpt-5.4-1m";
|
||||
}
|
||||
|
||||
if (normalized.startsWith("claude-4.6-opus-")) {
|
||||
return "claude-4.6-opus";
|
||||
}
|
||||
|
||||
if (normalized.startsWith("claude-4.6-sonnet-")) {
|
||||
return "claude-4.6-sonnet";
|
||||
}
|
||||
|
||||
if (normalized === "gemini-3.1-pro") {
|
||||
return "gemini-3.1-pro";
|
||||
}
|
||||
|
||||
return CURSOR_MODEL_FAMILY_SET.has(normalized as CursorModelFamily)
|
||||
? (normalized as CursorModelFamily)
|
||||
: fallbackCursorModelFamily();
|
||||
}
|
||||
|
||||
function resolveCursorReasoningFromSlug(model: CursorModelSlug): CursorReasoningOption {
|
||||
if (model.includes("-xhigh")) return "xhigh";
|
||||
if (model.includes("-high")) return "high";
|
||||
if (model.includes("-low")) return "low";
|
||||
return "normal";
|
||||
}
|
||||
|
||||
function parseClaudeOpusFromSlug(slug: string): {
|
||||
readonly tier: CursorClaudeOpusTier;
|
||||
readonly thinking: boolean;
|
||||
} {
|
||||
return {
|
||||
tier: slug.includes("opus-max") ? "max" : "high",
|
||||
thinking: slug.endsWith("-thinking"),
|
||||
};
|
||||
}
|
||||
|
||||
function mergePersistedCursorOptionsOntoSelection(
|
||||
sel: CursorModelSelection,
|
||||
cursorOpts: CursorModelOptions | null | undefined,
|
||||
): CursorModelSelection {
|
||||
if (!cursorOpts) return sel;
|
||||
let next: CursorModelSelection = sel;
|
||||
if (
|
||||
typeof cursorOpts.reasoning === "string" &&
|
||||
(CURSOR_REASONING_OPTIONS as readonly string[]).includes(cursorOpts.reasoning)
|
||||
) {
|
||||
next = { ...next, reasoning: cursorOpts.reasoning };
|
||||
}
|
||||
if (cursorOpts.fastMode === true) {
|
||||
next = { ...next, fast: true };
|
||||
}
|
||||
if (cursorOpts.fastMode === false) {
|
||||
next = { ...next, fast: false };
|
||||
}
|
||||
if (cursorOpts.thinking === true) {
|
||||
next = { ...next, thinking: true };
|
||||
}
|
||||
if (cursorOpts.thinking === false) {
|
||||
next = { ...next, thinking: false };
|
||||
}
|
||||
if (cursorOpts.claudeOpusTier === "max" || cursorOpts.claudeOpusTier === "high") {
|
||||
next = { ...next, claudeOpusTier: cursorOpts.claudeOpusTier };
|
||||
}
|
||||
return next;
|
||||
}
|
||||
|
||||
function parseCursorModelSelectionFromSlugOnly(
|
||||
model: string | null | undefined,
|
||||
): CursorModelSelection {
|
||||
const family = resolveCursorModelFamily(model);
|
||||
const capability = CURSOR_MODEL_CAPABILITY_BY_FAMILY[family];
|
||||
const normalized = resolveModelSlugForProvider("cursor", model) as CursorModelSlug;
|
||||
|
||||
const base: Pick<CursorModelSelection, "reasoning" | "fast" | "thinking" | "claudeOpusTier"> = {
|
||||
reasoning: capability.defaultReasoning,
|
||||
fast: false,
|
||||
thinking: capability.defaultThinking,
|
||||
claudeOpusTier: capability.defaultClaudeOpusTier,
|
||||
};
|
||||
|
||||
if (capability.supportsReasoning) {
|
||||
return {
|
||||
family,
|
||||
...base,
|
||||
reasoning: resolveCursorReasoningFromSlug(normalized),
|
||||
fast: normalized.endsWith("-fast"),
|
||||
thinking: false,
|
||||
claudeOpusTier: "high",
|
||||
};
|
||||
}
|
||||
|
||||
if (family === "claude-4.6-opus") {
|
||||
const parsed = parseClaudeOpusFromSlug(normalized);
|
||||
return {
|
||||
family,
|
||||
...base,
|
||||
reasoning: capability.defaultReasoning,
|
||||
fast: false,
|
||||
claudeOpusTier: parsed.tier,
|
||||
thinking: parsed.thinking,
|
||||
};
|
||||
}
|
||||
|
||||
if (family === "composer-2") {
|
||||
return {
|
||||
family,
|
||||
...base,
|
||||
fast: normalized === "composer-2-fast",
|
||||
thinking: false,
|
||||
claudeOpusTier: "high",
|
||||
};
|
||||
}
|
||||
|
||||
if (capability.supportsThinking) {
|
||||
return {
|
||||
family,
|
||||
...base,
|
||||
reasoning: capability.defaultReasoning,
|
||||
fast: false,
|
||||
thinking: normalized.includes("-thinking"),
|
||||
claudeOpusTier: "high",
|
||||
};
|
||||
}
|
||||
|
||||
return { family, ...base };
|
||||
}
|
||||
|
||||
export function parseCursorModelSelection(
|
||||
model: string | null | undefined,
|
||||
cursorOpts?: CursorModelOptions | null,
|
||||
): CursorModelSelection {
|
||||
return mergePersistedCursorOptionsOntoSelection(
|
||||
parseCursorModelSelectionFromSlugOnly(model),
|
||||
cursorOpts,
|
||||
);
|
||||
}
|
||||
|
||||
/** Minimal `cursor` modelOptions for API dispatch (non-default traits only). */
|
||||
export function normalizeCursorModelOptions(
|
||||
model: string | null | undefined,
|
||||
persisted: CursorModelOptions | null | undefined,
|
||||
): CursorModelOptions | undefined {
|
||||
const sel = parseCursorModelSelection(model, persisted);
|
||||
const cap = getCursorModelCapabilities(sel.family);
|
||||
const defaultReasoning = DEFAULT_REASONING_EFFORT_BY_PROVIDER.cursor as CursorReasoningOption;
|
||||
const next: {
|
||||
reasoning?: CursorReasoningOption;
|
||||
fastMode?: boolean;
|
||||
thinking?: boolean;
|
||||
claudeOpusTier?: CursorClaudeOpusTier;
|
||||
} = {};
|
||||
if (cap.supportsReasoning && sel.reasoning !== defaultReasoning) {
|
||||
next.reasoning = sel.reasoning;
|
||||
}
|
||||
if (cap.supportsFast && sel.fast) {
|
||||
next.fastMode = true;
|
||||
}
|
||||
if (cap.supportsThinking && sel.thinking === false) {
|
||||
next.thinking = false;
|
||||
}
|
||||
if (cap.supportsClaudeOpusTier && sel.claudeOpusTier === "max") {
|
||||
next.claudeOpusTier = "max";
|
||||
}
|
||||
return Object.keys(next).length > 0 ? (next as CursorModelOptions) : undefined;
|
||||
}
|
||||
|
||||
/** Persisted options for a trait selection (null = all defaults / omit from draft). */
|
||||
export function cursorSelectionToPersistedModelOptions(
|
||||
sel: CursorModelSelection,
|
||||
): CursorModelOptions | null {
|
||||
const cap = getCursorModelCapabilities(sel.family);
|
||||
const defaultReasoning = DEFAULT_REASONING_EFFORT_BY_PROVIDER.cursor as CursorReasoningOption;
|
||||
const next: {
|
||||
reasoning?: CursorReasoningOption;
|
||||
fastMode?: boolean;
|
||||
thinking?: boolean;
|
||||
claudeOpusTier?: CursorClaudeOpusTier;
|
||||
} = {};
|
||||
if (cap.supportsReasoning && sel.reasoning !== defaultReasoning) {
|
||||
next.reasoning = sel.reasoning;
|
||||
}
|
||||
if (cap.supportsFast && sel.fast) {
|
||||
next.fastMode = true;
|
||||
}
|
||||
if (cap.supportsThinking && sel.thinking === false) {
|
||||
next.thinking = false;
|
||||
}
|
||||
if (cap.supportsClaudeOpusTier && sel.claudeOpusTier === "max") {
|
||||
next.claudeOpusTier = "max";
|
||||
}
|
||||
return Object.keys(next).length > 0 ? (next as CursorModelOptions) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves the concrete Cursor CLI `--model` id from the logical family key (or custom slug) plus
|
||||
* optional persisted `modelOptions.cursor` traits.
|
||||
*/
|
||||
export function resolveCursorDispatchModel(
|
||||
model: string | null | undefined,
|
||||
cursorOpts: CursorModelOptions | null | undefined,
|
||||
): string {
|
||||
const normalized = normalizeModelSlug(model, "cursor") ?? DEFAULT_MODEL_BY_PROVIDER.cursor;
|
||||
const hasPersistedTraits = Boolean(cursorOpts && Object.keys(cursorOpts).length > 0);
|
||||
if (hasPersistedTraits && isCursorModelFamilySlug(normalized)) {
|
||||
const sel = parseCursorModelSelection(normalized, cursorOpts);
|
||||
return resolveCursorModelFromSelection(sel);
|
||||
}
|
||||
return resolveModelSlugForProvider("cursor", normalized);
|
||||
}
|
||||
|
||||
export function resolveCursorModelFromSelection(input: {
|
||||
readonly family: CursorModelFamily;
|
||||
readonly reasoning?: CursorReasoningOption | null;
|
||||
readonly fast?: boolean | null;
|
||||
readonly thinking?: boolean | null;
|
||||
readonly claudeOpusTier?: CursorClaudeOpusTier | null;
|
||||
}): CursorModelSlug {
|
||||
const family = resolveCursorModelFamily(input.family);
|
||||
const capability = CURSOR_MODEL_CAPABILITY_BY_FAMILY[family];
|
||||
|
||||
if (family === "composer-2") {
|
||||
const slug = input.fast === true ? "composer-2-fast" : "composer-2";
|
||||
return resolveModelSlugForProvider("cursor", slug) as CursorModelSlug;
|
||||
}
|
||||
|
||||
if (family === "gpt-5.4-1m") {
|
||||
const reasoning = CURSOR_REASONING_OPTIONS.includes(input.reasoning ?? "normal")
|
||||
? (input.reasoning ?? "normal")
|
||||
: capability.defaultReasoning;
|
||||
const tier = reasoning === "normal" ? "medium" : reasoning;
|
||||
const base = `gpt-5.4-${tier}`;
|
||||
if (input.fast === true) {
|
||||
const fastSlug = `${base}-fast`;
|
||||
const candidate = MODEL_SLUG_SET_BY_PROVIDER.cursor.has(fastSlug) ? fastSlug : base;
|
||||
return resolveModelSlugForProvider("cursor", candidate) as CursorModelSlug;
|
||||
}
|
||||
return resolveModelSlugForProvider("cursor", base) as CursorModelSlug;
|
||||
}
|
||||
|
||||
if (family === "gpt-5.3-codex-spark-preview") {
|
||||
const reasoning = CURSOR_REASONING_OPTIONS.includes(input.reasoning ?? "normal")
|
||||
? (input.reasoning ?? "normal")
|
||||
: capability.defaultReasoning;
|
||||
const suffix = reasoning === "normal" ? "" : `-${reasoning}`;
|
||||
const candidate = `gpt-5.3-codex-spark-preview${suffix}`;
|
||||
return resolveModelSlugForProvider("cursor", candidate) as CursorModelSlug;
|
||||
}
|
||||
|
||||
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 === true ? "-fast" : "";
|
||||
const candidate = `${family}${reasoningSuffix}${fastSuffix}`;
|
||||
return resolveModelSlugForProvider("cursor", candidate) as CursorModelSlug;
|
||||
}
|
||||
|
||||
if (family === "claude-4.6-opus") {
|
||||
const tier = input.claudeOpusTier === "max" ? "max" : "high";
|
||||
const thinking =
|
||||
input.thinking === false
|
||||
? false
|
||||
: input.thinking === true
|
||||
? true
|
||||
: capability.defaultThinking;
|
||||
const base = `claude-4.6-opus-${tier}`;
|
||||
const candidate = thinking ? `${base}-thinking` : base;
|
||||
return resolveModelSlugForProvider("cursor", candidate) as CursorModelSlug;
|
||||
}
|
||||
|
||||
if (family === "claude-4.6-sonnet") {
|
||||
const thinking =
|
||||
input.thinking === false
|
||||
? false
|
||||
: input.thinking === true
|
||||
? true
|
||||
: capability.defaultThinking;
|
||||
const candidate = thinking ? "claude-4.6-sonnet-medium-thinking" : "claude-4.6-sonnet-medium";
|
||||
return resolveModelSlugForProvider("cursor", candidate) as CursorModelSlug;
|
||||
}
|
||||
|
||||
return resolveModelSlugForProvider("cursor", family) as CursorModelSlug;
|
||||
}
|
||||
|
||||
const CLAUDE_OPUS_4_6_MODEL = "claude-opus-4-6";
|
||||
const CLAUDE_SONNET_4_6_MODEL = "claude-sonnet-4-6";
|
||||
const CLAUDE_HAIKU_4_5_MODEL = "claude-haiku-4-5";
|
||||
|
||||
export interface SelectableModelOption {
|
||||
slug: string;
|
||||
name: string;
|
||||
@@ -701,20 +218,7 @@ export function resolveSelectableModel(
|
||||
}
|
||||
|
||||
const resolved = options.find((option) => option.slug === normalized);
|
||||
if (resolved) {
|
||||
return resolved.slug;
|
||||
}
|
||||
|
||||
const familyMatch = options
|
||||
.toSorted((left, right) => right.slug.length - left.slug.length)
|
||||
.find((option) => {
|
||||
if (!normalized.startsWith(option.slug)) {
|
||||
return false;
|
||||
}
|
||||
const nextChar = normalized.charAt(option.slug.length);
|
||||
return nextChar === "-" || nextChar === "[" || nextChar === "";
|
||||
});
|
||||
return familyMatch?.slug ?? null;
|
||||
return resolved ? resolved.slug : null;
|
||||
}
|
||||
|
||||
function resolveModelSlug(model: string | null | undefined, provider: ProviderKind): string {
|
||||
@@ -739,178 +243,6 @@ export function trimOrNull<T extends string>(value: T | null | undefined): T | n
|
||||
return trimmed || null;
|
||||
}
|
||||
|
||||
export function supportsClaudeAdaptiveReasoning(model: string | null | undefined): boolean {
|
||||
const slug = normalizeModelSlug(model, "claudeAgent");
|
||||
return slug === CLAUDE_OPUS_4_6_MODEL || slug === CLAUDE_SONNET_4_6_MODEL;
|
||||
}
|
||||
|
||||
export function supportsClaudeMaxEffort(model: string | null | undefined): boolean {
|
||||
const slug = normalizeModelSlug(model, "claudeAgent");
|
||||
return slug === CLAUDE_OPUS_4_6_MODEL;
|
||||
}
|
||||
|
||||
export function supportsClaudeFastMode(model: string | null | undefined): boolean {
|
||||
const slug = normalizeModelSlug(model, "claudeAgent");
|
||||
return slug === CLAUDE_OPUS_4_6_MODEL;
|
||||
}
|
||||
|
||||
export function supportsClaudeUltrathinkKeyword(model: string | null | undefined): boolean {
|
||||
const slug = normalizeModelSlug(model, "claudeAgent");
|
||||
return slug === CLAUDE_OPUS_4_6_MODEL || slug === CLAUDE_SONNET_4_6_MODEL;
|
||||
}
|
||||
|
||||
export function supportsClaudeThinkingToggle(model: string | null | undefined): boolean {
|
||||
const slug = normalizeModelSlug(model, "claudeAgent");
|
||||
return slug === CLAUDE_HAIKU_4_5_MODEL;
|
||||
}
|
||||
|
||||
export function inferProviderForModel(
|
||||
model: string | null | undefined,
|
||||
fallback: ProviderKind = "codex",
|
||||
): ProviderKind {
|
||||
const normalizedClaude = normalizeModelSlug(model, "claudeAgent");
|
||||
if (normalizedClaude && MODEL_SLUG_SET_BY_PROVIDER.claudeAgent.has(normalizedClaude)) {
|
||||
return "claudeAgent";
|
||||
}
|
||||
|
||||
const normalizedCodex = normalizeModelSlug(model, "codex");
|
||||
if (normalizedCodex && MODEL_SLUG_SET_BY_PROVIDER.codex.has(normalizedCodex)) {
|
||||
return "codex";
|
||||
}
|
||||
|
||||
const normalizedCursor = normalizeModelSlug(model, "cursor");
|
||||
if (normalizedCursor && MODEL_SLUG_SET_BY_PROVIDER.cursor.has(normalizedCursor)) {
|
||||
return "cursor";
|
||||
}
|
||||
|
||||
if (typeof model === "string" && CURSOR_MODEL_FAMILY_SET.has(model.trim() as CursorModelFamily)) {
|
||||
return "cursor";
|
||||
}
|
||||
|
||||
return typeof model === "string" && model.trim().startsWith("claude-") ? "claudeAgent" : fallback;
|
||||
}
|
||||
|
||||
export function getReasoningEffortOptions(provider: "codex"): ReadonlyArray<CodexReasoningEffort>;
|
||||
export function getReasoningEffortOptions(
|
||||
provider: "claudeAgent",
|
||||
model?: string | null | undefined,
|
||||
): ReadonlyArray<ClaudeCodeEffort>;
|
||||
export function getReasoningEffortOptions(
|
||||
provider?: ProviderKind,
|
||||
model?: string | null | undefined,
|
||||
): ReadonlyArray<ProviderReasoningEffort>;
|
||||
export function getReasoningEffortOptions(
|
||||
provider: ProviderKind = "codex",
|
||||
model?: string | null | undefined,
|
||||
): ReadonlyArray<ProviderReasoningEffort> {
|
||||
if (provider === "claudeAgent") {
|
||||
if (supportsClaudeMaxEffort(model)) {
|
||||
return ["low", "medium", "high", "max", "ultrathink"];
|
||||
}
|
||||
if (supportsClaudeAdaptiveReasoning(model)) {
|
||||
return ["low", "medium", "high", "ultrathink"];
|
||||
}
|
||||
return [];
|
||||
}
|
||||
if (provider === "cursor") {
|
||||
return [];
|
||||
}
|
||||
return REASONING_EFFORT_OPTIONS_BY_PROVIDER[provider];
|
||||
}
|
||||
|
||||
export function getDefaultReasoningEffort(provider: "codex"): CodexReasoningEffort;
|
||||
export function getDefaultReasoningEffort(provider: "claudeAgent"): ClaudeCodeEffort;
|
||||
export function getDefaultReasoningEffort(provider: "cursor"): CursorReasoningOption;
|
||||
export function getDefaultReasoningEffort(provider?: ProviderKind): ProviderReasoningEffort;
|
||||
export function getDefaultReasoningEffort(
|
||||
provider: ProviderKind = "codex",
|
||||
): ProviderReasoningEffort {
|
||||
return DEFAULT_REASONING_EFFORT_BY_PROVIDER[provider];
|
||||
}
|
||||
|
||||
export function resolveReasoningEffortForProvider(
|
||||
provider: "codex",
|
||||
effort: string | null | undefined,
|
||||
): CodexReasoningEffort | null;
|
||||
export function resolveReasoningEffortForProvider(
|
||||
provider: "claudeAgent",
|
||||
effort: string | null | undefined,
|
||||
): ClaudeCodeEffort | null;
|
||||
export function resolveReasoningEffortForProvider(
|
||||
provider: ProviderKind,
|
||||
effort: string | null | undefined,
|
||||
): ProviderReasoningEffort | null;
|
||||
export function resolveReasoningEffortForProvider(
|
||||
provider: ProviderKind,
|
||||
effort: string | null | undefined,
|
||||
): ProviderReasoningEffort | null {
|
||||
if (typeof effort !== "string") {
|
||||
return null;
|
||||
}
|
||||
|
||||
const trimmed = effort.trim();
|
||||
if (!trimmed) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const options = REASONING_EFFORT_OPTIONS_BY_PROVIDER[provider] as ReadonlyArray<string>;
|
||||
return options.includes(trimmed) ? (trimmed as ProviderReasoningEffort) : null;
|
||||
}
|
||||
|
||||
export function isCursorModelFamilySlug(slug: string): boolean {
|
||||
return CURSOR_MODEL_FAMILY_SET.has(slug as CursorModelFamily);
|
||||
}
|
||||
|
||||
export function getEffectiveClaudeCodeEffort(
|
||||
effort: ClaudeCodeEffort | null | undefined,
|
||||
): Exclude<ClaudeCodeEffort, "ultrathink"> | null {
|
||||
if (!effort) {
|
||||
return null;
|
||||
}
|
||||
return effort === "ultrathink" ? null : effort;
|
||||
}
|
||||
|
||||
export function normalizeCodexModelOptions(
|
||||
modelOptions: CodexModelOptions | null | undefined,
|
||||
): CodexModelOptions | undefined {
|
||||
const defaultReasoningEffort = getDefaultReasoningEffort("codex");
|
||||
const reasoningEffort =
|
||||
resolveReasoningEffortForProvider("codex", modelOptions?.reasoningEffort) ??
|
||||
defaultReasoningEffort;
|
||||
const fastModeEnabled = modelOptions?.fastMode === true;
|
||||
const nextOptions: CodexModelOptions = {
|
||||
...(reasoningEffort !== defaultReasoningEffort ? { reasoningEffort } : {}),
|
||||
...(fastModeEnabled ? { fastMode: true } : {}),
|
||||
};
|
||||
return Object.keys(nextOptions).length > 0 ? nextOptions : undefined;
|
||||
}
|
||||
|
||||
export function normalizeClaudeModelOptions(
|
||||
model: string | null | undefined,
|
||||
modelOptions: ClaudeModelOptions | null | undefined,
|
||||
): ClaudeModelOptions | undefined {
|
||||
const reasoningOptions = getReasoningEffortOptions("claudeAgent", model);
|
||||
const defaultReasoningEffort = getDefaultReasoningEffort("claudeAgent");
|
||||
const resolvedEffort = resolveReasoningEffortForProvider("claudeAgent", modelOptions?.effort);
|
||||
const effort =
|
||||
resolvedEffort &&
|
||||
resolvedEffort !== "ultrathink" &&
|
||||
reasoningOptions.includes(resolvedEffort) &&
|
||||
resolvedEffort !== defaultReasoningEffort
|
||||
? resolvedEffort
|
||||
: undefined;
|
||||
const thinking =
|
||||
supportsClaudeThinkingToggle(model) && modelOptions?.thinking === false ? false : undefined;
|
||||
const fastMode =
|
||||
supportsClaudeFastMode(model) && modelOptions?.fastMode === true ? true : undefined;
|
||||
const nextOptions: ClaudeModelOptions = {
|
||||
...(thinking === false ? { thinking: false } : {}),
|
||||
...(effort ? { effort } : {}),
|
||||
...(fastMode ? { fastMode: true } : {}),
|
||||
};
|
||||
return Object.keys(nextOptions).length > 0 ? nextOptions : undefined;
|
||||
}
|
||||
|
||||
export function applyClaudePromptEffortPrefix(
|
||||
text: string,
|
||||
effort: ClaudeAgentEffort | null | undefined,
|
||||
|
||||
Reference in new issue
Block a user