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 +8 -0
- package/lib/tool-config.js +35 -15
- package/package.json +1 -1
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
|
*/
|
package/lib/tool-config.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
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
|
-
*
|
|
22
|
+
* Configure OpenClaw to route through Robot Resources Router.
|
|
22
23
|
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
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
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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
|
/**
|