robot-resources 1.7.6 → 1.7.8

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/README.md CHANGED
@@ -2,103 +2,88 @@
2
2
 
3
3
  > Tools for AI agents. Humans have HR. Agents have RR.
4
4
 
5
- Robot Resources builds tools for AI agents and any software that makes LLM API calls — chatbots, RAG pipelines, AI-powered apps, internal tools. Two products today: **Router** (intelligent model routing, 60-90% cost savings) and **Scraper** (token compression for web content, median 91% token reduction). Both run locally, both free.
5
+ Two products for any software that makes LLM API calls — chatbots, RAG pipelines, AI-powered apps, agent runtimes. Both run locally, both free.
6
6
 
7
- ## Quick Start
7
+ **Router** Intelligent LLM routing proxy. Classifies each prompt by task type, routes to the cheapest model that qualifies. 60-90% cost savings with zero quality loss.
8
+
9
+ **Scraper** — Token compression for web content. Fetches any URL, strips noise, returns clean markdown. Median 91% token reduction.
10
+
11
+ ## Install
8
12
 
9
13
  ```bash
10
14
  npx robot-resources
11
15
  ```
12
16
 
13
- One command: authenticates via GitHub OAuth, installs Router as an always-on service, registers Scraper as the default web compression tool, and configures your agent automatically.
17
+ One command: installs Router as an always-on system service, registers Scraper as an MCP tool, configures your agent automatically.
14
18
 
15
- ## Products
19
+ ## What It Does
16
20
 
17
- ### Router
21
+ 1. **Installs Router** — Python venv + system service on localhost:3838
22
+ 2. **Registers Scraper** — MCP tool `scraper_compress_url(url)` in your agent
23
+ 3. **Configures OpenClaw** — Plugin auto-installed if OpenClaw is detected
24
+ 4. **Provisions API key** — For telemetry and dashboard access
25
+ 5. **Health check** — Verifies everything is running after install
18
26
 
19
- Intelligent LLM routing proxy. Classifies each prompt by task type, filters by model capability, routes to the cheapest model that qualifies.
27
+ ## Router
20
28
 
21
- - Hybrid classification: keyword detection (~5ms) + LLM fallback for ambiguous prompts (~200ms)
22
- - Dynamic thresholds: simple tasks open cheap models (0.60), complex tasks require top models (0.85)
23
- - 11 models across OpenAI, Anthropic, and Google — routes within your available providers
24
- - 60-90% cost savings with zero quality loss
25
- - OpenAI-compatible API on localhost:3838 — change your base_url and you're done
26
- - OpenClaw compatible — plugin auto-installs, works with API keys and subscriptions
29
+ Transparent proxy on localhost:3838. Your LLM calls pass through, Router selects the cheapest capable model:
27
30
 
28
- ```bash
29
- npx @robot-resources/router
30
- ```
31
+ - Hybrid classification: keyword detection (~5ms) + LLM fallback (~200ms)
32
+ - Dynamic thresholds: simple tasks → cheap models, complex tasks → top models
33
+ - Models across OpenAI, Anthropic, Google — routes within your available providers
34
+ - Your API keys pass through via headers — never stored by Router
35
+ - OpenAI-compatible API — change `base_url` to `http://localhost:3838`
31
36
 
32
- ### Scraper
37
+ ## Scraper
33
38
 
34
- Token compression for web content. Fetches any URL, strips noise, returns clean markdown with token count.
39
+ Available as MCP tool after install:
35
40
 
36
41
  - Mozilla Readability extraction (0.97 F1 accuracy)
37
- - Content-aware token estimation (±15% of actual BPE)
42
+ - Content-aware token estimation
38
43
  - 3-tier fetch: fast, stealth (TLS fingerprint), render (headless browser)
39
44
  - Multi-page BFS crawl with robots.txt compliance
40
45
  - Median 91% token reduction per page
41
46
 
42
- Installed automatically via `npx robot-resources`. Available as MCP tool `scraper_compress_url(url)` in your agent.
47
+ ## Agent Compatibility
43
48
 
44
- ### Dashboard
49
+ | Agent | Integration | Status |
50
+ |-------|-------------|--------|
51
+ | **OpenClaw** | Plugin (auto-install) | Verified |
52
+ | **Claude Code** | MCP server | Verified |
53
+ | **Any OpenAI client** | HTTP proxy (localhost:3838) | Compatible |
54
+ | **Cursor** | MCP server | Compatible |
55
+ | **Windsurf** | MCP server | Compatible |
45
56
 
