web-search-plus-plugin 1.1.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/.env.template +4 -0
- package/LICENSE +21 -0
- package/README.md +82 -0
- package/index.ts +129 -0
- package/openclaw.plugin.json +11 -0
- package/package.json +22 -0
- package/scripts/search.py +2526 -0
- package/scripts/setup.py +453 -0
package/.env.template
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 robbyczgw-cla
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# web-search-plus-plugin — OpenClaw Plugin
|
|
2
|
+
|
|
3
|
+
A standalone OpenClaw plugin that exposes `web_search_plus` as a native tool with multi-provider routing.
|
|
4
|
+
|
|
5
|
+
It bundles its own Python backend script and supports:
|
|
6
|
+
- **Serper (Google)** — best for factual/shopping queries
|
|
7
|
+
- **Tavily** — best for research & analysis
|
|
8
|
+
- **Exa (Neural)** — best for discovery & semantic search
|
|
9
|
+
- **Perplexity** — AI-synthesized answers with citations
|
|
10
|
+
- **You.com** — real-time web + RAG
|
|
11
|
+
- **SearXNG** — self-hosted privacy-first search
|
|
12
|
+
|
|
13
|
+
The tool auto-routes queries by intent or you can force a specific provider.
|
|
14
|
+
|
|
15
|
+
## What it does
|
|
16
|
+
|
|
17
|
+
- Registers native tool: `web_search_plus`
|
|
18
|
+
- Runs bundled script at `scripts/search.py`
|
|
19
|
+
- Supports:
|
|
20
|
+
- `query` (required)
|
|
21
|
+
- `provider` (`serper` | `tavily` | `exa` | `perplexity` | `you` | `searxng` | `auto`)
|
|
22
|
+
- `count` (result count)
|
|
23
|
+
|
|
24
|
+
## Installation
|
|
25
|
+
|
|
26
|
+
Add plugin path to `plugins.load.paths` and enable in `plugins.entries`.
|
|
27
|
+
|
|
28
|
+
### Example OpenClaw config snippet
|
|
29
|
+
|
|
30
|
+
```json
|
|
31
|
+
{
|
|
32
|
+
"plugins": {
|
|
33
|
+
"load": {
|
|
34
|
+
"paths": [
|
|
35
|
+
"/path/to/web-search-plus-plugin"
|
|
36
|
+
]
|
|
37
|
+
},
|
|
38
|
+
"entries": [
|
|
39
|
+
{
|
|
40
|
+
"id": "web-search-plus-plugin",
|
|
41
|
+
"enabled": true
|
|
42
|
+
}
|
|
43
|
+
]
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Environment variables
|
|
49
|
+
|
|
50
|
+
Copy `.env.template` to `.env` and add your API keys.
|
|
51
|
+
|
|
52
|
+
At least one provider key is required:
|
|
53
|
+
- `SERPER_API_KEY` — [console.serper.dev](https://console.serper.dev)
|
|
54
|
+
- `TAVILY_API_KEY` — [tavily.com](https://tavily.com)
|
|
55
|
+
- `EXA_API_KEY` — [exa.ai](https://exa.ai)
|
|
56
|
+
- `KILOCODE_API_KEY` or `PERPLEXITY_API_KEY` — [perplexity.ai](https://docs.perplexity.ai) (optional, also works via [Kilo Gateway](https://kilocode.ai))
|
|
57
|
+
- `YOU_API_KEY` — [you.com/api](https://you.com/api) (optional)
|
|
58
|
+
- `SEARXNG_URL` — your SearXNG instance URL (optional, self-hosted)
|
|
59
|
+
|
|
60
|
+
## Enable for an agent
|
|
61
|
+
|
|
62
|
+
Allow the tool in agent config:
|
|
63
|
+
|
|
64
|
+
```json
|
|
65
|
+
{
|
|
66
|
+
"agents": {
|
|
67
|
+
"my-agent": {
|
|
68
|
+
"tools": {
|
|
69
|
+
"allow": [
|
|
70
|
+
"web_search_plus"
|
|
71
|
+
]
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Notes
|
|
79
|
+
|
|
80
|
+
- Plugin resolves the script path relative to the plugin directory.
|
|
81
|
+
- No dependency on external skill paths.
|
|
82
|
+
- Publishable as a standalone plugin repository.
|
package/index.ts
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { Type } from "@sinclair/typebox";
|
|
2
|
+
import { spawnSync } from "child_process";
|
|
3
|
+
import fs from "fs";
|
|
4
|
+
import path from "path";
|
|
5
|
+
import { fileURLToPath } from "url";
|
|
6
|
+
|
|
7
|
+
function getPluginDir(): string {
|
|
8
|
+
try {
|
|
9
|
+
if (typeof __dirname !== "undefined") return __dirname;
|
|
10
|
+
} catch {}
|
|
11
|
+
try {
|
|
12
|
+
return path.dirname(fileURLToPath(import.meta.url));
|
|
13
|
+
} catch {}
|
|
14
|
+
return path.join(process.cwd(), "skills", "web-search-plus-plugin");
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function loadEnvFile(envPath: string): Record<string, string> {
|
|
18
|
+
if (!fs.existsSync(envPath)) return {};
|
|
19
|
+
const env: Record<string, string> = {};
|
|
20
|
+
const lines = fs.readFileSync(envPath, "utf8").split("\n");
|
|
21
|
+
for (const line of lines) {
|
|
22
|
+
const trimmed = line.trim();
|
|
23
|
+
if (!trimmed || trimmed.startsWith("#")) continue;
|
|
24
|
+
const stripped = trimmed.startsWith("export ") ? trimmed.slice(7) : trimmed;
|
|
25
|
+
const eqIdx = stripped.indexOf("=");
|
|
26
|
+
if (eqIdx < 0) continue;
|
|
27
|
+
const key = stripped.slice(0, eqIdx).trim();
|
|
28
|
+
const val = stripped.slice(eqIdx + 1).trim().replace(/^['"]|['"]$/g, "");
|
|
29
|
+
if (key) env[key] = val;
|
|
30
|
+
}
|
|
31
|
+
return env;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const PLUGIN_DIR = getPluginDir();
|
|
35
|
+
const scriptPath = path.join(PLUGIN_DIR, "scripts", "search.py");
|
|
36
|
+
|
|
37
|
+
export default function (api: any) {
|
|
38
|
+
api.registerTool(
|
|
39
|
+
{
|
|
40
|
+
name: "web_search_plus",
|
|
41
|
+
description:
|
|
42
|
+
"Search the web using multi-provider routing (Serper/Google, Tavily/Research, Exa/Neural). Automatically routes to the best provider based on query intent. Use this for ALL web searches instead of web_search.",
|
|
43
|
+
parameters: Type.Object({
|
|
44
|
+
query: Type.String({ description: "Search query" }),
|
|
45
|
+
provider: Type.Optional(
|
|
46
|
+
Type.Union(
|
|
47
|
+
[
|
|
48
|
+
Type.Literal("serper"),
|
|
49
|
+
Type.Literal("tavily"),
|
|
50
|
+
Type.Literal("exa"),
|
|
51
|
+
Type.Literal("auto"),
|
|
52
|
+
],
|
|
53
|
+
{
|
|
54
|
+
description:
|
|
55
|
+
"Force a specific provider, or 'auto' for smart routing (default: auto)",
|
|
56
|
+
},
|
|
57
|
+
),
|
|
58
|
+
),
|
|
59
|
+
count: Type.Optional(
|
|
60
|
+
Type.Number({ description: "Number of results (default: 5)" }),
|
|
61
|
+
),
|
|
62
|
+
}),
|
|
63
|
+
async execute(
|
|
64
|
+
_id: string,
|
|
65
|
+
params: { query: string; provider?: string; count?: number },
|
|
66
|
+
) {
|
|
67
|
+
const args = [scriptPath, "--query", params.query, "--compact"];
|
|
68
|
+
|
|
69
|
+
if (params.provider && params.provider !== "auto") {
|
|
70
|
+
args.push("--provider", params.provider);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (typeof params.count === "number" && Number.isFinite(params.count)) {
|
|
74
|
+
args.push("--max-results", String(Math.max(1, Math.floor(params.count))));
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const envPaths = [
|
|
78
|
+
path.join(PLUGIN_DIR, ".env"),
|
|
79
|
+
path.join(PLUGIN_DIR, "..", "web-search-plus", ".env"),
|
|
80
|
+
];
|
|
81
|
+
const fileEnv: Record<string, string> = {};
|
|
82
|
+
for (const envPath of envPaths) {
|
|
83
|
+
Object.assign(fileEnv, loadEnvFile(envPath));
|
|
84
|
+
}
|
|
85
|
+
const childEnv = { ...process.env, ...fileEnv };
|
|
86
|
+
|
|
87
|
+
try {
|
|
88
|
+
const child = spawnSync("python3", args, {
|
|
89
|
+
timeout: 30000,
|
|
90
|
+
env: childEnv,
|
|
91
|
+
shell: false,
|
|
92
|
+
encoding: "utf8",
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
if (child.error) {
|
|
96
|
+
return {
|
|
97
|
+
content: [
|
|
98
|
+
{ type: "text", text: `Search failed: ${child.error.message}` },
|
|
99
|
+
],
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (child.status !== 0) {
|
|
104
|
+
const stderr = child.stderr?.trim() || "Unknown error";
|
|
105
|
+
return {
|
|
106
|
+
content: [
|
|
107
|
+
{
|
|
108
|
+
type: "text",
|
|
109
|
+
text: `Search failed (exit ${child.status}): ${stderr}`,
|
|
110
|
+
},
|
|
111
|
+
],
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return {
|
|
116
|
+
content: [{ type: "text", text: child.stdout?.trim() || "{}" }],
|
|
117
|
+
};
|
|
118
|
+
} catch (err: any) {
|
|
119
|
+
return {
|
|
120
|
+
content: [
|
|
121
|
+
{ type: "text", text: `Search failed: ${err?.message ?? err}` },
|
|
122
|
+
],
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
{ optional: true },
|
|
128
|
+
);
|
|
129
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "web-search-plus-plugin",
|
|
3
|
+
"name": "Web Search Plus",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"description": "Multi-provider web search (Serper/Tavily/Exa) as native tool",
|
|
6
|
+
"configSchema": {
|
|
7
|
+
"type": "object",
|
|
8
|
+
"additionalProperties": false,
|
|
9
|
+
"properties": {}
|
|
10
|
+
}
|
|
11
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "web-search-plus-plugin",
|
|
3
|
+
"version": "1.1.4",
|
|
4
|
+
"description": "OpenClaw plugin: multi-provider web search (Serper/Google, Tavily, Exa, Perplexity) as native tool",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "index.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"index.ts",
|
|
9
|
+
"openclaw.plugin.json",
|
|
10
|
+
"scripts/",
|
|
11
|
+
".env.template",
|
|
12
|
+
"README.md",
|
|
13
|
+
"LICENSE"
|
|
14
|
+
],
|
|
15
|
+
"keywords": ["openclaw", "plugin", "search", "serper", "tavily", "exa", "perplexity", "web-search"],
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "https://github.com/robbyczgw-cla/web-search-plus-plugin"
|
|
19
|
+
},
|
|
20
|
+
"author": "robbyczgw-cla",
|
|
21
|
+
"license": "MIT"
|
|
22
|
+
}
|