@ai-sdk/harness-cursor 0.0.0 → 1.0.3

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/dist/index.js ADDED
@@ -0,0 +1,388 @@
1
+ // src/cursor-harness.ts
2
+ import {
3
+ commonTool
4
+ } from "@ai-sdk/harness";
5
+ import {
6
+ createACP
7
+ } from "@ai-sdk/harness-acp";
8
+ import { tool } from "@ai-sdk/provider-utils";
9
+ import { z } from "zod/v4";
10
+
11
+ // src/version.ts
12
+ var VERSION = true ? "1.0.3" : "0.0.0-test";
13
+
14
+ // src/cursor-harness.ts
15
+ var CURSOR_CLIENT_APP = `ai-sdk/harness-cursor/${VERSION}`;
16
+ var CURSOR_BUILTIN_TOOLS = {
17
+ bash: {
18
+ ...commonTool("bash", {
19
+ nativeName: "shellToolCall",
20
+ toolUseKind: "bash",
21
+ inputSchema: z.looseObject({ command: z.string() })
22
+ }),
23
+ title: "Terminal"
24
+ },
25
+ delete: {
26
+ ...tool({
27
+ title: "Delete",
28
+ inputSchema: z.looseObject({ path: z.string() })
29
+ }),
30
+ nativeName: "deleteToolCall",
31
+ toolUseKind: "edit"
32
+ },
33
+ glob: {
34
+ ...commonTool("glob", {
35
+ nativeName: "globToolCall",
36
+ toolUseKind: "readonly",
37
+ inputSchema: z.looseObject({ pattern: z.string() })
38
+ }),
39
+ title: "Find"
40
+ },
41
+ grep: {
42
+ ...commonTool("grep", {
43
+ nativeName: "grepToolCall",
44
+ toolUseKind: "readonly",
45
+ inputSchema: z.looseObject({
46
+ pattern: z.string(),
47
+ path: z.string().optional()
48
+ })
49
+ }),
50
+ title: "grep"
51
+ },
52
+ read: {
53
+ ...tool({
54
+ title: "Read",
55
+ inputSchema: z.looseObject({ path: z.string() })
56
+ }),
57
+ nativeName: "readToolCall",
58
+ toolUseKind: "readonly"
59
+ },
60
+ updateTodos: {
61
+ ...tool({
62
+ title: "Update TODOs",
63
+ inputSchema: z.looseObject({
64
+ _toolName: z.literal("updateTodos"),
65
+ todos: z.array(
66
+ z.looseObject({
67
+ id: z.string(),
68
+ content: z.string(),
69
+ status: z.string()
70
+ })
71
+ ).optional()
72
+ })
73
+ }),
74
+ nativeName: "updateTodosToolCall"
75
+ },
76
+ readTodos: {
77
+ ...tool({
78
+ title: "Read TODOs",
79
+ inputSchema: z.looseObject({})
80
+ }),
81
+ nativeName: "readTodosToolCall",
82
+ toolUseKind: "readonly"
83
+ },
84
+ edit: {
85
+ ...tool({
86
+ title: "Edit",
87
+ inputSchema: z.looseObject({ path: z.string() })
88
+ }),
89
+ nativeName: "editToolCall",
90
+ toolUseKind: "edit"
91
+ },
92
+ ls: {
93
+ ...tool({
94
+ title: "List",
95
+ inputSchema: z.looseObject({ path: z.string() })
96
+ }),
97
+ nativeName: "lsToolCall",
98
+ toolUseKind: "readonly"
99
+ },
100
+ readLints: {
101
+ ...tool({
102
+ title: "Read Lints",
103
+ inputSchema: z.looseObject({ paths: z.array(z.string()) })
104
+ }),
105
+ nativeName: "readLintsToolCall",
106
+ toolUseKind: "readonly"
107
+ },
108
+ semanticSearch: {
109
+ ...tool({
110
+ title: "Codebase Search",
111
+ inputSchema: z.looseObject({ query: z.string() })
112
+ }),
113
+ nativeName: "semSearchToolCall",
114
+ toolUseKind: "readonly"
115
+ },
116
+ createPlan: {
117
+ ...tool({
118
+ title: "Create Plan",
119
+ inputSchema: z.looseObject({
120
+ _toolName: z.literal("createPlan"),
121
+ name: z.string().optional(),
122
+ plan: z.string().optional()
123
+ })
124
+ }),
125
+ nativeName: "createPlanToolCall"
126
+ },
127
+ webSearch: {
128
+ ...tool({
129
+ title: "Web Search",
130
+ inputSchema: z.looseObject({ searchTerm: z.string() })
131
+ }),
132
+ nativeName: "webSearchToolCall",
133
+ toolUseKind: "readonly"
134
+ },
135
+ task: {
136
+ ...tool({
137
+ title: "Task",
138
+ inputSchema: z.looseObject({
139
+ _toolName: z.literal("task"),
140
+ prompt: z.string().optional(),
141
+ description: z.string().optional(),
142
+ subagentType: z.unknown().optional()
143
+ })
144
+ }),
145
+ nativeName: "taskToolCall"
146
+ },
147
+ listMcpResources: {
148
+ ...tool({
149
+ title: "List MCP Resources",
150
+ inputSchema: z.looseObject({ server: z.string().optional() })
151
+ }),
152
+ nativeName: "listMcpResourcesToolCall",
153
+ toolUseKind: "readonly"
154
+ },
155
+ readMcpResource: {
156
+ ...tool({
157
+ title: "Fetch MCP Resource",
158
+ inputSchema: z.looseObject({
159
+ server: z.string().optional(),
160
+ uri: z.string().optional(),
161
+ downloadPath: z.string().optional()
162
+ })
163
+ }),
164
+ nativeName: "readMcpResourceToolCall",
165
+ toolUseKind: "readonly"
166
+ },
167
+ applyAgentDiff: {
168
+ ...tool({
169
+ title: "Apply Agent Diff",
170
+ inputSchema: z.looseObject({ path: z.string().optional() })
171
+ }),
172
+ nativeName: "applyAgentDiffToolCall",
173
+ toolUseKind: "edit"
174
+ },
175
+ askQuestion: {
176
+ ...tool({
177
+ inputSchema: z.looseObject({
178
+ _toolName: z.literal("askQuestion"),
179
+ title: z.string().optional(),
180
+ questions: z.array(
181
+ z.looseObject({
182
+ id: z.string(),
183
+ prompt: z.string(),
184
+ options: z.array(
185
+ z.looseObject({ id: z.string(), label: z.string() })
186
+ ),
187
+ allowMultiple: z.boolean().optional()
188
+ })
189
+ ).optional()
190
+ })
191
+ }),
192
+ nativeName: "askQuestionToolCall",
193
+ toolUseKind: "readonly"
194
+ },
195
+ fetch: {
196
+ ...tool({
197
+ title: "Fetch",
198
+ inputSchema: z.looseObject({ url: z.string() })
199
+ }),
200
+ nativeName: "fetchToolCall",
201
+ toolUseKind: "readonly"
202
+ },
203
+ switchMode: {
204
+ ...tool({
205
+ title: "Switch Mode",
206
+ inputSchema: z.looseObject({
207
+ targetModeId: z.string(),
208
+ explanation: z.string().optional()
209
+ })
210
+ }),
211
+ nativeName: "switchModeToolCall"
212
+ },
213
+ generateImage: {
214
+ ...tool({
215
+ title: "Generate Image",
216
+ inputSchema: z.looseObject({
217
+ _toolName: z.literal("generateImage"),
218
+ description: z.string().optional(),
219
+ filename: z.string().optional()
220
+ })
221
+ }),
222
+ nativeName: "generateImageToolCall"
223
+ },
224
+ recordScreen: {
225
+ ...tool({
226
+ title: "Record Screen",
227
+ inputSchema: z.looseObject({})
228
+ }),
229
+ nativeName: "recordScreenToolCall"
230
+ },
231
+ computerUse: {
232
+ ...tool({
233
+ title: "Computer Use",
234
+ inputSchema: z.looseObject({
235
+ action: z.string().optional(),
236
+ coordinate: z.unknown().optional(),
237
+ text: z.string().optional()
238
+ })
239
+ }),
240
+ nativeName: "computerUseToolCall",
241
+ toolUseKind: "bash"
242
+ },
243
+ writeShellStdin: {
244
+ ...tool({
245
+ title: "Write to stdin",
246
+ inputSchema: z.looseObject({
247
+ shellId: z.number().optional(),
248
+ chars: z.string().optional()
249
+ })
250
+ }),
251
+ nativeName: "writeShellStdinToolCall",
252
+ toolUseKind: "bash"
253
+ },
254
+ reflect: {
255
+ ...tool({
256
+ title: "Reflect",
257
+ inputSchema: z.looseObject({ reflection: z.string().optional() })
258
+ }),
259
+ nativeName: "reflectToolCall",
260
+ toolUseKind: "readonly"
261
+ },
262
+ setupVmEnvironment: {
263
+ ...tool({
264
+ title: "Setup VM Environment",
265
+ inputSchema: z.looseObject({})
266
+ }),
267
+ nativeName: "setupVmEnvironmentToolCall",
268
+ toolUseKind: "bash"
269
+ },
270
+ replaceEnv: {
271
+ ...tool({
272
+ title: "Replace Environment",
273
+ inputSchema: z.looseObject({})
274
+ }),
275
+ nativeName: "replaceEnvToolCall",
276
+ toolUseKind: "bash"
277
+ },
278
+ startGrindExecution: {
279
+ ...tool({
280
+ title: "Start Grind Execution",
281
+ inputSchema: z.looseObject({})
282
+ }),
283
+ nativeName: "startGrindExecutionToolCall",
284
+ toolUseKind: "bash"
285
+ },
286
+ startGrindPlanning: {
287
+ ...tool({
288
+ title: "Start Grind Planning",
289
+ inputSchema: z.looseObject({})
290
+ }),
291
+ nativeName: "startGrindPlanningToolCall",
292
+ toolUseKind: "readonly"
293
+ },
294
+ webFetch: {
295
+ ...tool({
296
+ title: "Web Fetch",
297
+ inputSchema: z.looseObject({ url: z.string() })
298
+ }),
299
+ nativeName: "webFetchToolCall",
300
+ toolUseKind: "readonly"
301
+ },
302
+ reportBugfixResults: {
303
+ ...tool({
304
+ title: "Report Bugfix Results",
305
+ inputSchema: z.looseObject({})
306
+ }),
307
+ nativeName: "reportBugfixResultsToolCall"
308
+ }
309
+ };
310
+ function createCursor(settings = {}) {
311
+ const clientAppSegments = CURSOR_CLIENT_APP.split("/");
312
+ const clientAppVersion = clientAppSegments.pop();
313
+ if (settings.auth === "direct" || settings.auth === "ai-gateway") {
314
+ warnCursorAuthenticationConfiguration({ auth: settings.auth });
315
+ }
316
+ return createACP({
317
+ credentialForwarding: settings.credentialForwarding,
318
+ modelId: settings.model,
319
+ port: settings.port,
320
+ portEndpoint: settings.portEndpoint,
321
+ startupTimeoutMs: settings.startupTimeoutMs,
322
+ mcpServers: settings.mcpServers,
323
+ isMcpToolCall: (toolCall) => {
324
+ const rawInput = toolCall.rawInput;
325
+ return isRecord(rawInput) && typeof rawInput.providerIdentifier === "string" && typeof rawInput.toolName === "string" && isRecord(rawInput.args);
326
+ },
327
+ mintBridgeToken: settings.mintBridgeToken,
328
+ version: "v1",
329
+ harnessId: "cursor",
330
+ builtinTools: CURSOR_BUILTIN_TOOLS,
331
+ clientApp: {
332
+ name: clientAppSegments.join("/"),
333
+ version: clientAppVersion
334
+ },
335
+ source: {
336
+ type: "install-command",
337
+ command: "curl https://cursor.com/install -fsS | bash"
338
+ },
339
+ executable: "agent",
340
+ args: ["--disable-auto-update", "acp"],
341
+ credentialEnv: ["CURSOR_API_KEY"],
342
+ credentialBrokering: ({ env, sandboxEnv }) => {
343
+ if (!env.CURSOR_API_KEY || !sandboxEnv?.CURSOR_API_KEY) return [];
344
+ return [
345
+ {
346
+ match: {
347
+ host: "api2.cursor.sh",
348
+ path: { exact: "/auth/exchange_user_api_key" },
349
+ method: ["POST"],
350
+ headers: [
351
+ {
352
+ key: { exact: "Authorization" },
353
+ value: {
354
+ exact: `Bearer ${sandboxEnv.CURSOR_API_KEY}`
355
+ }
356
+ }
357
+ ]
358
+ },
359
+ transform: {
360
+ headers: {
361
+ Authorization: `Bearer ${env.CURSOR_API_KEY}`
362
+ }
363
+ }
364
+ }
365
+ ];
366
+ }
367
+ });
368
+ }
369
+ function warnCursorAuthenticationConfiguration({
370
+ auth
371
+ }) {
372
+ 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.";
373
+ console.warn(
374
+ `[cursor] auth: ${JSON.stringify(auth)} cannot configure Cursor provider authentication. ${detail} CURSOR_API_KEY is still required for Cursor CLI authentication.`
375
+ );
376
+ }
377
+ function isRecord(value) {
378
+ return value != null && typeof value === "object" && !Array.isArray(value);
379
+ }
380
+
381
+ // src/index.ts
382
+ var cursor = createCursor();
383
+ export {
384
+ VERSION,
385
+ createCursor,
386
+ cursor
387
+ };
388
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/cursor-harness.ts","../src/version.ts","../src/index.ts"],"sourcesContent":["import {\n commonTool,\n type HarnessV1,\n type HarnessV1BuiltinTool,\n type HarnessV1CredentialForwarding,\n type HarnessV1PortEndpoint,\n} from '@ai-sdk/harness';\nimport {\n createACP,\n type ACPProviderAuthenticationMode,\n} from '@ai-sdk/harness-acp';\nimport { tool } from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\nimport { VERSION } from './version';\n\nconst CURSOR_CLIENT_APP = `ai-sdk/harness-cursor/${VERSION}`;\n\nexport type CursorHarnessSettings = {\n /**\n * Declares the provider authentication configured in Cursor. The adapter\n * cannot change this setting and warns for explicit routing modes.\n */\n readonly auth?: ACPProviderAuthenticationMode;\n /**\n * Customizes each credential value before it is forwarded into a sandbox\n * process. This does not restrict which credentials the harness adapter can\n * discover, read, or otherwise access in the host process.\n */\n readonly credentialForwarding?: HarnessV1CredentialForwarding;\n /**\n * Cursor model id selected through ACP. Unset preserves Cursor's default.\n */\n readonly model?: string;\n /**\n * Overrides the sandbox port used by the ACP bridge.\n */\n readonly port?: number;\n /**\n * Override the host endpoint used to connect to the sandbox bridge. Required\n * together with `port` when using a basic sandbox session.\n */\n readonly portEndpoint?: HarnessV1PortEndpoint;\n /**\n * Maximum milliseconds to wait for the ACP bridge to start.\n */\n readonly startupTimeoutMs?: number;\n /**\n * MCP server definitions keyed by server name. Each definition uses the\n * underlying runtime's native MCP server configuration format.\n */\n readonly mcpServers?: Record<string, unknown>;\n /**\n * Creates the authentication token used by the sandbox bridge. Defaults to\n * a random 32-byte hexadecimal token.\n */\n readonly mintBridgeToken?: (sandboxId: string) => string;\n};\n\n/*\n * Tool variants, display titles, ACP kinds, and raw input projections were\n * captured from the official Cursor CLI 2026.08.11-e8db854 ACP implementation.\n * `mcpToolCall` is dynamic and `truncatedToolCall` is a transport sentinel, so\n * neither is exposed as a built-in.\n */\nconst CURSOR_BUILTIN_TOOLS = {\n bash: {\n ...commonTool('bash', {\n nativeName: 'shellToolCall',\n toolUseKind: 'bash',\n inputSchema: z.looseObject({ command: z.string() }),\n }),\n title: 'Terminal',\n },\n delete: {\n ...tool({\n title: 'Delete',\n inputSchema: z.looseObject({ path: z.string() }),\n }),\n nativeName: 'deleteToolCall',\n toolUseKind: 'edit',\n },\n glob: {\n ...commonTool('glob', {\n nativeName: 'globToolCall',\n toolUseKind: 'readonly',\n inputSchema: z.looseObject({ pattern: z.string() }),\n }),\n title: 'Find',\n },\n grep: {\n ...commonTool('grep', {\n nativeName: 'grepToolCall',\n toolUseKind: 'readonly',\n inputSchema: z.looseObject({\n pattern: z.string(),\n path: z.string().optional(),\n }),\n }),\n title: 'grep',\n },\n read: {\n ...tool({\n title: 'Read',\n inputSchema: z.looseObject({ path: z.string() }),\n }),\n nativeName: 'readToolCall',\n toolUseKind: 'readonly',\n },\n updateTodos: {\n ...tool({\n title: 'Update TODOs',\n inputSchema: z.looseObject({\n _toolName: z.literal('updateTodos'),\n todos: z\n .array(\n z.looseObject({\n id: z.string(),\n content: z.string(),\n status: z.string(),\n }),\n )\n .optional(),\n }),\n }),\n nativeName: 'updateTodosToolCall',\n },\n readTodos: {\n ...tool({\n title: 'Read TODOs',\n inputSchema: z.looseObject({}),\n }),\n nativeName: 'readTodosToolCall',\n toolUseKind: 'readonly',\n },\n edit: {\n ...tool({\n title: 'Edit',\n inputSchema: z.looseObject({ path: z.string() }),\n }),\n nativeName: 'editToolCall',\n toolUseKind: 'edit',\n },\n ls: {\n ...tool({\n title: 'List',\n inputSchema: z.looseObject({ path: z.string() }),\n }),\n nativeName: 'lsToolCall',\n toolUseKind: 'readonly',\n },\n readLints: {\n ...tool({\n title: 'Read Lints',\n inputSchema: z.looseObject({ paths: z.array(z.string()) }),\n }),\n nativeName: 'readLintsToolCall',\n toolUseKind: 'readonly',\n },\n semanticSearch: {\n ...tool({\n title: 'Codebase Search',\n inputSchema: z.looseObject({ query: z.string() }),\n }),\n nativeName: 'semSearchToolCall',\n toolUseKind: 'readonly',\n },\n createPlan: {\n ...tool({\n title: 'Create Plan',\n inputSchema: z.looseObject({\n _toolName: z.literal('createPlan'),\n name: z.string().optional(),\n plan: z.string().optional(),\n }),\n }),\n nativeName: 'createPlanToolCall',\n },\n webSearch: {\n ...tool({\n title: 'Web Search',\n inputSchema: z.looseObject({ searchTerm: z.string() }),\n }),\n nativeName: 'webSearchToolCall',\n toolUseKind: 'readonly',\n },\n task: {\n ...tool({\n title: 'Task',\n inputSchema: z.looseObject({\n _toolName: z.literal('task'),\n prompt: z.string().optional(),\n description: z.string().optional(),\n subagentType: z.unknown().optional(),\n }),\n }),\n nativeName: 'taskToolCall',\n },\n listMcpResources: {\n ...tool({\n title: 'List MCP Resources',\n inputSchema: z.looseObject({ server: z.string().optional() }),\n }),\n nativeName: 'listMcpResourcesToolCall',\n toolUseKind: 'readonly',\n },\n readMcpResource: {\n ...tool({\n title: 'Fetch MCP Resource',\n inputSchema: z.looseObject({\n server: z.string().optional(),\n uri: z.string().optional(),\n downloadPath: z.string().optional(),\n }),\n }),\n nativeName: 'readMcpResourceToolCall',\n toolUseKind: 'readonly',\n },\n applyAgentDiff: {\n ...tool({\n title: 'Apply Agent Diff',\n inputSchema: z.looseObject({ path: z.string().optional() }),\n }),\n nativeName: 'applyAgentDiffToolCall',\n toolUseKind: 'edit',\n },\n askQuestion: {\n ...tool({\n inputSchema: z.looseObject({\n _toolName: z.literal('askQuestion'),\n title: z.string().optional(),\n questions: z\n .array(\n z.looseObject({\n id: z.string(),\n prompt: z.string(),\n options: z.array(\n z.looseObject({ id: z.string(), label: z.string() }),\n ),\n allowMultiple: z.boolean().optional(),\n }),\n )\n .optional(),\n }),\n }),\n nativeName: 'askQuestionToolCall',\n toolUseKind: 'readonly',\n },\n fetch: {\n ...tool({\n title: 'Fetch',\n inputSchema: z.looseObject({ url: z.string() }),\n }),\n nativeName: 'fetchToolCall',\n toolUseKind: 'readonly',\n },\n switchMode: {\n ...tool({\n title: 'Switch Mode',\n inputSchema: z.looseObject({\n targetModeId: z.string(),\n explanation: z.string().optional(),\n }),\n }),\n nativeName: 'switchModeToolCall',\n },\n generateImage: {\n ...tool({\n title: 'Generate Image',\n inputSchema: z.looseObject({\n _toolName: z.literal('generateImage'),\n description: z.string().optional(),\n filename: z.string().optional(),\n }),\n }),\n nativeName: 'generateImageToolCall',\n },\n recordScreen: {\n ...tool({\n title: 'Record Screen',\n inputSchema: z.looseObject({}),\n }),\n nativeName: 'recordScreenToolCall',\n },\n computerUse: {\n ...tool({\n title: 'Computer Use',\n inputSchema: z.looseObject({\n action: z.string().optional(),\n coordinate: z.unknown().optional(),\n text: z.string().optional(),\n }),\n }),\n nativeName: 'computerUseToolCall',\n toolUseKind: 'bash',\n },\n writeShellStdin: {\n ...tool({\n title: 'Write to stdin',\n inputSchema: z.looseObject({\n shellId: z.number().optional(),\n chars: z.string().optional(),\n }),\n }),\n nativeName: 'writeShellStdinToolCall',\n toolUseKind: 'bash',\n },\n reflect: {\n ...tool({\n title: 'Reflect',\n inputSchema: z.looseObject({ reflection: z.string().optional() }),\n }),\n nativeName: 'reflectToolCall',\n toolUseKind: 'readonly',\n },\n setupVmEnvironment: {\n ...tool({\n title: 'Setup VM Environment',\n inputSchema: z.looseObject({}),\n }),\n nativeName: 'setupVmEnvironmentToolCall',\n toolUseKind: 'bash',\n },\n replaceEnv: {\n ...tool({\n title: 'Replace Environment',\n inputSchema: z.looseObject({}),\n }),\n nativeName: 'replaceEnvToolCall',\n toolUseKind: 'bash',\n },\n startGrindExecution: {\n ...tool({\n title: 'Start Grind Execution',\n inputSchema: z.looseObject({}),\n }),\n nativeName: 'startGrindExecutionToolCall',\n toolUseKind: 'bash',\n },\n startGrindPlanning: {\n ...tool({\n title: 'Start Grind Planning',\n inputSchema: z.looseObject({}),\n }),\n nativeName: 'startGrindPlanningToolCall',\n toolUseKind: 'readonly',\n },\n webFetch: {\n ...tool({\n title: 'Web Fetch',\n inputSchema: z.looseObject({ url: z.string() }),\n }),\n nativeName: 'webFetchToolCall',\n toolUseKind: 'readonly',\n },\n reportBugfixResults: {\n ...tool({\n title: 'Report Bugfix Results',\n inputSchema: z.looseObject({}),\n }),\n nativeName: 'reportBugfixResultsToolCall',\n },\n} as const satisfies Record<string, HarnessV1BuiltinTool<any, any>>;\n\nexport function createCursor(\n settings: CursorHarnessSettings = {},\n): HarnessV1<typeof CURSOR_BUILTIN_TOOLS> {\n const clientAppSegments = CURSOR_CLIENT_APP.split('/');\n const clientAppVersion = clientAppSegments.pop()!;\n\n if (settings.auth === 'direct' || settings.auth === 'ai-gateway') {\n warnCursorAuthenticationConfiguration({ auth: settings.auth });\n }\n\n return createACP({\n credentialForwarding: settings.credentialForwarding,\n modelId: settings.model,\n port: settings.port,\n portEndpoint: settings.portEndpoint,\n startupTimeoutMs: settings.startupTimeoutMs,\n mcpServers: settings.mcpServers,\n isMcpToolCall: toolCall => {\n const rawInput = toolCall.rawInput;\n return (\n isRecord(rawInput) &&\n typeof rawInput.providerIdentifier === 'string' &&\n typeof rawInput.toolName === 'string' &&\n isRecord(rawInput.args)\n );\n },\n mintBridgeToken: settings.mintBridgeToken,\n version: 'v1',\n harnessId: 'cursor',\n builtinTools: CURSOR_BUILTIN_TOOLS,\n clientApp: {\n name: clientAppSegments.join('/'),\n version: clientAppVersion,\n },\n source: {\n type: 'install-command',\n command: 'curl https://cursor.com/install -fsS | bash',\n },\n executable: 'agent',\n args: ['--disable-auto-update', 'acp'],\n credentialEnv: ['CURSOR_API_KEY'],\n credentialBrokering: ({ env, sandboxEnv }) => {\n if (!env.CURSOR_API_KEY || !sandboxEnv?.CURSOR_API_KEY) return [];\n return [\n {\n match: {\n host: 'api2.cursor.sh',\n path: { exact: '/auth/exchange_user_api_key' },\n method: ['POST'],\n headers: [\n {\n key: { exact: 'Authorization' },\n value: {\n exact: `Bearer ${sandboxEnv.CURSOR_API_KEY}`,\n },\n },\n ],\n },\n transform: {\n headers: {\n Authorization: `Bearer ${env.CURSOR_API_KEY}`,\n },\n },\n },\n ];\n },\n });\n}\n\nfunction warnCursorAuthenticationConfiguration({\n auth,\n}: {\n auth: Exclude<ACPProviderAuthenticationMode, 'auto'>;\n}): void {\n const detail =\n auth === 'ai-gateway'\n ? \"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.\"\n : 'Configure Cursor to use its direct model-provider routing.';\n console.warn(\n `[cursor] auth: ${JSON.stringify(auth)} cannot configure Cursor provider authentication. ${detail} CURSOR_API_KEY is still required for Cursor CLI authentication.`,\n );\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return value != null && typeof value === 'object' && !Array.isArray(value);\n}\n","declare const __PACKAGE_VERSION__: string | undefined;\nexport const VERSION: string =\n typeof __PACKAGE_VERSION__ !== 'undefined'\n ? __PACKAGE_VERSION__\n : '0.0.0-test';\n","import { createCursor } from './cursor-harness';\n\n/**\n * Default Cursor harness instance. Equivalent to `createCursor()`.\n */\nexport const cursor = createCursor();\n\nexport { createCursor } from './cursor-harness';\nexport type { CursorHarnessSettings } from './cursor-harness';\nexport { VERSION } from './version';\n"],"mappings":";AAAA;AAAA,EACE;AAAA,OAKK;AACP;AAAA,EACE;AAAA,OAEK;AACP,SAAS,YAAY;AACrB,SAAS,SAAS;;;ACXX,IAAM,UACX,OACI,UACA;;;ADWN,IAAM,oBAAoB,yBAAyB,OAAO;AAiD1D,IAAM,uBAAuB;AAAA,EAC3B,MAAM;AAAA,IACJ,GAAG,WAAW,QAAQ;AAAA,MACpB,YAAY;AAAA,MACZ,aAAa;AAAA,MACb,aAAa,EAAE,YAAY,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC;AAAA,IACpD,CAAC;AAAA,IACD,OAAO;AAAA,EACT;AAAA,EACA,QAAQ;AAAA,IACN,GAAG,KAAK;AAAA,MACN,OAAO;AAAA,MACP,aAAa,EAAE,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;AAAA,IACjD,CAAC;AAAA,IACD,YAAY;AAAA,IACZ,aAAa;AAAA,EACf;AAAA,EACA,MAAM;AAAA,IACJ,GAAG,WAAW,QAAQ;AAAA,MACpB,YAAY;AAAA,MACZ,aAAa;AAAA,MACb,aAAa,EAAE,YAAY,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC;AAAA,IACpD,CAAC;AAAA,IACD,OAAO;AAAA,EACT;AAAA,EACA,MAAM;AAAA,IACJ,GAAG,WAAW,QAAQ;AAAA,MACpB,YAAY;AAAA,MACZ,aAAa;AAAA,MACb,aAAa,EAAE,YAAY;AAAA,QACzB,SAAS,EAAE,OAAO;AAAA,QAClB,MAAM,EAAE,OAAO,EAAE,SAAS;AAAA,MAC5B,CAAC;AAAA,IACH,CAAC;AAAA,IACD,OAAO;AAAA,EACT;AAAA,EACA,MAAM;AAAA,IACJ,G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,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF,CAAC;AACH;AAEA,SAAS,sCAAsC;AAAA,EAC7C;AACF,GAES;AACP,QAAM,SACJ,SAAS,eACL,2IACA;AACN,UAAQ;AAAA,IACN,kBAAkB,KAAK,UAAU,IAAI,CAAC,qDAAqD,MAAM;AAAA,EACnG;AACF;AAEA,SAAS,SAAS,OAAkD;AAClE,SAAO,SAAS,QAAQ,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,KAAK;AAC3E;;;AE3bO,IAAM,SAAS,aAAa;","names":[]}
package/package.json CHANGED
@@ -1,18 +1,74 @@
1
1
  {
2
2
  "name": "@ai-sdk/harness-cursor",
3
- "version": "0.0.0",
4
- "description": "AI SDK harness adapter for Cursor",
5
- "license": "Apache-2.0",
3
+ "version": "1.0.3",
6
4
  "type": "module",
7
- "main": "./index.js",
8
- "exports": {
9
- ".": "./index.js"
10
- },
5
+ "license": "Apache-2.0",
6
+ "sideEffects": false,
7
+ "main": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "source": "./src/index.ts",
11
10
  "files": [
12
- "index.js",
11
+ "dist/**/*",
12
+ "src",
13
+ "!src/**/*.test.ts",
14
+ "!src/**/*.test-d.ts",
15
+ "!src/**/__snapshots__",
16
+ "!src/**/__fixtures__",
17
+ "CHANGELOG.md",
13
18
  "README.md"
14
19
  ],
20
+ "exports": {
21
+ "./package.json": "./package.json",
22
+ ".": {
23
+ "types": "./dist/index.d.ts",
24
+ "import": "./dist/index.js",
25
+ "default": "./dist/index.js"
26
+ }
27
+ },
28
+ "dependencies": {
29
+ "@ai-sdk/harness": "1.0.90",
30
+ "@ai-sdk/harness-acp": "1.0.28",
31
+ "@ai-sdk/provider-utils": "5.0.32"
32
+ },
33
+ "peerDependencies": {
34
+ "zod": "^3.25.76 || ^4.1.8"
35
+ },
36
+ "devDependencies": {
37
+ "@types/node": "22.19.19",
38
+ "@vercel/ai-tsconfig": "0.0.0",
39
+ "tsup": "^8.5.1",
40
+ "typescript": "5.8.3",
41
+ "zod": "3.25.76"
42
+ },
43
+ "engines": {
44
+ "node": ">=22"
45
+ },
15
46
  "publishConfig": {
16
- "access": "public"
47
+ "access": "public",
48
+ "provenance": true
49
+ },
50
+ "homepage": "https://ai-sdk.dev/docs",
51
+ "repository": {
52
+ "type": "git",
53
+ "url": "https://github.com/vercel/ai",
54
+ "directory": "packages/harness-cursor"
55
+ },
56
+ "bugs": {
57
+ "url": "https://github.com/vercel/ai/issues"
58
+ },
59
+ "keywords": [
60
+ "ai",
61
+ "harness",
62
+ "acp",
63
+ "cursor"
64
+ ],
65
+ "scripts": {
66
+ "build": "pnpm clean && tsup --tsconfig tsconfig.build.json",
67
+ "build:watch": "pnpm clean && tsup --watch",
68
+ "clean": "del-cli dist *.tsbuildinfo",
69
+ "type-check": "tsc --build",
70
+ "test": "pnpm test:node",
71
+ "test:watch": "vitest --config vitest.node.config.js",
72
+ "test:node": "vitest --config vitest.node.config.js --run"
17
73
  }
18
- }
74
+ }