cursor-opencode-provider 0.3.2 → 0.4.1

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.
@@ -1,9 +1,11 @@
1
1
  /**
2
2
  * AUTO-GENERATED by scripts/generate-cursor-pricing.ts — do not edit by hand.
3
- * Source: https://cursor.com/docs/models-and-pricing.md
3
+ * Pricing source: https://cursor.com/docs/models-and-pricing.md
4
+ * Context source: https://cursor.com/docs.md
4
5
  * Regenerate: bun run generate:pricing
5
6
  */
6
7
  export declare const CURSOR_PRICING_SOURCE: "https://cursor.com/docs/models-and-pricing.md";
8
+ export declare const CURSOR_CONTEXT_SOURCE: "https://cursor.com/docs.md";
7
9
  export declare const CURSOR_MODEL_COSTS: {
8
10
  readonly "claude-fable-5": {
9
11
  readonly input: 10;
@@ -192,3 +194,221 @@ export declare const CURSOR_MODEL_COSTS: {
192
194
  readonly cache_read: 0.3;
193
195
  };
194
196
  };
197
+ export declare const CURSOR_MODEL_CONTEXTS: {
198
+ readonly "claude-fable-5": {
199
+ readonly maxContext: 300000;
200
+ readonly maxContextForMaxMode: 1000000;
201
+ };
202
+ readonly "claude-haiku-4-5": {
203
+ readonly maxContext: 200000;
204
+ };
205
+ readonly "claude-opus-4-5": {
206
+ readonly maxContext: 200000;
207
+ readonly maxContextForMaxMode: 200000;
208
+ };
209
+ readonly "claude-opus-4-6": {
210
+ readonly maxContext: 200000;
211
+ readonly maxContextForMaxMode: 1000000;
212
+ };
213
+ readonly "claude-opus-4-7": {
214
+ readonly maxContext: 300000;
215
+ readonly maxContextForMaxMode: 1000000;
216
+ };
217
+ readonly "claude-opus-4-8": {
218
+ readonly maxContext: 300000;
219
+ readonly maxContextForMaxMode: 1000000;
220
+ };
221
+ readonly "claude-opus-5": {
222
+ readonly maxContext: 300000;
223
+ readonly maxContextForMaxMode: 1000000;
224
+ };
225
+ readonly "claude-sonnet-4": {
226
+ readonly maxContext: 200000;
227
+ readonly maxContextForMaxMode: 1000000;
228
+ };
229
+ readonly "claude-sonnet-4-5": {
230
+ readonly maxContext: 200000;
231
+ readonly maxContextForMaxMode: 1000000;
232
+ };
233
+ readonly "claude-sonnet-4-6": {
234
+ readonly maxContext: 200000;
235
+ readonly maxContextForMaxMode: 1000000;
236
+ };
237
+ readonly "claude-sonnet-5": {
238
+ readonly maxContext: 200000;
239
+ readonly maxContextForMaxMode: 1000000;
240
+ };
241
+ readonly "composer-2.5": {
242
+ readonly maxContext: 200000;
243
+ };
244
+ readonly "gemini-2.5-flash": {
245
+ readonly maxContext: 200000;
246
+ readonly maxContextForMaxMode: 1000000;
247
+ };
248
+ readonly "gemini-3-flash": {
249
+ readonly maxContext: 200000;
250
+ readonly maxContextForMaxMode: 1000000;
251
+ };
252
+ readonly "gemini-3.1-pro": {
253
+ readonly maxContext: 200000;
254
+ readonly maxContextForMaxMode: 1000000;
255
+ };
256
+ readonly "gemini-3.5-flash": {
257
+ readonly maxContext: 200000;
258
+ readonly maxContextForMaxMode: 1000000;
259
+ };
260
+ readonly "gemini-3.6-flash": {
261
+ readonly maxContext: 200000;
262
+ readonly maxContextForMaxMode: 1000000;
263
+ };
264
+ readonly "glm-5.2": {
265
+ readonly maxContext: 200000;
266
+ };
267
+ readonly "gpt-5-mini": {
268
+ readonly maxContext: 272000;
269
+ };
270
+ readonly "gpt-5.1": {
271
+ readonly maxContext: 272000;
272
+ };
273
+ readonly "gpt-5.2": {
274
+ readonly maxContext: 272000;
275
+ };
276
+ readonly "gpt-5.3-codex": {
277
+ readonly maxContext: 272000;
278
+ };
279
+ readonly "gpt-5.4": {
280
+ readonly maxContext: 272000;
281
+ readonly maxContextForMaxMode: 1000000;
282
+ };
283
+ readonly "gpt-5.4-mini": {
284
+ readonly maxContext: 272000;
285
+ };
286
+ readonly "gpt-5.4-nano": {
287
+ readonly maxContext: 272000;
288
+ };
289
+ readonly "gpt-5.5": {
290
+ readonly maxContext: 272000;
291
+ readonly maxContextForMaxMode: 1000000;
292
+ };
293
+ readonly "gpt-5.6-luna": {
294
+ readonly maxContext: 272000;
295
+ };
296
+ readonly "gpt-5.6-sol": {
297
+ readonly maxContext: 272000;
298
+ readonly maxContextForMaxMode: 1000000;
299
+ };
300
+ readonly "gpt-5.6-terra": {
301
+ readonly maxContext: 272000;
302
+ };
303
+ readonly "grok-4.5": {
304
+ readonly maxContext: 256000;
305
+ };
306
+ readonly "kimi-k2.7-code": {
307
+ readonly maxContext: 262000;
308
+ };
309
+ readonly "kimi-k3": {
310
+ readonly maxContext: 200000;
311
+ readonly maxContextForMaxMode: 1000000;
312
+ };
313
+ };
314
+ export declare const CURSOR_MODEL_CAPABILITIES: {
315
+ readonly "claude-fable-5": {
316
+ readonly supportsImages: true;
317
+ };
318
+ readonly "claude-haiku-4-5": {
319
+ readonly supportsImages: true;
320
+ };
321
+ readonly "claude-opus-4-5": {
322
+ readonly supportsImages: true;
323
+ };
324
+ readonly "claude-opus-4-6": {
325
+ readonly supportsImages: true;
326
+ };
327
+ readonly "claude-opus-4-7": {
328
+ readonly supportsImages: true;
329
+ };
330
+ readonly "claude-opus-4-8": {
331
+ readonly supportsImages: true;
332
+ };
333
+ readonly "claude-opus-5": {
334
+ readonly supportsImages: true;
335
+ };
336
+ readonly "claude-sonnet-4": {
337
+ readonly supportsImages: true;
338
+ };
339
+ readonly "claude-sonnet-4-5": {
340
+ readonly supportsImages: true;
341
+ };
342
+ readonly "claude-sonnet-4-6": {
343
+ readonly supportsImages: true;
344
+ };
345
+ readonly "claude-sonnet-5": {
346
+ readonly supportsImages: true;
347
+ };
348
+ readonly "composer-2.5": {
349
+ readonly supportsImages: true;
350
+ };
351
+ readonly default: {
352
+ readonly supportsImages: false;
353
+ };
354
+ readonly "gemini-2.5-flash": {
355
+ readonly supportsImages: true;
356
+ };
357
+ readonly "gemini-3-flash": {
358
+ readonly supportsImages: true;
359
+ };
360
+ readonly "gemini-3.1-pro": {
361
+ readonly supportsImages: true;
362
+ };
363
+ readonly "gemini-3.5-flash": {
364
+ readonly supportsImages: true;
365
+ };
366
+ readonly "gemini-3.6-flash": {
367
+ readonly supportsImages: true;
368
+ };
369
+ readonly "glm-5.2": {
370
+ readonly supportsImages: false;
371
+ };
372
+ readonly "gpt-5-mini": {
373
+ readonly supportsImages: true;
374
+ };
375
+ readonly "gpt-5.1": {
376
+ readonly supportsImages: true;
377
+ };
378
+ readonly "gpt-5.2": {
379
+ readonly supportsImages: true;
380
+ };
381
+ readonly "gpt-5.3-codex": {
382
+ readonly supportsImages: true;
383
+ };
384
+ readonly "gpt-5.4": {
385
+ readonly supportsImages: true;
386
+ };
387
+ readonly "gpt-5.4-mini": {
388
+ readonly supportsImages: true;
389
+ };
390
+ readonly "gpt-5.4-nano": {
391
+ readonly supportsImages: true;
392
+ };
393
+ readonly "gpt-5.5": {
394
+ readonly supportsImages: true;
395
+ };
396
+ readonly "gpt-5.6-luna": {
397
+ readonly supportsImages: true;
398
+ };
399
+ readonly "gpt-5.6-sol": {
400
+ readonly supportsImages: true;
401
+ };
402
+ readonly "gpt-5.6-terra": {
403
+ readonly supportsImages: true;
404
+ };
405
+ readonly "grok-4.5": {
406
+ readonly supportsImages: false;
407
+ };
408
+ readonly "kimi-k2.7-code": {
409
+ readonly supportsImages: true;
410
+ };
411
+ readonly "kimi-k3": {
412
+ readonly supportsImages: true;
413
+ };
414
+ };
@@ -1,9 +1,11 @@
1
1
  /**
2
2
  * AUTO-GENERATED by scripts/generate-cursor-pricing.ts — do not edit by hand.
3
- * Source: https://cursor.com/docs/models-and-pricing.md
3
+ * Pricing source: https://cursor.com/docs/models-and-pricing.md
4
+ * Context source: https://cursor.com/docs.md
4
5
  * Regenerate: bun run generate:pricing
5
6
  */
6
7
  export const CURSOR_PRICING_SOURCE = "https://cursor.com/docs/models-and-pricing.md";
8
+ export const CURSOR_CONTEXT_SOURCE = "https://cursor.com/docs.md";
7
9
  export const CURSOR_MODEL_COSTS = {
8
10
  "claude-fable-5": {
9
11
  "input": 10,
@@ -192,3 +194,221 @@ export const CURSOR_MODEL_COSTS = {
192
194
  "cache_read": 0.3
193
195
  }
194
196
  };
197
+ export const CURSOR_MODEL_CONTEXTS = {
198
+ "claude-fable-5": {
199
+ "maxContext": 300000,
200
+ "maxContextForMaxMode": 1000000
201
+ },
202
+ "claude-haiku-4-5": {
203
+ "maxContext": 200000
204
+ },
205
+ "claude-opus-4-5": {
206
+ "maxContext": 200000,
207
+ "maxContextForMaxMode": 200000
208
+ },
209
+ "claude-opus-4-6": {
210
+ "maxContext": 200000,
211
+ "maxContextForMaxMode": 1000000
212
+ },
213
+ "claude-opus-4-7": {
214
+ "maxContext": 300000,
215
+ "maxContextForMaxMode": 1000000
216
+ },
217
+ "claude-opus-4-8": {
218
+ "maxContext": 300000,
219
+ "maxContextForMaxMode": 1000000
220
+ },
221
+ "claude-opus-5": {
222
+ "maxContext": 300000,
223
+ "maxContextForMaxMode": 1000000
224
+ },
225
+ "claude-sonnet-4": {
226
+ "maxContext": 200000,
227
+ "maxContextForMaxMode": 1000000
228
+ },
229
+ "claude-sonnet-4-5": {
230
+ "maxContext": 200000,
231
+ "maxContextForMaxMode": 1000000
232
+ },
233
+ "claude-sonnet-4-6": {
234
+ "maxContext": 200000,
235
+ "maxContextForMaxMode": 1000000
236
+ },
237
+ "claude-sonnet-5": {
238
+ "maxContext": 200000,
239
+ "maxContextForMaxMode": 1000000
240
+ },
241
+ "composer-2.5": {
242
+ "maxContext": 200000
243
+ },
244
+ "gemini-2.5-flash": {
245
+ "maxContext": 200000,
246
+ "maxContextForMaxMode": 1000000
247
+ },
248
+ "gemini-3-flash": {
249
+ "maxContext": 200000,
250
+ "maxContextForMaxMode": 1000000
251
+ },
252
+ "gemini-3.1-pro": {
253
+ "maxContext": 200000,
254
+ "maxContextForMaxMode": 1000000
255
+ },
256
+ "gemini-3.5-flash": {
257
+ "maxContext": 200000,
258
+ "maxContextForMaxMode": 1000000
259
+ },
260
+ "gemini-3.6-flash": {
261
+ "maxContext": 200000,
262
+ "maxContextForMaxMode": 1000000
263
+ },
264
+ "glm-5.2": {
265
+ "maxContext": 200000
266
+ },
267
+ "gpt-5-mini": {
268
+ "maxContext": 272000
269
+ },
270
+ "gpt-5.1": {
271
+ "maxContext": 272000
272
+ },
273
+ "gpt-5.2": {
274
+ "maxContext": 272000
275
+ },
276
+ "gpt-5.3-codex": {
277
+ "maxContext": 272000
278
+ },
279
+ "gpt-5.4": {
280
+ "maxContext": 272000,
281
+ "maxContextForMaxMode": 1000000
282
+ },
283
+ "gpt-5.4-mini": {
284
+ "maxContext": 272000
285
+ },
286
+ "gpt-5.4-nano": {
287
+ "maxContext": 272000
288
+ },
289
+ "gpt-5.5": {
290
+ "maxContext": 272000,
291
+ "maxContextForMaxMode": 1000000
292
+ },
293
+ "gpt-5.6-luna": {
294
+ "maxContext": 272000
295
+ },
296
+ "gpt-5.6-sol": {
297
+ "maxContext": 272000,
298
+ "maxContextForMaxMode": 1000000
299
+ },
300
+ "gpt-5.6-terra": {
301
+ "maxContext": 272000
302
+ },
303
+ "grok-4.5": {
304
+ "maxContext": 256000
305
+ },
306
+ "kimi-k2.7-code": {
307
+ "maxContext": 262000
308
+ },
309
+ "kimi-k3": {
310
+ "maxContext": 200000,
311
+ "maxContextForMaxMode": 1000000
312
+ }
313
+ };
314
+ export const CURSOR_MODEL_CAPABILITIES = {
315
+ "claude-fable-5": {
316
+ "supportsImages": true
317
+ },
318
+ "claude-haiku-4-5": {
319
+ "supportsImages": true
320
+ },
321
+ "claude-opus-4-5": {
322
+ "supportsImages": true
323
+ },
324
+ "claude-opus-4-6": {
325
+ "supportsImages": true
326
+ },
327
+ "claude-opus-4-7": {
328
+ "supportsImages": true
329
+ },
330
+ "claude-opus-4-8": {
331
+ "supportsImages": true
332
+ },
333
+ "claude-opus-5": {
334
+ "supportsImages": true
335
+ },
336
+ "claude-sonnet-4": {
337
+ "supportsImages": true
338
+ },
339
+ "claude-sonnet-4-5": {
340
+ "supportsImages": true
341
+ },
342
+ "claude-sonnet-4-6": {
343
+ "supportsImages": true
344
+ },
345
+ "claude-sonnet-5": {
346
+ "supportsImages": true
347
+ },
348
+ "composer-2.5": {
349
+ "supportsImages": true
350
+ },
351
+ "default": {
352
+ "supportsImages": false
353
+ },
354
+ "gemini-2.5-flash": {
355
+ "supportsImages": true
356
+ },
357
+ "gemini-3-flash": {
358
+ "supportsImages": true
359
+ },
360
+ "gemini-3.1-pro": {
361
+ "supportsImages": true
362
+ },
363
+ "gemini-3.5-flash": {
364
+ "supportsImages": true
365
+ },
366
+ "gemini-3.6-flash": {
367
+ "supportsImages": true
368
+ },
369
+ "glm-5.2": {
370
+ "supportsImages": false
371
+ },
372
+ "gpt-5-mini": {
373
+ "supportsImages": true
374
+ },
375
+ "gpt-5.1": {
376
+ "supportsImages": true
377
+ },
378
+ "gpt-5.2": {
379
+ "supportsImages": true
380
+ },
381
+ "gpt-5.3-codex": {
382
+ "supportsImages": true
383
+ },
384
+ "gpt-5.4": {
385
+ "supportsImages": true
386
+ },
387
+ "gpt-5.4-mini": {
388
+ "supportsImages": true
389
+ },
390
+ "gpt-5.4-nano": {
391
+ "supportsImages": true
392
+ },
393
+ "gpt-5.5": {
394
+ "supportsImages": true
395
+ },
396
+ "gpt-5.6-luna": {
397
+ "supportsImages": true
398
+ },
399
+ "gpt-5.6-sol": {
400
+ "supportsImages": true
401
+ },
402
+ "gpt-5.6-terra": {
403
+ "supportsImages": true
404
+ },
405
+ "grok-4.5": {
406
+ "supportsImages": false
407
+ },
408
+ "kimi-k2.7-code": {
409
+ "supportsImages": true
410
+ },
411
+ "kimi-k3": {
412
+ "supportsImages": true
413
+ }
414
+ };
@@ -917,9 +917,30 @@ export function createMessageTypes() {
917
917
  { id: 2, name: "max_mode", type: "bool" },
918
918
  { id: 3, name: "parameters", type: "ParameterValue", repeated: true },
919
919
  ]);
920
+ addType(root, "SelectedImageDimension", [
921
+ { id: 1, name: "width", type: "int32" },
922
+ { id: 2, name: "height", type: "int32" },
923
+ ]);
924
+ addType(root, "SelectedImageBlobIdWithData", [
925
+ { id: 1, name: "blob_id", type: "bytes" },
926
+ { id: 2, name: "data", type: "bytes" },
927
+ ]);
928
+ addType(root, "SelectedImage", [
929
+ { id: 1, name: "blob_id", type: "bytes" },
930
+ { id: 8, name: "data", type: "bytes" },
931
+ { id: 9, name: "blob_id_with_data", type: "SelectedImageBlobIdWithData" },
932
+ { id: 2, name: "uuid", type: "string" },
933
+ { id: 3, name: "path", type: "string" },
934
+ { id: 4, name: "dimension", type: "SelectedImageDimension" },
935
+ { id: 7, name: "mime_type", type: "string" },
936
+ ], [{ name: "data_or_blob_id", fields: ["blob_id", "data", "blob_id_with_data"] }]);
937
+ addType(root, "SelectedContext", [
938
+ { id: 1, name: "selected_images", type: "SelectedImage", repeated: true },
939
+ ]);
920
940
  addType(root, "UserMessage", [
921
941
  { id: 1, name: "text", type: "string" },
922
942
  { id: 2, name: "message_id", type: "string" },
943
+ { id: 3, name: "selected_context", type: "SelectedContext" },
923
944
  ]);
924
945
  // RequestContext — UserMessageAction #2. Live per-turn tools go here
925
946
  // (AgentRunRequest.mcp_tools #4 is prewarm-only / empty on real turns).
@@ -1,10 +1,12 @@
1
1
  import { type OpencodeToolDef } from "./tools.js";
2
+ import type { CursorImageInput } from "../image-input.js";
2
3
  export type SeedHistoryMessage = {
3
4
  role: "system" | "user" | "assistant";
4
5
  content: string;
5
6
  };
6
7
  export type RunRequestInput = {
7
8
  text: string;
9
+ images?: CursorImageInput[];
8
10
  modelId: string;
9
11
  conversationId: string;
10
12
  systemPrompt?: string;
@@ -48,12 +48,21 @@ export function buildRunRequest(input) {
48
48
  const tools = input.tools ?? [];
49
49
  const mcpTools = input.toolDescriptors ?? (tools.length > 0 ? toolsToDescriptors(tools) : []);
50
50
  const requestContext = input.requestContext;
51
- const userMessageAction = {
52
- user_message: {
53
- text: input.text,
54
- message_id: msgId,
55
- },
51
+ const userMessage = {
52
+ text: input.text,
53
+ message_id: msgId,
56
54
  };
55
+ if (input.images?.length) {
56
+ userMessage.selected_context = {
57
+ selected_images: input.images.map((image) => ({
58
+ data: image.data,
59
+ uuid: crypto.randomUUID(),
60
+ path: image.filename,
61
+ mime_type: image.mimeType,
62
+ })),
63
+ };
64
+ }
65
+ const userMessageAction = { user_message: userMessage };
57
66
  if (requestContext)
58
67
  userMessageAction.request_context = requestContext;
59
68
  const action = input.action === "resume"
@@ -87,6 +87,14 @@ export declare function resolveCursorSubagentType(subagentType: string, catalog?
87
87
  export declare function mapCursorSubagentTypeToOpenCode(subagentType: string): string;
88
88
  /** Resolve a native Cursor subagent request to this turn's executor and catalog. */
89
89
  export declare function remapNativeSubagentForCatalog(parsed: ParsedExecRequest, advertisedToolNames: Iterable<string>, catalog?: HostSubagentCatalog): void;
90
+ /**
91
+ * Preserve a legacy Cursor edit's intent when its internal executor follows
92
+ * `edit_tool_call` with a whole-file `write_args` request.
93
+ *
94
+ * The result field intentionally remains `write_result`: that is the response
95
+ * Cursor is awaiting even though OpenCode executes the mutation via `edit`.
96
+ */
97
+ export declare function remapCorrelatedEditWriteForCatalog(parsed: ParsedExecRequest, advertisedToolNames: Iterable<string>, editPath: string, workspaceRoot?: string): boolean;
90
98
  /**
91
99
  * Express a native Cursor write/edit as `apply_patch` when the host swapped the
92
100
  * edit-tool family out from under us.