@kodelyth/brave-plugin 2026.5.39 → 2026.5.42

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.
@@ -0,0 +1,53 @@
1
+ import { createWebSearchProviderContractFields } from "klaw/plugin-sdk/provider-web-search-config-contract";
2
+ //#region extensions/brave/web-search-contract-api.ts
3
+ function isRecord(value) {
4
+ return typeof value === "object" && value !== null && !Array.isArray(value);
5
+ }
6
+ function resolveLegacyTopLevelBraveCredential(config) {
7
+ if (!isRecord(config)) return;
8
+ const tools = isRecord(config.tools) ? config.tools : void 0;
9
+ const web = isRecord(tools?.web) ? tools.web : void 0;
10
+ const search = isRecord(web?.search) ? web.search : void 0;
11
+ if (!search || !("apiKey" in search)) return;
12
+ return {
13
+ path: "tools.web.search.apiKey",
14
+ value: search.apiKey
15
+ };
16
+ }
17
+ function resolveProviderWebSearchPluginConfig(config, pluginId) {
18
+ if (!isRecord(config)) return;
19
+ const plugins = isRecord(config.plugins) ? config.plugins : void 0;
20
+ const entries = isRecord(plugins?.entries) ? plugins.entries : void 0;
21
+ const entry = isRecord(entries?.[pluginId]) ? entries[pluginId] : void 0;
22
+ const pluginConfig = isRecord(entry?.config) ? entry.config : void 0;
23
+ return isRecord(pluginConfig?.webSearch) ? pluginConfig.webSearch : void 0;
24
+ }
25
+ function resolveConfiguredBraveCredential(config) {
26
+ return resolveProviderWebSearchPluginConfig(config, "brave")?.apiKey ?? resolveLegacyTopLevelBraveCredential(config)?.value;
27
+ }
28
+ function createBraveWebSearchProvider() {
29
+ const credentialPath = "plugins.entries.brave.config.webSearch.apiKey";
30
+ return {
31
+ id: "brave",
32
+ label: "Brave Search",
33
+ hint: "Structured results · country/language/time filters",
34
+ onboardingScopes: ["text-inference"],
35
+ credentialLabel: "Brave Search API key",
36
+ envVars: ["BRAVE_API_KEY"],
37
+ placeholder: "BSA...",
38
+ signupUrl: "https://brave.com/search/api/",
39
+ docsUrl: "https://klaw.kodelyth.com/tools/brave-search",
40
+ autoDetectOrder: 10,
41
+ credentialPath,
42
+ ...createWebSearchProviderContractFields({
43
+ credentialPath,
44
+ searchCredential: { type: "top-level" },
45
+ configuredCredential: { pluginId: "brave" }
46
+ }),
47
+ getConfiguredCredentialValue: resolveConfiguredBraveCredential,
48
+ getConfiguredCredentialFallback: resolveLegacyTopLevelBraveCredential,
49
+ createTool: () => null
50
+ };
51
+ }
52
+ //#endregion
53
+ export { createBraveWebSearchProvider };
@@ -0,0 +1,2 @@
1
+ import { t as createBraveWebSearchProvider } from "./brave-web-search-provider-CKA8mVdu.js";
2
+ export { createBraveWebSearchProvider };
package/index.ts ADDED
@@ -0,0 +1,11 @@
1
+ import { definePluginEntry } from "klaw/plugin-sdk/plugin-entry";
2
+ import { createBraveWebSearchProvider } from "./src/brave-web-search-provider.js";
3
+
4
+ export default definePluginEntry({
5
+ id: "brave",
6
+ name: "Brave Plugin",
7
+ description: "Bundled Brave plugin",
8
+ register(api) {
9
+ api.registerWebSearchProvider(createBraveWebSearchProvider());
10
+ },
11
+ });
package/klaw.plugin.json CHANGED
@@ -4,20 +4,14 @@
4
4
  "onStartup": false
5
5
  },
6
6
  "providerAuthEnvVars": {
7
- "brave": [
8
- "BRAVE_API_KEY"
9
- ]
7
+ "brave": ["BRAVE_API_KEY"]
10
8
  },
11
9
  "setup": {
12
10
  "providers": [
13
11
  {
14
12
  "id": "brave",
15
- "authMethods": [
16
- "api-key"
17
- ],
18
- "envVars": [
19
- "BRAVE_API_KEY"
20
- ]
13
+ "authMethods": ["api-key"],
14
+ "envVars": ["BRAVE_API_KEY"]
21
15
  }
22
16
  ]
23
17
  },
@@ -38,14 +32,10 @@
38
32
  }
39
33
  },
40
34
  "contracts": {
41
- "webSearchProviders": [
42
- "brave"
43
- ]
35
+ "webSearchProviders": ["brave"]
44
36
  },
45
37
  "configContracts": {
46
- "compatibilityRuntimePaths": [
47
- "tools.web.search.apiKey"
48
- ]
38
+ "compatibilityRuntimePaths": ["tools.web.search.apiKey"]
49
39
  },
50
40
  "configSchema": {
51
41
  "type": "object",
@@ -56,23 +46,14 @@
56
46
  "additionalProperties": false,
57
47
  "properties": {
58
48
  "apiKey": {
59
- "type": [
60
- "string",
61
- "object"
62
- ]
49
+ "type": ["string", "object"]
63
50
  },
64
51
  "mode": {
65
52
  "type": "string",
66
- "enum": [
67
- "web",
68
- "llm-context"
69
- ]
53
+ "enum": ["web", "llm-context"]
70
54
  },
71
55
  "baseUrl": {
72
- "type": [
73
- "string",
74
- "object"
75
- ]
56
+ "type": ["string", "object"]
76
57
  }
77
58
  }
78
59
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kodelyth/brave-plugin",
3
- "version": "2026.5.39",
3
+ "version": "2026.5.42",
4
4
  "description": "Klaw Brave plugin",
5
5
  "repository": {
6
6
  "type": "git",
@@ -12,7 +12,7 @@
12
12
  },
13
13
  "klaw": {
14
14
  "extensions": [
15
- "./index.js"
15
+ "./index.ts"
16
16
  ],
17
17
  "install": {
18
18
  "npmSpec": "@kodelyth/brave-plugin",