Skip to content

Commit 3816a2f

Browse files
author
Josselin Liebe
committed
fix(huntapi): address review feedback
- Keep the media metadata mapper in get_job.ts, its only caller - Document the HuntApiIcon export - Read the operation from the mapper context so agent tools coerce Max Duration too
1 parent 5831ec0 commit 3816a2f

5 files changed

Lines changed: 31 additions & 28 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+
/** HuntAPI logo, as used by the HuntAPI block. */
1046310464
export function HuntApiIcon(props: SVGProps<SVGSVGElement>) {
1046410465
return (
1046510466
<svg viewBox='-0.3 1.7 20.6 20.6' fill='none' xmlns='http://www.w3.org/2000/svg' {...props}>

‎apps/sim/blocks/blocks/huntapi.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,10 @@ export const HuntApiBlock: BlockConfig = {
142142
access: ['huntapi_download_video', 'huntapi_download_audio', 'huntapi_get_job'],
143143
config: {
144144
tool: (params) => `huntapi_${params.operation}`,
145-
params: (params) => {
145+
params: (params, context) => {
146+
const operation = context?.operation ?? params.operation
146147
const result: Record<string, unknown> = {}
147-
if (['download_video', 'download_audio'].includes(params.operation)) {
148+
if (['download_video', 'download_audio'].includes(operation)) {
148149
result.maxDuration = parseOptionalNumberInput(params.maxDuration, 'Max Duration', {
149150
integer: true,
150151
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+
/** HuntAPI logo, as used by the HuntAPI block. */
1046310464
export function HuntApiIcon(props: SVGProps<SVGSVGElement>) {
1046410465
return (
1046510466
<svg viewBox='-0.3 1.7 20.6 20.6' fill='none' xmlns='http://www.w3.org/2000/svg' {...props}>

‎apps/sim/tools/huntapi/get_job.ts‎

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,34 @@
11
import { toNumberOrNull, toStringOrNull } from '@sim/utils/coerce'
2-
import { toRecord } from '@sim/utils/object'
3-
import type { HuntApiGetJobParams, HuntApiGetJobResponse } from '@/tools/huntapi/types'
2+
import { toRecord, toRecordOrNull } from '@sim/utils/object'
3+
import type {
4+
HuntApiGetJobParams,
5+
HuntApiGetJobResponse,
6+
HuntApiMediaMetadata,
7+
} from '@/tools/huntapi/types'
48
import { HUNT_API_MEDIA_METADATA_OUTPUT_PROPERTIES } from '@/tools/huntapi/types'
5-
import { mapHuntApiMediaMetadata } from '@/tools/huntapi/utils'
69
import type { ToolConfig } from '@/tools/types'
710
import { safeUrlPathSegment } from '@/tools/url-path'
811

12+
/** Reads a `HuntApiMediaMetadata` from an untyped HuntAPI API payload. */
13+
function mapHuntApiMediaMetadata(value: unknown): HuntApiMediaMetadata | null {
14+
const record = toRecordOrNull(value)
15+
if (!record) return null
16+
return {
17+
title: toStringOrNull(record.title),
18+
description: toStringOrNull(record.description),
19+
duration: toNumberOrNull(record.duration),
20+
extension: toStringOrNull(record.ext),
21+
thumbnail: toStringOrNull(record.thumbnail),
22+
uploader: toStringOrNull(record.uploader),
23+
uploaderUrl: toStringOrNull(record.uploader_url),
24+
viewCount: toNumberOrNull(record.view_count),
25+
likeCount: toNumberOrNull(record.like_count),
26+
commentCount: toNumberOrNull(record.comment_count),
27+
uploadDate: toNumberOrNull(record.upload_date),
28+
webpageUrl: toStringOrNull(record.original_url),
29+
}
30+
}
31+
932
export const huntapiGetJobTool: ToolConfig<HuntApiGetJobParams, HuntApiGetJobResponse> = {
1033
id: 'huntapi_get_job',
1134
name: 'HuntAPI Get Job',

‎apps/sim/tools/huntapi/utils.ts‎

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)