@bitkyc08/opencodex 2.33.0 → 2.34.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/README.md +3 -3
- package/gui/dist/assets/index-C4TMRloX.js +112 -0
- package/gui/dist/assets/index-DQ-Ie18T.css +1 -0
- package/gui/dist/index.html +2 -2
- package/package.json +1 -1
- package/src/adapters/anthropic.ts +79 -2
- package/src/adapters/command-code.ts +40 -3
- package/src/adapters/cursor/call-id.ts +44 -0
- package/src/adapters/cursor/checkpoint-store.ts +15 -10
- package/src/adapters/cursor/discovery.ts +60 -2
- package/src/adapters/cursor/effort-map.ts +79 -1
- package/src/adapters/cursor/envelope-echo.ts +162 -0
- package/src/adapters/cursor/live-models.ts +7 -2
- package/src/adapters/cursor/live-transport.ts +14 -0
- package/src/adapters/cursor/message-mapper.ts +4 -1
- package/src/adapters/cursor/native-exec-desktop.ts +23 -0
- package/src/adapters/cursor/native-exec-fs.ts +2 -2
- package/src/adapters/cursor/native-exec-network.ts +1 -1
- package/src/adapters/cursor/native-exec-shell.ts +5 -2
- package/src/adapters/cursor/native-exec.ts +20 -0
- package/src/adapters/cursor/protobuf-request.ts +68 -14
- package/src/adapters/cursor/request-builder.ts +29 -6
- package/src/adapters/cursor/tool-definitions.ts +11 -2
- package/src/adapters/cursor/tool-result-normalize.ts +32 -1
- package/src/adapters/cursor/types.ts +20 -0
- package/src/adapters/cursor.ts +189 -37
- package/src/adapters/google-antigravity-replay.ts +102 -23
- package/src/adapters/google-errors.ts +44 -12
- package/src/adapters/google.ts +115 -16
- package/src/adapters/image.ts +1 -1
- package/src/adapters/kiro-constants.ts +15 -0
- package/src/adapters/kiro-tools.ts +43 -15
- package/src/adapters/kiro.ts +54 -9
- package/src/adapters/openai-chat.ts +286 -242
- package/src/adapters/openai-responses.ts +334 -24
- package/src/adapters/tool-catalog-nudge.ts +2 -2
- package/src/adapters/xai-tool-schema.ts +436 -0
- package/src/bridge.ts +67 -24
- package/src/chat/inbound.ts +14 -1
- package/src/chat/outbound.ts +15 -7
- package/src/claude/agents-inject.ts +8 -1
- package/src/claude/outbound.ts +10 -8
- package/src/cli/account-api.ts +32 -4
- package/src/cli/account-extended.ts +1 -1
- package/src/cli/account.ts +29 -5
- package/src/cli/alias.ts +66 -0
- package/src/cli/claude.ts +26 -1
- package/src/cli/dispatch.ts +13 -1
- package/src/cli/help.ts +1 -0
- package/src/cli/init.ts +1 -0
- package/src/cli/models-runtime.ts +95 -0
- package/src/cli/models.ts +13 -7
- package/src/cli/provider-runtime.ts +16 -2
- package/src/cli/registry.ts +6 -1
- package/src/cli/v2.ts +34 -10
- package/src/codex/account-pause.ts +2 -1
- package/src/codex/account-priority.ts +3 -2
- package/src/codex/app-server-processes.ts +80 -6
- package/src/codex/auth-api.ts +46 -8
- package/src/codex/auth-context.ts +21 -18
- package/src/codex/catalog/aggregation.ts +6 -0
- package/src/codex/catalog/native-models.ts +5 -2
- package/src/codex/catalog/parsing.ts +16 -0
- package/src/codex/catalog/provider-fetch.ts +20 -3
- package/src/codex/catalog/sync.ts +127 -2
- package/src/codex/catalog.ts +1 -1
- package/src/codex/codex-write-lock.ts +3 -1
- package/src/codex/convergence-types.ts +1 -1
- package/src/codex/convergence.ts +22 -2
- package/src/codex/desired-state.ts +2 -2
- package/src/codex/desktop-app-restart.ts +18 -5
- package/src/codex/inject-coordination.ts +83 -0
- package/src/codex/inject.ts +14 -1
- package/src/codex/log-guard/inspect.ts +22 -4
- package/src/codex/model-entitlements.ts +9 -2
- package/src/codex/prompt-layers.ts +371 -25
- package/src/codex/prompt-text-probe.ts +238 -0
- package/src/codex/quota.ts +91 -10
- package/src/codex/routing.ts +9 -0
- package/src/codex/subagent-model-fallback.ts +104 -25
- package/src/codex/transition-state.ts +107 -8
- package/src/combos/types.ts +10 -0
- package/src/compatibility/openai-responses.ts +33 -1
- package/src/config/rebase-provenance.ts +68 -0
- package/src/config.ts +107 -9
- package/src/generated/compatibility-version.json +191 -139
- package/src/images/loop.ts +5 -4
- package/src/lab/conformance/fixtures/protocol-v1-cases.json +1 -1
- package/src/lab/fabric/producer-child.ts +1 -1
- package/src/lib/config-ownership.ts +20 -0
- package/src/lib/errors.ts +11 -2
- package/src/lib/package-tree-integrity.ts +101 -0
- package/src/oauth/generic-account-failover.ts +231 -0
- package/src/oauth/index.ts +57 -5
- package/src/oauth/key-providers.ts +10 -1
- package/src/oauth/kiro.ts +45 -0
- package/src/oauth/types.ts +15 -0
- package/src/providers/command-code-efforts.ts +38 -6
- package/src/providers/context-cap.ts +4 -3
- package/src/providers/default-aliases.ts +65 -0
- package/src/providers/derive.ts +28 -0
- package/src/providers/fastwire.ts +7 -1
- package/src/providers/model-presets.ts +119 -0
- package/src/providers/new-model-policy.ts +146 -0
- package/src/providers/provider-id-rewrite.ts +2 -1
- package/src/providers/quota.ts +65 -7
- package/src/providers/registry.ts +160 -68
- package/src/providers/slug-codec.ts +52 -0
- package/src/responses/code-mode-helper-compat.ts +50 -0
- package/src/responses/custom-tool-compat.ts +34 -10
- package/src/responses/parser.ts +4 -0
- package/src/responses/schema.ts +5 -1
- package/src/responses/thought-signature-replay.ts +17 -0
- package/src/router.ts +40 -2
- package/src/routing/analytics.ts +1 -0
- package/src/routing/quota.ts +10 -0
- package/src/server/auth-cors.ts +4 -0
- package/src/server/chat-completions.ts +24 -16
- package/src/server/chat-native-sse.ts +3 -3
- package/src/server/chat-native.ts +30 -11
- package/src/server/claude-messages.ts +1 -1
- package/src/server/index.ts +77 -11
- package/src/server/lifecycle.ts +52 -1
- package/src/server/management/agent-settings-routes.ts +31 -15
- package/src/server/management/codex-prompt-routes.ts +570 -0
- package/src/server/management/combo-routes.ts +2 -1
- package/src/server/management/config-routes.ts +27 -9
- package/src/server/management/context.ts +9 -0
- package/src/server/management/model-routes.ts +266 -0
- package/src/server/management/provider-routes.ts +6 -0
- package/src/server/management/routing-profile-routes.ts +2 -2
- package/src/server/management-api.ts +2 -0
- package/src/server/relay-eager.ts +147 -20
- package/src/server/relay.ts +251 -19
- package/src/server/request-log-conversation.ts +21 -0
- package/src/server/request-log.ts +41 -15
- package/src/server/responses/collaboration.ts +37 -3
- package/src/server/responses/combo-stream-preflight.ts +10 -3
- package/src/server/responses/core.ts +494 -114
- package/src/server/responses/empty-completion-guard.ts +35 -0
- package/src/server/responses/fetch-helpers.ts +2 -1
- package/src/server/responses/input-admission.ts +3 -1
- package/src/server/responses/passthrough-error.ts +33 -9
- package/src/server/responses/responses-field-backfill.ts +105 -13
- package/src/server/responses-custom-tool-repair.ts +52 -7
- package/src/server/responses-terminal-repair.ts +25 -4
- package/src/server/sse-frame-buffer.ts +31 -4
- package/src/server/ws-bridge.ts +14 -2
- package/src/types/config.ts +53 -0
- package/src/types/provider.ts +64 -0
- package/src/types/request.ts +11 -3
- package/src/types/tools.ts +7 -5
- package/src/types.ts +1 -0
- package/src/usage/expected-prices.ts +43 -24
- package/src/usage/log.ts +3 -0
- package/src/web-search/exa-executor.ts +40 -9
- package/src/web-search/loop.ts +5 -4
- package/gui/dist/assets/index-23-Lf7jR.js +0 -102
- package/gui/dist/assets/index-DxJMDyOr.css +0 -1
|
@@ -7,6 +7,7 @@ import { isAllowedToolChoice, namespacedToolName, resolveToolChoiceWireName, too
|
|
|
7
7
|
import type { AdapterFetchContext, AdapterRequest, ProviderAdapter } from "./base";
|
|
8
8
|
import type { TranslatorBudget } from "../lib/translator-budget";
|
|
9
9
|
import { readBoundedResponseBody } from "../lib/bounded-body";
|
|
10
|
+
import { debugDroppedFrame } from "../lib/debug";
|
|
10
11
|
import { configuredReasoningEfforts } from "../reasoning-effort";
|
|
11
12
|
import { commandCodeReasoningEfforts, refreshCommandCodeReasoningEfforts } from "../providers/command-code-efforts";
|
|
12
13
|
import { identifyRoutedModel } from "./identity";
|
|
@@ -143,7 +144,8 @@ function wireMessages(messages: OcxMessage[]): Array<Record<string, unknown>> {
|
|
|
143
144
|
if (typeof message.content === "string") content.push({ type: "text", text: message.content });
|
|
144
145
|
else for (const part of message.content) {
|
|
145
146
|
if (part.type === "text") content.push({ type: "text", text: part.text });
|
|
146
|
-
else content.push(wireImagePart(part.imageUrl));
|
|
147
|
+
else if (part.type === "image") content.push(wireImagePart(part.imageUrl));
|
|
148
|
+
else content.push({ type: "text", text: "[video]" });
|
|
147
149
|
}
|
|
148
150
|
out.push({ role: "user", content });
|
|
149
151
|
}
|
|
@@ -365,7 +367,7 @@ async function*ndjson(response: Response, budget: TranslatorBudget): AsyncGenera
|
|
|
365
367
|
let newline = buffer.indexOf("\n");
|
|
366
368
|
while (newline >= 0) {
|
|
367
369
|
const line = buffer.slice(0, newline).trim(); buffer = buffer.slice(newline + 1);
|
|
368
|
-
if (line)
|
|
370
|
+
if (line) yield* decodeEventLine(line);
|
|
369
371
|
newline = buffer.indexOf("\n");
|
|
370
372
|
}
|
|
371
373
|
const residualBytes = encoder.encode(buffer).byteLength;
|
|
@@ -376,7 +378,7 @@ async function*ndjson(response: Response, budget: TranslatorBudget): AsyncGenera
|
|
|
376
378
|
if (done) break;
|
|
377
379
|
}
|
|
378
380
|
const final = buffer.trim();
|
|
379
|
-
if (final)
|
|
381
|
+
if (final) yield* decodeEventLine(final);
|
|
380
382
|
} finally {
|
|
381
383
|
budget.releaseRetained(bufferBytes, { kind: "live_transient" });
|
|
382
384
|
try { await reader.cancel(); } catch { /* already closed */ }
|
|
@@ -384,6 +386,41 @@ async function*ndjson(response: Response, budget: TranslatorBudget): AsyncGenera
|
|
|
384
386
|
}
|
|
385
387
|
}
|
|
386
388
|
|
|
389
|
+
/**
|
|
390
|
+
* Yield one NDJSON line as an event record, or nothing.
|
|
391
|
+
*
|
|
392
|
+
* `JSON.parse("null")` returns `null` instead of throwing, so the `try/catch` around the parse
|
|
393
|
+
* cannot see it and the `event.type` read in parseStream crashed the turn — the #1219 defect, on
|
|
394
|
+
* the one streaming transport the #1240 audit did not cover because it is NDJSON rather than SSE.
|
|
395
|
+
*
|
|
396
|
+
* A frame that does not parse to a record is padding, not an event: drop it and continue exactly
|
|
397
|
+
* as an unparseable line is already dropped, so a stream whose only frames are junk ends in the
|
|
398
|
+
* same single terminal `done` as an empty body. Skipping is what preserves an answer whose deltas
|
|
399
|
+
* have already arrived — the observed #1219 case is `null` padding BETWEEN content deltas, where
|
|
400
|
+
* terminating would discard a complete response (#1240).
|
|
401
|
+
*
|
|
402
|
+
* Note this deliberately makes a junk-only stream a quiet `[done]` where it previously threw. That
|
|
403
|
+
* throw was an unguarded type assumption, not a designed failure signal, and `[done]` is already
|
|
404
|
+
* what an empty body, a blank-line-only body and an unparseable-only body all produce here. The
|
|
405
|
+
* broader question — whether this adapter should report *any* no-valid-event stream as a failure
|
|
406
|
+
* rather than an empty success — is pre-existing, applies to all four of those inputs equally, and
|
|
407
|
+
* is deliberately not decided by this change.
|
|
408
|
+
*/
|
|
409
|
+
function* decodeEventLine(line: string): Generator<Record<string, unknown>> {
|
|
410
|
+
let parsed: unknown;
|
|
411
|
+
try {
|
|
412
|
+
parsed = JSON.parse(stripEventFrame(line));
|
|
413
|
+
} catch {
|
|
414
|
+
debugDroppedFrame("command-code", line);
|
|
415
|
+
return;
|
|
416
|
+
}
|
|
417
|
+
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
418
|
+
debugDroppedFrame("command-code", line);
|
|
419
|
+
return;
|
|
420
|
+
}
|
|
421
|
+
yield parsed as Record<string, unknown>;
|
|
422
|
+
}
|
|
423
|
+
|
|
387
424
|
/** The endpoint is newline-delimited JSON; defensively strip an SSE `data:` frame if the gateway ever switches shapes. */
|
|
388
425
|
function stripEventFrame(line: string): string {
|
|
389
426
|
return line.startsWith("data:") ? line.slice("data:".length).trim() : line;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reversible single-line codec for Cursor composite tool-call ids.
|
|
3
|
+
*
|
|
4
|
+
* Cursor's wire delivers tool-call ids that can be two identifiers glued with a
|
|
5
|
+
* literal newline ("call-<uuid>-<n>\nfc_<uuid>_<n>"). OpenCodex forwards ids
|
|
6
|
+
* verbatim, so that newline leaked into Responses-visible `call_id` values,
|
|
7
|
+
* where line-oriented clients (logging, splitting, validation) break. The codec
|
|
8
|
+
* encodes only ids containing CR/LF into a versioned single-line form and
|
|
9
|
+
* decodes both that form and legacy raw multi-line ids back to the exact
|
|
10
|
+
* upstream bytes before anything is serialized toward Cursor.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
const CALL_ID_PREFIX = "ocxc1_";
|
|
14
|
+
|
|
15
|
+
/** True when the id needs encoding to survive line-oriented consumers. */
|
|
16
|
+
function needsEncoding(id: string): boolean {
|
|
17
|
+
return id.includes("\n") || id.includes("\r");
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Encode a Cursor wire call id into a single-line Responses-safe id. */
|
|
21
|
+
export function encodeCursorCallId(id: string): string {
|
|
22
|
+
if (!needsEncoding(id)) return id;
|
|
23
|
+
return CALL_ID_PREFIX + Buffer.from(id, "utf8").toString("base64url");
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Decode a Responses-visible call id back to the exact Cursor wire id.
|
|
28
|
+
* Non-encoded ids (including legacy raw multi-line ids replayed by older
|
|
29
|
+
* clients) pass through unchanged; a malformed encoded payload also passes
|
|
30
|
+
* through rather than corrupting pairing.
|
|
31
|
+
*/
|
|
32
|
+
export function decodeCursorCallId(id: string): string {
|
|
33
|
+
if (!id.startsWith(CALL_ID_PREFIX)) return id;
|
|
34
|
+
const payload = id.slice(CALL_ID_PREFIX.length);
|
|
35
|
+
if (payload.length === 0) return id;
|
|
36
|
+
try {
|
|
37
|
+
const decoded = Buffer.from(payload, "base64url").toString("utf8");
|
|
38
|
+
// Round-trip guard: only trust payloads our encoder could have produced.
|
|
39
|
+
if (Buffer.from(decoded, "utf8").toString("base64url") !== payload) return id;
|
|
40
|
+
return decoded;
|
|
41
|
+
} catch {
|
|
42
|
+
return id;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -236,6 +236,7 @@ export function commitCursorCheckpoint(input: {
|
|
|
236
236
|
}
|
|
237
237
|
|
|
238
238
|
export function getCursorCheckpointForPrefix(input: {
|
|
239
|
+
conversationId: string;
|
|
239
240
|
prefixDigest: string;
|
|
240
241
|
systemDigest: string;
|
|
241
242
|
coveredMessageCount: number;
|
|
@@ -244,17 +245,21 @@ export function getCursorCheckpointForPrefix(input: {
|
|
|
244
245
|
}): CursorCheckpointSnapshot | undefined {
|
|
245
246
|
prune();
|
|
246
247
|
const refs = store.prefixIndex.get(input.prefixDigest);
|
|
247
|
-
if (!refs
|
|
248
|
-
const [ref] = refs;
|
|
249
|
-
if (!ref) return undefined;
|
|
250
|
-
const snapshot = getCursorCheckpoint(ref);
|
|
251
|
-
if (!snapshot) return undefined;
|
|
248
|
+
if (!refs) return undefined;
|
|
252
249
|
const identityScope = input.identityScope?.trim() || "local";
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
250
|
+
let foundRef: string | undefined;
|
|
251
|
+
for (const ref of refs) {
|
|
252
|
+
const snapshot = store.snapshots.get(ref);
|
|
253
|
+
if (!snapshot) continue;
|
|
254
|
+
if (snapshot.conversationId !== input.conversationId) continue;
|
|
255
|
+
if (snapshot.systemDigest !== input.systemDigest) continue;
|
|
256
|
+
if (snapshot.coveredMessageCount !== input.coveredMessageCount) continue;
|
|
257
|
+
if (snapshot.identityScope !== identityScope) continue;
|
|
258
|
+
if (snapshot.modelId !== input.modelId) continue;
|
|
259
|
+
if (foundRef) return undefined;
|
|
260
|
+
foundRef = ref;
|
|
261
|
+
}
|
|
262
|
+
return getCursorCheckpoint(foundRef);
|
|
258
263
|
}
|
|
259
264
|
|
|
260
265
|
export function getLatestCursorCheckpoint(
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CANONICAL_EFFORT_SUFFIXES,
|
|
3
3
|
cursorModelEffortLadder,
|
|
4
|
+
cursorModelHasEffortTiers,
|
|
4
5
|
cursorWireModelIdWithEffort,
|
|
6
|
+
CURSOR_THINKING_MODEL_IDS,
|
|
5
7
|
} from "./effort-map";
|
|
6
8
|
|
|
7
9
|
export interface CursorModelInfo {
|
|
@@ -152,6 +154,25 @@ export function cursorCodexToWireModelId(modelId: string): string {
|
|
|
152
154
|
return cursorWireModelSelection(modelId).modelId;
|
|
153
155
|
}
|
|
154
156
|
|
|
157
|
+
/**
|
|
158
|
+
* Synthetic ultra/big-context picker marker (devlog 260826 070). A `cursor/<base>-1m` row is a
|
|
159
|
+
* picker-only variant: the wire request keeps `<base>` (plus effort suffix) and turns on Cursor
|
|
160
|
+
* Max Mode instead. Only ids listed here are treated as synthetic — a real upstream wire id that
|
|
161
|
+
* happens to end in `-1m` never collides because it will not be in this set.
|
|
162
|
+
*/
|
|
163
|
+
export const CURSOR_ULTRA_1M_MODEL_IDS: ReadonlySet<string> = new Set([
|
|
164
|
+
"kimi-k3-1m",
|
|
165
|
+
]);
|
|
166
|
+
|
|
167
|
+
const CURSOR_ULTRA_1M_SUFFIX = "-1m";
|
|
168
|
+
|
|
169
|
+
/** Resolve a synthetic ultra marker id to its wire base, or undefined for ordinary ids. */
|
|
170
|
+
export function cursorUltraBaseModelId(modelId: string): string | undefined {
|
|
171
|
+
const normalized = modelId.startsWith("cursor/") ? modelId.slice("cursor/".length) : modelId;
|
|
172
|
+
if (!CURSOR_ULTRA_1M_MODEL_IDS.has(normalized)) return undefined;
|
|
173
|
+
return normalized.slice(0, -CURSOR_ULTRA_1M_SUFFIX.length);
|
|
174
|
+
}
|
|
175
|
+
|
|
155
176
|
/**
|
|
156
177
|
* Cursor-native wire models keep server-side conversation state reliably.
|
|
157
178
|
* External models (gpt/claude/gemini/grok families and similar) are more brittle on resumeAction.
|
|
@@ -212,10 +233,27 @@ export function filterCursorConfiguredModelsByLiveDiscovery<T extends { id: stri
|
|
|
212
233
|
liveIds: readonly string[],
|
|
213
234
|
): T[] {
|
|
214
235
|
return configured.filter(model =>
|
|
215
|
-
|
|
236
|
+
!CURSOR_KNOWN_UNCALLABLE_MODEL_IDS.has(model.id)
|
|
237
|
+
&& (
|
|
238
|
+
isCursorRouterModelId(model.id)
|
|
239
|
+
// Synthetic ultra rows ride their base model's account availability.
|
|
240
|
+
|| isCursorModelAvailableForAccount(cursorUltraBaseModelId(model.id) ?? model.id, liveIds)
|
|
241
|
+
),
|
|
216
242
|
);
|
|
217
243
|
}
|
|
218
244
|
|
|
245
|
+
/**
|
|
246
|
+
* Models GetUsableModels advertises but whose every Run returns not_found (catalog honesty,
|
|
247
|
+
* devlog 260826_cursor_responses_gap 060). Live probes 2026-08-26: cursor/claude-opus-5 failed
|
|
248
|
+
* 100% ("Cursor Connect error not_found") while its -fast and -thinking siblings — separate
|
|
249
|
+
* wire families — succeed. Quarantined here, in the shared filter, so live, cached, stale, and
|
|
250
|
+
* static serving paths all agree. Custom user provider overrides are not routed through this
|
|
251
|
+
* canonical seed and stay untouched.
|
|
252
|
+
*/
|
|
253
|
+
export const CURSOR_KNOWN_UNCALLABLE_MODEL_IDS: ReadonlySet<string> = new Set([
|
|
254
|
+
"claude-opus-5",
|
|
255
|
+
]);
|
|
256
|
+
|
|
219
257
|
export const CURSOR_STATIC_MODELS: readonly CursorModelInfo[] = normalizeCursorModels([
|
|
220
258
|
// Context windows and the model lineup mirror Cursor's public models/pricing docs plus the jawcode
|
|
221
259
|
// SOT (../jawcode/packages/ai/src/models.json, `cursor` provider), which mirrors the real
|
|
@@ -243,7 +281,8 @@ export const CURSOR_STATIC_MODELS: readonly CursorModelInfo[] = normalizeCursorM
|
|
|
243
281
|
{ id: "claude-opus-4-7-fast", contextWindow: CONTEXT_200K, supportsReasoningEffort: true },
|
|
244
282
|
{ id: "claude-opus-4-8-fast", contextWindow: CONTEXT_200K, supportsReasoningEffort: true },
|
|
245
283
|
{ id: "claude-opus-4-8", contextWindow: CONTEXT_200K, supportsReasoningEffort: true },
|
|
246
|
-
|
|
284
|
+
// claude-opus-5 (bare) removed from the seed: GetUsableModels lists it but every Run returns
|
|
285
|
+
// not_found (quarantined via CURSOR_KNOWN_UNCALLABLE_MODEL_IDS; -fast/-thinking families stay).
|
|
247
286
|
{ id: "claude-opus-5-fast", contextWindow: CONTEXT_200K, supportsReasoningEffort: true },
|
|
248
287
|
{ id: "claude-fable-5", contextWindow: CONTEXT_200K, supportsReasoningEffort: true },
|
|
249
288
|
|
|
@@ -257,6 +296,21 @@ export const CURSOR_STATIC_MODELS: readonly CursorModelInfo[] = normalizeCursorM
|
|
|
257
296
|
{ id: "gemini-3-pro-image-preview", contextWindow: CONTEXT_200K },
|
|
258
297
|
{ id: "gemini-3.1-pro", contextWindow: CONTEXT_GEMINI },
|
|
259
298
|
{ id: "gemini-3.5-flash", contextWindow: CONTEXT_200K },
|
|
299
|
+
// 260825 live GetUsableModels: both ship only as effort-suffixed ids, so each exposes a tier
|
|
300
|
+
// picker. 3.6 is the only Cursor model with a `minimal` rung.
|
|
301
|
+
{ id: "gemini-3.6-flash", contextWindow: CONTEXT_GEMINI, supportsReasoningEffort: true },
|
|
302
|
+
{ id: "gemini-3.7-flash", contextWindow: CONTEXT_GEMINI, supportsReasoningEffort: true },
|
|
303
|
+
|
|
304
|
+
// Explicit-thinking variants (260825 live roster). Exposed as first-class ids the same way the
|
|
305
|
+
// Opus Fast families were in 831810c13: `isCursorModelAvailableForAccount` matches a base id
|
|
306
|
+
// against `{base}`, `{base}-{effort}` and the family's wire form, and none of those ever
|
|
307
|
+
// matched a `-thinking` id, so every one of these was invisible in the routed catalog.
|
|
308
|
+
// Suffix ORDER differs per family; `cursorWireModelIdWithEffort` owns that mapping.
|
|
309
|
+
...CURSOR_THINKING_MODEL_IDS.map(id => ({
|
|
310
|
+
id,
|
|
311
|
+
contextWindow: CONTEXT_200K,
|
|
312
|
+
supportsReasoningEffort: cursorModelHasEffortTiers(id),
|
|
313
|
+
})),
|
|
260
314
|
|
|
261
315
|
{ id: "gpt-5-codex", contextWindow: CONTEXT_272K },
|
|
262
316
|
{ id: "gpt-5-fast", contextWindow: CONTEXT_272K },
|
|
@@ -291,6 +345,10 @@ export const CURSOR_STATIC_MODELS: readonly CursorModelInfo[] = normalizeCursorM
|
|
|
291
345
|
// kimi-k3: cursor.com/docs/models/kimi-k3; account-verified via GetUsableModels (2026-07-28) —
|
|
292
346
|
// ships only as effort-suffixed kimi-k3-{low,high,max}, so the tier picker is exposed.
|
|
293
347
|
{ id: "kimi-k3", contextWindow: CONTEXT_262K, supportsReasoningEffort: true },
|
|
348
|
+
// kimi-k3-1m: synthetic ultra/Max-Mode picker variant (CURSOR_ULTRA_1M_MODEL_IDS) — wire sends
|
|
349
|
+
// kimi-k3-<effort> with maxMode=true; 1M context user-verified live on the Ultra plan
|
|
350
|
+
// (devlog 260826_cursor_responses_gap/025). inferCursorContextWindow maps "1m" ids to 1M.
|
|
351
|
+
{ id: "kimi-k3-1m", contextWindow: CONTEXT_1M, supportsReasoningEffort: true },
|
|
294
352
|
|
|
295
353
|
{ id: "grok-4.5", contextWindow: 500_000, supportsReasoningEffort: true },
|
|
296
354
|
{ id: "grok-4.5-fast", contextWindow: 500_000, supportsReasoningEffort: true },
|
|
@@ -34,12 +34,33 @@ const CURSOR_MODEL_EFFORT_TIERS: Record<string, readonly string[]> = {
|
|
|
34
34
|
"claude-opus-5-fast": ["low", "medium", "high"],
|
|
35
35
|
"claude-sonnet-5": ["low", "medium", "high", "xhigh", "max"],
|
|
36
36
|
"glm-5.2": ["high", "max"],
|
|
37
|
+
// 260825 live GetUsableModels. gemini-3.6-flash is the only Cursor model exposing `minimal`;
|
|
38
|
+
// listing it here is also what admits the suffix into CANONICAL_EFFORT_SUFFIXES below.
|
|
39
|
+
"gemini-3.6-flash": ["minimal", "low", "medium", "high"],
|
|
40
|
+
"gemini-3.7-flash": ["low", "medium", "high"],
|
|
41
|
+
// Explicit-thinking variants (260825 live roster). Tiers are the rungs the wire actually
|
|
42
|
+
// lists for each family, which is not always the same set the non-thinking id carries:
|
|
43
|
+
// 4.6-opus thinks only at high/max, 4.5-opus only at high, 4.6-sonnet only at medium.
|
|
44
|
+
"claude-opus-5-thinking": ["low", "medium", "high", "xhigh", "max"],
|
|
45
|
+
"claude-opus-5-thinking-fast": ["low", "medium", "high", "xhigh", "max"],
|
|
46
|
+
"claude-opus-4-8-thinking": ["low", "medium", "high", "xhigh", "max"],
|
|
47
|
+
"claude-opus-4-8-thinking-fast": ["low", "medium", "high", "xhigh", "max"],
|
|
48
|
+
"claude-opus-4-7-thinking": ["low", "medium", "high", "xhigh", "max"],
|
|
49
|
+
"claude-opus-4-7-thinking-fast": ["low", "medium", "high", "xhigh", "max"],
|
|
50
|
+
"claude-sonnet-5-thinking": ["low", "medium", "high", "xhigh", "max"],
|
|
51
|
+
"claude-fable-5-thinking": ["low", "medium", "high", "xhigh", "max"],
|
|
52
|
+
"claude-4.6-opus-thinking": ["high", "max"],
|
|
53
|
+
"claude-4.5-opus-thinking": ["high"],
|
|
54
|
+
"claude-4.6-sonnet-thinking": ["medium"],
|
|
37
55
|
// 260814 preemptive: glm-5.3 seeded ahead of Cursor's lineup update. Unlike 5.2, Z.AI folds
|
|
38
56
|
// 5.3 efforts into low/high/max (docs.z.ai/devpack/latest-model), so `low` is a real tier.
|
|
39
57
|
"glm-5.3": ["low", "high", "max"],
|
|
40
58
|
// GetUsableModels (2026-07-28) lists kimi-k3 only as effort-suffixed kimi-k3-{low,high,max};
|
|
41
59
|
// the bare id returns not_found. Tiers mirror the native Kimi provider's K3 ladder.
|
|
42
60
|
"kimi-k3": ["low", "high", "max"],
|
|
61
|
+
// Synthetic ultra picker variant (devlog 260826 070): same tier ladder as kimi-k3; the -1m
|
|
62
|
+
// marker is stripped before wire-id composition, so these tiers never form a wire suffix.
|
|
63
|
+
"kimi-k3-1m": ["low", "high", "max"],
|
|
43
64
|
// Cursor renamed the Grok 4.5 slugs to cursor-grok-4.5-{low,medium,high} and
|
|
44
65
|
// cursor-grok-4.5-{low,medium,high}-fast. The bare Fast id returns not_found.
|
|
45
66
|
"grok-4.5": ["low", "medium", "high"],
|
|
@@ -71,6 +92,46 @@ export const CANONICAL_EFFORT_SUFFIXES: ReadonlySet<string> = new Set([
|
|
|
71
92
|
|
|
72
93
|
const CANONICAL_CODEX_EFFORT_ORDER = ["low", "medium", "high", "xhigh", "max"] as const;
|
|
73
94
|
|
|
95
|
+
/**
|
|
96
|
+
* Cursor's explicit-thinking variants, exposed as first-class Codex model ids the same way the
|
|
97
|
+
* `-fast` families were.
|
|
98
|
+
*
|
|
99
|
+
* `source` is the id whose wire name the variant is built from; `order` is where Cursor puts the
|
|
100
|
+
* thinking marker relative to the effort rung. All three shapes exist in the live roster
|
|
101
|
+
* (GetUsableModels, 260825), and using the wrong one is rejected with ERROR_BAD_MODEL_NAME:
|
|
102
|
+
*
|
|
103
|
+
* thinking-then-effort claude-opus-5-thinking-high, claude-opus-5-thinking-high-fast
|
|
104
|
+
* effort-then-thinking claude-4.6-opus-high-thinking
|
|
105
|
+
* bare claude-4.5-sonnet-thinking (the model has no effort rung)
|
|
106
|
+
*/
|
|
107
|
+
const CURSOR_THINKING_FAMILIES: Readonly<Record<string, { source: string; order: "thinking-then-effort" | "effort-then-thinking" | "bare" }>> = {
|
|
108
|
+
"claude-opus-5-thinking": { source: "claude-opus-5", order: "thinking-then-effort" },
|
|
109
|
+
"claude-opus-5-thinking-fast": { source: "claude-opus-5-fast", order: "thinking-then-effort" },
|
|
110
|
+
"claude-opus-4-8-thinking": { source: "claude-opus-4-8", order: "thinking-then-effort" },
|
|
111
|
+
"claude-opus-4-8-thinking-fast": { source: "claude-opus-4-8-fast", order: "thinking-then-effort" },
|
|
112
|
+
"claude-opus-4-7-thinking": { source: "claude-opus-4-7", order: "thinking-then-effort" },
|
|
113
|
+
"claude-opus-4-7-thinking-fast": { source: "claude-opus-4-7-fast", order: "thinking-then-effort" },
|
|
114
|
+
"claude-sonnet-5-thinking": { source: "claude-sonnet-5", order: "thinking-then-effort" },
|
|
115
|
+
"claude-fable-5-thinking": { source: "claude-fable-5", order: "thinking-then-effort" },
|
|
116
|
+
"claude-4.6-opus-thinking": { source: "claude-4.6-opus", order: "effort-then-thinking" },
|
|
117
|
+
"claude-4.5-opus-thinking": { source: "claude-4.5-opus", order: "effort-then-thinking" },
|
|
118
|
+
"claude-4.6-sonnet-thinking": { source: "claude-4.6-sonnet", order: "effort-then-thinking" },
|
|
119
|
+
"claude-4.5-sonnet-thinking": { source: "claude-4.5-sonnet", order: "bare" },
|
|
120
|
+
"claude-4-sonnet-thinking": { source: "claude-4-sonnet", order: "bare" },
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
/** Codex-facing ids for Cursor's explicit-thinking variants. */
|
|
124
|
+
export const CURSOR_THINKING_MODEL_IDS = Object.keys(CURSOR_THINKING_FAMILIES);
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Picker order, which is the canonical ladder plus the declared sentinels that rank below `low`.
|
|
128
|
+
*
|
|
129
|
+
* `cursorModelEffortLadder` filters against this, so a tier absent from it is silently dropped
|
|
130
|
+
* from the Codex picker even though `cursorEffortSuffix` would happily send it. That is what
|
|
131
|
+
* hid `gemini-3.6-flash-minimal`, the one Cursor model with a `minimal` rung.
|
|
132
|
+
*/
|
|
133
|
+
const CURSOR_PICKER_EFFORT_ORDER = ["minimal", ...CANONICAL_CODEX_EFFORT_ORDER] as const;
|
|
134
|
+
|
|
74
135
|
function normalizeRequestedEffort(reasoning: string | undefined): string | undefined {
|
|
75
136
|
const normalized = reasoning?.toLowerCase();
|
|
76
137
|
return normalized === "ultra" ? "max" : normalized;
|
|
@@ -119,7 +180,7 @@ export function cursorModelEffortLadder(baseModelId: string): string[] | undefin
|
|
|
119
180
|
const tiers = CURSOR_MODEL_EFFORT_TIERS[baseModelId];
|
|
120
181
|
if (!tiers || tiers.length === 0) return undefined;
|
|
121
182
|
const tierSet = new Set(tiers);
|
|
122
|
-
return
|
|
183
|
+
return CURSOR_PICKER_EFFORT_ORDER.filter(effort => tierSet.has(effort));
|
|
123
184
|
}
|
|
124
185
|
|
|
125
186
|
/** Base models known to carry a reasoning-effort suffix (everything else is sent bare). */
|
|
@@ -133,6 +194,23 @@ export function cursorModelHasEffortTiers(baseModelId: string): boolean {
|
|
|
133
194
|
* and send the base model plus requested_model parameters instead.
|
|
134
195
|
*/
|
|
135
196
|
export function cursorWireModelIdWithEffort(baseModelId: string, effortSuffix: string): string {
|
|
197
|
+
const thinking = CURSOR_THINKING_FAMILIES[baseModelId];
|
|
198
|
+
if (thinking) {
|
|
199
|
+
const { source, order } = thinking;
|
|
200
|
+
// Cursor writes the thinking marker on either side of the effort depending on family
|
|
201
|
+
// (measured against GetUsableModels, 260825):
|
|
202
|
+
// thinking-then-effort claude-opus-5-thinking-high, ...-thinking-high-fast
|
|
203
|
+
// effort-then-thinking claude-4.6-opus-high-thinking
|
|
204
|
+
// bare claude-4.5-sonnet-thinking (no effort rung at all)
|
|
205
|
+
// Sending the wrong order returns ERROR_BAD_MODEL_NAME, so this is not cosmetic.
|
|
206
|
+
if (order === "bare") return `${source}-thinking`;
|
|
207
|
+
if (order === "effort-then-thinking") return `${source}-${effortSuffix}-thinking`;
|
|
208
|
+
if (source.endsWith("-fast")) {
|
|
209
|
+
const stem = source.slice(0, -"-fast".length);
|
|
210
|
+
return `${stem}-thinking-${effortSuffix}-fast`;
|
|
211
|
+
}
|
|
212
|
+
return `${source}-thinking-${effortSuffix}`;
|
|
213
|
+
}
|
|
136
214
|
if (baseModelId.endsWith("-fast")) {
|
|
137
215
|
return `${baseModelId.slice(0, -"-fast".length)}-${effortSuffix}-fast`;
|
|
138
216
|
}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External Cursor output quarantine (devlog 260826 gaps 10-11).
|
|
3
|
+
*
|
|
4
|
+
* Gap 10: flattened tool-result history can prime an external model to echo the
|
|
5
|
+
* "[Tool Result]" envelope as its own reply.
|
|
6
|
+
*
|
|
7
|
+
* Gap 11: a model can invent a blocked native-tool attempt in visible commentary
|
|
8
|
+
* even though the only real current-turn tool is the advertised Codex bridge.
|
|
9
|
+
*
|
|
10
|
+
* Both failures are observable only at the output boundary. The sniffers below
|
|
11
|
+
* hold a bounded prefix until it either diverges or proves the failure, allowing
|
|
12
|
+
* cursor.ts to retry before any invalid text reaches the client.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
const ECHO_MARKERS = ["[Tool Result]", "[Tool Error]", "[tool_result]"] as const;
|
|
16
|
+
const MAX_SNIFF_BYTES = 40;
|
|
17
|
+
const MAX_ROUTING_COMMENTARY_BYTES = 512;
|
|
18
|
+
/** Aggregate quarantine cap: past this, flush and disarm. */
|
|
19
|
+
const MAX_HOLD_BYTES = 8 * 1024;
|
|
20
|
+
const encoder = new TextEncoder();
|
|
21
|
+
|
|
22
|
+
export class CursorToolResultEchoError extends Error {
|
|
23
|
+
readonly code = "cursor_tool_result_echo";
|
|
24
|
+
constructor(marker: string) {
|
|
25
|
+
super(
|
|
26
|
+
"Cursor external model echoed the replayed tool-result envelope (\"" + marker
|
|
27
|
+
+ "\") instead of continuing the task.",
|
|
28
|
+
);
|
|
29
|
+
this.name = "CursorToolResultEchoError";
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export class CursorRoutingCommentaryError extends Error {
|
|
34
|
+
readonly code = "cursor_routing_commentary_hallucination";
|
|
35
|
+
constructor() {
|
|
36
|
+
super("Cursor external model invented a blocked tool surface before any tool call occurred.");
|
|
37
|
+
this.name = "CursorRoutingCommentaryError";
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export type EchoSnifferDecision =
|
|
42
|
+
| { kind: "hold" }
|
|
43
|
+
| { kind: "flush" }
|
|
44
|
+
| { kind: "echo"; marker: string };
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Incremental envelope-prefix sniffer. Leading whitespace is tolerated so a
|
|
48
|
+
* marker copied after a newline is still caught.
|
|
49
|
+
*/
|
|
50
|
+
export class CursorEnvelopeEchoSniffer {
|
|
51
|
+
private buffered = "";
|
|
52
|
+
private byteCount = 0;
|
|
53
|
+
private done = false;
|
|
54
|
+
|
|
55
|
+
get settled(): boolean {
|
|
56
|
+
return this.done;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
feed(textDelta: string): EchoSnifferDecision {
|
|
60
|
+
if (this.done) return { kind: "flush" };
|
|
61
|
+
this.buffered += textDelta;
|
|
62
|
+
this.byteCount += encoder.encode(textDelta).byteLength;
|
|
63
|
+
const probe = this.buffered.replace(/^\s+/, "");
|
|
64
|
+
for (const marker of ECHO_MARKERS) {
|
|
65
|
+
if (probe.startsWith(marker)) {
|
|
66
|
+
this.done = true;
|
|
67
|
+
return { kind: "echo", marker };
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
const stillPrefix = ECHO_MARKERS.some(marker =>
|
|
71
|
+
probe.length < marker.length && marker.startsWith(probe),
|
|
72
|
+
);
|
|
73
|
+
if (stillPrefix && this.byteCount <= MAX_SNIFF_BYTES && this.buffered.length < MAX_HOLD_BYTES) {
|
|
74
|
+
return { kind: "hold" };
|
|
75
|
+
}
|
|
76
|
+
this.done = true;
|
|
77
|
+
return { kind: "flush" };
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
finish(): EchoSnifferDecision {
|
|
81
|
+
if (this.done) return { kind: "flush" };
|
|
82
|
+
this.done = true;
|
|
83
|
+
return { kind: "flush" };
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export type RoutingCommentaryDecision =
|
|
88
|
+
| { kind: "hold" }
|
|
89
|
+
| { kind: "flush" }
|
|
90
|
+
| { kind: "hallucination" };
|
|
91
|
+
|
|
92
|
+
const ROUTING_NATIVE_TOOL_NAME = /\b(shell|read|grep|list|bash)\b/giu;
|
|
93
|
+
const ROUTING_TOOL_HINT =
|
|
94
|
+
/(?:\b(?:shell|read|grep|list|bash)\b|exec_command|shell_command|브리지|네이티브\s*(?:셸|쉘))/iu;
|
|
95
|
+
const ROUTING_FAILURE_CLAIM =
|
|
96
|
+
/(?:blocked|unavailable|interrupted|차단|중단|막혀)/iu;
|
|
97
|
+
const ROUTING_REDIRECT_CLAIM =
|
|
98
|
+
/(?:exec_command|shell_command|\bexec\b|브리지|redirected|fallback|switch(?:ed|ing)?|전환|우회|통과(?:되|하)|다른\s*(?:도구|경로)|경로로)/iu;
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Quarantines the first line of code-mode / bridge output long enough to reject
|
|
102
|
+
* an impossible routing claim. It requires a failure claim plus either an
|
|
103
|
+
* explicit redirect to another execution surface or two distinct unadvertised
|
|
104
|
+
* native-tool names; a legitimate sentence such as "Shell is unavailable on
|
|
105
|
+
* this OS" therefore passes.
|
|
106
|
+
*/
|
|
107
|
+
export class CursorRoutingCommentarySniffer {
|
|
108
|
+
private buffered = "";
|
|
109
|
+
private byteCount = 0;
|
|
110
|
+
private done = false;
|
|
111
|
+
|
|
112
|
+
get settled(): boolean {
|
|
113
|
+
return this.done;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
feed(textDelta: string): RoutingCommentaryDecision {
|
|
117
|
+
if (this.done) return { kind: "flush" };
|
|
118
|
+
this.buffered += textDelta;
|
|
119
|
+
this.byteCount += encoder.encode(textDelta).byteLength;
|
|
120
|
+
if (this.matchesHallucination()) {
|
|
121
|
+
this.done = true;
|
|
122
|
+
return { kind: "hallucination" };
|
|
123
|
+
}
|
|
124
|
+
const lineBreakCount = (this.buffered.match(/\n/gu) ?? []).length;
|
|
125
|
+
const hasRoutingHint = ROUTING_TOOL_HINT.test(this.buffered) || ROUTING_FAILURE_CLAIM.test(this.buffered);
|
|
126
|
+
const pendingFailureClaim =
|
|
127
|
+
ROUTING_TOOL_HINT.test(this.buffered)
|
|
128
|
+
&& ROUTING_FAILURE_CLAIM.test(this.buffered)
|
|
129
|
+
&& lineBreakCount < 2;
|
|
130
|
+
if (
|
|
131
|
+
this.byteCount < MAX_ROUTING_COMMENTARY_BYTES
|
|
132
|
+
&& this.buffered.length < MAX_HOLD_BYTES
|
|
133
|
+
&& (lineBreakCount === 0 || pendingFailureClaim)
|
|
134
|
+
&& (hasRoutingHint || this.byteCount < 64)
|
|
135
|
+
) {
|
|
136
|
+
return { kind: "hold" };
|
|
137
|
+
}
|
|
138
|
+
this.done = true;
|
|
139
|
+
return { kind: "flush" };
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
finish(): RoutingCommentaryDecision {
|
|
143
|
+
if (this.done) return { kind: "flush" };
|
|
144
|
+
this.done = true;
|
|
145
|
+
return this.matchesHallucination() ? { kind: "hallucination" } : { kind: "flush" };
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
private matchesHallucination(): boolean {
|
|
149
|
+
if (!ROUTING_FAILURE_CLAIM.test(this.buffered)) return false;
|
|
150
|
+
const nativeTools = new Set(
|
|
151
|
+
[...this.buffered.matchAll(ROUTING_NATIVE_TOOL_NAME)].map(match => match[1]?.toLowerCase()),
|
|
152
|
+
);
|
|
153
|
+
if (nativeTools.size === 0) return false;
|
|
154
|
+
return ROUTING_REDIRECT_CLAIM.test(this.buffered) || nativeTools.size >= 2;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export const CURSOR_ECHO_RETRY_CONTINUATION_TEXT =
|
|
159
|
+
"Your previous reply copied an internal tool-output record verbatim and was rejected. Continue the original task now: issue the next required tool call, or answer in your own words if no tool is needed.";
|
|
160
|
+
|
|
161
|
+
export const CURSOR_ROUTING_COMMENTARY_RETRY_TEXT =
|
|
162
|
+
"Your previous reply claimed an execution-surface failure that did not occur and was rejected. Use the current tool catalog as ground truth. Perform the requested operation through the advertised execution tool now, with no commentary before the tool call.";
|
|
@@ -43,7 +43,7 @@ export interface CursorUsableModelsOptions {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
export type CursorUsableModelsResult =
|
|
46
|
-
| { ok: true; models: string[] }
|
|
46
|
+
| { ok: true; models: string[]; maxModeModels?: string[] }
|
|
47
47
|
| { ok: false; error: "auth" | "http" | "policy" | "transport" | "timeout" | "decode" | "empty" | "too_large"; detail?: string };
|
|
48
48
|
|
|
49
49
|
/** Test-only seam for management connectivity probes; production callers retain the HTTP/2 path. */
|
|
@@ -120,6 +120,7 @@ function decodeCursorUsableModels(bytes: Uint8Array): CursorUsableModelsResult {
|
|
|
120
120
|
// make stale configured ids such as `composer-2` look activated.
|
|
121
121
|
const ids: string[] = [];
|
|
122
122
|
const seenIds = new Set<string>();
|
|
123
|
+
const maxModeIds: string[] = [];
|
|
123
124
|
for (const model of response.models ?? []) {
|
|
124
125
|
const rawId = (model as { modelId?: string }).modelId;
|
|
125
126
|
if (typeof rawId !== "string") continue;
|
|
@@ -127,9 +128,13 @@ function decodeCursorUsableModels(bytes: Uint8Array): CursorUsableModelsResult {
|
|
|
127
128
|
if (!isValidModelDiscoveryModelId(id) || seenIds.has(id)) continue;
|
|
128
129
|
seenIds.add(id);
|
|
129
130
|
ids.push(id);
|
|
131
|
+
// Preserve Max-Mode capability for ultra/big-context auto-detection (devlog 260826 070).
|
|
132
|
+
if ((model as { maxMode?: boolean }).maxMode === true) maxModeIds.push(id);
|
|
130
133
|
if (ids.length >= CURSOR_MAX_DISCOVERED_MODELS) break;
|
|
131
134
|
}
|
|
132
|
-
return ids.length > 0
|
|
135
|
+
return ids.length > 0
|
|
136
|
+
? { ok: true, models: ids, ...(maxModeIds.length > 0 ? { maxModeModels: maxModeIds } : {}) }
|
|
137
|
+
: { ok: false, error: "empty" };
|
|
133
138
|
} catch {
|
|
134
139
|
return { ok: false, error: "decode", detail: "Invalid GetUsableModels protobuf response" };
|
|
135
140
|
}
|
|
@@ -415,6 +415,20 @@ export function finalizeAfterDrain(state: ReturnType<typeof createCursorProtobuf
|
|
|
415
415
|
export function clientToolFinalizeGraceMsForRequest(request: CursorRunRequest, baseGraceMs = CLIENT_TOOL_FINALIZE_GRACE_MS): number {
|
|
416
416
|
if (request.rawMessages?.at(-1)?.role === "toolResult") return baseGraceMs;
|
|
417
417
|
const text = activePromptText(request);
|
|
418
|
+
// Parallel-tool requests with several advertised tools get the expanded window regardless of
|
|
419
|
+
// prompt shape: external models (grok) assemble sibling calls serially over multiple frames,
|
|
420
|
+
// and the 50ms drain grace ended the turn after 1-2 of them (devlog 260826_cursor_responses_gap,
|
|
421
|
+
// live 10-parallel probe: calls=2 then calls=1).
|
|
422
|
+
if (request.parallelToolCalls === true && (request.tools?.length ?? 0) > 1) {
|
|
423
|
+
const advertised = request.tools?.length ?? 0;
|
|
424
|
+
return Math.max(
|
|
425
|
+
baseGraceMs,
|
|
426
|
+
Math.min(
|
|
427
|
+
GENERIC_TOOL_COUNT_MAX_FINALIZE_GRACE_MS,
|
|
428
|
+
Math.max(GENERIC_TOOL_COUNT_MIN_FINALIZE_GRACE_MS, advertised * GENERIC_TOOL_COUNT_PER_TOOL_GRACE_MS),
|
|
429
|
+
),
|
|
430
|
+
);
|
|
431
|
+
}
|
|
418
432
|
if (!cursorRequestHasShellAlias(request.tools) || !isGenericToolUseCountDemoPrompt(text)) return baseGraceMs;
|
|
419
433
|
const requestedCount = requestedCursorToolUseCount(text);
|
|
420
434
|
const expandedGraceMs = requestedCount
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { AdapterEvent } from "../../types";
|
|
2
|
+
import { encodeCursorCallId } from "./call-id";
|
|
2
3
|
import { cursorExecResult } from "./exec-policy";
|
|
3
4
|
import type { CursorClientMessage, CursorServerMessage } from "./types";
|
|
4
5
|
import type { CursorKvStore } from "./kv-store";
|
|
@@ -18,7 +19,9 @@ export function mapCursorServerMessage(
|
|
|
18
19
|
case "thinking":
|
|
19
20
|
return [{ type: "thinking_delta", thinking: message.thinking }];
|
|
20
21
|
case "tool_call_start":
|
|
21
|
-
|
|
22
|
+
// Cursor composite ids can contain a literal newline; Responses call_ids
|
|
23
|
+
// must stay single-line (see call-id.ts).
|
|
24
|
+
return [{ type: "tool_call_start", id: encodeCursorCallId(message.id), name: message.name }];
|
|
22
25
|
case "tool_call_delta":
|
|
23
26
|
return [{ type: "tool_call_delta", arguments: message.arguments }];
|
|
24
27
|
case "tool_call_end":
|
|
@@ -170,10 +170,33 @@ function runExternalJson(command: string, payload: unknown, config: DesktopExecu
|
|
|
170
170
|
}
|
|
171
171
|
});
|
|
172
172
|
|
|
173
|
+
// A command that never reads stdin - `echo`, a script that exits on a bad flag,
|
|
174
|
+
// anything that fails before its first read - closes the pipe while we are still
|
|
175
|
+
// writing to it. The write then fails with EPIPE, and on Linux that surfaces as an
|
|
176
|
+
// ASYNCHRONOUS 'error' event on the stream rather than a throw, so the try/catch
|
|
177
|
+
// below never saw it and the rejection escaped as an unhandled stream error. On
|
|
178
|
+
// macOS the same command usually drains the small payload first, which is why this
|
|
179
|
+
// only ever went red on the Linux shard.
|
|
180
|
+
//
|
|
181
|
+
// EPIPE here is not a failure of the executor CONTRACT: the child's exit code and
|
|
182
|
+
// stdout are what decide the result, and both are handled in 'close' above. So the
|
|
183
|
+
// pipe error is swallowed deliberately and the outcome is left to the child, which
|
|
184
|
+
// is what makes "bad output maps to failure" reachable instead of exploding.
|
|
185
|
+
child.stdin.on("error", (err: NodeJS.ErrnoException) => {
|
|
186
|
+
if (err.code === "EPIPE" || err.code === "ERR_STREAM_DESTROYED") return;
|
|
187
|
+
if (settled) return;
|
|
188
|
+
settled = true;
|
|
189
|
+
clearTimeout(timer);
|
|
190
|
+
reject(err);
|
|
191
|
+
});
|
|
173
192
|
try {
|
|
174
193
|
child.stdin.write(JSON.stringify(payload));
|
|
175
194
|
child.stdin.end();
|
|
176
195
|
} catch (err) {
|
|
196
|
+
// Kept for the synchronous half: a stream already destroyed when we reach this
|
|
197
|
+
// line throws immediately instead of emitting.
|
|
198
|
+
const code = (err as NodeJS.ErrnoException).code;
|
|
199
|
+
if (code === "EPIPE" || code === "ERR_STREAM_DESTROYED") return;
|
|
177
200
|
if (!settled) {
|
|
178
201
|
settled = true;
|
|
179
202
|
clearTimeout(timer);
|