@rethinkingstudio/clawpilot 1.0.12 → 1.0.13
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.
|
@@ -4,6 +4,39 @@ import { homedir } from "os";
|
|
|
4
4
|
import { execSync } from "child_process";
|
|
5
5
|
const OPENCLAW_DIR = join(homedir(), ".openclaw");
|
|
6
6
|
const OPENCLAW_CONFIG = join(OPENCLAW_DIR, "openclaw.json");
|
|
7
|
+
// ---------------------------------------------------------------------------
|
|
8
|
+
// Resolve the openclaw binary path once at startup.
|
|
9
|
+
// launchd services run with a minimal PATH — we try login shells (zsh first,
|
|
10
|
+
// macOS default since Catalina) then fall back to common install locations.
|
|
11
|
+
// ---------------------------------------------------------------------------
|
|
12
|
+
function resolveOpenclawBin() {
|
|
13
|
+
for (const shell of ["/bin/zsh", "/bin/bash"]) {
|
|
14
|
+
try {
|
|
15
|
+
const p = execSync(`${shell} -lc 'which openclaw'`, { stdio: "pipe", timeout: 3000 })
|
|
16
|
+
.toString().trim();
|
|
17
|
+
if (p && existsSync(p)) {
|
|
18
|
+
console.log(`[clawpilot] openclaw found at ${p} (via ${shell})`);
|
|
19
|
+
return p;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
catch { /* try next */ }
|
|
23
|
+
}
|
|
24
|
+
// Common install locations as final fallback
|
|
25
|
+
for (const p of [
|
|
26
|
+
"/opt/homebrew/bin/openclaw",
|
|
27
|
+
"/usr/local/bin/openclaw",
|
|
28
|
+
join(homedir(), ".local/bin/openclaw"),
|
|
29
|
+
]) {
|
|
30
|
+
if (existsSync(p)) {
|
|
31
|
+
console.log(`[clawpilot] openclaw found at ${p} (fallback)`);
|
|
32
|
+
return p;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
console.warn("[clawpilot] could not resolve openclaw path, using bare 'openclaw'");
|
|
36
|
+
return "openclaw";
|
|
37
|
+
}
|
|
38
|
+
const OPENCLAW_BIN = resolveOpenclawBin();
|
|
39
|
+
// ---------------------------------------------------------------------------
|
|
7
40
|
/**
|
|
8
41
|
* Handles clawpilot-specific commands locally, without forwarding to the gateway.
|
|
9
42
|
* Returns null if the method is not a local command (caller should forward to gateway).
|
|
@@ -26,9 +59,27 @@ export function handleLocalCommand(method) {
|
|
|
26
59
|
return null;
|
|
27
60
|
}
|
|
28
61
|
}
|
|
62
|
+
// ---------------------------------------------------------------------------
|
|
63
|
+
// Helpers
|
|
64
|
+
// ---------------------------------------------------------------------------
|
|
65
|
+
/** Extracts combined stdout+stderr from an execSync error. */
|
|
66
|
+
function execErrorOutput(err) {
|
|
67
|
+
const e = err;
|
|
68
|
+
const out = e.stdout?.toString() ?? "";
|
|
69
|
+
const errStr = e.stderr?.toString() ?? "";
|
|
70
|
+
if (out && errStr)
|
|
71
|
+
return `${out}\n${errStr}`;
|
|
72
|
+
return out || errStr;
|
|
73
|
+
}
|
|
74
|
+
/** Run openclaw with the resolved binary path. */
|
|
75
|
+
function openclaw(args) {
|
|
76
|
+
return execSync(`"${OPENCLAW_BIN}" ${args}`, { stdio: "pipe" });
|
|
77
|
+
}
|
|
78
|
+
// ---------------------------------------------------------------------------
|
|
79
|
+
// Command implementations
|
|
80
|
+
// ---------------------------------------------------------------------------
|
|
29
81
|
/**
|
|
30
82
|
* Finds the most recent openclaw.json.bak* file and copies it over openclaw.json.
|
|
31
|
-
* The backup files are kept intact so they can be used again if needed.
|
|
32
83
|
*/
|
|
33
84
|
function restoreConfig() {
|
|
34
85
|
try {
|
|
@@ -59,7 +110,7 @@ function restoreConfig() {
|
|
|
59
110
|
*/
|
|
60
111
|
function watchSkill() {
|
|
61
112
|
try {
|
|
62
|
-
|
|
113
|
+
openclaw("config set skills.load.watch true");
|
|
63
114
|
console.log("[clawpilot] skills.load.watch set to true");
|
|
64
115
|
return { ok: true, payload: { message: "skills.load.watch enabled" } };
|
|
65
116
|
}
|
|
@@ -67,28 +118,12 @@ function watchSkill() {
|
|
|
67
118
|
return { ok: false, error: String(err) };
|
|
68
119
|
}
|
|
69
120
|
}
|
|
70
|
-
/** Extracts combined stdout+stderr from an execSync error, with a newline separator if both exist. */
|
|
71
|
-
function execErrorOutput(err) {
|
|
72
|
-
const e = err;
|
|
73
|
-
const out = e.stdout?.toString() ?? "";
|
|
74
|
-
const errStr = e.stderr?.toString() ?? "";
|
|
75
|
-
if (out && errStr)
|
|
76
|
-
return `${out}\n${errStr}`;
|
|
77
|
-
return out || errStr;
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Runs a shell command via login bash so that PATH includes homebrew / user-installed bins.
|
|
81
|
-
* The command string must not contain user-controlled input (hardcoded calls only).
|
|
82
|
-
*/
|
|
83
|
-
function loginShell(cmd) {
|
|
84
|
-
return execSync(`/bin/bash -lc '${cmd}'`, { stdio: "pipe" });
|
|
85
|
-
}
|
|
86
121
|
/**
|
|
87
122
|
* Runs openclaw doctor to check system health.
|
|
88
123
|
*/
|
|
89
124
|
function runDoctor() {
|
|
90
125
|
try {
|
|
91
|
-
const output =
|
|
126
|
+
const output = openclaw("doctor").toString();
|
|
92
127
|
console.log("[clawpilot] doctor completed");
|
|
93
128
|
return { ok: true, payload: { output } };
|
|
94
129
|
}
|
|
@@ -137,7 +172,7 @@ function readLogs() {
|
|
|
137
172
|
*/
|
|
138
173
|
function restartGateway() {
|
|
139
174
|
try {
|
|
140
|
-
const output =
|
|
175
|
+
const output = openclaw("gateway restart").toString();
|
|
141
176
|
console.log("[clawpilot] gateway restarted");
|
|
142
177
|
return { ok: true, payload: { output: output || "Gateway restarted successfully." } };
|
|
143
178
|
}
|
|
@@ -153,7 +188,7 @@ function restartGateway() {
|
|
|
153
188
|
*/
|
|
154
189
|
function updateOpenclaw() {
|
|
155
190
|
try {
|
|
156
|
-
const output =
|
|
191
|
+
const output = openclaw("update").toString();
|
|
157
192
|
console.log("[clawpilot] openclaw updated");
|
|
158
193
|
return { ok: true, payload: { output: output || "openclaw updated successfully." } };
|
|
159
194
|
}
|
|
@@ -1 +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,YAAY,EAAE,MAAM,IAAI,CAAC;AACnF,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,KAAK,kBAAkB;YACrB,OAAO,SAAS,EAAE,CAAC;QACrB,KAAK,gBAAgB;YACnB,OAAO,QAAQ,EAAE,CAAC;QACpB,KAAK,2BAA2B;YAC9B,OAAO,cAAc,EAAE,CAAC;QAC1B,KAAK,kBAAkB;YACrB,OAAO,cAAc,EAAE,CAAC;QAC1B;YACE,OAAO,IAAI,CAAC;IAChB,CAAC;AACH,CAAC;AAED
|
|
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,YAAY,EAAE,MAAM,IAAI,CAAC;AACnF,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAC7B,OAAO,EAAE,QAAQ,EA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AC,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;IACxC,CAAC;AACH,CAAC"}
|
package/dist/index.js
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
|
import { setTokenCommand } from "./commands/set-token.js";
|
|
8
|
-
const version = "1.0.
|
|
8
|
+
const version = "1.0.13";
|
|
9
9
|
const program = new Command();
|
|
10
10
|
program
|
|
11
11
|
.name("clawpilot")
|
package/package.json
CHANGED
|
@@ -10,6 +10,42 @@ export type LocalResult =
|
|
|
10
10
|
| { ok: true; payload?: unknown }
|
|
11
11
|
| { ok: false; error: string };
|
|
12
12
|
|
|
13
|
+
// ---------------------------------------------------------------------------
|
|
14
|
+
// Resolve the openclaw binary path once at startup.
|
|
15
|
+
// launchd services run with a minimal PATH — we try login shells (zsh first,
|
|
16
|
+
// macOS default since Catalina) then fall back to common install locations.
|
|
17
|
+
// ---------------------------------------------------------------------------
|
|
18
|
+
|
|
19
|
+
function resolveOpenclawBin(): string {
|
|
20
|
+
for (const shell of ["/bin/zsh", "/bin/bash"]) {
|
|
21
|
+
try {
|
|
22
|
+
const p = execSync(`${shell} -lc 'which openclaw'`, { stdio: "pipe", timeout: 3000 })
|
|
23
|
+
.toString().trim();
|
|
24
|
+
if (p && existsSync(p)) {
|
|
25
|
+
console.log(`[clawpilot] openclaw found at ${p} (via ${shell})`);
|
|
26
|
+
return p;
|
|
27
|
+
}
|
|
28
|
+
} catch { /* try next */ }
|
|
29
|
+
}
|
|
30
|
+
// Common install locations as final fallback
|
|
31
|
+
for (const p of [
|
|
32
|
+
"/opt/homebrew/bin/openclaw",
|
|
33
|
+
"/usr/local/bin/openclaw",
|
|
34
|
+
join(homedir(), ".local/bin/openclaw"),
|
|
35
|
+
]) {
|
|
36
|
+
if (existsSync(p)) {
|
|
37
|
+
console.log(`[clawpilot] openclaw found at ${p} (fallback)`);
|
|
38
|
+
return p;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
console.warn("[clawpilot] could not resolve openclaw path, using bare 'openclaw'");
|
|
42
|
+
return "openclaw";
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const OPENCLAW_BIN = resolveOpenclawBin();
|
|
46
|
+
|
|
47
|
+
// ---------------------------------------------------------------------------
|
|
48
|
+
|
|
13
49
|
/**
|
|
14
50
|
* Handles clawpilot-specific commands locally, without forwarding to the gateway.
|
|
15
51
|
* Returns null if the method is not a local command (caller should forward to gateway).
|
|
@@ -33,9 +69,30 @@ export function handleLocalCommand(method: string): LocalResult | null {
|
|
|
33
69
|
}
|
|
34
70
|
}
|
|
35
71
|
|
|
72
|
+
// ---------------------------------------------------------------------------
|
|
73
|
+
// Helpers
|
|
74
|
+
// ---------------------------------------------------------------------------
|
|
75
|
+
|
|
76
|
+
/** Extracts combined stdout+stderr from an execSync error. */
|
|
77
|
+
function execErrorOutput(err: unknown): string {
|
|
78
|
+
const e = err as { stdout?: Buffer | string; stderr?: Buffer | string };
|
|
79
|
+
const out = e.stdout?.toString() ?? "";
|
|
80
|
+
const errStr = e.stderr?.toString() ?? "";
|
|
81
|
+
if (out && errStr) return `${out}\n${errStr}`;
|
|
82
|
+
return out || errStr;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** Run openclaw with the resolved binary path. */
|
|
86
|
+
function openclaw(args: string): Buffer {
|
|
87
|
+
return execSync(`"${OPENCLAW_BIN}" ${args}`, { stdio: "pipe" });
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// ---------------------------------------------------------------------------
|
|
91
|
+
// Command implementations
|
|
92
|
+
// ---------------------------------------------------------------------------
|
|
93
|
+
|
|
36
94
|
/**
|
|
37
95
|
* Finds the most recent openclaw.json.bak* file and copies it over openclaw.json.
|
|
38
|
-
* The backup files are kept intact so they can be used again if needed.
|
|
39
96
|
*/
|
|
40
97
|
function restoreConfig(): LocalResult {
|
|
41
98
|
try {
|
|
@@ -70,7 +127,7 @@ function restoreConfig(): LocalResult {
|
|
|
70
127
|
*/
|
|
71
128
|
function watchSkill(): LocalResult {
|
|
72
129
|
try {
|
|
73
|
-
|
|
130
|
+
openclaw("config set skills.load.watch true");
|
|
74
131
|
console.log("[clawpilot] skills.load.watch set to true");
|
|
75
132
|
return { ok: true, payload: { message: "skills.load.watch enabled" } };
|
|
76
133
|
} catch (err) {
|
|
@@ -78,29 +135,12 @@ function watchSkill(): LocalResult {
|
|
|
78
135
|
}
|
|
79
136
|
}
|
|
80
137
|
|
|
81
|
-
/** Extracts combined stdout+stderr from an execSync error, with a newline separator if both exist. */
|
|
82
|
-
function execErrorOutput(err: unknown): string {
|
|
83
|
-
const e = err as { stdout?: Buffer | string; stderr?: Buffer | string };
|
|
84
|
-
const out = e.stdout?.toString() ?? "";
|
|
85
|
-
const errStr = e.stderr?.toString() ?? "";
|
|
86
|
-
if (out && errStr) return `${out}\n${errStr}`;
|
|
87
|
-
return out || errStr;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Runs a shell command via login bash so that PATH includes homebrew / user-installed bins.
|
|
92
|
-
* The command string must not contain user-controlled input (hardcoded calls only).
|
|
93
|
-
*/
|
|
94
|
-
function loginShell(cmd: string): Buffer {
|
|
95
|
-
return execSync(`/bin/bash -lc '${cmd}'`, { stdio: "pipe" });
|
|
96
|
-
}
|
|
97
|
-
|
|
98
138
|
/**
|
|
99
139
|
* Runs openclaw doctor to check system health.
|
|
100
140
|
*/
|
|
101
141
|
function runDoctor(): LocalResult {
|
|
102
142
|
try {
|
|
103
|
-
const output =
|
|
143
|
+
const output = openclaw("doctor").toString();
|
|
104
144
|
console.log("[clawpilot] doctor completed");
|
|
105
145
|
return { ok: true, payload: { output } };
|
|
106
146
|
} catch (err) {
|
|
@@ -152,7 +192,7 @@ function readLogs(): LocalResult {
|
|
|
152
192
|
*/
|
|
153
193
|
function restartGateway(): LocalResult {
|
|
154
194
|
try {
|
|
155
|
-
const output =
|
|
195
|
+
const output = openclaw("gateway restart").toString();
|
|
156
196
|
console.log("[clawpilot] gateway restarted");
|
|
157
197
|
return { ok: true, payload: { output: output || "Gateway restarted successfully." } };
|
|
158
198
|
} catch (err) {
|
|
@@ -168,7 +208,7 @@ function restartGateway(): LocalResult {
|
|
|
168
208
|
*/
|
|
169
209
|
function updateOpenclaw(): LocalResult {
|
|
170
210
|
try {
|
|
171
|
-
const output =
|
|
211
|
+
const output = openclaw("update").toString();
|
|
172
212
|
console.log("[clawpilot] openclaw updated");
|
|
173
213
|
return { ok: true, payload: { output: output || "openclaw updated successfully." } };
|
|
174
214
|
} catch (err) {
|
package/src/index.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { installCommand, uninstallCommand, stopCommand, restartCommand, resetCom
|
|
|
6
6
|
import { statusCommand } from "./commands/status.js";
|
|
7
7
|
import { setTokenCommand } from "./commands/set-token.js";
|
|
8
8
|
|
|
9
|
-
const version = "1.0.
|
|
9
|
+
const version = "1.0.13";
|
|
10
10
|
|
|
11
11
|
const program = new Command();
|
|
12
12
|
|