@floless/app 0.122.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 +376 -346
- package/dist/schemas/steel.model.v2.schema.json +3 -1
- package/dist/skills/floless-app-steel-takeoff/SKILL.md +332 -37
- package/dist/web/grid-core.js +11 -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
|
|
|
@@ -54611,7 +54611,7 @@ function appVersion() {
|
|
|
54611
54611
|
return resolveVersion({
|
|
54612
54612
|
isSea: isSea2(),
|
|
54613
54613
|
sqVersionXml: readSqVersionXml(),
|
|
54614
|
-
define: true ? "0.
|
|
54614
|
+
define: true ? "0.123.0" : void 0,
|
|
54615
54615
|
pkgVersion: readPkgVersion()
|
|
54616
54616
|
});
|
|
54617
54617
|
}
|
|
@@ -54627,7 +54627,7 @@ function resolveChannel(s) {
|
|
|
54627
54627
|
function appChannel() {
|
|
54628
54628
|
return resolveChannel({
|
|
54629
54629
|
isSea: isSea2(),
|
|
54630
|
-
define: true ? "0.
|
|
54630
|
+
define: true ? "0.123.0" : void 0,
|
|
54631
54631
|
// argv[1] is the entry the runtime actually loaded (…/dist/floless-server.cjs), which is what
|
|
54632
54632
|
// carries the npx cache prefix. Absent under the SEA exe, which never reaches the npx branch.
|
|
54633
54633
|
modulePath: process.argv[1]
|
|
@@ -57978,7 +57978,7 @@ function bearingFaces(x, uOnN, vOnN, requestedSide) {
|
|
|
57978
57978
|
}
|
|
57979
57979
|
|
|
57980
57980
|
// index.ts
|
|
57981
|
-
var
|
|
57981
|
+
var import_node_crypto32 = require("node:crypto");
|
|
57982
57982
|
|
|
57983
57983
|
// ifc-guid.ts
|
|
57984
57984
|
var import_node_crypto10 = require("node:crypto");
|
|
@@ -59511,6 +59511,10 @@ var import_node_crypto13 = require("node:crypto");
|
|
|
59511
59511
|
|
|
59512
59512
|
// ../web/steel-3d-core.js
|
|
59513
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
|
+
}
|
|
59514
59518
|
var MODEL_V2_TOL = Object.freeze({
|
|
59515
59519
|
CUT_PLANE_MM: 1.5875,
|
|
59516
59520
|
// 1/16" — a member includes a sheet elevation within this
|
|
@@ -61125,7 +61129,6 @@ function previewMigration(v1, ctx) {
|
|
|
61125
61129
|
}
|
|
61126
61130
|
|
|
61127
61131
|
// ../web/steel-plan-transform.js
|
|
61128
|
-
var FT_MM2 = 304.8;
|
|
61129
61132
|
var finite2 = (p) => Array.isArray(p) && p.length === 2 && p.every(Number.isFinite);
|
|
61130
61133
|
var PlanTransformError = class extends Error {
|
|
61131
61134
|
constructor(code, message, viewKind = null) {
|
|
@@ -61194,10 +61197,10 @@ function planTransform(plan) {
|
|
|
61194
61197
|
const registrationGrid = plan.modelGrid || plan.grid;
|
|
61195
61198
|
const world0 = plan.datum_ref ? gridIntersection(registrationGrid, plan.datum_ref, plan) : [0, 0];
|
|
61196
61199
|
const world1 = gridIntersection(registrationGrid, plan.control2_ref, plan);
|
|
61197
|
-
const
|
|
61200
|
+
const scale = mmPerPx(ptPerFt);
|
|
61198
61201
|
const local1 = [
|
|
61199
|
-
(plan.control2_at[0] - plan.datum_at[0]) *
|
|
61200
|
-
(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
|
|
61201
61204
|
];
|
|
61202
61205
|
const worldDelta = [world1[0] - world0[0], world1[1] - world0[1]];
|
|
61203
61206
|
const localLen = Math.hypot(local1[0], local1[1]);
|
|
@@ -61212,7 +61215,7 @@ function planTransform(plan) {
|
|
|
61212
61215
|
if (![c, s, fitScale, world0[0], world0[1]].every(Number.isFinite)) {
|
|
61213
61216
|
return refuse("registration-invalid", `sheet "${plan.sheet || "?"}" has a non-finite registration transform`, plan);
|
|
61214
61217
|
}
|
|
61215
|
-
return { datumPx: plan.datum_at, world0, mmPerPx:
|
|
61218
|
+
return { datumPx: plan.datum_at, world0, mmPerPx: scale, fitScale, rotation, c, s };
|
|
61216
61219
|
}
|
|
61217
61220
|
|
|
61218
61221
|
// steel-v1-staging-exit.ts
|
|
@@ -66204,10 +66207,6 @@ function pickColor(profile, idx, contract) {
|
|
|
66204
66207
|
const pal = contract.palette && contract.palette.length ? contract.palette : SCENE_DEFAULT_PAL;
|
|
66205
66208
|
return pal[(idx % pal.length + pal.length) % pal.length];
|
|
66206
66209
|
}
|
|
66207
|
-
function dispToMm(pt, ptPerFt) {
|
|
66208
|
-
const k = FT_TO_MM / ptPerFt;
|
|
66209
|
-
return [pt[0] * k, -pt[1] * k];
|
|
66210
|
-
}
|
|
66211
66210
|
function inferMaterial(profile) {
|
|
66212
66211
|
const P = canonicalDesignation(profile);
|
|
66213
66212
|
if (P.startsWith("HSS")) return "A500-GR.B";
|
|
@@ -67972,6 +67971,24 @@ function renderable(o) {
|
|
|
67972
67971
|
const q = o;
|
|
67973
67972
|
return !!q && Array.isArray(q.positions) && Array.isArray(q.indices) && q.positions.length >= 9 && q.indices.length >= 3 && q.positions.length % 3 === 0;
|
|
67974
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
|
+
}
|
|
67975
67992
|
var FILE_Z_UP = "z-up";
|
|
67976
67993
|
var FILE_Y_UP = "y-up";
|
|
67977
67994
|
function yUpToZUp(positions) {
|
|
@@ -68002,9 +68019,31 @@ function toReferenceObjects(raw) {
|
|
|
68002
68019
|
profile: typeof o.profile === "string" ? o.profile : null,
|
|
68003
68020
|
material: typeof o.material === "string" ? o.material : null,
|
|
68004
68021
|
positions: alreadyZUp ? o.positions.slice() : yUpToZUp(o.positions),
|
|
68005
|
-
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
|
+
})()
|
|
68006
68029
|
}));
|
|
68007
|
-
|
|
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
|
+
};
|
|
68008
68047
|
}
|
|
68009
68048
|
var REFERENCE_DIR = "references";
|
|
68010
68049
|
var SAFE_NAME = /[^A-Za-z0-9._-]+/g;
|
|
@@ -68146,6 +68185,7 @@ function realish(p) {
|
|
|
68146
68185
|
return (0, import_node_path28.resolve)(p);
|
|
68147
68186
|
}
|
|
68148
68187
|
}
|
|
68188
|
+
var REFERENCE_CACHE_VERSION = 3;
|
|
68149
68189
|
var cachePath2 = (projectId, refId2) => (0, import_node_path28.join)(projectDir(projectId), `.floless-refcache-${safeId2(refId2)}.json`);
|
|
68150
68190
|
function safeId2(refId2) {
|
|
68151
68191
|
const s = String(refId2 ?? "").replace(/[^A-Za-z0-9._-]+/g, "_");
|
|
@@ -68190,7 +68230,7 @@ function cachedGeometry(projectId, refId2, expectHash) {
|
|
|
68190
68230
|
if (!(0, import_node_fs32.existsSync)(p)) return null;
|
|
68191
68231
|
try {
|
|
68192
68232
|
const parsed = JSON.parse((0, import_node_fs32.readFileSync)(p, "utf8"));
|
|
68193
|
-
if (!parsed || parsed.v !==
|
|
68233
|
+
if (!parsed || parsed.v !== REFERENCE_CACHE_VERSION || !Array.isArray(parsed.objects)) return null;
|
|
68194
68234
|
if (parsed.sourceHash !== expectHash) return null;
|
|
68195
68235
|
return parsed;
|
|
68196
68236
|
} catch {
|
|
@@ -68375,7 +68415,7 @@ function registerReferenceRoutes(app, deps) {
|
|
|
68375
68415
|
rollback();
|
|
68376
68416
|
return reply.status(400).send({ ok: false, error: `"${displayName}" has no geometry we can draw` });
|
|
68377
68417
|
}
|
|
68378
|
-
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 });
|
|
68379
68419
|
const entry2 = {
|
|
68380
68420
|
id,
|
|
68381
68421
|
file: rel,
|
|
@@ -68398,7 +68438,7 @@ function registerReferenceRoutes(app, deps) {
|
|
|
68398
68438
|
});
|
|
68399
68439
|
committed = true;
|
|
68400
68440
|
deps.broadcast(contractChangedEvent(g.appId, g.project, etag, req.headers["x-floless-mutation-id"]));
|
|
68401
|
-
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) };
|
|
68402
68442
|
} catch (e) {
|
|
68403
68443
|
rollback();
|
|
68404
68444
|
const r = importRefusal(e);
|
|
@@ -68434,8 +68474,9 @@ function registerReferenceRoutes(app, deps) {
|
|
|
68434
68474
|
} catch {
|
|
68435
68475
|
return reply.status(409).send({ ok: false, code: "reference-unresolved", error: `"${entry2.name}" could not be read` });
|
|
68436
68476
|
}
|
|
68437
|
-
const
|
|
68438
|
-
|
|
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) };
|
|
68439
68480
|
const scope = runScope(deps, req);
|
|
68440
68481
|
try {
|
|
68441
68482
|
const geometry = await deps.reader.readModel(companion(g.appId), abs, { ticket: scope.ticket() });
|
|
@@ -68446,8 +68487,8 @@ function registerReferenceRoutes(app, deps) {
|
|
|
68446
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."
|
|
68447
68488
|
});
|
|
68448
68489
|
}
|
|
68449
|
-
writeCache2(g.project, entry2.id, { v:
|
|
68450
|
-
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) };
|
|
68451
68492
|
} catch (e) {
|
|
68452
68493
|
const r = importRefusal(e);
|
|
68453
68494
|
if (r) return reply.status(r.status).send(r.body);
|
|
@@ -73377,20 +73418,26 @@ function buildApprovalReview(input) {
|
|
|
73377
73418
|
}
|
|
73378
73419
|
|
|
73379
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
|
|
73380
73426
|
var import_node_crypto21 = require("node:crypto");
|
|
73381
73427
|
var import_node_fs36 = require("node:fs");
|
|
73382
|
-
|
|
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
|
|
73383
73435
|
var pathOf = (projectId) => (0, import_node_path33.join)(projectDir(projectId), ".floless-working-revision-state-v1.json");
|
|
73384
73436
|
var checksumOf = (body) => hashOf(body);
|
|
73385
73437
|
function bodyOf(value) {
|
|
73386
73438
|
const { checksum: _checksum, ...body } = value;
|
|
73387
73439
|
return body;
|
|
73388
73440
|
}
|
|
73389
|
-
function atomicWrite(path, value) {
|
|
73390
|
-
const tmp = `${path}.${process.pid}.${(0, import_node_crypto21.randomUUID)()}.tmp`;
|
|
73391
|
-
(0, import_node_fs36.writeFileSync)(tmp, canonicalJson(value));
|
|
73392
|
-
(0, import_node_fs36.renameSync)(tmp, path);
|
|
73393
|
-
}
|
|
73394
73441
|
function assertProject(project) {
|
|
73395
73442
|
if (!project.uuid) throw new Error(`project ${project.id} has no incarnation UUID`);
|
|
73396
73443
|
return project.uuid;
|
|
@@ -73398,7 +73445,7 @@ function assertProject(project) {
|
|
|
73398
73445
|
function readWorkingRevisionManifest(project) {
|
|
73399
73446
|
const uuid = assertProject(project);
|
|
73400
73447
|
try {
|
|
73401
|
-
const value = JSON.parse((0,
|
|
73448
|
+
const value = JSON.parse((0, import_node_fs37.readFileSync)(pathOf(project.id), "utf8"));
|
|
73402
73449
|
if (value?.schema !== 1 || value.projectUuid !== uuid || !Number.isInteger(value.epoch) || value.epoch < 0) return null;
|
|
73403
73450
|
return checksumOf(bodyOf(value)) === value.checksum ? value : null;
|
|
73404
73451
|
} catch {
|
|
@@ -73412,7 +73459,7 @@ function ensureWorkingRevisionManifest(input) {
|
|
|
73412
73459
|
schema: 1,
|
|
73413
73460
|
projectUuid: assertProject(input.project),
|
|
73414
73461
|
publicationIdentity: input.publicationIdentity,
|
|
73415
|
-
revisionId: (0,
|
|
73462
|
+
revisionId: (0, import_node_crypto22.randomUUID)(),
|
|
73416
73463
|
epoch: 0,
|
|
73417
73464
|
source: { kind: "working" },
|
|
73418
73465
|
workingBase: input.workingBase,
|
|
@@ -73420,8 +73467,8 @@ function ensureWorkingRevisionManifest(input) {
|
|
|
73420
73467
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
73421
73468
|
};
|
|
73422
73469
|
const value = { ...body, checksum: checksumOf(body) };
|
|
73423
|
-
(0,
|
|
73424
|
-
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);
|
|
73425
73472
|
return readWorkingRevisionManifest(input.project) ?? value;
|
|
73426
73473
|
}
|
|
73427
73474
|
function advanceWorkingRevisionManifest(input) {
|
|
@@ -73433,7 +73480,7 @@ function advanceWorkingRevisionManifest(input) {
|
|
|
73433
73480
|
if (current.publicationIdentity !== input.publicationIdentity) throw new Error("working revision belongs to another app publication");
|
|
73434
73481
|
const body = {
|
|
73435
73482
|
...bodyOf(current),
|
|
73436
|
-
revisionId: (0,
|
|
73483
|
+
revisionId: (0, import_node_crypto22.randomUUID)(),
|
|
73437
73484
|
epoch: current.epoch + 1,
|
|
73438
73485
|
source: input.source,
|
|
73439
73486
|
workingBase: input.workingBase,
|
|
@@ -73441,7 +73488,7 @@ function advanceWorkingRevisionManifest(input) {
|
|
|
73441
73488
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
73442
73489
|
};
|
|
73443
73490
|
const value = { ...body, checksum: checksumOf(body) };
|
|
73444
|
-
|
|
73491
|
+
writeJsonAtomic(pathOf(input.project.id), value);
|
|
73445
73492
|
return value;
|
|
73446
73493
|
}
|
|
73447
73494
|
function refreshWorkingDraftHash(input) {
|
|
@@ -73452,7 +73499,7 @@ function refreshWorkingDraftHash(input) {
|
|
|
73452
73499
|
}
|
|
73453
73500
|
const body = { ...bodyOf(current), draftHash: hashOf(input.contract), updatedAt: (/* @__PURE__ */ new Date()).toISOString() };
|
|
73454
73501
|
const value = { ...body, checksum: checksumOf(body) };
|
|
73455
|
-
|
|
73502
|
+
writeJsonAtomic(pathOf(input.project.id), value);
|
|
73456
73503
|
return value;
|
|
73457
73504
|
}
|
|
73458
73505
|
|
|
@@ -73672,8 +73719,8 @@ function projectApprovalCandidateAccepted(appId, projectId, candidate) {
|
|
|
73672
73719
|
}
|
|
73673
73720
|
|
|
73674
73721
|
// project-checkpoints-store.ts
|
|
73675
|
-
var
|
|
73676
|
-
var
|
|
73722
|
+
var import_node_crypto23 = require("node:crypto");
|
|
73723
|
+
var import_node_fs38 = require("node:fs");
|
|
73677
73724
|
var import_node_path34 = require("node:path");
|
|
73678
73725
|
var HASH_RE2 = /^[0-9a-f]{64}$/;
|
|
73679
73726
|
function root4(projectId) {
|
|
@@ -73681,14 +73728,9 @@ function root4(projectId) {
|
|
|
73681
73728
|
}
|
|
73682
73729
|
var objectsDir2 = (projectId) => (0, import_node_path34.join)(root4(projectId), "objects");
|
|
73683
73730
|
var eventsPath = (projectId) => (0, import_node_path34.join)(root4(projectId), "events.json");
|
|
73684
|
-
function atomicWrite2(path, value) {
|
|
73685
|
-
const tmp = `${path}.${process.pid}.${(0, import_node_crypto22.randomUUID)()}.tmp`;
|
|
73686
|
-
(0, import_node_fs37.writeFileSync)(tmp, canonicalJson(value));
|
|
73687
|
-
(0, import_node_fs37.renameSync)(tmp, path);
|
|
73688
|
-
}
|
|
73689
73731
|
function readEvents(projectId) {
|
|
73690
73732
|
try {
|
|
73691
|
-
const parsed = JSON.parse((0,
|
|
73733
|
+
const parsed = JSON.parse((0, import_node_fs38.readFileSync)(eventsPath(projectId), "utf8"));
|
|
73692
73734
|
if (parsed?.schema !== 1 || !Array.isArray(parsed.events)) return { schema: 1, events: [] };
|
|
73693
73735
|
return { schema: 1, events: parsed.events.filter(validEvent) };
|
|
73694
73736
|
} catch {
|
|
@@ -73703,7 +73745,7 @@ function validEvent(value) {
|
|
|
73703
73745
|
function readContent(projectId, id) {
|
|
73704
73746
|
if (!HASH_RE2.test(id)) return null;
|
|
73705
73747
|
try {
|
|
73706
|
-
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"));
|
|
73707
73749
|
if (value?.schema !== 1 || value.id !== id || hashCheckpoint(value) !== id) return null;
|
|
73708
73750
|
return value;
|
|
73709
73751
|
} catch {
|
|
@@ -73719,11 +73761,11 @@ function requireIdentity(project) {
|
|
|
73719
73761
|
return project.uuid;
|
|
73720
73762
|
}
|
|
73721
73763
|
function appendEvent(projectId, event) {
|
|
73722
|
-
(0,
|
|
73764
|
+
(0, import_node_fs38.mkdirSync)(root4(projectId), { recursive: true });
|
|
73723
73765
|
const log2 = readEvents(projectId);
|
|
73724
|
-
const row = { ...event, eventId: (0,
|
|
73766
|
+
const row = { ...event, eventId: (0, import_node_crypto23.randomUUID)(), at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
73725
73767
|
log2.events.push(row);
|
|
73726
|
-
|
|
73768
|
+
writeJsonAtomic(eventsPath(projectId), log2);
|
|
73727
73769
|
return row;
|
|
73728
73770
|
}
|
|
73729
73771
|
function captureProjectCheckpoint(input) {
|
|
@@ -73737,9 +73779,9 @@ function captureProjectCheckpoint(input) {
|
|
|
73737
73779
|
contract: input.contract
|
|
73738
73780
|
};
|
|
73739
73781
|
const id = hashCheckpoint(withoutId);
|
|
73740
|
-
(0,
|
|
73782
|
+
(0, import_node_fs38.mkdirSync)(objectsDir2(input.project.id), { recursive: true });
|
|
73741
73783
|
const path = (0, import_node_path34.join)(objectsDir2(input.project.id), `${id}.json`);
|
|
73742
|
-
if (!(0,
|
|
73784
|
+
if (!(0, import_node_fs38.existsSync)(path)) writeJsonAtomic(path, { ...withoutId, id });
|
|
73743
73785
|
const event = appendEvent(input.project.id, {
|
|
73744
73786
|
checkpointId: id,
|
|
73745
73787
|
kind: "captured",
|
|
@@ -73781,8 +73823,8 @@ function markProjectCheckpoint(project, checkpointId, kind, expectedEventId) {
|
|
|
73781
73823
|
}
|
|
73782
73824
|
|
|
73783
73825
|
// export-source.ts
|
|
73784
|
-
var
|
|
73785
|
-
var
|
|
73826
|
+
var import_node_crypto24 = require("node:crypto");
|
|
73827
|
+
var import_node_fs39 = require("node:fs");
|
|
73786
73828
|
var import_node_os18 = require("node:os");
|
|
73787
73829
|
var import_node_path35 = require("node:path");
|
|
73788
73830
|
var HANDLE_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
@@ -73792,11 +73834,6 @@ function storeRoot() {
|
|
|
73792
73834
|
return (0, import_node_path35.join)(root5, ".floless-export-handles-v1");
|
|
73793
73835
|
}
|
|
73794
73836
|
var handlePath = (id) => (0, import_node_path35.join)(storeRoot(), `${id}.json`);
|
|
73795
|
-
function atomicWrite3(path, value) {
|
|
73796
|
-
const tmp = `${path}.${process.pid}.${(0, import_node_crypto23.randomUUID)()}.tmp`;
|
|
73797
|
-
(0, import_node_fs38.writeFileSync)(tmp, canonicalJson(value));
|
|
73798
|
-
(0, import_node_fs38.renameSync)(tmp, path);
|
|
73799
|
-
}
|
|
73800
73837
|
function withoutChecksum(value) {
|
|
73801
73838
|
const { checksum: _checksum, ...body } = value;
|
|
73802
73839
|
return body;
|
|
@@ -73810,7 +73847,7 @@ function validId(id) {
|
|
|
73810
73847
|
function readExportHandle(handleId) {
|
|
73811
73848
|
if (!validId(handleId)) return null;
|
|
73812
73849
|
try {
|
|
73813
|
-
const value = JSON.parse((0,
|
|
73850
|
+
const value = JSON.parse((0, import_node_fs39.readFileSync)(handlePath(handleId), "utf8"));
|
|
73814
73851
|
if (value?.schema !== 1 || value.handleId !== handleId || value.checksum !== hashOf(withoutChecksum(value))) return null;
|
|
73815
73852
|
return value;
|
|
73816
73853
|
} catch {
|
|
@@ -73819,7 +73856,7 @@ function readExportHandle(handleId) {
|
|
|
73819
73856
|
}
|
|
73820
73857
|
function captureExportSource(projectId, selector = { kind: "latest-approved" }, isDerivedEligible) {
|
|
73821
73858
|
collectExpiredExportHandles();
|
|
73822
|
-
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) {
|
|
73823
73860
|
throw new Error("too many frozen export sources are waiting; finish or retry older exports first");
|
|
73824
73861
|
}
|
|
73825
73862
|
const project = getProject(projectId);
|
|
@@ -73881,7 +73918,7 @@ function captureExportSource(projectId, selector = { kind: "latest-approved" },
|
|
|
73881
73918
|
}
|
|
73882
73919
|
const contentHash = hashOf(contract);
|
|
73883
73920
|
const capturedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
73884
|
-
const handleId = (0,
|
|
73921
|
+
const handleId = (0, import_node_crypto24.randomUUID)();
|
|
73885
73922
|
const shortHash2 = contentHash.slice(0, 8);
|
|
73886
73923
|
const filenameLabel = kind === "approved" ? `v${approvedVersion}` : kind === "working" ? `Working-DRAFT-${shortHash2}` : `Checkpoint-${sourceRef.slice(0, 8)}-DRAFT-${shortHash2}`;
|
|
73887
73924
|
const body = {
|
|
@@ -73905,8 +73942,8 @@ function captureExportSource(projectId, selector = { kind: "latest-approved" },
|
|
|
73905
73942
|
expiresAt: new Date(Date.now() + HANDLE_TTL_MS).toISOString(),
|
|
73906
73943
|
resultRefs: []
|
|
73907
73944
|
};
|
|
73908
|
-
(0,
|
|
73909
|
-
|
|
73945
|
+
(0, import_node_fs39.mkdirSync)(storeRoot(), { recursive: true });
|
|
73946
|
+
writeJsonAtomic(handlePath(handleId), stored(body));
|
|
73910
73947
|
const { contract: _contract, lease: _lease, expiresAt: _expiresAt, resultRefs: _refs, checksum: _checksum, ...resolved } = readExportHandle(handleId);
|
|
73911
73948
|
return resolved;
|
|
73912
73949
|
}
|
|
@@ -73917,22 +73954,22 @@ function cloneExportHandle(handleId, copies) {
|
|
|
73917
73954
|
if (!original || original.lease !== "active" || Date.parse(original.expiresAt) <= Date.now()) {
|
|
73918
73955
|
throw new Error("export source handle is unavailable");
|
|
73919
73956
|
}
|
|
73920
|
-
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;
|
|
73921
73958
|
if (storedCount + copies - 1 > MAX_STORED_HANDLES) throw new Error("too many frozen export sources are waiting");
|
|
73922
73959
|
const results = [];
|
|
73923
73960
|
const created = [];
|
|
73924
73961
|
try {
|
|
73925
73962
|
for (let index = 0; index < copies; index++) {
|
|
73926
|
-
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: [] });
|
|
73927
73964
|
if (index > 0) {
|
|
73928
|
-
|
|
73965
|
+
writeJsonAtomic(handlePath(value.handleId), value);
|
|
73929
73966
|
created.push(value.handleId);
|
|
73930
73967
|
}
|
|
73931
73968
|
const { contract: _contract, lease: _lease, expiresAt: _expiresAt, resultRefs: _refs, checksum: _checksum, ...resolved } = value;
|
|
73932
73969
|
results.push(resolved);
|
|
73933
73970
|
}
|
|
73934
73971
|
} catch (error) {
|
|
73935
|
-
for (const id of created) (0,
|
|
73972
|
+
for (const id of created) (0, import_node_fs39.rmSync)(handlePath(id), { force: true });
|
|
73936
73973
|
throw error;
|
|
73937
73974
|
}
|
|
73938
73975
|
return results;
|
|
@@ -73955,7 +73992,7 @@ function releaseExportHandle(handleId, resultRef) {
|
|
|
73955
73992
|
lease: "released",
|
|
73956
73993
|
resultRefs: resultRef ? [.../* @__PURE__ */ new Set([...handle.resultRefs, resultRef])] : handle.resultRefs
|
|
73957
73994
|
});
|
|
73958
|
-
|
|
73995
|
+
writeJsonAtomic(handlePath(handleId), next);
|
|
73959
73996
|
const { contract: _contract, lease: _lease, expiresAt: _expiresAt, resultRefs: _refs, checksum: _checksum, ...resolved } = next;
|
|
73960
73997
|
return resolved;
|
|
73961
73998
|
}
|
|
@@ -73972,21 +74009,21 @@ function releaseUnusedExportHandle(handleId, projectId, projectUuid) {
|
|
|
73972
74009
|
}
|
|
73973
74010
|
function projectIdHasActiveExportLeases(projectId) {
|
|
73974
74011
|
collectExpiredExportHandles();
|
|
73975
|
-
if (!(0,
|
|
73976
|
-
return (0,
|
|
74012
|
+
if (!(0, import_node_fs39.existsSync)(storeRoot())) return false;
|
|
74013
|
+
return (0, import_node_fs39.readdirSync)(storeRoot()).some((name) => {
|
|
73977
74014
|
const handle = name.endsWith(".json") ? readExportHandle(name.slice(0, -5)) : null;
|
|
73978
74015
|
return handle?.projectId === projectId && handle.lease === "active" && Date.parse(handle.expiresAt) > Date.now();
|
|
73979
74016
|
});
|
|
73980
74017
|
}
|
|
73981
74018
|
function collectExpiredExportHandles(now = Date.now()) {
|
|
73982
|
-
if (!(0,
|
|
74019
|
+
if (!(0, import_node_fs39.existsSync)(storeRoot())) return 0;
|
|
73983
74020
|
let removed = 0;
|
|
73984
|
-
for (const name of (0,
|
|
74021
|
+
for (const name of (0, import_node_fs39.readdirSync)(storeRoot())) {
|
|
73985
74022
|
if (!name.endsWith(".json")) continue;
|
|
73986
74023
|
const id = name.slice(0, -5);
|
|
73987
74024
|
const handle = readExportHandle(id);
|
|
73988
74025
|
if (!handle || Date.parse(handle.expiresAt) <= now && handle.resultRefs.length === 0) {
|
|
73989
|
-
(0,
|
|
74026
|
+
(0, import_node_fs39.rmSync)(handlePath(id), { force: true });
|
|
73990
74027
|
removed++;
|
|
73991
74028
|
}
|
|
73992
74029
|
}
|
|
@@ -73994,8 +74031,8 @@ function collectExpiredExportHandles(now = Date.now()) {
|
|
|
73994
74031
|
}
|
|
73995
74032
|
|
|
73996
74033
|
// file-publication.ts
|
|
73997
|
-
var
|
|
73998
|
-
var
|
|
74034
|
+
var import_node_crypto25 = require("node:crypto");
|
|
74035
|
+
var import_node_fs40 = require("node:fs");
|
|
73999
74036
|
var import_node_path36 = require("node:path");
|
|
74000
74037
|
var FilePublicationError = class extends Error {
|
|
74001
74038
|
constructor(message, code, paths = []) {
|
|
@@ -74009,11 +74046,11 @@ var FilePublicationError = class extends Error {
|
|
|
74009
74046
|
};
|
|
74010
74047
|
var proofOfBytes = (bytes) => ({
|
|
74011
74048
|
bytes: bytes.byteLength,
|
|
74012
|
-
sha256: (0,
|
|
74049
|
+
sha256: (0, import_node_crypto25.createHash)("sha256").update(bytes).digest("hex")
|
|
74013
74050
|
});
|
|
74014
74051
|
function readFileProof2(path) {
|
|
74015
74052
|
try {
|
|
74016
|
-
return proofOfBytes((0,
|
|
74053
|
+
return proofOfBytes((0, import_node_fs40.readFileSync)(path));
|
|
74017
74054
|
} catch (error) {
|
|
74018
74055
|
if (error.code === "ENOENT") return null;
|
|
74019
74056
|
throw error;
|
|
@@ -74023,38 +74060,38 @@ function fileProofEquals2(a, b) {
|
|
|
74023
74060
|
return a === null || b === null ? a === b : a.bytes === b.bytes && a.sha256 === b.sha256;
|
|
74024
74061
|
}
|
|
74025
74062
|
function syncFile2(path) {
|
|
74026
|
-
const fd2 = (0,
|
|
74063
|
+
const fd2 = (0, import_node_fs40.openSync)(path, "r+");
|
|
74027
74064
|
try {
|
|
74028
|
-
(0,
|
|
74065
|
+
(0, import_node_fs40.fsyncSync)(fd2);
|
|
74029
74066
|
} finally {
|
|
74030
|
-
(0,
|
|
74067
|
+
(0, import_node_fs40.closeSync)(fd2);
|
|
74031
74068
|
}
|
|
74032
74069
|
}
|
|
74033
74070
|
function syncDirectoryBestEffort3(path) {
|
|
74034
74071
|
try {
|
|
74035
|
-
const fd2 = (0,
|
|
74072
|
+
const fd2 = (0, import_node_fs40.openSync)(path, "r");
|
|
74036
74073
|
try {
|
|
74037
|
-
(0,
|
|
74074
|
+
(0, import_node_fs40.fsyncSync)(fd2);
|
|
74038
74075
|
} finally {
|
|
74039
|
-
(0,
|
|
74076
|
+
(0, import_node_fs40.closeSync)(fd2);
|
|
74040
74077
|
}
|
|
74041
74078
|
} catch {
|
|
74042
74079
|
}
|
|
74043
74080
|
}
|
|
74044
74081
|
function durableCanonicalJson(path, value) {
|
|
74045
74082
|
const dir = (0, import_node_path36.dirname)(path);
|
|
74046
|
-
(0,
|
|
74047
|
-
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`);
|
|
74048
74085
|
try {
|
|
74049
|
-
(0,
|
|
74086
|
+
(0, import_node_fs40.writeFileSync)(temp, `${canonicalJson(value)}
|
|
74050
74087
|
`, { encoding: "utf8", flag: "wx" });
|
|
74051
74088
|
syncFile2(temp);
|
|
74052
|
-
(0,
|
|
74089
|
+
(0, import_node_fs40.renameSync)(temp, path);
|
|
74053
74090
|
syncFile2(path);
|
|
74054
74091
|
syncDirectoryBestEffort3(dir);
|
|
74055
74092
|
} finally {
|
|
74056
74093
|
try {
|
|
74057
|
-
(0,
|
|
74094
|
+
(0, import_node_fs40.rmSync)(temp, { force: true });
|
|
74058
74095
|
} catch {
|
|
74059
74096
|
}
|
|
74060
74097
|
}
|
|
@@ -74073,7 +74110,7 @@ function mappedError(error, paths) {
|
|
|
74073
74110
|
}
|
|
74074
74111
|
function linkExclusive(source, destination) {
|
|
74075
74112
|
try {
|
|
74076
|
-
(0,
|
|
74113
|
+
(0, import_node_fs40.linkSync)(source, destination);
|
|
74077
74114
|
} catch (error) {
|
|
74078
74115
|
throw mappedError(error, [source, destination]);
|
|
74079
74116
|
}
|
|
@@ -74082,27 +74119,27 @@ function assertSameVolume(a, b) {
|
|
|
74082
74119
|
let aDev;
|
|
74083
74120
|
let bDev;
|
|
74084
74121
|
try {
|
|
74085
|
-
aDev = (0,
|
|
74086
|
-
bDev = (0,
|
|
74122
|
+
aDev = (0, import_node_fs40.statSync)(a, { bigint: true }).dev;
|
|
74123
|
+
bDev = (0, import_node_fs40.statSync)(b, { bigint: true }).dev;
|
|
74087
74124
|
} catch (error) {
|
|
74088
74125
|
throw mappedError(error, [a, b]);
|
|
74089
74126
|
}
|
|
74090
74127
|
if (aDev !== bDev) throw new FilePublicationError("publication paths are not on the same volume", "different-volume", [a, b]);
|
|
74091
74128
|
}
|
|
74092
74129
|
function uniqueArtifact(dir, label2, livePath) {
|
|
74093
|
-
(0,
|
|
74094
|
-
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)}`);
|
|
74095
74132
|
}
|
|
74096
74133
|
function publishFileExclusive(input) {
|
|
74097
74134
|
const { livePath, stagedPath, expectedLive, artifactDir } = input;
|
|
74098
|
-
assertSameVolume(stagedPath, (0,
|
|
74135
|
+
assertSameVolume(stagedPath, (0, import_node_fs40.existsSync)(livePath) ? livePath : (0, import_node_path36.dirname)(livePath));
|
|
74099
74136
|
const stagedProof = readFileProof2(stagedPath);
|
|
74100
74137
|
if (!stagedProof) throw new FilePublicationError("staged publication file is missing", "io-failure", [stagedPath]);
|
|
74101
74138
|
let beforeImage = null;
|
|
74102
74139
|
if (expectedLive) {
|
|
74103
74140
|
beforeImage = uniqueArtifact(artifactDir, "before", livePath);
|
|
74104
74141
|
try {
|
|
74105
|
-
(0,
|
|
74142
|
+
(0, import_node_fs40.renameSync)(livePath, beforeImage);
|
|
74106
74143
|
} catch (error) {
|
|
74107
74144
|
throw mappedError(error, [livePath, beforeImage]);
|
|
74108
74145
|
}
|
|
@@ -74114,19 +74151,19 @@ function publishFileExclusive(input) {
|
|
|
74114
74151
|
}
|
|
74115
74152
|
throw new FilePublicationError("the live file changed before publication", "live-changed", [livePath, beforeImage]);
|
|
74116
74153
|
}
|
|
74117
|
-
} else if ((0,
|
|
74154
|
+
} else if ((0, import_node_fs40.existsSync)(livePath)) {
|
|
74118
74155
|
throw new FilePublicationError("the live destination appeared before publication", "destination-exists", [livePath]);
|
|
74119
74156
|
}
|
|
74120
74157
|
try {
|
|
74121
74158
|
input.onFaultPoint?.("after-live-move", { livePath, stagedPath, beforeImage });
|
|
74122
74159
|
linkExclusive(stagedPath, livePath);
|
|
74123
74160
|
input.onFaultPoint?.("after-live-link", { livePath, stagedPath, beforeImage });
|
|
74124
|
-
(0,
|
|
74161
|
+
(0, import_node_fs40.unlinkSync)(stagedPath);
|
|
74125
74162
|
input.onFaultPoint?.("after-staged-unlink", { livePath, stagedPath, beforeImage });
|
|
74126
74163
|
syncFile2(livePath);
|
|
74127
74164
|
syncDirectoryBestEffort3((0, import_node_path36.dirname)(livePath));
|
|
74128
74165
|
} catch (error) {
|
|
74129
|
-
if (beforeImage && !(0,
|
|
74166
|
+
if (beforeImage && !(0, import_node_fs40.existsSync)(livePath)) {
|
|
74130
74167
|
try {
|
|
74131
74168
|
linkExclusive(beforeImage, livePath);
|
|
74132
74169
|
} catch {
|
|
@@ -74149,7 +74186,7 @@ function publishFileExclusive(input) {
|
|
|
74149
74186
|
var import_node_path38 = require("node:path");
|
|
74150
74187
|
|
|
74151
74188
|
// app-source-lock.ts
|
|
74152
|
-
var
|
|
74189
|
+
var import_node_fs41 = require("node:fs");
|
|
74153
74190
|
var import_node_os19 = require("node:os");
|
|
74154
74191
|
var import_node_path37 = require("node:path");
|
|
74155
74192
|
var AppSourcePublicationBusyError = class extends Error {
|
|
@@ -74162,9 +74199,9 @@ var AppSourcePublicationBusyError = class extends Error {
|
|
|
74162
74199
|
function activeApprovalTransaction(appId) {
|
|
74163
74200
|
const home = process.env.AWARE_HOME || (0, import_node_path37.join)((0, import_node_os19.homedir)(), ".aware");
|
|
74164
74201
|
const path = (0, import_node_path37.join)(home, "apps", appId, ".floless-approval-publication-journal-v1.json");
|
|
74165
|
-
if (!(0,
|
|
74202
|
+
if (!(0, import_node_fs41.existsSync)(path)) return null;
|
|
74166
74203
|
try {
|
|
74167
|
-
const stored2 = JSON.parse((0,
|
|
74204
|
+
const stored2 = JSON.parse((0, import_node_fs41.readFileSync)(path, "utf8"));
|
|
74168
74205
|
return typeof stored2?.journal?.id === "string" && stored2.journal.id ? stored2.journal.id : "__invalid__";
|
|
74169
74206
|
} catch {
|
|
74170
74207
|
return "__invalid__";
|
|
@@ -74179,8 +74216,8 @@ function withAppSourceLock(appId, label2, fn, options = {}) {
|
|
|
74179
74216
|
}
|
|
74180
74217
|
|
|
74181
74218
|
// app-publication-manifest.ts
|
|
74182
|
-
var
|
|
74183
|
-
var
|
|
74219
|
+
var import_node_crypto26 = require("node:crypto");
|
|
74220
|
+
var import_node_fs42 = require("node:fs");
|
|
74184
74221
|
var import_yaml7 = __toESM(require_dist6(), 1);
|
|
74185
74222
|
var APP_PUBLICATION_MANIFEST_SCHEMA = 1;
|
|
74186
74223
|
var AppPublicationManifestError = class extends Error {
|
|
@@ -74197,7 +74234,7 @@ function observeAppPublication(sourcePath, lockPath2) {
|
|
|
74197
74234
|
let lockSourceHash = null;
|
|
74198
74235
|
if (lock) {
|
|
74199
74236
|
try {
|
|
74200
|
-
const parsed = (0, import_yaml7.parse)((0,
|
|
74237
|
+
const parsed = (0, import_yaml7.parse)((0, import_node_fs42.readFileSync)(lockPath2, "utf8"));
|
|
74201
74238
|
lockSourceHash = typeof parsed?.["source-hash"] === "string" ? parsed["source-hash"] : null;
|
|
74202
74239
|
} catch {
|
|
74203
74240
|
}
|
|
@@ -74222,10 +74259,10 @@ function validManifest(value) {
|
|
|
74222
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);
|
|
74223
74260
|
}
|
|
74224
74261
|
function readAppPublicationManifest(path) {
|
|
74225
|
-
if (!(0,
|
|
74262
|
+
if (!(0, import_node_fs42.existsSync)(path)) return null;
|
|
74226
74263
|
let stored2;
|
|
74227
74264
|
try {
|
|
74228
|
-
stored2 = JSON.parse((0,
|
|
74265
|
+
stored2 = JSON.parse((0, import_node_fs42.readFileSync)(path, "utf8"));
|
|
74229
74266
|
} catch {
|
|
74230
74267
|
throw new AppPublicationManifestError(`app publication manifest is unreadable: ${path}`, "corrupt");
|
|
74231
74268
|
}
|
|
@@ -74251,7 +74288,7 @@ function bootstrapAppPublicationManifest(input) {
|
|
|
74251
74288
|
const observed2 = observeAppPublication(input.sourcePath, input.lockPath);
|
|
74252
74289
|
const rebound = {
|
|
74253
74290
|
schema: APP_PUBLICATION_MANIFEST_SCHEMA,
|
|
74254
|
-
publicationId: (0,
|
|
74291
|
+
publicationId: (0, import_node_crypto26.randomUUID)(),
|
|
74255
74292
|
appId: input.appId,
|
|
74256
74293
|
generation: 0,
|
|
74257
74294
|
state: observed2.coherent ? "ready-clean" : "ready-dirty",
|
|
@@ -74272,7 +74309,7 @@ function bootstrapAppPublicationManifest(input) {
|
|
|
74272
74309
|
const observed = observeAppPublication(input.sourcePath, input.lockPath);
|
|
74273
74310
|
const manifest = {
|
|
74274
74311
|
schema: APP_PUBLICATION_MANIFEST_SCHEMA,
|
|
74275
|
-
publicationId: (0,
|
|
74312
|
+
publicationId: (0, import_node_crypto26.randomUUID)(),
|
|
74276
74313
|
appId: input.appId,
|
|
74277
74314
|
generation: 0,
|
|
74278
74315
|
state: observed.coherent ? "ready-clean" : "ready-dirty",
|
|
@@ -74417,8 +74454,8 @@ function withAppPublicationWhileProjectLocked(input) {
|
|
|
74417
74454
|
}
|
|
74418
74455
|
|
|
74419
74456
|
// approval-app-publication.ts
|
|
74420
|
-
var
|
|
74421
|
-
var
|
|
74457
|
+
var import_node_crypto27 = require("node:crypto");
|
|
74458
|
+
var import_node_fs43 = require("node:fs");
|
|
74422
74459
|
var import_node_path39 = require("node:path");
|
|
74423
74460
|
var JOURNAL = ".floless-approval-publication-journal-v1.json";
|
|
74424
74461
|
var MANIFEST = ".floless-app-publication-state-v1.json";
|
|
@@ -74445,7 +74482,7 @@ function storeJournal(journal) {
|
|
|
74445
74482
|
}
|
|
74446
74483
|
function readApprovalPublicationJournal(sourcePath) {
|
|
74447
74484
|
try {
|
|
74448
|
-
const stored2 = JSON.parse((0,
|
|
74485
|
+
const stored2 = JSON.parse((0, import_node_fs43.readFileSync)(approvalPublicationJournalPath(sourcePath), "utf8"));
|
|
74449
74486
|
const value = stored2?.journal;
|
|
74450
74487
|
const expectedLiveLock = sourcePath.replace(/\.[^.]+$/, ".lock");
|
|
74451
74488
|
const expectedStageDir = (0, import_node_path39.join)(stagingRoot2(sourcePath), `${value?.appId ?? ""}-${value?.id ?? ""}`);
|
|
@@ -74461,7 +74498,7 @@ function readApprovalPublicationJournal(sourcePath) {
|
|
|
74461
74498
|
}
|
|
74462
74499
|
async function stageApprovalPublication(input) {
|
|
74463
74500
|
const appRoot = (0, import_node_path39.dirname)(input.sourcePath);
|
|
74464
|
-
const id = (0,
|
|
74501
|
+
const id = (0, import_node_crypto27.randomUUID)();
|
|
74465
74502
|
const stageDir = (0, import_node_path39.join)(stagingRoot2(input.sourcePath), `${input.appId}-${id}`);
|
|
74466
74503
|
const stagedAppRoot = (0, import_node_path39.join)(stageDir, "app");
|
|
74467
74504
|
let stagedSourcePath = "";
|
|
@@ -74471,8 +74508,8 @@ async function stageApprovalPublication(input) {
|
|
|
74471
74508
|
const beforeSource = readFileProof2(input.sourcePath);
|
|
74472
74509
|
const beforeLock = readFileProof2(input.liveLockPath);
|
|
74473
74510
|
try {
|
|
74474
|
-
(0,
|
|
74475
|
-
(0,
|
|
74511
|
+
(0, import_node_fs43.mkdirSync)(stageDir, { recursive: true });
|
|
74512
|
+
(0, import_node_fs43.cpSync)(appRoot, stagedAppRoot, {
|
|
74476
74513
|
recursive: true,
|
|
74477
74514
|
filter: (path) => ![JOURNAL, MANIFEST].includes((0, import_node_path39.basename)(path))
|
|
74478
74515
|
});
|
|
@@ -74485,7 +74522,7 @@ async function stageApprovalPublication(input) {
|
|
|
74485
74522
|
throw new Error("live workflow changed while the approval was being staged");
|
|
74486
74523
|
}
|
|
74487
74524
|
} catch (error) {
|
|
74488
|
-
(0,
|
|
74525
|
+
(0, import_node_fs43.rmSync)(stageDir, { recursive: true, force: true });
|
|
74489
74526
|
throw error;
|
|
74490
74527
|
}
|
|
74491
74528
|
const journal = {
|
|
@@ -74518,12 +74555,12 @@ function publishOne(livePath, stagedPath, before, staged, artifactDir) {
|
|
|
74518
74555
|
const live = readFileProof2(livePath);
|
|
74519
74556
|
if (fileProofEquals2(live, staged)) return;
|
|
74520
74557
|
if (!fileProofEquals2(live, before)) throw new Error(`live publication changed outside the approval transaction: ${livePath}`);
|
|
74521
|
-
if (!(0,
|
|
74558
|
+
if (!(0, import_node_fs43.existsSync)(stagedPath)) throw new Error(`staged publication bytes are unavailable: ${stagedPath}`);
|
|
74522
74559
|
publishFileExclusive({ livePath, stagedPath, expectedLive: before, artifactDir });
|
|
74523
74560
|
}
|
|
74524
74561
|
function completeApprovalPublication(journal) {
|
|
74525
74562
|
if (journal.phase !== "authorized" && journal.phase !== "published") throw new Error("approval publication is not authorized");
|
|
74526
|
-
(0,
|
|
74563
|
+
(0, import_node_fs43.mkdirSync)(journal.artifactDir, { recursive: true });
|
|
74527
74564
|
publishOne(journal.liveSourcePath, journal.stagedSourcePath, journal.beforeSource, journal.stagedSource, journal.artifactDir);
|
|
74528
74565
|
publishOne(journal.liveLockPath, journal.stagedLockPath, journal.beforeLock, journal.stagedLock, journal.artifactDir);
|
|
74529
74566
|
if (!fileProofEquals2(readFileProof2(journal.liveSourcePath), journal.stagedSource) || !fileProofEquals2(readFileProof2(journal.liveLockPath), journal.stagedLock)) {
|
|
@@ -74536,17 +74573,17 @@ function finalizeApprovalPublication(journal) {
|
|
|
74536
74573
|
if (!current || current.id !== journal.id || current.phase !== "published") {
|
|
74537
74574
|
throw new Error("published approval recovery authority is unavailable");
|
|
74538
74575
|
}
|
|
74539
|
-
(0,
|
|
74540
|
-
(0,
|
|
74576
|
+
(0, import_node_fs43.rmSync)(journal.stageDir, { recursive: true, force: true });
|
|
74577
|
+
(0, import_node_fs43.rmSync)(approvalPublicationJournalPath(journal.liveSourcePath), { force: true });
|
|
74541
74578
|
}
|
|
74542
74579
|
function abandonApprovalPublication(journal) {
|
|
74543
74580
|
if (journal.phase !== "staged") throw new Error("an authorized approval publication must be completed, not abandoned");
|
|
74544
|
-
(0,
|
|
74545
|
-
(0,
|
|
74581
|
+
(0, import_node_fs43.rmSync)(approvalPublicationJournalPath(journal.liveSourcePath), { force: true });
|
|
74582
|
+
(0, import_node_fs43.rmSync)(journal.stageDir, { recursive: true, force: true });
|
|
74546
74583
|
}
|
|
74547
74584
|
|
|
74548
74585
|
// workspace-data.ts
|
|
74549
|
-
var
|
|
74586
|
+
var import_node_fs44 = require("node:fs");
|
|
74550
74587
|
var VALID_INCLUDES = /* @__PURE__ */ new Set(["contract", "exports"]);
|
|
74551
74588
|
var VALID_EXPORT_KINDS = /* @__PURE__ */ new Set([
|
|
74552
74589
|
"bom-csv",
|
|
@@ -74607,15 +74644,15 @@ function exportBody(projectId, receipt, opts) {
|
|
|
74607
74644
|
};
|
|
74608
74645
|
if (opts.includePaths) body.path = path;
|
|
74609
74646
|
if (opts.exportContents) {
|
|
74610
|
-
const st = (0,
|
|
74647
|
+
const st = (0, import_node_fs44.statSync)(path);
|
|
74611
74648
|
if (st.size > opts.maxBytes) {
|
|
74612
74649
|
body.contentOmitted = true;
|
|
74613
74650
|
body.omittedReason = `export is ${st.size} bytes, over max-bytes ${opts.maxBytes}`;
|
|
74614
74651
|
} else if (receipt.encoding === "base64") {
|
|
74615
|
-
body.content = (0,
|
|
74652
|
+
body.content = (0, import_node_fs44.readFileSync)(path).toString("base64");
|
|
74616
74653
|
} else {
|
|
74617
74654
|
body.encoding = receipt.encoding ?? "utf8";
|
|
74618
|
-
body.content = (0,
|
|
74655
|
+
body.content = (0, import_node_fs44.readFileSync)(path, "utf8");
|
|
74619
74656
|
}
|
|
74620
74657
|
}
|
|
74621
74658
|
return body;
|
|
@@ -74894,7 +74931,7 @@ function registerMigrationCommitRoute(app, deps) {
|
|
|
74894
74931
|
}
|
|
74895
74932
|
|
|
74896
74933
|
// workspace-agent-manifest.ts
|
|
74897
|
-
var
|
|
74934
|
+
var import_node_fs45 = require("node:fs");
|
|
74898
74935
|
var import_node_os20 = require("node:os");
|
|
74899
74936
|
var import_node_path40 = require("node:path");
|
|
74900
74937
|
function awareHome() {
|
|
@@ -74905,7 +74942,7 @@ function workspaceAgentDir() {
|
|
|
74905
74942
|
}
|
|
74906
74943
|
function syncWorkspaceAgentManifest(port) {
|
|
74907
74944
|
const dir = workspaceAgentDir();
|
|
74908
|
-
(0,
|
|
74945
|
+
(0, import_node_fs45.mkdirSync)(dir, { recursive: true });
|
|
74909
74946
|
const manifest = `agent: floless-workspace
|
|
74910
74947
|
version: 0.2.0
|
|
74911
74948
|
sdk-target: 2.4.0
|
|
@@ -75036,7 +75073,7 @@ commands:
|
|
|
75036
75073
|
body: object
|
|
75037
75074
|
`;
|
|
75038
75075
|
const path = (0, import_node_path40.join)(dir, "manifest.yaml");
|
|
75039
|
-
if (!(0,
|
|
75076
|
+
if (!(0, import_node_fs45.existsSync)(path) || manifest !== "") (0, import_node_fs45.writeFileSync)(path, manifest, "utf8");
|
|
75040
75077
|
return path;
|
|
75041
75078
|
}
|
|
75042
75079
|
|
|
@@ -75153,8 +75190,8 @@ function indexJoints(contract, lib, mapRef) {
|
|
|
75153
75190
|
for (const sigs of idx.values()) sigs.sort();
|
|
75154
75191
|
return idx;
|
|
75155
75192
|
}
|
|
75156
|
-
var
|
|
75157
|
-
var MOVE_TOL_MM = MOVE_TOL_FT *
|
|
75193
|
+
var FT_MM2 = 304.8;
|
|
75194
|
+
var MOVE_TOL_MM = MOVE_TOL_FT * FT_MM2;
|
|
75158
75195
|
var knownZof = (wp) => {
|
|
75159
75196
|
const z = wp?.z;
|
|
75160
75197
|
if (!z || typeof z !== "object") return null;
|
|
@@ -75389,7 +75426,7 @@ function diffV2V2(a, b, ctx, tonnage) {
|
|
|
75389
75426
|
} else {
|
|
75390
75427
|
pairing = pair3d(am.seg, bm.seg);
|
|
75391
75428
|
if (pairing.mm > MOVE_TOL_MM) {
|
|
75392
|
-
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 });
|
|
75393
75430
|
changed = true;
|
|
75394
75431
|
}
|
|
75395
75432
|
}
|
|
@@ -76131,7 +76168,7 @@ function computeVersionDiff(id, n, base) {
|
|
|
76131
76168
|
}
|
|
76132
76169
|
|
|
76133
76170
|
// contract-bake.ts
|
|
76134
|
-
var
|
|
76171
|
+
var import_node_fs46 = require("node:fs");
|
|
76135
76172
|
var import_yaml8 = __toESM(require_dist6(), 1);
|
|
76136
76173
|
function isSteelType(t) {
|
|
76137
76174
|
return t === STEEL_V1 || t === STEEL_V2;
|
|
@@ -76155,7 +76192,7 @@ function bakedV2(contract) {
|
|
|
76155
76192
|
return stripConfidentialImages(baked);
|
|
76156
76193
|
}
|
|
76157
76194
|
function bakeContractIntoApp(sourcePath, contract) {
|
|
76158
|
-
const doc = (0, import_yaml8.parseDocument)((0,
|
|
76195
|
+
const doc = (0, import_yaml8.parseDocument)((0, import_node_fs46.readFileSync)(sourcePath, "utf8"));
|
|
76159
76196
|
if (doc.errors.length > 0) {
|
|
76160
76197
|
throw new Error(`contract bake: source is not valid YAML: ${doc.errors[0]?.message ?? "parse error"}`);
|
|
76161
76198
|
}
|
|
@@ -76179,7 +76216,7 @@ function bakeContractIntoApp(sourcePath, contract) {
|
|
|
76179
76216
|
throw new InvalidModelV2Error(`refusing to bake: contract declares steel.model/v2 but is not valid v2: ${issues[0] ?? "unknown"}`, issues);
|
|
76180
76217
|
}
|
|
76181
76218
|
doc.setIn(["nodes", idx, "config", "takeoff"], bakedV2(contract));
|
|
76182
|
-
(0,
|
|
76219
|
+
(0, import_node_fs46.writeFileSync)(sourcePath, doc.toString());
|
|
76183
76220
|
return;
|
|
76184
76221
|
}
|
|
76185
76222
|
const baked = { ...contract };
|
|
@@ -76224,7 +76261,7 @@ function bakeContractIntoApp(sourcePath, contract) {
|
|
|
76224
76261
|
);
|
|
76225
76262
|
}
|
|
76226
76263
|
doc.setIn(["nodes", idx, "config", "takeoff"], baked);
|
|
76227
|
-
(0,
|
|
76264
|
+
(0, import_node_fs46.writeFileSync)(sourcePath, doc.toString());
|
|
76228
76265
|
}
|
|
76229
76266
|
|
|
76230
76267
|
// vectorize.ts
|
|
@@ -76646,11 +76683,11 @@ function awareFailureMessage(e, fallback2) {
|
|
|
76646
76683
|
}
|
|
76647
76684
|
|
|
76648
76685
|
// scene-bake.ts
|
|
76649
|
-
var
|
|
76686
|
+
var import_node_fs47 = require("node:fs");
|
|
76650
76687
|
var import_node_path41 = require("node:path");
|
|
76651
76688
|
var import_yaml9 = __toESM(require_dist6(), 1);
|
|
76652
76689
|
function bakeSceneIntoApp(sourcePath, scene, agent = "viewer-3d") {
|
|
76653
|
-
const doc = (0, import_yaml9.parseDocument)((0,
|
|
76690
|
+
const doc = (0, import_yaml9.parseDocument)((0, import_node_fs47.readFileSync)(sourcePath, "utf8"));
|
|
76654
76691
|
if (doc.errors.length > 0) {
|
|
76655
76692
|
throw new Error(`scene bake: source is not valid YAML: ${doc.errors[0]?.message ?? "parse error"}`);
|
|
76656
76693
|
}
|
|
@@ -76659,10 +76696,10 @@ function bakeSceneIntoApp(sourcePath, scene, agent = "viewer-3d") {
|
|
|
76659
76696
|
const idx = items.findIndex((it) => ((0, import_yaml9.isMap)(it) ? it.toJSON() : null)?.agent === agent);
|
|
76660
76697
|
if (idx < 0) throw new Error(`no ${agent} render node to bake the scene into`);
|
|
76661
76698
|
doc.setIn(["nodes", idx, "config", "scene"], scene);
|
|
76662
|
-
(0,
|
|
76699
|
+
(0, import_node_fs47.writeFileSync)(sourcePath, doc.toString());
|
|
76663
76700
|
}
|
|
76664
76701
|
function bakeNodeConfigById(sourcePath, nodeId, patch2) {
|
|
76665
|
-
const doc = (0, import_yaml9.parseDocument)((0,
|
|
76702
|
+
const doc = (0, import_yaml9.parseDocument)((0, import_node_fs47.readFileSync)(sourcePath, "utf8"));
|
|
76666
76703
|
if (doc.errors.length > 0) {
|
|
76667
76704
|
throw new Error(`node bake: source is not valid YAML: ${doc.errors[0]?.message ?? "parse error"}`);
|
|
76668
76705
|
}
|
|
@@ -76671,12 +76708,12 @@ function bakeNodeConfigById(sourcePath, nodeId, patch2) {
|
|
|
76671
76708
|
const idx = items.findIndex((it) => ((0, import_yaml9.isMap)(it) ? it.toJSON() : null)?.id === nodeId);
|
|
76672
76709
|
if (idx < 0) throw new Error(`no node with id "${nodeId}"`);
|
|
76673
76710
|
for (const [key, value] of Object.entries(patch2)) doc.setIn(["nodes", idx, "config", key], value);
|
|
76674
|
-
(0,
|
|
76711
|
+
(0, import_node_fs47.writeFileSync)(sourcePath, doc.toString());
|
|
76675
76712
|
}
|
|
76676
76713
|
function writeViewer3dApp(dir, appId, scene) {
|
|
76677
|
-
(0,
|
|
76714
|
+
(0, import_node_fs47.mkdirSync)(dir, { recursive: true });
|
|
76678
76715
|
const flo = (0, import_node_path41.join)(dir, `${appId}.flo`);
|
|
76679
|
-
(0,
|
|
76716
|
+
(0, import_node_fs47.writeFileSync)(flo, [
|
|
76680
76717
|
`app: ${appId}`,
|
|
76681
76718
|
"version: 0.1.0",
|
|
76682
76719
|
"display-name: Steel 3D",
|
|
@@ -76699,18 +76736,18 @@ function writeViewer3dApp(dir, appId, scene) {
|
|
|
76699
76736
|
var COMPANION_MARKER = "# floless-companion: generated by FloLess \u2014 overwritten on every export";
|
|
76700
76737
|
function isCompanionApp(flo) {
|
|
76701
76738
|
try {
|
|
76702
|
-
return (0,
|
|
76739
|
+
return (0, import_node_fs47.readFileSync)(flo, "utf8").split(/\r?\n/, 1)[0]?.trim() === COMPANION_MARKER;
|
|
76703
76740
|
} catch (e) {
|
|
76704
76741
|
return e?.code === "ENOENT";
|
|
76705
76742
|
}
|
|
76706
76743
|
}
|
|
76707
76744
|
function writeBomReportApp(dir, appId, table) {
|
|
76708
|
-
(0,
|
|
76745
|
+
(0, import_node_fs47.mkdirSync)(dir, { recursive: true });
|
|
76709
76746
|
const flo = (0, import_node_path41.join)(dir, `${appId}.flo`);
|
|
76710
76747
|
if (!isCompanionApp(flo)) {
|
|
76711
76748
|
throw new Error(`refusing to overwrite "${appId}": an app of that name exists and FloLess did not write it`);
|
|
76712
76749
|
}
|
|
76713
|
-
(0,
|
|
76750
|
+
(0, import_node_fs47.writeFileSync)(flo, [
|
|
76714
76751
|
COMPANION_MARKER,
|
|
76715
76752
|
`app: ${appId}`,
|
|
76716
76753
|
"version: 0.1.0",
|
|
@@ -76737,9 +76774,9 @@ function writeBomReportApp(dir, appId, table) {
|
|
|
76737
76774
|
return flo;
|
|
76738
76775
|
}
|
|
76739
76776
|
function writeRevitApp(dir, appId, scene, hostPid, revitVersion = "2026") {
|
|
76740
|
-
(0,
|
|
76777
|
+
(0, import_node_fs47.mkdirSync)(dir, { recursive: true });
|
|
76741
76778
|
const flo = (0, import_node_path41.join)(dir, `${appId}.flo`);
|
|
76742
|
-
(0,
|
|
76779
|
+
(0, import_node_fs47.writeFileSync)(flo, [
|
|
76743
76780
|
`app: ${appId}`,
|
|
76744
76781
|
"version: 0.1.0",
|
|
76745
76782
|
"display-name: Steel to Revit",
|
|
@@ -76773,9 +76810,9 @@ function writeRevitApp(dir, appId, scene, hostPid, revitVersion = "2026") {
|
|
|
76773
76810
|
return flo;
|
|
76774
76811
|
}
|
|
76775
76812
|
function writeSketchupApp(dir, appId, scene) {
|
|
76776
|
-
(0,
|
|
76813
|
+
(0, import_node_fs47.mkdirSync)(dir, { recursive: true });
|
|
76777
76814
|
const flo = (0, import_node_path41.join)(dir, `${appId}.flo`);
|
|
76778
|
-
(0,
|
|
76815
|
+
(0, import_node_fs47.writeFileSync)(flo, [
|
|
76779
76816
|
`app: ${appId}`,
|
|
76780
76817
|
"version: 0.1.0",
|
|
76781
76818
|
"display-name: Steel to SketchUp",
|
|
@@ -76802,10 +76839,10 @@ function writeSketchupApp(dir, appId, scene) {
|
|
|
76802
76839
|
return flo;
|
|
76803
76840
|
}
|
|
76804
76841
|
function writeRhinoApp(dir, appId, scene, rhinoId, hostPid) {
|
|
76805
|
-
(0,
|
|
76842
|
+
(0, import_node_fs47.mkdirSync)(dir, { recursive: true });
|
|
76806
76843
|
const flo = (0, import_node_path41.join)(dir, `${appId}.flo`);
|
|
76807
76844
|
const exactRhinoId = typeof rhinoId === "string" && rhinoId.trim() ? rhinoId.trim() : null;
|
|
76808
|
-
(0,
|
|
76845
|
+
(0, import_node_fs47.writeFileSync)(flo, [
|
|
76809
76846
|
`app: ${appId}`,
|
|
76810
76847
|
"version: 0.1.0",
|
|
76811
76848
|
"display-name: Steel to Rhino",
|
|
@@ -76832,9 +76869,9 @@ function writeRhinoApp(dir, appId, scene, rhinoId, hostPid) {
|
|
|
76832
76869
|
return flo;
|
|
76833
76870
|
}
|
|
76834
76871
|
function writeTeklaApp(dir, appId, scene, teklaVersion = "2026.0") {
|
|
76835
|
-
(0,
|
|
76872
|
+
(0, import_node_fs47.mkdirSync)(dir, { recursive: true });
|
|
76836
76873
|
const flo = (0, import_node_path41.join)(dir, `${appId}.flo`);
|
|
76837
|
-
(0,
|
|
76874
|
+
(0, import_node_fs47.writeFileSync)(flo, [
|
|
76838
76875
|
`app: ${appId}`,
|
|
76839
76876
|
"version: 0.1.0",
|
|
76840
76877
|
"display-name: Steel to Tekla",
|
|
@@ -76997,8 +77034,8 @@ async function teklaVersionToBake() {
|
|
|
76997
77034
|
}
|
|
76998
77035
|
|
|
76999
77036
|
// ifc-publication.ts
|
|
77000
|
-
var
|
|
77001
|
-
var
|
|
77037
|
+
var import_node_crypto28 = require("node:crypto");
|
|
77038
|
+
var import_node_fs48 = require("node:fs");
|
|
77002
77039
|
var import_node_os21 = require("node:os");
|
|
77003
77040
|
var import_node_path42 = require("node:path");
|
|
77004
77041
|
var IfcPublicationError = class extends Error {
|
|
@@ -77023,7 +77060,7 @@ var MAX_TRANSACTIONS = 256;
|
|
|
77023
77060
|
var MAX_PHASE_BYTES = 1024 * 1024;
|
|
77024
77061
|
var MAX_INDEX_SNAPSHOT_BYTES = 512 * 1024;
|
|
77025
77062
|
function sha2562(bytes) {
|
|
77026
|
-
return (0,
|
|
77063
|
+
return (0, import_node_crypto28.createHash)("sha256").update(bytes).digest("hex");
|
|
77027
77064
|
}
|
|
77028
77065
|
function proof2(bytes) {
|
|
77029
77066
|
return { exists: true, bytes: bytes.length, sha256: sha2562(bytes) };
|
|
@@ -77032,37 +77069,37 @@ function sameProof(path, expected) {
|
|
|
77032
77069
|
return fileProofEquals(readFileProof(path), expected);
|
|
77033
77070
|
}
|
|
77034
77071
|
function syncFile3(path) {
|
|
77035
|
-
const fd2 = (0,
|
|
77072
|
+
const fd2 = (0, import_node_fs48.openSync)(path, "r+");
|
|
77036
77073
|
try {
|
|
77037
|
-
(0,
|
|
77074
|
+
(0, import_node_fs48.fsyncSync)(fd2);
|
|
77038
77075
|
} finally {
|
|
77039
|
-
(0,
|
|
77076
|
+
(0, import_node_fs48.closeSync)(fd2);
|
|
77040
77077
|
}
|
|
77041
77078
|
}
|
|
77042
77079
|
function syncDirectory2(path) {
|
|
77043
77080
|
try {
|
|
77044
|
-
const fd2 = (0,
|
|
77081
|
+
const fd2 = (0, import_node_fs48.openSync)(path, "r");
|
|
77045
77082
|
try {
|
|
77046
|
-
(0,
|
|
77083
|
+
(0, import_node_fs48.fsyncSync)(fd2);
|
|
77047
77084
|
} finally {
|
|
77048
|
-
(0,
|
|
77085
|
+
(0, import_node_fs48.closeSync)(fd2);
|
|
77049
77086
|
}
|
|
77050
77087
|
} catch {
|
|
77051
77088
|
}
|
|
77052
77089
|
}
|
|
77053
77090
|
function durableReplace2(path, bytes) {
|
|
77054
77091
|
const dir = (0, import_node_path42.dirname)(path);
|
|
77055
|
-
(0,
|
|
77056
|
-
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)()}`);
|
|
77057
77094
|
try {
|
|
77058
|
-
(0,
|
|
77095
|
+
(0, import_node_fs48.writeFileSync)(tmp, bytes, { flag: "wx" });
|
|
77059
77096
|
syncFile3(tmp);
|
|
77060
|
-
(0,
|
|
77097
|
+
(0, import_node_fs48.renameSync)(tmp, path);
|
|
77061
77098
|
syncFile3(path);
|
|
77062
77099
|
syncDirectory2(dir);
|
|
77063
77100
|
} finally {
|
|
77064
77101
|
try {
|
|
77065
|
-
(0,
|
|
77102
|
+
(0, import_node_fs48.rmSync)(tmp, { force: true });
|
|
77066
77103
|
} catch {
|
|
77067
77104
|
}
|
|
77068
77105
|
}
|
|
@@ -77088,12 +77125,12 @@ function validateRequestPaths(tempPath, finalPath) {
|
|
|
77088
77125
|
function requestIfcTempPath(finalPath) {
|
|
77089
77126
|
const final = canonicalPath(finalPath);
|
|
77090
77127
|
if (!plainIfcFilename((0, import_node_path42.basename)(final))) throw new IfcPublicationError("IFC final filename is unsafe.");
|
|
77091
|
-
(0,
|
|
77092
|
-
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`);
|
|
77093
77130
|
}
|
|
77094
77131
|
function validateIfc(path) {
|
|
77095
|
-
if (!(0,
|
|
77096
|
-
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);
|
|
77097
77134
|
const prefix = bytes.subarray(0, Math.min(bytes.length, 128)).toString("utf8");
|
|
77098
77135
|
if (!prefix.includes("ISO-10303-21")) throw new IfcPublicationError("the IFC export did not produce a valid STEP envelope");
|
|
77099
77136
|
return { bytes, proof: proof2(bytes) };
|
|
@@ -77107,20 +77144,20 @@ function writePhase2(txnDir2, journal) {
|
|
|
77107
77144
|
const index = PHASES2.indexOf(journal.phase);
|
|
77108
77145
|
if (index < 0) throw new IfcPublicationError(`unknown IFC publication phase "${journal.phase}".`);
|
|
77109
77146
|
const destination = (0, import_node_path42.join)(txnDir2, `${String(index).padStart(3, "0")}-${journal.phase}.json`);
|
|
77110
|
-
if ((0,
|
|
77111
|
-
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`);
|
|
77112
77149
|
const bytes = Buffer.from(`${JSON.stringify(journal, null, 2)}
|
|
77113
77150
|
`, "utf8");
|
|
77114
77151
|
try {
|
|
77115
|
-
(0,
|
|
77152
|
+
(0, import_node_fs48.writeFileSync)(temp, bytes, { flag: "wx" });
|
|
77116
77153
|
syncFile3(temp);
|
|
77117
|
-
(0,
|
|
77154
|
+
(0, import_node_fs48.renameSync)(temp, destination);
|
|
77118
77155
|
syncFile3(destination);
|
|
77119
77156
|
syncDirectory2(txnDir2);
|
|
77120
77157
|
syncDirectory2((0, import_node_path42.dirname)(txnDir2));
|
|
77121
77158
|
} finally {
|
|
77122
77159
|
try {
|
|
77123
|
-
(0,
|
|
77160
|
+
(0, import_node_fs48.rmSync)(temp, { force: true });
|
|
77124
77161
|
} catch {
|
|
77125
77162
|
}
|
|
77126
77163
|
}
|
|
@@ -77186,7 +77223,7 @@ function loadJournal(txnDir2) {
|
|
|
77186
77223
|
const match = (0, import_node_path42.basename)(txnDir2).match(ACTIVE_RE);
|
|
77187
77224
|
if (!match) throw new IfcPublicationError(`unsafe IFC transaction directory "${(0, import_node_path42.basename)(txnDir2)}".`);
|
|
77188
77225
|
const txnId = match[1];
|
|
77189
|
-
const entries2 = (0,
|
|
77226
|
+
const entries2 = (0, import_node_fs48.readdirSync)(txnDir2, { withFileTypes: true });
|
|
77190
77227
|
if (!entries2.length) return null;
|
|
77191
77228
|
const phaseFiles = entries2.filter((entry2) => entry2.isFile() && PHASE_RE.test(entry2.name)).sort((a, b) => a.name.localeCompare(b.name));
|
|
77192
77229
|
const unknown = entries2.filter((entry2) => !(entry2.isFile() && (PHASE_RE.test(entry2.name) || /^\.phase-[a-f0-9-]+\.tmp$/i.test(entry2.name))));
|
|
@@ -77201,10 +77238,10 @@ function loadJournal(txnDir2) {
|
|
|
77201
77238
|
const declaredPhase = phaseMatch[2];
|
|
77202
77239
|
if (declaredIndex !== index || PHASES2[index] !== declaredPhase) break;
|
|
77203
77240
|
const path = (0, import_node_path42.join)(txnDir2, entry2.name);
|
|
77204
|
-
if ((0,
|
|
77241
|
+
if ((0, import_node_fs48.statSync)(path).size > MAX_PHASE_BYTES) break;
|
|
77205
77242
|
let parsed;
|
|
77206
77243
|
try {
|
|
77207
|
-
parsed = JSON.parse((0,
|
|
77244
|
+
parsed = JSON.parse((0, import_node_fs48.readFileSync)(path, "utf8"));
|
|
77208
77245
|
} catch {
|
|
77209
77246
|
break;
|
|
77210
77247
|
}
|
|
@@ -77231,7 +77268,7 @@ function restoreIndex(journal) {
|
|
|
77231
77268
|
if (journal.priorIndex.exists) {
|
|
77232
77269
|
durableReplace2(indexPath, Buffer.from(journal.priorIndexBase64, "base64"));
|
|
77233
77270
|
} else {
|
|
77234
|
-
(0,
|
|
77271
|
+
(0, import_node_fs48.rmSync)(indexPath, { force: true });
|
|
77235
77272
|
syncDirectory2((0, import_node_path42.dirname)(indexPath));
|
|
77236
77273
|
}
|
|
77237
77274
|
if (!sameProof(indexPath, journal.priorIndex)) {
|
|
@@ -77247,14 +77284,14 @@ function restoreArtifact(journal) {
|
|
|
77247
77284
|
if (!fileProofEquals(backup, journal.priorArtifact)) {
|
|
77248
77285
|
throw new IfcPublicationError("IFC backup does not match the recorded prior artifact.");
|
|
77249
77286
|
}
|
|
77250
|
-
(0,
|
|
77287
|
+
(0, import_node_fs48.rmSync)(journal.backupPath, { force: true });
|
|
77251
77288
|
}
|
|
77252
77289
|
} else if (!final.exists || fileProofEquals(final, journal.newArtifact)) {
|
|
77253
77290
|
if (!fileProofEquals(backup, journal.priorArtifact)) {
|
|
77254
77291
|
throw new IfcPublicationError("IFC prior artifact cannot be proven for rollback.");
|
|
77255
77292
|
}
|
|
77256
|
-
if (final.exists) (0,
|
|
77257
|
-
(0,
|
|
77293
|
+
if (final.exists) (0, import_node_fs48.rmSync)(journal.finalPath, { force: true });
|
|
77294
|
+
(0, import_node_fs48.renameSync)(journal.backupPath, journal.finalPath);
|
|
77258
77295
|
syncFile3(journal.finalPath);
|
|
77259
77296
|
} else {
|
|
77260
77297
|
throw new IfcPublicationError("IFC final artifact is in an unknown state; recovery retained evidence.");
|
|
@@ -77267,15 +77304,15 @@ function restoreArtifact(journal) {
|
|
|
77267
77304
|
if (!fileProofEquals(final, journal.newArtifact)) {
|
|
77268
77305
|
throw new IfcPublicationError("IFC final artifact is in an unknown state; recovery retained evidence.");
|
|
77269
77306
|
}
|
|
77270
|
-
(0,
|
|
77307
|
+
(0, import_node_fs48.rmSync)(journal.finalPath, { force: true });
|
|
77271
77308
|
}
|
|
77272
77309
|
if (backup.exists) throw new IfcPublicationError("unexpected IFC backup exists for a no-prior transaction.");
|
|
77273
77310
|
}
|
|
77274
|
-
if ((0,
|
|
77311
|
+
if ((0, import_node_fs48.existsSync)(journal.tempPath)) {
|
|
77275
77312
|
if (!sameProof(journal.tempPath, journal.newArtifact)) {
|
|
77276
77313
|
throw new IfcPublicationError("IFC temp artifact does not match its recorded proof.");
|
|
77277
77314
|
}
|
|
77278
|
-
(0,
|
|
77315
|
+
(0, import_node_fs48.rmSync)(journal.tempPath, { force: true });
|
|
77279
77316
|
}
|
|
77280
77317
|
syncDirectory2(journal.exportDir);
|
|
77281
77318
|
}
|
|
@@ -77283,8 +77320,8 @@ function retireTransaction(txnDir2) {
|
|
|
77283
77320
|
const match = (0, import_node_path42.basename)(txnDir2).match(ACTIVE_RE);
|
|
77284
77321
|
if (!match) throw new IfcPublicationError("cannot retire an unsafe IFC transaction directory.");
|
|
77285
77322
|
const cleanupDir = (0, import_node_path42.join)((0, import_node_path42.dirname)(txnDir2), `.floless-cleanup-ifc-${match[1]}`);
|
|
77286
|
-
if ((0,
|
|
77287
|
-
(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);
|
|
77288
77325
|
syncDirectory2((0, import_node_path42.dirname)(txnDir2));
|
|
77289
77326
|
return cleanupDir;
|
|
77290
77327
|
}
|
|
@@ -77301,7 +77338,7 @@ function finishCommitted(txnDir2, journal, allowMissingBackup) {
|
|
|
77301
77338
|
if (!fileProofEquals(backup, journal.priorArtifact)) {
|
|
77302
77339
|
throw new IfcPublicationError("committed IFC backup does not match the recorded prior artifact.");
|
|
77303
77340
|
}
|
|
77304
|
-
(0,
|
|
77341
|
+
(0, import_node_fs48.rmSync)(journal.backupPath, { force: true });
|
|
77305
77342
|
syncDirectory2(journal.exportDir);
|
|
77306
77343
|
} else if (!allowMissingBackup) {
|
|
77307
77344
|
throw new IfcPublicationError("committed IFC backup disappeared before verified cleanup.");
|
|
@@ -77310,18 +77347,18 @@ function finishCommitted(txnDir2, journal, allowMissingBackup) {
|
|
|
77310
77347
|
throw new IfcPublicationError("unexpected committed IFC backup exists for a no-prior transaction.");
|
|
77311
77348
|
}
|
|
77312
77349
|
const cleanupDir = retireTransaction(txnDir2);
|
|
77313
|
-
(0,
|
|
77350
|
+
(0, import_node_fs48.rmSync)(cleanupDir, { recursive: true, force: true });
|
|
77314
77351
|
syncDirectory2(journal.exportDir);
|
|
77315
77352
|
}
|
|
77316
77353
|
function rollbackTransaction(txnDir2, journal) {
|
|
77317
77354
|
restoreArtifact(journal);
|
|
77318
77355
|
restoreIndex(journal);
|
|
77319
77356
|
const cleanupDir = retireTransaction(txnDir2);
|
|
77320
|
-
(0,
|
|
77357
|
+
(0, import_node_fs48.rmSync)(cleanupDir, { recursive: true, force: true });
|
|
77321
77358
|
syncDirectory2(journal.exportDir);
|
|
77322
77359
|
}
|
|
77323
77360
|
function safeTransactionDirectory(path) {
|
|
77324
|
-
const st = (0,
|
|
77361
|
+
const st = (0, import_node_fs48.lstatSync)(path);
|
|
77325
77362
|
if (!st.isDirectory() || st.isSymbolicLink()) {
|
|
77326
77363
|
throw new IfcPublicationError(`IFC transaction path is not a plain directory: ${path}`);
|
|
77327
77364
|
}
|
|
@@ -77331,7 +77368,7 @@ async function recoverActive(txnDir2, expected) {
|
|
|
77331
77368
|
const journal = loadJournal(txnDir2);
|
|
77332
77369
|
if (!journal) {
|
|
77333
77370
|
const cleanupDir = retireTransaction(txnDir2);
|
|
77334
|
-
(0,
|
|
77371
|
+
(0, import_node_fs48.rmSync)(cleanupDir, { recursive: true, force: true });
|
|
77335
77372
|
return;
|
|
77336
77373
|
}
|
|
77337
77374
|
if (expected && (journal.resource.kind !== expected.kind || journal.resource.key !== expected.key)) {
|
|
@@ -77344,9 +77381,9 @@ async function recoverActive(txnDir2, expected) {
|
|
|
77344
77381
|
}
|
|
77345
77382
|
async function recoverIfcPublicationsInDirectory(exportDir, expected) {
|
|
77346
77383
|
const dir = canonicalPath(exportDir);
|
|
77347
|
-
if (!(0,
|
|
77384
|
+
if (!(0, import_node_fs48.existsSync)(dir)) return [];
|
|
77348
77385
|
safeTransactionDirectory(dir);
|
|
77349
|
-
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));
|
|
77350
77387
|
if (entries2.length > MAX_TRANSACTIONS) {
|
|
77351
77388
|
throw new IfcPublicationError(`IFC recovery refused ${entries2.length} transaction directories (limit ${MAX_TRANSACTIONS}).`);
|
|
77352
77389
|
}
|
|
@@ -77355,7 +77392,7 @@ async function recoverIfcPublicationsInDirectory(exportDir, expected) {
|
|
|
77355
77392
|
const path = (0, import_node_path42.join)(dir, entry2.name);
|
|
77356
77393
|
safeTransactionDirectory(path);
|
|
77357
77394
|
if (CLEANUP_RE.test(entry2.name)) {
|
|
77358
|
-
(0,
|
|
77395
|
+
(0, import_node_fs48.rmSync)(path, { recursive: true, force: true });
|
|
77359
77396
|
syncDirectory2(dir);
|
|
77360
77397
|
recovered.push(entry2.name);
|
|
77361
77398
|
continue;
|
|
@@ -77369,9 +77406,9 @@ async function recoverAllIfcPublications() {
|
|
|
77369
77406
|
const recovered = [];
|
|
77370
77407
|
const rootHome = process.env.FLOLESS_HOME ?? (0, import_node_path42.join)((0, import_node_os21.homedir)(), ".floless");
|
|
77371
77408
|
const projectsRoot2 = (0, import_node_path42.join)(rootHome, "projects");
|
|
77372
|
-
if ((0,
|
|
77409
|
+
if ((0, import_node_fs48.existsSync)(projectsRoot2)) {
|
|
77373
77410
|
safeTransactionDirectory(projectsRoot2);
|
|
77374
|
-
for (const entry2 of (0,
|
|
77411
|
+
for (const entry2 of (0, import_node_fs48.readdirSync)(projectsRoot2, { withFileTypes: true })) {
|
|
77375
77412
|
if (entry2.name.startsWith(".")) continue;
|
|
77376
77413
|
if (entry2.isSymbolicLink()) throw new IfcPublicationError(`project recovery root is a link: ${entry2.name}`);
|
|
77377
77414
|
if (!entry2.isDirectory() || !/^[a-z0-9][a-z0-9-]*$/.test(entry2.name)) continue;
|
|
@@ -77383,9 +77420,9 @@ async function recoverAllIfcPublications() {
|
|
|
77383
77420
|
}
|
|
77384
77421
|
}
|
|
77385
77422
|
const root5 = (0, import_node_path42.join)(rootHome, "exports");
|
|
77386
|
-
if ((0,
|
|
77423
|
+
if ((0, import_node_fs48.existsSync)(root5)) {
|
|
77387
77424
|
safeTransactionDirectory(root5);
|
|
77388
|
-
for (const entry2 of (0,
|
|
77425
|
+
for (const entry2 of (0, import_node_fs48.readdirSync)(root5, { withFileTypes: true })) {
|
|
77389
77426
|
if (entry2.name.startsWith(".")) continue;
|
|
77390
77427
|
if (entry2.isSymbolicLink()) throw new IfcPublicationError(`workflow recovery root is a link: ${entry2.name}`);
|
|
77391
77428
|
if (!entry2.isDirectory()) continue;
|
|
@@ -77416,7 +77453,7 @@ function promiseLike(value) {
|
|
|
77416
77453
|
async function publishIfcAtomically(tempPath, finalPath, options) {
|
|
77417
77454
|
if (!options || !validResource(options.resource)) throw new IfcPublicationError("IFC publication resource is invalid.");
|
|
77418
77455
|
const paths = validateRequestPaths(tempPath, finalPath);
|
|
77419
|
-
const tempStat = (0,
|
|
77456
|
+
const tempStat = (0, import_node_fs48.lstatSync)(paths.temp);
|
|
77420
77457
|
if (!tempStat.isFile()) throw new IfcPublicationError("the IFC to publish is not a regular file.");
|
|
77421
77458
|
const validated = validateIfc(paths.temp);
|
|
77422
77459
|
if (options.expectedContentSha256 !== void 0 && validated.proof.sha256 !== options.expectedContentSha256) {
|
|
@@ -77428,7 +77465,7 @@ async function publishIfcAtomically(tempPath, finalPath, options) {
|
|
|
77428
77465
|
}
|
|
77429
77466
|
return withLifecycleLock(options.resource.kind, options.resource.key, async () => {
|
|
77430
77467
|
await recoverIfcPublicationsInDirectory(paths.dir, options.resource);
|
|
77431
|
-
const txnId = (0,
|
|
77468
|
+
const txnId = (0, import_node_crypto28.randomUUID)();
|
|
77432
77469
|
const txnDir2 = (0, import_node_path42.join)(paths.dir, `.floless-txn-ifc-${txnId}`);
|
|
77433
77470
|
const backupPath = (0, import_node_path42.join)(paths.dir, `.floless-backup-ifc-${txnId}.ifc`);
|
|
77434
77471
|
const priorArtifact = readFileProof(paths.final);
|
|
@@ -77454,7 +77491,7 @@ async function publishIfcAtomically(tempPath, finalPath, options) {
|
|
|
77454
77491
|
};
|
|
77455
77492
|
let journal = { ...base, phase: "prepared" };
|
|
77456
77493
|
let committed = false;
|
|
77457
|
-
(0,
|
|
77494
|
+
(0, import_node_fs48.mkdirSync)(txnDir2);
|
|
77458
77495
|
syncDirectory2(paths.dir);
|
|
77459
77496
|
const hit = (point) => {
|
|
77460
77497
|
options.fault?.(point);
|
|
@@ -77470,11 +77507,11 @@ async function publishIfcAtomically(tempPath, finalPath, options) {
|
|
|
77470
77507
|
phase("prepared");
|
|
77471
77508
|
phase("backing-up");
|
|
77472
77509
|
if (priorArtifact.exists) {
|
|
77473
|
-
(0,
|
|
77510
|
+
(0, import_node_fs48.renameSync)(paths.final, backupPath);
|
|
77474
77511
|
syncDirectory2(paths.dir);
|
|
77475
77512
|
}
|
|
77476
77513
|
phase("promoting");
|
|
77477
|
-
(0,
|
|
77514
|
+
(0, import_node_fs48.renameSync)(paths.temp, paths.final);
|
|
77478
77515
|
syncFile3(paths.final);
|
|
77479
77516
|
syncDirectory2(paths.dir);
|
|
77480
77517
|
if (!sameProof(paths.final, validated.proof)) {
|
|
@@ -77503,7 +77540,7 @@ async function publishIfcAtomically(tempPath, finalPath, options) {
|
|
|
77503
77540
|
if (!fileProofEquals(backup, priorArtifact)) {
|
|
77504
77541
|
throw new IfcPublicationError("IFC backup did not match the recorded prior artifact before cleanup.");
|
|
77505
77542
|
}
|
|
77506
|
-
(0,
|
|
77543
|
+
(0, import_node_fs48.rmSync)(backupPath, { force: true });
|
|
77507
77544
|
syncDirectory2(paths.dir);
|
|
77508
77545
|
} else if (backup.exists) {
|
|
77509
77546
|
throw new IfcPublicationError("unexpected IFC backup exists for a no-prior transaction.");
|
|
@@ -77513,7 +77550,7 @@ async function publishIfcAtomically(tempPath, finalPath, options) {
|
|
|
77513
77550
|
const cleanupDir = retireTransaction(txnDir2);
|
|
77514
77551
|
hit("after-retire");
|
|
77515
77552
|
hit("before-cleanup-remove");
|
|
77516
|
-
(0,
|
|
77553
|
+
(0, import_node_fs48.rmSync)(cleanupDir, { recursive: true, force: true });
|
|
77517
77554
|
syncDirectory2(paths.dir);
|
|
77518
77555
|
return { bytes: validated.bytes, cleanupPending: false };
|
|
77519
77556
|
} catch (error) {
|
|
@@ -77559,8 +77596,8 @@ function cleanupIfcTemp(path) {
|
|
|
77559
77596
|
if (!TEMP_RE.test((0, import_node_path42.basename)(path))) return;
|
|
77560
77597
|
const canonical = canonicalPath(path);
|
|
77561
77598
|
const dir = (0, import_node_path42.dirname)(canonical);
|
|
77562
|
-
if ((0,
|
|
77563
|
-
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 })) {
|
|
77564
77601
|
if (!entry2.isDirectory() || !ACTIVE_RE.test(entry2.name)) continue;
|
|
77565
77602
|
try {
|
|
77566
77603
|
const journal = loadJournal((0, import_node_path42.join)(dir, entry2.name));
|
|
@@ -77571,14 +77608,14 @@ function cleanupIfcTemp(path) {
|
|
|
77571
77608
|
}
|
|
77572
77609
|
}
|
|
77573
77610
|
try {
|
|
77574
|
-
(0,
|
|
77611
|
+
(0, import_node_fs48.rmSync)(path, { force: true });
|
|
77575
77612
|
} catch {
|
|
77576
77613
|
}
|
|
77577
77614
|
}
|
|
77578
77615
|
|
|
77579
77616
|
// export-companion.ts
|
|
77580
|
-
var
|
|
77581
|
-
var
|
|
77617
|
+
var import_node_crypto29 = require("node:crypto");
|
|
77618
|
+
var import_node_fs49 = require("node:fs");
|
|
77582
77619
|
var import_node_path43 = require("node:path");
|
|
77583
77620
|
var PREFIX = "floless-export-tmp-";
|
|
77584
77621
|
var LEASE = ".floless-export-lease.json";
|
|
@@ -77604,11 +77641,11 @@ function assertScratchPath(path, appsRoot) {
|
|
|
77604
77641
|
}
|
|
77605
77642
|
function removeScratch(path, appsRoot) {
|
|
77606
77643
|
assertScratchPath(path, appsRoot);
|
|
77607
|
-
(0,
|
|
77644
|
+
(0, import_node_fs49.rmSync)(path, { recursive: true, force: true });
|
|
77608
77645
|
}
|
|
77609
77646
|
function createExportCompanion(ownerId, sink, appsRoot = defaultAppsRoot()) {
|
|
77610
77647
|
const safeOwner = ownerId.replace(/[^a-z0-9._-]/gi, "-").slice(0, 80) || "app";
|
|
77611
|
-
const token2 = (0,
|
|
77648
|
+
const token2 = (0, import_node_crypto29.randomUUID)();
|
|
77612
77649
|
const id = `${PREFIX}${safeOwner}-${sink}-${token2}`;
|
|
77613
77650
|
const root5 = (0, import_node_path43.resolve)(appsRoot);
|
|
77614
77651
|
const path = (0, import_node_path43.resolve)(root5, id);
|
|
@@ -77617,10 +77654,10 @@ function createExportCompanion(ownerId, sink, appsRoot = defaultAppsRoot()) {
|
|
|
77617
77654
|
path,
|
|
77618
77655
|
token: token2,
|
|
77619
77656
|
cleanup: () => {
|
|
77620
|
-
if (!(0,
|
|
77657
|
+
if (!(0, import_node_fs49.existsSync)(path)) return;
|
|
77621
77658
|
let current = null;
|
|
77622
77659
|
try {
|
|
77623
|
-
current = JSON.parse((0,
|
|
77660
|
+
current = JSON.parse((0, import_node_fs49.readFileSync)((0, import_node_path43.resolve)(path, LEASE), "utf8"));
|
|
77624
77661
|
} catch {
|
|
77625
77662
|
}
|
|
77626
77663
|
if (current && current.token !== token2) throw new Error(`export companion lease changed for ${id}`);
|
|
@@ -77629,7 +77666,7 @@ function createExportCompanion(ownerId, sink, appsRoot = defaultAppsRoot()) {
|
|
|
77629
77666
|
};
|
|
77630
77667
|
}
|
|
77631
77668
|
function stampExportCompanionLease(companion2) {
|
|
77632
|
-
(0,
|
|
77669
|
+
(0, import_node_fs49.writeFileSync)((0, import_node_path43.resolve)(companion2.path, LEASE), JSON.stringify({
|
|
77633
77670
|
pid: process.pid,
|
|
77634
77671
|
token: companion2.token,
|
|
77635
77672
|
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -77637,19 +77674,19 @@ function stampExportCompanionLease(companion2) {
|
|
|
77637
77674
|
}
|
|
77638
77675
|
function sweepStaleExportCompanions(now = Date.now(), appsRoot = defaultAppsRoot()) {
|
|
77639
77676
|
const root5 = (0, import_node_path43.resolve)(appsRoot);
|
|
77640
|
-
if (!(0,
|
|
77677
|
+
if (!(0, import_node_fs49.existsSync)(root5)) return [];
|
|
77641
77678
|
const removed = [];
|
|
77642
|
-
for (const entry2 of (0,
|
|
77679
|
+
for (const entry2 of (0, import_node_fs49.readdirSync)(root5, { withFileTypes: true })) {
|
|
77643
77680
|
if (!entry2.isDirectory() || !entry2.name.startsWith(PREFIX)) continue;
|
|
77644
77681
|
const path = (0, import_node_path43.resolve)(root5, entry2.name);
|
|
77645
77682
|
let lease = null;
|
|
77646
77683
|
try {
|
|
77647
|
-
lease = JSON.parse((0,
|
|
77684
|
+
lease = JSON.parse((0, import_node_fs49.readFileSync)((0, import_node_path43.resolve)(path, LEASE), "utf8"));
|
|
77648
77685
|
} catch {
|
|
77649
77686
|
}
|
|
77650
77687
|
let created;
|
|
77651
77688
|
try {
|
|
77652
|
-
created = lease ? Date.parse(lease.createdAt) : (0,
|
|
77689
|
+
created = lease ? Date.parse(lease.createdAt) : (0, import_node_fs49.statSync)(path).mtimeMs;
|
|
77653
77690
|
} catch {
|
|
77654
77691
|
continue;
|
|
77655
77692
|
}
|
|
@@ -78223,14 +78260,14 @@ function looksLikeHostUnavailable(host, ...messages) {
|
|
|
78223
78260
|
}
|
|
78224
78261
|
|
|
78225
78262
|
// render-readiness.ts
|
|
78226
|
-
var
|
|
78263
|
+
var import_node_fs50 = require("node:fs");
|
|
78227
78264
|
var import_node_path44 = require("node:path");
|
|
78228
78265
|
var import_node_os22 = require("node:os");
|
|
78229
78266
|
var RENDER_AWARE_FLOOR = "0.103.0";
|
|
78230
78267
|
var RENDER_AGENT_ID = "blender";
|
|
78231
78268
|
function isFile(path) {
|
|
78232
78269
|
try {
|
|
78233
|
-
return (0,
|
|
78270
|
+
return (0, import_node_fs50.existsSync)(path) && (0, import_node_fs50.statSync)(path).isFile();
|
|
78234
78271
|
} catch {
|
|
78235
78272
|
return false;
|
|
78236
78273
|
}
|
|
@@ -78264,7 +78301,7 @@ function windowsCandidates(env2) {
|
|
|
78264
78301
|
for (const root5 of roots) {
|
|
78265
78302
|
let entries2;
|
|
78266
78303
|
try {
|
|
78267
|
-
entries2 = (0,
|
|
78304
|
+
entries2 = (0, import_node_fs50.readdirSync)(root5);
|
|
78268
78305
|
} catch {
|
|
78269
78306
|
continue;
|
|
78270
78307
|
}
|
|
@@ -78443,16 +78480,16 @@ function nothingToApprove(contract) {
|
|
|
78443
78480
|
}
|
|
78444
78481
|
|
|
78445
78482
|
// app-lifecycle.ts
|
|
78446
|
-
var
|
|
78483
|
+
var import_node_fs53 = require("node:fs");
|
|
78447
78484
|
var import_node_os24 = require("node:os");
|
|
78448
78485
|
var import_node_path47 = require("node:path");
|
|
78449
78486
|
|
|
78450
78487
|
// routines.ts
|
|
78451
|
-
var
|
|
78488
|
+
var import_node_fs52 = require("node:fs");
|
|
78452
78489
|
var import_node_path46 = require("node:path");
|
|
78453
78490
|
|
|
78454
78491
|
// trigger-sessions.ts
|
|
78455
|
-
var
|
|
78492
|
+
var import_node_fs51 = require("node:fs");
|
|
78456
78493
|
var import_node_os23 = require("node:os");
|
|
78457
78494
|
var import_node_path45 = require("node:path");
|
|
78458
78495
|
var import_yaml10 = __toESM(require_dist6(), 1);
|
|
@@ -78474,9 +78511,9 @@ function isHostBacked(agent, agentsDir = AGENTS_DIR2) {
|
|
|
78474
78511
|
const safe2 = (n) => !n.includes("/") && !n.includes("\\") && !n.includes("..");
|
|
78475
78512
|
if (!safe2(agent)) return false;
|
|
78476
78513
|
const manifestPath2 = (0, import_node_path45.join)(agentsDir, agent, "manifest.yaml");
|
|
78477
|
-
if (!(0,
|
|
78514
|
+
if (!(0, import_node_fs51.existsSync)(manifestPath2)) return false;
|
|
78478
78515
|
try {
|
|
78479
|
-
const doc = (0, import_yaml10.parse)((0,
|
|
78516
|
+
const doc = (0, import_yaml10.parse)((0, import_node_fs51.readFileSync)(manifestPath2, "utf8"));
|
|
78480
78517
|
const transport = doc?.transport;
|
|
78481
78518
|
return !!(transport && typeof transport === "object" && "cli" in transport);
|
|
78482
78519
|
} catch {
|
|
@@ -78820,10 +78857,10 @@ function sanitizeRoutine(raw) {
|
|
|
78820
78857
|
};
|
|
78821
78858
|
}
|
|
78822
78859
|
function loadFromDisk() {
|
|
78823
|
-
if (!(0,
|
|
78860
|
+
if (!(0, import_node_fs52.existsSync)(ROUTINES_FILE)) return [];
|
|
78824
78861
|
let text3;
|
|
78825
78862
|
try {
|
|
78826
|
-
text3 = (0,
|
|
78863
|
+
text3 = (0, import_node_fs52.readFileSync)(ROUTINES_FILE, "utf8");
|
|
78827
78864
|
} catch {
|
|
78828
78865
|
return [];
|
|
78829
78866
|
}
|
|
@@ -78832,17 +78869,17 @@ function loadFromDisk() {
|
|
|
78832
78869
|
return Array.isArray(parsed) ? parsed.map(sanitizeRoutine).filter((r) => r !== null) : [];
|
|
78833
78870
|
} catch {
|
|
78834
78871
|
try {
|
|
78835
|
-
(0,
|
|
78872
|
+
(0, import_node_fs52.renameSync)(ROUTINES_FILE, `${ROUTINES_FILE}.corrupt-${Date.now()}`);
|
|
78836
78873
|
} catch {
|
|
78837
78874
|
}
|
|
78838
78875
|
return [];
|
|
78839
78876
|
}
|
|
78840
78877
|
}
|
|
78841
78878
|
function saveRoutines() {
|
|
78842
|
-
if (!(0,
|
|
78879
|
+
if (!(0, import_node_fs52.existsSync)(flolessRoot)) (0, import_node_fs52.mkdirSync)(flolessRoot, { recursive: true });
|
|
78843
78880
|
const tmp = `${ROUTINES_FILE}.${process.pid}.tmp`;
|
|
78844
|
-
(0,
|
|
78845
|
-
(0,
|
|
78881
|
+
(0, import_node_fs52.writeFileSync)(tmp, JSON.stringify(routines, null, 2));
|
|
78882
|
+
(0, import_node_fs52.renameSync)(tmp, ROUTINES_FILE);
|
|
78846
78883
|
}
|
|
78847
78884
|
function listRoutines() {
|
|
78848
78885
|
ensureLoaded();
|
|
@@ -79268,7 +79305,7 @@ function appDirPath(id) {
|
|
|
79268
79305
|
return (0, import_node_path47.join)(appsDir(), id);
|
|
79269
79306
|
}
|
|
79270
79307
|
function appInstalled(id) {
|
|
79271
|
-
return APP_ID4.test(id) && (0,
|
|
79308
|
+
return APP_ID4.test(id) && (0, import_node_fs53.existsSync)(appDirPath(id));
|
|
79272
79309
|
}
|
|
79273
79310
|
function logCascade(what, e) {
|
|
79274
79311
|
console.error(`[app-lifecycle] cascade step failed (${what}):`, e instanceof Error ? e.message : e);
|
|
@@ -79506,7 +79543,7 @@ function isGatedAwareRoute(url, method) {
|
|
|
79506
79543
|
|
|
79507
79544
|
// autostart.mjs
|
|
79508
79545
|
var import_node_child_process7 = require("node:child_process");
|
|
79509
|
-
var
|
|
79546
|
+
var import_node_fs54 = require("node:fs");
|
|
79510
79547
|
var import_node_os25 = require("node:os");
|
|
79511
79548
|
var import_node_path48 = require("node:path");
|
|
79512
79549
|
|
|
@@ -79620,8 +79657,8 @@ function removeLegacyRunKey() {
|
|
|
79620
79657
|
}
|
|
79621
79658
|
function logLine(msg) {
|
|
79622
79659
|
try {
|
|
79623
|
-
(0,
|
|
79624
|
-
(0,
|
|
79660
|
+
(0, import_node_fs54.mkdirSync)(logDir(), { recursive: true });
|
|
79661
|
+
(0, import_node_fs54.appendFileSync)(logFilePath(), `${(/* @__PURE__ */ new Date()).toISOString()} ${msg}
|
|
79625
79662
|
`);
|
|
79626
79663
|
} catch {
|
|
79627
79664
|
}
|
|
@@ -79630,7 +79667,7 @@ function registerAutostart(exePath) {
|
|
|
79630
79667
|
if (!isWin) return;
|
|
79631
79668
|
const xml = buildAutostartTaskXml(exePath, currentUserId());
|
|
79632
79669
|
const tmp = (0, import_node_path48.join)((0, import_node_os25.tmpdir)(), `floless-autostart-${process.pid}-${Date.now()}.xml`);
|
|
79633
|
-
(0,
|
|
79670
|
+
(0, import_node_fs54.writeFileSync)(tmp, "\uFEFF" + xml, { encoding: "utf16le" });
|
|
79634
79671
|
try {
|
|
79635
79672
|
(0, import_node_child_process7.execFileSync)("schtasks", ["/Create", "/TN", TASK_NAME, "/XML", tmp, "/F"], {
|
|
79636
79673
|
stdio: ["ignore", "ignore", "ignore"],
|
|
@@ -79641,7 +79678,7 @@ function registerAutostart(exePath) {
|
|
|
79641
79678
|
throw err2;
|
|
79642
79679
|
} finally {
|
|
79643
79680
|
try {
|
|
79644
|
-
(0,
|
|
79681
|
+
(0, import_node_fs54.rmSync)(tmp, { force: true });
|
|
79645
79682
|
} catch {
|
|
79646
79683
|
}
|
|
79647
79684
|
}
|
|
@@ -79675,14 +79712,14 @@ function unregisterAutostart() {
|
|
|
79675
79712
|
|
|
79676
79713
|
// updater.ts
|
|
79677
79714
|
var import_node_child_process8 = require("node:child_process");
|
|
79678
|
-
var
|
|
79679
|
-
var
|
|
79715
|
+
var import_node_crypto30 = require("node:crypto");
|
|
79716
|
+
var import_node_fs56 = require("node:fs");
|
|
79680
79717
|
var import_node_stream3 = require("node:stream");
|
|
79681
79718
|
var import_promises4 = require("node:stream/promises");
|
|
79682
79719
|
var import_node_path50 = require("node:path");
|
|
79683
79720
|
|
|
79684
79721
|
// post-update-marker.mjs
|
|
79685
|
-
var
|
|
79722
|
+
var import_node_fs55 = require("node:fs");
|
|
79686
79723
|
var import_node_os26 = require("node:os");
|
|
79687
79724
|
var import_node_path49 = require("node:path");
|
|
79688
79725
|
var FRESH_MS = 12e4;
|
|
@@ -79705,7 +79742,7 @@ function writePostUpdateMarker() {
|
|
|
79705
79742
|
for (const p of [markerPath(), legacyMarkerPath()]) {
|
|
79706
79743
|
if (!p) continue;
|
|
79707
79744
|
try {
|
|
79708
|
-
(0,
|
|
79745
|
+
(0, import_node_fs55.writeFileSync)(p, (/* @__PURE__ */ new Date()).toISOString());
|
|
79709
79746
|
wrote = true;
|
|
79710
79747
|
} catch {
|
|
79711
79748
|
}
|
|
@@ -79717,9 +79754,9 @@ function consumePostUpdateMarker() {
|
|
|
79717
79754
|
for (const p of [markerPath(), legacyMarkerPath()]) {
|
|
79718
79755
|
if (!p) continue;
|
|
79719
79756
|
try {
|
|
79720
|
-
if (!(0,
|
|
79721
|
-
const ageMs = Date.now() - (0,
|
|
79722
|
-
(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 });
|
|
79723
79760
|
if (ageMs < FRESH_MS) fresh = true;
|
|
79724
79761
|
} catch {
|
|
79725
79762
|
}
|
|
@@ -79727,6 +79764,17 @@ function consumePostUpdateMarker() {
|
|
|
79727
79764
|
return fresh;
|
|
79728
79765
|
}
|
|
79729
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
|
+
|
|
79730
79778
|
// updater.ts
|
|
79731
79779
|
var CHANNEL = "win";
|
|
79732
79780
|
var FEED_TIMEOUT_MS = 15e3;
|
|
@@ -79761,15 +79809,6 @@ function classifyFeedStatus(status) {
|
|
|
79761
79809
|
if (status === 402 || status === 403) return { updateAvailable: false, reason: "active subscription required for updates" };
|
|
79762
79810
|
return null;
|
|
79763
79811
|
}
|
|
79764
|
-
function versionGt(a, b) {
|
|
79765
|
-
const pa = a.split(".").map((n) => parseInt(n, 10) || 0);
|
|
79766
|
-
const pb = b.split(".").map((n) => parseInt(n, 10) || 0);
|
|
79767
|
-
for (let i = 0; i < Math.max(pa.length, pb.length); i++) {
|
|
79768
|
-
const d = (pa[i] ?? 0) - (pb[i] ?? 0);
|
|
79769
|
-
if (d !== 0) return d > 0;
|
|
79770
|
-
}
|
|
79771
|
-
return false;
|
|
79772
|
-
}
|
|
79773
79812
|
var NPM_LATEST_URL = "https://registry.npmjs.org/@floless/app/latest";
|
|
79774
79813
|
var NPM_UPDATE_COMMAND = "npm i -g @floless/app@latest";
|
|
79775
79814
|
async function checkNpmUpdate(cur, channel = "npm") {
|
|
@@ -79841,23 +79880,23 @@ async function checkForUpdate() {
|
|
|
79841
79880
|
return { supported: true, currentVersion: cur, updateAvailable: true, targetVersion: latest.Version, asset: latest };
|
|
79842
79881
|
}
|
|
79843
79882
|
async function sha1OfFile(path) {
|
|
79844
|
-
const hash2 = (0,
|
|
79845
|
-
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);
|
|
79846
79885
|
return hash2.digest("hex").toUpperCase();
|
|
79847
79886
|
}
|
|
79848
79887
|
async function downloadPackage(asset) {
|
|
79849
79888
|
if (!NUPKG_NAME.test(asset.FileName)) throw new Error(`refusing suspicious package name: ${asset.FileName}`);
|
|
79850
79889
|
const want = asset.SHA1.toUpperCase();
|
|
79851
79890
|
const dir = packagesDir();
|
|
79852
|
-
(0,
|
|
79891
|
+
(0, import_node_fs56.mkdirSync)(dir, { recursive: true });
|
|
79853
79892
|
const dest = (0, import_node_path50.join)(dir, asset.FileName);
|
|
79854
|
-
if ((0,
|
|
79893
|
+
if ((0, import_node_fs56.existsSync)(dest) && await sha1OfFile(dest) === want) return dest;
|
|
79855
79894
|
const res = await authedFetch(`${feedUrl()}/${encodeURIComponent(asset.FileName)}`, {
|
|
79856
79895
|
redirect: "follow",
|
|
79857
79896
|
signal: AbortSignal.timeout(DOWNLOAD_TIMEOUT_MS)
|
|
79858
79897
|
});
|
|
79859
79898
|
if (!res.ok || !res.body) throw new Error(`download failed: HTTP ${res.status} for ${asset.FileName}`);
|
|
79860
|
-
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));
|
|
79861
79900
|
const got = await sha1OfFile(dest);
|
|
79862
79901
|
if (got !== want) throw new Error(`SHA1 mismatch for ${asset.FileName}: feed=${want} got=${got}`);
|
|
79863
79902
|
return dest;
|
|
@@ -79866,7 +79905,7 @@ async function applyUpdate(check, opts) {
|
|
|
79866
79905
|
if (!check.supported) return { applied: false, message: check.reason ?? "auto-update not supported in this runtime" };
|
|
79867
79906
|
if (!check.updateAvailable || !check.asset) return { applied: false, message: check.reason ?? "no update available" };
|
|
79868
79907
|
const exe = updateExePath();
|
|
79869
|
-
if (!(0,
|
|
79908
|
+
if (!(0, import_node_fs56.existsSync)(exe)) {
|
|
79870
79909
|
return { applied: false, message: `Update.exe not found at ${exe} \u2014 is this a Velopack install?` };
|
|
79871
79910
|
}
|
|
79872
79911
|
const pkg = await downloadPackage(check.asset);
|
|
@@ -80108,7 +80147,7 @@ function isTraceCorrupt(events) {
|
|
|
80108
80147
|
var import_node_child_process9 = require("node:child_process");
|
|
80109
80148
|
var import_node_path51 = require("node:path");
|
|
80110
80149
|
var import_node_url3 = require("node:url");
|
|
80111
|
-
var
|
|
80150
|
+
var import_node_fs57 = require("node:fs");
|
|
80112
80151
|
var import_node_http = __toESM(require("node:http"), 1);
|
|
80113
80152
|
var import_node_readline = require("node:readline");
|
|
80114
80153
|
var __dirname2 = (0, import_node_path51.dirname)((0, import_node_url3.fileURLToPath)(__import_meta_url));
|
|
@@ -80190,7 +80229,7 @@ function resolveServerStart() {
|
|
|
80190
80229
|
const packaged = /flolessapp\.exe$/i.test(process.execPath);
|
|
80191
80230
|
if (packaged) return { cmd: process.execPath, args: ["--serve"], shell: false };
|
|
80192
80231
|
const bundle = (0, import_node_path51.join)(__dirname2, "dist", "floless-server.cjs");
|
|
80193
|
-
if ((0,
|
|
80232
|
+
if ((0, import_node_fs57.existsSync)(bundle)) return { cmd: process.execPath, args: [bundle, "--serve"], shell: false };
|
|
80194
80233
|
return { cmd: "npm", args: ["run", "start"], shell: isWin2 };
|
|
80195
80234
|
}
|
|
80196
80235
|
function startServerDetached() {
|
|
@@ -80525,7 +80564,7 @@ if (entry === "launch.mjs") {
|
|
|
80525
80564
|
|
|
80526
80565
|
// aware-update.ts
|
|
80527
80566
|
var import_promises5 = require("node:fs/promises");
|
|
80528
|
-
var
|
|
80567
|
+
var import_node_crypto31 = require("node:crypto");
|
|
80529
80568
|
var import_node_path52 = require("node:path");
|
|
80530
80569
|
var REGISTRY_LATEST = "https://registry.npmjs.org/@aware-aeco/cli/latest";
|
|
80531
80570
|
var FEED_TIMEOUT_MS2 = 15e3;
|
|
@@ -80665,7 +80704,7 @@ function validateMarker(value) {
|
|
|
80665
80704
|
function createMaintenanceMarkerStore(markerPath2, options = {}) {
|
|
80666
80705
|
const io = options.io ?? nodeMarkerIo;
|
|
80667
80706
|
const maxBytes = Math.min(options.maxBytes ?? MARKER_MAX_BYTES, MARKER_MAX_BYTES);
|
|
80668
|
-
const randomId = options.randomId ??
|
|
80707
|
+
const randomId = options.randomId ?? import_node_crypto31.randomUUID;
|
|
80669
80708
|
const directory = (0, import_node_path52.dirname)(markerPath2);
|
|
80670
80709
|
return {
|
|
80671
80710
|
async read() {
|
|
@@ -80723,7 +80762,7 @@ function validatePending(value) {
|
|
|
80723
80762
|
}
|
|
80724
80763
|
function createBridgePendingStore(pendingPath, options = {}) {
|
|
80725
80764
|
const io = options.io ?? nodeMarkerIo;
|
|
80726
|
-
const randomId = options.randomId ??
|
|
80765
|
+
const randomId = options.randomId ?? import_node_crypto31.randomUUID;
|
|
80727
80766
|
const directory = (0, import_node_path52.dirname)(pendingPath);
|
|
80728
80767
|
return {
|
|
80729
80768
|
async read() {
|
|
@@ -80783,7 +80822,7 @@ function decideRecoveryTarget(input) {
|
|
|
80783
80822
|
}
|
|
80784
80823
|
function compareExactAwareVersions(a, b) {
|
|
80785
80824
|
if (a === b) return 0;
|
|
80786
|
-
return
|
|
80825
|
+
return versionGt(a, b) ? 1 : -1;
|
|
80787
80826
|
}
|
|
80788
80827
|
function sanitizeAwareError(error, fallbackCode = "operation-failed") {
|
|
80789
80828
|
const raw = error instanceof Error ? error.message : String(error);
|
|
@@ -80804,15 +80843,6 @@ function awareInstalledVersion(probe = aware.npmVersion) {
|
|
|
80804
80843
|
function invalidateAwareVersion() {
|
|
80805
80844
|
_v = null;
|
|
80806
80845
|
}
|
|
80807
|
-
function versionGt2(a, b) {
|
|
80808
|
-
const pa = a.split(".").map((n) => parseInt(n, 10) || 0);
|
|
80809
|
-
const pb = b.split(".").map((n) => parseInt(n, 10) || 0);
|
|
80810
|
-
for (let i = 0; i < Math.max(pa.length, pb.length); i++) {
|
|
80811
|
-
const d = (pa[i] ?? 0) - (pb[i] ?? 0);
|
|
80812
|
-
if (d !== 0) return d > 0;
|
|
80813
|
-
}
|
|
80814
|
-
return false;
|
|
80815
|
-
}
|
|
80816
80846
|
function decideAwareUpdate(cur, latest) {
|
|
80817
80847
|
const base = {
|
|
80818
80848
|
supported: true,
|
|
@@ -80822,7 +80852,7 @@ function decideAwareUpdate(cur, latest) {
|
|
|
80822
80852
|
};
|
|
80823
80853
|
if (!latest) return { ...base, updateAvailable: false, reason: "could not read the npm registry latest" };
|
|
80824
80854
|
if (!cur) return { ...base, updateAvailable: false, targetVersion: latest, reason: "AWARE not installed yet" };
|
|
80825
|
-
if (
|
|
80855
|
+
if (versionGt(latest, cur)) return { ...base, updateAvailable: true, targetVersion: latest, operation: "runtime-update" };
|
|
80826
80856
|
return { ...base, updateAvailable: false, targetVersion: latest, reason: `already up to date (v${cur})` };
|
|
80827
80857
|
}
|
|
80828
80858
|
async function inspectPersistentBridgeInventory(bridgeDirectory, target) {
|
|
@@ -81811,7 +81841,7 @@ function registerAwareUpdateRoutes(app, manager) {
|
|
|
81811
81841
|
}
|
|
81812
81842
|
|
|
81813
81843
|
// skill-sync.ts
|
|
81814
|
-
var
|
|
81844
|
+
var import_node_fs58 = require("node:fs");
|
|
81815
81845
|
var import_node_os27 = require("node:os");
|
|
81816
81846
|
var import_node_path54 = require("node:path");
|
|
81817
81847
|
var import_node_url4 = require("node:url");
|
|
@@ -81867,7 +81897,7 @@ function bundledSkillsRoot() {
|
|
|
81867
81897
|
(0, import_node_path54.join)((0, import_node_path54.dirname)(process.execPath), "skills"),
|
|
81868
81898
|
(0, import_node_path54.join)(__dirname3, "..", ".claude", "skills")
|
|
81869
81899
|
];
|
|
81870
|
-
return candidates.find((p) => (0,
|
|
81900
|
+
return candidates.find((p) => (0, import_node_fs58.existsSync)(p)) ?? null;
|
|
81871
81901
|
}
|
|
81872
81902
|
function targetConfigDirs() {
|
|
81873
81903
|
const override = process.env.FLOLESS_SKILL_TARGETS;
|
|
@@ -81883,7 +81913,7 @@ function targetConfigDirs() {
|
|
|
81883
81913
|
}
|
|
81884
81914
|
function skillVersion(skillMdPath) {
|
|
81885
81915
|
try {
|
|
81886
|
-
const text3 = (0,
|
|
81916
|
+
const text3 = (0, import_node_fs58.readFileSync)(skillMdPath, "utf8");
|
|
81887
81917
|
const m = /^---\r?\n([\s\S]*?)\r?\n---/.exec(text3);
|
|
81888
81918
|
if (!m || m[1] === void 0) return null;
|
|
81889
81919
|
const fm = (0, import_yaml11.parse)(m[1]);
|
|
@@ -81923,7 +81953,7 @@ function decideAction(installed, bundled) {
|
|
|
81923
81953
|
function bundledSkills(root5) {
|
|
81924
81954
|
let entries2 = [];
|
|
81925
81955
|
try {
|
|
81926
|
-
entries2 = selectShippedSkillNames((0,
|
|
81956
|
+
entries2 = selectShippedSkillNames((0, import_node_fs58.readdirSync)(root5));
|
|
81927
81957
|
} catch {
|
|
81928
81958
|
return [];
|
|
81929
81959
|
}
|
|
@@ -81932,7 +81962,7 @@ function bundledSkills(root5) {
|
|
|
81932
81962
|
const dir = (0, import_node_path54.join)(root5, name);
|
|
81933
81963
|
let isDir = false;
|
|
81934
81964
|
try {
|
|
81935
|
-
isDir = (0,
|
|
81965
|
+
isDir = (0, import_node_fs58.statSync)(dir).isDirectory();
|
|
81936
81966
|
} catch {
|
|
81937
81967
|
isDir = false;
|
|
81938
81968
|
}
|
|
@@ -81950,17 +81980,17 @@ function syncSkills() {
|
|
|
81950
81980
|
const skills = bundledSkills(root5);
|
|
81951
81981
|
if (!skills.length) return results;
|
|
81952
81982
|
for (const { runtime, dir: cfg } of targetConfigDirs()) {
|
|
81953
|
-
if (!(0,
|
|
81983
|
+
if (!(0, import_node_fs58.existsSync)(cfg)) continue;
|
|
81954
81984
|
const skillsDir = (0, import_node_path54.join)(cfg, "skills");
|
|
81955
81985
|
for (const s of skills) {
|
|
81956
81986
|
const dest = (0, import_node_path54.join)(skillsDir, s.name);
|
|
81957
81987
|
const installedMd = (0, import_node_path54.join)(dest, "SKILL.md");
|
|
81958
|
-
const installed = (0,
|
|
81988
|
+
const installed = (0, import_node_fs58.existsSync)(installedMd) ? skillVersion(installedMd) : null;
|
|
81959
81989
|
const action = decideAction(installed, s.version);
|
|
81960
81990
|
if (action === "installed" || action === "updated") {
|
|
81961
81991
|
try {
|
|
81962
|
-
if (action === "updated") (0,
|
|
81963
|
-
(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 });
|
|
81964
81994
|
results.push({ runtime, skill: s.name, action, from: installed, to: s.version });
|
|
81965
81995
|
} catch {
|
|
81966
81996
|
}
|
|
@@ -81975,7 +82005,7 @@ function syncSkills() {
|
|
|
81975
82005
|
// watch.ts
|
|
81976
82006
|
var import_node_os28 = require("node:os");
|
|
81977
82007
|
var import_node_path56 = require("node:path");
|
|
81978
|
-
var
|
|
82008
|
+
var import_node_fs59 = require("node:fs");
|
|
81979
82009
|
|
|
81980
82010
|
// node_modules/chokidar/esm/index.js
|
|
81981
82011
|
var import_fs2 = require("fs");
|
|
@@ -83688,20 +83718,20 @@ function underDir(path, dir) {
|
|
|
83688
83718
|
function startWatcher() {
|
|
83689
83719
|
const awareDir = process.env.AWARE_HOME ?? (0, import_node_path56.join)((0, import_node_os28.homedir)(), ".aware");
|
|
83690
83720
|
const credentialsDir = (0, import_node_path56.join)(awareDir, "credentials");
|
|
83691
|
-
if (!(0,
|
|
83721
|
+
if (!(0, import_node_fs59.existsSync)(credentialsDir)) {
|
|
83692
83722
|
try {
|
|
83693
|
-
(0,
|
|
83723
|
+
(0, import_node_fs59.mkdirSync)(credentialsDir, { recursive: true });
|
|
83694
83724
|
} catch {
|
|
83695
83725
|
}
|
|
83696
83726
|
}
|
|
83697
|
-
if (!(0,
|
|
83727
|
+
if (!(0, import_node_fs59.existsSync)(uiDir)) {
|
|
83698
83728
|
try {
|
|
83699
|
-
(0,
|
|
83729
|
+
(0, import_node_fs59.mkdirSync)(uiDir, { recursive: true });
|
|
83700
83730
|
} catch {
|
|
83701
83731
|
}
|
|
83702
83732
|
}
|
|
83703
|
-
const targets = ["apps", "logs", "credentials"].map((d) => (0, import_node_path56.join)(awareDir, d)).filter((p) => (0,
|
|
83704
|
-
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);
|
|
83705
83735
|
if (targets.length === 0) {
|
|
83706
83736
|
return null;
|
|
83707
83737
|
}
|
|
@@ -83730,11 +83760,11 @@ function startWatcher() {
|
|
|
83730
83760
|
const isCredential = path.split(/[\\/]/).includes("credentials");
|
|
83731
83761
|
const kind = isCredential ? "credential" : path.endsWith(".jsonl") ? "trace" : path.endsWith(".lock") ? "lock" : path.endsWith(".flo") || path.endsWith(".app") ? "source" : "file";
|
|
83732
83762
|
broadcast({ type: "fs-change", kind, event, path });
|
|
83733
|
-
if (kind === "trace" && event !== "unlink" && (0,
|
|
83763
|
+
if (kind === "trace" && event !== "unlink" && (0, import_node_fs59.existsSync)(path)) {
|
|
83734
83764
|
const id = appIdFromLogPath(path);
|
|
83735
83765
|
if (!id) return;
|
|
83736
83766
|
try {
|
|
83737
|
-
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")) });
|
|
83738
83768
|
} catch {
|
|
83739
83769
|
}
|
|
83740
83770
|
}
|
|
@@ -83745,7 +83775,7 @@ function startWatcher() {
|
|
|
83745
83775
|
// index.ts
|
|
83746
83776
|
var __dirname4 = (0, import_node_path57.dirname)((0, import_node_url5.fileURLToPath)(__import_meta_url));
|
|
83747
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(
|
|
83748
|
-
(p) => (0,
|
|
83778
|
+
(p) => (0, import_node_fs60.existsSync)(p)
|
|
83749
83779
|
) ?? (0, import_node_path57.join)(__dirname4, "..", "web");
|
|
83750
83780
|
var PORT2 = Number(process.env.PORT ?? 4317);
|
|
83751
83781
|
var HOST = "127.0.0.1";
|
|
@@ -83762,7 +83792,7 @@ function installCrashHandlers() {
|
|
|
83762
83792
|
${stack}
|
|
83763
83793
|
`;
|
|
83764
83794
|
try {
|
|
83765
|
-
(0,
|
|
83795
|
+
(0, import_node_fs60.appendFileSync)(logFilePath(), line);
|
|
83766
83796
|
} catch {
|
|
83767
83797
|
}
|
|
83768
83798
|
if (process.stderr.isTTY) process.stderr.write(line);
|
|
@@ -83981,7 +84011,7 @@ async function startServer() {
|
|
|
83981
84011
|
let snapshot = Object.freeze(AWARE_BRIDGE_HOSTS.filter((host) => (marker?.snapshot ?? []).includes(host) || observedHosts.includes(host) || durable?.target === target && durable.hosts.includes(host)));
|
|
83982
84012
|
let recoveryMarker = {
|
|
83983
84013
|
schema: 2,
|
|
83984
|
-
transaction: marker?.transaction ?? (0,
|
|
84014
|
+
transaction: marker?.transaction ?? (0, import_node_crypto32.randomUUID)(),
|
|
83985
84015
|
stage: "recovery",
|
|
83986
84016
|
target,
|
|
83987
84017
|
snapshot,
|
|
@@ -84412,10 +84442,10 @@ async function startServer() {
|
|
|
84412
84442
|
const bdir = backupDir(id, fromVersion, Date.now());
|
|
84413
84443
|
let backedUp = false;
|
|
84414
84444
|
try {
|
|
84415
|
-
(0,
|
|
84416
|
-
(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 });
|
|
84417
84447
|
backedUp = true;
|
|
84418
|
-
(0,
|
|
84448
|
+
(0, import_node_fs60.cpSync)(templatePath, srcPath);
|
|
84419
84449
|
if (id !== templateId) stampSourceAppId(srcPath, id);
|
|
84420
84450
|
if (contract != null) {
|
|
84421
84451
|
bakeContractIntoApp(srcPath, contract);
|
|
@@ -84429,8 +84459,8 @@ async function startServer() {
|
|
|
84429
84459
|
throw new TemplateSwapError(`${verb} failed before any change was made (${msg}) \u2014 the workflow is untouched`, `${verb}-not-started`);
|
|
84430
84460
|
}
|
|
84431
84461
|
try {
|
|
84432
|
-
(0,
|
|
84433
|
-
(0,
|
|
84462
|
+
(0, import_node_fs60.rmSync)(appDirPath2, { recursive: true, force: true });
|
|
84463
|
+
(0, import_node_fs60.cpSync)(bdir, appDirPath2, { recursive: true });
|
|
84434
84464
|
} catch (re) {
|
|
84435
84465
|
const rmsg = re instanceof Error ? re.message : String(re);
|
|
84436
84466
|
throw new TemplateSwapError(`${verb} failed (${msg}) AND rollback failed (${rmsg}) \u2014 restore manually from ${bdir}`, "rollback-failed", bdir);
|
|
@@ -84442,7 +84472,7 @@ async function startServer() {
|
|
|
84442
84472
|
function readSwapContract(id, verb) {
|
|
84443
84473
|
const gerund = verb === "update" ? "updating" : "restoring";
|
|
84444
84474
|
const contract = readAcceptedForRequest(id, void 0);
|
|
84445
|
-
if (contract == null && (0,
|
|
84475
|
+
if (contract == null && (0, import_node_fs60.existsSync)(contractPath(id))) {
|
|
84446
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" } };
|
|
84447
84477
|
}
|
|
84448
84478
|
if (contract != null && !validateContract(contract).valid) {
|
|
@@ -84742,7 +84772,7 @@ async function startServer() {
|
|
|
84742
84772
|
}
|
|
84743
84773
|
let data;
|
|
84744
84774
|
try {
|
|
84745
|
-
data = (0,
|
|
84775
|
+
data = (0, import_node_fs60.readFileSync)(thumb.path);
|
|
84746
84776
|
} catch {
|
|
84747
84777
|
return reply.status(404).send({ ok: false, error: "no thumbnail" });
|
|
84748
84778
|
}
|
|
@@ -85262,8 +85292,8 @@ async function startServer() {
|
|
|
85262
85292
|
if (bad) return reply.status(404).send({ ok: false, error: bad });
|
|
85263
85293
|
const safe2 = req.params.sheet.replace(/[^A-Za-z0-9._-]/g, "");
|
|
85264
85294
|
const file = (0, import_node_path57.join)((0, import_node_path57.dirname)(contractPath(req.params.appId, project)), "details", `${safe2}.svg`);
|
|
85265
|
-
if (!(0,
|
|
85266
|
-
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"));
|
|
85267
85297
|
}
|
|
85268
85298
|
);
|
|
85269
85299
|
app.put(
|
|
@@ -85749,7 +85779,7 @@ async function startServer() {
|
|
|
85749
85779
|
}
|
|
85750
85780
|
const statedAt = (filename) => {
|
|
85751
85781
|
try {
|
|
85752
|
-
const st = (0,
|
|
85782
|
+
const st = (0, import_node_fs60.statSync)((0, import_node_path57.join)(dir, filename));
|
|
85753
85783
|
return st.isFile() ? st.mtime.toISOString() : null;
|
|
85754
85784
|
} catch {
|
|
85755
85785
|
return null;
|
|
@@ -85868,7 +85898,7 @@ async function startServer() {
|
|
|
85868
85898
|
}
|
|
85869
85899
|
async function dropExportSourceId(appId, project) {
|
|
85870
85900
|
const ownerId = project ? await getOrCreateProjectExportSourceId(project) : await getOrCreateWorkflowExportSourceId(appId);
|
|
85871
|
-
return deriveDropExportSourceId(project ? "project" : "workflow", ownerId, (0,
|
|
85901
|
+
return deriveDropExportSourceId(project ? "project" : "workflow", ownerId, (0, import_node_crypto32.randomUUID)());
|
|
85872
85902
|
}
|
|
85873
85903
|
function explicitExportSourceSuffix(input) {
|
|
85874
85904
|
if (input.kind !== "project" || !input.snapshot.source) return "";
|
|
@@ -85921,15 +85951,15 @@ async function startServer() {
|
|
|
85921
85951
|
scene,
|
|
85922
85952
|
"output-path": tempPath
|
|
85923
85953
|
});
|
|
85924
|
-
if (!(0,
|
|
85954
|
+
if (!(0, import_node_fs60.existsSync)(tempPath) || (0, import_node_fs60.statSync)(tempPath).size === 0) {
|
|
85925
85955
|
throw new ReceiptReconciliationError("AWARE reported a successful export but wrote no IFC file.");
|
|
85926
85956
|
}
|
|
85927
|
-
const artifactBytes = (0,
|
|
85957
|
+
const artifactBytes = (0, import_node_fs60.readFileSync)(tempPath);
|
|
85928
85958
|
const receipt = reconcileIfcExportReceipt(scene, rawReceipt, producerUnsupported, {
|
|
85929
85959
|
index: parseStepData(artifactBytes),
|
|
85930
85960
|
bytes: artifactBytes
|
|
85931
85961
|
});
|
|
85932
|
-
const expectedContentSha256 = (0,
|
|
85962
|
+
const expectedContentSha256 = (0, import_node_crypto32.createHash)("sha256").update(artifactBytes).digest("hex");
|
|
85933
85963
|
const transition = project && projectSnapshot && projectSnapshot.version.n !== null ? prepareProjectExport(project, {
|
|
85934
85964
|
kind: "ifc",
|
|
85935
85965
|
filename,
|
|
@@ -85980,7 +86010,7 @@ async function startServer() {
|
|
|
85980
86010
|
ok: false,
|
|
85981
86011
|
error: awareFailureMessage(error, "IFC export failed"),
|
|
85982
86012
|
...reason ? { reason } : {},
|
|
85983
|
-
preservedPrevious: project && priorProjectIfc ? receiptHasFile(project, priorProjectIfc) : (0,
|
|
86013
|
+
preservedPrevious: project && priorProjectIfc ? receiptHasFile(project, priorProjectIfc) : (0, import_node_fs60.existsSync)(finalPath)
|
|
85984
86014
|
});
|
|
85985
86015
|
} finally {
|
|
85986
86016
|
cleanupIfcTemp(tempPath);
|
|
@@ -86024,10 +86054,10 @@ async function startServer() {
|
|
|
86024
86054
|
const receipt = wanted ? stills.find((row) => row.variant === wanted) : [...stills].sort((a, b) => b.exportedAt.localeCompare(a.exportedAt))[0];
|
|
86025
86055
|
if (!receipt) return reply.status(404).send({ ok: false, error: "nothing rendered yet" });
|
|
86026
86056
|
const path = resolveProjectExportReceiptPath(project, receipt);
|
|
86027
|
-
if (!path || !(0,
|
|
86057
|
+
if (!path || !(0, import_node_fs60.existsSync)(path)) {
|
|
86028
86058
|
return reply.status(404).send({ ok: false, error: "the rendered image is no longer on disk" });
|
|
86029
86059
|
}
|
|
86030
|
-
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));
|
|
86031
86061
|
});
|
|
86032
86062
|
const RENDER_VIEWPOINTS = /* @__PURE__ */ new Set(["hero", "iso", "front", "back", "left", "right", "top"]);
|
|
86033
86063
|
app.post("/api/contract/:appId/render", async (req, reply) => {
|
|
@@ -86087,7 +86117,7 @@ async function startServer() {
|
|
|
86087
86117
|
}
|
|
86088
86118
|
const kind = output === "turntable" ? "render-mp4" : "render-png";
|
|
86089
86119
|
const extension = output === "turntable" ? ".mp4" : ".png";
|
|
86090
|
-
const scratch = (0,
|
|
86120
|
+
const scratch = (0, import_node_fs60.mkdtempSync)((0, import_node_path57.join)((0, import_node_os29.tmpdir)(), "floless-render-"));
|
|
86091
86121
|
const ifcPath = (0, import_node_path57.join)(scratch, "model.ifc");
|
|
86092
86122
|
const rendered = [];
|
|
86093
86123
|
const progress = (stage, extra = {}) => {
|
|
@@ -86099,7 +86129,7 @@ async function startServer() {
|
|
|
86099
86129
|
try {
|
|
86100
86130
|
progress("preparing");
|
|
86101
86131
|
await aware.agentInvoke("ifc", "write", { scene: built.scene, "output-path": ifcPath });
|
|
86102
|
-
if (!(0,
|
|
86132
|
+
if (!(0, import_node_fs60.existsSync)(ifcPath) || (0, import_node_fs60.statSync)(ifcPath).size === 0) {
|
|
86103
86133
|
throw new Error("AWARE reported a successful IFC write but produced no file to render");
|
|
86104
86134
|
}
|
|
86105
86135
|
const renderBudgetMs = output === "turntable" ? 30 * 6e4 : 10 * 6e4;
|
|
@@ -86117,10 +86147,10 @@ async function startServer() {
|
|
|
86117
86147
|
environment: "studio",
|
|
86118
86148
|
...output === "turntable" ? { "duration-seconds": 12, fps: 24, "width-pixels": 1280, "height-pixels": 720 } : { quality, "width-pixels": 1920, "height-pixels": 1080 }
|
|
86119
86149
|
}, { timeoutMs: renderBudgetMs });
|
|
86120
|
-
if (!(0,
|
|
86150
|
+
if (!(0, import_node_fs60.existsSync)(artifactPath) || (0, import_node_fs60.statSync)(artifactPath).size === 0) {
|
|
86121
86151
|
throw new Error(`the ${viewpoint} render reported success but produced no image`);
|
|
86122
86152
|
}
|
|
86123
|
-
const bytes = (0,
|
|
86153
|
+
const bytes = (0, import_node_fs60.readFileSync)(artifactPath);
|
|
86124
86154
|
const sourceSuffix = "source" in projectSnapshot && projectSnapshot.source ? `-${projectSnapshot.source.filenameLabel.replace(/[^A-Za-z0-9._-]+/g, "-")}` : "";
|
|
86125
86155
|
const preferred = `${exportFileBase(project, appId)}-${viewpoint}${sourceSuffix}${extension}`;
|
|
86126
86156
|
const filename = uniqueProjectExportFilename(project, preferred);
|
|
@@ -86176,7 +86206,7 @@ async function startServer() {
|
|
|
86176
86206
|
rendered
|
|
86177
86207
|
});
|
|
86178
86208
|
} finally {
|
|
86179
|
-
(0,
|
|
86209
|
+
(0, import_node_fs60.rmSync)(scratch, { recursive: true, force: true });
|
|
86180
86210
|
}
|
|
86181
86211
|
}, {
|
|
86182
86212
|
// What anyone blocked on this project is told, and for how long to expect it. Erring long
|
|
@@ -86417,7 +86447,7 @@ async function startServer() {
|
|
|
86417
86447
|
const outPath = project ? (0, import_node_path57.join)(projectExportsDir(project), filename) : bomExportPath(appId, format);
|
|
86418
86448
|
const dir = (0, import_node_path57.dirname)(outPath);
|
|
86419
86449
|
try {
|
|
86420
|
-
(0,
|
|
86450
|
+
(0, import_node_fs60.mkdirSync)(dir, { recursive: true });
|
|
86421
86451
|
const kind = BOM_EXPORT_KIND[format];
|
|
86422
86452
|
let text3 = null;
|
|
86423
86453
|
let buf;
|
|
@@ -86445,8 +86475,8 @@ async function startServer() {
|
|
|
86445
86475
|
sourceKind: projectSnapshot.source?.kind ?? "approved",
|
|
86446
86476
|
contractHash: projectSnapshot.contractHash
|
|
86447
86477
|
}, buf);
|
|
86448
|
-
} else if (text3 != null) (0,
|
|
86449
|
-
else (0,
|
|
86478
|
+
} else if (text3 != null) (0, import_node_fs60.writeFileSync)(outPath, text3, "utf8");
|
|
86479
|
+
else (0, import_node_fs60.writeFileSync)(outPath, buf);
|
|
86450
86480
|
return {
|
|
86451
86481
|
ok: true,
|
|
86452
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 }
|
|
@@ -86486,7 +86516,7 @@ async function startServer() {
|
|
|
86486
86516
|
const filename = project ? uniqueProjectExportFilename(project, preferredFilename) : preferredFilename;
|
|
86487
86517
|
const outPath = project ? (0, import_node_path57.join)(projectExportsDir(project), filename) : (0, import_node_path57.join)(appPath(appId), filename);
|
|
86488
86518
|
try {
|
|
86489
|
-
(0,
|
|
86519
|
+
(0, import_node_fs60.mkdirSync)((0, import_node_path57.dirname)(outPath), { recursive: true });
|
|
86490
86520
|
if (project && projectSnapshot) {
|
|
86491
86521
|
publishProjectExportArtifact(project, {
|
|
86492
86522
|
kind: "svg",
|
|
@@ -86497,7 +86527,7 @@ async function startServer() {
|
|
|
86497
86527
|
sourceKind: projectSnapshot.source?.kind ?? "approved",
|
|
86498
86528
|
contractHash: projectSnapshot.contractHash
|
|
86499
86529
|
}, Buffer.from(svg, "utf8"));
|
|
86500
|
-
} else (0,
|
|
86530
|
+
} else (0, import_node_fs60.writeFileSync)(outPath, svg, "utf8");
|
|
86501
86531
|
return { ok: true, filename, encoding: "utf8", content: svg, bytes: Buffer.byteLength(svg), savedTo: outPath };
|
|
86502
86532
|
} catch (e) {
|
|
86503
86533
|
app.log.error({ appId, err: e instanceof Error ? e.message : e }, "export-svg: write failed");
|
|
@@ -86679,11 +86709,11 @@ async function startServer() {
|
|
|
86679
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 });
|
|
86680
86710
|
}
|
|
86681
86711
|
await deleteOrigin(id);
|
|
86682
|
-
const stageRoot = (0,
|
|
86712
|
+
const stageRoot = (0, import_node_fs60.mkdtempSync)((0, import_node_path57.join)((0, import_node_os29.tmpdir)(), "floless-import-"));
|
|
86683
86713
|
try {
|
|
86684
86714
|
const stageDir = (0, import_node_path57.join)(stageRoot, id);
|
|
86685
|
-
(0,
|
|
86686
|
-
(0,
|
|
86715
|
+
(0, import_node_fs60.mkdirSync)(stageDir);
|
|
86716
|
+
(0, import_node_fs60.writeFileSync)((0, import_node_path57.join)(stageDir, `${id}.flo`), content);
|
|
86687
86717
|
await aware.install(stageDir);
|
|
86688
86718
|
} catch (err2) {
|
|
86689
86719
|
try {
|
|
@@ -86694,7 +86724,7 @@ async function startServer() {
|
|
|
86694
86724
|
const reason = awareStderr(err2);
|
|
86695
86725
|
return reply.status(502).send({ ok: false, error: `import failed: ${msg}`, code: "install-failed", reason, agentsUnavailable: unavailableAgents(reason) });
|
|
86696
86726
|
} finally {
|
|
86697
|
-
(0,
|
|
86727
|
+
(0, import_node_fs60.rmSync)(stageRoot, { recursive: true, force: true });
|
|
86698
86728
|
}
|
|
86699
86729
|
broadcast({ type: "apps-changed", id });
|
|
86700
86730
|
return { ok: true, id };
|
|
@@ -86710,13 +86740,13 @@ async function startServer() {
|
|
|
86710
86740
|
}
|
|
86711
86741
|
const inputs = appData.inputs.map((i) => ({ name: i.name, type: i.type }));
|
|
86712
86742
|
const baked = bakeFloSource(appData.source.text, inputs);
|
|
86713
|
-
const tmpRoot = (0,
|
|
86743
|
+
const tmpRoot = (0, import_node_fs60.mkdtempSync)((0, import_node_path57.join)((0, import_node_os29.tmpdir)(), "floless-bake-"));
|
|
86714
86744
|
const backupDir2 = (0, import_node_path57.join)(tmpRoot, `${id}-backup`);
|
|
86715
86745
|
const bakeDir = (0, import_node_path57.join)(tmpRoot, id);
|
|
86716
|
-
(0,
|
|
86717
|
-
(0,
|
|
86746
|
+
(0, import_node_fs60.cpSync)(appDir(id), backupDir2, { recursive: true });
|
|
86747
|
+
(0, import_node_fs60.cpSync)(appDir(id), bakeDir, { recursive: true });
|
|
86718
86748
|
const floName = appData.source.path.split(/[\\/]/).pop();
|
|
86719
|
-
(0,
|
|
86749
|
+
(0, import_node_fs60.writeFileSync)((0, import_node_path57.join)(bakeDir, floName), baked);
|
|
86720
86750
|
let appInstalled2 = true;
|
|
86721
86751
|
try {
|
|
86722
86752
|
await aware.uninstall(id);
|
|
@@ -86745,7 +86775,7 @@ async function startServer() {
|
|
|
86745
86775
|
broadcast({ type: "baked", id });
|
|
86746
86776
|
return { ok: true, id, agent: id, inputs };
|
|
86747
86777
|
} finally {
|
|
86748
|
-
if (appInstalled2) (0,
|
|
86778
|
+
if (appInstalled2) (0, import_node_fs60.rmSync)(tmpRoot, { recursive: true, force: true });
|
|
86749
86779
|
}
|
|
86750
86780
|
});
|
|
86751
86781
|
});
|
|
@@ -86766,7 +86796,7 @@ async function startServer() {
|
|
|
86766
86796
|
if (!sourceKind || !sourceRef) {
|
|
86767
86797
|
return reply.status(400).send({ ok: false, error: "sourceKind and sourceRef required" });
|
|
86768
86798
|
}
|
|
86769
|
-
const tempHome = (0,
|
|
86799
|
+
const tempHome = (0, import_node_fs60.mkdtempSync)((0, import_node_path57.join)((0, import_node_os29.tmpdir)(), "floless-graft-"));
|
|
86770
86800
|
let result;
|
|
86771
86801
|
try {
|
|
86772
86802
|
result = await aware.build({
|
|
@@ -86779,19 +86809,19 @@ async function startServer() {
|
|
|
86779
86809
|
awareHome: tempHome
|
|
86780
86810
|
});
|
|
86781
86811
|
} catch (err2) {
|
|
86782
|
-
(0,
|
|
86812
|
+
(0, import_node_fs60.rmSync)(tempHome, { recursive: true, force: true });
|
|
86783
86813
|
const msg = err2 instanceof AwareError ? err2.message : String(err2?.message ?? err2);
|
|
86784
86814
|
return reply.status(422).send({ ok: false, error: msg });
|
|
86785
86815
|
}
|
|
86786
86816
|
const manifest = readStagedManifest(result.agentDir);
|
|
86787
86817
|
if (!manifest) {
|
|
86788
|
-
(0,
|
|
86818
|
+
(0, import_node_fs60.rmSync)(tempHome, { recursive: true, force: true });
|
|
86789
86819
|
return reply.status(502).send({ ok: false, error: `build produced output at ${result.agentDir} but no manifest.yaml` });
|
|
86790
86820
|
}
|
|
86791
|
-
const token2 = (0,
|
|
86821
|
+
const token2 = (0, import_node_crypto32.randomUUID)();
|
|
86792
86822
|
registerStage(token2, tempHome, result.agentId);
|
|
86793
86823
|
const preview2 = buildPreview(manifest, sourceKind, sourceRef, token2);
|
|
86794
|
-
if ((0,
|
|
86824
|
+
if ((0, import_node_fs60.existsSync)((0, import_node_path57.join)(graftAgentsDir(), result.agentId))) {
|
|
86795
86825
|
preview2.warnings.unshift(`An agent named "${result.agentId}" is already installed \u2014 creating it will overwrite it.`);
|
|
86796
86826
|
}
|
|
86797
86827
|
return { ok: true, preview: preview2 };
|
|
@@ -86810,7 +86840,7 @@ async function startServer() {
|
|
|
86810
86840
|
registerStage(stagedRef, stage.tempDir, stage.agentId);
|
|
86811
86841
|
return reply.status(409).send({ ok: false, error: err2.message, agentId: stage.agentId, collision: true });
|
|
86812
86842
|
}
|
|
86813
|
-
(0,
|
|
86843
|
+
(0, import_node_fs60.rmSync)(stage.tempDir, { recursive: true, force: true });
|
|
86814
86844
|
throw err2;
|
|
86815
86845
|
}
|
|
86816
86846
|
broadcast({ type: "grafted", id: stage.agentId });
|
|
@@ -87131,11 +87161,11 @@ async function startServer() {
|
|
|
87131
87161
|
app.get("/api/requests/:id/snapshot/:n", async (req, reply) => {
|
|
87132
87162
|
const n = Number.parseInt(req.params.n, 10);
|
|
87133
87163
|
const p = Number.isInteger(n) ? snapshotPathFor(req.params.id, n) : null;
|
|
87134
|
-
if (!p || !(0,
|
|
87164
|
+
if (!p || !(0, import_node_fs60.existsSync)(p)) return reply.status(404).send({ ok: false, error: "snapshot not found" });
|
|
87135
87165
|
const ext = p.split(".").pop().toLowerCase();
|
|
87136
87166
|
reply.header("Content-Type", ext === "png" ? "image/png" : ext === "webp" ? "image/webp" : ext === "pdf" ? "application/pdf" : "image/jpeg");
|
|
87137
87167
|
reply.header("Cache-Control", "no-store");
|
|
87138
|
-
return (0,
|
|
87168
|
+
return (0, import_node_fs60.readFileSync)(p);
|
|
87139
87169
|
});
|
|
87140
87170
|
app.post(
|
|
87141
87171
|
"/api/tweak",
|
|
@@ -87370,7 +87400,7 @@ async function startServer() {
|
|
|
87370
87400
|
warn(`last-run-status:${ref} \u2014 trace exists but couldn't be parsed (corrupt/truncated)`);
|
|
87371
87401
|
let finishedAt2 = null;
|
|
87372
87402
|
try {
|
|
87373
|
-
finishedAt2 = (0,
|
|
87403
|
+
finishedAt2 = (0, import_node_fs60.statSync)(latest.path).mtime.toISOString();
|
|
87374
87404
|
} catch {
|
|
87375
87405
|
finishedAt2 = null;
|
|
87376
87406
|
}
|
|
@@ -87380,7 +87410,7 @@ async function startServer() {
|
|
|
87380
87410
|
let finishedAt = typeof runEnd?.ts === "string" ? runEnd.ts : null;
|
|
87381
87411
|
if (!finishedAt) {
|
|
87382
87412
|
try {
|
|
87383
|
-
finishedAt = (0,
|
|
87413
|
+
finishedAt = (0, import_node_fs60.statSync)(latest.path).mtime.toISOString();
|
|
87384
87414
|
} catch {
|
|
87385
87415
|
finishedAt = null;
|
|
87386
87416
|
}
|