@openclaw/brave-plugin 2026.8.1-beta.3 → 2026.9.1-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.
@@ -8,7 +8,7 @@ import { isRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
8
8
  * Brave web-search provider factory. It builds the agent tool definition and
9
9
  * lazy-loads HTTP execution only when a search is run.
10
10
  */
11
- const loadBraveWebSearchRuntime = createLazyRuntimeModule(() => import("./brave-web-search-provider.runtime-DqLOemiz.js"));
11
+ const loadBraveWebSearchRuntime = createLazyRuntimeModule(() => import("./brave-web-search-provider.runtime-D1eCbRZi.js"));
12
12
  const BraveSearchSchema = {
13
13
  type: "object",
14
14
  properties: {
@@ -165,21 +165,13 @@ function normalizeBraveLanguageParams(params) {
165
165
  ui_lang
166
166
  };
167
167
  }
168
- function resolveSiteName$1(url) {
169
- if (!url) return;
170
- try {
171
- return new URL(url).hostname;
172
- } catch {
173
- return;
174
- }
175
- }
176
168
  /** Map Brave LLM Context API grounding results into web-search result rows. */
177
169
  function mapBraveLlmContextResults(data) {
178
170
  return (Array.isArray(data.grounding?.generic) ? data.grounding.generic : []).map((entry) => ({
179
171
  url: entry.url ?? "",
180
172
  title: entry.title ?? "",
181
173
  snippets: (entry.snippets ?? []).filter((snippet) => typeof snippet === "string" && snippet.length > 0),
182
- siteName: resolveSiteName$1(entry.url) || void 0
174
+ siteName: resolveSiteName(entry.url) || void 0
183
175
  }));
184
176
  }
185
177
  //#endregion
@@ -196,13 +188,6 @@ function logBraveHttp(diagnostics, event, meta) {
196
188
  if (!diagnostics?.enabled) return;
197
189
  braveHttpLogger.info(`brave http ${event}`, meta);
198
190
  }
199
- function describeBraveRequestUrl(url) {
200
- return {
201
- url: url.toString(),
202
- query: url.searchParams.get("q") ?? "",
203
- params: Object.fromEntries(url.searchParams.entries())
204
- };
205
- }
206
191
  function resolveBraveApiKey(searchConfig) {
207
192
  return readConfiguredSecretString(searchConfig?.apiKey, "plugins.entries.brave.config.webSearch.apiKey") ?? readProviderEnvValue(["BRAVE_API_KEY"]);
208
193
  }
@@ -267,7 +252,9 @@ async function runBraveJsonRequest(params, errorLabel) {
267
252
  params.configureUrl(url);
268
253
  logBraveHttp(params.diagnostics, "request", {
269
254
  mode: params.mode,
270
- ...describeBraveRequestUrl(url)
255
+ url: url.toString(),
256
+ query: url.searchParams.get("q") ?? "",
257
+ params: Object.fromEntries(url.searchParams.entries())
271
258
  });
272
259
  const startedAt = Date.now();
273
260
  return (params.endpointMode === "selfHosted" ? withSelfHostedWebSearchEndpoint : withTrustedWebSearchEndpoint)({
@@ -294,14 +281,9 @@ async function runBraveJsonRequest(params, errorLabel) {
294
281
  }
295
282
  async function runBraveLlmContextSearch(params) {
296
283
  const data = await runBraveJsonRequest({
297
- baseUrl: params.baseUrl,
284
+ ...params,
298
285
  endpointPath: BRAVE_LLM_CONTEXT_ENDPOINT_PATH,
299
286
  mode: "llm-context",
300
- endpointMode: params.endpointMode,
301
- apiKey: params.apiKey,
302
- timeoutSeconds: params.timeoutSeconds,
303
- diagnostics: params.diagnostics,
304
- signal: params.signal,
305
287
  configureUrl: (url) => {
306
288
  setBraveSearchUrlParams(url, params);
307
289
  }
@@ -313,14 +295,9 @@ async function runBraveLlmContextSearch(params) {
313
295
  }
314
296
  async function runBraveWebSearch(params) {
315
297
  const data = await runBraveJsonRequest({
316
- baseUrl: params.baseUrl,
298
+ ...params,
317
299
  endpointPath: BRAVE_SEARCH_ENDPOINT_PATH,
318
300
  mode: "web",
319
- endpointMode: params.endpointMode,
320
- apiKey: params.apiKey,
321
- timeoutSeconds: params.timeoutSeconds,
322
- diagnostics: params.diagnostics,
323
- signal: params.signal,
324
301
  configureUrl: (url) => {
325
302
  setBraveSearchUrlParams(url, {
326
303
  ...params,
@@ -447,72 +424,42 @@ async function executeBraveSearch(args, searchConfig, options) {
447
424
  const start = Date.now();
448
425
  const timeoutSeconds = resolveSearchTimeoutSeconds(searchConfig);
449
426
  const cacheTtlMs = resolveSearchCacheTtlMs(searchConfig);
450
- if (braveMode === "llm-context") {
451
- const { results, sources } = await runBraveLlmContextSearch({
452
- baseUrl: braveBaseUrl,
453
- endpointMode: braveEndpointMode,
454
- query,
455
- apiKey,
456
- timeoutSeconds,
457
- diagnostics,
458
- signal: options?.signal,
459
- country: country ?? void 0,
460
- search_lang: normalizedLanguage.search_lang,
461
- freshness,
462
- dateAfter,
463
- dateBefore
464
- });
465
- options?.signal?.throwIfAborted();
466
- const payload = {
467
- query,
468
- provider: "brave",
469
- mode: "llm-context",
470
- count: results.length,
471
- tookMs: Date.now() - start,
472
- externalContent: {
473
- untrusted: true,
474
- source: "web_search",
475
- provider: "brave",
476
- wrapped: true
477
- },
478
- results: results.map((entry) => ({
479
- title: entry.title ? wrapWebContent(entry.title, "web_search") : "",
480
- url: entry.url,
481
- snippets: entry.snippets.map((snippet) => wrapWebContent(snippet, "web_search")),
482
- siteName: entry.siteName
483
- })),
484
- sources
485
- };
486
- writeCachedSearchPayload(cacheKey, payload, cacheTtlMs);
487
- logBraveHttp(diagnostics, "cache write", {
488
- mode: "llm-context",
489
- query,
490
- cacheKey,
491
- ttlMs: cacheTtlMs,
492
- count: results.length
493
- });
494
- return payload;
495
- }
496
- const results = await runBraveWebSearch({
427
+ const request = {
497
428
  baseUrl: braveBaseUrl,
498
429
  endpointMode: braveEndpointMode,
499
430
  query,
500
- count: resolveSearchCount(count, DEFAULT_SEARCH_COUNT),
501
431
  apiKey,
502
432
  timeoutSeconds,
503
433
  diagnostics,
504
434
  signal: options?.signal,
505
435
  country: country ?? void 0,
506
436
  search_lang: normalizedLanguage.search_lang,
507
- ui_lang: normalizedLanguage.ui_lang,
508
437
  freshness,
509
438
  dateAfter,
510
439
  dateBefore
511
- });
440
+ };
441
+ const response = braveMode === "llm-context" ? {
442
+ ...await runBraveLlmContextSearch(request),
443
+ mode: "llm-context"
444
+ } : {
445
+ results: await runBraveWebSearch({
446
+ ...request,
447
+ count: resolveSearchCount(count, DEFAULT_SEARCH_COUNT),
448
+ ui_lang: normalizedLanguage.ui_lang
449
+ }),
450
+ mode: "web"
451
+ };
512
452
  options?.signal?.throwIfAborted();
453
+ const results = response.mode === "llm-context" ? response.results.map((entry) => ({
454
+ title: entry.title ? wrapWebContent(entry.title, "web_search") : "",
455
+ url: entry.url,
456
+ snippets: entry.snippets.map((snippet) => wrapWebContent(snippet, "web_search")),
457
+ siteName: entry.siteName
458
+ })) : response.results;
513
459
  const payload = {
514
460
  query,
515
461
  provider: "brave",
462
+ ...response.mode === "llm-context" ? { mode: response.mode } : {},
516
463
  count: results.length,
517
464
  tookMs: Date.now() - start,
518
465
  externalContent: {
@@ -521,11 +468,12 @@ async function executeBraveSearch(args, searchConfig, options) {
521
468
  provider: "brave",
522
469
  wrapped: true
523
470
  },
524
- results
471
+ results,
472
+ ...response.mode === "llm-context" ? { sources: response.sources } : {}
525
473
  };
526
474
  writeCachedSearchPayload(cacheKey, payload, cacheTtlMs);
527
475
  logBraveHttp(diagnostics, "cache write", {
528
- mode: "web",
476
+ mode: response.mode,
529
477
  query,
530
478
  cacheKey,
531
479
  ttlMs: cacheTtlMs,
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { t as createBraveWebSearchProvider } from "./brave-web-search-provider-BFrhKp8F.js";
1
+ import { t as createBraveWebSearchProvider } from "./brave-web-search-provider-BbKJ74HP.js";
2
2
  import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
3
3
  //#region extensions/brave/index.ts
4
4
  /**
@@ -1,11 +1,3 @@
1
- import { buildBraveWebSearchProviderBase } from "./web-search-shared.js";
2
- //#region extensions/brave/web-search-contract-api.ts
3
- /** Create the Brave provider descriptor for contract checks. */
4
- function createBraveWebSearchProvider() {
5
- return {
6
- ...buildBraveWebSearchProviderBase(),
7
- createTool: () => null
8
- };
9
- }
10
- //#endregion
1
+ import { t as createBraveWebSearchProvider } from "./brave-web-search-provider-BbKJ74HP.js";
2
+ import "./web-search-provider.js";
11
3
  export { createBraveWebSearchProvider };
@@ -1,2 +1,2 @@
1
- import { t as createBraveWebSearchProvider } from "./brave-web-search-provider-BFrhKp8F.js";
1
+ import { t as createBraveWebSearchProvider } from "./brave-web-search-provider-BbKJ74HP.js";
2
2
  export { createBraveWebSearchProvider };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openclaw/brave-plugin",
3
- "version": "2026.8.1-beta.3",
3
+ "version": "2026.9.1-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.8.1-beta.3"
21
+ "pluginApi": ">=2026.9.1-beta.1"
22
22
  },
23
23
  "build": {
24
- "openclawVersion": "2026.8.1-beta.3"
24
+ "openclawVersion": "2026.9.1-beta.1"
25
25
  },
26
26
  "release": {
27
27
  "publishToClawHub": true,
@@ -37,7 +37,7 @@
37
37
  "README.md"
38
38
  ],
39
39
  "peerDependencies": {
40
- "openclaw": ">=2026.8.1-beta.3"
40
+ "openclaw": ">=2026.9.1-beta.1"
41
41
  },
42
42
  "peerDependenciesMeta": {
43
43
  "openclaw": {