@alfe.ai/openclaw-search 0.0.2 → 0.0.4
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/plugin.d.cts +1 -0
- package/dist/plugin.d.cts.map +1 -1
- package/dist/plugin.d.ts +1 -0
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin2.cjs +14 -12
- package/dist/plugin2.js +14 -12
- package/dist/plugin2.js.map +1 -1
- package/openclaw.plugin.json +2 -3
- package/package.json +2 -2
package/dist/plugin.d.cts
CHANGED
package/dist/plugin.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.cts","names":[],"sources":["../src/plugin.ts"],"mappings":";
|
|
1
|
+
{"version":3,"file":"plugin.d.cts","names":[],"sources":["../src/plugin.ts"],"mappings":";UAMU,SAAA;EAAA,MAAA,EAAA;IAMJ,IAAA,EAiCL,CAAA,GAAA,IAAA,EAAA,OAAA,EAAA,EAAA,GAAA,IAAA;IAAA,IAAA,EAAA,CAAA,GAAA,IAAA,EAAA,OAAA,EAAA,EAAA,GAAA,IAAA;IA5Be,KAAA,EAAA,CAAA,GAAA,IAAA,EAAA,OAAA,EAAA,EAAA,GAAA,IAAA;IAyBE,KAAA,EAAA,CAAA,GAAA,IAAA,EAAA,OAAA,EAAA,EAAA,GAAA,IAAA;EAAS,CAAA;;;;cA9BrB;;;;gBAKU;kBAyBE"}
|
package/dist/plugin.d.ts
CHANGED
package/dist/plugin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","names":[],"sources":["../src/plugin.ts"],"mappings":";
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","names":[],"sources":["../src/plugin.ts"],"mappings":";UAMU,SAAA;EAAA,MAAA,EAAA;IAMJ,IAAA,EAiCL,CAAA,GAAA,IAAA,EAAA,OAAA,EAAA,EAAA,GAAA,IAAA;IAAA,IAAA,EAAA,CAAA,GAAA,IAAA,EAAA,OAAA,EAAA,EAAA,GAAA,IAAA;IA5Be,KAAA,EAAA,CAAA,GAAA,IAAA,EAAA,OAAA,EAAA,EAAA,GAAA,IAAA;IAyBE,KAAA,EAAA,CAAA,GAAA,IAAA,EAAA,OAAA,EAAA,EAAA,GAAA,IAAA;EAAS,CAAA;;;;cA9BrB;;;;gBAKU;kBAyBE"}
|
package/dist/plugin2.cjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
let _alfe_ai_config = require("@alfe.ai/config");
|
|
2
|
+
let node_module = require("node:module");
|
|
2
3
|
//#region src/tools.ts
|
|
3
4
|
async function searchRequest(apiUrl, apiKey, type, params) {
|
|
4
5
|
const res = await fetch(`${apiUrl}/agents/search/${type}`, {
|
|
@@ -18,9 +19,9 @@ async function searchRequest(apiUrl, apiKey, type, params) {
|
|
|
18
19
|
}
|
|
19
20
|
function registerTools(api, apiUrl, apiKey) {
|
|
20
21
|
api.registerTool({
|
|
21
|
-
name: "
|
|
22
|
-
label: "
|
|
23
|
-
description: "Search the web
|
|
22
|
+
name: "web_search",
|
|
23
|
+
label: "web_search",
|
|
24
|
+
description: "Search the web. Returns web pages with titles, URLs, and descriptions.",
|
|
24
25
|
parameters: {
|
|
25
26
|
type: "object",
|
|
26
27
|
properties: {
|
|
@@ -46,9 +47,9 @@ function registerTools(api, apiUrl, apiKey) {
|
|
|
46
47
|
}
|
|
47
48
|
});
|
|
48
49
|
api.registerTool({
|
|
49
|
-
name: "
|
|
50
|
-
label: "
|
|
51
|
-
description: "Search for images
|
|
50
|
+
name: "image_search",
|
|
51
|
+
label: "image_search",
|
|
52
|
+
description: "Search for images. Returns image URLs, thumbnails, and metadata.",
|
|
52
53
|
parameters: {
|
|
53
54
|
type: "object",
|
|
54
55
|
properties: {
|
|
@@ -69,9 +70,9 @@ function registerTools(api, apiUrl, apiKey) {
|
|
|
69
70
|
}
|
|
70
71
|
});
|
|
71
72
|
api.registerTool({
|
|
72
|
-
name: "
|
|
73
|
-
label: "
|
|
74
|
-
description: "Search for news articles
|
|
73
|
+
name: "news_search",
|
|
74
|
+
label: "news_search",
|
|
75
|
+
description: "Search for news articles. Returns articles with titles, sources, and publication dates.",
|
|
75
76
|
parameters: {
|
|
76
77
|
type: "object",
|
|
77
78
|
properties: {
|
|
@@ -101,10 +102,11 @@ function registerTools(api, apiUrl, apiKey) {
|
|
|
101
102
|
//#region src/plugin.ts
|
|
102
103
|
const plugin = {
|
|
103
104
|
id: "@alfe.ai/openclaw-search",
|
|
104
|
-
name: "
|
|
105
|
-
version:
|
|
105
|
+
name: "Search",
|
|
106
|
+
version: (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href)("../package.json").version,
|
|
106
107
|
activate(api) {
|
|
107
108
|
const log = api.logger;
|
|
109
|
+
if (api.registrationMode && api.registrationMode !== "full") return;
|
|
108
110
|
log.info("Search plugin activating...");
|
|
109
111
|
let apiUrl;
|
|
110
112
|
let apiKey;
|
|
@@ -117,7 +119,7 @@ const plugin = {
|
|
|
117
119
|
return;
|
|
118
120
|
}
|
|
119
121
|
registerTools(api, apiUrl, apiKey);
|
|
120
|
-
log.info("Search plugin activated —
|
|
122
|
+
log.info("Search plugin activated — web_search, image_search, news_search tools registered");
|
|
121
123
|
},
|
|
122
124
|
deactivate(api) {
|
|
123
125
|
api.logger.info("Search plugin deactivating...");
|
package/dist/plugin2.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
1
2
|
import { resolveConfig } from "@alfe.ai/config";
|
|
2
3
|
//#region src/tools.ts
|
|
3
4
|
async function searchRequest(apiUrl, apiKey, type, params) {
|
|
@@ -18,9 +19,9 @@ async function searchRequest(apiUrl, apiKey, type, params) {
|
|
|
18
19
|
}
|
|
19
20
|
function registerTools(api, apiUrl, apiKey) {
|
|
20
21
|
api.registerTool({
|
|
21
|
-
name: "
|
|
22
|
-
label: "
|
|
23
|
-
description: "Search the web
|
|
22
|
+
name: "web_search",
|
|
23
|
+
label: "web_search",
|
|
24
|
+
description: "Search the web. Returns web pages with titles, URLs, and descriptions.",
|
|
24
25
|
parameters: {
|
|
25
26
|
type: "object",
|
|
26
27
|
properties: {
|
|
@@ -46,9 +47,9 @@ function registerTools(api, apiUrl, apiKey) {
|
|
|
46
47
|
}
|
|
47
48
|
});
|
|
48
49
|
api.registerTool({
|
|
49
|
-
name: "
|
|
50
|
-
label: "
|
|
51
|
-
description: "Search for images
|
|
50
|
+
name: "image_search",
|
|
51
|
+
label: "image_search",
|
|
52
|
+
description: "Search for images. Returns image URLs, thumbnails, and metadata.",
|
|
52
53
|
parameters: {
|
|
53
54
|
type: "object",
|
|
54
55
|
properties: {
|
|
@@ -69,9 +70,9 @@ function registerTools(api, apiUrl, apiKey) {
|
|
|
69
70
|
}
|
|
70
71
|
});
|
|
71
72
|
api.registerTool({
|
|
72
|
-
name: "
|
|
73
|
-
label: "
|
|
74
|
-
description: "Search for news articles
|
|
73
|
+
name: "news_search",
|
|
74
|
+
label: "news_search",
|
|
75
|
+
description: "Search for news articles. Returns articles with titles, sources, and publication dates.",
|
|
75
76
|
parameters: {
|
|
76
77
|
type: "object",
|
|
77
78
|
properties: {
|
|
@@ -101,10 +102,11 @@ function registerTools(api, apiUrl, apiKey) {
|
|
|
101
102
|
//#region src/plugin.ts
|
|
102
103
|
const plugin = {
|
|
103
104
|
id: "@alfe.ai/openclaw-search",
|
|
104
|
-
name: "
|
|
105
|
-
version: "
|
|
105
|
+
name: "Search",
|
|
106
|
+
version: createRequire(import.meta.url)("../package.json").version,
|
|
106
107
|
activate(api) {
|
|
107
108
|
const log = api.logger;
|
|
109
|
+
if (api.registrationMode && api.registrationMode !== "full") return;
|
|
108
110
|
log.info("Search plugin activating...");
|
|
109
111
|
let apiUrl;
|
|
110
112
|
let apiKey;
|
|
@@ -117,7 +119,7 @@ const plugin = {
|
|
|
117
119
|
return;
|
|
118
120
|
}
|
|
119
121
|
registerTools(api, apiUrl, apiKey);
|
|
120
|
-
log.info("Search plugin activated —
|
|
122
|
+
log.info("Search plugin activated — web_search, image_search, news_search tools registered");
|
|
121
123
|
},
|
|
122
124
|
deactivate(api) {
|
|
123
125
|
api.logger.info("Search plugin deactivating...");
|
package/dist/plugin2.js.map
CHANGED
|
@@ -1 +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: \"
|
|
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: \"web_search\",\n label: \"web_search\",\n description: \"Search the web. 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: \"image_search\",\n label: \"image_search\",\n description: \"Search for images. 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: \"news_search\",\n label: \"news_search\",\n description: \"Search for news articles. 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\";\nimport { createRequire } from 'node:module';\nconst require = createRequire(import.meta.url);\nconst pkg = require('../package.json') as { version: string };\n\ninterface PluginApi {\n logger: { info: (...args: unknown[]) => void; warn: (...args: unknown[]) => void; error: (...args: unknown[]) => void; debug: (...args: unknown[]) => void };\n registrationMode?: \"full\" | \"setup-only\" | \"setup-runtime\" | \"cli-metadata\";\n registerTool(tool: unknown): void;\n}\n\nconst plugin = {\n id: \"@alfe.ai/openclaw-search\",\n name: \"Search\",\n version: pkg.version,\n\n activate(api: PluginApi) {\n const log = api.logger;\n\n // Only run during full gateway execution — skip CLI commands, setup, etc.\n if (api.registrationMode && api.registrationMode !== \"full\") {\n return;\n }\n\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 — web_search, image_search, 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,QACA,MACA,QACkB;CAClB,MAAM,MAAM,MAAM,MAAM,GAAG,OAAO,iBAAiB,QAAQ;EACzD,QAAQ;EACR,SAAS;GACP,gBAAgB;GAChB,eAAe,UAAU;GAC1B;EACD,MAAM,KAAK,UAAU,OAAO;EAC7B,CAAC;AAEF,KAAI,CAAC,IAAI,IAAI;EACX,MAAM,OAAO,MAAM,IAAI,MAAM,CAAC,YAAY,GAAG;AAC7C,QAAM,IAAI,MAAM,qBAAqB,OAAO,IAAI,OAAO,CAAC,GAAG,OAAO;;CAGpE,MAAM,OAAO,MAAM,IAAI,MAAM;AAC7B,QAAO,KAAK,QAAQ;;AAGtB,SAAgB,cAAc,KAAgB,QAAgB,QAAsB;AAGlF,KAAI,aAAa;EACf,MAAM;EACN,OAAO;EACP,aAAa;EACb,YAAY;GACV,MAAM;GACN,YAAY;IAC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e;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,mFAAmF;;CAG9F,WAAW,KAAgB;AACzB,MAAI,OAAO,KAAK,gCAAgC;;CAEnD"}
|
package/openclaw.plugin.json
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "@alfe.ai/openclaw-search",
|
|
3
|
-
"name": "
|
|
4
|
-
"
|
|
5
|
-
"description": "Web, image, and news search powered by Brave Search API",
|
|
3
|
+
"name": "Search",
|
|
4
|
+
"description": "Web, image, and news search",
|
|
6
5
|
"entry": "./dist/plugin.js",
|
|
7
6
|
"configSchema": {
|
|
8
7
|
"type": "object",
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alfe.ai/openclaw-search",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "OpenClaw search plugin — web, image, and news search
|
|
3
|
+
"version": "0.0.4",
|
|
4
|
+
"description": "OpenClaw search plugin — web, image, and news search",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/plugin.js",
|
|
7
7
|
"types": "./dist/index.d.ts",
|