Skip to content

Commit 9ad6368

Browse files
tonychang04claude
andcommitted
fix(insforge): use correct InsForge API paths
Updated all InsForge tool API endpoints to match the actual backend routes: - Database: /api/database/:tableName (was /rest/v1/:tableName) - Storage: /api/storage/buckets/:bucket/objects/:key - Functions: /functions/:slug - AI Chat: /api/ai/chat/completion - AI Image: /api/ai/image/generation Also updated storage_delete to use single file deletion instead of bulk delete to match InsForge API design. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 48cf5e3 commit 9ad6368

File tree

15 files changed

+45
-43
lines changed

15 files changed

+45
-43
lines changed

apps/sim/tools/insforge/completion.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export const completionTool: ToolConfig<InsForgeCompletionParams, InsForgeComple
4949
request: {
5050
url: (params) => {
5151
const base = params.baseUrl.replace(/\/$/, '')
52-
return `${base}/ai/v1/chat/completions`
52+
return `${base}/api/ai/chat/completion`
5353
},
5454
method: 'POST',
5555
headers: (params) => ({

apps/sim/tools/insforge/delete.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export const deleteTool: ToolConfig<InsForgeDeleteParams, InsForgeDeleteResponse
3737
request: {
3838
url: (params) => {
3939
const base = params.baseUrl.replace(/\/$/, '')
40-
let url = `${base}/rest/v1/${params.table}?select=*`
40+
let url = `${base}/api/database/${params.table}?select=*`
4141

4242
if (params.filter?.trim()) {
4343
url += `&${params.filter.trim()}`

apps/sim/tools/insforge/get_row.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export const getRowTool: ToolConfig<InsForgeGetRowParams, InsForgeGetRowResponse
3737
request: {
3838
url: (params) => {
3939
const base = params.baseUrl.replace(/\/$/, '')
40-
let url = `${base}/rest/v1/${params.table}?select=*`
40+
let url = `${base}/api/database/${params.table}?select=*`
4141

4242
if (params.filter?.trim()) {
4343
url += `&${params.filter.trim()}`

apps/sim/tools/insforge/image_generation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export const imageGenerationTool: ToolConfig<
6161
request: {
6262
url: (params) => {
6363
const base = params.baseUrl.replace(/\/$/, '')
64-
return `${base}/ai/v1/images/generations`
64+
return `${base}/api/ai/image/generation`
6565
},
6666
method: 'POST',
6767
headers: (params) => ({

apps/sim/tools/insforge/insert.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export const insertTool: ToolConfig<InsForgeInsertParams, InsForgeInsertResponse
3737
request: {
3838
url: (params) => {
3939
const base = params.baseUrl.replace(/\/$/, '')
40-
return `${base}/rest/v1/${params.table}?select=*`
40+
return `${base}/api/database/${params.table}?select=*`
4141
},
4242
method: 'POST',
4343
headers: (params) => ({

apps/sim/tools/insforge/invoke.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export const invokeTool: ToolConfig<InsForgeInvokeParams, InsForgeInvokeResponse
3737
request: {
3838
url: (params) => {
3939
const base = params.baseUrl.replace(/\/$/, '')
40-
return `${base}/functions/v1/${params.functionName}`
40+
return `${base}/functions/${params.functionName}`
4141
},
4242
method: 'POST',
4343
headers: (params) => ({

apps/sim/tools/insforge/query.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export const queryTool: ToolConfig<InsForgeQueryParams, InsForgeQueryResponse> =
4949
request: {
5050
url: (params) => {
5151
const base = params.baseUrl.replace(/\/$/, '')
52-
let url = `${base}/rest/v1/${params.table}?select=*`
52+
let url = `${base}/api/database/${params.table}?select=*`
5353

5454
if (params.filter?.trim()) {
5555
url += `&${params.filter.trim()}`

apps/sim/tools/insforge/storage_delete.ts

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export const storageDeleteTool: ToolConfig<
1010
> = {
1111
id: 'insforge_storage_delete',
1212
name: 'InsForge Storage Delete',
13-
description: 'Delete files from an InsForge storage bucket',
13+
description: 'Delete a file from an InsForge storage bucket',
1414
version: '1.0',
1515

1616
params: {
@@ -26,11 +26,11 @@ export const storageDeleteTool: ToolConfig<
2626
visibility: 'user-or-llm',
2727
description: 'The name of the storage bucket',
2828
},
29-
paths: {
30-
type: 'array',
29+
path: {
30+
type: 'string',
3131
required: true,
3232
visibility: 'user-or-llm',
33-
description: 'Array of file paths to delete (e.g., ["folder/file1.jpg", "folder/file2.jpg"])',
33+
description: 'The file path to delete (e.g., "folder/file.jpg")',
3434
},
3535
apiKey: {
3636
type: 'string',
@@ -43,35 +43,36 @@ export const storageDeleteTool: ToolConfig<
4343
request: {
4444
url: (params) => {
4545
const base = params.baseUrl.replace(/\/$/, '')
46-
return `${base}/storage/v1/object/${params.bucket}`
46+
return `${base}/api/storage/buckets/${params.bucket}/objects/${params.path}`
4747
},
4848
method: 'DELETE',
4949
headers: (params) => ({
5050
apikey: params.apiKey,
5151
Authorization: `Bearer ${params.apiKey}`,
52-
'Content-Type': 'application/json',
5352
}),
54-
body: (params) => {
55-
return {
56-
prefixes: params.paths,
57-
}
58-
},
5953
},
6054

6155
transformResponse: async (response: Response) => {
6256
let data
6357
try {
64-
data = await response.json()
58+
const text = await response.text()
59+
if (text?.trim()) {
60+
try {
61+
data = JSON.parse(text)
62+
} catch {
63+
data = { result: text }
64+
}
65+
} else {
66+
data = {}
67+
}
6568
} catch (parseError) {
6669
throw new Error(`Failed to parse InsForge storage delete response: ${parseError}`)
6770
}
6871

69-
const deletedCount = Array.isArray(data) ? data.length : 0
70-
7172
return {
7273
success: true,
7374
output: {
74-
message: `Successfully deleted ${deletedCount} file${deletedCount === 1 ? '' : 's'} from storage`,
75+
message: 'Successfully deleted file from storage',
7576
results: data,
7677
},
7778
error: undefined,
@@ -80,6 +81,6 @@ export const storageDeleteTool: ToolConfig<
8081

8182
outputs: {
8283
message: { type: 'string', description: 'Operation status message' },
83-
results: { type: 'array', description: 'Array of deleted file objects' },
84+
results: { type: 'json', description: 'Delete operation result' },
8485
},
8586
}

apps/sim/tools/insforge/storage_download.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export const storageDownloadTool: ToolConfig<
5252
request: {
5353
url: (params) => {
5454
const base = params.baseUrl.replace(/\/$/, '')
55-
return `${base}/storage/v1/object/${params.bucket}/${params.path}`
55+
return `${base}/api/storage/buckets/${params.bucket}/objects/${params.path}`
5656
},
5757
method: 'GET',
5858
headers: (params) => ({

apps/sim/tools/insforge/storage_list.ts

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -49,31 +49,32 @@ export const storageListTool: ToolConfig<InsForgeStorageListParams, InsForgeStor
4949
request: {
5050
url: (params) => {
5151
const base = params.baseUrl.replace(/\/$/, '')
52-
return `${base}/storage/v1/object/list/${params.bucket}`
53-
},
54-
method: 'POST',
55-
headers: (params) => ({
56-
apikey: params.apiKey,
57-
Authorization: `Bearer ${params.apiKey}`,
58-
'Content-Type': 'application/json',
59-
}),
60-
body: (params) => {
61-
const body: Record<string, unknown> = {}
52+
let url = `${base}/api/storage/buckets/${params.bucket}/objects`
53+
const queryParams: string[] = []
6254

6355
if (params.path) {
64-
body.prefix = params.path
56+
queryParams.push(`prefix=${encodeURIComponent(params.path)}`)
6557
}
6658

6759
if (params.limit) {
68-
body.limit = Number(params.limit)
60+
queryParams.push(`limit=${Number(params.limit)}`)
6961
}
7062

7163
if (params.offset) {
72-
body.offset = Number(params.offset)
64+
queryParams.push(`offset=${Number(params.offset)}`)
7365
}
7466

75-
return body
67+
if (queryParams.length > 0) {
68+
url += `?${queryParams.join('&')}`
69+
}
70+
71+
return url
7672
},
73+
method: 'GET',
74+
headers: (params) => ({
75+
apikey: params.apiKey,
76+
Authorization: `Bearer ${params.apiKey}`,
77+
}),
7778
},
7879

7980
transformResponse: async (response: Response) => {

0 commit comments

Comments
 (0)