46
- Usage dashboard with real-time telemetry. Auth via GitHub OAuth, KPI panels, routing stats, cost savings tracking. Mobile-responsive.
47
-
48
- ### MCP Servers
49
-
50
- Both products include MCP servers for AI agent integration:
57
+ ## MCP Servers
51
58
 
52
59
  ```bash
53
60
  npx -y @robot-resources/router-mcp # Router stats + config
54
61
  npx -y @robot-resources/scraper-mcp # Scraper compression
55
62
  ```
56
63
 
57
- ## Pricing
58
-
59
- Free. Unlimited. No tiers. Both tools run locally — you pay your AI providers directly. No markup, no rate limits, no quotas. Your API keys never leave your machine.
64
+ ## Dashboard
60
65
 
61
- ## Monorepo Structure
66
+ Usage dashboard at https://robotresources.ai/dashboard — real-time telemetry, cost savings, routing stats. Auth via GitHub OAuth.
62
67
 
63
- ```
64
- robot-resources/
65
- ├── router/ # LLM routing proxy (Python + TypeScript MCP)
66
- ├── scraper/ # Token compression (TypeScript)
67
- ├── web/ # Landing page + dashboard (React/Vite)
68
- ├── platform/ # Backend API — auth, telemetry (Hono/Cloudflare Workers)
69
- ├── packages/ # Unified CLI installer (npx robot-resources)
70
- ├── skills/ # Agent skills (ClawHub)
71
- ├── _orchestrator/ # Business coordination
72
- └── _brand/ # Brand assets and design system
73
- ```
74
-
75
- ## Development
76
-
77
- Each product has its own setup:
68
+ ## Pricing
78
69
 
79
- - [Router](./router/README.md)
80
- - [Scraper](./scraper/packages/scraper/README.md)
81
- - [Platform](./platform/README.md)
82
- - [CLI](./packages/cli/README.md)
70
+ Free. Unlimited. No tiers. Your API keys never leave your machine.
83
71
 
84
- ## CI/CD
72
+ ## Telemetry
85
73
 
86
- Unified pipeline on push/PR to main:
74
+ Anonymous usage telemetry (model selection, cost savings) to improve the product. No personal data, no request content, no API keys.
87
75
 
88
- - **Router**: ruff, mypy, pytest
89
- - **Scraper**: tsc, vitest
90
- - **Web**: tsc, eslint
91
- - **Publish**: 7 npm packages via OIDC (`router`, `router-mcp`, `scraper`, `scraper-mcp`, `scraper-tracking`, `cli-core`, `cli`)
76
+ Opt out: `export RR_TELEMETRY=off`
92
77
 
93
78
  ## Links
94
79
 
95
80
  - Website: https://robotresources.ai
96
- - GitHub: https://github.com/robot-resources
97
- - npm: `npx robot-resources`
98
- - Twitter/X: https://x.com/robotresources
81
+ - Dashboard: https://robotresources.ai/dashboard
82
+ - Agent docs: https://robotresources.ai/llms.txt
83
+ - npm: https://www.npmjs.com/package/robot-resources
84
+ - GitHub: https://github.com/robot-resources/packages
99
85
  - Discord: https://robotresources.ai/discord
100
86
  - Contact: agent@robotresources.ai
101
- - Agent docs: https://robotresources.ai/llms.txt
102
87
 
103
88
  ## License
104
89
 
@@ -1,3 +1,4 @@
1
+ import { spawn } from 'node:child_process';
1
2
  import { createRequire } from 'node:module';
2
3
  import { readFileSync, writeFileSync, copyFileSync, mkdirSync, existsSync } from 'node:fs';
3
4
  import { homedir } from 'node:os';
@@ -220,5 +221,49 @@ export function configureToolRouting() {
220
221
  return results;
221
222
  }
222
223
 
