clawmatrix 0.1.2 → 0.1.3
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/llms.txt +1 -1
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
- package/src/cluster-service.ts +5 -4
- package/src/handoff.ts +4 -4
- package/src/model-proxy.ts +9 -4
- package/src/tool-proxy.ts +2 -4
package/llms.txt
CHANGED
|
@@ -120,7 +120,7 @@ To use cluster models, set your agent's model to a cluster-proxied model:
|
|
|
120
120
|
| Field | Type | Default | Description |
|
|
121
121
|
|-------|------|---------|-------------|
|
|
122
122
|
| `enabled` | boolean | `false` | Allow remote tool execution on this node |
|
|
123
|
-
| `allow` | array | `[]` | Allowed OpenClaw tool names
|
|
123
|
+
| `allow` | array | `[]` | Allowed OpenClaw tool names. `["*"]` or `[]` = all allowed |
|
|
124
124
|
| `deny` | array | `[]` | Denied OpenClaw tool names (takes precedence over allow) |
|
|
125
125
|
| `maxOutputBytes` | number | `1048576` | Max output size per tool response (1 MB) |
|
|
126
126
|
|
package/openclaw.plugin.json
CHANGED
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"type": "array",
|
|
60
60
|
"items": { "type": "string" },
|
|
61
61
|
"default": [],
|
|
62
|
-
"description": "Allowed OpenClaw tool names
|
|
62
|
+
"description": "Allowed OpenClaw tool names. Use [\"*\"] for all. Empty or [\"*\"] = all allowed."
|
|
63
63
|
},
|
|
64
64
|
"deny": {
|
|
65
65
|
"type": "array",
|
package/package.json
CHANGED
package/src/cluster-service.ts
CHANGED
|
@@ -46,10 +46,11 @@ export class ClusterRuntime {
|
|
|
46
46
|
constructor(config: ClawMatrixConfig, logger: PluginLogger, openclawConfig: OpenClawConfig) {
|
|
47
47
|
this.config = config;
|
|
48
48
|
this.logger = logger;
|
|
49
|
+
const gatewayInfo = resolveGatewayInfo(openclawConfig);
|
|
49
50
|
this.peerManager = new PeerManager(config);
|
|
50
51
|
this.handoffManager = new HandoffManager(config, this.peerManager);
|
|
51
|
-
this.modelProxy = new ModelProxy(config, this.peerManager);
|
|
52
|
-
this.toolProxy = new ToolProxy(config, this.peerManager,
|
|
52
|
+
this.modelProxy = new ModelProxy(config, this.peerManager, gatewayInfo);
|
|
53
|
+
this.toolProxy = new ToolProxy(config, this.peerManager, gatewayInfo);
|
|
53
54
|
}
|
|
54
55
|
|
|
55
56
|
start() {
|
|
@@ -137,8 +138,8 @@ export class ClusterRuntime {
|
|
|
137
138
|
return;
|
|
138
139
|
}
|
|
139
140
|
|
|
140
|
-
// Fire-and-forget: inject message via openclaw agent
|
|
141
|
-
spawnProcess(["openclaw", "agent", "--message", message], {
|
|
141
|
+
// Fire-and-forget: inject message via openclaw agent CLI
|
|
142
|
+
spawnProcess(["openclaw", "agent", "--agent", agent.id, "--message", message], {
|
|
142
143
|
stdout: "ignore",
|
|
143
144
|
stderr: "ignore",
|
|
144
145
|
});
|
package/src/handoff.ts
CHANGED
|
@@ -148,10 +148,10 @@ export class HandoffManager {
|
|
|
148
148
|
? `${payload.task}\n\nContext:\n${payload.context}`
|
|
149
149
|
: payload.task;
|
|
150
150
|
|
|
151
|
-
const proc = spawnProcess(
|
|
152
|
-
|
|
153
|
-
stderr: "pipe",
|
|
154
|
-
|
|
151
|
+
const proc = spawnProcess(
|
|
152
|
+
["openclaw", "agent", "--agent", agent.id, "--message", message],
|
|
153
|
+
{ stdout: "pipe", stderr: "pipe" },
|
|
154
|
+
);
|
|
155
155
|
|
|
156
156
|
const stdout = proc.stdout ? await new Response(proc.stdout).text() : "";
|
|
157
157
|
const exitCode = await proc.exited;
|
package/src/model-proxy.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createServer, type Server } from "node:http";
|
|
2
2
|
import type { PeerManager } from "./peer-manager.ts";
|
|
3
3
|
import type { ClawMatrixConfig } from "./config.ts";
|
|
4
|
+
import type { GatewayInfo } from "./tool-proxy.ts";
|
|
4
5
|
import type {
|
|
5
6
|
ModelRequest,
|
|
6
7
|
ModelResponse,
|
|
@@ -23,10 +24,12 @@ export class ModelProxy {
|
|
|
23
24
|
private peerManager: PeerManager;
|
|
24
25
|
private pending = new Map<string, PendingModelReq>();
|
|
25
26
|
private httpServer: Server | null = null;
|
|
27
|
+
private gatewayInfo: GatewayInfo;
|
|
26
28
|
|
|
27
|
-
constructor(config: ClawMatrixConfig, peerManager: PeerManager) {
|
|
29
|
+
constructor(config: ClawMatrixConfig, peerManager: PeerManager, gatewayInfo: GatewayInfo) {
|
|
28
30
|
this.config = config;
|
|
29
31
|
this.peerManager = peerManager;
|
|
32
|
+
this.gatewayInfo = gatewayInfo;
|
|
30
33
|
}
|
|
31
34
|
|
|
32
35
|
/** Start the local HTTP proxy server for OpenAI-compatible requests. */
|
|
@@ -372,11 +375,13 @@ export class ModelProxy {
|
|
|
372
375
|
}
|
|
373
376
|
|
|
374
377
|
try {
|
|
375
|
-
const
|
|
378
|
+
const { port, authHeader } = this.gatewayInfo;
|
|
379
|
+
const headers: Record<string, string> = { "Content-Type": "application/json" };
|
|
380
|
+
if (authHeader) headers["Authorization"] = authHeader;
|
|
376
381
|
|
|
377
|
-
const response = await fetch(
|
|
382
|
+
const response = await fetch(`http://127.0.0.1:${port}/v1/chat/completions`, {
|
|
378
383
|
method: "POST",
|
|
379
|
-
headers
|
|
384
|
+
headers,
|
|
380
385
|
body: JSON.stringify({
|
|
381
386
|
model: `${model.provider}/${model.id}`,
|
|
382
387
|
messages: payload.messages,
|
package/src/tool-proxy.ts
CHANGED
|
@@ -182,10 +182,8 @@ export class ToolProxy {
|
|
|
182
182
|
// ── Security ───────────────────────────────────────────────────
|
|
183
183
|
private isToolAllowed(tool: string, tpConfig: ToolProxyConfig): boolean {
|
|
184
184
|
if (tpConfig.deny.includes(tool)) return false;
|
|
185
|
-
if (tpConfig.allow.length
|
|
186
|
-
|
|
187
|
-
}
|
|
188
|
-
return true;
|
|
185
|
+
if (tpConfig.allow.length === 0 || tpConfig.allow.includes("*")) return true;
|
|
186
|
+
return tpConfig.allow.includes(tool);
|
|
189
187
|
}
|
|
190
188
|
|
|
191
189
|
destroy() {
|