valyu-js 2.0.2 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -59,6 +59,64 @@ var Valyu = class {
59
59
  const parsedDate = new Date(date);
60
60
  return parsedDate instanceof Date && !isNaN(parsedDate.getTime());
61
61
  }
62
+ /**
63
+ * Validates if a string is a valid URL
64
+ */
65
+ validateUrl(url) {
66
+ try {
67
+ new URL(url);
68
+ return true;
69
+ } catch {
70
+ return false;
71
+ }
72
+ }
73
+ /**
74
+ * Validates if a string is a valid domain (with optional path)
75
+ */
76
+ validateDomain(domain) {
77
+ const domainRegex = /^[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])?)+(\/.+)?$/;
78
+ return domainRegex.test(domain);
79
+ }
80
+ /**
81
+ * Validates if a string is a valid dataset identifier (provider/datasetname)
82
+ */
83
+ validateDatasetId(datasetId) {
84
+ const parts = datasetId.split("/");
85
+ if (parts.length !== 2) return false;
86
+ const providerRegex = /^[a-zA-Z0-9_-]+$/;
87
+ const datasetRegex = /^[a-zA-Z0-9_-]+$/;
88
+ return providerRegex.test(parts[0]) && datasetRegex.test(parts[1]) && parts[0].length > 0 && parts[1].length > 0;
89
+ }
90
+ /**
91
+ * Validates source strings (domains, URLs, or dataset IDs)
92
+ */
93
+ validateSource(source) {
94
+ if (this.validateUrl(source)) {
95
+ return true;
96
+ }
97
+ if (this.validateDomain(source)) {
98
+ return true;
99
+ }
100
+ if (this.validateDatasetId(source)) {
101
+ return true;
102
+ }
103
+ return false;
104
+ }
105
+ /**
106
+ * Validates an array of source strings
107
+ */
108
+ validateSources(sources) {
109
+ const invalidSources = [];
110
+ for (const source of sources) {
111
+ if (!this.validateSource(source)) {
112
+ invalidSources.push(source);
113
+ }
114
+ }
115
+ return {
116
+ valid: invalidSources.length === 0,
117
+ invalidSources
118
+ };
119
+ }
62
120
  /**
63
121
  * Search for information using the Valyu DeepSearch API
64
122
  * @param query - The search query string
@@ -75,6 +133,7 @@ var Valyu = class {
75
133
  * @param options.endDate - End date filter (YYYY-MM-DD format)
76
134
  * @param options.countryCode - Country code filter for search results
77
135
  * @param options.responseLength - Response content length: "short"/"medium"/"large"/"max" or integer character count
136
+ * @param options.fastMode - Fast mode for quicker but shorter results (default: false)
78
137
  * @returns Promise resolving to search results
79
138
  */
80
139
  async search(query, options = {}) {
@@ -141,6 +200,72 @@ var Valyu = class {
141
200
  total_characters: 0
142
201
  };
143
202
  }
