@alfe.ai/openclaw-search 0.0.4 → 0.0.6
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 +0 -1
- package/dist/plugin.d.cts.map +1 -1
- package/dist/plugin.d.ts +0 -1
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin2.cjs +11 -26
- package/dist/plugin2.js +11 -26
- package/dist/plugin2.js.map +1 -1
- package/package.json +2 -1
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":";UAOU,SAAA;EAAA,MAAA,EAAA;IAKJ,IAAA,EA0BL,CAAA,GAAA,IAAA,EAAA,OAAA,EAAA,EAAA,GAAA,IAAA;IAAA,IAAA,EAAA,CAAA,GAAA,IAAA,EAAA,OAAA,EAAA,EAAA,GAAA,IAAA;IArBe,KAAA,EAAA,CAAA,GAAA,IAAA,EAAA,OAAA,EAAA,EAAA,GAAA,IAAA;IAkBE,KAAA,EAAA,CAAA,GAAA,IAAA,EAAA,OAAA,EAAA,EAAA,GAAA,IAAA;EAAS,CAAA;;;cAvBrB;;;;gBAKU;kBAkBE"}
|
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":";UAOU,SAAA;EAAA,MAAA,EAAA;IAKJ,IAAA,EA0BL,CAAA,GAAA,IAAA,EAAA,OAAA,EAAA,EAAA,GAAA,IAAA;IAAA,IAAA,EAAA,CAAA,GAAA,IAAA,EAAA,OAAA,EAAA,EAAA,GAAA,IAAA;IArBe,KAAA,EAAA,CAAA,GAAA,IAAA,EAAA,OAAA,EAAA,EAAA,GAAA,IAAA;IAkBE,KAAA,EAAA,CAAA,GAAA,IAAA,EAAA,OAAA,EAAA,EAAA,GAAA,IAAA;EAAS,CAAA;;;cAvBrB;;;;gBAKU;kBAkBE"}
|
package/dist/plugin2.cjs
CHANGED
|
@@ -1,23 +1,8 @@
|
|
|
1
1
|
let _alfe_ai_config = require("@alfe.ai/config");
|
|
2
|
+
let _alfe_ai_agent_api_client = require("@alfe.ai/agent-api-client");
|
|
2
3
|
let node_module = require("node:module");
|
|
3
4
|
//#region src/tools.ts
|
|
4
|
-
|
|
5
|
-
const res = await fetch(`${apiUrl}/agents/search/${type}`, {
|
|
6
|
-
method: "POST",
|
|
7
|
-
headers: {
|
|
8
|
-
"Content-Type": "application/json",
|
|
9
|
-
Authorization: `Bearer ${apiKey}`
|
|
10
|
-
},
|
|
11
|
-
body: JSON.stringify(params)
|
|
12
|
-
});
|
|
13
|
-
if (!res.ok) {
|
|
14
|
-
const body = await res.text().catch(() => "");
|
|
15
|
-
throw new Error(`Search API error: ${String(res.status)} ${body}`);
|
|
16
|
-
}
|
|
17
|
-
const json = await res.json();
|
|
18
|
-
return json.data ?? json;
|
|
19
|
-
}
|
|
20
|
-
function registerTools(api, apiUrl, apiKey) {
|
|
5
|
+
function registerTools(api, client) {
|
|
21
6
|
api.registerTool({
|
|
22
7
|
name: "web_search",
|
|
23
8
|
label: "web_search",
|
|
@@ -43,7 +28,7 @@ function registerTools(api, apiUrl, apiKey) {
|
|
|
43
28
|
required: ["query"]
|
|
44
29
|
},
|
|
45
30
|
execute: async (_id, params) => {
|
|
46
|
-
return
|
|
31
|
+
return client.searchWeb(params);
|
|
47
32
|
}
|
|
48
33
|
});
|
|
49
34
|
api.registerTool({
|
|
@@ -66,7 +51,7 @@ function registerTools(api, apiUrl, apiKey) {
|
|
|
66
51
|
required: ["query"]
|
|
67
52
|
},
|
|
68
53
|
execute: async (_id, params) => {
|
|
69
|
-
return
|
|
54
|
+
return client.searchImages(params);
|
|
70
55
|
}
|
|
71
56
|
});
|
|
72
57
|
api.registerTool({
|
|
@@ -94,7 +79,7 @@ function registerTools(api, apiUrl, apiKey) {
|
|
|
94
79
|
required: ["query"]
|
|
95
80
|
},
|
|
96
81
|
execute: async (_id, params) => {
|
|
97
|
-
return
|
|
82
|
+
return client.searchNews(params);
|
|
98
83
|
}
|
|
99
84
|
});
|
|
100
85
|
}
|
|
@@ -106,19 +91,19 @@ const plugin = {
|
|
|
106
91
|
version: (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href)("../package.json").version,
|
|
107
92
|
activate(api) {
|
|
108
93
|
const log = api.logger;
|
|
109
|
-
if (api.registrationMode && api.registrationMode !== "full") return;
|
|
110
94
|
log.info("Search plugin activating...");
|
|
111
|
-
let
|
|
112
|
-
let apiKey;
|
|
95
|
+
let client;
|
|
113
96
|
try {
|
|
114
97
|
const config = (0, _alfe_ai_config.resolveConfig)();
|
|
115
|
-
|
|
116
|
-
|
|
98
|
+
client = new _alfe_ai_agent_api_client.AgentApiClient({
|
|
99
|
+
apiUrl: config.apiUrl,
|
|
100
|
+
apiKey: config.apiKey
|
|
101
|
+
});
|
|
117
102
|
} catch (err) {
|
|
118
103
|
log.error(`Search plugin: failed to resolve config — ${err instanceof Error ? err.message : String(err)}`);
|
|
119
104
|
return;
|
|
120
105
|
}
|
|
121
|
-
registerTools(api,
|
|
106
|
+
registerTools(api, client);
|
|
122
107
|
log.info("Search plugin activated — web_search, image_search, news_search tools registered");
|
|
123
108
|
},
|
|
124
109
|
deactivate(api) {
|
package/dist/plugin2.js
CHANGED
|
@@ -1,23 +1,8 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
2
|
import { resolveConfig } from "@alfe.ai/config";
|
|
3
|
+
import { AgentApiClient } from "@alfe.ai/agent-api-client";
|
|
3
4
|
//#region src/tools.ts
|
|
4
|
-
|
|
5
|
-
const res = await fetch(`${apiUrl}/agents/search/${type}`, {
|
|
6
|
-
method: "POST",
|
|
7
|
-
headers: {
|
|
8
|
-
"Content-Type": "application/json",
|
|
9
|
-
Authorization: `Bearer ${apiKey}`
|
|
10
|
-
},
|
|
11
|
-
body: JSON.stringify(params)
|
|
12
|
-
});
|
|
13
|
-
if (!res.ok) {
|
|
14
|
-
const body = await res.text().catch(() => "");
|
|
15
|
-
throw new Error(`Search API error: ${String(res.status)} ${body}`);
|
|
16
|
-
}
|
|
17
|
-
const json = await res.json();
|
|
18
|
-
return json.data ?? json;
|
|
19
|
-
}
|
|
20
|
-
function registerTools(api, apiUrl, apiKey) {
|
|
5
|
+
function registerTools(api, client) {
|
|
21
6
|
api.registerTool({
|
|
22
7
|
name: "web_search",
|
|
23
8
|
label: "web_search",
|
|
@@ -43,7 +28,7 @@ function registerTools(api, apiUrl, apiKey) {
|
|
|
43
28
|
required: ["query"]
|
|
44
29
|
},
|
|
45
30
|
execute: async (_id, params) => {
|
|
46
|
-
return
|
|
31
|
+
return client.searchWeb(params);
|
|
47
32
|
}
|
|
48
33
|
});
|
|
49
34
|
api.registerTool({
|
|
@@ -66,7 +51,7 @@ function registerTools(api, apiUrl, apiKey) {
|
|
|
66
51
|
required: ["query"]
|
|
67
52
|
},
|
|
68
53
|
execute: async (_id, params) => {
|
|
69
|
-
return
|
|
54
|
+
return client.searchImages(params);
|
|
70
55
|
}
|
|
71
56
|
});
|
|
72
57
|
api.registerTool({
|
|
@@ -94,7 +79,7 @@ function registerTools(api, apiUrl, apiKey) {
|
|
|
94
79
|
required: ["query"]
|
|
95
80
|
},
|
|
96
81
|
execute: async (_id, params) => {
|
|
97
|
-
return
|
|
82
|
+
return client.searchNews(params);
|
|
98
83
|
}
|
|
99
84
|
});
|
|
100
85
|
}
|
|
@@ -106,19 +91,19 @@ const plugin = {
|
|
|
106
91
|
version: createRequire(import.meta.url)("../package.json").version,
|
|
107
92
|
activate(api) {
|
|
108
93
|
const log = api.logger;
|
|
109
|
-
if (api.registrationMode && api.registrationMode !== "full") return;
|
|
110
94
|
log.info("Search plugin activating...");
|
|
111
|
-
let
|
|
112
|
-
let apiKey;
|
|
95
|
+
let client;
|
|
113
96
|
try {
|
|
114
97
|
const config = resolveConfig();
|
|
115
|
-
|
|
116
|
-
|
|
98
|
+
client = new AgentApiClient({
|
|
99
|
+
apiUrl: config.apiUrl,
|
|
100
|
+
apiKey: config.apiKey
|
|
101
|
+
});
|
|
117
102
|
} catch (err) {
|
|
118
103
|
log.error(`Search plugin: failed to resolve config — ${err instanceof Error ? err.message : String(err)}`);
|
|
119
104
|
return;
|
|
120
105
|
}
|
|
121
|
-
registerTools(api,
|
|
106
|
+
registerTools(api, client);
|
|
122
107
|
log.info("Search plugin activated — web_search, image_search, news_search tools registered");
|
|
123
108
|
},
|
|
124
109
|
deactivate(api) {
|
package/dist/plugin2.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin2.js","names":[],"sources":["../src/tools.ts","../src/plugin.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"plugin2.js","names":[],"sources":["../src/tools.ts","../src/plugin.ts"],"sourcesContent":["import type { AgentApiClient } from \"@alfe.ai/agent-api-client\";\n\ninterface 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\nexport function registerTools(api: PluginApi, client: AgentApiClient): 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 client.searchWeb(params as { query: string; count?: number; offset?: number });\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 client.searchImages(params as { query: string; count?: number });\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 client.searchNews(params as { query: string; count?: number; freshness?: string });\n },\n });\n}\n","import { registerTools } from \"./tools.js\";\nimport { resolveConfig } from \"@alfe.ai/config\";\nimport { AgentApiClient } from \"@alfe.ai/agent-api-client\";\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 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 log.info(\"Search plugin activating...\");\n\n let client: AgentApiClient;\n try {\n const config = resolveConfig();\n client = new AgentApiClient({ apiUrl: config.apiUrl, 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, client);\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":";;;;AAcA,SAAgB,cAAc,KAAgB,QAA8B;AAG1E,KAAI,aAAa;EACf,MAAM;EACN,OAAO;EACP,aAAa;EACb,YAAY;GACV,MAAM;GACN,YAAY;IACV,OAAO;KAAE,MAAM;KAAU,aAAa;KAAoB;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,OAAO,UAAU,OAA6D;;EAExF,CAAC;AAIF,KAAI,aAAa;EACf,MAAM;EACN,OAAO;EACP,aAAa;EACb,YAAY;GACV,MAAM;GACN,YAAY;IACV,OAAO;KAAE,MAAM;KAAU,aAAa;KAAoB;IAC1D,OAAO;KAAE,MAAM;KAAU,aAAa;KAAsC,SAAS;KAAI;IAC1F;GACD,UAAU,CAAC,QAAQ;GACpB;EACD,SAAS,OAAO,KAAK,WAAW;AAC9B,UAAO,OAAO,aAAa,OAA4C;;EAE1E,CAAC;AAIF,KAAI,aAAa;EACf,MAAM;EACN,OAAO;EACP,aAAa;EACb,YAAY;GACV,MAAM;GACN,YAAY;IACV,OAAO;KAAE,MAAM;KAAU,aAAa;KAAoB;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,OAAO,WAAW,OAAgE;;EAE5F,CAAC;;;;AC5DJ,MAAM,SAAS;CACb,IAAI;CACJ,MAAM;CACN,SAXc,cAAc,OAAO,KAAK,IAAI,CAC1B,kBAAkB,CAUvB;CAEb,SAAS,KAAgB;EACvB,MAAM,MAAM,IAAI;AAEhB,MAAI,KAAK,8BAA8B;EAEvC,IAAI;AACJ,MAAI;GACF,MAAM,SAAS,eAAe;AAC9B,YAAS,IAAI,eAAe;IAAE,QAAQ,OAAO;IAAQ,QAAQ,OAAO;IAAQ,CAAC;WACtE,KAAK;AACZ,OAAI,MAAM,6CAA6C,eAAe,QAAQ,IAAI,UAAU,OAAO,IAAI,GAAG;AAC1G;;AAGF,gBAAc,KAAK,OAAO;AAC1B,MAAI,KAAK,mFAAmF;;CAG9F,WAAW,KAAgB;AACzB,MAAI,OAAO,KAAK,gCAAgC;;CAEnD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alfe.ai/openclaw-search",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"description": "OpenClaw search plugin — web, image, and news search",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/plugin.js",
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"openclaw.plugin.json"
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
|
+
"@alfe.ai/agent-api-client": "0.0.12",
|
|
30
31
|
"@alfe.ai/config": "0.0.8"
|
|
31
32
|
},
|
|
32
33
|
"license": "UNLICENSED",
|