diff --git a/apps/sim/tools/google_books/types.ts b/apps/sim/tools/google_books/types.ts index f56966095..3484d576a 100644 --- a/apps/sim/tools/google_books/types.ts +++ b/apps/sim/tools/google_books/types.ts @@ -1,5 +1,35 @@ import type { ToolResponse } from '@/tools/types' +/** + * Raw volume item from Google Books API response + */ +export interface GoogleBooksVolumeItem { + id: string + volumeInfo: { + title?: string + subtitle?: string + authors?: string[] + publisher?: string + publishedDate?: string + description?: string + pageCount?: number + categories?: string[] + averageRating?: number + ratingsCount?: number + language?: string + previewLink?: string + infoLink?: string + imageLinks?: { + thumbnail?: string + smallThumbnail?: string + } + industryIdentifiers?: Array<{ + type: string + identifier: string + }> + } +} + /** * Volume information structure shared between search and details responses */ diff --git a/apps/sim/tools/google_books/volume_details.ts b/apps/sim/tools/google_books/volume_details.ts index 114a78361..f50e23986 100644 --- a/apps/sim/tools/google_books/volume_details.ts +++ b/apps/sim/tools/google_books/volume_details.ts @@ -29,9 +29,6 @@ interface GoogleBooksVolumeResponse { identifier: string }> } - error?: { - message?: string - } } export const googleBooksVolumeDetailsTool: ToolConfig< @@ -84,10 +81,6 @@ export const googleBooksVolumeDetailsTool: ToolConfig< transformResponse: async (response: Response) => { const data: GoogleBooksVolumeResponse = await response.json() - if (data.error) { - throw new Error(`Google Books API error: ${data.error.message || 'Unknown error'}`) - } - if (!data.volumeInfo) { throw new Error('Volume not found') } diff --git a/apps/sim/tools/google_books/volume_search.ts b/apps/sim/tools/google_books/volume_search.ts index 72ca1a783..55d90cf9a 100644 --- a/apps/sim/tools/google_books/volume_search.ts +++ b/apps/sim/tools/google_books/volume_search.ts @@ -1,37 +1,11 @@ import type { + GoogleBooksVolumeItem, GoogleBooksVolumeSearchParams, GoogleBooksVolumeSearchResponse, VolumeInfo, } from '@/tools/google_books/types' import type { ToolConfig } from '@/tools/types' -interface GoogleBooksVolumeItem { - id: string - volumeInfo: { - title?: string - subtitle?: string - authors?: string[] - publisher?: string - publishedDate?: string - description?: string - pageCount?: number - categories?: string[] - averageRating?: number - ratingsCount?: number - language?: string - previewLink?: string - infoLink?: string - imageLinks?: { - thumbnail?: string - smallThumbnail?: string - } - industryIdentifiers?: Array<{ - type: string - identifier: string - }> - } -} - function extractVolumeInfo(item: GoogleBooksVolumeItem): VolumeInfo { const info = item.volumeInfo const identifiers = info.industryIdentifiers ?? [] @@ -155,10 +129,6 @@ export const googleBooksVolumeSearchTool: ToolConfig< transformResponse: async (response: Response) => { const data = await response.json() - if (data.error) { - throw new Error(`Google Books API error: ${data.error.message || 'Unknown error'}`) - } - const items: GoogleBooksVolumeItem[] = data.items ?? [] const volumes = items.map(extractVolumeInfo)