{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { createHmac, timingSafeEqual } from \"crypto\";\nimport http from \"http\";\nimport https from \"https\";\nimport axios, { AxiosInstance } from \"axios\";\nimport {\n  SearchResponse,\n  SearchType,\n  SearchOptions,\n  ContentsOptions,\n  ContentsResponse,\n  ContentsAsyncJobResponse,\n  ContentsJobResponse,\n  ContentsJobWaitOptions,\n  AnswerOptions,\n  AnswerResponse,\n  AnswerSuccessResponse,\n  AnswerStreamChunk,\n  SearchResult,\n  DeepResearchCreateOptions,\n  DeepResearchCreateResponse,\n  DeepResearchStatusResponse,\n  DeepResearchListResponse,\n  DeepResearchUpdateResponse,\n  DeepResearchCancelResponse,\n  DeepResearchDeleteResponse,\n  DeepResearchTogglePublicResponse,\n  DeepResearchGetAssetsOptions,\n  DeepResearchGetAssetsResponse,\n  DeepResearchRespondResponse,\n  WaitOptions,\n  StreamCallback,\n  ListOptions,\n  CreateBatchOptions,\n  CreateBatchResponse,\n  BatchStatusResponse,\n  AddBatchTasksOptions,\n  AddBatchTasksResponse,\n  ListBatchTasksOptions,\n  ListBatchTasksResponse,\n  CancelBatchResponse,\n  ListBatchesOptions,\n  ListBatchesResponse,\n  BatchWaitOptions,\n  DeepResearchBatch,\n  DatasourcesListOptions,\n  DatasourcesListResponse,\n  DatasourcesCategoriesResponse,\n  WorkflowsListOptions,\n  WorkflowsListResponse,\n  WorkflowResponse,\n  WorkflowVersionsResponse,\n  WorkflowPreviewOptions,\n  WorkflowPreviewResponse,\n  WorkflowCreateOptions,\n  WorkflowUpdateOptions,\n  WorkflowDeleteResponse,\n} from \"./types\";\n\nconst SDK_VERSION = \"2.9.2\";\n\n/**\n * Maximum combined character length of research_strategy (or its legacy\n * alias strategy) and report_format accepted by the DeepResearch create\n * endpoint. The server rejects anything strictly greater than this with a\n * 400. Enforced client-side so the caller fails fast without a round trip.\n */\nconst MAX_STRATEGY_REPORT_FORMAT_COMBINED_LENGTH = 15000;\n\n/**\n * HTTP status codes that indicate a transient gateway/server/rate-limit\n * condition rather than a definitive answer about the task. The status\n * endpoint is idempotent and meant to be polled, so these are retried.\n */\nconst TRANSIENT_STATUS_CODES = new Set([408, 429, 500, 502, 503, 504]);\n\n/** Normalize API job response (snake_case) to SDK format (camelCase). */\nfunction normalizeContentsJobResponse(api: Record<string, any>): ContentsJobResponse {\n  return {\n    success: api.success ?? true,\n    jobId: api.job_id ?? api.jobId,\n    status: api.status ?? \"pending\",\n    urlsTotal: api.urls_total ?? api.urlsTotal ?? 0,\n    urlsProcessed: api.urls_processed ?? api.urlsProcessed ?? 0,\n    urlsFailed: api.urls_failed ?? api.urlsFailed ?? 0,\n    createdAt: api.created_at ?? api.createdAt ?? 0,\n    updatedAt: api.updated_at ?? api.updatedAt ?? 0,\n    currentBatch: api.current_batch ?? api.currentBatch,\n    totalBatches: api.total_batches ?? api.totalBatches,\n    results: api.results,\n    actualCostDollars: api.actual_cost_dollars ?? api.actualCostDollars,\n    error: api.error,\n    webhookSecret: api.webhook_secret ?? api.webhookSecret,\n  };\n}\n\n/** Normalize API async job creation response (202) to SDK format. */\nfunction normalizeContentsAsyncJobResponse(\n  api: Record<string, any>\n): ContentsAsyncJobResponse {\n  return {\n    success: api.success ?? true,\n    jobId: api.job_id ?? api.jobId,\n    status: \"pending\",\n    urlsTotal: api.urls_total ?? api.urlsTotal ?? 0,\n    pollUrl: api.poll_url ?? api.pollUrl,\n    webhookSecret: api.webhook_secret ?? api.webhookSecret,\n    txId: api.tx_id ?? api.txId ?? \"\",\n  };\n}\n\n/**\n * Verify webhook signature for Contents API async completion notifications.\n * Use the raw request body (not parsed JSON) as payload.\n * @param payload - Raw request body string\n * @param signature - X-Webhook-Signature header value\n * @param timestamp - X-Webhook-Timestamp header value\n * @param secret - webhookSecret from job creation\n */\nexport function verifyContentsWebhookSignature(\n  payload: string,\n  signature: string,\n  timestamp: string,\n  secret: string\n): boolean {\n  const expected = createHmac(\"sha256\", secret)\n    .update(`${timestamp}.${payload}`)\n    .digest(\"hex\");\n  const expectedSignature = `sha256=${expected}`;\n  if (signature.length !== expectedSignature.length) return false;\n  return timingSafeEqual(\n    Buffer.from(signature, \"utf8\"),\n    Buffer.from(expectedSignature, \"utf8\")\n  );\n}\n\n// Valyu API client\nexport class Valyu {\n  private baseUrl: string;\n  private headers: Record<string, string>;\n  private client: AxiosInstance;\n\n  // DeepResearch namespace\n  public deepresearch: {\n    create: (\n      options: DeepResearchCreateOptions\n    ) => Promise<DeepResearchCreateResponse>;\n    status: (taskId: string) => Promise<DeepResearchStatusResponse>;\n    wait: (\n      taskId: string,\n      options?: WaitOptions\n    ) => Promise<DeepResearchStatusResponse>;\n    stream: (taskId: string, callback: StreamCallback) => Promise<void>;\n    list: (options: ListOptions) => Promise<DeepResearchListResponse>;\n    update: (\n      taskId: string,\n      instruction: string\n    ) => Promise<DeepResearchUpdateResponse>;\n    cancel: (taskId: string) => Promise<DeepResearchCancelResponse>;\n    delete: (taskId: string) => Promise<DeepResearchDeleteResponse>;\n    togglePublic: (\n      taskId: string,\n      isPublic: boolean\n    ) => Promise<DeepResearchTogglePublicResponse>;\n    getAssets: (\n      taskId: string,\n      assetId: string,\n      options?: DeepResearchGetAssetsOptions\n    ) => Promise<DeepResearchGetAssetsResponse>;\n    respond: (\n      taskId: string,\n      interactionId: string,\n      response: Record<string, any>\n    ) => Promise<DeepResearchRespondResponse>;\n    respondPlanningQuestions: (taskId: string, interactionId: string, answers: { question: string; answer: string }[]) => Promise<DeepResearchRespondResponse>;\n    approvePlan: (taskId: string, interactionId: string, modifications?: string) => Promise<DeepResearchRespondResponse>;\n    respondSourceReview: (taskId: string, interactionId: string, options?: { includedDomains?: string[]; excludedDomains?: string[] }) => Promise<DeepResearchRespondResponse>;\n    approveOutline: (taskId: string, interactionId: string, modifications?: string) => Promise<DeepResearchRespondResponse>;\n  };\n\n  // Batch API namespace\n  public batch: {\n    create: (options?: CreateBatchOptions) => Promise<CreateBatchResponse>;\n    status: (batchId: string) => Promise<BatchStatusResponse>;\n    addTasks: (\n      batchId: string,\n      options: AddBatchTasksOptions\n    ) => Promise<AddBatchTasksResponse>;\n    listTasks: (\n      batchId: string,\n      options?: ListBatchTasksOptions\n    ) => Promise<ListBatchTasksResponse>;\n    cancel: (batchId: string) => Promise<CancelBatchResponse>;\n    list: (options?: ListBatchesOptions) => Promise<ListBatchesResponse>;\n    waitForCompletion: (\n      batchId: string,\n      options?: BatchWaitOptions\n    ) => Promise<DeepResearchBatch>;\n  };\n\n  // Datasources API namespace\n  public datasources: {\n    list: (options?: DatasourcesListOptions) => Promise<DatasourcesListResponse>;\n    categories: () => Promise<DatasourcesCategoriesResponse>;\n  };\n\n  // Workflows API namespace\n  public workflows: {\n    list: (options?: WorkflowsListOptions) => Promise<WorkflowsListResponse>;\n    get: (slug: string, version?: number) => Promise<WorkflowResponse>;\n    versions: (slug: string) => Promise<WorkflowVersionsResponse>;\n    preview: (\n      slug: string,\n      options?: WorkflowPreviewOptions\n    ) => Promise<WorkflowPreviewResponse>;\n    create: (options: WorkflowCreateOptions) => Promise<WorkflowResponse>;\n    update: (\n      slug: string,\n      options: WorkflowUpdateOptions\n    ) => Promise<WorkflowResponse>;\n    delete: (slug: string) => Promise<WorkflowDeleteResponse>;\n  };\n\n  constructor(apiKey?: string, baseUrl: string = \"https://api.valyu.ai/v1\") {\n    if (!apiKey) {\n      apiKey = process.env.VALYU_API_KEY;\n      if (!apiKey) {\n        throw new Error(\"VALYU_API_KEY is not set\");\n      }\n    }\n    this.baseUrl = baseUrl;\n    this.headers = {\n      \"Content-Type\": \"application/json\",\n      \"x-api-key\": apiKey,\n      \"User-Agent\": `valyu-js/${SDK_VERSION}`,\n      \"X-Valyu-SDK\": \"valyu-js\",\n      \"X-Valyu-SDK-Version\": SDK_VERSION,\n    };\n\n    this.client = axios.create({\n      baseURL: this.baseUrl,\n      headers: this.headers,\n      httpAgent: new http.Agent({ keepAlive: true }),\n      httpsAgent: new https.Agent({ keepAlive: true }),\n    });\n\n    // Initialize DeepResearch namespace\n    this.deepresearch = {\n      create: this._deepresearchCreate.bind(this),\n      status: this._deepresearchStatus.bind(this),\n      wait: this._deepresearchWait.bind(this),\n      stream: this._deepresearchStream.bind(this),\n      list: this._deepresearchList.bind(this),\n      update: this._deepresearchUpdate.bind(this),\n      cancel: this._deepresearchCancel.bind(this),\n      delete: this._deepresearchDelete.bind(this),\n      togglePublic: this._deepresearchTogglePublic.bind(this),\n      getAssets: this._deepresearchGetAssets.bind(this),\n      respond: this._deepresearchRespond.bind(this),\n      respondPlanningQuestions: this._deepresearchRespondPlanningQuestions.bind(this),\n      approvePlan: this._deepresearchApprovePlan.bind(this),\n      respondSourceReview: this._deepresearchRespondSourceReview.bind(this),\n      approveOutline: this._deepresearchApproveOutline.bind(this),\n    };\n\n    // Initialize Batch namespace\n    this.batch = {\n      create: this._batchCreate.bind(this),\n      status: this._batchStatus.bind(this),\n      addTasks: this._batchAddTasks.bind(this),\n      listTasks: this._batchListTasks.bind(this),\n      cancel: this._batchCancel.bind(this),\n      list: this._batchList.bind(this),\n      waitForCompletion: this._batchWaitForCompletion.bind(this),\n    };\n\n    // Initialize Datasources namespace\n    this.datasources = {\n      list: this._datasourcesList.bind(this),\n      categories: this._datasourcesCategories.bind(this),\n    };\n\n    // Initialize Workflows namespace\n    this.workflows = {\n      list: this._workflowsList.bind(this),\n      get: this._workflowsGet.bind(this),\n      versions: this._workflowsVersions.bind(this),\n      preview: this._workflowsPreview.bind(this),\n      create: this._workflowsCreate.bind(this),\n      update: this._workflowsUpdate.bind(this),\n      delete: this._workflowsDelete.bind(this),\n    };\n  }\n\n  /**\n   * Validates date format (YYYY-MM-DD)\n   */\n  private validateDateFormat(date: string): boolean {\n    const dateRegex = /^\\d{4}-\\d{2}-\\d{2}$/;\n    if (!dateRegex.test(date)) {\n      return false;\n    }\n    const parsedDate = new Date(date);\n    return parsedDate instanceof Date && !isNaN(parsedDate.getTime());\n  }\n\n  /**\n   * Validates if a string is a valid URL\n   */\n  private validateUrl(url: string): boolean {\n    try {\n      new URL(url);\n      return true;\n    } catch {\n      return false;\n    }\n  }\n\n  /**\n   * Validates if a string is a valid domain (with optional path)\n   */\n  private validateDomain(domain: string): boolean {\n    // Domain must have at least one dot and valid structure\n    // Supports: example.com, example.com/path, subdomain.example.com/path/to/resource\n    const domainRegex =\n      /^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(\\/.+)?$/;\n    return domainRegex.test(domain);\n  }\n\n  /**\n   * Validates if a string is a valid dataset identifier (provider/datasetname)\n   */\n  private validateDatasetId(datasetId: string): boolean {\n    // Dataset format: provider/datasetname (exactly one slash)\n    // Provider and dataset name can contain alphanumeric, hyphens, underscores\n    const parts = datasetId.split(\"/\");\n    if (parts.length !== 2) return false;\n\n    const providerRegex = /^[a-zA-Z0-9_-]+$/;\n    const datasetRegex = /^[a-zA-Z0-9_-]+$/;\n\n    return (\n      providerRegex.test(parts[0]) &&\n      datasetRegex.test(parts[1]) &&\n      parts[0].length > 0 &&\n      parts[1].length > 0\n    );\n  }\n\n  /**\n   * Validates source strings (domains, URLs, or dataset IDs)\n   */\n  private validateSource(source: string): boolean {\n    // Check if it's a valid URL\n    if (this.validateUrl(source)) {\n      return true;\n    }\n\n    // Check if it's a valid domain (with optional path)\n    if (this.validateDomain(source)) {\n      return true;\n    }\n\n    // Check if it's a valid dataset identifier\n    if (this.validateDatasetId(source)) {\n      return true;\n    }\n\n    return false;\n  }\n\n  /**\n   * Validates an array of source strings\n   */\n  private validateSources(sources: string[]): {\n    valid: boolean;\n    invalidSources: string[];\n  } {\n    const invalidSources: string[] = [];\n\n    for (const source of sources) {\n      if (!this.validateSource(source)) {\n        invalidSources.push(source);\n      }\n    }\n\n    return {\n      valid: invalidSources.length === 0,\n      invalidSources,\n    };\n  }\n\n  /**\n   * Search for information using the Valyu DeepSearch API\n   * @param query - The search query string\n   * @param options - Search configuration options\n   * @param options.searchType - Type of search: \"web\", \"proprietary\", \"all\", or \"news\"\n   * @param options.maxNumResults - Maximum number of results (1-100)\n   * @param options.maxPrice - Maximum price per thousand characters (CPM)\n   * @param options.isToolCall - Whether this is a tool call\n   * @param options.relevanceThreshold - Minimum relevance score (0-1)\n   * @param options.includedSources - List of specific sources to include\n   * @param options.excludeSources - List of URLs/domains to exclude from search results\n   * @param options.category - Category filter for search results\n   * @param options.startDate - Start date filter (YYYY-MM-DD format)\n   * @param options.endDate - End date filter (YYYY-MM-DD format)\n   * @param options.historicalCache - When true and a date range is set, return the newest cached snapshot inside the range instead of the latest crawl. No-op without a date range (default: false)\n   * @param options.countryCode - Country code filter for search results\n   * @param options.responseLength - Response content length: \"short\"/\"medium\"/\"large\"/\"max\" or integer character count\n   * @param options.fastMode - Fast mode for quicker but shorter results (default: false)\n   * @param options.urlOnly - Returns shortened snippets (default: false)\n   * @returns Promise resolving to search results\n   */\n  async search(\n    query: string,\n    options: SearchOptions = {}\n  ): Promise<SearchResponse> {\n    try {\n      // Default values\n      const defaultSearchType: SearchType = \"all\";\n      const defaultMaxNumResults = 10;\n      const defaultIsToolCall = true;\n      const defaultRelevanceThreshold = 0.5;\n\n      // Validate searchType\n      let finalSearchType: SearchType = defaultSearchType;\n      const providedSearchTypeString = options.searchType?.toLowerCase();\n\n      if (\n        providedSearchTypeString === \"web\" ||\n        providedSearchTypeString === \"proprietary\" ||\n        providedSearchTypeString === \"all\" ||\n        providedSearchTypeString === \"news\"\n      ) {\n        finalSearchType = providedSearchTypeString as SearchType;\n      } else if (options.searchType !== undefined) {\n        return {\n          success: false,\n          error:\n            \"Invalid searchType provided. Must be one of: all, web, proprietary, news\",\n          tx_id: null,\n          query,\n          results: [],\n          results_by_source: { web: 0, proprietary: 0 },\n          total_deduction_dollars: 0.0,\n          total_characters: 0,\n        };\n      }\n\n      // Validate date formats\n      if (options.startDate && !this.validateDateFormat(options.startDate)) {\n        return {\n          success: false,\n          error: \"Invalid startDate format. Must be YYYY-MM-DD\",\n          tx_id: null,\n          query,\n          results: [],\n          results_by_source: { web: 0, proprietary: 0 },\n          total_deduction_dollars: 0.0,\n          total_characters: 0,\n        };\n      }\n\n      if (options.endDate && !this.validateDateFormat(options.endDate)) {\n        return {\n          success: false,\n          error: \"Invalid endDate format. Must be YYYY-MM-DD\",\n          tx_id: null,\n          query,\n          results: [],\n          results_by_source: { web: 0, proprietary: 0 },\n          total_deduction_dollars: 0.0,\n          total_characters: 0,\n        };\n      }\n\n      // Validate maxNumResults range\n      const maxNumResults = options.maxNumResults ?? defaultMaxNumResults;\n      if (maxNumResults < 1 || maxNumResults > 100) {\n        return {\n          success: false,\n          error: \"maxNumResults must be between 1 and 100\",\n          tx_id: null,\n          query,\n          results: [],\n          results_by_source: { web: 0, proprietary: 0 },\n          total_deduction_dollars: 0.0,\n          total_characters: 0,\n        };\n      }\n\n      // Validate includedSources format\n      if (options.includedSources !== undefined) {\n        if (!Array.isArray(options.includedSources)) {\n          return {\n            success: false,\n            error: \"includedSources must be an array\",\n            tx_id: null,\n            query,\n            results: [],\n            results_by_source: { web: 0, proprietary: 0 },\n              total_deduction_dollars: 0.0,\n            total_characters: 0,\n          };\n        }\n\n        const includedSourcesValidation = this.validateSources(\n          options.includedSources\n        );\n        if (!includedSourcesValidation.valid) {\n          return {\n            success: false,\n            error: `Invalid includedSources format. Invalid sources: ${includedSourcesValidation.invalidSources.join(\n              \", \"\n            )}. Sources must be valid URLs, domains (with optional paths), or dataset identifiers in 'provider/dataset' format.`,\n            tx_id: null,\n            query,\n            results: [],\n            results_by_source: { web: 0, proprietary: 0 },\n              total_deduction_dollars: 0.0,\n            total_characters: 0,\n          };\n        }\n      }\n\n      // Validate excludeSources format\n      if (options.excludeSources !== undefined) {\n        if (!Array.isArray(options.excludeSources)) {\n          return {\n            success: false,\n            error: \"excludeSources must be an array\",\n            tx_id: null,\n            query,\n            results: [],\n            results_by_source: { web: 0, proprietary: 0 },\n              total_deduction_dollars: 0.0,\n            total_characters: 0,\n          };\n        }\n\n        const excludeSourcesValidation = this.validateSources(\n          options.excludeSources\n        );\n        if (!excludeSourcesValidation.valid) {\n          return {\n            success: false,\n            error: `Invalid excludeSources format. Invalid sources: ${excludeSourcesValidation.invalidSources.join(\n              \", \"\n            )}. Sources must be valid URLs, domains (with optional paths), or dataset identifiers in 'provider/dataset' format.`,\n            tx_id: null,\n            query,\n            results: [],\n            results_by_source: { web: 0, proprietary: 0 },\n              total_deduction_dollars: 0.0,\n            total_characters: 0,\n          };\n        }\n      }\n\n      // Build payload with snake_case for API\n      const payload: Record<string, any> = {\n        query,\n        search_type: finalSearchType,\n        max_num_results: maxNumResults,\n        is_tool_call: options.isToolCall ?? defaultIsToolCall,\n        relevance_threshold:\n          options.relevanceThreshold ?? defaultRelevanceThreshold,\n      };\n\n      // Add maxPrice only if explicitly provided\n      if (options.maxPrice !== undefined) {\n        payload.max_price = options.maxPrice;\n      }\n\n      // Add optional parameters only if provided\n      if (options.includedSources !== undefined) {\n        payload.included_sources = options.includedSources;\n      }\n\n      if (options.excludeSources !== undefined) {\n        payload.excluded_sources = options.excludeSources;\n      }\n\n      if (options.sourceBiases !== undefined) {\n        payload.source_biases = options.sourceBiases;\n      }\n\n      if (options.category !== undefined) {\n        payload.category = options.category;\n      }\n\n      if (options.startDate !== undefined) {\n        payload.start_date = options.startDate;\n      }\n\n      if (options.endDate !== undefined) {\n        payload.end_date = options.endDate;\n      }\n\n      if (options.historicalCache !== undefined) {\n        payload.historical_cache = options.historicalCache;\n      }\n\n      if (options.countryCode !== undefined) {\n        payload.country_code = options.countryCode;\n      }\n\n      if (options.responseLength !== undefined) {\n        payload.response_length = options.responseLength;\n      }\n\n      if (options.fastMode !== undefined) {\n        payload.fast_mode = options.fastMode;\n      }\n\n      if (options.urlOnly !== undefined) {\n        payload.url_only = options.urlOnly;\n      }\n\n      if (options.instructions !== undefined) {\n        payload.instructions = options.instructions;\n      }\n\n      const response = await this.client.post(`${this.baseUrl}/search`, payload, {\n        headers: this.headers,\n      });\n\n      if (!response.status || response.status < 200 || response.status >= 300) {\n        return {\n          success: false,\n          error: response.data?.error,\n          tx_id: null,\n          query,\n          results: [],\n          results_by_source: { web: 0, proprietary: 0 },\n          total_deduction_dollars: 0.0,\n          total_characters: 0,\n        };\n      }\n\n      return response.data;\n    } catch (e: any) {\n      return {\n        success: false,\n        error: e.response?.data?.error || e.message,\n        tx_id: null,\n        query,\n        results: [],\n        results_by_source: { web: 0, proprietary: 0 },\n        total_deduction_dollars: 0.0,\n        total_characters: 0,\n      };\n    }\n  }\n\n  /**\n   * Extract content from URLs with optional AI processing\n   * @param urls - Array of URLs to process (max 10 sync, max 50 with async: true)\n   * @param options - Content extraction configuration options\n   * @param options.summary - AI summary configuration: false (raw), true (auto), string (custom), or JSON schema\n   * @param options.extractEffort - Extraction thoroughness: \"normal\", \"high\", or \"auto\"\n   * @param options.responseLength - Content length per URL\n   * @param options.maxPriceDollars - Maximum cost limit in USD\n   * @param options.screenshot - Request page screenshots (default: false)\n   * @param options.async - Force async processing (required for >10 URLs)\n   * @param options.webhookUrl - HTTPS URL for completion notification (async only)\n   * @param options.startDate - Start date filter (YYYY-MM-DD format), inclusive\n   * @param options.endDate - End date filter (YYYY-MM-DD format), inclusive\n   * @param options.historicalCache - When true and a date range is set, return the newest cached snapshot inside the range instead of the latest crawl. No-op without a date range (default: false)\n   * @returns Promise resolving to sync results or async job (when async: true or >10 URLs)\n   */\n  async contents(\n    urls: string[],\n    options: ContentsOptions = {}\n  ): Promise<ContentsResponse | ContentsAsyncJobResponse> {\n    try {\n      // Validate URLs array\n      if (!urls || !Array.isArray(urls)) {\n        return {\n          success: false,\n          error: \"urls must be an array\",\n          urls_requested: 0,\n          urls_processed: 0,\n          urls_failed: 0,\n          results: [],\n          total_cost_dollars: 0,\n          total_characters: 0,\n        };\n      }\n\n      if (urls.length === 0) {\n        return {\n          success: false,\n          error: \"urls array cannot be empty\",\n          urls_requested: 0,\n          urls_processed: 0,\n          urls_failed: 0,\n          results: [],\n          total_cost_dollars: 0,\n          total_characters: 0,\n        };\n      }\n\n      const isAsync = options.async === true || urls.length > 10;\n\n      if (urls.length > 10 && !options.async) {\n        return {\n          success: false,\n          error:\n            \"Requests with more than 10 URLs require async processing. Add async: true to the request.\",\n          urls_requested: urls.length,\n          urls_processed: 0,\n          urls_failed: urls.length,\n          results: [],\n          total_cost_dollars: 0,\n          total_characters: 0,\n        };\n      }\n\n      if (urls.length > 50) {\n        return {\n          success: false,\n          error: \"Maximum 50 URLs allowed per request\",\n          urls_requested: urls.length,\n          urls_processed: 0,\n          urls_failed: urls.length,\n          results: [],\n          total_cost_dollars: 0,\n          total_characters: 0,\n        };\n      }\n\n      // Validate extractEffort if provided\n      if (\n        options.extractEffort &&\n        ![\"normal\", \"high\", \"auto\"].includes(options.extractEffort)\n      ) {\n        return {\n          success: false,\n          error: \"extractEffort must be 'normal', 'high', or 'auto'\",\n          urls_requested: urls.length,\n          urls_processed: 0,\n          urls_failed: urls.length,\n          results: [],\n          total_cost_dollars: 0,\n          total_characters: 0,\n        };\n      }\n\n      // Validate responseLength if provided\n      if (options.responseLength !== undefined) {\n        const validLengths = [\"short\", \"medium\", \"large\", \"max\"];\n        if (\n          typeof options.responseLength === \"string\" &&\n          !validLengths.includes(options.responseLength)\n        ) {\n          return {\n            success: false,\n            error:\n              \"responseLength must be 'short', 'medium', 'large', 'max', or a number\",\n            urls_requested: urls.length,\n            urls_processed: 0,\n            urls_failed: urls.length,\n            results: [],\n            total_cost_dollars: 0,\n            total_characters: 0,\n          };\n        }\n        if (\n          typeof options.responseLength === \"number\" &&\n          options.responseLength <= 0\n        ) {\n          return {\n            success: false,\n            error: \"responseLength number must be positive\",\n            urls_requested: urls.length,\n            urls_processed: 0,\n            urls_failed: urls.length,\n            results: [],\n            total_cost_dollars: 0,\n            total_characters: 0,\n          };\n        }\n      }\n\n      // Build payload with snake_case for API\n      const payload: Record<string, any> = {\n        urls,\n      };\n\n      // Add optional parameters only if provided\n      if (options.summary !== undefined) {\n        payload.summary = options.summary;\n      }\n\n      if (options.extractEffort !== undefined) {\n        payload.extract_effort = options.extractEffort;\n      }\n\n      if (options.responseLength !== undefined) {\n        payload.response_length = options.responseLength;\n      }\n\n      if (options.maxPriceDollars !== undefined) {\n        payload.max_price_dollars = options.maxPriceDollars;\n      }\n\n      if (options.screenshot !== undefined) {\n        payload.screenshot = options.screenshot;\n      }\n\n      if (isAsync) {\n        payload.async = true;\n      }\n      if (options.webhookUrl !== undefined) {\n        payload.webhook_url = options.webhookUrl;\n      }\n\n      if (options.startDate !== undefined) {\n        payload.start_date = options.startDate;\n      }\n\n      if (options.endDate !== undefined) {\n        payload.end_date = options.endDate;\n      }\n\n      if (options.historicalCache !== undefined) {\n        payload.historical_cache = options.historicalCache;\n      }\n\n      const response = await this.client.post(`${this.baseUrl}/contents`, payload, {\n        headers: this.headers,\n      });\n\n      if (!response.status || response.status < 200 || response.status >= 300) {\n        return {\n          success: false,\n          error: response.data?.error || \"Request failed\",\n          urls_requested: urls.length,\n          urls_processed: 0,\n          urls_failed: urls.length,\n          results: [],\n          total_cost_dollars: 0,\n          total_characters: 0,\n        };\n      }\n\n      // 202 Accepted - async job created\n      if (response.status === 202) {\n        return normalizeContentsAsyncJobResponse(response.data);\n      }\n\n      return response.data as ContentsResponse;\n    } catch (e: any) {\n      return {\n        success: false,\n        error: e.response?.data?.error || e.message,\n        urls_requested: urls.length,\n        urls_processed: 0,\n        urls_failed: urls.length,\n        results: [],\n        total_cost_dollars: 0,\n        total_characters: 0,\n      };\n    }\n  }\n\n  /**\n   * Get async Contents job status and results\n   * @param jobId - Job ID from contents() async response\n   * @returns Promise resolving to job status\n   */\n  async getContentsJob(jobId: string): Promise<ContentsJobResponse> {\n    try {\n      const response = await this.client.get(\n        `${this.baseUrl}/contents/jobs/${jobId}`,\n        { headers: this.headers }\n      );\n      return normalizeContentsJobResponse(response.data);\n    } catch (e: any) {\n      const errData = e.response?.data;\n      const status = e.response?.status;\n      return {\n        success: false,\n        jobId,\n        status: \"failed\",\n        urlsTotal: 0,\n        urlsProcessed: 0,\n        urlsFailed: 0,\n        createdAt: 0,\n        updatedAt: 0,\n        error:\n          errData?.error ||\n          (status === 403\n            ? \"Forbidden - you do not have access to this job\"\n            : status === 404\n              ? `Job ${jobId} not found`\n              : e.message),\n      };\n    }\n  }\n\n  /**\n   * Wait for async Contents job completion (polls until terminal state)\n   * @param jobId - Job ID from contents() async response\n   * @param options - Wait configuration (pollInterval, maxWaitTime, onProgress)\n   * @returns Promise resolving to final job status with results\n   */\n  async waitForJob(\n    jobId: string,\n    options: ContentsJobWaitOptions = {}\n  ): Promise<ContentsJobResponse> {\n    const pollInterval = options.pollInterval ?? 5000;\n    const maxWaitTime = options.maxWaitTime ?? 7200000;\n    const startTime = Date.now();\n\n    while (true) {\n      const status = await this.getContentsJob(jobId);\n\n      if (!status.success && status.error) {\n        throw new Error(status.error);\n      }\n\n      if (options.onProgress) {\n        options.onProgress(status);\n      }\n\n      if (\n        status.status === \"completed\" ||\n        status.status === \"partial\" ||\n        status.status === \"failed\"\n      ) {\n        return status;\n      }\n\n      if (Date.now() - startTime > maxWaitTime) {\n        throw new Error(\"Maximum wait time exceeded\");\n      }\n\n      await new Promise((resolve) => setTimeout(resolve, pollInterval));\n    }\n  }\n\n  /**\n   * DeepResearch: Create a new research task\n   * @param options.search - Search configuration options\n   * @param options.search.searchType - Type of search: \"all\", \"web\", or \"proprietary\" (default: \"all\")\n   * @param options.search.includedSources - Array of source types to include (e.g., [\"academic\", \"finance\", \"web\"])\n   * @param options.search.excludedSources - Array of source types to exclude (e.g., [\"web\", \"patent\"])\n   * @param options.search.startDate - Start date filter in ISO format (YYYY-MM-DD)\n   * @param options.search.endDate - End date filter in ISO format (YYYY-MM-DD)\n   * @param options.search.historicalCache - When true and a date range is set, searches return the newest cached snapshot inside the range instead of the latest crawl. Locked for the whole research run — the agent cannot toggle it mid-research\n   * @param options.search.category - Category filter for search results\n   */\n  private async _deepresearchCreate(\n    options: DeepResearchCreateOptions\n  ): Promise<DeepResearchCreateResponse> {\n    try {\n      // Enforce the server's combined-length cap on research_strategy (or its\n      // legacy alias strategy) plus report_format before doing any work, so the\n      // client-side error matches the server's 400 body exactly and no request\n      // is made when the payload is guaranteed to be rejected.\n      const effectiveStrategy = options.researchStrategy ?? options.strategy;\n      const combined =\n        (effectiveStrategy?.length ?? 0) + (options.reportFormat?.length ?? 0);\n      if (combined > MAX_STRATEGY_REPORT_FORMAT_COMBINED_LENGTH) {\n        return {\n          success: false,\n          error: `research_strategy and report_format combined length (${combined}) exceeds 15,000 character limit`,\n        };\n      }\n\n      // Use query field (input is supported for backward compatibility)\n      const queryValue = options.query ?? options.input;\n\n      // Workflow runs: the template supplies the freeform fields\n      if (options.workflowId) {\n        if (\n          queryValue ||\n          options.strategy ||\n          options.researchStrategy ||\n          options.reportFormat\n        ) {\n          return {\n            success: false,\n            error:\n              \"workflowId is mutually exclusive with query/input/researchStrategy/reportFormat - the workflow template supplies those fields\",\n          };\n        }\n        const payload: Record<string, any> = {\n          workflow_id: options.workflowId,\n        };\n        if (options.workflowParams !== undefined) {\n          payload.workflow_params = options.workflowParams;\n        }\n        if (options.workflowVersion !== undefined) {\n          payload.workflow_version = options.workflowVersion;\n        }\n        // Only send mode/output_formats when explicitly set so the\n        // workflow's recommended defaults apply otherwise\n        const explicitMode = options.mode ?? options.model;\n        if (explicitMode) payload.mode = explicitMode;\n        if (options.outputFormats) payload.output_formats = options.outputFormats;\n        if (options.tools) payload.tools = options.tools;\n        if (options.webhookUrl) payload.webhook_url = options.webhookUrl;\n        if (options.alertEmail) {\n          payload.alert_email =\n            typeof options.alertEmail === \"string\"\n              ? options.alertEmail\n              : {\n                  email: options.alertEmail.email,\n                  custom_url: options.alertEmail.custom_url,\n                };\n        }\n        if (options.metadata) payload.metadata = options.metadata;\n\n        const response = await this.client.post(\n          `${this.baseUrl}/deepresearch/tasks`,\n          payload,\n          { headers: this.headers }\n        );\n        return { success: true, ...response.data };\n      }\n\n      // Validation\n      if (!queryValue?.trim()) {\n        return {\n          success: false,\n          error: \"query is required and cannot be empty\",\n        };\n      }\n\n      if (queryValue.length > 25000) {\n        return {\n          success: false,\n          error: `query exceeds 25,000 character limit (${queryValue.length} characters)`,\n        };\n      }\n\n      if (options.files) {\n        for (let i = 0; i < options.files.length; i++) {\n          const ctx = options.files[i].context;\n          if (ctx && ctx.length > 10000) {\n            return {\n              success: false,\n              error: `files[${i}].context exceeds 10,000 character limit (${ctx.length} characters)`,\n            };\n          }\n        }\n      }\n\n      // Build payload with snake_case\n      // Prefer mode over model (backward compatible)\n      const mode = options.mode ?? options.model;\n      const payload: Record<string, any> = {\n        query: queryValue,\n        mode: mode || \"fast\", // API defaults to \"standard\", but we keep \"fast\" for backward compatibility\n        output_formats: options.outputFormats || [\"markdown\"],\n      };\n\n      // Handle tools configuration\n      if (options.tools) {\n        payload.tools = options.tools;\n      } else if (options.codeExecution !== undefined) {\n        // Backward compatibility: top-level code_execution (deprecated)\n        payload.code_execution = options.codeExecution;\n      }\n\n      // Add optional fields\n      if (options.strategy) payload.strategy = options.strategy;\n      if (options.researchStrategy)\n        payload.research_strategy = options.researchStrategy;\n      if (options.reportFormat)\n        payload.report_format = options.reportFormat;\n      if (options.search) {\n        payload.search = {};\n        if (options.search.searchType) {\n          payload.search.search_type = options.search.searchType;\n        }\n        if (options.search.includedSources) {\n          payload.search.included_sources = options.search.includedSources;\n        }\n        if (options.search.excludedSources) {\n          payload.search.excluded_sources = options.search.excludedSources;\n        }\n        if (options.search.sourceBiases) {\n          payload.search.source_biases = options.search.sourceBiases;\n        }\n        if (options.search.startDate) {\n          payload.search.start_date = options.search.startDate;\n        }\n        if (options.search.endDate) {\n          payload.search.end_date = options.search.endDate;\n        }\n        if (options.search.historicalCache !== undefined) {\n          payload.search.historical_cache = options.search.historicalCache;\n        }\n        if (options.search.category) {\n          payload.search.category = options.search.category;\n        }\n      }\n      if (options.urls) payload.urls = options.urls;\n      if (options.files) payload.files = options.files;\n      if (options.deliverables) payload.deliverables = options.deliverables;\n      if (options.mcpServers) payload.mcp_servers = options.mcpServers;\n      if (options.previousReports) {\n        payload.previous_reports = options.previousReports;\n      }\n      if (options.webhookUrl) payload.webhook_url = options.webhookUrl;\n      if (options.brandCollectionId)\n        payload.brand_collection_id = options.brandCollectionId;\n      if (options.alertEmail) {\n        if (typeof options.alertEmail === \"string\") {\n          payload.alert_email = options.alertEmail;\n        } else {\n          payload.alert_email = {\n            email: options.alertEmail.email,\n            custom_url: options.alertEmail.custom_url,\n          };\n        }\n      }\n      if (options.metadata) payload.metadata = options.metadata;\n      if (options.hitl) {\n        payload.hitl = {};\n        if (options.hitl.planningQuestions !== undefined)\n          payload.hitl.planning_questions = options.hitl.planningQuestions;\n        if (options.hitl.planReview !== undefined)\n          payload.hitl.plan_review = options.hitl.planReview;\n        if (options.hitl.sourceReview !== undefined)\n          payload.hitl.source_review = options.hitl.sourceReview;\n        if (options.hitl.outlineReview !== undefined)\n          payload.hitl.outline_review = options.hitl.outlineReview;\n      }\n\n      const response = await this.client.post(\n        `${this.baseUrl}/deepresearch/tasks`,\n        payload,\n        { headers: this.headers }\n      );\n\n      return { success: true, ...response.data };\n    } catch (e: any) {\n      return {\n        success: false,\n        error: e.response?.data?.error || e.message,\n      };\n    }\n  }\n\n  /**\n   * DeepResearch: Get task status\n   */\n  private async _deepresearchStatus(\n    taskId: string,\n    maxAttempts: number = 5\n  ): Promise<DeepResearchStatusResponse> {\n    // The status endpoint is idempotent and built to be polled, so transient\n    // failures are retried with exponential backoff + jitter instead of being\n    // reported as task failures. Treated as transient (and retried): network\n    // errors and timeouts, HTTP 429/5xx (e.g. an ALB 502 gateway page), and\n    // non-JSON or empty response bodies. Only a definitive error response (a\n    // 4xx other than 429 carrying a JSON error) is returned as a failure.\n    const url = `${this.baseUrl}/deepresearch/tasks/${taskId}/status`;\n    let lastError = \"status endpoint unreachable\";\n\n    for (let attempt = 0; attempt < maxAttempts; attempt++) {\n      try {\n        const response = await this.client.get(url, {\n          headers: this.headers,\n          // Classify status codes ourselves rather than letting axios throw.\n          validateStatus: () => true,\n        });\n\n        if (TRANSIENT_STATUS_CODES.has(response.status)) {\n          // Gateway/rate-limit/server blip — the task is unaffected.\n          lastError = `HTTP ${response.status}`;\n        } else {\n          const contentType = String(\n            response.headers?.[\"content-type\"] || \"\"\n          );\n          const body = response.data;\n          // An HTML 502 page or an empty body is a gateway artifact, not the\n          // task's real status. Guard before trusting it so we never conflate\n          // a bad body with a failed task.\n          const isJsonObject =\n            contentType.toLowerCase().includes(\"application/json\") &&\n            typeof body === \"object\" &&\n            body !== null &&\n            !Array.isArray(body);\n\n          if (!isJsonObject) {\n            lastError = `non-JSON/empty status response (HTTP ${response.status}, content-type: ${contentType || \"none\"})`;\n          } else if (response.status >= 400) {\n            // Definitive error response (e.g. 4xx) — terminal, not transient.\n            return {\n              success: false,\n              error: (body as any).error || `HTTP Error: ${response.status}`,\n            };\n          } else {\n            const { success: _ignored, ...rest } = body as any;\n            return { success: true, ...rest };\n          }\n        }\n      } catch (e: any) {\n        // Network errors / timeouts — no HTTP response was received.\n        lastError = e?.message || String(e);\n      }\n\n      if (attempt < maxAttempts - 1) {\n        // Exponential backoff capped at 30s, with jitter to avoid synchronised\n        // retries hammering a recovering gateway.\n        const delayMs = Math.min(2 ** attempt, 30) * 1000 + Math.random() * 1000;\n        await new Promise((resolve) => setTimeout(resolve, delayMs));\n      }\n    }\n\n    return {\n      success: false,\n      unreachable: true,\n      error: `Status endpoint unreachable after ${maxAttempts} attempts: ${lastError}`,\n    };\n  }\n\n  /**\n   * DeepResearch: Wait for task completion with polling\n   */\n  private async _deepresearchWait(\n    taskId: string,\n    options: WaitOptions = {}\n  ): Promise<DeepResearchStatusResponse> {\n    const pollInterval = options.pollInterval || 5000;\n    const maxWaitTime = options.maxWaitTime || 7200000;\n    const startTime = Date.now();\n\n    while (true) {\n      const status = await this._deepresearchStatus(taskId);\n\n      if (!status.success) {\n        // A transiently unreachable status endpoint is not a task failure —\n        // keep polling within maxWaitTime, since the task may well be running\n        // (or already completed) server-side.\n        if (status.unreachable) {\n          if (Date.now() - startTime > maxWaitTime) {\n            throw new Error(\n              `Status endpoint unreachable for ${maxWaitTime}ms: ${status.error}`\n            );\n          }\n          await new Promise((resolve) => setTimeout(resolve, pollInterval));\n          continue;\n        }\n        throw new Error(status.error);\n      }\n\n      // Notify progress callback\n      if (options.onProgress) {\n        options.onProgress(status);\n      }\n\n      // HITL checkpoint handling\n      if (\n        (status.status === \"awaiting_input\" || status.status === \"paused\") &&\n        status.interaction\n      ) {\n        if (options.onInteraction) {\n          const response = await options.onInteraction(status.interaction);\n          if (response) {\n            await this._deepresearchRespond(\n              taskId,\n              status.interaction.interaction_id,\n              response\n            );\n            continue;\n          }\n        }\n      }\n\n      // Terminal states\n      if (\n        status.status === \"completed\" ||\n        status.status === \"failed\" ||\n        status.status === \"cancelled\"\n      ) {\n        return status;\n      }\n\n      // Check timeout\n      if (Date.now() - startTime > maxWaitTime) {\n        throw new Error(\"Maximum wait time exceeded\");\n      }\n\n      // Wait before next poll\n      await new Promise((resolve) => setTimeout(resolve, pollInterval));\n    }\n  }\n\n  /**\n   * DeepResearch: Stream real-time updates\n   */\n  private async _deepresearchStream(\n    taskId: string,\n    callback: StreamCallback\n  ): Promise<void> {\n    let isComplete = false;\n    let lastMessageCount = 0;\n\n    while (!isComplete) {\n      try {\n        const status = await this._deepresearchStatus(taskId);\n\n        if (!status.success) {\n          if (callback.onError) {\n            callback.onError(new Error(status.error));\n          }\n          return;\n        }\n\n        // Progress updates\n        if (status.progress && callback.onProgress) {\n          callback.onProgress(\n            status.progress.current_step,\n            status.progress.total_steps\n          );\n        }\n\n        // New messages\n        if (status.messages && callback.onMessage) {\n          const newMessages = status.messages.slice(lastMessageCount);\n          newMessages.forEach((msg) => callback.onMessage!(msg));\n          lastMessageCount = status.messages.length;\n        }\n\n        // Terminal states\n        if (status.status === \"completed\") {\n          if (callback.onComplete) {\n            callback.onComplete(status);\n          }\n          isComplete = true;\n        } else if (\n          status.status === \"failed\" ||\n          status.status === \"cancelled\"\n        ) {\n          if (callback.onError) {\n            callback.onError(\n              new Error(status.error || `Task ${status.status}`)\n            );\n          }\n          isComplete = true;\n        }\n\n        if (!isComplete) {\n          await new Promise((resolve) => setTimeout(resolve, 5000));\n        }\n      } catch (error: any) {\n        if (callback.onError) {\n          callback.onError(error);\n        }\n        throw error;\n      }\n    }\n  }\n\n  /**\n   * DeepResearch: List all tasks\n   */\n  private async _deepresearchList(\n    options?: ListOptions\n  ): Promise<DeepResearchListResponse> {\n    try {\n      const limit = options?.limit || 10;\n      const response = await this.client.get(\n        `${this.baseUrl}/deepresearch/list?limit=${limit}`,\n        { headers: this.headers }\n      );\n\n      return { success: true, data: response.data };\n    } catch (e: any) {\n      return {\n        success: false,\n        error: e.response?.data?.error || e.message,\n      };\n    }\n  }\n\n  /**\n   * DeepResearch: Add follow-up instruction\n   */\n  private async _deepresearchUpdate(\n    taskId: string,\n    instruction: string\n  ): Promise<DeepResearchUpdateResponse> {\n    try {\n      if (!instruction?.trim()) {\n        return {\n          success: false,\n          error: \"instruction is required and cannot be empty\",\n        };\n      }\n\n      const response = await this.client.post(\n        `${this.baseUrl}/deepresearch/tasks/${taskId}/update`,\n        { instruction },\n        { headers: this.headers }\n      );\n\n      return { success: true, ...response.data };\n    } catch (e: any) {\n      return {\n        success: false,\n        error: e.response?.data?.error || e.message,\n      };\n    }\n  }\n\n  /**\n   * DeepResearch: Respond to a HITL checkpoint\n   * @param taskId - The task ID to respond to\n   * @param interactionId - The interaction_id from the task's interaction field\n   * @param response - Response data matching the checkpoint type\n   */\n  private async _deepresearchRespond(\n    taskId: string,\n    interactionId: string,\n    response: Record<string, any>\n  ): Promise<DeepResearchRespondResponse> {\n    try {\n      const resp = await this.client.post(\n        `${this.baseUrl}/deepresearch/tasks/${taskId}/respond`,\n        {\n          interaction_id: interactionId,\n          response,\n        },\n        { headers: this.headers }\n      );\n\n      return { success: true, ...resp.data };\n    } catch (e: any) {\n      return {\n        success: false,\n        error: e.response?.data?.error || e.message,\n      };\n    }\n  }\n\n  /**\n   * DeepResearch: Respond to a planning_questions checkpoint\n   */\n  private async _deepresearchRespondPlanningQuestions(\n    taskId: string,\n    interactionId: string,\n    answers: { question: string; answer: string }[]\n  ): Promise<DeepResearchRespondResponse> {\n    return this._deepresearchRespond(taskId, interactionId, {\n      answers,\n    });\n  }\n\n  /**\n   * DeepResearch: Approve or request modifications to a plan_review checkpoint\n   */\n  private async _deepresearchApprovePlan(\n    taskId: string,\n    interactionId: string,\n    modifications?: string\n  ): Promise<DeepResearchRespondResponse> {\n    const response: Record<string, any> = { approved: true };\n    if (modifications) {\n      response.approved = false;\n      response.modifications = modifications;\n    }\n    return this._deepresearchRespond(taskId, interactionId, response);\n  }\n\n  /**\n   * DeepResearch: Respond to a source_review checkpoint\n   */\n  private async _deepresearchRespondSourceReview(\n    taskId: string,\n    interactionId: string,\n    options: {\n      includedDomains?: string[];\n      excludedDomains?: string[];\n    } = {}\n  ): Promise<DeepResearchRespondResponse> {\n    return this._deepresearchRespond(taskId, interactionId, {\n      included_domains: options.includedDomains || [],\n      excluded_domains: options.excludedDomains || [],\n    });\n  }\n\n  /**\n   * DeepResearch: Approve or request modifications to an outline_review checkpoint\n   */\n  private async _deepresearchApproveOutline(\n    taskId: string,\n    interactionId: string,\n    modifications?: string\n  ): Promise<DeepResearchRespondResponse> {\n    const response: Record<string, any> = { approved: true };\n    if (modifications) {\n      response.approved = false;\n      response.modifications = modifications;\n    }\n    return this._deepresearchRespond(taskId, interactionId, response);\n  }\n\n  /**\n   * DeepResearch: Cancel task\n   */\n  private async _deepresearchCancel(\n    taskId: string\n  ): Promise<DeepResearchCancelResponse> {\n    try {\n      const response = await this.client.post(\n        `${this.baseUrl}/deepresearch/tasks/${taskId}/cancel`,\n        {},\n        { headers: this.headers }\n      );\n\n      return { success: true, ...response.data };\n    } catch (e: any) {\n      return {\n        success: false,\n        error: e.response?.data?.error || e.message,\n      };\n    }\n  }\n\n  /**\n   * DeepResearch: Delete task\n   */\n  private async _deepresearchDelete(\n    taskId: string\n  ): Promise<DeepResearchDeleteResponse> {\n    try {\n      const response = await this.client.delete(\n        `${this.baseUrl}/deepresearch/tasks/${taskId}/delete`,\n        { headers: this.headers }\n      );\n\n      return { success: true, ...response.data };\n    } catch (e: any) {\n      return {\n        success: false,\n        error: e.response?.data?.error || e.message,\n      };\n    }\n  }\n\n  /**\n   * DeepResearch: Toggle public flag\n   */\n  private async _deepresearchTogglePublic(\n    taskId: string,\n    isPublic: boolean\n  ): Promise<DeepResearchTogglePublicResponse> {\n    try {\n      const response = await this.client.post(\n        `${this.baseUrl}/deepresearch/tasks/${taskId}/public`,\n        { public: isPublic },\n        { headers: this.headers }\n      );\n\n      return { success: true, ...response.data };\n    } catch (e: any) {\n      return {\n        success: false,\n        error: e.response?.data?.error || e.message,\n      };\n    }\n  }\n\n  /**\n   * DeepResearch: Get task assets (images, deliverables, PDFs)\n   */\n  private async _deepresearchGetAssets(\n    taskId: string,\n    assetId: string,\n    options: DeepResearchGetAssetsOptions = {}\n  ): Promise<DeepResearchGetAssetsResponse> {\n    try {\n      // Build query params\n      const params = new URLSearchParams();\n      if (options.token) {\n        params.append(\"token\", options.token);\n      }\n\n      // Build headers - use API key if no token provided, always include SDK metadata\n      const headers: Record<string, string> = {\n        \"User-Agent\": `valyu-js/${SDK_VERSION}`,\n        \"X-Valyu-SDK\": \"valyu-js\",\n        \"X-Valyu-SDK-Version\": SDK_VERSION,\n      };\n      if (!options.token) {\n        headers[\"x-api-key\"] = this.headers[\"x-api-key\"];\n      }\n\n      const url = `${\n        this.baseUrl\n      }/deepresearch/tasks/${taskId}/assets/${assetId}${\n        params.toString() ? `?${params.toString()}` : \"\"\n      }`;\n\n      const response = await this.client.get(url, {\n        headers,\n        responseType: \"arraybuffer\", // For binary data\n      });\n\n      return {\n        success: true,\n        data: Buffer.from(response.data),\n        contentType: String(\n          response.headers[\"content-type\"] || \"application/octet-stream\"\n        ),\n      };\n    } catch (e: any) {\n      return {\n        success: false,\n        error: e.response?.data?.error || e.message,\n      };\n    }\n  }\n\n  /**\n   * Batch: Create a new batch\n   * @param options - Batch configuration options\n   * @param options.name - Optional name for the batch\n   * @param options.model - DeepResearch mode: \"fast\", \"standard\", or \"heavy\" (default: \"standard\")\n   * @param options.outputFormats - Output formats for tasks (default: [\"markdown\"])\n   * @param options.search - Search configuration for all tasks in batch\n   * @param options.search.searchType - Type of search: \"all\", \"web\", or \"proprietary\" (default: \"all\")\n   * @param options.search.includedSources - Array of source types to include (e.g., [\"academic\", \"finance\", \"web\"])\n   * @param options.search.excludedSources - Array of source types to exclude (e.g., [\"web\", \"patent\"])\n   * @param options.search.startDate - Start date filter in ISO format (YYYY-MM-DD)\n   * @param options.search.endDate - End date filter in ISO format (YYYY-MM-DD)\n   * @param options.search.historicalCache - When true and a date range is set, searches return the newest cached snapshot inside the range instead of the latest crawl\n   * @param options.search.category - Category filter for search results\n   * @param options.webhookUrl - Optional HTTPS URL for completion notification\n   * @param options.metadata - Optional metadata key-value pairs\n   * @returns Promise resolving to batch creation response with batch_id and webhook_secret\n   */\n  private async _batchCreate(\n    options: CreateBatchOptions = {}\n  ): Promise<CreateBatchResponse> {\n    try {\n      const payload: Record<string, any> = {};\n\n      if (options.name) payload.name = options.name;\n      // Accept both mode (preferred) and model (backward compatible)\n      const mode = options.mode ?? options.model;\n      if (mode) payload.mode = mode;\n      if (options.outputFormats) payload.output_formats = options.outputFormats;\n      if (options.search) {\n        payload.search = {};\n        if (options.search.searchType) {\n          payload.search.search_type = options.search.searchType;\n        }\n        if (options.search.includedSources) {\n          payload.search.included_sources = options.search.includedSources;\n        }\n        if (options.search.excludedSources) {\n          payload.search.excluded_sources = options.search.excludedSources;\n        }\n        if (options.search.sourceBiases) {\n          payload.search.source_biases = options.search.sourceBiases;\n        }\n        if (options.search.startDate) {\n          payload.search.start_date = options.search.startDate;\n        }\n        if (options.search.endDate) {\n          payload.search.end_date = options.search.endDate;\n        }\n        if (options.search.historicalCache !== undefined) {\n          payload.search.historical_cache = options.search.historicalCache;\n        }\n        if (options.search.category) {\n          payload.search.category = options.search.category;\n        }\n      }\n      if (options.webhookUrl) payload.webhook_url = options.webhookUrl;\n      if (options.metadata) payload.metadata = options.metadata;\n\n      const response = await this.client.post(\n        `${this.baseUrl}/deepresearch/batches`,\n        payload,\n        { headers: this.headers }\n      );\n\n      return { success: true, ...response.data };\n    } catch (e: any) {\n      return {\n        success: false,\n        error: e.response?.data?.error || e.message,\n      };\n    }\n  }\n\n  /**\n   * Batch: Get batch status\n   * @param batchId - The batch ID to query\n   * @returns Promise resolving to batch status with counts and usage\n   */\n  private async _batchStatus(batchId: string): Promise<BatchStatusResponse> {\n    try {\n      const response = await this.client.get(\n        `${this.baseUrl}/deepresearch/batches/${batchId}`,\n        { headers: this.headers }\n      );\n\n      return { success: true, batch: response.data };\n    } catch (e: any) {\n      return {\n        success: false,\n        error: e.response?.data?.error || e.message,\n      };\n    }\n  }\n\n  /**\n   * Batch: Add tasks to a batch\n   * @param batchId - The batch ID to add tasks to\n   * @param options - Task configuration options\n   * @param options.tasks - Array of task inputs (use 'query' field for each task)\n   * @returns Promise resolving to response with added, tasks array, counts, and batch_id\n   */\n  private async _batchAddTasks(\n    batchId: string,\n    options: AddBatchTasksOptions\n  ): Promise<AddBatchTasksResponse> {\n    try {\n      if (!options.tasks || !Array.isArray(options.tasks)) {\n        return {\n          success: false,\n          error: \"tasks must be an array\",\n        };\n      }\n\n      if (options.tasks.length === 0) {\n        return {\n          success: false,\n          error: \"tasks array cannot be empty\",\n        };\n      }\n\n      if (options.tasks.length > 100) {\n        return {\n          success: false,\n          error: \"Maximum 100 tasks allowed per request\",\n        };\n      }\n\n      // Validate that each task has a query\n      for (const task of options.tasks) {\n        if (!task.query && !task.input) {\n          return {\n            success: false,\n            error: \"Each task must have a 'query' field\",\n          };\n        }\n      }\n\n      // Convert tasks to snake_case format for API\n      // Note: Tasks can only include: id, query, strategy, urls, metadata\n      // Tasks inherit model, output_formats, and search_params from batch\n      const tasksPayload = options.tasks.map((task) => {\n        const taskPayload: Record<string, any> = {};\n\n        // Use query field (input is supported for backward compatibility)\n        const queryValue = task.query ?? task.input;\n        if (queryValue) {\n          taskPayload.query = queryValue;\n        }\n\n        if (task.id) taskPayload.id = task.id;\n        if (task.strategy) taskPayload.strategy = task.strategy;\n        if (task.researchStrategy)\n          taskPayload.research_strategy = task.researchStrategy;\n        if (task.reportFormat)\n          taskPayload.report_format = task.reportFormat;\n        if (task.urls) taskPayload.urls = task.urls;\n        if (task.metadata) taskPayload.metadata = task.metadata;\n\n        return taskPayload;\n      });\n\n      const response = await this.client.post(\n        `${this.baseUrl}/deepresearch/batches/${batchId}/tasks`,\n        { tasks: tasksPayload },\n        { headers: this.headers }\n      );\n\n      return { success: true, ...response.data };\n    } catch (e: any) {\n      return {\n        success: false,\n        error: e.response?.data?.error || e.message,\n      };\n    }\n  }\n\n  /**\n   * Batch: List all tasks in a batch\n   * @param batchId - The batch ID to query\n   * @param options - Optional pagination and filtering options\n   * @param options.status - Filter by status: \"queued\", \"running\", \"completed\", \"failed\", or \"cancelled\"\n   * @param options.limit - Maximum number of tasks to return\n   * @param options.lastKey - Pagination token from previous response\n   * @returns Promise resolving to list of tasks with their status and pagination info\n   */\n  private async _batchListTasks(\n    batchId: string,\n    options: ListBatchTasksOptions = {}\n  ): Promise<ListBatchTasksResponse> {\n    try {\n      // Build query params\n      const params = new URLSearchParams();\n      if (options.status) {\n        params.append(\"status\", options.status);\n      }\n      if (options.limit !== undefined) {\n        params.append(\"limit\", options.limit.toString());\n      }\n      if (options.lastKey) {\n        params.append(\"last_key\", options.lastKey);\n      }\n      if (options.includeOutput !== undefined) {\n        params.append(\"include_output\", options.includeOutput.toString());\n      }\n\n      const url = `${this.baseUrl}/deepresearch/batches/${batchId}/tasks${\n        params.toString() ? `?${params.toString()}` : \"\"\n      }`;\n      const response = await this.client.get(url, { headers: this.headers });\n\n      return { success: true, ...response.data };\n    } catch (e: any) {\n      return {\n        success: false,\n        error: e.response?.data?.error || e.message,\n      };\n    }\n  }\n\n  /**\n   * Batch: Cancel a batch and all its pending tasks\n   * @param batchId - The batch ID to cancel\n   * @returns Promise resolving to cancellation confirmation\n   */\n  private async _batchCancel(batchId: string): Promise<CancelBatchResponse> {\n    try {\n      const response = await this.client.post(\n        `${this.baseUrl}/deepresearch/batches/${batchId}/cancel`,\n        {},\n        { headers: this.headers }\n      );\n\n      return { success: true, ...response.data };\n    } catch (e: any) {\n      return {\n        success: false,\n        error: e.response?.data?.error || e.message,\n      };\n    }\n  }\n\n  /**\n   * Batch: List all batches\n   * @param options - Optional options\n   * @param options.limit - Maximum number of batches to return\n   * @returns Promise resolving to list of all batches\n   */\n  private async _batchList(\n    options: ListBatchesOptions = {}\n  ): Promise<ListBatchesResponse> {\n    try {\n      // Build query params\n      const params = new URLSearchParams();\n      if (options.limit !== undefined) {\n        params.append(\"limit\", options.limit.toString());\n      }\n\n      const url = `${this.baseUrl}/deepresearch/batches${\n        params.toString() ? `?${params.toString()}` : \"\"\n      }`;\n      const response = await this.client.get(url, {\n        headers: this.headers,\n      });\n\n      return { success: true, batches: response.data };\n    } catch (e: any) {\n      return {\n        success: false,\n        error: e.response?.data?.error || e.message,\n      };\n    }\n  }\n\n  /**\n   * Batch: Wait for batch completion with polling\n   * @param batchId - The batch ID to wait for\n   * @param options - Wait configuration options\n   * @param options.pollInterval - Polling interval in milliseconds (default: 10000)\n   * @param options.maxWaitTime - Maximum wait time in milliseconds (default: 7200000)\n   * @param options.onProgress - Callback for progress updates\n   * @returns Promise resolving to final batch status\n   */\n  private async _batchWaitForCompletion(\n    batchId: string,\n    options: BatchWaitOptions = {}\n  ): Promise<DeepResearchBatch> {\n    const pollInterval = options.pollInterval || 10000; // 10 seconds default\n    const maxWaitTime = options.maxWaitTime || 7200000; // 2 hours default\n    const startTime = Date.now();\n\n    while (true) {\n      const statusResponse = await this._batchStatus(batchId);\n\n      if (!statusResponse.success || !statusResponse.batch) {\n        throw new Error(statusResponse.error || \"Failed to get batch status\");\n      }\n\n      const batch = statusResponse.batch;\n\n      // Notify progress callback\n      if (options.onProgress) {\n        options.onProgress(batch);\n      }\n\n      // Terminal states\n      if (\n        batch.status === \"completed\" ||\n        batch.status === \"completed_with_errors\" ||\n        batch.status === \"cancelled\"\n      ) {\n        return batch;\n      }\n\n      // Check timeout\n      if (Date.now() - startTime > maxWaitTime) {\n        throw new Error(\"Maximum wait time exceeded\");\n      }\n\n      // Wait before next poll\n      await new Promise((resolve) => setTimeout(resolve, pollInterval));\n    }\n  }\n\n  /**\n   * Get AI-powered answers using the Valyu Answer API\n   * @param query - The question or query string\n   * @param options - Answer configuration options\n   * @param options.structuredOutput - JSON Schema object for structured responses\n   * @param options.systemInstructions - Custom system-level instructions (max 2000 chars)\n   * @param options.searchType - Type of search: \"web\", \"proprietary\", \"all\", or \"news\"\n   * @param options.dataMaxPrice - Maximum spend (USD) for data retrieval\n   * @param options.countryCode - Country code filter for search results\n   * @param options.includedSources - List of specific sources to include\n   * @param options.excludedSources - List of URLs/domains to exclude from search results\n   * @param options.startDate - Start date filter (YYYY-MM-DD format)\n   * @param options.endDate - End date filter (YYYY-MM-DD format)\n   * @param options.fastMode - Fast mode for quicker but shorter results (default: false)\n   * @param options.streaming - Enable streaming mode (default: false)\n   * @returns Promise resolving to answer response, or AsyncGenerator for streaming\n   */\n  async answer(\n    query: string,\n    options: AnswerOptions = {}\n  ): Promise<\n    AnswerResponse | AsyncGenerator<AnswerStreamChunk, void, unknown>\n  > {\n    // Validate inputs first\n    const validationError = this.validateAnswerParams(query, options);\n    if (validationError) {\n      if (options.streaming) {\n        return this.createErrorGenerator(validationError);\n      }\n      return { success: false, error: validationError };\n    }\n\n    const payload = this.buildAnswerPayload(query, options);\n\n    if (options.streaming) {\n      return this.streamAnswer(payload);\n    } else {\n      return this.fetchAnswer(payload);\n    }\n  }\n\n  /**\n   * Validate answer parameters\n   */\n  private validateAnswerParams(\n    query: string,\n    options: AnswerOptions\n  ): string | null {\n    // Validate query\n    if (!query || typeof query !== \"string\" || query.trim().length === 0) {\n      return \"Query is required and must be a non-empty string\";\n    }\n\n    // Validate searchType\n    const providedSearchTypeString = options.searchType?.toLowerCase();\n    if (\n      providedSearchTypeString !== undefined &&\n      providedSearchTypeString !== \"web\" &&\n      providedSearchTypeString !== \"proprietary\" &&\n      providedSearchTypeString !== \"all\" &&\n      providedSearchTypeString !== \"news\"\n    ) {\n      return \"Invalid searchType provided. Must be one of: all, web, proprietary, news\";\n    }\n\n    // Validate systemInstructions\n    if (options.systemInstructions !== undefined) {\n      if (typeof options.systemInstructions !== \"string\") {\n        return \"systemInstructions must be a string\";\n      }\n      const trimmed = options.systemInstructions.trim();\n      if (trimmed.length === 0) {\n        return \"systemInstructions cannot be empty when provided\";\n      }\n      if (trimmed.length > 2000) {\n        return \"systemInstructions must be 2000 characters or less\";\n      }\n    }\n\n    // Validate dataMaxPrice\n    if (options.dataMaxPrice !== undefined) {\n      if (\n        typeof options.dataMaxPrice !== \"number\" ||\n        options.dataMaxPrice <= 0\n      ) {\n        return \"dataMaxPrice must be a positive number\";\n      }\n    }\n\n    // Validate date formats\n    if (options.startDate && !this.validateDateFormat(options.startDate)) {\n      return \"Invalid startDate format. Must be YYYY-MM-DD\";\n    }\n    if (options.endDate && !this.validateDateFormat(options.endDate)) {\n      return \"Invalid endDate format. Must be YYYY-MM-DD\";\n    }\n    if (options.startDate && options.endDate) {\n      const startDate = new Date(options.startDate);\n      const endDate = new Date(options.endDate);\n      if (startDate > endDate) {\n        return \"startDate must be before endDate\";\n      }\n    }\n\n    // Validate sources\n    if (options.includedSources !== undefined) {\n      if (!Array.isArray(options.includedSources)) {\n        return \"includedSources must be an array\";\n      }\n      const validation = this.validateSources(options.includedSources);\n      if (!validation.valid) {\n        return `Invalid includedSources format. Invalid sources: ${validation.invalidSources.join(\n          \", \"\n        )}.`;\n      }\n    }\n    if (options.excludedSources !== undefined) {\n      if (!Array.isArray(options.excludedSources)) {\n        return \"excludedSources must be an array\";\n      }\n      const validation = this.validateSources(options.excludedSources);\n      if (!validation.valid) {\n        return `Invalid excludedSources format. Invalid sources: ${validation.invalidSources.join(\n          \", \"\n        )}.`;\n      }\n    }\n\n    return null;\n  }\n\n  /**\n   * Build payload for answer API\n   */\n  private buildAnswerPayload(\n    query: string,\n    options: AnswerOptions\n  ): Record<string, any> {\n    const defaultSearchType: SearchType = \"all\";\n    const providedSearchTypeString = options.searchType?.toLowerCase();\n    let finalSearchType: SearchType = defaultSearchType;\n\n    if (\n      providedSearchTypeString === \"web\" ||\n      providedSearchTypeString === \"proprietary\" ||\n      providedSearchTypeString === \"all\" ||\n      providedSearchTypeString === \"news\"\n    ) {\n      finalSearchType = providedSearchTypeString as SearchType;\n    }\n\n    const payload: Record<string, any> = {\n      query: query.trim(),\n      search_type: finalSearchType,\n    };\n\n    if (options.dataMaxPrice !== undefined)\n      payload.data_max_price = options.dataMaxPrice;\n    if (options.structuredOutput !== undefined)\n      payload.structured_output = options.structuredOutput;\n    if (options.systemInstructions !== undefined)\n      payload.system_instructions = options.systemInstructions.trim();\n    if (options.countryCode !== undefined)\n      payload.country_code = options.countryCode;\n    if (options.includedSources !== undefined)\n      payload.included_sources = options.includedSources;\n    if (options.excludedSources !== undefined)\n      payload.excluded_sources = options.excludedSources;\n    if (options.startDate !== undefined) payload.start_date = options.startDate;\n    if (options.endDate !== undefined) payload.end_date = options.endDate;\n    if (options.fastMode !== undefined) payload.fast_mode = options.fastMode;\n\n    return payload;\n  }\n\n  /**\n   * Fetch answer (non-streaming mode)\n   */\n  private async fetchAnswer(\n    payload: Record<string, any>\n  ): Promise<AnswerResponse> {\n    try {\n      const response = await fetch(`${this.baseUrl}/answer`, {\n        method: \"POST\",\n        headers: {\n          ...this.headers,\n          Accept: \"text/event-stream\",\n        },\n        body: JSON.stringify(payload),\n      });\n\n      if (!response.ok) {\n        const errorData = await response.json().catch(() => ({}));\n        return {\n          success: false,\n          error: errorData.error || `HTTP Error: ${response.status}`,\n        };\n      }\n\n      // Collect streamed data into final response\n      let fullContent = \"\";\n      let searchResults: SearchResult[] = [];\n      let finalMetadata: any = {};\n\n      const reader = response.body?.getReader();\n      const decoder = new TextDecoder();\n      let buffer = \"\";\n\n      if (reader) {\n        while (true) {\n          const { done, value } = await reader.read();\n          if (done) break;\n\n          buffer += decoder.decode(value, { stream: true });\n          const lines = buffer.split(\"\\n\");\n          buffer = lines.pop() || \"\";\n\n          for (const line of lines) {\n            if (!line.startsWith(\"data: \")) continue;\n            const dataStr = line.slice(6);\n\n            if (dataStr === \"[DONE]\") continue;\n\n            try {\n              const parsed = JSON.parse(dataStr);\n\n              // Handle search results\n              if (parsed.search_results && !parsed.success) {\n                searchResults = [...searchResults, ...parsed.search_results];\n              }\n              // Handle content chunks\n              else if (parsed.choices) {\n                const content = parsed.choices[0]?.delta?.content || \"\";\n                if (content) fullContent += content;\n              }\n              // Handle final metadata\n              else if (parsed.success !== undefined) {\n                finalMetadata = parsed;\n              }\n            } catch {\n              continue;\n            }\n          }\n        }\n      }\n\n      // Build final response\n      if (finalMetadata.success) {\n        const finalSearchResults =\n          finalMetadata.search_results || searchResults;\n        const response: AnswerSuccessResponse = {\n          success: true,\n          tx_id: finalMetadata.tx_id || \"\",\n          original_query: finalMetadata.original_query || payload.query,\n          contents: finalMetadata.contents || fullContent || \"\",\n          search_results: finalSearchResults,\n          search_metadata: finalMetadata.search_metadata || {\n            tx_ids: [],\n            number_of_results: 0,\n            total_characters: 0,\n          },\n          ai_usage: finalMetadata.ai_usage || {\n            input_tokens: 0,\n            output_tokens: 0,\n          },\n          cost: finalMetadata.cost || {\n            total_deduction_dollars: 0,\n            search_deduction_dollars: 0,\n            ai_deduction_dollars: 0,\n          },\n        };\n        if (finalMetadata.extraction_metadata) {\n          response.extraction_metadata = finalMetadata.extraction_metadata;\n        }\n        return response;\n      }\n\n      return {\n        success: false,\n        error: finalMetadata.error || \"Unknown error occurred\",\n      };\n    } catch (e: any) {\n      return {\n        success: false,\n        error: e.message || \"Request failed\",\n      };\n    }\n  }\n\n  /**\n   * Stream answer using SSE\n   */\n  private async *streamAnswer(\n    payload: Record<string, any>\n  ): AsyncGenerator<AnswerStreamChunk, void, unknown> {\n    try {\n      const response = await fetch(`${this.baseUrl}/answer`, {\n        method: \"POST\",\n        headers: {\n          ...this.headers,\n          Accept: \"text/event-stream\",\n        },\n        body: JSON.stringify(payload),\n      });\n\n      if (!response.ok) {\n        const errorData = await response.json().catch(() => ({}));\n        yield {\n          type: \"error\",\n          error: errorData.error || `HTTP Error: ${response.status}`,\n        };\n        return;\n      }\n\n      const reader = response.body?.getReader();\n      const decoder = new TextDecoder();\n      let buffer = \"\";\n\n      if (!reader) {\n        yield { type: \"error\", error: \"No response body\" };\n        return;\n      }\n\n      while (true) {\n        const { done, value } = await reader.read();\n        if (done) break;\n\n        buffer += decoder.decode(value, { stream: true });\n        const lines = buffer.split(\"\\n\");\n        buffer = lines.pop() || \"\";\n\n        for (const line of lines) {\n          if (!line.startsWith(\"data: \")) continue;\n          const dataStr = line.slice(6);\n\n          if (dataStr === \"[DONE]\") {\n            yield { type: \"done\" };\n            continue;\n          }\n\n          try {\n            const parsed = JSON.parse(dataStr);\n\n            // Handle search results\n            if (parsed.search_results && parsed.success === undefined) {\n              yield {\n                type: \"search_results\",\n                search_results: parsed.search_results,\n              };\n            }\n            // Handle content chunks\n            else if (parsed.choices) {\n              const delta = parsed.choices[0]?.delta || {};\n              const content = delta.content || \"\";\n              const finishReason = parsed.choices[0]?.finish_reason;\n\n              if (content || finishReason) {\n                yield { type: \"content\", content, finish_reason: finishReason };\n              }\n            }\n            // Handle final metadata\n            else if (parsed.success !== undefined) {\n              yield {\n                type: \"metadata\",\n                tx_id: parsed.tx_id,\n                original_query: parsed.original_query,\n                contents: parsed.contents,\n                search_results: parsed.search_results,\n                search_metadata: parsed.search_metadata,\n                ai_usage: parsed.ai_usage,\n                cost: parsed.cost,\n                extraction_metadata: parsed.extraction_metadata,\n              };\n            }\n          } catch {\n            continue;\n          }\n        }\n      }\n    } catch (e: any) {\n      yield { type: \"error\", error: e.message || \"Stream failed\" };\n    }\n  }\n\n  /**\n   * Create an error generator for streaming errors\n   */\n  private async *createErrorGenerator(\n    error: string\n  ): AsyncGenerator<AnswerStreamChunk, void, unknown> {\n    yield { type: \"error\", error };\n  }\n\n  /**\n   * Datasources: List all available datasources\n   * @param options - Optional filter options\n   * @param options.category - Filter by category (e.g., \"research\", \"markets\", \"healthcare\")\n   * @returns Promise resolving to list of datasources with their metadata\n   */\n  private async _datasourcesList(\n    options: DatasourcesListOptions = {}\n  ): Promise<DatasourcesListResponse> {\n    try {\n      // Build query params\n      const params = new URLSearchParams();\n      if (options.category) {\n        params.append(\"category\", options.category);\n      }\n\n      const url = `${this.baseUrl}/datasources${\n        params.toString() ? `?${params.toString()}` : \"\"\n      }`;\n      const response = await this.client.get(url, { headers: this.headers });\n\n      return { success: true, datasources: response.data.datasources };\n    } catch (e: any) {\n      return {\n        success: false,\n        error: e.response?.data?.error || e.message,\n      };\n    }\n  }\n\n  /**\n   * Datasources: Get all available categories\n   * @returns Promise resolving to list of categories with their metadata\n   */\n  private async _datasourcesCategories(): Promise<DatasourcesCategoriesResponse> {\n    try {\n      const response = await this.client.get(`${this.baseUrl}/datasources/categories`, {\n        headers: this.headers,\n      });\n\n      return { success: true, categories: response.data.categories };\n    } catch (e: any) {\n      return {\n        success: false,\n        error: e.response?.data?.error || e.message,\n      };\n    }\n  }\n\n  /** Extract the most descriptive error message from a Workflows API error. */\n  private workflowError(e: any): string {\n    return e.response?.data?.message || e.response?.data?.error || e.message;\n  }\n\n  /**\n   * Workflows: List workflows available to your org\n   * @param options - Filters: vertical, scope (\"valyu\" | \"org\" | \"all\"), q, tags, limit, expand\n   */\n  private async _workflowsList(\n    options: WorkflowsListOptions = {}\n  ): Promise<WorkflowsListResponse> {\n    try {\n      const params = new URLSearchParams();\n      if (options.vertical) params.append(\"vertical\", options.vertical);\n      if (options.scope) params.append(\"scope\", options.scope);\n      if (options.q) params.append(\"q\", options.q);\n      if (options.tags?.length) params.append(\"tags\", options.tags.join(\",\"));\n      if (options.limit !== undefined) {\n        params.append(\"limit\", String(options.limit));\n      }\n      if (options.expand) params.append(\"expand\", \"true\");\n\n      const url = `${this.baseUrl}/workflows${\n        params.toString() ? `?${params.toString()}` : \"\"\n      }`;\n      const response = await this.client.get(url, { headers: this.headers });\n\n      return { success: true, ...response.data };\n    } catch (e: any) {\n      return { success: false, error: this.workflowError(e) };\n    }\n  }\n\n  /**\n   * Workflows: Get a workflow's full detail, including its template\n   * @param slug - Workflow slug\n   * @param version - Specific version to fetch (defaults to the current version)\n   */\n  private async _workflowsGet(\n    slug: string,\n    version?: number\n  ): Promise<WorkflowResponse> {\n    try {\n      const url = `${this.baseUrl}/workflows/${encodeURIComponent(slug)}${\n        version !== undefined ? `?version=${version}` : \"\"\n      }`;\n      const response = await this.client.get(url, { headers: this.headers });\n\n      return { success: true, workflow: response.data };\n    } catch (e: any) {\n      return { success: false, error: this.workflowError(e) };\n    }\n  }\n\n  /**\n   * Workflows: List a workflow's version history\n   * @param slug - Workflow slug\n   */\n  private async _workflowsVersions(\n    slug: string\n  ): Promise<WorkflowVersionsResponse> {\n    try {\n      const response = await this.client.get(\n        `${this.baseUrl}/workflows/${encodeURIComponent(slug)}/versions`,\n        { headers: this.headers }\n      );\n\n      return { success: true, ...response.data };\n    } catch (e: any) {\n      return { success: false, error: this.workflowError(e) };\n    }\n  }\n\n  /**\n   * Workflows: Resolve a workflow's template with params without creating a task\n   * @param slug - Workflow slug\n   * @param options - workflowParams (variable values) and optional workflowVersion\n   */\n  private async _workflowsPreview(\n    slug: string,\n    options: WorkflowPreviewOptions = {}\n  ): Promise<WorkflowPreviewResponse> {\n    try {\n      const payload: Record<string, any> = {};\n      if (options.workflowParams !== undefined) {\n        payload.workflow_params = options.workflowParams;\n      }\n      if (options.workflowVersion !== undefined) {\n        payload.workflow_version = options.workflowVersion;\n      }\n\n      const response = await this.client.post(\n        `${this.baseUrl}/workflows/${encodeURIComponent(slug)}/preview`,\n        payload,\n        { headers: this.headers }\n      );\n\n      return { success: true, ...response.data };\n    } catch (e: any) {\n      return { success: false, error: this.workflowError(e) };\n    }\n  }\n\n  /**\n   * Workflows: Create a new workflow for your org\n   * @param options - slug, title, version (template body), and optional metadata\n   */\n  private async _workflowsCreate(\n    options: WorkflowCreateOptions\n  ): Promise<WorkflowResponse> {\n    try {\n      const payload: Record<string, any> = {\n        slug: options.slug,\n        title: options.title,\n        version: options.version,\n      };\n      if (options.subtitle !== undefined) payload.subtitle = options.subtitle;\n      if (options.description !== undefined) {\n        payload.description = options.description;\n      }\n      if (options.vertical !== undefined) payload.vertical = options.vertical;\n      if (options.tags !== undefined) payload.tags = options.tags;\n      if (options.icon !== undefined) payload.icon = options.icon;\n\n      const response = await this.client.post(\n        `${this.baseUrl}/workflows`,\n        payload,\n        { headers: this.headers }\n      );\n\n      return { success: true, workflow: response.data };\n    } catch (e: any) {\n      return { success: false, error: this.workflowError(e) };\n    }\n  }\n\n  /**\n   * Workflows: Update a workflow's metadata and/or publish a new template version.\n   * Only workflows owned by your org can be updated; versions are append-only\n   * (a version body requires a changelog).\n   * @param slug - Workflow slug\n   * @param options - Metadata fields and/or a new version body\n   */\n  private async _workflowsUpdate(\n    slug: string,\n    options: WorkflowUpdateOptions\n  ): Promise<WorkflowResponse> {\n    try {\n      const payload: Record<string, any> = {};\n      if (options.title !== undefined) payload.title = options.title;\n      if (options.subtitle !== undefined) payload.subtitle = options.subtitle;\n      if (options.description !== undefined) {\n        payload.description = options.description;\n      }\n      if (options.vertical !== undefined) payload.vertical = options.vertical;\n      if (options.tags !== undefined) payload.tags = options.tags;\n      if (options.icon !== undefined) payload.icon = options.icon;\n      if (options.version !== undefined) payload.version = options.version;\n      if (options.setCurrent !== undefined) {\n        payload.set_current = options.setCurrent;\n      }\n\n      const response = await this.client.patch(\n        `${this.baseUrl}/workflows/${encodeURIComponent(slug)}`,\n        payload,\n        { headers: this.headers }\n      );\n\n      return { success: true, workflow: response.data };\n    } catch (e: any) {\n      return { success: false, error: this.workflowError(e) };\n    }\n  }\n\n  /**\n   * Workflows: Delete a workflow owned by your org (soft delete)\n   * @param slug - Workflow slug\n   */\n  private async _workflowsDelete(\n    slug: string\n  ): Promise<WorkflowDeleteResponse> {\n    try {\n      const response = await this.client.delete(\n        `${this.baseUrl}/workflows/${encodeURIComponent(slug)}`,\n        { headers: this.headers }\n      );\n\n      return { success: true, ...response.data };\n    } catch (e: any) {\n      return { success: false, error: this.workflowError(e) };\n    }\n  }\n}\n\nexport type {\n  SearchResponse,\n  SearchType,\n  SearchResult,\n  FeedbackSentiment,\n  FeedbackResponse,\n  SearchOptions,\n  CountryCode,\n  ResponseLength,\n  ContentsOptions,\n  ContentsResponse,\n  ContentsAsyncJobResponse,\n  ContentsJobResponse,\n  ContentsJobStatus,\n  ContentsJobWaitOptions,\n  ContentResult,\n  ContentResultSuccess,\n  ContentResultFailed,\n  ExtractEffort,\n  ContentResponseLength,\n  AnswerOptions,\n  AnswerResponse,\n  AnswerSuccessResponse,\n  AnswerErrorResponse,\n  AnswerStreamChunk,\n  AnswerStreamChunkType,\n  SearchMetadata,\n  AIUsage,\n  Cost,\n  ExtractionMetadata,\n  AlertEmailConfig,\n  DeepResearchMode,\n  DeepResearchStatus,\n  DeepResearchOutputFormat,\n  ImageType,\n  ChartType,\n  FileAttachment,\n  MCPServerConfig,\n  DeepResearchSearchConfig,\n  DeepResearchCreateOptions,\n  Progress,\n  ChartDataPoint,\n  ChartDataSeries,\n  ImageMetadata,\n  DeepResearchSource,\n  DeepResearchUsage,\n  DeepResearchCostBreakdown,\n  ToolConfig,\n  DeepResearchTools,\n  DeepResearchCreateResponse,\n  DeepResearchStatusResponse,\n  DeepResearchTaskListItem,\n  DeepResearchListResponse,\n  DeepResearchUpdateResponse,\n  DeepResearchCancelResponse,\n  DeepResearchDeleteResponse,\n  DeepResearchTogglePublicResponse,\n  DeepResearchGetAssetsOptions,\n  DeepResearchGetAssetsResponse,\n  DeepResearchRespondResponse,\n  HitlConfig,\n  InteractionType,\n  Interaction,\n  InteractionHistoryEntry,\n  WaitOptions,\n  StreamCallback,\n  ListOptions,\n  BatchStatus,\n  BatchCounts,\n  DeepResearchBatch,\n  CreateBatchOptions,\n  BatchTaskInput,\n  AddBatchTasksOptions,\n  CreateBatchResponse,\n  BatchStatusResponse,\n  AddBatchTasksResponse,\n  BatchTaskCreated,\n  BatchTaskListItem,\n  BatchPagination,\n  ListBatchTasksOptions,\n  ListBatchTasksResponse,\n  CancelBatchResponse,\n  ListBatchesOptions,\n  ListBatchesResponse,\n  BatchWaitOptions,\n  DatasourceCategoryId,\n  DatasourceModality,\n  DatasourcePricing,\n  DatasourceCoverage,\n  Datasource,\n  DatasourceCategory,\n  DatasourcesListOptions,\n  DatasourcesListResponse,\n  DatasourcesCategoriesResponse,\n  WorkflowMode,\n  WorkflowVariableType,\n  WorkflowVariableValidation,\n  WorkflowVariable,\n  WorkflowDeliverable,\n  WorkflowTools,\n  Workflow,\n  WorkflowVersionSummary,\n  WorkflowRunInfo,\n  ResolvedWorkflowTemplate,\n  WorkflowVersionInput,\n  WorkflowsListOptions,\n  WorkflowCreateOptions,\n  WorkflowUpdateOptions,\n  WorkflowPreviewOptions,\n  WorkflowsListResponse,\n  WorkflowResponse,\n  WorkflowVersionsResponse,\n  WorkflowPreviewResponse,\n  WorkflowDeleteResponse,\n} from \"./types\";\n"],"mappings":";AAAA,SAAS,YAAY,uBAAuB;AAC5C,OAAO,UAAU;AACjB,OAAO,WAAW;AAClB,OAAO,WAA8B;AAuDrC,IAAM,cAAc;AAQpB,IAAM,6CAA6C;AAOnD,IAAM,yBAAyB,oBAAI,IAAI,CAAC,KAAK,KAAK,KAAK,KAAK,KAAK,GAAG,CAAC;AAGrE,SAAS,6BAA6B,KAA+C;AACnF,SAAO;AAAA,IACL,SAAS,IAAI,WAAW;AAAA,IACxB,OAAO,IAAI,UAAU,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