@floless/app 0.123.1 → 0.124.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 +600 -317
- package/dist/schemas/steel.model.v2.schema.json +10 -0
- package/dist/skills/floless-app-approval/SKILL.md +7 -1
- package/dist/skills/floless-app-steel-takeoff/SKILL.md +21 -3
- package/dist/web/app.js +3 -3
- package/dist/web/aware.js +62 -10
- package/dist/web/index.html +2 -2
- package/dist/web/steel-3d-view.js +345 -14
- package/dist/web/steel-editor.html +1281 -34
- package/dist/web/steel-filter.html +64 -8
- package/dist/web/vector-editor.html +15 -1
- package/dist/web/workspaces.js +342 -4
- package/package.json +1 -1
package/dist/floless-server.cjs
CHANGED
|
@@ -6006,9 +6006,9 @@ var require_transport = __commonJS({
|
|
|
6006
6006
|
"node_modules/pino/lib/transport.js"(exports2, module2) {
|
|
6007
6007
|
"use strict";
|
|
6008
6008
|
var { createRequire: createRequire5 } = require("module");
|
|
6009
|
-
var { existsSync:
|
|
6009
|
+
var { existsSync: existsSync51 } = require("node:fs");
|
|
6010
6010
|
var getCallers = require_caller();
|
|
6011
|
-
var { join: join55, isAbsolute:
|
|
6011
|
+
var { join: join55, isAbsolute: isAbsolute5, sep: sep7 } = require("node:path");
|
|
6012
6012
|
var { fileURLToPath: fileURLToPath6 } = require("node:url");
|
|
6013
6013
|
var sleep2 = require_atomic_sleep();
|
|
6014
6014
|
var onExit = require_on_exit_leak_free();
|
|
@@ -6080,7 +6080,7 @@ var require_transport = __commonJS({
|
|
|
6080
6080
|
return false;
|
|
6081
6081
|
}
|
|
6082
6082
|
}
|
|
6083
|
-
return
|
|
6083
|
+
return isAbsolute5(path) && !existsSync51(path);
|
|
6084
6084
|
}
|
|
6085
6085
|
function stripQuotes(value) {
|
|
6086
6086
|
const first = value[0];
|
|
@@ -6198,7 +6198,7 @@ var require_transport = __commonJS({
|
|
|
6198
6198
|
return buildStream(fixTarget(target), options, worker, sync, name);
|
|
6199
6199
|
function fixTarget(origin) {
|
|
6200
6200
|
origin = bundlerOverrides[origin] || origin;
|
|
6201
|
-
if (
|
|
6201
|
+
if (isAbsolute5(origin) || origin.indexOf("file://") === 0) {
|
|
6202
6202
|
return origin;
|
|
6203
6203
|
}
|
|
6204
6204
|
if (origin === "pino/file") {
|
|
@@ -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_path59 = require("node:path");
|
|
50831
50831
|
var import_node_os29 = require("node:os");
|
|
50832
|
-
var
|
|
50832
|
+
var import_node_fs62 = require("node:fs");
|
|
50833
50833
|
var import_node_child_process12 = require("node:child_process");
|
|
50834
50834
|
var import_node_util5 = 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.124.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.124.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]
|
|
@@ -54942,6 +54942,9 @@ function walk(value, node, root5, path, errors) {
|
|
|
54942
54942
|
for (const r of node.required ?? []) {
|
|
54943
54943
|
if (!Object.hasOwn(value, r)) errors.push({ path: `${path}.${r}`, message: "required" });
|
|
54944
54944
|
}
|
|
54945
|
+
if (typeof node.minProperties === "number" && Object.keys(value).length < node.minProperties) {
|
|
54946
|
+
errors.push({ path, message: `expected at least ${node.minProperties} propert${node.minProperties === 1 ? "y" : "ies"}` });
|
|
54947
|
+
}
|
|
54945
54948
|
const props = node.properties ?? {};
|
|
54946
54949
|
const ap = node.additionalProperties;
|
|
54947
54950
|
for (const key of Object.keys(value)) {
|
|
@@ -57954,7 +57957,7 @@ async function chooseProjectExportPath(options, platform = process.platform, run
|
|
|
57954
57957
|
);
|
|
57955
57958
|
const selected = result.stdout.trim();
|
|
57956
57959
|
if (selected === CANCELLED) return null;
|
|
57957
|
-
if (!selected || !
|
|
57960
|
+
if (!selected || !import_node_path17.win32.isAbsolute(selected) || !/\.zip$/i.test(selected)) {
|
|
57958
57961
|
throw new Error("the Save dialog returned an invalid archive path");
|
|
57959
57962
|
}
|
|
57960
57963
|
return selected;
|
|
@@ -59926,6 +59929,21 @@ function decodeSnapshots(inputs) {
|
|
|
59926
59929
|
// connection-import.ts
|
|
59927
59930
|
var import_node_fs26 = require("node:fs");
|
|
59928
59931
|
var import_node_path25 = require("node:path");
|
|
59932
|
+
|
|
59933
|
+
// ifc-frame.ts
|
|
59934
|
+
var FILE_Z_UP = "z-up";
|
|
59935
|
+
var FILE_Y_UP = "y-up";
|
|
59936
|
+
function yUpToZUp(positions) {
|
|
59937
|
+
const out = new Array(positions.length);
|
|
59938
|
+
for (let i = 0; i + 2 < positions.length; i += 3) {
|
|
59939
|
+
out[i] = positions[i];
|
|
59940
|
+
out[i + 1] = -positions[i + 2];
|
|
59941
|
+
out[i + 2] = positions[i + 1];
|
|
59942
|
+
}
|
|
59943
|
+
return out;
|
|
59944
|
+
}
|
|
59945
|
+
|
|
59946
|
+
// connection-import.ts
|
|
59929
59947
|
var AGENT = "connection-reader";
|
|
59930
59948
|
var MAX_PARTS = 5e3;
|
|
59931
59949
|
var MAX_VERTICES = 3e6;
|
|
@@ -59951,7 +59969,21 @@ function writeReaderApp(companionId, command, ifcPath, id) {
|
|
|
59951
59969
|
`description: ${command === "list" ? "List the steel connections found in an IFC file \u2014 the candidates a user picks from before importing one." : "Read one steel connection from an IFC file as tessellated mesh geometry, for import into the model."}`,
|
|
59952
59970
|
"exposes-as-agent: false",
|
|
59953
59971
|
"requires:",
|
|
59954
|
-
|
|
59972
|
+
// UNPINNED, DELIBERATELY — and this is not laziness, it is the only true statement
|
|
59973
|
+
// available. floless supports BOTH reader lines and tells them apart by the `frame` in
|
|
59974
|
+
// the response, because the agent and the BRIDGE BINARY that actually produces the
|
|
59975
|
+
// coordinates are versioned independently: the bridge installs separately and a stale one
|
|
59976
|
+
// only warns. So no version pin describes what you will actually get, and AWARE's pin
|
|
59977
|
+
// grammar has no way to say "either line" — it takes `maj.min.pat`, `maj.min.x` or
|
|
59978
|
+
// `maj.x`, with no ranges and no alternation. An entry with no `@` is legal and means
|
|
59979
|
+
// exactly what we mean: this app needs the agent, and judges its output itself.
|
|
59980
|
+
//
|
|
59981
|
+
// Measured against the real binary (aware-aeco/aware @ b6084d5d9): `@0.1.x` against the
|
|
59982
|
+
// shipped 1.0.0 agent fails compile with E_APP_AGENT_PIN_UNSATISFIED, and `@>=0.1.0` fails
|
|
59983
|
+
// with E_APP_REQUIRES_MALFORMED because `>=` is not in the grammar at all. Both were
|
|
59984
|
+
// harmless while pins were enforced nowhere; aware-aeco/aware#349 made them enforced at
|
|
59985
|
+
// compile AND run, so both would have broken IFC import outright on the next AWARE release.
|
|
59986
|
+
` - ${AGENT}`,
|
|
59955
59987
|
"layout: linear",
|
|
59956
59988
|
"nodes:",
|
|
59957
59989
|
` - id: ${command}`,
|
|
@@ -60041,16 +60073,25 @@ function toCustomConnection(raw, fallbackId) {
|
|
|
60041
60073
|
throw new ConnectionImportError(typeof raw.message === "string" ? raw.message : "could not read that connection");
|
|
60042
60074
|
}
|
|
60043
60075
|
const c = conn;
|
|
60076
|
+
const alreadyZUp = c.frame === FILE_Z_UP;
|
|
60077
|
+
if (!alreadyZUp && c.frame !== void 0 && c.frame !== FILE_Y_UP) {
|
|
60078
|
+
throw new ConnectionImportError(
|
|
60079
|
+
`the connection reader returned a coordinate frame this version of FloLess does not understand (${JSON.stringify(c.frame)}) \u2014 updating FloLess should fix it`
|
|
60080
|
+
);
|
|
60081
|
+
}
|
|
60044
60082
|
const valid = (Array.isArray(c.parts) ? c.parts : []).filter(validPart);
|
|
60045
60083
|
if (valid.length > MAX_PARTS) throw new ConnectionImportError(`that connection has too many parts (${valid.length}) to import`);
|
|
60046
60084
|
let totalVerts = 0;
|
|
60047
60085
|
for (const p of valid) totalVerts += p.positions.length / 3;
|
|
60048
60086
|
if (totalVerts > MAX_VERTICES) throw new ConnectionImportError(`that connection is too large to import (${Math.round(totalVerts / 1e3)}k vertices)`);
|
|
60049
|
-
const
|
|
60050
|
-
const
|
|
60087
|
+
const framed = valid.map((p) => alreadyZUp ? p : { ...p, positions: yUpToZUp(p.positions) });
|
|
60088
|
+
const anchor = bboxCenter(framed);
|
|
60089
|
+
const geometry = framed.map((p) => ({
|
|
60051
60090
|
...typeof p.id === "string" ? { id: p.id } : {},
|
|
60052
60091
|
...typeof p.role === "string" ? { role: p.role } : {},
|
|
60053
60092
|
positions: shiftPositions(p.positions, anchor),
|
|
60093
|
+
// The frame correction rewrites POSITIONS and never touches indices, so a triangle means the
|
|
60094
|
+
// same thing whichever branch produced its vertices.
|
|
60054
60095
|
indices: p.indices.slice()
|
|
60055
60096
|
}));
|
|
60056
60097
|
const recipe = sanitizeRecipe(c.recipe);
|
|
@@ -60234,6 +60275,9 @@ function writeContract(appId, doc, projectId, privileged) {
|
|
|
60234
60275
|
(0, import_node_fs27.renameSync)(tmp, p);
|
|
60235
60276
|
}
|
|
60236
60277
|
|
|
60278
|
+
// contract-gateway.ts
|
|
60279
|
+
var import_node_fs31 = require("node:fs");
|
|
60280
|
+
|
|
60237
60281
|
// contract-resolve.ts
|
|
60238
60282
|
function bakedContractNode(app) {
|
|
60239
60283
|
return app.nodes.find(
|
|
@@ -62946,6 +62990,9 @@ function etagOf(doc) {
|
|
|
62946
62990
|
function storeEtag(appId, projectId) {
|
|
62947
62991
|
return etagOf(readContract(appId, projectId));
|
|
62948
62992
|
}
|
|
62993
|
+
function storedContractBytesExist(appId, projectId) {
|
|
62994
|
+
return (0, import_node_fs31.existsSync)(contractPath(appId, projectId));
|
|
62995
|
+
}
|
|
62949
62996
|
var PreconditionFailedError = class extends Error {
|
|
62950
62997
|
code = "precondition-failed";
|
|
62951
62998
|
constructor(message) {
|
|
@@ -63076,7 +63123,7 @@ function acceptSteelForRoute(doc, ctx, from, reads) {
|
|
|
63076
63123
|
}
|
|
63077
63124
|
|
|
63078
63125
|
// knowledge-routes.ts
|
|
63079
|
-
var
|
|
63126
|
+
var import_node_fs33 = require("node:fs");
|
|
63080
63127
|
|
|
63081
63128
|
// sse.ts
|
|
63082
63129
|
var clients = /* @__PURE__ */ new Set();
|
|
@@ -63114,7 +63161,7 @@ function clientCount() {
|
|
|
63114
63161
|
|
|
63115
63162
|
// knowledge-store.ts
|
|
63116
63163
|
var import_node_crypto18 = require("node:crypto");
|
|
63117
|
-
var
|
|
63164
|
+
var import_node_fs32 = require("node:fs");
|
|
63118
63165
|
var import_node_path30 = require("node:path");
|
|
63119
63166
|
var import_yaml6 = __toESM(require_dist6(), 1);
|
|
63120
63167
|
var KnowledgeError = class extends Error {
|
|
@@ -63135,9 +63182,9 @@ function isSourceRow(row) {
|
|
|
63135
63182
|
}
|
|
63136
63183
|
function readManifest(id) {
|
|
63137
63184
|
const p = manifestPath(id);
|
|
63138
|
-
if (!(0,
|
|
63185
|
+
if (!(0, import_node_fs32.existsSync)(p)) return { ...EMPTY_MANIFEST, sources: [] };
|
|
63139
63186
|
try {
|
|
63140
|
-
const parsed = JSON.parse((0,
|
|
63187
|
+
const parsed = JSON.parse((0, import_node_fs32.readFileSync)(p, "utf8"));
|
|
63141
63188
|
if (!parsed || typeof parsed !== "object" || !Array.isArray(parsed.sources)) {
|
|
63142
63189
|
console.warn(`knowledge-store: ignoring schema-invalid manifest.json at ${p} (missing/invalid sources array)`);
|
|
63143
63190
|
return { ...EMPTY_MANIFEST, sources: [] };
|
|
@@ -63161,11 +63208,11 @@ function readManifest(id) {
|
|
|
63161
63208
|
}
|
|
63162
63209
|
function writeManifest(id, manifest) {
|
|
63163
63210
|
const dir = projectKnowledgeDir(id);
|
|
63164
|
-
(0,
|
|
63211
|
+
(0, import_node_fs32.mkdirSync)(dir, { recursive: true });
|
|
63165
63212
|
const dest = manifestPath(id);
|
|
63166
63213
|
const tmp = (0, import_node_path30.join)(dir, `.manifest.json.${process.pid}.${(0, import_node_crypto18.randomUUID)()}.tmp`);
|
|
63167
|
-
(0,
|
|
63168
|
-
(0,
|
|
63214
|
+
(0, import_node_fs32.writeFileSync)(tmp, JSON.stringify(manifest, null, 2));
|
|
63215
|
+
(0, import_node_fs32.renameSync)(tmp, dest);
|
|
63169
63216
|
}
|
|
63170
63217
|
var MAX_FILES = 50;
|
|
63171
63218
|
var MAX_FILE_BYTES = 100 * 1024 * 1024;
|
|
@@ -63242,12 +63289,12 @@ function addSource(id, input) {
|
|
|
63242
63289
|
const { buf, mime, filename } = input;
|
|
63243
63290
|
const sha2563 = (0, import_node_crypto18.createHash)("sha256").update(buf).digest("hex");
|
|
63244
63291
|
const dir = blobsDir(id);
|
|
63245
|
-
(0,
|
|
63292
|
+
(0, import_node_fs32.mkdirSync)(dir, { recursive: true });
|
|
63246
63293
|
const blobPath = blobPathFor(id, sha2563);
|
|
63247
|
-
if (!(0,
|
|
63294
|
+
if (!(0, import_node_fs32.existsSync)(blobPath)) {
|
|
63248
63295
|
const tmp = `${blobPath}.${process.pid}.${(0, import_node_crypto18.randomUUID)()}.tmp`;
|
|
63249
|
-
(0,
|
|
63250
|
-
(0,
|
|
63296
|
+
(0, import_node_fs32.writeFileSync)(tmp, buf);
|
|
63297
|
+
(0, import_node_fs32.renameSync)(tmp, blobPath);
|
|
63251
63298
|
}
|
|
63252
63299
|
const manifest = readManifest(id);
|
|
63253
63300
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -63290,7 +63337,7 @@ function removeSource(id, sourceId) {
|
|
|
63290
63337
|
if (!stillReferenced) {
|
|
63291
63338
|
const blobPath = blobPathFor(id, removed.blobSha256);
|
|
63292
63339
|
try {
|
|
63293
|
-
if ((0,
|
|
63340
|
+
if ((0, import_node_fs32.existsSync)(blobPath)) (0, import_node_fs32.unlinkSync)(blobPath);
|
|
63294
63341
|
} catch (e) {
|
|
63295
63342
|
console.warn(`knowledge-store: could not GC blob ${removed.blobSha256} for ${id}: ${e instanceof Error ? e.message : e}`);
|
|
63296
63343
|
}
|
|
@@ -63300,17 +63347,17 @@ var LOCK_STALE_MS = 10 * 60 * 1e3;
|
|
|
63300
63347
|
var lockPath = (id) => (0, import_node_path30.join)(projectKnowledgeDir(id), "lock.json");
|
|
63301
63348
|
function writeLockFile(id, lock) {
|
|
63302
63349
|
const dir = projectKnowledgeDir(id);
|
|
63303
|
-
(0,
|
|
63350
|
+
(0, import_node_fs32.mkdirSync)(dir, { recursive: true });
|
|
63304
63351
|
const dest = lockPath(id);
|
|
63305
63352
|
const tmp = (0, import_node_path30.join)(dir, `.lock.json.${process.pid}.${(0, import_node_crypto18.randomUUID)()}.tmp`);
|
|
63306
|
-
(0,
|
|
63307
|
-
(0,
|
|
63353
|
+
(0, import_node_fs32.writeFileSync)(tmp, JSON.stringify(lock, null, 2));
|
|
63354
|
+
(0, import_node_fs32.renameSync)(tmp, dest);
|
|
63308
63355
|
}
|
|
63309
63356
|
function readLock(id) {
|
|
63310
63357
|
const p = lockPath(id);
|
|
63311
|
-
if (!(0,
|
|
63358
|
+
if (!(0, import_node_fs32.existsSync)(p)) return null;
|
|
63312
63359
|
try {
|
|
63313
|
-
const parsed = JSON.parse((0,
|
|
63360
|
+
const parsed = JSON.parse((0, import_node_fs32.readFileSync)(p, "utf8"));
|
|
63314
63361
|
if (!parsed || typeof parsed !== "object" || typeof parsed.requestId !== "string" || typeof parsed.createdAt !== "number" || !Number.isFinite(parsed.createdAt)) {
|
|
63315
63362
|
console.warn(`knowledge-store: ignoring schema-invalid lock.json at ${p}`);
|
|
63316
63363
|
return null;
|
|
@@ -63346,7 +63393,7 @@ function releaseLock(id, requestId) {
|
|
|
63346
63393
|
if (existing.requestId !== requestId) return false;
|
|
63347
63394
|
const p = lockPath(id);
|
|
63348
63395
|
try {
|
|
63349
|
-
if ((0,
|
|
63396
|
+
if ((0, import_node_fs32.existsSync)(p)) (0, import_node_fs32.unlinkSync)(p);
|
|
63350
63397
|
} catch (e) {
|
|
63351
63398
|
console.warn(`knowledge-store: could not release lock.json at ${p}: ${e instanceof Error ? e.message : e}`);
|
|
63352
63399
|
}
|
|
@@ -63371,14 +63418,14 @@ function generationWikiDir(id, generationId) {
|
|
|
63371
63418
|
}
|
|
63372
63419
|
function publishGeneration(id, generationId) {
|
|
63373
63420
|
assertGenerationId(generationId);
|
|
63374
|
-
if (!(0,
|
|
63421
|
+
if (!(0, import_node_fs32.existsSync)(generationWikiDir(id, generationId))) throw new KnowledgeError("generation not found");
|
|
63375
63422
|
const pointer = { generationId, publishedAt: (/* @__PURE__ */ new Date()).toISOString() };
|
|
63376
63423
|
const dir = vaultDir(id);
|
|
63377
|
-
(0,
|
|
63424
|
+
(0, import_node_fs32.mkdirSync)(dir, { recursive: true });
|
|
63378
63425
|
const dest = currentGenerationPath(id);
|
|
63379
63426
|
const tmp = (0, import_node_path30.join)(dir, `.current-generation.json.${process.pid}.${(0, import_node_crypto18.randomUUID)()}.tmp`);
|
|
63380
|
-
(0,
|
|
63381
|
-
(0,
|
|
63427
|
+
(0, import_node_fs32.writeFileSync)(tmp, JSON.stringify(pointer, null, 2));
|
|
63428
|
+
(0, import_node_fs32.renameSync)(tmp, dest);
|
|
63382
63429
|
const manifest = readManifest(id);
|
|
63383
63430
|
manifest.currentGeneration = generationId;
|
|
63384
63431
|
writeManifest(id, manifest);
|
|
@@ -63387,9 +63434,9 @@ function publishGeneration(id, generationId) {
|
|
|
63387
63434
|
}
|
|
63388
63435
|
function readCurrentGeneration(id) {
|
|
63389
63436
|
const p = currentGenerationPath(id);
|
|
63390
|
-
if (!(0,
|
|
63437
|
+
if (!(0, import_node_fs32.existsSync)(p)) return null;
|
|
63391
63438
|
try {
|
|
63392
|
-
const parsed = JSON.parse((0,
|
|
63439
|
+
const parsed = JSON.parse((0, import_node_fs32.readFileSync)(p, "utf8"));
|
|
63393
63440
|
if (typeof parsed?.generationId !== "string" || !GENERATION_ID_RE.test(parsed.generationId) || typeof parsed.publishedAt !== "string") {
|
|
63394
63441
|
console.warn(`knowledge-store: ignoring schema-invalid current-generation.json at ${p}`);
|
|
63395
63442
|
return null;
|
|
@@ -63404,7 +63451,7 @@ function currentGenerationWikiDir(id) {
|
|
|
63404
63451
|
const current = readCurrentGeneration(id);
|
|
63405
63452
|
if (!current) return null;
|
|
63406
63453
|
const dir = generationWikiDir(id, current.generationId);
|
|
63407
|
-
return (0,
|
|
63454
|
+
return (0, import_node_fs32.existsSync)(dir) ? dir : null;
|
|
63408
63455
|
}
|
|
63409
63456
|
var WIKI_SLUG_RE = /^[a-z0-9][a-z0-9._-]*$/;
|
|
63410
63457
|
var KB_MAX_NODES = 300;
|
|
@@ -63412,9 +63459,9 @@ var KB_MAX_TOTAL_BYTES = 8 * 1024 * 1024;
|
|
|
63412
63459
|
var KB_MAX_VISITS = 5e3;
|
|
63413
63460
|
var KB_MAX_PAGE_BYTES = 512 * 1024;
|
|
63414
63461
|
var REAL_IO = {
|
|
63415
|
-
readdir: (dir) => (0,
|
|
63416
|
-
readFile: (path) => (0,
|
|
63417
|
-
statSize: (path) => (0,
|
|
63462
|
+
readdir: (dir) => (0, import_node_fs32.readdirSync)(dir, { withFileTypes: true }),
|
|
63463
|
+
readFile: (path) => (0, import_node_fs32.readFileSync)(path, "utf8"),
|
|
63464
|
+
statSize: (path) => (0, import_node_fs32.statSync)(path).size
|
|
63418
63465
|
};
|
|
63419
63466
|
var VAULT_START = "<!-- vault:generated:start -->";
|
|
63420
63467
|
var VAULT_END = "<!-- vault:generated:end -->";
|
|
@@ -63714,17 +63761,17 @@ function readKnowledgeSummaries(wikiDir, opts = {}, io = REAL_IO) {
|
|
|
63714
63761
|
var organizePath = (id) => (0, import_node_path30.join)(projectKnowledgeDir(id), "organize.json");
|
|
63715
63762
|
function writeOrganizeFile(id, org) {
|
|
63716
63763
|
const dir = projectKnowledgeDir(id);
|
|
63717
|
-
(0,
|
|
63764
|
+
(0, import_node_fs32.mkdirSync)(dir, { recursive: true });
|
|
63718
63765
|
const dest = organizePath(id);
|
|
63719
63766
|
const tmp = (0, import_node_path30.join)(dir, `.organize.json.${process.pid}.${(0, import_node_crypto18.randomUUID)()}.tmp`);
|
|
63720
|
-
(0,
|
|
63721
|
-
(0,
|
|
63767
|
+
(0, import_node_fs32.writeFileSync)(tmp, JSON.stringify(org, null, 2));
|
|
63768
|
+
(0, import_node_fs32.renameSync)(tmp, dest);
|
|
63722
63769
|
}
|
|
63723
63770
|
function readOrganize(id) {
|
|
63724
63771
|
const p = organizePath(id);
|
|
63725
|
-
if (!(0,
|
|
63772
|
+
if (!(0, import_node_fs32.existsSync)(p)) return null;
|
|
63726
63773
|
try {
|
|
63727
|
-
const parsed = JSON.parse((0,
|
|
63774
|
+
const parsed = JSON.parse((0, import_node_fs32.readFileSync)(p, "utf8"));
|
|
63728
63775
|
if (!parsed || typeof parsed !== "object" || typeof parsed.requestId !== "string" || typeof parsed.generationId !== "string" || !GENERATION_ID_RE.test(parsed.generationId) || typeof parsed.baseRevision !== "number" || !Number.isFinite(parsed.baseRevision)) {
|
|
63729
63776
|
console.warn(`knowledge-store: ignoring schema-invalid organize.json at ${p}`);
|
|
63730
63777
|
return null;
|
|
@@ -63743,7 +63790,7 @@ function readOrganize(id) {
|
|
|
63743
63790
|
function deleteOrganizeFile(id) {
|
|
63744
63791
|
const p = organizePath(id);
|
|
63745
63792
|
try {
|
|
63746
|
-
if ((0,
|
|
63793
|
+
if ((0, import_node_fs32.existsSync)(p)) (0, import_node_fs32.unlinkSync)(p);
|
|
63747
63794
|
} catch (e) {
|
|
63748
63795
|
console.warn(`knowledge-store: could not delete organize.json at ${p}: ${e instanceof Error ? e.message : e}`);
|
|
63749
63796
|
}
|
|
@@ -63761,7 +63808,7 @@ function startOrganize(id, requestId) {
|
|
|
63761
63808
|
const generationId = mintGenerationId();
|
|
63762
63809
|
const manifest = readManifest(id);
|
|
63763
63810
|
const baseRevision = manifest.revision;
|
|
63764
|
-
(0,
|
|
63811
|
+
(0, import_node_fs32.mkdirSync)(generationWikiDir(id, generationId), { recursive: true });
|
|
63765
63812
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
63766
63813
|
for (const row of manifest.sources) {
|
|
63767
63814
|
if (row.useAsKb) {
|
|
@@ -63782,8 +63829,8 @@ function finishOrganize(id, requestId, opts) {
|
|
|
63782
63829
|
throw new KnowledgeError("generation id mismatch");
|
|
63783
63830
|
}
|
|
63784
63831
|
const wikiDir = generationWikiDir(id, org.generationId);
|
|
63785
|
-
if (!(0,
|
|
63786
|
-
if ((0,
|
|
63832
|
+
if (!(0, import_node_fs32.existsSync)(wikiDir)) throw new KnowledgeError("generation not found");
|
|
63833
|
+
if ((0, import_node_fs32.readdirSync)(wikiDir).length === 0) {
|
|
63787
63834
|
throw new KnowledgeError("nothing to publish \u2014 generation is empty");
|
|
63788
63835
|
}
|
|
63789
63836
|
publishGeneration(id, org.generationId);
|
|
@@ -63824,14 +63871,14 @@ function failOrganize(id, requestId, opts) {
|
|
|
63824
63871
|
}
|
|
63825
63872
|
function gcOldGenerations(id, currentGenerationId) {
|
|
63826
63873
|
const dir = generationsDir(id);
|
|
63827
|
-
if (!(0,
|
|
63828
|
-
const entries2 = (0,
|
|
63874
|
+
if (!(0, import_node_fs32.existsSync)(dir)) return;
|
|
63875
|
+
const entries2 = (0, import_node_fs32.readdirSync)(dir, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => ({ name: e.name, mtimeMs: (0, import_node_fs32.statSync)((0, import_node_path30.join)(dir, e.name)).mtimeMs })).sort((a, b) => b.mtimeMs - a.mtimeMs);
|
|
63829
63876
|
const keep = new Set(entries2.slice(0, GEN_KEEP).map((e) => e.name));
|
|
63830
63877
|
keep.add(currentGenerationId);
|
|
63831
63878
|
for (const e of entries2) {
|
|
63832
63879
|
if (keep.has(e.name)) continue;
|
|
63833
63880
|
try {
|
|
63834
|
-
(0,
|
|
63881
|
+
(0, import_node_fs32.rmSync)((0, import_node_path30.join)(dir, e.name), { recursive: true, force: true });
|
|
63835
63882
|
} catch (err2) {
|
|
63836
63883
|
console.warn(`knowledge-store: could not GC stale generation dir ${e.name}: ${err2 instanceof Error ? err2.message : err2}`);
|
|
63837
63884
|
}
|
|
@@ -63947,7 +63994,7 @@ function registerKnowledgeRoutes(app) {
|
|
|
63947
63994
|
const blobPath = blobPathFor(project.id, row.blobSha256);
|
|
63948
63995
|
let fd2;
|
|
63949
63996
|
try {
|
|
63950
|
-
fd2 = (0,
|
|
63997
|
+
fd2 = (0, import_node_fs33.openSync)(blobPath, "r");
|
|
63951
63998
|
} catch (e) {
|
|
63952
63999
|
const code = e.code;
|
|
63953
64000
|
if (code === "ENOENT" || code === "ENOTDIR") {
|
|
@@ -63957,17 +64004,17 @@ function registerKnowledgeRoutes(app) {
|
|
|
63957
64004
|
}
|
|
63958
64005
|
let streamOwnsFd = false;
|
|
63959
64006
|
try {
|
|
63960
|
-
const st = (0,
|
|
64007
|
+
const st = (0, import_node_fs33.fstatSync)(fd2);
|
|
63961
64008
|
if (!st.isFile()) {
|
|
63962
64009
|
return reply.status(404).send({ ok: false, error: "source bytes are missing" });
|
|
63963
64010
|
}
|
|
63964
64011
|
reply.header("Content-Type", row.mime).header("Content-Length", String(st.size)).header("X-Content-Type-Options", "nosniff").header("Content-Disposition", "inline").header("Cache-Control", "private, no-store").header("Content-Security-Policy", "default-src 'none'; sandbox; frame-ancestors 'self'").header("Cross-Origin-Resource-Policy", "same-origin");
|
|
63965
64012
|
if (req.method === "HEAD") return reply.send();
|
|
63966
|
-
const stream = (0,
|
|
64013
|
+
const stream = (0, import_node_fs33.createReadStream)(blobPath, { fd: fd2, autoClose: true });
|
|
63967
64014
|
streamOwnsFd = true;
|
|
63968
64015
|
return reply.send(stream);
|
|
63969
64016
|
} finally {
|
|
63970
|
-
if (!streamOwnsFd) (0,
|
|
64017
|
+
if (!streamOwnsFd) (0, import_node_fs33.closeSync)(fd2);
|
|
63971
64018
|
}
|
|
63972
64019
|
} catch (e) {
|
|
63973
64020
|
if (e instanceof ProjectError) return reply.status(400).send({ ok: false, error: e.message });
|
|
@@ -64933,21 +64980,21 @@ function viewOf(p, facts) {
|
|
|
64933
64980
|
|
|
64934
64981
|
// project-sources-store.ts
|
|
64935
64982
|
var import_node_crypto19 = require("node:crypto");
|
|
64936
|
-
var
|
|
64983
|
+
var import_node_fs34 = require("node:fs");
|
|
64937
64984
|
var import_node_path31 = require("node:path");
|
|
64938
64985
|
var sourcesDir = (id) => (0, import_node_path31.join)(projectDir(id), "sources");
|
|
64939
64986
|
var safeExt = (ext) => typeof ext === "string" && /^[a-z0-9]{1,8}$/i.test(ext) ? ext.toLowerCase() : "bin";
|
|
64940
64987
|
function writeAtomic2(path, buf) {
|
|
64941
64988
|
const tmp = `${path}.${process.pid}.tmp`;
|
|
64942
|
-
(0,
|
|
64943
|
-
(0,
|
|
64989
|
+
(0, import_node_fs34.writeFileSync)(tmp, buf);
|
|
64990
|
+
(0, import_node_fs34.renameSync)(tmp, path);
|
|
64944
64991
|
}
|
|
64945
64992
|
function saveSource(id, file) {
|
|
64946
|
-
(0,
|
|
64993
|
+
(0, import_node_fs34.mkdirSync)(sourcesDir(id), { recursive: true });
|
|
64947
64994
|
const sha2563 = (0, import_node_crypto19.createHash)("sha256").update(file.buf).digest("hex");
|
|
64948
64995
|
const ext = safeExt(file.ext);
|
|
64949
64996
|
const p = (0, import_node_path31.join)(sourcesDir(id), `${sha2563}.${ext}`);
|
|
64950
|
-
if (!(0,
|
|
64997
|
+
if (!(0, import_node_fs34.existsSync)(p)) writeAtomic2(p, file.buf);
|
|
64951
64998
|
return { name: String(file.name), sha256: sha2563, ext, bytes: file.buf.length };
|
|
64952
64999
|
}
|
|
64953
65000
|
|
|
@@ -69063,13 +69110,33 @@ function registerSteelPrepassRoute(app, deps) {
|
|
|
69063
69110
|
var import_node_crypto22 = require("node:crypto");
|
|
69064
69111
|
|
|
69065
69112
|
// reference-import.ts
|
|
69066
|
-
var
|
|
69113
|
+
var import_node_fs35 = require("node:fs");
|
|
69067
69114
|
var import_node_path32 = require("node:path");
|
|
69068
69115
|
var AGENT2 = "ifc-reference-reader";
|
|
69069
69116
|
var WARN_BYTES = 50 * 1024 * 1024;
|
|
69070
69117
|
var MAX_BYTES5 = 150 * 1024 * 1024;
|
|
69071
69118
|
var MAX_VERTICES2 = 8e6;
|
|
69119
|
+
var MAX_OBJECTS = 2e4;
|
|
69120
|
+
var WARN_OBJECTS = 11e3;
|
|
69121
|
+
function objectVerdict(objects) {
|
|
69122
|
+
if (!Number.isFinite(objects)) return "ok";
|
|
69123
|
+
if (objects > MAX_OBJECTS) return "refuse";
|
|
69124
|
+
return objects >= WARN_OBJECTS ? "warn" : "ok";
|
|
69125
|
+
}
|
|
69072
69126
|
var ReferenceImportError = class extends Error {
|
|
69127
|
+
/**
|
|
69128
|
+
* A stable discriminator for the refusals a CALLER has to tell apart.
|
|
69129
|
+
*
|
|
69130
|
+
* Added for the unconfirmed-filter refusal: without it every `ReferenceImportError` reaches the
|
|
69131
|
+
* browser as a bare message, and the import modal — which keeps the storey picker on screen only for
|
|
69132
|
+
* refusals it recognises — threw the user's whole selection away on the one refusal whose remedy is
|
|
69133
|
+
* to try again.
|
|
69134
|
+
*/
|
|
69135
|
+
constructor(message, code) {
|
|
69136
|
+
super(message);
|
|
69137
|
+
this.code = code;
|
|
69138
|
+
}
|
|
69139
|
+
code;
|
|
69073
69140
|
};
|
|
69074
69141
|
var mb2 = (bytes) => `${Math.round(bytes / (1024 * 1024))} MB`;
|
|
69075
69142
|
function dataUrlBytes(dataUrl) {
|
|
@@ -69144,16 +69211,74 @@ function toPropertySets(raw) {
|
|
|
69144
69211
|
function offersPropertySets(raw) {
|
|
69145
69212
|
return Array.isArray(raw) && raw.some((s) => !!s && typeof s === "object" && Array.isArray(s.properties));
|
|
69146
69213
|
}
|
|
69147
|
-
|
|
69148
|
-
|
|
69149
|
-
|
|
69150
|
-
const
|
|
69151
|
-
|
|
69152
|
-
|
|
69153
|
-
|
|
69154
|
-
|
|
69214
|
+
function toProbeBreakdown(raw) {
|
|
69215
|
+
if (!Array.isArray(raw)) return null;
|
|
69216
|
+
const rows2 = [];
|
|
69217
|
+
for (const r of raw) {
|
|
69218
|
+
const q = r;
|
|
69219
|
+
if (!q || typeof q !== "object" || Array.isArray(q)) return null;
|
|
69220
|
+
if (!("name" in q) || q.name !== null && typeof q.name !== "string") return null;
|
|
69221
|
+
if (!Number.isInteger(q.elements) || q.elements < 0) return null;
|
|
69222
|
+
rows2.push({ name: q.name ?? null, elements: q.elements });
|
|
69223
|
+
}
|
|
69224
|
+
return rows2;
|
|
69225
|
+
}
|
|
69226
|
+
var sumRows = (rows2) => rows2 === null ? null : rows2.reduce((n, r) => n + r.elements, 0);
|
|
69227
|
+
function readPopulation(probe) {
|
|
69228
|
+
const sums = [sumRows(probe.storeys), sumRows(probe.types)].filter((n) => n !== null);
|
|
69229
|
+
const known = sums.length ? Math.max(...sums) : null;
|
|
69230
|
+
return known ? known : null;
|
|
69231
|
+
}
|
|
69232
|
+
function selectedPopulation(probe, filter) {
|
|
69233
|
+
if (!emittedFilter(filter)) return readPopulation(probe);
|
|
69234
|
+
const sumOf = (rows2, want) => {
|
|
69235
|
+
if (rows2 === null || !want?.length) return null;
|
|
69236
|
+
const lower = new Set(want.map((s) => s.toLowerCase()));
|
|
69237
|
+
const hit = rows2.filter((r) => r.name !== null && lower.has(r.name.toLowerCase()));
|
|
69238
|
+
return hit.length ? hit.reduce((n, r) => n + r.elements, 0) : null;
|
|
69239
|
+
};
|
|
69240
|
+
const both = [sumOf(probe.storeys, filter?.storeys), sumOf(probe.types, filter?.ifcTypes)].filter((n) => n !== null);
|
|
69241
|
+
return both.length ? Math.min(...both) : null;
|
|
69242
|
+
}
|
|
69243
|
+
function emittedFilter(filter) {
|
|
69244
|
+
const storeys = filter?.storeys?.length ? filter.storeys : void 0;
|
|
69245
|
+
const ifcTypes = filter?.ifcTypes?.length ? filter.ifcTypes : void 0;
|
|
69246
|
+
return storeys || ifcTypes ? { ...storeys ? { storeys } : {}, ...ifcTypes ? { ifcTypes } : {} } : null;
|
|
69247
|
+
}
|
|
69248
|
+
function assertSelectionConfirmed(selected, filter) {
|
|
69249
|
+
const asked = emittedFilter(filter);
|
|
69250
|
+
if (!asked) return;
|
|
69251
|
+
if (!selected) {
|
|
69252
|
+
throw new ReferenceImportError(
|
|
69253
|
+
"the reader did not confirm which storeys it loaded, so FloLess stopped rather than show you the whole model by mistake.",
|
|
69254
|
+
"reference-filter-unconfirmed"
|
|
69255
|
+
);
|
|
69155
69256
|
}
|
|
69156
|
-
|
|
69257
|
+
for (const axis of ["storeys", "ifcTypes"]) {
|
|
69258
|
+
if (asked[axis]?.length && !selected[axis]?.length) {
|
|
69259
|
+
throw new ReferenceImportError(
|
|
69260
|
+
"the reader confirmed only part of what you chose, so FloLess stopped rather than show you more of the model than you asked for.",
|
|
69261
|
+
"reference-filter-unconfirmed"
|
|
69262
|
+
);
|
|
69263
|
+
}
|
|
69264
|
+
}
|
|
69265
|
+
}
|
|
69266
|
+
function toSelection(raw) {
|
|
69267
|
+
const q = raw;
|
|
69268
|
+
if (!q || typeof q !== "object" || Array.isArray(q)) return null;
|
|
69269
|
+
if (!Number.isInteger(q.candidates) || q.candidates < 0) return null;
|
|
69270
|
+
if (!Array.isArray(q.unmatched)) return null;
|
|
69271
|
+
const names = (v) => Array.isArray(v) && v.every((s) => typeof s === "string") ? v : void 0;
|
|
69272
|
+
const storeys = names(q.storeys);
|
|
69273
|
+
const ifcTypes = names(q.ifcTypes);
|
|
69274
|
+
const ids = names(q.ids);
|
|
69275
|
+
return {
|
|
69276
|
+
...storeys ? { storeys } : {},
|
|
69277
|
+
...ifcTypes ? { ifcTypes } : {},
|
|
69278
|
+
...ids ? { ids } : {},
|
|
69279
|
+
candidates: q.candidates,
|
|
69280
|
+
unmatched: q.unmatched.filter((u) => !!u && typeof u === "object" && !Array.isArray(u))
|
|
69281
|
+
};
|
|
69157
69282
|
}
|
|
69158
69283
|
function toReferenceObjects(raw) {
|
|
69159
69284
|
if (!raw || !Array.isArray(raw.objects)) {
|
|
@@ -69225,7 +69350,12 @@ function toReferenceObjects(raw) {
|
|
|
69225
69350
|
* the truth is that we refused what arrived. Counting the validated output makes that case report
|
|
69226
69351
|
* `null` instead, which is the state whose remedy ("Reload its geometry") is the right one.
|
|
69227
69352
|
*/
|
|
69228
|
-
propertySetsAvailable: objects.some((o) => o.propertySets) ? true : null
|
|
69353
|
+
propertySetsAvailable: objects.some((o) => o.propertySets) ? true : null,
|
|
69354
|
+
/**
|
|
69355
|
+
* THE FILTER RECEIPT, carried verbatim so the caller can check the run it asked for is the run it
|
|
69356
|
+
* got. Null for an unfiltered read — which is a fact about the reader, not a shortfall.
|
|
69357
|
+
*/
|
|
69358
|
+
selected: toSelection(raw.selected)
|
|
69229
69359
|
};
|
|
69230
69360
|
}
|
|
69231
69361
|
var REFERENCE_DIR = "references";
|
|
@@ -69245,9 +69375,9 @@ function projectRelativeReferencePath(fileName, taken = /* @__PURE__ */ new Set(
|
|
|
69245
69375
|
return candidate;
|
|
69246
69376
|
}
|
|
69247
69377
|
var readerChain2 = Promise.resolve();
|
|
69248
|
-
function writeReaderApp2(companionId, command, ifcPath) {
|
|
69378
|
+
function writeReaderApp2(companionId, command, ifcPath, filter) {
|
|
69249
69379
|
const dir = appPath(companionId);
|
|
69250
|
-
(0,
|
|
69380
|
+
(0, import_node_fs35.mkdirSync)(dir, { recursive: true });
|
|
69251
69381
|
const flo = (0, import_node_path32.join)(dir, `${companionId}.flo`);
|
|
69252
69382
|
const lines = [
|
|
69253
69383
|
`app: ${companionId}`,
|
|
@@ -69256,13 +69386,23 @@ function writeReaderApp2(companionId, command, ifcPath) {
|
|
|
69256
69386
|
`description: ${JSON.stringify(command === "probe" ? "Check what an IFC file says about itself \u2014 its units, schema, element count and rough extent \u2014 without reading its geometry, so an oversized file can be refused before it is loaded." : "Read a whole IFC file as reference geometry \u2014 every element as a mesh, with the name, type, storey, profile and material the file records for it.")}`,
|
|
69257
69387
|
"exposes-as-agent: false",
|
|
69258
69388
|
"requires:",
|
|
69259
|
-
//
|
|
69260
|
-
//
|
|
69261
|
-
//
|
|
69262
|
-
//
|
|
69263
|
-
//
|
|
69264
|
-
//
|
|
69265
|
-
`
|
|
69389
|
+
// UNPINNED, DELIBERATELY — and this is not laziness, it is the only true statement
|
|
69390
|
+
// available. floless supports BOTH reader lines and tells them apart by the `frame` in
|
|
69391
|
+
// the response, because the agent and the BRIDGE BINARY that actually produces the
|
|
69392
|
+
// coordinates are versioned independently: the bridge installs separately and a stale one
|
|
69393
|
+
// only warns. So no version pin describes what you will actually get, and AWARE's pin
|
|
69394
|
+
// grammar has no way to say "either line" — it takes `maj.min.pat`, `maj.min.x` or
|
|
69395
|
+
// `maj.x`, with no ranges and no alternation. An entry with no `@` is legal and means
|
|
69396
|
+
// exactly what we mean: this app needs the agent, and judges its output itself.
|
|
69397
|
+
//
|
|
69398
|
+
// Measured against the real binary (aware-aeco/aware @ b6084d5d9): `@0.1.x` against the
|
|
69399
|
+
// shipped 1.0.0 agent fails compile with E_APP_AGENT_PIN_UNSATISFIED, and `@>=0.1.0` fails
|
|
69400
|
+
// with E_APP_REQUIRES_MALFORMED because `>=` is not in the grammar at all. Both were
|
|
69401
|
+
// harmless while pins were enforced nowhere; aware-aeco/aware#349 made them enforced at
|
|
69402
|
+
// compile AND run, so both would have broken IFC import outright on the next AWARE release.
|
|
69403
|
+
// (This line previously read `@>=0.1.0`, reaching for the right meaning with a spelling the
|
|
69404
|
+
// grammar does not have. The intent was right; the syntax was never parsed.)
|
|
69405
|
+
` - ${AGENT2}`,
|
|
69266
69406
|
"layout: linear",
|
|
69267
69407
|
"nodes:",
|
|
69268
69408
|
` - id: ${command}`,
|
|
@@ -69271,9 +69411,14 @@ function writeReaderApp2(companionId, command, ifcPath) {
|
|
|
69271
69411
|
" config:",
|
|
69272
69412
|
` ifc-path: ${JSON.stringify(ifcPath)}`
|
|
69273
69413
|
];
|
|
69274
|
-
if (command === "read-model")
|
|
69414
|
+
if (command === "read-model") {
|
|
69415
|
+
lines.push(` max-vertices: ${MAX_VERTICES2}`);
|
|
69416
|
+
const emit = emittedFilter(filter);
|
|
69417
|
+
if (emit?.storeys) lines.push(` storeys: ${JSON.stringify(emit.storeys)}`);
|
|
69418
|
+
if (emit?.ifcTypes) lines.push(` ifc-types: ${JSON.stringify(emit.ifcTypes)}`);
|
|
69419
|
+
}
|
|
69275
69420
|
lines.push("");
|
|
69276
|
-
(0,
|
|
69421
|
+
(0, import_node_fs35.writeFileSync)(flo, lines.join("\n"));
|
|
69277
69422
|
return flo;
|
|
69278
69423
|
}
|
|
69279
69424
|
function nodeOutput2(traceText, node) {
|
|
@@ -69299,7 +69444,7 @@ async function runReader2(companionId, command, ifcPath, opts = {}) {
|
|
|
69299
69444
|
await prev.catch(() => {
|
|
69300
69445
|
});
|
|
69301
69446
|
try {
|
|
69302
|
-
const flo = writeReaderApp2(companionId, command, ifcPath);
|
|
69447
|
+
const flo = writeReaderApp2(companionId, command, ifcPath, opts.filter);
|
|
69303
69448
|
try {
|
|
69304
69449
|
await aware.compile(flo);
|
|
69305
69450
|
} catch (e) {
|
|
@@ -69330,18 +69475,24 @@ async function probeReference(companionId, ifcPath, opts = {}) {
|
|
|
69330
69475
|
elements: typeof out.elements === "number" ? out.elements : 0,
|
|
69331
69476
|
// null is meaningful here and must survive: it means the reader could not establish an extent, and
|
|
69332
69477
|
// a consumer that treated it as a zero box would read "a point at the origin" as fact.
|
|
69333
|
-
bbox: bbox && Array.isArray(bbox.min) && Array.isArray(bbox.max) ? bbox : null
|
|
69478
|
+
bbox: bbox && Array.isArray(bbox.min) && Array.isArray(bbox.max) ? bbox : null,
|
|
69479
|
+
// The picker's whole data source. Null here means the bridge could not answer, never that the file
|
|
69480
|
+
// has no storeys — see `ReferenceProbe`.
|
|
69481
|
+
storeys: toProbeBreakdown(out.storeys),
|
|
69482
|
+
types: toProbeBreakdown(out.types)
|
|
69334
69483
|
};
|
|
69335
69484
|
}
|
|
69336
69485
|
async function readReferenceModel(companionId, ifcPath, opts = {}) {
|
|
69337
69486
|
await ensureReferenceReader();
|
|
69338
69487
|
const out = await runReader2(companionId, "read-model", ifcPath, opts);
|
|
69339
|
-
|
|
69488
|
+
const read = toReferenceObjects(out);
|
|
69489
|
+
assertSelectionConfirmed(read.selected, opts.filter);
|
|
69490
|
+
return read;
|
|
69340
69491
|
}
|
|
69341
69492
|
|
|
69342
69493
|
// reference-store.ts
|
|
69343
69494
|
var import_node_crypto21 = require("node:crypto");
|
|
69344
|
-
var
|
|
69495
|
+
var import_node_fs36 = require("node:fs");
|
|
69345
69496
|
var import_promises4 = require("node:stream/promises");
|
|
69346
69497
|
var import_node_path33 = require("node:path");
|
|
69347
69498
|
function insideProject(projectId, relPath) {
|
|
@@ -69363,7 +69514,7 @@ function insideProject(projectId, relPath) {
|
|
|
69363
69514
|
}
|
|
69364
69515
|
function realish(p) {
|
|
69365
69516
|
try {
|
|
69366
|
-
return
|
|
69517
|
+
return import_node_fs36.realpathSync.native((0, import_node_path33.resolve)(p));
|
|
69367
69518
|
} catch {
|
|
69368
69519
|
return (0, import_node_path33.resolve)(p);
|
|
69369
69520
|
}
|
|
@@ -69377,20 +69528,20 @@ function safeId2(refId2) {
|
|
|
69377
69528
|
}
|
|
69378
69529
|
async function hashFile(path) {
|
|
69379
69530
|
const h = (0, import_node_crypto21.createHash)("sha256");
|
|
69380
|
-
await (0, import_promises4.pipeline)((0,
|
|
69531
|
+
await (0, import_promises4.pipeline)((0, import_node_fs36.createReadStream)(path), h);
|
|
69381
69532
|
return h.digest("hex");
|
|
69382
69533
|
}
|
|
69383
69534
|
function copyOriginal(projectId, relPath, sourceAbs, tag) {
|
|
69384
69535
|
const abs = insideProject(projectId, relPath);
|
|
69385
|
-
(0,
|
|
69536
|
+
(0, import_node_fs36.mkdirSync)((0, import_node_path33.dirname)(abs), { recursive: true });
|
|
69386
69537
|
const tmp = `${abs}.${safeId2(tag)}.part`;
|
|
69387
|
-
(0,
|
|
69388
|
-
(0,
|
|
69538
|
+
(0, import_node_fs36.copyFileSync)(sourceAbs, tmp);
|
|
69539
|
+
(0, import_node_fs36.renameSync)(tmp, abs);
|
|
69389
69540
|
return abs;
|
|
69390
69541
|
}
|
|
69391
69542
|
function referenceFilesOnDisk(projectId) {
|
|
69392
69543
|
try {
|
|
69393
|
-
return (0,
|
|
69544
|
+
return (0, import_node_fs36.readdirSync)((0, import_node_path33.join)(projectDir(projectId), REFERENCE_DIR)).map((f) => `${REFERENCE_DIR}/${f}`);
|
|
69394
69545
|
} catch (e) {
|
|
69395
69546
|
if (e.code === "ENOENT") return [];
|
|
69396
69547
|
throw new ReferenceImportError(
|
|
@@ -69400,32 +69551,39 @@ function referenceFilesOnDisk(projectId) {
|
|
|
69400
69551
|
}
|
|
69401
69552
|
function originalPath(projectId, relPath) {
|
|
69402
69553
|
const abs = insideProject(projectId, relPath);
|
|
69403
|
-
return (0,
|
|
69554
|
+
return (0, import_node_fs36.existsSync)(abs) ? abs : null;
|
|
69404
69555
|
}
|
|
69405
69556
|
function writeCache2(projectId, refId2, cache2) {
|
|
69406
69557
|
const p = cachePath2(projectId, refId2);
|
|
69407
69558
|
const tmp = `${p}.part`;
|
|
69408
|
-
(0,
|
|
69409
|
-
(0,
|
|
69559
|
+
(0, import_node_fs36.writeFileSync)(tmp, JSON.stringify(cache2));
|
|
69560
|
+
(0, import_node_fs36.renameSync)(tmp, p);
|
|
69561
|
+
}
|
|
69562
|
+
function filterKey(filter) {
|
|
69563
|
+
const part = (v) => v?.length ? [...v].sort() : [];
|
|
69564
|
+
const s = part(filter?.storeys);
|
|
69565
|
+
const t = part(filter?.ifcTypes);
|
|
69566
|
+
return s.length || t.length ? JSON.stringify([s, t]) : null;
|
|
69410
69567
|
}
|
|
69411
|
-
function cachedGeometry(projectId, refId2, expectHash) {
|
|
69568
|
+
function cachedGeometry(projectId, refId2, expectHash, expectFilter) {
|
|
69412
69569
|
const p = cachePath2(projectId, refId2);
|
|
69413
|
-
if (!(0,
|
|
69570
|
+
if (!(0, import_node_fs36.existsSync)(p)) return null;
|
|
69414
69571
|
try {
|
|
69415
|
-
const parsed = JSON.parse((0,
|
|
69572
|
+
const parsed = JSON.parse((0, import_node_fs36.readFileSync)(p, "utf8"));
|
|
69416
69573
|
if (!parsed || parsed.v !== REFERENCE_CACHE_VERSION || !Array.isArray(parsed.objects)) return null;
|
|
69417
69574
|
if (parsed.sourceHash !== expectHash) return null;
|
|
69575
|
+
if (filterKey(parsed.filter) !== filterKey(expectFilter)) return null;
|
|
69418
69576
|
return parsed;
|
|
69419
69577
|
} catch {
|
|
69420
69578
|
return null;
|
|
69421
69579
|
}
|
|
69422
69580
|
}
|
|
69423
69581
|
function dropCache(projectId, refId2) {
|
|
69424
|
-
(0,
|
|
69582
|
+
(0, import_node_fs36.rmSync)(cachePath2(projectId, refId2), { force: true });
|
|
69425
69583
|
}
|
|
69426
69584
|
function removeReference(projectId, refId2, relPath) {
|
|
69427
69585
|
dropCache(projectId, refId2);
|
|
69428
|
-
if (relPath) (0,
|
|
69586
|
+
if (relPath) (0, import_node_fs36.rmSync)(insideProject(projectId, relPath), { force: true });
|
|
69429
69587
|
}
|
|
69430
69588
|
function takenReferencePaths(refs) {
|
|
69431
69589
|
return new Set((refs ?? []).map((r) => r.file).filter((f) => typeof f === "string"));
|
|
@@ -69534,13 +69692,31 @@ function spanOf(objects) {
|
|
|
69534
69692
|
const span = Math.max(hi[0] - lo[0], hi[1] - lo[1], hi[2] - lo[2]);
|
|
69535
69693
|
return Number.isFinite(span) && span > 0 ? span : 0;
|
|
69536
69694
|
}
|
|
69695
|
+
function tooMany(what, probe) {
|
|
69696
|
+
const limit = `${what}, and the limit is ${MAX_OBJECTS.toLocaleString("en-US")}. `;
|
|
69697
|
+
return limit + (pickerCanExist(probe) ? "Choose fewer storeys or types and try again." : "This file is too large to load whole, and it does not offer storeys or types to load part of it \u2014 update your IFC reader, or export a smaller model.");
|
|
69698
|
+
}
|
|
69699
|
+
function pickerCanExist(probe) {
|
|
69700
|
+
if (probe.storeys === null || probe.types === null) return false;
|
|
69701
|
+
const selectable = (rows2) => rows2.filter((r) => r.name !== null).length;
|
|
69702
|
+
return selectable(probe.storeys) > 1 || selectable(probe.types) > 1;
|
|
69703
|
+
}
|
|
69704
|
+
function unmatchedNames(selected) {
|
|
69705
|
+
return (selected?.unmatched ?? []).map((u) => u.storey ?? u.ifcType ?? u.id).filter((n) => typeof n === "string" && !!n);
|
|
69706
|
+
}
|
|
69707
|
+
var hasUnmatched = (selected) => !!selected?.unmatched?.length;
|
|
69708
|
+
function unmatchedMessage(name, missed, remedy) {
|
|
69709
|
+
const what = missed.length ? `has nothing under ${missed.map((m) => `"${m}"`).join(", ")}` : "has nothing under the storeys or types it was loaded with";
|
|
69710
|
+
return `"${name}" ${what}. The file may have been re-exported with different names \u2014 ${remedy}`;
|
|
69711
|
+
}
|
|
69537
69712
|
function referencesOf(doc) {
|
|
69538
69713
|
const refs = doc.reference_models;
|
|
69539
69714
|
return Array.isArray(refs) ? refs : [];
|
|
69540
69715
|
}
|
|
69541
69716
|
function importRefusal(e) {
|
|
69542
69717
|
if (e instanceof ReferenceImportError || e instanceof VisualInputError) {
|
|
69543
|
-
|
|
69718
|
+
const code = e instanceof ReferenceImportError ? e.code : void 0;
|
|
69719
|
+
return { status: 400, body: { ok: false, error: e.message, ...code ? { code } : {} } };
|
|
69544
69720
|
}
|
|
69545
69721
|
return null;
|
|
69546
69722
|
}
|
|
@@ -69567,7 +69743,20 @@ function registerReferenceRoutes(app, deps) {
|
|
|
69567
69743
|
const scope = runScope(deps, reply);
|
|
69568
69744
|
try {
|
|
69569
69745
|
const probe = await deps.reader.probe(companion(g.appId), stored2.path, { ticket: scope.ticket() });
|
|
69570
|
-
|
|
69746
|
+
const population = readPopulation(probe);
|
|
69747
|
+
return {
|
|
69748
|
+
ok: true,
|
|
69749
|
+
sha: stored2.sha256,
|
|
69750
|
+
bytes: stored2.bytes,
|
|
69751
|
+
warn,
|
|
69752
|
+
probe,
|
|
69753
|
+
verdict: verdictFor(probe, req.body?.nativeSpan, req.body?.nativeCenter),
|
|
69754
|
+
// The number the confirm stage shows and the gate judges — the READ population, never
|
|
69755
|
+
// `probe.elements`, which counts a different thing and is smaller (measured 10 against 16).
|
|
69756
|
+
// Null means the bridge offered no breakdown, so no estimate exists and none is invented.
|
|
69757
|
+
population,
|
|
69758
|
+
objectVerdict: population === null ? null : objectVerdict(population)
|
|
69759
|
+
};
|
|
69571
69760
|
} catch (e) {
|
|
69572
69761
|
const r = importRefusal(e);
|
|
69573
69762
|
if (r) return reply.status(r.status).send(r.body);
|
|
@@ -69586,6 +69775,16 @@ function registerReferenceRoutes(app, deps) {
|
|
|
69586
69775
|
if (!g.ok) return reply.status(g.refusal.status).send(g.refusal.body);
|
|
69587
69776
|
const { sha, name, placement } = req.body ?? {};
|
|
69588
69777
|
if (!sha) return reply.status(400).send({ ok: false, error: "probe the file first \u2014 its sha is required" });
|
|
69778
|
+
const asked = req.body?.filter;
|
|
69779
|
+
const names = (v) => Array.isArray(v) ? v.filter((s) => typeof s === "string" && !!s.trim()) : [];
|
|
69780
|
+
const filter = emittedFilter({ storeys: names(asked?.storeys), ifcTypes: names(asked?.ifcTypes) }) ?? void 0;
|
|
69781
|
+
if (asked !== void 0 && !filter) {
|
|
69782
|
+
return reply.status(400).send({
|
|
69783
|
+
ok: false,
|
|
69784
|
+
code: "reference-empty-filter",
|
|
69785
|
+
error: "choose at least one storey or type to load, or clear the selection to load the whole file"
|
|
69786
|
+
});
|
|
69787
|
+
}
|
|
69589
69788
|
const source = ifcInputPath(g.appId, sha);
|
|
69590
69789
|
if (!source) {
|
|
69591
69790
|
return reply.status(404).send({ ok: false, error: "the uploaded IFC is no longer available \u2014 drop the file again" });
|
|
@@ -69621,18 +69820,46 @@ function registerReferenceRoutes(app, deps) {
|
|
|
69621
69820
|
if (!abs) throw new ReferenceImportError("the copied file vanished before it could be read");
|
|
69622
69821
|
const probe = await deps.reader.probe(companion(g.appId), abs, { ticket: scope.ticket() });
|
|
69623
69822
|
const sourceHash = await hashFile(abs);
|
|
69624
|
-
const
|
|
69823
|
+
const estimate = selectedPopulation(probe, filter);
|
|
69824
|
+
if (estimate !== null && objectVerdict(estimate) === "refuse") {
|
|
69825
|
+
rollback();
|
|
69826
|
+
return reply.status(400).send({
|
|
69827
|
+
ok: false,
|
|
69828
|
+
code: "reference-too-many-objects",
|
|
69829
|
+
error: tooMany(`"${displayName}" would load about ${estimate.toLocaleString("en-US")} objects`, probe)
|
|
69830
|
+
});
|
|
69831
|
+
}
|
|
69832
|
+
const geometry = await deps.reader.readModel(companion(g.appId), abs, { ticket: scope.ticket(), filter });
|
|
69625
69833
|
if (scope.gone()) throw new ReferenceImportError("cancelled");
|
|
69834
|
+
const missed = unmatchedNames(geometry.selected);
|
|
69835
|
+
if (!geometry.objects.length && hasUnmatched(geometry.selected)) {
|
|
69836
|
+
rollback();
|
|
69837
|
+
return reply.status(400).send({
|
|
69838
|
+
ok: false,
|
|
69839
|
+
code: "reference-filter-unmatched",
|
|
69840
|
+
error: unmatchedMessage(displayName, missed, "pick from the list above and try again.")
|
|
69841
|
+
});
|
|
69842
|
+
}
|
|
69626
69843
|
if (!geometry.objects.length) {
|
|
69627
69844
|
rollback();
|
|
69628
69845
|
return reply.status(400).send({ ok: false, error: `"${displayName}" has no geometry we can draw` });
|
|
69629
69846
|
}
|
|
69630
|
-
|
|
69847
|
+
if (objectVerdict(geometry.objects.length) === "refuse") {
|
|
69848
|
+
rollback();
|
|
69849
|
+
return reply.status(400).send({
|
|
69850
|
+
ok: false,
|
|
69851
|
+
code: "reference-too-many-objects",
|
|
69852
|
+
error: tooMany(`"${displayName}" read ${geometry.objects.length.toLocaleString("en-US")} objects`, probe)
|
|
69853
|
+
});
|
|
69854
|
+
}
|
|
69855
|
+
writeCache2(g.project, id, { v: REFERENCE_CACHE_VERSION, sourceHash, dropped: geometry.dropped, colorsAvailable: geometry.colorsAvailable, colorsDropped: geometry.colorsDropped, propertySetsAvailable: geometry.propertySetsAvailable, ...filter ? { filter } : {}, objects: geometry.objects });
|
|
69631
69856
|
const entry2 = {
|
|
69632
69857
|
id,
|
|
69633
69858
|
file: rel,
|
|
69634
69859
|
name: displayName,
|
|
69635
69860
|
...placement ? { placement } : {},
|
|
69861
|
+
// STORED, so a later re-read reproduces this reference rather than the whole building.
|
|
69862
|
+
...filter ? { filter } : {},
|
|
69636
69863
|
units: { declared: probe.units.declared, override: null },
|
|
69637
69864
|
// Half-opacity by default, because a reference that arrives looking like our own steel is the
|
|
69638
69865
|
// one mistake this feature must never make.
|
|
@@ -69651,7 +69878,7 @@ function registerReferenceRoutes(app, deps) {
|
|
|
69651
69878
|
});
|
|
69652
69879
|
committed = true;
|
|
69653
69880
|
deps.broadcast(contractChangedEvent(g.appId, g.project, etag, req.headers["x-floless-mutation-id"]));
|
|
69654
|
-
return { ok: true, etag, reference: entry2, objects: geometry.objects, dropped: geometry.dropped, colorsAvailable: geometry.colorsAvailable, colorsDropped: geometry.colorsDropped, propertySetsAvailable: geometry.propertySetsAvailable, spanMm: spanOf(geometry.objects) };
|
|
69881
|
+
return { ok: true, etag, reference: entry2, objects: geometry.objects, dropped: geometry.dropped, colorsAvailable: geometry.colorsAvailable, colorsDropped: geometry.colorsDropped, propertySetsAvailable: geometry.propertySetsAvailable, spanMm: spanOf(geometry.objects), ...hasUnmatched(geometry.selected) ? { unmatched: missed } : {} };
|
|
69655
69882
|
} catch (e) {
|
|
69656
69883
|
rollback();
|
|
69657
69884
|
const r = importRefusal(e);
|
|
@@ -69689,10 +69916,26 @@ function registerReferenceRoutes(app, deps) {
|
|
|
69689
69916
|
return reply.status(409).send({ ok: false, code: "reference-unresolved", error: `"${entry2.name}" could not be read` });
|
|
69690
69917
|
}
|
|
69691
69918
|
const rebuild = /^(1|true)$/i.test(String(req.query?.rebuild ?? ""));
|
|
69692
|
-
|
|
69919
|
+
if (entry2.filter && !emittedFilter(entry2.filter)) {
|
|
69920
|
+
return reply.status(409).send({
|
|
69921
|
+
ok: false,
|
|
69922
|
+
code: "reference-filter-unreadable",
|
|
69923
|
+
error: `"${entry2.name}" records which part of the file to load, but not in a form FloLess can read. Remove the reference and add it again to choose the storeys afresh.`
|
|
69924
|
+
});
|
|
69925
|
+
}
|
|
69926
|
+
const stored2 = entry2.filter;
|
|
69927
|
+
const hit = rebuild ? null : cachedGeometry(g.project, entry2.id, sourceHash, stored2);
|
|
69693
69928
|
if (hit) return { ok: true, cached: true, objects: hit.objects, dropped: hit.dropped, colorsAvailable: hit.colorsAvailable ?? null, colorsDropped: hit.colorsDropped ?? 0, propertySetsAvailable: hit.propertySetsAvailable ?? null, spanMm: spanOf(hit.objects) };
|
|
69694
69929
|
try {
|
|
69695
|
-
const geometry = await deps.reader.readModel(companion(g.appId), abs, { ticket: scope.ticket() });
|
|
69930
|
+
const geometry = await deps.reader.readModel(companion(g.appId), abs, { ticket: scope.ticket(), filter: stored2 });
|
|
69931
|
+
const missed = unmatchedNames(geometry.selected);
|
|
69932
|
+
if (!geometry.objects.length && hasUnmatched(geometry.selected)) {
|
|
69933
|
+
return reply.status(409).send({
|
|
69934
|
+
ok: false,
|
|
69935
|
+
code: "reference-filter-unmatched",
|
|
69936
|
+
error: unmatchedMessage(entry2.name, missed, "remove the reference and add it again to pick from the current list.")
|
|
69937
|
+
});
|
|
69938
|
+
}
|
|
69696
69939
|
if (!geometry.objects.length) {
|
|
69697
69940
|
return reply.status(409).send({
|
|
69698
69941
|
ok: false,
|
|
@@ -69700,8 +69943,19 @@ function registerReferenceRoutes(app, deps) {
|
|
|
69700
69943
|
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."
|
|
69701
69944
|
});
|
|
69702
69945
|
}
|
|
69703
|
-
|
|
69704
|
-
|
|
69946
|
+
if (objectVerdict(geometry.objects.length) === "refuse") {
|
|
69947
|
+
return reply.status(409).send({
|
|
69948
|
+
ok: false,
|
|
69949
|
+
code: "reference-too-many-objects",
|
|
69950
|
+
// ITS OWN SENTENCE, not `tooMany`'s. This path never probes, so it has no breakdown to judge
|
|
69951
|
+
// and no picker to offer — and routing it through a fabricated empty probe made the message
|
|
69952
|
+
// blame the user's IFC reader for a reference that may already carry a filter. The remedy
|
|
69953
|
+
// here is to re-add the reference and choose less of it.
|
|
69954
|
+
error: `"${entry2.name}" now reads ${geometry.objects.length.toLocaleString("en-US")} objects, and the limit is ${MAX_OBJECTS.toLocaleString("en-US")}. The file behind it has grown. Remove the reference and add it again to choose a smaller part of it.`
|
|
69955
|
+
});
|
|
69956
|
+
}
|
|
69957
|
+
writeCache2(g.project, entry2.id, { v: REFERENCE_CACHE_VERSION, sourceHash, dropped: geometry.dropped, colorsAvailable: geometry.colorsAvailable, colorsDropped: geometry.colorsDropped, propertySetsAvailable: geometry.propertySetsAvailable, ...stored2 ? { filter: stored2 } : {}, objects: geometry.objects });
|
|
69958
|
+
return { ok: true, cached: false, objects: geometry.objects, dropped: geometry.dropped, colorsAvailable: geometry.colorsAvailable, colorsDropped: geometry.colorsDropped, propertySetsAvailable: geometry.propertySetsAvailable, spanMm: spanOf(geometry.objects), ...hasUnmatched(geometry.selected) ? { unmatched: missed } : {} };
|
|
69705
69959
|
} catch (e) {
|
|
69706
69960
|
const r = importRefusal(e);
|
|
69707
69961
|
if (r) return reply.status(r.status).send(r.body);
|
|
@@ -69770,7 +70024,7 @@ var import_node_os18 = require("node:os");
|
|
|
69770
70024
|
var import_node_path34 = require("node:path");
|
|
69771
70025
|
|
|
69772
70026
|
// node_modules/write-excel-file/modules/export/writeXlsxFileNode.js
|
|
69773
|
-
var
|
|
70027
|
+
var import_node_fs37 = __toESM(require("node:fs"), 1);
|
|
69774
70028
|
|
|
69775
70029
|
// node_modules/write-excel-file/modules/xlsx/helpers/features/getAdditionalContent.js
|
|
69776
70030
|
function _createForOfIteratorHelperLoose(r, e) {
|
|
@@ -72870,7 +73124,7 @@ function writeXlsxFile(arg1, arg2, arg3) {
|
|
|
72870
73124
|
},
|
|
72871
73125
|
toFile: function toFile(filePath) {
|
|
72872
73126
|
return createReadableStream().then(function(readableStream) {
|
|
72873
|
-
return pipe(readableStream,
|
|
73127
|
+
return pipe(readableStream, import_node_fs37.default.createWriteStream(filePath));
|
|
72874
73128
|
});
|
|
72875
73129
|
}
|
|
72876
73130
|
};
|
|
@@ -73526,7 +73780,7 @@ function replyLifecycleLockBusyError(error, logger, reply) {
|
|
|
73526
73780
|
}
|
|
73527
73781
|
|
|
73528
73782
|
// project-export-files.ts
|
|
73529
|
-
var
|
|
73783
|
+
var import_node_fs38 = require("node:fs");
|
|
73530
73784
|
var import_node_path35 = require("node:path");
|
|
73531
73785
|
function projectExportFiles(appId, kindOf2 = appId) {
|
|
73532
73786
|
if (kindOf2 === "vectorize") {
|
|
@@ -73556,23 +73810,25 @@ function exportFileBase(projectId, appId, now = /* @__PURE__ */ new Date()) {
|
|
|
73556
73810
|
}
|
|
73557
73811
|
function uniqueProjectExportFilename(projectId, preferred) {
|
|
73558
73812
|
const dir = projectExportsDir(projectId);
|
|
73559
|
-
if (!(0,
|
|
73813
|
+
if (!(0, import_node_fs38.existsSync)((0, import_node_path35.join)(dir, preferred))) return preferred;
|
|
73560
73814
|
const extension = (0, import_node_path35.extname)(preferred);
|
|
73561
73815
|
const stem = preferred.slice(0, preferred.length - extension.length);
|
|
73562
73816
|
for (let suffix = 2; suffix <= 9999; suffix += 1) {
|
|
73563
73817
|
const candidate = `${stem}-${suffix}${extension}`;
|
|
73564
|
-
if (!(0,
|
|
73818
|
+
if (!(0, import_node_fs38.existsSync)((0, import_node_path35.join)(dir, candidate))) return candidate;
|
|
73565
73819
|
}
|
|
73566
73820
|
throw new Error("could not allocate a unique project export filename");
|
|
73567
73821
|
}
|
|
73568
73822
|
|
|
73569
73823
|
// workspace-approved-snapshot.ts
|
|
73570
73824
|
var WorkspaceSnapshotError = class extends Error {
|
|
73571
|
-
constructor(status, message) {
|
|
73825
|
+
constructor(status, message, notReviewable) {
|
|
73572
73826
|
super(message);
|
|
73573
73827
|
this.status = status;
|
|
73828
|
+
this.notReviewable = notReviewable;
|
|
73574
73829
|
}
|
|
73575
73830
|
status;
|
|
73831
|
+
notReviewable;
|
|
73576
73832
|
};
|
|
73577
73833
|
function approvedRows(projectId) {
|
|
73578
73834
|
const project = getProject(projectId);
|
|
@@ -74279,16 +74535,16 @@ function buildApprovalReview(input) {
|
|
|
74279
74535
|
|
|
74280
74536
|
// working-revision-manifest.ts
|
|
74281
74537
|
var import_node_crypto24 = require("node:crypto");
|
|
74282
|
-
var
|
|
74538
|
+
var import_node_fs40 = require("node:fs");
|
|
74283
74539
|
var import_node_path36 = require("node:path");
|
|
74284
74540
|
|
|
74285
74541
|
// write-json-atomic.ts
|
|
74286
74542
|
var import_node_crypto23 = require("node:crypto");
|
|
74287
|
-
var
|
|
74543
|
+
var import_node_fs39 = require("node:fs");
|
|
74288
74544
|
function writeJsonAtomic(path, value) {
|
|
74289
74545
|
const tmp = `${path}.${process.pid}.${(0, import_node_crypto23.randomUUID)()}.tmp`;
|
|
74290
|
-
(0,
|
|
74291
|
-
(0,
|
|
74546
|
+
(0, import_node_fs39.writeFileSync)(tmp, canonicalJson(value));
|
|
74547
|
+
(0, import_node_fs39.renameSync)(tmp, path);
|
|
74292
74548
|
}
|
|
74293
74549
|
|
|
74294
74550
|
// working-revision-manifest.ts
|
|
@@ -74305,7 +74561,7 @@ function assertProject(project) {
|
|
|
74305
74561
|
function readWorkingRevisionManifest(project) {
|
|
74306
74562
|
const uuid = assertProject(project);
|
|
74307
74563
|
try {
|
|
74308
|
-
const value = JSON.parse((0,
|
|
74564
|
+
const value = JSON.parse((0, import_node_fs40.readFileSync)(pathOf(project.id), "utf8"));
|
|
74309
74565
|
if (value?.schema !== 1 || value.projectUuid !== uuid || !Number.isInteger(value.epoch) || value.epoch < 0) return null;
|
|
74310
74566
|
return checksumOf(bodyOf(value)) === value.checksum ? value : null;
|
|
74311
74567
|
} catch {
|
|
@@ -74327,8 +74583,8 @@ function ensureWorkingRevisionManifest(input) {
|
|
|
74327
74583
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
74328
74584
|
};
|
|
74329
74585
|
const value = { ...body, checksum: checksumOf(body) };
|
|
74330
|
-
(0,
|
|
74331
|
-
if (!(0,
|
|
74586
|
+
(0, import_node_fs40.mkdirSync)(projectDir(input.project.id), { recursive: true });
|
|
74587
|
+
if (!(0, import_node_fs40.existsSync)(pathOf(input.project.id))) writeJsonAtomic(pathOf(input.project.id), value);
|
|
74332
74588
|
return readWorkingRevisionManifest(input.project) ?? value;
|
|
74333
74589
|
}
|
|
74334
74590
|
function advanceWorkingRevisionManifest(input) {
|
|
@@ -74438,9 +74694,21 @@ function mergeContractForward(base, latest, draft, resolutions = {}) {
|
|
|
74438
74694
|
function prepareProjectApprovalReview(projectId, deps) {
|
|
74439
74695
|
const project = getProject(projectId);
|
|
74440
74696
|
if (!project) throw new WorkspaceSnapshotError(404, `unknown project: ${projectId}`);
|
|
74441
|
-
if (!project.uuid) throw new WorkspaceSnapshotError(
|
|
74697
|
+
if (!project.uuid) throw new WorkspaceSnapshotError(
|
|
74698
|
+
409,
|
|
74699
|
+
"This project can\u2019t be approved \u2014 duplicate it from the Workspaces list to sign off",
|
|
74700
|
+
"no-incarnation"
|
|
74701
|
+
);
|
|
74442
74702
|
const draft = readAcceptedForRequest(project.app, projectId, "read");
|
|
74443
|
-
if (draft == null)
|
|
74703
|
+
if (draft == null) {
|
|
74704
|
+
if (storedContractBytesExist(project.app, projectId)) {
|
|
74705
|
+
throw new WorkspaceSnapshotError(
|
|
74706
|
+
409,
|
|
74707
|
+
"This project\u2019s saved model is there but could not be read. Close anything that has it open, then reload."
|
|
74708
|
+
);
|
|
74709
|
+
}
|
|
74710
|
+
throw new WorkspaceSnapshotError(404, "Nothing to approve yet \u2014 read a drawing into this project first", "no-contract");
|
|
74711
|
+
}
|
|
74444
74712
|
const row = latestApprovedVersion(projectId);
|
|
74445
74713
|
const manifest = readWorkingRevisionManifest(project);
|
|
74446
74714
|
let baseContract = null;
|
|
@@ -74580,7 +74848,7 @@ function projectApprovalCandidateAccepted(appId, projectId, candidate) {
|
|
|
74580
74848
|
|
|
74581
74849
|
// project-checkpoints-store.ts
|
|
74582
74850
|
var import_node_crypto25 = require("node:crypto");
|
|
74583
|
-
var
|
|
74851
|
+
var import_node_fs41 = require("node:fs");
|
|
74584
74852
|
var import_node_path37 = require("node:path");
|
|
74585
74853
|
var HASH_RE2 = /^[0-9a-f]{64}$/;
|
|
74586
74854
|
function root4(projectId) {
|
|
@@ -74590,7 +74858,7 @@ var objectsDir2 = (projectId) => (0, import_node_path37.join)(root4(projectId),
|
|
|
74590
74858
|
var eventsPath = (projectId) => (0, import_node_path37.join)(root4(projectId), "events.json");
|
|
74591
74859
|
function readEvents(projectId) {
|
|
74592
74860
|
try {
|
|
74593
|
-
const parsed = JSON.parse((0,
|
|
74861
|
+
const parsed = JSON.parse((0, import_node_fs41.readFileSync)(eventsPath(projectId), "utf8"));
|
|
74594
74862
|
if (parsed?.schema !== 1 || !Array.isArray(parsed.events)) return { schema: 1, events: [] };
|
|
74595
74863
|
return { schema: 1, events: parsed.events.filter(validEvent) };
|
|
74596
74864
|
} catch {
|
|
@@ -74605,7 +74873,7 @@ function validEvent(value) {
|
|
|
74605
74873
|
function readContent(projectId, id) {
|
|
74606
74874
|
if (!HASH_RE2.test(id)) return null;
|
|
74607
74875
|
try {
|
|
74608
|
-
const value = JSON.parse((0,
|
|
74876
|
+
const value = JSON.parse((0, import_node_fs41.readFileSync)((0, import_node_path37.join)(objectsDir2(projectId), `${id}.json`), "utf8"));
|
|
74609
74877
|
if (value?.schema !== 1 || value.id !== id || hashCheckpoint(value) !== id) return null;
|
|
74610
74878
|
return value;
|
|
74611
74879
|
} catch {
|
|
@@ -74621,7 +74889,7 @@ function requireIdentity(project) {
|
|
|
74621
74889
|
return project.uuid;
|
|
74622
74890
|
}
|
|
74623
74891
|
function appendEvent(projectId, event) {
|
|
74624
|
-
(0,
|
|
74892
|
+
(0, import_node_fs41.mkdirSync)(root4(projectId), { recursive: true });
|
|
74625
74893
|
const log2 = readEvents(projectId);
|
|
74626
74894
|
const row = { ...event, eventId: (0, import_node_crypto25.randomUUID)(), at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
74627
74895
|
log2.events.push(row);
|
|
@@ -74639,9 +74907,9 @@ function captureProjectCheckpoint(input) {
|
|
|
74639
74907
|
contract: input.contract
|
|
74640
74908
|
};
|
|
74641
74909
|
const id = hashCheckpoint(withoutId);
|
|
74642
|
-
(0,
|
|
74910
|
+
(0, import_node_fs41.mkdirSync)(objectsDir2(input.project.id), { recursive: true });
|
|
74643
74911
|
const path = (0, import_node_path37.join)(objectsDir2(input.project.id), `${id}.json`);
|
|
74644
|
-
if (!(0,
|
|
74912
|
+
if (!(0, import_node_fs41.existsSync)(path)) writeJsonAtomic(path, { ...withoutId, id });
|
|
74645
74913
|
const event = appendEvent(input.project.id, {
|
|
74646
74914
|
checkpointId: id,
|
|
74647
74915
|
kind: "captured",
|
|
@@ -74684,7 +74952,7 @@ function markProjectCheckpoint(project, checkpointId, kind, expectedEventId) {
|
|
|
74684
74952
|
|
|
74685
74953
|
// export-source.ts
|
|
74686
74954
|
var import_node_crypto26 = require("node:crypto");
|
|
74687
|
-
var
|
|
74955
|
+
var import_node_fs42 = require("node:fs");
|
|
74688
74956
|
var import_node_os19 = require("node:os");
|
|
74689
74957
|
var import_node_path38 = require("node:path");
|
|
74690
74958
|
var HANDLE_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
@@ -74707,7 +74975,7 @@ function validId(id) {
|
|
|
74707
74975
|
function readExportHandle(handleId) {
|
|
74708
74976
|
if (!validId(handleId)) return null;
|
|
74709
74977
|
try {
|
|
74710
|
-
const value = JSON.parse((0,
|
|
74978
|
+
const value = JSON.parse((0, import_node_fs42.readFileSync)(handlePath(handleId), "utf8"));
|
|
74711
74979
|
if (value?.schema !== 1 || value.handleId !== handleId || value.checksum !== hashOf(withoutChecksum(value))) return null;
|
|
74712
74980
|
return value;
|
|
74713
74981
|
} catch {
|
|
@@ -74716,7 +74984,7 @@ function readExportHandle(handleId) {
|
|
|
74716
74984
|
}
|
|
74717
74985
|
function captureExportSource(projectId, selector = { kind: "latest-approved" }, isDerivedEligible) {
|
|
74718
74986
|
collectExpiredExportHandles();
|
|
74719
|
-
if ((0,
|
|
74987
|
+
if ((0, import_node_fs42.existsSync)(storeRoot()) && (0, import_node_fs42.readdirSync)(storeRoot()).filter((name) => name.endsWith(".json")).length >= MAX_STORED_HANDLES) {
|
|
74720
74988
|
throw new Error("too many frozen export sources are waiting; finish or retry older exports first");
|
|
74721
74989
|
}
|
|
74722
74990
|
const project = getProject(projectId);
|
|
@@ -74802,7 +75070,7 @@ function captureExportSource(projectId, selector = { kind: "latest-approved" },
|
|
|
74802
75070
|
expiresAt: new Date(Date.now() + HANDLE_TTL_MS).toISOString(),
|
|
74803
75071
|
resultRefs: []
|
|
74804
75072
|
};
|
|
74805
|
-
(0,
|
|
75073
|
+
(0, import_node_fs42.mkdirSync)(storeRoot(), { recursive: true });
|
|
74806
75074
|
writeJsonAtomic(handlePath(handleId), stored(body));
|
|
74807
75075
|
const { contract: _contract, lease: _lease, expiresAt: _expiresAt, resultRefs: _refs, checksum: _checksum, ...resolved } = readExportHandle(handleId);
|
|
74808
75076
|
return resolved;
|
|
@@ -74814,7 +75082,7 @@ function cloneExportHandle(handleId, copies) {
|
|
|
74814
75082
|
if (!original || original.lease !== "active" || Date.parse(original.expiresAt) <= Date.now()) {
|
|
74815
75083
|
throw new Error("export source handle is unavailable");
|
|
74816
75084
|
}
|
|
74817
|
-
const storedCount = (0,
|
|
75085
|
+
const storedCount = (0, import_node_fs42.existsSync)(storeRoot()) ? (0, import_node_fs42.readdirSync)(storeRoot()).filter((name) => name.endsWith(".json")).length : 0;
|
|
74818
75086
|
if (storedCount + copies - 1 > MAX_STORED_HANDLES) throw new Error("too many frozen export sources are waiting");
|
|
74819
75087
|
const results = [];
|
|
74820
75088
|
const created = [];
|
|
@@ -74829,7 +75097,7 @@ function cloneExportHandle(handleId, copies) {
|
|
|
74829
75097
|
results.push(resolved);
|
|
74830
75098
|
}
|
|
74831
75099
|
} catch (error) {
|
|
74832
|
-
for (const id of created) (0,
|
|
75100
|
+
for (const id of created) (0, import_node_fs42.rmSync)(handlePath(id), { force: true });
|
|
74833
75101
|
throw error;
|
|
74834
75102
|
}
|
|
74835
75103
|
return results;
|
|
@@ -74869,21 +75137,21 @@ function releaseUnusedExportHandle(handleId, projectId, projectUuid) {
|
|
|
74869
75137
|
}
|
|
74870
75138
|
function projectIdHasActiveExportLeases(projectId) {
|
|
74871
75139
|
collectExpiredExportHandles();
|
|
74872
|
-
if (!(0,
|
|
74873
|
-
return (0,
|
|
75140
|
+
if (!(0, import_node_fs42.existsSync)(storeRoot())) return false;
|
|
75141
|
+
return (0, import_node_fs42.readdirSync)(storeRoot()).some((name) => {
|
|
74874
75142
|
const handle = name.endsWith(".json") ? readExportHandle(name.slice(0, -5)) : null;
|
|
74875
75143
|
return handle?.projectId === projectId && handle.lease === "active" && Date.parse(handle.expiresAt) > Date.now();
|
|
74876
75144
|
});
|
|
74877
75145
|
}
|
|
74878
75146
|
function collectExpiredExportHandles(now = Date.now()) {
|
|
74879
|
-
if (!(0,
|
|
75147
|
+
if (!(0, import_node_fs42.existsSync)(storeRoot())) return 0;
|
|
74880
75148
|
let removed = 0;
|
|
74881
|
-
for (const name of (0,
|
|
75149
|
+
for (const name of (0, import_node_fs42.readdirSync)(storeRoot())) {
|
|
74882
75150
|
if (!name.endsWith(".json")) continue;
|
|
74883
75151
|
const id = name.slice(0, -5);
|
|
74884
75152
|
const handle = readExportHandle(id);
|
|
74885
75153
|
if (!handle || Date.parse(handle.expiresAt) <= now && handle.resultRefs.length === 0) {
|
|
74886
|
-
(0,
|
|
75154
|
+
(0, import_node_fs42.rmSync)(handlePath(id), { force: true });
|
|
74887
75155
|
removed++;
|
|
74888
75156
|
}
|
|
74889
75157
|
}
|
|
@@ -74892,7 +75160,7 @@ function collectExpiredExportHandles(now = Date.now()) {
|
|
|
74892
75160
|
|
|
74893
75161
|
// file-publication.ts
|
|
74894
75162
|
var import_node_crypto27 = require("node:crypto");
|
|
74895
|
-
var
|
|
75163
|
+
var import_node_fs43 = require("node:fs");
|
|
74896
75164
|
var import_node_path39 = require("node:path");
|
|
74897
75165
|
var FilePublicationError = class extends Error {
|
|
74898
75166
|
constructor(message, code, paths = []) {
|
|
@@ -74910,7 +75178,7 @@ var proofOfBytes = (bytes) => ({
|
|
|
74910
75178
|
});
|
|
74911
75179
|
function readFileProof2(path) {
|
|
74912
75180
|
try {
|
|
74913
|
-
return proofOfBytes((0,
|
|
75181
|
+
return proofOfBytes((0, import_node_fs43.readFileSync)(path));
|
|
74914
75182
|
} catch (error) {
|
|
74915
75183
|
if (error.code === "ENOENT") return null;
|
|
74916
75184
|
throw error;
|
|
@@ -74920,38 +75188,38 @@ function fileProofEquals2(a, b) {
|
|
|
74920
75188
|
return a === null || b === null ? a === b : a.bytes === b.bytes && a.sha256 === b.sha256;
|
|
74921
75189
|
}
|
|
74922
75190
|
function syncFile3(path) {
|
|
74923
|
-
const fd2 = (0,
|
|
75191
|
+
const fd2 = (0, import_node_fs43.openSync)(path, "r+");
|
|
74924
75192
|
try {
|
|
74925
|
-
(0,
|
|
75193
|
+
(0, import_node_fs43.fsyncSync)(fd2);
|
|
74926
75194
|
} finally {
|
|
74927
|
-
(0,
|
|
75195
|
+
(0, import_node_fs43.closeSync)(fd2);
|
|
74928
75196
|
}
|
|
74929
75197
|
}
|
|
74930
75198
|
function syncDirectoryBestEffort3(path) {
|
|
74931
75199
|
try {
|
|
74932
|
-
const fd2 = (0,
|
|
75200
|
+
const fd2 = (0, import_node_fs43.openSync)(path, "r");
|
|
74933
75201
|
try {
|
|
74934
|
-
(0,
|
|
75202
|
+
(0, import_node_fs43.fsyncSync)(fd2);
|
|
74935
75203
|
} finally {
|
|
74936
|
-
(0,
|
|
75204
|
+
(0, import_node_fs43.closeSync)(fd2);
|
|
74937
75205
|
}
|
|
74938
75206
|
} catch {
|
|
74939
75207
|
}
|
|
74940
75208
|
}
|
|
74941
75209
|
function durableCanonicalJson(path, value) {
|
|
74942
75210
|
const dir = (0, import_node_path39.dirname)(path);
|
|
74943
|
-
(0,
|
|
75211
|
+
(0, import_node_fs43.mkdirSync)(dir, { recursive: true });
|
|
74944
75212
|
const temp = (0, import_node_path39.join)(dir, `.${(0, import_node_path39.basename)(path)}.${process.pid}.${(0, import_node_crypto27.randomUUID)()}.tmp`);
|
|
74945
75213
|
try {
|
|
74946
|
-
(0,
|
|
75214
|
+
(0, import_node_fs43.writeFileSync)(temp, `${canonicalJson(value)}
|
|
74947
75215
|
`, { encoding: "utf8", flag: "wx" });
|
|
74948
75216
|
syncFile3(temp);
|
|
74949
|
-
(0,
|
|
75217
|
+
(0, import_node_fs43.renameSync)(temp, path);
|
|
74950
75218
|
syncFile3(path);
|
|
74951
75219
|
syncDirectoryBestEffort3(dir);
|
|
74952
75220
|
} finally {
|
|
74953
75221
|
try {
|
|
74954
|
-
(0,
|
|
75222
|
+
(0, import_node_fs43.rmSync)(temp, { force: true });
|
|
74955
75223
|
} catch {
|
|
74956
75224
|
}
|
|
74957
75225
|
}
|
|
@@ -74970,7 +75238,7 @@ function mappedError(error, paths) {
|
|
|
74970
75238
|
}
|
|
74971
75239
|
function linkExclusive(source, destination) {
|
|
74972
75240
|
try {
|
|
74973
|
-
(0,
|
|
75241
|
+
(0, import_node_fs43.linkSync)(source, destination);
|
|
74974
75242
|
} catch (error) {
|
|
74975
75243
|
throw mappedError(error, [source, destination]);
|
|
74976
75244
|
}
|
|
@@ -74979,27 +75247,27 @@ function assertSameVolume(a, b) {
|
|
|
74979
75247
|
let aDev;
|
|
74980
75248
|
let bDev;
|
|
74981
75249
|
try {
|
|
74982
|
-
aDev = (0,
|
|
74983
|
-
bDev = (0,
|
|
75250
|
+
aDev = (0, import_node_fs43.statSync)(a, { bigint: true }).dev;
|
|
75251
|
+
bDev = (0, import_node_fs43.statSync)(b, { bigint: true }).dev;
|
|
74984
75252
|
} catch (error) {
|
|
74985
75253
|
throw mappedError(error, [a, b]);
|
|
74986
75254
|
}
|
|
74987
75255
|
if (aDev !== bDev) throw new FilePublicationError("publication paths are not on the same volume", "different-volume", [a, b]);
|
|
74988
75256
|
}
|
|
74989
75257
|
function uniqueArtifact(dir, label2, livePath) {
|
|
74990
|
-
(0,
|
|
75258
|
+
(0, import_node_fs43.mkdirSync)(dir, { recursive: true });
|
|
74991
75259
|
return (0, import_node_path39.join)(dir, `.floless-${label2}-${(0, import_node_crypto27.randomUUID)()}-${(0, import_node_path39.basename)(livePath)}`);
|
|
74992
75260
|
}
|
|
74993
75261
|
function publishFileExclusive(input) {
|
|
74994
75262
|
const { livePath, stagedPath, expectedLive, artifactDir } = input;
|
|
74995
|
-
assertSameVolume(stagedPath, (0,
|
|
75263
|
+
assertSameVolume(stagedPath, (0, import_node_fs43.existsSync)(livePath) ? livePath : (0, import_node_path39.dirname)(livePath));
|
|
74996
75264
|
const stagedProof = readFileProof2(stagedPath);
|
|
74997
75265
|
if (!stagedProof) throw new FilePublicationError("staged publication file is missing", "io-failure", [stagedPath]);
|
|
74998
75266
|
let beforeImage = null;
|
|
74999
75267
|
if (expectedLive) {
|
|
75000
75268
|
beforeImage = uniqueArtifact(artifactDir, "before", livePath);
|
|
75001
75269
|
try {
|
|
75002
|
-
(0,
|
|
75270
|
+
(0, import_node_fs43.renameSync)(livePath, beforeImage);
|
|
75003
75271
|
} catch (error) {
|
|
75004
75272
|
throw mappedError(error, [livePath, beforeImage]);
|
|
75005
75273
|
}
|
|
@@ -75011,19 +75279,19 @@ function publishFileExclusive(input) {
|
|
|
75011
75279
|
}
|
|
75012
75280
|
throw new FilePublicationError("the live file changed before publication", "live-changed", [livePath, beforeImage]);
|
|
75013
75281
|
}
|
|
75014
|
-
} else if ((0,
|
|
75282
|
+
} else if ((0, import_node_fs43.existsSync)(livePath)) {
|
|
75015
75283
|
throw new FilePublicationError("the live destination appeared before publication", "destination-exists", [livePath]);
|
|
75016
75284
|
}
|
|
75017
75285
|
try {
|
|
75018
75286
|
input.onFaultPoint?.("after-live-move", { livePath, stagedPath, beforeImage });
|
|
75019
75287
|
linkExclusive(stagedPath, livePath);
|
|
75020
75288
|
input.onFaultPoint?.("after-live-link", { livePath, stagedPath, beforeImage });
|
|
75021
|
-
(0,
|
|
75289
|
+
(0, import_node_fs43.unlinkSync)(stagedPath);
|
|
75022
75290
|
input.onFaultPoint?.("after-staged-unlink", { livePath, stagedPath, beforeImage });
|
|
75023
75291
|
syncFile3(livePath);
|
|
75024
75292
|
syncDirectoryBestEffort3((0, import_node_path39.dirname)(livePath));
|
|
75025
75293
|
} catch (error) {
|
|
75026
|
-
if (beforeImage && !(0,
|
|
75294
|
+
if (beforeImage && !(0, import_node_fs43.existsSync)(livePath)) {
|
|
75027
75295
|
try {
|
|
75028
75296
|
linkExclusive(beforeImage, livePath);
|
|
75029
75297
|
} catch {
|
|
@@ -75046,7 +75314,7 @@ function publishFileExclusive(input) {
|
|
|
75046
75314
|
var import_node_path41 = require("node:path");
|
|
75047
75315
|
|
|
75048
75316
|
// app-source-lock.ts
|
|
75049
|
-
var
|
|
75317
|
+
var import_node_fs44 = require("node:fs");
|
|
75050
75318
|
var import_node_os20 = require("node:os");
|
|
75051
75319
|
var import_node_path40 = require("node:path");
|
|
75052
75320
|
var AppSourcePublicationBusyError = class extends Error {
|
|
@@ -75059,9 +75327,9 @@ var AppSourcePublicationBusyError = class extends Error {
|
|
|
75059
75327
|
function activeApprovalTransaction(appId) {
|
|
75060
75328
|
const home = process.env.AWARE_HOME || (0, import_node_path40.join)((0, import_node_os20.homedir)(), ".aware");
|
|
75061
75329
|
const path = (0, import_node_path40.join)(home, "apps", appId, ".floless-approval-publication-journal-v1.json");
|
|
75062
|
-
if (!(0,
|
|
75330
|
+
if (!(0, import_node_fs44.existsSync)(path)) return null;
|
|
75063
75331
|
try {
|
|
75064
|
-
const stored2 = JSON.parse((0,
|
|
75332
|
+
const stored2 = JSON.parse((0, import_node_fs44.readFileSync)(path, "utf8"));
|
|
75065
75333
|
return typeof stored2?.journal?.id === "string" && stored2.journal.id ? stored2.journal.id : "__invalid__";
|
|
75066
75334
|
} catch {
|
|
75067
75335
|
return "__invalid__";
|
|
@@ -75077,7 +75345,7 @@ function withAppSourceLock(appId, label2, fn, options = {}) {
|
|
|
75077
75345
|
|
|
75078
75346
|
// app-publication-manifest.ts
|
|
75079
75347
|
var import_node_crypto28 = require("node:crypto");
|
|
75080
|
-
var
|
|
75348
|
+
var import_node_fs45 = require("node:fs");
|
|
75081
75349
|
var import_yaml7 = __toESM(require_dist6(), 1);
|
|
75082
75350
|
var APP_PUBLICATION_MANIFEST_SCHEMA = 1;
|
|
75083
75351
|
var AppPublicationManifestError = class extends Error {
|
|
@@ -75094,7 +75362,7 @@ function observeAppPublication(sourcePath, lockPath2) {
|
|
|
75094
75362
|
let lockSourceHash = null;
|
|
75095
75363
|
if (lock) {
|
|
75096
75364
|
try {
|
|
75097
|
-
const parsed = (0, import_yaml7.parse)((0,
|
|
75365
|
+
const parsed = (0, import_yaml7.parse)((0, import_node_fs45.readFileSync)(lockPath2, "utf8"));
|
|
75098
75366
|
lockSourceHash = typeof parsed?.["source-hash"] === "string" ? parsed["source-hash"] : null;
|
|
75099
75367
|
} catch {
|
|
75100
75368
|
}
|
|
@@ -75119,10 +75387,10 @@ function validManifest(value) {
|
|
|
75119
75387
|
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);
|
|
75120
75388
|
}
|
|
75121
75389
|
function readAppPublicationManifest(path) {
|
|
75122
|
-
if (!(0,
|
|
75390
|
+
if (!(0, import_node_fs45.existsSync)(path)) return null;
|
|
75123
75391
|
let stored2;
|
|
75124
75392
|
try {
|
|
75125
|
-
stored2 = JSON.parse((0,
|
|
75393
|
+
stored2 = JSON.parse((0, import_node_fs45.readFileSync)(path, "utf8"));
|
|
75126
75394
|
} catch {
|
|
75127
75395
|
throw new AppPublicationManifestError(`app publication manifest is unreadable: ${path}`, "corrupt");
|
|
75128
75396
|
}
|
|
@@ -75315,7 +75583,7 @@ function withAppPublicationWhileProjectLocked(input) {
|
|
|
75315
75583
|
|
|
75316
75584
|
// approval-app-publication.ts
|
|
75317
75585
|
var import_node_crypto29 = require("node:crypto");
|
|
75318
|
-
var
|
|
75586
|
+
var import_node_fs46 = require("node:fs");
|
|
75319
75587
|
var import_node_path42 = require("node:path");
|
|
75320
75588
|
var JOURNAL = ".floless-approval-publication-journal-v1.json";
|
|
75321
75589
|
var MANIFEST = ".floless-app-publication-state-v1.json";
|
|
@@ -75342,7 +75610,7 @@ function storeJournal(journal) {
|
|
|
75342
75610
|
}
|
|
75343
75611
|
function readApprovalPublicationJournal(sourcePath) {
|
|
75344
75612
|
try {
|
|
75345
|
-
const stored2 = JSON.parse((0,
|
|
75613
|
+
const stored2 = JSON.parse((0, import_node_fs46.readFileSync)(approvalPublicationJournalPath(sourcePath), "utf8"));
|
|
75346
75614
|
const value = stored2?.journal;
|
|
75347
75615
|
const expectedLiveLock = sourcePath.replace(/\.[^.]+$/, ".lock");
|
|
75348
75616
|
const expectedStageDir = (0, import_node_path42.join)(stagingRoot2(sourcePath), `${value?.appId ?? ""}-${value?.id ?? ""}`);
|
|
@@ -75368,8 +75636,8 @@ async function stageApprovalPublication(input) {
|
|
|
75368
75636
|
const beforeSource = readFileProof2(input.sourcePath);
|
|
75369
75637
|
const beforeLock = readFileProof2(input.liveLockPath);
|
|
75370
75638
|
try {
|
|
75371
|
-
(0,
|
|
75372
|
-
(0,
|
|
75639
|
+
(0, import_node_fs46.mkdirSync)(stageDir, { recursive: true });
|
|
75640
|
+
(0, import_node_fs46.cpSync)(appRoot, stagedAppRoot, {
|
|
75373
75641
|
recursive: true,
|
|
75374
75642
|
filter: (path) => ![JOURNAL, MANIFEST].includes((0, import_node_path42.basename)(path))
|
|
75375
75643
|
});
|
|
@@ -75382,7 +75650,7 @@ async function stageApprovalPublication(input) {
|
|
|
75382
75650
|
throw new Error("live workflow changed while the approval was being staged");
|
|
75383
75651
|
}
|
|
75384
75652
|
} catch (error) {
|
|
75385
|
-
(0,
|
|
75653
|
+
(0, import_node_fs46.rmSync)(stageDir, { recursive: true, force: true });
|
|
75386
75654
|
throw error;
|
|
75387
75655
|
}
|
|
75388
75656
|
const journal = {
|
|
@@ -75415,12 +75683,12 @@ function publishOne(livePath, stagedPath, before, staged, artifactDir) {
|
|
|
75415
75683
|
const live = readFileProof2(livePath);
|
|
75416
75684
|
if (fileProofEquals2(live, staged)) return;
|
|
75417
75685
|
if (!fileProofEquals2(live, before)) throw new Error(`live publication changed outside the approval transaction: ${livePath}`);
|
|
75418
|
-
if (!(0,
|
|
75686
|
+
if (!(0, import_node_fs46.existsSync)(stagedPath)) throw new Error(`staged publication bytes are unavailable: ${stagedPath}`);
|
|
75419
75687
|
publishFileExclusive({ livePath, stagedPath, expectedLive: before, artifactDir });
|
|
75420
75688
|
}
|
|
75421
75689
|
function completeApprovalPublication(journal) {
|
|
75422
75690
|
if (journal.phase !== "authorized" && journal.phase !== "published") throw new Error("approval publication is not authorized");
|
|
75423
|
-
(0,
|
|
75691
|
+
(0, import_node_fs46.mkdirSync)(journal.artifactDir, { recursive: true });
|
|
75424
75692
|
publishOne(journal.liveSourcePath, journal.stagedSourcePath, journal.beforeSource, journal.stagedSource, journal.artifactDir);
|
|
75425
75693
|
publishOne(journal.liveLockPath, journal.stagedLockPath, journal.beforeLock, journal.stagedLock, journal.artifactDir);
|
|
75426
75694
|
if (!fileProofEquals2(readFileProof2(journal.liveSourcePath), journal.stagedSource) || !fileProofEquals2(readFileProof2(journal.liveLockPath), journal.stagedLock)) {
|
|
@@ -75433,17 +75701,17 @@ function finalizeApprovalPublication(journal) {
|
|
|
75433
75701
|
if (!current || current.id !== journal.id || current.phase !== "published") {
|
|
75434
75702
|
throw new Error("published approval recovery authority is unavailable");
|
|
75435
75703
|
}
|
|
75436
|
-
(0,
|
|
75437
|
-
(0,
|
|
75704
|
+
(0, import_node_fs46.rmSync)(journal.stageDir, { recursive: true, force: true });
|
|
75705
|
+
(0, import_node_fs46.rmSync)(approvalPublicationJournalPath(journal.liveSourcePath), { force: true });
|
|
75438
75706
|
}
|
|
75439
75707
|
function abandonApprovalPublication(journal) {
|
|
75440
75708
|
if (journal.phase !== "staged") throw new Error("an authorized approval publication must be completed, not abandoned");
|
|
75441
|
-
(0,
|
|
75442
|
-
(0,
|
|
75709
|
+
(0, import_node_fs46.rmSync)(approvalPublicationJournalPath(journal.liveSourcePath), { force: true });
|
|
75710
|
+
(0, import_node_fs46.rmSync)(journal.stageDir, { recursive: true, force: true });
|
|
75443
75711
|
}
|
|
75444
75712
|
|
|
75445
75713
|
// workspace-data.ts
|
|
75446
|
-
var
|
|
75714
|
+
var import_node_fs47 = require("node:fs");
|
|
75447
75715
|
var VALID_INCLUDES = /* @__PURE__ */ new Set(["contract", "exports"]);
|
|
75448
75716
|
var VALID_EXPORT_KINDS = /* @__PURE__ */ new Set([
|
|
75449
75717
|
"bom-csv",
|
|
@@ -75504,15 +75772,15 @@ function exportBody(projectId, receipt, opts) {
|
|
|
75504
75772
|
};
|
|
75505
75773
|
if (opts.includePaths) body.path = path;
|
|
75506
75774
|
if (opts.exportContents) {
|
|
75507
|
-
const st = (0,
|
|
75775
|
+
const st = (0, import_node_fs47.statSync)(path);
|
|
75508
75776
|
if (st.size > opts.maxBytes) {
|
|
75509
75777
|
body.contentOmitted = true;
|
|
75510
75778
|
body.omittedReason = `export is ${st.size} bytes, over max-bytes ${opts.maxBytes}`;
|
|
75511
75779
|
} else if (receipt.encoding === "base64") {
|
|
75512
|
-
body.content = (0,
|
|
75780
|
+
body.content = (0, import_node_fs47.readFileSync)(path).toString("base64");
|
|
75513
75781
|
} else {
|
|
75514
75782
|
body.encoding = receipt.encoding ?? "utf8";
|
|
75515
|
-
body.content = (0,
|
|
75783
|
+
body.content = (0, import_node_fs47.readFileSync)(path, "utf8");
|
|
75516
75784
|
}
|
|
75517
75785
|
}
|
|
75518
75786
|
return body;
|
|
@@ -75791,7 +76059,7 @@ function registerMigrationCommitRoute(app, deps) {
|
|
|
75791
76059
|
}
|
|
75792
76060
|
|
|
75793
76061
|
// workspace-agent-manifest.ts
|
|
75794
|
-
var
|
|
76062
|
+
var import_node_fs48 = require("node:fs");
|
|
75795
76063
|
var import_node_os21 = require("node:os");
|
|
75796
76064
|
var import_node_path43 = require("node:path");
|
|
75797
76065
|
function awareHome() {
|
|
@@ -75802,7 +76070,7 @@ function workspaceAgentDir() {
|
|
|
75802
76070
|
}
|
|
75803
76071
|
function syncWorkspaceAgentManifest(port) {
|
|
75804
76072
|
const dir = workspaceAgentDir();
|
|
75805
|
-
(0,
|
|
76073
|
+
(0, import_node_fs48.mkdirSync)(dir, { recursive: true });
|
|
75806
76074
|
const manifest = `agent: floless-workspace
|
|
75807
76075
|
version: 0.2.0
|
|
75808
76076
|
sdk-target: 2.4.0
|
|
@@ -75933,7 +76201,7 @@ commands:
|
|
|
75933
76201
|
body: object
|
|
75934
76202
|
`;
|
|
75935
76203
|
const path = (0, import_node_path43.join)(dir, "manifest.yaml");
|
|
75936
|
-
if (!(0,
|
|
76204
|
+
if (!(0, import_node_fs48.existsSync)(path) || manifest !== "") (0, import_node_fs48.writeFileSync)(path, manifest, "utf8");
|
|
75937
76205
|
return path;
|
|
75938
76206
|
}
|
|
75939
76207
|
|
|
@@ -77028,7 +77296,7 @@ function computeVersionDiff(id, n, base) {
|
|
|
77028
77296
|
}
|
|
77029
77297
|
|
|
77030
77298
|
// contract-bake.ts
|
|
77031
|
-
var
|
|
77299
|
+
var import_node_fs49 = require("node:fs");
|
|
77032
77300
|
var import_yaml8 = __toESM(require_dist6(), 1);
|
|
77033
77301
|
function isSteelType(t) {
|
|
77034
77302
|
return t === STEEL_V1 || t === STEEL_V2;
|
|
@@ -77052,7 +77320,7 @@ function bakedV2(contract) {
|
|
|
77052
77320
|
return stripConfidentialImages(baked);
|
|
77053
77321
|
}
|
|
77054
77322
|
function bakeContractIntoApp(sourcePath, contract) {
|
|
77055
|
-
const doc = (0, import_yaml8.parseDocument)((0,
|
|
77323
|
+
const doc = (0, import_yaml8.parseDocument)((0, import_node_fs49.readFileSync)(sourcePath, "utf8"));
|
|
77056
77324
|
if (doc.errors.length > 0) {
|
|
77057
77325
|
throw new Error(`contract bake: source is not valid YAML: ${doc.errors[0]?.message ?? "parse error"}`);
|
|
77058
77326
|
}
|
|
@@ -77076,7 +77344,7 @@ function bakeContractIntoApp(sourcePath, contract) {
|
|
|
77076
77344
|
throw new InvalidModelV2Error(`refusing to bake: contract declares steel.model/v2 but is not valid v2: ${issues[0] ?? "unknown"}`, issues);
|
|
77077
77345
|
}
|
|
77078
77346
|
doc.setIn(["nodes", idx, "config", "takeoff"], bakedV2(contract));
|
|
77079
|
-
(0,
|
|
77347
|
+
(0, import_node_fs49.writeFileSync)(sourcePath, doc.toString());
|
|
77080
77348
|
return;
|
|
77081
77349
|
}
|
|
77082
77350
|
const baked = { ...contract };
|
|
@@ -77121,7 +77389,7 @@ function bakeContractIntoApp(sourcePath, contract) {
|
|
|
77121
77389
|
);
|
|
77122
77390
|
}
|
|
77123
77391
|
doc.setIn(["nodes", idx, "config", "takeoff"], baked);
|
|
77124
|
-
(0,
|
|
77392
|
+
(0, import_node_fs49.writeFileSync)(sourcePath, doc.toString());
|
|
77125
77393
|
}
|
|
77126
77394
|
|
|
77127
77395
|
// vectorize.ts
|
|
@@ -77543,11 +77811,11 @@ function awareFailureMessage(e, fallback2) {
|
|
|
77543
77811
|
}
|
|
77544
77812
|
|
|
77545
77813
|
// scene-bake.ts
|
|
77546
|
-
var
|
|
77814
|
+
var import_node_fs50 = require("node:fs");
|
|
77547
77815
|
var import_node_path44 = require("node:path");
|
|
77548
77816
|
var import_yaml9 = __toESM(require_dist6(), 1);
|
|
77549
77817
|
function bakeSceneIntoApp(sourcePath, scene, agent = "viewer-3d") {
|
|
77550
|
-
const doc = (0, import_yaml9.parseDocument)((0,
|
|
77818
|
+
const doc = (0, import_yaml9.parseDocument)((0, import_node_fs50.readFileSync)(sourcePath, "utf8"));
|
|
77551
77819
|
if (doc.errors.length > 0) {
|
|
77552
77820
|
throw new Error(`scene bake: source is not valid YAML: ${doc.errors[0]?.message ?? "parse error"}`);
|
|
77553
77821
|
}
|
|
@@ -77556,10 +77824,10 @@ function bakeSceneIntoApp(sourcePath, scene, agent = "viewer-3d") {
|
|
|
77556
77824
|
const idx = items.findIndex((it) => ((0, import_yaml9.isMap)(it) ? it.toJSON() : null)?.agent === agent);
|
|
77557
77825
|
if (idx < 0) throw new Error(`no ${agent} render node to bake the scene into`);
|
|
77558
77826
|
doc.setIn(["nodes", idx, "config", "scene"], scene);
|
|
77559
|
-
(0,
|
|
77827
|
+
(0, import_node_fs50.writeFileSync)(sourcePath, doc.toString());
|
|
77560
77828
|
}
|
|
77561
77829
|
function bakeNodeConfigById(sourcePath, nodeId, patch2) {
|
|
77562
|
-
const doc = (0, import_yaml9.parseDocument)((0,
|
|
77830
|
+
const doc = (0, import_yaml9.parseDocument)((0, import_node_fs50.readFileSync)(sourcePath, "utf8"));
|
|
77563
77831
|
if (doc.errors.length > 0) {
|
|
77564
77832
|
throw new Error(`node bake: source is not valid YAML: ${doc.errors[0]?.message ?? "parse error"}`);
|
|
77565
77833
|
}
|
|
@@ -77568,12 +77836,12 @@ function bakeNodeConfigById(sourcePath, nodeId, patch2) {
|
|
|
77568
77836
|
const idx = items.findIndex((it) => ((0, import_yaml9.isMap)(it) ? it.toJSON() : null)?.id === nodeId);
|
|
77569
77837
|
if (idx < 0) throw new Error(`no node with id "${nodeId}"`);
|
|
77570
77838
|
for (const [key, value] of Object.entries(patch2)) doc.setIn(["nodes", idx, "config", key], value);
|
|
77571
|
-
(0,
|
|
77839
|
+
(0, import_node_fs50.writeFileSync)(sourcePath, doc.toString());
|
|
77572
77840
|
}
|
|
77573
77841
|
function writeViewer3dApp(dir, appId, scene) {
|
|
77574
|
-
(0,
|
|
77842
|
+
(0, import_node_fs50.mkdirSync)(dir, { recursive: true });
|
|
77575
77843
|
const flo = (0, import_node_path44.join)(dir, `${appId}.flo`);
|
|
77576
|
-
(0,
|
|
77844
|
+
(0, import_node_fs50.writeFileSync)(flo, [
|
|
77577
77845
|
`app: ${appId}`,
|
|
77578
77846
|
"version: 0.1.0",
|
|
77579
77847
|
"display-name: Steel 3D",
|
|
@@ -77596,18 +77864,18 @@ function writeViewer3dApp(dir, appId, scene) {
|
|
|
77596
77864
|
var COMPANION_MARKER = "# floless-companion: generated by FloLess \u2014 overwritten on every export";
|
|
77597
77865
|
function isCompanionApp(flo) {
|
|
77598
77866
|
try {
|
|
77599
|
-
return (0,
|
|
77867
|
+
return (0, import_node_fs50.readFileSync)(flo, "utf8").split(/\r?\n/, 1)[0]?.trim() === COMPANION_MARKER;
|
|
77600
77868
|
} catch (e) {
|
|
77601
77869
|
return e?.code === "ENOENT";
|
|
77602
77870
|
}
|
|
77603
77871
|
}
|
|
77604
77872
|
function writeBomReportApp(dir, appId, table) {
|
|
77605
|
-
(0,
|
|
77873
|
+
(0, import_node_fs50.mkdirSync)(dir, { recursive: true });
|
|
77606
77874
|
const flo = (0, import_node_path44.join)(dir, `${appId}.flo`);
|
|
77607
77875
|
if (!isCompanionApp(flo)) {
|
|
77608
77876
|
throw new Error(`refusing to overwrite "${appId}": an app of that name exists and FloLess did not write it`);
|
|
77609
77877
|
}
|
|
77610
|
-
(0,
|
|
77878
|
+
(0, import_node_fs50.writeFileSync)(flo, [
|
|
77611
77879
|
COMPANION_MARKER,
|
|
77612
77880
|
`app: ${appId}`,
|
|
77613
77881
|
"version: 0.1.0",
|
|
@@ -77634,9 +77902,9 @@ function writeBomReportApp(dir, appId, table) {
|
|
|
77634
77902
|
return flo;
|
|
77635
77903
|
}
|
|
77636
77904
|
function writeRevitApp(dir, appId, scene, hostPid, revitVersion = "2026") {
|
|
77637
|
-
(0,
|
|
77905
|
+
(0, import_node_fs50.mkdirSync)(dir, { recursive: true });
|
|
77638
77906
|
const flo = (0, import_node_path44.join)(dir, `${appId}.flo`);
|
|
77639
|
-
(0,
|
|
77907
|
+
(0, import_node_fs50.writeFileSync)(flo, [
|
|
77640
77908
|
`app: ${appId}`,
|
|
77641
77909
|
"version: 0.1.0",
|
|
77642
77910
|
"display-name: Steel to Revit",
|
|
@@ -77670,9 +77938,9 @@ function writeRevitApp(dir, appId, scene, hostPid, revitVersion = "2026") {
|
|
|
77670
77938
|
return flo;
|
|
77671
77939
|
}
|
|
77672
77940
|
function writeSketchupApp(dir, appId, scene) {
|
|
77673
|
-
(0,
|
|
77941
|
+
(0, import_node_fs50.mkdirSync)(dir, { recursive: true });
|
|
77674
77942
|
const flo = (0, import_node_path44.join)(dir, `${appId}.flo`);
|
|
77675
|
-
(0,
|
|
77943
|
+
(0, import_node_fs50.writeFileSync)(flo, [
|
|
77676
77944
|
`app: ${appId}`,
|
|
77677
77945
|
"version: 0.1.0",
|
|
77678
77946
|
"display-name: Steel to SketchUp",
|
|
@@ -77699,10 +77967,10 @@ function writeSketchupApp(dir, appId, scene) {
|
|
|
77699
77967
|
return flo;
|
|
77700
77968
|
}
|
|
77701
77969
|
function writeRhinoApp(dir, appId, scene, rhinoId, hostPid) {
|
|
77702
|
-
(0,
|
|
77970
|
+
(0, import_node_fs50.mkdirSync)(dir, { recursive: true });
|
|
77703
77971
|
const flo = (0, import_node_path44.join)(dir, `${appId}.flo`);
|
|
77704
77972
|
const exactRhinoId = typeof rhinoId === "string" && rhinoId.trim() ? rhinoId.trim() : null;
|
|
77705
|
-
(0,
|
|
77973
|
+
(0, import_node_fs50.writeFileSync)(flo, [
|
|
77706
77974
|
`app: ${appId}`,
|
|
77707
77975
|
"version: 0.1.0",
|
|
77708
77976
|
"display-name: Steel to Rhino",
|
|
@@ -77729,9 +77997,9 @@ function writeRhinoApp(dir, appId, scene, rhinoId, hostPid) {
|
|
|
77729
77997
|
return flo;
|
|
77730
77998
|
}
|
|
77731
77999
|
function writeTeklaApp(dir, appId, scene, teklaVersion = "2026.0") {
|
|
77732
|
-
(0,
|
|
78000
|
+
(0, import_node_fs50.mkdirSync)(dir, { recursive: true });
|
|
77733
78001
|
const flo = (0, import_node_path44.join)(dir, `${appId}.flo`);
|
|
77734
|
-
(0,
|
|
78002
|
+
(0, import_node_fs50.writeFileSync)(flo, [
|
|
77735
78003
|
`app: ${appId}`,
|
|
77736
78004
|
"version: 0.1.0",
|
|
77737
78005
|
"display-name: Steel to Tekla",
|
|
@@ -77895,7 +78163,7 @@ async function teklaVersionToBake() {
|
|
|
77895
78163
|
|
|
77896
78164
|
// export-companion.ts
|
|
77897
78165
|
var import_node_crypto30 = require("node:crypto");
|
|
77898
|
-
var
|
|
78166
|
+
var import_node_fs51 = require("node:fs");
|
|
77899
78167
|
var import_node_path45 = require("node:path");
|
|
77900
78168
|
var PREFIX = "floless-export-tmp-";
|
|
77901
78169
|
var LEASE = ".floless-export-lease.json";
|
|
@@ -77921,7 +78189,7 @@ function assertScratchPath(path, appsRoot) {
|
|
|
77921
78189
|
}
|
|
77922
78190
|
function removeScratch(path, appsRoot) {
|
|
77923
78191
|
assertScratchPath(path, appsRoot);
|
|
77924
|
-
(0,
|
|
78192
|
+
(0, import_node_fs51.rmSync)(path, { recursive: true, force: true });
|
|
77925
78193
|
}
|
|
77926
78194
|
function createExportCompanion(ownerId, sink, appsRoot = defaultAppsRoot()) {
|
|
77927
78195
|
const safeOwner = ownerId.replace(/[^a-z0-9._-]/gi, "-").slice(0, 80) || "app";
|
|
@@ -77934,10 +78202,10 @@ function createExportCompanion(ownerId, sink, appsRoot = defaultAppsRoot()) {
|
|
|
77934
78202
|
path,
|
|
77935
78203
|
token: token2,
|
|
77936
78204
|
cleanup: () => {
|
|
77937
|
-
if (!(0,
|
|
78205
|
+
if (!(0, import_node_fs51.existsSync)(path)) return;
|
|
77938
78206
|
let current = null;
|
|
77939
78207
|
try {
|
|
77940
|
-
current = JSON.parse((0,
|
|
78208
|
+
current = JSON.parse((0, import_node_fs51.readFileSync)((0, import_node_path45.resolve)(path, LEASE), "utf8"));
|
|
77941
78209
|
} catch {
|
|
77942
78210
|
}
|
|
77943
78211
|
if (current && current.token !== token2) throw new Error(`export companion lease changed for ${id}`);
|
|
@@ -77946,7 +78214,7 @@ function createExportCompanion(ownerId, sink, appsRoot = defaultAppsRoot()) {
|
|
|
77946
78214
|
};
|
|
77947
78215
|
}
|
|
77948
78216
|
function stampExportCompanionLease(companion2) {
|
|
77949
|
-
(0,
|
|
78217
|
+
(0, import_node_fs51.writeFileSync)((0, import_node_path45.resolve)(companion2.path, LEASE), JSON.stringify({
|
|
77950
78218
|
pid: process.pid,
|
|
77951
78219
|
token: companion2.token,
|
|
77952
78220
|
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -77954,19 +78222,19 @@ function stampExportCompanionLease(companion2) {
|
|
|
77954
78222
|
}
|
|
77955
78223
|
function sweepStaleExportCompanions(now = Date.now(), appsRoot = defaultAppsRoot()) {
|
|
77956
78224
|
const root5 = (0, import_node_path45.resolve)(appsRoot);
|
|
77957
|
-
if (!(0,
|
|
78225
|
+
if (!(0, import_node_fs51.existsSync)(root5)) return [];
|
|
77958
78226
|
const removed = [];
|
|
77959
|
-
for (const entry2 of (0,
|
|
78227
|
+
for (const entry2 of (0, import_node_fs51.readdirSync)(root5, { withFileTypes: true })) {
|
|
77960
78228
|
if (!entry2.isDirectory() || !entry2.name.startsWith(PREFIX)) continue;
|
|
77961
78229
|
const path = (0, import_node_path45.resolve)(root5, entry2.name);
|
|
77962
78230
|
let lease = null;
|
|
77963
78231
|
try {
|
|
77964
|
-
lease = JSON.parse((0,
|
|
78232
|
+
lease = JSON.parse((0, import_node_fs51.readFileSync)((0, import_node_path45.resolve)(path, LEASE), "utf8"));
|
|
77965
78233
|
} catch {
|
|
77966
78234
|
}
|
|
77967
78235
|
let created;
|
|
77968
78236
|
try {
|
|
77969
|
-
created = lease ? Date.parse(lease.createdAt) : (0,
|
|
78237
|
+
created = lease ? Date.parse(lease.createdAt) : (0, import_node_fs51.statSync)(path).mtimeMs;
|
|
77970
78238
|
} catch {
|
|
77971
78239
|
continue;
|
|
77972
78240
|
}
|
|
@@ -78540,14 +78808,14 @@ function looksLikeHostUnavailable(host, ...messages) {
|
|
|
78540
78808
|
}
|
|
78541
78809
|
|
|
78542
78810
|
// render-readiness.ts
|
|
78543
|
-
var
|
|
78811
|
+
var import_node_fs52 = require("node:fs");
|
|
78544
78812
|
var import_node_path46 = require("node:path");
|
|
78545
78813
|
var import_node_os22 = require("node:os");
|
|
78546
78814
|
var RENDER_AWARE_FLOOR = "0.103.0";
|
|
78547
78815
|
var RENDER_AGENT_ID = "blender";
|
|
78548
78816
|
function isFile(path) {
|
|
78549
78817
|
try {
|
|
78550
|
-
return (0,
|
|
78818
|
+
return (0, import_node_fs52.existsSync)(path) && (0, import_node_fs52.statSync)(path).isFile();
|
|
78551
78819
|
} catch {
|
|
78552
78820
|
return false;
|
|
78553
78821
|
}
|
|
@@ -78581,7 +78849,7 @@ function windowsCandidates(env2) {
|
|
|
78581
78849
|
for (const root5 of roots) {
|
|
78582
78850
|
let entries2;
|
|
78583
78851
|
try {
|
|
78584
|
-
entries2 = (0,
|
|
78852
|
+
entries2 = (0, import_node_fs52.readdirSync)(root5);
|
|
78585
78853
|
} catch {
|
|
78586
78854
|
continue;
|
|
78587
78855
|
}
|
|
@@ -78760,16 +79028,16 @@ function nothingToApprove(contract) {
|
|
|
78760
79028
|
}
|
|
78761
79029
|
|
|
78762
79030
|
// app-lifecycle.ts
|
|
78763
|
-
var
|
|
79031
|
+
var import_node_fs55 = require("node:fs");
|
|
78764
79032
|
var import_node_os24 = require("node:os");
|
|
78765
79033
|
var import_node_path49 = require("node:path");
|
|
78766
79034
|
|
|
78767
79035
|
// routines.ts
|
|
78768
|
-
var
|
|
79036
|
+
var import_node_fs54 = require("node:fs");
|
|
78769
79037
|
var import_node_path48 = require("node:path");
|
|
78770
79038
|
|
|
78771
79039
|
// trigger-sessions.ts
|
|
78772
|
-
var
|
|
79040
|
+
var import_node_fs53 = require("node:fs");
|
|
78773
79041
|
var import_node_os23 = require("node:os");
|
|
78774
79042
|
var import_node_path47 = require("node:path");
|
|
78775
79043
|
var import_yaml10 = __toESM(require_dist6(), 1);
|
|
@@ -78791,9 +79059,9 @@ function isHostBacked(agent, agentsDir = AGENTS_DIR2) {
|
|
|
78791
79059
|
const safe2 = (n) => !n.includes("/") && !n.includes("\\") && !n.includes("..");
|
|
78792
79060
|
if (!safe2(agent)) return false;
|
|
78793
79061
|
const manifestPath2 = (0, import_node_path47.join)(agentsDir, agent, "manifest.yaml");
|
|
78794
|
-
if (!(0,
|
|
79062
|
+
if (!(0, import_node_fs53.existsSync)(manifestPath2)) return false;
|
|
78795
79063
|
try {
|
|
78796
|
-
const doc = (0, import_yaml10.parse)((0,
|
|
79064
|
+
const doc = (0, import_yaml10.parse)((0, import_node_fs53.readFileSync)(manifestPath2, "utf8"));
|
|
78797
79065
|
const transport = doc?.transport;
|
|
78798
79066
|
return !!(transport && typeof transport === "object" && "cli" in transport);
|
|
78799
79067
|
} catch {
|
|
@@ -79137,10 +79405,10 @@ function sanitizeRoutine(raw) {
|
|
|
79137
79405
|
};
|
|
79138
79406
|
}
|
|
79139
79407
|
function loadFromDisk() {
|
|
79140
|
-
if (!(0,
|
|
79408
|
+
if (!(0, import_node_fs54.existsSync)(ROUTINES_FILE)) return [];
|
|
79141
79409
|
let text3;
|
|
79142
79410
|
try {
|
|
79143
|
-
text3 = (0,
|
|
79411
|
+
text3 = (0, import_node_fs54.readFileSync)(ROUTINES_FILE, "utf8");
|
|
79144
79412
|
} catch {
|
|
79145
79413
|
return [];
|
|
79146
79414
|
}
|
|
@@ -79149,17 +79417,17 @@ function loadFromDisk() {
|
|
|
79149
79417
|
return Array.isArray(parsed) ? parsed.map(sanitizeRoutine).filter((r) => r !== null) : [];
|
|
79150
79418
|
} catch {
|
|
79151
79419
|
try {
|
|
79152
|
-
(0,
|
|
79420
|
+
(0, import_node_fs54.renameSync)(ROUTINES_FILE, `${ROUTINES_FILE}.corrupt-${Date.now()}`);
|
|
79153
79421
|
} catch {
|
|
79154
79422
|
}
|
|
79155
79423
|
return [];
|
|
79156
79424
|
}
|
|
79157
79425
|
}
|
|
79158
79426
|
function saveRoutines() {
|
|
79159
|
-
if (!(0,
|
|
79427
|
+
if (!(0, import_node_fs54.existsSync)(flolessRoot)) (0, import_node_fs54.mkdirSync)(flolessRoot, { recursive: true });
|
|
79160
79428
|
const tmp = `${ROUTINES_FILE}.${process.pid}.tmp`;
|
|
79161
|
-
(0,
|
|
79162
|
-
(0,
|
|
79429
|
+
(0, import_node_fs54.writeFileSync)(tmp, JSON.stringify(routines, null, 2));
|
|
79430
|
+
(0, import_node_fs54.renameSync)(tmp, ROUTINES_FILE);
|
|
79163
79431
|
}
|
|
79164
79432
|
function listRoutines() {
|
|
79165
79433
|
ensureLoaded();
|
|
@@ -79585,7 +79853,7 @@ function appDirPath(id) {
|
|
|
79585
79853
|
return (0, import_node_path49.join)(appsDir(), id);
|
|
79586
79854
|
}
|
|
79587
79855
|
function appInstalled(id) {
|
|
79588
|
-
return APP_ID4.test(id) && (0,
|
|
79856
|
+
return APP_ID4.test(id) && (0, import_node_fs55.existsSync)(appDirPath(id));
|
|
79589
79857
|
}
|
|
79590
79858
|
function logCascade(what, e) {
|
|
79591
79859
|
console.error(`[app-lifecycle] cascade step failed (${what}):`, e instanceof Error ? e.message : e);
|
|
@@ -79823,7 +80091,7 @@ function isGatedAwareRoute(url, method) {
|
|
|
79823
80091
|
|
|
79824
80092
|
// autostart.mjs
|
|
79825
80093
|
var import_node_child_process8 = require("node:child_process");
|
|
79826
|
-
var
|
|
80094
|
+
var import_node_fs56 = require("node:fs");
|
|
79827
80095
|
var import_node_os25 = require("node:os");
|
|
79828
80096
|
var import_node_path50 = require("node:path");
|
|
79829
80097
|
|
|
@@ -79937,8 +80205,8 @@ function removeLegacyRunKey() {
|
|
|
79937
80205
|
}
|
|
79938
80206
|
function logLine(msg) {
|
|
79939
80207
|
try {
|
|
79940
|
-
(0,
|
|
79941
|
-
(0,
|
|
80208
|
+
(0, import_node_fs56.mkdirSync)(logDir(), { recursive: true });
|
|
80209
|
+
(0, import_node_fs56.appendFileSync)(logFilePath(), `${(/* @__PURE__ */ new Date()).toISOString()} ${msg}
|
|
79942
80210
|
`);
|
|
79943
80211
|
} catch {
|
|
79944
80212
|
}
|
|
@@ -79947,7 +80215,7 @@ function registerAutostart(exePath) {
|
|
|
79947
80215
|
if (!isWin) return;
|
|
79948
80216
|
const xml = buildAutostartTaskXml(exePath, currentUserId());
|
|
79949
80217
|
const tmp = (0, import_node_path50.join)((0, import_node_os25.tmpdir)(), `floless-autostart-${process.pid}-${Date.now()}.xml`);
|
|
79950
|
-
(0,
|
|
80218
|
+
(0, import_node_fs56.writeFileSync)(tmp, "\uFEFF" + xml, { encoding: "utf16le" });
|
|
79951
80219
|
try {
|
|
79952
80220
|
(0, import_node_child_process8.execFileSync)("schtasks", ["/Create", "/TN", TASK_NAME, "/XML", tmp, "/F"], {
|
|
79953
80221
|
stdio: ["ignore", "ignore", "ignore"],
|
|
@@ -79958,7 +80226,7 @@ function registerAutostart(exePath) {
|
|
|
79958
80226
|
throw err2;
|
|
79959
80227
|
} finally {
|
|
79960
80228
|
try {
|
|
79961
|
-
(0,
|
|
80229
|
+
(0, import_node_fs56.rmSync)(tmp, { force: true });
|
|
79962
80230
|
} catch {
|
|
79963
80231
|
}
|
|
79964
80232
|
}
|
|
@@ -79993,13 +80261,13 @@ function unregisterAutostart() {
|
|
|
79993
80261
|
// updater.ts
|
|
79994
80262
|
var import_node_child_process9 = require("node:child_process");
|
|
79995
80263
|
var import_node_crypto31 = require("node:crypto");
|
|
79996
|
-
var
|
|
80264
|
+
var import_node_fs58 = require("node:fs");
|
|
79997
80265
|
var import_node_stream3 = require("node:stream");
|
|
79998
80266
|
var import_promises5 = require("node:stream/promises");
|
|
79999
80267
|
var import_node_path52 = require("node:path");
|
|
80000
80268
|
|
|
80001
80269
|
// post-update-marker.mjs
|
|
80002
|
-
var
|
|
80270
|
+
var import_node_fs57 = require("node:fs");
|
|
80003
80271
|
var import_node_os26 = require("node:os");
|
|
80004
80272
|
var import_node_path51 = require("node:path");
|
|
80005
80273
|
var FRESH_MS = 12e4;
|
|
@@ -80022,7 +80290,7 @@ function writePostUpdateMarker() {
|
|
|
80022
80290
|
for (const p of [markerPath(), legacyMarkerPath()]) {
|
|
80023
80291
|
if (!p) continue;
|
|
80024
80292
|
try {
|
|
80025
|
-
(0,
|
|
80293
|
+
(0, import_node_fs57.writeFileSync)(p, (/* @__PURE__ */ new Date()).toISOString());
|
|
80026
80294
|
wrote = true;
|
|
80027
80295
|
} catch {
|
|
80028
80296
|
}
|
|
@@ -80034,9 +80302,9 @@ function consumePostUpdateMarker() {
|
|
|
80034
80302
|
for (const p of [markerPath(), legacyMarkerPath()]) {
|
|
80035
80303
|
if (!p) continue;
|
|
80036
80304
|
try {
|
|
80037
|
-
if (!(0,
|
|
80038
|
-
const ageMs = Date.now() - (0,
|
|
80039
|
-
(0,
|
|
80305
|
+
if (!(0, import_node_fs57.existsSync)(p)) continue;
|
|
80306
|
+
const ageMs = Date.now() - (0, import_node_fs57.statSync)(p).mtimeMs;
|
|
80307
|
+
(0, import_node_fs57.rmSync)(p, { force: true });
|
|
80040
80308
|
if (ageMs < FRESH_MS) fresh = true;
|
|
80041
80309
|
} catch {
|
|
80042
80310
|
}
|
|
@@ -80161,22 +80429,22 @@ async function checkForUpdate() {
|
|
|
80161
80429
|
}
|
|
80162
80430
|
async function sha1OfFile(path) {
|
|
80163
80431
|
const hash2 = (0, import_node_crypto31.createHash)("sha1");
|
|
80164
|
-
await (0, import_promises5.pipeline)((0,
|
|
80432
|
+
await (0, import_promises5.pipeline)((0, import_node_fs58.createReadStream)(path), hash2);
|
|
80165
80433
|
return hash2.digest("hex").toUpperCase();
|
|
80166
80434
|
}
|
|
80167
80435
|
async function downloadPackage(asset) {
|
|
80168
80436
|
if (!NUPKG_NAME.test(asset.FileName)) throw new Error(`refusing suspicious package name: ${asset.FileName}`);
|
|
80169
80437
|
const want = asset.SHA1.toUpperCase();
|
|
80170
80438
|
const dir = packagesDir();
|
|
80171
|
-
(0,
|
|
80439
|
+
(0, import_node_fs58.mkdirSync)(dir, { recursive: true });
|
|
80172
80440
|
const dest = (0, import_node_path52.join)(dir, asset.FileName);
|
|
80173
|
-
if ((0,
|
|
80441
|
+
if ((0, import_node_fs58.existsSync)(dest) && await sha1OfFile(dest) === want) return dest;
|
|
80174
80442
|
const res = await authedFetch(`${feedUrl()}/${encodeURIComponent(asset.FileName)}`, {
|
|
80175
80443
|
redirect: "follow",
|
|
80176
80444
|
signal: AbortSignal.timeout(DOWNLOAD_TIMEOUT_MS)
|
|
80177
80445
|
});
|
|
80178
80446
|
if (!res.ok || !res.body) throw new Error(`download failed: HTTP ${res.status} for ${asset.FileName}`);
|
|
80179
|
-
await (0, import_promises5.pipeline)(import_node_stream3.Readable.fromWeb(res.body), (0,
|
|
80447
|
+
await (0, import_promises5.pipeline)(import_node_stream3.Readable.fromWeb(res.body), (0, import_node_fs58.createWriteStream)(dest));
|
|
80180
80448
|
const got = await sha1OfFile(dest);
|
|
80181
80449
|
if (got !== want) throw new Error(`SHA1 mismatch for ${asset.FileName}: feed=${want} got=${got}`);
|
|
80182
80450
|
return dest;
|
|
@@ -80185,7 +80453,7 @@ async function applyUpdate(check, opts) {
|
|
|
80185
80453
|
if (!check.supported) return { applied: false, message: check.reason ?? "auto-update not supported in this runtime" };
|
|
80186
80454
|
if (!check.updateAvailable || !check.asset) return { applied: false, message: check.reason ?? "no update available" };
|
|
80187
80455
|
const exe = updateExePath();
|
|
80188
|
-
if (!(0,
|
|
80456
|
+
if (!(0, import_node_fs58.existsSync)(exe)) {
|
|
80189
80457
|
return { applied: false, message: `Update.exe not found at ${exe} \u2014 is this a Velopack install?` };
|
|
80190
80458
|
}
|
|
80191
80459
|
const pkg = await downloadPackage(check.asset);
|
|
@@ -80427,7 +80695,7 @@ function isTraceCorrupt(events) {
|
|
|
80427
80695
|
var import_node_child_process10 = require("node:child_process");
|
|
80428
80696
|
var import_node_path53 = require("node:path");
|
|
80429
80697
|
var import_node_url3 = require("node:url");
|
|
80430
|
-
var
|
|
80698
|
+
var import_node_fs59 = require("node:fs");
|
|
80431
80699
|
var import_node_http = __toESM(require("node:http"), 1);
|
|
80432
80700
|
var import_node_readline = require("node:readline");
|
|
80433
80701
|
var __dirname2 = (0, import_node_path53.dirname)((0, import_node_url3.fileURLToPath)(__import_meta_url));
|
|
@@ -80509,7 +80777,7 @@ function resolveServerStart() {
|
|
|
80509
80777
|
const packaged = /flolessapp\.exe$/i.test(process.execPath);
|
|
80510
80778
|
if (packaged) return { cmd: process.execPath, args: ["--serve"], shell: false };
|
|
80511
80779
|
const bundle = (0, import_node_path53.join)(__dirname2, "dist", "floless-server.cjs");
|
|
80512
|
-
if ((0,
|
|
80780
|
+
if ((0, import_node_fs59.existsSync)(bundle)) return { cmd: process.execPath, args: [bundle, "--serve"], shell: false };
|
|
80513
80781
|
return { cmd: "npm", args: ["run", "start"], shell: isWin2 };
|
|
80514
80782
|
}
|
|
80515
80783
|
function startServerDetached() {
|
|
@@ -82121,7 +82389,7 @@ function registerAwareUpdateRoutes(app, manager) {
|
|
|
82121
82389
|
}
|
|
82122
82390
|
|
|
82123
82391
|
// skill-sync.ts
|
|
82124
|
-
var
|
|
82392
|
+
var import_node_fs60 = require("node:fs");
|
|
82125
82393
|
var import_node_os27 = require("node:os");
|
|
82126
82394
|
var import_node_path56 = require("node:path");
|
|
82127
82395
|
var import_node_url4 = require("node:url");
|
|
@@ -82177,7 +82445,7 @@ function bundledSkillsRoot() {
|
|
|
82177
82445
|
(0, import_node_path56.join)((0, import_node_path56.dirname)(process.execPath), "skills"),
|
|
82178
82446
|
(0, import_node_path56.join)(__dirname3, "..", ".claude", "skills")
|
|
82179
82447
|
];
|
|
82180
|
-
return candidates.find((p) => (0,
|
|
82448
|
+
return candidates.find((p) => (0, import_node_fs60.existsSync)(p)) ?? null;
|
|
82181
82449
|
}
|
|
82182
82450
|
function targetConfigDirs() {
|
|
82183
82451
|
const override = process.env.FLOLESS_SKILL_TARGETS;
|
|
@@ -82193,7 +82461,7 @@ function targetConfigDirs() {
|
|
|
82193
82461
|
}
|
|
82194
82462
|
function skillVersion(skillMdPath) {
|
|
82195
82463
|
try {
|
|
82196
|
-
const text3 = (0,
|
|
82464
|
+
const text3 = (0, import_node_fs60.readFileSync)(skillMdPath, "utf8");
|
|
82197
82465
|
const m = /^---\r?\n([\s\S]*?)\r?\n---/.exec(text3);
|
|
82198
82466
|
if (!m || m[1] === void 0) return null;
|
|
82199
82467
|
const fm = (0, import_yaml11.parse)(m[1]);
|
|
@@ -82233,7 +82501,7 @@ function decideAction(installed, bundled) {
|
|
|
82233
82501
|
function bundledSkills(root5) {
|
|
82234
82502
|
let entries2 = [];
|
|
82235
82503
|
try {
|
|
82236
|
-
entries2 = selectShippedSkillNames((0,
|
|
82504
|
+
entries2 = selectShippedSkillNames((0, import_node_fs60.readdirSync)(root5));
|
|
82237
82505
|
} catch {
|
|
82238
82506
|
return [];
|
|
82239
82507
|
}
|
|
@@ -82242,7 +82510,7 @@ function bundledSkills(root5) {
|
|
|
82242
82510
|
const dir = (0, import_node_path56.join)(root5, name);
|
|
82243
82511
|
let isDir = false;
|
|
82244
82512
|
try {
|
|
82245
|
-
isDir = (0,
|
|
82513
|
+
isDir = (0, import_node_fs60.statSync)(dir).isDirectory();
|
|
82246
82514
|
} catch {
|
|
82247
82515
|
isDir = false;
|
|
82248
82516
|
}
|
|
@@ -82260,17 +82528,17 @@ function syncSkills() {
|
|
|
82260
82528
|
const skills = bundledSkills(root5);
|
|
82261
82529
|
if (!skills.length) return results;
|
|
82262
82530
|
for (const { runtime, dir: cfg } of targetConfigDirs()) {
|
|
82263
|
-
if (!(0,
|
|
82531
|
+
if (!(0, import_node_fs60.existsSync)(cfg)) continue;
|
|
82264
82532
|
const skillsDir = (0, import_node_path56.join)(cfg, "skills");
|
|
82265
82533
|
for (const s of skills) {
|
|
82266
82534
|
const dest = (0, import_node_path56.join)(skillsDir, s.name);
|
|
82267
82535
|
const installedMd = (0, import_node_path56.join)(dest, "SKILL.md");
|
|
82268
|
-
const installed = (0,
|
|
82536
|
+
const installed = (0, import_node_fs60.existsSync)(installedMd) ? skillVersion(installedMd) : null;
|
|
82269
82537
|
const action = decideAction(installed, s.version);
|
|
82270
82538
|
if (action === "installed" || action === "updated") {
|
|
82271
82539
|
try {
|
|
82272
|
-
if (action === "updated") (0,
|
|
82273
|
-
(0,
|
|
82540
|
+
if (action === "updated") (0, import_node_fs60.rmSync)(dest, { recursive: true, force: true });
|
|
82541
|
+
(0, import_node_fs60.cpSync)(s.dir, dest, { recursive: true });
|
|
82274
82542
|
results.push({ runtime, skill: s.name, action, from: installed, to: s.version });
|
|
82275
82543
|
} catch {
|
|
82276
82544
|
}
|
|
@@ -82285,7 +82553,7 @@ function syncSkills() {
|
|
|
82285
82553
|
// watch.ts
|
|
82286
82554
|
var import_node_os28 = require("node:os");
|
|
82287
82555
|
var import_node_path58 = require("node:path");
|
|
82288
|
-
var
|
|
82556
|
+
var import_node_fs61 = require("node:fs");
|
|
82289
82557
|
|
|
82290
82558
|
// node_modules/chokidar/esm/index.js
|
|
82291
82559
|
var import_fs2 = require("fs");
|
|
@@ -83998,20 +84266,20 @@ function underDir(path, dir) {
|
|
|
83998
84266
|
function startWatcher() {
|
|
83999
84267
|
const awareDir = process.env.AWARE_HOME ?? (0, import_node_path58.join)((0, import_node_os28.homedir)(), ".aware");
|
|
84000
84268
|
const credentialsDir = (0, import_node_path58.join)(awareDir, "credentials");
|
|
84001
|
-
if (!(0,
|
|
84269
|
+
if (!(0, import_node_fs61.existsSync)(credentialsDir)) {
|
|
84002
84270
|
try {
|
|
84003
|
-
(0,
|
|
84271
|
+
(0, import_node_fs61.mkdirSync)(credentialsDir, { recursive: true });
|
|
84004
84272
|
} catch {
|
|
84005
84273
|
}
|
|
84006
84274
|
}
|
|
84007
|
-
if (!(0,
|
|
84275
|
+
if (!(0, import_node_fs61.existsSync)(uiDir)) {
|
|
84008
84276
|
try {
|
|
84009
|
-
(0,
|
|
84277
|
+
(0, import_node_fs61.mkdirSync)(uiDir, { recursive: true });
|
|
84010
84278
|
} catch {
|
|
84011
84279
|
}
|
|
84012
84280
|
}
|
|
84013
|
-
const targets = ["apps", "logs", "credentials"].map((d) => (0, import_node_path58.join)(awareDir, d)).filter((p) => (0,
|
|
84014
|
-
if ((0,
|
|
84281
|
+
const targets = ["apps", "logs", "credentials"].map((d) => (0, import_node_path58.join)(awareDir, d)).filter((p) => (0, import_node_fs61.existsSync)(p));
|
|
84282
|
+
if ((0, import_node_fs61.existsSync)(uiDir)) targets.push(uiDir);
|
|
84015
84283
|
if (targets.length === 0) {
|
|
84016
84284
|
return null;
|
|
84017
84285
|
}
|
|
@@ -84040,11 +84308,11 @@ function startWatcher() {
|
|
|
84040
84308
|
const isCredential = path.split(/[\\/]/).includes("credentials");
|
|
84041
84309
|
const kind = isCredential ? "credential" : path.endsWith(".jsonl") ? "trace" : path.endsWith(".lock") ? "lock" : path.endsWith(".flo") || path.endsWith(".app") ? "source" : "file";
|
|
84042
84310
|
broadcast({ type: "fs-change", kind, event, path });
|
|
84043
|
-
if (kind === "trace" && event !== "unlink" && (0,
|
|
84311
|
+
if (kind === "trace" && event !== "unlink" && (0, import_node_fs61.existsSync)(path)) {
|
|
84044
84312
|
const id = appIdFromLogPath(path);
|
|
84045
84313
|
if (!id) return;
|
|
84046
84314
|
try {
|
|
84047
|
-
broadcast({ type: "trace-file", id, runId: path.split(import_node_path58.sep).pop()?.replace(/\.jsonl$/, "") ?? null, events: parseTrace((0,
|
|
84315
|
+
broadcast({ type: "trace-file", id, runId: path.split(import_node_path58.sep).pop()?.replace(/\.jsonl$/, "") ?? null, events: parseTrace((0, import_node_fs61.readFileSync)(path, "utf8")) });
|
|
84048
84316
|
} catch {
|
|
84049
84317
|
}
|
|
84050
84318
|
}
|
|
@@ -84055,7 +84323,7 @@ function startWatcher() {
|
|
|
84055
84323
|
// index.ts
|
|
84056
84324
|
var __dirname4 = (0, import_node_path59.dirname)((0, import_node_url5.fileURLToPath)(__import_meta_url));
|
|
84057
84325
|
var WEB_ROOT = [(0, import_node_path59.join)(__dirname4, "web"), (0, import_node_path59.join)((0, import_node_path59.dirname)(process.execPath), "web"), (0, import_node_path59.join)(__dirname4, "..", "web")].find(
|
|
84058
|
-
(p) => (0,
|
|
84326
|
+
(p) => (0, import_node_fs62.existsSync)(p)
|
|
84059
84327
|
) ?? (0, import_node_path59.join)(__dirname4, "..", "web");
|
|
84060
84328
|
var PORT2 = Number(process.env.PORT ?? 4317);
|
|
84061
84329
|
var HOST = "127.0.0.1";
|
|
@@ -84072,7 +84340,7 @@ function installCrashHandlers() {
|
|
|
84072
84340
|
${stack}
|
|
84073
84341
|
`;
|
|
84074
84342
|
try {
|
|
84075
|
-
(0,
|
|
84343
|
+
(0, import_node_fs62.appendFileSync)(logFilePath(), line);
|
|
84076
84344
|
} catch {
|
|
84077
84345
|
}
|
|
84078
84346
|
if (process.stderr.isTTY) process.stderr.write(line);
|
|
@@ -84722,10 +84990,10 @@ async function startServer() {
|
|
|
84722
84990
|
const bdir = backupDir(id, fromVersion, Date.now());
|
|
84723
84991
|
let backedUp = false;
|
|
84724
84992
|
try {
|
|
84725
|
-
(0,
|
|
84726
|
-
(0,
|
|
84993
|
+
(0, import_node_fs62.mkdirSync)((0, import_node_path59.dirname)(bdir), { recursive: true });
|
|
84994
|
+
(0, import_node_fs62.cpSync)(appDirPath2, bdir, { recursive: true });
|
|
84727
84995
|
backedUp = true;
|
|
84728
|
-
(0,
|
|
84996
|
+
(0, import_node_fs62.cpSync)(templatePath, srcPath);
|
|
84729
84997
|
if (id !== templateId) stampSourceAppId(srcPath, id);
|
|
84730
84998
|
if (contract != null) {
|
|
84731
84999
|
bakeContractIntoApp(srcPath, contract);
|
|
@@ -84739,8 +85007,8 @@ async function startServer() {
|
|
|
84739
85007
|
throw new TemplateSwapError(`${verb} failed before any change was made (${msg}) \u2014 the workflow is untouched`, `${verb}-not-started`);
|
|
84740
85008
|
}
|
|
84741
85009
|
try {
|
|
84742
|
-
(0,
|
|
84743
|
-
(0,
|
|
85010
|
+
(0, import_node_fs62.rmSync)(appDirPath2, { recursive: true, force: true });
|
|
85011
|
+
(0, import_node_fs62.cpSync)(bdir, appDirPath2, { recursive: true });
|
|
84744
85012
|
} catch (re) {
|
|
84745
85013
|
const rmsg = re instanceof Error ? re.message : String(re);
|
|
84746
85014
|
throw new TemplateSwapError(`${verb} failed (${msg}) AND rollback failed (${rmsg}) \u2014 restore manually from ${bdir}`, "rollback-failed", bdir);
|
|
@@ -84752,7 +85020,7 @@ async function startServer() {
|
|
|
84752
85020
|
function readSwapContract(id, verb) {
|
|
84753
85021
|
const gerund = verb === "update" ? "updating" : "restoring";
|
|
84754
85022
|
const contract = readAcceptedForRequest(id, void 0);
|
|
84755
|
-
if (contract == null && (0,
|
|
85023
|
+
if (contract == null && (0, import_node_fs62.existsSync)(contractPath(id))) {
|
|
84756
85024
|
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" } };
|
|
84757
85025
|
}
|
|
84758
85026
|
if (contract != null && !validateContract(contract).valid) {
|
|
@@ -84968,7 +85236,19 @@ async function startServer() {
|
|
|
84968
85236
|
projectExportsDir(req.params.id),
|
|
84969
85237
|
{ kind: "project", key: req.params.id }
|
|
84970
85238
|
);
|
|
84971
|
-
|
|
85239
|
+
const before = getProject(req.params.id);
|
|
85240
|
+
const project = renameProject(req.params.id, req.body?.name);
|
|
85241
|
+
if (!before) {
|
|
85242
|
+
req.log.error({ id: req.params.id }, "rename: pre-read missing \u2014 other tabs cannot reconcile this rename");
|
|
85243
|
+
} else if (before.id !== project.id) {
|
|
85244
|
+
broadcast({
|
|
85245
|
+
type: "projects-changed",
|
|
85246
|
+
appId: project.app,
|
|
85247
|
+
projectId: project.id,
|
|
85248
|
+
previousProjectId: before.id
|
|
85249
|
+
});
|
|
85250
|
+
}
|
|
85251
|
+
return { ok: true, project: projectView(project) };
|
|
84972
85252
|
});
|
|
84973
85253
|
} catch (e) {
|
|
84974
85254
|
if (e instanceof ProjectError) return reply.status(400).send({ ok: false, error: e.message });
|
|
@@ -85052,7 +85332,7 @@ async function startServer() {
|
|
|
85052
85332
|
}
|
|
85053
85333
|
let data;
|
|
85054
85334
|
try {
|
|
85055
|
-
data = (0,
|
|
85335
|
+
data = (0, import_node_fs62.readFileSync)(thumb.path);
|
|
85056
85336
|
} catch {
|
|
85057
85337
|
return reply.status(404).send({ ok: false, error: "no thumbnail" });
|
|
85058
85338
|
}
|
|
@@ -85572,8 +85852,8 @@ async function startServer() {
|
|
|
85572
85852
|
if (bad) return reply.status(404).send({ ok: false, error: bad });
|
|
85573
85853
|
const safe2 = req.params.sheet.replace(/[^A-Za-z0-9._-]/g, "");
|
|
85574
85854
|
const file = (0, import_node_path59.join)((0, import_node_path59.dirname)(contractPath(req.params.appId, project)), "details", `${safe2}.svg`);
|
|
85575
|
-
if (!(0,
|
|
85576
|
-
return reply.type("image/svg+xml").send((0,
|
|
85855
|
+
if (!(0, import_node_fs62.existsSync)(file)) return reply.status(404).send({ ok: false, error: "no vector for this sheet" });
|
|
85856
|
+
return reply.type("image/svg+xml").send((0, import_node_fs62.readFileSync)(file, "utf8"));
|
|
85577
85857
|
}
|
|
85578
85858
|
);
|
|
85579
85859
|
app.put(
|
|
@@ -85611,10 +85891,13 @@ async function startServer() {
|
|
|
85611
85891
|
try {
|
|
85612
85892
|
return await withLifecycleLock("project", req.params.id, () => {
|
|
85613
85893
|
const prepared = prepareProjectApprovalReview(req.params.id, { validateCandidate: projectApprovalCandidateAccepted });
|
|
85614
|
-
return { ok: true,
|
|
85894
|
+
return { ...prepared.review, ok: true, reviewable: true };
|
|
85615
85895
|
}, { label: "preparing approval review" });
|
|
85616
85896
|
} catch (error) {
|
|
85617
|
-
if (error instanceof WorkspaceSnapshotError)
|
|
85897
|
+
if (error instanceof WorkspaceSnapshotError) {
|
|
85898
|
+
if (error.notReviewable) return { ok: true, reviewable: false, reason: error.notReviewable, message: error.message };
|
|
85899
|
+
return reply.status(error.status).send({ ok: false, error: error.message });
|
|
85900
|
+
}
|
|
85618
85901
|
throw error;
|
|
85619
85902
|
}
|
|
85620
85903
|
});
|
|
@@ -86059,7 +86342,7 @@ async function startServer() {
|
|
|
86059
86342
|
}
|
|
86060
86343
|
const statedAt = (filename) => {
|
|
86061
86344
|
try {
|
|
86062
|
-
const st = (0,
|
|
86345
|
+
const st = (0, import_node_fs62.statSync)((0, import_node_path59.join)(dir, filename));
|
|
86063
86346
|
return st.isFile() ? st.mtime.toISOString() : null;
|
|
86064
86347
|
} catch {
|
|
86065
86348
|
return null;
|
|
@@ -86231,10 +86514,10 @@ async function startServer() {
|
|
|
86231
86514
|
scene,
|
|
86232
86515
|
"output-path": tempPath
|
|
86233
86516
|
});
|
|
86234
|
-
if (!(0,
|
|
86517
|
+
if (!(0, import_node_fs62.existsSync)(tempPath) || (0, import_node_fs62.statSync)(tempPath).size === 0) {
|
|
86235
86518
|
throw new ReceiptReconciliationError("AWARE reported a successful export but wrote no IFC file.");
|
|
86236
86519
|
}
|
|
86237
|
-
const artifactBytes = (0,
|
|
86520
|
+
const artifactBytes = (0, import_node_fs62.readFileSync)(tempPath);
|
|
86238
86521
|
const receipt = reconcileIfcExportReceipt(scene, rawReceipt, producerUnsupported, {
|
|
86239
86522
|
index: parseStepData(artifactBytes),
|
|
86240
86523
|
bytes: artifactBytes
|
|
@@ -86290,7 +86573,7 @@ async function startServer() {
|
|
|
86290
86573
|
ok: false,
|
|
86291
86574
|
error: awareFailureMessage(error, "IFC export failed"),
|
|
86292
86575
|
...reason ? { reason } : {},
|
|
86293
|
-
preservedPrevious: project && priorProjectIfc ? receiptHasFile(project, priorProjectIfc) : (0,
|
|
86576
|
+
preservedPrevious: project && priorProjectIfc ? receiptHasFile(project, priorProjectIfc) : (0, import_node_fs62.existsSync)(finalPath)
|
|
86294
86577
|
});
|
|
86295
86578
|
} finally {
|
|
86296
86579
|
cleanupIfcTemp(tempPath);
|
|
@@ -86334,10 +86617,10 @@ async function startServer() {
|
|
|
86334
86617
|
const receipt = wanted ? stills.find((row) => row.variant === wanted) : [...stills].sort((a, b) => b.exportedAt.localeCompare(a.exportedAt))[0];
|
|
86335
86618
|
if (!receipt) return reply.status(404).send({ ok: false, error: "nothing rendered yet" });
|
|
86336
86619
|
const path = resolveProjectExportReceiptPath(project, receipt);
|
|
86337
|
-
if (!path || !(0,
|
|
86620
|
+
if (!path || !(0, import_node_fs62.existsSync)(path)) {
|
|
86338
86621
|
return reply.status(404).send({ ok: false, error: "the rendered image is no longer on disk" });
|
|
86339
86622
|
}
|
|
86340
|
-
return reply.header("content-type", "image/png").header("cache-control", "private, max-age=31536000, immutable").send((0,
|
|
86623
|
+
return reply.header("content-type", "image/png").header("cache-control", "private, max-age=31536000, immutable").send((0, import_node_fs62.readFileSync)(path));
|
|
86341
86624
|
});
|
|
86342
86625
|
const RENDER_VIEWPOINTS = /* @__PURE__ */ new Set(["hero", "iso", "front", "back", "left", "right", "top"]);
|
|
86343
86626
|
app.post("/api/contract/:appId/render", async (req, reply) => {
|
|
@@ -86397,7 +86680,7 @@ async function startServer() {
|
|
|
86397
86680
|
}
|
|
86398
86681
|
const kind = output === "turntable" ? "render-mp4" : "render-png";
|
|
86399
86682
|
const extension = output === "turntable" ? ".mp4" : ".png";
|
|
86400
|
-
const scratch = (0,
|
|
86683
|
+
const scratch = (0, import_node_fs62.mkdtempSync)((0, import_node_path59.join)((0, import_node_os29.tmpdir)(), "floless-render-"));
|
|
86401
86684
|
const ifcPath = (0, import_node_path59.join)(scratch, "model.ifc");
|
|
86402
86685
|
const rendered = [];
|
|
86403
86686
|
const progress = (stage, extra = {}) => {
|
|
@@ -86409,7 +86692,7 @@ async function startServer() {
|
|
|
86409
86692
|
try {
|
|
86410
86693
|
progress("preparing");
|
|
86411
86694
|
await aware.agentInvoke("ifc", "write", { scene: built.scene, "output-path": ifcPath });
|
|
86412
|
-
if (!(0,
|
|
86695
|
+
if (!(0, import_node_fs62.existsSync)(ifcPath) || (0, import_node_fs62.statSync)(ifcPath).size === 0) {
|
|
86413
86696
|
throw new Error("AWARE reported a successful IFC write but produced no file to render");
|
|
86414
86697
|
}
|
|
86415
86698
|
const renderBudgetMs = output === "turntable" ? 30 * 6e4 : 10 * 6e4;
|
|
@@ -86427,10 +86710,10 @@ async function startServer() {
|
|
|
86427
86710
|
environment: "studio",
|
|
86428
86711
|
...output === "turntable" ? { "duration-seconds": 12, fps: 24, "width-pixels": 1280, "height-pixels": 720 } : { quality, "width-pixels": 1920, "height-pixels": 1080 }
|
|
86429
86712
|
}, { timeoutMs: renderBudgetMs });
|
|
86430
|
-
if (!(0,
|
|
86713
|
+
if (!(0, import_node_fs62.existsSync)(artifactPath) || (0, import_node_fs62.statSync)(artifactPath).size === 0) {
|
|
86431
86714
|
throw new Error(`the ${viewpoint} render reported success but produced no image`);
|
|
86432
86715
|
}
|
|
86433
|
-
const bytes = (0,
|
|
86716
|
+
const bytes = (0, import_node_fs62.readFileSync)(artifactPath);
|
|
86434
86717
|
const sourceSuffix = "source" in projectSnapshot && projectSnapshot.source ? `-${projectSnapshot.source.filenameLabel.replace(/[^A-Za-z0-9._-]+/g, "-")}` : "";
|
|
86435
86718
|
const preferred = `${exportFileBase(project, appId)}-${viewpoint}${sourceSuffix}${extension}`;
|
|
86436
86719
|
const filename = uniqueProjectExportFilename(project, preferred);
|
|
@@ -86486,7 +86769,7 @@ async function startServer() {
|
|
|
86486
86769
|
rendered
|
|
86487
86770
|
});
|
|
86488
86771
|
} finally {
|
|
86489
|
-
(0,
|
|
86772
|
+
(0, import_node_fs62.rmSync)(scratch, { recursive: true, force: true });
|
|
86490
86773
|
}
|
|
86491
86774
|
}, {
|
|
86492
86775
|
// What anyone blocked on this project is told, and for how long to expect it. Erring long
|
|
@@ -86727,7 +87010,7 @@ async function startServer() {
|
|
|
86727
87010
|
const outPath = project ? (0, import_node_path59.join)(projectExportsDir(project), filename) : bomExportPath(appId, format);
|
|
86728
87011
|
const dir = (0, import_node_path59.dirname)(outPath);
|
|
86729
87012
|
try {
|
|
86730
|
-
(0,
|
|
87013
|
+
(0, import_node_fs62.mkdirSync)(dir, { recursive: true });
|
|
86731
87014
|
const kind = BOM_EXPORT_KIND[format];
|
|
86732
87015
|
let text3 = null;
|
|
86733
87016
|
let buf;
|
|
@@ -86755,8 +87038,8 @@ async function startServer() {
|
|
|
86755
87038
|
sourceKind: projectSnapshot.source?.kind ?? "approved",
|
|
86756
87039
|
contractHash: projectSnapshot.contractHash
|
|
86757
87040
|
}, buf);
|
|
86758
|
-
} else if (text3 != null) (0,
|
|
86759
|
-
else (0,
|
|
87041
|
+
} else if (text3 != null) (0, import_node_fs62.writeFileSync)(outPath, text3, "utf8");
|
|
87042
|
+
else (0, import_node_fs62.writeFileSync)(outPath, buf);
|
|
86760
87043
|
return {
|
|
86761
87044
|
ok: true,
|
|
86762
87045
|
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 }
|
|
@@ -86796,7 +87079,7 @@ async function startServer() {
|
|
|
86796
87079
|
const filename = project ? uniqueProjectExportFilename(project, preferredFilename) : preferredFilename;
|
|
86797
87080
|
const outPath = project ? (0, import_node_path59.join)(projectExportsDir(project), filename) : (0, import_node_path59.join)(appPath(appId), filename);
|
|
86798
87081
|
try {
|
|
86799
|
-
(0,
|
|
87082
|
+
(0, import_node_fs62.mkdirSync)((0, import_node_path59.dirname)(outPath), { recursive: true });
|
|
86800
87083
|
if (project && projectSnapshot) {
|
|
86801
87084
|
publishProjectExportArtifact(project, {
|
|
86802
87085
|
kind: "svg",
|
|
@@ -86807,7 +87090,7 @@ async function startServer() {
|
|
|
86807
87090
|
sourceKind: projectSnapshot.source?.kind ?? "approved",
|
|
86808
87091
|
contractHash: projectSnapshot.contractHash
|
|
86809
87092
|
}, Buffer.from(svg, "utf8"));
|
|
86810
|
-
} else (0,
|
|
87093
|
+
} else (0, import_node_fs62.writeFileSync)(outPath, svg, "utf8");
|
|
86811
87094
|
return { ok: true, filename, encoding: "utf8", content: svg, bytes: Buffer.byteLength(svg), savedTo: outPath };
|
|
86812
87095
|
} catch (e) {
|
|
86813
87096
|
app.log.error({ appId, err: e instanceof Error ? e.message : e }, "export-svg: write failed");
|
|
@@ -86989,11 +87272,11 @@ async function startServer() {
|
|
|
86989
87272
|
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 });
|
|
86990
87273
|
}
|
|
86991
87274
|
await deleteOrigin(id);
|
|
86992
|
-
const stageRoot = (0,
|
|
87275
|
+
const stageRoot = (0, import_node_fs62.mkdtempSync)((0, import_node_path59.join)((0, import_node_os29.tmpdir)(), "floless-import-"));
|
|
86993
87276
|
try {
|
|
86994
87277
|
const stageDir = (0, import_node_path59.join)(stageRoot, id);
|
|
86995
|
-
(0,
|
|
86996
|
-
(0,
|
|
87278
|
+
(0, import_node_fs62.mkdirSync)(stageDir);
|
|
87279
|
+
(0, import_node_fs62.writeFileSync)((0, import_node_path59.join)(stageDir, `${id}.flo`), content);
|
|
86997
87280
|
await aware.install(stageDir);
|
|
86998
87281
|
} catch (err2) {
|
|
86999
87282
|
try {
|
|
@@ -87004,7 +87287,7 @@ async function startServer() {
|
|
|
87004
87287
|
const reason = awareStderr(err2);
|
|
87005
87288
|
return reply.status(502).send({ ok: false, error: `import failed: ${msg}`, code: "install-failed", reason, agentsUnavailable: unavailableAgents(reason) });
|
|
87006
87289
|
} finally {
|
|
87007
|
-
(0,
|
|
87290
|
+
(0, import_node_fs62.rmSync)(stageRoot, { recursive: true, force: true });
|
|
87008
87291
|
}
|
|
87009
87292
|
broadcast({ type: "apps-changed", id });
|
|
87010
87293
|
return { ok: true, id };
|
|
@@ -87020,13 +87303,13 @@ async function startServer() {
|
|
|
87020
87303
|
}
|
|
87021
87304
|
const inputs = appData.inputs.map((i) => ({ name: i.name, type: i.type }));
|
|
87022
87305
|
const baked = bakeFloSource(appData.source.text, inputs);
|
|
87023
|
-
const tmpRoot = (0,
|
|
87306
|
+
const tmpRoot = (0, import_node_fs62.mkdtempSync)((0, import_node_path59.join)((0, import_node_os29.tmpdir)(), "floless-bake-"));
|
|
87024
87307
|
const backupDir2 = (0, import_node_path59.join)(tmpRoot, `${id}-backup`);
|
|
87025
87308
|
const bakeDir = (0, import_node_path59.join)(tmpRoot, id);
|
|
87026
|
-
(0,
|
|
87027
|
-
(0,
|
|
87309
|
+
(0, import_node_fs62.cpSync)(appDir(id), backupDir2, { recursive: true });
|
|
87310
|
+
(0, import_node_fs62.cpSync)(appDir(id), bakeDir, { recursive: true });
|
|
87028
87311
|
const floName = appData.source.path.split(/[\\/]/).pop();
|
|
87029
|
-
(0,
|
|
87312
|
+
(0, import_node_fs62.writeFileSync)((0, import_node_path59.join)(bakeDir, floName), baked);
|
|
87030
87313
|
let appInstalled2 = true;
|
|
87031
87314
|
try {
|
|
87032
87315
|
await aware.uninstall(id);
|
|
@@ -87055,7 +87338,7 @@ async function startServer() {
|
|
|
87055
87338
|
broadcast({ type: "baked", id });
|
|
87056
87339
|
return { ok: true, id, agent: id, inputs };
|
|
87057
87340
|
} finally {
|
|
87058
|
-
if (appInstalled2) (0,
|
|
87341
|
+
if (appInstalled2) (0, import_node_fs62.rmSync)(tmpRoot, { recursive: true, force: true });
|
|
87059
87342
|
}
|
|
87060
87343
|
});
|
|
87061
87344
|
});
|
|
@@ -87076,7 +87359,7 @@ async function startServer() {
|
|
|
87076
87359
|
if (!sourceKind || !sourceRef) {
|
|
87077
87360
|
return reply.status(400).send({ ok: false, error: "sourceKind and sourceRef required" });
|
|
87078
87361
|
}
|
|
87079
|
-
const tempHome = (0,
|
|
87362
|
+
const tempHome = (0, import_node_fs62.mkdtempSync)((0, import_node_path59.join)((0, import_node_os29.tmpdir)(), "floless-graft-"));
|
|
87080
87363
|
let result;
|
|
87081
87364
|
try {
|
|
87082
87365
|
result = await aware.build({
|
|
@@ -87089,19 +87372,19 @@ async function startServer() {
|
|
|
87089
87372
|
awareHome: tempHome
|
|
87090
87373
|
});
|
|
87091
87374
|
} catch (err2) {
|
|
87092
|
-
(0,
|
|
87375
|
+
(0, import_node_fs62.rmSync)(tempHome, { recursive: true, force: true });
|
|
87093
87376
|
const msg = err2 instanceof AwareError ? err2.message : String(err2?.message ?? err2);
|
|
87094
87377
|
return reply.status(422).send({ ok: false, error: msg });
|
|
87095
87378
|
}
|
|
87096
87379
|
const manifest = readStagedManifest(result.agentDir);
|
|
87097
87380
|
if (!manifest) {
|
|
87098
|
-
(0,
|
|
87381
|
+
(0, import_node_fs62.rmSync)(tempHome, { recursive: true, force: true });
|
|
87099
87382
|
return reply.status(502).send({ ok: false, error: `build produced output at ${result.agentDir} but no manifest.yaml` });
|
|
87100
87383
|
}
|
|
87101
87384
|
const token2 = (0, import_node_crypto33.randomUUID)();
|
|
87102
87385
|
registerStage(token2, tempHome, result.agentId);
|
|
87103
87386
|
const preview2 = buildPreview(manifest, sourceKind, sourceRef, token2);
|
|
87104
|
-
if ((0,
|
|
87387
|
+
if ((0, import_node_fs62.existsSync)((0, import_node_path59.join)(graftAgentsDir(), result.agentId))) {
|
|
87105
87388
|
preview2.warnings.unshift(`An agent named "${result.agentId}" is already installed \u2014 creating it will overwrite it.`);
|
|
87106
87389
|
}
|
|
87107
87390
|
return { ok: true, preview: preview2 };
|
|
@@ -87120,7 +87403,7 @@ async function startServer() {
|
|
|
87120
87403
|
registerStage(stagedRef, stage.tempDir, stage.agentId);
|
|
87121
87404
|
return reply.status(409).send({ ok: false, error: err2.message, agentId: stage.agentId, collision: true });
|
|
87122
87405
|
}
|
|
87123
|
-
(0,
|
|
87406
|
+
(0, import_node_fs62.rmSync)(stage.tempDir, { recursive: true, force: true });
|
|
87124
87407
|
throw err2;
|
|
87125
87408
|
}
|
|
87126
87409
|
broadcast({ type: "grafted", id: stage.agentId });
|
|
@@ -87442,11 +87725,11 @@ async function startServer() {
|
|
|
87442
87725
|
app.get("/api/requests/:id/snapshot/:n", async (req, reply) => {
|
|
87443
87726
|
const n = Number.parseInt(req.params.n, 10);
|
|
87444
87727
|
const p = Number.isInteger(n) ? snapshotPathFor(req.params.id, n) : null;
|
|
87445
|
-
if (!p || !(0,
|
|
87728
|
+
if (!p || !(0, import_node_fs62.existsSync)(p)) return reply.status(404).send({ ok: false, error: "snapshot not found" });
|
|
87446
87729
|
const ext = p.split(".").pop().toLowerCase();
|
|
87447
87730
|
reply.header("Content-Type", ext === "png" ? "image/png" : ext === "webp" ? "image/webp" : ext === "pdf" ? "application/pdf" : "image/jpeg");
|
|
87448
87731
|
reply.header("Cache-Control", "no-store");
|
|
87449
|
-
return (0,
|
|
87732
|
+
return (0, import_node_fs62.readFileSync)(p);
|
|
87450
87733
|
});
|
|
87451
87734
|
app.post(
|
|
87452
87735
|
"/api/tweak",
|
|
@@ -87675,7 +87958,7 @@ async function startServer() {
|
|
|
87675
87958
|
warn(`last-run-status:${ref} \u2014 trace exists but couldn't be parsed (corrupt/truncated)`);
|
|
87676
87959
|
let finishedAt2 = null;
|
|
87677
87960
|
try {
|
|
87678
|
-
finishedAt2 = (0,
|
|
87961
|
+
finishedAt2 = (0, import_node_fs62.statSync)(latest.path).mtime.toISOString();
|
|
87679
87962
|
} catch {
|
|
87680
87963
|
finishedAt2 = null;
|
|
87681
87964
|
}
|
|
@@ -87685,7 +87968,7 @@ async function startServer() {
|
|
|
87685
87968
|
let finishedAt = typeof runEnd?.ts === "string" ? runEnd.ts : null;
|
|
87686
87969
|
if (!finishedAt) {
|
|
87687
87970
|
try {
|
|
87688
|
-
finishedAt = (0,
|
|
87971
|
+
finishedAt = (0, import_node_fs62.statSync)(latest.path).mtime.toISOString();
|
|
87689
87972
|
} catch {
|
|
87690
87973
|
finishedAt = null;
|
|
87691
87974
|
}
|