jeopi-catalog 16.2.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +523 -0
- package/README.md +43 -0
- package/dist/types/build.d.ts +3 -0
- package/dist/types/compat/anthropic.d.ts +11 -0
- package/dist/types/compat/apply.d.ts +7 -0
- package/dist/types/compat/devin.d.ts +9 -0
- package/dist/types/compat/openai.d.ts +28 -0
- package/dist/types/discovery/antigravity.d.ts +70 -0
- package/dist/types/discovery/codex.d.ts +38 -0
- package/dist/types/discovery/cursor-gen/agent_pb.d.ts +13022 -0
- package/dist/types/discovery/cursor.d.ts +23 -0
- package/dist/types/discovery/devin-gen/buf/validate/validate_pb.d.ts +1715 -0
- package/dist/types/discovery/devin-gen/exa/analytics_pb/analytics_pb.d.ts +693 -0
- package/dist/types/discovery/devin-gen/exa/api_server_pb/api_server_pb.d.ts +9158 -0
- package/dist/types/discovery/devin-gen/exa/auth_pb/auth_pb.d.ts +52 -0
- package/dist/types/discovery/devin-gen/exa/auto_cascade_common_pb/auto_cascade_common_pb.d.ts +276 -0
- package/dist/types/discovery/devin-gen/exa/bug_checker_pb/bug_checker_pb.d.ts +78 -0
- package/dist/types/discovery/devin-gen/exa/cascade_plugins_pb/cascade_plugins_pb.d.ts +999 -0
- package/dist/types/discovery/devin-gen/exa/chat_pb/chat_pb.d.ts +1704 -0
- package/dist/types/discovery/devin-gen/exa/code_edit/code_edit_pb/code_edit_pb.d.ts +656 -0
- package/dist/types/discovery/devin-gen/exa/codeium_common_pb/codeium_common_pb.d.ts +15014 -0
- package/dist/types/discovery/devin-gen/exa/context_module_pb/context_module_pb.d.ts +607 -0
- package/dist/types/discovery/devin-gen/exa/cortex_pb/cortex_pb.d.ts +11830 -0
- package/dist/types/discovery/devin-gen/exa/diff_action_pb/diff_action_pb.d.ts +248 -0
- package/dist/types/discovery/devin-gen/exa/index_pb/index_pb.d.ts +1747 -0
- package/dist/types/discovery/devin-gen/exa/knowledge_base_pb/knowledge_base_pb.d.ts +509 -0
- package/dist/types/discovery/devin-gen/exa/language_server_pb/language_server_pb.d.ts +9048 -0
- package/dist/types/discovery/devin-gen/exa/opensearch_clients_pb/opensearch_clients_pb.d.ts +1760 -0
- package/dist/types/discovery/devin-gen/exa/prompt_pb/prompt_pb.d.ts +286 -0
- package/dist/types/discovery/devin-gen/exa/reactive_component_pb/reactive_component_pb.d.ts +405 -0
- package/dist/types/discovery/devin-gen/exa/trust_pb/trust_pb.d.ts +582 -0
- package/dist/types/discovery/devin.d.ts +24 -0
- package/dist/types/discovery/gemini.d.ts +25 -0
- package/dist/types/discovery/gitlab-duo-workflow.d.ts +30 -0
- package/dist/types/discovery/index.d.ts +5 -0
- package/dist/types/discovery/openai-compatible.d.ts +74 -0
- package/dist/types/effort.d.ts +9 -0
- package/dist/types/fireworks-model-id.d.ts +23 -0
- package/dist/types/hosts.d.ts +137 -0
- package/dist/types/identity/bundled.d.ts +3 -0
- package/dist/types/identity/classify.d.ts +69 -0
- package/dist/types/identity/dialect.d.ts +3 -0
- package/dist/types/identity/family.d.ts +139 -0
- package/dist/types/identity/id.d.ts +12 -0
- package/dist/types/identity/index.d.ts +8 -0
- package/dist/types/identity/markers.d.ts +4 -0
- package/dist/types/identity/priority.d.ts +1 -0
- package/dist/types/identity/reference.d.ts +23 -0
- package/dist/types/index.d.ts +17 -0
- package/dist/types/model-cache.d.ts +17 -0
- package/dist/types/model-manager.d.ts +68 -0
- package/dist/types/model-thinking.d.ts +79 -0
- package/dist/types/models.d.ts +12 -0
- package/dist/types/provider-models/bundled-references.d.ts +11 -0
- package/dist/types/provider-models/descriptor-types.d.ts +74 -0
- package/dist/types/provider-models/descriptors.d.ts +427 -0
- package/dist/types/provider-models/google.d.ts +27 -0
- package/dist/types/provider-models/index.d.ts +6 -0
- package/dist/types/provider-models/ollama.d.ts +9 -0
- package/dist/types/provider-models/openai-compat.d.ts +450 -0
- package/dist/types/provider-models/special.d.ts +33 -0
- package/dist/types/types.d.ts +656 -0
- package/dist/types/utils.d.ts +20 -0
- package/dist/types/variant-collapse.d.ts +133 -0
- package/dist/types/wire/codex.d.ts +26 -0
- package/dist/types/wire/coreweave.d.ts +12 -0
- package/dist/types/wire/gemini-headers.d.ts +37 -0
- package/dist/types/wire/github-copilot.d.ts +45 -0
- package/package.json +101 -0
- package/src/build.ts +47 -0
- package/src/compat/anthropic.ts +93 -0
- package/src/compat/apply.ts +15 -0
- package/src/compat/devin.ts +12 -0
- package/src/compat/openai.ts +689 -0
- package/src/discovery/antigravity.ts +253 -0
- package/src/discovery/codex.ts +371 -0
- package/src/discovery/cursor-gen/agent_pb.ts +15274 -0
- package/src/discovery/cursor.ts +314 -0
- package/src/discovery/devin-gen/buf/validate/validate_pb.ts +1862 -0
- package/src/discovery/devin-gen/exa/analytics_pb/analytics_pb.ts +871 -0
- package/src/discovery/devin-gen/exa/api_server_pb/api_server_pb.ts +11083 -0
- package/src/discovery/devin-gen/exa/auth_pb/auth_pb.ts +71 -0
- package/src/discovery/devin-gen/exa/auto_cascade_common_pb/auto_cascade_common_pb.ts +348 -0
- package/src/discovery/devin-gen/exa/bug_checker_pb/bug_checker_pb.ts +103 -0
- package/src/discovery/devin-gen/exa/cascade_plugins_pb/cascade_plugins_pb.ts +1198 -0
- package/src/discovery/devin-gen/exa/chat_pb/chat_pb.ts +2063 -0
- package/src/discovery/devin-gen/exa/code_edit/code_edit_pb/code_edit_pb.ts +810 -0
- package/src/discovery/devin-gen/exa/codeium_common_pb/codeium_common_pb.ts +18354 -0
- package/src/discovery/devin-gen/exa/context_module_pb/context_module_pb.ts +732 -0
- package/src/discovery/devin-gen/exa/cortex_pb/cortex_pb.ts +14277 -0
- package/src/discovery/devin-gen/exa/diff_action_pb/diff_action_pb.ts +312 -0
- package/src/discovery/devin-gen/exa/index_pb/index_pb.ts +2106 -0
- package/src/discovery/devin-gen/exa/knowledge_base_pb/knowledge_base_pb.ts +623 -0
- package/src/discovery/devin-gen/exa/language_server_pb/language_server_pb.ts +10918 -0
- package/src/discovery/devin-gen/exa/opensearch_clients_pb/opensearch_clients_pb.ts +2125 -0
- package/src/discovery/devin-gen/exa/prompt_pb/prompt_pb.ts +361 -0
- package/src/discovery/devin-gen/exa/reactive_component_pb/reactive_component_pb.ts +450 -0
- package/src/discovery/devin-gen/exa/trust_pb/trust_pb.ts +712 -0
- package/src/discovery/devin.ts +151 -0
- package/src/discovery/gemini.ts +260 -0
- package/src/discovery/gitlab-duo-workflow.ts +855 -0
- package/src/discovery/index.ts +5 -0
- package/src/discovery/openai-compatible.ts +249 -0
- package/src/effort.ts +16 -0
- package/src/fireworks-model-id.ts +50 -0
- package/src/hosts.ts +129 -0
- package/src/identity/bundled.ts +28 -0
- package/src/identity/classify.ts +214 -0
- package/src/identity/dialect.ts +42 -0
- package/src/identity/family.ts +296 -0
- package/src/identity/id.ts +81 -0
- package/src/identity/index.ts +8 -0
- package/src/identity/markers.ts +49 -0
- package/src/identity/priority.ts +57 -0
- package/src/identity/reference.ts +148 -0
- package/src/index.ts +17 -0
- package/src/model-cache.ts +171 -0
- package/src/model-manager.ts +520 -0
- package/src/model-thinking.ts +760 -0
- package/src/models.json +88898 -0
- package/src/models.json.d.ts +9 -0
- package/src/models.ts +64 -0
- package/src/provider-models/bundled-references.ts +58 -0
- package/src/provider-models/descriptor-types.ts +79 -0
- package/src/provider-models/descriptors.ts +503 -0
- package/src/provider-models/google.ts +107 -0
- package/src/provider-models/index.ts +6 -0
- package/src/provider-models/ollama.ts +172 -0
- package/src/provider-models/openai-compat.ts +4283 -0
- package/src/provider-models/special.ts +159 -0
- package/src/types.ts +786 -0
- package/src/utils.ts +69 -0
- package/src/variant-collapse.ts +1065 -0
- package/src/wire/codex.ts +43 -0
- package/src/wire/coreweave.ts +51 -0
- package/src/wire/gemini-headers.ts +74 -0
- package/src/wire/github-copilot.ts +121 -0
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
import * as http2 from "node:http2";
|
|
2
|
+
import { create, fromBinary, toBinary } from "@bufbuild/protobuf";
|
|
3
|
+
import { type } from "arktype";
|
|
4
|
+
import { getBundledModels } from "../models";
|
|
5
|
+
import { toModelSpec } from "../provider-models/bundled-references";
|
|
6
|
+
import type { Model, ModelSpec } from "../types";
|
|
7
|
+
import { GetUsableModelsRequestSchema, GetUsableModelsResponseSchema } from "./cursor-gen/agent_pb";
|
|
8
|
+
|
|
9
|
+
const CURSOR_DEFAULT_BASE_URL = "https://api2.cursor.sh";
|
|
10
|
+
const CURSOR_DEFAULT_CLIENT_VERSION = "cli-2026.02.13-41ac335";
|
|
11
|
+
const CURSOR_GET_USABLE_MODELS_PATH = "/agent.v1.AgentService/GetUsableModels";
|
|
12
|
+
|
|
13
|
+
const DEFAULT_CONTEXT_WINDOW = 200_000;
|
|
14
|
+
const DEFAULT_MAX_TOKENS = 64_000;
|
|
15
|
+
|
|
16
|
+
const OptionalDisplayNameSchema = type("unknown").pipe(raw => (typeof raw === "string" ? raw : undefined));
|
|
17
|
+
const CursorAliasesSchema = type("unknown").pipe(raw => {
|
|
18
|
+
if (Array.isArray(raw)) {
|
|
19
|
+
return raw.filter((alias: unknown): alias is string => typeof alias === "string");
|
|
20
|
+
}
|
|
21
|
+
return [];
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
const CursorModelDetailsSchema = type({
|
|
25
|
+
modelId: "string",
|
|
26
|
+
displayName: OptionalDisplayNameSchema.default(undefined),
|
|
27
|
+
displayNameShort: OptionalDisplayNameSchema.default(undefined),
|
|
28
|
+
displayModelId: OptionalDisplayNameSchema.default(undefined),
|
|
29
|
+
aliases: CursorAliasesSchema.default(() => []),
|
|
30
|
+
"thinkingDetails?": "unknown",
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const CursorModelsInnerSchema = type("unknown[]");
|
|
34
|
+
const ResilientCursorModelsSchema = type("unknown").pipe(raw => {
|
|
35
|
+
const out = CursorModelsInnerSchema(raw);
|
|
36
|
+
return out instanceof type.errors ? [] : out;
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const CursorDecodedResponseSchema = type({
|
|
40
|
+
models: ResilientCursorModelsSchema.default(() => []),
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
type CursorModelDetailsValue = typeof CursorModelDetailsSchema.infer;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Options for fetching dynamic Cursor models from `GetUsableModels`.
|
|
47
|
+
*/
|
|
48
|
+
export interface CursorModelDiscoveryOptions {
|
|
49
|
+
/** Cursor access token used for bearer authentication. */
|
|
50
|
+
apiKey: string;
|
|
51
|
+
/** Optional Cursor API base URL override. */
|
|
52
|
+
baseUrl?: string;
|
|
53
|
+
/** Optional client version override sent as `x-cursor-client-version`. */
|
|
54
|
+
clientVersion?: string;
|
|
55
|
+
/** Optional request timeout in milliseconds. */
|
|
56
|
+
timeoutMs?: number;
|
|
57
|
+
/** Optional list of custom Cursor model ids to include in request context. */
|
|
58
|
+
customModelIds?: string[];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Fetches Cursor models through `GetUsableModels` and normalizes them into canonical model entries.
|
|
63
|
+
*
|
|
64
|
+
* Returns `null` on request/decode failures.
|
|
65
|
+
* Returns `[]` only when the endpoint responds successfully with no usable models.
|
|
66
|
+
*/
|
|
67
|
+
export async function fetchCursorUsableModels(
|
|
68
|
+
options: CursorModelDiscoveryOptions,
|
|
69
|
+
): Promise<ModelSpec<"cursor-agent">[] | null> {
|
|
70
|
+
const timeoutMs = options.timeoutMs ?? 5_000;
|
|
71
|
+
try {
|
|
72
|
+
const requestPayload = create(GetUsableModelsRequestSchema, {
|
|
73
|
+
customModelIds: normalizeCustomModelIds(options.customModelIds),
|
|
74
|
+
});
|
|
75
|
+
const body = toBinary(GetUsableModelsRequestSchema, requestPayload);
|
|
76
|
+
const baseUrl = (options.baseUrl ?? CURSOR_DEFAULT_BASE_URL).replace(/\/+$/, "");
|
|
77
|
+
|
|
78
|
+
const responseBuffer = await fetchViaHttp2(baseUrl, body, options, timeoutMs);
|
|
79
|
+
|
|
80
|
+
if (!responseBuffer) {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
const decoded = decodeGetUsableModelsResponse(responseBuffer);
|
|
84
|
+
const parsedDecoded = CursorDecodedResponseSchema(decoded);
|
|
85
|
+
if (parsedDecoded instanceof type.errors) {
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const references = createCursorReferenceMap();
|
|
90
|
+
return normalizeCursorModels(parsedDecoded.models, options.baseUrl, references);
|
|
91
|
+
} catch {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function buildRequestHeaders(options: CursorModelDiscoveryOptions): Record<string, string> {
|
|
97
|
+
return {
|
|
98
|
+
"content-type": "application/proto",
|
|
99
|
+
te: "trailers",
|
|
100
|
+
authorization: `Bearer ${options.apiKey}`,
|
|
101
|
+
"x-ghost-mode": "true",
|
|
102
|
+
"x-cursor-client-version": options.clientVersion ?? CURSOR_DEFAULT_CLIENT_VERSION,
|
|
103
|
+
"x-cursor-client-type": "cli",
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** HTTP/2 transport required by Cursor API (HTTP/1.1 is rejected with 464). */
|
|
108
|
+
async function fetchViaHttp2(
|
|
109
|
+
baseUrl: string,
|
|
110
|
+
body: Uint8Array,
|
|
111
|
+
options: CursorModelDiscoveryOptions,
|
|
112
|
+
timeoutMs: number,
|
|
113
|
+
): Promise<Uint8Array | null> {
|
|
114
|
+
const { promise, resolve } = Promise.withResolvers<Uint8Array | null>();
|
|
115
|
+
const client = http2.connect(baseUrl);
|
|
116
|
+
const timer = setTimeout(() => {
|
|
117
|
+
client.destroy();
|
|
118
|
+
resolve(null);
|
|
119
|
+
}, timeoutMs);
|
|
120
|
+
|
|
121
|
+
client.on("error", () => {
|
|
122
|
+
clearTimeout(timer);
|
|
123
|
+
resolve(null);
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
const req = client.request({
|
|
127
|
+
":method": "POST",
|
|
128
|
+
":path": CURSOR_GET_USABLE_MODELS_PATH,
|
|
129
|
+
...buildRequestHeaders(options),
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
const chunks: Buffer[] = [];
|
|
133
|
+
req.on("data", (chunk: Buffer) => chunks.push(chunk));
|
|
134
|
+
req.on("end", () => {
|
|
135
|
+
clearTimeout(timer);
|
|
136
|
+
client.close();
|
|
137
|
+
resolve(new Uint8Array(Buffer.concat(chunks)));
|
|
138
|
+
});
|
|
139
|
+
req.on("error", () => {
|
|
140
|
+
clearTimeout(timer);
|
|
141
|
+
client.close();
|
|
142
|
+
resolve(null);
|
|
143
|
+
});
|
|
144
|
+
req.on("response", headers => {
|
|
145
|
+
const status = Number(headers[":status"] ?? 0);
|
|
146
|
+
if (status < 200 || status >= 300) {
|
|
147
|
+
clearTimeout(timer);
|
|
148
|
+
client.close();
|
|
149
|
+
resolve(null);
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
if (body.length > 0) {
|
|
154
|
+
req.end(Buffer.from(body));
|
|
155
|
+
} else {
|
|
156
|
+
req.end();
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return promise;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function normalizeCustomModelIds(customModelIds: readonly string[] | undefined): string[] {
|
|
163
|
+
if (!customModelIds) {
|
|
164
|
+
return [];
|
|
165
|
+
}
|
|
166
|
+
const normalized = new Set<string>();
|
|
167
|
+
for (const value of customModelIds) {
|
|
168
|
+
if (typeof value !== "string") {
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
171
|
+
const trimmed = value.trim();
|
|
172
|
+
if (!trimmed) {
|
|
173
|
+
continue;
|
|
174
|
+
}
|
|
175
|
+
normalized.add(trimmed);
|
|
176
|
+
}
|
|
177
|
+
return [...normalized];
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function createCursorReferenceMap(): Map<string, ModelSpec<"cursor-agent">> {
|
|
181
|
+
const references = new Map<string, ModelSpec<"cursor-agent">>();
|
|
182
|
+
for (const model of getBundledModels("cursor")) {
|
|
183
|
+
references.set(model.id, toModelSpec(model as Model<"cursor-agent">));
|
|
184
|
+
}
|
|
185
|
+
return references;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function decodeGetUsableModelsResponse(payload: Uint8Array) {
|
|
189
|
+
if (payload.length === 0) {
|
|
190
|
+
return null;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
const framedBody = decodeConnectUnaryBody(payload);
|
|
194
|
+
if (framedBody) {
|
|
195
|
+
try {
|
|
196
|
+
return fromBinary(GetUsableModelsResponseSchema, framedBody);
|
|
197
|
+
} catch {
|
|
198
|
+
return null;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
try {
|
|
203
|
+
return fromBinary(GetUsableModelsResponseSchema, payload);
|
|
204
|
+
} catch {
|
|
205
|
+
return null;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function decodeConnectUnaryBody(payload: Uint8Array): Uint8Array | null {
|
|
210
|
+
if (payload.length < 5) {
|
|
211
|
+
return null;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
let offset = 0;
|
|
215
|
+
while (offset + 5 <= payload.length) {
|
|
216
|
+
const flags = payload[offset];
|
|
217
|
+
const view = new DataView(payload.buffer, payload.byteOffset + offset, payload.byteLength - offset);
|
|
218
|
+
const messageLength = view.getUint32(1, false);
|
|
219
|
+
const frameEnd = offset + 5 + messageLength;
|
|
220
|
+
if (frameEnd > payload.length) {
|
|
221
|
+
return null;
|
|
222
|
+
}
|
|
223
|
+
const compressionFlagSet = (flags & 0b0000_0001) !== 0;
|
|
224
|
+
if (compressionFlagSet) {
|
|
225
|
+
return null;
|
|
226
|
+
}
|
|
227
|
+
const endStreamFlagSet = (flags & 0b0000_0010) !== 0;
|
|
228
|
+
if (!endStreamFlagSet) {
|
|
229
|
+
return payload.subarray(offset + 5, frameEnd);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
offset = frameEnd;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
return null;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
function normalizeCursorModels(
|
|
239
|
+
models: readonly unknown[] | undefined,
|
|
240
|
+
baseUrlOverride: string | undefined,
|
|
241
|
+
references: Map<string, ModelSpec<"cursor-agent">>,
|
|
242
|
+
): ModelSpec<"cursor-agent">[] {
|
|
243
|
+
if (!models || models.length === 0) {
|
|
244
|
+
return [];
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
const byId = new Map<string, ModelSpec<"cursor-agent">>();
|
|
248
|
+
for (const model of models) {
|
|
249
|
+
const normalized = normalizeCursorModel(model, baseUrlOverride, references);
|
|
250
|
+
if (!normalized) {
|
|
251
|
+
continue;
|
|
252
|
+
}
|
|
253
|
+
byId.set(normalized.id, normalized);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
return [...byId.values()].sort((a, b) => a.id.localeCompare(b.id));
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
function normalizeCursorModel(
|
|
260
|
+
model: unknown,
|
|
261
|
+
baseUrlOverride: string | undefined,
|
|
262
|
+
references: Map<string, ModelSpec<"cursor-agent">>,
|
|
263
|
+
): ModelSpec<"cursor-agent"> | null {
|
|
264
|
+
const parsedModel = CursorModelDetailsSchema(model);
|
|
265
|
+
if (parsedModel instanceof type.errors) {
|
|
266
|
+
return null;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
const details = parsedModel;
|
|
270
|
+
const id = details.modelId.trim();
|
|
271
|
+
if (!id) {
|
|
272
|
+
return null;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
const name = pickModelDisplayName(details, id);
|
|
276
|
+
const reference = references.get(id);
|
|
277
|
+
const reasoning = Boolean(details.thinkingDetails) || reference?.reasoning === true;
|
|
278
|
+
|
|
279
|
+
if (reference) {
|
|
280
|
+
return {
|
|
281
|
+
...reference,
|
|
282
|
+
id,
|
|
283
|
+
name,
|
|
284
|
+
baseUrl: baseUrlOverride ?? reference.baseUrl,
|
|
285
|
+
reasoning,
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
return {
|
|
289
|
+
id,
|
|
290
|
+
name,
|
|
291
|
+
api: "cursor-agent",
|
|
292
|
+
provider: "cursor",
|
|
293
|
+
baseUrl: baseUrlOverride ?? CURSOR_DEFAULT_BASE_URL,
|
|
294
|
+
reasoning,
|
|
295
|
+
input: ["text"],
|
|
296
|
+
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
297
|
+
contextWindow: DEFAULT_CONTEXT_WINDOW,
|
|
298
|
+
maxTokens: DEFAULT_MAX_TOKENS,
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
function pickModelDisplayName(model: CursorModelDetailsValue, fallbackId: string): string {
|
|
303
|
+
const candidates = [model.displayName, model.displayNameShort, model.displayModelId, ...model.aliases, fallbackId];
|
|
304
|
+
for (const candidate of candidates) {
|
|
305
|
+
if (typeof candidate !== "string") {
|
|
306
|
+
continue;
|
|
307
|
+
}
|
|
308
|
+
const trimmed = candidate.trim();
|
|
309
|
+
if (trimmed) {
|
|
310
|
+
return trimmed;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
return fallbackId;
|
|
314
|
+
}
|