@agentforge/tools 0.18.3 → 0.18.4
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.cjs +29 -34
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +29 -34
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -738,26 +738,23 @@ var DuckDuckGoProvider = class {
|
|
|
738
738
|
* @param timeout - Request timeout in milliseconds (default: 30000)
|
|
739
739
|
*/
|
|
740
740
|
async search(query, maxResults, timeout = DEFAULT_TIMEOUT) {
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
const response = await axios11__default.default.get(
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
timeout
|
|
754
|
-
}
|
|
755
|
-
);
|
|
741
|
+
try {
|
|
742
|
+
return await retryWithBackoff(async () => {
|
|
743
|
+
const response = await axios11__default.default.get("https://api.duckduckgo.com/", {
|
|
744
|
+
params: {
|
|
745
|
+
q: query,
|
|
746
|
+
format: "json"
|
|
747
|
+
},
|
|
748
|
+
headers: {
|
|
749
|
+
"User-Agent": "Mozilla/5.0 (compatible; AgentForge/1.0; +https://github.com/agentforge)"
|
|
750
|
+
},
|
|
751
|
+
timeout
|
|
752
|
+
});
|
|
756
753
|
return this.normalizeResults(response.data, maxResults);
|
|
757
|
-
}
|
|
758
|
-
|
|
759
|
-
}
|
|
760
|
-
}
|
|
754
|
+
});
|
|
755
|
+
} catch (error) {
|
|
756
|
+
throw new Error(`DuckDuckGo search failed: ${error.message}`);
|
|
757
|
+
}
|
|
761
758
|
}
|
|
762
759
|
/**
|
|
763
760
|
* Normalize DuckDuckGo response to SearchResult[]
|
|
@@ -842,8 +839,8 @@ var SerperProvider = class {
|
|
|
842
839
|
"Serper API key not found. Set SERPER_API_KEY environment variable. Get your key at https://serper.dev"
|
|
843
840
|
);
|
|
844
841
|
}
|
|
845
|
-
|
|
846
|
-
|
|
842
|
+
try {
|
|
843
|
+
return await retryWithBackoff(async () => {
|
|
847
844
|
const response = await axios11__default.default.post(
|
|
848
845
|
"https://google.serper.dev/search",
|
|
849
846
|
{
|
|
@@ -859,20 +856,18 @@ var SerperProvider = class {
|
|
|
859
856
|
}
|
|
860
857
|
);
|
|
861
858
|
return this.normalizeResults(response.data, maxResults);
|
|
862
|
-
}
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
);
|
|
867
|
-
}
|
|
868
|
-
if (error.response?.status === 429) {
|
|
869
|
-
throw new Error(
|
|
870
|
-
"Serper API rate limit exceeded. Please try again later or upgrade your plan at https://serper.dev"
|
|
871
|
-
);
|
|
872
|
-
}
|
|
873
|
-
throw new Error(`Serper search failed: ${error.message}`);
|
|
859
|
+
});
|
|
860
|
+
} catch (error) {
|
|
861
|
+
if (error.response?.status === 401) {
|
|
862
|
+
throw new Error("Invalid Serper API key. Get your key at https://serper.dev");
|
|
874
863
|
}
|
|
875
|
-
|
|
864
|
+
if (error.response?.status === 429) {
|
|
865
|
+
throw new Error(
|
|
866
|
+
"Serper API rate limit exceeded. Please try again later or upgrade your plan at https://serper.dev"
|
|
867
|
+
);
|
|
868
|
+
}
|
|
869
|
+
throw new Error(`Serper search failed: ${error.message}`);
|
|
870
|
+
}
|
|
876
871
|
}
|
|
877
872
|
/**
|
|
878
873
|
* Normalize Serper response to SearchResult[]
|