224
+ /**
225
+ * Run a command with a heartbeat to keep agent sessions alive.
226
+ * OC kills processes after 5s of no output (noOutputTimeoutMs = 5000).
227
+ * Prints immediately, then every 4s (safely under the 5s threshold).
228
+ */
229
+ function spawnWithHeartbeat(cmd, args, { label, timeout = 30_000 } = {}) {
230
+ return new Promise((resolve, reject) => {
231
+ const proc = spawn(cmd, args, {
232
+ stdio: ['ignore', 'pipe', 'pipe'],
233
+ timeout,
234
+ });
235
+
236
+ process.stdout.write(` ${label}...\n`);
237
+ let seconds = 0;
238
+ const heartbeat = setInterval(() => {
239
+ seconds += 4;
240
+ process.stdout.write(` ${label}... ${seconds}s\n`);
241
+ }, 4000);
242
+
243
+ proc.on('close', (code) => {
244
+ clearInterval(heartbeat);
245
+ if (code === 0) resolve();
246
+ else reject(new Error(`${cmd} ${args.join(' ')} exited with code ${code}`));
247
+ });
248
+
249
+ proc.on('error', (err) => {
250
+ clearInterval(heartbeat);
251
+ reject(err);
252
+ });
253
+ });
254
+ }
255
+
256
+ /**
257
+ * Restart the OpenClaw gateway so it picks up new plugin + config.
258
+ * Uses heartbeat to keep OC sessions alive during the restart.
259
+ * Telegram survives this restart — tested end-to-end (PR #89).
260
+ */
261
+ async function restartOpenClawGateway() {
262
+ await spawnWithHeartbeat('openclaw', ['gateway', 'restart'], {
263
+ label: 'Restarting gateway',
264
+ timeout: 15_000,
265
+ });
266
+ }
267
+
223
268
  // Exported for testing and direct use
224
- export { stripJson5, configureOpenClaw, registerScraperMcp };
269
+ export { stripJson5, configureOpenClaw, registerScraperMcp, restartOpenClawGateway };
package/lib/wizard.js CHANGED
@@ -2,11 +2,11 @@ import { readFileSync, writeFileSync, mkdirSync } from 'node:fs';
2
2
  import { join } from 'node:path';
3
3
  import { homedir, hostname } from 'node:os';
4
4
  import { readConfig, writeConfig } from '@robot-resources/cli-core/config.mjs';
5
- import { findPython, isPortAvailable, isHeadless } from './detect.js';
5
+ import { findPython, isPortAvailable, isHeadless, isOpenClawInstalled } from './detect.js';
6
6
  import { getOrCreateMachineId } from './machine-id.js';
7
7
  import { setupRouter, isRouterInstalled, getVenvPythonPath } from './python-bridge.js';
8
8
  import { installService, isServiceRunning, isServiceInstalled } from './service.js';
9
- import { configureToolRouting, registerScraperMcp } from './tool-config.js';
9
+ import { configureToolRouting, registerScraperMcp, restartOpenClawGateway } from './tool-config.js';
10
10
  import { checkHealth } from './health-report.js';
11
11
  import { header, step, success, warn, error, info, blank, summary } from './ui.js';
12
12
  /**
@@ -382,11 +382,19 @@ export async function runWizard({ nonInteractive = false } = {}) {
382
382
  }
383
383
  }
384
384
 
385
- // ── Gateway restart: NOT needed ─────────────────────────────────────────
385
+ // ── Best-effort: Single gateway restart (MUST be last) ─────────────────
386
386
  //
387
- // OC has a built-in config watcher. When openclaw.json changes (plugin
388
- // entry, scraper MCP, plugins.allow), the gateway detects the change,
389
- // waits for active operations to complete, then restarts gracefully.
390
- // No manual restart needed — the wizard just writes config and OC
391
- // handles the rest.
387
+ // Everything is already installed, configured, and reported above.
388
+ // The restart loads the plugin + scraper MCP into the running gateway.
389
+ // Telegram survives this restart. If the session dies here, the agent
390
+ // picks up on the next message with all tools loaded.
391
+
392
+ if (isOpenClawInstalled() && (results.tools?.some(r => r.action === 'installed') || scraperRegistered)) {
393
+ try {
394
+ await restartOpenClawGateway();
395
+ success('OpenClaw gateway restarted');
396
+ } catch {
397
+ // Best-effort — gateway picks up changes on next restart
398
+ }
399
+ }
392
400
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "robot-resources",
3
- "version": "1.7.6",
3
+ "version": "1.7.8",
4
4
  "description": "Robot Resources — AI agent tools. One command to install everything.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -19,7 +19,7 @@
19
19
  "dependencies": {
20
20
  "@robot-resources/cli-core": "*",
21
21
  "@robot-resources/openclaw-plugin": "*",
22
- "@robot-resources/scraper": "^0.3.0"
22
+ "@robot-resources/scraper": "^0.3.1"
23
23
  },
24
24
  "devDependencies": {
25
25
  "vitest": "^1.2.0"
@@ -41,7 +41,7 @@
41
41
  "author": "Robot Resources Team",
42
42
  "repository": {
43
43
  "type": "git",
44
- "url": "git+https://github.com/robot-resources/robot-resources.git",
44
+ "url": "git+https://github.com/robot-resources/packages.git",
45
45
  "directory": "packages/cli"
46
46
  },
47
47
  "homepage": "https://robotresources.ai",