@xiaoso/dsh-tool-plus 0.1.16 → 0.1.17-beta.0
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/lib/{abort-DZ54CaKU.mjs → abort-BTblp0Rt.mjs} +2 -2
- package/lib/{alibaba-coding-plan-DODpkcqi.mjs → alibaba-coding-plan-t3R4YKCB.mjs} +3 -3
- package/lib/{alibaba-token-plan-C6lpKCda.mjs → alibaba-token-plan-CO4djG1y.mjs} +4 -4
- package/lib/{alibaba-token-plan-CHGyWOfX.mjs → alibaba-token-plan-CUjYJX0-.mjs} +1 -1
- package/lib/{anthropic-Dv_GGX6g.mjs → anthropic-nf7w6so1.mjs} +48 -21
- package/lib/{api-key-validation-MnMf_ihX.mjs → api-key-validation-C_tZ7Y9a.mjs} +2 -2
- package/lib/behavior-BwvTUtag.mjs +111 -0
- package/lib/{browser-render-BZXt548F.mjs → browser-render-BQaEVK_n.mjs} +4 -4
- package/lib/{reference-CtvM4zLU.mjs → bundled-references-CrQ4dQcT.mjs} +57 -4
- package/lib/cascade-BWjRTD1q.mjs +30265 -0
- package/lib/{cline-pass-BT9CBEOj.mjs → cline-pass-Bjm-O8GG.mjs} +2 -2
- package/lib/cloudflare-CKXRJ0l9.mjs +37 -0
- package/lib/{cloudflare-ai-gateway-DReN6ohJ.mjs → cloudflare-ai-gateway-BpnBSjwV.mjs} +8 -4
- package/lib/cloudflare-workers-ai-odj9XswL.mjs +32 -0
- package/lib/collapse-_nkb2dn7.mjs +1945 -0
- package/lib/{coreweave-C82HrLpb.mjs → coreweave-CGDZOD8-.mjs} +1 -1
- package/lib/{coreweave-C68UgRQO.mjs → coreweave-DwffcgW5.mjs} +4 -4
- package/lib/cursor-BgOuV7Qf.mjs +794 -0
- package/lib/{cursor-_gHHq-Dq.mjs → cursor-CF1iHHbv.mjs} +68 -19
- package/lib/{cursor-proto-Cr_WEMuv.mjs → cursor-proto-BuNTjX3L.mjs} +823 -23
- package/lib/{devin-QpfTSl9H.mjs → devin-7OEeEb80.mjs} +112 -31
- package/lib/{devin-proto-DYhp4Ty6.mjs → devin-proto-C-QreeAv.mjs} +71 -5
- package/lib/{dom-DG3sPESc.mjs → dom-BmbZv4v9.mjs} +598 -182
- package/lib/{error-O63pC8zg.mjs → error-8LVo7tug.mjs} +725 -104
- package/lib/factory-droid-ChhmsGWb.mjs +71 -0
- package/lib/{fs-promises-shim-B2YFWkcd.mjs → fs-promises-shim-CANAxFWh.mjs} +10 -1
- package/lib/{github-copilot-BMEcw8N1.mjs → github-copilot-QwevdT30.mjs} +4 -4
- package/lib/{github-copilot-headers-DnjGEbko.mjs → github-copilot-headers-CAUZ0rUD.mjs} +138 -26
- package/lib/{gitlab-duo-DnHqJjFY.mjs → gitlab-duo-DigV7k_o.mjs} +2 -2
- package/lib/{google-antigravity-B1mSckrK.mjs → google-antigravity-D-oe0r8A.mjs} +6 -7
- package/lib/{google-gemini-cli-DJwThCCn.mjs → google-gemini-cli-CQBHgGJT.mjs} +5 -6
- package/lib/{google-oauth-shared-BctLpVUN.mjs → google-oauth-shared-CvgVIUwJ.mjs} +2 -2
- package/lib/google-validation-CdvRj4ec.mjs +126 -0
- package/lib/id-EJwVLDHE.mjs +2548 -0
- package/lib/index.mjs +248 -258
- package/lib/{kilo-BEgEwMJQ.mjs → kilo-5r6OffCa.mjs} +2 -2
- package/lib/{kimi-T9NldEIJ.mjs → kimi-DOOtbXmm.mjs} +9 -10
- package/lib/{launch-BIWNyrBB.mjs → launch-DkAjib7h.mjs} +1 -1
- package/lib/{markit-Dvp2JPdT.mjs → markit-CCcyeAds.mjs} +359 -140
- package/lib/{models-DnXMYGcJ.mjs → models-DCpDT_im.mjs} +199203 -112275
- package/lib/{muse-code-CNvqqAp6.mjs → muse-code-CYf8zj_B.mjs} +5 -5
- package/lib/{openai-codex-D5-CyTxa.mjs → openai-codex-Cj-TvSFh.mjs} +13 -10
- package/lib/{perplexity-A2PEoGaC.mjs → perplexity-Dh_Qgsmx.mjs} +68 -25
- package/lib/{pkce-BYjmugmw.mjs → pkce-DO-jBJLV.mjs} +1 -1
- package/lib/pricing-DusBEhwm.mjs +593 -0
- package/lib/{readability-uGhqb4GC.mjs → readability-XHK0o3bv.mjs} +287 -27
- package/lib/{scrapers-C1ujjV8k.mjs → scrapers-B6PADOVm.mjs} +13 -13
- package/lib/slugify-ynYWBIA5.mjs +11 -0
- package/lib/snowflake-B_jap6lz.mjs +666 -0
- package/lib/snowflake-Cu1ZyOp6.mjs +151 -0
- package/lib/{src-AELUUb5U.mjs → src-BhinCSpi.mjs} +1172 -458
- package/lib/{stream-AVOoe5Hj.mjs → stream-D2ivg3GH.mjs} +3740 -5311
- package/lib/{turndown-D6fof1OX.mjs → turndown-Vya8SavL.mjs} +82 -30
- package/lib/types/tools/hashline/native/index.d.ts +2 -2
- package/lib/types/tools/hashline/native/policy.d.ts +19 -21
- package/lib/types/tools/omp/session/agent-storage.d.ts +3 -3
- package/lib/types/tools/shared/bun-named-shim.d.ts +5 -0
- package/lib/{types-BLrLohwK.mjs → types-tH1v9uRm.mjs} +2 -2
- package/lib/{utils-cZX3f_Ls.mjs → utils-C_Ncya1r.mjs} +1737 -509
- package/lib/utils-D2tK38xq.mjs +34006 -0
- package/lib/{utils-I4I8azHN.mjs → utils-DrDwmNtu.mjs} +8 -3
- package/lib/{xai-oauth-CbeldUSV.mjs → xai-oauth-DLLzX6my.mjs} +4 -4
- package/lib/{xiaomi-Dl3VSs04.mjs → xiaomi-CqK-KivK.mjs} +2 -2
- package/lib/{zai-FyjGSypr.mjs → zai-DoJ2xPIH.mjs} +2 -2
- package/lib/{zip-DRrycScC.mjs → zip-DG1mUV6X.mjs} +1 -1
- package/package.json +8 -8
- package/lib/amazon-bedrock-Dx0rr9dY.mjs +0 -996
- package/lib/anthropic-ClCw0PV_.mjs +0 -3624
- package/lib/anthropic-wire-lbGAFzYb.mjs +0 -927
- package/lib/azure-openai-responses-WE_bgFWp.mjs +0 -285
- package/lib/bundled-references-DY3EJxZV.mjs +0 -56
- package/lib/cloudflare-ai-gateway-CrMa97Ap.mjs +0 -44
- package/lib/collapse-CkMNRNr7.mjs +0 -2304
- package/lib/cursor-C6jaIJDg.mjs +0 -283
- package/lib/cursor-D-XZYDf_.mjs +0 -4544
- package/lib/deterministic-id-CUEIMSqR.mjs +0 -17
- package/lib/devin-ExGIghmx.mjs +0 -69
- package/lib/devin-u0ljw5P6.mjs +0 -628
- package/lib/effort-BdtQMN-_.mjs +0 -23
- package/lib/event-stream-BKEtb45Y.mjs +0 -167
- package/lib/gemini-headers-Co9cVvex.mjs +0 -54
- package/lib/google-auth-qAN-6DMW.mjs +0 -232
- package/lib/google-gemini-cli-B2Aw1S5w.mjs +0 -844
- package/lib/google-lTxuq28n.mjs +0 -38
- package/lib/google-shared-Y01j9xOr.mjs +0 -856
- package/lib/google-validation-BEkNs-Bx.mjs +0 -18
- package/lib/google-vertex-DcM-FRC5.mjs +0 -99
- package/lib/hosts-00rjRzUD.mjs +0 -203
- package/lib/id-AL5obQzR.mjs +0 -71
- package/lib/idle-iterator-D0ZXEcUq.mjs +0 -366
- package/lib/ollama-6R0oXZks.mjs +0 -574
- package/lib/openai-codex-responses-C8bnBWOe.mjs +0 -3232
- package/lib/openai-completions-DNr3mUsn.mjs +0 -1430
- package/lib/openai-configuration-update-xMYUjaK_.mjs +0 -150
- package/lib/openai-reasoning-fallback-Ju-5pSR8.mjs +0 -380
- package/lib/openai-responses-CjpafAEr.mjs +0 -861
- package/lib/protobuf-BMgDYu_U.mjs +0 -717
- package/lib/provider-response-SqKSkkUc.mjs +0 -22
- package/lib/proxy-DxvCQOCA.mjs +0 -230
- package/lib/request-debug-BwPOqN_j.mjs +0 -183
- package/lib/sanitize-text-BCf5KmCf.mjs +0 -33
- package/lib/sse-debug-B-tkLCPW.mjs +0 -11
- package/lib/stream-markup-healing-CN3RsqG9.mjs +0 -267
- package/lib/strict-tool-validation-CBTz1dAA.mjs +0 -105
- package/lib/taxonomy-DSIM99rS.mjs +0 -15392
- package/lib/thinking-ngMwf_1Y.mjs +0 -336
- package/lib/type-guards-CttAANEx.mjs +0 -11
- package/lib/utils-CE3DSebh.mjs +0 -11763
- package/lib/vision-guard-BCpXWUj3.mjs +0 -77
package/lib/cursor-C6jaIJDg.mjs
DELETED
|
@@ -1,283 +0,0 @@
|
|
|
1
|
-
import { installBunShim as __installBunShim } from "./bun-shim.mjs";
|
|
2
|
-
__installBunShim();
|
|
3
|
-
import { d as compareRevision, f as parseRevision, n as classifyModel } from "./taxonomy-DSIM99rS.mjs";
|
|
4
|
-
import { r as getBundledModels } from "./models-DnXMYGcJ.mjs";
|
|
5
|
-
import { r as toModelSpec } from "./bundled-references-DY3EJxZV.mjs";
|
|
6
|
-
import { i as fromBinary, o as toBinary, t as create } from "./protobuf-BMgDYu_U.mjs";
|
|
7
|
-
import { nt as GetUsableModelsResponseSchema, tt as GetUsableModelsRequestSchema } from "./cursor-proto-Cr_WEMuv.mjs";
|
|
8
|
-
import { type } from "@oh-my-pi/omptype";
|
|
9
|
-
import * as http2$1 from "node:http2";
|
|
10
|
-
//#region node_modules/.pnpm/@oh-my-pi+pi-catalog@18.1.17/node_modules/@oh-my-pi/pi-catalog/src/discovery/cursor.ts
|
|
11
|
-
const CURSOR_DEFAULT_BASE_URL = "https://api2.cursor.sh";
|
|
12
|
-
const CURSOR_DEFAULT_CLIENT_VERSION = "cli-2026.02.13-41ac335";
|
|
13
|
-
const CURSOR_GET_USABLE_MODELS_PATH = "/agent.v1.AgentService/GetUsableModels";
|
|
14
|
-
const DEFAULT_CONTEXT_WINDOW = 2e5;
|
|
15
|
-
const DEFAULT_MAX_TOKENS = 64e3;
|
|
16
|
-
/**
|
|
17
|
-
* `GetUsableModels` carries no context-window field, so the 1M ceiling is
|
|
18
|
-
* recovered from the signals Cursor does send:
|
|
19
|
-
* - display-name labels ("Opus 5 1M", "GPT-5.5 1M High") across families,
|
|
20
|
-
* - natively 1M families Cursor serves unlabeled (Kimi K3, GLM 5.2+),
|
|
21
|
-
* - the max-mode flag on Claude/Gemini ids, whose max-mode ceiling is 1M.
|
|
22
|
-
*/
|
|
23
|
-
const CURSOR_1M_CONTEXT_WINDOW = 1e6;
|
|
24
|
-
const CURSOR_1M_NAME_PATTERN = /\b1m\b/i;
|
|
25
|
-
const OptionalDisplayNameSchema = type("unknown").pipe((raw) => typeof raw === "string" ? raw : void 0);
|
|
26
|
-
const CursorAliasesSchema = type("unknown").pipe((raw) => {
|
|
27
|
-
if (Array.isArray(raw)) return raw.filter((alias) => typeof alias === "string");
|
|
28
|
-
return [];
|
|
29
|
-
});
|
|
30
|
-
const CursorModelDetailsSchema = type({
|
|
31
|
-
modelId: "string",
|
|
32
|
-
displayName: OptionalDisplayNameSchema.default(void 0),
|
|
33
|
-
displayNameShort: OptionalDisplayNameSchema.default(void 0),
|
|
34
|
-
displayModelId: OptionalDisplayNameSchema.default(void 0),
|
|
35
|
-
aliases: CursorAliasesSchema.default(() => []),
|
|
36
|
-
"thinkingDetails?": "unknown",
|
|
37
|
-
maxMode: "boolean = false"
|
|
38
|
-
});
|
|
39
|
-
const CursorModelsInnerSchema = type("unknown[]");
|
|
40
|
-
const ResilientCursorModelsSchema = type("unknown").pipe((raw) => {
|
|
41
|
-
const out = CursorModelsInnerSchema(raw);
|
|
42
|
-
return out instanceof type.errors ? [] : out;
|
|
43
|
-
});
|
|
44
|
-
const CursorDecodedResponseSchema = type({ models: ResilientCursorModelsSchema.default(() => []) });
|
|
45
|
-
/**
|
|
46
|
-
* Fetches Cursor models through `GetUsableModels` and normalizes them into canonical model entries.
|
|
47
|
-
*
|
|
48
|
-
* Returns `null` on request/decode failures.
|
|
49
|
-
* Returns `[]` only when the endpoint responds successfully with no usable models.
|
|
50
|
-
*/
|
|
51
|
-
async function fetchCursorUsableModels(options) {
|
|
52
|
-
const timeoutMs = options.timeoutMs ?? 5e3;
|
|
53
|
-
try {
|
|
54
|
-
const requestPayload = create(GetUsableModelsRequestSchema, { customModelIds: normalizeCustomModelIds(options.customModelIds) });
|
|
55
|
-
const body = toBinary(GetUsableModelsRequestSchema, requestPayload);
|
|
56
|
-
const responseBuffer = await fetchViaHttp2((options.baseUrl ?? CURSOR_DEFAULT_BASE_URL).replace(/\/+$/, ""), body, options, timeoutMs);
|
|
57
|
-
if (!responseBuffer) return null;
|
|
58
|
-
const decoded = decodeGetUsableModelsResponse(responseBuffer);
|
|
59
|
-
const parsedDecoded = CursorDecodedResponseSchema(decoded);
|
|
60
|
-
if (parsedDecoded instanceof type.errors) return null;
|
|
61
|
-
const references = createCursorReferenceMap();
|
|
62
|
-
return normalizeCursorModels(parsedDecoded.models, options.baseUrl, references);
|
|
63
|
-
} catch {
|
|
64
|
-
return null;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
function buildRequestHeaders(options) {
|
|
68
|
-
return {
|
|
69
|
-
"content-type": "application/proto",
|
|
70
|
-
te: "trailers",
|
|
71
|
-
authorization: `Bearer ${options.apiKey}`,
|
|
72
|
-
"x-ghost-mode": "true",
|
|
73
|
-
"x-cursor-client-version": options.clientVersion ?? CURSOR_DEFAULT_CLIENT_VERSION,
|
|
74
|
-
"x-cursor-client-type": "cli"
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
/** HTTP/2 transport required by Cursor API (HTTP/1.1 is rejected with 464). */
|
|
78
|
-
async function fetchViaHttp2(baseUrl, body, options, timeoutMs) {
|
|
79
|
-
const { promise, resolve } = Promise.withResolvers();
|
|
80
|
-
const client = http2$1.connect(baseUrl);
|
|
81
|
-
const timer = setTimeout(() => {
|
|
82
|
-
client.destroy();
|
|
83
|
-
resolve(null);
|
|
84
|
-
}, timeoutMs);
|
|
85
|
-
client.on("error", () => {
|
|
86
|
-
clearTimeout(timer);
|
|
87
|
-
resolve(null);
|
|
88
|
-
});
|
|
89
|
-
const req = client.request({
|
|
90
|
-
":method": "POST",
|
|
91
|
-
":path": CURSOR_GET_USABLE_MODELS_PATH,
|
|
92
|
-
...buildRequestHeaders(options)
|
|
93
|
-
});
|
|
94
|
-
const chunks = [];
|
|
95
|
-
req.on("data", (chunk) => chunks.push(chunk));
|
|
96
|
-
req.on("end", () => {
|
|
97
|
-
clearTimeout(timer);
|
|
98
|
-
client.close();
|
|
99
|
-
resolve(new Uint8Array(Buffer.concat(chunks)));
|
|
100
|
-
});
|
|
101
|
-
req.on("error", () => {
|
|
102
|
-
clearTimeout(timer);
|
|
103
|
-
client.close();
|
|
104
|
-
resolve(null);
|
|
105
|
-
});
|
|
106
|
-
req.on("response", (headers) => {
|
|
107
|
-
const status = Number(headers[":status"] ?? 0);
|
|
108
|
-
if (status < 200 || status >= 300) {
|
|
109
|
-
clearTimeout(timer);
|
|
110
|
-
client.close();
|
|
111
|
-
resolve(null);
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
if (body.length > 0) req.end(Buffer.from(body));
|
|
115
|
-
else req.end();
|
|
116
|
-
return promise;
|
|
117
|
-
}
|
|
118
|
-
function normalizeCustomModelIds(customModelIds) {
|
|
119
|
-
if (!customModelIds) return [];
|
|
120
|
-
const normalized = /* @__PURE__ */ new Set();
|
|
121
|
-
for (const value of customModelIds) {
|
|
122
|
-
if (typeof value !== "string") continue;
|
|
123
|
-
const trimmed = value.trim();
|
|
124
|
-
if (!trimmed) continue;
|
|
125
|
-
normalized.add(trimmed);
|
|
126
|
-
}
|
|
127
|
-
return [...normalized];
|
|
128
|
-
}
|
|
129
|
-
function createCursorReferenceMap() {
|
|
130
|
-
const references = /* @__PURE__ */ new Map();
|
|
131
|
-
for (const model of getBundledModels("cursor")) references.set(model.id, toModelSpec(model));
|
|
132
|
-
return references;
|
|
133
|
-
}
|
|
134
|
-
function decodeGetUsableModelsResponse(payload) {
|
|
135
|
-
if (payload.length === 0) return null;
|
|
136
|
-
const framedBody = decodeConnectUnaryBody(payload);
|
|
137
|
-
if (framedBody) try {
|
|
138
|
-
return fromBinary(GetUsableModelsResponseSchema, framedBody);
|
|
139
|
-
} catch {
|
|
140
|
-
return null;
|
|
141
|
-
}
|
|
142
|
-
try {
|
|
143
|
-
return fromBinary(GetUsableModelsResponseSchema, payload);
|
|
144
|
-
} catch {
|
|
145
|
-
return null;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
function decodeConnectUnaryBody(payload) {
|
|
149
|
-
if (payload.length < 5) return null;
|
|
150
|
-
let offset = 0;
|
|
151
|
-
while (offset + 5 <= payload.length) {
|
|
152
|
-
const flags = payload[offset];
|
|
153
|
-
const messageLength = new DataView(payload.buffer, payload.byteOffset + offset, payload.byteLength - offset).getUint32(1, false);
|
|
154
|
-
const frameEnd = offset + 5 + messageLength;
|
|
155
|
-
if (frameEnd > payload.length) return null;
|
|
156
|
-
if ((flags & 1) !== 0) return null;
|
|
157
|
-
if (!((flags & 2) !== 0)) return payload.subarray(offset + 5, frameEnd);
|
|
158
|
-
offset = frameEnd;
|
|
159
|
-
}
|
|
160
|
-
return null;
|
|
161
|
-
}
|
|
162
|
-
function isCursorKimiK3(id) {
|
|
163
|
-
const identity = classifyModel("cursor", id, { lenient: true });
|
|
164
|
-
return identity.class === "kimi" && identity.family === "k3";
|
|
165
|
-
}
|
|
166
|
-
function isCursorVersionedGrok(id) {
|
|
167
|
-
const identity = classifyModel("cursor", id, { lenient: true });
|
|
168
|
-
if (identity.class !== "xai" || identity.revision === void 0) return false;
|
|
169
|
-
const revision = parseRevision(identity.revision);
|
|
170
|
-
const floor = parseRevision("4");
|
|
171
|
-
return revision !== void 0 && floor !== void 0 && compareRevision(revision, floor) >= 0;
|
|
172
|
-
}
|
|
173
|
-
function isCursorGlm52CodingModel(id) {
|
|
174
|
-
const identity = classifyModel("cursor", id, { lenient: true });
|
|
175
|
-
if (identity.class !== "glm" || identity.revision === void 0) return false;
|
|
176
|
-
if (identity.family !== void 0 && identity.family !== "air" && identity.family !== "turbo") return false;
|
|
177
|
-
const revision = parseRevision(identity.revision);
|
|
178
|
-
const floor = parseRevision("5.2");
|
|
179
|
-
return revision !== void 0 && floor !== void 0 && compareRevision(revision, floor) >= 0;
|
|
180
|
-
}
|
|
181
|
-
function normalizeCursorModels(models, baseUrlOverride, references) {
|
|
182
|
-
if (!models || models.length === 0) return [];
|
|
183
|
-
const byId = /* @__PURE__ */ new Map();
|
|
184
|
-
for (const model of models) {
|
|
185
|
-
const normalized = normalizeCursorModel(model, baseUrlOverride, references);
|
|
186
|
-
if (!normalized) continue;
|
|
187
|
-
byId.set(normalized.id, normalized);
|
|
188
|
-
}
|
|
189
|
-
return [...byId.values()].sort((a, b) => a.id.localeCompare(b.id));
|
|
190
|
-
}
|
|
191
|
-
function normalizeCursorModel(model, baseUrlOverride, references) {
|
|
192
|
-
const parsedModel = CursorModelDetailsSchema(model);
|
|
193
|
-
if (parsedModel instanceof type.errors) return null;
|
|
194
|
-
const details = parsedModel;
|
|
195
|
-
const id = details.modelId.trim();
|
|
196
|
-
if (!id) return null;
|
|
197
|
-
const name = pickModelDisplayName(details, id);
|
|
198
|
-
const reference = references.get(id);
|
|
199
|
-
const reasoning = isCursorKimiK3(id) || isCursorVersionedGrok(id) || Boolean(details.thinkingDetails) || reference?.reasoning === true;
|
|
200
|
-
if (reference) return {
|
|
201
|
-
...reference,
|
|
202
|
-
id,
|
|
203
|
-
name,
|
|
204
|
-
baseUrl: baseUrlOverride ?? reference.baseUrl,
|
|
205
|
-
reasoning,
|
|
206
|
-
input: resolveCursorInput(id, reference.input),
|
|
207
|
-
contextWindow: resolveCursorContextWindow(details, id, reference.contextWindow),
|
|
208
|
-
cursorMaxMode: details.maxMode
|
|
209
|
-
};
|
|
210
|
-
return {
|
|
211
|
-
id,
|
|
212
|
-
name,
|
|
213
|
-
api: "cursor-agent",
|
|
214
|
-
provider: "cursor",
|
|
215
|
-
baseUrl: baseUrlOverride ?? CURSOR_DEFAULT_BASE_URL,
|
|
216
|
-
reasoning,
|
|
217
|
-
input: resolveCursorInput(id),
|
|
218
|
-
cost: {
|
|
219
|
-
input: 0,
|
|
220
|
-
output: 0,
|
|
221
|
-
cacheRead: 0,
|
|
222
|
-
cacheWrite: 0
|
|
223
|
-
},
|
|
224
|
-
contextWindow: resolveCursorContextWindow(details, id, DEFAULT_CONTEXT_WINDOW),
|
|
225
|
-
maxTokens: DEFAULT_MAX_TOKENS,
|
|
226
|
-
cursorMaxMode: details.maxMode
|
|
227
|
-
};
|
|
228
|
-
}
|
|
229
|
-
/**
|
|
230
|
-
* Context window for a discovered Cursor model: the 1M ceiling when any 1M
|
|
231
|
-
* signal fires (never below a larger bundled reference), else the fallback.
|
|
232
|
-
*/
|
|
233
|
-
function resolveCursorContextWindow(model, id, fallback) {
|
|
234
|
-
const labeled1M = CURSOR_1M_NAME_PATTERN.test(id) || [
|
|
235
|
-
model.displayName,
|
|
236
|
-
model.displayNameShort,
|
|
237
|
-
model.displayModelId,
|
|
238
|
-
...model.aliases
|
|
239
|
-
].some((candidate) => typeof candidate === "string" && CURSOR_1M_NAME_PATTERN.test(candidate));
|
|
240
|
-
const identity = classifyModel("cursor", id, { lenient: true });
|
|
241
|
-
const maxMode1M = model.maxMode && (identity.class === "anthropic" || identity.class === "gemini");
|
|
242
|
-
if (labeled1M || isCursorNative1MModelId(id) || maxMode1M) return Math.max(fallback ?? 0, CURSOR_1M_CONTEXT_WINDOW);
|
|
243
|
-
return fallback;
|
|
244
|
-
}
|
|
245
|
-
/**
|
|
246
|
-
* Natively 1M-context families Cursor serves without a "1M" label: GLM 5.2+
|
|
247
|
-
* base/air/turbo coding SKUs (structured family and revision gates exclude
|
|
248
|
-
* vision and sub-1M variants). K3 — including Cursor's bare `k3` alias — is
|
|
249
|
-
* rule-owned via `context-window-floor` in `providers/cursor.kdl`.
|
|
250
|
-
*/
|
|
251
|
-
function isCursorNative1MModelId(id) {
|
|
252
|
-
return isCursorGlm52CodingModel(id);
|
|
253
|
-
}
|
|
254
|
-
function pickModelDisplayName(model, fallbackId) {
|
|
255
|
-
const candidates = [
|
|
256
|
-
model.displayName,
|
|
257
|
-
model.displayNameShort,
|
|
258
|
-
model.displayModelId,
|
|
259
|
-
...model.aliases,
|
|
260
|
-
fallbackId
|
|
261
|
-
];
|
|
262
|
-
for (const candidate of candidates) {
|
|
263
|
-
if (typeof candidate !== "string") continue;
|
|
264
|
-
const trimmed = candidate.trim();
|
|
265
|
-
if (trimmed) return trimmed;
|
|
266
|
-
}
|
|
267
|
-
return fallbackId;
|
|
268
|
-
}
|
|
269
|
-
/**
|
|
270
|
-
* Resolves input modalities from a bundled reference when available. The
|
|
271
|
-
* Cursor-verified families (K3, grok-4, composer-2.5) are rule-owned via
|
|
272
|
-
* `input-modalities` in `providers/cursor.kdl` and corrected at build time.
|
|
273
|
-
* Without a reference, families whose native catalogs are multimodal
|
|
274
|
-
* (anthropic, gemini, openai) fall back to id classification.
|
|
275
|
-
*/
|
|
276
|
-
function resolveCursorInput(id, referenceInput) {
|
|
277
|
-
if (referenceInput) return referenceInput;
|
|
278
|
-
const identity = classifyModel("cursor", id, { lenient: true });
|
|
279
|
-
if (identity.class === "anthropic" || identity.class === "gemini" || identity.class === "openai") return ["text", "image"];
|
|
280
|
-
return ["text"];
|
|
281
|
-
}
|
|
282
|
-
//#endregion
|
|
283
|
-
export { fetchCursorUsableModels, resolveCursorInput };
|