@chrysb/alphaclaw 0.8.4-beta.0 → 0.8.5
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,5 +1,6 @@
|
|
|
1
1
|
const childProcess = require("child_process");
|
|
2
2
|
const fs = require("fs");
|
|
3
|
+
const os = require("os");
|
|
3
4
|
const path = require("path");
|
|
4
5
|
const https = require("https");
|
|
5
6
|
const http = require("http");
|
|
@@ -7,6 +8,7 @@ const {
|
|
|
7
8
|
kLatestVersionCacheTtlMs,
|
|
8
9
|
kAlphaclawRegistryUrl,
|
|
9
10
|
kNpmPackageRoot,
|
|
11
|
+
kOpenclawUpdateCopyTimeoutMs,
|
|
10
12
|
kRootDir,
|
|
11
13
|
} = require("./constants");
|
|
12
14
|
|
|
@@ -114,7 +116,7 @@ const createAlphaclawVersionService = () => {
|
|
|
114
116
|
const parent = path.dirname(dir);
|
|
115
117
|
if (
|
|
116
118
|
path.basename(parent) === "node_modules" ||
|
|
117
|
-
parent.includes(
|
|
119
|
+
parent.includes(`${path.sep}node_modules${path.sep}`)
|
|
118
120
|
) {
|
|
119
121
|
dir = parent;
|
|
120
122
|
continue;
|
|
@@ -123,7 +125,11 @@ const createAlphaclawVersionService = () => {
|
|
|
123
125
|
if (fs.existsSync(pkgPath)) {
|
|
124
126
|
try {
|
|
125
127
|
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
|
|
126
|
-
if (
|
|
128
|
+
if (
|
|
129
|
+
pkg.dependencies?.["@chrysb/alphaclaw"] ||
|
|
130
|
+
pkg.devDependencies?.["@chrysb/alphaclaw"] ||
|
|
131
|
+
pkg.optionalDependencies?.["@chrysb/alphaclaw"]
|
|
132
|
+
) {
|
|
127
133
|
return parent;
|
|
128
134
|
}
|
|
129
135
|
} catch {}
|
|
@@ -137,19 +143,39 @@ const createAlphaclawVersionService = () => {
|
|
|
137
143
|
const installLatestAlphaclaw = () =>
|
|
138
144
|
new Promise((resolve, reject) => {
|
|
139
145
|
const installDir = findInstallDir();
|
|
146
|
+
const tmpDir = fs.mkdtempSync(
|
|
147
|
+
path.join(os.tmpdir(), "alphaclaw-update-"),
|
|
148
|
+
);
|
|
149
|
+
|
|
150
|
+
const cleanup = () => {
|
|
151
|
+
try {
|
|
152
|
+
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
153
|
+
} catch {}
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
fs.writeFileSync(
|
|
157
|
+
path.join(tmpDir, "package.json"),
|
|
158
|
+
JSON.stringify({
|
|
159
|
+
private: true,
|
|
160
|
+
dependencies: { "@chrysb/alphaclaw": "latest" },
|
|
161
|
+
}),
|
|
162
|
+
);
|
|
163
|
+
|
|
164
|
+
const npmEnv = {
|
|
165
|
+
...process.env,
|
|
166
|
+
npm_config_update_notifier: "false",
|
|
167
|
+
npm_config_fund: "false",
|
|
168
|
+
npm_config_audit: "false",
|
|
169
|
+
};
|
|
170
|
+
|
|
140
171
|
console.log(
|
|
141
|
-
`[alphaclaw] Running: npm install @chrysb/alphaclaw@latest (
|
|
172
|
+
`[alphaclaw] Running: npm install @chrysb/alphaclaw@latest in temp dir (target: ${installDir})`,
|
|
142
173
|
);
|
|
143
174
|
childProcess.exec(
|
|
144
|
-
"npm install
|
|
175
|
+
"npm install --omit=dev --prefer-online --package-lock=false",
|
|
145
176
|
{
|
|
146
|
-
cwd:
|
|
147
|
-
env:
|
|
148
|
-
...process.env,
|
|
149
|
-
npm_config_update_notifier: "false",
|
|
150
|
-
npm_config_fund: "false",
|
|
151
|
-
npm_config_audit: "false",
|
|
152
|
-
},
|
|
177
|
+
cwd: tmpDir,
|
|
178
|
+
env: npmEnv,
|
|
153
179
|
timeout: 180000,
|
|
154
180
|
},
|
|
155
181
|
(err, stdout, stderr) => {
|
|
@@ -158,6 +184,7 @@ const createAlphaclawVersionService = () => {
|
|
|
158
184
|
console.log(
|
|
159
185
|
`[alphaclaw] alphaclaw install error: ${message.slice(0, 200)}`,
|
|
160
186
|
);
|
|
187
|
+
cleanup();
|
|
161
188
|
return reject(
|
|
162
189
|
new Error(
|
|
163
190
|
message || "Failed to install @chrysb/alphaclaw@latest",
|
|
@@ -169,8 +196,28 @@ const createAlphaclawVersionService = () => {
|
|
|
169
196
|
`[alphaclaw] alphaclaw install stdout: ${stdout.trim().slice(0, 300)}`,
|
|
170
197
|
);
|
|
171
198
|
}
|
|
172
|
-
|
|
173
|
-
|
|
199
|
+
|
|
200
|
+
const src = path.join(tmpDir, "node_modules");
|
|
201
|
+
const dest = path.join(installDir, "node_modules");
|
|
202
|
+
childProcess.exec(
|
|
203
|
+
`cp -af "${src}/." "${dest}/"`,
|
|
204
|
+
{ timeout: kOpenclawUpdateCopyTimeoutMs },
|
|
205
|
+
(copyErr) => {
|
|
206
|
+
cleanup();
|
|
207
|
+
if (copyErr) {
|
|
208
|
+
console.log(
|
|
209
|
+
`[alphaclaw] alphaclaw copy error: ${(copyErr.message || "").slice(0, 200)}`,
|
|
210
|
+
);
|
|
211
|
+
return reject(
|
|
212
|
+
new Error(
|
|
213
|
+
`Failed to copy updated AlphaClaw files: ${copyErr.message}`,
|
|
214
|
+
),
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
console.log("[alphaclaw] alphaclaw install completed");
|
|
218
|
+
resolve({ stdout: stdout?.trim(), stderr: stderr?.trim() });
|
|
219
|
+
},
|
|
220
|
+
);
|
|
174
221
|
},
|
|
175
222
|
);
|
|
176
223
|
});
|
|
@@ -55,22 +55,21 @@ const ensureManagedExecApprovalsDefaults = (rawFile = {}) => {
|
|
|
55
55
|
const file =
|
|
56
56
|
rawFile && typeof rawFile === "object" && !Array.isArray(rawFile) ? rawFile : {};
|
|
57
57
|
const before = JSON.stringify(file);
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
defaults.askFallback = kManagedExecApprovalsDefaults.askFallback;
|
|
58
|
+
const defaults =
|
|
59
|
+
file.defaults && typeof file.defaults === "object" && !Array.isArray(file.defaults)
|
|
60
|
+
? file.defaults
|
|
61
|
+
: null;
|
|
62
|
+
const hasNonEmptyDefaults = !!defaults && Object.keys(defaults).length > 0;
|
|
63
|
+
if (!hasNonEmptyDefaults) {
|
|
64
|
+
if (!Number.isInteger(file.version)) file.version = 1;
|
|
65
|
+
file.defaults = {
|
|
66
|
+
security: kManagedExecApprovalsDefaults.security,
|
|
67
|
+
ask: kManagedExecApprovalsDefaults.ask,
|
|
68
|
+
askFallback: kManagedExecApprovalsDefaults.askFallback,
|
|
69
|
+
};
|
|
70
|
+
if (!file.agents || typeof file.agents !== "object" || Array.isArray(file.agents)) {
|
|
71
|
+
file.agents = {};
|
|
72
|
+
}
|
|
74
73
|
}
|
|
75
74
|
return {
|
|
76
75
|
file,
|
|
@@ -85,19 +84,11 @@ const ensureManagedOpenclawExecDefaults = (rawConfig = {}) => {
|
|
|
85
84
|
if (!config.tools || typeof config.tools !== "object" || Array.isArray(config.tools)) {
|
|
86
85
|
config.tools = {};
|
|
87
86
|
}
|
|
88
|
-
if (
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
config.tools.exec = {};
|
|
94
|
-
}
|
|
95
|
-
const exec = config.tools.exec;
|
|
96
|
-
if (!String(exec.security || "").trim()) {
|
|
97
|
-
exec.security = kManagedOpenclawExecDefaults.security;
|
|
98
|
-
}
|
|
99
|
-
if (!hasOwn(exec, "strictInlineEval")) {
|
|
100
|
-
exec.strictInlineEval = kManagedOpenclawExecDefaults.strictInlineEval;
|
|
87
|
+
if (!hasOwn(config.tools, "exec")) {
|
|
88
|
+
config.tools.exec = {
|
|
89
|
+
security: kManagedOpenclawExecDefaults.security,
|
|
90
|
+
strictInlineEval: kManagedOpenclawExecDefaults.strictInlineEval,
|
|
91
|
+
};
|
|
101
92
|
}
|
|
102
93
|
return {
|
|
103
94
|
config,
|