omnius 1.0.866 → 1.0.868
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/assets/fonts/DepartureMono-LICENSE.txt +93 -0
- package/assets/licenses/Prism-1.29.0-LICENSE.txt +21 -0
- package/dist/api/py-embed.js +32 -4
- package/dist/index.js +2 -2
- package/dist/library.js +1212 -1084
- package/dist/tui/native/worker.js +863 -159
- package/dist/update-worker.js +147 -81
- package/docs/DISCOVERY.json +10535 -8877
- package/docs/DISCOVERY.md +37 -7
- package/docs/design/dashboard-TODO.md +86 -0
- package/docs/design/dashboard-reconstruction-plan.md +58 -0
- package/docs/design/dashboard-styleguide.md +86 -0
- package/docs/design/media-unification-TODO.md +78 -0
- package/docs/design/media-unification-design.md +89 -0
- package/docs/design/update-operation-cancellation.md +40 -0
- package/docs/design/update-session-restoration-TODO.md +30 -0
- package/docs/work-orders/evidence/dashboard-browser-reconstruction-20261016.json +75 -0
- package/docs/work-orders/evidence/dashboard-media-management-20261016.json +145 -0
- package/docs/work-orders/evidence/instrument-media-live-20261016/media-audio-playing.png +0 -0
- package/docs/work-orders/evidence/instrument-media-live-20261016/media-image-100x30.png +0 -0
- package/docs/work-orders/evidence/instrument-media-live-20261016/media-image-120x36.png +0 -0
- package/docs/work-orders/evidence/instrument-media-live-20261016/media-image-160x48.png +0 -0
- package/docs/work-orders/evidence/instrument-media-live-20261016/media-image-60x20.png +0 -0
- package/docs/work-orders/evidence/instrument-media-live-20261016/media-image-80x24.png +0 -0
- package/docs/work-orders/evidence/instrument-media-live-20261016/media-progress-collapsed.png +0 -0
- package/docs/work-orders/evidence/instrument-media-live-20261016/media-video-frame-a.png +0 -0
- package/docs/work-orders/evidence/instrument-media-live-20261016/media-video-frame-b.png +0 -0
- package/docs/work-orders/evidence/instrument-media-live-20261016/media-voice-autocomplete-junction.png +0 -0
- package/docs/work-orders/evidence/instrument-media-live-20261016/report.json +813 -0
- package/docs/work-orders/evidence/instrument-media-verification-20261016.json +59 -0
- package/docs/work-orders/evidence/native-interface-state-verification-20261016.json +59 -0
- package/docs/work-orders/evidence/native-straight-boundaries-verification-20261016.json +36 -0
- package/docs/work-orders/evidence/project-media-unification-20261016.json +108 -0
- package/docs/work-orders/instrument-tui.md +17 -7
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/dist/update-worker.js
CHANGED
|
@@ -1944,12 +1944,23 @@ var init_venv_paths = __esm({
|
|
|
1944
1944
|
}
|
|
1945
1945
|
});
|
|
1946
1946
|
|
|
1947
|
+
// packages/execution/dist/tools/media-store-lease.js
|
|
1948
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
1949
|
+
var ownedLease;
|
|
1950
|
+
var init_media_store_lease = __esm({
|
|
1951
|
+
"packages/execution/dist/tools/media-store-lease.js"() {
|
|
1952
|
+
"use strict";
|
|
1953
|
+
ownedLease = new AsyncLocalStorage();
|
|
1954
|
+
}
|
|
1955
|
+
});
|
|
1956
|
+
|
|
1947
1957
|
// packages/execution/dist/tools/model-store.js
|
|
1948
1958
|
import { homedir, platform } from "node:os";
|
|
1949
1959
|
var platformId;
|
|
1950
1960
|
var init_model_store = __esm({
|
|
1951
1961
|
"packages/execution/dist/tools/model-store.js"() {
|
|
1952
1962
|
"use strict";
|
|
1963
|
+
init_media_store_lease();
|
|
1953
1964
|
platformId = platform();
|
|
1954
1965
|
}
|
|
1955
1966
|
});
|
|
@@ -2578,12 +2589,21 @@ var init_identity_kernel = __esm({
|
|
|
2578
2589
|
}
|
|
2579
2590
|
});
|
|
2580
2591
|
|
|
2592
|
+
// packages/execution/dist/tools/media-progress.js
|
|
2593
|
+
var init_media_progress = __esm({
|
|
2594
|
+
"packages/execution/dist/tools/media-progress.js"() {
|
|
2595
|
+
"use strict";
|
|
2596
|
+
}
|
|
2597
|
+
});
|
|
2598
|
+
|
|
2581
2599
|
// packages/execution/dist/tools/audio-generate.js
|
|
2582
2600
|
var DIFFUSERS_AUDIO_RUNNER, AUDIOCRAFT_RUNNER, TRANSFORMERS_AUDIO_RUNNER, TANGOFLUX_RUNNER;
|
|
2583
2601
|
var init_audio_generate = __esm({
|
|
2584
2602
|
"packages/execution/dist/tools/audio-generate.js"() {
|
|
2585
2603
|
"use strict";
|
|
2586
2604
|
init_process_async();
|
|
2605
|
+
init_media_progress();
|
|
2606
|
+
init_media_store_lease();
|
|
2587
2607
|
init_model_broker();
|
|
2588
2608
|
init_venv_paths();
|
|
2589
2609
|
init_model_store();
|
|
@@ -247721,8 +247741,8 @@ init_process_lifecycle();
|
|
|
247721
247741
|
init_process_lifecycle();
|
|
247722
247742
|
|
|
247723
247743
|
// packages/execution/dist/run-context.js
|
|
247724
|
-
import { AsyncLocalStorage } from "node:async_hooks";
|
|
247725
|
-
var runContextStorage = new
|
|
247744
|
+
import { AsyncLocalStorage as AsyncLocalStorage2 } from "node:async_hooks";
|
|
247745
|
+
var runContextStorage = new AsyncLocalStorage2();
|
|
247726
247746
|
|
|
247727
247747
|
// packages/execution/dist/tools/shell.js
|
|
247728
247748
|
init_process_kill();
|
|
@@ -295756,12 +295776,12 @@ init_venv_paths();
|
|
|
295756
295776
|
init_process_lifecycle();
|
|
295757
295777
|
|
|
295758
295778
|
// packages/execution/dist/tools/playwright-browser.js
|
|
295759
|
-
import { AsyncLocalStorage as
|
|
295779
|
+
import { AsyncLocalStorage as AsyncLocalStorage3 } from "node:async_hooks";
|
|
295760
295780
|
init_process_async();
|
|
295761
295781
|
import { dirname as dirname2, isAbsolute as isAbsolute2, join as join2, resolve as resolve2 } from "node:path";
|
|
295762
295782
|
import { homedir as homedir3 } from "node:os";
|
|
295763
295783
|
init_vision();
|
|
295764
|
-
var browserSessionScope = new
|
|
295784
|
+
var browserSessionScope = new AsyncLocalStorage3();
|
|
295765
295785
|
var PLAYWRIGHT_RUNTIME_DIR = join2(homedir3(), ".omnius", "playwright-runtime");
|
|
295766
295786
|
var PLAYWRIGHT_BROWSERS_DIR = join2(PLAYWRIGHT_RUNTIME_DIR, "browsers");
|
|
295767
295787
|
|
|
@@ -296859,6 +296879,10 @@ init_process_lifecycle();
|
|
|
296859
296879
|
init_identity_kernel();
|
|
296860
296880
|
|
|
296861
296881
|
// packages/execution/dist/tools/image-generate.js
|
|
296882
|
+
init_process_async();
|
|
296883
|
+
import { AsyncLocalStorage as AsyncLocalStorage4 } from "node:async_hooks";
|
|
296884
|
+
init_media_progress();
|
|
296885
|
+
init_media_store_lease();
|
|
296862
296886
|
init_model_broker();
|
|
296863
296887
|
init_venv_paths();
|
|
296864
296888
|
init_model_store();
|
|
@@ -297678,6 +297702,7 @@ def main():
|
|
|
297678
297702
|
if __name__ == "__main__":
|
|
297679
297703
|
main()
|
|
297680
297704
|
`;
|
|
297705
|
+
var imageInvocationSignal = new AsyncLocalStorage4();
|
|
297681
297706
|
|
|
297682
297707
|
// packages/execution/dist/index.js
|
|
297683
297708
|
init_audio_generate();
|
|
@@ -297685,6 +297710,7 @@ init_cuda_device_filter();
|
|
|
297685
297710
|
init_model_store();
|
|
297686
297711
|
|
|
297687
297712
|
// packages/execution/dist/tools/media-store-migrate.js
|
|
297713
|
+
init_media_store_lease();
|
|
297688
297714
|
init_model_store();
|
|
297689
297715
|
|
|
297690
297716
|
// packages/execution/dist/av/media-capability.js
|
|
@@ -297703,6 +297729,8 @@ var execFileAsync2 = promisify3(execFile3);
|
|
|
297703
297729
|
|
|
297704
297730
|
// packages/execution/dist/tools/video-generate.js
|
|
297705
297731
|
init_process_async();
|
|
297732
|
+
init_media_progress();
|
|
297733
|
+
init_media_store_lease();
|
|
297706
297734
|
init_model_broker();
|
|
297707
297735
|
init_venv_paths();
|
|
297708
297736
|
init_model_store();
|
|
@@ -300136,6 +300164,7 @@ import {
|
|
|
300136
300164
|
chmodSync,
|
|
300137
300165
|
closeSync as closeSync3,
|
|
300138
300166
|
existsSync as existsSync6,
|
|
300167
|
+
lstatSync,
|
|
300139
300168
|
mkdirSync as mkdirSync5,
|
|
300140
300169
|
openSync as openSync3,
|
|
300141
300170
|
readFileSync as readFileSync6,
|
|
@@ -300202,6 +300231,41 @@ function compareOmniusVersions(left, right) {
|
|
|
300202
300231
|
}
|
|
300203
300232
|
|
|
300204
300233
|
// packages/cli/src/update-service.ts
|
|
300234
|
+
var UpdateCancelledError = class extends Error {
|
|
300235
|
+
constructor(message = "Update cancelled. Package changes already made are retained; no rollback is claimed.") {
|
|
300236
|
+
super(message);
|
|
300237
|
+
this.name = "UpdateCancelledError";
|
|
300238
|
+
}
|
|
300239
|
+
};
|
|
300240
|
+
function cancellationPath(operationId, paths) {
|
|
300241
|
+
if (!/^[a-zA-Z0-9_-]{1,128}$/.test(operationId)) throw new Error("Invalid update operation identity");
|
|
300242
|
+
return join15(paths.stateDir, `cancel-${operationId}.json`);
|
|
300243
|
+
}
|
|
300244
|
+
function watchUpdateCancellation(operationId, paths = resolveUpdatePaths()) {
|
|
300245
|
+
const controller = new AbortController();
|
|
300246
|
+
const path3 = cancellationPath(operationId, paths);
|
|
300247
|
+
const check = () => {
|
|
300248
|
+
if (controller.signal.aborted) return;
|
|
300249
|
+
try {
|
|
300250
|
+
const metadata = lstatSync(path3);
|
|
300251
|
+
if (!metadata.isFile() || metadata.isSymbolicLink() || metadata.size > 1024) return;
|
|
300252
|
+
const request = JSON.parse(readFileSync6(path3, "utf8"));
|
|
300253
|
+
const state = readUpdateState(paths);
|
|
300254
|
+
if (state?.operation_id === operationId && state.status === "running" && state.cancel_token_hash && request.operation_id === operationId && request.token_hash === state.cancel_token_hash) controller.abort(new UpdateCancelledError());
|
|
300255
|
+
} catch {
|
|
300256
|
+
}
|
|
300257
|
+
};
|
|
300258
|
+
check();
|
|
300259
|
+
const timer = setInterval(check, 100);
|
|
300260
|
+
timer.unref?.();
|
|
300261
|
+
return { signal: controller.signal, close() {
|
|
300262
|
+
clearInterval(timer);
|
|
300263
|
+
try {
|
|
300264
|
+
unlinkSync3(path3);
|
|
300265
|
+
} catch {
|
|
300266
|
+
}
|
|
300267
|
+
} };
|
|
300268
|
+
}
|
|
300205
300269
|
function resolveUpdatePaths(env = process.env, platform2 = process.platform, home = homedir15()) {
|
|
300206
300270
|
const stateBase = platform2 === "win32" ? env["LOCALAPPDATA"] || join15(home, "AppData", "Local") : platform2 === "darwin" ? join15(home, "Library", "Application Support") : env["XDG_STATE_HOME"] || join15(home, ".local", "state");
|
|
300207
300271
|
const cacheBase = platform2 === "win32" ? env["LOCALAPPDATA"] || join15(home, "AppData", "Local") : platform2 === "darwin" ? join15(home, "Library", "Caches") : env["XDG_CACHE_HOME"] || join15(home, ".cache");
|
|
@@ -300308,13 +300372,15 @@ function commandVersion(value) {
|
|
|
300308
300372
|
const match2 = value.match(/(?:^|\s)v?(\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?)(?:\s|$)/);
|
|
300309
300373
|
return match2?.[1] ?? null;
|
|
300310
300374
|
}
|
|
300311
|
-
async function
|
|
300375
|
+
async function runUpdateCommand(command, args, options = {}) {
|
|
300312
300376
|
if (options.signal?.aborted) {
|
|
300313
300377
|
return { status: null, stdout: "", stderr: "command cancelled", signal: null, error: new Error("command cancelled") };
|
|
300314
300378
|
}
|
|
300315
300379
|
return await new Promise((resolve10) => {
|
|
300316
300380
|
const child = spawn2(command, args, {
|
|
300317
300381
|
env: options.env ?? process.env,
|
|
300382
|
+
cwd: options.cwd,
|
|
300383
|
+
shell: options.shell,
|
|
300318
300384
|
stdio: options.inherit ? ["ignore", "inherit", "inherit"] : ["ignore", "pipe", "pipe"],
|
|
300319
300385
|
windowsHide: true,
|
|
300320
300386
|
detached: process.platform !== "win32"
|
|
@@ -300326,12 +300392,19 @@ async function runCommand(command, args, options = {}) {
|
|
|
300326
300392
|
let stopping = false;
|
|
300327
300393
|
let timer;
|
|
300328
300394
|
let forceTimer;
|
|
300329
|
-
let settlementTimer;
|
|
300330
300395
|
const capture = (current, chunk) => `${current}${chunk.toString()}`.slice(-256 * 1024);
|
|
300331
300396
|
const signalChild = (signal) => {
|
|
300332
300397
|
try {
|
|
300333
300398
|
if (child.pid && process.platform !== "win32") process.kill(-child.pid, signal);
|
|
300334
|
-
else child.
|
|
300399
|
+
else if (child.pid && process.platform === "win32") {
|
|
300400
|
+
const killer = spawn2("taskkill", ["/pid", String(child.pid), "/t", "/f"], { stdio: "ignore", windowsHide: true });
|
|
300401
|
+
killer.once("error", () => {
|
|
300402
|
+
try {
|
|
300403
|
+
child.kill(signal);
|
|
300404
|
+
} catch {
|
|
300405
|
+
}
|
|
300406
|
+
});
|
|
300407
|
+
} else child.kill(signal);
|
|
300335
300408
|
} catch {
|
|
300336
300409
|
}
|
|
300337
300410
|
};
|
|
@@ -300342,15 +300415,12 @@ async function runCommand(command, args, options = {}) {
|
|
|
300342
300415
|
signalChild("SIGTERM");
|
|
300343
300416
|
forceTimer = setTimeout(() => signalChild("SIGKILL"), 1e3);
|
|
300344
300417
|
forceTimer.unref?.();
|
|
300345
|
-
settlementTimer = setTimeout(() => finish({ status: null, stdout, stderr, signal: null, error }), 2e3);
|
|
300346
|
-
settlementTimer.unref?.();
|
|
300347
300418
|
};
|
|
300348
300419
|
const finish = (result) => {
|
|
300349
300420
|
if (settled) return;
|
|
300350
300421
|
settled = true;
|
|
300351
300422
|
clearTimeout(timer);
|
|
300352
300423
|
if (forceTimer) clearTimeout(forceTimer);
|
|
300353
|
-
if (settlementTimer) clearTimeout(settlementTimer);
|
|
300354
300424
|
options.signal?.removeEventListener("abort", onAbort);
|
|
300355
300425
|
resolve10(result);
|
|
300356
300426
|
};
|
|
@@ -300358,20 +300428,27 @@ async function runCommand(command, args, options = {}) {
|
|
|
300358
300428
|
terminate(new Error("command cancelled"));
|
|
300359
300429
|
};
|
|
300360
300430
|
options.signal?.addEventListener("abort", onAbort, { once: true });
|
|
300431
|
+
if (options.signal?.aborted) onAbort();
|
|
300361
300432
|
child.stdout?.on("data", (chunk) => {
|
|
300362
300433
|
stdout = capture(stdout, chunk);
|
|
300434
|
+
options.onStdout?.(chunk.toString());
|
|
300363
300435
|
});
|
|
300364
300436
|
child.stderr?.on("data", (chunk) => {
|
|
300365
300437
|
stderr = capture(stderr, chunk);
|
|
300438
|
+
options.onStderr?.(chunk.toString());
|
|
300366
300439
|
});
|
|
300367
300440
|
child.once("error", (error) => finish({ status: null, stdout, stderr, signal: null, error }));
|
|
300368
|
-
child.once("close", (status, signal) =>
|
|
300441
|
+
child.once("close", (status, signal) => {
|
|
300442
|
+
if (stopping) signalChild("SIGKILL");
|
|
300443
|
+
finish({ status, stdout, stderr, signal, ...stopError ? { error: stopError } : {} });
|
|
300444
|
+
});
|
|
300369
300445
|
timer = setTimeout(() => {
|
|
300370
300446
|
terminate(new Error(`command timed out after ${options.timeout ?? 15e3}ms`));
|
|
300371
300447
|
}, options.timeout ?? 15e3);
|
|
300372
300448
|
timer.unref?.();
|
|
300373
300449
|
});
|
|
300374
300450
|
}
|
|
300451
|
+
var runCommand = runUpdateCommand;
|
|
300375
300452
|
function globalPackageCandidates(prefix) {
|
|
300376
300453
|
return process.platform === "win32" ? [join15(prefix, "node_modules", "omnius", "package.json"), join15(prefix, "omnius", "package.json")] : [join15(prefix, "lib", "node_modules", "omnius", "package.json"), join15(prefix, "node_modules", "omnius", "package.json")];
|
|
300377
300454
|
}
|
|
@@ -300433,71 +300510,38 @@ async function quiesceDaemonWithRetry(quiesce, attempts = 3, pauseMs = 250) {
|
|
|
300433
300510
|
}
|
|
300434
300511
|
return false;
|
|
300435
300512
|
}
|
|
300436
|
-
function installGlobalPackageStreaming(input) {
|
|
300437
|
-
|
|
300438
|
-
|
|
300439
|
-
|
|
300440
|
-
|
|
300441
|
-
|
|
300442
|
-
|
|
300443
|
-
|
|
300444
|
-
|
|
300445
|
-
|
|
300446
|
-
|
|
300447
|
-
|
|
300448
|
-
|
|
300449
|
-
|
|
300450
|
-
|
|
300451
|
-
"-g",
|
|
300452
|
-
`omnius@${input.targetVersion}`,
|
|
300453
|
-
"--prefer-online",
|
|
300454
|
-
"--no-audit",
|
|
300455
|
-
"--no-fund",
|
|
300456
|
-
"--no-progress"
|
|
300457
|
-
],
|
|
300458
|
-
{
|
|
300459
|
-
env: input.env,
|
|
300460
|
-
stdio: ["ignore", "pipe", "pipe"],
|
|
300461
|
-
windowsHide: true
|
|
300462
|
-
}
|
|
300463
|
-
);
|
|
300464
|
-
child.stdout?.on("data", (chunk) => {
|
|
300465
|
-
process.stdout.write(chunk);
|
|
300466
|
-
});
|
|
300467
|
-
child.stderr?.on("data", (chunk) => {
|
|
300468
|
-
const text2 = String(chunk);
|
|
300469
|
-
process.stderr.write(text2);
|
|
300470
|
-
stderrTail.push(text2);
|
|
300471
|
-
while (stderrTail.join("").length > 8e3 && stderrTail.length > 1) stderrTail.shift();
|
|
300472
|
-
});
|
|
300473
|
-
child.once("error", (error) => finish(-1, error.message));
|
|
300474
|
-
child.once("close", (code, signal) => {
|
|
300475
|
-
const exitCode = code ?? -1;
|
|
300476
|
-
const evidence = stderrTail.join("").trim();
|
|
300477
|
-
finish(
|
|
300478
|
-
exitCode,
|
|
300479
|
-
exitCode === 0 ? void 0 : timedOut ? "npm install timed out after 5 minutes" : evidence || `npm install exited with ${signal ? `signal ${signal}` : `code ${exitCode}`}`
|
|
300480
|
-
);
|
|
300481
|
-
});
|
|
300482
|
-
const timer = setTimeout(() => {
|
|
300483
|
-
timedOut = true;
|
|
300484
|
-
try {
|
|
300485
|
-
child.kill("SIGTERM");
|
|
300486
|
-
} catch {
|
|
300487
|
-
}
|
|
300488
|
-
const forceTimer = setTimeout(() => {
|
|
300489
|
-
try {
|
|
300490
|
-
child.kill("SIGKILL");
|
|
300491
|
-
} catch {
|
|
300492
|
-
}
|
|
300493
|
-
}, 2500);
|
|
300494
|
-
forceTimer.unref?.();
|
|
300495
|
-
}, 5 * 6e4);
|
|
300513
|
+
async function installGlobalPackageStreaming(input) {
|
|
300514
|
+
const result = await runUpdateCommand(input.npmPath, [
|
|
300515
|
+
"install",
|
|
300516
|
+
"-g",
|
|
300517
|
+
`omnius@${input.targetVersion}`,
|
|
300518
|
+
"--prefer-online",
|
|
300519
|
+
"--no-audit",
|
|
300520
|
+
"--no-fund",
|
|
300521
|
+
"--no-progress"
|
|
300522
|
+
], {
|
|
300523
|
+
env: input.env,
|
|
300524
|
+
signal: input.signal,
|
|
300525
|
+
timeout: 5 * 6e4,
|
|
300526
|
+
onStdout: (text2) => process.stdout.write(text2),
|
|
300527
|
+
onStderr: (text2) => process.stderr.write(text2)
|
|
300496
300528
|
});
|
|
300529
|
+
const exitCode = result.status ?? -1;
|
|
300530
|
+
return { exitCode, ...result.error || exitCode !== 0 ? {
|
|
300531
|
+
error: result.error?.message || result.stderr.slice(-8e3).trim() || `npm install exited with ${result.signal || exitCode}`
|
|
300532
|
+
} : {} };
|
|
300497
300533
|
}
|
|
300498
300534
|
async function runVerifiedUpdateTransaction(initial, dependencies, paths = resolveUpdatePaths()) {
|
|
300499
300535
|
let state = initial;
|
|
300500
300536
|
let daemonQuiesced = false;
|
|
300537
|
+
let installStarted = false;
|
|
300538
|
+
const throwIfCancelled = () => {
|
|
300539
|
+
if (dependencies.signal?.aborted) throw new UpdateCancelledError();
|
|
300540
|
+
};
|
|
300541
|
+
const onCancel = () => {
|
|
300542
|
+
if (state.status === "running") state = transition(state, { phase: "cancelling" }, paths);
|
|
300543
|
+
};
|
|
300544
|
+
dependencies.signal?.addEventListener("abort", onCancel, { once: true });
|
|
300501
300545
|
const target = assertExactUpdateTarget(initial.target_version);
|
|
300502
300546
|
const npmPath = resolveNpmPath();
|
|
300503
300547
|
const env = {
|
|
@@ -300509,6 +300553,7 @@ async function runVerifiedUpdateTransaction(initial, dependencies, paths = resol
|
|
|
300509
300553
|
OMNIUS_UPDATE_COORDINATED: "1"
|
|
300510
300554
|
};
|
|
300511
300555
|
try {
|
|
300556
|
+
throwIfCancelled();
|
|
300512
300557
|
if (dependencies.quiesceDaemon) {
|
|
300513
300558
|
state = transition(state, { phase: "daemon_quiescing" }, paths);
|
|
300514
300559
|
if (!await quiesceDaemonWithRetry(dependencies.quiesceDaemon)) {
|
|
@@ -300517,20 +300562,25 @@ async function runVerifiedUpdateTransaction(initial, dependencies, paths = resol
|
|
|
300517
300562
|
);
|
|
300518
300563
|
}
|
|
300519
300564
|
daemonQuiesced = true;
|
|
300565
|
+
throwIfCancelled();
|
|
300520
300566
|
}
|
|
300521
|
-
const prefixProbe = await runCommand(npmPath, ["prefix", "-g"], { env, timeout: 1e4 });
|
|
300567
|
+
const prefixProbe = await runCommand(npmPath, ["prefix", "-g"], { env, timeout: 1e4, signal: dependencies.signal });
|
|
300568
|
+
throwIfCancelled();
|
|
300522
300569
|
state = transition(state, {
|
|
300523
300570
|
phase: "installing",
|
|
300524
300571
|
npm_path: npmPath,
|
|
300525
300572
|
...prefixProbe.status === 0 && prefixProbe.stdout.trim() ? { npm_prefix: prefixProbe.stdout.trim() } : {}
|
|
300526
300573
|
}, paths);
|
|
300527
300574
|
const installer = dependencies.install ?? installGlobalPackageStreaming;
|
|
300528
|
-
|
|
300575
|
+
installStarted = true;
|
|
300576
|
+
const installResult = await installer({ npmPath, targetVersion: target, env, signal: dependencies.signal });
|
|
300529
300577
|
state = transition(state, { installer_exit_code: installResult.exitCode }, paths);
|
|
300578
|
+
throwIfCancelled();
|
|
300530
300579
|
if (installResult.exitCode !== 0) {
|
|
300531
300580
|
throw new Error(installResult.error || `npm install exited with code ${installResult.exitCode}`);
|
|
300532
300581
|
}
|
|
300533
300582
|
const evidence = dependencies.inspectInstall ? await dependencies.inspectInstall(target, npmPath, env) : await inspectGlobalOmniusInstall(target, { npmPath, env });
|
|
300583
|
+
throwIfCancelled();
|
|
300534
300584
|
state = transition(state, {
|
|
300535
300585
|
phase: "package_verified",
|
|
300536
300586
|
npm_prefix: evidence.npmPrefix,
|
|
@@ -300544,8 +300594,10 @@ async function runVerifiedUpdateTransaction(initial, dependencies, paths = resol
|
|
|
300544
300594
|
let daemon = null;
|
|
300545
300595
|
let restartAcknowledged = false;
|
|
300546
300596
|
for (let attempt = 1; attempt <= 3; attempt++) {
|
|
300597
|
+
throwIfCancelled();
|
|
300547
300598
|
restartAcknowledged = await dependencies.restartDaemon(target, evidence.executablePath) || restartAcknowledged;
|
|
300548
300599
|
daemon = await dependencies.observeDaemon();
|
|
300600
|
+
throwIfCancelled();
|
|
300549
300601
|
if (daemon?.bootVersion === target && daemon.bootPackageHash === evidence.packageHash) {
|
|
300550
300602
|
break;
|
|
300551
300603
|
}
|
|
@@ -300572,12 +300624,14 @@ async function runVerifiedUpdateTransaction(initial, dependencies, paths = resol
|
|
|
300572
300624
|
daemon_boot_hash: daemon.bootPackageHash
|
|
300573
300625
|
}, paths);
|
|
300574
300626
|
if (state.tray_was_running && dependencies.restartTray) {
|
|
300627
|
+
throwIfCancelled();
|
|
300575
300628
|
state = transition(state, { phase: "tray_restarting" }, paths);
|
|
300576
300629
|
if (!await dependencies.restartTray(evidence.executablePath)) {
|
|
300577
300630
|
throw new Error("The package and daemon updated, but the running tray could not be relaunched");
|
|
300578
300631
|
}
|
|
300579
300632
|
state = transition(state, { tray_restarted: true }, paths);
|
|
300580
300633
|
}
|
|
300634
|
+
throwIfCancelled();
|
|
300581
300635
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
300582
300636
|
state = transition(state, {
|
|
300583
300637
|
status: "completed",
|
|
@@ -300588,25 +300642,32 @@ async function runVerifiedUpdateTransaction(initial, dependencies, paths = resol
|
|
|
300588
300642
|
}, paths);
|
|
300589
300643
|
return state;
|
|
300590
300644
|
} catch (error) {
|
|
300645
|
+
const cancelled = error instanceof UpdateCancelledError || dependencies.signal?.aborted === true;
|
|
300591
300646
|
const message = error instanceof Error ? error.message : String(error);
|
|
300592
300647
|
let recoveryNote;
|
|
300593
300648
|
if (daemonQuiesced && dependencies.recoverDaemon) {
|
|
300649
|
+
state = transition(state, { phase: "recovering" }, paths);
|
|
300594
300650
|
try {
|
|
300595
300651
|
const recovered = await dependencies.recoverDaemon();
|
|
300596
|
-
recoveryNote = recovered ? "The
|
|
300652
|
+
recoveryNote = recovered ? "The daemon was restarted after the interrupted update." : "The daemon could not be recovered automatically after the failed update.";
|
|
300597
300653
|
} catch (recoveryError) {
|
|
300598
300654
|
recoveryNote = `Daemon recovery failed: ${recoveryError instanceof Error ? recoveryError.message : String(recoveryError)}`;
|
|
300599
300655
|
}
|
|
300600
300656
|
}
|
|
300601
300657
|
state = transition(state, {
|
|
300602
|
-
status: "failed",
|
|
300603
|
-
phase: "failed",
|
|
300658
|
+
status: cancelled ? "cancelled" : "failed",
|
|
300659
|
+
phase: cancelled ? "cancelled" : "failed",
|
|
300604
300660
|
completed_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
300605
|
-
error: message,
|
|
300606
|
-
remediation: [
|
|
300661
|
+
error: cancelled ? "Update cancelled after the owned operation settled." : message,
|
|
300662
|
+
remediation: [
|
|
300663
|
+
cancelled && installStarted ? "Package files may have changed. No rollback was performed; verify the installed version before retrying." : void 0,
|
|
300664
|
+
permissionRemediation(message),
|
|
300665
|
+
recoveryNote
|
|
300666
|
+
].filter(Boolean).join(" ") || void 0
|
|
300607
300667
|
}, paths);
|
|
300608
300668
|
return state;
|
|
300609
300669
|
} finally {
|
|
300670
|
+
dependencies.signal?.removeEventListener("abort", onCancel);
|
|
300610
300671
|
releaseUpdateLock(paths, initial.operation_id);
|
|
300611
300672
|
}
|
|
300612
300673
|
}
|
|
@@ -300952,20 +301013,25 @@ async function main() {
|
|
|
300952
301013
|
const port = Number(new URL(endpoint).port || "11435");
|
|
300953
301014
|
const trayWasRunning = state.tray_was_running || (await getTrayStatus(endpoint)).running;
|
|
300954
301015
|
state.tray_was_running = trayWasRunning;
|
|
301016
|
+
const cancellation = watchUpdateCancellation(operationId, paths);
|
|
300955
301017
|
const finalState = await runVerifiedUpdateTransaction(
|
|
300956
301018
|
state,
|
|
300957
301019
|
{
|
|
300958
301020
|
quiesceDaemon: () => quiesceDaemonForUpdate(port),
|
|
300959
301021
|
restartDaemon: (expected, executable) => restartDaemon(port, expected, executable),
|
|
300960
|
-
recoverDaemon: () =>
|
|
301022
|
+
recoverDaemon: async () => {
|
|
301023
|
+
await restartDaemon(port);
|
|
301024
|
+
return Boolean(await getDaemonReportedIdentity(port));
|
|
301025
|
+
},
|
|
300961
301026
|
observeDaemon: async () => {
|
|
300962
301027
|
const identity = await getDaemonReportedIdentity(port);
|
|
300963
301028
|
return identity ? { bootVersion: identity.bootVersion, bootPackageHash: identity.bootPackageHash } : null;
|
|
300964
301029
|
},
|
|
300965
|
-
restartTray: trayWasRunning ? (executable) => restartTrayWithInstalledExecutable(executable, endpoint) : void 0
|
|
301030
|
+
restartTray: trayWasRunning ? (executable) => restartTrayWithInstalledExecutable(executable, endpoint) : void 0,
|
|
301031
|
+
signal: cancellation.signal
|
|
300966
301032
|
},
|
|
300967
301033
|
paths
|
|
300968
|
-
);
|
|
301034
|
+
).finally(() => cancellation.close());
|
|
300969
301035
|
process.exitCode = finalState.status === "completed" ? 0 : 1;
|
|
300970
301036
|
}
|
|
300971
301037
|
void main().catch((error) => {
|