@corbat-tech/coco 2.28.1 → 2.28.2
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/cli/index.js +9 -2
- package/dist/cli/index.js.map +1 -1
- package/dist/index.js +9 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -44959,6 +44959,11 @@ var DEFAULT_SEARCH_TIMEOUT_MS = 15e3;
|
|
|
44959
44959
|
var MAX_QUERY_LENGTH = 500;
|
|
44960
44960
|
var MIN_REQUEST_INTERVAL_MS = 1e3;
|
|
44961
44961
|
var lastRequestTime = 0;
|
|
44962
|
+
function isEngineConfigured(engine) {
|
|
44963
|
+
if (engine === "duckduckgo") return true;
|
|
44964
|
+
if (engine === "brave") return !!process.env.BRAVE_SEARCH_API_KEY;
|
|
44965
|
+
return !!process.env.SERPAPI_KEY;
|
|
44966
|
+
}
|
|
44962
44967
|
function sanitizeQuery(query) {
|
|
44963
44968
|
const cleaned = query.replace(/[\x00-\x1F\x7F]/g, " ").trim();
|
|
44964
44969
|
return cleaned.slice(0, MAX_QUERY_LENGTH);
|
|
@@ -45160,7 +45165,9 @@ Examples:
|
|
|
45160
45165
|
await enforceRateLimit();
|
|
45161
45166
|
try {
|
|
45162
45167
|
let results;
|
|
45163
|
-
|
|
45168
|
+
const requestedEngine = engine;
|
|
45169
|
+
const effectiveEngine = isEngineConfigured(requestedEngine) ? requestedEngine : "duckduckgo";
|
|
45170
|
+
switch (effectiveEngine) {
|
|
45164
45171
|
case "brave":
|
|
45165
45172
|
results = await searchBrave(sanitizedQuery, maxResults, DEFAULT_SEARCH_TIMEOUT_MS);
|
|
45166
45173
|
break;
|
|
@@ -45175,7 +45182,7 @@ Examples:
|
|
|
45175
45182
|
return {
|
|
45176
45183
|
results,
|
|
45177
45184
|
totalResults: results.length,
|
|
45178
|
-
engine:
|
|
45185
|
+
engine: effectiveEngine,
|
|
45179
45186
|
duration: performance.now() - startTime
|
|
45180
45187
|
};
|
|
45181
45188
|
} catch (error) {
|