@openclaw/duckduckgo-plugin 2026.9.5 → 2026.9.7

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/assets/icon.png CHANGED
Binary file
@@ -1,12 +1,12 @@
1
1
  import { decodeHtmlEntities } from "openclaw/plugin-sdk/html-entity-runtime";
2
- import { readProviderTextResponse } from "openclaw/plugin-sdk/provider-http";
2
+ import { ProviderHttpError, readProviderTextResponse } from "openclaw/plugin-sdk/provider-http";
3
3
  import { DEFAULT_CACHE_TTL_MINUTES, DEFAULT_SEARCH_COUNT, normalizeCacheKey, readCache, readResponseText, resolveCacheTtlMs, resolveSearchCount, resolveSiteName, resolveTimeoutSeconds, withTrustedWebSearchEndpoint, wrapWebContent, writeCache } from "openclaw/plugin-sdk/provider-web-search";
4
- import { normalizeLowercaseStringOrEmpty, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
4
+ import { asOptionalRecord, normalizeLowercaseStringOrEmpty, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
5
5
  //#region extensions/duckduckgo/src/config.ts
6
6
  const DEFAULT_DDG_SAFE_SEARCH = "moderate";
7
7
  function resolveDdgWebSearchConfig(config) {
8
- const webSearch = (config?.plugins?.entries?.duckduckgo?.config)?.webSearch;
9
- if (webSearch && typeof webSearch === "object" && !Array.isArray(webSearch)) return webSearch;
8
+ const pluginConfig = config?.plugins?.entries?.duckduckgo?.config;
9
+ return asOptionalRecord(pluginConfig?.webSearch);
10
10
  }
11
11
  function resolveDdgRegion(config) {
12
12
  return normalizeOptionalString(resolveDdgWebSearchConfig(config)?.region);
@@ -51,17 +51,11 @@ function decodeDuckDuckGoUrl(rawUrl) {
51
51
  } catch {}
52
52
  return rawUrl;
53
53
  }
54
- function readHrefAttribute(tagAttributes) {
55
- return /\bhref="([^"]*)"/i.exec(tagAttributes)?.[1] ?? "";
56
- }
57
54
  function isBotChallenge(html) {
58
55
  if (/class="[^"]*\bresult__a\b[^"]*"/i.test(html)) return false;
59
56
  return /g-recaptcha|are you a human|id="challenge-form"|name="challenge"/i.test(html);
60
57
  }
61
- async function readDuckDuckGoHtmlResponse(response) {
62
- return await readProviderTextResponse(response, "DuckDuckGo search");
63
- }
64
- function parseDuckDuckGoHtml(html) {
58
+ function parseDuckDuckGoHtml(html, count) {
65
59
  const results = [];
66
60
  const resultRegex = /<a\b(?=[^>]*\bclass="[^"]*\bresult__a\b[^"]*")([^>]*)>([\s\S]*?)<\/a>/gi;
67
61
  const nextResultRegex = /<a\b(?=[^>]*\bclass="[^"]*\bresult__a\b[^"]*")[^>]*>/i;
@@ -69,7 +63,7 @@ function parseDuckDuckGoHtml(html) {
69
63
  for (const match of html.matchAll(resultRegex)) {
70
64
  const rawAttributes = match[1] ?? "";
71
65
  const rawTitle = match[2] ?? "";
72
- const rawUrl = readHrefAttribute(rawAttributes);
66
+ const rawUrl = /\bhref="([^"]*)"/i.exec(rawAttributes)?.[1] ?? "";
73
67
  const matchEnd = (match.index ?? 0) + match[0].length;
74
68
  const trailingHtml = html.slice(matchEnd);
75
69
  const nextResultIndex = trailingHtml.search(nextResultRegex);
@@ -78,11 +72,14 @@ function parseDuckDuckGoHtml(html) {
78
72
  const title = decodeHtmlEntities$1(stripHtml(rawTitle));
79
73
  const url = decodeDuckDuckGoUrl(decodeHtmlEntities$1(rawUrl));
80
74
  const snippet = decodeHtmlEntities$1(stripHtml(rawSnippet));
81
- if (title && url) results.push({
82
- title,
83
- url,
84
- snippet
85
- });
75
+ if (title && url) {
76
+ results.push({
77
+ title,
78
+ url,
79
+ snippet
80
+ });
81
+ if (results.length >= count) break;
82
+ }
86
83
  }
87
84
  return results;
88
85
  }
@@ -120,11 +117,11 @@ async function runDuckDuckGoSearch(params) {
120
117
  }, async (response) => {
121
118
  if (!response.ok) {
122
119
  const detail = (await readResponseText(response, { maxBytes: 64e3 })).text;
123
- throw new Error(`DuckDuckGo search error (${response.status}): ${detail || response.statusText}`);
120
+ throw new ProviderHttpError(`DuckDuckGo search error (${response.status}): ${detail || response.statusText}`, { status: response.status });
124
121
  }
125
- const html = await readDuckDuckGoHtmlResponse(response);
122
+ const html = await readProviderTextResponse(response, "DuckDuckGo search");
126
123
  if (isBotChallenge(html)) throw new Error("DuckDuckGo returned a bot-detection challenge.");
127
- return parseDuckDuckGoHtml(html).slice(0, count);
124
+ return parseDuckDuckGoHtml(html, count);
128
125
  });
