robot-resources 1.2.5 → 1.2.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/lib/detect.js CHANGED
@@ -80,6 +80,14 @@ export function isOpenClawInstalled() {
80
80
  return existsSync(join(home, '.openclaw')) || existsSync(join(home, 'openclaw.json'));
81
81
  }
82
82
 
83
+ /**
84
+ * Check if the Robot Resources OpenClaw plugin is already installed.
85
+ */
86
+ export function isOpenClawPluginInstalled() {
87
+ const home = homedir();
88
+ return existsSync(join(home, '.openclaw', 'extensions', 'robot-resources-router'));
89
+ }
90
+
83
91
  /**
84
92
  * Check if the router service is already registered.
85
93
  */
@@ -1,4 +1,5 @@
1
- import { isOpenClawInstalled } from './detect.js';
1
+ import { execFileSync } from 'node:child_process';
2
+ import { isOpenClawInstalled, isOpenClawPluginInstalled } from './detect.js';
2
3
 
3
4
  /**
4
5
  * Strip JSON5 features (comments + trailing commas) to produce valid JSON.
@@ -18,23 +19,42 @@ function stripJson5(text) {
18
19
  }
19
20
 
20
21
  /**
21
- * Detect OpenClaw and report status.
22
+ * Configure OpenClaw to route through Robot Resources Router.
22
23
  *
23
- * OpenClaw integration is pending — requires a plugin hook
24
- * (openclaw/openclaw#9402) that hasn't shipped yet. Until then,
25
- * we detect OpenClaw and return instructions instead of writing
26
- * config that gets clobbered on gateway restart.
24
+ * Installs the @robot-resources/openclaw-plugin via OpenClaw's
25
+ * native plugin system. The plugin uses before_model_resolve to
26
+ * override the provider survives gateway restarts because it
27
+ * lives in ~/.openclaw/extensions/, not in openclaw.json.
27
28
  */
28
29
  function configureOpenClaw() {
29
- return {
30
- name: 'OpenClaw',
31
- action: 'instructions',
32
- instructions: [
33
- 'OpenClaw detected — Router integration coming soon.',
34
- 'Track progress: https://github.com/openclaw/openclaw/issues/9402',
35
- 'Router works now with Claude Desktop, Cursor, and any OpenAI SDK app.',
36
- ],
37
- };
30
+ if (isOpenClawPluginInstalled()) {
31
+ return {
32
+ name: 'OpenClaw',
33
+ action: 'already_configured',
34
+ };
35
+ }
36
+
37
+ try {
38
+ execFileSync('openclaw', ['plugins', 'install', '@robot-resources/openclaw-plugin'], {
39
+ stdio: 'ignore',
40
+ timeout: 30_000,
41
+ });
42
+ return {
43
+ name: 'OpenClaw',
44
+ action: 'installed',
45
+ };
46
+ } catch {
47
+ // Plugin install failed — fall back to instructions
48
+ return {
49
+ name: 'OpenClaw',
50
+ action: 'instructions',
51
+ instructions: [
52
+ 'Could not auto-install plugin. Install manually:',
53
+ ' openclaw plugins install @robot-resources/openclaw-plugin',
54
+ 'Docs: https://github.com/robot-resources/robot-resources',
55
+ ],
56
+ };
57
+ }
38
58
  }
39
59
 
40
60
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "robot-resources",
3
- "version": "1.2.5",
3
+ "version": "1.2.6",
4
4
  "description": "Robot Resources — AI agent runtime tools. One command to install everything.",
5
5
  "type": "module",
6
6
  "bin": {