@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 04:45 UTC

main
ts 106 lines 2.97 KB
Raw
1 import { ProviderInstanceId } from "@t3tools/contracts";
2 import { describe, expect, it } from "vite-plus/test";
3
4 import { cursorSdkModelSelection } from "./sdkModel.ts";
5 import { buildCursorDiscoveredModelsFromSdk } from "./status.ts";
6
7 const instanceId = ProviderInstanceId.make("cursor");
8 const models = buildCursorDiscoveredModelsFromSdk([
9 {
10 id: "grok-4.5",
11 displayName: "Grok 4.5",
12 parameters: [
13 {
14 id: "effort",
15 displayName: "Effort",
16 values: [{ value: "low" }, { value: "medium" }, { value: "high" }],
17 },
18 { id: "fast", displayName: "Fast", values: [{ value: "false" }, { value: "true" }] },
19 ],
20 variants: [
21 {
22 displayName: "Grok 4.5 High Fast",
23 isDefault: true,
24 params: [
25 { id: "effort", value: "high" },
26 { id: "fast", value: "true" },
27 ],
28 },
29 ],
30 },
31 ]);
32
33 describe("cursorSdkModelSelection", () => {
34 it.each([
35 {
36 name: "fills unset catalog parameters and keeps Fast off",
37 options: undefined,
38 params: [
39 { id: "effort", value: "high" },
40 { id: "fast", value: "false" },
41 ],
42 },
43 {
44 name: "keeps explicit options",
45 options: [
46 { id: "effort", value: "low" },
47 { id: "fastMode", value: true },
48 ],
49 params: [
50 { id: "effort", value: "low" },
51 { id: "fast", value: "true" },
52 ],
53 },
54 ])("$name", ({ options, params }) => {
55 const selection = cursorSdkModelSelection(
56 { instanceId, model: "grok-4.5", ...(options === undefined ? {} : { options }) },
57 models,
58 );
59 expect({
60 ...selection,
61 params: selection.params?.toSorted((a, b) => a.id.localeCompare(b.id)),
62 }).toEqual({
63 id: "grok-4.5",
64 params,
65 });
66 });
67
68 it.each([
69 { context: undefined, maxMode: true },
70 { context: "1m", maxMode: true },
71 { context: "300k", maxMode: undefined },
72 ])("sets Max Mode from the catalog for context $context", ({ context, maxMode }) => {
73 const sdkModels = [
74 {
75 id: "gemini-4-neon",
76 displayName: "Gemini 4 Neon",
77 parameters: [{ id: "context", values: [{ value: "300k" }, { value: "1m" }] }],
78 variants: [
79 { displayName: "300K", params: [{ id: "context", value: "300k" }] },
80 {
81 displayName: "1M",
82 isDefault: true,
83 isMaxMode: true,
84 params: [{ id: "context", value: "1m" }],
85 },
86 ],
87 },
88 ];
89 const selection = cursorSdkModelSelection(
90 {
91 instanceId,
92 model: "gemini-4-neon",
93 ...(context === undefined ? {} : { options: [{ id: "contextWindow", value: context }] }),
94 },
95 buildCursorDiscoveredModelsFromSdk(sdkModels),
96 sdkModels,
97 );
98 expect(selection.maxMode).toBe(maxMode);
99 });
100
101 it("sends no parameters for a model missing from the catalog", () => {
102 expect(cursorSdkModelSelection({ instanceId, model: "auto" }, models)).toEqual({
103 id: "default",
104 });
105 });
106 });