203
+ if (options.includedSources !== void 0) {
204
+ if (!Array.isArray(options.includedSources)) {
205
+ return {
206
+ success: false,
207
+ error: "includedSources must be an array",
208
+ tx_id: null,
209
+ query,
210
+ results: [],
211
+ results_by_source: { web: 0, proprietary: 0 },
212
+ total_deduction_pcm: 0,
213
+ total_deduction_dollars: 0,
214
+ total_characters: 0
215
+ };
216
+ }
217
+ const includedSourcesValidation = this.validateSources(
218
+ options.includedSources
219
+ );
220
+ if (!includedSourcesValidation.valid) {
221
+ return {
222
+ success: false,
223
+ error: `Invalid includedSources format. Invalid sources: ${includedSourcesValidation.invalidSources.join(
224
+ ", "
225
+ )}. Sources must be valid URLs, domains (with optional paths), or dataset identifiers in 'provider/dataset' format.`,
226
+ tx_id: null,
227
+ query,
228
+ results: [],
229
+ results_by_source: { web: 0, proprietary: 0 },
230
+ total_deduction_pcm: 0,
231
+ total_deduction_dollars: 0,
232
+ total_characters: 0
233
+ };
234
+ }
235
+ }
236
+ if (options.excludeSources !== void 0) {
237
+ if (!Array.isArray(options.excludeSources)) {
238
+ return {
239
+ success: false,
240
+ error: "excludeSources must be an array",
241
+ tx_id: null,
242
+ query,
243
+ results: [],
244
+ results_by_source: { web: 0, proprietary: 0 },
245
+ total_deduction_pcm: 0,
246
+ total_deduction_dollars: 0,
247
+ total_characters: 0
248
+ };
249
+ }
250
+ const excludeSourcesValidation = this.validateSources(
251
+ options.excludeSources
252
+ );
253
+ if (!excludeSourcesValidation.valid) {
254
+ return {
255
+ success: false,
256
+ error: `Invalid excludeSources format. Invalid sources: ${excludeSourcesValidation.invalidSources.join(
257
+ ", "
258
+ )}. Sources must be valid URLs, domains (with optional paths), or dataset identifiers in 'provider/dataset' format.`,
259
+ tx_id: null,
260
+ query,
261
+ results: [],
262
+ results_by_source: { web: 0, proprietary: 0 },
263
+ total_deduction_pcm: 0,
264
+ total_deduction_dollars: 0,
265
+ total_characters: 0
266
+ };
267
+ }
268
+ }
144
269
  const payload = {
145
270
  query,
146
271
  search_type: finalSearchType,
@@ -170,11 +295,12 @@ var Valyu = class {
170
295
  if (options.responseLength !== void 0) {
171
296
  payload.response_length = options.responseLength;
172
297
  }
173
- const response = await import_axios.default.post(
174
- `${this.baseUrl}/deepsearch`,
175
- payload,
176
- { headers: this.headers }
177
- );
298
+ if (options.fastMode !== void 0) {
299
+ payload.fast_mode = options.fastMode;
300
+ }
301
+ const response = await import_axios.default.post(`${this.baseUrl}/deepsearch`, payload, {
302
+ headers: this.headers
303
+ });
178
304
  if (!response.status || response.status < 200 || response.status >= 300) {
179
305
  return {
180
306
  success: false,
@@ -203,6 +329,308 @@ var Valyu = class {
203
329
  };
204
330
  }
205
331
  }
332
+ /**
333
+ * Extract content from URLs with optional AI processing
334
+ * @param urls - Array of URLs to process (max 10)
335
+ * @param options - Content extraction configuration options
336
+ * @param options.summary - AI summary configuration: false (raw), true (auto), string (custom), or JSON schema
337
+ * @param options.extractEffort - Extraction thoroughness: "normal" or "high"
338
+ * @param options.responseLength - Content length per URL
339
+ * @param options.maxPriceDollars - Maximum cost limit in USD
340
+ * @returns Promise resolving to content extraction results
341
+ */
342
+ async contents(urls, options = {}) {
343
+ try {
344
+ if (!urls || !Array.isArray(urls)) {
345
+ return {
346
+ success: false,
347
+ error: "urls must be an array",
348
+ urls_requested: 0,
349
+ urls_processed: 0,
350
+ urls_failed: 0,
351
+ results: [],
352
+ total_cost_dollars: 0,
353
+ total_characters: 0
354
+ };
355
+ }
356
+ if (urls.length === 0) {
357
+ return {
358
+ success: false,
359
+ error: "urls array cannot be empty",
360
+ urls_requested: 0,
361
+ urls_processed: 0,
362
+ urls_failed: 0,
363
+ results: [],
364
+ total_cost_dollars: 0,
365
+ total_characters: 0
366
+ };
367
+ }
368
+ if (urls.length > 10) {
369
+ return {
370
+ success: false,
371
+ error: "Maximum 10 URLs allowed per request",
372
+ urls_requested: urls.length,
373
+ urls_processed: 0,
374
+ urls_failed: urls.length,
375
+ results: [],
376
+ total_cost_dollars: 0,
377
+ total_characters: 0
378
+ };
379
+ }
380
+ if (options.extractEffort && !["normal", "high", "auto"].includes(options.extractEffort)) {
381
+ return {
382
+ success: false,
383
+ error: "extractEffort must be 'normal', 'high', or 'auto'",
384
+ urls_requested: urls.length,
385
+ urls_processed: 0,
386
+ urls_failed: urls.length,
387
+ results: [],
388
+ total_cost_dollars: 0,
389
+ total_characters: 0
390
+ };
391
+ }
392
+ if (options.responseLength !== void 0) {
393
+ const validLengths = ["short", "medium", "large", "max"];
394
+ if (typeof options.responseLength === "string" && !validLengths.includes(options.responseLength)) {
395
+ return {
396
+ success: false,
397
+ error: "responseLength must be 'short', 'medium', 'large', 'max', or a number",
398
+ urls_requested: urls.length,
399
+ urls_processed: 0,
400
+ urls_failed: urls.length,
401
+ results: [],
402
+ total_cost_dollars: 0,
403
+ total_characters: 0
404
+ };
405
+ }
406
+ if (typeof options.responseLength === "number" && options.responseLength <= 0) {
407
+ return {
408
+ success: false,
409
+ error: "responseLength number must be positive",
410
+ urls_requested: urls.length,
411
+ urls_processed: 0,
412
+ urls_failed: urls.length,
413
+ results: [],
414
+ total_cost_dollars: 0,
415
+ total_characters: 0
416
+ };
417
+ }
418
+ }
419
+ const payload = {
420
+ urls
421
+ };
422
+ if (options.summary !== void 0) {
423
+ payload.summary = options.summary;
424
+ }
425
+ if (options.extractEffort !== void 0) {
426
+ payload.extract_effort = options.extractEffort;
427
+ }
428
+ if (options.responseLength !== void 0) {
429
+ payload.response_length = options.responseLength;
430
+ }
431
+ if (options.maxPriceDollars !== void 0) {
432
+ payload.max_price_dollars = options.maxPriceDollars;
433
+ }
434
+ const response = await import_axios.default.post(`${this.baseUrl}/contents`, payload, {
435
+ headers: this.headers
436
+ });
437
+ if (!response.status || response.status < 200 || response.status >= 300) {
438
+ return {
439
+ success: false,
440
+ error: response.data?.error || "Request failed",
441
+ urls_requested: urls.length,
442
+ urls_processed: 0,
443
+ urls_failed: urls.length,
444
+ results: [],
445
+ total_cost_dollars: 0,
446
+ total_characters: 0
447
+ };
448
+ }
449
+ return response.data;
450
+ } catch (e) {
451
+ return {
452
+ success: false,
453
+ error: e.response?.data?.error || e.message,
454
+ urls_requested: urls.length,
455
+ urls_processed: 0,
456
+ urls_failed: urls.length,
457
+ results: [],
458
+ total_cost_dollars: 0,
459
+ total_characters: 0
460
+ };
461
+ }
462
+ }
463
+ /**
464
+ * Get AI-powered answers using the Valyu Answer API
465
+ * @param query - The question or query string
466
+ * @param options - Answer configuration options
467
+ * @param options.structuredOutput - JSON Schema object for structured responses
468
+ * @param options.systemInstructions - Custom system-level instructions (max 2000 chars)
469
+ * @param options.searchType - Type of search: "web", "proprietary", or "all"
470
+ * @param options.dataMaxPrice - Maximum spend (USD) for data retrieval
471
+ * @param options.countryCode - Country code filter for search results
472
+ * @param options.includedSources - List of specific sources to include
473
+ * @param options.excludedSources - List of URLs/domains to exclude from search results
474
+ * @param options.startDate - Start date filter (YYYY-MM-DD format)
475
+ * @param options.endDate - End date filter (YYYY-MM-DD format)
476
+ * @param options.fastMode - Fast mode for quicker but shorter results (default: false)
477
+ * @returns Promise resolving to answer response
478
+ */
479
+ async answer(query, options = {}) {
480
+ try {
481
+ const defaultSearchType = "all";
482
+ const defaultDataMaxPrice = 30;
483
+ if (!query || typeof query !== "string" || query.trim().length === 0) {
484
+ return {
485
+ success: false,
486
+ error: "Query is required and must be a non-empty string"
487
+ };
488
+ }
489
+ let finalSearchType = defaultSearchType;
490
+ const providedSearchTypeString = options.searchType?.toLowerCase();
491
+ if (providedSearchTypeString === "web" || providedSearchTypeString === "proprietary" || providedSearchTypeString === "all") {
492
+ finalSearchType = providedSearchTypeString;
493
+ } else if (options.searchType !== void 0) {
494
+ return {
495
+ success: false,
496
+ error: "Invalid searchType provided. Must be one of: all, web, proprietary"
497
+ };
498
+ }
499
+ if (options.systemInstructions !== void 0) {
500
+ if (typeof options.systemInstructions !== "string") {
501
+ return {
502
+ success: false,
503
+ error: "systemInstructions must be a string"
504
+ };
505
+ }
506
+ const trimmed = options.systemInstructions.trim();
507
+ if (trimmed.length === 0) {
508
+ return {
509
+ success: false,
510
+ error: "systemInstructions cannot be empty when provided"
511
+ };
512
+ }
513
+ if (trimmed.length > 2e3) {
514
+ return {
515
+ success: false,
516
+ error: "systemInstructions must be 2000 characters or less"
517
+ };
518
+ }
519
+ }
520
+ if (options.dataMaxPrice !== void 0) {
521
+ if (typeof options.dataMaxPrice !== "number" || options.dataMaxPrice <= 0) {
522
+ return {
523
+ success: false,
524
+ error: "dataMaxPrice must be a positive number"
525
+ };
526
+ }
527
+ }
528
+ if (options.startDate && !this.validateDateFormat(options.startDate)) {
529
+ return {
530
+ success: false,
531
+ error: "Invalid startDate format. Must be YYYY-MM-DD"
532
+ };
533
+ }
534
+ if (options.endDate && !this.validateDateFormat(options.endDate)) {
535
+ return {
536
+ success: false,
537
+ error: "Invalid endDate format. Must be YYYY-MM-DD"
538
+ };
539
+ }
540
+ if (options.startDate && options.endDate) {
541
+ const startDate = new Date(options.startDate);
542
+ const endDate = new Date(options.endDate);
543
+ if (startDate > endDate) {
544
+ return {
545
+ success: false,
546
+ error: "startDate must be before endDate"
547
+ };
548
+ }
549
+ }
550
+ if (options.includedSources !== void 0) {
551
+ if (!Array.isArray(options.includedSources)) {
552
+ return {
553
+ success: false,
554
+ error: "includedSources must be an array"
555
+ };
556
+ }
557
+ const includedSourcesValidation = this.validateSources(
558
+ options.includedSources
559
+ );
560
+ if (!includedSourcesValidation.valid) {
561
+ return {
562
+ success: false,
563
+ error: `Invalid includedSources format. Invalid sources: ${includedSourcesValidation.invalidSources.join(
564
+ ", "
565
+ )}. Sources must be valid URLs, domains (with optional paths), or dataset identifiers in 'provider/dataset' format.`
566
+ };
567
+ }
568
+ }
569
+ if (options.excludedSources !== void 0) {
570
+ if (!Array.isArray(options.excludedSources)) {
571
+ return {
572
+ success: false,
573
+ error: "excludedSources must be an array"
574
+ };
575
+ }
576
+ const excludedSourcesValidation = this.validateSources(
577
+ options.excludedSources
578
+ );
579
+ if (!excludedSourcesValidation.valid) {
580
+ return {
581
+ success: false,
582
+ error: `Invalid excludedSources format. Invalid sources: ${excludedSourcesValidation.invalidSources.join(
583
+ ", "
584
+ )}. Sources must be valid URLs, domains (with optional paths), or dataset identifiers in 'provider/dataset' format.`
585
+ };
586
+ }
587
+ }
588
+ const payload = {
589
+ query: query.trim(),
590
+ search_type: finalSearchType,
591
+ data_max_price: options.dataMaxPrice ?? defaultDataMaxPrice
592
+ };
593
+ if (options.structuredOutput !== void 0) {
594
+ payload.structured_output = options.structuredOutput;
595
+ }
596
+ if (options.systemInstructions !== void 0) {
597
+ payload.system_instructions = options.systemInstructions.trim();
598
+ }
599
+ if (options.countryCode !== void 0) {
600
+ payload.country_code = options.countryCode;
601
+ }
602
+ if (options.includedSources !== void 0) {
603
+ payload.included_sources = options.includedSources;
604
+ }
605
+ if (options.excludedSources !== void 0) {
606
+ payload.excluded_sources = options.excludedSources;
607
+ }
608
+ if (options.startDate !== void 0) {
609
+ payload.start_date = options.startDate;
610
+ }
611
+ if (options.endDate !== void 0) {
612
+ payload.end_date = options.endDate;
613
+ }
614
+ if (options.fastMode !== void 0) {
615
+ payload.fast_mode = options.fastMode;
616
+ }
617
+ const response = await import_axios.default.post(`${this.baseUrl}/answer`, payload, {
618
+ headers: this.headers
619
+ });
620
+ if (!response.status || response.status < 200 || response.status >= 300) {
621
+ return {
622
+ success: false,
623
+ error: response.data?.error || "Request failed"
624
+ };
625
+ }
626
+ return response.data;
627
+ } catch (e) {
628
+ return {
629
+ success: false,
630
+ error: e.response?.data?.error || e.message
631
+ };
632
+ }
633
+ }
206
634
  };
207
635
  // Annotate the CommonJS export names for ESM import in node:
208
636
  0 && (module.exports = {
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import axios from 'axios';\nimport { SearchResponse, SearchType, SearchOptions } from './types';\n\nexport class Valyu {\n private baseUrl: string;\n private headers: Record<string, string>;\n\n constructor(apiKey?: string, baseUrl: string = \"https://api.valyu.network/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 };\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 * 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\", or \"all\"\n * @param options.maxNumResults - Maximum number of results (1-20)\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.countryCode - Country code filter for search results\n * @param options.responseLength - Response content length: \"short\"/\"medium\"/\"large\"/\"max\" or integer character count\n * @returns Promise resolving to search results\n */\n async search(query: string, options: SearchOptions = {}): 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 const defaultMaxPrice = 30;\n\n // Validate searchType\n let finalSearchType: SearchType = defaultSearchType;\n const providedSearchTypeString = options.searchType?.toLowerCase();\n\n if (providedSearchTypeString === \"web\" || providedSearchTypeString === \"proprietary\" || providedSearchTypeString === \"all\") {\n finalSearchType = providedSearchTypeString as SearchType;\n } else if (options.searchType !== undefined) {\n return {\n success: false,\n error: \"Invalid searchType provided. Must be one of: all, web, proprietary\",\n tx_id: null,\n query,\n results: [],\n results_by_source: { web: 0, proprietary: 0 },\n total_deduction_pcm: 0.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_pcm: 0.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_pcm: 0.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 > 20) {\n return {\n success: false,\n error: \"maxNumResults must be between 1 and 20\",\n tx_id: null,\n query,\n results: [],\n results_by_source: { web: 0, proprietary: 0 },\n total_deduction_pcm: 0.0,\n total_deduction_dollars: 0.0,\n total_characters: 0\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: options.relevanceThreshold ?? defaultRelevanceThreshold,\n max_price: options.maxPrice ?? defaultMaxPrice,\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.exclude_sources = options.excludeSources;\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.countryCode !== undefined) {\n payload.country_code = options.countryCode;\n }\n\n if (options.responseLength !== undefined) {\n payload.response_length = options.responseLength;\n }\n\n const response = await axios.post(\n `${this.baseUrl}/deepsearch`,\n 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_pcm: 0.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_pcm: 0.0,\n total_deduction_dollars: 0.0,\n total_characters: 0\n };\n }\n }\n}\n\nexport type { \n SearchResponse, \n SearchType, \n FeedbackSentiment, \n FeedbackResponse,\n SearchOptions,\n CountryCode,\n ResponseLength\n} from './types'; "],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAGX,IAAM,QAAN,MAAY;AAAA,EAIjB,YAAY,QAAiB,UAAkB,gCAAgC;AAC7E,QAAI,CAAC,QAAQ;AACX,eAAS,QAAQ,IAAI;AACrB,UAAI,CAAC,QAAQ;AACX,cAAM,IAAI,MAAM,0BAA0B;AAAA,MAC5C;AAAA,IACF;AACA,SAAK,UAAU;AACf,SAAK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W;AACrC,gBAAQ,eAAe,QAAQ;AAAA,MACjC;AAEA,UAAI,QAAQ,mBAAmB,QAAW;AACxC,gBAAQ,kBAAkB,QAAQ;AAAA,MACpC;AAEA,YAAM,WAAW,MAAM,aAAAA,QAAM;AAAA,QAC3B,GAAG,KAAK,OAAO;AAAA,QACf;AAAA,QACA,EAAE,SAAS,KAAK,QAAQ;AAAA,MAC1B;AAEA,UAAI,CAAC,SAAS,UAAU,SAAS,SAAS,OAAO,SAAS,UAAU,KAAK;AACvE,eAAO;AAAA,UACL,SAAS;AAAA,UACT,OAAO,SAAS,MAAM;AAAA,UACtB,OAAO;AAAA,UACP;AAAA,UACA,SAAS,CAAC;AAAA,UACV,mBAAmB,EAAE,KAAK,GAAG,aAAa,EAAE;AAAA,UAC5C,qBAAqB;AAAA,UACrB,yBAAyB;AAAA,UACzB,kBAAkB;AAAA,QACpB;AAAA,MACF;AAEA,aAAO,SAAS;AAAA,IAClB,SAAS,GAAQ;AACf,aAAO;AAAA,QACL,SAAS;AAAA,QACT,OAAO,EAAE,UAAU,MAAM,SAAS,EAAE;AAAA,QACpC,OAAO;AAAA,QACP;AAAA,QACA,SAAS,CAAC;AAAA,QACV,mBAAmB,EAAE,KAAK,GAAG,aAAa,EAAE;AAAA,QAC5C,qBAAqB;AAAA,QACrB,yBAAyB;AAAA,QACzB,kBAAkB;AAAA,MACpB;AAAA,IACF;AAAA,EACF;AACF;","names":["axios"]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import axios from \"axios\";\nimport {\n SearchResponse,\n SearchType,\n SearchOptions,\n ContentsOptions,\n ContentsResponse,\n AnswerOptions,\n AnswerResponse,\n} from \"./types\";\n\nexport class Valyu {\n private baseUrl: string;\n private headers: Record<string, string>;\n\n constructor(\n apiKey?: string,\n baseUrl: string = \"https://api.valyu.network/v1\"\n ) {\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 };\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\", or \"all\"\n * @param options.maxNumResults - Maximum number of results (1-20)\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.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 * @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 const defaultMaxPrice = 30;\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 ) {\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\",\n tx_id: null,\n query,\n results: [],\n results_by_source: { web: 0, proprietary: 0 },\n total_deduction_pcm: 0.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_pcm: 0.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_pcm: 0.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 > 20) {\n return {\n success: false,\n error: \"maxNumResults must be between 1 and 20\",\n tx_id: null,\n query,\n results: [],\n results_by_source: { web: 0, proprietary: 0 },\n total_deduction_pcm: 0.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_pcm: 0.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_pcm: 0.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_pcm: 0.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_pcm: 0.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 max_price: options.maxPrice ?? defaultMaxPrice,\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.exclude_sources = options.excludeSources;\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.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 const response = await axios.post(`${this.baseUrl}/deepsearch`, 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_pcm: 0.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_pcm: 0.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)\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\" or \"high\"\n * @param options.responseLength - Content length per URL\n * @param options.maxPriceDollars - Maximum cost limit in USD\n * @returns Promise resolving to content extraction results\n */\n async contents(\n urls: string[],\n options: ContentsOptions = {}\n ): Promise<ContentsResponse> {\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 if (urls.length > 10) {\n return {\n success: false,\n error: \"Maximum 10 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 const response = await axios.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 return response.data;\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 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\", or \"all\"\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 * @returns Promise resolving to answer response\n */\n async answer(\n query: string,\n options: AnswerOptions = {}\n ): Promise<AnswerResponse> {\n try {\n // Default values\n const defaultSearchType: SearchType = \"all\";\n const defaultDataMaxPrice = 30.0;\n\n // Validate query\n if (!query || typeof query !== \"string\" || query.trim().length === 0) {\n return {\n success: false,\n error: \"Query is required and must be a non-empty string\",\n };\n }\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 ) {\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\",\n };\n }\n\n // Validate systemInstructions length\n if (options.systemInstructions !== undefined) {\n if (typeof options.systemInstructions !== \"string\") {\n return {\n success: false,\n error: \"systemInstructions must be a string\",\n };\n }\n\n const trimmed = options.systemInstructions.trim();\n if (trimmed.length === 0) {\n return {\n success: false,\n error: \"systemInstructions cannot be empty when provided\",\n };\n }\n\n if (trimmed.length > 2000) {\n return {\n success: false,\n error: \"systemInstructions must be 2000 characters or less\",\n };\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 {\n success: false,\n error: \"dataMaxPrice must be a positive number\",\n };\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 };\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 };\n }\n\n // Validate date order\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 {\n success: false,\n error: \"startDate must be before endDate\",\n };\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 };\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 };\n }\n }\n\n // Validate excludedSources format\n if (options.excludedSources !== undefined) {\n if (!Array.isArray(options.excludedSources)) {\n return {\n success: false,\n error: \"excludedSources must be an array\",\n };\n }\n\n const excludedSourcesValidation = this.validateSources(\n options.excludedSources\n );\n if (!excludedSourcesValidation.valid) {\n return {\n success: false,\n error: `Invalid excludedSources format. Invalid sources: ${excludedSourcesValidation.invalidSources.join(\n \", \"\n )}. Sources must be valid URLs, domains (with optional paths), or dataset identifiers in 'provider/dataset' format.`,\n };\n }\n }\n\n // Build payload with snake_case for API\n const payload: Record<string, any> = {\n query: query.trim(),\n search_type: finalSearchType,\n data_max_price: options.dataMaxPrice ?? defaultDataMaxPrice,\n };\n\n // Add optional parameters only if provided\n if (options.structuredOutput !== undefined) {\n payload.structured_output = options.structuredOutput;\n }\n\n if (options.systemInstructions !== undefined) {\n payload.system_instructions = options.systemInstructions.trim();\n }\n\n if (options.countryCode !== undefined) {\n payload.country_code = options.countryCode;\n }\n\n if (options.includedSources !== undefined) {\n payload.included_sources = options.includedSources;\n }\n\n if (options.excludedSources !== undefined) {\n payload.excluded_sources = options.excludedSources;\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.fastMode !== undefined) {\n payload.fast_mode = options.fastMode;\n }\n\n const response = await axios.post(`${this.baseUrl}/answer`, 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 };\n }\n\n return response.data;\n } catch (e: any) {\n return {\n success: false,\n error: e.response?.data?.error || e.message,\n };\n }\n }\n}\n\nexport type {\n SearchResponse,\n SearchType,\n FeedbackSentiment,\n FeedbackResponse,\n SearchOptions,\n CountryCode,\n ResponseLength,\n ContentsOptions,\n ContentsResponse,\n ContentResult,\n ExtractEffort,\n ContentResponseLength,\n AnswerOptions,\n AnswerResponse,\n AnswerSuccessResponse,\n AnswerErrorResponse,\n SearchMetadata,\n AIUsage,\n Cost,\n} from \"./types\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAWX,IAAM,QAAN,MAAY;AAAA,EAIjB,YACE,QACA,UAAkB,gCAClB;AACA,QAAI,CAAC,QAAQ;AACX,eAAS,QAAQ,IAAI;AACrB,UAAI,CAAC,QAAQ;AACX,cAAM,IAAI,MAAM,0BAA0B;AAAA,MAC5C;AAAA,IACF;AACA,SAAK,UAAU;AACf,SAAK,UAAU;AAAA,MACb,gBAAgB;AAAA,MAChB,aAAa;AAAA,IACf;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKQ,mBAAmB,MAAuB;AAChD,UAAM,YAAY;AAClB,QAAI,CAAC,UAAU,KAAK,IAAI,GAAG;AACzB,aAAO;AAAA,IACT;AACA,UAAM,aAAa,IAAI,KAAK,IAAI;AAChC,WAAO,sBAAsB,QAAQ,CAAC,MAAM,WAAW,QAAQ,CAAC;AAAA,EAClE;AAAA;AAAA;AAAA;AAAA,EAKQ,YAAY,KAAsB;AACxC,QAAI;AACF,UAAI,IAAI,GAAG;AACX,aAAO;AAAA,IACT,QAAQ;AACN,aAAO;AAAA,IACT;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKQ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