@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 CHANGED
@@ -1,18 +1,15 @@
1
1
  /**
2
- * Robot Resources Router plugin for OpenClaw.
2
+ * Robot Resources plugin for OpenClaw.
3
3
  *
4
- * Two routing modes depending on auth:
4
+ * Two integrations:
5
5
  *
6
- * 1. API-key users: Registers "robot-resources" as a provider that proxies
7
- * requests through the Router at localhost:3838. Works end-to-end.
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. Subscription (OAuth) users: Uses `message_received` hook to ask the
10
- * Router's /v1/route endpoint for the cheapest model, then logs the
11
- * recommendation. Full modelOverride requires a `before_model_select`
12
- * hook that the OpenClaw plugin SDK does not yet provide.
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 Router',
86
- description: 'Cost-optimized AI model routing selects the cheapest capable model per request',
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',
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "id": "openclaw-plugin",
3
- "name": "Robot Resources Router",
4
- "description": "Cost-optimized AI model routing selects the cheapest capable model per request",
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",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@robot-resources/openclaw-plugin",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "Robot Resources Router plugin for OpenClaw — cost-optimized AI model routing",
5
5
  "type": "module",
6
6
  "main": "index.js",