@floless/app 0.121.0 → 0.123.0
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/floless-server.cjs +863 -380
- package/dist/schemas/steel.model.v2.schema.json +3 -1
- package/dist/skills/floless-app-steel-takeoff/SKILL.md +332 -37
- package/dist/web/aware-update-client.js +77 -4
- package/dist/web/aware.js +153 -22
- package/dist/web/grid-core.js +11 -1
- package/dist/web/index.html +4 -1
- package/dist/web/steel-3d-core.js +10 -6
- package/dist/web/steel-3d-view.js +213 -19
- package/dist/web/steel-editor.html +138 -7
- package/dist/web/steel-model-adapter.js +16 -18
- package/dist/web/steel-model-commands.js +4 -4
- package/dist/web/steel-plan-transform.js +8 -6
- package/dist/web/steel-view-generation.js +0 -2
- package/dist/web/workspaces.js +10 -66
- package/package.json +2 -1
package/dist/floless-server.cjs
CHANGED
|
@@ -32061,7 +32061,7 @@ var require_parse_url = __commonJS({
|
|
|
32061
32061
|
var require_form_data = __commonJS({
|
|
32062
32062
|
"node_modules/light-my-request/lib/form-data.js"(exports2, module2) {
|
|
32063
32063
|
"use strict";
|
|
32064
|
-
var { randomUUID:
|
|
32064
|
+
var { randomUUID: randomUUID24 } = require("node:crypto");
|
|
32065
32065
|
var { Readable: Readable3 } = require("node:stream");
|
|
32066
32066
|
var textEncoder;
|
|
32067
32067
|
function isFormDataLike(payload) {
|
|
@@ -32069,7 +32069,7 @@ var require_form_data = __commonJS({
|
|
|
32069
32069
|
}
|
|
32070
32070
|
function formDataToStream(formdata) {
|
|
32071
32071
|
textEncoder = textEncoder ?? new TextEncoder();
|
|
32072
|
-
const boundary = `----formdata-${
|
|
32072
|
+
const boundary = `----formdata-${randomUUID24()}`;
|
|
32073
32073
|
const prefix = `--${boundary}\r
|
|
32074
32074
|
Content-Disposition: form-data`;
|
|
32075
32075
|
const escape2 = (str5) => str5.replace(/\n/g, "%0A").replace(/\r/g, "%0D").replace(/"/g, "%22");
|
|
@@ -50829,7 +50829,7 @@ var import_node_readline2 = require("node:readline");
|
|
|
50829
50829
|
var import_node_url5 = require("node:url");
|
|
50830
50830
|
var import_node_path57 = require("node:path");
|
|
50831
50831
|
var import_node_os29 = require("node:os");
|
|
50832
|
-
var
|
|
50832
|
+
var import_node_fs60 = require("node:fs");
|
|
50833
50833
|
var import_node_child_process11 = require("node:child_process");
|
|
50834
50834
|
var import_node_util4 = require("node:util");
|
|
50835
50835
|
|
|
@@ -52400,6 +52400,13 @@ function parseTrace(text3) {
|
|
|
52400
52400
|
// aware-lifecycle-gate.ts
|
|
52401
52401
|
var import_node_async_hooks2 = require("node:async_hooks");
|
|
52402
52402
|
var OWNER_BRAND = /* @__PURE__ */ Symbol("aware-lifecycle-owner");
|
|
52403
|
+
var AwareMaintenanceBusyError = class extends Error {
|
|
52404
|
+
code = "maintenance-busy";
|
|
52405
|
+
constructor(message = "AWARE is busy with automatic maintenance.") {
|
|
52406
|
+
super(message);
|
|
52407
|
+
this.name = "AwareMaintenanceBusyError";
|
|
52408
|
+
}
|
|
52409
|
+
};
|
|
52403
52410
|
function owner() {
|
|
52404
52411
|
return Object.freeze({ [OWNER_BRAND]: true, id: /* @__PURE__ */ Symbol("aware-owner") });
|
|
52405
52412
|
}
|
|
@@ -52412,9 +52419,12 @@ var AwareLifecycleGate = class {
|
|
|
52412
52419
|
#owners = new import_node_async_hooks2.AsyncLocalStorage();
|
|
52413
52420
|
#readerDepth = /* @__PURE__ */ new Map();
|
|
52414
52421
|
#queue = [];
|
|
52422
|
+
#idleListeners = /* @__PURE__ */ new Set();
|
|
52415
52423
|
#readerCount = 0;
|
|
52416
52424
|
#writer = null;
|
|
52417
52425
|
#writerDepth = 0;
|
|
52426
|
+
#writerOrigin = "user";
|
|
52427
|
+
#wasIdle = true;
|
|
52418
52428
|
currentOwner() {
|
|
52419
52429
|
return this.#owners.getStore() ?? null;
|
|
52420
52430
|
}
|
|
@@ -52426,14 +52436,55 @@ var AwareLifecycleGate = class {
|
|
|
52426
52436
|
queuedWriters: this.#queue.filter((w) => w.mode === "exclusive").length
|
|
52427
52437
|
};
|
|
52428
52438
|
}
|
|
52439
|
+
/** True while unattended maintenance holds or has queued the writer — the refusal condition. */
|
|
52440
|
+
autoWriterActive() {
|
|
52441
|
+
return this.#writer !== null && this.#writerOrigin === "auto" || this.#queue.some((w) => w.mode === "exclusive" && w.origin === "auto");
|
|
52442
|
+
}
|
|
52443
|
+
/** Nothing running and nothing waiting. The only state unattended work may reserve from. */
|
|
52444
|
+
idle() {
|
|
52445
|
+
return this.#writer === null && this.#readerCount === 0 && this.#queue.length === 0;
|
|
52446
|
+
}
|
|
52447
|
+
/**
|
|
52448
|
+
* Edge-triggered idle notification. Unattended maintenance cannot poll for a moment to run:
|
|
52449
|
+
* polling either misses the window or, worse, tempts a snapshot-then-acquire that a trigger can
|
|
52450
|
+
* slip between. Listeners fire on the transition INTO idle; combine with tryWithExclusiveIfIdle,
|
|
52451
|
+
* which re-tests and reserves atomically, so a listener is only ever a hint to try again.
|
|
52452
|
+
*/
|
|
52453
|
+
onIdle(listener) {
|
|
52454
|
+
this.#idleListeners.add(listener);
|
|
52455
|
+
return () => this.#idleListeners.delete(listener);
|
|
52456
|
+
}
|
|
52457
|
+
/**
|
|
52458
|
+
* Test idleness and reserve the writer in ONE synchronous step, or decline without queuing.
|
|
52459
|
+
*
|
|
52460
|
+
* This is the whole reason unattended repair cannot use withExclusive: a queued auto writer
|
|
52461
|
+
* waits behind long-lived trigger sessions that hold shared leases for their entire lifetime.
|
|
52462
|
+
* The gate imposes NO acquisition timeout, so it would wait indefinitely, refuse user work the
|
|
52463
|
+
* whole time under the fail-fast rule, and still repair nothing. Declining is the correct answer
|
|
52464
|
+
* — the caller stays pending and retries on the next idle edge.
|
|
52465
|
+
*/
|
|
52466
|
+
async tryWithExclusiveIfIdle(origin, fn) {
|
|
52467
|
+
if (!this.idle()) return { ran: false };
|
|
52468
|
+
const leaseOwner = owner();
|
|
52469
|
+
this.#writer = leaseOwner;
|
|
52470
|
+
this.#writerDepth = 1;
|
|
52471
|
+
this.#writerOrigin = origin;
|
|
52472
|
+
this.#wasIdle = false;
|
|
52473
|
+
const lease = this.#writerLease(leaseOwner);
|
|
52474
|
+
try {
|
|
52475
|
+
return { ran: true, value: await this.runAs(leaseOwner, fn) };
|
|
52476
|
+
} finally {
|
|
52477
|
+
lease.release();
|
|
52478
|
+
}
|
|
52479
|
+
}
|
|
52429
52480
|
runAs(leaseOwner, fn) {
|
|
52430
52481
|
return this.#owners.run(leaseOwner, fn);
|
|
52431
52482
|
}
|
|
52432
52483
|
acquireShared(signal) {
|
|
52433
|
-
return this.#acquire("shared", signal);
|
|
52484
|
+
return this.#acquire("shared", "user", signal);
|
|
52434
52485
|
}
|
|
52435
|
-
acquireExclusive(signal) {
|
|
52436
|
-
return this.#acquire("exclusive", signal);
|
|
52486
|
+
acquireExclusive(signal, origin = "user") {
|
|
52487
|
+
return this.#acquire("exclusive", origin, signal);
|
|
52437
52488
|
}
|
|
52438
52489
|
async withShared(fn, signal) {
|
|
52439
52490
|
const lease = await this.acquireShared(signal);
|
|
@@ -52443,15 +52494,15 @@ var AwareLifecycleGate = class {
|
|
|
52443
52494
|
lease.release();
|
|
52444
52495
|
}
|
|
52445
52496
|
}
|
|
52446
|
-
async withExclusive(fn, signal) {
|
|
52447
|
-
const lease = await this.acquireExclusive(signal);
|
|
52497
|
+
async withExclusive(fn, signal, origin = "user") {
|
|
52498
|
+
const lease = await this.acquireExclusive(signal, origin);
|
|
52448
52499
|
try {
|
|
52449
52500
|
return await this.runAs(lease.owner, fn);
|
|
52450
52501
|
} finally {
|
|
52451
52502
|
lease.release();
|
|
52452
52503
|
}
|
|
52453
52504
|
}
|
|
52454
|
-
#acquire(mode, signal) {
|
|
52505
|
+
#acquire(mode, origin, signal) {
|
|
52455
52506
|
if (signal?.aborted) return Promise.reject(abortError());
|
|
52456
52507
|
const leaseOwner = this.currentOwner() ?? owner();
|
|
52457
52508
|
if (this.#writer === leaseOwner) {
|
|
@@ -52476,15 +52527,19 @@ var AwareLifecycleGate = class {
|
|
|
52476
52527
|
const writerQueued = this.#queue.some((w) => w.mode === "exclusive");
|
|
52477
52528
|
if (mode === "shared" && this.#writer === null && !writerQueued) {
|
|
52478
52529
|
this.#grantReader(leaseOwner);
|
|
52530
|
+
this.#wasIdle = false;
|
|
52479
52531
|
return Promise.resolve(this.#readerLease(leaseOwner));
|
|
52480
52532
|
}
|
|
52481
52533
|
if (mode === "exclusive" && this.#writer === null && this.#readerCount === 0) {
|
|
52482
52534
|
this.#writer = leaseOwner;
|
|
52483
52535
|
this.#writerDepth = 1;
|
|
52536
|
+
this.#writerOrigin = origin;
|
|
52537
|
+
this.#wasIdle = false;
|
|
52484
52538
|
return Promise.resolve(this.#writerLease(leaseOwner));
|
|
52485
52539
|
}
|
|
52540
|
+
if (this.autoWriterActive()) return Promise.reject(new AwareMaintenanceBusyError());
|
|
52486
52541
|
return new Promise((resolve15, reject) => {
|
|
52487
|
-
const waiter = { mode, owner: leaseOwner, resolve: resolve15, reject, ...signal ? { signal } : {} };
|
|
52542
|
+
const waiter = { mode, origin, owner: leaseOwner, resolve: resolve15, reject, ...signal ? { signal } : {} };
|
|
52488
52543
|
if (signal) {
|
|
52489
52544
|
waiter.onAbort = () => {
|
|
52490
52545
|
const index = this.#queue.indexOf(waiter);
|
|
@@ -52527,16 +52582,40 @@ var AwareLifecycleGate = class {
|
|
|
52527
52582
|
this.#writerDepth--;
|
|
52528
52583
|
if (this.#writerDepth === 0) {
|
|
52529
52584
|
this.#writer = null;
|
|
52585
|
+
this.#writerOrigin = "user";
|
|
52530
52586
|
this.#drain();
|
|
52531
52587
|
}
|
|
52532
52588
|
});
|
|
52533
52589
|
}
|
|
52590
|
+
/**
|
|
52591
|
+
* Edge-triggered, and deliberately so: listeners fire on the transition into idle, never
|
|
52592
|
+
* repeatedly while idle. A listener that throws must not corrupt the gate or stop its peers.
|
|
52593
|
+
*/
|
|
52594
|
+
#maybeEmitIdle() {
|
|
52595
|
+
const nowIdle = this.idle();
|
|
52596
|
+
if (!nowIdle) {
|
|
52597
|
+
this.#wasIdle = false;
|
|
52598
|
+
return;
|
|
52599
|
+
}
|
|
52600
|
+
if (this.#wasIdle) return;
|
|
52601
|
+
this.#wasIdle = true;
|
|
52602
|
+
for (const listener of [...this.#idleListeners]) {
|
|
52603
|
+
try {
|
|
52604
|
+
listener();
|
|
52605
|
+
} catch {
|
|
52606
|
+
}
|
|
52607
|
+
}
|
|
52608
|
+
}
|
|
52534
52609
|
#take(waiter) {
|
|
52535
52610
|
if (waiter.signal && waiter.onAbort) {
|
|
52536
52611
|
waiter.signal.removeEventListener("abort", waiter.onAbort);
|
|
52537
52612
|
}
|
|
52538
52613
|
}
|
|
52539
52614
|
#drain() {
|
|
52615
|
+
this.#drainQueue();
|
|
52616
|
+
this.#maybeEmitIdle();
|
|
52617
|
+
}
|
|
52618
|
+
#drainQueue() {
|
|
52540
52619
|
if (this.#writer !== null || this.#readerCount > 0 || this.#queue.length === 0) return;
|
|
52541
52620
|
const writerIndex = this.#queue.findIndex((w) => w.mode === "exclusive");
|
|
52542
52621
|
if (writerIndex >= 0) {
|
|
@@ -52545,6 +52624,7 @@ var AwareLifecycleGate = class {
|
|
|
52545
52624
|
this.#take(waiter);
|
|
52546
52625
|
this.#writer = waiter.owner;
|
|
52547
52626
|
this.#writerDepth = 1;
|
|
52627
|
+
this.#writerOrigin = waiter.origin;
|
|
52548
52628
|
waiter.resolve(this.#writerLease(waiter.owner));
|
|
52549
52629
|
return;
|
|
52550
52630
|
}
|
|
@@ -52558,7 +52638,9 @@ var AwareLifecycleGate = class {
|
|
|
52558
52638
|
};
|
|
52559
52639
|
var awareLifecycleGate = new AwareLifecycleGate();
|
|
52560
52640
|
var withAwareShared = (fn, signal) => awareLifecycleGate.withShared(fn, signal);
|
|
52561
|
-
var withAwareExclusive = (fn, signal) => awareLifecycleGate.withExclusive(fn, signal);
|
|
52641
|
+
var withAwareExclusive = (fn, signal, origin = "user") => awareLifecycleGate.withExclusive(fn, signal, origin);
|
|
52642
|
+
var tryWithAwareExclusiveIfIdle = (origin, fn) => awareLifecycleGate.tryWithExclusiveIfIdle(origin, fn);
|
|
52643
|
+
var onAwareIdle = (listener) => awareLifecycleGate.onIdle(listener);
|
|
52562
52644
|
var acquireAwareShared = (signal) => awareLifecycleGate.acquireShared(signal);
|
|
52563
52645
|
var runAsAwareOwner = (leaseOwner, fn) => awareLifecycleGate.runAs(leaseOwner, fn);
|
|
52564
52646
|
var currentAwareOwner = () => awareLifecycleGate.currentOwner();
|
|
@@ -54529,7 +54611,7 @@ function appVersion() {
|
|
|
54529
54611
|
return resolveVersion({
|
|
54530
54612
|
isSea: isSea2(),
|
|
54531
54613
|
sqVersionXml: readSqVersionXml(),
|
|
54532
|
-
define: true ? "0.
|
|
54614
|
+
define: true ? "0.123.0" : void 0,
|
|
54533
54615
|
pkgVersion: readPkgVersion()
|
|
54534
54616
|
});
|
|
54535
54617
|
}
|
|
@@ -54545,7 +54627,7 @@ function resolveChannel(s) {
|
|
|
54545
54627
|
function appChannel() {
|
|
54546
54628
|
return resolveChannel({
|
|
54547
54629
|
isSea: isSea2(),
|
|
54548
|
-
define: true ? "0.
|
|
54630
|
+
define: true ? "0.123.0" : void 0,
|
|
54549
54631
|
// argv[1] is the entry the runtime actually loaded (…/dist/floless-server.cjs), which is what
|
|
54550
54632
|
// carries the npx cache prefix. Absent under the SEA exe, which never reaches the npx branch.
|
|
54551
54633
|
modulePath: process.argv[1]
|
|
@@ -57896,7 +57978,7 @@ function bearingFaces(x, uOnN, vOnN, requestedSide) {
|
|
|
57896
57978
|
}
|
|
57897
57979
|
|
|
57898
57980
|
// index.ts
|
|
57899
|
-
var
|
|
57981
|
+
var import_node_crypto32 = require("node:crypto");
|
|
57900
57982
|
|
|
57901
57983
|
// ifc-guid.ts
|
|
57902
57984
|
var import_node_crypto10 = require("node:crypto");
|
|
@@ -59429,6 +59511,10 @@ var import_node_crypto13 = require("node:crypto");
|
|
|
59429
59511
|
|
|
59430
59512
|
// ../web/steel-3d-core.js
|
|
59431
59513
|
var nz = (n) => n + 0;
|
|
59514
|
+
function dispToMm(pt, ptPerFt) {
|
|
59515
|
+
const k = mmPerPx(ptPerFt);
|
|
59516
|
+
return [nz(pt[0] * k), nz(-pt[1] * k)];
|
|
59517
|
+
}
|
|
59432
59518
|
var MODEL_V2_TOL = Object.freeze({
|
|
59433
59519
|
CUT_PLANE_MM: 1.5875,
|
|
59434
59520
|
// 1/16" — a member includes a sheet elevation within this
|
|
@@ -61043,7 +61129,6 @@ function previewMigration(v1, ctx) {
|
|
|
61043
61129
|
}
|
|
61044
61130
|
|
|
61045
61131
|
// ../web/steel-plan-transform.js
|
|
61046
|
-
var FT_MM2 = 304.8;
|
|
61047
61132
|
var finite2 = (p) => Array.isArray(p) && p.length === 2 && p.every(Number.isFinite);
|
|
61048
61133
|
var PlanTransformError = class extends Error {
|
|
61049
61134
|
constructor(code, message, viewKind = null) {
|
|
@@ -61112,10 +61197,10 @@ function planTransform(plan) {
|
|
|
61112
61197
|
const registrationGrid = plan.modelGrid || plan.grid;
|
|
61113
61198
|
const world0 = plan.datum_ref ? gridIntersection(registrationGrid, plan.datum_ref, plan) : [0, 0];
|
|
61114
61199
|
const world1 = gridIntersection(registrationGrid, plan.control2_ref, plan);
|
|
61115
|
-
const
|
|
61200
|
+
const scale = mmPerPx(ptPerFt);
|
|
61116
61201
|
const local1 = [
|
|
61117
|
-
(plan.control2_at[0] - plan.datum_at[0]) *
|
|
61118
|
-
(plan.datum_at[1] - plan.control2_at[1]) *
|
|
61202
|
+
(plan.control2_at[0] - plan.datum_at[0]) * scale,
|
|
61203
|
+
(plan.datum_at[1] - plan.control2_at[1]) * scale
|
|
61119
61204
|
];
|
|
61120
61205
|
const worldDelta = [world1[0] - world0[0], world1[1] - world0[1]];
|
|
61121
61206
|
const localLen = Math.hypot(local1[0], local1[1]);
|
|
@@ -61130,7 +61215,7 @@ function planTransform(plan) {
|
|
|
61130
61215
|
if (![c, s, fitScale, world0[0], world0[1]].every(Number.isFinite)) {
|
|
61131
61216
|
return refuse("registration-invalid", `sheet "${plan.sheet || "?"}" has a non-finite registration transform`, plan);
|
|
61132
61217
|
}
|
|
61133
|
-
return { datumPx: plan.datum_at, world0, mmPerPx:
|
|
61218
|
+
return { datumPx: plan.datum_at, world0, mmPerPx: scale, fitScale, rotation, c, s };
|
|
61134
61219
|
}
|
|
61135
61220
|
|
|
61136
61221
|
// steel-v1-staging-exit.ts
|
|
@@ -66122,10 +66207,6 @@ function pickColor(profile, idx, contract) {
|
|
|
66122
66207
|
const pal = contract.palette && contract.palette.length ? contract.palette : SCENE_DEFAULT_PAL;
|
|
66123
66208
|
return pal[(idx % pal.length + pal.length) % pal.length];
|
|
66124
66209
|
}
|
|
66125
|
-
function dispToMm(pt, ptPerFt) {
|
|
66126
|
-
const k = FT_TO_MM / ptPerFt;
|
|
66127
|
-
return [pt[0] * k, -pt[1] * k];
|
|
66128
|
-
}
|
|
66129
66210
|
function inferMaterial(profile) {
|
|
66130
66211
|
const P = canonicalDesignation(profile);
|
|
66131
66212
|
if (P.startsWith("HSS")) return "A500-GR.B";
|
|
@@ -67890,6 +67971,24 @@ function renderable(o) {
|
|
|
67890
67971
|
const q = o;
|
|
67891
67972
|
return !!q && Array.isArray(q.positions) && Array.isArray(q.indices) && q.positions.length >= 9 && q.indices.length >= 3 && q.positions.length % 3 === 0;
|
|
67892
67973
|
}
|
|
67974
|
+
function toColorRuns(raw, indexCount) {
|
|
67975
|
+
if (!Array.isArray(raw) || raw.length === 0) return void 0;
|
|
67976
|
+
const runs = [];
|
|
67977
|
+
let at = 0;
|
|
67978
|
+
for (const r of raw) {
|
|
67979
|
+
const q = r;
|
|
67980
|
+
if (!q || !Array.isArray(q.rgba) || q.rgba.length !== 4) return void 0;
|
|
67981
|
+
if (!q.rgba.every((v) => typeof v === "number" && Number.isFinite(v) && v >= 0 && v <= 1)) return void 0;
|
|
67982
|
+
if (!Number.isInteger(q.start) || !Number.isInteger(q.count)) return void 0;
|
|
67983
|
+
const start = q.start, count = q.count;
|
|
67984
|
+
if (start !== at || count <= 0) return void 0;
|
|
67985
|
+
if (start % 3 !== 0 || count % 3 !== 0) return void 0;
|
|
67986
|
+
at += count;
|
|
67987
|
+
if (at > indexCount) return void 0;
|
|
67988
|
+
runs.push({ rgba: [q.rgba[0], q.rgba[1], q.rgba[2], q.rgba[3]], start, count });
|
|
67989
|
+
}
|
|
67990
|
+
return at === indexCount ? runs : void 0;
|
|
67991
|
+
}
|
|
67893
67992
|
var FILE_Z_UP = "z-up";
|
|
67894
67993
|
var FILE_Y_UP = "y-up";
|
|
67895
67994
|
function yUpToZUp(positions) {
|
|
@@ -67920,9 +68019,31 @@ function toReferenceObjects(raw) {
|
|
|
67920
68019
|
profile: typeof o.profile === "string" ? o.profile : null,
|
|
67921
68020
|
material: typeof o.material === "string" ? o.material : null,
|
|
67922
68021
|
positions: alreadyZUp ? o.positions.slice() : yUpToZUp(o.positions),
|
|
67923
|
-
indices: o.indices.slice()
|
|
68022
|
+
indices: o.indices.slice(),
|
|
68023
|
+
// The frame correction above rewrites POSITIONS and never touches indices, so a colour run's
|
|
68024
|
+
// window into the index buffer means the same thing whichever branch produced the vertices.
|
|
68025
|
+
...(() => {
|
|
68026
|
+
const colors = toColorRuns(o.colors, o.indices.length);
|
|
68027
|
+
return colors ? { colors } : {};
|
|
68028
|
+
})()
|
|
67924
68029
|
}));
|
|
67925
|
-
|
|
68030
|
+
const offered = all.filter((o) => o && Array.isArray(o.colors) && o.colors.length).length;
|
|
68031
|
+
const colorsDropped = Math.max(0, offered - objects.filter((o) => o.colors).length);
|
|
68032
|
+
const claimed2 = typeof raw.colorsAvailable === "boolean" ? raw.colorsAvailable : null;
|
|
68033
|
+
return {
|
|
68034
|
+
objects,
|
|
68035
|
+
dropped: all.length - objects.length,
|
|
68036
|
+
colorsDropped,
|
|
68037
|
+
// THREE STATES, NOT TWO, and null is the one that earns its keep. `false` says this file authors
|
|
68038
|
+
// no colour and never will; `null` says the bridge predates the field and an install would fix
|
|
68039
|
+
// it (the reference row's "Reload its geometry" forces the re-read that makes that true). Both
|
|
68040
|
+
// render identically — the app's own grey — but the UI must not tell a user "this file has no
|
|
68041
|
+
// colours" when the truth is "your bridge is old", so the difference survives to the client
|
|
68042
|
+
// rather than being flattened here.
|
|
68043
|
+
//
|
|
68044
|
+
// `true` is the one claim that gets checked: it only survives if something can actually be drawn.
|
|
68045
|
+
colorsAvailable: claimed2 === true && offered > 0 && colorsDropped === offered ? false : claimed2
|
|
68046
|
+
};
|
|
67926
68047
|
}
|
|
67927
68048
|
var REFERENCE_DIR = "references";
|
|
67928
68049
|
var SAFE_NAME = /[^A-Za-z0-9._-]+/g;
|
|
@@ -68064,6 +68185,7 @@ function realish(p) {
|
|
|
68064
68185
|
return (0, import_node_path28.resolve)(p);
|
|
68065
68186
|
}
|
|
68066
68187
|
}
|
|
68188
|
+
var REFERENCE_CACHE_VERSION = 3;
|
|
68067
68189
|
var cachePath2 = (projectId, refId2) => (0, import_node_path28.join)(projectDir(projectId), `.floless-refcache-${safeId2(refId2)}.json`);
|
|
68068
68190
|
function safeId2(refId2) {
|
|
68069
68191
|
const s = String(refId2 ?? "").replace(/[^A-Za-z0-9._-]+/g, "_");
|
|
@@ -68108,7 +68230,7 @@ function cachedGeometry(projectId, refId2, expectHash) {
|
|
|
68108
68230
|
if (!(0, import_node_fs32.existsSync)(p)) return null;
|
|
68109
68231
|
try {
|
|
68110
68232
|
const parsed = JSON.parse((0, import_node_fs32.readFileSync)(p, "utf8"));
|
|
68111
|
-
if (!parsed || parsed.v !==
|
|
68233
|
+
if (!parsed || parsed.v !== REFERENCE_CACHE_VERSION || !Array.isArray(parsed.objects)) return null;
|
|
68112
68234
|
if (parsed.sourceHash !== expectHash) return null;
|
|
68113
68235
|
return parsed;
|
|
68114
68236
|
} catch {
|
|
@@ -68293,7 +68415,7 @@ function registerReferenceRoutes(app, deps) {
|
|
|
68293
68415
|
rollback();
|
|
68294
68416
|
return reply.status(400).send({ ok: false, error: `"${displayName}" has no geometry we can draw` });
|
|
68295
68417
|
}
|
|
68296
|
-
writeCache2(g.project, id, { v:
|
|
68418
|
+
writeCache2(g.project, id, { v: REFERENCE_CACHE_VERSION, sourceHash, dropped: geometry.dropped, colorsAvailable: geometry.colorsAvailable, colorsDropped: geometry.colorsDropped, objects: geometry.objects });
|
|
68297
68419
|
const entry2 = {
|
|
68298
68420
|
id,
|
|
68299
68421
|
file: rel,
|
|
@@ -68316,7 +68438,7 @@ function registerReferenceRoutes(app, deps) {
|
|
|
68316
68438
|
});
|
|
68317
68439
|
committed = true;
|
|
68318
68440
|
deps.broadcast(contractChangedEvent(g.appId, g.project, etag, req.headers["x-floless-mutation-id"]));
|
|
68319
|
-
return { ok: true, etag, reference: entry2, objects: geometry.objects, dropped: geometry.dropped, spanMm: spanOf(geometry.objects) };
|
|
68441
|
+
return { ok: true, etag, reference: entry2, objects: geometry.objects, dropped: geometry.dropped, colorsAvailable: geometry.colorsAvailable, colorsDropped: geometry.colorsDropped, spanMm: spanOf(geometry.objects) };
|
|
68320
68442
|
} catch (e) {
|
|
68321
68443
|
rollback();
|
|
68322
68444
|
const r = importRefusal(e);
|
|
@@ -68352,8 +68474,9 @@ function registerReferenceRoutes(app, deps) {
|
|
|
68352
68474
|
} catch {
|
|
68353
68475
|
return reply.status(409).send({ ok: false, code: "reference-unresolved", error: `"${entry2.name}" could not be read` });
|
|
68354
68476
|
}
|
|
68355
|
-
const
|
|
68356
|
-
|
|
68477
|
+
const rebuild = /^(1|true)$/i.test(String(req.query?.rebuild ?? ""));
|
|
68478
|
+
const hit = rebuild ? null : cachedGeometry(g.project, entry2.id, sourceHash);
|
|
68479
|
+
if (hit) return { ok: true, cached: true, objects: hit.objects, dropped: hit.dropped, colorsAvailable: hit.colorsAvailable ?? null, colorsDropped: hit.colorsDropped ?? 0, spanMm: spanOf(hit.objects) };
|
|
68357
68480
|
const scope = runScope(deps, req);
|
|
68358
68481
|
try {
|
|
68359
68482
|
const geometry = await deps.reader.readModel(companion(g.appId), abs, { ticket: scope.ticket() });
|
|
@@ -68364,8 +68487,8 @@ function registerReferenceRoutes(app, deps) {
|
|
|
68364
68487
|
error: `"${entry2.name}" was read, but produced nothing we can draw` + (geometry.dropped ? ` (${geometry.dropped} object${geometry.dropped === 1 ? "" : "s"} had no usable mesh)` : "") + ". The file may be a newer IFC flavour than the reader handles."
|
|
68365
68488
|
});
|
|
68366
68489
|
}
|
|
68367
|
-
writeCache2(g.project, entry2.id, { v:
|
|
68368
|
-
return { ok: true, cached: false, objects: geometry.objects, dropped: geometry.dropped, spanMm: spanOf(geometry.objects) };
|
|
68490
|
+
writeCache2(g.project, entry2.id, { v: REFERENCE_CACHE_VERSION, sourceHash, dropped: geometry.dropped, colorsAvailable: geometry.colorsAvailable, colorsDropped: geometry.colorsDropped, objects: geometry.objects });
|
|
68491
|
+
return { ok: true, cached: false, objects: geometry.objects, dropped: geometry.dropped, colorsAvailable: geometry.colorsAvailable, colorsDropped: geometry.colorsDropped, spanMm: spanOf(geometry.objects) };
|
|
68369
68492
|
} catch (e) {
|
|
68370
68493
|
const r = importRefusal(e);
|
|
68371
68494
|
if (r) return reply.status(r.status).send(r.body);
|
|
@@ -73295,20 +73418,26 @@ function buildApprovalReview(input) {
|
|
|
73295
73418
|
}
|
|
73296
73419
|
|
|
73297
73420
|
// working-revision-manifest.ts
|
|
73421
|
+
var import_node_crypto22 = require("node:crypto");
|
|
73422
|
+
var import_node_fs37 = require("node:fs");
|
|
73423
|
+
var import_node_path33 = require("node:path");
|
|
73424
|
+
|
|
73425
|
+
// write-json-atomic.ts
|
|
73298
73426
|
var import_node_crypto21 = require("node:crypto");
|
|
73299
73427
|
var import_node_fs36 = require("node:fs");
|
|
73300
|
-
|
|
73428
|
+
function writeJsonAtomic(path, value) {
|
|
73429
|
+
const tmp = `${path}.${process.pid}.${(0, import_node_crypto21.randomUUID)()}.tmp`;
|
|
73430
|
+
(0, import_node_fs36.writeFileSync)(tmp, canonicalJson(value));
|
|
73431
|
+
(0, import_node_fs36.renameSync)(tmp, path);
|
|
73432
|
+
}
|
|
73433
|
+
|
|
73434
|
+
// working-revision-manifest.ts
|
|
73301
73435
|
var pathOf = (projectId) => (0, import_node_path33.join)(projectDir(projectId), ".floless-working-revision-state-v1.json");
|
|
73302
73436
|
var checksumOf = (body) => hashOf(body);
|
|
73303
73437
|
function bodyOf(value) {
|
|
73304
73438
|
const { checksum: _checksum, ...body } = value;
|
|
73305
73439
|
return body;
|
|
73306
73440
|
}
|
|
73307
|
-
function atomicWrite(path, value) {
|
|
73308
|
-
const tmp = `${path}.${process.pid}.${(0, import_node_crypto21.randomUUID)()}.tmp`;
|
|
73309
|
-
(0, import_node_fs36.writeFileSync)(tmp, canonicalJson(value));
|
|
73310
|
-
(0, import_node_fs36.renameSync)(tmp, path);
|
|
73311
|
-
}
|
|
73312
73441
|
function assertProject(project) {
|
|
73313
73442
|
if (!project.uuid) throw new Error(`project ${project.id} has no incarnation UUID`);
|
|
73314
73443
|
return project.uuid;
|
|
@@ -73316,7 +73445,7 @@ function assertProject(project) {
|
|
|
73316
73445
|
function readWorkingRevisionManifest(project) {
|
|
73317
73446
|
const uuid = assertProject(project);
|
|
73318
73447
|
try {
|
|
73319
|
-
const value = JSON.parse((0,
|
|
73448
|
+
const value = JSON.parse((0, import_node_fs37.readFileSync)(pathOf(project.id), "utf8"));
|
|
73320
73449
|
if (value?.schema !== 1 || value.projectUuid !== uuid || !Number.isInteger(value.epoch) || value.epoch < 0) return null;
|
|
73321
73450
|
return checksumOf(bodyOf(value)) === value.checksum ? value : null;
|
|
73322
73451
|
} catch {
|
|
@@ -73330,7 +73459,7 @@ function ensureWorkingRevisionManifest(input) {
|
|
|
73330
73459
|
schema: 1,
|
|
73331
73460
|
projectUuid: assertProject(input.project),
|
|
73332
73461
|
publicationIdentity: input.publicationIdentity,
|
|
73333
|
-
revisionId: (0,
|
|
73462
|
+
revisionId: (0, import_node_crypto22.randomUUID)(),
|
|
73334
73463
|
epoch: 0,
|
|
73335
73464
|
source: { kind: "working" },
|
|
73336
73465
|
workingBase: input.workingBase,
|
|
@@ -73338,8 +73467,8 @@ function ensureWorkingRevisionManifest(input) {
|
|
|
73338
73467
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
73339
73468
|
};
|
|
73340
73469
|
const value = { ...body, checksum: checksumOf(body) };
|
|
73341
|
-
(0,
|
|
73342
|
-
if (!(0,
|
|
73470
|
+
(0, import_node_fs37.mkdirSync)(projectDir(input.project.id), { recursive: true });
|
|
73471
|
+
if (!(0, import_node_fs37.existsSync)(pathOf(input.project.id))) writeJsonAtomic(pathOf(input.project.id), value);
|
|
73343
73472
|
return readWorkingRevisionManifest(input.project) ?? value;
|
|
73344
73473
|
}
|
|
73345
73474
|
function advanceWorkingRevisionManifest(input) {
|
|
@@ -73351,7 +73480,7 @@ function advanceWorkingRevisionManifest(input) {
|
|
|
73351
73480
|
if (current.publicationIdentity !== input.publicationIdentity) throw new Error("working revision belongs to another app publication");
|
|
73352
73481
|
const body = {
|
|
73353
73482
|
...bodyOf(current),
|
|
73354
|
-
revisionId: (0,
|
|
73483
|
+
revisionId: (0, import_node_crypto22.randomUUID)(),
|
|
73355
73484
|
epoch: current.epoch + 1,
|
|
73356
73485
|
source: input.source,
|
|
73357
73486
|
workingBase: input.workingBase,
|
|
@@ -73359,7 +73488,7 @@ function advanceWorkingRevisionManifest(input) {
|
|
|
73359
73488
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
73360
73489
|
};
|
|
73361
73490
|
const value = { ...body, checksum: checksumOf(body) };
|
|
73362
|
-
|
|
73491
|
+
writeJsonAtomic(pathOf(input.project.id), value);
|
|
73363
73492
|
return value;
|
|
73364
73493
|
}
|
|
73365
73494
|
function refreshWorkingDraftHash(input) {
|
|
@@ -73370,7 +73499,7 @@ function refreshWorkingDraftHash(input) {
|
|
|
73370
73499
|
}
|
|
73371
73500
|
const body = { ...bodyOf(current), draftHash: hashOf(input.contract), updatedAt: (/* @__PURE__ */ new Date()).toISOString() };
|
|
73372
73501
|
const value = { ...body, checksum: checksumOf(body) };
|
|
73373
|
-
|
|
73502
|
+
writeJsonAtomic(pathOf(input.project.id), value);
|
|
73374
73503
|
return value;
|
|
73375
73504
|
}
|
|
73376
73505
|
|
|
@@ -73590,8 +73719,8 @@ function projectApprovalCandidateAccepted(appId, projectId, candidate) {
|
|
|
73590
73719
|
}
|
|
73591
73720
|
|
|
73592
73721
|
// project-checkpoints-store.ts
|
|
73593
|
-
var
|
|
73594
|
-
var
|
|
73722
|
+
var import_node_crypto23 = require("node:crypto");
|
|
73723
|
+
var import_node_fs38 = require("node:fs");
|
|
73595
73724
|
var import_node_path34 = require("node:path");
|
|
73596
73725
|
var HASH_RE2 = /^[0-9a-f]{64}$/;
|
|
73597
73726
|
function root4(projectId) {
|
|
@@ -73599,14 +73728,9 @@ function root4(projectId) {
|
|
|
73599
73728
|
}
|
|
73600
73729
|
var objectsDir2 = (projectId) => (0, import_node_path34.join)(root4(projectId), "objects");
|
|
73601
73730
|
var eventsPath = (projectId) => (0, import_node_path34.join)(root4(projectId), "events.json");
|
|
73602
|
-
function atomicWrite2(path, value) {
|
|
73603
|
-
const tmp = `${path}.${process.pid}.${(0, import_node_crypto22.randomUUID)()}.tmp`;
|
|
73604
|
-
(0, import_node_fs37.writeFileSync)(tmp, canonicalJson(value));
|
|
73605
|
-
(0, import_node_fs37.renameSync)(tmp, path);
|
|
73606
|
-
}
|
|
73607
73731
|
function readEvents(projectId) {
|
|
73608
73732
|
try {
|
|
73609
|
-
const parsed = JSON.parse((0,
|
|
73733
|
+
const parsed = JSON.parse((0, import_node_fs38.readFileSync)(eventsPath(projectId), "utf8"));
|
|
73610
73734
|
if (parsed?.schema !== 1 || !Array.isArray(parsed.events)) return { schema: 1, events: [] };
|
|
73611
73735
|
return { schema: 1, events: parsed.events.filter(validEvent) };
|
|
73612
73736
|
} catch {
|
|
@@ -73621,7 +73745,7 @@ function validEvent(value) {
|
|
|
73621
73745
|
function readContent(projectId, id) {
|
|
73622
73746
|
if (!HASH_RE2.test(id)) return null;
|
|
73623
73747
|
try {
|
|
73624
|
-
const value = JSON.parse((0,
|
|
73748
|
+
const value = JSON.parse((0, import_node_fs38.readFileSync)((0, import_node_path34.join)(objectsDir2(projectId), `${id}.json`), "utf8"));
|
|
73625
73749
|
if (value?.schema !== 1 || value.id !== id || hashCheckpoint(value) !== id) return null;
|
|
73626
73750
|
return value;
|
|
73627
73751
|
} catch {
|
|
@@ -73637,11 +73761,11 @@ function requireIdentity(project) {
|
|
|
73637
73761
|
return project.uuid;
|
|
73638
73762
|
}
|
|
73639
73763
|
function appendEvent(projectId, event) {
|
|
73640
|
-
(0,
|
|
73764
|
+
(0, import_node_fs38.mkdirSync)(root4(projectId), { recursive: true });
|
|
73641
73765
|
const log2 = readEvents(projectId);
|
|
73642
|
-
const row = { ...event, eventId: (0,
|
|
73766
|
+
const row = { ...event, eventId: (0, import_node_crypto23.randomUUID)(), at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
73643
73767
|
log2.events.push(row);
|
|
73644
|
-
|
|
73768
|
+
writeJsonAtomic(eventsPath(projectId), log2);
|
|
73645
73769
|
return row;
|
|
73646
73770
|
}
|
|
73647
73771
|
function captureProjectCheckpoint(input) {
|
|
@@ -73655,9 +73779,9 @@ function captureProjectCheckpoint(input) {
|
|
|
73655
73779
|
contract: input.contract
|
|
73656
73780
|
};
|
|
73657
73781
|
const id = hashCheckpoint(withoutId);
|
|
73658
|
-
(0,
|
|
73782
|
+
(0, import_node_fs38.mkdirSync)(objectsDir2(input.project.id), { recursive: true });
|
|
73659
73783
|
const path = (0, import_node_path34.join)(objectsDir2(input.project.id), `${id}.json`);
|
|
73660
|
-
if (!(0,
|
|
73784
|
+
if (!(0, import_node_fs38.existsSync)(path)) writeJsonAtomic(path, { ...withoutId, id });
|
|
73661
73785
|
const event = appendEvent(input.project.id, {
|
|
73662
73786
|
checkpointId: id,
|
|
73663
73787
|
kind: "captured",
|
|
@@ -73699,8 +73823,8 @@ function markProjectCheckpoint(project, checkpointId, kind, expectedEventId) {
|
|
|
73699
73823
|
}
|
|
73700
73824
|
|
|
73701
73825
|
// export-source.ts
|
|
73702
|
-
var
|
|
73703
|
-
var
|
|
73826
|
+
var import_node_crypto24 = require("node:crypto");
|
|
73827
|
+
var import_node_fs39 = require("node:fs");
|
|
73704
73828
|
var import_node_os18 = require("node:os");
|
|
73705
73829
|
var import_node_path35 = require("node:path");
|
|
73706
73830
|
var HANDLE_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
@@ -73710,11 +73834,6 @@ function storeRoot() {
|
|
|
73710
73834
|
return (0, import_node_path35.join)(root5, ".floless-export-handles-v1");
|
|
73711
73835
|
}
|
|
73712
73836
|
var handlePath = (id) => (0, import_node_path35.join)(storeRoot(), `${id}.json`);
|
|
73713
|
-
function atomicWrite3(path, value) {
|
|
73714
|
-
const tmp = `${path}.${process.pid}.${(0, import_node_crypto23.randomUUID)()}.tmp`;
|
|
73715
|
-
(0, import_node_fs38.writeFileSync)(tmp, canonicalJson(value));
|
|
73716
|
-
(0, import_node_fs38.renameSync)(tmp, path);
|
|
73717
|
-
}
|
|
73718
73837
|
function withoutChecksum(value) {
|
|
73719
73838
|
const { checksum: _checksum, ...body } = value;
|
|
73720
73839
|
return body;
|
|
@@ -73728,7 +73847,7 @@ function validId(id) {
|
|
|
73728
73847
|
function readExportHandle(handleId) {
|
|
73729
73848
|
if (!validId(handleId)) return null;
|
|
73730
73849
|
try {
|
|
73731
|
-
const value = JSON.parse((0,
|
|
73850
|
+
const value = JSON.parse((0, import_node_fs39.readFileSync)(handlePath(handleId), "utf8"));
|
|
73732
73851
|
if (value?.schema !== 1 || value.handleId !== handleId || value.checksum !== hashOf(withoutChecksum(value))) return null;
|
|
73733
73852
|
return value;
|
|
73734
73853
|
} catch {
|
|
@@ -73737,7 +73856,7 @@ function readExportHandle(handleId) {
|
|
|
73737
73856
|
}
|
|
73738
73857
|
function captureExportSource(projectId, selector = { kind: "latest-approved" }, isDerivedEligible) {
|
|
73739
73858
|
collectExpiredExportHandles();
|
|
73740
|
-
if ((0,
|
|
73859
|
+
if ((0, import_node_fs39.existsSync)(storeRoot()) && (0, import_node_fs39.readdirSync)(storeRoot()).filter((name) => name.endsWith(".json")).length >= MAX_STORED_HANDLES) {
|
|
73741
73860
|
throw new Error("too many frozen export sources are waiting; finish or retry older exports first");
|
|
73742
73861
|
}
|
|
73743
73862
|
const project = getProject(projectId);
|
|
@@ -73799,7 +73918,7 @@ function captureExportSource(projectId, selector = { kind: "latest-approved" },
|
|
|
73799
73918
|
}
|
|
73800
73919
|
const contentHash = hashOf(contract);
|
|
73801
73920
|
const capturedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
73802
|
-
const handleId = (0,
|
|
73921
|
+
const handleId = (0, import_node_crypto24.randomUUID)();
|
|
73803
73922
|
const shortHash2 = contentHash.slice(0, 8);
|
|
73804
73923
|
const filenameLabel = kind === "approved" ? `v${approvedVersion}` : kind === "working" ? `Working-DRAFT-${shortHash2}` : `Checkpoint-${sourceRef.slice(0, 8)}-DRAFT-${shortHash2}`;
|
|
73805
73924
|
const body = {
|
|
@@ -73823,8 +73942,8 @@ function captureExportSource(projectId, selector = { kind: "latest-approved" },
|
|
|
73823
73942
|
expiresAt: new Date(Date.now() + HANDLE_TTL_MS).toISOString(),
|
|
73824
73943
|
resultRefs: []
|
|
73825
73944
|
};
|
|
73826
|
-
(0,
|
|
73827
|
-
|
|
73945
|
+
(0, import_node_fs39.mkdirSync)(storeRoot(), { recursive: true });
|
|
73946
|
+
writeJsonAtomic(handlePath(handleId), stored(body));
|
|
73828
73947
|
const { contract: _contract, lease: _lease, expiresAt: _expiresAt, resultRefs: _refs, checksum: _checksum, ...resolved } = readExportHandle(handleId);
|
|
73829
73948
|
return resolved;
|
|
73830
73949
|
}
|
|
@@ -73835,22 +73954,22 @@ function cloneExportHandle(handleId, copies) {
|
|
|
73835
73954
|
if (!original || original.lease !== "active" || Date.parse(original.expiresAt) <= Date.now()) {
|
|
73836
73955
|
throw new Error("export source handle is unavailable");
|
|
73837
73956
|
}
|
|
73838
|
-
const storedCount = (0,
|
|
73957
|
+
const storedCount = (0, import_node_fs39.existsSync)(storeRoot()) ? (0, import_node_fs39.readdirSync)(storeRoot()).filter((name) => name.endsWith(".json")).length : 0;
|
|
73839
73958
|
if (storedCount + copies - 1 > MAX_STORED_HANDLES) throw new Error("too many frozen export sources are waiting");
|
|
73840
73959
|
const results = [];
|
|
73841
73960
|
const created = [];
|
|
73842
73961
|
try {
|
|
73843
73962
|
for (let index = 0; index < copies; index++) {
|
|
73844
|
-
const value = index === 0 ? original : stored({ ...withoutChecksum(original), handleId: (0,
|
|
73963
|
+
const value = index === 0 ? original : stored({ ...withoutChecksum(original), handleId: (0, import_node_crypto24.randomUUID)(), resultRefs: [] });
|
|
73845
73964
|
if (index > 0) {
|
|
73846
|
-
|
|
73965
|
+
writeJsonAtomic(handlePath(value.handleId), value);
|
|
73847
73966
|
created.push(value.handleId);
|
|
73848
73967
|
}
|
|
73849
73968
|
const { contract: _contract, lease: _lease, expiresAt: _expiresAt, resultRefs: _refs, checksum: _checksum, ...resolved } = value;
|
|
73850
73969
|
results.push(resolved);
|
|
73851
73970
|
}
|
|
73852
73971
|
} catch (error) {
|
|
73853
|
-
for (const id of created) (0,
|
|
73972
|
+
for (const id of created) (0, import_node_fs39.rmSync)(handlePath(id), { force: true });
|
|
73854
73973
|
throw error;
|
|
73855
73974
|
}
|
|
73856
73975
|
return results;
|
|
@@ -73873,7 +73992,7 @@ function releaseExportHandle(handleId, resultRef) {
|
|
|
73873
73992
|
lease: "released",
|
|
73874
73993
|
resultRefs: resultRef ? [.../* @__PURE__ */ new Set([...handle.resultRefs, resultRef])] : handle.resultRefs
|
|
73875
73994
|
});
|
|
73876
|
-
|
|
73995
|
+
writeJsonAtomic(handlePath(handleId), next);
|
|
73877
73996
|
const { contract: _contract, lease: _lease, expiresAt: _expiresAt, resultRefs: _refs, checksum: _checksum, ...resolved } = next;
|
|
73878
73997
|
return resolved;
|
|
73879
73998
|
}
|
|
@@ -73890,21 +74009,21 @@ function releaseUnusedExportHandle(handleId, projectId, projectUuid) {
|
|
|
73890
74009
|
}
|
|
73891
74010
|
function projectIdHasActiveExportLeases(projectId) {
|
|
73892
74011
|
collectExpiredExportHandles();
|
|
73893
|
-
if (!(0,
|
|
73894
|
-
return (0,
|
|
74012
|
+
if (!(0, import_node_fs39.existsSync)(storeRoot())) return false;
|
|
74013
|
+
return (0, import_node_fs39.readdirSync)(storeRoot()).some((name) => {
|
|
73895
74014
|
const handle = name.endsWith(".json") ? readExportHandle(name.slice(0, -5)) : null;
|
|
73896
74015
|
return handle?.projectId === projectId && handle.lease === "active" && Date.parse(handle.expiresAt) > Date.now();
|
|
73897
74016
|
});
|
|
73898
74017
|
}
|
|
73899
74018
|
function collectExpiredExportHandles(now = Date.now()) {
|
|
73900
|
-
if (!(0,
|
|
74019
|
+
if (!(0, import_node_fs39.existsSync)(storeRoot())) return 0;
|
|
73901
74020
|
let removed = 0;
|
|
73902
|
-
for (const name of (0,
|
|
74021
|
+
for (const name of (0, import_node_fs39.readdirSync)(storeRoot())) {
|
|
73903
74022
|
if (!name.endsWith(".json")) continue;
|
|
73904
74023
|
const id = name.slice(0, -5);
|
|
73905
74024
|
const handle = readExportHandle(id);
|
|
73906
74025
|
if (!handle || Date.parse(handle.expiresAt) <= now && handle.resultRefs.length === 0) {
|
|
73907
|
-
(0,
|
|
74026
|
+
(0, import_node_fs39.rmSync)(handlePath(id), { force: true });
|
|
73908
74027
|
removed++;
|
|
73909
74028
|
}
|
|
73910
74029
|
}
|
|
@@ -73912,8 +74031,8 @@ function collectExpiredExportHandles(now = Date.now()) {
|
|
|
73912
74031
|
}
|
|
73913
74032
|
|
|
73914
74033
|
// file-publication.ts
|
|
73915
|
-
var
|
|
73916
|
-
var
|
|
74034
|
+
var import_node_crypto25 = require("node:crypto");
|
|
74035
|
+
var import_node_fs40 = require("node:fs");
|
|
73917
74036
|
var import_node_path36 = require("node:path");
|
|
73918
74037
|
var FilePublicationError = class extends Error {
|
|
73919
74038
|
constructor(message, code, paths = []) {
|
|
@@ -73927,11 +74046,11 @@ var FilePublicationError = class extends Error {
|
|
|
73927
74046
|
};
|
|
73928
74047
|
var proofOfBytes = (bytes) => ({
|
|
73929
74048
|
bytes: bytes.byteLength,
|
|
73930
|
-
sha256: (0,
|
|
74049
|
+
sha256: (0, import_node_crypto25.createHash)("sha256").update(bytes).digest("hex")
|
|
73931
74050
|
});
|
|
73932
74051
|
function readFileProof2(path) {
|
|
73933
74052
|
try {
|
|
73934
|
-
return proofOfBytes((0,
|
|
74053
|
+
return proofOfBytes((0, import_node_fs40.readFileSync)(path));
|
|
73935
74054
|
} catch (error) {
|
|
73936
74055
|
if (error.code === "ENOENT") return null;
|
|
73937
74056
|
throw error;
|
|
@@ -73941,38 +74060,38 @@ function fileProofEquals2(a, b) {
|
|
|
73941
74060
|
return a === null || b === null ? a === b : a.bytes === b.bytes && a.sha256 === b.sha256;
|
|
73942
74061
|
}
|
|
73943
74062
|
function syncFile2(path) {
|
|
73944
|
-
const fd2 = (0,
|
|
74063
|
+
const fd2 = (0, import_node_fs40.openSync)(path, "r+");
|
|
73945
74064
|
try {
|
|
73946
|
-
(0,
|
|
74065
|
+
(0, import_node_fs40.fsyncSync)(fd2);
|
|
73947
74066
|
} finally {
|
|
73948
|
-
(0,
|
|
74067
|
+
(0, import_node_fs40.closeSync)(fd2);
|
|
73949
74068
|
}
|
|
73950
74069
|
}
|
|
73951
74070
|
function syncDirectoryBestEffort3(path) {
|
|
73952
74071
|
try {
|
|
73953
|
-
const fd2 = (0,
|
|
74072
|
+
const fd2 = (0, import_node_fs40.openSync)(path, "r");
|
|
73954
74073
|
try {
|
|
73955
|
-
(0,
|
|
74074
|
+
(0, import_node_fs40.fsyncSync)(fd2);
|
|
73956
74075
|
} finally {
|
|
73957
|
-
(0,
|
|
74076
|
+
(0, import_node_fs40.closeSync)(fd2);
|
|
73958
74077
|
}
|
|
73959
74078
|
} catch {
|
|
73960
74079
|
}
|
|
73961
74080
|
}
|
|
73962
74081
|
function durableCanonicalJson(path, value) {
|
|
73963
74082
|
const dir = (0, import_node_path36.dirname)(path);
|
|
73964
|
-
(0,
|
|
73965
|
-
const temp = (0, import_node_path36.join)(dir, `.${(0, import_node_path36.basename)(path)}.${process.pid}.${(0,
|
|
74083
|
+
(0, import_node_fs40.mkdirSync)(dir, { recursive: true });
|
|
74084
|
+
const temp = (0, import_node_path36.join)(dir, `.${(0, import_node_path36.basename)(path)}.${process.pid}.${(0, import_node_crypto25.randomUUID)()}.tmp`);
|
|
73966
74085
|
try {
|
|
73967
|
-
(0,
|
|
74086
|
+
(0, import_node_fs40.writeFileSync)(temp, `${canonicalJson(value)}
|
|
73968
74087
|
`, { encoding: "utf8", flag: "wx" });
|
|
73969
74088
|
syncFile2(temp);
|
|
73970
|
-
(0,
|
|
74089
|
+
(0, import_node_fs40.renameSync)(temp, path);
|
|
73971
74090
|
syncFile2(path);
|
|
73972
74091
|
syncDirectoryBestEffort3(dir);
|
|
73973
74092
|
} finally {
|
|
73974
74093
|
try {
|
|
73975
|
-
(0,
|
|
74094
|
+
(0, import_node_fs40.rmSync)(temp, { force: true });
|
|
73976
74095
|
} catch {
|
|
73977
74096
|
}
|
|
73978
74097
|
}
|
|
@@ -73991,7 +74110,7 @@ function mappedError(error, paths) {
|
|
|
73991
74110
|
}
|
|
73992
74111
|
function linkExclusive(source, destination) {
|
|
73993
74112
|
try {
|
|
73994
|
-
(0,
|
|
74113
|
+
(0, import_node_fs40.linkSync)(source, destination);
|
|
73995
74114
|
} catch (error) {
|
|
73996
74115
|
throw mappedError(error, [source, destination]);
|
|
73997
74116
|
}
|
|
@@ -74000,27 +74119,27 @@ function assertSameVolume(a, b) {
|
|
|
74000
74119
|
let aDev;
|
|
74001
74120
|
let bDev;
|
|
74002
74121
|
try {
|
|
74003
|
-
aDev = (0,
|
|
74004
|
-
bDev = (0,
|
|
74122
|
+
aDev = (0, import_node_fs40.statSync)(a, { bigint: true }).dev;
|
|
74123
|
+
bDev = (0, import_node_fs40.statSync)(b, { bigint: true }).dev;
|
|
74005
74124
|
} catch (error) {
|
|
74006
74125
|
throw mappedError(error, [a, b]);
|
|
74007
74126
|
}
|
|
74008
74127
|
if (aDev !== bDev) throw new FilePublicationError("publication paths are not on the same volume", "different-volume", [a, b]);
|
|
74009
74128
|
}
|
|
74010
74129
|
function uniqueArtifact(dir, label2, livePath) {
|
|
74011
|
-
(0,
|
|
74012
|
-
return (0, import_node_path36.join)(dir, `.floless-${label2}-${(0,
|
|
74130
|
+
(0, import_node_fs40.mkdirSync)(dir, { recursive: true });
|
|
74131
|
+
return (0, import_node_path36.join)(dir, `.floless-${label2}-${(0, import_node_crypto25.randomUUID)()}-${(0, import_node_path36.basename)(livePath)}`);
|
|
74013
74132
|
}
|
|
74014
74133
|
function publishFileExclusive(input) {
|
|
74015
74134
|
const { livePath, stagedPath, expectedLive, artifactDir } = input;
|
|
74016
|
-
assertSameVolume(stagedPath, (0,
|
|
74135
|
+
assertSameVolume(stagedPath, (0, import_node_fs40.existsSync)(livePath) ? livePath : (0, import_node_path36.dirname)(livePath));
|
|
74017
74136
|
const stagedProof = readFileProof2(stagedPath);
|
|
74018
74137
|
if (!stagedProof) throw new FilePublicationError("staged publication file is missing", "io-failure", [stagedPath]);
|
|
74019
74138
|
let beforeImage = null;
|
|
74020
74139
|
if (expectedLive) {
|
|
74021
74140
|
beforeImage = uniqueArtifact(artifactDir, "before", livePath);
|
|
74022
74141
|
try {
|
|
74023
|
-
(0,
|
|
74142
|
+
(0, import_node_fs40.renameSync)(livePath, beforeImage);
|
|
74024
74143
|
} catch (error) {
|
|
74025
74144
|
throw mappedError(error, [livePath, beforeImage]);
|
|
74026
74145
|
}
|
|
@@ -74032,19 +74151,19 @@ function publishFileExclusive(input) {
|
|
|
74032
74151
|
}
|
|
74033
74152
|
throw new FilePublicationError("the live file changed before publication", "live-changed", [livePath, beforeImage]);
|
|
74034
74153
|
}
|
|
74035
|
-
} else if ((0,
|
|
74154
|
+
} else if ((0, import_node_fs40.existsSync)(livePath)) {
|
|
74036
74155
|
throw new FilePublicationError("the live destination appeared before publication", "destination-exists", [livePath]);
|
|
74037
74156
|
}
|
|
74038
74157
|
try {
|
|
74039
74158
|
input.onFaultPoint?.("after-live-move", { livePath, stagedPath, beforeImage });
|
|
74040
74159
|
linkExclusive(stagedPath, livePath);
|
|
74041
74160
|
input.onFaultPoint?.("after-live-link", { livePath, stagedPath, beforeImage });
|
|
74042
|
-
(0,
|
|
74161
|
+
(0, import_node_fs40.unlinkSync)(stagedPath);
|
|
74043
74162
|
input.onFaultPoint?.("after-staged-unlink", { livePath, stagedPath, beforeImage });
|
|
74044
74163
|
syncFile2(livePath);
|
|
74045
74164
|
syncDirectoryBestEffort3((0, import_node_path36.dirname)(livePath));
|
|
74046
74165
|
} catch (error) {
|
|
74047
|
-
if (beforeImage && !(0,
|
|
74166
|
+
if (beforeImage && !(0, import_node_fs40.existsSync)(livePath)) {
|
|
74048
74167
|
try {
|
|
74049
74168
|
linkExclusive(beforeImage, livePath);
|
|
74050
74169
|
} catch {
|
|
@@ -74067,7 +74186,7 @@ function publishFileExclusive(input) {
|
|
|
74067
74186
|
var import_node_path38 = require("node:path");
|
|
74068
74187
|
|
|
74069
74188
|
// app-source-lock.ts
|
|
74070
|
-
var
|
|
74189
|
+
var import_node_fs41 = require("node:fs");
|
|
74071
74190
|
var import_node_os19 = require("node:os");
|
|
74072
74191
|
var import_node_path37 = require("node:path");
|
|
74073
74192
|
var AppSourcePublicationBusyError = class extends Error {
|
|
@@ -74080,9 +74199,9 @@ var AppSourcePublicationBusyError = class extends Error {
|
|
|
74080
74199
|
function activeApprovalTransaction(appId) {
|
|
74081
74200
|
const home = process.env.AWARE_HOME || (0, import_node_path37.join)((0, import_node_os19.homedir)(), ".aware");
|
|
74082
74201
|
const path = (0, import_node_path37.join)(home, "apps", appId, ".floless-approval-publication-journal-v1.json");
|
|
74083
|
-
if (!(0,
|
|
74202
|
+
if (!(0, import_node_fs41.existsSync)(path)) return null;
|
|
74084
74203
|
try {
|
|
74085
|
-
const stored2 = JSON.parse((0,
|
|
74204
|
+
const stored2 = JSON.parse((0, import_node_fs41.readFileSync)(path, "utf8"));
|
|
74086
74205
|
return typeof stored2?.journal?.id === "string" && stored2.journal.id ? stored2.journal.id : "__invalid__";
|
|
74087
74206
|
} catch {
|
|
74088
74207
|
return "__invalid__";
|
|
@@ -74097,8 +74216,8 @@ function withAppSourceLock(appId, label2, fn, options = {}) {
|
|
|
74097
74216
|
}
|
|
74098
74217
|
|
|
74099
74218
|
// app-publication-manifest.ts
|
|
74100
|
-
var
|
|
74101
|
-
var
|
|
74219
|
+
var import_node_crypto26 = require("node:crypto");
|
|
74220
|
+
var import_node_fs42 = require("node:fs");
|
|
74102
74221
|
var import_yaml7 = __toESM(require_dist6(), 1);
|
|
74103
74222
|
var APP_PUBLICATION_MANIFEST_SCHEMA = 1;
|
|
74104
74223
|
var AppPublicationManifestError = class extends Error {
|
|
@@ -74115,7 +74234,7 @@ function observeAppPublication(sourcePath, lockPath2) {
|
|
|
74115
74234
|
let lockSourceHash = null;
|
|
74116
74235
|
if (lock) {
|
|
74117
74236
|
try {
|
|
74118
|
-
const parsed = (0, import_yaml7.parse)((0,
|
|
74237
|
+
const parsed = (0, import_yaml7.parse)((0, import_node_fs42.readFileSync)(lockPath2, "utf8"));
|
|
74119
74238
|
lockSourceHash = typeof parsed?.["source-hash"] === "string" ? parsed["source-hash"] : null;
|
|
74120
74239
|
} catch {
|
|
74121
74240
|
}
|
|
@@ -74140,10 +74259,10 @@ function validManifest(value) {
|
|
|
74140
74259
|
return m.schema === APP_PUBLICATION_MANIFEST_SCHEMA && typeof m.publicationId === "string" && !!m.publicationId && typeof m.appId === "string" && !!m.appId && Number.isSafeInteger(m.generation) && (m.generation ?? -1) >= 0 && (m.state === "ready-clean" || m.state === "ready-dirty" || m.state === "recovering") && validProof(m.source) && validProof(m.lock) && (m.lockSourceHash === null || typeof m.lockSourceHash === "string") && validTxn && typeof m.updatedAt === "string" && (m.state === "recovering" ? m.transaction !== null : m.transaction === null);
|
|
74141
74260
|
}
|
|
74142
74261
|
function readAppPublicationManifest(path) {
|
|
74143
|
-
if (!(0,
|
|
74262
|
+
if (!(0, import_node_fs42.existsSync)(path)) return null;
|
|
74144
74263
|
let stored2;
|
|
74145
74264
|
try {
|
|
74146
|
-
stored2 = JSON.parse((0,
|
|
74265
|
+
stored2 = JSON.parse((0, import_node_fs42.readFileSync)(path, "utf8"));
|
|
74147
74266
|
} catch {
|
|
74148
74267
|
throw new AppPublicationManifestError(`app publication manifest is unreadable: ${path}`, "corrupt");
|
|
74149
74268
|
}
|
|
@@ -74169,7 +74288,7 @@ function bootstrapAppPublicationManifest(input) {
|
|
|
74169
74288
|
const observed2 = observeAppPublication(input.sourcePath, input.lockPath);
|
|
74170
74289
|
const rebound = {
|
|
74171
74290
|
schema: APP_PUBLICATION_MANIFEST_SCHEMA,
|
|
74172
|
-
publicationId: (0,
|
|
74291
|
+
publicationId: (0, import_node_crypto26.randomUUID)(),
|
|
74173
74292
|
appId: input.appId,
|
|
74174
74293
|
generation: 0,
|
|
74175
74294
|
state: observed2.coherent ? "ready-clean" : "ready-dirty",
|
|
@@ -74190,7 +74309,7 @@ function bootstrapAppPublicationManifest(input) {
|
|
|
74190
74309
|
const observed = observeAppPublication(input.sourcePath, input.lockPath);
|
|
74191
74310
|
const manifest = {
|
|
74192
74311
|
schema: APP_PUBLICATION_MANIFEST_SCHEMA,
|
|
74193
|
-
publicationId: (0,
|
|
74312
|
+
publicationId: (0, import_node_crypto26.randomUUID)(),
|
|
74194
74313
|
appId: input.appId,
|
|
74195
74314
|
generation: 0,
|
|
74196
74315
|
state: observed.coherent ? "ready-clean" : "ready-dirty",
|
|
@@ -74335,8 +74454,8 @@ function withAppPublicationWhileProjectLocked(input) {
|
|
|
74335
74454
|
}
|
|
74336
74455
|
|
|
74337
74456
|
// approval-app-publication.ts
|
|
74338
|
-
var
|
|
74339
|
-
var
|
|
74457
|
+
var import_node_crypto27 = require("node:crypto");
|
|
74458
|
+
var import_node_fs43 = require("node:fs");
|
|
74340
74459
|
var import_node_path39 = require("node:path");
|
|
74341
74460
|
var JOURNAL = ".floless-approval-publication-journal-v1.json";
|
|
74342
74461
|
var MANIFEST = ".floless-app-publication-state-v1.json";
|
|
@@ -74363,7 +74482,7 @@ function storeJournal(journal) {
|
|
|
74363
74482
|
}
|
|
74364
74483
|
function readApprovalPublicationJournal(sourcePath) {
|
|
74365
74484
|
try {
|
|
74366
|
-
const stored2 = JSON.parse((0,
|
|
74485
|
+
const stored2 = JSON.parse((0, import_node_fs43.readFileSync)(approvalPublicationJournalPath(sourcePath), "utf8"));
|
|
74367
74486
|
const value = stored2?.journal;
|
|
74368
74487
|
const expectedLiveLock = sourcePath.replace(/\.[^.]+$/, ".lock");
|
|
74369
74488
|
const expectedStageDir = (0, import_node_path39.join)(stagingRoot2(sourcePath), `${value?.appId ?? ""}-${value?.id ?? ""}`);
|
|
@@ -74379,7 +74498,7 @@ function readApprovalPublicationJournal(sourcePath) {
|
|
|
74379
74498
|
}
|
|
74380
74499
|
async function stageApprovalPublication(input) {
|
|
74381
74500
|
const appRoot = (0, import_node_path39.dirname)(input.sourcePath);
|
|
74382
|
-
const id = (0,
|
|
74501
|
+
const id = (0, import_node_crypto27.randomUUID)();
|
|
74383
74502
|
const stageDir = (0, import_node_path39.join)(stagingRoot2(input.sourcePath), `${input.appId}-${id}`);
|
|
74384
74503
|
const stagedAppRoot = (0, import_node_path39.join)(stageDir, "app");
|
|
74385
74504
|
let stagedSourcePath = "";
|
|
@@ -74389,8 +74508,8 @@ async function stageApprovalPublication(input) {
|
|
|
74389
74508
|
const beforeSource = readFileProof2(input.sourcePath);
|
|
74390
74509
|
const beforeLock = readFileProof2(input.liveLockPath);
|
|
74391
74510
|
try {
|
|
74392
|
-
(0,
|
|
74393
|
-
(0,
|
|
74511
|
+
(0, import_node_fs43.mkdirSync)(stageDir, { recursive: true });
|
|
74512
|
+
(0, import_node_fs43.cpSync)(appRoot, stagedAppRoot, {
|
|
74394
74513
|
recursive: true,
|
|
74395
74514
|
filter: (path) => ![JOURNAL, MANIFEST].includes((0, import_node_path39.basename)(path))
|
|
74396
74515
|
});
|
|
@@ -74403,7 +74522,7 @@ async function stageApprovalPublication(input) {
|
|
|
74403
74522
|
throw new Error("live workflow changed while the approval was being staged");
|
|
74404
74523
|
}
|
|
74405
74524
|
} catch (error) {
|
|
74406
|
-
(0,
|
|
74525
|
+
(0, import_node_fs43.rmSync)(stageDir, { recursive: true, force: true });
|
|
74407
74526
|
throw error;
|
|
74408
74527
|
}
|
|
74409
74528
|
const journal = {
|
|
@@ -74436,12 +74555,12 @@ function publishOne(livePath, stagedPath, before, staged, artifactDir) {
|
|
|
74436
74555
|
const live = readFileProof2(livePath);
|
|
74437
74556
|
if (fileProofEquals2(live, staged)) return;
|
|
74438
74557
|
if (!fileProofEquals2(live, before)) throw new Error(`live publication changed outside the approval transaction: ${livePath}`);
|
|
74439
|
-
if (!(0,
|
|
74558
|
+
if (!(0, import_node_fs43.existsSync)(stagedPath)) throw new Error(`staged publication bytes are unavailable: ${stagedPath}`);
|
|
74440
74559
|
publishFileExclusive({ livePath, stagedPath, expectedLive: before, artifactDir });
|
|
74441
74560
|
}
|
|
74442
74561
|
function completeApprovalPublication(journal) {
|
|
74443
74562
|
if (journal.phase !== "authorized" && journal.phase !== "published") throw new Error("approval publication is not authorized");
|
|
74444
|
-
(0,
|
|
74563
|
+
(0, import_node_fs43.mkdirSync)(journal.artifactDir, { recursive: true });
|
|
74445
74564
|
publishOne(journal.liveSourcePath, journal.stagedSourcePath, journal.beforeSource, journal.stagedSource, journal.artifactDir);
|
|
74446
74565
|
publishOne(journal.liveLockPath, journal.stagedLockPath, journal.beforeLock, journal.stagedLock, journal.artifactDir);
|
|
74447
74566
|
if (!fileProofEquals2(readFileProof2(journal.liveSourcePath), journal.stagedSource) || !fileProofEquals2(readFileProof2(journal.liveLockPath), journal.stagedLock)) {
|
|
@@ -74454,17 +74573,17 @@ function finalizeApprovalPublication(journal) {
|
|
|
74454
74573
|
if (!current || current.id !== journal.id || current.phase !== "published") {
|
|
74455
74574
|
throw new Error("published approval recovery authority is unavailable");
|
|
74456
74575
|
}
|
|
74457
|
-
(0,
|
|
74458
|
-
(0,
|
|
74576
|
+
(0, import_node_fs43.rmSync)(journal.stageDir, { recursive: true, force: true });
|
|
74577
|
+
(0, import_node_fs43.rmSync)(approvalPublicationJournalPath(journal.liveSourcePath), { force: true });
|
|
74459
74578
|
}
|
|
74460
74579
|
function abandonApprovalPublication(journal) {
|
|
74461
74580
|
if (journal.phase !== "staged") throw new Error("an authorized approval publication must be completed, not abandoned");
|
|
74462
|
-
(0,
|
|
74463
|
-
(0,
|
|
74581
|
+
(0, import_node_fs43.rmSync)(approvalPublicationJournalPath(journal.liveSourcePath), { force: true });
|
|
74582
|
+
(0, import_node_fs43.rmSync)(journal.stageDir, { recursive: true, force: true });
|
|
74464
74583
|
}
|
|
74465
74584
|
|
|
74466
74585
|
// workspace-data.ts
|
|
74467
|
-
var
|
|
74586
|
+
var import_node_fs44 = require("node:fs");
|
|
74468
74587
|
var VALID_INCLUDES = /* @__PURE__ */ new Set(["contract", "exports"]);
|
|
74469
74588
|
var VALID_EXPORT_KINDS = /* @__PURE__ */ new Set([
|
|
74470
74589
|
"bom-csv",
|
|
@@ -74525,15 +74644,15 @@ function exportBody(projectId, receipt, opts) {
|
|
|
74525
74644
|
};
|
|
74526
74645
|
if (opts.includePaths) body.path = path;
|
|
74527
74646
|
if (opts.exportContents) {
|
|
74528
|
-
const st = (0,
|
|
74647
|
+
const st = (0, import_node_fs44.statSync)(path);
|
|
74529
74648
|
if (st.size > opts.maxBytes) {
|
|
74530
74649
|
body.contentOmitted = true;
|
|
74531
74650
|
body.omittedReason = `export is ${st.size} bytes, over max-bytes ${opts.maxBytes}`;
|
|
74532
74651
|
} else if (receipt.encoding === "base64") {
|
|
74533
|
-
body.content = (0,
|
|
74652
|
+
body.content = (0, import_node_fs44.readFileSync)(path).toString("base64");
|
|
74534
74653
|
} else {
|
|
74535
74654
|
body.encoding = receipt.encoding ?? "utf8";
|
|
74536
|
-
body.content = (0,
|
|
74655
|
+
body.content = (0, import_node_fs44.readFileSync)(path, "utf8");
|
|
74537
74656
|
}
|
|
74538
74657
|
}
|
|
74539
74658
|
return body;
|
|
@@ -74812,7 +74931,7 @@ function registerMigrationCommitRoute(app, deps) {
|
|
|
74812
74931
|
}
|
|
74813
74932
|
|
|
74814
74933
|
// workspace-agent-manifest.ts
|
|
74815
|
-
var
|
|
74934
|
+
var import_node_fs45 = require("node:fs");
|
|
74816
74935
|
var import_node_os20 = require("node:os");
|
|
74817
74936
|
var import_node_path40 = require("node:path");
|
|
74818
74937
|
function awareHome() {
|
|
@@ -74823,7 +74942,7 @@ function workspaceAgentDir() {
|
|
|
74823
74942
|
}
|
|
74824
74943
|
function syncWorkspaceAgentManifest(port) {
|
|
74825
74944
|
const dir = workspaceAgentDir();
|
|
74826
|
-
(0,
|
|
74945
|
+
(0, import_node_fs45.mkdirSync)(dir, { recursive: true });
|
|
74827
74946
|
const manifest = `agent: floless-workspace
|
|
74828
74947
|
version: 0.2.0
|
|
74829
74948
|
sdk-target: 2.4.0
|
|
@@ -74954,7 +75073,7 @@ commands:
|
|
|
74954
75073
|
body: object
|
|
74955
75074
|
`;
|
|
74956
75075
|
const path = (0, import_node_path40.join)(dir, "manifest.yaml");
|
|
74957
|
-
if (!(0,
|
|
75076
|
+
if (!(0, import_node_fs45.existsSync)(path) || manifest !== "") (0, import_node_fs45.writeFileSync)(path, manifest, "utf8");
|
|
74958
75077
|
return path;
|
|
74959
75078
|
}
|
|
74960
75079
|
|
|
@@ -75071,8 +75190,8 @@ function indexJoints(contract, lib, mapRef) {
|
|
|
75071
75190
|
for (const sigs of idx.values()) sigs.sort();
|
|
75072
75191
|
return idx;
|
|
75073
75192
|
}
|
|
75074
|
-
var
|
|
75075
|
-
var MOVE_TOL_MM = MOVE_TOL_FT *
|
|
75193
|
+
var FT_MM2 = 304.8;
|
|
75194
|
+
var MOVE_TOL_MM = MOVE_TOL_FT * FT_MM2;
|
|
75076
75195
|
var knownZof = (wp) => {
|
|
75077
75196
|
const z = wp?.z;
|
|
75078
75197
|
if (!z || typeof z !== "object") return null;
|
|
@@ -75307,7 +75426,7 @@ function diffV2V2(a, b, ctx, tonnage) {
|
|
|
75307
75426
|
} else {
|
|
75308
75427
|
pairing = pair3d(am.seg, bm.seg);
|
|
75309
75428
|
if (pairing.mm > MOVE_TOL_MM) {
|
|
75310
|
-
out.moved.push({ ref: refOfV2(bm), feet: Math.round(pairing.mm /
|
|
75429
|
+
out.moved.push({ ref: refOfV2(bm), feet: Math.round(pairing.mm / FT_MM2 * 10) / 10 });
|
|
75311
75430
|
changed = true;
|
|
75312
75431
|
}
|
|
75313
75432
|
}
|
|
@@ -76049,7 +76168,7 @@ function computeVersionDiff(id, n, base) {
|
|
|
76049
76168
|
}
|
|
76050
76169
|
|
|
76051
76170
|
// contract-bake.ts
|
|
76052
|
-
var
|
|
76171
|
+
var import_node_fs46 = require("node:fs");
|
|
76053
76172
|
var import_yaml8 = __toESM(require_dist6(), 1);
|
|
76054
76173
|
function isSteelType(t) {
|
|
76055
76174
|
return t === STEEL_V1 || t === STEEL_V2;
|
|
@@ -76073,7 +76192,7 @@ function bakedV2(contract) {
|
|
|
76073
76192
|
return stripConfidentialImages(baked);
|
|
76074
76193
|
}
|
|
76075
76194
|
function bakeContractIntoApp(sourcePath, contract) {
|
|
76076
|
-
const doc = (0, import_yaml8.parseDocument)((0,
|
|
76195
|
+
const doc = (0, import_yaml8.parseDocument)((0, import_node_fs46.readFileSync)(sourcePath, "utf8"));
|
|
76077
76196
|
if (doc.errors.length > 0) {
|
|
76078
76197
|
throw new Error(`contract bake: source is not valid YAML: ${doc.errors[0]?.message ?? "parse error"}`);
|
|
76079
76198
|
}
|
|
@@ -76097,7 +76216,7 @@ function bakeContractIntoApp(sourcePath, contract) {
|
|
|
76097
76216
|
throw new InvalidModelV2Error(`refusing to bake: contract declares steel.model/v2 but is not valid v2: ${issues[0] ?? "unknown"}`, issues);
|
|
76098
76217
|
}
|
|
76099
76218
|
doc.setIn(["nodes", idx, "config", "takeoff"], bakedV2(contract));
|
|
76100
|
-
(0,
|
|
76219
|
+
(0, import_node_fs46.writeFileSync)(sourcePath, doc.toString());
|
|
76101
76220
|
return;
|
|
76102
76221
|
}
|
|
76103
76222
|
const baked = { ...contract };
|
|
@@ -76142,7 +76261,7 @@ function bakeContractIntoApp(sourcePath, contract) {
|
|
|
76142
76261
|
);
|
|
76143
76262
|
}
|
|
76144
76263
|
doc.setIn(["nodes", idx, "config", "takeoff"], baked);
|
|
76145
|
-
(0,
|
|
76264
|
+
(0, import_node_fs46.writeFileSync)(sourcePath, doc.toString());
|
|
76146
76265
|
}
|
|
76147
76266
|
|
|
76148
76267
|
// vectorize.ts
|
|
@@ -76564,11 +76683,11 @@ function awareFailureMessage(e, fallback2) {
|
|
|
76564
76683
|
}
|
|
76565
76684
|
|
|
76566
76685
|
// scene-bake.ts
|
|
76567
|
-
var
|
|
76686
|
+
var import_node_fs47 = require("node:fs");
|
|
76568
76687
|
var import_node_path41 = require("node:path");
|
|
76569
76688
|
var import_yaml9 = __toESM(require_dist6(), 1);
|
|
76570
76689
|
function bakeSceneIntoApp(sourcePath, scene, agent = "viewer-3d") {
|
|
76571
|
-
const doc = (0, import_yaml9.parseDocument)((0,
|
|
76690
|
+
const doc = (0, import_yaml9.parseDocument)((0, import_node_fs47.readFileSync)(sourcePath, "utf8"));
|
|
76572
76691
|
if (doc.errors.length > 0) {
|
|
76573
76692
|
throw new Error(`scene bake: source is not valid YAML: ${doc.errors[0]?.message ?? "parse error"}`);
|
|
76574
76693
|
}
|
|
@@ -76577,10 +76696,10 @@ function bakeSceneIntoApp(sourcePath, scene, agent = "viewer-3d") {
|
|
|
76577
76696
|
const idx = items.findIndex((it) => ((0, import_yaml9.isMap)(it) ? it.toJSON() : null)?.agent === agent);
|
|
76578
76697
|
if (idx < 0) throw new Error(`no ${agent} render node to bake the scene into`);
|
|
76579
76698
|
doc.setIn(["nodes", idx, "config", "scene"], scene);
|
|
76580
|
-
(0,
|
|
76699
|
+
(0, import_node_fs47.writeFileSync)(sourcePath, doc.toString());
|
|
76581
76700
|
}
|
|
76582
76701
|
function bakeNodeConfigById(sourcePath, nodeId, patch2) {
|
|
76583
|
-
const doc = (0, import_yaml9.parseDocument)((0,
|
|
76702
|
+
const doc = (0, import_yaml9.parseDocument)((0, import_node_fs47.readFileSync)(sourcePath, "utf8"));
|
|
76584
76703
|
if (doc.errors.length > 0) {
|
|
76585
76704
|
throw new Error(`node bake: source is not valid YAML: ${doc.errors[0]?.message ?? "parse error"}`);
|
|
76586
76705
|
}
|
|
@@ -76589,12 +76708,12 @@ function bakeNodeConfigById(sourcePath, nodeId, patch2) {
|
|
|
76589
76708
|
const idx = items.findIndex((it) => ((0, import_yaml9.isMap)(it) ? it.toJSON() : null)?.id === nodeId);
|
|
76590
76709
|
if (idx < 0) throw new Error(`no node with id "${nodeId}"`);
|
|
76591
76710
|
for (const [key, value] of Object.entries(patch2)) doc.setIn(["nodes", idx, "config", key], value);
|
|
76592
|
-
(0,
|
|
76711
|
+
(0, import_node_fs47.writeFileSync)(sourcePath, doc.toString());
|
|
76593
76712
|
}
|
|
76594
76713
|
function writeViewer3dApp(dir, appId, scene) {
|
|
76595
|
-
(0,
|
|
76714
|
+
(0, import_node_fs47.mkdirSync)(dir, { recursive: true });
|
|
76596
76715
|
const flo = (0, import_node_path41.join)(dir, `${appId}.flo`);
|
|
76597
|
-
(0,
|
|
76716
|
+
(0, import_node_fs47.writeFileSync)(flo, [
|
|
76598
76717
|
`app: ${appId}`,
|
|
76599
76718
|
"version: 0.1.0",
|
|
76600
76719
|
"display-name: Steel 3D",
|
|
@@ -76617,18 +76736,18 @@ function writeViewer3dApp(dir, appId, scene) {
|
|
|
76617
76736
|
var COMPANION_MARKER = "# floless-companion: generated by FloLess \u2014 overwritten on every export";
|
|
76618
76737
|
function isCompanionApp(flo) {
|
|
76619
76738
|
try {
|
|
76620
|
-
return (0,
|
|
76739
|
+
return (0, import_node_fs47.readFileSync)(flo, "utf8").split(/\r?\n/, 1)[0]?.trim() === COMPANION_MARKER;
|
|
76621
76740
|
} catch (e) {
|
|
76622
76741
|
return e?.code === "ENOENT";
|
|
76623
76742
|
}
|
|
76624
76743
|
}
|
|
76625
76744
|
function writeBomReportApp(dir, appId, table) {
|
|
76626
|
-
(0,
|
|
76745
|
+
(0, import_node_fs47.mkdirSync)(dir, { recursive: true });
|
|
76627
76746
|
const flo = (0, import_node_path41.join)(dir, `${appId}.flo`);
|
|
76628
76747
|
if (!isCompanionApp(flo)) {
|
|
76629
76748
|
throw new Error(`refusing to overwrite "${appId}": an app of that name exists and FloLess did not write it`);
|
|
76630
76749
|
}
|
|
76631
|
-
(0,
|
|
76750
|
+
(0, import_node_fs47.writeFileSync)(flo, [
|
|
76632
76751
|
COMPANION_MARKER,
|
|
76633
76752
|
`app: ${appId}`,
|
|
76634
76753
|
"version: 0.1.0",
|
|
@@ -76655,9 +76774,9 @@ function writeBomReportApp(dir, appId, table) {
|
|
|
76655
76774
|
return flo;
|
|
76656
76775
|
}
|
|
76657
76776
|
function writeRevitApp(dir, appId, scene, hostPid, revitVersion = "2026") {
|
|
76658
|
-
(0,
|
|
76777
|
+
(0, import_node_fs47.mkdirSync)(dir, { recursive: true });
|
|
76659
76778
|
const flo = (0, import_node_path41.join)(dir, `${appId}.flo`);
|
|
76660
|
-
(0,
|
|
76779
|
+
(0, import_node_fs47.writeFileSync)(flo, [
|
|
76661
76780
|
`app: ${appId}`,
|
|
76662
76781
|
"version: 0.1.0",
|
|
76663
76782
|
"display-name: Steel to Revit",
|
|
@@ -76691,9 +76810,9 @@ function writeRevitApp(dir, appId, scene, hostPid, revitVersion = "2026") {
|
|
|
76691
76810
|
return flo;
|
|
76692
76811
|
}
|
|
76693
76812
|
function writeSketchupApp(dir, appId, scene) {
|
|
76694
|
-
(0,
|
|
76813
|
+
(0, import_node_fs47.mkdirSync)(dir, { recursive: true });
|
|
76695
76814
|
const flo = (0, import_node_path41.join)(dir, `${appId}.flo`);
|
|
76696
|
-
(0,
|
|
76815
|
+
(0, import_node_fs47.writeFileSync)(flo, [
|
|
76697
76816
|
`app: ${appId}`,
|
|
76698
76817
|
"version: 0.1.0",
|
|
76699
76818
|
"display-name: Steel to SketchUp",
|
|
@@ -76720,10 +76839,10 @@ function writeSketchupApp(dir, appId, scene) {
|
|
|
76720
76839
|
return flo;
|
|
76721
76840
|
}
|
|
76722
76841
|
function writeRhinoApp(dir, appId, scene, rhinoId, hostPid) {
|
|
76723
|
-
(0,
|
|
76842
|
+
(0, import_node_fs47.mkdirSync)(dir, { recursive: true });
|
|
76724
76843
|
const flo = (0, import_node_path41.join)(dir, `${appId}.flo`);
|
|
76725
76844
|
const exactRhinoId = typeof rhinoId === "string" && rhinoId.trim() ? rhinoId.trim() : null;
|
|
76726
|
-
(0,
|
|
76845
|
+
(0, import_node_fs47.writeFileSync)(flo, [
|
|
76727
76846
|
`app: ${appId}`,
|
|
76728
76847
|
"version: 0.1.0",
|
|
76729
76848
|
"display-name: Steel to Rhino",
|
|
@@ -76750,9 +76869,9 @@ function writeRhinoApp(dir, appId, scene, rhinoId, hostPid) {
|
|
|
76750
76869
|
return flo;
|
|
76751
76870
|
}
|
|
76752
76871
|
function writeTeklaApp(dir, appId, scene, teklaVersion = "2026.0") {
|
|
76753
|
-
(0,
|
|
76872
|
+
(0, import_node_fs47.mkdirSync)(dir, { recursive: true });
|
|
76754
76873
|
const flo = (0, import_node_path41.join)(dir, `${appId}.flo`);
|
|
76755
|
-
(0,
|
|
76874
|
+
(0, import_node_fs47.writeFileSync)(flo, [
|
|
76756
76875
|
`app: ${appId}`,
|
|
76757
76876
|
"version: 0.1.0",
|
|
76758
76877
|
"display-name: Steel to Tekla",
|
|
@@ -76915,8 +77034,8 @@ async function teklaVersionToBake() {
|
|
|
76915
77034
|
}
|
|
76916
77035
|
|
|
76917
77036
|
// ifc-publication.ts
|
|
76918
|
-
var
|
|
76919
|
-
var
|
|
77037
|
+
var import_node_crypto28 = require("node:crypto");
|
|
77038
|
+
var import_node_fs48 = require("node:fs");
|
|
76920
77039
|
var import_node_os21 = require("node:os");
|
|
76921
77040
|
var import_node_path42 = require("node:path");
|
|
76922
77041
|
var IfcPublicationError = class extends Error {
|
|
@@ -76941,7 +77060,7 @@ var MAX_TRANSACTIONS = 256;
|
|
|
76941
77060
|
var MAX_PHASE_BYTES = 1024 * 1024;
|
|
76942
77061
|
var MAX_INDEX_SNAPSHOT_BYTES = 512 * 1024;
|
|
76943
77062
|
function sha2562(bytes) {
|
|
76944
|
-
return (0,
|
|
77063
|
+
return (0, import_node_crypto28.createHash)("sha256").update(bytes).digest("hex");
|
|
76945
77064
|
}
|
|
76946
77065
|
function proof2(bytes) {
|
|
76947
77066
|
return { exists: true, bytes: bytes.length, sha256: sha2562(bytes) };
|
|
@@ -76950,37 +77069,37 @@ function sameProof(path, expected) {
|
|
|
76950
77069
|
return fileProofEquals(readFileProof(path), expected);
|
|
76951
77070
|
}
|
|
76952
77071
|
function syncFile3(path) {
|
|
76953
|
-
const fd2 = (0,
|
|
77072
|
+
const fd2 = (0, import_node_fs48.openSync)(path, "r+");
|
|
76954
77073
|
try {
|
|
76955
|
-
(0,
|
|
77074
|
+
(0, import_node_fs48.fsyncSync)(fd2);
|
|
76956
77075
|
} finally {
|
|
76957
|
-
(0,
|
|
77076
|
+
(0, import_node_fs48.closeSync)(fd2);
|
|
76958
77077
|
}
|
|
76959
77078
|
}
|
|
76960
77079
|
function syncDirectory2(path) {
|
|
76961
77080
|
try {
|
|
76962
|
-
const fd2 = (0,
|
|
77081
|
+
const fd2 = (0, import_node_fs48.openSync)(path, "r");
|
|
76963
77082
|
try {
|
|
76964
|
-
(0,
|
|
77083
|
+
(0, import_node_fs48.fsyncSync)(fd2);
|
|
76965
77084
|
} finally {
|
|
76966
|
-
(0,
|
|
77085
|
+
(0, import_node_fs48.closeSync)(fd2);
|
|
76967
77086
|
}
|
|
76968
77087
|
} catch {
|
|
76969
77088
|
}
|
|
76970
77089
|
}
|
|
76971
77090
|
function durableReplace2(path, bytes) {
|
|
76972
77091
|
const dir = (0, import_node_path42.dirname)(path);
|
|
76973
|
-
(0,
|
|
76974
|
-
const tmp = (0, import_node_path42.join)(dir, `.floless-tmp-recovery-${(0,
|
|
77092
|
+
(0, import_node_fs48.mkdirSync)(dir, { recursive: true });
|
|
77093
|
+
const tmp = (0, import_node_path42.join)(dir, `.floless-tmp-recovery-${(0, import_node_crypto28.randomUUID)()}`);
|
|
76975
77094
|
try {
|
|
76976
|
-
(0,
|
|
77095
|
+
(0, import_node_fs48.writeFileSync)(tmp, bytes, { flag: "wx" });
|
|
76977
77096
|
syncFile3(tmp);
|
|
76978
|
-
(0,
|
|
77097
|
+
(0, import_node_fs48.renameSync)(tmp, path);
|
|
76979
77098
|
syncFile3(path);
|
|
76980
77099
|
syncDirectory2(dir);
|
|
76981
77100
|
} finally {
|
|
76982
77101
|
try {
|
|
76983
|
-
(0,
|
|
77102
|
+
(0, import_node_fs48.rmSync)(tmp, { force: true });
|
|
76984
77103
|
} catch {
|
|
76985
77104
|
}
|
|
76986
77105
|
}
|
|
@@ -77006,12 +77125,12 @@ function validateRequestPaths(tempPath, finalPath) {
|
|
|
77006
77125
|
function requestIfcTempPath(finalPath) {
|
|
77007
77126
|
const final = canonicalPath(finalPath);
|
|
77008
77127
|
if (!plainIfcFilename((0, import_node_path42.basename)(final))) throw new IfcPublicationError("IFC final filename is unsafe.");
|
|
77009
|
-
(0,
|
|
77010
|
-
return (0, import_node_path42.join)((0, import_node_path42.dirname)(final), `.floless-tmp-ifc-${(0,
|
|
77128
|
+
(0, import_node_fs48.mkdirSync)((0, import_node_path42.dirname)(final), { recursive: true });
|
|
77129
|
+
return (0, import_node_path42.join)((0, import_node_path42.dirname)(final), `.floless-tmp-ifc-${(0, import_node_crypto28.randomUUID)()}.ifc`);
|
|
77011
77130
|
}
|
|
77012
77131
|
function validateIfc(path) {
|
|
77013
|
-
if (!(0,
|
|
77014
|
-
const bytes = (0,
|
|
77132
|
+
if (!(0, import_node_fs48.existsSync)(path) || (0, import_node_fs48.statSync)(path).size === 0) throw new IfcPublicationError("the IFC export produced no file");
|
|
77133
|
+
const bytes = (0, import_node_fs48.readFileSync)(path);
|
|
77015
77134
|
const prefix = bytes.subarray(0, Math.min(bytes.length, 128)).toString("utf8");
|
|
77016
77135
|
if (!prefix.includes("ISO-10303-21")) throw new IfcPublicationError("the IFC export did not produce a valid STEP envelope");
|
|
77017
77136
|
return { bytes, proof: proof2(bytes) };
|
|
@@ -77025,20 +77144,20 @@ function writePhase2(txnDir2, journal) {
|
|
|
77025
77144
|
const index = PHASES2.indexOf(journal.phase);
|
|
77026
77145
|
if (index < 0) throw new IfcPublicationError(`unknown IFC publication phase "${journal.phase}".`);
|
|
77027
77146
|
const destination = (0, import_node_path42.join)(txnDir2, `${String(index).padStart(3, "0")}-${journal.phase}.json`);
|
|
77028
|
-
if ((0,
|
|
77029
|
-
const temp = (0, import_node_path42.join)(txnDir2, `.phase-${(0,
|
|
77147
|
+
if ((0, import_node_fs48.existsSync)(destination)) throw new IfcPublicationError(`IFC publication phase "${journal.phase}" already exists.`);
|
|
77148
|
+
const temp = (0, import_node_path42.join)(txnDir2, `.phase-${(0, import_node_crypto28.randomUUID)()}.tmp`);
|
|
77030
77149
|
const bytes = Buffer.from(`${JSON.stringify(journal, null, 2)}
|
|
77031
77150
|
`, "utf8");
|
|
77032
77151
|
try {
|
|
77033
|
-
(0,
|
|
77152
|
+
(0, import_node_fs48.writeFileSync)(temp, bytes, { flag: "wx" });
|
|
77034
77153
|
syncFile3(temp);
|
|
77035
|
-
(0,
|
|
77154
|
+
(0, import_node_fs48.renameSync)(temp, destination);
|
|
77036
77155
|
syncFile3(destination);
|
|
77037
77156
|
syncDirectory2(txnDir2);
|
|
77038
77157
|
syncDirectory2((0, import_node_path42.dirname)(txnDir2));
|
|
77039
77158
|
} finally {
|
|
77040
77159
|
try {
|
|
77041
|
-
(0,
|
|
77160
|
+
(0, import_node_fs48.rmSync)(temp, { force: true });
|
|
77042
77161
|
} catch {
|
|
77043
77162
|
}
|
|
77044
77163
|
}
|
|
@@ -77104,7 +77223,7 @@ function loadJournal(txnDir2) {
|
|
|
77104
77223
|
const match = (0, import_node_path42.basename)(txnDir2).match(ACTIVE_RE);
|
|
77105
77224
|
if (!match) throw new IfcPublicationError(`unsafe IFC transaction directory "${(0, import_node_path42.basename)(txnDir2)}".`);
|
|
77106
77225
|
const txnId = match[1];
|
|
77107
|
-
const entries2 = (0,
|
|
77226
|
+
const entries2 = (0, import_node_fs48.readdirSync)(txnDir2, { withFileTypes: true });
|
|
77108
77227
|
if (!entries2.length) return null;
|
|
77109
77228
|
const phaseFiles = entries2.filter((entry2) => entry2.isFile() && PHASE_RE.test(entry2.name)).sort((a, b) => a.name.localeCompare(b.name));
|
|
77110
77229
|
const unknown = entries2.filter((entry2) => !(entry2.isFile() && (PHASE_RE.test(entry2.name) || /^\.phase-[a-f0-9-]+\.tmp$/i.test(entry2.name))));
|
|
@@ -77119,10 +77238,10 @@ function loadJournal(txnDir2) {
|
|
|
77119
77238
|
const declaredPhase = phaseMatch[2];
|
|
77120
77239
|
if (declaredIndex !== index || PHASES2[index] !== declaredPhase) break;
|
|
77121
77240
|
const path = (0, import_node_path42.join)(txnDir2, entry2.name);
|
|
77122
|
-
if ((0,
|
|
77241
|
+
if ((0, import_node_fs48.statSync)(path).size > MAX_PHASE_BYTES) break;
|
|
77123
77242
|
let parsed;
|
|
77124
77243
|
try {
|
|
77125
|
-
parsed = JSON.parse((0,
|
|
77244
|
+
parsed = JSON.parse((0, import_node_fs48.readFileSync)(path, "utf8"));
|
|
77126
77245
|
} catch {
|
|
77127
77246
|
break;
|
|
77128
77247
|
}
|
|
@@ -77149,7 +77268,7 @@ function restoreIndex(journal) {
|
|
|
77149
77268
|
if (journal.priorIndex.exists) {
|
|
77150
77269
|
durableReplace2(indexPath, Buffer.from(journal.priorIndexBase64, "base64"));
|
|
77151
77270
|
} else {
|
|
77152
|
-
(0,
|
|
77271
|
+
(0, import_node_fs48.rmSync)(indexPath, { force: true });
|
|
77153
77272
|
syncDirectory2((0, import_node_path42.dirname)(indexPath));
|
|
77154
77273
|
}
|
|
77155
77274
|
if (!sameProof(indexPath, journal.priorIndex)) {
|
|
@@ -77165,14 +77284,14 @@ function restoreArtifact(journal) {
|
|
|
77165
77284
|
if (!fileProofEquals(backup, journal.priorArtifact)) {
|
|
77166
77285
|
throw new IfcPublicationError("IFC backup does not match the recorded prior artifact.");
|
|
77167
77286
|
}
|
|
77168
|
-
(0,
|
|
77287
|
+
(0, import_node_fs48.rmSync)(journal.backupPath, { force: true });
|
|
77169
77288
|
}
|
|
77170
77289
|
} else if (!final.exists || fileProofEquals(final, journal.newArtifact)) {
|
|
77171
77290
|
if (!fileProofEquals(backup, journal.priorArtifact)) {
|
|
77172
77291
|
throw new IfcPublicationError("IFC prior artifact cannot be proven for rollback.");
|
|
77173
77292
|
}
|
|
77174
|
-
if (final.exists) (0,
|
|
77175
|
-
(0,
|
|
77293
|
+
if (final.exists) (0, import_node_fs48.rmSync)(journal.finalPath, { force: true });
|
|
77294
|
+
(0, import_node_fs48.renameSync)(journal.backupPath, journal.finalPath);
|
|
77176
77295
|
syncFile3(journal.finalPath);
|
|
77177
77296
|
} else {
|
|
77178
77297
|
throw new IfcPublicationError("IFC final artifact is in an unknown state; recovery retained evidence.");
|
|
@@ -77185,15 +77304,15 @@ function restoreArtifact(journal) {
|
|
|
77185
77304
|
if (!fileProofEquals(final, journal.newArtifact)) {
|
|
77186
77305
|
throw new IfcPublicationError("IFC final artifact is in an unknown state; recovery retained evidence.");
|
|
77187
77306
|
}
|
|
77188
|
-
(0,
|
|
77307
|
+
(0, import_node_fs48.rmSync)(journal.finalPath, { force: true });
|
|
77189
77308
|
}
|
|
77190
77309
|
if (backup.exists) throw new IfcPublicationError("unexpected IFC backup exists for a no-prior transaction.");
|
|
77191
77310
|
}
|
|
77192
|
-
if ((0,
|
|
77311
|
+
if ((0, import_node_fs48.existsSync)(journal.tempPath)) {
|
|
77193
77312
|
if (!sameProof(journal.tempPath, journal.newArtifact)) {
|
|
77194
77313
|
throw new IfcPublicationError("IFC temp artifact does not match its recorded proof.");
|
|
77195
77314
|
}
|
|
77196
|
-
(0,
|
|
77315
|
+
(0, import_node_fs48.rmSync)(journal.tempPath, { force: true });
|
|
77197
77316
|
}
|
|
77198
77317
|
syncDirectory2(journal.exportDir);
|
|
77199
77318
|
}
|
|
@@ -77201,8 +77320,8 @@ function retireTransaction(txnDir2) {
|
|
|
77201
77320
|
const match = (0, import_node_path42.basename)(txnDir2).match(ACTIVE_RE);
|
|
77202
77321
|
if (!match) throw new IfcPublicationError("cannot retire an unsafe IFC transaction directory.");
|
|
77203
77322
|
const cleanupDir = (0, import_node_path42.join)((0, import_node_path42.dirname)(txnDir2), `.floless-cleanup-ifc-${match[1]}`);
|
|
77204
|
-
if ((0,
|
|
77205
|
-
(0,
|
|
77323
|
+
if ((0, import_node_fs48.existsSync)(cleanupDir)) throw new IfcPublicationError("IFC cleanup directory already exists.");
|
|
77324
|
+
(0, import_node_fs48.renameSync)(txnDir2, cleanupDir);
|
|
77206
77325
|
syncDirectory2((0, import_node_path42.dirname)(txnDir2));
|
|
77207
77326
|
return cleanupDir;
|
|
77208
77327
|
}
|
|
@@ -77219,7 +77338,7 @@ function finishCommitted(txnDir2, journal, allowMissingBackup) {
|
|
|
77219
77338
|
if (!fileProofEquals(backup, journal.priorArtifact)) {
|
|
77220
77339
|
throw new IfcPublicationError("committed IFC backup does not match the recorded prior artifact.");
|
|
77221
77340
|
}
|
|
77222
|
-
(0,
|
|
77341
|
+
(0, import_node_fs48.rmSync)(journal.backupPath, { force: true });
|
|
77223
77342
|
syncDirectory2(journal.exportDir);
|
|
77224
77343
|
} else if (!allowMissingBackup) {
|
|
77225
77344
|
throw new IfcPublicationError("committed IFC backup disappeared before verified cleanup.");
|
|
@@ -77228,18 +77347,18 @@ function finishCommitted(txnDir2, journal, allowMissingBackup) {
|
|
|
77228
77347
|
throw new IfcPublicationError("unexpected committed IFC backup exists for a no-prior transaction.");
|
|
77229
77348
|
}
|
|
77230
77349
|
const cleanupDir = retireTransaction(txnDir2);
|
|
77231
|
-
(0,
|
|
77350
|
+
(0, import_node_fs48.rmSync)(cleanupDir, { recursive: true, force: true });
|
|
77232
77351
|
syncDirectory2(journal.exportDir);
|
|
77233
77352
|
}
|
|
77234
77353
|
function rollbackTransaction(txnDir2, journal) {
|
|
77235
77354
|
restoreArtifact(journal);
|
|
77236
77355
|
restoreIndex(journal);
|
|
77237
77356
|
const cleanupDir = retireTransaction(txnDir2);
|
|
77238
|
-
(0,
|
|
77357
|
+
(0, import_node_fs48.rmSync)(cleanupDir, { recursive: true, force: true });
|
|
77239
77358
|
syncDirectory2(journal.exportDir);
|
|
77240
77359
|
}
|
|
77241
77360
|
function safeTransactionDirectory(path) {
|
|
77242
|
-
const st = (0,
|
|
77361
|
+
const st = (0, import_node_fs48.lstatSync)(path);
|
|
77243
77362
|
if (!st.isDirectory() || st.isSymbolicLink()) {
|
|
77244
77363
|
throw new IfcPublicationError(`IFC transaction path is not a plain directory: ${path}`);
|
|
77245
77364
|
}
|
|
@@ -77249,7 +77368,7 @@ async function recoverActive(txnDir2, expected) {
|
|
|
77249
77368
|
const journal = loadJournal(txnDir2);
|
|
77250
77369
|
if (!journal) {
|
|
77251
77370
|
const cleanupDir = retireTransaction(txnDir2);
|
|
77252
|
-
(0,
|
|
77371
|
+
(0, import_node_fs48.rmSync)(cleanupDir, { recursive: true, force: true });
|
|
77253
77372
|
return;
|
|
77254
77373
|
}
|
|
77255
77374
|
if (expected && (journal.resource.kind !== expected.kind || journal.resource.key !== expected.key)) {
|
|
@@ -77262,9 +77381,9 @@ async function recoverActive(txnDir2, expected) {
|
|
|
77262
77381
|
}
|
|
77263
77382
|
async function recoverIfcPublicationsInDirectory(exportDir, expected) {
|
|
77264
77383
|
const dir = canonicalPath(exportDir);
|
|
77265
|
-
if (!(0,
|
|
77384
|
+
if (!(0, import_node_fs48.existsSync)(dir)) return [];
|
|
77266
77385
|
safeTransactionDirectory(dir);
|
|
77267
|
-
const entries2 = (0,
|
|
77386
|
+
const entries2 = (0, import_node_fs48.readdirSync)(dir, { withFileTypes: true }).filter((entry2) => ACTIVE_RE.test(entry2.name) || CLEANUP_RE.test(entry2.name));
|
|
77268
77387
|
if (entries2.length > MAX_TRANSACTIONS) {
|
|
77269
77388
|
throw new IfcPublicationError(`IFC recovery refused ${entries2.length} transaction directories (limit ${MAX_TRANSACTIONS}).`);
|
|
77270
77389
|
}
|
|
@@ -77273,7 +77392,7 @@ async function recoverIfcPublicationsInDirectory(exportDir, expected) {
|
|
|
77273
77392
|
const path = (0, import_node_path42.join)(dir, entry2.name);
|
|
77274
77393
|
safeTransactionDirectory(path);
|
|
77275
77394
|
if (CLEANUP_RE.test(entry2.name)) {
|
|
77276
|
-
(0,
|
|
77395
|
+
(0, import_node_fs48.rmSync)(path, { recursive: true, force: true });
|
|
77277
77396
|
syncDirectory2(dir);
|
|
77278
77397
|
recovered.push(entry2.name);
|
|
77279
77398
|
continue;
|
|
@@ -77287,9 +77406,9 @@ async function recoverAllIfcPublications() {
|
|
|
77287
77406
|
const recovered = [];
|
|
77288
77407
|
const rootHome = process.env.FLOLESS_HOME ?? (0, import_node_path42.join)((0, import_node_os21.homedir)(), ".floless");
|
|
77289
77408
|
const projectsRoot2 = (0, import_node_path42.join)(rootHome, "projects");
|
|
77290
|
-
if ((0,
|
|
77409
|
+
if ((0, import_node_fs48.existsSync)(projectsRoot2)) {
|
|
77291
77410
|
safeTransactionDirectory(projectsRoot2);
|
|
77292
|
-
for (const entry2 of (0,
|
|
77411
|
+
for (const entry2 of (0, import_node_fs48.readdirSync)(projectsRoot2, { withFileTypes: true })) {
|
|
77293
77412
|
if (entry2.name.startsWith(".")) continue;
|
|
77294
77413
|
if (entry2.isSymbolicLink()) throw new IfcPublicationError(`project recovery root is a link: ${entry2.name}`);
|
|
77295
77414
|
if (!entry2.isDirectory() || !/^[a-z0-9][a-z0-9-]*$/.test(entry2.name)) continue;
|
|
@@ -77301,9 +77420,9 @@ async function recoverAllIfcPublications() {
|
|
|
77301
77420
|
}
|
|
77302
77421
|
}
|
|
77303
77422
|
const root5 = (0, import_node_path42.join)(rootHome, "exports");
|
|
77304
|
-
if ((0,
|
|
77423
|
+
if ((0, import_node_fs48.existsSync)(root5)) {
|
|
77305
77424
|
safeTransactionDirectory(root5);
|
|
77306
|
-
for (const entry2 of (0,
|
|
77425
|
+
for (const entry2 of (0, import_node_fs48.readdirSync)(root5, { withFileTypes: true })) {
|
|
77307
77426
|
if (entry2.name.startsWith(".")) continue;
|
|
77308
77427
|
if (entry2.isSymbolicLink()) throw new IfcPublicationError(`workflow recovery root is a link: ${entry2.name}`);
|
|
77309
77428
|
if (!entry2.isDirectory()) continue;
|
|
@@ -77334,7 +77453,7 @@ function promiseLike(value) {
|
|
|
77334
77453
|
async function publishIfcAtomically(tempPath, finalPath, options) {
|
|
77335
77454
|
if (!options || !validResource(options.resource)) throw new IfcPublicationError("IFC publication resource is invalid.");
|
|
77336
77455
|
const paths = validateRequestPaths(tempPath, finalPath);
|
|
77337
|
-
const tempStat = (0,
|
|
77456
|
+
const tempStat = (0, import_node_fs48.lstatSync)(paths.temp);
|
|
77338
77457
|
if (!tempStat.isFile()) throw new IfcPublicationError("the IFC to publish is not a regular file.");
|
|
77339
77458
|
const validated = validateIfc(paths.temp);
|
|
77340
77459
|
if (options.expectedContentSha256 !== void 0 && validated.proof.sha256 !== options.expectedContentSha256) {
|
|
@@ -77346,7 +77465,7 @@ async function publishIfcAtomically(tempPath, finalPath, options) {
|
|
|
77346
77465
|
}
|
|
77347
77466
|
return withLifecycleLock(options.resource.kind, options.resource.key, async () => {
|
|
77348
77467
|
await recoverIfcPublicationsInDirectory(paths.dir, options.resource);
|
|
77349
|
-
const txnId = (0,
|
|
77468
|
+
const txnId = (0, import_node_crypto28.randomUUID)();
|
|
77350
77469
|
const txnDir2 = (0, import_node_path42.join)(paths.dir, `.floless-txn-ifc-${txnId}`);
|
|
77351
77470
|
const backupPath = (0, import_node_path42.join)(paths.dir, `.floless-backup-ifc-${txnId}.ifc`);
|
|
77352
77471
|
const priorArtifact = readFileProof(paths.final);
|
|
@@ -77372,7 +77491,7 @@ async function publishIfcAtomically(tempPath, finalPath, options) {
|
|
|
77372
77491
|
};
|
|
77373
77492
|
let journal = { ...base, phase: "prepared" };
|
|
77374
77493
|
let committed = false;
|
|
77375
|
-
(0,
|
|
77494
|
+
(0, import_node_fs48.mkdirSync)(txnDir2);
|
|
77376
77495
|
syncDirectory2(paths.dir);
|
|
77377
77496
|
const hit = (point) => {
|
|
77378
77497
|
options.fault?.(point);
|
|
@@ -77388,11 +77507,11 @@ async function publishIfcAtomically(tempPath, finalPath, options) {
|
|
|
77388
77507
|
phase("prepared");
|
|
77389
77508
|
phase("backing-up");
|
|
77390
77509
|
if (priorArtifact.exists) {
|
|
77391
|
-
(0,
|
|
77510
|
+
(0, import_node_fs48.renameSync)(paths.final, backupPath);
|
|
77392
77511
|
syncDirectory2(paths.dir);
|
|
77393
77512
|
}
|
|
77394
77513
|
phase("promoting");
|
|
77395
|
-
(0,
|
|
77514
|
+
(0, import_node_fs48.renameSync)(paths.temp, paths.final);
|
|
77396
77515
|
syncFile3(paths.final);
|
|
77397
77516
|
syncDirectory2(paths.dir);
|
|
77398
77517
|
if (!sameProof(paths.final, validated.proof)) {
|
|
@@ -77421,7 +77540,7 @@ async function publishIfcAtomically(tempPath, finalPath, options) {
|
|
|
77421
77540
|
if (!fileProofEquals(backup, priorArtifact)) {
|
|
77422
77541
|
throw new IfcPublicationError("IFC backup did not match the recorded prior artifact before cleanup.");
|
|
77423
77542
|
}
|
|
77424
|
-
(0,
|
|
77543
|
+
(0, import_node_fs48.rmSync)(backupPath, { force: true });
|
|
77425
77544
|
syncDirectory2(paths.dir);
|
|
77426
77545
|
} else if (backup.exists) {
|
|
77427
77546
|
throw new IfcPublicationError("unexpected IFC backup exists for a no-prior transaction.");
|
|
@@ -77431,7 +77550,7 @@ async function publishIfcAtomically(tempPath, finalPath, options) {
|
|
|
77431
77550
|
const cleanupDir = retireTransaction(txnDir2);
|
|
77432
77551
|
hit("after-retire");
|
|
77433
77552
|
hit("before-cleanup-remove");
|
|
77434
|
-
(0,
|
|
77553
|
+
(0, import_node_fs48.rmSync)(cleanupDir, { recursive: true, force: true });
|
|
77435
77554
|
syncDirectory2(paths.dir);
|
|
77436
77555
|
return { bytes: validated.bytes, cleanupPending: false };
|
|
77437
77556
|
} catch (error) {
|
|
@@ -77477,8 +77596,8 @@ function cleanupIfcTemp(path) {
|
|
|
77477
77596
|
if (!TEMP_RE.test((0, import_node_path42.basename)(path))) return;
|
|
77478
77597
|
const canonical = canonicalPath(path);
|
|
77479
77598
|
const dir = (0, import_node_path42.dirname)(canonical);
|
|
77480
|
-
if ((0,
|
|
77481
|
-
for (const entry2 of (0,
|
|
77599
|
+
if ((0, import_node_fs48.existsSync)(dir)) {
|
|
77600
|
+
for (const entry2 of (0, import_node_fs48.readdirSync)(dir, { withFileTypes: true })) {
|
|
77482
77601
|
if (!entry2.isDirectory() || !ACTIVE_RE.test(entry2.name)) continue;
|
|
77483
77602
|
try {
|
|
77484
77603
|
const journal = loadJournal((0, import_node_path42.join)(dir, entry2.name));
|
|
@@ -77489,14 +77608,14 @@ function cleanupIfcTemp(path) {
|
|
|
77489
77608
|
}
|
|
77490
77609
|
}
|
|
77491
77610
|
try {
|
|
77492
|
-
(0,
|
|
77611
|
+
(0, import_node_fs48.rmSync)(path, { force: true });
|
|
77493
77612
|
} catch {
|
|
77494
77613
|
}
|
|
77495
77614
|
}
|
|
77496
77615
|
|
|
77497
77616
|
// export-companion.ts
|
|
77498
|
-
var
|
|
77499
|
-
var
|
|
77617
|
+
var import_node_crypto29 = require("node:crypto");
|
|
77618
|
+
var import_node_fs49 = require("node:fs");
|
|
77500
77619
|
var import_node_path43 = require("node:path");
|
|
77501
77620
|
var PREFIX = "floless-export-tmp-";
|
|
77502
77621
|
var LEASE = ".floless-export-lease.json";
|
|
@@ -77522,11 +77641,11 @@ function assertScratchPath(path, appsRoot) {
|
|
|
77522
77641
|
}
|
|
77523
77642
|
function removeScratch(path, appsRoot) {
|
|
77524
77643
|
assertScratchPath(path, appsRoot);
|
|
77525
|
-
(0,
|
|
77644
|
+
(0, import_node_fs49.rmSync)(path, { recursive: true, force: true });
|
|
77526
77645
|
}
|
|
77527
77646
|
function createExportCompanion(ownerId, sink, appsRoot = defaultAppsRoot()) {
|
|
77528
77647
|
const safeOwner = ownerId.replace(/[^a-z0-9._-]/gi, "-").slice(0, 80) || "app";
|
|
77529
|
-
const token2 = (0,
|
|
77648
|
+
const token2 = (0, import_node_crypto29.randomUUID)();
|
|
77530
77649
|
const id = `${PREFIX}${safeOwner}-${sink}-${token2}`;
|
|
77531
77650
|
const root5 = (0, import_node_path43.resolve)(appsRoot);
|
|
77532
77651
|
const path = (0, import_node_path43.resolve)(root5, id);
|
|
@@ -77535,10 +77654,10 @@ function createExportCompanion(ownerId, sink, appsRoot = defaultAppsRoot()) {
|
|
|
77535
77654
|
path,
|
|
77536
77655
|
token: token2,
|
|
77537
77656
|
cleanup: () => {
|
|
77538
|
-
if (!(0,
|
|
77657
|
+
if (!(0, import_node_fs49.existsSync)(path)) return;
|
|
77539
77658
|
let current = null;
|
|
77540
77659
|
try {
|
|
77541
|
-
current = JSON.parse((0,
|
|
77660
|
+
current = JSON.parse((0, import_node_fs49.readFileSync)((0, import_node_path43.resolve)(path, LEASE), "utf8"));
|
|
77542
77661
|
} catch {
|
|
77543
77662
|
}
|
|
77544
77663
|
if (current && current.token !== token2) throw new Error(`export companion lease changed for ${id}`);
|
|
@@ -77547,7 +77666,7 @@ function createExportCompanion(ownerId, sink, appsRoot = defaultAppsRoot()) {
|
|
|
77547
77666
|
};
|
|
77548
77667
|
}
|
|
77549
77668
|
function stampExportCompanionLease(companion2) {
|
|
77550
|
-
(0,
|
|
77669
|
+
(0, import_node_fs49.writeFileSync)((0, import_node_path43.resolve)(companion2.path, LEASE), JSON.stringify({
|
|
77551
77670
|
pid: process.pid,
|
|
77552
77671
|
token: companion2.token,
|
|
77553
77672
|
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -77555,19 +77674,19 @@ function stampExportCompanionLease(companion2) {
|
|
|
77555
77674
|
}
|
|
77556
77675
|
function sweepStaleExportCompanions(now = Date.now(), appsRoot = defaultAppsRoot()) {
|
|
77557
77676
|
const root5 = (0, import_node_path43.resolve)(appsRoot);
|
|
77558
|
-
if (!(0,
|
|
77677
|
+
if (!(0, import_node_fs49.existsSync)(root5)) return [];
|
|
77559
77678
|
const removed = [];
|
|
77560
|
-
for (const entry2 of (0,
|
|
77679
|
+
for (const entry2 of (0, import_node_fs49.readdirSync)(root5, { withFileTypes: true })) {
|
|
77561
77680
|
if (!entry2.isDirectory() || !entry2.name.startsWith(PREFIX)) continue;
|
|
77562
77681
|
const path = (0, import_node_path43.resolve)(root5, entry2.name);
|
|
77563
77682
|
let lease = null;
|
|
77564
77683
|
try {
|
|
77565
|
-
lease = JSON.parse((0,
|
|
77684
|
+
lease = JSON.parse((0, import_node_fs49.readFileSync)((0, import_node_path43.resolve)(path, LEASE), "utf8"));
|
|
77566
77685
|
} catch {
|
|
77567
77686
|
}
|
|
77568
77687
|
let created;
|
|
77569
77688
|
try {
|
|
77570
|
-
created = lease ? Date.parse(lease.createdAt) : (0,
|
|
77689
|
+
created = lease ? Date.parse(lease.createdAt) : (0, import_node_fs49.statSync)(path).mtimeMs;
|
|
77571
77690
|
} catch {
|
|
77572
77691
|
continue;
|
|
77573
77692
|
}
|
|
@@ -78141,14 +78260,14 @@ function looksLikeHostUnavailable(host, ...messages) {
|
|
|
78141
78260
|
}
|
|
78142
78261
|
|
|
78143
78262
|
// render-readiness.ts
|
|
78144
|
-
var
|
|
78263
|
+
var import_node_fs50 = require("node:fs");
|
|
78145
78264
|
var import_node_path44 = require("node:path");
|
|
78146
78265
|
var import_node_os22 = require("node:os");
|
|
78147
78266
|
var RENDER_AWARE_FLOOR = "0.103.0";
|
|
78148
78267
|
var RENDER_AGENT_ID = "blender";
|
|
78149
78268
|
function isFile(path) {
|
|
78150
78269
|
try {
|
|
78151
|
-
return (0,
|
|
78270
|
+
return (0, import_node_fs50.existsSync)(path) && (0, import_node_fs50.statSync)(path).isFile();
|
|
78152
78271
|
} catch {
|
|
78153
78272
|
return false;
|
|
78154
78273
|
}
|
|
@@ -78182,7 +78301,7 @@ function windowsCandidates(env2) {
|
|
|
78182
78301
|
for (const root5 of roots) {
|
|
78183
78302
|
let entries2;
|
|
78184
78303
|
try {
|
|
78185
|
-
entries2 = (0,
|
|
78304
|
+
entries2 = (0, import_node_fs50.readdirSync)(root5);
|
|
78186
78305
|
} catch {
|
|
78187
78306
|
continue;
|
|
78188
78307
|
}
|
|
@@ -78361,16 +78480,16 @@ function nothingToApprove(contract) {
|
|
|
78361
78480
|
}
|
|
78362
78481
|
|
|
78363
78482
|
// app-lifecycle.ts
|
|
78364
|
-
var
|
|
78483
|
+
var import_node_fs53 = require("node:fs");
|
|
78365
78484
|
var import_node_os24 = require("node:os");
|
|
78366
78485
|
var import_node_path47 = require("node:path");
|
|
78367
78486
|
|
|
78368
78487
|
// routines.ts
|
|
78369
|
-
var
|
|
78488
|
+
var import_node_fs52 = require("node:fs");
|
|
78370
78489
|
var import_node_path46 = require("node:path");
|
|
78371
78490
|
|
|
78372
78491
|
// trigger-sessions.ts
|
|
78373
|
-
var
|
|
78492
|
+
var import_node_fs51 = require("node:fs");
|
|
78374
78493
|
var import_node_os23 = require("node:os");
|
|
78375
78494
|
var import_node_path45 = require("node:path");
|
|
78376
78495
|
var import_yaml10 = __toESM(require_dist6(), 1);
|
|
@@ -78392,9 +78511,9 @@ function isHostBacked(agent, agentsDir = AGENTS_DIR2) {
|
|
|
78392
78511
|
const safe2 = (n) => !n.includes("/") && !n.includes("\\") && !n.includes("..");
|
|
78393
78512
|
if (!safe2(agent)) return false;
|
|
78394
78513
|
const manifestPath2 = (0, import_node_path45.join)(agentsDir, agent, "manifest.yaml");
|
|
78395
|
-
if (!(0,
|
|
78514
|
+
if (!(0, import_node_fs51.existsSync)(manifestPath2)) return false;
|
|
78396
78515
|
try {
|
|
78397
|
-
const doc = (0, import_yaml10.parse)((0,
|
|
78516
|
+
const doc = (0, import_yaml10.parse)((0, import_node_fs51.readFileSync)(manifestPath2, "utf8"));
|
|
78398
78517
|
const transport = doc?.transport;
|
|
78399
78518
|
return !!(transport && typeof transport === "object" && "cli" in transport);
|
|
78400
78519
|
} catch {
|
|
@@ -78738,10 +78857,10 @@ function sanitizeRoutine(raw) {
|
|
|
78738
78857
|
};
|
|
78739
78858
|
}
|
|
78740
78859
|
function loadFromDisk() {
|
|
78741
|
-
if (!(0,
|
|
78860
|
+
if (!(0, import_node_fs52.existsSync)(ROUTINES_FILE)) return [];
|
|
78742
78861
|
let text3;
|
|
78743
78862
|
try {
|
|
78744
|
-
text3 = (0,
|
|
78863
|
+
text3 = (0, import_node_fs52.readFileSync)(ROUTINES_FILE, "utf8");
|
|
78745
78864
|
} catch {
|
|
78746
78865
|
return [];
|
|
78747
78866
|
}
|
|
@@ -78750,17 +78869,17 @@ function loadFromDisk() {
|
|
|
78750
78869
|
return Array.isArray(parsed) ? parsed.map(sanitizeRoutine).filter((r) => r !== null) : [];
|
|
78751
78870
|
} catch {
|
|
78752
78871
|
try {
|
|
78753
|
-
(0,
|
|
78872
|
+
(0, import_node_fs52.renameSync)(ROUTINES_FILE, `${ROUTINES_FILE}.corrupt-${Date.now()}`);
|
|
78754
78873
|
} catch {
|
|
78755
78874
|
}
|
|
78756
78875
|
return [];
|
|
78757
78876
|
}
|
|
78758
78877
|
}
|
|
78759
78878
|
function saveRoutines() {
|
|
78760
|
-
if (!(0,
|
|
78879
|
+
if (!(0, import_node_fs52.existsSync)(flolessRoot)) (0, import_node_fs52.mkdirSync)(flolessRoot, { recursive: true });
|
|
78761
78880
|
const tmp = `${ROUTINES_FILE}.${process.pid}.tmp`;
|
|
78762
|
-
(0,
|
|
78763
|
-
(0,
|
|
78881
|
+
(0, import_node_fs52.writeFileSync)(tmp, JSON.stringify(routines, null, 2));
|
|
78882
|
+
(0, import_node_fs52.renameSync)(tmp, ROUTINES_FILE);
|
|
78764
78883
|
}
|
|
78765
78884
|
function listRoutines() {
|
|
78766
78885
|
ensureLoaded();
|
|
@@ -79186,7 +79305,7 @@ function appDirPath(id) {
|
|
|
79186
79305
|
return (0, import_node_path47.join)(appsDir(), id);
|
|
79187
79306
|
}
|
|
79188
79307
|
function appInstalled(id) {
|
|
79189
|
-
return APP_ID4.test(id) && (0,
|
|
79308
|
+
return APP_ID4.test(id) && (0, import_node_fs53.existsSync)(appDirPath(id));
|
|
79190
79309
|
}
|
|
79191
79310
|
function logCascade(what, e) {
|
|
79192
79311
|
console.error(`[app-lifecycle] cascade step failed (${what}):`, e instanceof Error ? e.message : e);
|
|
@@ -79424,7 +79543,7 @@ function isGatedAwareRoute(url, method) {
|
|
|
79424
79543
|
|
|
79425
79544
|
// autostart.mjs
|
|
79426
79545
|
var import_node_child_process7 = require("node:child_process");
|
|
79427
|
-
var
|
|
79546
|
+
var import_node_fs54 = require("node:fs");
|
|
79428
79547
|
var import_node_os25 = require("node:os");
|
|
79429
79548
|
var import_node_path48 = require("node:path");
|
|
79430
79549
|
|
|
@@ -79538,8 +79657,8 @@ function removeLegacyRunKey() {
|
|
|
79538
79657
|
}
|
|
79539
79658
|
function logLine(msg) {
|
|
79540
79659
|
try {
|
|
79541
|
-
(0,
|
|
79542
|
-
(0,
|
|
79660
|
+
(0, import_node_fs54.mkdirSync)(logDir(), { recursive: true });
|
|
79661
|
+
(0, import_node_fs54.appendFileSync)(logFilePath(), `${(/* @__PURE__ */ new Date()).toISOString()} ${msg}
|
|
79543
79662
|
`);
|
|
79544
79663
|
} catch {
|
|
79545
79664
|
}
|
|
@@ -79548,7 +79667,7 @@ function registerAutostart(exePath) {
|
|
|
79548
79667
|
if (!isWin) return;
|
|
79549
79668
|
const xml = buildAutostartTaskXml(exePath, currentUserId());
|
|
79550
79669
|
const tmp = (0, import_node_path48.join)((0, import_node_os25.tmpdir)(), `floless-autostart-${process.pid}-${Date.now()}.xml`);
|
|
79551
|
-
(0,
|
|
79670
|
+
(0, import_node_fs54.writeFileSync)(tmp, "\uFEFF" + xml, { encoding: "utf16le" });
|
|
79552
79671
|
try {
|
|
79553
79672
|
(0, import_node_child_process7.execFileSync)("schtasks", ["/Create", "/TN", TASK_NAME, "/XML", tmp, "/F"], {
|
|
79554
79673
|
stdio: ["ignore", "ignore", "ignore"],
|
|
@@ -79559,7 +79678,7 @@ function registerAutostart(exePath) {
|
|
|
79559
79678
|
throw err2;
|
|
79560
79679
|
} finally {
|
|
79561
79680
|
try {
|
|
79562
|
-
(0,
|
|
79681
|
+
(0, import_node_fs54.rmSync)(tmp, { force: true });
|
|
79563
79682
|
} catch {
|
|
79564
79683
|
}
|
|
79565
79684
|
}
|
|
@@ -79593,14 +79712,14 @@ function unregisterAutostart() {
|
|
|
79593
79712
|
|
|
79594
79713
|
// updater.ts
|
|
79595
79714
|
var import_node_child_process8 = require("node:child_process");
|
|
79596
|
-
var
|
|
79597
|
-
var
|
|
79715
|
+
var import_node_crypto30 = require("node:crypto");
|
|
79716
|
+
var import_node_fs56 = require("node:fs");
|
|
79598
79717
|
var import_node_stream3 = require("node:stream");
|
|
79599
79718
|
var import_promises4 = require("node:stream/promises");
|
|
79600
79719
|
var import_node_path50 = require("node:path");
|
|
79601
79720
|
|
|
79602
79721
|
// post-update-marker.mjs
|
|
79603
|
-
var
|
|
79722
|
+
var import_node_fs55 = require("node:fs");
|
|
79604
79723
|
var import_node_os26 = require("node:os");
|
|
79605
79724
|
var import_node_path49 = require("node:path");
|
|
79606
79725
|
var FRESH_MS = 12e4;
|
|
@@ -79623,7 +79742,7 @@ function writePostUpdateMarker() {
|
|
|
79623
79742
|
for (const p of [markerPath(), legacyMarkerPath()]) {
|
|
79624
79743
|
if (!p) continue;
|
|
79625
79744
|
try {
|
|
79626
|
-
(0,
|
|
79745
|
+
(0, import_node_fs55.writeFileSync)(p, (/* @__PURE__ */ new Date()).toISOString());
|
|
79627
79746
|
wrote = true;
|
|
79628
79747
|
} catch {
|
|
79629
79748
|
}
|
|
@@ -79635,9 +79754,9 @@ function consumePostUpdateMarker() {
|
|
|
79635
79754
|
for (const p of [markerPath(), legacyMarkerPath()]) {
|
|
79636
79755
|
if (!p) continue;
|
|
79637
79756
|
try {
|
|
79638
|
-
if (!(0,
|
|
79639
|
-
const ageMs = Date.now() - (0,
|
|
79640
|
-
(0,
|
|
79757
|
+
if (!(0, import_node_fs55.existsSync)(p)) continue;
|
|
79758
|
+
const ageMs = Date.now() - (0, import_node_fs55.statSync)(p).mtimeMs;
|
|
79759
|
+
(0, import_node_fs55.rmSync)(p, { force: true });
|
|
79641
79760
|
if (ageMs < FRESH_MS) fresh = true;
|
|
79642
79761
|
} catch {
|
|
79643
79762
|
}
|
|
@@ -79645,6 +79764,17 @@ function consumePostUpdateMarker() {
|
|
|
79645
79764
|
return fresh;
|
|
79646
79765
|
}
|
|
79647
79766
|
|
|
79767
|
+
// dotted-version.ts
|
|
79768
|
+
function versionGt(a, b) {
|
|
79769
|
+
const pa = a.split(".").map((n) => parseInt(n, 10) || 0);
|
|
79770
|
+
const pb = b.split(".").map((n) => parseInt(n, 10) || 0);
|
|
79771
|
+
for (let i = 0; i < Math.max(pa.length, pb.length); i++) {
|
|
79772
|
+
const d = (pa[i] ?? 0) - (pb[i] ?? 0);
|
|
79773
|
+
if (d !== 0) return d > 0;
|
|
79774
|
+
}
|
|
79775
|
+
return false;
|
|
79776
|
+
}
|
|
79777
|
+
|
|
79648
79778
|
// updater.ts
|
|
79649
79779
|
var CHANNEL = "win";
|
|
79650
79780
|
var FEED_TIMEOUT_MS = 15e3;
|
|
@@ -79679,15 +79809,6 @@ function classifyFeedStatus(status) {
|
|
|
79679
79809
|
if (status === 402 || status === 403) return { updateAvailable: false, reason: "active subscription required for updates" };
|
|
79680
79810
|
return null;
|
|
79681
79811
|
}
|
|
79682
|
-
function versionGt(a, b) {
|
|
79683
|
-
const pa = a.split(".").map((n) => parseInt(n, 10) || 0);
|
|
79684
|
-
const pb = b.split(".").map((n) => parseInt(n, 10) || 0);
|
|
79685
|
-
for (let i = 0; i < Math.max(pa.length, pb.length); i++) {
|
|
79686
|
-
const d = (pa[i] ?? 0) - (pb[i] ?? 0);
|
|
79687
|
-
if (d !== 0) return d > 0;
|
|
79688
|
-
}
|
|
79689
|
-
return false;
|
|
79690
|
-
}
|
|
79691
79812
|
var NPM_LATEST_URL = "https://registry.npmjs.org/@floless/app/latest";
|
|
79692
79813
|
var NPM_UPDATE_COMMAND = "npm i -g @floless/app@latest";
|
|
79693
79814
|
async function checkNpmUpdate(cur, channel = "npm") {
|
|
@@ -79759,23 +79880,23 @@ async function checkForUpdate() {
|
|
|
79759
79880
|
return { supported: true, currentVersion: cur, updateAvailable: true, targetVersion: latest.Version, asset: latest };
|
|
79760
79881
|
}
|
|
79761
79882
|
async function sha1OfFile(path) {
|
|
79762
|
-
const hash2 = (0,
|
|
79763
|
-
await (0, import_promises4.pipeline)((0,
|
|
79883
|
+
const hash2 = (0, import_node_crypto30.createHash)("sha1");
|
|
79884
|
+
await (0, import_promises4.pipeline)((0, import_node_fs56.createReadStream)(path), hash2);
|
|
79764
79885
|
return hash2.digest("hex").toUpperCase();
|
|
79765
79886
|
}
|
|
79766
79887
|
async function downloadPackage(asset) {
|
|
79767
79888
|
if (!NUPKG_NAME.test(asset.FileName)) throw new Error(`refusing suspicious package name: ${asset.FileName}`);
|
|
79768
79889
|
const want = asset.SHA1.toUpperCase();
|
|
79769
79890
|
const dir = packagesDir();
|
|
79770
|
-
(0,
|
|
79891
|
+
(0, import_node_fs56.mkdirSync)(dir, { recursive: true });
|
|
79771
79892
|
const dest = (0, import_node_path50.join)(dir, asset.FileName);
|
|
79772
|
-
if ((0,
|
|
79893
|
+
if ((0, import_node_fs56.existsSync)(dest) && await sha1OfFile(dest) === want) return dest;
|
|
79773
79894
|
const res = await authedFetch(`${feedUrl()}/${encodeURIComponent(asset.FileName)}`, {
|
|
79774
79895
|
redirect: "follow",
|
|
79775
79896
|
signal: AbortSignal.timeout(DOWNLOAD_TIMEOUT_MS)
|
|
79776
79897
|
});
|
|
79777
79898
|
if (!res.ok || !res.body) throw new Error(`download failed: HTTP ${res.status} for ${asset.FileName}`);
|
|
79778
|
-
await (0, import_promises4.pipeline)(import_node_stream3.Readable.fromWeb(res.body), (0,
|
|
79899
|
+
await (0, import_promises4.pipeline)(import_node_stream3.Readable.fromWeb(res.body), (0, import_node_fs56.createWriteStream)(dest));
|
|
79779
79900
|
const got = await sha1OfFile(dest);
|
|
79780
79901
|
if (got !== want) throw new Error(`SHA1 mismatch for ${asset.FileName}: feed=${want} got=${got}`);
|
|
79781
79902
|
return dest;
|
|
@@ -79784,7 +79905,7 @@ async function applyUpdate(check, opts) {
|
|
|
79784
79905
|
if (!check.supported) return { applied: false, message: check.reason ?? "auto-update not supported in this runtime" };
|
|
79785
79906
|
if (!check.updateAvailable || !check.asset) return { applied: false, message: check.reason ?? "no update available" };
|
|
79786
79907
|
const exe = updateExePath();
|
|
79787
|
-
if (!(0,
|
|
79908
|
+
if (!(0, import_node_fs56.existsSync)(exe)) {
|
|
79788
79909
|
return { applied: false, message: `Update.exe not found at ${exe} \u2014 is this a Velopack install?` };
|
|
79789
79910
|
}
|
|
79790
79911
|
const pkg = await downloadPackage(check.asset);
|
|
@@ -80026,7 +80147,7 @@ function isTraceCorrupt(events) {
|
|
|
80026
80147
|
var import_node_child_process9 = require("node:child_process");
|
|
80027
80148
|
var import_node_path51 = require("node:path");
|
|
80028
80149
|
var import_node_url3 = require("node:url");
|
|
80029
|
-
var
|
|
80150
|
+
var import_node_fs57 = require("node:fs");
|
|
80030
80151
|
var import_node_http = __toESM(require("node:http"), 1);
|
|
80031
80152
|
var import_node_readline = require("node:readline");
|
|
80032
80153
|
var __dirname2 = (0, import_node_path51.dirname)((0, import_node_url3.fileURLToPath)(__import_meta_url));
|
|
@@ -80108,7 +80229,7 @@ function resolveServerStart() {
|
|
|
80108
80229
|
const packaged = /flolessapp\.exe$/i.test(process.execPath);
|
|
80109
80230
|
if (packaged) return { cmd: process.execPath, args: ["--serve"], shell: false };
|
|
80110
80231
|
const bundle = (0, import_node_path51.join)(__dirname2, "dist", "floless-server.cjs");
|
|
80111
|
-
if ((0,
|
|
80232
|
+
if ((0, import_node_fs57.existsSync)(bundle)) return { cmd: process.execPath, args: [bundle, "--serve"], shell: false };
|
|
80112
80233
|
return { cmd: "npm", args: ["run", "start"], shell: isWin2 };
|
|
80113
80234
|
}
|
|
80114
80235
|
function startServerDetached() {
|
|
@@ -80443,7 +80564,7 @@ if (entry === "launch.mjs") {
|
|
|
80443
80564
|
|
|
80444
80565
|
// aware-update.ts
|
|
80445
80566
|
var import_promises5 = require("node:fs/promises");
|
|
80446
|
-
var
|
|
80567
|
+
var import_node_crypto31 = require("node:crypto");
|
|
80447
80568
|
var import_node_path52 = require("node:path");
|
|
80448
80569
|
var REGISTRY_LATEST = "https://registry.npmjs.org/@aware-aeco/cli/latest";
|
|
80449
80570
|
var FEED_TIMEOUT_MS2 = 15e3;
|
|
@@ -80542,6 +80663,8 @@ async function persistentBridgeVersion(bridgeDirectory, host, io = nodeBridgeVer
|
|
|
80542
80663
|
throw new Error(`Could not safely verify the installed ${host} bridge.`, { cause: error });
|
|
80543
80664
|
}
|
|
80544
80665
|
}
|
|
80666
|
+
var LEGACY_MARKER_OPERATION = "runtime-update";
|
|
80667
|
+
var LEGACY_MARKER_ORIGIN = "user";
|
|
80545
80668
|
var nodeMarkerIo = { mkdir: import_promises5.mkdir, readFile: import_promises5.readFile, writeFile: import_promises5.writeFile, rename: import_promises5.rename, chmod: import_promises5.chmod, rm: import_promises5.rm };
|
|
80546
80669
|
var MARKER_MAX_BYTES = 4096;
|
|
80547
80670
|
var TOKEN = /^[A-Za-z0-9._-]{1,128}$/;
|
|
@@ -80552,7 +80675,11 @@ function isBridgeHost(value) {
|
|
|
80552
80675
|
function validateMarker(value) {
|
|
80553
80676
|
if (!value || typeof value !== "object") return null;
|
|
80554
80677
|
const v = value;
|
|
80555
|
-
if (v.schema !== 1 || !TOKEN.test(v.transaction ?? "") || !isExactAwareTarget(v.target)) return null;
|
|
80678
|
+
if (v.schema !== 1 && v.schema !== 2 || !TOKEN.test(v.transaction ?? "") || !isExactAwareTarget(v.target)) return null;
|
|
80679
|
+
const operation = v.schema === 1 ? LEGACY_MARKER_OPERATION : v.operation;
|
|
80680
|
+
const origin = v.schema === 1 ? LEGACY_MARKER_ORIGIN : v.origin;
|
|
80681
|
+
if (operation !== "runtime-update" && operation !== "bridge-repair") return null;
|
|
80682
|
+
if (origin !== "user" && origin !== "auto") return null;
|
|
80556
80683
|
if (!["runtime-install", "runtime-verify", "bridge-install", "bridge-verify", "retry-install", "retry-verify", "recovery"].includes(v.stage ?? "")) return null;
|
|
80557
80684
|
if (!Array.isArray(v.snapshot) || v.snapshot.some((host) => !isBridgeHost(host)) || new Set(v.snapshot).size !== v.snapshot.length) return null;
|
|
80558
80685
|
if (v.host != null && !isBridgeHost(v.host)) return null;
|
|
@@ -80561,19 +80688,23 @@ function validateMarker(value) {
|
|
|
80561
80688
|
if (!Number.isSafeInteger(child.pid) || child.pid <= 0 || !PROCESS_IDENTITY.test(child.startIdentity) || !PROCESS_IDENTITY.test(child.executableIdentity) || (0, import_node_path52.basename)(child.executableIdentity) !== child.executableIdentity) return null;
|
|
80562
80689
|
}
|
|
80563
80690
|
return {
|
|
80564
|
-
|
|
80691
|
+
// Normalised on read: a decoded schema-1 marker is handed to callers as a schema-2 value with
|
|
80692
|
+
// conservative defaults, so nothing downstream has to know two shapes.
|
|
80693
|
+
schema: 2,
|
|
80565
80694
|
transaction: v.transaction,
|
|
80566
80695
|
stage: v.stage,
|
|
80567
80696
|
target: v.target,
|
|
80568
80697
|
...v.host ? { host: v.host } : {},
|
|
80569
80698
|
snapshot: Object.freeze([...v.snapshot]),
|
|
80570
|
-
...v.child ? { child: { ...v.child } } : {}
|
|
80699
|
+
...v.child ? { child: { ...v.child } } : {},
|
|
80700
|
+
operation,
|
|
80701
|
+
origin
|
|
80571
80702
|
};
|
|
80572
80703
|
}
|
|
80573
80704
|
function createMaintenanceMarkerStore(markerPath2, options = {}) {
|
|
80574
80705
|
const io = options.io ?? nodeMarkerIo;
|
|
80575
80706
|
const maxBytes = Math.min(options.maxBytes ?? MARKER_MAX_BYTES, MARKER_MAX_BYTES);
|
|
80576
|
-
const randomId = options.randomId ??
|
|
80707
|
+
const randomId = options.randomId ?? import_node_crypto31.randomUUID;
|
|
80577
80708
|
const directory = (0, import_node_path52.dirname)(markerPath2);
|
|
80578
80709
|
return {
|
|
80579
80710
|
async read() {
|
|
@@ -80619,6 +80750,80 @@ function createMaintenanceMarkerStore(markerPath2, options = {}) {
|
|
|
80619
80750
|
}
|
|
80620
80751
|
};
|
|
80621
80752
|
}
|
|
80753
|
+
var PENDING_MAX_BYTES = 1024;
|
|
80754
|
+
function validatePending(value) {
|
|
80755
|
+
if (!value || typeof value !== "object") return null;
|
|
80756
|
+
const v = value;
|
|
80757
|
+
if (v.schema !== 1 || !isExactAwareTarget(v.target)) return null;
|
|
80758
|
+
if (!Array.isArray(v.hosts)) return null;
|
|
80759
|
+
const hosts = [...new Set(v.hosts.filter(isBridgeHost))];
|
|
80760
|
+
if (!hosts.length) return null;
|
|
80761
|
+
return { schema: 1, target: v.target, hosts: Object.freeze(hosts) };
|
|
80762
|
+
}
|
|
80763
|
+
function createBridgePendingStore(pendingPath, options = {}) {
|
|
80764
|
+
const io = options.io ?? nodeMarkerIo;
|
|
80765
|
+
const randomId = options.randomId ?? import_node_crypto31.randomUUID;
|
|
80766
|
+
const directory = (0, import_node_path52.dirname)(pendingPath);
|
|
80767
|
+
return {
|
|
80768
|
+
async read() {
|
|
80769
|
+
let bytes;
|
|
80770
|
+
try {
|
|
80771
|
+
bytes = await io.readFile(pendingPath, "utf8");
|
|
80772
|
+
} catch {
|
|
80773
|
+
return null;
|
|
80774
|
+
}
|
|
80775
|
+
if (Buffer.byteLength(bytes) > PENDING_MAX_BYTES) return null;
|
|
80776
|
+
try {
|
|
80777
|
+
return validatePending(JSON.parse(bytes));
|
|
80778
|
+
} catch {
|
|
80779
|
+
return null;
|
|
80780
|
+
}
|
|
80781
|
+
},
|
|
80782
|
+
async write(pending) {
|
|
80783
|
+
const valid = validatePending(pending);
|
|
80784
|
+
if (!valid) throw new Error("Refused to write an invalid AWARE bridge-repair intent.");
|
|
80785
|
+
const bytes = JSON.stringify(valid);
|
|
80786
|
+
if (Buffer.byteLength(bytes) > PENDING_MAX_BYTES) {
|
|
80787
|
+
throw new Error("Refused to write an oversized AWARE bridge-repair intent.");
|
|
80788
|
+
}
|
|
80789
|
+
await io.mkdir(directory, { recursive: true, mode: 448 });
|
|
80790
|
+
const temp = (0, import_node_path52.join)(directory, `.${(0, import_node_path52.basename)(pendingPath)}.${randomId()}.tmp`);
|
|
80791
|
+
try {
|
|
80792
|
+
await io.writeFile(temp, bytes, { encoding: "utf8", flag: "wx", mode: 384 });
|
|
80793
|
+
await io.rename(temp, pendingPath);
|
|
80794
|
+
await io.chmod(pendingPath, 384);
|
|
80795
|
+
} finally {
|
|
80796
|
+
await io.rm(temp, { force: true }).catch(() => {
|
|
80797
|
+
});
|
|
80798
|
+
}
|
|
80799
|
+
},
|
|
80800
|
+
async clear() {
|
|
80801
|
+
await io.rm(pendingPath, { force: true });
|
|
80802
|
+
}
|
|
80803
|
+
};
|
|
80804
|
+
}
|
|
80805
|
+
function bridgesNeedingRepair(inventory, pending, target) {
|
|
80806
|
+
const hosts = new Set(
|
|
80807
|
+
inventory.filter((bridge) => bridge.status !== "current").map((bridge) => bridge.host)
|
|
80808
|
+
);
|
|
80809
|
+
if (pending && pending.target === target) {
|
|
80810
|
+
for (const host of pending.hosts) hosts.add(host);
|
|
80811
|
+
}
|
|
80812
|
+
return Object.freeze(AWARE_BRIDGE_HOSTS.filter((host) => hosts.has(host)));
|
|
80813
|
+
}
|
|
80814
|
+
function decideRecoveryTarget(input) {
|
|
80815
|
+
const { markerTarget, markerOperation, installed } = input;
|
|
80816
|
+
const exactInstalled = installed && isExactAwareTarget(installed) ? installed : null;
|
|
80817
|
+
const exactMarker = markerTarget && isExactAwareTarget(markerTarget) ? markerTarget : null;
|
|
80818
|
+
if (markerOperation === "bridge-repair") return exactInstalled ?? exactMarker;
|
|
80819
|
+
if (!exactMarker) return exactInstalled;
|
|
80820
|
+
if (exactInstalled && compareExactAwareVersions(exactInstalled, exactMarker) > 0) return exactInstalled;
|
|
80821
|
+
return exactMarker;
|
|
80822
|
+
}
|
|
80823
|
+
function compareExactAwareVersions(a, b) {
|
|
80824
|
+
if (a === b) return 0;
|
|
80825
|
+
return versionGt(a, b) ? 1 : -1;
|
|
80826
|
+
}
|
|
80622
80827
|
function sanitizeAwareError(error, fallbackCode = "operation-failed") {
|
|
80623
80828
|
const raw = error instanceof Error ? error.message : String(error);
|
|
80624
80829
|
const code = typeof error?.code === "string" ? error.code.toLowerCase().replace(/[^a-z0-9_-]/g, "").slice(0, 48) : fallbackCode;
|
|
@@ -80638,15 +80843,6 @@ function awareInstalledVersion(probe = aware.npmVersion) {
|
|
|
80638
80843
|
function invalidateAwareVersion() {
|
|
80639
80844
|
_v = null;
|
|
80640
80845
|
}
|
|
80641
|
-
function versionGt2(a, b) {
|
|
80642
|
-
const pa = a.split(".").map((n) => parseInt(n, 10) || 0);
|
|
80643
|
-
const pb = b.split(".").map((n) => parseInt(n, 10) || 0);
|
|
80644
|
-
for (let i = 0; i < Math.max(pa.length, pb.length); i++) {
|
|
80645
|
-
const d = (pa[i] ?? 0) - (pb[i] ?? 0);
|
|
80646
|
-
if (d !== 0) return d > 0;
|
|
80647
|
-
}
|
|
80648
|
-
return false;
|
|
80649
|
-
}
|
|
80650
80846
|
function decideAwareUpdate(cur, latest) {
|
|
80651
80847
|
const base = {
|
|
80652
80848
|
supported: true,
|
|
@@ -80656,7 +80852,7 @@ function decideAwareUpdate(cur, latest) {
|
|
|
80656
80852
|
};
|
|
80657
80853
|
if (!latest) return { ...base, updateAvailable: false, reason: "could not read the npm registry latest" };
|
|
80658
80854
|
if (!cur) return { ...base, updateAvailable: false, targetVersion: latest, reason: "AWARE not installed yet" };
|
|
80659
|
-
if (
|
|
80855
|
+
if (versionGt(latest, cur)) return { ...base, updateAvailable: true, targetVersion: latest, operation: "runtime-update" };
|
|
80660
80856
|
return { ...base, updateAvailable: false, targetVersion: latest, reason: `already up to date (v${cur})` };
|
|
80661
80857
|
}
|
|
80662
80858
|
async function inspectPersistentBridgeInventory(bridgeDirectory, target) {
|
|
@@ -80971,12 +81167,19 @@ var AwareUpdateJobManager = class {
|
|
|
80971
81167
|
#active = null;
|
|
80972
81168
|
#starting = null;
|
|
80973
81169
|
#retrying = null;
|
|
81170
|
+
#shuttingDown = false;
|
|
81171
|
+
/** The in-flight job's controller, so shutdown() can actually abort rather than just wait. */
|
|
81172
|
+
#activeController = null;
|
|
80974
81173
|
#requestStarts = /* @__PURE__ */ new Map();
|
|
80975
81174
|
#requestTransactions = /* @__PURE__ */ new Map();
|
|
81175
|
+
#settlements = /* @__PURE__ */ new Map();
|
|
80976
81176
|
constructor(deps) {
|
|
80977
81177
|
this.#deps = deps;
|
|
80978
81178
|
}
|
|
80979
|
-
async start(requestId) {
|
|
81179
|
+
async start(requestId, options = {}) {
|
|
81180
|
+
const operation = options.operation ?? "runtime-update";
|
|
81181
|
+
const origin = options.origin ?? "user";
|
|
81182
|
+
if (this.#shuttingDown) throw new AwareUpdateConflictError("FloLess is shutting down.");
|
|
80980
81183
|
this.#purge();
|
|
80981
81184
|
if (requestId) {
|
|
80982
81185
|
const transaction = this.#requestTransactions.get(requestId);
|
|
@@ -80985,7 +81188,7 @@ var AwareUpdateJobManager = class {
|
|
|
80985
81188
|
if (existing) return cloneStatus(await existing);
|
|
80986
81189
|
}
|
|
80987
81190
|
if (this.#active || this.#starting || this.#retrying) throw new AwareUpdateConflictError("An AWARE update is already in progress.");
|
|
80988
|
-
const starting = this.#begin();
|
|
81191
|
+
const starting = this.#begin(operation, origin);
|
|
80989
81192
|
this.#starting = starting;
|
|
80990
81193
|
if (requestId) this.#requestStarts.set(requestId, starting);
|
|
80991
81194
|
try {
|
|
@@ -80997,25 +81200,118 @@ var AwareUpdateJobManager = class {
|
|
|
80997
81200
|
if (requestId && this.#requestStarts.get(requestId) === starting) this.#requestStarts.delete(requestId);
|
|
80998
81201
|
}
|
|
80999
81202
|
}
|
|
81000
|
-
async #begin() {
|
|
81001
|
-
|
|
81203
|
+
async #begin(requestedOperation, origin) {
|
|
81204
|
+
let operation = requestedOperation;
|
|
81205
|
+
let preResolved = null;
|
|
81206
|
+
let target;
|
|
81207
|
+
if (operation === "bridge-repair") {
|
|
81208
|
+
const resolved = await this.#deps.resolveBridgeRepair(this.#currentOwnerOrThrow());
|
|
81209
|
+
if (!resolved) throw new AwareUpdateConflictError("No installed AWARE bridge needs repair.");
|
|
81210
|
+
target = requireExactAwareTarget(resolved.target);
|
|
81211
|
+
preResolved = resolved.hosts;
|
|
81212
|
+
if (!preResolved.length) throw new AwareUpdateConflictError("No installed AWARE bridge needs repair.");
|
|
81213
|
+
} else {
|
|
81214
|
+
const resolved = await this.#deps.resolveCurrentTarget();
|
|
81215
|
+
target = requireExactAwareTarget(resolved.target);
|
|
81216
|
+
operation = resolved.operation;
|
|
81217
|
+
}
|
|
81002
81218
|
if (this.#active || this.#retrying) throw new AwareUpdateConflictError("An AWARE update is already in progress.");
|
|
81219
|
+
if (this.#shuttingDown) throw new AwareUpdateConflictError("FloLess is shutting down.");
|
|
81003
81220
|
const transaction = (this.#deps.randomId ?? cryptoRandomId)();
|
|
81004
81221
|
const status = {
|
|
81005
81222
|
state: "running",
|
|
81006
81223
|
transaction,
|
|
81007
81224
|
stage: "queued",
|
|
81008
81225
|
target,
|
|
81226
|
+
operation,
|
|
81227
|
+
origin,
|
|
81009
81228
|
completed: 0,
|
|
81010
81229
|
total: 0,
|
|
81011
81230
|
updated: frozenHosts([])
|
|
81012
81231
|
};
|
|
81013
81232
|
const startedAt = this.#now();
|
|
81014
|
-
this.#jobs.set(transaction, {
|
|
81233
|
+
this.#jobs.set(transaction, {
|
|
81234
|
+
status,
|
|
81235
|
+
snapshot: frozenHosts([]),
|
|
81236
|
+
startedAt,
|
|
81237
|
+
touchedAt: startedAt,
|
|
81238
|
+
...preResolved ? { preResolved } : {}
|
|
81239
|
+
});
|
|
81015
81240
|
this.#active = transaction;
|
|
81016
|
-
|
|
81241
|
+
const settled = this.#execute(transaction).catch((error) => this.#unexpectedFailure(transaction, error));
|
|
81242
|
+
this.#settlements.set(transaction, settled);
|
|
81243
|
+
void settled;
|
|
81017
81244
|
return cloneStatus(status);
|
|
81018
81245
|
}
|
|
81246
|
+
/**
|
|
81247
|
+
* Resolves when the job reaches a terminal state. The automatic path awaits this INSIDE its
|
|
81248
|
+
* leased callback so the lease is held for the whole job — without it the callback would return
|
|
81249
|
+
* the moment the job was accepted, drop the lease, and let #execute re-acquire it in a race it
|
|
81250
|
+
* was created to avoid.
|
|
81251
|
+
*/
|
|
81252
|
+
async settled(transaction) {
|
|
81253
|
+
await this.#settlements.get(transaction);
|
|
81254
|
+
}
|
|
81255
|
+
#currentOwnerOrThrow() {
|
|
81256
|
+
const owner2 = this.#deps.currentOwner();
|
|
81257
|
+
if (!owner2) throw new Error("A bridge repair must be started inside the exclusive lifecycle lease.");
|
|
81258
|
+
return owner2;
|
|
81259
|
+
}
|
|
81260
|
+
/**
|
|
81261
|
+
* What a browser that started nothing should adopt: the running job, else the most recent
|
|
81262
|
+
* UNACKNOWLEDGED automatic failure. Lease-free by construction — a leased read would queue
|
|
81263
|
+
* behind the very repair it is trying to observe.
|
|
81264
|
+
*
|
|
81265
|
+
* Ordering is by `terminalAt`, never `touchedAt`: `get()` bumps `touchedAt` on every poll, so an
|
|
81266
|
+
* old failure that happens to be polled would otherwise outrank a newer one. Successes are never
|
|
81267
|
+
* surfaced (nothing to act on), and acknowledged failures stop coming back — without that a
|
|
81268
|
+
* dismissed `partial` re-alarms on every page load for the full retention window.
|
|
81269
|
+
*/
|
|
81270
|
+
activeStatus() {
|
|
81271
|
+
this.#purge();
|
|
81272
|
+
if (this.#active) {
|
|
81273
|
+
const running = this.#jobs.get(this.#active);
|
|
81274
|
+
if (running && !isTerminal(running.status)) return cloneStatus(running.status);
|
|
81275
|
+
}
|
|
81276
|
+
let best = null;
|
|
81277
|
+
for (const record3 of this.#jobs.values()) {
|
|
81278
|
+
if (record3.status.origin !== "auto" || record3.acknowledged) continue;
|
|
81279
|
+
if (record3.status.state !== "partial" && record3.status.state !== "runtime-failed") continue;
|
|
81280
|
+
if (!best || (record3.terminalAt ?? 0) > (best.terminalAt ?? 0)) best = record3;
|
|
81281
|
+
}
|
|
81282
|
+
return best ? cloneStatus(best.status) : null;
|
|
81283
|
+
}
|
|
81284
|
+
/**
|
|
81285
|
+
* Retire a terminal automatic result the user has seen. Scoped to one transaction and refused
|
|
81286
|
+
* while it is still running: a blanket "the modal closed" acknowledgement could retire a job
|
|
81287
|
+
* that later turns partial, hiding a failure nobody ever saw. Idempotent.
|
|
81288
|
+
*/
|
|
81289
|
+
acknowledge(transaction) {
|
|
81290
|
+
this.#purge();
|
|
81291
|
+
const record3 = this.#jobs.get(transaction);
|
|
81292
|
+
if (!record3) {
|
|
81293
|
+
if (this.#gone.has(transaction)) throw new AwareUpdateGoneError("This AWARE update result has expired.");
|
|
81294
|
+
throw new AwareUpdateNotFoundError("AWARE update transaction not found.");
|
|
81295
|
+
}
|
|
81296
|
+
if (!isTerminal(record3.status)) {
|
|
81297
|
+
throw new AwareUpdateConflictError("That AWARE operation has not finished yet.");
|
|
81298
|
+
}
|
|
81299
|
+
record3.acknowledged = true;
|
|
81300
|
+
record3.touchedAt = this.#now();
|
|
81301
|
+
return cloneStatus(record3.status);
|
|
81302
|
+
}
|
|
81303
|
+
/**
|
|
81304
|
+
* Stop admitting work, abort the in-flight child, and await settlement. A bridge-repair marker is
|
|
81305
|
+
* deliberately LEFT in place: it describes unfinished work, and the next launch's recovery is
|
|
81306
|
+
* what finishes it. Clearing it here would look like a clean finish and strand the bridges.
|
|
81307
|
+
*/
|
|
81308
|
+
async shutdown() {
|
|
81309
|
+
this.#shuttingDown = true;
|
|
81310
|
+
this.#activeController?.abort(new DeadlineError("FloLess is shutting down."));
|
|
81311
|
+
await Promise.allSettled([this.#starting, ...this.#settlements.values()].filter(Boolean));
|
|
81312
|
+
this.#activeController?.abort(new DeadlineError("FloLess is shutting down."));
|
|
81313
|
+
await Promise.allSettled([...this.#settlements.values()]);
|
|
81314
|
+
}
|
|
81019
81315
|
get(transaction) {
|
|
81020
81316
|
this.#purge();
|
|
81021
81317
|
const record3 = this.#jobs.get(transaction);
|
|
@@ -81066,21 +81362,25 @@ var AwareUpdateJobManager = class {
|
|
|
81066
81362
|
const jobBudget = this.#deps.jobTimeoutMs ?? DEFAULT_JOB_TIMEOUT;
|
|
81067
81363
|
const deadline = started + jobBudget;
|
|
81068
81364
|
const jobController = new AbortController();
|
|
81365
|
+
this.#activeController = jobController;
|
|
81069
81366
|
const jobTimer = setTimeout(() => jobController.abort(new DeadlineError()), jobBudget);
|
|
81070
81367
|
jobTimer.unref?.();
|
|
81071
81368
|
try {
|
|
81072
81369
|
await this.#deps.withExclusive(async (owner2) => this.#deps.withMutationContainment(transaction, owner2, async () => {
|
|
81370
|
+
const operation = record3.status.operation;
|
|
81073
81371
|
this.#running(record3, "snapshot", 0, 0, []);
|
|
81074
|
-
const snapshot = await this.#deps.snapshotPersistentBridges(owner2, record3.status.target);
|
|
81372
|
+
const snapshot = record3.preResolved ?? await this.#deps.snapshotPersistentBridges(owner2, record3.status.target);
|
|
81075
81373
|
this.#assertSnapshot(snapshot);
|
|
81076
81374
|
record3.snapshot = frozenHosts(snapshot);
|
|
81077
81375
|
this.#running(record3, "runtime-install", 0, snapshot.length, []);
|
|
81078
81376
|
let marker = {
|
|
81079
|
-
schema:
|
|
81377
|
+
schema: 2,
|
|
81080
81378
|
transaction,
|
|
81081
81379
|
stage: "runtime-install",
|
|
81082
81380
|
target: record3.status.target,
|
|
81083
|
-
snapshot: record3.snapshot
|
|
81381
|
+
snapshot: record3.snapshot,
|
|
81382
|
+
operation,
|
|
81383
|
+
origin: record3.status.origin
|
|
81084
81384
|
};
|
|
81085
81385
|
await this.#deps.maintenance.write(marker);
|
|
81086
81386
|
let observed = null;
|
|
@@ -81088,6 +81388,12 @@ var AwareUpdateJobManager = class {
|
|
|
81088
81388
|
try {
|
|
81089
81389
|
const installedBefore = await this.#deps.probeRuntime(owner2);
|
|
81090
81390
|
if (installedBefore !== record3.status.target) {
|
|
81391
|
+
if (operation === "bridge-repair") {
|
|
81392
|
+
throw Object.assign(
|
|
81393
|
+
new Error("The installed AWARE runtime changed before the bridge repair began."),
|
|
81394
|
+
{ code: "runtime-superseded" }
|
|
81395
|
+
);
|
|
81396
|
+
}
|
|
81091
81397
|
await bounded(
|
|
81092
81398
|
(signal) => this.#deps.installRuntime(record3.status.target, {
|
|
81093
81399
|
owner: owner2,
|
|
@@ -81164,6 +81470,17 @@ var AwareUpdateJobManager = class {
|
|
|
81164
81470
|
}
|
|
81165
81471
|
}
|
|
81166
81472
|
}
|
|
81473
|
+
await this.#persistBridgeIntent(record3, failed);
|
|
81474
|
+
await Promise.resolve(this.#deps.refreshRuntime(owner2)).catch(() => {
|
|
81475
|
+
});
|
|
81476
|
+
this.#deps.invalidateVersion();
|
|
81477
|
+
const afterBridges = await this.#deps.probeRuntime(owner2);
|
|
81478
|
+
if (afterBridges !== record3.status.target) {
|
|
81479
|
+
throw Object.assign(
|
|
81480
|
+
new Error("The installed AWARE runtime changed while the bridges were being refreshed."),
|
|
81481
|
+
{ code: "runtime-superseded" }
|
|
81482
|
+
);
|
|
81483
|
+
}
|
|
81167
81484
|
this.#finishBridges(record3, observed, updated, failed);
|
|
81168
81485
|
} catch (error) {
|
|
81169
81486
|
await Promise.resolve(this.#deps.refreshRuntime(owner2)).catch(() => {
|
|
@@ -81189,7 +81506,9 @@ var AwareUpdateJobManager = class {
|
|
|
81189
81506
|
}), { signal: jobController.signal });
|
|
81190
81507
|
} finally {
|
|
81191
81508
|
clearTimeout(jobTimer);
|
|
81509
|
+
if (this.#activeController === jobController) this.#activeController = null;
|
|
81192
81510
|
if (this.#active === transaction) this.#active = null;
|
|
81511
|
+
this.#settlements.delete(transaction);
|
|
81193
81512
|
this.#purge();
|
|
81194
81513
|
}
|
|
81195
81514
|
}
|
|
@@ -81219,6 +81538,8 @@ var AwareUpdateJobManager = class {
|
|
|
81219
81538
|
state: "retrying",
|
|
81220
81539
|
transaction: status.transaction,
|
|
81221
81540
|
target: status.target,
|
|
81541
|
+
operation: status.operation,
|
|
81542
|
+
origin: status.origin,
|
|
81222
81543
|
host,
|
|
81223
81544
|
completed: status.updated.length,
|
|
81224
81545
|
total: record3.snapshot.length,
|
|
@@ -81228,12 +81549,14 @@ var AwareUpdateJobManager = class {
|
|
|
81228
81549
|
reserved = true;
|
|
81229
81550
|
resolveReserved(cloneStatus(record3.status));
|
|
81230
81551
|
let marker = {
|
|
81231
|
-
schema:
|
|
81552
|
+
schema: 2,
|
|
81232
81553
|
transaction: status.transaction,
|
|
81233
81554
|
stage: "retry-install",
|
|
81234
81555
|
target: status.target,
|
|
81235
81556
|
host,
|
|
81236
|
-
snapshot: record3.snapshot
|
|
81557
|
+
snapshot: record3.snapshot,
|
|
81558
|
+
operation: status.operation,
|
|
81559
|
+
origin: status.origin
|
|
81237
81560
|
};
|
|
81238
81561
|
try {
|
|
81239
81562
|
await this.#deps.maintenance.write(marker);
|
|
@@ -81259,6 +81582,7 @@ var AwareUpdateJobManager = class {
|
|
|
81259
81582
|
if (!verified) throw Object.assign(new Error(`The ${host} bridge version could not be verified.`), { code: "bridge-version-mismatch" });
|
|
81260
81583
|
const updatedSet = /* @__PURE__ */ new Set([...status.updated, host]);
|
|
81261
81584
|
const updated = frozenHosts(record3.snapshot.filter((candidate) => updatedSet.has(candidate)));
|
|
81585
|
+
await this.#persistBridgeIntent(record3, otherFailures);
|
|
81262
81586
|
if (otherFailures.length) {
|
|
81263
81587
|
this.#setTerminal(record3, {
|
|
81264
81588
|
state: "partial",
|
|
@@ -81280,13 +81604,15 @@ var AwareUpdateJobManager = class {
|
|
|
81280
81604
|
} catch (error) {
|
|
81281
81605
|
const failure = error instanceof DeadlineError ? timeoutFailure(host) : { host, ...sanitizeAwareError(error, "bridge-update-failed") };
|
|
81282
81606
|
this.#log(record3, "bridge-retry", failure, host);
|
|
81607
|
+
const stillFailing = frozenFailures([...otherFailures, failure]);
|
|
81608
|
+
await this.#persistBridgeIntent(record3, stillFailing);
|
|
81283
81609
|
this.#setTerminal(record3, {
|
|
81284
81610
|
state: "partial",
|
|
81285
81611
|
transaction: status.transaction,
|
|
81286
81612
|
target: status.target,
|
|
81287
81613
|
observedVersion: status.observedVersion,
|
|
81288
81614
|
updated: status.updated,
|
|
81289
|
-
failed:
|
|
81615
|
+
failed: stillFailing
|
|
81290
81616
|
});
|
|
81291
81617
|
} finally {
|
|
81292
81618
|
await this.#deps.maintenance.clear().catch((error) => {
|
|
@@ -81304,6 +81630,28 @@ var AwareUpdateJobManager = class {
|
|
|
81304
81630
|
if (this.#retrying === record3.status.transaction) this.#retrying = null;
|
|
81305
81631
|
}
|
|
81306
81632
|
}
|
|
81633
|
+
/**
|
|
81634
|
+
* Persist which installed hosts still owe us a matching bridge — or discharge the record when
|
|
81635
|
+
* none do. The single place that decision is written, because getting it wrong in either
|
|
81636
|
+
* direction is expensive: losing it forgets a host whose executable a failed installer removed,
|
|
81637
|
+
* and failing to clear it re-runs a full sidecar reinstall of healthy bridges on every launch.
|
|
81638
|
+
*
|
|
81639
|
+
* A failure here is reported, never swallowed. This store exists precisely to stop a bridge
|
|
81640
|
+
* disappearing silently, so a silent write failure would defeat the mechanism it implements.
|
|
81641
|
+
*/
|
|
81642
|
+
async #persistBridgeIntent(record3, failed) {
|
|
81643
|
+
const hosts = frozenHosts(failed.map((failure) => failure.host));
|
|
81644
|
+
try {
|
|
81645
|
+
if (hosts.length) await this.#deps.recordBridgePending(record3.status.target, hosts);
|
|
81646
|
+
else await this.#deps.clearBridgePending();
|
|
81647
|
+
} catch (error) {
|
|
81648
|
+
this.#log(
|
|
81649
|
+
record3,
|
|
81650
|
+
hosts.length ? "bridge-pending-record" : "bridge-pending-clear",
|
|
81651
|
+
sanitizeAwareError(error, "bridge-pending-failed")
|
|
81652
|
+
);
|
|
81653
|
+
}
|
|
81654
|
+
}
|
|
81307
81655
|
#finishBridges(record3, observedVersion, updated, failed) {
|
|
81308
81656
|
if (updated.length + failed.length !== record3.snapshot.length) {
|
|
81309
81657
|
throw new Error("AWARE bridge update did not partition its immutable snapshot.");
|
|
@@ -81332,6 +81680,8 @@ var AwareUpdateJobManager = class {
|
|
|
81332
81680
|
state: "running",
|
|
81333
81681
|
transaction: record3.status.transaction,
|
|
81334
81682
|
target: record3.status.target,
|
|
81683
|
+
operation: record3.status.operation,
|
|
81684
|
+
origin: record3.status.origin,
|
|
81335
81685
|
stage,
|
|
81336
81686
|
completed,
|
|
81337
81687
|
total,
|
|
@@ -81340,7 +81690,13 @@ var AwareUpdateJobManager = class {
|
|
|
81340
81690
|
record3.touchedAt = this.#now();
|
|
81341
81691
|
}
|
|
81342
81692
|
#setTerminal(record3, status) {
|
|
81343
|
-
record3.status = {
|
|
81693
|
+
record3.status = {
|
|
81694
|
+
...status,
|
|
81695
|
+
// Carried from the record, never from the caller — see TerminalAwareUpdateInput.
|
|
81696
|
+
operation: record3.status.operation,
|
|
81697
|
+
origin: record3.status.origin,
|
|
81698
|
+
durationMs: Math.max(0, this.#now() - record3.startedAt)
|
|
81699
|
+
};
|
|
81344
81700
|
record3.terminalAt = this.#now();
|
|
81345
81701
|
record3.touchedAt = record3.terminalAt;
|
|
81346
81702
|
}
|
|
@@ -81443,6 +81799,17 @@ function sendRouteError(reply, error) {
|
|
|
81443
81799
|
return reply.status(400).send({ ok: false, error: sanitizeAwareError(error, "invalid-update-request").message });
|
|
81444
81800
|
}
|
|
81445
81801
|
function registerAwareUpdateRoutes(app, manager) {
|
|
81802
|
+
app.get("/api/aware/update/active", async (_request, reply) => reply.send({ ok: true, job: manager.activeStatus() }));
|
|
81803
|
+
app.post(
|
|
81804
|
+
"/api/aware/update/status/:transaction/acknowledge",
|
|
81805
|
+
async (request, reply) => {
|
|
81806
|
+
try {
|
|
81807
|
+
return reply.send({ ok: true, ...manager.acknowledge(request.params.transaction) });
|
|
81808
|
+
} catch (error) {
|
|
81809
|
+
return sendRouteError(reply, error);
|
|
81810
|
+
}
|
|
81811
|
+
}
|
|
81812
|
+
);
|
|
81446
81813
|
app.post("/api/aware/update/apply", async (request, reply) => {
|
|
81447
81814
|
try {
|
|
81448
81815
|
const value = request.headers["x-floless-request-id"];
|
|
@@ -81474,7 +81841,7 @@ function registerAwareUpdateRoutes(app, manager) {
|
|
|
81474
81841
|
}
|
|
81475
81842
|
|
|
81476
81843
|
// skill-sync.ts
|
|
81477
|
-
var
|
|
81844
|
+
var import_node_fs58 = require("node:fs");
|
|
81478
81845
|
var import_node_os27 = require("node:os");
|
|
81479
81846
|
var import_node_path54 = require("node:path");
|
|
81480
81847
|
var import_node_url4 = require("node:url");
|
|
@@ -81530,7 +81897,7 @@ function bundledSkillsRoot() {
|
|
|
81530
81897
|
(0, import_node_path54.join)((0, import_node_path54.dirname)(process.execPath), "skills"),
|
|
81531
81898
|
(0, import_node_path54.join)(__dirname3, "..", ".claude", "skills")
|
|
81532
81899
|
];
|
|
81533
|
-
return candidates.find((p) => (0,
|
|
81900
|
+
return candidates.find((p) => (0, import_node_fs58.existsSync)(p)) ?? null;
|
|
81534
81901
|
}
|
|
81535
81902
|
function targetConfigDirs() {
|
|
81536
81903
|
const override = process.env.FLOLESS_SKILL_TARGETS;
|
|
@@ -81546,7 +81913,7 @@ function targetConfigDirs() {
|
|
|
81546
81913
|
}
|
|
81547
81914
|
function skillVersion(skillMdPath) {
|
|
81548
81915
|
try {
|
|
81549
|
-
const text3 = (0,
|
|
81916
|
+
const text3 = (0, import_node_fs58.readFileSync)(skillMdPath, "utf8");
|
|
81550
81917
|
const m = /^---\r?\n([\s\S]*?)\r?\n---/.exec(text3);
|
|
81551
81918
|
if (!m || m[1] === void 0) return null;
|
|
81552
81919
|
const fm = (0, import_yaml11.parse)(m[1]);
|
|
@@ -81586,7 +81953,7 @@ function decideAction(installed, bundled) {
|
|
|
81586
81953
|
function bundledSkills(root5) {
|
|
81587
81954
|
let entries2 = [];
|
|
81588
81955
|
try {
|
|
81589
|
-
entries2 = selectShippedSkillNames((0,
|
|
81956
|
+
entries2 = selectShippedSkillNames((0, import_node_fs58.readdirSync)(root5));
|
|
81590
81957
|
} catch {
|
|
81591
81958
|
return [];
|
|
81592
81959
|
}
|
|
@@ -81595,7 +81962,7 @@ function bundledSkills(root5) {
|
|
|
81595
81962
|
const dir = (0, import_node_path54.join)(root5, name);
|
|
81596
81963
|
let isDir = false;
|
|
81597
81964
|
try {
|
|
81598
|
-
isDir = (0,
|
|
81965
|
+
isDir = (0, import_node_fs58.statSync)(dir).isDirectory();
|
|
81599
81966
|
} catch {
|
|
81600
81967
|
isDir = false;
|
|
81601
81968
|
}
|
|
@@ -81613,17 +81980,17 @@ function syncSkills() {
|
|
|
81613
81980
|
const skills = bundledSkills(root5);
|
|
81614
81981
|
if (!skills.length) return results;
|
|
81615
81982
|
for (const { runtime, dir: cfg } of targetConfigDirs()) {
|
|
81616
|
-
if (!(0,
|
|
81983
|
+
if (!(0, import_node_fs58.existsSync)(cfg)) continue;
|
|
81617
81984
|
const skillsDir = (0, import_node_path54.join)(cfg, "skills");
|
|
81618
81985
|
for (const s of skills) {
|
|
81619
81986
|
const dest = (0, import_node_path54.join)(skillsDir, s.name);
|
|
81620
81987
|
const installedMd = (0, import_node_path54.join)(dest, "SKILL.md");
|
|
81621
|
-
const installed = (0,
|
|
81988
|
+
const installed = (0, import_node_fs58.existsSync)(installedMd) ? skillVersion(installedMd) : null;
|
|
81622
81989
|
const action = decideAction(installed, s.version);
|
|
81623
81990
|
if (action === "installed" || action === "updated") {
|
|
81624
81991
|
try {
|
|
81625
|
-
if (action === "updated") (0,
|
|
81626
|
-
(0,
|
|
81992
|
+
if (action === "updated") (0, import_node_fs58.rmSync)(dest, { recursive: true, force: true });
|
|
81993
|
+
(0, import_node_fs58.cpSync)(s.dir, dest, { recursive: true });
|
|
81627
81994
|
results.push({ runtime, skill: s.name, action, from: installed, to: s.version });
|
|
81628
81995
|
} catch {
|
|
81629
81996
|
}
|
|
@@ -81638,7 +82005,7 @@ function syncSkills() {
|
|
|
81638
82005
|
// watch.ts
|
|
81639
82006
|
var import_node_os28 = require("node:os");
|
|
81640
82007
|
var import_node_path56 = require("node:path");
|
|
81641
|
-
var
|
|
82008
|
+
var import_node_fs59 = require("node:fs");
|
|
81642
82009
|
|
|
81643
82010
|
// node_modules/chokidar/esm/index.js
|
|
81644
82011
|
var import_fs2 = require("fs");
|
|
@@ -83351,20 +83718,20 @@ function underDir(path, dir) {
|
|
|
83351
83718
|
function startWatcher() {
|
|
83352
83719
|
const awareDir = process.env.AWARE_HOME ?? (0, import_node_path56.join)((0, import_node_os28.homedir)(), ".aware");
|
|
83353
83720
|
const credentialsDir = (0, import_node_path56.join)(awareDir, "credentials");
|
|
83354
|
-
if (!(0,
|
|
83721
|
+
if (!(0, import_node_fs59.existsSync)(credentialsDir)) {
|
|
83355
83722
|
try {
|
|
83356
|
-
(0,
|
|
83723
|
+
(0, import_node_fs59.mkdirSync)(credentialsDir, { recursive: true });
|
|
83357
83724
|
} catch {
|
|
83358
83725
|
}
|
|
83359
83726
|
}
|
|
83360
|
-
if (!(0,
|
|
83727
|
+
if (!(0, import_node_fs59.existsSync)(uiDir)) {
|
|
83361
83728
|
try {
|
|
83362
|
-
(0,
|
|
83729
|
+
(0, import_node_fs59.mkdirSync)(uiDir, { recursive: true });
|
|
83363
83730
|
} catch {
|
|
83364
83731
|
}
|
|
83365
83732
|
}
|
|
83366
|
-
const targets = ["apps", "logs", "credentials"].map((d) => (0, import_node_path56.join)(awareDir, d)).filter((p) => (0,
|
|
83367
|
-
if ((0,
|
|
83733
|
+
const targets = ["apps", "logs", "credentials"].map((d) => (0, import_node_path56.join)(awareDir, d)).filter((p) => (0, import_node_fs59.existsSync)(p));
|
|
83734
|
+
if ((0, import_node_fs59.existsSync)(uiDir)) targets.push(uiDir);
|
|
83368
83735
|
if (targets.length === 0) {
|
|
83369
83736
|
return null;
|
|
83370
83737
|
}
|
|
@@ -83393,11 +83760,11 @@ function startWatcher() {
|
|
|
83393
83760
|
const isCredential = path.split(/[\\/]/).includes("credentials");
|
|
83394
83761
|
const kind = isCredential ? "credential" : path.endsWith(".jsonl") ? "trace" : path.endsWith(".lock") ? "lock" : path.endsWith(".flo") || path.endsWith(".app") ? "source" : "file";
|
|
83395
83762
|
broadcast({ type: "fs-change", kind, event, path });
|
|
83396
|
-
if (kind === "trace" && event !== "unlink" && (0,
|
|
83763
|
+
if (kind === "trace" && event !== "unlink" && (0, import_node_fs59.existsSync)(path)) {
|
|
83397
83764
|
const id = appIdFromLogPath(path);
|
|
83398
83765
|
if (!id) return;
|
|
83399
83766
|
try {
|
|
83400
|
-
broadcast({ type: "trace-file", id, runId: path.split(import_node_path56.sep).pop()?.replace(/\.jsonl$/, "") ?? null, events: parseTrace((0,
|
|
83767
|
+
broadcast({ type: "trace-file", id, runId: path.split(import_node_path56.sep).pop()?.replace(/\.jsonl$/, "") ?? null, events: parseTrace((0, import_node_fs59.readFileSync)(path, "utf8")) });
|
|
83401
83768
|
} catch {
|
|
83402
83769
|
}
|
|
83403
83770
|
}
|
|
@@ -83408,7 +83775,7 @@ function startWatcher() {
|
|
|
83408
83775
|
// index.ts
|
|
83409
83776
|
var __dirname4 = (0, import_node_path57.dirname)((0, import_node_url5.fileURLToPath)(__import_meta_url));
|
|
83410
83777
|
var WEB_ROOT = [(0, import_node_path57.join)(__dirname4, "web"), (0, import_node_path57.join)((0, import_node_path57.dirname)(process.execPath), "web"), (0, import_node_path57.join)(__dirname4, "..", "web")].find(
|
|
83411
|
-
(p) => (0,
|
|
83778
|
+
(p) => (0, import_node_fs60.existsSync)(p)
|
|
83412
83779
|
) ?? (0, import_node_path57.join)(__dirname4, "..", "web");
|
|
83413
83780
|
var PORT2 = Number(process.env.PORT ?? 4317);
|
|
83414
83781
|
var HOST = "127.0.0.1";
|
|
@@ -83425,7 +83792,7 @@ function installCrashHandlers() {
|
|
|
83425
83792
|
${stack}
|
|
83426
83793
|
`;
|
|
83427
83794
|
try {
|
|
83428
|
-
(0,
|
|
83795
|
+
(0, import_node_fs60.appendFileSync)(logFilePath(), line);
|
|
83429
83796
|
} catch {
|
|
83430
83797
|
}
|
|
83431
83798
|
if (process.stderr.isTTY) process.stderr.write(line);
|
|
@@ -83524,6 +83891,16 @@ async function startServer() {
|
|
|
83524
83891
|
const awareMaintenance = createMaintenanceMarkerStore(
|
|
83525
83892
|
(0, import_node_path57.join)((0, import_node_os29.homedir)(), ".floless", "aware-maintenance.json")
|
|
83526
83893
|
);
|
|
83894
|
+
const awareBridgePending = createBridgePendingStore(
|
|
83895
|
+
(0, import_node_path57.join)((0, import_node_os29.homedir)(), ".floless", "aware-bridge-pending.json")
|
|
83896
|
+
);
|
|
83897
|
+
async function staleBridgesForInstalledRuntime() {
|
|
83898
|
+
const target = aware.npmVersion();
|
|
83899
|
+
if (!target || !isExactAwareTarget(target)) return null;
|
|
83900
|
+
const inventory = await inspectPersistentBridgeInventory(AWARE_BRIDGE_DIRECTORY, target);
|
|
83901
|
+
const hosts = bridgesNeedingRepair(inventory, await awareBridgePending.read(), target);
|
|
83902
|
+
return hosts.length ? { target, hosts } : null;
|
|
83903
|
+
}
|
|
83527
83904
|
function upgradeOwner() {
|
|
83528
83905
|
const owner2 = currentAwareOwner();
|
|
83529
83906
|
if (!owner2) throw new Error("AWARE updater is outside its exclusive lifecycle owner");
|
|
@@ -83557,11 +83934,27 @@ async function startServer() {
|
|
|
83557
83934
|
throw Object.assign(new Error("An interrupted AWARE update must be recovered before starting another."), { code: "maintenance-pending" });
|
|
83558
83935
|
}
|
|
83559
83936
|
const check = await checkAwareUpdate(AWARE_BRIDGE_DIRECTORY);
|
|
83560
|
-
return
|
|
83937
|
+
return {
|
|
83938
|
+
target: check.updateAvailable ? check.targetVersion ?? null : null,
|
|
83939
|
+
// 'none' cannot reach a started job (the target is null and requireExactAwareTarget throws),
|
|
83940
|
+
// but map it defensively rather than casting — the check type lets the two disagree.
|
|
83941
|
+
operation: check.operation === "bridge-repair" ? "bridge-repair" : "runtime-update"
|
|
83942
|
+
};
|
|
83943
|
+
},
|
|
83944
|
+
// Runs inside the caller's exclusive lease, so the installed version it reads cannot move under
|
|
83945
|
+
// it — and it never asks npm what the newest release is. Both properties are load-bearing: this
|
|
83946
|
+
// is what stops a "repair" from installing a newer runtime, or reinstalling an older one.
|
|
83947
|
+
resolveBridgeRepair: async (owner2) => {
|
|
83948
|
+
if (owner2 !== upgradeOwner()) throw new Error("AWARE bridge-repair owner mismatch");
|
|
83949
|
+
return staleBridgesForInstalledRuntime();
|
|
83561
83950
|
},
|
|
83951
|
+
recordBridgePending: (target, hosts) => awareBridgePending.write({ schema: 1, target, hosts }),
|
|
83952
|
+
clearBridgePending: () => awareBridgePending.clear(),
|
|
83953
|
+
currentOwner: () => currentAwareOwner(),
|
|
83562
83954
|
snapshotPersistentBridges: async (_owner, target) => {
|
|
83563
83955
|
const inventory = await inspectPersistentBridgeInventory(AWARE_BRIDGE_DIRECTORY, target);
|
|
83564
|
-
|
|
83956
|
+
const hosts = bridgesNeedingRepair(inventory, await awareBridgePending.read(), target);
|
|
83957
|
+
return hosts;
|
|
83565
83958
|
},
|
|
83566
83959
|
withExclusive: (work, options) => withAwareExclusive(
|
|
83567
83960
|
() => work(upgradeOwner()),
|
|
@@ -83607,18 +84000,26 @@ async function startServer() {
|
|
|
83607
84000
|
if (owner2 !== upgradeOwner()) return false;
|
|
83608
84001
|
refreshInvoker();
|
|
83609
84002
|
invalidateAwareVersion();
|
|
83610
|
-
|
|
84003
|
+
const target = decideRecoveryTarget({
|
|
84004
|
+
markerTarget: marker?.target ?? null,
|
|
84005
|
+
markerOperation: marker?.operation ?? null,
|
|
84006
|
+
installed: aware.npmVersion()
|
|
84007
|
+
});
|
|
83611
84008
|
if (!target || !/^\d+\.\d+\.\d+$/.test(target)) return false;
|
|
83612
|
-
|
|
84009
|
+
const durable = await awareBridgePending.read();
|
|
84010
|
+
const observedHosts = await snapshotPersistentBridges(AWARE_BRIDGE_DIRECTORY);
|
|
84011
|
+
let snapshot = Object.freeze(AWARE_BRIDGE_HOSTS.filter((host) => (marker?.snapshot ?? []).includes(host) || observedHosts.includes(host) || durable?.target === target && durable.hosts.includes(host)));
|
|
83613
84012
|
let recoveryMarker = {
|
|
83614
|
-
schema:
|
|
83615
|
-
transaction: marker?.transaction ?? (0,
|
|
84013
|
+
schema: 2,
|
|
84014
|
+
transaction: marker?.transaction ?? (0, import_node_crypto32.randomUUID)(),
|
|
83616
84015
|
stage: "recovery",
|
|
83617
84016
|
target,
|
|
83618
|
-
snapshot
|
|
84017
|
+
snapshot,
|
|
84018
|
+
operation: marker?.operation ?? LEGACY_MARKER_OPERATION,
|
|
84019
|
+
origin: marker?.origin ?? LEGACY_MARKER_ORIGIN
|
|
83619
84020
|
};
|
|
83620
84021
|
await awareMaintenance.write(recoveryMarker);
|
|
83621
|
-
if (aware.npmVersion() !== target) {
|
|
84022
|
+
if (aware.npmVersion() !== target || !await aware.smoke()) {
|
|
83622
84023
|
await installAwareGlobal(target, () => {
|
|
83623
84024
|
}, {
|
|
83624
84025
|
onChild: async (child) => {
|
|
@@ -83651,6 +84052,8 @@ async function startServer() {
|
|
|
83651
84052
|
}
|
|
83652
84053
|
});
|
|
83653
84054
|
}
|
|
84055
|
+
await awareBridgePending.clear().catch(() => {
|
|
84056
|
+
});
|
|
83654
84057
|
return true;
|
|
83655
84058
|
}
|
|
83656
84059
|
async function recoverAwareMaintenance() {
|
|
@@ -83662,16 +84065,84 @@ async function startServer() {
|
|
|
83662
84065
|
repairAndVerify: repairInterruptedAwareMaintenance
|
|
83663
84066
|
});
|
|
83664
84067
|
}
|
|
83665
|
-
|
|
84068
|
+
const SKIP_AUTO_BRIDGE_REPAIR = process.env.FLOLESS_SKIP_AUTO_BRIDGE_REPAIR === "1";
|
|
84069
|
+
let autoRepairScheduled = false;
|
|
84070
|
+
let autoRepairInFlight = false;
|
|
84071
|
+
let detachAutoRepairIdleWatch = null;
|
|
84072
|
+
function disarmAutoBridgeRepair() {
|
|
84073
|
+
detachAutoRepairIdleWatch?.();
|
|
84074
|
+
detachAutoRepairIdleWatch = null;
|
|
84075
|
+
}
|
|
84076
|
+
async function attemptAutoBridgeRepair() {
|
|
84077
|
+
if (autoRepairInFlight || SKIP_AUTO_BRIDGE_REPAIR) return;
|
|
84078
|
+
autoRepairInFlight = true;
|
|
83666
84079
|
try {
|
|
83667
|
-
await
|
|
84080
|
+
if (!await staleBridgesForInstalledRuntime()) {
|
|
84081
|
+
disarmAutoBridgeRepair();
|
|
84082
|
+
return;
|
|
84083
|
+
}
|
|
84084
|
+
const outcome = await tryWithAwareExclusiveIfIdle("auto", async () => {
|
|
84085
|
+
const status = await awareUpdateJobs.start(void 0, { operation: "bridge-repair", origin: "auto" });
|
|
84086
|
+
app.log.info({ transaction: status.transaction, target: status.target }, "repairing stale AWARE bridges");
|
|
84087
|
+
broadcast({ type: "aware-update", transaction: status.transaction });
|
|
84088
|
+
await awareUpdateJobs.settled(status.transaction);
|
|
84089
|
+
});
|
|
84090
|
+
if (!outcome.ran) return;
|
|
84091
|
+
disarmAutoBridgeRepair();
|
|
83668
84092
|
} catch (error) {
|
|
83669
|
-
|
|
83670
|
-
|
|
84093
|
+
const err2 = error instanceof Error ? error : new Error(String(error));
|
|
84094
|
+
const code = error?.code ?? null;
|
|
84095
|
+
const ordinary = error instanceof AwareUpdateConflictError || code === "maintenance-pending" || code === "runtime-superseded";
|
|
84096
|
+
if (ordinary) {
|
|
84097
|
+
app.log.info({ code, err: err2.message }, "automatic AWARE bridge repair declined");
|
|
84098
|
+
} else {
|
|
84099
|
+
app.log.error({ code, err: err2.message, stack: err2.stack }, "automatic AWARE bridge repair failed unexpectedly");
|
|
84100
|
+
}
|
|
84101
|
+
disarmAutoBridgeRepair();
|
|
84102
|
+
} finally {
|
|
84103
|
+
autoRepairInFlight = false;
|
|
83671
84104
|
}
|
|
83672
|
-
|
|
84105
|
+
}
|
|
84106
|
+
function scheduleAutoBridgeRepair() {
|
|
84107
|
+
if (autoRepairScheduled || SKIP_AUTO_BRIDGE_REPAIR) return;
|
|
84108
|
+
autoRepairScheduled = true;
|
|
84109
|
+
const backstop = (err2) => app.log.error({ err: String(err2) }, "automatic AWARE bridge repair wrapper rejected");
|
|
84110
|
+
detachAutoRepairIdleWatch = onAwareIdle(() => {
|
|
84111
|
+
void attemptAutoBridgeRepair().catch(backstop);
|
|
84112
|
+
});
|
|
84113
|
+
void attemptAutoBridgeRepair().catch(backstop);
|
|
84114
|
+
}
|
|
84115
|
+
let awareBootstrapInflight = null;
|
|
84116
|
+
async function startAwareBootstrap() {
|
|
84117
|
+
if (awareBootstrapInflight) return awareBootstrapInflight;
|
|
84118
|
+
awareBootstrapInflight = (async () => {
|
|
84119
|
+
try {
|
|
84120
|
+
await recoverAwareMaintenance();
|
|
84121
|
+
} catch (error) {
|
|
84122
|
+
app.log.error({ err: error instanceof Error ? error.message : String(error) }, "AWARE maintenance recovery failed");
|
|
84123
|
+
return failBootstrapMaintenanceRecovery(bootstrapDeps);
|
|
84124
|
+
}
|
|
84125
|
+
const state2 = await withAwareExclusive(() => runBootstrap(bootstrapDeps));
|
|
84126
|
+
if (state2.status === "ready") scheduleAutoBridgeRepair();
|
|
84127
|
+
return state2;
|
|
84128
|
+
})().finally(() => {
|
|
84129
|
+
awareBootstrapInflight = null;
|
|
84130
|
+
});
|
|
84131
|
+
return awareBootstrapInflight;
|
|
83673
84132
|
}
|
|
83674
84133
|
app.setErrorHandler((err2, req, reply) => {
|
|
84134
|
+
if (err2 instanceof AwareMaintenanceBusyError) {
|
|
84135
|
+
const job = awareUpdateJobs.activeStatus();
|
|
84136
|
+
const progress = job?.state === "running" && job.total ? { completed: job.completed, total: job.total } : null;
|
|
84137
|
+
return reply.status(409).send({
|
|
84138
|
+
ok: false,
|
|
84139
|
+
error: "aware_maintenance_busy",
|
|
84140
|
+
code: "maintenance-busy",
|
|
84141
|
+
operation: job?.operation ?? "bridge-repair",
|
|
84142
|
+
...progress ?? {},
|
|
84143
|
+
message: progress ? `FloLess is refreshing your installed bridges (${progress.completed} of ${progress.total}). This will be available again in a moment.` : "FloLess is refreshing your installed bridges. This will be available again in a moment."
|
|
84144
|
+
});
|
|
84145
|
+
}
|
|
83675
84146
|
if (err2 instanceof AppNotFoundError) {
|
|
83676
84147
|
return reply.status(404).send({ ok: false, error: err2.message });
|
|
83677
84148
|
}
|
|
@@ -83971,10 +84442,10 @@ async function startServer() {
|
|
|
83971
84442
|
const bdir = backupDir(id, fromVersion, Date.now());
|
|
83972
84443
|
let backedUp = false;
|
|
83973
84444
|
try {
|
|
83974
|
-
(0,
|
|
83975
|
-
(0,
|
|
84445
|
+
(0, import_node_fs60.mkdirSync)((0, import_node_path57.dirname)(bdir), { recursive: true });
|
|
84446
|
+
(0, import_node_fs60.cpSync)(appDirPath2, bdir, { recursive: true });
|
|
83976
84447
|
backedUp = true;
|
|
83977
|
-
(0,
|
|
84448
|
+
(0, import_node_fs60.cpSync)(templatePath, srcPath);
|
|
83978
84449
|
if (id !== templateId) stampSourceAppId(srcPath, id);
|
|
83979
84450
|
if (contract != null) {
|
|
83980
84451
|
bakeContractIntoApp(srcPath, contract);
|
|
@@ -83988,8 +84459,8 @@ async function startServer() {
|
|
|
83988
84459
|
throw new TemplateSwapError(`${verb} failed before any change was made (${msg}) \u2014 the workflow is untouched`, `${verb}-not-started`);
|
|
83989
84460
|
}
|
|
83990
84461
|
try {
|
|
83991
|
-
(0,
|
|
83992
|
-
(0,
|
|
84462
|
+
(0, import_node_fs60.rmSync)(appDirPath2, { recursive: true, force: true });
|
|
84463
|
+
(0, import_node_fs60.cpSync)(bdir, appDirPath2, { recursive: true });
|
|
83993
84464
|
} catch (re) {
|
|
83994
84465
|
const rmsg = re instanceof Error ? re.message : String(re);
|
|
83995
84466
|
throw new TemplateSwapError(`${verb} failed (${msg}) AND rollback failed (${rmsg}) \u2014 restore manually from ${bdir}`, "rollback-failed", bdir);
|
|
@@ -84001,7 +84472,7 @@ async function startServer() {
|
|
|
84001
84472
|
function readSwapContract(id, verb) {
|
|
84002
84473
|
const gerund = verb === "update" ? "updating" : "restoring";
|
|
84003
84474
|
const contract = readAcceptedForRequest(id, void 0);
|
|
84004
|
-
if (contract == null && (0,
|
|
84475
|
+
if (contract == null && (0, import_node_fs60.existsSync)(contractPath(id))) {
|
|
84005
84476
|
return { ok: false, body: { ok: false, error: `"${id}"'s saved data is unreadable \u2014 open it in the editor and re-save before ${gerund}`, code: "contract-corrupt" } };
|
|
84006
84477
|
}
|
|
84007
84478
|
if (contract != null && !validateContract(contract).valid) {
|
|
@@ -84301,7 +84772,7 @@ async function startServer() {
|
|
|
84301
84772
|
}
|
|
84302
84773
|
let data;
|
|
84303
84774
|
try {
|
|
84304
|
-
data = (0,
|
|
84775
|
+
data = (0, import_node_fs60.readFileSync)(thumb.path);
|
|
84305
84776
|
} catch {
|
|
84306
84777
|
return reply.status(404).send({ ok: false, error: "no thumbnail" });
|
|
84307
84778
|
}
|
|
@@ -84821,8 +85292,8 @@ async function startServer() {
|
|
|
84821
85292
|
if (bad) return reply.status(404).send({ ok: false, error: bad });
|
|
84822
85293
|
const safe2 = req.params.sheet.replace(/[^A-Za-z0-9._-]/g, "");
|
|
84823
85294
|
const file = (0, import_node_path57.join)((0, import_node_path57.dirname)(contractPath(req.params.appId, project)), "details", `${safe2}.svg`);
|
|
84824
|
-
if (!(0,
|
|
84825
|
-
return reply.type("image/svg+xml").send((0,
|
|
85295
|
+
if (!(0, import_node_fs60.existsSync)(file)) return reply.status(404).send({ ok: false, error: "no vector for this sheet" });
|
|
85296
|
+
return reply.type("image/svg+xml").send((0, import_node_fs60.readFileSync)(file, "utf8"));
|
|
84826
85297
|
}
|
|
84827
85298
|
);
|
|
84828
85299
|
app.put(
|
|
@@ -85308,7 +85779,7 @@ async function startServer() {
|
|
|
85308
85779
|
}
|
|
85309
85780
|
const statedAt = (filename) => {
|
|
85310
85781
|
try {
|
|
85311
|
-
const st = (0,
|
|
85782
|
+
const st = (0, import_node_fs60.statSync)((0, import_node_path57.join)(dir, filename));
|
|
85312
85783
|
return st.isFile() ? st.mtime.toISOString() : null;
|
|
85313
85784
|
} catch {
|
|
85314
85785
|
return null;
|
|
@@ -85427,7 +85898,7 @@ async function startServer() {
|
|
|
85427
85898
|
}
|
|
85428
85899
|
async function dropExportSourceId(appId, project) {
|
|
85429
85900
|
const ownerId = project ? await getOrCreateProjectExportSourceId(project) : await getOrCreateWorkflowExportSourceId(appId);
|
|
85430
|
-
return deriveDropExportSourceId(project ? "project" : "workflow", ownerId, (0,
|
|
85901
|
+
return deriveDropExportSourceId(project ? "project" : "workflow", ownerId, (0, import_node_crypto32.randomUUID)());
|
|
85431
85902
|
}
|
|
85432
85903
|
function explicitExportSourceSuffix(input) {
|
|
85433
85904
|
if (input.kind !== "project" || !input.snapshot.source) return "";
|
|
@@ -85480,15 +85951,15 @@ async function startServer() {
|
|
|
85480
85951
|
scene,
|
|
85481
85952
|
"output-path": tempPath
|
|
85482
85953
|
});
|
|
85483
|
-
if (!(0,
|
|
85954
|
+
if (!(0, import_node_fs60.existsSync)(tempPath) || (0, import_node_fs60.statSync)(tempPath).size === 0) {
|
|
85484
85955
|
throw new ReceiptReconciliationError("AWARE reported a successful export but wrote no IFC file.");
|
|
85485
85956
|
}
|
|
85486
|
-
const artifactBytes = (0,
|
|
85957
|
+
const artifactBytes = (0, import_node_fs60.readFileSync)(tempPath);
|
|
85487
85958
|
const receipt = reconcileIfcExportReceipt(scene, rawReceipt, producerUnsupported, {
|
|
85488
85959
|
index: parseStepData(artifactBytes),
|
|
85489
85960
|
bytes: artifactBytes
|
|
85490
85961
|
});
|
|
85491
|
-
const expectedContentSha256 = (0,
|
|
85962
|
+
const expectedContentSha256 = (0, import_node_crypto32.createHash)("sha256").update(artifactBytes).digest("hex");
|
|
85492
85963
|
const transition = project && projectSnapshot && projectSnapshot.version.n !== null ? prepareProjectExport(project, {
|
|
85493
85964
|
kind: "ifc",
|
|
85494
85965
|
filename,
|
|
@@ -85539,7 +86010,7 @@ async function startServer() {
|
|
|
85539
86010
|
ok: false,
|
|
85540
86011
|
error: awareFailureMessage(error, "IFC export failed"),
|
|
85541
86012
|
...reason ? { reason } : {},
|
|
85542
|
-
preservedPrevious: project && priorProjectIfc ? receiptHasFile(project, priorProjectIfc) : (0,
|
|
86013
|
+
preservedPrevious: project && priorProjectIfc ? receiptHasFile(project, priorProjectIfc) : (0, import_node_fs60.existsSync)(finalPath)
|
|
85543
86014
|
});
|
|
85544
86015
|
} finally {
|
|
85545
86016
|
cleanupIfcTemp(tempPath);
|
|
@@ -85583,10 +86054,10 @@ async function startServer() {
|
|
|
85583
86054
|
const receipt = wanted ? stills.find((row) => row.variant === wanted) : [...stills].sort((a, b) => b.exportedAt.localeCompare(a.exportedAt))[0];
|
|
85584
86055
|
if (!receipt) return reply.status(404).send({ ok: false, error: "nothing rendered yet" });
|
|
85585
86056
|
const path = resolveProjectExportReceiptPath(project, receipt);
|
|
85586
|
-
if (!path || !(0,
|
|
86057
|
+
if (!path || !(0, import_node_fs60.existsSync)(path)) {
|
|
85587
86058
|
return reply.status(404).send({ ok: false, error: "the rendered image is no longer on disk" });
|
|
85588
86059
|
}
|
|
85589
|
-
return reply.header("content-type", "image/png").header("cache-control", "private, max-age=31536000, immutable").send((0,
|
|
86060
|
+
return reply.header("content-type", "image/png").header("cache-control", "private, max-age=31536000, immutable").send((0, import_node_fs60.readFileSync)(path));
|
|
85590
86061
|
});
|
|
85591
86062
|
const RENDER_VIEWPOINTS = /* @__PURE__ */ new Set(["hero", "iso", "front", "back", "left", "right", "top"]);
|
|
85592
86063
|
app.post("/api/contract/:appId/render", async (req, reply) => {
|
|
@@ -85646,7 +86117,7 @@ async function startServer() {
|
|
|
85646
86117
|
}
|
|
85647
86118
|
const kind = output === "turntable" ? "render-mp4" : "render-png";
|
|
85648
86119
|
const extension = output === "turntable" ? ".mp4" : ".png";
|
|
85649
|
-
const scratch = (0,
|
|
86120
|
+
const scratch = (0, import_node_fs60.mkdtempSync)((0, import_node_path57.join)((0, import_node_os29.tmpdir)(), "floless-render-"));
|
|
85650
86121
|
const ifcPath = (0, import_node_path57.join)(scratch, "model.ifc");
|
|
85651
86122
|
const rendered = [];
|
|
85652
86123
|
const progress = (stage, extra = {}) => {
|
|
@@ -85658,7 +86129,7 @@ async function startServer() {
|
|
|
85658
86129
|
try {
|
|
85659
86130
|
progress("preparing");
|
|
85660
86131
|
await aware.agentInvoke("ifc", "write", { scene: built.scene, "output-path": ifcPath });
|
|
85661
|
-
if (!(0,
|
|
86132
|
+
if (!(0, import_node_fs60.existsSync)(ifcPath) || (0, import_node_fs60.statSync)(ifcPath).size === 0) {
|
|
85662
86133
|
throw new Error("AWARE reported a successful IFC write but produced no file to render");
|
|
85663
86134
|
}
|
|
85664
86135
|
const renderBudgetMs = output === "turntable" ? 30 * 6e4 : 10 * 6e4;
|
|
@@ -85676,10 +86147,10 @@ async function startServer() {
|
|
|
85676
86147
|
environment: "studio",
|
|
85677
86148
|
...output === "turntable" ? { "duration-seconds": 12, fps: 24, "width-pixels": 1280, "height-pixels": 720 } : { quality, "width-pixels": 1920, "height-pixels": 1080 }
|
|
85678
86149
|
}, { timeoutMs: renderBudgetMs });
|
|
85679
|
-
if (!(0,
|
|
86150
|
+
if (!(0, import_node_fs60.existsSync)(artifactPath) || (0, import_node_fs60.statSync)(artifactPath).size === 0) {
|
|
85680
86151
|
throw new Error(`the ${viewpoint} render reported success but produced no image`);
|
|
85681
86152
|
}
|
|
85682
|
-
const bytes = (0,
|
|
86153
|
+
const bytes = (0, import_node_fs60.readFileSync)(artifactPath);
|
|
85683
86154
|
const sourceSuffix = "source" in projectSnapshot && projectSnapshot.source ? `-${projectSnapshot.source.filenameLabel.replace(/[^A-Za-z0-9._-]+/g, "-")}` : "";
|
|
85684
86155
|
const preferred = `${exportFileBase(project, appId)}-${viewpoint}${sourceSuffix}${extension}`;
|
|
85685
86156
|
const filename = uniqueProjectExportFilename(project, preferred);
|
|
@@ -85735,7 +86206,7 @@ async function startServer() {
|
|
|
85735
86206
|
rendered
|
|
85736
86207
|
});
|
|
85737
86208
|
} finally {
|
|
85738
|
-
(0,
|
|
86209
|
+
(0, import_node_fs60.rmSync)(scratch, { recursive: true, force: true });
|
|
85739
86210
|
}
|
|
85740
86211
|
}, {
|
|
85741
86212
|
// What anyone blocked on this project is told, and for how long to expect it. Erring long
|
|
@@ -85976,7 +86447,7 @@ async function startServer() {
|
|
|
85976
86447
|
const outPath = project ? (0, import_node_path57.join)(projectExportsDir(project), filename) : bomExportPath(appId, format);
|
|
85977
86448
|
const dir = (0, import_node_path57.dirname)(outPath);
|
|
85978
86449
|
try {
|
|
85979
|
-
(0,
|
|
86450
|
+
(0, import_node_fs60.mkdirSync)(dir, { recursive: true });
|
|
85980
86451
|
const kind = BOM_EXPORT_KIND[format];
|
|
85981
86452
|
let text3 = null;
|
|
85982
86453
|
let buf;
|
|
@@ -86004,8 +86475,8 @@ async function startServer() {
|
|
|
86004
86475
|
sourceKind: projectSnapshot.source?.kind ?? "approved",
|
|
86005
86476
|
contractHash: projectSnapshot.contractHash
|
|
86006
86477
|
}, buf);
|
|
86007
|
-
} else if (text3 != null) (0,
|
|
86008
|
-
else (0,
|
|
86478
|
+
} else if (text3 != null) (0, import_node_fs60.writeFileSync)(outPath, text3, "utf8");
|
|
86479
|
+
else (0, import_node_fs60.writeFileSync)(outPath, buf);
|
|
86009
86480
|
return {
|
|
86010
86481
|
ok: true,
|
|
86011
86482
|
payload: text3 != null ? { filename, encoding: "utf8", content: text3, bytes: buf.length, savedTo: outPath } : { filename, encoding: "base64", content: buf.toString("base64"), bytes: buf.length, savedTo: outPath }
|
|
@@ -86045,7 +86516,7 @@ async function startServer() {
|
|
|
86045
86516
|
const filename = project ? uniqueProjectExportFilename(project, preferredFilename) : preferredFilename;
|
|
86046
86517
|
const outPath = project ? (0, import_node_path57.join)(projectExportsDir(project), filename) : (0, import_node_path57.join)(appPath(appId), filename);
|
|
86047
86518
|
try {
|
|
86048
|
-
(0,
|
|
86519
|
+
(0, import_node_fs60.mkdirSync)((0, import_node_path57.dirname)(outPath), { recursive: true });
|
|
86049
86520
|
if (project && projectSnapshot) {
|
|
86050
86521
|
publishProjectExportArtifact(project, {
|
|
86051
86522
|
kind: "svg",
|
|
@@ -86056,7 +86527,7 @@ async function startServer() {
|
|
|
86056
86527
|
sourceKind: projectSnapshot.source?.kind ?? "approved",
|
|
86057
86528
|
contractHash: projectSnapshot.contractHash
|
|
86058
86529
|
}, Buffer.from(svg, "utf8"));
|
|
86059
|
-
} else (0,
|
|
86530
|
+
} else (0, import_node_fs60.writeFileSync)(outPath, svg, "utf8");
|
|
86060
86531
|
return { ok: true, filename, encoding: "utf8", content: svg, bytes: Buffer.byteLength(svg), savedTo: outPath };
|
|
86061
86532
|
} catch (e) {
|
|
86062
86533
|
app.log.error({ appId, err: e instanceof Error ? e.message : e }, "export-svg: write failed");
|
|
@@ -86238,11 +86709,11 @@ async function startServer() {
|
|
|
86238
86709
|
return reply.status(409).send({ ok: false, error: `a workflow named "${id}" is already installed \u2014 remove it first, or rename the file's app: id`, code: "exists", id });
|
|
86239
86710
|
}
|
|
86240
86711
|
await deleteOrigin(id);
|
|
86241
|
-
const stageRoot = (0,
|
|
86712
|
+
const stageRoot = (0, import_node_fs60.mkdtempSync)((0, import_node_path57.join)((0, import_node_os29.tmpdir)(), "floless-import-"));
|
|
86242
86713
|
try {
|
|
86243
86714
|
const stageDir = (0, import_node_path57.join)(stageRoot, id);
|
|
86244
|
-
(0,
|
|
86245
|
-
(0,
|
|
86715
|
+
(0, import_node_fs60.mkdirSync)(stageDir);
|
|
86716
|
+
(0, import_node_fs60.writeFileSync)((0, import_node_path57.join)(stageDir, `${id}.flo`), content);
|
|
86246
86717
|
await aware.install(stageDir);
|
|
86247
86718
|
} catch (err2) {
|
|
86248
86719
|
try {
|
|
@@ -86253,7 +86724,7 @@ async function startServer() {
|
|
|
86253
86724
|
const reason = awareStderr(err2);
|
|
86254
86725
|
return reply.status(502).send({ ok: false, error: `import failed: ${msg}`, code: "install-failed", reason, agentsUnavailable: unavailableAgents(reason) });
|
|
86255
86726
|
} finally {
|
|
86256
|
-
(0,
|
|
86727
|
+
(0, import_node_fs60.rmSync)(stageRoot, { recursive: true, force: true });
|
|
86257
86728
|
}
|
|
86258
86729
|
broadcast({ type: "apps-changed", id });
|
|
86259
86730
|
return { ok: true, id };
|
|
@@ -86269,13 +86740,13 @@ async function startServer() {
|
|
|
86269
86740
|
}
|
|
86270
86741
|
const inputs = appData.inputs.map((i) => ({ name: i.name, type: i.type }));
|
|
86271
86742
|
const baked = bakeFloSource(appData.source.text, inputs);
|
|
86272
|
-
const tmpRoot = (0,
|
|
86743
|
+
const tmpRoot = (0, import_node_fs60.mkdtempSync)((0, import_node_path57.join)((0, import_node_os29.tmpdir)(), "floless-bake-"));
|
|
86273
86744
|
const backupDir2 = (0, import_node_path57.join)(tmpRoot, `${id}-backup`);
|
|
86274
86745
|
const bakeDir = (0, import_node_path57.join)(tmpRoot, id);
|
|
86275
|
-
(0,
|
|
86276
|
-
(0,
|
|
86746
|
+
(0, import_node_fs60.cpSync)(appDir(id), backupDir2, { recursive: true });
|
|
86747
|
+
(0, import_node_fs60.cpSync)(appDir(id), bakeDir, { recursive: true });
|
|
86277
86748
|
const floName = appData.source.path.split(/[\\/]/).pop();
|
|
86278
|
-
(0,
|
|
86749
|
+
(0, import_node_fs60.writeFileSync)((0, import_node_path57.join)(bakeDir, floName), baked);
|
|
86279
86750
|
let appInstalled2 = true;
|
|
86280
86751
|
try {
|
|
86281
86752
|
await aware.uninstall(id);
|
|
@@ -86304,7 +86775,7 @@ async function startServer() {
|
|
|
86304
86775
|
broadcast({ type: "baked", id });
|
|
86305
86776
|
return { ok: true, id, agent: id, inputs };
|
|
86306
86777
|
} finally {
|
|
86307
|
-
if (appInstalled2) (0,
|
|
86778
|
+
if (appInstalled2) (0, import_node_fs60.rmSync)(tmpRoot, { recursive: true, force: true });
|
|
86308
86779
|
}
|
|
86309
86780
|
});
|
|
86310
86781
|
});
|
|
@@ -86325,7 +86796,7 @@ async function startServer() {
|
|
|
86325
86796
|
if (!sourceKind || !sourceRef) {
|
|
86326
86797
|
return reply.status(400).send({ ok: false, error: "sourceKind and sourceRef required" });
|
|
86327
86798
|
}
|
|
86328
|
-
const tempHome = (0,
|
|
86799
|
+
const tempHome = (0, import_node_fs60.mkdtempSync)((0, import_node_path57.join)((0, import_node_os29.tmpdir)(), "floless-graft-"));
|
|
86329
86800
|
let result;
|
|
86330
86801
|
try {
|
|
86331
86802
|
result = await aware.build({
|
|
@@ -86338,19 +86809,19 @@ async function startServer() {
|
|
|
86338
86809
|
awareHome: tempHome
|
|
86339
86810
|
});
|
|
86340
86811
|
} catch (err2) {
|
|
86341
|
-
(0,
|
|
86812
|
+
(0, import_node_fs60.rmSync)(tempHome, { recursive: true, force: true });
|
|
86342
86813
|
const msg = err2 instanceof AwareError ? err2.message : String(err2?.message ?? err2);
|
|
86343
86814
|
return reply.status(422).send({ ok: false, error: msg });
|
|
86344
86815
|
}
|
|
86345
86816
|
const manifest = readStagedManifest(result.agentDir);
|
|
86346
86817
|
if (!manifest) {
|
|
86347
|
-
(0,
|
|
86818
|
+
(0, import_node_fs60.rmSync)(tempHome, { recursive: true, force: true });
|
|
86348
86819
|
return reply.status(502).send({ ok: false, error: `build produced output at ${result.agentDir} but no manifest.yaml` });
|
|
86349
86820
|
}
|
|
86350
|
-
const token2 = (0,
|
|
86821
|
+
const token2 = (0, import_node_crypto32.randomUUID)();
|
|
86351
86822
|
registerStage(token2, tempHome, result.agentId);
|
|
86352
86823
|
const preview2 = buildPreview(manifest, sourceKind, sourceRef, token2);
|
|
86353
|
-
if ((0,
|
|
86824
|
+
if ((0, import_node_fs60.existsSync)((0, import_node_path57.join)(graftAgentsDir(), result.agentId))) {
|
|
86354
86825
|
preview2.warnings.unshift(`An agent named "${result.agentId}" is already installed \u2014 creating it will overwrite it.`);
|
|
86355
86826
|
}
|
|
86356
86827
|
return { ok: true, preview: preview2 };
|
|
@@ -86369,7 +86840,7 @@ async function startServer() {
|
|
|
86369
86840
|
registerStage(stagedRef, stage.tempDir, stage.agentId);
|
|
86370
86841
|
return reply.status(409).send({ ok: false, error: err2.message, agentId: stage.agentId, collision: true });
|
|
86371
86842
|
}
|
|
86372
|
-
(0,
|
|
86843
|
+
(0, import_node_fs60.rmSync)(stage.tempDir, { recursive: true, force: true });
|
|
86373
86844
|
throw err2;
|
|
86374
86845
|
}
|
|
86375
86846
|
broadcast({ type: "grafted", id: stage.agentId });
|
|
@@ -86690,11 +87161,11 @@ async function startServer() {
|
|
|
86690
87161
|
app.get("/api/requests/:id/snapshot/:n", async (req, reply) => {
|
|
86691
87162
|
const n = Number.parseInt(req.params.n, 10);
|
|
86692
87163
|
const p = Number.isInteger(n) ? snapshotPathFor(req.params.id, n) : null;
|
|
86693
|
-
if (!p || !(0,
|
|
87164
|
+
if (!p || !(0, import_node_fs60.existsSync)(p)) return reply.status(404).send({ ok: false, error: "snapshot not found" });
|
|
86694
87165
|
const ext = p.split(".").pop().toLowerCase();
|
|
86695
87166
|
reply.header("Content-Type", ext === "png" ? "image/png" : ext === "webp" ? "image/webp" : ext === "pdf" ? "application/pdf" : "image/jpeg");
|
|
86696
87167
|
reply.header("Cache-Control", "no-store");
|
|
86697
|
-
return (0,
|
|
87168
|
+
return (0, import_node_fs60.readFileSync)(p);
|
|
86698
87169
|
});
|
|
86699
87170
|
app.post(
|
|
86700
87171
|
"/api/tweak",
|
|
@@ -86929,7 +87400,7 @@ async function startServer() {
|
|
|
86929
87400
|
warn(`last-run-status:${ref} \u2014 trace exists but couldn't be parsed (corrupt/truncated)`);
|
|
86930
87401
|
let finishedAt2 = null;
|
|
86931
87402
|
try {
|
|
86932
|
-
finishedAt2 = (0,
|
|
87403
|
+
finishedAt2 = (0, import_node_fs60.statSync)(latest.path).mtime.toISOString();
|
|
86933
87404
|
} catch {
|
|
86934
87405
|
finishedAt2 = null;
|
|
86935
87406
|
}
|
|
@@ -86939,7 +87410,7 @@ async function startServer() {
|
|
|
86939
87410
|
let finishedAt = typeof runEnd?.ts === "string" ? runEnd.ts : null;
|
|
86940
87411
|
if (!finishedAt) {
|
|
86941
87412
|
try {
|
|
86942
|
-
finishedAt = (0,
|
|
87413
|
+
finishedAt = (0, import_node_fs60.statSync)(latest.path).mtime.toISOString();
|
|
86943
87414
|
} catch {
|
|
86944
87415
|
finishedAt = null;
|
|
86945
87416
|
}
|
|
@@ -87052,7 +87523,19 @@ async function startServer() {
|
|
|
87052
87523
|
const close = async () => {
|
|
87053
87524
|
cancelAllConnects();
|
|
87054
87525
|
clearAllStages();
|
|
87526
|
+
detachAutoRepairIdleWatch?.();
|
|
87055
87527
|
await stopScheduler();
|
|
87528
|
+
const updaterSettled = awareUpdateJobs.shutdown().catch((err2) => app.log.warn({ err: String(err2) }, "AWARE updater shutdown did not settle cleanly"));
|
|
87529
|
+
const shutdownTimedOut = await Promise.race([
|
|
87530
|
+
updaterSettled.then(() => false),
|
|
87531
|
+
new Promise((resolve15) => {
|
|
87532
|
+
const t = setTimeout(() => resolve15(true), 15e3);
|
|
87533
|
+
t.unref?.();
|
|
87534
|
+
})
|
|
87535
|
+
]);
|
|
87536
|
+
if (shutdownTimedOut) {
|
|
87537
|
+
app.log.warn("AWARE updater still settling at shutdown; exiting anyway \u2014 recovery finishes it next launch");
|
|
87538
|
+
}
|
|
87056
87539
|
await watcher?.close();
|
|
87057
87540
|
await app.close();
|
|
87058
87541
|
process.exit(0);
|