@rethinkingstudio/clawpilot 1.0.8 → 1.0.9
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/dist/commands/local-handlers.d.ts +12 -0
- package/dist/commands/local-handlers.js +62 -0
- package/dist/commands/local-handlers.js.map +1 -0
- package/dist/index.js +1 -1
- package/dist/relay/relay-manager.js +14 -0
- package/dist/relay/relay-manager.js.map +1 -1
- package/package.json +1 -1
- package/src/commands/local-handlers.ts +71 -0
- package/src/index.ts +1 -1
- package/src/relay/relay-manager.ts +15 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type LocalResult = {
|
|
2
|
+
ok: true;
|
|
3
|
+
payload?: unknown;
|
|
4
|
+
} | {
|
|
5
|
+
ok: false;
|
|
6
|
+
error: string;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Handles clawpilot-specific commands locally, without forwarding to the gateway.
|
|
10
|
+
* Returns null if the method is not a local command (caller should forward to gateway).
|
|
11
|
+
*/
|
|
12
|
+
export declare function handleLocalCommand(method: string): LocalResult | null;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { readdirSync, statSync, copyFileSync, existsSync } from "fs";
|
|
2
|
+
import { join } from "path";
|
|
3
|
+
import { homedir } from "os";
|
|
4
|
+
import { execSync } from "child_process";
|
|
5
|
+
const OPENCLAW_DIR = join(homedir(), ".openclaw");
|
|
6
|
+
const OPENCLAW_CONFIG = join(OPENCLAW_DIR, "openclaw.json");
|
|
7
|
+
/**
|
|
8
|
+
* Handles clawpilot-specific commands locally, without forwarding to the gateway.
|
|
9
|
+
* Returns null if the method is not a local command (caller should forward to gateway).
|
|
10
|
+
*/
|
|
11
|
+
export function handleLocalCommand(method) {
|
|
12
|
+
switch (method) {
|
|
13
|
+
case "clawpilot.restore.config":
|
|
14
|
+
return restoreConfig();
|
|
15
|
+
case "clawpilot.watchskill":
|
|
16
|
+
return watchSkill();
|
|
17
|
+
default:
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Finds the most recent openclaw.json.bak* file and copies it over openclaw.json.
|
|
23
|
+
* The backup files are kept intact so they can be used again if needed.
|
|
24
|
+
*/
|
|
25
|
+
function restoreConfig() {
|
|
26
|
+
try {
|
|
27
|
+
if (!existsSync(OPENCLAW_DIR)) {
|
|
28
|
+
return { ok: false, error: `openclaw config dir not found: ${OPENCLAW_DIR}` };
|
|
29
|
+
}
|
|
30
|
+
const bakFiles = readdirSync(OPENCLAW_DIR)
|
|
31
|
+
.filter(name => name.startsWith("openclaw.json.bak"))
|
|
32
|
+
.map(name => {
|
|
33
|
+
const path = join(OPENCLAW_DIR, name);
|
|
34
|
+
return { name, path, mtime: statSync(path).mtimeMs };
|
|
35
|
+
})
|
|
36
|
+
.sort((a, b) => b.mtime - a.mtime);
|
|
37
|
+
if (bakFiles.length === 0) {
|
|
38
|
+
return { ok: false, error: "No backup files found in ~/.openclaw/" };
|
|
39
|
+
}
|
|
40
|
+
const latest = bakFiles[0];
|
|
41
|
+
copyFileSync(latest.path, OPENCLAW_CONFIG);
|
|
42
|
+
console.log(`[clawpilot] Config restored from ${latest.name}`);
|
|
43
|
+
return { ok: true, payload: { restoredFrom: latest.name } };
|
|
44
|
+
}
|
|
45
|
+
catch (err) {
|
|
46
|
+
return { ok: false, error: String(err) };
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Enables real-time skill file watching via openclaw CLI.
|
|
51
|
+
*/
|
|
52
|
+
function watchSkill() {
|
|
53
|
+
try {
|
|
54
|
+
execSync("openclaw config set skills.load.watch true", { stdio: "pipe" });
|
|
55
|
+
console.log("[clawpilot] skills.load.watch set to true");
|
|
56
|
+
return { ok: true, payload: { message: "skills.load.watch enabled" } };
|
|
57
|
+
}
|
|
58
|
+
catch (err) {
|
|
59
|
+
return { ok: false, error: String(err) };
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=local-handlers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local-handlers.js","sourceRoot":"","sources":["../../src/commands/local-handlers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AACrE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,MAAM,YAAY,GAAM,IAAI,CAAC,OAAO,EAAE,EAAE,WAAW,CAAC,CAAC;AACrD,MAAM,eAAe,GAAG,IAAI,CAAC,YAAY,EAAE,eAAe,CAAC,CAAC;AAM5D;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAAc;IAC/C,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,0BAA0B;YAC7B,OAAO,aAAa,EAAE,CAAC;QACzB,KAAK,sBAAsB;YACzB,OAAO,UAAU,EAAE,CAAC;QACtB;YACE,OAAO,IAAI,CAAC;IAChB,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,SAAS,aAAa;IACpB,IAAI,CAAC;QACH,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;YAC9B,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,kCAAkC,YAAY,EAAE,EAAE,CAAC;QAChF,CAAC;QAED,MAAM,QAAQ,GAAG,WAAW,CAAC,YAAY,CAAC;aACvC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,mBAAmB,CAAC,CAAC;aACpD,GAAG,CAAC,IAAI,CAAC,EAAE;YACV,MAAM,IAAI,GAAG,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;YACtC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KA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
CHANGED
|
@@ -4,7 +4,7 @@ import { pairCommand } from "./commands/pair.js";
|
|
|
4
4
|
import { runCommand } from "./commands/run.js";
|
|
5
5
|
import { installCommand, uninstallCommand, stopCommand, restartCommand, resetCommand } from "./commands/install.js";
|
|
6
6
|
import { statusCommand } from "./commands/status.js";
|
|
7
|
-
const version = "1.0.
|
|
7
|
+
const version = "1.0.9";
|
|
8
8
|
const program = new Command();
|
|
9
9
|
program
|
|
10
10
|
.name("clawpilot")
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { WebSocket } from "ws";
|
|
2
2
|
import { OpenClawGatewayClient } from "./gateway-client.js";
|
|
3
|
+
import { handleLocalCommand } from "../commands/local-handlers.js";
|
|
3
4
|
// ---------------------------------------------------------------------------
|
|
4
5
|
// Main entry point
|
|
5
6
|
// ---------------------------------------------------------------------------
|
|
@@ -64,6 +65,19 @@ export async function runRelayManager(opts) {
|
|
|
64
65
|
return;
|
|
65
66
|
const requestId = msg.id;
|
|
66
67
|
console.log(`[relay] cmd received method=${msg.method} id=${requestId ?? "(no-id)"}`);
|
|
68
|
+
// Handle clawpilot.* commands locally without forwarding to the gateway
|
|
69
|
+
const localResult = handleLocalCommand(msg.method);
|
|
70
|
+
if (localResult !== null) {
|
|
71
|
+
if (requestId) {
|
|
72
|
+
if (localResult.ok) {
|
|
73
|
+
send({ type: "res", id: requestId, ok: true, payload: localResult.payload });
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
send({ type: "res", id: requestId, ok: false, error: { message: localResult.error } });
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
67
81
|
gatewayClient
|
|
68
82
|
?.request(msg.method, msg.params)
|
|
69
83
|
.then((result) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"relay-manager.js","sourceRoot":"","sources":["../../src/relay/relay-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,IAAI,CAA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+
import { homedir } from "os";
|
|
4
|
+
import { execSync } from "child_process";
|
|
5
|
+
|
|
6
|
+
const OPENCLAW_DIR = join(homedir(), ".openclaw");
|
|
7
|
+
const OPENCLAW_CONFIG = join(OPENCLAW_DIR, "openclaw.json");
|
|
8
|
+
|
|
9
|
+
export type LocalResult =
|
|
10
|
+
| { ok: true; payload?: unknown }
|
|
11
|
+
| { ok: false; error: string };
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Handles clawpilot-specific commands locally, without forwarding to the gateway.
|
|
15
|
+
* Returns null if the method is not a local command (caller should forward to gateway).
|
|
16
|
+
*/
|
|
17
|
+
export function handleLocalCommand(method: string): LocalResult | null {
|
|
18
|
+
switch (method) {
|
|
19
|
+
case "clawpilot.restore.config":
|
|
20
|
+
return restoreConfig();
|
|
21
|
+
case "clawpilot.watchskill":
|
|
22
|
+
return watchSkill();
|
|
23
|
+
default:
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Finds the most recent openclaw.json.bak* file and copies it over openclaw.json.
|
|
30
|
+
* The backup files are kept intact so they can be used again if needed.
|
|
31
|
+
*/
|
|
32
|
+
function restoreConfig(): LocalResult {
|
|
33
|
+
try {
|
|
34
|
+
if (!existsSync(OPENCLAW_DIR)) {
|
|
35
|
+
return { ok: false, error: `openclaw config dir not found: ${OPENCLAW_DIR}` };
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const bakFiles = readdirSync(OPENCLAW_DIR)
|
|
39
|
+
.filter(name => name.startsWith("openclaw.json.bak"))
|
|
40
|
+
.map(name => {
|
|
41
|
+
const path = join(OPENCLAW_DIR, name);
|
|
42
|
+
return { name, path, mtime: statSync(path).mtimeMs };
|
|
43
|
+
})
|
|
44
|
+
.sort((a, b) => b.mtime - a.mtime);
|
|
45
|
+
|
|
46
|
+
if (bakFiles.length === 0) {
|
|
47
|
+
return { ok: false, error: "No backup files found in ~/.openclaw/" };
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const latest = bakFiles[0];
|
|
51
|
+
copyFileSync(latest.path, OPENCLAW_CONFIG);
|
|
52
|
+
|
|
53
|
+
console.log(`[clawpilot] Config restored from ${latest.name}`);
|
|
54
|
+
return { ok: true, payload: { restoredFrom: latest.name } };
|
|
55
|
+
} catch (err) {
|
|
56
|
+
return { ok: false, error: String(err) };
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Enables real-time skill file watching via openclaw CLI.
|
|
62
|
+
*/
|
|
63
|
+
function watchSkill(): LocalResult {
|
|
64
|
+
try {
|
|
65
|
+
execSync("openclaw config set skills.load.watch true", { stdio: "pipe" });
|
|
66
|
+
console.log("[clawpilot] skills.load.watch set to true");
|
|
67
|
+
return { ok: true, payload: { message: "skills.load.watch enabled" } };
|
|
68
|
+
} catch (err) {
|
|
69
|
+
return { ok: false, error: String(err) };
|
|
70
|
+
}
|
|
71
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { runCommand } from "./commands/run.js";
|
|
|
5
5
|
import { installCommand, uninstallCommand, stopCommand, restartCommand, resetCommand } from "./commands/install.js";
|
|
6
6
|
import { statusCommand } from "./commands/status.js";
|
|
7
7
|
|
|
8
|
-
const version = "1.0.
|
|
8
|
+
const version = "1.0.9";
|
|
9
9
|
|
|
10
10
|
const program = new Command();
|
|
11
11
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { WebSocket } from "ws";
|
|
2
2
|
import { OpenClawGatewayClient } from "./gateway-client.js";
|
|
3
|
+
import { handleLocalCommand } from "../commands/local-handlers.js";
|
|
3
4
|
|
|
4
5
|
// ---------------------------------------------------------------------------
|
|
5
6
|
// Messages: relay client ↔ relay server
|
|
@@ -109,6 +110,20 @@ export async function runRelayManager(opts: RelayManagerOptions): Promise<boolea
|
|
|
109
110
|
|
|
110
111
|
const requestId = msg.id;
|
|
111
112
|
console.log(`[relay] cmd received method=${msg.method} id=${requestId ?? "(no-id)"}`);
|
|
113
|
+
|
|
114
|
+
// Handle clawpilot.* commands locally without forwarding to the gateway
|
|
115
|
+
const localResult = handleLocalCommand(msg.method);
|
|
116
|
+
if (localResult !== null) {
|
|
117
|
+
if (requestId) {
|
|
118
|
+
if (localResult.ok) {
|
|
119
|
+
send({ type: "res", id: requestId, ok: true, payload: localResult.payload });
|
|
120
|
+
} else {
|
|
121
|
+
send({ type: "res", id: requestId, ok: false, error: { message: localResult.error } });
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
|
|
112
127
|
gatewayClient
|
|
113
128
|
?.request(msg.method, msg.params)
|
|
114
129
|
.then((result) => {
|