Skip to content

Commit 901f62f

Browse files
committed
fix various broken docs links, neo4j param validation
1 parent 52b9d51 commit 901f62f

9 files changed

Lines changed: 88 additions & 47 deletions

File tree

apps/sim/app/api/tools/neo4j/query/route.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,13 @@ export async function POST(request: NextRequest) {
6464
session = driver.session({ database: params.database })
6565

6666
let finalQuery = params.cypherQuery.trim()
67+
const finalParameters = { ...params.parameters }
6768
if (params.limit && !/\bLIMIT\s+\d+/i.test(finalQuery)) {
68-
finalQuery = `${finalQuery} LIMIT ${params.limit}`
69+
finalQuery = `${finalQuery} LIMIT $limitValue`
70+
finalParameters.limitValue = params.limit
6971
}
7072

71-
const result = await session.run(finalQuery, params.parameters)
73+
const result = await session.run(finalQuery, finalParameters)
7274

7375
const records = result.records.map((record) => {
7476
const obj: Record<string, unknown> = {}

apps/sim/blocks/blocks/mcp.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export const McpBlock: BlockConfig<McpResponse> = {
1313
description: 'Execute tools from Model Context Protocol (MCP) servers',
1414
longDescription:
1515
'Integrate MCP into the workflow. Can execute tools from MCP servers. Requires MCP servers in workspace settings.',
16-
docsLink: 'https://docs.sim.ai/tools/mcp',
16+
docsLink: 'https://docs.sim.ai/mcp',
1717
category: 'tools',
1818
bgColor: '#181C1E',
1919
icon: ServerIcon,

apps/sim/blocks/blocks/memory.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export const MemoryBlock: BlockConfig = {
3131
value: () => 'add',
3232
},
3333
{
34-
id: 'conversationId',
34+
id: 'id',
3535
title: 'Conversation ID',
3636
type: 'short-input',
3737
placeholder: 'Enter conversation ID (e.g., user-123)',
@@ -53,7 +53,7 @@ export const MemoryBlock: BlockConfig = {
5353
required: false,
5454
},
5555
{
56-
id: 'conversationId',
56+
id: 'id',
5757
title: 'Conversation ID',
5858
type: 'short-input',
5959
placeholder: 'Enter conversation ID (e.g., user-123)',
@@ -86,7 +86,7 @@ export const MemoryBlock: BlockConfig = {
8686
required: false,
8787
},
8888
{
89-
id: 'conversationId',
89+
id: 'id',
9090
title: 'Conversation ID',
9191
type: 'short-input',
9292
placeholder: 'Enter conversation ID (e.g., user-123)',
@@ -171,8 +171,10 @@ export const MemoryBlock: BlockConfig = {
171171
errors.push('Operation is required')
172172
}
173173

174+
const conversationId = params.id || params.conversationId
175+
174176
if (params.operation === 'add') {
175-
if (!params.conversationId) {
177+
if (!conversationId) {
176178
errors.push('Conversation ID is required for add operation')
177179
}
178180
if (!params.role) {
@@ -184,9 +186,9 @@ export const MemoryBlock: BlockConfig = {
184186
}
185187

186188
if (params.operation === 'get' || params.operation === 'delete') {
187-
if (!params.conversationId && !params.blockId && !params.blockName) {
189+
if (!conversationId && !params.blockId && !params.blockName) {
188190
errors.push(
189-
`At least one of conversationId, blockId, or blockName is required for ${params.operation} operation`
191+
`At least one of ID, blockId, or blockName is required for ${params.operation} operation`
190192
)
191193
}
192194
}
@@ -200,7 +202,7 @@ export const MemoryBlock: BlockConfig = {
200202
if (params.operation === 'add') {
201203
const result: Record<string, any> = {
202204
...baseResult,
203-
conversationId: params.conversationId,
205+
conversationId: conversationId,
204206
role: params.role,
205207
content: params.content,
206208
}
@@ -213,15 +215,15 @@ export const MemoryBlock: BlockConfig = {
213215

214216
if (params.operation === 'get') {
215217
const result: Record<string, any> = { ...baseResult }
216-
if (params.conversationId) result.conversationId = params.conversationId
218+
if (conversationId) result.conversationId = conversationId
217219
if (params.blockId) result.blockId = params.blockId
218220
if (params.blockName) result.blockName = params.blockName
219221
return result
220222
}
221223

222224
if (params.operation === 'delete') {
223225
const result: Record<string, any> = { ...baseResult }
224-
if (params.conversationId) result.conversationId = params.conversationId
226+
if (conversationId) result.conversationId = conversationId
225227
if (params.blockId) result.blockId = params.blockId
226228
if (params.blockName) result.blockName = params.blockName
227229
return result

apps/sim/blocks/blocks/schedule.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export const ScheduleBlock: BlockConfig = {
1010
triggerAllowed: true,
1111
name: 'Schedule',
1212
description: 'Trigger workflow execution on a schedule',
13+
docsLink: 'https://docs.sim.ai/triggers/schedule',
1314
longDescription:
1415
'Integrate Schedule into the workflow. Can trigger a workflow on a schedule configuration.',
1516
bestPractices: `

apps/sim/blocks/blocks/webhook.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export const WebhookBlock: BlockConfig = {
4141
category: 'triggers',
4242
icon: WebhookIcon,
4343
bgColor: '#10B981', // Green color for triggers
44+
docsLink: 'https://docs.sim.ai/triggers/webhook',
4445
triggerAllowed: true,
4546
hideFromToolbar: true, // Hidden for backwards compatibility - use generic webhook trigger instead
4647

apps/sim/tools/memory/add.ts

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,16 @@ export const memoryAddTool: ToolConfig<any, MemoryResponse> = {
1111
params: {
1212
conversationId: {
1313
type: 'string',
14-
required: true,
14+
required: false,
1515
description:
1616
'Conversation identifier (e.g., user-123, session-abc). If a memory with this conversationId already exists for this block, the new message will be appended to it.',
1717
},
18+
id: {
19+
type: 'string',
20+
required: false,
21+
description:
22+
'Legacy parameter for conversation identifier. Use conversationId instead. Provided for backwards compatibility.',
23+
},
1824
role: {
1925
type: 'string',
2026
required: true,
@@ -29,7 +35,7 @@ export const memoryAddTool: ToolConfig<any, MemoryResponse> = {
2935
type: 'string',
3036
required: false,
3137
description:
32-
'Optional block ID. If not provided, uses the current block ID from execution context.',
38+
'Optional block ID. If not provided, uses the current block ID from execution context, or defaults to "default".',
3339
},
3440
},
3541

@@ -57,30 +63,20 @@ export const memoryAddTool: ToolConfig<any, MemoryResponse> = {
5763
}
5864
}
5965

60-
const blockId = params.blockId || contextBlockId
61-
if (!blockId) {
62-
return {
63-
_errorResponse: {
64-
status: 400,
65-
data: {
66-
success: false,
67-
error: {
68-
message:
69-
'blockId is required. Either provide it as a parameter or ensure it is available in execution context.',
70-
},
71-
},
72-
},
73-
}
74-
}
66+
// Use 'id' as fallback for 'conversationId' for backwards compatibility
67+
const conversationId = params.conversationId || params.id
68+
69+
// Default blockId to 'default' if not provided in params or context
70+
const blockId = params.blockId || contextBlockId || 'default'
7571

76-
if (!params.conversationId || params.conversationId.trim() === '') {
72+
if (!conversationId || conversationId.trim() === '') {
7773
return {
7874
_errorResponse: {
7975
status: 400,
8076
data: {
8177
success: false,
8278
error: {
83-
message: 'conversationId is required',
79+
message: 'conversationId or id is required',
8480
},
8581
},
8682
},
@@ -101,7 +97,7 @@ export const memoryAddTool: ToolConfig<any, MemoryResponse> = {
10197
}
10298
}
10399

104-
const key = buildMemoryKey(params.conversationId, blockId)
100+
const key = buildMemoryKey(conversationId, blockId)
105101

106102
const body: Record<string, any> = {
107103
key,

apps/sim/tools/memory/delete.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ export const memoryDeleteTool: ToolConfig<any, MemoryResponse> = {
1515
description:
1616
'Conversation identifier (e.g., user-123, session-abc). If provided alone, deletes all memories for this conversation across all blocks.',
1717
},
18+
id: {
19+
type: 'string',
20+
required: false,
21+
description:
22+
'Legacy parameter for conversation identifier. Use conversationId instead. Provided for backwards compatibility.',
23+
},
1824
blockId: {
1925
type: 'string',
2026
required: false,
@@ -47,14 +53,18 @@ export const memoryDeleteTool: ToolConfig<any, MemoryResponse> = {
4753
}
4854
}
4955

50-
if (!params.conversationId && !params.blockId && !params.blockName) {
56+
// Use 'id' as fallback for 'conversationId' for backwards compatibility
57+
const conversationId = params.conversationId || params.id
58+
59+
if (!conversationId && !params.blockId && !params.blockName) {
5160
return {
5261
_errorResponse: {
5362
status: 400,
5463
data: {
5564
success: false,
5665
error: {
57-
message: 'At least one of conversationId, blockId, or blockName must be provided',
66+
message:
67+
'At least one of conversationId, id, blockId, or blockName must be provided',
5868
},
5969
},
6070
},
@@ -64,8 +74,8 @@ export const memoryDeleteTool: ToolConfig<any, MemoryResponse> = {
6474
const url = new URL('/api/memory', 'http://dummy')
6575
url.searchParams.set('workflowId', workflowId)
6676

67-
if (params.conversationId) {
68-
url.searchParams.set('conversationId', params.conversationId)
77+
if (conversationId) {
78+
url.searchParams.set('conversationId', conversationId)
6979
}
7080
if (params.blockId) {
7181
url.searchParams.set('blockId', params.blockId)

apps/sim/tools/memory/get.ts

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ export const memoryGetTool: ToolConfig<any, MemoryResponse> = {
1616
description:
1717
'Conversation identifier (e.g., user-123, session-abc). If provided alone, returns all memories for this conversation across all blocks.',
1818
},
19+
id: {
20+
type: 'string',
21+
required: false,
22+
description:
23+
'Legacy parameter for conversation identifier. Use conversationId instead. Provided for backwards compatibility.',
24+
},
1925
blockId: {
2026
type: 'string',
2127
required: false,
@@ -48,14 +54,18 @@ export const memoryGetTool: ToolConfig<any, MemoryResponse> = {
4854
}
4955
}
5056

51-
if (!params.conversationId && !params.blockId && !params.blockName) {
57+
// Use 'id' as fallback for 'conversationId' for backwards compatibility
58+
const conversationId = params.conversationId || params.id
59+
60+
if (!conversationId && !params.blockId && !params.blockName) {
5261
return {
5362
_errorResponse: {
5463
status: 400,
5564
data: {
5665
success: false,
5766
error: {
58-
message: 'At least one of conversationId, blockId, or blockName must be provided',
67+
message:
68+
'At least one of conversationId, id, blockId, or blockName must be provided',
5969
},
6070
},
6171
},
@@ -64,10 +74,11 @@ export const memoryGetTool: ToolConfig<any, MemoryResponse> = {
6474

6575
let query = ''
6676

67-
if (params.conversationId && params.blockId) {
68-
query = buildMemoryKey(params.conversationId, params.blockId)
69-
} else if (params.conversationId) {
70-
query = `${params.conversationId}:`
77+
if (conversationId && params.blockId) {
78+
query = buildMemoryKey(conversationId, params.blockId)
79+
} else if (conversationId) {
80+
// Also check for legacy format (conversationId without blockId)
81+
query = `${conversationId}:`
7182
} else if (params.blockId) {
7283
query = `:${params.blockId}`
7384
}

apps/sim/tools/memory/helpers.ts

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,36 @@
11
/**
22
* Parse memory key into conversationId and blockId
3-
* Key format: conversationId:blockId
3+
* Supports two formats:
4+
* - New format: conversationId:blockId (splits on LAST colon to handle IDs with colons)
5+
* - Legacy format: id (without colon, treated as conversationId with blockId='default')
46
* @param key The memory key to parse
57
* @returns Object with conversationId and blockId, or null if invalid
68
*/
79
export function parseMemoryKey(key: string): { conversationId: string; blockId: string } | null {
8-
const parts = key.split(':')
9-
if (parts.length !== 2) {
10+
if (!key) {
1011
return null
1112
}
1213

14+
const lastColonIndex = key.lastIndexOf(':')
15+
16+
// Legacy format: no colon found
17+
if (lastColonIndex === -1) {
18+
return {
19+
conversationId: key,
20+
blockId: 'default',
21+
}
22+
}
23+
24+
// Invalid: colon at start or end
25+
if (lastColonIndex === 0 || lastColonIndex === key.length - 1) {
26+
return null
27+
}
28+
29+
// New format: split on last colon to handle IDs with colons
30+
// This allows conversationIds like "user:123" to work correctly
1331
return {
14-
conversationId: parts[0],
15-
blockId: parts[1],
32+
conversationId: key.substring(0, lastColonIndex),
33+
blockId: key.substring(lastColonIndex + 1),
1634
}
1735
}
1836

0 commit comments

Comments
 (0)