Skip to content

Commit 56dcdf7

Browse files
author
Josselin Liebe
committed
fix(piloterr): address review feedback
- Describe Google Search without a knowledge graph, which it does not return - Read the operation from the mapper context so agent tools coerce numeric inputs too - Keep response mappers with a single caller in that tool's file - Document the PiloterrIcon export
1 parent 82473ff commit 56dcdf7

15 files changed

Lines changed: 192 additions & 214 deletions

File tree

‎apps/docs/components/icons.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10460,6 +10460,7 @@ export function PlaneIcon(props: SVGProps<SVGSVGElement>) {
1046010460
)
1046110461
}
1046210462

10463+
/** Piloterr logo, as used by the Piloterr block. */
1046310464
export function PiloterrIcon(props: SVGProps<SVGSVGElement>) {
1046410465
return (
1046510466
<svg viewBox='-0.3 1.2 20 20' fill='none' xmlns='http://www.w3.org/2000/svg' {...props}>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ Detect the technologies a website runs, such as its CMS, frameworks, analytics,
137137

138138
### Piloterr Google Search
139139

140-
Search Google and get organic results with their position, title, link and snippet, the knowledge graph and the estimated total.
140+
Search Google and get organic results with their position, title, link and snippet, and the estimated total.
141141

142142
<ReferenceDetails>
143143

‎apps/sim/blocks/blocks/piloterr.ts‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -305,31 +305,32 @@ export const PiloterrBlock: BlockConfig = {
305305
],
306306
config: {
307307
tool: (params) => `piloterr_${params.operation}`,
308-
params: (params) => {
308+
params: (params, context) => {
309+
const operation = context?.operation ?? params.operation
309310
const result: Record<string, unknown> = {}
310-
if (params.operation === 'render_html') {
311+
if (operation === 'render_html') {
311312
result.waitInSeconds = parseOptionalNumberInput(params.waitInSeconds, 'Wait', { min: 0 })
312313
}
313-
if (params.operation === 'screenshot') {
314+
if (operation === 'screenshot') {
314315
result.viewportWidth = parseOptionalNumberInput(params.viewportWidth, 'Viewport Width', {
315316
integer: true,
316317
min: 1,
317318
})
318319
}
319-
if (params.operation === 'screenshot') {
320+
if (operation === 'screenshot') {
320321
result.viewportHeight = parseOptionalNumberInput(
321322
params.viewportHeight,
322323
'Viewport Height',
323324
{ integer: true, min: 1 }
324325
)
325326
}
326-
if (params.operation === 'screenshot') {
327+
if (operation === 'screenshot') {
327328
result.delay = parseOptionalNumberInput(params.delay, 'Delay', { min: 0 })
328329
}
329-
if (['google_search', 'amazon_search', 'ebay_search'].includes(params.operation)) {
330+
if (['google_search', 'amazon_search', 'ebay_search'].includes(operation)) {
330331
result.page = parseOptionalNumberInput(params.page, 'Page', { integer: true, min: 1 })
331332
}
332-
if (params.operation === 'google_search') {
333+
if (operation === 'google_search') {
333334
result.numResults = parseOptionalNumberInput(params.numResults, 'Results per Page', {
334335
integer: true,
335336
min: 1,

‎apps/sim/components/icons.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10460,6 +10460,7 @@ export function PlaneIcon(props: SVGProps<SVGSVGElement>) {
1046010460
)
1046110461
}
1046210462

10463+
/** Piloterr logo, as used by the Piloterr block. */
1046310464
export function PiloterrIcon(props: SVGProps<SVGSVGElement>) {
1046410465
return (
1046510466
<svg viewBox='-0.3 1.2 20 20' fill='none' xmlns='http://www.w3.org/2000/svg' {...props}>

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

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

‎apps/sim/tools/piloterr/amazon_search.ts‎

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,28 @@
1-
import { toArray } from '@sim/utils/object'
1+
import { toNumberOrNull, toStringOrNull } from '@sim/utils/coerce'
2+
import { toArray, toRecordOrNull } from '@sim/utils/object'
23
import type {
34
PiloterrAmazonProduct,
45
PiloterrAmazonSearchParams,
56
PiloterrAmazonSearchResponse,
67
} from '@/tools/piloterr/types'
78
import { PILOTERR_AMAZON_PRODUCT_OUTPUT_PROPERTIES } from '@/tools/piloterr/types'
8-
import { mapPiloterrAmazonProduct } from '@/tools/piloterr/utils'
99
import type { ToolConfig } from '@/tools/types'
1010

11+
/** Reads a `PiloterrAmazonProduct` from an untyped Piloterr API payload. */
12+
function mapPiloterrAmazonProduct(value: unknown): PiloterrAmazonProduct | null {
13+
const record = toRecordOrNull(value)
14+
if (!record) return null
15+
return {
16+
asin: toStringOrNull(record.asin),
17+
title: toStringOrNull(record.title),
18+
url: toStringOrNull(record.url),
19+
price: toNumberOrNull(record.price),
20+
realPrice: toNumberOrNull(record.real_price),
21+
rating: toNumberOrNull(record.rating),
22+
reviewsCount: toNumberOrNull(record.reviews_count),
23+
}
24+
}
25+
1126
export const piloterrAmazonSearchTool: ToolConfig<
1227
PiloterrAmazonSearchParams,
1328
PiloterrAmazonSearchResponse

‎apps/sim/tools/piloterr/crunchbase_company.ts‎

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { toNumberOrNull, toStringOrNull } from '@sim/utils/coerce'
2-
import { toArray, toRecord } from '@sim/utils/object'
2+
import { toArray, toRecord, toRecordOrNull } from '@sim/utils/object'
33
import type {
44
PiloterrCrunchbaseCategory,
55
PiloterrCrunchbaseCompanyParams,
@@ -14,14 +14,49 @@ import {
1414
PILOTERR_CRUNCHBASE_LOCATION_OUTPUT_PROPERTIES,
1515
PILOTERR_CRUNCHBASE_PRODUCT_OUTPUT_PROPERTIES,
1616
} from '@/tools/piloterr/types'
17-
import {
18-
mapPiloterrCrunchbaseCategory,
19-
mapPiloterrCrunchbaseInvestor,
20-
mapPiloterrCrunchbaseLocation,
21-
mapPiloterrCrunchbaseProduct,
22-
} from '@/tools/piloterr/utils'
2317
import type { ToolConfig } from '@/tools/types'
2418

19+
/** Reads a `PiloterrCrunchbaseCategory` from an untyped Piloterr API payload. */
20+
function mapPiloterrCrunchbaseCategory(value: unknown): PiloterrCrunchbaseCategory | null {
21+
const record = toRecordOrNull(value)
22+
if (!record) return null
23+
return {
24+
name: toStringOrNull(record.name),
25+
permalink: toStringOrNull(record.permalink),
26+
}
27+
}
28+
29+
/** Reads a `PiloterrCrunchbaseLocation` from an untyped Piloterr API payload. */
30+
function mapPiloterrCrunchbaseLocation(value: unknown): PiloterrCrunchbaseLocation | null {
31+
const record = toRecordOrNull(value)
32+
if (!record) return null
33+
return {
34+
name: toStringOrNull(record.name),
35+
type: toStringOrNull(record.type),
36+
}
37+
}
38+
39+
/** Reads a `PiloterrCrunchbaseInvestor` from an untyped Piloterr API payload. */
40+
function mapPiloterrCrunchbaseInvestor(value: unknown): PiloterrCrunchbaseInvestor | null {
41+
const record = toRecordOrNull(value)
42+
if (!record) return null
43+
return {
44+
name: toStringOrNull(toRecord(record.investor_identifier).value),
45+
permalink: toStringOrNull(toRecord(record.investor_identifier).permalink),
46+
fundingRound: toStringOrNull(toRecord(record.funding_round_identifier).value),
47+
}
48+
}
49+
50+
/** Reads a `PiloterrCrunchbaseProduct` from an untyped Piloterr API payload. */
51+
function mapPiloterrCrunchbaseProduct(value: unknown): PiloterrCrunchbaseProduct | null {
52+
const record = toRecordOrNull(value)
53+
if (!record) return null
54+
return {
55+
name: toStringOrNull(record.name),
56+
description: toStringOrNull(record.description),
57+
}
58+
}
59+
2560
export const piloterrCrunchbaseCompanyTool: ToolConfig<
2661
PiloterrCrunchbaseCompanyParams,
2762
PiloterrCrunchbaseCompanyResponse

‎apps/sim/tools/piloterr/detect_technologies.ts‎

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,41 @@
1-
import { toArray, toRecord } from '@sim/utils/object'
1+
import { toNumberOrNull, toStringOrNull } from '@sim/utils/coerce'
2+
import { toArray, toRecord, toRecordOrNull } from '@sim/utils/object'
23
import type {
34
PiloterrDetectTechnologiesParams,
45
PiloterrDetectTechnologiesResponse,
56
PiloterrTechnology,
7+
PiloterrTechnologyCategory,
68
} from '@/tools/piloterr/types'
79
import { PILOTERR_TECHNOLOGY_OUTPUT_PROPERTIES } from '@/tools/piloterr/types'
8-
import { mapPiloterrTechnology } from '@/tools/piloterr/utils'
910
import type { ToolConfig } from '@/tools/types'
1011

12+
/** Reads a `PiloterrTechnologyCategory` from an untyped Piloterr API payload. */
13+
function mapPiloterrTechnologyCategory(value: unknown): PiloterrTechnologyCategory | null {
14+
const record = toRecordOrNull(value)
15+
if (!record) return null
16+
return {
17+
name: toStringOrNull(record.name),
18+
slug: toStringOrNull(record.slug),
19+
}
20+
}
21+
22+
/** Reads a `PiloterrTechnology` from an untyped Piloterr API payload. */
23+
function mapPiloterrTechnology(value: unknown): PiloterrTechnology | null {
24+
const record = toRecordOrNull(value)
25+
if (!record) return null
26+
return {
27+
name: toStringOrNull(record.name),
28+
slug: toStringOrNull(record.slug),
29+
version: toStringOrNull(record.version),
30+
website: toStringOrNull(record.website),
31+
description: toStringOrNull(record.description),
32+
confidence: toNumberOrNull(record.confidence),
33+
categories: toArray(record.categories)
34+
.map(mapPiloterrTechnologyCategory)
35+
.filter((item): item is PiloterrTechnologyCategory => item !== null),
36+
}
37+
}
38+
1139
export const piloterrDetectTechnologiesTool: ToolConfig<
1240
PiloterrDetectTechnologiesParams,
1341
PiloterrDetectTechnologiesResponse

‎apps/sim/tools/piloterr/ebay_get_listing.ts‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { toBooleanOrNull, toNumberOrNull, toStringOrNull } from '@sim/utils/coerce'
2-
import { toArray, toRecord } from '@sim/utils/object'
2+
import { toArray, toRecord, toRecordOrNull } from '@sim/utils/object'
33
import type {
44
PiloterrEbayGetListingParams,
55
PiloterrEbayGetListingResponse,
@@ -9,9 +9,19 @@ import {
99
PILOTERR_EBAY_SELLER_OUTPUT_PROPERTIES,
1010
PILOTERR_EBAY_SPECIFICATION_OUTPUT_PROPERTIES,
1111
} from '@/tools/piloterr/types'
12-
import { mapPiloterrEbaySeller, mapPiloterrEbaySpecification } from '@/tools/piloterr/utils'
12+
import { mapPiloterrEbaySeller } from '@/tools/piloterr/utils'
1313
import type { ToolConfig } from '@/tools/types'
1414

15+
/** Reads a `PiloterrEbaySpecification` from an untyped Piloterr API payload. */
16+
function mapPiloterrEbaySpecification(value: unknown): PiloterrEbaySpecification | null {
17+
const record = toRecordOrNull(value)
18+
if (!record) return null
19+
return {
20+
name: toStringOrNull(record.name),
21+
value: toStringOrNull(record.value),
22+
}
23+
}
24+
1525
export const piloterrEbayGetListingTool: ToolConfig<
1626
PiloterrEbayGetListingParams,
1727
PiloterrEbayGetListingResponse

‎apps/sim/tools/piloterr/ebay_search.ts‎

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,35 @@
11
import { toNumberOrNull, toStringOrNull } from '@sim/utils/coerce'
2-
import { toArray, toRecord } from '@sim/utils/object'
2+
import { toArray, toRecord, toRecordOrNull } from '@sim/utils/object'
33
import type {
44
PiloterrEbayListing,
55
PiloterrEbaySearchParams,
66
PiloterrEbaySearchResponse,
77
} from '@/tools/piloterr/types'
88
import { PILOTERR_EBAY_LISTING_OUTPUT_PROPERTIES } from '@/tools/piloterr/types'
9-
import { mapPiloterrEbayListing } from '@/tools/piloterr/utils'
9+
import { mapPiloterrEbaySeller } from '@/tools/piloterr/utils'
1010
import type { ToolConfig } from '@/tools/types'
1111

12+
/** Reads a `PiloterrEbayListing` from an untyped Piloterr API payload. */
13+
function mapPiloterrEbayListing(value: unknown): PiloterrEbayListing | null {
14+
const record = toRecordOrNull(value)
15+
if (!record) return null
16+
return {
17+
position: toNumberOrNull(record.position),
18+
itemId: toStringOrNull(record.item_id),
19+
title: toStringOrNull(record.title),
20+
subtitle: toStringOrNull(record.subtitle),
21+
url: toStringOrNull(record.url),
22+
price: toNumberOrNull(record.price),
23+
currency: toStringOrNull(record.currency),
24+
priceDisplay: toStringOrNull(record.price_display),
25+
condition: toStringOrNull(record.condition),
26+
buyingFormat: toStringOrNull(record.buying_format),
27+
shipping: toStringOrNull(record.shipping),
28+
imageUrl: toStringOrNull(record.image_url),
29+
seller: mapPiloterrEbaySeller(record.seller),
30+
}
31+
}
32+
1233
export const piloterrEbaySearchTool: ToolConfig<
1334
PiloterrEbaySearchParams,
1435
PiloterrEbaySearchResponse

0 commit comments

Comments
 (0)