omnius 1.0.966 → 1.0.967
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/_types/execution/shell-runs.d.ts +1 -1
- package/dist/_types/execution/types.d.ts +18 -0
- package/dist/_types/orchestrator/agenticRunner.d.ts +7 -0
- package/dist/_types/orchestrator/owned-inference-wait.d.ts +3 -0
- package/dist/_types/orchestrator/owned-model-wait.d.ts +7 -0
- package/dist/_types/orchestrator/taskRequirements.d.ts +7 -0
- package/dist/index.js +2 -2
- package/dist/library.js +266 -48
- package/dist/postinstall-daemon.cjs +34 -31
- package/dist/update-worker-runtime.js +133 -76
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
|
@@ -689,9 +689,24 @@ function cleanNexus() {
|
|
|
689
689
|
|
|
690
690
|
// ─── Linux: systemd user unit ───────────────────────────────────────────────
|
|
691
691
|
|
|
692
|
-
function
|
|
693
|
-
if (
|
|
694
|
-
|
|
692
|
+
function userSystemctl(user) {
|
|
693
|
+
if (process.getuid && process.getuid() === 0 && user && user !== "root") {
|
|
694
|
+
var uid = runCapture("id -u " + shellQuote(user));
|
|
695
|
+
if (/^\d+$/.test(uid)) {
|
|
696
|
+
return "sudo -n -u " + shellQuote(user) + " XDG_RUNTIME_DIR=/run/user/" + uid +
|
|
697
|
+
" DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/" + uid + "/bus systemctl --user";
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
return "systemctl --user";
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
function discoverSystemdOwner(user, capture) {
|
|
704
|
+
if (!IS_LINUX) return null;
|
|
705
|
+
var request = " show " + SERVICE_LABEL + ".service --property=LoadState,ActiveState";
|
|
706
|
+
var system = capture("systemctl" + request);
|
|
707
|
+
if (/^LoadState=loaded$/m.test(system) && /^ActiveState=(active|activating|reloading|deactivating)$/m.test(system)) return "system";
|
|
708
|
+
if (/^LoadState=loaded$/m.test(capture(userSystemctl(user) + request))) return "user";
|
|
709
|
+
return /^LoadState=loaded$/m.test(system) ? "system" : null;
|
|
695
710
|
}
|
|
696
711
|
|
|
697
712
|
function installDesktopCompanion(nodeBin, omniusScript, user) {
|
|
@@ -734,9 +749,10 @@ function installDesktopCompanion(nodeBin, omniusScript, user) {
|
|
|
734
749
|
// Linger is a one-time account setting. Re-requesting it on every update can
|
|
735
750
|
// raise a polkit password prompt, so ask only when it is off and never
|
|
736
751
|
// interactively; a missing grant is reported instead of prompting.
|
|
737
|
-
function ensureLinger(user
|
|
738
|
-
if (runCapture(
|
|
739
|
-
|
|
752
|
+
function ensureLinger(user) {
|
|
753
|
+
if (runCapture("loginctl show-user " + shellQuote(user) + " --property=Linger --value") === "yes") return;
|
|
754
|
+
var prefix = process.getuid && process.getuid() === 0 ? "" : "sudo -n ";
|
|
755
|
+
if (!runQuiet(prefix + "loginctl --no-ask-password enable-linger " + shellQuote(user))) {
|
|
740
756
|
warn("User services stop at logout until linger is enabled once: loginctl enable-linger " + user);
|
|
741
757
|
}
|
|
742
758
|
}
|
|
@@ -766,7 +782,7 @@ function ensureDeclaredDaemonEnvironmentFiles(sysctl, userHome, user) {
|
|
|
766
782
|
}
|
|
767
783
|
}
|
|
768
784
|
|
|
769
|
-
function installSystemd(nodeBin, omniusScript, user) {
|
|
785
|
+
function installSystemd(nodeBin, omniusScript, user, owner) {
|
|
770
786
|
if (!IS_LINUX) return false;
|
|
771
787
|
if (!hasCmd("systemctl")) {
|
|
772
788
|
warn("systemctl not found — skipping systemd install.");
|
|
@@ -781,7 +797,7 @@ function installSystemd(nodeBin, omniusScript, user) {
|
|
|
781
797
|
}
|
|
782
798
|
} catch (e) {}
|
|
783
799
|
|
|
784
|
-
if (
|
|
800
|
+
if (owner === "system") {
|
|
785
801
|
log("Native system daemon unit is installed; preserving its launcher and sole service ownership.");
|
|
786
802
|
ensureDeclaredDaemonEnvironmentFiles("systemctl", userHome, user);
|
|
787
803
|
return true;
|
|
@@ -861,23 +877,9 @@ function installSystemd(nodeBin, omniusScript, user) {
|
|
|
861
877
|
return false;
|
|
862
878
|
}
|
|
863
879
|
|
|
864
|
-
//
|
|
865
|
-
|
|
866
|
-
var
|
|
867
|
-
if (!IS_WIN && process.getuid && process.getuid() === 0 && user !== "root") {
|
|
868
|
-
// Try to resolve UID for the target user.
|
|
869
|
-
var uid = runCapture("id -u " + user);
|
|
870
|
-
if (uid && /^\d+$/.test(uid)) {
|
|
871
|
-
// Ensure loginctl linger so user services can run without a session.
|
|
872
|
-
ensureLinger(user);
|
|
873
|
-
asUserPrefix = "sudo -u " + user + " XDG_RUNTIME_DIR=/run/user/" + uid + " DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/" + uid + "/bus ";
|
|
874
|
-
}
|
|
875
|
-
} else if (!IS_WIN && process.getuid && process.getuid() !== 0) {
|
|
876
|
-
// Self-install: enable-linger ourselves if we can (best-effort; needs sudo on most distros).
|
|
877
|
-
ensureLinger(user);
|
|
878
|
-
}
|
|
879
|
-
|
|
880
|
-
var sysctl = asUserPrefix + "systemctl --user";
|
|
880
|
+
// Linger is account setup. Existing unit updates only use the user manager.
|
|
881
|
+
if (!owner) ensureLinger(user);
|
|
882
|
+
var sysctl = userSystemctl(user);
|
|
881
883
|
runQuiet(sysctl + " daemon-reload");
|
|
882
884
|
ensureDeclaredDaemonEnvironmentFiles(sysctl, userHome, user);
|
|
883
885
|
// A unit that previously failed (e.g. a missing EnvironmentFile) can be
|
|
@@ -1235,19 +1237,20 @@ function main() {
|
|
|
1235
1237
|
// the new service-managed daemon fails to bind port 11435 and the user
|
|
1236
1238
|
// ends up running stale in-memory code from the previous version.
|
|
1237
1239
|
progress(6, INSTALL_STEPS, "Clearing daemon port");
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1240
|
+
var owner = discoverSystemdOwner(effectiveUser(), runCapture);
|
|
1241
|
+
if (owner) {
|
|
1242
|
+
log("The " + owner + " service owns daemon restart; skipping standalone process signals.");
|
|
1243
|
+
return runMainAfterKill(owner);
|
|
1241
1244
|
}
|
|
1242
1245
|
stopAttestedDaemonPortHolder(PORT, function (killedCount) {
|
|
1243
1246
|
if (killedCount > 0) {
|
|
1244
1247
|
log("Killed " + killedCount + " stale daemon process(es) holding port " + PORT + ".");
|
|
1245
1248
|
}
|
|
1246
|
-
runMainAfterKill();
|
|
1249
|
+
runMainAfterKill(owner);
|
|
1247
1250
|
});
|
|
1248
1251
|
}
|
|
1249
1252
|
|
|
1250
|
-
function runMainAfterKill() {
|
|
1253
|
+
function runMainAfterKill(owner) {
|
|
1251
1254
|
// Fast path: daemon already answering /health on the target port.
|
|
1252
1255
|
// After forceKillPortHolder, this should be false unless a service manager
|
|
1253
1256
|
// already auto-restarted (rare race). We still check so the rest of the
|
|
@@ -1285,7 +1288,7 @@ function runMainAfterKill() {
|
|
|
1285
1288
|
|
|
1286
1289
|
var ok = false;
|
|
1287
1290
|
if (IS_LINUX) {
|
|
1288
|
-
ok = installSystemd(nodeBin, omniusScript, user);
|
|
1291
|
+
ok = installSystemd(nodeBin, omniusScript, user, owner);
|
|
1289
1292
|
} else if (IS_MAC) {
|
|
1290
1293
|
ok = installLaunchd(nodeBin, omniusScript, user);
|
|
1291
1294
|
} else if (IS_WIN) {
|
|
@@ -5141,6 +5141,14 @@ var init_verificationRevision = __esm({
|
|
|
5141
5141
|
}
|
|
5142
5142
|
});
|
|
5143
5143
|
|
|
5144
|
+
// packages/execution/dist/focusedPythonAssertion.js
|
|
5145
|
+
var init_focusedPythonAssertion = __esm({
|
|
5146
|
+
"packages/execution/dist/focusedPythonAssertion.js"() {
|
|
5147
|
+
"use strict";
|
|
5148
|
+
init_verificationCommand();
|
|
5149
|
+
}
|
|
5150
|
+
});
|
|
5151
|
+
|
|
5144
5152
|
// packages/execution/dist/system-auth.js
|
|
5145
5153
|
var init_system_auth = __esm({
|
|
5146
5154
|
"packages/execution/dist/system-auth.js"() {
|
|
@@ -5180,6 +5188,7 @@ var init_shell = __esm({
|
|
|
5180
5188
|
init_verificationCommand();
|
|
5181
5189
|
init_verificationPreviewReceipt();
|
|
5182
5190
|
init_verificationRevision();
|
|
5191
|
+
init_focusedPythonAssertion();
|
|
5183
5192
|
init_system_auth();
|
|
5184
5193
|
init_shell_pipeline_status();
|
|
5185
5194
|
init_shell_observation_only();
|
|
@@ -304304,6 +304313,15 @@ var init_daemon_supervision = __esm({
|
|
|
304304
304313
|
}
|
|
304305
304314
|
});
|
|
304306
304315
|
|
|
304316
|
+
// packages/cli/src/daemon-service-authorization.ts
|
|
304317
|
+
var DaemonServiceAuthorizationError;
|
|
304318
|
+
var init_daemon_service_authorization = __esm({
|
|
304319
|
+
"packages/cli/src/daemon-service-authorization.ts"() {
|
|
304320
|
+
DaemonServiceAuthorizationError = class extends Error {
|
|
304321
|
+
};
|
|
304322
|
+
}
|
|
304323
|
+
});
|
|
304324
|
+
|
|
304307
304325
|
// packages/cli/src/daemon-tray.ts
|
|
304308
304326
|
var daemon_tray_exports = {};
|
|
304309
304327
|
__export(daemon_tray_exports, {
|
|
@@ -304339,32 +304357,31 @@ function daemonSystemctlArgs(scope, args) {
|
|
|
304339
304357
|
return scope === "user" ? ["--user", ...args] : args;
|
|
304340
304358
|
}
|
|
304341
304359
|
async function discoverManagedDaemonService(run2 = runDaemonServiceCommand, requestedScope) {
|
|
304342
|
-
|
|
304360
|
+
const read = async (scope) => {
|
|
304343
304361
|
const result = await run2("systemctl", daemonSystemctlArgs(scope, [
|
|
304344
304362
|
"show",
|
|
304345
304363
|
DAEMON_SERVICE_UNIT,
|
|
304346
|
-
"--property=LoadState,ActiveState,UnitFileState,FragmentPath,User"
|
|
304364
|
+
"--property=LoadState,ActiveState,UnitFileState,FragmentPath,User,ControlGroup"
|
|
304347
304365
|
]), 5e3);
|
|
304348
|
-
if (result.code !== 0)
|
|
304366
|
+
if (result.code !== 0) return null;
|
|
304349
304367
|
const values = Object.fromEntries(result.stdout.split(/\r?\n/).filter((line) => line.includes("=")).map((line) => {
|
|
304350
304368
|
const at = line.indexOf("=");
|
|
304351
304369
|
return [line.slice(0, at), line.slice(at + 1)];
|
|
304352
304370
|
}));
|
|
304353
|
-
if (values.LoadState !== "loaded")
|
|
304371
|
+
if (values.LoadState !== "loaded") return null;
|
|
304354
304372
|
return {
|
|
304355
304373
|
scope,
|
|
304356
304374
|
unit: DAEMON_SERVICE_UNIT,
|
|
304357
304375
|
active: values.ActiveState || "unknown",
|
|
304358
304376
|
enabled: values.UnitFileState || "unknown",
|
|
304359
304377
|
fragmentPath: values.FragmentPath || "",
|
|
304360
|
-
user: values.User || ""
|
|
304378
|
+
user: values.User || "",
|
|
304379
|
+
controlGroup: values.ControlGroup || void 0
|
|
304361
304380
|
};
|
|
304362
|
-
}
|
|
304363
|
-
return
|
|
304364
|
-
|
|
304365
|
-
|
|
304366
|
-
const service = await discoverManagedDaemonService();
|
|
304367
|
-
return runDaemonServiceControl(service?.scope ?? "user", args, timeoutMs);
|
|
304381
|
+
};
|
|
304382
|
+
if (requestedScope) return read(requestedScope);
|
|
304383
|
+
const [system, user] = await Promise.all([read("system"), read("user")]);
|
|
304384
|
+
return system && serviceIsBusy(system.active) ? system : user ?? system;
|
|
304368
304385
|
}
|
|
304369
304386
|
function daemonOwnerAwareRunner(owner, run2 = runDaemonServiceCommand) {
|
|
304370
304387
|
return (command, args, timeoutMs) => command === "systemctl" && args.includes("--user") && process.getuid?.() === 0 && owner && owner.uid !== 0 ? run2("runuser", [
|
|
@@ -304381,6 +304398,12 @@ function daemonOwnerAwareRunner(owner, run2 = runDaemonServiceCommand) {
|
|
|
304381
304398
|
function serviceIsBusy(active) {
|
|
304382
304399
|
return ["active", "activating", "reloading", "deactivating"].includes(active);
|
|
304383
304400
|
}
|
|
304401
|
+
function daemonControlGroupContains(group, cgroup) {
|
|
304402
|
+
return Boolean(group && group !== "/" && cgroup.split(/\r?\n/).some((line) => {
|
|
304403
|
+
const path3 = line.slice(line.indexOf(":", line.indexOf(":") + 1) + 1);
|
|
304404
|
+
return path3 === group || path3.startsWith(`${group}/`);
|
|
304405
|
+
}));
|
|
304406
|
+
}
|
|
304384
304407
|
async function assertNoCompetingDaemonService(scope, owner, run2 = runDaemonServiceCommand) {
|
|
304385
304408
|
const other = await discoverManagedDaemonService(daemonOwnerAwareRunner(owner, run2), scope === "system" ? "user" : "system");
|
|
304386
304409
|
if (other && serviceIsBusy(other.active)) throw new Error(`The ${other.scope} daemon unit is ${other.active}; stop/disable the old ${other.scope} unit first before starting the ${scope} daemon service. No existing service was stopped.`);
|
|
@@ -304422,9 +304445,14 @@ async function ensureManagedDaemonEnvironmentFiles(service, run2 = runDaemonServ
|
|
|
304422
304445
|
}
|
|
304423
304446
|
async function runDaemonServiceControl(scope, args, timeoutMs = 2e4, run2 = runDaemonServiceCommand) {
|
|
304424
304447
|
const commandArgs = daemonSystemctlArgs(scope, ["--no-ask-password", ...args]);
|
|
304425
|
-
|
|
304426
|
-
|
|
304427
|
-
|
|
304448
|
+
if (scope !== "system" || process.getuid?.() === 0 || ["show", "status", "is-active", "is-enabled"].includes(args[0] || "")) {
|
|
304449
|
+
return run2("systemctl", commandArgs, timeoutMs);
|
|
304450
|
+
}
|
|
304451
|
+
const result = await run2("sudo", ["-n", "systemctl", ...commandArgs], timeoutMs);
|
|
304452
|
+
if (!result.available || result.code !== 0 && /^sudo:/m.test(result.stderr)) {
|
|
304453
|
+
throw new DaemonServiceAuthorizationError("System-owned Omnius daemon requires an existing noninteractive administrator grant. Run the update from the owning administrator context or migrate the daemon to user scope once.");
|
|
304454
|
+
}
|
|
304455
|
+
return result;
|
|
304428
304456
|
}
|
|
304429
304457
|
function quote(value) {
|
|
304430
304458
|
if (/[\r\n\0]/.test(value)) throw new Error("Service values must not contain control characters");
|
|
@@ -304602,6 +304630,7 @@ async function daemonServiceAction(action, scope) {
|
|
|
304602
304630
|
var DAEMON_SERVICE_UNIT, DAEMON_SERVICE_STOP_GRACE_MS, DAEMON_SERVICE_COMMAND_TIMEOUT_MS, runDaemonServiceCommand, daemonEnvironmentModule;
|
|
304603
304631
|
var init_daemon_service = __esm({
|
|
304604
304632
|
"packages/cli/src/daemon-service.ts"() {
|
|
304633
|
+
init_daemon_service_authorization();
|
|
304605
304634
|
DAEMON_SERVICE_UNIT = "omnius-daemon.service";
|
|
304606
304635
|
DAEMON_SERVICE_STOP_GRACE_MS = 12e4;
|
|
304607
304636
|
DAEMON_SERVICE_COMMAND_TIMEOUT_MS = 13e4;
|
|
@@ -304850,18 +304879,19 @@ function runUtilityCommand(command, args, timeout) {
|
|
|
304850
304879
|
timer.unref?.();
|
|
304851
304880
|
});
|
|
304852
304881
|
}
|
|
304853
|
-
async function
|
|
304882
|
+
async function runScopedSystemctl(scope, args, timeout = 2e4) {
|
|
304854
304883
|
const commandTimeout = ["stop", "restart", "start"].includes(args[0] || "") ? Math.max(timeout, DAEMON_SERVICE_COMMAND_TIMEOUT_MS) : timeout;
|
|
304855
|
-
const result = await
|
|
304884
|
+
const result = await runDaemonServiceControl(scope, args, commandTimeout);
|
|
304856
304885
|
return { available: result.available, ok: result.code === 0 };
|
|
304857
304886
|
}
|
|
304858
|
-
async function
|
|
304859
|
-
const result = await
|
|
304887
|
+
async function readDaemonServiceEnvironment(scope) {
|
|
304888
|
+
const result = await runDaemonServiceControl(
|
|
304889
|
+
scope,
|
|
304890
|
+
["show", "omnius-daemon.service", "--property", "Environment", "--value"],
|
|
304891
|
+
5e3
|
|
304892
|
+
);
|
|
304860
304893
|
return result.code === 0 ? result.stdout.trim() : null;
|
|
304861
304894
|
}
|
|
304862
|
-
async function hasManagedDaemonService() {
|
|
304863
|
-
return await discoverManagedDaemonService() !== null;
|
|
304864
|
-
}
|
|
304865
304895
|
function daemonPortFromServiceEnvironment(value) {
|
|
304866
304896
|
const host = value.match(/(?:^|\s)OMNIUS_HOST=(?:"([^"]+)"|'([^']+)'|([^\s]+))/)?.slice(1).find(Boolean);
|
|
304867
304897
|
const direct = value.match(/(?:^|\s)OMNIUS_PORT=(?:"(\d+)"|'(\d+)'|(\d+))/)?.slice(1).find(Boolean);
|
|
@@ -304874,17 +304904,18 @@ function daemonServiceMatchesPort(requestedPort, effectiveEnvironment) {
|
|
|
304874
304904
|
const effectivePort = daemonPortFromServiceEnvironment(effectiveEnvironment);
|
|
304875
304905
|
return effectivePort === null ? requestedPort === DEFAULT_PORT2 : effectivePort === requestedPort;
|
|
304876
304906
|
}
|
|
304877
|
-
async function
|
|
304878
|
-
|
|
304879
|
-
|
|
304880
|
-
|
|
304881
|
-
|
|
304882
|
-
|
|
304883
|
-
|
|
304884
|
-
|
|
304885
|
-
|
|
304886
|
-
|
|
304887
|
-
|
|
304907
|
+
async function discoverDaemonServiceAtPort(port, scope) {
|
|
304908
|
+
const service = await discoverManagedDaemonService(void 0, scope);
|
|
304909
|
+
if (!service) return null;
|
|
304910
|
+
const matches = async (candidate) => {
|
|
304911
|
+
const environment = await readDaemonServiceEnvironment(candidate.scope);
|
|
304912
|
+
return environment !== null && daemonServiceMatchesPort(port, environment);
|
|
304913
|
+
};
|
|
304914
|
+
const declared = await matches(service) ? service : null;
|
|
304915
|
+
if (scope || declared && await scopedDaemonServiceOwnsPort(declared, port)) return declared;
|
|
304916
|
+
const other = await discoverManagedDaemonService(void 0, service.scope === "system" ? "user" : "system");
|
|
304917
|
+
if (other && await matches(other) && await scopedDaemonServiceOwnsPort(other, port)) return other;
|
|
304918
|
+
return declared;
|
|
304888
304919
|
}
|
|
304889
304920
|
function pidIsInManagedDaemonUnit(pid, readCgroup = defaultReadProcCgroup) {
|
|
304890
304921
|
const cgroup = readCgroup(pid);
|
|
@@ -304907,18 +304938,23 @@ async function managedDaemonServiceOwnsPort(port, dependencies = {
|
|
|
304907
304938
|
if (uniqueHolders.length === 0) return true;
|
|
304908
304939
|
return uniqueHolders.every((pid) => dependencies.pidInUnit(pid));
|
|
304909
304940
|
}
|
|
304910
|
-
|
|
304941
|
+
function scopedDaemonServiceOwnsPort(service, port) {
|
|
304942
|
+
return managedDaemonServiceOwnsPort(port, {
|
|
304943
|
+
holderPids: portHolderPids,
|
|
304944
|
+
pidInUnit: (pid) => daemonControlGroupContains(service.controlGroup, defaultReadProcCgroup(pid) ?? "")
|
|
304945
|
+
});
|
|
304946
|
+
}
|
|
304947
|
+
async function repairManagedDaemonUnit(managed, port, preferredEntrypoint) {
|
|
304911
304948
|
if (process.platform !== "linux") return false;
|
|
304912
304949
|
const command = await resolveDaemonCommand(process.execPath, preferredEntrypoint);
|
|
304913
304950
|
if (!command) return false;
|
|
304914
304951
|
try {
|
|
304915
|
-
const
|
|
304916
|
-
const scope = managed?.scope ?? "user";
|
|
304952
|
+
const scope = managed.scope;
|
|
304917
304953
|
if (scope === "system" && process.getuid?.() !== 0) return false;
|
|
304918
304954
|
if (command.args[0] === "serve") return false;
|
|
304919
304955
|
const definition = await resolveDaemonServiceDefinition({
|
|
304920
304956
|
scope,
|
|
304921
|
-
user: managed
|
|
304957
|
+
user: managed.user || void 0,
|
|
304922
304958
|
entrypoint: command.args[0],
|
|
304923
304959
|
nodePath: command.command,
|
|
304924
304960
|
port,
|
|
@@ -304927,12 +304963,15 @@ async function repairManagedDaemonUnit(port, preferredEntrypoint) {
|
|
|
304927
304963
|
const unitDir = scope === "system" ? "/etc/systemd/system" : join15(definition.homeDir, ".config", "systemd", "user");
|
|
304928
304964
|
const unitPath = join15(unitDir, "omnius-daemon.service");
|
|
304929
304965
|
mkdirSync6(unitDir, { recursive: true });
|
|
304930
|
-
const priorUnitPath = managed
|
|
304931
|
-
const
|
|
304932
|
-
const
|
|
304933
|
-
|
|
304934
|
-
|
|
304935
|
-
|
|
304966
|
+
const priorUnitPath = managed.fragmentPath || unitPath;
|
|
304967
|
+
const priorUnit = existsSync7(priorUnitPath) ? readFileSync6(priorUnitPath, "utf8") : null;
|
|
304968
|
+
const unit = priorUnit === null ? buildDaemonSystemdUnit(definition) : repairDaemonSystemdUnit(priorUnit, definition);
|
|
304969
|
+
if (priorUnitPath !== unitPath || priorUnit !== unit) {
|
|
304970
|
+
const tmp = `${unitPath}.tmp.${process.pid}.${Date.now()}`;
|
|
304971
|
+
writeFileSync4(tmp, unit, { encoding: "utf8", mode: 384 });
|
|
304972
|
+
renameSync4(tmp, unitPath);
|
|
304973
|
+
}
|
|
304974
|
+
return (await runScopedSystemctl(scope, ["daemon-reload"], 1e4)).ok;
|
|
304936
304975
|
} catch {
|
|
304937
304976
|
return false;
|
|
304938
304977
|
}
|
|
@@ -305090,34 +305129,39 @@ async function reclaimOwnedDaemonListener(port = getDaemonPort(), dependencies =
|
|
|
305090
305129
|
}
|
|
305091
305130
|
return { ok: true, action: "cleared", port, clearedPids, blockedPids: [] };
|
|
305092
305131
|
}
|
|
305093
|
-
async function restartDaemon(port, expectedVersion, preferredEntrypoint) {
|
|
305132
|
+
async function restartDaemon(port, expectedVersion, preferredEntrypoint, serviceScope) {
|
|
305094
305133
|
const p = port ?? getDaemonPort();
|
|
305095
305134
|
const supervision = readDaemonSupervisionHealth(p);
|
|
305096
305135
|
if (supervision.degraded && supervision.retryAfterMs > 0) return false;
|
|
305097
|
-
const managed = await
|
|
305136
|
+
const managed = serviceScope === null ? null : await discoverDaemonServiceAtPort(p, serviceScope);
|
|
305137
|
+
if (serviceScope && !managed) return false;
|
|
305098
305138
|
if (managed) {
|
|
305099
|
-
if (!await
|
|
305139
|
+
if (!await scopedDaemonServiceOwnsPort(managed, p)) {
|
|
305140
|
+
const holders = await portHolderPids(p);
|
|
305141
|
+
if (!holders || holders.some((pid2) => pidIsInManagedDaemonUnit(pid2))) return false;
|
|
305100
305142
|
const reclaimed2 = await reclaimOwnedDaemonListener(p);
|
|
305101
305143
|
if (!reclaimed2.ok) return false;
|
|
305102
305144
|
await reclaimStaleDaemonEndpointClaim(p, new Set(reclaimed2.clearedPids));
|
|
305103
305145
|
}
|
|
305146
|
+
const scope = managed.scope;
|
|
305104
305147
|
try {
|
|
305105
|
-
await ensureManagedDaemonEnvironmentFiles();
|
|
305148
|
+
await ensureManagedDaemonEnvironmentFiles(managed);
|
|
305106
305149
|
} catch {
|
|
305107
305150
|
}
|
|
305108
|
-
await
|
|
305109
|
-
|
|
305151
|
+
const repairedBeforeRestart = Boolean(preferredEntrypoint && await repairManagedDaemonUnit(managed, p, preferredEntrypoint));
|
|
305152
|
+
await runScopedSystemctl(scope, ["reset-failed", "omnius-daemon.service"]);
|
|
305153
|
+
const restarted = await runScopedSystemctl(scope, ["restart", "omnius-daemon.service"]);
|
|
305110
305154
|
if (restarted.ok && (await waitForDaemonReady(p, expectedVersion)).ok) return true;
|
|
305111
|
-
const repaired = await repairManagedDaemonUnit(p, preferredEntrypoint);
|
|
305155
|
+
const repaired = !repairedBeforeRestart && await repairManagedDaemonUnit(managed, p, preferredEntrypoint);
|
|
305112
305156
|
if (repaired) {
|
|
305113
|
-
await
|
|
305157
|
+
await runScopedSystemctl(scope, ["stop", "omnius-daemon.service"]);
|
|
305114
305158
|
await waitForDaemonStopped(p);
|
|
305115
|
-
await
|
|
305116
|
-
const started = await
|
|
305159
|
+
await runScopedSystemctl(scope, ["reset-failed", "omnius-daemon.service"]);
|
|
305160
|
+
const started = await runScopedSystemctl(scope, ["start", "omnius-daemon.service"]);
|
|
305117
305161
|
if (started.ok && (await waitForDaemonReady(p, expectedVersion)).ok) return true;
|
|
305118
305162
|
}
|
|
305119
|
-
if (await reinstallUserDaemonService(p, expectedVersion, preferredEntrypoint)) return true;
|
|
305120
|
-
await
|
|
305163
|
+
if (scope === "user" && await reinstallUserDaemonService(p, expectedVersion, preferredEntrypoint)) return true;
|
|
305164
|
+
await runScopedSystemctl(scope, ["stop", "omnius-daemon.service"]);
|
|
305121
305165
|
if (!await waitForDaemonStopped(p)) {
|
|
305122
305166
|
const reclaimed2 = await reclaimOwnedDaemonListener(p);
|
|
305123
305167
|
if (!reclaimed2.ok) return false;
|
|
@@ -305172,7 +305216,7 @@ async function resolveDaemonCommand(nodeExe, preferredEntrypoint) {
|
|
|
305172
305216
|
async function reinstallUserDaemonService(port, expectedVersion, preferredEntrypoint) {
|
|
305173
305217
|
if (process.platform !== "linux" || process.getuid?.() === 0) return false;
|
|
305174
305218
|
try {
|
|
305175
|
-
if (
|
|
305219
|
+
if (!await discoverDaemonServiceAtPort(port, "user")) return false;
|
|
305176
305220
|
const command = await resolveDaemonCommand(process.execPath, preferredEntrypoint);
|
|
305177
305221
|
if (!command || command.args[0] === "serve") return false;
|
|
305178
305222
|
await installDaemonService({
|
|
@@ -305185,7 +305229,7 @@ async function reinstallUserDaemonService(port, expectedVersion, preferredEntryp
|
|
|
305185
305229
|
enable: true,
|
|
305186
305230
|
start: false
|
|
305187
305231
|
});
|
|
305188
|
-
await
|
|
305232
|
+
await runScopedSystemctl("user", ["stop", "omnius-daemon.service"]);
|
|
305189
305233
|
await waitForDaemonStopped(port);
|
|
305190
305234
|
await daemonServiceAction("start", "user");
|
|
305191
305235
|
return (await waitForDaemonReady(port, expectedVersion)).ok;
|
|
@@ -305260,28 +305304,29 @@ async function startDaemon(port = getDaemonPort(), preferredEntrypoint) {
|
|
|
305260
305304
|
}
|
|
305261
305305
|
}
|
|
305262
305306
|
}
|
|
305263
|
-
async function stopDaemonAtPort(port = getDaemonPort(), dependencies
|
|
305264
|
-
|
|
305265
|
-
|
|
305266
|
-
|
|
305267
|
-
}
|
|
305268
|
-
const reclaimed = await dependencies.reclaimListener(port);
|
|
305307
|
+
async function stopDaemonAtPort(port = getDaemonPort(), dependencies) {
|
|
305308
|
+
const deps = dependencies ?? daemonStopDependencies(await discoverDaemonServiceAtPort(port));
|
|
305309
|
+
if (await deps.managedServiceMatchesPort(port)) return await deps.stopManagedService() && await deps.waitForStopped(port);
|
|
305310
|
+
const reclaimed = await deps.reclaimListener(port);
|
|
305269
305311
|
if (!reclaimed.ok) return false;
|
|
305270
|
-
const claimCleared = await
|
|
305312
|
+
const claimCleared = await deps.reclaimClaim(
|
|
305271
305313
|
port,
|
|
305272
305314
|
new Set(reclaimed.clearedPids)
|
|
305273
305315
|
);
|
|
305274
|
-
return claimCleared &&
|
|
305316
|
+
return claimCleared && deps.waitForStopped(port);
|
|
305275
305317
|
}
|
|
305276
|
-
async function quiesceDaemonForUpdate(port = getDaemonPort()) {
|
|
305277
|
-
|
|
305318
|
+
async function quiesceDaemonForUpdate(port = getDaemonPort(), scope) {
|
|
305319
|
+
const managed = scope === null ? null : await discoverDaemonServiceAtPort(port, scope);
|
|
305320
|
+
if (scope && !managed) return false;
|
|
305321
|
+
return stopDaemonAtPort(port, daemonStopDependencies(managed));
|
|
305278
305322
|
}
|
|
305279
|
-
var OMNIUS_DIR, PID_FILE, DEFAULT_PORT2, LOCK_INITIALIZATION_GRACE_MS, DAEMON_GRACEFUL_STOP_ATTEMPTS, DEFAULT_RECLAIM_DEPENDENCIES, DEFAULT_CLAIM_RECLAIM_DEPENDENCIES,
|
|
305323
|
+
var OMNIUS_DIR, PID_FILE, DEFAULT_PORT2, LOCK_INITIALIZATION_GRACE_MS, DAEMON_GRACEFUL_STOP_ATTEMPTS, DEFAULT_RECLAIM_DEPENDENCIES, DEFAULT_CLAIM_RECLAIM_DEPENDENCIES, daemonStopDependencies;
|
|
305280
305324
|
var init_daemon = __esm({
|
|
305281
305325
|
"packages/cli/src/daemon.ts"() {
|
|
305282
305326
|
init_dist5();
|
|
305283
305327
|
init_daemon_supervision();
|
|
305284
305328
|
init_daemon_service();
|
|
305329
|
+
init_daemon_service_authorization();
|
|
305285
305330
|
OMNIUS_DIR = process.env["OMNIUS_HOME"]?.trim() || join15(homedir15(), ".omnius");
|
|
305286
305331
|
PID_FILE = join15(OMNIUS_DIR, "daemon.pid");
|
|
305287
305332
|
DEFAULT_PORT2 = 11435;
|
|
@@ -305302,13 +305347,17 @@ var init_daemon = __esm({
|
|
|
305302
305347
|
stopLease: (leaseId, port) => stopDaemonLeaseGracefully(leaseId, `stale daemon endpoint claim on port ${port}`),
|
|
305303
305348
|
removeLockIfUnchanged: (port, expected) => removeDaemonLockIfUnchanged(port, expected)
|
|
305304
305349
|
};
|
|
305305
|
-
|
|
305306
|
-
managedServiceMatchesPort: (port) =>
|
|
305307
|
-
stopManagedService: async () => (await
|
|
305350
|
+
daemonStopDependencies = (managed) => ({
|
|
305351
|
+
managedServiceMatchesPort: async (port) => Boolean(managed && await scopedDaemonServiceOwnsPort(managed, port)),
|
|
305352
|
+
stopManagedService: async () => Boolean(managed && (await runScopedSystemctl(managed.scope, ["stop", managed.unit])).ok),
|
|
305308
305353
|
waitForStopped: (port) => waitForDaemonStopped(port),
|
|
305309
|
-
reclaimListener: (port) =>
|
|
305354
|
+
reclaimListener: async (port) => {
|
|
305355
|
+
const holders = await portHolderPids(port);
|
|
305356
|
+
const unitPids = holders?.filter((pid) => pidIsInManagedDaemonUnit(pid));
|
|
305357
|
+
return unitPids?.length ? { ok: false, action: "blocked", port, clearedPids: [], blockedPids: unitPids, reason: "Listener belongs to a different systemd service scope" } : reclaimOwnedDaemonListener(port);
|
|
305358
|
+
},
|
|
305310
305359
|
reclaimClaim: (port, verifiedStoppedPids) => reclaimStaleDaemonEndpointClaim(port, verifiedStoppedPids)
|
|
305311
|
-
};
|
|
305360
|
+
});
|
|
305312
305361
|
}
|
|
305313
305362
|
});
|
|
305314
305363
|
|
|
@@ -305396,6 +305445,9 @@ function compareOmniusVersions(left, right) {
|
|
|
305396
305445
|
return 0;
|
|
305397
305446
|
}
|
|
305398
305447
|
|
|
305448
|
+
// packages/cli/src/update-service.ts
|
|
305449
|
+
init_daemon_service_authorization();
|
|
305450
|
+
|
|
305399
305451
|
// packages/cli/src/user-systemd-environment.ts
|
|
305400
305452
|
import { lstatSync as lstatSync2 } from "node:fs";
|
|
305401
305453
|
function userManagerEnvironment(env, uid = process.getuid?.(), inspect = lstatSync2) {
|
|
@@ -306472,7 +306524,8 @@ async function quiesceDaemonWithRetry(quiesce, attempts = 3, pauseMs = 250) {
|
|
|
306472
306524
|
for (let attempt = 1; attempt <= boundedAttempts; attempt++) {
|
|
306473
306525
|
try {
|
|
306474
306526
|
if (await quiesce()) return true;
|
|
306475
|
-
} catch {
|
|
306527
|
+
} catch (error) {
|
|
306528
|
+
if (error instanceof DaemonServiceAuthorizationError) throw error;
|
|
306476
306529
|
}
|
|
306477
306530
|
if (attempt < boundedAttempts && pauseMs > 0) {
|
|
306478
306531
|
await new Promise((resolve13) => setTimeout(resolve13, pauseMs));
|
|
@@ -307960,13 +308013,17 @@ async function runUpdateWorkerRuntime(state, paths, endpoint) {
|
|
|
307960
308013
|
const port = Number(new URL(endpoint).port || "11435");
|
|
307961
308014
|
const trayWasRunning = state.tray_was_running || !cancellation.signal.aborted && (await getTrayStatus(endpoint)).running;
|
|
307962
308015
|
state.tray_was_running = trayWasRunning;
|
|
308016
|
+
let daemonScope;
|
|
307963
308017
|
const finalState = await runVerifiedUpdateTransaction(
|
|
307964
308018
|
state,
|
|
307965
308019
|
{
|
|
307966
|
-
quiesceDaemon: () =>
|
|
307967
|
-
|
|
308020
|
+
quiesceDaemon: async () => {
|
|
308021
|
+
if (daemonScope === void 0) daemonScope = (await discoverDaemonServiceAtPort(port))?.scope ?? null;
|
|
308022
|
+
return quiesceDaemonForUpdate(port, daemonScope);
|
|
308023
|
+
},
|
|
308024
|
+
restartDaemon: (expected, executable) => restartDaemon(port, expected, executable, daemonScope),
|
|
307968
308025
|
recoverDaemon: async () => {
|
|
307969
|
-
await restartDaemon(port);
|
|
308026
|
+
await restartDaemon(port, void 0, void 0, daemonScope);
|
|
307970
308027
|
return Boolean(await getDaemonReportedIdentity(port));
|
|
307971
308028
|
},
|
|
307972
308029
|
observeDaemon: async () => {
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "omnius",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.967",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "omnius",
|
|
9
|
-
"version": "1.0.
|
|
9
|
+
"version": "1.0.967",
|
|
10
10
|
"hasInstallScript": true,
|
|
11
11
|
"license": "CC-BY-NC-4.0",
|
|
12
12
|
"dependencies": {
|
package/package.json
CHANGED