@goodandready/dsh-subscriptions 0.5.4 → 0.5.5

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.
@@ -97,6 +97,17 @@ export async function discoverLocalCliSessions() {
97
97
  }
98
98
  }
99
99
 
100
+
101
+ // 6. Cursor Token (env or CLI)
102
+ if (process.env.CURSOR_ACCESS_TOKEN) {
103
+ detected.cursor = {
104
+ provider: 'cursor',
105
+ path: 'CURSOR_ACCESS_TOKEN env',
106
+ email: 'Cursor IDE User',
107
+ hasRefreshToken: false,
108
+ }
109
+ }
110
+
100
111
  return detected
101
112
  }
102
113
 
@@ -159,5 +170,16 @@ export async function loadLocalCliBlob(provider) {
159
170
  }
160
171
  }
161
172
 
173
+
174
+ if (provider === 'cursor') {
175
+ const token = process.env.CURSOR_ACCESS_TOKEN || (raw && (raw.accessToken || raw.access_token)) || ''
176
+ return {
177
+ accessToken: token,
178
+ refreshToken: '',
179
+ expiresAt: Date.now() + 30 * 86400 * 1000,
180
+ email: 'Cursor User',
181
+ }
182
+ }
183
+
162
184
  throw new Error(`unsupported local CLI import for provider ${provider}`)
163
185
  }
package/lib/refs.js CHANGED
@@ -6,6 +6,7 @@ export const BUILTIN_PROVIDERS = Object.freeze([
6
6
  'antigravity',
7
7
  'kimi',
8
8
  'glm',
9
+ 'cursor',
9
10
  ])
10
11
 
11
12
  const dynamicIds = new Set()
@@ -43,6 +44,7 @@ const DISPLAY = {
43
44
  antigravity: 'Antigravity',
44
45
  kimi: 'Moonshot Kimi',
45
46
  glm: 'Zhipu GLM',
47
+ cursor: 'Cursor',
46
48
  }
47
49
 
