Skip to content

Commit 62efcee

Browse files
authored
fix(integrations): validate cursor, devin, vercel (#10170)
* fix(integrations): validate cursor, devin, vercel * fix(integrations): keep the post-update timestamp and mark absent artifact fields nullable * fix(integrations): name the created vercel project in the update error and describe cursor artifact aliases * fix(integrations): fail vercel create project when the node version update throws * chore(integrations): regenerate tool metadata after rebase
1 parent a24b401 commit 62efcee

27 files changed

Lines changed: 361 additions & 39 deletions

‎apps/docs/content/docs/integrations/cursor.mdx‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ Permanently delete a cloud agent. Returns API-aligned fields only.
182182

183183
### Cursor List Artifacts
184184

185-
List generated artifact files for a cloud agent. Returns API-aligned fields only.
185+
List generated artifact files for a cloud agent. Returns the API fields plus `path` and `size` aliases.
186186

187187
<ReferenceDetails>
188188

@@ -197,8 +197,11 @@ List generated artifact files for a cloud agent. Returns API-aligned fields only
197197
| Parameter | Type | Description |
198198
| --------- | ---- | ----------- |
199199
| `artifacts` | array | List of artifact files |
200-
| ↳ `path` | string | Artifact file path |
201-
| ↳ `size` | number | File size in bytes |
200+
| ↳ `absolutePath` | string | Absolute artifact path on the agent filesystem; pass it to Download Artifact |
201+
| ↳ `sizeBytes` | number | File size in bytes |
202+
| ↳ `updatedAt` | string | ISO 8601 time the artifact was last updated |
203+
| ↳ `path` | string | Artifact file path \(same as absolutePath\) |
204+
| ↳ `size` | number | File size in bytes \(same as sizeBytes\) |
202205

203206
</ReferenceDetails>
204207

@@ -213,7 +216,7 @@ Download a generated artifact file from a cloud agent. Returns the file for exec
213216
| Parameter | Type | Required | Description |
214217
| --------- | ---- | -------- | ----------- |
215218
| `agentId` | string | Yes | Unique identifier for the cloud agent \(e.g., bc_abc123\) |
216-
| `path` | string | Yes | Absolute path of the artifact to download \(e.g., /src/index.ts\) |
219+
| `path` | string | Yes | Absolute artifact path from List Artifacts \(e.g., /opt/cursor/artifacts/screenshot.png\) |
217220

218221
#### Output
219222

‎apps/sim/blocks/blocks/cursor.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,11 @@ export const CursorV2Block: BlockConfig = {
302302
agents: { type: 'json', description: 'Array of agent objects (list operation)' },
303303
nextCursor: { type: 'string', description: 'Pagination cursor (list operation)' },
304304
messages: { type: 'json', description: 'Conversation messages (get conversation operation)' },
305-
artifacts: { type: 'json', description: 'List of artifact files (list artifacts operation)' },
305+
artifacts: {
306+
type: 'json',
307+
description:
308+
'Artifact files [{absolutePath, sizeBytes, updatedAt, path, size}] (list artifacts operation)',
309+
},
306310
file: { type: 'file', description: 'Downloaded artifact file (download artifact operation)' },
307311
models: { type: 'json', description: 'Available model names (list models operation)' },
308312
repositories: {

‎apps/sim/tools/cursor/add_followup.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
import type { AddFollowupParams, AddFollowupResponse } from '@/tools/cursor/types'
66
import { CURSOR_CREDENTIAL_OAUTH } from '@/tools/shared/saved-credentials'
77
import type { ToolConfig } from '@/tools/types'
8+
import { safeUrlPathSegment } from '@/tools/url-path'
89

910
const addFollowupBase = {
1011
params: {
@@ -46,7 +47,7 @@ const addFollowupBase = {
4647
),
4748
},
4849
url: (params: AddFollowupParams) =>
49-
`https://api.cursor.com/v0/agents/${params.agentId.trim()}/followup`,
50+
`https://api.cursor.com/v0/agents/${safeUrlPathSegment(params.agentId, 'agentId')}/followup`,
5051
method: 'POST',
5152
headers: (params: AddFollowupParams) => ({
5253
'Content-Type': 'application/json',
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import { describe, expect, it } from 'vitest'
2+
import { deleteAgentV2Tool } from '@/tools/cursor/delete_agent'
3+
import { listArtifactsTool, listArtifactsV2Tool } from '@/tools/cursor/list_artifacts'
4+
5+
const artifactsResponse = () =>
6+
new Response(
7+
JSON.stringify({
8+
artifacts: [
9+
{
10+
absolutePath: '/opt/cursor/artifacts/screenshot.png',
11+
sizeBytes: 12345,
12+
updatedAt: '2024-01-15T11:02:00.000Z',
13+
},
14+
],
15+
})
16+
)
17+
18+
const expectedArtifact = {
19+
absolutePath: '/opt/cursor/artifacts/screenshot.png',
20+
sizeBytes: 12345,
21+
updatedAt: '2024-01-15T11:02:00.000Z',
22+
path: '/opt/cursor/artifacts/screenshot.png',
23+
size: 12345,
24+
}
25+
26+
describe('cursor list artifacts', () => {
27+
it('fills path and size from the absolutePath and sizeBytes Cursor returns', async () => {
28+
const v2 = await listArtifactsV2Tool.transformResponse?.(artifactsResponse())
29+
expect(v2?.output.artifacts).toEqual([expectedArtifact])
30+
31+
const v1 = await listArtifactsTool.transformResponse?.(artifactsResponse())
32+
expect(v1?.output.metadata.artifacts).toEqual([expectedArtifact])
33+
})
34+
})
35+
36+
describe('cursor agent path segments', () => {
37+
const deleteUrl = (agentId: string) => {
38+
const url = deleteAgentV2Tool.request.url
39+
if (typeof url !== 'function') throw new Error('expected a url builder')
40+
return url({ apiKey: 'k', agentId })
41+
}
42+
43+
it.each(['..', '.', 'bc_1/../me'])(
44+
'rejects agent id %j before a DELETE can leave the agent route',
45+
(id) => {
46+
expect(() => deleteUrl(id)).toThrow(/agentId/)
47+
}
48+
)
49+
50+
it('leaves ordinary ids unchanged', () => {
51+
expect(deleteUrl(' bc_abc123 ')).toBe('https://api.cursor.com/v0/agents/bc_abc123')
52+
})
53+
})

‎apps/sim/tools/cursor/delete_agent.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { DeleteAgentParams, DeleteAgentResponse } from '@/tools/cursor/types'
22
import { CURSOR_CREDENTIAL_OAUTH } from '@/tools/shared/saved-credentials'
33
import type { ToolConfig } from '@/tools/types'
4+
import { safeUrlPathSegment } from '@/tools/url-path'
45

56
const deleteAgentBase = {
67
params: {
@@ -18,7 +19,8 @@ const deleteAgentBase = {
1819
},
1920
},
2021
request: {
21-
url: (params: DeleteAgentParams) => `https://api.cursor.com/v0/agents/${params.agentId.trim()}`,
22+
url: (params: DeleteAgentParams) =>
23+
`https://api.cursor.com/v0/agents/${safeUrlPathSegment(params.agentId, 'agentId')}`,
2224
method: 'DELETE',
2325
headers: (params: DeleteAgentParams) => ({
2426
Authorization: `Basic ${Buffer.from(`${params.apiKey}:`).toString('base64')}`,

‎apps/sim/tools/cursor/download_artifact.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ const downloadArtifactBase = {
2424
type: 'string',
2525
required: true,
2626
visibility: 'user-or-llm',
27-
description: 'Absolute path of the artifact to download (e.g., /src/index.ts)',
27+
description:
28+
'Absolute artifact path from List Artifacts (e.g., /opt/cursor/artifacts/screenshot.png)',
2829
},
2930
},
3031
operation: {

‎apps/sim/tools/cursor/get_agent.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { GetAgentParams, GetAgentResponse } from '@/tools/cursor/types'
22
import { CURSOR_CREDENTIAL_OAUTH } from '@/tools/shared/saved-credentials'
33
import type { ToolConfig } from '@/tools/types'
4+
import { safeUrlPathSegment } from '@/tools/url-path'
45

56
const getAgentBase = {
67
params: {
@@ -18,7 +19,8 @@ const getAgentBase = {
1819
},
1920
},
2021
request: {
21-
url: (params: GetAgentParams) => `https://api.cursor.com/v0/agents/${params.agentId.trim()}`,
22+
url: (params: GetAgentParams) =>
23+
`https://api.cursor.com/v0/agents/${safeUrlPathSegment(params.agentId, 'agentId')}`,
2224
method: 'GET',
2325
headers: (params: GetAgentParams) => ({
2426
Authorization: `Basic ${Buffer.from(`${params.apiKey}:`).toString('base64')}`,

‎apps/sim/tools/cursor/get_conversation.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { GetConversationParams, GetConversationResponse } from '@/tools/cursor/types'
22
import { CURSOR_CREDENTIAL_OAUTH } from '@/tools/shared/saved-credentials'
33
import type { ToolConfig } from '@/tools/types'
4+
import { safeUrlPathSegment } from '@/tools/url-path'
45

56
const getConversationBase = {
67
params: {
@@ -19,7 +20,7 @@ const getConversationBase = {
1920
},
2021
request: {
2122
url: (params: GetConversationParams) =>
22-
`https://api.cursor.com/v0/agents/${params.agentId.trim()}/conversation`,
23+
`https://api.cursor.com/v0/agents/${safeUrlPathSegment(params.agentId, 'agentId')}/conversation`,
2324
method: 'GET',
2425
headers: (params: GetConversationParams) => ({
2526
Authorization: `Basic ${Buffer.from(`${params.apiKey}:`).toString('base64')}`,

‎apps/sim/tools/cursor/list_artifacts.ts‎

Lines changed: 77 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,27 @@
1-
import type { ListArtifactsParams, ListArtifactsResponse } from '@/tools/cursor/types'
1+
import type {
2+
ArtifactMetadata,
3+
ListArtifactsParams,
4+
ListArtifactsResponse,
5+
} from '@/tools/cursor/types'
26
import { CURSOR_CREDENTIAL_OAUTH } from '@/tools/shared/saved-credentials'
37
import type { ToolConfig } from '@/tools/types'
8+
import { safeUrlPathSegment } from '@/tools/url-path'
9+
10+
/** Maps Cursor's `{ absolutePath, sizeBytes, updatedAt }` artifacts, also filling the original `path`/`size` names. */
11+
function mapArtifacts(raw: unknown): ArtifactMetadata[] {
12+
if (!Array.isArray(raw)) return []
13+
return raw.map((item: Record<string, unknown> | null) => {
14+
const absolutePath = typeof item?.absolutePath === 'string' ? item.absolutePath : ''
15+
const sizeBytes = typeof item?.sizeBytes === 'number' ? item.sizeBytes : null
16+
return {
17+
absolutePath,
18+
sizeBytes,
19+
updatedAt: typeof item?.updatedAt === 'string' ? item.updatedAt : null,
20+
path: absolutePath,
21+
size: sizeBytes,
22+
}
23+
})
24+
}
425

526
const listArtifactsBase = {
627
params: {
@@ -19,7 +40,7 @@ const listArtifactsBase = {
1940
},
2041
request: {
2142
url: (params: ListArtifactsParams) =>
22-
`https://api.cursor.com/v0/agents/${params.agentId.trim()}/artifacts`,
43+
`https://api.cursor.com/v0/agents/${safeUrlPathSegment(params.agentId, 'agentId')}/artifacts`,
2344
method: 'GET',
2445
headers: (params: ListArtifactsParams) => ({
2546
Authorization: `Basic ${Buffer.from(`${params.apiKey}:`).toString('base64')}`,
@@ -38,7 +59,7 @@ export const listArtifactsTool: ToolConfig<ListArtifactsParams, ListArtifactsRes
3859

3960
transformResponse: async (response) => {
4061
const data = await response.json()
41-
const artifacts = data.artifacts ?? []
62+
const artifacts = mapArtifacts(data.artifacts)
4263

4364
return {
4465
success: true,
@@ -63,8 +84,30 @@ export const listArtifactsTool: ToolConfig<ListArtifactsParams, ListArtifactsRes
6384
items: {
6485
type: 'object',
6586
properties: {
66-
path: { type: 'string', description: 'Artifact file path' },
67-
size: { type: 'number', description: 'File size in bytes', optional: true },
87+
absolutePath: {
88+
type: 'string',
89+
description:
90+
'Absolute artifact path on the agent filesystem; pass it to Download Artifact',
91+
},
92+
sizeBytes: {
93+
type: 'number',
94+
description: 'File size in bytes',
95+
optional: true,
96+
nullable: true,
97+
},
98+
updatedAt: {
99+
type: 'string',
100+
description: 'ISO 8601 time the artifact was last updated',
101+
nullable: true,
102+
optional: true,
103+
},
104+
path: { type: 'string', description: 'Artifact file path (same as absolutePath)' },
105+
size: {
106+
type: 'number',
107+
description: 'File size in bytes (same as sizeBytes)',
108+
nullable: true,
109+
optional: true,
110+
},
68111
},
69112
},
70113
},
@@ -76,26 +119,27 @@ export const listArtifactsTool: ToolConfig<ListArtifactsParams, ListArtifactsRes
76119
interface ListArtifactsV2Response {
77120
success: boolean
78121
output: {
79-
artifacts: Array<{ path: string; size?: number }>
122+
artifacts: ArtifactMetadata[]
80123
}
81124
}
82125

83126
export const listArtifactsV2Tool: ToolConfig<ListArtifactsParams, ListArtifactsV2Response> = {
84127
...listArtifactsBase,
85128
id: 'cursor_list_artifacts_v2',
86129
name: 'Cursor List Artifacts',
87-
description: 'List generated artifact files for a cloud agent. Returns API-aligned fields only.',
130+
description:
131+
'List generated artifact files for a cloud agent. Returns the API fields plus `path` and `size` aliases.',
88132
version: '2.0.0',
89133
oauth: CURSOR_CREDENTIAL_OAUTH,
90134

91135
transformResponse: async (response) => {
92136
const data = await response.json()
93-
const artifacts = data.artifacts ?? []
137+
const artifacts = mapArtifacts(data.artifacts)
94138

95139
return {
96140
success: true,
97141
output: {
98-
artifacts: Array.isArray(artifacts) ? artifacts : [],
142+
artifacts,
99143
},
100144
}
101145
},
@@ -107,8 +151,30 @@ export const listArtifactsV2Tool: ToolConfig<ListArtifactsParams, ListArtifactsV
107151
items: {
108152
type: 'object',
109153
properties: {
110-
path: { type: 'string', description: 'Artifact file path' },
111-
size: { type: 'number', description: 'File size in bytes', optional: true },
154+
absolutePath: {
155+
type: 'string',
156+
description:
157+
'Absolute artifact path on the agent filesystem; pass it to Download Artifact',
158+
},
159+
sizeBytes: {
160+
type: 'number',
161+
description: 'File size in bytes',
162+
optional: true,
163+
nullable: true,
164+
},
165+
updatedAt: {
166+
type: 'string',
167+
description: 'ISO 8601 time the artifact was last updated',
168+
nullable: true,
169+
optional: true,
170+
},
171+
path: { type: 'string', description: 'Artifact file path (same as absolutePath)' },
172+
size: {
173+
type: 'number',
174+
description: 'File size in bytes (same as sizeBytes)',
175+
nullable: true,
176+
optional: true,
177+
},
112178
},
113179
},
114180
},

‎apps/sim/tools/cursor/stop_agent.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { StopAgentParams, StopAgentResponse } from '@/tools/cursor/types'
22
import { CURSOR_CREDENTIAL_OAUTH } from '@/tools/shared/saved-credentials'
33
import type { ToolConfig } from '@/tools/types'
4+
import { safeUrlPathSegment } from '@/tools/url-path'
45

56
const stopAgentBase = {
67
params: {
@@ -19,7 +20,7 @@ const stopAgentBase = {
1920
},
2021
request: {
2122
url: (params: StopAgentParams) =>
22-
`https://api.cursor.com/v0/agents/${params.agentId.trim()}/stop`,
23+
`https://api.cursor.com/v0/agents/${safeUrlPathSegment(params.agentId, 'agentId')}/stop`,
2324
method: 'POST',
2425
headers: (params: StopAgentParams) => ({
2526
Authorization: `Basic ${Buffer.from(`${params.apiKey}:`).toString('base64')}`,

0 commit comments

Comments
 (0)