Skip to content

Commit fbd8730

Browse files
committed
fix(serply): sync generated tool metadata and type the result mapping
Addresses review feedback on the Serply tool. serply_search was registered in tools/registry.ts but missing from the generated artifacts, so hasToolId/getToolParams/getToolMetadata resolved it as unknown and tool-metadata:check failed. Regenerated via tool-metadata:generate; the only delta is the added serply_search entry in each file, no existing tool changed. Replaced the explicit any in transformResponse with declared SerplyResultItem/SerplySearchApiResponse shapes, and typed the URL builder cast in the test as SearchParams.
1 parent a4129fe commit fbd8730

5 files changed

Lines changed: 18 additions & 6 deletions

File tree

apps/sim/tools/generated/tool-ids.ts

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

apps/sim/tools/generated/tool-metadata.ts

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

apps/sim/tools/generated/tool-outputs.ts

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

apps/sim/tools/serply/search.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* @vitest-environment node
33
*/
44
import { describe, expect, it } from 'vitest'
5+
import type { SearchParams } from '@/tools/serply/search'
56
import { searchTool } from '@/tools/serply/search'
67

78
describe('serply searchTool', () => {
@@ -14,7 +15,7 @@ describe('serply searchTool', () => {
1415
})
1516

1617
it('builds the query URL with the optional num param', () => {
17-
const url = (searchTool.request.url as (params: any) => string)({
18+
const url = (searchTool.request.url as (params: SearchParams) => string)({
1819
query: 'sim workflows',
1920
apiKey: 'test-key',
2021
num: 20,

apps/sim/tools/serply/search.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,17 @@ export interface SearchResult {
1818
snippet?: string
1919
}
2020

21+
/** Raw item shape returned by the Serply search endpoint. */
22+
interface SerplyResultItem {
23+
title?: string
24+
link?: string
25+
description?: string
26+
}
27+
28+
interface SerplySearchApiResponse {
29+
results?: SerplyResultItem[]
30+
}
31+
2132
export interface SearchResponse extends ToolResponse {
2233
output: {
2334
searchResults: SearchResult[]
@@ -70,10 +81,10 @@ export const searchTool: ToolConfig<SearchParams, SearchResponse> = {
7081
},
7182

7283
transformResponse: async (response: Response) => {
73-
const data = await response.json()
84+
const data = (await response.json()) as SerplySearchApiResponse
7485
const results = Array.isArray(data.results) ? data.results : []
7586

76-
const searchResults: SearchResult[] = results.map((item: any) => ({
87+
const searchResults: SearchResult[] = results.map((item) => ({
7788
title: item.title || '',
7889
link: item.link || '',
7990
snippet: item.description || undefined,

0 commit comments

Comments
 (0)