48
50
  export function displayName(provider) {
@@ -0,0 +1,133 @@
1
+ import { LlmError } from '@deepseek-ai/dsh-llm'
2
+ import { openaiMessages, openaiTools } from '../messages.js'
3
+ import { openaiChatStream, readJson, httpError } from '../wire.js'
4
+ import { asUsageSnapshot } from '../usage.js'
5
+
6
+ export const id = 'cursor'
7
+
8
+ export const CURSOR_API_BASE = 'https://api2.cursor.sh'
9
+ export const CURSOR_USAGE_URL = 'https://api2.cursor.sh/aiserver.v1.DashboardService/GetCurrentPeriodUsage'
10
+ export const CURSOR_AGENT_URL = 'https://agentn.us.api5.cursor.sh/agent.v1.AgentService/Run'
11
+ export const CURSOR_CLIENT_VERSION = 'cli-2026.05.01-eea359f'
12
+
13
+ export const CURSOR_MODELS = [
14
+ {
15
+ id: 'composer-2',
16
+ name: 'Composer 2',
17
+ contextWindow: 200000,
18
+ maxTokens: 64000,
19
+ inputModalities: ['text', 'image'],
20
+ reasoning: { efforts: [{ id: 'low', name: 'Low' }, { id: 'medium', name: 'Medium' }, { id: 'high', name: 'High' }, { id: 'max', name: 'Max' }] },
21
+ },
22
+ {
23
+ id: 'composer-1.5',
24
+ name: 'Composer 1.5',
25
+ contextWindow: 200000,
26
+ maxTokens: 64000,
27
+ inputModalities: ['text', 'image'],
28
+ },
29
+ {
30
+ id: 'claude-sonnet-5',
31
+ name: 'Claude Sonnet 5 (Cursor)',
32
+ contextWindow: 200000,
33
+ maxTokens: 64000,
34
+ inputModalities: ['text', 'image'],
35
+ },
36
+ {
37
+ id: 'gpt-5.5',
38
+ name: 'GPT-5.5 (Cursor)',
39
+ contextWindow: 200000,
40
+ maxTokens: 128000,
41
+ inputModalities: ['text'],
42
+ },
43
+ {
44
+ id: 'grok-4.5',
45
+ name: 'Grok 4.5 (Cursor)',
46
+ contextWindow: 200000,
47
+ maxTokens: 64000,
48
+ inputModalities: ['text'],
49
+ },
50
+ ]
51
+
52
+ export function providerInfo() {
53
+ return { id, name: 'Cursor' }
54
+ }
55
+
56
+ export function defaults() {
57
+ return {
58
+ apiBase: CURSOR_API_BASE,
59
+ models: CURSOR_MODELS.map((m) => m.id),
60
+ }
61
+ }
62
+
63
+ export function authorizeUrl() {
64
+ return 'https://cursor.com/loginDeepControl'
65
+ }
66
+
67
+ export async function listModels() {
68
+ return CURSOR_MODELS
69
+ }
70
+
71
+ export async function usage(blob, config, fetchImpl) {
72
+ try {
73
+ const impl = fetchImpl || fetch
74
+ const token = blob && (blob.accessToken || blob.access_token)
75
+ if (!token) return null
76
+ const res = await impl(CURSOR_USAGE_URL, {
77
+ method: 'POST',
78
+ headers: {
79
+ Authorization: `Bearer ${token}`,
80
+ 'x-cursor-client-version': CURSOR_CLIENT_VERSION,
81
+ 'User-Agent': CURSOR_CLIENT_VERSION,
82
+ 'Content-Type': 'application/json',
83
+ },
84
+ body: '{}',
85
+ })
86
+ if (!res.ok) return null
87
+ const json = await readJson(res)
88
+ // Cursor returns { numRequests, maxRequestUsage, plan }
89
+ if (json && json.numRequests != null && json.maxRequestUsage != null && json.maxRequestUsage > 0) {
90
+ const pct = Math.round((json.numRequests / json.maxRequestUsage) * 100)
91
+ const snap = asUsageSnapshot(pct)
92
+ if (snap) snap.plan = json.plan || 'Pro'
93
+ return snap
94
+ }
95
+ return null
96
+ } catch {
97
+ return null
98
+ }
99
+ }
100
+
101
+ export async function* streamOnce({ blob, options, fetchImpl, headers, config, signal }) {
102
+ const impl = fetchImpl || fetch
103
+ const token = blob && (blob.accessToken || blob.access_token)
104
+ if (!token) throw new LlmError('Cursor not authenticated', 'AUTH')
105
+
106
+ const body = {
107
+ model: options.model || 'composer-2',
108
+ messages: openaiMessages(options),
109
+ stream: true,
110
+ ...(options.maxTokens != null ? { max_tokens: options.maxTokens } : {}),
111
+ ...(options.temperature != null ? { temperature: options.temperature } : {}),
112
+ }
113
+
114
+ const tools = openaiTools(options)
115
+ if (tools && tools.length) body.tools = tools
116
+
117
+ const url = (config && config.agentUrl) || CURSOR_AGENT_URL
118
+ const res = await impl(url, {
119
+ method: 'POST',
120
+ headers: {
121
+ ...headers,
122
+ Authorization: `Bearer ${token}`,
123
+ 'x-cursor-client-version': CURSOR_CLIENT_VERSION,
124
+ 'User-Agent': CURSOR_CLIENT_VERSION,
125
+ 'Content-Type': 'application/json',
126
+ },
127
+ body: JSON.stringify(body),
128
+ signal,
129
+ })
130
+
131
+ if (!res.ok) throw httpError(res.status, await res.text())
132
+ yield* openaiChatStream(res.body)
133
+ }
@@ -1,3 +1,4 @@
1
+ import * as cursor from './cursor.js'
1
2
  import * as codex from './codex.js'
2
3
  import * as claude from './claude.js'
3
4
  import * as grok from './grok.js'
@@ -6,7 +7,7 @@ import * as kimi from './kimi.js'
6
7
  import * as glm from './glm.js'
7
8
  import { createVendorFromProfile } from '../vendor-factory.js'
8
9
 
9
- const builtins = { codex, claude, grok, antigravity, kimi, glm }
10
+ const builtins = { codex, claude, grok, antigravity, kimi, glm, cursor }
10
11
 
11
12
  const customVendors = new Map()
12
13
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@goodandready/dsh-subscriptions",
3
- "version": "0.5.4",
3
+ "version": "0.5.5",
4
4
  "description": "Use ChatGPT Codex, Claude, Grok, and Antigravity subscriptions as DeepSeek Harness LLM providers via OAuth.",
5
5
  "license": "MIT",
6
6
  "type": "module",