@alfe.ai/openclaw-search 0.0.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/index.cjs ADDED
@@ -0,0 +1,2 @@
1
+ const require_plugin = require("./plugin2.cjs");
2
+ module.exports = require_plugin.plugin;
@@ -0,0 +1,2 @@
1
+ import plugin from "./plugin.cjs";
2
+ export { plugin as default };
@@ -0,0 +1,2 @@
1
+ import plugin from "./plugin.js";
2
+ export { plugin as default };
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ import { t as plugin } from "./plugin2.js";
2
+ export { plugin as default };
@@ -0,0 +1,2 @@
1
+ const require_plugin = require("./plugin2.cjs");
2
+ module.exports = require_plugin.plugin;
@@ -0,0 +1,20 @@
1
+ //#region src/plugin.d.ts
2
+ interface PluginApi {
3
+ logger: {
4
+ info: (...args: unknown[]) => void;
5
+ warn: (...args: unknown[]) => void;
6
+ error: (...args: unknown[]) => void;
7
+ debug: (...args: unknown[]) => void;
8
+ };
9
+ registerTool(tool: unknown): void;
10
+ }
11
+ declare const plugin: {
12
+ id: string;
13
+ name: string;
14
+ version: string;
15
+ activate(api: PluginApi): void;
16
+ deactivate(api: PluginApi): void;
17
+ };
18
+ //#endregion
19
+ export { plugin as default };
20
+ //# sourceMappingURL=plugin.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.cts","names":[],"sources":["../src/plugin.ts"],"mappings":";UAGU,SAAA;EAAA,MAAA,EAAA;IAKJ,IAAA,EA2BL,CAAA,GAAA,IAAA,EAAA,OAAA,EAAA,EAAA,GAAA,IAAA;IAAA,IAAA,EAAA,CAAA,GAAA,IAAA,EAAA,OAAA,EAAA,EAAA,GAAA,IAAA;IAtBe,KAAA,EAAA,CAAA,GAAA,IAAA,EAAA,OAAA,EAAA,EAAA,GAAA,IAAA;IAmBE,KAAA,EAAA,CAAA,GAAA,IAAA,EAAA,OAAA,EAAA,EAAA,GAAA,IAAA;EAAS,CAAA;;;cAxBrB;;;;gBAKU;kBAmBE"}
@@ -0,0 +1,20 @@
1
+ //#region src/plugin.d.ts
2
+ interface PluginApi {
3
+ logger: {
4
+ info: (...args: unknown[]) => void;
5
+ warn: (...args: unknown[]) => void;
6
+ error: (...args: unknown[]) => void;
7
+ debug: (...args: unknown[]) => void;
8
+ };
9
+ registerTool(tool: unknown): void;
10
+ }
11
+ declare const plugin: {
12
+ id: string;
13
+ name: string;
14
+ version: string;
15
+ activate(api: PluginApi): void;
16
+ deactivate(api: PluginApi): void;
17
+ };
18
+ //#endregion
19
+ export { plugin as default };
20
+ //# sourceMappingURL=plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.ts","names":[],"sources":["../src/plugin.ts"],"mappings":";UAGU,SAAA;EAAA,MAAA,EAAA;IAKJ,IAAA,EA2BL,CAAA,GAAA,IAAA,EAAA,OAAA,EAAA,EAAA,GAAA,IAAA;IAAA,IAAA,EAAA,CAAA,GAAA,IAAA,EAAA,OAAA,EAAA,EAAA,GAAA,IAAA;IAtBe,KAAA,EAAA,CAAA,GAAA,IAAA,EAAA,OAAA,EAAA,EAAA,GAAA,IAAA;IAmBE,KAAA,EAAA,CAAA,GAAA,IAAA,EAAA,OAAA,EAAA,EAAA,GAAA,IAAA;EAAS,CAAA;;;cAxBrB;;;;gBAKU;kBAmBE"}
package/dist/plugin.js ADDED
@@ -0,0 +1,2 @@
1
+ import { t as plugin } from "./plugin2.js";
2
+ export { plugin as default };
@@ -0,0 +1,132 @@
1
+ let _alfe_ai_config = require("@alfe.ai/config");
2
+ //#region src/tools.ts
3
+ async function searchRequest(apiUrl, apiKey, type, params) {
4
+ const res = await fetch(`${apiUrl}/agents/search/${type}`, {
5
+ method: "POST",
6
+ headers: {
7
+ "Content-Type": "application/json",
8
+ Authorization: `Bearer ${apiKey}`
9
+ },
10
+ body: JSON.stringify(params)
11
+ });
12
+ if (!res.ok) {
13
+ const body = await res.text().catch(() => "");
14
+ throw new Error(`Search API error: ${String(res.status)} ${body}`);
15
+ }
16
+ const json = await res.json();
17
+ return json.data ?? json;
18
+ }
19
+ function registerTools(api, apiUrl, apiKey) {
20
+ api.registerTool({
21
+ name: "brave_web_search",
22
+ label: "brave_web_search",
23
+ description: "Search the web using Brave Search. Returns web pages with titles, URLs, and descriptions.",
24
+ parameters: {
25
+ type: "object",
26
+ properties: {
27
+ query: {
28
+ type: "string",
29
+ description: "The search query"
30
+ },
31
+ count: {
32
+ type: "number",
33
+ description: "Number of results to return (1-20)",
34
+ default: 10
35
+ },
36
+ offset: {
37
+ type: "number",
38
+ description: "Pagination offset (0-9)",
39
+ default: 0
40
+ }
41
+ },
42
+ required: ["query"]
43
+ },
44
+ execute: async (_id, params) => {
45
+ return searchRequest(apiUrl, apiKey, "web", params);
46
+ }
47
+ });
48
+ api.registerTool({
49
+ name: "brave_image_search",
50
+ label: "brave_image_search",
51
+ description: "Search for images using Brave Search. Returns image URLs, thumbnails, and metadata.",
52
+ parameters: {
53
+ type: "object",
54
+ properties: {
55
+ query: {
56
+ type: "string",
57
+ description: "The search query"
58
+ },
59
+ count: {
60
+ type: "number",
61
+ description: "Number of results to return (1-20)",
62
+ default: 10
63
+ }
64
+ },
65
+ required: ["query"]
66
+ },
67
+ execute: async (_id, params) => {
68
+ return searchRequest(apiUrl, apiKey, "images", params);
69
+ }
70
+ });
71
+ api.registerTool({
72
+ name: "brave_news_search",
73
+ label: "brave_news_search",
74
+ description: "Search for news articles using Brave Search. Returns articles with titles, sources, and publication dates.",
75
+ parameters: {
76
+ type: "object",
77
+ properties: {
78
+ query: {
79
+ type: "string",
80
+ description: "The search query"
81
+ },
82
+ count: {
83
+ type: "number",
84
+ description: "Number of results to return (1-20)",
85
+ default: 10
86
+ },
87
+ offset: {
88
+ type: "number",
89
+ description: "Pagination offset (0-9)",
90
+ default: 0
91
+ }
92
+ },
93
+ required: ["query"]
94
+ },
95
+ execute: async (_id, params) => {
96
+ return searchRequest(apiUrl, apiKey, "news", params);
97
+ }
98
+ });
99
+ }
100
+ //#endregion
101
+ //#region src/plugin.ts
102
+ const plugin = {
103
+ id: "@alfe.ai/openclaw-search",
104
+ name: "Brave Search",
105
+ version: "0.0.1",
106
+ activate(api) {
107
+ const log = api.logger;
108
+ log.info("Search plugin activating...");
109
+ let apiUrl;
110
+ let apiKey;
111
+ try {
112
+ const config = (0, _alfe_ai_config.resolveConfig)();
113
+ apiUrl = config.apiUrl;
114
+ apiKey = config.apiKey;
115
+ } catch (err) {
116
+ log.error(`Search plugin: failed to resolve config — ${err instanceof Error ? err.message : String(err)}`);
117
+ return;
118
+ }
119
+ registerTools(api, apiUrl, apiKey);
120
+ log.info("Search plugin activated — brave_web_search, brave_image_search, brave_news_search tools registered");
121
+ },
122
+ deactivate(api) {
123
+ api.logger.info("Search plugin deactivating...");
124
+ }
125
+ };
126
+ //#endregion
127
+ Object.defineProperty(exports, "plugin", {
128
+ enumerable: true,
129
+ get: function() {
130
+ return plugin;
131
+ }
132
+ });
@@ -0,0 +1,129 @@
1
+ import { resolveConfig } from "@alfe.ai/config";
2
+ //#region src/tools.ts
3
+ async function searchRequest(apiUrl, apiKey, type, params) {
4
+ const res = await fetch(`${apiUrl}/agents/search/${type}`, {
5
+ method: "POST",
6
+ headers: {
7
+ "Content-Type": "application/json",
8
+ Authorization: `Bearer ${apiKey}`
9
+ },
10
+ body: JSON.stringify(params)
11
+ });
12
+ if (!res.ok) {
13
+ const body = await res.text().catch(() => "");
14
+ throw new Error(`Search API error: ${String(res.status)} ${body}`);
15
+ }
16
+ const json = await res.json();
17
+ return json.data ?? json;
18
+ }
19
+ function registerTools(api, apiUrl, apiKey) {
20
+ api.registerTool({
21
+ name: "brave_web_search",
22
+ label: "brave_web_search",
23
+ description: "Search the web using Brave Search. Returns web pages with titles, URLs, and descriptions.",
24
+ parameters: {
25
+ type: "object",
26
+ properties: {
27
+ query: {
28
+ type: "string",
29
+ description: "The search query"
30
+ },
31
+ count: {
32
+ type: "number",
33
+ description: "Number of results to return (1-20)",
34
+ default: 10
35
+ },
36
+ offset: {
37
+ type: "number",
38
+ description: "Pagination offset (0-9)",
39
+ default: 0
40
+ }
41
+ },
42
+ required: ["query"]
43
+ },
44
+ execute: async (_id, params) => {
45
+ return searchRequest(apiUrl, apiKey, "web", params);
46
+ }
47
+ });
48
+ api.registerTool({
49
+ name: "brave_image_search",
50
+ label: "brave_image_search",
51
+ description: "Search for images using Brave Search. Returns image URLs, thumbnails, and metadata.",
52
+ parameters: {
53
+ type: "object",
54
+ properties: {
55
+ query: {
56
+ type: "string",
57
+ description: "The search query"
58
+ },
59
+ count: {
60
+ type: "number",
61
+ description: "Number of results to return (1-20)",
62
+ default: 10
63
+ }
64
+ },
65
+ required: ["query"]
66
+ },
67
+ execute: async (_id, params) => {
68
+ return searchRequest(apiUrl, apiKey, "images", params);
69
+ }
70
+ });
71
+ api.registerTool({
72
+ name: "brave_news_search",
73
+ label: "brave_news_search",
74
+ description: "Search for news articles using Brave Search. Returns articles with titles, sources, and publication dates.",
75
+ parameters: {
76
+ type: "object",
77
+ properties: {
78
+ query: {
79
+ type: "string",
80
+ description: "The search query"
81
+ },
82
+ count: {
83
+ type: "number",
84
+ description: "Number of results to return (1-20)",
85
+ default: 10
86
+ },
87
+ offset: {
88
+ type: "number",
89
+ description: "Pagination offset (0-9)",
90
+ default: 0
91
+ }
92
+ },
93
+ required: ["query"]
94
+ },
95
+ execute: async (_id, params) => {
96
+ return searchRequest(apiUrl, apiKey, "news", params);
97
+ }
98
+ });
99
+ }
100
+ //#endregion
101
+ //#region src/plugin.ts
102
+ const plugin = {
103
+ id: "@alfe.ai/openclaw-search",
104
+ name: "Brave Search",
105
+ version: "0.0.1",
106
+ activate(api) {
107
+ const log = api.logger;
108
+ log.info("Search plugin activating...");
109
+ let apiUrl;
110
+ let apiKey;
111
+ try {
112
+ const config = resolveConfig();
113
+ apiUrl = config.apiUrl;
114
+ apiKey = config.apiKey;
115
+ } catch (err) {
116
+ log.error(`Search plugin: failed to resolve config — ${err instanceof Error ? err.message : String(err)}`);
117
+ return;
118
+ }
119
+ registerTools(api, apiUrl, apiKey);
120
+ log.info("Search plugin activated — brave_web_search, brave_image_search, brave_news_search tools registered");
121
+ },
122
+ deactivate(api) {
123
+ api.logger.info("Search plugin deactivating...");
124
+ }
125
+ };
126
+ //#endregion
127
+ export { plugin as t };
128
+
129
+ //# sourceMappingURL=plugin2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin2.js","names":[],"sources":["../src/tools.ts","../src/plugin.ts"],"sourcesContent":["interface PluginApi {\n registerTool(tool: ToolDef): void;\n}\n\ninterface ToolDef {\n name: string;\n description: string;\n label: string;\n parameters: Record<string, unknown>;\n execute: (toolCallId: string, params: Record<string, unknown>) => Promise<unknown>;\n}\n\nasync function searchRequest(\n apiUrl: string,\n apiKey: string,\n type: \"web\" | \"images\" | \"news\",\n params: Record<string, unknown>,\n): Promise<unknown> {\n const res = await fetch(`${apiUrl}/agents/search/${type}`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n Authorization: `Bearer ${apiKey}`,\n },\n body: JSON.stringify(params),\n });\n\n if (!res.ok) {\n const body = await res.text().catch(() => \"\");\n throw new Error(`Search API error: ${String(res.status)} ${body}`);\n }\n\n const json = await res.json() as { data?: unknown };\n return json.data ?? json;\n}\n\nexport function registerTools(api: PluginApi, apiUrl: string, apiKey: string): void {\n // ── Web Search ──────────────────────────────────────\n\n api.registerTool({\n name: \"brave_web_search\",\n label: \"brave_web_search\",\n description: \"Search the web using Brave Search. Returns web pages with titles, URLs, and descriptions.\",\n parameters: {\n type: \"object\",\n properties: {\n query: { type: \"string\", description: \"The search query\" },\n count: { type: \"number\", description: \"Number of results to return (1-20)\", default: 10 },\n offset: { type: \"number\", description: \"Pagination offset (0-9)\", default: 0 },\n },\n required: [\"query\"],\n },\n execute: async (_id, params) => {\n return searchRequest(apiUrl, apiKey, \"web\", params);\n },\n });\n\n // ── Image Search ────────────────────────────────────\n\n api.registerTool({\n name: \"brave_image_search\",\n label: \"brave_image_search\",\n description: \"Search for images using Brave Search. Returns image URLs, thumbnails, and metadata.\",\n parameters: {\n type: \"object\",\n properties: {\n query: { type: \"string\", description: \"The search query\" },\n count: { type: \"number\", description: \"Number of results to return (1-20)\", default: 10 },\n },\n required: [\"query\"],\n },\n execute: async (_id, params) => {\n return searchRequest(apiUrl, apiKey, \"images\", params);\n },\n });\n\n // ── News Search ─────────────────────────────────────\n\n api.registerTool({\n name: \"brave_news_search\",\n label: \"brave_news_search\",\n description: \"Search for news articles using Brave Search. Returns articles with titles, sources, and publication dates.\",\n parameters: {\n type: \"object\",\n properties: {\n query: { type: \"string\", description: \"The search query\" },\n count: { type: \"number\", description: \"Number of results to return (1-20)\", default: 10 },\n offset: { type: \"number\", description: \"Pagination offset (0-9)\", default: 0 },\n },\n required: [\"query\"],\n },\n execute: async (_id, params) => {\n return searchRequest(apiUrl, apiKey, \"news\", params);\n },\n });\n}\n","import { registerTools } from \"./tools.js\";\nimport { resolveConfig } from \"@alfe.ai/config\";\n\ninterface PluginApi {\n logger: { info: (...args: unknown[]) => void; warn: (...args: unknown[]) => void; error: (...args: unknown[]) => void; debug: (...args: unknown[]) => void };\n registerTool(tool: unknown): void;\n}\n\nconst plugin = {\n id: \"@alfe.ai/openclaw-search\",\n name: \"Brave Search\",\n version: \"0.0.1\",\n\n activate(api: PluginApi) {\n const log = api.logger;\n log.info(\"Search plugin activating...\");\n\n let apiUrl: string;\n let apiKey: string;\n try {\n const config = resolveConfig();\n apiUrl = config.apiUrl;\n apiKey = config.apiKey;\n } catch (err) {\n log.error(`Search plugin: failed to resolve config — ${err instanceof Error ? err.message : String(err)}`);\n return;\n }\n\n registerTools(api, apiUrl, apiKey);\n log.info(\"Search plugin activated — brave_web_search, brave_image_search, brave_news_search tools registered\");\n },\n\n deactivate(api: PluginApi) {\n api.logger.info(\"Search plugin deactivating...\");\n },\n};\n\nexport default plugin;\n"],"mappings":";;AAYA,eAAe,cACb,QACA,Q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AoB;IAC1D,OAAO;KAAE,MAAM;KAAU,aAAa;KAAsC,SAAS;KAAI;IACzF,QAAQ;KAAE,MAAM;KAAU,aAAa;KAA2B,SAAS;KAAG;IAC/E;GACD,UAAU,CAAC,QAAQ;GACpB;EACD,SAAS,OAAO,KAAK,WAAW;AAC9B,UAAO,cAAc,QAAQ,QAAQ,QAAQ,OAAO;;EAEvD,CAAC;;;;ACtFJ,MAAM,SAAS;CACb,IAAI;CACJ,MAAM;CACN,SAAS;CAET,SAAS,KAAgB;EACvB,MAAM,MAAM,IAAI;AAChB,MAAI,KAAK,8BAA8B;EAEvC,IAAI;EACJ,IAAI;AACJ,MAAI;GACF,MAAM,SAAS,eAAe;AAC9B,YAAS,OAAO;AAChB,YAAS,OAAO;WACT,KAAK;AACZ,OAAI,MAAM,6CAA6C,eAAe,QAAQ,IAAI,UAAU,OAAO,IAAI,GAAG;AAC1G;;AAGF,gBAAc,KAAK,QAAQ,OAAO;AAClC,MAAI,KAAK,qGAAqG;;CAGhH,WAAW,KAAgB;AACzB,MAAI,OAAO,KAAK,gCAAgC;;CAEnD"}
@@ -0,0 +1,12 @@
1
+ {
2
+ "id": "@alfe.ai/openclaw-search",
3
+ "name": "Brave Search",
4
+ "version": "0.0.1",
5
+ "description": "Web, image, and news search powered by Brave Search API",
6
+ "entry": "./dist/plugin.js",
7
+ "configSchema": {
8
+ "type": "object",
9
+ "additionalProperties": false,
10
+ "properties": {}
11
+ }
12
+ }
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "@alfe.ai/openclaw-search",
3
+ "version": "0.0.1",
4
+ "description": "OpenClaw search plugin — web, image, and news search via Brave Search API",
5
+ "type": "module",
6
+ "main": "./dist/plugin.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "require": "./dist/index.cjs",
12
+ "import": "./dist/index.js"
13
+ },
14
+ "./plugin": {
15
+ "types": "./dist/plugin.d.ts",
16
+ "require": "./dist/plugin.cjs",
17
+ "import": "./dist/plugin.js"
18
+ }
19
+ },
20
+ "openclaw": {
21
+ "extensions": [
22
+ "./dist/plugin.js"
23
+ ]
24
+ },
25
+ "files": [
26
+ "dist",
27
+ "openclaw.plugin.json"
28
+ ],
29
+ "dependencies": {
30
+ "@alfe.ai/config": "0.0.7"
31
+ },
32
+ "license": "UNLICENSED",
33
+ "scripts": {
34
+ "build": "tsdown",
35
+ "dev": "tsdown --watch",
36
+ "typecheck": "tsc --noEmit",
37
+ "lint": "eslint ."
38
+ }
39
+ }