Skip to content

Commit 56ede1c

Browse files
authored
improvement(tools): removed transformError, isInternalRoute, directExecution (#928)
* standardized response format for transformError * removed trasnformError, moved error handling to executeTool for all different error formats * remove isInternalRoute, make it implicit in executeTool * removed directExecution, everything on the server nothing on the client * fix supabase * fix(tag-dropdown): fix values for parallel & loop blocks (#929) * fix(search-modal): add parallel and loop blocks to search modal * reordered tool params * update docs
1 parent df16382 commit 56ede1c

File tree

186 files changed

+4541
-7824
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

186 files changed

+4541
-7824
lines changed

.github/CONTRIBUTING.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -416,8 +416,8 @@ In addition, you will need to update the registries:
416416
Your tool should export a constant with a naming convention of `{toolName}Tool`. The tool ID should follow the format `{provider}_{tool_name}`. For example:
417417
418418
```typescript:/apps/sim/tools/pinecone/fetch.ts
419-
import { ToolConfig, ToolResponse } from '../types'
420-
import { PineconeParams, PineconeResponse } from './types'
419+
import { ToolConfig, ToolResponse } from '@/tools/types'
420+
import { PineconeParams, PineconeResponse } from '@/tools/pinecone/types'
421421
422422
export const fetchTool: ToolConfig<PineconeParams, PineconeResponse> = {
423423
id: 'pinecone_fetch', // Follow the {provider}_{tool_name} format
@@ -448,17 +448,14 @@ In addition, you will need to update the registries:
448448
transformResponse: async (response: Response) => {
449449
// Transform response
450450
},
451-
transformError: (error) => {
452-
// Handle errors
453-
},
454451
}
455452
```
456453
457454
6. **Register Your Tool:**
458455
Update the tools registry in `/apps/sim/tools/index.ts` to include your new tool:
459456
460457
```typescript:/apps/sim/tools/index.ts
461-
import { fetchTool, generateEmbeddingsTool, searchTextTool } from './pinecone'
458+
import { fetchTool, generateEmbeddingsTool, searchTextTool } from '/@tools/pinecone'
462459
// ... other imports
463460
464461
export const tools: Record<string, ToolConfig> = {

apps/docs/content/docs/tools/airtable.mdx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,6 @@ Update multiple existing records in an Airtable table
151151
| `baseId` | string | Yes | ID of the Airtable base |
152152
| `tableId` | string | Yes | ID or name of the table |
153153
| `records` | json | Yes | Array of records to update, each with an `id` and a `fields` object |
154-
| `fields` | string | No | No description |
155-
| `fields` | string | No | No description |
156154

157155
#### Output
158156

apps/docs/content/docs/tools/browser_use.mdx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,10 @@ Runs a browser automation task using BrowserUse
8282

8383
| Parameter | Type | Description |
8484
| --------- | ---- | ----------- |
85-
| `success` | boolean | Operation success status |
86-
| `output` | json | Browser automation task results including task ID, success status, output data, and execution steps |
87-
| `error` | string | Error message if the operation failed |
85+
| `id` | string | Task execution identifier |
86+
| `success` | boolean | Task completion status |
87+
| `output` | json | Task output data |
88+
| `steps` | json | Execution steps taken |
8889

8990

9091

apps/docs/content/docs/tools/elevenlabs.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ Convert TTS using ElevenLabs voices
6262

6363
| Parameter | Type | Description |
6464
| --------- | ---- | ----------- |
65-
| `audioUrl` | string | Generated audio URL |
65+
| `audioUrl` | string | The URL of the generated audio |
6666

6767

6868

apps/docs/content/docs/tools/file.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ Parse one or more uploaded files or files from URLs (text, PDF, CSV, images, etc
7171

7272
| Parameter | Type | Description |
7373
| --------- | ---- | ----------- |
74-
| `files` | json | Array of parsed file objects with content, metadata, and file properties |
75-
| `combinedContent` | string | All file contents merged into a single text string |
74+
| `files` | array | Array of parsed files |
75+
| `combinedContent` | string | Combined content of all parsed files |
7676

7777

7878

apps/docs/content/docs/tools/supabase.mdx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ Query data from a Supabase table
101101

102102
| Parameter | Type | Description |
103103
| --------- | ---- | ----------- |
104-
| `success` | boolean | Operation success status |
105-
| `output` | object | Query operation results |
104+
| `message` | string | Operation status message |
105+
| `results` | array | Array of records returned from the query |
106106

107107
### `supabase_insert`
108108

@@ -121,8 +121,8 @@ Insert data into a Supabase table
121121

122122
| Parameter | Type | Description |
123123
| --------- | ---- | ----------- |
124-
| `success` | boolean | Operation success status |
125-
| `output` | object | Insert operation results |
124+
| `message` | string | Operation status message |
125+
| `results` | array | Array of inserted records |
126126

127127
### `supabase_get_row`
128128

@@ -141,8 +141,8 @@ Get a single row from a Supabase table based on filter criteria
141141

142142
| Parameter | Type | Description |
143143
| --------- | ---- | ----------- |
144-
| `success` | boolean | Operation success status |
145-
| `output` | object | Get row operation results |
144+
| `message` | string | Operation status message |
145+
| `results` | object | The row data if found, null if not found |
146146

147147
### `supabase_update`
148148

@@ -162,8 +162,8 @@ Update rows in a Supabase table based on filter criteria
162162

163163
| Parameter | Type | Description |
164164
| --------- | ---- | ----------- |
165-
| `success` | boolean | Operation success status |
166-
| `output` | object | Update operation results |
165+
| `message` | string | Operation status message |
166+
| `results` | array | Array of updated records |
167167

168168
### `supabase_delete`
169169

@@ -182,8 +182,8 @@ Delete rows from a Supabase table based on filter criteria
182182

183183
| Parameter | Type | Description |
184184
| --------- | ---- | ----------- |
185-
| `success` | boolean | Operation success status |
186-
| `output` | object | Delete operation results |
185+
| `message` | string | Operation status message |
186+
| `results` | array | Array of deleted records |
187187

188188

189189

apps/sim/app/api/proxy/route.ts

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -235,42 +235,8 @@ export async function POST(request: Request) {
235235
error: result.error || 'Unknown error',
236236
})
237237

238-
if (tool.transformError) {
239-
try {
240-
const errorResult = tool.transformError(result)
241-
242-
// Handle both string and Promise return types
243-
if (typeof errorResult === 'string') {
244-
throw new Error(errorResult)
245-
}
246-
// It's a Promise, await it
247-
const transformedError = await errorResult
248-
// If it's a string or has an error property, use it
249-
if (typeof transformedError === 'string') {
250-
throw new Error(transformedError)
251-
}
252-
if (
253-
transformedError &&
254-
typeof transformedError === 'object' &&
255-
'error' in transformedError
256-
) {
257-
throw new Error(transformedError.error || 'Tool returned an error')
258-
}
259-
// Fallback
260-
throw new Error('Tool returned an error')
261-
} catch (transformError) {
262-
logger.error(`[${requestId}] Error transformation failed for ${toolId}`, {
263-
error:
264-
transformError instanceof Error ? transformError.message : String(transformError),
265-
})
266-
if (transformError instanceof Error) {
267-
throw transformError
268-
}
269-
throw new Error('Tool returned an error')
270-
}
271-
} else {
272-
throw new Error('Tool returned an error')
273-
}
238+
// Let the main executeTool handle error transformation to avoid double transformation
239+
throw new Error(result.error || 'Tool execution failed')
274240
}
275241

276242
const endTime = new Date()
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
import { NextResponse } from 'next/server'
2+
import { Logger } from '@/lib/logs/console/logger'
3+
import { getJiraCloudId } from '@/tools/jira/utils'
4+
5+
export const dynamic = 'force-dynamic'
6+
7+
const logger = new Logger('JiraUpdateAPI')
8+
9+
export async function PUT(request: Request) {
10+
try {
11+
const {
12+
domain,
13+
accessToken,
14+
issueKey,
15+
summary,
16+
title, // Support both summary and title for backwards compatibility
17+
description,
18+
status,
19+
priority,
20+
assignee,
21+
cloudId: providedCloudId,
22+
} = await request.json()
23+
24+
// Validate required parameters
25+
if (!domain) {
26+
logger.error('Missing domain in request')
27+
return NextResponse.json({ error: 'Domain is required' }, { status: 400 })
28+
}
29+
30+
if (!accessToken) {
31+
logger.error('Missing access token in request')
32+
return NextResponse.json({ error: 'Access token is required' }, { status: 400 })
33+
}
34+
35+
if (!issueKey) {
36+
logger.error('Missing issue key in request')
37+
return NextResponse.json({ error: 'Issue key is required' }, { status: 400 })
38+
}
39+
40+
// Use provided cloudId or fetch it if not provided
41+
const cloudId = providedCloudId || (await getJiraCloudId(domain, accessToken))
42+
logger.info('Using cloud ID:', cloudId)
43+
44+
// Build the URL using cloudId for Jira API
45+
const url = `https://api.atlassian.com/ex/jira/${cloudId}/rest/api/3/issue/${issueKey}`
46+
47+
logger.info('Updating Jira issue at:', url)
48+
49+
// Map the summary from either summary or title field
50+
const summaryValue = summary || title
51+
const fields: Record<string, any> = {}
52+
53+
if (summaryValue) {
54+
fields.summary = summaryValue
55+
}
56+
57+
if (description) {
58+
fields.description = {
59+
type: 'doc',
60+
version: 1,
61+
content: [
62+
{
63+
type: 'paragraph',
64+
content: [
65+
{
66+
type: 'text',
67+
text: description,
68+
},
69+
],
70+
},
71+
],
72+
}
73+
}
74+
75+
if (status) {
76+
fields.status = {
77+
name: status,
78+
}
79+
}
80+
81+
if (priority) {
82+
fields.priority = {
83+
name: priority,
84+
}
85+
}
86+
87+
if (assignee) {
88+
fields.assignee = {
89+
id: assignee,
90+
}
91+
}
92+
93+
const body = { fields }
94+
95+
// Make the request to Jira API
96+
const response = await fetch(url, {
97+
method: 'PUT',
98+
headers: {
99+
Authorization: `Bearer ${accessToken}`,
100+
Accept: 'application/json',
101+
'Content-Type': 'application/json',
102+
},
103+
body: JSON.stringify(body),
104+
})
105+
106+
if (!response.ok) {
107+
const errorText = await response.text()
108+
logger.error('Jira API error:', {
109+
status: response.status,
110+
statusText: response.statusText,
111+
error: errorText,
112+
})
113+
114+
return NextResponse.json(
115+
{ error: `Jira API error: ${response.status} ${response.statusText}`, details: errorText },
116+
{ status: response.status }
117+
)
118+
}
119+
120+
// Note: Jira update API typically returns 204 No Content on success
121+
const responseData = response.status === 204 ? {} : await response.json()
122+
logger.info('Successfully updated Jira issue:', issueKey)
123+
124+
return NextResponse.json({
125+
success: true,
126+
output: {
127+
ts: new Date().toISOString(),
128+
issueKey: responseData.key || issueKey,
129+
summary: responseData.fields?.summary || 'Issue updated',
130+
success: true,
131+
},
132+
})
133+
} catch (error: any) {
134+
logger.error('Error updating Jira issue:', {
135+
error: error instanceof Error ? error.message : String(error),
136+
stack: error instanceof Error ? error.stack : undefined,
137+
})
138+
139+
return NextResponse.json(
140+
{
141+
error: error instanceof Error ? error.message : 'Internal server error',
142+
success: false,
143+
},
144+
{ status: 500 }
145+
)
146+
}
147+
}

0 commit comments

Comments
 (0)