@robot-resources/openclaw-plugin 0.3.0 → 0.4.0
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/index.js +31 -13
- package/openclaw.plugin.json +2 -2
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Robot Resources
|
|
2
|
+
* Robot Resources plugin for OpenClaw.
|
|
3
3
|
*
|
|
4
|
-
* Two
|
|
4
|
+
* Two integrations:
|
|
5
5
|
*
|
|
6
|
-
* 1.
|
|
7
|
-
*
|
|
6
|
+
* 1. Model routing (before_model_resolve): Routes each LLM call through
|
|
7
|
+
* the Router at localhost:3838 to select the cheapest capable model.
|
|
8
8
|
*
|
|
9
|
-
* 2.
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* LIMITATION: `message_received` only fires for channel messages
|
|
15
|
-
* (Telegram, Slack, etc.), NOT for `openclaw agent --local` CLI mode.
|
|
9
|
+
* 2. Web fetch override (before_tool_call): Intercepts web_fetch calls
|
|
10
|
+
* and routes them through the Scraper MCP for token-compressed output.
|
|
11
|
+
* The scraper-mcp must be registered in openclaw.json (done by the
|
|
12
|
+
* unified installer: npx robot-resources).
|
|
16
13
|
*
|
|
17
14
|
* Install: openclaw plugins install @robot-resources/openclaw-plugin
|
|
18
15
|
* Requires: Robot Resources Router running (npx robot-resources)
|
|
@@ -82,8 +79,8 @@ function buildModelDefinition(modelId) {
|
|
|
82
79
|
|
|
83
80
|
const robotResourcesPlugin = {
|
|
84
81
|
id: 'openclaw-plugin',
|
|
85
|
-
name: 'Robot Resources
|
|
86
|
-
description: 'Cost-optimized
|
|
82
|
+
name: 'Robot Resources',
|
|
83
|
+
description: 'Cost-optimized model routing + token-compressed web fetching',
|
|
87
84
|
|
|
88
85
|
register(api) {
|
|
89
86
|
const pluginConfig = api.pluginConfig || {};
|
|
@@ -127,6 +124,27 @@ const robotResourcesPlugin = {
|
|
|
127
124
|
return { content: event.content + tag };
|
|
128
125
|
}, { priority: -10 });
|
|
129
126
|
|
|
127
|
+
// ── Scraper override: intercept web_fetch → use scraper_compress_url ──
|
|
128
|
+
// When the agent calls web_fetch, redirect to scraper_compress_url for
|
|
129
|
+
// token-compressed output. Falls through silently if scraper-mcp is not
|
|
130
|
+
// registered (the tool just won't exist).
|
|
131
|
+
api.on('before_tool_call', async (event, _ctx) => {
|
|
132
|
+
if (event.tool !== 'web_fetch') return;
|
|
133
|
+
|
|
134
|
+
const url = event.params?.url;
|
|
135
|
+
if (!url) return;
|
|
136
|
+
|
|
137
|
+
api.logger.info(`[robot-resources] Redirecting web_fetch → scraper_compress_url: ${url}`);
|
|
138
|
+
|
|
139
|
+
return {
|
|
140
|
+
toolOverride: 'scraper_compress_url',
|
|
141
|
+
paramsOverride: {
|
|
142
|
+
url,
|
|
143
|
+
mode: 'auto',
|
|
144
|
+
},
|
|
145
|
+
};
|
|
146
|
+
}, { priority: 10 });
|
|
147
|
+
|
|
130
148
|
// ── API-key mode: register provider for HTTP proxy ──
|
|
131
149
|
api.registerProvider({
|
|
132
150
|
id: 'robot-resources',
|
package/openclaw.plugin.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "openclaw-plugin",
|
|
3
|
-
"name": "Robot Resources
|
|
4
|
-
"description": "Cost-optimized
|
|
3
|
+
"name": "Robot Resources",
|
|
4
|
+
"description": "Cost-optimized model routing + token-compressed web fetching",
|
|
5
5
|
"providers": ["robot-resources"],
|
|
6
6
|
"configSchema": {
|
|
7
7
|
"type": "object",
|