From 262d6ef89f84a6407ef5cda37ce76dc873a2c5b6 Mon Sep 17 00:00:00 2001 From: Win Cheng Date: Fri, 29 Aug 2025 15:38:59 -0700 Subject: [PATCH 01/34] base typing for sdks for usage --- src/validate/interfaces.ts | 13 +++++++------ src/vision/interfaces.ts | 6 ++++-- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/validate/interfaces.ts b/src/validate/interfaces.ts index 649b778..eb0b771 100644 --- a/src/validate/interfaces.ts +++ b/src/validate/interfaces.ts @@ -1,4 +1,5 @@ -export interface EmailValidationResponse { +import { BaseResponse } from "../../types"; +export interface EmailValidationResponse extends BaseResponse { email: string; disposable: boolean; role_account: boolean; @@ -9,7 +10,7 @@ export interface EmailValidationResponse { valid: boolean; } -export interface NSFWValidationResponse { +export interface NSFWValidationResponse extends BaseResponse { success: boolean; nsfw: boolean; nudity: boolean; @@ -24,7 +25,7 @@ export interface ProfanityParams { censor_replacement?: string; } -export interface ProfanityValidationResponse { +export interface ProfanityValidationResponse extends BaseResponse { success: boolean; message: string; clean_text: string; @@ -41,7 +42,7 @@ export interface SpellCheckParams { language_code?: string; } -export interface SpellCheckValidationResponse { +export interface SpellCheckValidationResponse extends BaseResponse { success: boolean; misspellings_found: boolean; misspellings: Array<{ @@ -54,7 +55,7 @@ export interface SpellCheckValidationResponse { auto_correct_text: string; } -export interface SpamCheckValidationResponse { +export interface SpamCheckValidationResponse extends BaseResponse { success: boolean; check: { is_spam: boolean; @@ -62,7 +63,7 @@ export interface SpamCheckValidationResponse { }; } -export interface SpamCheckValidationArrayResponse { +export interface SpamCheckValidationArrayResponse extends BaseResponse { success: boolean; check: { is_spam: boolean; diff --git a/src/vision/interfaces.ts b/src/vision/interfaces.ts index aba7b4b..53341f8 100644 --- a/src/vision/interfaces.ts +++ b/src/vision/interfaces.ts @@ -1,3 +1,5 @@ +import { BaseResponse } from "../../types"; + export type VOCRParams = { prompt?: string | string[]; url?: string; @@ -24,7 +26,7 @@ interface Bounds { }; } -export interface VOCRResponse { +export interface VOCRResponse extends BaseResponse { success: boolean; context: string; width: number; @@ -55,7 +57,7 @@ export type ObjectDetectionParams = { return_type?: "url" | "base64"; }; -export interface ObjectDetectionResponse { +export interface ObjectDetectionResponse extends BaseResponse { // Optional annotated image - included only if annotated_image=true and objects/gui_elements exist annotated_image?: string; // URL or base64 string depending on return_type From a3eedb02eeb1750d2fb46e282447c20b422adcc0 Mon Sep 17 00:00:00 2001 From: Win Cheng Date: Fri, 29 Aug 2025 16:01:56 -0700 Subject: [PATCH 02/34] success and extend base response --- src/validate/interfaces.ts | 5 ----- src/vision/interfaces.ts | 1 - src/web/interfaces/deep_research.ts | 4 ++-- src/web/interfaces/html_to_any.ts | 21 +++++++++++++++++++++ src/web/interfaces/scrape.ts | 10 +++++----- src/web/interfaces/search.ts | 7 +++---- src/web/web.ts | 17 ++++++++++++----- 7 files changed, 43 insertions(+), 22 deletions(-) diff --git a/src/validate/interfaces.ts b/src/validate/interfaces.ts index eb0b771..b11474f 100644 --- a/src/validate/interfaces.ts +++ b/src/validate/interfaces.ts @@ -11,7 +11,6 @@ export interface EmailValidationResponse extends BaseResponse { } export interface NSFWValidationResponse extends BaseResponse { - success: boolean; nsfw: boolean; nudity: boolean; gore: boolean; @@ -26,7 +25,6 @@ export interface ProfanityParams { } export interface ProfanityValidationResponse extends BaseResponse { - success: boolean; message: string; clean_text: string; profanities: { @@ -43,7 +41,6 @@ export interface SpellCheckParams { } export interface SpellCheckValidationResponse extends BaseResponse { - success: boolean; misspellings_found: boolean; misspellings: Array<{ word: string; @@ -56,7 +53,6 @@ export interface SpellCheckValidationResponse extends BaseResponse { } export interface SpamCheckValidationResponse extends BaseResponse { - success: boolean; check: { is_spam: boolean; score: number; @@ -64,7 +60,6 @@ export interface SpamCheckValidationResponse extends BaseResponse { } export interface SpamCheckValidationArrayResponse extends BaseResponse { - success: boolean; check: { is_spam: boolean; score: number; diff --git a/src/vision/interfaces.ts b/src/vision/interfaces.ts index 53341f8..4f26b96 100644 --- a/src/vision/interfaces.ts +++ b/src/vision/interfaces.ts @@ -27,7 +27,6 @@ interface Bounds { } export interface VOCRResponse extends BaseResponse { - success: boolean; context: string; width: number; height: number; diff --git a/src/web/interfaces/deep_research.ts b/src/web/interfaces/deep_research.ts index 8d69030..0357ff2 100644 --- a/src/web/interfaces/deep_research.ts +++ b/src/web/interfaces/deep_research.ts @@ -1,3 +1,4 @@ +import { BaseResponse } from "../../../types"; // Input parameters interface for reference export interface DeepResearchParams { query: string; @@ -10,8 +11,7 @@ export interface DeepResearchParams { target_output_tokens?: number; } -export interface DeepResearchResponse { - success: boolean; +export interface DeepResearchResponse extends BaseResponse { query: string; results: string; sources: SearchResult[]; diff --git a/src/web/interfaces/html_to_any.ts b/src/web/interfaces/html_to_any.ts index 1750250..641d760 100644 --- a/src/web/interfaces/html_to_any.ts +++ b/src/web/interfaces/html_to_any.ts @@ -1,3 +1,5 @@ +import { BaseResponse } from "../../../types"; + export interface HTMLAnyParams { html?: string; url?: string; @@ -21,3 +23,22 @@ export interface HTMLAnyParams { }; return_type?: "url" | "binary" | "base64"; } + +// response for "url" and "base64" return types (both return url string) +export interface HTMLAnyURLResponse extends BaseResponse { + url: string; +} + +export interface HTMLAnyBinaryResponse extends Response { + // binary response doesn't have structure +} + +export interface HTMLAnyURLParams extends Omit { + return_type: "url" | "base64"; +} + +export interface HTMLAnyBinaryParams extends Omit { + return_type: "binary"; +} + +export type HTMLAnyResponse = HTMLAnyURLResponse | HTMLAnyBinaryResponse; diff --git a/src/web/interfaces/scrape.ts b/src/web/interfaces/scrape.ts index 91acf9a..f65d8c7 100644 --- a/src/web/interfaces/scrape.ts +++ b/src/web/interfaces/scrape.ts @@ -1,4 +1,5 @@ -export interface CookieParameter { +import { BaseResponse } from "../../../types"; +interface CookieParameter { name: string; value: string; url?: string; @@ -49,20 +50,19 @@ export interface BaseAIScrapeParams { features?: Array<"meta" | "link"> | null; } -export interface AIScrapeParamsWithSelector extends BaseAIScrapeParams { +interface AIScrapeParamsWithSelector extends BaseAIScrapeParams { selectors: Array; element_prompts?: string[]; } -export interface AIScrapeParamsWithPrompts extends BaseAIScrapeParams { +interface AIScrapeParamsWithPrompts extends BaseAIScrapeParams { selectors?: Array; element_prompts?: string[]; } export type AIScrapeParams = AIScrapeParamsWithSelector | AIScrapeParamsWithPrompts; -export interface AIScrapeResponse { - success: boolean; +export interface AIScrapeResponse extends BaseResponse { data: Array<{ key: string; selector: string; diff --git a/src/web/interfaces/search.ts b/src/web/interfaces/search.ts index e8fdd8e..4254088 100644 --- a/src/web/interfaces/search.ts +++ b/src/web/interfaces/search.ts @@ -1,3 +1,4 @@ +import { BaseResponse } from "../../../types"; export interface SearchParams { query: string; spell_check?: boolean; @@ -23,8 +24,7 @@ interface RelatedIndex { is_safe?: boolean; } -export interface SearchResponse { - success: boolean; +export interface SearchResponse extends BaseResponse { query: string; ai_overview?: string; spell_fixed: boolean; @@ -72,7 +72,6 @@ export interface SearchResponse { }[]; } -export interface SuggestionResponse { - success: boolean; +export interface SuggestionResponse extends BaseResponse { suggestions: string[]; } diff --git a/src/web/web.ts b/src/web/web.ts index ca54599..47881d5 100644 --- a/src/web/web.ts +++ b/src/web/web.ts @@ -1,7 +1,7 @@ import { respToFileChoice } from "../helpers"; import { RequestClient } from "../request"; import { DeepResearchParams, DeepResearchResponse } from "./interfaces/deep_research"; -import { HTMLAnyParams } from "./interfaces/html_to_any"; +import { HTMLAnyParams, HTMLAnyURLResponse, HTMLAnyBinaryResponse, HTMLAnyURLParams, HTMLAnyBinaryParams } from "./interfaces/html_to_any"; import { AIScrapeParams, AIScrapeResponse } from "./interfaces/scrape"; import { SearchParams, SearchResponse, SuggestionResponse } from "./interfaces/search"; class Web { @@ -11,10 +11,17 @@ class Web { return await this.client.fetchJSS("/ai/scrape", "POST", params); }; - html_to_any = async (params: HTMLAnyParams) => { - const resp = await this.client.fetchJSS("/web/html_to_any", "POST", params); - return respToFileChoice(resp); - }; + // Simplified function overloads + html_to_any(params: HTMLAnyURLParams): Promise; + html_to_any(params: HTMLAnyBinaryParams): Promise; + html_to_any(params: HTMLAnyParams): Promise; + async html_to_any(params: HTMLAnyParams): Promise { + if (params.return_type === "binary") { + return (await this.client.fetchJSS("/web/html_to_any", "POST", params)) as HTMLAnyBinaryResponse; + } + // For both "url" and "base64", return the same structure with url property + return (await this.client.fetchJSS("/web/html_to_any", "POST", params)) as HTMLAnyURLResponse; + } deep_research = async (params: DeepResearchParams): Promise => { return await this.client.fetchJSS("/web/deep_research", "POST", params); From cd6e8801eb85217d10ab93090245e4517a4c6ca3 Mon Sep 17 00:00:00 2001 From: Win Cheng Date: Sat, 30 Aug 2025 19:52:39 -0700 Subject: [PATCH 03/34] obj detection return masks --- src/vision/interfaces.ts | 41 ++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/src/vision/interfaces.ts b/src/vision/interfaces.ts index 4f26b96..bafb807 100644 --- a/src/vision/interfaces.ts +++ b/src/vision/interfaces.ts @@ -7,27 +7,8 @@ export type VOCRParams = { page_range?: Array; }; -interface Bounds { - top_left: { - x: number; - y: number; - }; - top_right: { - x: number; - y: number; - }; - bottom_left: { - x: number; - y: number; - }; - bottom_right: { - x: number; - y: number; - }; -} - export interface VOCRResponse extends BaseResponse { - context: string; + context: string | Record; width: number; height: number; tags: string[]; @@ -54,6 +35,7 @@ export type ObjectDetectionParams = { features?: ("object_detection" | "gui")[]; annotated_image?: boolean; return_type?: "url" | "base64"; + return_masks: }; export interface ObjectDetectionResponse extends BaseResponse { @@ -91,3 +73,22 @@ interface Point { x: number; y: number; } + +interface Bounds { + top_left: { + x: number; + y: number; + }; + top_right: { + x: number; + y: number; + }; + bottom_left: { + x: number; + y: number; + }; + bottom_right: { + x: number; + y: number; + }; +} From 92bf5604fa63d842763184dd354d04a29d6f246f Mon Sep 17 00:00:00 2001 From: Win Cheng Date: Sun, 31 Aug 2025 11:11:17 -0700 Subject: [PATCH 04/34] update object detection --- src/vision/interfaces.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/vision/interfaces.ts b/src/vision/interfaces.ts index bafb807..df65d37 100644 --- a/src/vision/interfaces.ts +++ b/src/vision/interfaces.ts @@ -35,7 +35,7 @@ export type ObjectDetectionParams = { features?: ("object_detection" | "gui")[]; annotated_image?: boolean; return_type?: "url" | "base64"; - return_masks: + return_masks?: boolean; }; export interface ObjectDetectionResponse extends BaseResponse { @@ -47,6 +47,8 @@ export interface ObjectDetectionResponse extends BaseResponse { // Optional detected objects - included only if features includes "object_detection" objects?: DetectedObject[]; + + tags?: string[]; } interface GuiElement { From 413cc063a797fda893d620a6c5f0a5d177e9dee0 Mon Sep 17 00:00:00 2001 From: Win Cheng Date: Sun, 31 Aug 2025 11:16:58 -0700 Subject: [PATCH 05/34] linting --- src/web/web.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/web/web.ts b/src/web/web.ts index 47881d5..6cd7d68 100644 --- a/src/web/web.ts +++ b/src/web/web.ts @@ -1,7 +1,7 @@ import { respToFileChoice } from "../helpers"; import { RequestClient } from "../request"; import { DeepResearchParams, DeepResearchResponse } from "./interfaces/deep_research"; -import { HTMLAnyParams, HTMLAnyURLResponse, HTMLAnyBinaryResponse, HTMLAnyURLParams, HTMLAnyBinaryParams } from "./interfaces/html_to_any"; +import { HTMLAnyBinaryParams, HTMLAnyBinaryResponse, HTMLAnyParams, HTMLAnyURLParams, HTMLAnyURLResponse } from "./interfaces/html_to_any"; import { AIScrapeParams, AIScrapeResponse } from "./interfaces/scrape"; import { SearchParams, SearchResponse, SuggestionResponse } from "./interfaces/search"; class Web { From 411ca78a1dd66449b34c595c4079798392c46139 Mon Sep 17 00:00:00 2001 From: Win Cheng Date: Sun, 31 Aug 2025 13:08:05 -0700 Subject: [PATCH 06/34] update stt, typing for non webhooks and webhooks --- .gitignore | 2 ++ src/audio/audio.ts | 33 +++++++++++++++++++++++++++++---- src/audio/interfaces.ts | 14 +++++++++++--- 3 files changed, 42 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index d3ddc9f..2643c1b 100644 --- a/.gitignore +++ b/.gitignore @@ -135,3 +135,5 @@ test.ts .DS_Store .vscode + +local_tests/* diff --git a/src/audio/audio.ts b/src/audio/audio.ts index 46f81f7..4d28c71 100644 --- a/src/audio/audio.ts +++ b/src/audio/audio.ts @@ -1,14 +1,39 @@ import { RequestClient } from "../request"; import { createFileUploadFormData } from "../utils"; -import { SpeechToTextParams, SpeechToTextSyncResponse, SpeechToTextWebhookResponse } from "./interfaces"; +import { + SpeechToTextParams, + SpeechToTextResponse, + SpeechToTextWebhookResponse, + SpeechToTextParamsWithWebhook, + SpeechToTextParamsWithoutWebhook +} from "./interfaces"; + class Audio { constructor(private readonly client: RequestClient) {} - speech_to_text(params: SpeechToTextParams): Promise; - speech_to_text(file: Blob | Buffer, params?: Omit): Promise; + + // Overload for webhook case + speech_to_text(params: SpeechToTextParamsWithWebhook): Promise; + + // Overload for Blob/Buffer with webhook + speech_to_text( + file: Blob | Buffer, + params: Omit + ): Promise; + + // Overload for non-webhook case + speech_to_text(params: SpeechToTextParamsWithoutWebhook): Promise; + + // Overload for Blob/Buffer without webhook + speech_to_text( + file: Blob | Buffer, + params?: Omit + ): Promise; + + // Implementation async speech_to_text( params: SpeechToTextParams | Blob | Buffer, options?: SpeechToTextParams - ): Promise { + ): Promise { if (params instanceof Blob || params instanceof Buffer) { const formData = createFileUploadFormData(params, options); return await this.client.fetchJSS("/ai/transcribe", "POST", formData); diff --git a/src/audio/interfaces.ts b/src/audio/interfaces.ts index 90dd79c..5b09732 100644 --- a/src/audio/interfaces.ts +++ b/src/audio/interfaces.ts @@ -11,17 +11,25 @@ export interface SpeechToTextParams { chunk_duration?: number; } -export interface SpeechToTextSyncResponse extends BaseResponse { +export interface SpeechToTextParamsWithWebhook extends SpeechToTextParams { + webhook_url: string; +} + +export interface SpeechToTextParamsWithoutWebhook extends Omit { + webhook_url?: never; +} + +export interface SpeechToTextResponse extends BaseResponse { text: string; chunks: Array<{ timestamp: number[]; text: string; }>; - speakers?: { + speakers?: Array<{ speaker: string; timestamp: number[]; text: string; - }[]; + }>; } export interface SpeechToTextWebhookResponse extends BaseResponse { From 08b94129bf029cabf62a67685ba628e66732d0a9 Mon Sep 17 00:00:00 2001 From: Win Cheng Date: Sun, 31 Aug 2025 18:41:27 -0700 Subject: [PATCH 07/34] linting --- src/audio/audio.ts | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/src/audio/audio.ts b/src/audio/audio.ts index 4d28c71..571a514 100644 --- a/src/audio/audio.ts +++ b/src/audio/audio.ts @@ -1,34 +1,28 @@ import { RequestClient } from "../request"; import { createFileUploadFormData } from "../utils"; -import { - SpeechToTextParams, - SpeechToTextResponse, - SpeechToTextWebhookResponse, +import { + SpeechToTextParams, SpeechToTextParamsWithWebhook, - SpeechToTextParamsWithoutWebhook + SpeechToTextParamsWithoutWebhook, + SpeechToTextResponse, + SpeechToTextWebhookResponse, } from "./interfaces"; class Audio { constructor(private readonly client: RequestClient) {} - + // Overload for webhook case speech_to_text(params: SpeechToTextParamsWithWebhook): Promise; - + // Overload for Blob/Buffer with webhook - speech_to_text( - file: Blob | Buffer, - params: Omit - ): Promise; - + speech_to_text(file: Blob | Buffer, params: Omit): Promise; + // Overload for non-webhook case speech_to_text(params: SpeechToTextParamsWithoutWebhook): Promise; - + // Overload for Blob/Buffer without webhook - speech_to_text( - file: Blob | Buffer, - params?: Omit - ): Promise; - + speech_to_text(file: Blob | Buffer, params?: Omit): Promise; + // Implementation async speech_to_text( params: SpeechToTextParams | Blob | Buffer, From 1b9fc416a504ebd5de0b7b9293522b9c2dcd63e8 Mon Sep 17 00:00:00 2001 From: Win Cheng Date: Mon, 1 Sep 2025 18:54:41 -0700 Subject: [PATCH 08/34] update to embedding --- src/general/interfaces.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/general/interfaces.ts b/src/general/interfaces.ts index 1bd2e99..eb3ad46 100644 --- a/src/general/interfaces.ts +++ b/src/general/interfaces.ts @@ -117,5 +117,5 @@ export interface EmbeddingParams { export interface EmbeddingResponse extends BaseResponse { embeddings: number[][]; - chunks: string[]; // only for text + chunks?: Array<{ text: string; timestamp: number[] }>; // only available for text and audio } From e1ad1ccf67a88414b053f1cb9b45528218fc9935 Mon Sep 17 00:00:00 2001 From: Win Cheng Date: Tue, 2 Sep 2025 09:55:33 -0700 Subject: [PATCH 09/34] classification into one type accepts either image or text --- src/classification/index.ts | 8 ++------ src/classification/interfaces.ts | 19 +++---------------- src/core.ts | 2 +- 3 files changed, 6 insertions(+), 23 deletions(-) diff --git a/src/classification/index.ts b/src/classification/index.ts index ffaf2d4..f528a7c 100644 --- a/src/classification/index.ts +++ b/src/classification/index.ts @@ -1,5 +1,5 @@ import { RequestClient } from "../request"; -import { ClassificationImageParams, ClassificationResponse, ClassificationTextParams } from "./interfaces"; +import { ClassificationParams, ClassificationResponse } from "./interfaces"; class Classification { private readonly client: RequestClient; @@ -7,11 +7,7 @@ class Classification { this.client = client; } - text = async (params: ClassificationTextParams): Promise => { - return await this.client.fetchJSS("/classification", "POST", params); - }; - - image = async (params: ClassificationImageParams): Promise => { + classify = async (params: ClassificationParams): Promise => { return await this.client.fetchJSS("/classification", "POST", params); }; } diff --git a/src/classification/interfaces.ts b/src/classification/interfaces.ts index a2f345e..7c9a25b 100644 --- a/src/classification/interfaces.ts +++ b/src/classification/interfaces.ts @@ -4,27 +4,14 @@ export interface ClassificationResponse extends BaseResponse { predictions: (string | string[])[]; } -export interface ClassificationTextParams { +export interface ClassificationParams { dataset: Array<{ - type: "text"; + type: "text" | "image"; value: string; }>; labels: Array<{ key?: string; - type: "text"; - value: string; - }>; - multiple_labels?: boolean; -} - -export interface ClassificationImageParams { - dataset: Array<{ - type: "image"; - value: string; - }>; - labels: Array<{ - key?: string; - type: "image" | "text"; + type: "text" | "image"; value: string; }>; multiple_labels?: boolean; diff --git a/src/core.ts b/src/core.ts index 1d3b8aa..e00db8d 100644 --- a/src/core.ts +++ b/src/core.ts @@ -57,6 +57,6 @@ export const JigsawStack = (config?: BaseConfig) => { }, store, validate, - classification, + classification: classification.classify, }; }; From 719385a91e02b7e44cbd66f77fb61717660f9106 Mon Sep 17 00:00:00 2001 From: Win Cheng Date: Tue, 2 Sep 2025 11:00:05 -0700 Subject: [PATCH 10/34] update nsfw --- src/validate/interfaces.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/validate/interfaces.ts b/src/validate/interfaces.ts index b11474f..af711b0 100644 --- a/src/validate/interfaces.ts +++ b/src/validate/interfaces.ts @@ -10,15 +10,6 @@ export interface EmailValidationResponse extends BaseResponse { valid: boolean; } -export interface NSFWValidationResponse extends BaseResponse { - nsfw: boolean; - nudity: boolean; - gore: boolean; - nsfw_score: number; - nudity_score: number; - gore_score: number; -} - export interface ProfanityParams { text: string; censor_replacement?: string; @@ -70,3 +61,12 @@ export interface NSFWParams { url?: string; file_store_key?: string; } + +export interface NSFWValidationResponse extends BaseResponse { + nsfw: boolean; + nudity: boolean; + gore: boolean; + nsfw_score: number; + nudity_score: number; + gore_score: number; +} From 0ae53853709f2db18f503bcb15ad53026da03196 Mon Sep 17 00:00:00 2001 From: Win Cheng Date: Tue, 2 Sep 2025 12:41:29 -0700 Subject: [PATCH 11/34] update scrape --- src/web/interfaces/scrape.ts | 25 +++++++++---------------- src/web/web.ts | 1 - 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/src/web/interfaces/scrape.ts b/src/web/interfaces/scrape.ts index f65d8c7..e337599 100644 --- a/src/web/interfaces/scrape.ts +++ b/src/web/interfaces/scrape.ts @@ -16,16 +16,14 @@ interface CookieParameter { export interface BaseAIScrapeParams { url?: string; html?: string; - root_element_selector?: string; - page_position?: number; http_headers?: object; reject_request_pattern?: string[]; goto_options?: { timeout?: number; wait_until?: "load" | "domcontentloaded" | "networkidle0" | "networkidle2"; - } | null; + }; wait_for?: { - mode: string; + mode: "selector" | "timeout" | "function"; value: string | number; }; advance_config?: { @@ -48,20 +46,15 @@ export interface BaseAIScrapeParams { }; }; features?: Array<"meta" | "link"> | null; + selectors?: Array; } -interface AIScrapeParamsWithSelector extends BaseAIScrapeParams { - selectors: Array; - element_prompts?: string[]; -} - -interface AIScrapeParamsWithPrompts extends BaseAIScrapeParams { - selectors?: Array; +export interface AIScrapeParams extends BaseAIScrapeParams { element_prompts?: string[]; + root_element_selector?: string; + page_position?: number; } -export type AIScrapeParams = AIScrapeParamsWithSelector | AIScrapeParamsWithPrompts; - export interface AIScrapeResponse extends BaseResponse { data: Array<{ key: string; @@ -79,9 +72,9 @@ export interface AIScrapeResponse extends BaseResponse { page_position_length: number; advance_config: | { - console?: any[]; - network?: any[]; - cookies?: any[]; + console?: boolean; + network?: boolean; + cookies?: boolean; } | undefined; context: any; diff --git a/src/web/web.ts b/src/web/web.ts index 6cd7d68..6d5f9ca 100644 --- a/src/web/web.ts +++ b/src/web/web.ts @@ -1,4 +1,3 @@ -import { respToFileChoice } from "../helpers"; import { RequestClient } from "../request"; import { DeepResearchParams, DeepResearchResponse } from "./interfaces/deep_research"; import { HTMLAnyBinaryParams, HTMLAnyBinaryResponse, HTMLAnyParams, HTMLAnyURLParams, HTMLAnyURLResponse } from "./interfaces/html_to_any"; From 897863143e108a8dd0ce585e1b20ac39577faece Mon Sep 17 00:00:00 2001 From: Win Cheng Date: Tue, 2 Sep 2025 12:49:19 -0700 Subject: [PATCH 12/34] update params scrape --- src/web/interfaces/scrape.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/web/interfaces/scrape.ts b/src/web/interfaces/scrape.ts index e337599..a43ad09 100644 --- a/src/web/interfaces/scrape.ts +++ b/src/web/interfaces/scrape.ts @@ -16,7 +16,7 @@ interface CookieParameter { export interface BaseAIScrapeParams { url?: string; html?: string; - http_headers?: object; + http_headers?: Record; reject_request_pattern?: string[]; goto_options?: { timeout?: number; From 2cb2d6b54ec89b93d066d4e30af0be6d37598f0f Mon Sep 17 00:00:00 2001 From: Win Cheng Date: Tue, 2 Sep 2025 14:46:06 -0700 Subject: [PATCH 13/34] update ai scrape types --- src/vision/interfaces.ts | 2 +- src/web/interfaces/scrape.ts | 107 +++++++++++++++++++++++++++++++---- 2 files changed, 96 insertions(+), 13 deletions(-) diff --git a/src/vision/interfaces.ts b/src/vision/interfaces.ts index df65d37..e595ad2 100644 --- a/src/vision/interfaces.ts +++ b/src/vision/interfaces.ts @@ -8,7 +8,7 @@ export type VOCRParams = { }; export interface VOCRResponse extends BaseResponse { - context: string | Record; + context?: string | Record; width: number; height: number; tags: string[]; diff --git a/src/web/interfaces/scrape.ts b/src/web/interfaces/scrape.ts index a43ad09..aa80134 100644 --- a/src/web/interfaces/scrape.ts +++ b/src/web/interfaces/scrape.ts @@ -14,29 +14,29 @@ interface CookieParameter { } export interface BaseAIScrapeParams { - url?: string; - html?: string; - http_headers?: Record; - reject_request_pattern?: string[]; + url?: string | null; + html?: string | null; + http_headers?: Record | null; + reject_request_pattern?: string[] | null; goto_options?: { timeout?: number; wait_until?: "load" | "domcontentloaded" | "networkidle0" | "networkidle2"; - }; + } | null; wait_for?: { mode: "selector" | "timeout" | "function"; value: string | number; - }; + } | null; advance_config?: { console?: boolean; network?: boolean; cookies?: boolean; - }; - size_preset?: string; + } | null; + size_preset?: ScreenSizeNames | null; is_mobile?: boolean; scale?: number; width?: number; height?: number; - cookies?: Array; + cookies?: Array | null; force_rotate_proxy?: boolean; byo_proxy?: { server: string; @@ -44,13 +44,13 @@ export interface BaseAIScrapeParams { username: string; password: string; }; - }; + } | null; features?: Array<"meta" | "link"> | null; - selectors?: Array; + selectors?: Array | null; } export interface AIScrapeParams extends BaseAIScrapeParams { - element_prompts?: string[]; + element_prompts?: string[] | null; root_element_selector?: string; page_position?: number; } @@ -93,3 +93,86 @@ export interface AIScrapeResponse extends BaseResponse { type: "a" | "img"; }>; } + +export type ScreenSizeNames = + | "QVGA" + | "VGA" + | "SVGA" + | "HD" + | "SXGA" + | "HD+" + | "FHD" + | "2K" + | "2K QHD" + | "5K" + | "4K UHD" + | "8K UHD" + | "iPhone 13 Pro" + | "iPhone XR" + | "iPhone XS" + | "iPhone XS Max" + | "iPhone X" + | "iPhone 8 Plus" + | "iPhone 8" + | "iPhone 7 Plus" + | "iPhone 7" + | "iPhone 6 Plus/6S Plus" + | "iPhone 6/6S" + | "iPhone 5" + | "iPod Touch" + | "iPad Pro" + | "iPad Third & Fourth Generation" + | "iPad Air 1 & 2" + | "iPad Mini 2 & 3" + | "iPad Mini" + | "Nexus 6P" + | "Nexus 5X" + | "Google Pixel 7 Pro" + | "Google Pixel 4 XL" + | "Google Pixel 4" + | "Google Pixel 3a XL" + | "Google Pixel 3a" + | "Google Pixel 3 XL" + | "Google Pixel 3" + | "Google Pixel 2 XL" + | "Google Pixel XL" + | "Google Pixel" + | "Samsung Galaxy Note 10+" + | "Samsung Galaxy Note 10" + | "Samsung Galaxy Note 9" + | "Samsung Galaxy Note 5" + | "LG G5" + | "One Plus 3" + | "Samsung Galaxy S9+" + | "Samsung Galaxy S9" + | "Samsung Galaxy S8+" + | "Samsung Galaxy S8" + | "Samsung Galaxy S7 Edge" + | "Samsung Galaxy S7" + | "Nexus 9" + | "Nexus 7 (2013)" + | "Pixel C" + | "Samsung Galaxy Tab 10" + | "Chromebook Pixel" + | "Letter" + | "Legal" + | "Tabloid" + | "Ledger" + | "A0" + | "A1" + | "A2" + | "A3" + | "A4" + | "A5" + | "A6" + | "Letter landscape" + | "Legal landscape" + | "Tabloid landscape" + | "Ledger landscape" + | "A0 landscape" + | "A1 landscape" + | "A2 landscape" + | "A3 landscape" + | "A4 landscape" + | "A5 landscape" + | "A6 landscape"; From 97142259b01b33e334bb52af1ef1dcb47b204084 Mon Sep 17 00:00:00 2001 From: Win Cheng Date: Tue, 2 Sep 2025 15:19:03 -0700 Subject: [PATCH 14/34] update scrape advance config response --- src/web/interfaces/scrape.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/web/interfaces/scrape.ts b/src/web/interfaces/scrape.ts index aa80134..69edc21 100644 --- a/src/web/interfaces/scrape.ts +++ b/src/web/interfaces/scrape.ts @@ -72,9 +72,16 @@ export interface AIScrapeResponse extends BaseResponse { page_position_length: number; advance_config: | { - console?: boolean; - network?: boolean; - cookies?: boolean; + console?: any; + network?: { + url: string; + method: string; + status: number; + headers: Record; + body: string | null; + type: "request" | "response"; + }; + cookies?: any; } | undefined; context: any; From 3cf98737e892a1713f9aa3072a4f1d64c399d08e Mon Sep 17 00:00:00 2001 From: Win Cheng Date: Tue, 2 Sep 2025 15:22:03 -0700 Subject: [PATCH 15/34] updated classification test to match new classification --- tests/classification.test.ts | 62 ++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/tests/classification.test.ts b/tests/classification.test.ts index d8f3206..7fdcfa8 100644 --- a/tests/classification.test.ts +++ b/tests/classification.test.ts @@ -77,7 +77,7 @@ describe("Text Classification API", () => { // Test missing required parameters test("should fail when no parameters are provided", async () => { try { - await client.classification.text({} as any); + await client.classification({} as any); throw new Error("Expected API call to fail with no parameters"); } catch (error) { expectType(error, "object"); @@ -86,7 +86,7 @@ describe("Text Classification API", () => { test("should fail when dataset is missing", async () => { try { - await client.classification.text({ + await client.classification({ labels: TEXT_LABELS, } as any); throw new Error("Expected API call to fail with missing dataset"); @@ -97,7 +97,7 @@ describe("Text Classification API", () => { test("should fail when labels are missing", async () => { try { - await client.classification.text({ + await client.classification({ dataset: TEST_TEXT_DATA, labels: [], } as any); @@ -109,7 +109,7 @@ describe("Text Classification API", () => { test("should fail when dataset is empty", async () => { try { - await client.classification.text({ + await client.classification({ dataset: [], labels: TEXT_LABELS, }); @@ -121,7 +121,7 @@ describe("Text Classification API", () => { // Basic functionality tests test("should work with basic text classification", async () => { - const result = await client.classification.text({ + const result = await client.classification({ dataset: [ { type: "text" as const, value: "This is a great product! I love it." }, { type: "text" as const, value: "This is a great product! I hate it." }, @@ -145,7 +145,7 @@ describe("Text Classification API", () => { }); test("should work with multiple text samples", async () => { - const result = await client.classification.text({ + const result = await client.classification({ dataset: [ { type: "text" as const, value: "This is a great product! I love it." }, { type: "text" as const, value: "This product is terrible and broken." }, @@ -168,7 +168,7 @@ describe("Text Classification API", () => { }); test("should work with multiple_labels enabled", async () => { - const result = await client.classification.text({ + const result = await client.classification({ dataset: [{ type: "text" as const, value: "This is a great product with excellent customer service!" }], labels: [ { key: "quality", type: "text" as const, value: "relates to product quality" }, @@ -193,7 +193,7 @@ describe("Text Classification API", () => { }); test("should work with multiple_labels disabled", async () => { - const result = await client.classification.text({ + const result = await client.classification({ dataset: [{ type: "text" as const, value: "This is a great product! I love it." }], labels: [ { key: "positive", type: "text" as const, value: "positive sentiment" }, @@ -210,7 +210,7 @@ describe("Text Classification API", () => { test("should work with long text", async () => { const longText = "This is a comprehensive review of a product that I purchased recently. ".repeat(10); - const result = await client.classification.text({ + const result = await client.classification({ dataset: [{ type: "text" as const, value: longText }], labels: [ { key: "review", type: "text" as const, value: "product review" }, @@ -223,7 +223,7 @@ describe("Text Classification API", () => { }); test("should work with special characters and unicode", async () => { - const result = await client.classification.text({ + const result = await client.classification({ dataset: [{ type: "text" as const, value: "¡Excelente producto! 🚀 Me encanta. Ñoño café français." }], labels: [ { key: "positive", type: "text" as const, value: "positive sentiment" }, @@ -245,7 +245,7 @@ describe("Text Classification API", () => { }); } - const result = await client.classification.text({ + const result = await client.classification({ dataset: [{ type: "text" as const, value: "This is a test text for classification." }], labels: labels, }); @@ -257,7 +257,7 @@ describe("Text Classification API", () => { // Edge cases and error handling test("should handle empty text gracefully", async () => { try { - const result = await client.classification.text({ + const result = await client.classification({ dataset: [{ type: "text" as const, value: "" }], labels: [ { key: "empty", type: "text" as const, value: "empty text" }, @@ -275,7 +275,7 @@ describe("Text Classification API", () => { test("should handle whitespace-only text", async () => { try { - const result = await client.classification.text({ + const result = await client.classification({ dataset: [{ type: "text" as const, value: " \n\t " }], labels: [ { key: "whitespace", type: "text" as const, value: "whitespace content" }, @@ -293,7 +293,7 @@ describe("Text Classification API", () => { test("should fail with invalid dataset type", async () => { try { - await client.classification.text({ + await client.classification({ dataset: [{ type: "image" as any, value: "This is a great product! I love it." }], labels: [{ key: "positive", type: "text" as const, value: "positive sentiment" }], } as any); @@ -305,7 +305,7 @@ describe("Text Classification API", () => { test("should fail with invalid label type", async () => { try { - await client.classification.text({ + await client.classification({ dataset: [{ type: "text" as const, value: "This is a great product! I love it." }], labels: [{ key: "positive", type: "image" as any, value: "positive sentiment" }], } as any); @@ -327,7 +327,7 @@ describe("Image Classification API", () => { // Test missing required parameters test("should fail when no parameters are provided", async () => { try { - await client.classification.image({} as any); + await client.classification({} as any); throw new Error("Expected API call to fail with no parameters"); } catch (error) { expectType(error, "object"); @@ -336,7 +336,7 @@ describe("Image Classification API", () => { test("should fail when dataset is missing", async () => { try { - await client.classification.image({ + await client.classification({ labels: IMAGE_LABELS, } as any); throw new Error("Expected API call to fail with missing dataset"); @@ -347,7 +347,7 @@ describe("Image Classification API", () => { test("should fail when labels are missing", async () => { try { - await client.classification.image({ + await client.classification({ dataset: TEST_IMAGE_DATA, } as any); throw new Error("Expected API call to fail with missing labels"); @@ -358,7 +358,7 @@ describe("Image Classification API", () => { test("should fail when dataset is empty", async () => { try { - await client.classification.image({ + await client.classification({ dataset: [], labels: IMAGE_LABELS, }); @@ -370,7 +370,7 @@ describe("Image Classification API", () => { test("should fail when labels are empty", async () => { try { - await client.classification.image({ + await client.classification({ dataset: TEST_IMAGE_DATA, labels: [], }); @@ -382,7 +382,7 @@ describe("Image Classification API", () => { // Basic functionality tests test("should work with basic image classification", async () => { - const result = await client.classification.image({ + const result = await client.classification({ dataset: TEST_IMAGE_DATA, labels: IMAGE_LABELS, }); @@ -404,7 +404,7 @@ describe("Image Classification API", () => { }); test("should work with multiple images", async () => { - const result = await client.classification.image({ + const result = await client.classification({ dataset: [ { type: "image" as const, value: "https://as2.ftcdn.net/v2/jpg/02/24/11/57/1000_F_224115780_2ssvcCoTfQrx68Qsl5NxtVIDFWKtAgq2.jpg" }, { type: "image" as const, value: "https://t3.ftcdn.net/jpg/02/95/44/22/240_F_295442295_OXsXOmLmqBUfZreTnGo9PREuAPSLQhff.jpg" }, @@ -425,7 +425,7 @@ describe("Image Classification API", () => { }); test("should work with multiple_labels enabled for images", async () => { - const result = await client.classification.image({ + const result = await client.classification({ dataset: [{ type: "image" as const, value: "https://as2.ftcdn.net/v2/jpg/02/24/11/57/1000_F_224115780_2ssvcCoTfQrx68Qsl5NxtVIDFWKtAgq2.jpg" }], labels: [ { key: "banana", type: "text" as const, value: "banana" }, @@ -449,7 +449,7 @@ describe("Image Classification API", () => { }); test("should work with multiple_labels disabled for images", async () => { - const result = await client.classification.image({ + const result = await client.classification({ dataset: [{ type: "image" as const, value: "https://as2.ftcdn.net/v2/jpg/02/24/11/57/1000_F_224115780_2ssvcCoTfQrx68Qsl5NxtVIDFWKtAgq2.jpg" }], labels: [ { key: "banana", type: "text" as const, value: "banana" }, @@ -475,7 +475,7 @@ describe("Image Classification API", () => { }); } - const result = await client.classification.image({ + const result = await client.classification({ dataset: [{ type: "image" as const, value: "https://as2.ftcdn.net/v2/jpg/02/24/11/57/1000_F_224115780_2ssvcCoTfQrx68Qsl5NxtVIDFWKtAgq2.jpg" }], labels: labels, }); @@ -487,7 +487,7 @@ describe("Image Classification API", () => { // Edge cases and error handling test("should handle invalid image URL gracefully", async () => { try { - await client.classification.image({ + await client.classification({ dataset: [{ type: "image" as const, value: "not-a-valid-url" }], labels: [{ key: "banana", type: "text" as const, value: "banana" }], }); @@ -499,7 +499,7 @@ describe("Image Classification API", () => { test("should handle empty image URL", async () => { try { - await client.classification.image({ + await client.classification({ dataset: [{ type: "image" as const, value: "" }], labels: [{ key: "banana", type: "text" as const, value: "banana" }], }); @@ -511,7 +511,7 @@ describe("Image Classification API", () => { test("should fail with invalid dataset type", async () => { try { - await client.classification.image({ + await client.classification({ dataset: [{ type: "text" as any, value: "https://as2.ftcdn.net/v2/jpg/02/24/11/57/1000_F_224115780_2ssvcCoTfQrx68Qsl5NxtVIDFWKtAgq2.jpg" }], labels: [{ key: "banana", type: "text" as const, value: "banana" }], } as any); @@ -523,7 +523,7 @@ describe("Image Classification API", () => { test("should fail with invalid label type", async () => { try { - await client.classification.image({ + await client.classification({ dataset: [ { type: "image" as const, value: "https://as2.ftcdn.net/v2/jpg/02/24/11/57/1000_F_224115780_2ssvcCoTfQrx68Qsl5NxtVIDFWKtAgq2.jpg" }, ], @@ -537,7 +537,7 @@ describe("Image Classification API", () => { // Complex scenario test test("should work with comprehensive image classification configuration", async () => { - const result = await client.classification.image({ + const result = await client.classification({ dataset: [ { type: "image" as const, value: "https://as2.ftcdn.net/v2/jpg/02/24/11/57/1000_F_224115780_2ssvcCoTfQrx68Qsl5NxtVIDFWKtAgq2.jpg" }, { type: "image" as const, value: "https://t3.ftcdn.net/jpg/02/95/44/22/240_F_295442295_OXsXOmLmqBUfZreTnGo9PREuAPSLQhff.jpg" }, @@ -572,7 +572,7 @@ describe("Classification API Edge Cases", () => { }); } - const result = await client.classification.text({ + const result = await client.classification({ dataset: dataset, labels: [ { key: "test", type: "text" as const, value: "test content" }, From 3a3064a1ce95b41939ae19b77669097105d26d81 Mon Sep 17 00:00:00 2001 From: Win Cheng Date: Wed, 3 Sep 2025 09:30:21 -0700 Subject: [PATCH 16/34] update web search --- src/web/interfaces/scrape.ts | 8 +- src/web/interfaces/search.ts | 209 +++++++++++++++++++++++++++++++++-- 2 files changed, 200 insertions(+), 17 deletions(-) diff --git a/src/web/interfaces/scrape.ts b/src/web/interfaces/scrape.ts index 69edc21..8af7e4e 100644 --- a/src/web/interfaces/scrape.ts +++ b/src/web/interfaces/scrape.ts @@ -2,15 +2,13 @@ import { BaseResponse } from "../../../types"; interface CookieParameter { name: string; value: string; - url?: string; domain?: string; - path?: string; + url?: string; secure?: boolean; httpOnly?: boolean; - sameSite?: "Strict" | "Lax" | "None"; - expires?: boolean; - priority?: string; sameParty?: boolean; + expires?: number; + priority?: "Low" | "High" | "Medium"; } export interface BaseAIScrapeParams { diff --git a/src/web/interfaces/search.ts b/src/web/interfaces/search.ts index 4254088..f0a06c4 100644 --- a/src/web/interfaces/search.ts +++ b/src/web/interfaces/search.ts @@ -6,15 +6,8 @@ export interface SearchParams { safe_search?: "strict" | "moderate" | "off"; ai_overview?: boolean; byo_urls?: string[]; - country_code?: string; + country_code?: CountryCode; auto_scrape?: boolean; - deep_research?: boolean; - deep_research_config?: { - max_depth?: number; - max_breadth?: number; - max_output_tokens?: number; - target_output_tokens?: number; - }; } interface RelatedIndex { @@ -29,7 +22,7 @@ export interface SearchResponse extends BaseResponse { ai_overview?: string; spell_fixed: boolean; is_safe: boolean; - results: { + results: Array<{ title: string; url: string; description: string; @@ -48,10 +41,10 @@ export interface SearchResponse extends BaseResponse { favicon: string; snippets: string[]; related_index: RelatedIndex[]; - }[]; + }>; image_urls: string[]; links: string[]; - geo_results: { + geo_results: Array<{ type: string; full_address: string; name: string; @@ -69,9 +62,201 @@ export interface SearchResponse extends BaseResponse { }; poi_category?: string; additional_properties?: any; - }[]; + }>; } export interface SuggestionResponse extends BaseResponse { suggestions: string[]; } + +export type CountryCode = + | "BEN" + | "ARG" + | "AGO" + | "ARM" + | "IRN" + | "NRU" + | "ITA" + | "MLI" + | "AUS" + | "UGA" + | "AUT" + | "TUR" + | "AND" + | "AFG" + | "ALB" + | "DZA" + | "ASM" + | "AZE" + | "BHR" + | "BGD" + | "BRB" + | "BLR" + | "BEL" + | "BTN" + | "BOL" + | "BWA" + | "BRA" + | "BRN" + | "BGR" + | "BFA" + | "KHM" + | "CMR" + | "CAN" + | "CPV" + | "CAF" + | "TCD" + | "CHL" + | "CHN" + | "COL" + | "COK" + | "CRI" + | "HRV" + | "CUB" + | "CYP" + | "CZE" + | "DNK" + | "DMA" + | "DOM" + | "ECU" + | "EGY" + | "EST" + | "ETH" + | "SLV" + | "FIN" + | "FRA" + | "GAB" + | "GEO" + | "IRL" + | "DEU" + | "GHA" + | "GRC" + | "GRL" + | "GTM" + | "GIN" + | "GNB" + | "GUY" + | "HTI" + | "HND" + | "HUN" + | "IND" + | "IDN" + | "IRQ" + | "ISL" + | "HKG" + | "ISR" + | "JAM" + | "JPN" + | "JOR" + | "KAZ" + | "KEN" + | "KIR" + | "KWT" + | "KGZ" + | "LAO" + | "LVA" + | "LBN" + | "LSO" + | "LBR" + | "LBY" + | "LIE" + | "LTU" + | "LUX" + | "MAC" + | "MDG" + | "MWI" + | "MYS" + | "MDV" + | "MLT" + | "MUS" + | "MEX" + | "FSM" + | "MDA" + | "MCO" + | "MNG" + | "MNE" + | "MAR" + | "MOZ" + | "MMR" + | "NAM" + | "NPL" + | "NLD" + | "NZL" + | "NIC" + | "NER" + | "NGA" + | "NIU" + | "MKD" + | "NOR" + | "OMN" + | "PAK" + | "PAN" + | "PRY" + | "PER" + | "PHL" + | "POL" + | "PRT" + | "PRI" + | "QAT" + | "ROU" + | "RUS" + | "RWA" + | "KNA" + | "WSM" + | "SMR" + | "SAU" + | "SEN" + | "SRB" + | "SYC" + | "SLE" + | "SVK" + | "SVN" + | "SLB" + | "SOM" + | "ZAF" + | "SGP" + | "KOR" + | "SSD" + | "ESP" + | "LKA" + | "SDN" + | "SUR" + | "SWE" + | "CHE" + | "SYR" + | "TWN" + | "TJK" + | "TZA" + | "THA" + | "BHS" + | "TGO" + | "TON" + | "TKM" + | "UKR" + | "ARE" + | "GBR" + | "USA" + | "URY" + | "UZB" + | "VUT" + | "VEN" + | "VNM" + | "TUN" + | "ZMB" + | "ZWE" + | "BIH" + | "COG" + | "CIV" + | "COD" + | "DJI" + | "GNQ" + | "ERI" + | "MRT" + | "PNG" + | "TTO" + | "YEM" + | "BLZ" + | "BDI" + | "COM" + | "SWZ" + | "GMB"; From 62b96ee377ec55bbbaf56992ef996df79415f91f Mon Sep 17 00:00:00 2001 From: Win Cheng Date: Wed, 3 Sep 2025 10:32:32 -0700 Subject: [PATCH 17/34] update spell check --- src/validate/interfaces.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/validate/interfaces.ts b/src/validate/interfaces.ts index af711b0..cb24051 100644 --- a/src/validate/interfaces.ts +++ b/src/validate/interfaces.ts @@ -34,7 +34,7 @@ export interface SpellCheckParams { export interface SpellCheckValidationResponse extends BaseResponse { misspellings_found: boolean; misspellings: Array<{ - word: string; + word: string | null; startIndex: number; endIndex: number; expected: string[]; From 36042b78e339b0911e55864d2eb075e27ab96186 Mon Sep 17 00:00:00 2001 From: Win Cheng Date: Wed, 3 Sep 2025 11:27:56 -0700 Subject: [PATCH 18/34] update spam check --- src/validate/interfaces.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/validate/interfaces.ts b/src/validate/interfaces.ts index cb24051..07a0c29 100644 --- a/src/validate/interfaces.ts +++ b/src/validate/interfaces.ts @@ -51,10 +51,10 @@ export interface SpamCheckValidationResponse extends BaseResponse { } export interface SpamCheckValidationArrayResponse extends BaseResponse { - check: { + check: Array<{ is_spam: boolean; score: number; - }[]; + }>; } export interface NSFWParams { From bd0f986b148a96a11289c7ff9a37247ff7eefe49 Mon Sep 17 00:00:00 2001 From: Win Cheng Date: Wed, 3 Sep 2025 12:00:05 -0700 Subject: [PATCH 19/34] update spamcheck --- src/validate/index.ts | 10 ++++------ src/vercel-ai-toolkit.ts | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/validate/index.ts b/src/validate/index.ts index 586443a..d69e57a 100644 --- a/src/validate/index.ts +++ b/src/validate/index.ts @@ -12,9 +12,7 @@ import { } from "./interfaces"; class Validate { - constructor(private readonly client: RequestClient) { - this.spamcheck = this.spamcheck.bind(this); - } + constructor(private readonly client: RequestClient) {} nsfw(params: NSFWParams): Promise; nsfw(file: Blob | Buffer, params?: Omit): Promise; @@ -34,9 +32,9 @@ class Validate { return await this.client.fetchJSS("/validate/spell_check", "POST", { text, language_code }); }; - spamcheck(text: string): Promise; - spamcheck(text: string[]): Promise; - async spamcheck(text: string | string[]): Promise { + spamcheck({ text }: { text: string }): Promise; + spamcheck({ text }: { text: string[] }): Promise; + async spamcheck({ text }: { text: string | string[] }): Promise { return await this.client.fetchJSS("/validate/spam_check", "POST", { text }); } } diff --git a/src/vercel-ai-toolkit.ts b/src/vercel-ai-toolkit.ts index a6bcb91..63dfd8d 100644 --- a/src/vercel-ai-toolkit.ts +++ b/src/vercel-ai-toolkit.ts @@ -332,7 +332,7 @@ export class JigsawStackToolSet { text: z.string().describe("Text to check for spam"), }), execute: async ({ text }) => { - return await this.jigsawStack.validate.spamcheck(text); + return await this.jigsawStack.validate.spamcheck({ text }); }, }), }; From f381d1c7dfd29af2be5091e4a41ae17acef17089 Mon Sep 17 00:00:00 2001 From: Win Cheng Date: Wed, 3 Sep 2025 13:03:19 -0700 Subject: [PATCH 20/34] update html to any --- src/core.ts | 2 +- src/vercel-ai-toolkit.ts | 2 +- src/web/interfaces/html_to_any.ts | 35 ++++++++++++++++--------------- 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/src/core.ts b/src/core.ts index e00db8d..25d335e 100644 --- a/src/core.ts +++ b/src/core.ts @@ -51,7 +51,7 @@ export const JigsawStack = (config?: BaseConfig) => { }, web: { ai_scrape: web.ai_scrape, - html_to_any: web.html_to_any, + html_to_any: createBoundMethod(web, web.html_to_any), search: web.search, search_suggestions: web.search_suggestions, }, diff --git a/src/vercel-ai-toolkit.ts b/src/vercel-ai-toolkit.ts index 63dfd8d..2c08205 100644 --- a/src/vercel-ai-toolkit.ts +++ b/src/vercel-ai-toolkit.ts @@ -179,7 +179,7 @@ export class JigsawStackToolSet { parameters: z.object({ html: z.string().optional().describe("HTML content to convert"), url: z.string().optional().describe("URL of webpage to convert"), - type: z.string().optional().describe("Output format type"), + type: z.enum(["pdf", "png", "jpeg", "webp"]).optional().describe("Output format type"), width: z.number().optional().describe("Output width"), height: z.number().optional().describe("Output height"), full_page: z.boolean().optional().describe("Capture full page"), diff --git a/src/web/interfaces/html_to_any.ts b/src/web/interfaces/html_to_any.ts index 641d760..7761144 100644 --- a/src/web/interfaces/html_to_any.ts +++ b/src/web/interfaces/html_to_any.ts @@ -1,27 +1,28 @@ import { BaseResponse } from "../../../types"; +import { ScreenSizeNames } from "./scrape"; export interface HTMLAnyParams { - html?: string; - url?: string; - use_graphic_renderer?: boolean; - dark_mode?: boolean; - is_mobile?: boolean; - pdf_page_range?: string; - pdf_print_background?: boolean; - pdf_display_header_footer?: boolean; - size_preset?: string; + html?: string | null; + url?: string | null; + goto_options?: { + timeout: number; + wait_until: "load" | "domcontentloaded" | "networkidle0" | "networkidle2"; + } | null; + full_page?: boolean; + omit_background?: boolean; + type?: "pdf" | "png" | "jpeg" | "webp"; height?: number; width?: number; - type?: string; - quality?: number; - omit_background?: boolean; - full_page?: boolean; scale?: number; - goto_options?: { - timeout: number; - wait_until: string; - }; + is_mobile?: boolean; + dark_mode?: boolean; + use_graphic_renderer?: boolean; + size_preset?: ScreenSizeNames | null; + pdf_display_header_footer?: boolean; + pdf_print_background?: boolean; + pdf_page_range?: string | null; return_type?: "url" | "binary" | "base64"; + quality?: number; } // response for "url" and "base64" return types (both return url string) From 36a5a1c7679244ce064ab5cd273d27f1ff8f9c1e Mon Sep 17 00:00:00 2001 From: Win Cheng Date: Wed, 3 Sep 2025 13:38:44 -0700 Subject: [PATCH 21/34] add object to vocr prompts --- src/vision/interfaces.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vision/interfaces.ts b/src/vision/interfaces.ts index e595ad2..45d9137 100644 --- a/src/vision/interfaces.ts +++ b/src/vision/interfaces.ts @@ -1,7 +1,7 @@ import { BaseResponse } from "../../types"; export type VOCRParams = { - prompt?: string | string[]; + prompt?: string | string[] | Record; url?: string; file_store_key?: string; page_range?: Array; From 0a4e5ea1af2f7e7b049a6ba2fa371c0182e1fe90 Mon Sep 17 00:00:00 2001 From: Win Cheng Date: Wed, 3 Sep 2025 14:12:13 -0700 Subject: [PATCH 22/34] update deep research --- src/web/interfaces/deep_research.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/web/interfaces/deep_research.ts b/src/web/interfaces/deep_research.ts index 0357ff2..f7be613 100644 --- a/src/web/interfaces/deep_research.ts +++ b/src/web/interfaces/deep_research.ts @@ -1,10 +1,11 @@ import { BaseResponse } from "../../../types"; +import { CountryCode } from "./search"; // Input parameters interface for reference export interface DeepResearchParams { query: string; spell_check?: boolean; safe_search?: "strict" | "moderate" | "off"; - country_code?: string; + country_code?: CountryCode | null; max_depth?: number; max_breadth?: number; max_output_tokens?: number; From 8456c562d7abf42a9af9dc2513f3b05a9b57b54d Mon Sep 17 00:00:00 2001 From: Win Cheng Date: Wed, 3 Sep 2025 14:29:29 -0700 Subject: [PATCH 23/34] update deep research --- src/core.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/core.ts b/src/core.ts index 25d335e..f456478 100644 --- a/src/core.ts +++ b/src/core.ts @@ -54,6 +54,7 @@ export const JigsawStack = (config?: BaseConfig) => { html_to_any: createBoundMethod(web, web.html_to_any), search: web.search, search_suggestions: web.search_suggestions, + deep_research: web.deep_research, }, store, validate, From 950df4ecf92137dd5bc9a3972864d3c77de33076 Mon Sep 17 00:00:00 2001 From: Win Cheng Date: Wed, 3 Sep 2025 14:36:04 -0700 Subject: [PATCH 24/34] update search suggestions --- src/vercel-ai-toolkit.ts | 2 +- src/web/web.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/vercel-ai-toolkit.ts b/src/vercel-ai-toolkit.ts index 2c08205..46f87e5 100644 --- a/src/vercel-ai-toolkit.ts +++ b/src/vercel-ai-toolkit.ts @@ -225,7 +225,7 @@ export class JigsawStackToolSet { query: z.string().describe("Query to get suggestions for"), }), execute: async ({ query }) => { - return await this.jigsawStack.web.search_suggestions(query); + return await this.jigsawStack.web.search_suggestions({ query }); }, }), diff --git a/src/web/web.ts b/src/web/web.ts index 6d5f9ca..9e90173 100644 --- a/src/web/web.ts +++ b/src/web/web.ts @@ -29,7 +29,7 @@ class Web { search = async (params: SearchParams): Promise => { return await this.client.fetchJSS("/web/search", "POST", params); }; - search_suggestions = async (query: string): Promise => { + search_suggestions = async ({ query }: { query: string }): Promise => { return await this.client.fetchJSS(`/web/search/suggest?query=${query}`, "GET", undefined); }; } From d5aea5d61a10fbd652ec9b61f1cb149a4fafa8e8 Mon Sep 17 00:00:00 2001 From: Win Cheng Date: Wed, 3 Sep 2025 14:56:22 -0700 Subject: [PATCH 25/34] add types to utils --- src/audio/interfaces.ts | 165 +---------- src/general/interfaces.ts | 2 +- src/utils.ts | 439 ++++++++++++++++++++++++++++ src/vercel-ai-toolkit.ts | 2 +- src/web/interfaces/deep_research.ts | 2 +- src/web/interfaces/html_to_any.ts | 2 +- src/web/interfaces/scrape.ts | 85 +----- src/web/interfaces/search.ts | 193 +----------- 8 files changed, 447 insertions(+), 443 deletions(-) diff --git a/src/audio/interfaces.ts b/src/audio/interfaces.ts index 5b09732..288bd2b 100644 --- a/src/audio/interfaces.ts +++ b/src/audio/interfaces.ts @@ -1,4 +1,5 @@ import { BaseResponse } from "../../types"; +import { LanguageCodes } from "../utils"; export interface SpeechToTextParams { url?: string; @@ -36,167 +37,3 @@ export interface SpeechToTextWebhookResponse extends BaseResponse { status: "processing" | "error"; id: string; } - -export type LanguageCodes = - | "af" - | "am" - | "ar" - | "as" - | "az" - | "ba" - | "be" - | "bg" - | "bn" - | "bo" - | "br" - | "bs" - | "ca" - | "ch" - | "co" - | "cs" - | "cy" - | "da" - | "de" - | "dv" - | "dz" - | "el" - | "en" - | "eo" - | "es" - | "et" - | "eu" - | "fa" - | "ff" - | "fi" - | "fj" - | "fo" - | "fr" - | "fy" - | "ga" - | "gd" - | "gl" - | "gu" - | "gv" - | "ha" - | "he" - | "hi" - | "hr" - | "ht" - | "hu" - | "hy" - | "id" - | "ig" - | "is" - | "it" - | "iu" - | "ja" - | "jv" - | "ka" - | "kg" - | "ki" - | "kj" - | "kk" - | "kl" - | "km" - | "kn" - | "ko" - | "kr" - | "ks" - | "ku" - | "kv" - | "kw" - | "ky" - | "la" - | "lb" - | "lg" - | "li" - | "ln" - | "lo" - | "lt" - | "lu" - | "lv" - | "mg" - | "mh" - | "mi" - | "mk" - | "ml" - | "mn" - | "mo" - | "mr" - | "ms" - | "mt" - | "my" - | "na" - | "nb" - | "nd" - | "ne" - | "ng" - | "nl" - | "nn" - | "no" - | "nr" - | "nv" - | "ny" - | "oc" - | "oj" - | "om" - | "or" - | "os" - | "pa" - | "pi" - | "pl" - | "ps" - | "pt" - | "qu" - | "rm" - | "rn" - | "ro" - | "ru" - | "rw" - | "sa" - | "sc" - | "sd" - | "se" - | "sg" - | "sh" - | "si" - | "sk" - | "sl" - | "sm" - | "sn" - | "so" - | "sq" - | "sr" - | "ss" - | "st" - | "su" - | "sv" - | "sw" - | "ta" - | "te" - | "tg" - | "th" - | "ti" - | "tk" - | "tl" - | "tn" - | "to" - | "tr" - | "ts" - | "tt" - | "tw" - | "ty" - | "ug" - | "uk" - | "ur" - | "uz" - | "ve" - | "vi" - | "vo" - | "wo" - | "xh" - | "yi" - | "yo" - | "zh" - | "zh-TW" - | "zu"; diff --git a/src/general/interfaces.ts b/src/general/interfaces.ts index eb3ad46..1c4e9cf 100644 --- a/src/general/interfaces.ts +++ b/src/general/interfaces.ts @@ -47,9 +47,9 @@ export interface TranslateResponse extends BaseResponse { } export interface TranslateParams { + text: string | string[]; current_language?: string; target_language: string; - text: string | string[]; } export type TranslateImageParams = { diff --git a/src/utils.ts b/src/utils.ts index a189153..8bd3e73 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -34,3 +34,442 @@ export function createFileUploadFormData(file: Blob | Buffer, options?: Record; } - -export type ScreenSizeNames = - | "QVGA" - | "VGA" - | "SVGA" - | "HD" - | "SXGA" - | "HD+" - | "FHD" - | "2K" - | "2K QHD" - | "5K" - | "4K UHD" - | "8K UHD" - | "iPhone 13 Pro" - | "iPhone XR" - | "iPhone XS" - | "iPhone XS Max" - | "iPhone X" - | "iPhone 8 Plus" - | "iPhone 8" - | "iPhone 7 Plus" - | "iPhone 7" - | "iPhone 6 Plus/6S Plus" - | "iPhone 6/6S" - | "iPhone 5" - | "iPod Touch" - | "iPad Pro" - | "iPad Third & Fourth Generation" - | "iPad Air 1 & 2" - | "iPad Mini 2 & 3" - | "iPad Mini" - | "Nexus 6P" - | "Nexus 5X" - | "Google Pixel 7 Pro" - | "Google Pixel 4 XL" - | "Google Pixel 4" - | "Google Pixel 3a XL" - | "Google Pixel 3a" - | "Google Pixel 3 XL" - | "Google Pixel 3" - | "Google Pixel 2 XL" - | "Google Pixel XL" - | "Google Pixel" - | "Samsung Galaxy Note 10+" - | "Samsung Galaxy Note 10" - | "Samsung Galaxy Note 9" - | "Samsung Galaxy Note 5" - | "LG G5" - | "One Plus 3" - | "Samsung Galaxy S9+" - | "Samsung Galaxy S9" - | "Samsung Galaxy S8+" - | "Samsung Galaxy S8" - | "Samsung Galaxy S7 Edge" - | "Samsung Galaxy S7" - | "Nexus 9" - | "Nexus 7 (2013)" - | "Pixel C" - | "Samsung Galaxy Tab 10" - | "Chromebook Pixel" - | "Letter" - | "Legal" - | "Tabloid" - | "Ledger" - | "A0" - | "A1" - | "A2" - | "A3" - | "A4" - | "A5" - | "A6" - | "Letter landscape" - | "Legal landscape" - | "Tabloid landscape" - | "Ledger landscape" - | "A0 landscape" - | "A1 landscape" - | "A2 landscape" - | "A3 landscape" - | "A4 landscape" - | "A5 landscape" - | "A6 landscape"; diff --git a/src/web/interfaces/search.ts b/src/web/interfaces/search.ts index f0a06c4..8d77c4d 100644 --- a/src/web/interfaces/search.ts +++ b/src/web/interfaces/search.ts @@ -1,4 +1,5 @@ import { BaseResponse } from "../../../types"; +import { CountryCode } from "../../utils"; export interface SearchParams { query: string; spell_check?: boolean; @@ -68,195 +69,3 @@ export interface SearchResponse extends BaseResponse { export interface SuggestionResponse extends BaseResponse { suggestions: string[]; } - -export type CountryCode = - | "BEN" - | "ARG" - | "AGO" - | "ARM" - | "IRN" - | "NRU" - | "ITA" - | "MLI" - | "AUS" - | "UGA" - | "AUT" - | "TUR" - | "AND" - | "AFG" - | "ALB" - | "DZA" - | "ASM" - | "AZE" - | "BHR" - | "BGD" - | "BRB" - | "BLR" - | "BEL" - | "BTN" - | "BOL" - | "BWA" - | "BRA" - | "BRN" - | "BGR" - | "BFA" - | "KHM" - | "CMR" - | "CAN" - | "CPV" - | "CAF" - | "TCD" - | "CHL" - | "CHN" - | "COL" - | "COK" - | "CRI" - | "HRV" - | "CUB" - | "CYP" - | "CZE" - | "DNK" - | "DMA" - | "DOM" - | "ECU" - | "EGY" - | "EST" - | "ETH" - | "SLV" - | "FIN" - | "FRA" - | "GAB" - | "GEO" - | "IRL" - | "DEU" - | "GHA" - | "GRC" - | "GRL" - | "GTM" - | "GIN" - | "GNB" - | "GUY" - | "HTI" - | "HND" - | "HUN" - | "IND" - | "IDN" - | "IRQ" - | "ISL" - | "HKG" - | "ISR" - | "JAM" - | "JPN" - | "JOR" - | "KAZ" - | "KEN" - | "KIR" - | "KWT" - | "KGZ" - | "LAO" - | "LVA" - | "LBN" - | "LSO" - | "LBR" - | "LBY" - | "LIE" - | "LTU" - | "LUX" - | "MAC" - | "MDG" - | "MWI" - | "MYS" - | "MDV" - | "MLT" - | "MUS" - | "MEX" - | "FSM" - | "MDA" - | "MCO" - | "MNG" - | "MNE" - | "MAR" - | "MOZ" - | "MMR" - | "NAM" - | "NPL" - | "NLD" - | "NZL" - | "NIC" - | "NER" - | "NGA" - | "NIU" - | "MKD" - | "NOR" - | "OMN" - | "PAK" - | "PAN" - | "PRY" - | "PER" - | "PHL" - | "POL" - | "PRT" - | "PRI" - | "QAT" - | "ROU" - | "RUS" - | "RWA" - | "KNA" - | "WSM" - | "SMR" - | "SAU" - | "SEN" - | "SRB" - | "SYC" - | "SLE" - | "SVK" - | "SVN" - | "SLB" - | "SOM" - | "ZAF" - | "SGP" - | "KOR" - | "SSD" - | "ESP" - | "LKA" - | "SDN" - | "SUR" - | "SWE" - | "CHE" - | "SYR" - | "TWN" - | "TJK" - | "TZA" - | "THA" - | "BHS" - | "TGO" - | "TON" - | "TKM" - | "UKR" - | "ARE" - | "GBR" - | "USA" - | "URY" - | "UZB" - | "VUT" - | "VEN" - | "VNM" - | "TUN" - | "ZMB" - | "ZWE" - | "BIH" - | "COG" - | "CIV" - | "COD" - | "DJI" - | "GNQ" - | "ERI" - | "MRT" - | "PNG" - | "TTO" - | "YEM" - | "BLZ" - | "BDI" - | "COM" - | "SWZ" - | "GMB"; From 013b50e4574397aea3f0678897dae3f05be64675 Mon Sep 17 00:00:00 2001 From: Win Cheng Date: Wed, 3 Sep 2025 15:03:23 -0700 Subject: [PATCH 26/34] update translate text --- src/general/interfaces.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/general/interfaces.ts b/src/general/interfaces.ts index 1c4e9cf..b9c4749 100644 --- a/src/general/interfaces.ts +++ b/src/general/interfaces.ts @@ -1,4 +1,5 @@ import { BaseResponse } from "../../types"; +import { LanguageCodes } from "../utils"; export type TextToSQLParams = { prompt: string; @@ -43,13 +44,13 @@ export interface SentimentResponse extends BaseResponse { } export interface TranslateResponse extends BaseResponse { - translated_text: string; + translated_text: string | string[]; } export interface TranslateParams { text: string | string[]; - current_language?: string; - target_language: string; + current_language?: LanguageCodes; + target_language: LanguageCodes; } export type TranslateImageParams = { From 8d27f0f21392cd09a8e0f98104fa34ff8899033c Mon Sep 17 00:00:00 2001 From: Win Cheng Date: Wed, 3 Sep 2025 16:13:18 -0700 Subject: [PATCH 27/34] update summary --- src/general/interfaces.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/general/interfaces.ts b/src/general/interfaces.ts index b9c4749..fe1b3c1 100644 --- a/src/general/interfaces.ts +++ b/src/general/interfaces.ts @@ -82,16 +82,16 @@ export interface TextToSQLResponse extends BaseResponse { } export interface SummaryParams { - text?: string; // maximum 300_000 characters + text?: string | null; // maximum 300_000 characters + url?: string | null; // PDF url only supported type?: "text" | "points"; - url?: string; // PDF url only supported - file_store_key?: string; - max_points?: number; // max 100 - max_characters?: number; + file_store_key?: string | null; + max_points?: number | null; // max 100 + max_characters?: number | null; } export interface SummaryResponse extends BaseResponse { - summary: string; + summary: string | string[]; } export interface PredictionParams { From 0a2dc1b49c9f67a34eacd33843fc162525ca927b Mon Sep 17 00:00:00 2001 From: Win Cheng Date: Wed, 3 Sep 2025 16:23:09 -0700 Subject: [PATCH 28/34] update sql --- src/general/interfaces.ts | 8 ++++---- src/vercel-ai-toolkit.ts | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/general/interfaces.ts b/src/general/interfaces.ts index fe1b3c1..1d6e80d 100644 --- a/src/general/interfaces.ts +++ b/src/general/interfaces.ts @@ -8,6 +8,10 @@ export type TextToSQLParams = { file_store_key?: string; }; +export interface TextToSQLResponse extends BaseResponse { + sql: string; +} + export interface ImageGenerationParams { prompt: string; aspect_ratio?: "1:1" | "16:9" | "21:9" | "3:2" | "2:3" | "4:5" | "5:4" | "3:4" | "4:3" | "9:16" | "9:21"; @@ -77,10 +81,6 @@ export interface SpeechToTextWebhookResponse extends BaseResponse { id: string; } -export interface TextToSQLResponse extends BaseResponse { - sql: string; -} - export interface SummaryParams { text?: string | null; // maximum 300_000 characters url?: string | null; // PDF url only supported diff --git a/src/vercel-ai-toolkit.ts b/src/vercel-ai-toolkit.ts index d47a1a1..6ef1c7a 100644 --- a/src/vercel-ai-toolkit.ts +++ b/src/vercel-ai-toolkit.ts @@ -74,8 +74,8 @@ export class JigsawStackToolSet { execute: async ({ text, target_language, current_language }) => { return await this.jigsawStack.translate.text({ text, - target_language, - current_language, + target_language: target_language as LanguageCodes, + current_language: current_language as LanguageCodes, }); }, }), From a92f1c475f2d6194b713aa8419044574f46800ae Mon Sep 17 00:00:00 2001 From: Win Cheng Date: Wed, 3 Sep 2025 18:09:02 -0700 Subject: [PATCH 29/34] udpate to sentiment --- src/validate/interfaces.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/validate/interfaces.ts b/src/validate/interfaces.ts index 07a0c29..4fd0a80 100644 --- a/src/validate/interfaces.ts +++ b/src/validate/interfaces.ts @@ -18,11 +18,11 @@ export interface ProfanityParams { export interface ProfanityValidationResponse extends BaseResponse { message: string; clean_text: string; - profanities: { - profanity: string; + profanities: Array<{ + profanity: string | null; startIndex: number; endIndex: number; - }[]; + }>; profanities_found: boolean; } From 07a741c3674e870c4d0b556e84e6daaa9094787c Mon Sep 17 00:00:00 2001 From: Win Cheng Date: Wed, 3 Sep 2025 21:31:45 -0700 Subject: [PATCH 30/34] update web test for search --- tests/web.test.ts | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/tests/web.test.ts b/tests/web.test.ts index 9c9e225..49fb077 100644 --- a/tests/web.test.ts +++ b/tests/web.test.ts @@ -1103,21 +1103,6 @@ describe("Web Search API", () => { expectArray(result.results); }); - test("should work with deep research mode", async () => { - const result = await client.web.search({ - query: "What is diffusion?", - deep_research: true, - deep_research_config: { - max_depth: 3, - max_breadth: 2, - max_output_tokens: 12000, - }, - }); - - expectSuccess(result); - expectArray(result.results); - }); - test("should handle empty query gracefully", async () => { try { await client.web.search({ @@ -1162,7 +1147,7 @@ describe("Web Search Suggestions API", () => { }); test("should work with basic query", async () => { - const result = await client.web.search_suggestions("artificial int"); + const result = await client.web.search_suggestions({ query: "artificial int" }); expectSuccess(result); expectProperty(result, "suggestions"); @@ -1175,7 +1160,7 @@ describe("Web Search Suggestions API", () => { }); test("should work with partial query", async () => { - const result = await client.web.search_suggestions("machine learn"); + const result = await client.web.search_suggestions({ query: "machine learn" }); expectSuccess(result); expectArray(result.suggestions); @@ -1191,7 +1176,7 @@ describe("Web Search Suggestions API", () => { test("should fail with empty string", async () => { try { - await client.web.search_suggestions(""); + await client.web.search_suggestions({ query: "" }); throw new Error("Expected API call to fail with empty string"); } catch (error) { expectType(error, "object"); @@ -1202,7 +1187,7 @@ describe("Web Search Suggestions API", () => { const longQuery = "a".repeat(201); // Over 200 character limit try { - await client.web.search_suggestions(longQuery); + await client.web.search_suggestions({ query: longQuery }); throw new Error("Expected API call to fail with query too long"); } catch (error) { expectType(error, "object"); @@ -1210,14 +1195,14 @@ describe("Web Search Suggestions API", () => { }); test("should work with special characters", async () => { - const result = await client.web.search_suggestions("what is the capital?"); + const result = await client.web.search_suggestions({ query: "what is the capital?" }); expectSuccess(result); expectArray(result.suggestions); }); test("should work with unicode characters", async () => { - const result = await client.web.search_suggestions("café français"); + const result = await client.web.search_suggestions({ query: "café français" }); expectSuccess(result); expectArray(result.suggestions); From 474c6a508c051cb469369ab36bcca5348d9ffef4 Mon Sep 17 00:00:00 2001 From: Win Cheng Date: Wed, 3 Sep 2025 22:37:42 -0700 Subject: [PATCH 31/34] update file retrieve --- src/store/interfaces/file.ts | 4 ---- src/vercel-ai-toolkit.ts | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/store/interfaces/file.ts b/src/store/interfaces/file.ts index 6c9da06..7acd9b6 100644 --- a/src/store/interfaces/file.ts +++ b/src/store/interfaces/file.ts @@ -7,10 +7,6 @@ export interface FileUploadParams { temp_public_url?: boolean; } -export interface FileRetrieveParams { - key: string; -} - export interface FileUploadResponse extends BaseResponse { key: string; url: string; diff --git a/src/vercel-ai-toolkit.ts b/src/vercel-ai-toolkit.ts index 6ef1c7a..610e50d 100644 --- a/src/vercel-ai-toolkit.ts +++ b/src/vercel-ai-toolkit.ts @@ -1,7 +1,7 @@ import { z } from "zod"; import { BaseConfig } from "../types"; -import { LanguageCodes } from "./utils"; import { JigsawStack } from "./core"; +import { LanguageCodes } from "./utils"; import { tool } from "./vercel-tool"; export interface JigsawStackToolOptions { tools?: string[]; From b3715beb79bb2bc07bafa2345a54741e3a07e881 Mon Sep 17 00:00:00 2001 From: Win Cheng Date: Fri, 5 Sep 2025 20:20:55 -0700 Subject: [PATCH 32/34] summary depends on params --- src/general/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/general/index.ts b/src/general/index.ts index 56fc0b3..7183e52 100644 --- a/src/general/index.ts +++ b/src/general/index.ts @@ -62,8 +62,8 @@ class General { }; summary(params: SummaryParams & { type: "points" }): Promise; - summary(params: SummaryParams & { type: "text" }): Promise; - async summary(params: SummaryParams): Promise { + summary(params: SummaryParams & { type: "text" }): Promise; + async summary(params: SummaryParams): Promise<(BaseResponse & { summary: string[] }) | (BaseResponse & { summary: string })> { if (params.type === "points") { const resp = await this.client.fetchJSS("/ai/summary", "POST", params); return resp as BaseResponse & { summary: string[] }; From e43d64eb0cf948891598c4812c2346c6af6b92c1 Mon Sep 17 00:00:00 2001 From: Win Cheng Date: Sat, 6 Sep 2025 17:41:07 -0700 Subject: [PATCH 33/34] added types for gui elements --- src/vision/interfaces.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/vision/interfaces.ts b/src/vision/interfaces.ts index 45d9137..6fc8338 100644 --- a/src/vision/interfaces.ts +++ b/src/vision/interfaces.ts @@ -54,6 +54,8 @@ export interface ObjectDetectionResponse extends BaseResponse { interface GuiElement { bounds: BoundingBox; content: string | null; // Can be null if no object detected + interactivity: boolean; + type: string; } interface DetectedObject { From 3ef3b351fe80822cf2e56e7f7e16da0d82d72fa2 Mon Sep 17 00:00:00 2001 From: Win Cheng Date: Sun, 7 Sep 2025 11:15:59 -0700 Subject: [PATCH 34/34] update bounds to be of same type --- src/vision/interfaces.ts | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/src/vision/interfaces.ts b/src/vision/interfaces.ts index 6fc8338..ae1cfd4 100644 --- a/src/vision/interfaces.ts +++ b/src/vision/interfaces.ts @@ -17,10 +17,10 @@ export interface VOCRResponse extends BaseResponse { text: string; lines: Array<{ text: string; - bounds: Bounds; + bounds: BoundingBox; words: Array<{ text: string; - bounds: Bounds; + bounds: BoundingBox; }>; }>; }>; @@ -77,22 +77,3 @@ interface Point { x: number; y: number; } - -interface Bounds { - top_left: { - x: number; - y: number; - }; - top_right: { - x: number; - y: number; - }; - bottom_left: { - x: number; - y: number; - }; - bottom_right: { - x: number; - y: number; - }; -}