@ai-sdk/harness-cursor 1.0.45 → 1.0.47
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 +22 -0
- package/dist/index.d.ts +24813 -24812
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +392 -450
- package/dist/index.js.map +1 -1
- package/package.json +8 -7
- package/src/index.ts +1 -0
package/dist/index.js
CHANGED
|
@@ -1,464 +1,406 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
commonTool
|
|
4
|
-
} from "@ai-sdk/harness";
|
|
1
|
+
import { commonTool } from "@ai-sdk/harness";
|
|
5
2
|
import { createACP } from "@ai-sdk/harness-acp";
|
|
6
|
-
import { tool } from "@ai-sdk/provider-utils";
|
|
3
|
+
import { isRecord, safeParseJSON, tool } from "@ai-sdk/provider-utils";
|
|
7
4
|
import { z } from "zod/v4";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
auth,
|
|
29
|
-
env
|
|
30
|
-
}) {
|
|
31
|
-
if (isHarnessAuthenticationEnvironment(auth)) return auth;
|
|
32
|
-
if (!shouldResolveNativeSubscription({
|
|
33
|
-
auth,
|
|
34
|
-
env,
|
|
35
|
-
hasDirectCredential: env.CURSOR_API_KEY != null
|
|
36
|
-
})) {
|
|
37
|
-
return env;
|
|
38
|
-
}
|
|
39
|
-
const subscription = await readCursorSubscription({ env });
|
|
40
|
-
return subscription == null ? env : { ...env, CURSOR_API_KEY: subscription };
|
|
5
|
+
import { readFile } from "node:fs/promises";
|
|
6
|
+
import { homedir } from "node:os";
|
|
7
|
+
import { join } from "node:path";
|
|
8
|
+
import { getJwtExpiresAt, isAccessTokenExpiringSoon, isHarnessAuthenticationEnvironment, isLinux, isMacOS, isWindows, readMacOSKeychainPassword, shouldResolveNativeSubscription } from "@ai-sdk/harness/utils";
|
|
9
|
+
//#region src/version.ts
|
|
10
|
+
const VERSION = "1.0.47";
|
|
11
|
+
//#endregion
|
|
12
|
+
//#region src/cursor-subscription.ts
|
|
13
|
+
async function resolveCursorSubscriptionEnvironment({ auth, env }) {
|
|
14
|
+
if (isHarnessAuthenticationEnvironment(auth)) return auth;
|
|
15
|
+
if (!shouldResolveNativeSubscription({
|
|
16
|
+
auth,
|
|
17
|
+
env,
|
|
18
|
+
hasDirectCredential: env.CURSOR_API_KEY != null
|
|
19
|
+
})) return env;
|
|
20
|
+
const subscription = await readCursorSubscription({ env });
|
|
21
|
+
return subscription == null ? env : {
|
|
22
|
+
...env,
|
|
23
|
+
CURSOR_API_KEY: subscription
|
|
24
|
+
};
|
|
41
25
|
}
|
|
42
|
-
async function readCursorSubscription({
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
throw new Error(
|
|
59
|
-
"Cursor subscription access token is expiring soon. Run Cursor login again."
|
|
60
|
-
);
|
|
61
|
-
}
|
|
62
|
-
return accessToken;
|
|
26
|
+
async function readCursorSubscription({ env = process.env, homeDirectory = homedir(), platform = process.platform } = {}) {
|
|
27
|
+
if (env.AGENT_CLI_CREDENTIAL_STORE === "memory") return void 0;
|
|
28
|
+
const authPath = resolveCursorAuthPath({
|
|
29
|
+
env,
|
|
30
|
+
homeDirectory,
|
|
31
|
+
platform
|
|
32
|
+
});
|
|
33
|
+
const text = await readFile(authPath, "utf8").catch(() => void 0);
|
|
34
|
+
const accessToken = (text == null ? void 0 : await parseAccessToken(text)) ?? (isMacOS(platform) && env.AGENT_CLI_CREDENTIAL_STORE !== "file" ? await readMacOSKeychainPassword({
|
|
35
|
+
service: "cursor-access-token",
|
|
36
|
+
account: "cursor-user"
|
|
37
|
+
}) : void 0);
|
|
38
|
+
if (accessToken == null) return void 0;
|
|
39
|
+
const expiresAt = await getJwtExpiresAt({ token: accessToken });
|
|
40
|
+
if (expiresAt != null && isAccessTokenExpiringSoon({ expiresAt })) throw new Error("Cursor subscription access token is expiring soon. Run Cursor login again.");
|
|
41
|
+
return accessToken;
|
|
63
42
|
}
|
|
64
|
-
function resolveCursorAuthPath({
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}) {
|
|
69
|
-
if (isWindows(platform)) {
|
|
70
|
-
return join(
|
|
71
|
-
env.APPDATA ?? join(homeDirectory, "AppData", "Roaming"),
|
|
72
|
-
"Cursor",
|
|
73
|
-
"auth.json"
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
|
-
if (isLinux(platform)) {
|
|
77
|
-
return join(
|
|
78
|
-
env.XDG_CONFIG_HOME ?? join(homeDirectory, ".config"),
|
|
79
|
-
"cursor",
|
|
80
|
-
"auth.json"
|
|
81
|
-
);
|
|
82
|
-
}
|
|
83
|
-
return join(homeDirectory, ".cursor", "auth.json");
|
|
43
|
+
function resolveCursorAuthPath({ env, homeDirectory, platform }) {
|
|
44
|
+
if (isWindows(platform)) return join(env.APPDATA ?? join(homeDirectory, "AppData", "Roaming"), "Cursor", "auth.json");
|
|
45
|
+
if (isLinux(platform)) return join(env.XDG_CONFIG_HOME ?? join(homeDirectory, ".config"), "cursor", "auth.json");
|
|
46
|
+
return join(homeDirectory, ".cursor", "auth.json");
|
|
84
47
|
}
|
|
85
48
|
async function parseAccessToken(text) {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
49
|
+
const parsed = await safeParseJSON({ text });
|
|
50
|
+
if (!parsed.success || !isRecord(parsed.value)) return void 0;
|
|
51
|
+
return typeof parsed.value.accessToken === "string" ? parsed.value.accessToken : void 0;
|
|
89
52
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
nativeName: "reportBugfixResultsToolCall"
|
|
365
|
-
}
|
|
53
|
+
//#endregion
|
|
54
|
+
//#region src/cursor-harness.ts
|
|
55
|
+
const CURSOR_CLIENT_APP = `ai-sdk-harness-cursor/${VERSION}`;
|
|
56
|
+
const CURSOR_BUILTIN_TOOLS = {
|
|
57
|
+
bash: {
|
|
58
|
+
...commonTool("bash", {
|
|
59
|
+
nativeName: "shellToolCall",
|
|
60
|
+
toolUseKind: "bash",
|
|
61
|
+
inputSchema: z.looseObject({ command: z.string() })
|
|
62
|
+
}),
|
|
63
|
+
title: "Terminal"
|
|
64
|
+
},
|
|
65
|
+
delete: {
|
|
66
|
+
...tool({
|
|
67
|
+
title: "Delete",
|
|
68
|
+
inputSchema: z.looseObject({ path: z.string() })
|
|
69
|
+
}),
|
|
70
|
+
nativeName: "deleteToolCall",
|
|
71
|
+
toolUseKind: "edit"
|
|
72
|
+
},
|
|
73
|
+
glob: {
|
|
74
|
+
...commonTool("glob", {
|
|
75
|
+
nativeName: "globToolCall",
|
|
76
|
+
toolUseKind: "readonly",
|
|
77
|
+
inputSchema: z.looseObject({ pattern: z.string() })
|
|
78
|
+
}),
|
|
79
|
+
title: "Find"
|
|
80
|
+
},
|
|
81
|
+
grep: {
|
|
82
|
+
...commonTool("grep", {
|
|
83
|
+
nativeName: "grepToolCall",
|
|
84
|
+
toolUseKind: "readonly",
|
|
85
|
+
inputSchema: z.looseObject({
|
|
86
|
+
pattern: z.string(),
|
|
87
|
+
path: z.string().optional()
|
|
88
|
+
})
|
|
89
|
+
}),
|
|
90
|
+
title: "grep"
|
|
91
|
+
},
|
|
92
|
+
read: {
|
|
93
|
+
...tool({
|
|
94
|
+
title: "Read",
|
|
95
|
+
inputSchema: z.looseObject({ path: z.string() })
|
|
96
|
+
}),
|
|
97
|
+
nativeName: "readToolCall",
|
|
98
|
+
toolUseKind: "readonly"
|
|
99
|
+
},
|
|
100
|
+
updateTodos: {
|
|
101
|
+
...tool({
|
|
102
|
+
title: "Update TODOs",
|
|
103
|
+
inputSchema: z.looseObject({
|
|
104
|
+
_toolName: z.literal("updateTodos"),
|
|
105
|
+
todos: z.array(z.looseObject({
|
|
106
|
+
id: z.string(),
|
|
107
|
+
content: z.string(),
|
|
108
|
+
status: z.string()
|
|
109
|
+
})).optional()
|
|
110
|
+
})
|
|
111
|
+
}),
|
|
112
|
+
nativeName: "updateTodosToolCall"
|
|
113
|
+
},
|
|
114
|
+
readTodos: {
|
|
115
|
+
...tool({
|
|
116
|
+
title: "Read TODOs",
|
|
117
|
+
inputSchema: z.looseObject({})
|
|
118
|
+
}),
|
|
119
|
+
nativeName: "readTodosToolCall",
|
|
120
|
+
toolUseKind: "readonly"
|
|
121
|
+
},
|
|
122
|
+
edit: {
|
|
123
|
+
...tool({
|
|
124
|
+
title: "Edit",
|
|
125
|
+
inputSchema: z.looseObject({ path: z.string() })
|
|
126
|
+
}),
|
|
127
|
+
nativeName: "editToolCall",
|
|
128
|
+
toolUseKind: "edit"
|
|
129
|
+
},
|
|
130
|
+
ls: {
|
|
131
|
+
...tool({
|
|
132
|
+
title: "List",
|
|
133
|
+
inputSchema: z.looseObject({ path: z.string() })
|
|
134
|
+
}),
|
|
135
|
+
nativeName: "lsToolCall",
|
|
136
|
+
toolUseKind: "readonly"
|
|
137
|
+
},
|
|
138
|
+
readLints: {
|
|
139
|
+
...tool({
|
|
140
|
+
title: "Read Lints",
|
|
141
|
+
inputSchema: z.looseObject({ paths: z.array(z.string()) })
|
|
142
|
+
}),
|
|
143
|
+
nativeName: "readLintsToolCall",
|
|
144
|
+
toolUseKind: "readonly"
|
|
145
|
+
},
|
|
146
|
+
semanticSearch: {
|
|
147
|
+
...tool({
|
|
148
|
+
title: "Codebase Search",
|
|
149
|
+
inputSchema: z.looseObject({ query: z.string() })
|
|
150
|
+
}),
|
|
151
|
+
nativeName: "semSearchToolCall",
|
|
152
|
+
toolUseKind: "readonly"
|
|
153
|
+
},
|
|
154
|
+
createPlan: {
|
|
155
|
+
...tool({
|
|
156
|
+
title: "Create Plan",
|
|
157
|
+
inputSchema: z.looseObject({
|
|
158
|
+
_toolName: z.literal("createPlan"),
|
|
159
|
+
name: z.string().optional(),
|
|
160
|
+
plan: z.string().optional()
|
|
161
|
+
})
|
|
162
|
+
}),
|
|
163
|
+
nativeName: "createPlanToolCall"
|
|
164
|
+
},
|
|
165
|
+
webSearch: {
|
|
166
|
+
...tool({
|
|
167
|
+
title: "Web Search",
|
|
168
|
+
inputSchema: z.looseObject({ searchTerm: z.string() })
|
|
169
|
+
}),
|
|
170
|
+
nativeName: "webSearchToolCall",
|
|
171
|
+
toolUseKind: "readonly"
|
|
172
|
+
},
|
|
173
|
+
task: {
|
|
174
|
+
...tool({
|
|
175
|
+
title: "Task",
|
|
176
|
+
inputSchema: z.looseObject({
|
|
177
|
+
_toolName: z.literal("task"),
|
|
178
|
+
prompt: z.string().optional(),
|
|
179
|
+
description: z.string().optional(),
|
|
180
|
+
subagentType: z.unknown().optional()
|
|
181
|
+
})
|
|
182
|
+
}),
|
|
183
|
+
nativeName: "taskToolCall"
|
|
184
|
+
},
|
|
185
|
+
listMcpResources: {
|
|
186
|
+
...tool({
|
|
187
|
+
title: "List MCP Resources",
|
|
188
|
+
inputSchema: z.looseObject({ server: z.string().optional() })
|
|
189
|
+
}),
|
|
190
|
+
nativeName: "listMcpResourcesToolCall",
|
|
191
|
+
toolUseKind: "readonly"
|
|
192
|
+
},
|
|
193
|
+
readMcpResource: {
|
|
194
|
+
...tool({
|
|
195
|
+
title: "Fetch MCP Resource",
|
|
196
|
+
inputSchema: z.looseObject({
|
|
197
|
+
server: z.string().optional(),
|
|
198
|
+
uri: z.string().optional(),
|
|
199
|
+
downloadPath: z.string().optional()
|
|
200
|
+
})
|
|
201
|
+
}),
|
|
202
|
+
nativeName: "readMcpResourceToolCall",
|
|
203
|
+
toolUseKind: "readonly"
|
|
204
|
+
},
|
|
205
|
+
applyAgentDiff: {
|
|
206
|
+
...tool({
|
|
207
|
+
title: "Apply Agent Diff",
|
|
208
|
+
inputSchema: z.looseObject({ path: z.string().optional() })
|
|
209
|
+
}),
|
|
210
|
+
nativeName: "applyAgentDiffToolCall",
|
|
211
|
+
toolUseKind: "edit"
|
|
212
|
+
},
|
|
213
|
+
fetch: {
|
|
214
|
+
...tool({
|
|
215
|
+
title: "Fetch",
|
|
216
|
+
inputSchema: z.looseObject({ url: z.string() })
|
|
217
|
+
}),
|
|
218
|
+
nativeName: "fetchToolCall",
|
|
219
|
+
toolUseKind: "readonly"
|
|
220
|
+
},
|
|
221
|
+
switchMode: {
|
|
222
|
+
...tool({
|
|
223
|
+
title: "Switch Mode",
|
|
224
|
+
inputSchema: z.looseObject({
|
|
225
|
+
targetModeId: z.string(),
|
|
226
|
+
explanation: z.string().optional()
|
|
227
|
+
})
|
|
228
|
+
}),
|
|
229
|
+
nativeName: "switchModeToolCall"
|
|
230
|
+
},
|
|
231
|
+
generateImage: {
|
|
232
|
+
...tool({
|
|
233
|
+
title: "Generate Image",
|
|
234
|
+
inputSchema: z.looseObject({
|
|
235
|
+
_toolName: z.literal("generateImage"),
|
|
236
|
+
description: z.string().optional(),
|
|
237
|
+
filename: z.string().optional()
|
|
238
|
+
})
|
|
239
|
+
}),
|
|
240
|
+
nativeName: "generateImageToolCall"
|
|
241
|
+
},
|
|
242
|
+
recordScreen: {
|
|
243
|
+
...tool({
|
|
244
|
+
title: "Record Screen",
|
|
245
|
+
inputSchema: z.looseObject({})
|
|
246
|
+
}),
|
|
247
|
+
nativeName: "recordScreenToolCall"
|
|
248
|
+
},
|
|
249
|
+
computerUse: {
|
|
250
|
+
...tool({
|
|
251
|
+
title: "Computer Use",
|
|
252
|
+
inputSchema: z.looseObject({
|
|
253
|
+
action: z.string().optional(),
|
|
254
|
+
coordinate: z.unknown().optional(),
|
|
255
|
+
text: z.string().optional()
|
|
256
|
+
})
|
|
257
|
+
}),
|
|
258
|
+
nativeName: "computerUseToolCall",
|
|
259
|
+
toolUseKind: "bash"
|
|
260
|
+
},
|
|
261
|
+
writeShellStdin: {
|
|
262
|
+
...tool({
|
|
263
|
+
title: "Write to stdin",
|
|
264
|
+
inputSchema: z.looseObject({
|
|
265
|
+
shellId: z.number().optional(),
|
|
266
|
+
chars: z.string().optional()
|
|
267
|
+
})
|
|
268
|
+
}),
|
|
269
|
+
nativeName: "writeShellStdinToolCall",
|
|
270
|
+
toolUseKind: "bash"
|
|
271
|
+
},
|
|
272
|
+
reflect: {
|
|
273
|
+
...tool({
|
|
274
|
+
title: "Reflect",
|
|
275
|
+
inputSchema: z.looseObject({ reflection: z.string().optional() })
|
|
276
|
+
}),
|
|
277
|
+
nativeName: "reflectToolCall",
|
|
278
|
+
toolUseKind: "readonly"
|
|
279
|
+
},
|
|
280
|
+
setupVmEnvironment: {
|
|
281
|
+
...tool({
|
|
282
|
+
title: "Setup VM Environment",
|
|
283
|
+
inputSchema: z.looseObject({})
|
|
284
|
+
}),
|
|
285
|
+
nativeName: "setupVmEnvironmentToolCall",
|
|
286
|
+
toolUseKind: "bash"
|
|
287
|
+
},
|
|
288
|
+
replaceEnv: {
|
|
289
|
+
...tool({
|
|
290
|
+
title: "Replace Environment",
|
|
291
|
+
inputSchema: z.looseObject({})
|
|
292
|
+
}),
|
|
293
|
+
nativeName: "replaceEnvToolCall",
|
|
294
|
+
toolUseKind: "bash"
|
|
295
|
+
},
|
|
296
|
+
startGrindExecution: {
|
|
297
|
+
...tool({
|
|
298
|
+
title: "Start Grind Execution",
|
|
299
|
+
inputSchema: z.looseObject({})
|
|
300
|
+
}),
|
|
301
|
+
nativeName: "startGrindExecutionToolCall",
|
|
302
|
+
toolUseKind: "bash"
|
|
303
|
+
},
|
|
304
|
+
startGrindPlanning: {
|
|
305
|
+
...tool({
|
|
306
|
+
title: "Start Grind Planning",
|
|
307
|
+
inputSchema: z.looseObject({})
|
|
308
|
+
}),
|
|
309
|
+
nativeName: "startGrindPlanningToolCall",
|
|
310
|
+
toolUseKind: "readonly"
|
|
311
|
+
},
|
|
312
|
+
webFetch: {
|
|
313
|
+
...tool({
|
|
314
|
+
title: "Web Fetch",
|
|
315
|
+
inputSchema: z.looseObject({ url: z.string() })
|
|
316
|
+
}),
|
|
317
|
+
nativeName: "webFetchToolCall",
|
|
318
|
+
toolUseKind: "readonly"
|
|
319
|
+
},
|
|
320
|
+
reportBugfixResults: {
|
|
321
|
+
...tool({
|
|
322
|
+
title: "Report Bugfix Results",
|
|
323
|
+
inputSchema: z.looseObject({})
|
|
324
|
+
}),
|
|
325
|
+
nativeName: "reportBugfixResultsToolCall"
|
|
326
|
+
}
|
|
366
327
|
};
|
|
367
328
|
function createCursor(settings = {}) {
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
});
|
|
431
|
-
}
|
|
432
|
-
if (headers != null) {
|
|
433
|
-
transformations.push({
|
|
434
|
-
match: settings.auth === "ai-gateway" ? {
|
|
435
|
-
host: "ai-gateway.vercel.sh",
|
|
436
|
-
path: { startsWith: "/cursor/v1" }
|
|
437
|
-
} : { host: "api2.cursor.sh" },
|
|
438
|
-
transform: { headers }
|
|
439
|
-
});
|
|
440
|
-
}
|
|
441
|
-
return transformations;
|
|
442
|
-
}
|
|
443
|
-
});
|
|
329
|
+
const clientAppSegments = CURSOR_CLIENT_APP.split("/");
|
|
330
|
+
const clientAppVersion = clientAppSegments.pop();
|
|
331
|
+
if (settings.auth === "direct" || settings.auth === "ai-gateway") warnCursorAuthenticationConfiguration({ auth: settings.auth });
|
|
332
|
+
return createACP({
|
|
333
|
+
auth: settings.auth,
|
|
334
|
+
resolveAuthenticationEnvironment: resolveCursorSubscriptionEnvironment,
|
|
335
|
+
credentialForwarding: settings.credentialForwarding,
|
|
336
|
+
port: settings.port,
|
|
337
|
+
portEndpoint: settings.portEndpoint,
|
|
338
|
+
startupTimeoutMs: settings.startupTimeoutMs,
|
|
339
|
+
reconnect: settings.reconnect,
|
|
340
|
+
mcpServers: settings.mcpServers,
|
|
341
|
+
isMcpToolCall: (toolCall) => {
|
|
342
|
+
const rawInput = toolCall.rawInput;
|
|
343
|
+
return isRecord$1(rawInput) && typeof rawInput.providerIdentifier === "string" && typeof rawInput.toolName === "string" && isRecord$1(rawInput.args);
|
|
344
|
+
},
|
|
345
|
+
mintBridgeToken: settings.mintBridgeToken,
|
|
346
|
+
version: "v1",
|
|
347
|
+
harnessId: "cursor",
|
|
348
|
+
builtinTools: CURSOR_BUILTIN_TOOLS,
|
|
349
|
+
clientApp: {
|
|
350
|
+
name: clientAppSegments.join("/"),
|
|
351
|
+
version: clientAppVersion
|
|
352
|
+
},
|
|
353
|
+
source: {
|
|
354
|
+
type: "install-command",
|
|
355
|
+
command: "curl https://cursor.com/install -fsS | bash"
|
|
356
|
+
},
|
|
357
|
+
executable: "agent",
|
|
358
|
+
args: ["--disable-auto-update", "acp"],
|
|
359
|
+
modelMapping: {
|
|
360
|
+
type: "session-config-option",
|
|
361
|
+
path: "model"
|
|
362
|
+
},
|
|
363
|
+
clientCapabilities: { _meta: { parameterizedModelPicker: true } },
|
|
364
|
+
credentialEnv: ["CURSOR_API_KEY"],
|
|
365
|
+
credentialBrokering: ({ env, sandboxEnv, headers }) => {
|
|
366
|
+
const transformations = [];
|
|
367
|
+
if (env.CURSOR_API_KEY && sandboxEnv?.CURSOR_API_KEY) transformations.push({
|
|
368
|
+
match: {
|
|
369
|
+
host: "api2.cursor.sh",
|
|
370
|
+
path: { exact: "/auth/exchange_user_api_key" },
|
|
371
|
+
method: ["POST"],
|
|
372
|
+
headers: [{
|
|
373
|
+
key: { exact: "Authorization" },
|
|
374
|
+
value: { exact: `Bearer ${sandboxEnv.CURSOR_API_KEY}` }
|
|
375
|
+
}]
|
|
376
|
+
},
|
|
377
|
+
transform: { headers: { Authorization: `Bearer ${env.CURSOR_API_KEY}` } }
|
|
378
|
+
});
|
|
379
|
+
if (headers != null) transformations.push({
|
|
380
|
+
match: settings.auth === "ai-gateway" ? {
|
|
381
|
+
host: "ai-gateway.vercel.sh",
|
|
382
|
+
path: { startsWith: "/cursor/v1" }
|
|
383
|
+
} : { host: "api2.cursor.sh" },
|
|
384
|
+
transform: { headers }
|
|
385
|
+
});
|
|
386
|
+
return transformations;
|
|
387
|
+
}
|
|
388
|
+
});
|
|
444
389
|
}
|
|
445
|
-
function warnCursorAuthenticationConfiguration({
|
|
446
|
-
|
|
447
|
-
}
|
|
448
|
-
const detail = auth === "ai-gateway" ? "Configure an AI Gateway API key as Cursor's OpenAI API key and set Override OpenAI Base URL to https://ai-gateway.vercel.sh/cursor/v1." : "Configure Cursor to use its direct model-provider routing.";
|
|
449
|
-
console.warn(
|
|
450
|
-
`[cursor] auth: ${JSON.stringify(auth)} cannot configure Cursor provider authentication. ${detail} CURSOR_API_KEY is still required for Cursor CLI authentication.`
|
|
451
|
-
);
|
|
390
|
+
function warnCursorAuthenticationConfiguration({ auth }) {
|
|
391
|
+
const detail = auth === "ai-gateway" ? "Configure an AI Gateway API key as Cursor's OpenAI API key and set Override OpenAI Base URL to https://ai-gateway.vercel.sh/cursor/v1." : "Configure Cursor to use its direct model-provider routing.";
|
|
392
|
+
console.warn(`[cursor] auth: ${JSON.stringify(auth)} cannot configure Cursor provider authentication. ${detail} CURSOR_API_KEY is still required for Cursor CLI authentication.`);
|
|
452
393
|
}
|
|
453
|
-
function
|
|
454
|
-
|
|
394
|
+
function isRecord$1(value) {
|
|
395
|
+
return value != null && typeof value === "object" && !Array.isArray(value);
|
|
455
396
|
}
|
|
397
|
+
//#endregion
|
|
398
|
+
//#region src/index.ts
|
|
399
|
+
/**
|
|
400
|
+
* Default Cursor harness instance. Equivalent to `createCursor()`.
|
|
401
|
+
*/
|
|
402
|
+
const cursor = createCursor();
|
|
403
|
+
//#endregion
|
|
404
|
+
export { VERSION, createCursor, cursor };
|
|
456
405
|
|
|
457
|
-
// src/index.ts
|
|
458
|
-
var cursor = createCursor();
|
|
459
|
-
export {
|
|
460
|
-
VERSION,
|
|
461
|
-
createCursor,
|
|
462
|
-
cursor
|
|
463
|
-
};
|
|
464
406
|
//# sourceMappingURL=index.js.map
|