@rethinkingstudio/clawpilot 1.1.14-beta.1 → 1.1.14-beta.2
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { execSync } from "child_process";
|
|
1
|
+
import { execFileSync, execSync, } from "child_process";
|
|
2
2
|
import { existsSync } from "fs";
|
|
3
3
|
import { dirname, join } from "path";
|
|
4
4
|
import { homedir } from "os";
|
|
@@ -86,6 +86,49 @@ export function resolveOpenclawBin(forceRefresh = false) {
|
|
|
86
86
|
console.warn("[clawpilot] could not resolve openclaw path, using bare name");
|
|
87
87
|
return cachedOpenclawBin;
|
|
88
88
|
}
|
|
89
|
+
function splitShellArgs(input) {
|
|
90
|
+
const args = [];
|
|
91
|
+
let current = "";
|
|
92
|
+
let quote = null;
|
|
93
|
+
let escaping = false;
|
|
94
|
+
for (const ch of input) {
|
|
95
|
+
if (escaping) {
|
|
96
|
+
current += ch;
|
|
97
|
+
escaping = false;
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
if (ch === "\\") {
|
|
101
|
+
escaping = true;
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
if (quote) {
|
|
105
|
+
if (ch === quote) {
|
|
106
|
+
quote = null;
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
current += ch;
|
|
110
|
+
}
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
if (ch === "'" || ch === '"') {
|
|
114
|
+
quote = ch;
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
if (/\s/.test(ch)) {
|
|
118
|
+
if (current) {
|
|
119
|
+
args.push(current);
|
|
120
|
+
current = "";
|
|
121
|
+
}
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
current += ch;
|
|
125
|
+
}
|
|
126
|
+
if (escaping)
|
|
127
|
+
current += "\\";
|
|
128
|
+
if (current)
|
|
129
|
+
args.push(current);
|
|
130
|
+
return args;
|
|
131
|
+
}
|
|
89
132
|
function execErrorOutput(err) {
|
|
90
133
|
const e = err;
|
|
91
134
|
const out = e.stdout?.toString() ?? "";
|
|
@@ -94,8 +137,9 @@ function execErrorOutput(err) {
|
|
|
94
137
|
}
|
|
95
138
|
export function execOpenclaw(args) {
|
|
96
139
|
let bin = resolveOpenclawBin();
|
|
140
|
+
const argv = splitShellArgs(args);
|
|
97
141
|
try {
|
|
98
|
-
return
|
|
142
|
+
return execFileSync(bin, argv, { stdio: "pipe", env: SUBPROCESS_ENV });
|
|
99
143
|
}
|
|
100
144
|
catch (error) {
|
|
101
145
|
const output = execErrorOutput(error);
|
|
@@ -105,7 +149,7 @@ export function execOpenclaw(args) {
|
|
|
105
149
|
throw error;
|
|
106
150
|
}
|
|
107
151
|
bin = resolveOpenclawBin(true);
|
|
108
|
-
return
|
|
152
|
+
return execFileSync(bin, argv, { stdio: "pipe", env: SUBPROCESS_ENV });
|
|
109
153
|
}
|
|
110
154
|
}
|
|
111
155
|
//# sourceMappingURL=openclaw-cli.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openclaw-cli.js","sourceRoot":"","sources":["../../src/commands/openclaw-cli.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"openclaw-cli.js","sourceRoot":"","sources":["../../src/commands/openclaw-cli.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,QAAQ,GAET,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAE7B,MAAM,QAAQ,GAAG,OAAO,EAAE,CAAC;AAC3B,MAAM,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;AAC/C,MAAM,cAAc,GAAG;I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C"}
|
package/package.json
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
execFileSync,
|
|
3
|
+
execSync,
|
|
4
|
+
type ExecSyncOptionsWithStringEncoding,
|
|
5
|
+
} from "child_process";
|
|
2
6
|
import { existsSync } from "fs";
|
|
3
7
|
import { dirname, join } from "path";
|
|
4
8
|
import { homedir } from "os";
|
|
@@ -96,6 +100,54 @@ export function resolveOpenclawBin(forceRefresh = false): string {
|
|
|
96
100
|
return cachedOpenclawBin;
|
|
97
101
|
}
|
|
98
102
|
|
|
103
|
+
function splitShellArgs(input: string): string[] {
|
|
104
|
+
const args: string[] = [];
|
|
105
|
+
let current = "";
|
|
106
|
+
let quote: "'" | '"' | null = null;
|
|
107
|
+
let escaping = false;
|
|
108
|
+
|
|
109
|
+
for (const ch of input) {
|
|
110
|
+
if (escaping) {
|
|
111
|
+
current += ch;
|
|
112
|
+
escaping = false;
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (ch === "\\") {
|
|
117
|
+
escaping = true;
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (quote) {
|
|
122
|
+
if (ch === quote) {
|
|
123
|
+
quote = null;
|
|
124
|
+
} else {
|
|
125
|
+
current += ch;
|
|
126
|
+
}
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (ch === "'" || ch === '"') {
|
|
131
|
+
quote = ch;
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (/\s/.test(ch)) {
|
|
136
|
+
if (current) {
|
|
137
|
+
args.push(current);
|
|
138
|
+
current = "";
|
|
139
|
+
}
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
current += ch;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (escaping) current += "\\";
|
|
147
|
+
if (current) args.push(current);
|
|
148
|
+
return args;
|
|
149
|
+
}
|
|
150
|
+
|
|
99
151
|
function execErrorOutput(err: unknown): string {
|
|
100
152
|
const e = err as { stdout?: Buffer | string; stderr?: Buffer | string };
|
|
101
153
|
const out = e.stdout?.toString() ?? "";
|
|
@@ -105,8 +157,9 @@ function execErrorOutput(err: unknown): string {
|
|
|
105
157
|
|
|
106
158
|
export function execOpenclaw(args: string): Buffer {
|
|
107
159
|
let bin = resolveOpenclawBin();
|
|
160
|
+
const argv = splitShellArgs(args);
|
|
108
161
|
try {
|
|
109
|
-
return
|
|
162
|
+
return execFileSync(bin, argv, { stdio: "pipe", env: SUBPROCESS_ENV });
|
|
110
163
|
} catch (error) {
|
|
111
164
|
const output = execErrorOutput(error);
|
|
112
165
|
const shouldRetry =
|
|
@@ -118,6 +171,6 @@ export function execOpenclaw(args: string): Buffer {
|
|
|
118
171
|
}
|
|
119
172
|
|
|
120
173
|
bin = resolveOpenclawBin(true);
|
|
121
|
-
return
|
|
174
|
+
return execFileSync(bin, argv, { stdio: "pipe", env: SUBPROCESS_ENV });
|
|
122
175
|
}
|
|
123
176
|
}
|