baychat 0.32.2 → 0.33.1
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/.claude-plugin/plugin.json +1 -1
- package/dist/auto-update/hint.js +20 -0
- package/dist/auto-update/policy.js +8 -1
- package/dist/auto-update/relay-glue.js +3 -0
- package/dist/auto-update/updater.js +37 -1
- package/dist/channel/feed.js +12 -4
- package/dist/channel/server.js +12 -14
- package/dist/mcp-register.js +1 -0
- package/dist/protocol-content.js +1 -1
- package/dist/relay/ws.js +5 -0
- package/dist/runtimes.js +4 -4
- package/dist/self-upgrade.js +38 -1
- package/dist/tool-defs.js +218 -361
- package/package.json +1 -1
package/dist/self-upgrade.js
CHANGED
|
@@ -42,6 +42,7 @@ exports.upgradePackage = upgradePackage;
|
|
|
42
42
|
exports.lookupLatest = lookupLatest;
|
|
43
43
|
exports.installRelease = installRelease;
|
|
44
44
|
exports.describeOutcome = describeOutcome;
|
|
45
|
+
exports.npmCommand = npmCommand;
|
|
45
46
|
exports.realNpm = realNpm;
|
|
46
47
|
exports.readPackageVersion = readPackageVersion;
|
|
47
48
|
exports.packageEntry = packageEntry;
|
|
@@ -249,6 +250,30 @@ function npmFailure(r) {
|
|
|
249
250
|
const lines = r.stderr.split("\n").map((l) => l.trim()).filter(Boolean);
|
|
250
251
|
return lines.slice(-3).join(" ") || `npm exited with ${r.status}`;
|
|
251
252
|
}
|
|
253
|
+
/**
|
|
254
|
+
* Which npm to run, and the PATH to run it with: the npm installed beside the Node running this
|
|
255
|
+
* code, when there is one — else plain `npm` from PATH.
|
|
256
|
+
*
|
|
257
|
+
* A relay under systemd or launchd does not read a shell profile, so with Node from nvm (or any
|
|
258
|
+
* version manager) its PATH holds no npm at all: every automatic update on such a computer failed
|
|
259
|
+
* with "npm was not found on PATH" (Karmen's PC, 2026-10-21: 11 failed checks, never one update).
|
|
260
|
+
* The Node that is running is the Node that installed this copy, and its npm sits next to it. That
|
|
261
|
+
* directory also goes first on the child's PATH, because npm itself starts with
|
|
262
|
+
* `#!/usr/bin/env node`, which must find a node too.
|
|
263
|
+
*
|
|
264
|
+
* Which global folder that npm calls its own (Volta, asdf, a custom `prefix`) does not matter:
|
|
265
|
+
* installRelease always passes `--prefix <the running copy's prefix>`, which npm puts above its
|
|
266
|
+
* own config (checked 2026-10-21 with npm_config_prefix pointing elsewhere: the install landed in
|
|
267
|
+
* `--prefix`), and then believes only the version on disk there.
|
|
268
|
+
*/
|
|
269
|
+
function npmCommand(execPath, platform, pathEnv, exists) {
|
|
270
|
+
const dir = path.dirname(execPath);
|
|
271
|
+
const beside = path.join(dir, platform === "win32" ? "npm.cmd" : "npm");
|
|
272
|
+
if (!exists(beside))
|
|
273
|
+
return { command: "npm", path: pathEnv };
|
|
274
|
+
const sep = platform === "win32" ? ";" : ":";
|
|
275
|
+
return { command: beside, path: pathEnv ? `${dir}${sep}${pathEnv}` : dir };
|
|
276
|
+
}
|
|
252
277
|
/** Run npm for real, without blocking the event loop (the relay keeps serving while npm runs).
|
|
253
278
|
* Windows' npm is a `.cmd` shim, which Node will only start through a shell, so every argument
|
|
254
279
|
* is first checked against what cmd.exe could misread and then quoted. */
|
|
@@ -257,8 +282,20 @@ function realNpm(args, timeoutMs) {
|
|
|
257
282
|
if (windows && args.some((a) => commands_1.WINDOWS_UNSAFE.test(a))) {
|
|
258
283
|
return Promise.resolve({ status: null, stdout: "", stderr: "", error: new Error("a path npm needs cannot be passed safely through cmd.exe") });
|
|
259
284
|
}
|
|
285
|
+
const found = npmCommand(process.execPath, process.platform, process.env.PATH, fs.existsSync);
|
|
286
|
+
// A Node directory cmd.exe could misread is not run through it: PATH's npm then, as before.
|
|
287
|
+
const npm = windows && commands_1.WINDOWS_UNSAFE.test(found.command) ? { command: "npm", path: process.env.PATH } : found;
|
|
288
|
+
// Through cmd.exe the command is a string too: a path with spaces must arrive as one word.
|
|
289
|
+
const command = windows && npm.command !== "npm" ? (0, commands_1.quoteForCmd)(npm.command) : npm.command;
|
|
260
290
|
return new Promise((resolve) => {
|
|
261
|
-
(0, child_process_1.execFile)(
|
|
291
|
+
(0, child_process_1.execFile)(command, windows ? args.map(commands_1.quoteForCmd) : args, {
|
|
292
|
+
encoding: "utf8",
|
|
293
|
+
timeout: timeoutMs,
|
|
294
|
+
shell: windows,
|
|
295
|
+
windowsHide: true,
|
|
296
|
+
maxBuffer: 16 * 1024 * 1024,
|
|
297
|
+
env: { ...process.env, ...(npm.path !== undefined ? { PATH: npm.path } : {}) },
|
|
298
|
+
}, (err, stdout, stderr) => {
|
|
262
299
|
if (!err)
|
|
263
300
|
return resolve({ status: 0, stdout, stderr });
|
|
264
301
|
const code = err.code;
|