129
126
  params.signal?.throwIfAborted();
130
127
  const payload = {
@@ -28,7 +28,7 @@ function createDuckDuckGoWebSearchProviderBase() {
28
28
  }
29
29
  //#endregion
30
30
  //#region extensions/duckduckgo/src/ddg-search-provider.ts
31
- const loadDuckDuckGoClientModule = createLazyRuntimeModule(() => import("./ddg-client-CbFlWxF7.mjs"));
31
+ const loadDuckDuckGoClientModule = createLazyRuntimeModule(() => import("./ddg-client-BGCnzqUb.mjs"));
32
32
  const DuckDuckGoSearchSchema = {
33
33
  type: "object",
34
34
  properties: {
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { t as createDuckDuckGoWebSearchProvider } from "./.setup/ddg-search-provider-CPgV5euE.mjs";
1
+ import { t as createDuckDuckGoWebSearchProvider } from "./.setup/ddg-search-provider-CuJUFuao.mjs";
2
2
  import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
3
3
  //#region extensions/duckduckgo/index.ts
4
4
  var duckduckgo_default = definePluginEntry({
@@ -1,3 +1,3 @@
1
- import { t as createDuckDuckGoWebSearchProvider } from "./.setup/ddg-search-provider-CPgV5euE.mjs";
1
+ import { t as createDuckDuckGoWebSearchProvider } from "./.setup/ddg-search-provider-CuJUFuao.mjs";
2
2
  import "./web-search-provider.js";
3
3
  export { createDuckDuckGoWebSearchProvider };
@@ -1,2 +1,2 @@
1
- import { t as createDuckDuckGoWebSearchProvider } from "./.setup/ddg-search-provider-CPgV5euE.mjs";
1
+ import { t as createDuckDuckGoWebSearchProvider } from "./.setup/ddg-search-provider-CuJUFuao.mjs";
2
2
  export { createDuckDuckGoWebSearchProvider };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openclaw/duckduckgo-plugin",
3
- "version": "2026.9.5",
3
+ "version": "2026.9.7",
4
4
  "description": "OpenClaw DuckDuckGo plugin.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -18,10 +18,10 @@
18
18
  "minHostVersion": ">=2026.7.2"
19
19
  },
20
20
  "compat": {
21
- "pluginApi": ">=2026.9.5"
21
+ "pluginApi": ">=2026.9.7"
22
22
  },
23
23
  "build": {
24
- "openclawVersion": "2026.9.5",
24
+ "openclawVersion": "2026.9.7",
25
25
  "bundledDist": false
26
26
  },
27
27
  "release": {
@@ -40,7 +40,7 @@
40
40
  "assets/activity.svg"
41
41
  ],
42
42
  "peerDependencies": {
43
- "openclaw": ">=2026.9.5"
43
+ "openclaw": ">=2026.9.7"
44
44
  },
45
45
  "peerDependenciesMeta": {
46
46
  "openclaw": {