@robot-resources/openclaw-plugin 0.1.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 ADDED
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Robot Resources Router plugin for OpenClaw.
3
+ *
4
+ * Routes requests through the local Robot Resources Router for
5
+ * cost-optimized model selection. The Router picks the cheapest
6
+ * capable model per request via keyword/LLM confidence branching.
7
+ *
8
+ * Architecture:
9
+ * - Plugin registers "robot-resources" as a provider (via manifest)
10
+ * - before_model_resolve hook overrides provider to "robot-resources"
11
+ * - OpenClaw sends requests to Router at localhost:3838
12
+ * - Router selects optimal model, forwards to upstream provider
13
+ * - Response flows back through OpenClaw transparently
14
+ *
15
+ * The plugin survives gateway restarts because it lives in
16
+ * ~/.openclaw/extensions/, not in openclaw.json.
17
+ *
18
+ * Install: openclaw plugins install @robot-resources/openclaw-plugin
19
+ * Requires: Robot Resources Router running (npx robot-resources)
20
+ */
21
+
22
+ const DEFAULT_ROUTER_URL = 'http://localhost:3838';
23
+
24
+ export default function register(api) {
25
+ const pluginConfig = api.config || {};
26
+ const routerUrl = pluginConfig.routerUrl || DEFAULT_ROUTER_URL;
27
+
28
+ // Register provider with Router's baseUrl
29
+ if (typeof api.registerProvider === 'function') {
30
+ api.registerProvider('robot-resources', {
31
+ baseUrl: routerUrl,
32
+ api: 'anthropic-messages',
33
+ });
34
+ }
35
+
36
+ // Override model resolution to route through Robot Resources
37
+ api.on('before_model_resolve', (_event, _ctx) => {
38
+ return {
39
+ providerOverride: 'robot-resources',
40
+ };
41
+ }, { priority: 10 });
42
+ }
43
+
44
+ export { DEFAULT_ROUTER_URL };
@@ -0,0 +1,17 @@
1
+ {
2
+ "id": "robot-resources-router",
3
+ "name": "Robot Resources Router",
4
+ "description": "Cost-optimized AI model routing — selects the cheapest capable model per request",
5
+ "providers": ["robot-resources"],
6
+ "configSchema": {
7
+ "type": "object",
8
+ "properties": {
9
+ "routerUrl": {
10
+ "type": "string",
11
+ "default": "http://localhost:3838",
12
+ "description": "URL of the Robot Resources Router proxy"
13
+ }
14
+ },
15
+ "additionalProperties": false
16
+ }
17
+ }
package/package.json ADDED
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "@robot-resources/openclaw-plugin",
3
+ "version": "0.1.0",
4
+ "description": "Robot Resources Router plugin for OpenClaw — cost-optimized AI model routing",
5
+ "type": "module",
6
+ "main": "index.js",
7
+ "scripts": {
8
+ "test": "vitest",
9
+ "test:run": "vitest run"
10
+ },
11
+ "files": [
12
+ "index.js",
13
+ "openclaw.plugin.json"
14
+ ],
15
+ "keywords": [
16
+ "openclaw",
17
+ "plugin",
18
+ "robot-resources",
19
+ "llm",
20
+ "routing",
21
+ "ai",
22
+ "cost-optimization"
23
+ ],
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "https://github.com/robot-resources/robot-resources.git",
27
+ "directory": "packages/openclaw-plugin"
28
+ },
29
+ "license": "MIT",
30
+ "devDependencies": {
31
+ "vitest": "^3.0.0"
32
+ }
33
+ }