@openclaw/brave-plugin 2026.5.28 → 2026.5.30-beta.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/{brave-web-search-provider-CjlXA4SO.js → brave-web-search-provider-BzuOscZC.js} +1 -1
- package/dist/{brave-web-search-provider.runtime-DqjJHSR5.js → brave-web-search-provider.runtime-SKsUJmbH.js} +64 -77
- package/dist/index.js +1 -1
- package/dist/web-search-provider.js +1 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +4 -4
package/dist/{brave-web-search-provider-CjlXA4SO.js → brave-web-search-provider-BzuOscZC.js}
RENAMED
|
@@ -5,7 +5,7 @@ import { isRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
|
5
5
|
//#region extensions/brave/src/brave-web-search-provider.ts
|
|
6
6
|
let braveWebSearchRuntimePromise;
|
|
7
7
|
function loadBraveWebSearchRuntime() {
|
|
8
|
-
braveWebSearchRuntimePromise ??= import("./brave-web-search-provider.runtime-
|
|
8
|
+
braveWebSearchRuntimePromise ??= import("./brave-web-search-provider.runtime-SKsUJmbH.js");
|
|
9
9
|
return braveWebSearchRuntimePromise;
|
|
10
10
|
}
|
|
11
11
|
const BraveSearchSchema = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { normalizeLowercaseStringOrEmpty, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
2
2
|
import { assertOkOrThrowProviderError, readProviderJsonResponse } from "openclaw/plugin-sdk/provider-http";
|
|
3
|
-
import { DEFAULT_SEARCH_COUNT, MAX_SEARCH_COUNT, buildSearchCacheKey, formatCliCommand,
|
|
3
|
+
import { DEFAULT_SEARCH_COUNT, MAX_SEARCH_COUNT, buildSearchCacheKey, formatCliCommand, parseWebSearchTimeFilters, readCachedSearchPayload, readConfiguredSecretString, readPositiveIntegerParam, readProviderEnvValue, readStringParam, resolveSearchCacheTtlMs, resolveSearchCount, resolveSearchTimeoutSeconds, resolveSiteName, withSelfHostedWebSearchEndpoint, withTrustedWebSearchEndpoint, wrapWebContent, writeCachedSearchPayload } from "openclaw/plugin-sdk/provider-web-search";
|
|
4
4
|
import { createSubsystemLogger } from "openclaw/plugin-sdk/runtime-env";
|
|
5
5
|
import { assertHttpUrlTargetsPrivateNetwork, isBlockedHostnameOrIp, isPrivateIpAddress, resolvePinnedHostnameWithPolicy } from "openclaw/plugin-sdk/ssrf-runtime";
|
|
6
6
|
//#region extensions/brave/src/brave-web-search-provider.shared.ts
|
|
@@ -236,19 +236,23 @@ function missingBraveKeyPayload() {
|
|
|
236
236
|
docs: "https://docs.openclaw.ai/tools/web"
|
|
237
237
|
};
|
|
238
238
|
}
|
|
239
|
-
|
|
240
|
-
const url = buildBraveEndpointUrl({
|
|
241
|
-
baseUrl: params.baseUrl,
|
|
242
|
-
endpointPath: BRAVE_LLM_CONTEXT_ENDPOINT_PATH
|
|
243
|
-
});
|
|
239
|
+
function setBraveSearchUrlParams(url, params) {
|
|
244
240
|
url.searchParams.set("q", params.query);
|
|
245
241
|
if (params.country) url.searchParams.set("country", params.country);
|
|
246
242
|
if (params.search_lang) url.searchParams.set("search_lang", params.search_lang);
|
|
247
243
|
if (params.freshness) url.searchParams.set("freshness", params.freshness);
|
|
248
244
|
else if (params.dateAfter && params.dateBefore) url.searchParams.set("freshness", `${params.dateAfter}to${params.dateBefore}`);
|
|
249
245
|
else if (params.dateAfter) url.searchParams.set("freshness", `${params.dateAfter}to${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}`);
|
|
246
|
+
else if (params.allowDateBeforeOnly && params.dateBefore) url.searchParams.set("freshness", `1970-01-01to${params.dateBefore}`);
|
|
247
|
+
}
|
|
248
|
+
async function runBraveJsonRequest(params, errorLabel) {
|
|
249
|
+
const url = buildBraveEndpointUrl({
|
|
250
|
+
baseUrl: params.baseUrl,
|
|
251
|
+
endpointPath: params.endpointPath
|
|
252
|
+
});
|
|
253
|
+
params.configureUrl(url);
|
|
250
254
|
logBraveHttp(params.diagnostics, "request", {
|
|
251
|
-
mode:
|
|
255
|
+
mode: params.mode,
|
|
252
256
|
...describeBraveRequestUrl(url)
|
|
253
257
|
});
|
|
254
258
|
const startedAt = Date.now();
|
|
@@ -264,69 +268,62 @@ async function runBraveLlmContextSearch(params) {
|
|
|
264
268
|
}
|
|
265
269
|
}, async (response) => {
|
|
266
270
|
logBraveHttp(params.diagnostics, "response", {
|
|
267
|
-
mode:
|
|
271
|
+
mode: params.mode,
|
|
268
272
|
status: response.status,
|
|
269
273
|
ok: response.ok,
|
|
270
274
|
durationMs: Date.now() - startedAt
|
|
271
275
|
});
|
|
272
|
-
await assertOkOrThrowProviderError(response,
|
|
273
|
-
|
|
274
|
-
return {
|
|
275
|
-
results: mapBraveLlmContextResults(data),
|
|
276
|
-
sources: data.sources
|
|
277
|
-
};
|
|
276
|
+
await assertOkOrThrowProviderError(response, errorLabel);
|
|
277
|
+
return readProviderJsonResponse(response, errorLabel);
|
|
278
278
|
});
|
|
279
279
|
}
|
|
280
|
+
async function runBraveLlmContextSearch(params) {
|
|
281
|
+
const data = await runBraveJsonRequest({
|
|
282
|
+
baseUrl: params.baseUrl,
|
|
283
|
+
endpointPath: BRAVE_LLM_CONTEXT_ENDPOINT_PATH,
|
|
284
|
+
mode: "llm-context",
|
|
285
|
+
endpointMode: params.endpointMode,
|
|
286
|
+
apiKey: params.apiKey,
|
|
287
|
+
timeoutSeconds: params.timeoutSeconds,
|
|
288
|
+
diagnostics: params.diagnostics,
|
|
289
|
+
configureUrl: (url) => {
|
|
290
|
+
setBraveSearchUrlParams(url, params);
|
|
291
|
+
}
|
|
292
|
+
}, "Brave LLM Context API error");
|
|
293
|
+
return {
|
|
294
|
+
results: mapBraveLlmContextResults(data),
|
|
295
|
+
sources: data.sources
|
|
296
|
+
};
|
|
297
|
+
}
|
|
280
298
|
async function runBraveWebSearch(params) {
|
|
281
|
-
const
|
|
299
|
+
const data = await runBraveJsonRequest({
|
|
282
300
|
baseUrl: params.baseUrl,
|
|
283
|
-
endpointPath: BRAVE_SEARCH_ENDPOINT_PATH
|
|
284
|
-
});
|
|
285
|
-
url.searchParams.set("q", params.query);
|
|
286
|
-
url.searchParams.set("count", String(params.count));
|
|
287
|
-
if (params.country) url.searchParams.set("country", params.country);
|
|
288
|
-
if (params.search_lang) url.searchParams.set("search_lang", params.search_lang);
|
|
289
|
-
if (params.ui_lang) url.searchParams.set("ui_lang", params.ui_lang);
|
|
290
|
-
if (params.freshness) url.searchParams.set("freshness", params.freshness);
|
|
291
|
-
else if (params.dateAfter && params.dateBefore) url.searchParams.set("freshness", `${params.dateAfter}to${params.dateBefore}`);
|
|
292
|
-
else if (params.dateAfter) url.searchParams.set("freshness", `${params.dateAfter}to${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}`);
|
|
293
|
-
else if (params.dateBefore) url.searchParams.set("freshness", `1970-01-01to${params.dateBefore}`);
|
|
294
|
-
logBraveHttp(params.diagnostics, "request", {
|
|
301
|
+
endpointPath: BRAVE_SEARCH_ENDPOINT_PATH,
|
|
295
302
|
mode: "web",
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
const startedAt = Date.now();
|
|
299
|
-
return (params.endpointMode === "selfHosted" ? withSelfHostedWebSearchEndpoint : withTrustedWebSearchEndpoint)({
|
|
300
|
-
url: url.toString(),
|
|
303
|
+
endpointMode: params.endpointMode,
|
|
304
|
+
apiKey: params.apiKey,
|
|
301
305
|
timeoutSeconds: params.timeoutSeconds,
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
}
|
|
306
|
+
diagnostics: params.diagnostics,
|
|
307
|
+
configureUrl: (url) => {
|
|
308
|
+
setBraveSearchUrlParams(url, {
|
|
309
|
+
...params,
|
|
310
|
+
allowDateBeforeOnly: true
|
|
311
|
+
});
|
|
312
|
+
url.searchParams.set("count", String(params.count));
|
|
313
|
+
if (params.ui_lang) url.searchParams.set("ui_lang", params.ui_lang);
|
|
308
314
|
}
|
|
309
|
-
},
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
const url = entry.url ?? "";
|
|
322
|
-
return {
|
|
323
|
-
title: title ? wrapWebContent(title, "web_search") : "",
|
|
324
|
-
url,
|
|
325
|
-
description: description ? wrapWebContent(description, "web_search") : "",
|
|
326
|
-
published: entry.age || void 0,
|
|
327
|
-
siteName: resolveSiteName(url) || void 0
|
|
328
|
-
};
|
|
329
|
-
});
|
|
315
|
+
}, "Brave Search API error");
|
|
316
|
+
return (Array.isArray(data.web?.results) ? data.web?.results ?? [] : []).map((entry) => {
|
|
317
|
+
const description = entry.description ?? "";
|
|
318
|
+
const title = entry.title ?? "";
|
|
319
|
+
const url = entry.url ?? "";
|
|
320
|
+
return {
|
|
321
|
+
title: title ? wrapWebContent(title, "web_search") : "",
|
|
322
|
+
url,
|
|
323
|
+
description: description ? wrapWebContent(description, "web_search") : "",
|
|
324
|
+
published: entry.age || void 0,
|
|
325
|
+
siteName: resolveSiteName(url) || void 0
|
|
326
|
+
};
|
|
330
327
|
});
|
|
331
328
|
}
|
|
332
329
|
async function executeBraveSearch(args, searchConfig, options) {
|
|
@@ -365,28 +362,18 @@ async function executeBraveSearch(args, searchConfig, options) {
|
|
|
365
362
|
docs: "https://docs.openclaw.ai/tools/web"
|
|
366
363
|
};
|
|
367
364
|
const rawFreshness = readStringParam(args, "freshness");
|
|
368
|
-
const
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
const rawDateAfter = readStringParam(args, "date_after");
|
|
375
|
-
const rawDateBefore = readStringParam(args, "date_before");
|
|
376
|
-
if (rawFreshness && (rawDateAfter || rawDateBefore)) return {
|
|
377
|
-
error: "conflicting_time_filters",
|
|
378
|
-
message: "freshness and date_after/date_before cannot be used together. Use either freshness (day/week/month/year) or a date range (date_after/date_before), not both.",
|
|
379
|
-
docs: "https://docs.openclaw.ai/tools/web"
|
|
380
|
-
};
|
|
381
|
-
const parsedDateRange = parseIsoDateRange({
|
|
382
|
-
rawDateAfter,
|
|
383
|
-
rawDateBefore,
|
|
365
|
+
const parsedTimeFilters = parseWebSearchTimeFilters({
|
|
366
|
+
rawDateAfter: readStringParam(args, "date_after"),
|
|
367
|
+
rawDateBefore: readStringParam(args, "date_before"),
|
|
368
|
+
rawFreshness,
|
|
369
|
+
freshnessProvider: "brave",
|
|
370
|
+
invalidFreshnessMessage: "freshness must be day, week, month, or year.",
|
|
384
371
|
invalidDateAfterMessage: "date_after must be YYYY-MM-DD format.",
|
|
385
372
|
invalidDateBeforeMessage: "date_before must be YYYY-MM-DD format.",
|
|
386
373
|
invalidDateRangeMessage: "date_after must be before date_before."
|
|
387
374
|
});
|
|
388
|
-
if ("error" in
|
|
389
|
-
const { dateAfter, dateBefore } =
|
|
375
|
+
if ("error" in parsedTimeFilters) return parsedTimeFilters;
|
|
376
|
+
const { freshness, dateAfter, dateBefore } = parsedTimeFilters;
|
|
390
377
|
if (braveMode === "llm-context") {
|
|
391
378
|
const today = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
392
379
|
if (dateAfter && !dateBefore && dateAfter > today) return {
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as createBraveWebSearchProvider } from "./brave-web-search-provider-
|
|
1
|
+
import { t as createBraveWebSearchProvider } from "./brave-web-search-provider-BzuOscZC.js";
|
|
2
2
|
import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
|
|
3
3
|
//#region extensions/brave/index.ts
|
|
4
4
|
var brave_default = definePluginEntry({
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as createBraveWebSearchProvider } from "./brave-web-search-provider-
|
|
1
|
+
import { t as createBraveWebSearchProvider } from "./brave-web-search-provider-BzuOscZC.js";
|
|
2
2
|
export { createBraveWebSearchProvider };
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/brave-plugin",
|
|
3
|
-
"version": "2026.5.
|
|
3
|
+
"version": "2026.5.30-beta.1",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@openclaw/brave-plugin",
|
|
9
|
-
"version": "2026.5.
|
|
9
|
+
"version": "2026.5.30-beta.1"
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/brave-plugin",
|
|
3
|
-
"version": "2026.5.
|
|
3
|
+
"version": "2026.5.30-beta.1",
|
|
4
4
|
"description": "OpenClaw Brave Search provider plugin for web search.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -18,10 +18,10 @@
|
|
|
18
18
|
"allowInvalidConfigRecovery": true
|
|
19
19
|
},
|
|
20
20
|
"compat": {
|
|
21
|
-
"pluginApi": ">=2026.5.
|
|
21
|
+
"pluginApi": ">=2026.5.30-beta.1"
|
|
22
22
|
},
|
|
23
23
|
"build": {
|
|
24
|
-
"openclawVersion": "2026.5.
|
|
24
|
+
"openclawVersion": "2026.5.30-beta.1"
|
|
25
25
|
},
|
|
26
26
|
"release": {
|
|
27
27
|
"publishToClawHub": true,
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"README.md"
|
|
39
39
|
],
|
|
40
40
|
"peerDependencies": {
|
|
41
|
-
"openclaw": ">=2026.5.
|
|
41
|
+
"openclaw": ">=2026.5.30-beta.1"
|
|
42
42
|
},
|
|
43
43
|
"peerDependenciesMeta": {
|
|
44
44
|
"openclaw": {
|