@agentforge/tools 0.18.2 → 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.js CHANGED
@@ -710,26 +710,23 @@ var DuckDuckGoProvider = class {
710
710
  * @param timeout - Request timeout in milliseconds (default: 30000)
711
711
  */
712
712
  async search(query, maxResults, timeout = DEFAULT_TIMEOUT) {
713
- return retryWithBackoff(async () => {
714
- try {
715
- const response = await axios11.get(
716
- "https://api.duckduckgo.com/",
717
- {
718
- params: {
719
- q: query,
720
- format: "json"
721
- },
722
- headers: {
723
- "User-Agent": "Mozilla/5.0 (compatible; AgentForge/1.0; +https://github.com/agentforge)"
724
- },
725
- timeout
726
- }
727
- );
713
+ try {
714
+ return await retryWithBackoff(async () => {
715
+ const response = await axios11.get("https://api.duckduckgo.com/", {
716
+ params: {
717
+ q: query,
718
+ format: "json"
719
+ },
720
+ headers: {
721
+ "User-Agent": "Mozilla/5.0 (compatible; AgentForge/1.0; +https://github.com/agentforge)"
722
+ },
723
+ timeout
724
+ });
728
725
  return this.normalizeResults(response.data, maxResults);
729
- } catch (error) {
730
- throw new Error(`DuckDuckGo search failed: ${error.message}`);
731
- }
732
- });
726
+ });
727
+ } catch (error) {
728
+ throw new Error(`DuckDuckGo search failed: ${error.message}`);
729
+ }
733
730
  }
734
731
  /**
735
732
  * Normalize DuckDuckGo response to SearchResult[]
@@ -814,8 +811,8 @@ var SerperProvider = class {
814
811
  "Serper API key not found. Set SERPER_API_KEY environment variable. Get your key at https://serper.dev"
815
812
  );
816
813
  }
817
- return retryWithBackoff(async () => {
818
- try {
814
+ try {
815
+ return await retryWithBackoff(async () => {
819
816
  const response = await axios11.post(
820
817
  "https://google.serper.dev/search",
821
818
  {
@@ -831,20 +828,18 @@ var SerperProvider = class {
831
828
  }
832
829
  );
833
830
  return this.normalizeResults(response.data, maxResults);
834
- } catch (error) {
835
- if (error.response?.status === 401) {
836
- throw new Error(
837
- "Invalid Serper API key. Get your key at https://serper.dev"
838
- );
839
- }
840
- if (error.response?.status === 429) {
841
- throw new Error(
842
- "Serper API rate limit exceeded. Please try again later or upgrade your plan at https://serper.dev"
843
- );
844
- }
845
- throw new Error(`Serper search failed: ${error.message}`);
831
+ });
832
+ } catch (error) {
833
+ if (error.response?.status === 401) {
834
+ throw new Error("Invalid Serper API key. Get your key at https://serper.dev");
846
835
  }
847
- });
836
+ if (error.response?.status === 429) {
837
+ throw new Error(
838
+ "Serper API rate limit exceeded. Please try again later or upgrade your plan at https://serper.dev"
839
+ );
840
+ }
841
+ throw new Error(`Serper search failed: ${error.message}`);
842
+ }
848
843
  }
849
844
  /**
850
845
  * Normalize Serper response to SearchResult[]