@mutmutco/hub 4.5.15 → 4.5.16
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/index.cjs +16 -109
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -26,7 +26,6 @@ __export(index_exports, {
|
|
|
26
26
|
buildWatcherCommand: () => buildWatcherCommand,
|
|
27
27
|
checkAtomicity: () => checkAtomicity,
|
|
28
28
|
claudeArm: () => claudeArm,
|
|
29
|
-
claudeHostEvidence: () => claudeHostEvidence,
|
|
30
29
|
clearLaunchTarget: () => clearLaunchTarget,
|
|
31
30
|
clearPending: () => clearPending,
|
|
32
31
|
createInstallerRun: () => createInstallerRun,
|
|
@@ -37,7 +36,6 @@ __export(index_exports, {
|
|
|
37
36
|
hermesHome: () => hermesHome,
|
|
38
37
|
hermesHomes: () => hermesHomes,
|
|
39
38
|
hermesHostCommand: () => hermesHostCommand,
|
|
40
|
-
hermesHostEvidence: () => hermesHostEvidence,
|
|
41
39
|
hermesHostPresent: () => hermesHostPresent,
|
|
42
40
|
hubStatus: () => hubStatus,
|
|
43
41
|
hubStatusReport: () => hubStatusReport,
|
|
@@ -88,7 +86,7 @@ __export(index_exports, {
|
|
|
88
86
|
writePending: () => writePending
|
|
89
87
|
});
|
|
90
88
|
module.exports = __toCommonJS(index_exports);
|
|
91
|
-
var
|
|
89
|
+
var import_node_child_process9 = require("node:child_process");
|
|
92
90
|
var import_node_fs24 = require("node:fs");
|
|
93
91
|
var import_node_path16 = require("node:path");
|
|
94
92
|
|
|
@@ -2398,32 +2396,8 @@ function claudeMarkerVersion(root) {
|
|
|
2398
2396
|
function claudeTreeHealthy(root) {
|
|
2399
2397
|
return CLAUDE_TREE_MARKERS.every((rel) => fileExists((0, import_node_path9.join)(root, ...rel.split("/"))));
|
|
2400
2398
|
}
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
function claudeProcessToken(line) {
|
|
2404
|
-
if (HUB_UPDATE_COMMAND.test(line)) return null;
|
|
2405
|
-
for (const token of line.replace(/["']/g, " ").split(/\s+/)) {
|
|
2406
|
-
for (const segment of token.split(/[/\\]/)) {
|
|
2407
|
-
if (CLAUDE_PROCESS_SEGMENT.test(segment)) return segment;
|
|
2408
|
-
}
|
|
2409
|
-
}
|
|
2410
|
-
return null;
|
|
2411
|
-
}
|
|
2412
|
-
function realClaudeProcessListing() {
|
|
2413
|
-
const result = process.platform === "win32" ? (0, import_node_child_process6.spawnSync)("powershell.exe", ["-NoProfile", "-Command", "Get-CimInstance Win32_Process | ForEach-Object { $_.Name + ' ' + $_.CommandLine }"], { encoding: "utf8", windowsHide: true, timeout: 15e3 }) : (0, import_node_child_process6.spawnSync)("ps", ["-eo", "args="], { encoding: "utf8", windowsHide: true, timeout: 15e3 });
|
|
2414
|
-
return result.status === 0 ? result.stdout ?? "" : null;
|
|
2415
|
-
}
|
|
2416
|
-
function claudeHostEvidence(env, processListProvider) {
|
|
2417
|
-
for (const marker of ["CLAUDE_CODE_SESSION_ID", "CLAUDECODE", "CLAUDE_PLUGIN_ROOT"]) {
|
|
2418
|
-
if (env[marker]?.trim()) return `env marker ${marker}`;
|
|
2419
|
-
}
|
|
2420
|
-
const listing = processListProvider ? processListProvider() : realClaudeProcessListing();
|
|
2421
|
-
if (listing === null || !listing.trim()) return "the process list is unreadable (unsafe to write)";
|
|
2422
|
-
for (const line of listing.split(/\r?\n/)) {
|
|
2423
|
-
const token = claudeProcessToken(line);
|
|
2424
|
-
if (token) return `a live process names claude (${token})`;
|
|
2425
|
-
}
|
|
2426
|
-
return null;
|
|
2399
|
+
function claudeNpmEnv(env) {
|
|
2400
|
+
return { ...env, npm_config_allow_remote: "all" };
|
|
2427
2401
|
}
|
|
2428
2402
|
function probeClaudeLaunchStaging(env = process.env) {
|
|
2429
2403
|
return probeLaunchTargetVersion((0, import_node_path9.join)(claudePluginsRoot(env), "staging", "launch-target.json"), claudeMarkerVersion);
|
|
@@ -2434,14 +2408,12 @@ function claudeArm(options) {
|
|
|
2434
2408
|
const paths = options.paths ?? ensureState(env);
|
|
2435
2409
|
const target = options.target;
|
|
2436
2410
|
const repoUrl = options.repoUrl ?? (env.MMI_UPDATER_REPO || REPO_URL_DEFAULT);
|
|
2437
|
-
const
|
|
2438
|
-
const result = (from2, to, verdict, detail, launchStaged = false) => ({
|
|
2411
|
+
const result = (from2, to, verdict, detail) => ({
|
|
2439
2412
|
surface: "claude",
|
|
2440
2413
|
from: from2,
|
|
2441
2414
|
to,
|
|
2442
2415
|
verdict,
|
|
2443
|
-
detail
|
|
2444
|
-
launchStaged: launchStaged || void 0
|
|
2416
|
+
detail
|
|
2445
2417
|
});
|
|
2446
2418
|
const before = claudeMmi(runner, env);
|
|
2447
2419
|
if (before.error) return result(null, target, "defer", before.error);
|
|
@@ -2497,32 +2469,6 @@ function claudeArm(options) {
|
|
|
2497
2469
|
return result(from, target, "defer", "incoming Claude generation did not reproduce the verified payload");
|
|
2498
2470
|
}
|
|
2499
2471
|
}
|
|
2500
|
-
const busy = claudeHostEvidence(env, options.processListProvider);
|
|
2501
|
-
if (busy) {
|
|
2502
|
-
const pending = noteLaunchStaged(paths, env, {
|
|
2503
|
-
surface: "claude",
|
|
2504
|
-
target,
|
|
2505
|
-
reason: busy,
|
|
2506
|
-
launchTargetPath,
|
|
2507
|
-
incoming,
|
|
2508
|
-
images: ["claude"],
|
|
2509
|
-
dirs: [home]
|
|
2510
|
-
});
|
|
2511
|
-
return result(from, target, "ok", `staged ${target} for next launch while Claude Code is running (${busy}) \u2014 ${pending}`, true);
|
|
2512
|
-
}
|
|
2513
|
-
const started = claudeHostEvidence(env, options.processListProvider);
|
|
2514
|
-
if (started) {
|
|
2515
|
-
const pending = noteLaunchStaged(paths, env, {
|
|
2516
|
-
surface: "claude",
|
|
2517
|
-
target,
|
|
2518
|
-
reason: started,
|
|
2519
|
-
launchTargetPath,
|
|
2520
|
-
incoming,
|
|
2521
|
-
images: ["claude"],
|
|
2522
|
-
dirs: [home]
|
|
2523
|
-
});
|
|
2524
|
-
return result(from, target, "ok", `staged ${target} for next launch \u2014 Claude Code started during staging (${started}) \u2014 ${pending}`, true);
|
|
2525
|
-
}
|
|
2526
2472
|
const cacheTarget = (0, import_node_path9.join)(pluginsRoot, "cache", "mutmutco", "mmi", target);
|
|
2527
2473
|
try {
|
|
2528
2474
|
if (!(0, import_node_fs13.existsSync)(cacheTarget) || claudeMarkerVersion(cacheTarget) !== target || !claudeTreeHealthy(cacheTarget)) {
|
|
@@ -2535,7 +2481,7 @@ function claudeArm(options) {
|
|
|
2535
2481
|
}
|
|
2536
2482
|
const scope = observed.row?.scope || before.row?.scope || "user";
|
|
2537
2483
|
const command = observed.row ? ["plugin", "update", "mmi@mutmutco", "--scope", scope] : ["plugin", "install", "mmi@mutmutco", "--scope", scope];
|
|
2538
|
-
const converge = runner("claude", command, env);
|
|
2484
|
+
const converge = runner("claude", command, claudeNpmEnv(env));
|
|
2539
2485
|
if (converge.status !== 0) {
|
|
2540
2486
|
return result(from, target, "defer", `${observed.row ? "plugin update" : "plugin install"} failed: ${failure(converge)}`);
|
|
2541
2487
|
}
|
|
@@ -3255,7 +3201,6 @@ function jervcodeArm(options) {
|
|
|
3255
3201
|
|
|
3256
3202
|
// src/arm-hermes.ts
|
|
3257
3203
|
var import_node_fs19 = require("node:fs");
|
|
3258
|
-
var import_node_child_process8 = require("node:child_process");
|
|
3259
3204
|
var import_node_path13 = require("node:path");
|
|
3260
3205
|
var PACKAGE2 = "@mutmutco/hermes-plugin";
|
|
3261
3206
|
var MANIFEST2 = "plugin.yaml";
|
|
@@ -3329,30 +3274,6 @@ function discard2(path) {
|
|
|
3329
3274
|
function message2(error) {
|
|
3330
3275
|
return String(error?.message ?? error).replace(/\s+/g, " ").slice(0, 200);
|
|
3331
3276
|
}
|
|
3332
|
-
var HERMES_PROCESS_SEGMENT = /^hermes(-cli|-code)?(\.(exe|cmd|bat|ps1|js|mjs|cjs|py))?$/i;
|
|
3333
|
-
var HUB_UPDATE_COMMAND2 = /(?:\bmmi-hub(?:\.(?:cmd|exe|bat|ps1))?\b|@mutmutco[/\\]hub[/\\]dist[/\\]index\.(?:cjs|mjs|js))[\s'"]+update\b/i;
|
|
3334
|
-
function hermesProcessToken(line, home) {
|
|
3335
|
-
const normalized = line.replace(/["']/g, " ");
|
|
3336
|
-
const tokens = normalized.split(/\s+/);
|
|
3337
|
-
const hermesToken = (candidates) => candidates.find((token) => token && token.split(/[/\\]/).some((segment) => HERMES_PROCESS_SEGMENT.test(segment))) ?? null;
|
|
3338
|
-
const direct = hermesToken(tokens.slice(0, 2));
|
|
3339
|
-
if (direct) return direct;
|
|
3340
|
-
if (HUB_UPDATE_COMMAND2.test(line)) return null;
|
|
3341
|
-
return hermesToken(tokens) ?? (home && normalized.toLowerCase().includes(home.toLowerCase()) ? home : null);
|
|
3342
|
-
}
|
|
3343
|
-
function realProcessListing() {
|
|
3344
|
-
const result = process.platform === "win32" ? (0, import_node_child_process8.spawnSync)("powershell.exe", ["-NoProfile", "-Command", "Get-CimInstance Win32_Process | ForEach-Object { $_.Name + ' ' + $_.CommandLine }"], { encoding: "utf8", windowsHide: true, timeout: 15e3 }) : (0, import_node_child_process8.spawnSync)("ps", ["-eo", "args="], { encoding: "utf8", windowsHide: true, timeout: 15e3 });
|
|
3345
|
-
return result.status === 0 ? result.stdout ?? "" : null;
|
|
3346
|
-
}
|
|
3347
|
-
function hermesHostEvidence(env, home, processListProvider) {
|
|
3348
|
-
const listing = processListProvider ? processListProvider() : realProcessListing();
|
|
3349
|
-
if (listing === null || !listing.trim()) return "the process list is unreadable (unsafe to write)";
|
|
3350
|
-
for (const line of listing.split(/\r?\n/)) {
|
|
3351
|
-
const token = hermesProcessToken(line, home);
|
|
3352
|
-
if (token) return `a live process names hermes (${token})`;
|
|
3353
|
-
}
|
|
3354
|
-
return null;
|
|
3355
|
-
}
|
|
3356
3277
|
function materializeHermesSkills(home) {
|
|
3357
3278
|
const pluginSkills = (0, import_node_path13.join)(home, "plugins", "mmi", "skills");
|
|
3358
3279
|
const skillsRoot = (0, import_node_path13.join)(home, "skills");
|
|
@@ -3488,20 +3409,8 @@ function armHermesHome(home, env, options, primary) {
|
|
|
3488
3409
|
}
|
|
3489
3410
|
}
|
|
3490
3411
|
const displaced = (0, import_node_fs19.existsSync)(live);
|
|
3491
|
-
const busy = displaced ? hermesHostEvidence(env, home, options.processListProvider) : null;
|
|
3492
|
-
if (busy) {
|
|
3493
|
-
const pending = noteLaunchStaged(options.paths, env, {
|
|
3494
|
-
surface: "hermes",
|
|
3495
|
-
target: options.target,
|
|
3496
|
-
reason: busy,
|
|
3497
|
-
launchTargetPath,
|
|
3498
|
-
incoming,
|
|
3499
|
-
images: ["hermes"],
|
|
3500
|
-
dirs: [home]
|
|
3501
|
-
});
|
|
3502
|
-
return result(installed, options.target, "ok", `staged ${options.target} for next launch while Hermes is running (${busy}) \u2014 ${pending}`, true);
|
|
3503
|
-
}
|
|
3504
3412
|
try {
|
|
3413
|
+
(0, import_node_fs19.mkdirSync)((0, import_node_path13.join)(scratch, "quarantine"), { recursive: true });
|
|
3505
3414
|
if (displaced) (0, import_node_fs19.renameSync)(live, quarantine);
|
|
3506
3415
|
(0, import_node_fs19.renameSync)(incoming, live);
|
|
3507
3416
|
} catch (error) {
|
|
@@ -3534,7 +3443,7 @@ function armHermesHome(home, env, options, primary) {
|
|
|
3534
3443
|
if (!skills.ok) return result(installed, options.target, "fail", `plugin converged to ${options.target}, but skills provisioning failed: ${skills.detail}`);
|
|
3535
3444
|
const enabled = enableHermesPlugin(env, hostRunner);
|
|
3536
3445
|
if (!enabled.ok) return result(installed, options.target, "fail", `plugin converged to ${options.target}, but ${enabled.detail}`);
|
|
3537
|
-
return result(installed, options.target, "ok", `converged ${installed ?? "absent"} -> ${options.target} (staged, verified,
|
|
3446
|
+
return result(installed, options.target, "ok", `converged ${installed ?? "absent"} -> ${options.target} (staged, verified, switched${displaced ? `; previous generation quarantined at ${quarantine}` : ""}); ${skills.detail}; ${enabled.detail}`);
|
|
3538
3447
|
}
|
|
3539
3448
|
function probeHermesLaunchStaging(env = process.env) {
|
|
3540
3449
|
return probeLaunchTargetVersion((0, import_node_path13.join)(hermesHome(env), ".mmi-updater", "launch-target.json"), yamlVersion);
|
|
@@ -3856,7 +3765,7 @@ async function reconcile(options) {
|
|
|
3856
3765
|
}
|
|
3857
3766
|
|
|
3858
3767
|
// src/scheduler.ts
|
|
3859
|
-
var
|
|
3768
|
+
var import_node_child_process8 = require("node:child_process");
|
|
3860
3769
|
var import_node_fs21 = require("node:fs");
|
|
3861
3770
|
var import_node_os8 = require("node:os");
|
|
3862
3771
|
var import_node_path15 = require("node:path");
|
|
@@ -3875,15 +3784,15 @@ var SYSTEMD_UNIT = "mmi-hub-updater";
|
|
|
3875
3784
|
var SYSTEMD_SERVICE_NAME = `${SYSTEMD_UNIT}.service`;
|
|
3876
3785
|
var SYSTEMD_TIMER_NAME = `${SYSTEMD_UNIT}.timer`;
|
|
3877
3786
|
function schtasks(args) {
|
|
3878
|
-
const result = (0,
|
|
3787
|
+
const result = (0, import_node_child_process8.spawnSync)("schtasks.exe", args, { encoding: "utf8", windowsHide: true });
|
|
3879
3788
|
return { status: result.status, stdout: result.stdout ?? "", stderr: result.stderr ?? "" };
|
|
3880
3789
|
}
|
|
3881
3790
|
function launchctl(args) {
|
|
3882
|
-
const result = (0,
|
|
3791
|
+
const result = (0, import_node_child_process8.spawnSync)("launchctl", args, { encoding: "utf8", windowsHide: true });
|
|
3883
3792
|
return { status: result.status, stdout: result.stdout ?? "", stderr: result.stderr ?? "" };
|
|
3884
3793
|
}
|
|
3885
3794
|
function systemctlUser(args) {
|
|
3886
|
-
const result = (0,
|
|
3795
|
+
const result = (0, import_node_child_process8.spawnSync)("systemctl", ["--user", ...args], { encoding: "utf8", windowsHide: true });
|
|
3887
3796
|
return { status: result.status, stdout: result.stdout ?? "", stderr: result.stderr ?? "" };
|
|
3888
3797
|
}
|
|
3889
3798
|
function uid() {
|
|
@@ -3908,7 +3817,7 @@ WScript.Quit code
|
|
|
3908
3817
|
`;
|
|
3909
3818
|
}
|
|
3910
3819
|
function loginPath(fallback = process.env.PATH ?? "") {
|
|
3911
|
-
const probe = (0,
|
|
3820
|
+
const probe = (0, import_node_child_process8.spawnSync)("/bin/sh", ["-lc", 'printf %s "$PATH"'], { encoding: "utf8", windowsHide: true, timeout: 1e4 });
|
|
3912
3821
|
const captured = (probe.status === 0 ? probe.stdout ?? "" : "").trim();
|
|
3913
3822
|
const source = captured || fallback;
|
|
3914
3823
|
const durable = source.split(":").filter((entry) => entry && !/^\/(?:private\/)?(?:tmp|var\/folders)\//.test(entry));
|
|
@@ -4029,7 +3938,7 @@ function elevatedRelaunch(mode, env) {
|
|
|
4029
3938
|
if (env.MMI_UPDATER_ELEVATED_RETRY === "1") return false;
|
|
4030
3939
|
const self = process.argv[1];
|
|
4031
3940
|
const command = self ? `"${process.execPath}" "${self}" autoupdate ${mode}` : `mmi-hub autoupdate ${mode}`;
|
|
4032
|
-
const relaunch = (0,
|
|
3941
|
+
const relaunch = (0, import_node_child_process8.spawnSync)(
|
|
4033
3942
|
"powershell.exe",
|
|
4034
3943
|
["-NoProfile", "-Command", `Start-Process -Verb RunAs -Wait -WindowStyle Hidden -FilePath 'cmd.exe' -ArgumentList '/c',${psQuote(`set MMI_UPDATER_ELEVATED_RETRY=1&& ${command}`)}`],
|
|
4035
3944
|
{ encoding: "utf8", windowsHide: true }
|
|
@@ -4040,7 +3949,7 @@ var NEVER_RUN_RESULT = 267011;
|
|
|
4040
3949
|
var NEVER_RUN_YEAR = 1999;
|
|
4041
3950
|
var EMPTY_RUN_INFO = { lastRunTime: null, lastTaskResult: null, nextRunTime: null };
|
|
4042
3951
|
function taskRunInfo() {
|
|
4043
|
-
const result = (0,
|
|
3952
|
+
const result = (0, import_node_child_process8.spawnSync)(
|
|
4044
3953
|
"powershell.exe",
|
|
4045
3954
|
["-NoProfile", "-Command", `$stamp = { param($t) if ($t) { $t.ToString('yyyy-MM-dd HH:mm:ss') } }; Get-ScheduledTaskInfo -TaskName '${TASK_NAME}' | Select-Object @{n='LastRunTime';e={& $stamp $_.LastRunTime}},LastTaskResult,@{n='NextRunTime';e={& $stamp $_.NextRunTime}} | ConvertTo-Json -Compress`],
|
|
4046
3955
|
{ encoding: "utf8", windowsHide: true, timeout: 3e4 }
|
|
@@ -4611,7 +4520,7 @@ function notice(screen, render) {
|
|
|
4611
4520
|
printScreen(renderNotice(FACE, screen, render), screen.state === "fail" ? "stderr" : "stdout");
|
|
4612
4521
|
}
|
|
4613
4522
|
function handOff(reexec, args, env) {
|
|
4614
|
-
const child = (0,
|
|
4523
|
+
const child = (0, import_node_child_process9.spawnSync)(process.execPath, [reexec.dist, ...args], {
|
|
4615
4524
|
stdio: "inherit",
|
|
4616
4525
|
windowsHide: true,
|
|
4617
4526
|
env: { ...env, MMI_UPDATER_REEXEC: "1" }
|
|
@@ -4701,7 +4610,6 @@ if (typeof require !== "undefined" && require.main === module) {
|
|
|
4701
4610
|
buildWatcherCommand,
|
|
4702
4611
|
checkAtomicity,
|
|
4703
4612
|
claudeArm,
|
|
4704
|
-
claudeHostEvidence,
|
|
4705
4613
|
clearLaunchTarget,
|
|
4706
4614
|
clearPending,
|
|
4707
4615
|
createInstallerRun,
|
|
@@ -4712,7 +4620,6 @@ if (typeof require !== "undefined" && require.main === module) {
|
|
|
4712
4620
|
hermesHome,
|
|
4713
4621
|
hermesHomes,
|
|
4714
4622
|
hermesHostCommand,
|
|
4715
|
-
hermesHostEvidence,
|
|
4716
4623
|
hermesHostPresent,
|
|
4717
4624
|
hubStatus,
|
|
4718
4625
|
hubStatusReport,
|
package/package.json
CHANGED