Files
t3code/apps/server/src/provider/cursorSdkModel.ts
T
Julius Marminge 6f35159fbe Switch Cursor provider to the official SDK
- remove ACP model discovery and mismatch probe code
- update provider, orchestration, and tests for SDK-based flows
- refresh marketing copy to match the SDK runtime
2026-08-14 11:23:24 +02:00

53 lines
1.5 KiB
TypeScript

import type { ModelSelection as CursorSdkModelSelection, ModelParameterValue } from "@cursor/sdk";
import type { ModelSelection } from "@t3tools/contracts";
const CURSOR_SDK_PARAMETER_TO_PROVIDER_OPTION: Readonly<Record<string, string>> = {
context: "contextWindow",
fast: "fastMode",
};
const PROVIDER_OPTION_TO_CURSOR_SDK_PARAMETER: Readonly<Record<string, string>> = {
contextWindow: "context",
fastMode: "fast",
};
export function cursorSdkProviderOptionId(parameterId: string): string {
return CURSOR_SDK_PARAMETER_TO_PROVIDER_OPTION[parameterId] ?? parameterId;
}
export function cursorSdkParameterId(providerOptionId: string): string {
return PROVIDER_OPTION_TO_CURSOR_SDK_PARAMETER[providerOptionId] ?? providerOptionId;
}
export function cursorSdkParameterPriority(parameterId: string): number {
switch (parameterId) {
case "effort":
case "reasoning":
return 0;
case "context":
return 1;
case "fast":
return 2;
case "thinking":
return 3;
default:
return 4;
}
}
export function cursorSdkModelSelection(modelSelection: ModelSelection): CursorSdkModelSelection {
return {
id: modelSelection.model === "auto" ? "default" : modelSelection.model,
...(modelSelection.options === undefined || modelSelection.options.length === 0
? {}
: {
params: modelSelection.options.map(
(option): ModelParameterValue => ({
id: cursorSdkParameterId(option.id),
value: String(option.value),
}),
),
}),
};
}