@floless/app 0.123.2 → 0.124.1
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 +787 -326
- package/dist/schemas/steel.model.v2.schema.json +10 -0
- package/dist/schemas/steel.takeoff.v1.schema.json +1 -1
- package/dist/skills/floless-app-approval/SKILL.md +7 -1
- package/dist/skills/floless-app-queue/SKILL.md +58 -14
- package/dist/skills/floless-app-steel-model/SKILL.md +30 -1
- package/dist/skills/floless-app-steel-takeoff/SKILL.md +21 -3
- package/dist/skills/floless-app-tweak-contract/SKILL.md +55 -18
- package/dist/web/app.js +3 -3
- package/dist/web/aware.js +132 -17
- package/dist/web/index.html +2 -2
- package/dist/web/steel-3d-view.js +345 -14
- package/dist/web/steel-editor.html +807 -35
- package/dist/web/steel-filter.html +64 -8
- package/dist/web/vector-editor.html +15 -1
- package/dist/web/workspaces.js +333 -9
- package/package.json +2 -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.1" : 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.1" : 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)) {
|
|
@@ -54997,8 +55000,26 @@ function loadDrawingVectorSchema() {
|
|
|
54997
55000
|
function loadSteelModelSchema() {
|
|
54998
55001
|
return loadContractSchema("steel.model.v2.schema.json");
|
|
54999
55002
|
}
|
|
55003
|
+
function duplicateJointIds(doc) {
|
|
55004
|
+
if (!doc || typeof doc !== "object") return [];
|
|
55005
|
+
const joints = doc.joints;
|
|
55006
|
+
if (!Array.isArray(joints)) return [];
|
|
55007
|
+
const counts = /* @__PURE__ */ new Map();
|
|
55008
|
+
for (const j of joints) {
|
|
55009
|
+
const id = j && typeof j === "object" ? j.id : void 0;
|
|
55010
|
+
if (typeof id !== "string" || !id) continue;
|
|
55011
|
+
counts.set(id, (counts.get(id) ?? 0) + 1);
|
|
55012
|
+
}
|
|
55013
|
+
return [...counts].filter(([, n]) => n > 1).map(([id, n]) => ({
|
|
55014
|
+
path: "$.joints",
|
|
55015
|
+
message: `joint id "${id}" occurs ${n} times; a connection part's id is derived from it, so duplicates collide in the built scene`
|
|
55016
|
+
}));
|
|
55017
|
+
}
|
|
55000
55018
|
function validateSteelTakeoff(doc) {
|
|
55001
|
-
|
|
55019
|
+
const base = validate(doc, loadSteelTakeoffSchema());
|
|
55020
|
+
const dupes = duplicateJointIds(doc);
|
|
55021
|
+
if (!dupes.length) return base;
|
|
55022
|
+
return { valid: false, errors: [...dupes, ...base.errors] };
|
|
55002
55023
|
}
|
|
55003
55024
|
function validateDrawingVector(doc) {
|
|
55004
55025
|
return validate(doc, loadDrawingVectorSchema());
|
|
@@ -57954,7 +57975,7 @@ async function chooseProjectExportPath(options, platform = process.platform, run
|
|
|
57954
57975
|
);
|
|
57955
57976
|
const selected = result.stdout.trim();
|
|
57956
57977
|
if (selected === CANCELLED) return null;
|
|
57957
|
-
if (!selected || !
|
|
57978
|
+
if (!selected || !import_node_path17.win32.isAbsolute(selected) || !/\.zip$/i.test(selected)) {
|
|
57958
57979
|
throw new Error("the Save dialog returned an invalid archive path");
|
|
57959
57980
|
}
|
|
57960
57981
|
return selected;
|
|
@@ -59926,6 +59947,21 @@ function decodeSnapshots(inputs) {
|
|
|
59926
59947
|
// connection-import.ts
|
|
59927
59948
|
var import_node_fs26 = require("node:fs");
|
|
59928
59949
|
var import_node_path25 = require("node:path");
|
|
59950
|
+
|
|
59951
|
+
// ifc-frame.ts
|
|
59952
|
+
var FILE_Z_UP = "z-up";
|
|
59953
|
+
var FILE_Y_UP = "y-up";
|
|
59954
|
+
function yUpToZUp(positions) {
|
|
59955
|
+
const out = new Array(positions.length);
|
|
59956
|
+
for (let i = 0; i + 2 < positions.length; i += 3) {
|
|
59957
|
+
out[i] = positions[i];
|
|
59958
|
+
out[i + 1] = -positions[i + 2];
|
|
59959
|
+
out[i + 2] = positions[i + 1];
|
|
59960
|
+
}
|
|
59961
|
+
return out;
|
|
59962
|
+
}
|
|
59963
|
+
|
|
59964
|
+
// connection-import.ts
|
|
59929
59965
|
var AGENT = "connection-reader";
|
|
59930
59966
|
var MAX_PARTS = 5e3;
|
|
59931
59967
|
var MAX_VERTICES = 3e6;
|
|
@@ -59951,7 +59987,21 @@ function writeReaderApp(companionId, command, ifcPath, id) {
|
|
|
59951
59987
|
`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
59988
|
"exposes-as-agent: false",
|
|
59953
59989
|
"requires:",
|
|
59954
|
-
|
|
59990
|
+
// UNPINNED, DELIBERATELY — and this is not laziness, it is the only true statement
|
|
59991
|
+
// available. floless supports BOTH reader lines and tells them apart by the `frame` in
|
|
59992
|
+
// the response, because the agent and the BRIDGE BINARY that actually produces the
|
|
59993
|
+
// coordinates are versioned independently: the bridge installs separately and a stale one
|
|
59994
|
+
// only warns. So no version pin describes what you will actually get, and AWARE's pin
|
|
59995
|
+
// grammar has no way to say "either line" — it takes `maj.min.pat`, `maj.min.x` or
|
|
59996
|
+
// `maj.x`, with no ranges and no alternation. An entry with no `@` is legal and means
|
|
59997
|
+
// exactly what we mean: this app needs the agent, and judges its output itself.
|
|
59998
|
+
//
|
|
59999
|
+
// Measured against the real binary (aware-aeco/aware @ b6084d5d9): `@0.1.x` against the
|
|
60000
|
+
// shipped 1.0.0 agent fails compile with E_APP_AGENT_PIN_UNSATISFIED, and `@>=0.1.0` fails
|
|
60001
|
+
// with E_APP_REQUIRES_MALFORMED because `>=` is not in the grammar at all. Both were
|
|
60002
|
+
// harmless while pins were enforced nowhere; aware-aeco/aware#349 made them enforced at
|
|
60003
|
+
// compile AND run, so both would have broken IFC import outright on the next AWARE release.
|
|
60004
|
+
` - ${AGENT}`,
|
|
59955
60005
|
"layout: linear",
|
|
59956
60006
|
"nodes:",
|
|
59957
60007
|
` - id: ${command}`,
|
|
@@ -60041,16 +60091,25 @@ function toCustomConnection(raw, fallbackId) {
|
|
|
60041
60091
|
throw new ConnectionImportError(typeof raw.message === "string" ? raw.message : "could not read that connection");
|
|
60042
60092
|
}
|
|
60043
60093
|
const c = conn;
|
|
60094
|
+
const alreadyZUp = c.frame === FILE_Z_UP;
|
|
60095
|
+
if (!alreadyZUp && c.frame !== void 0 && c.frame !== FILE_Y_UP) {
|
|
60096
|
+
throw new ConnectionImportError(
|
|
60097
|
+
`the connection reader returned a coordinate frame this version of FloLess does not understand (${JSON.stringify(c.frame)}) \u2014 updating FloLess should fix it`
|
|
60098
|
+
);
|
|
60099
|
+
}
|
|
60044
60100
|
const valid = (Array.isArray(c.parts) ? c.parts : []).filter(validPart);
|
|
60045
60101
|
if (valid.length > MAX_PARTS) throw new ConnectionImportError(`that connection has too many parts (${valid.length}) to import`);
|
|
60046
60102
|
let totalVerts = 0;
|
|
60047
60103
|
for (const p of valid) totalVerts += p.positions.length / 3;
|
|
60048
60104
|
if (totalVerts > MAX_VERTICES) throw new ConnectionImportError(`that connection is too large to import (${Math.round(totalVerts / 1e3)}k vertices)`);
|
|
60049
|
-
const
|
|
60050
|
-
const
|
|
60105
|
+
const framed = valid.map((p) => alreadyZUp ? p : { ...p, positions: yUpToZUp(p.positions) });
|
|
60106
|
+
const anchor = bboxCenter(framed);
|
|
60107
|
+
const geometry = framed.map((p) => ({
|
|
60051
60108
|
...typeof p.id === "string" ? { id: p.id } : {},
|
|
60052
60109
|
...typeof p.role === "string" ? { role: p.role } : {},
|
|
60053
60110
|
positions: shiftPositions(p.positions, anchor),
|
|
60111
|
+
// The frame correction rewrites POSITIONS and never touches indices, so a triangle means the
|
|
60112
|
+
// same thing whichever branch produced its vertices.
|
|
60054
60113
|
indices: p.indices.slice()
|
|
60055
60114
|
}));
|
|
60056
60115
|
const recipe = sanitizeRecipe(c.recipe);
|
|
@@ -60234,6 +60293,9 @@ function writeContract(appId, doc, projectId, privileged) {
|
|
|
60234
60293
|
(0, import_node_fs27.renameSync)(tmp, p);
|
|
60235
60294
|
}
|
|
60236
60295
|
|
|
60296
|
+
// contract-gateway.ts
|
|
60297
|
+
var import_node_fs31 = require("node:fs");
|
|
60298
|
+
|
|
60237
60299
|
// contract-resolve.ts
|
|
60238
60300
|
function bakedContractNode(app) {
|
|
60239
60301
|
return app.nodes.find(
|
|
@@ -62379,6 +62441,42 @@ function planBlockerSummary(candidate, cap = 8) {
|
|
|
62379
62441
|
return `plan-uneditable:${code} on ${sheets.length === 1 ? "sheet" : "sheets"} ${shown}${more}`;
|
|
62380
62442
|
});
|
|
62381
62443
|
}
|
|
62444
|
+
function blockingIssueDetails(report, cap = 8) {
|
|
62445
|
+
const byLine = /* @__PURE__ */ new Map();
|
|
62446
|
+
const order = [];
|
|
62447
|
+
for (const issue of report.issues) {
|
|
62448
|
+
if (issue.severity !== "block") continue;
|
|
62449
|
+
const sheet = typeof issue.sheet === "string" && issue.sheet.trim() ? issue.sheet.trim() : null;
|
|
62450
|
+
const path = typeof issue.path === "string" && issue.path.trim() ? issue.path.trim() : null;
|
|
62451
|
+
const parts = [sheet ? `sheet ${sheet}` : null, path].filter(Boolean);
|
|
62452
|
+
const at = parts.length ? ` [${parts.join(" \xB7 ")}]` : "";
|
|
62453
|
+
const line = issue.message ? `${issue.code}${at}: ${issue.message}` : `${issue.code}${at} (no detail available)`;
|
|
62454
|
+
const row = byLine.get(line);
|
|
62455
|
+
if (row) {
|
|
62456
|
+
row.count += 1;
|
|
62457
|
+
continue;
|
|
62458
|
+
}
|
|
62459
|
+
byLine.set(line, { code: issue.code, line, count: 1 });
|
|
62460
|
+
order.push(line);
|
|
62461
|
+
}
|
|
62462
|
+
const rows2 = order.map((line) => byLine.get(line));
|
|
62463
|
+
const firstPerCode = /* @__PURE__ */ new Set();
|
|
62464
|
+
const ordered = [];
|
|
62465
|
+
const rest = [];
|
|
62466
|
+
for (const row of rows2) {
|
|
62467
|
+
if (firstPerCode.has(row.code)) {
|
|
62468
|
+
rest.push(row);
|
|
62469
|
+
continue;
|
|
62470
|
+
}
|
|
62471
|
+
firstPerCode.add(row.code);
|
|
62472
|
+
ordered.push(row);
|
|
62473
|
+
}
|
|
62474
|
+
ordered.push(...rest);
|
|
62475
|
+
const render = (row) => row.count > 1 ? `${row.line} (\xD7${row.count})` : row.line;
|
|
62476
|
+
if (ordered.length <= cap) return ordered.map(render);
|
|
62477
|
+
const cut = ordered.slice(cap).reduce((n, row) => n + row.count, 0);
|
|
62478
|
+
return [...ordered.slice(0, cap).map(render), `and ${cut} more blocking issue(s)`];
|
|
62479
|
+
}
|
|
62382
62480
|
function migrationBlockingCodes(report, candidate) {
|
|
62383
62481
|
const projectionCodes = planBlockers(candidate).map((b) => `plan-uneditable:${b.code}`);
|
|
62384
62482
|
return [.../* @__PURE__ */ new Set(
|
|
@@ -62434,12 +62532,24 @@ function v1CarriesAuthoredModel(doc) {
|
|
|
62434
62532
|
// contract-transaction.ts
|
|
62435
62533
|
var ContractTransactionError = class extends Error {
|
|
62436
62534
|
code;
|
|
62437
|
-
|
|
62535
|
+
/**
|
|
62536
|
+
* The UNCAPPED evidence behind this refusal, for the log — never for the response body.
|
|
62537
|
+
*
|
|
62538
|
+
* `message` is capped so a human can read it, and until this existed the capped copy was the ONLY
|
|
62539
|
+
* surviving record: the full report is a local in `runInitialReadToV2`, destroyed by the throw, and
|
|
62540
|
+
* the route logs nothing. A support question of the form "why did my read fail" then had no
|
|
62541
|
+
* server-side artefact to consult at all — no log line, no journal (the journal is written after the
|
|
62542
|
+
* refusal), nothing but an HTTP body the user may not have kept.
|
|
62543
|
+
*/
|
|
62544
|
+
details;
|
|
62545
|
+
constructor(message, code = "contract-transaction-failed", details) {
|
|
62438
62546
|
super(message);
|
|
62439
62547
|
this.name = "ContractTransactionError";
|
|
62440
62548
|
this.code = code;
|
|
62549
|
+
if (details !== void 0) this.details = details;
|
|
62441
62550
|
}
|
|
62442
62551
|
};
|
|
62552
|
+
var DETAIL_LOG_CAP = 200;
|
|
62443
62553
|
function contractAuthorityFor(appId) {
|
|
62444
62554
|
try {
|
|
62445
62555
|
return resolveContractAuthorityId(appId);
|
|
@@ -62720,10 +62830,32 @@ async function runInitialReadToV2(opts) {
|
|
|
62720
62830
|
const codes = migrationBlockingCodes(report, candidate);
|
|
62721
62831
|
if (!candidate || codes.length) {
|
|
62722
62832
|
const where = planBlockerSummary(candidate);
|
|
62723
|
-
const
|
|
62833
|
+
const why = blockingIssueDetails(report);
|
|
62834
|
+
const items = [...where, ...why];
|
|
62835
|
+
const blocking = report.issues.filter((issue) => issue.severity === "block");
|
|
62836
|
+
if (items.length === 0) {
|
|
62837
|
+
throw new ContractTransactionError(
|
|
62838
|
+
"the migration refused this read but produced no blocking issue and no unprojectable plan, so the refusal cannot say why \u2014 that is a bug in previewMigration, not a problem with the drawing set",
|
|
62839
|
+
"v1-staging-exit-indeterminate",
|
|
62840
|
+
{ codes, issueCodes: report.issues.map((issue) => `${issue.severity}:${issue.code}`), candidate: candidate !== null }
|
|
62841
|
+
);
|
|
62842
|
+
}
|
|
62724
62843
|
throw new ContractTransactionError(
|
|
62725
|
-
`v1 reader staging must end because this fresh read cannot become ${STEEL_V2}:
|
|
62726
|
-
|
|
62844
|
+
`v1 reader staging must end because this fresh read cannot become ${STEEL_V2}:
|
|
62845
|
+
${items.map((item) => ` \u2022 ${item}`).join("\n")}`,
|
|
62846
|
+
"v1-staging-exit",
|
|
62847
|
+
{
|
|
62848
|
+
// CAPPED, with the true total beside it. `member-geometry-unusable` emits one issue per member,
|
|
62849
|
+
// bounded only by the v1's member count — 20,000 of them serialise to a 3.1 MB single log line.
|
|
62850
|
+
// Truncation in the log is stated the same way it is in the message, never implied.
|
|
62851
|
+
blocking: blocking.slice(0, DETAIL_LOG_CAP),
|
|
62852
|
+
totalBlocking: blocking.length,
|
|
62853
|
+
// PREFIXED, so support greps ONE spelling. `planBlockers` returns the raw
|
|
62854
|
+
// `registration-incomplete` while both the message and `migrationBlockingCodes` say
|
|
62855
|
+
// `plan-uneditable:registration-incomplete`; leaving the raw form here would reintroduce, in
|
|
62856
|
+
// the artefact, the "one reason, two spellings" defect the message half already fixed.
|
|
62857
|
+
planBlockers: planBlockers(candidate).map((b) => ({ ...b, code: `plan-uneditable:${b.code}` }))
|
|
62858
|
+
}
|
|
62727
62859
|
);
|
|
62728
62860
|
}
|
|
62729
62861
|
const uuid = getProject(projectId)?.uuid ?? null;
|
|
@@ -62946,6 +63078,9 @@ function etagOf(doc) {
|
|
|
62946
63078
|
function storeEtag(appId, projectId) {
|
|
62947
63079
|
return etagOf(readContract(appId, projectId));
|
|
62948
63080
|
}
|
|
63081
|
+
function storedContractBytesExist(appId, projectId) {
|
|
63082
|
+
return (0, import_node_fs31.existsSync)(contractPath(appId, projectId));
|
|
63083
|
+
}
|
|
62949
63084
|
var PreconditionFailedError = class extends Error {
|
|
62950
63085
|
code = "precondition-failed";
|
|
62951
63086
|
constructor(message) {
|
|
@@ -63076,7 +63211,7 @@ function acceptSteelForRoute(doc, ctx, from, reads) {
|
|
|
63076
63211
|
}
|
|
63077
63212
|
|
|
63078
63213
|
// knowledge-routes.ts
|
|
63079
|
-
var
|
|
63214
|
+
var import_node_fs33 = require("node:fs");
|
|
63080
63215
|
|
|
63081
63216
|
// sse.ts
|
|
63082
63217
|
var clients = /* @__PURE__ */ new Set();
|
|
@@ -63114,7 +63249,7 @@ function clientCount() {
|
|
|
63114
63249
|
|
|
63115
63250
|
// knowledge-store.ts
|
|
63116
63251
|
var import_node_crypto18 = require("node:crypto");
|
|
63117
|
-
var
|
|
63252
|
+
var import_node_fs32 = require("node:fs");
|
|
63118
63253
|
var import_node_path30 = require("node:path");
|
|
63119
63254
|
var import_yaml6 = __toESM(require_dist6(), 1);
|
|
63120
63255
|
var KnowledgeError = class extends Error {
|
|
@@ -63135,9 +63270,9 @@ function isSourceRow(row) {
|
|
|
63135
63270
|
}
|
|
63136
63271
|
function readManifest(id) {
|
|
63137
63272
|
const p = manifestPath(id);
|
|
63138
|
-
if (!(0,
|
|
63273
|
+
if (!(0, import_node_fs32.existsSync)(p)) return { ...EMPTY_MANIFEST, sources: [] };
|
|
63139
63274
|
try {
|
|
63140
|
-
const parsed = JSON.parse((0,
|
|
63275
|
+
const parsed = JSON.parse((0, import_node_fs32.readFileSync)(p, "utf8"));
|
|
63141
63276
|
if (!parsed || typeof parsed !== "object" || !Array.isArray(parsed.sources)) {
|
|
63142
63277
|
console.warn(`knowledge-store: ignoring schema-invalid manifest.json at ${p} (missing/invalid sources array)`);
|
|
63143
63278
|
return { ...EMPTY_MANIFEST, sources: [] };
|
|
@@ -63161,11 +63296,11 @@ function readManifest(id) {
|
|
|
63161
63296
|
}
|
|
63162
63297
|
function writeManifest(id, manifest) {
|
|
63163
63298
|
const dir = projectKnowledgeDir(id);
|
|
63164
|
-
(0,
|
|
63299
|
+
(0, import_node_fs32.mkdirSync)(dir, { recursive: true });
|
|
63165
63300
|
const dest = manifestPath(id);
|
|
63166
63301
|
const tmp = (0, import_node_path30.join)(dir, `.manifest.json.${process.pid}.${(0, import_node_crypto18.randomUUID)()}.tmp`);
|
|
63167
|
-
(0,
|
|
63168
|
-
(0,
|
|
63302
|
+
(0, import_node_fs32.writeFileSync)(tmp, JSON.stringify(manifest, null, 2));
|
|
63303
|
+
(0, import_node_fs32.renameSync)(tmp, dest);
|
|
63169
63304
|
}
|
|
63170
63305
|
var MAX_FILES = 50;
|
|
63171
63306
|
var MAX_FILE_BYTES = 100 * 1024 * 1024;
|
|
@@ -63242,12 +63377,12 @@ function addSource(id, input) {
|
|
|
63242
63377
|
const { buf, mime, filename } = input;
|
|
63243
63378
|
const sha2563 = (0, import_node_crypto18.createHash)("sha256").update(buf).digest("hex");
|
|
63244
63379
|
const dir = blobsDir(id);
|
|
63245
|
-
(0,
|
|
63380
|
+
(0, import_node_fs32.mkdirSync)(dir, { recursive: true });
|
|
63246
63381
|
const blobPath = blobPathFor(id, sha2563);
|
|
63247
|
-
if (!(0,
|
|
63382
|
+
if (!(0, import_node_fs32.existsSync)(blobPath)) {
|
|
63248
63383
|
const tmp = `${blobPath}.${process.pid}.${(0, import_node_crypto18.randomUUID)()}.tmp`;
|
|
63249
|
-
(0,
|
|
63250
|
-
(0,
|
|
63384
|
+
(0, import_node_fs32.writeFileSync)(tmp, buf);
|
|
63385
|
+
(0, import_node_fs32.renameSync)(tmp, blobPath);
|
|
63251
63386
|
}
|
|
63252
63387
|
const manifest = readManifest(id);
|
|
63253
63388
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -63290,7 +63425,7 @@ function removeSource(id, sourceId) {
|
|
|
63290
63425
|
if (!stillReferenced) {
|
|
63291
63426
|
const blobPath = blobPathFor(id, removed.blobSha256);
|
|
63292
63427
|
try {
|
|
63293
|
-
if ((0,
|
|
63428
|
+
if ((0, import_node_fs32.existsSync)(blobPath)) (0, import_node_fs32.unlinkSync)(blobPath);
|
|
63294
63429
|
} catch (e) {
|
|
63295
63430
|
console.warn(`knowledge-store: could not GC blob ${removed.blobSha256} for ${id}: ${e instanceof Error ? e.message : e}`);
|
|
63296
63431
|
}
|
|
@@ -63300,17 +63435,17 @@ var LOCK_STALE_MS = 10 * 60 * 1e3;
|
|
|
63300
63435
|
var lockPath = (id) => (0, import_node_path30.join)(projectKnowledgeDir(id), "lock.json");
|
|
63301
63436
|
function writeLockFile(id, lock) {
|
|
63302
63437
|
const dir = projectKnowledgeDir(id);
|
|
63303
|
-
(0,
|
|
63438
|
+
(0, import_node_fs32.mkdirSync)(dir, { recursive: true });
|
|
63304
63439
|
const dest = lockPath(id);
|
|
63305
63440
|
const tmp = (0, import_node_path30.join)(dir, `.lock.json.${process.pid}.${(0, import_node_crypto18.randomUUID)()}.tmp`);
|
|
63306
|
-
(0,
|
|
63307
|
-
(0,
|
|
63441
|
+
(0, import_node_fs32.writeFileSync)(tmp, JSON.stringify(lock, null, 2));
|
|
63442
|
+
(0, import_node_fs32.renameSync)(tmp, dest);
|
|
63308
63443
|
}
|
|
63309
63444
|
function readLock(id) {
|
|
63310
63445
|
const p = lockPath(id);
|
|
63311
|
-
if (!(0,
|
|
63446
|
+
if (!(0, import_node_fs32.existsSync)(p)) return null;
|
|
63312
63447
|
try {
|
|
63313
|
-
const parsed = JSON.parse((0,
|
|
63448
|
+
const parsed = JSON.parse((0, import_node_fs32.readFileSync)(p, "utf8"));
|
|
63314
63449
|
if (!parsed || typeof parsed !== "object" || typeof parsed.requestId !== "string" || typeof parsed.createdAt !== "number" || !Number.isFinite(parsed.createdAt)) {
|
|
63315
63450
|
console.warn(`knowledge-store: ignoring schema-invalid lock.json at ${p}`);
|
|
63316
63451
|
return null;
|
|
@@ -63346,7 +63481,7 @@ function releaseLock(id, requestId) {
|
|
|
63346
63481
|
if (existing.requestId !== requestId) return false;
|
|
63347
63482
|
const p = lockPath(id);
|
|
63348
63483
|
try {
|
|
63349
|
-
if ((0,
|
|
63484
|
+
if ((0, import_node_fs32.existsSync)(p)) (0, import_node_fs32.unlinkSync)(p);
|
|
63350
63485
|
} catch (e) {
|
|
63351
63486
|
console.warn(`knowledge-store: could not release lock.json at ${p}: ${e instanceof Error ? e.message : e}`);
|
|
63352
63487
|
}
|
|
@@ -63371,14 +63506,14 @@ function generationWikiDir(id, generationId) {
|
|
|
63371
63506
|
}
|
|
63372
63507
|
function publishGeneration(id, generationId) {
|
|
63373
63508
|
assertGenerationId(generationId);
|
|
63374
|
-
if (!(0,
|
|
63509
|
+
if (!(0, import_node_fs32.existsSync)(generationWikiDir(id, generationId))) throw new KnowledgeError("generation not found");
|
|
63375
63510
|
const pointer = { generationId, publishedAt: (/* @__PURE__ */ new Date()).toISOString() };
|
|
63376
63511
|
const dir = vaultDir(id);
|
|
63377
|
-
(0,
|
|
63512
|
+
(0, import_node_fs32.mkdirSync)(dir, { recursive: true });
|
|
63378
63513
|
const dest = currentGenerationPath(id);
|
|
63379
63514
|
const tmp = (0, import_node_path30.join)(dir, `.current-generation.json.${process.pid}.${(0, import_node_crypto18.randomUUID)()}.tmp`);
|
|
63380
|
-
(0,
|
|
63381
|
-
(0,
|
|
63515
|
+
(0, import_node_fs32.writeFileSync)(tmp, JSON.stringify(pointer, null, 2));
|
|
63516
|
+
(0, import_node_fs32.renameSync)(tmp, dest);
|
|
63382
63517
|
const manifest = readManifest(id);
|
|
63383
63518
|
manifest.currentGeneration = generationId;
|
|
63384
63519
|
writeManifest(id, manifest);
|
|
@@ -63387,9 +63522,9 @@ function publishGeneration(id, generationId) {
|
|
|
63387
63522
|
}
|
|
63388
63523
|
function readCurrentGeneration(id) {
|
|
63389
63524
|
const p = currentGenerationPath(id);
|
|
63390
|
-
if (!(0,
|
|
63525
|
+
if (!(0, import_node_fs32.existsSync)(p)) return null;
|
|
63391
63526
|
try {
|
|
63392
|
-
const parsed = JSON.parse((0,
|
|
63527
|
+
const parsed = JSON.parse((0, import_node_fs32.readFileSync)(p, "utf8"));
|
|
63393
63528
|
if (typeof parsed?.generationId !== "string" || !GENERATION_ID_RE.test(parsed.generationId) || typeof parsed.publishedAt !== "string") {
|
|
63394
63529
|
console.warn(`knowledge-store: ignoring schema-invalid current-generation.json at ${p}`);
|
|
63395
63530
|
return null;
|
|
@@ -63404,7 +63539,7 @@ function currentGenerationWikiDir(id) {
|
|
|
63404
63539
|
const current = readCurrentGeneration(id);
|
|
63405
63540
|
if (!current) return null;
|
|
63406
63541
|
const dir = generationWikiDir(id, current.generationId);
|
|
63407
|
-
return (0,
|
|
63542
|
+
return (0, import_node_fs32.existsSync)(dir) ? dir : null;
|
|
63408
63543
|
}
|
|
63409
63544
|
var WIKI_SLUG_RE = /^[a-z0-9][a-z0-9._-]*$/;
|
|
63410
63545
|
var KB_MAX_NODES = 300;
|
|
@@ -63412,9 +63547,9 @@ var KB_MAX_TOTAL_BYTES = 8 * 1024 * 1024;
|
|
|
63412
63547
|
var KB_MAX_VISITS = 5e3;
|
|
63413
63548
|
var KB_MAX_PAGE_BYTES = 512 * 1024;
|
|
63414
63549
|
var REAL_IO = {
|
|
63415
|
-
readdir: (dir) => (0,
|
|
63416
|
-
readFile: (path) => (0,
|
|
63417
|
-
statSize: (path) => (0,
|
|
63550
|
+
readdir: (dir) => (0, import_node_fs32.readdirSync)(dir, { withFileTypes: true }),
|
|
63551
|
+
readFile: (path) => (0, import_node_fs32.readFileSync)(path, "utf8"),
|
|
63552
|
+
statSize: (path) => (0, import_node_fs32.statSync)(path).size
|
|
63418
63553
|
};
|
|
63419
63554
|
var VAULT_START = "<!-- vault:generated:start -->";
|
|
63420
63555
|
var VAULT_END = "<!-- vault:generated:end -->";
|
|
@@ -63714,17 +63849,17 @@ function readKnowledgeSummaries(wikiDir, opts = {}, io = REAL_IO) {
|
|
|
63714
63849
|
var organizePath = (id) => (0, import_node_path30.join)(projectKnowledgeDir(id), "organize.json");
|
|
63715
63850
|
function writeOrganizeFile(id, org) {
|
|
63716
63851
|
const dir = projectKnowledgeDir(id);
|
|
63717
|
-
(0,
|
|
63852
|
+
(0, import_node_fs32.mkdirSync)(dir, { recursive: true });
|
|
63718
63853
|
const dest = organizePath(id);
|
|
63719
63854
|
const tmp = (0, import_node_path30.join)(dir, `.organize.json.${process.pid}.${(0, import_node_crypto18.randomUUID)()}.tmp`);
|
|
63720
|
-
(0,
|
|
63721
|
-
(0,
|
|
63855
|
+
(0, import_node_fs32.writeFileSync)(tmp, JSON.stringify(org, null, 2));
|
|
63856
|
+
(0, import_node_fs32.renameSync)(tmp, dest);
|
|
63722
63857
|
}
|
|
63723
63858
|
function readOrganize(id) {
|
|
63724
63859
|
const p = organizePath(id);
|
|
63725
|
-
if (!(0,
|
|
63860
|
+
if (!(0, import_node_fs32.existsSync)(p)) return null;
|
|
63726
63861
|
try {
|
|
63727
|
-
const parsed = JSON.parse((0,
|
|
63862
|
+
const parsed = JSON.parse((0, import_node_fs32.readFileSync)(p, "utf8"));
|
|
63728
63863
|
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
63864
|
console.warn(`knowledge-store: ignoring schema-invalid organize.json at ${p}`);
|
|
63730
63865
|
return null;
|
|
@@ -63743,7 +63878,7 @@ function readOrganize(id) {
|
|
|
63743
63878
|
function deleteOrganizeFile(id) {
|
|
63744
63879
|
const p = organizePath(id);
|
|
63745
63880
|
try {
|
|
63746
|
-
if ((0,
|
|
63881
|
+
if ((0, import_node_fs32.existsSync)(p)) (0, import_node_fs32.unlinkSync)(p);
|
|
63747
63882
|
} catch (e) {
|
|
63748
63883
|
console.warn(`knowledge-store: could not delete organize.json at ${p}: ${e instanceof Error ? e.message : e}`);
|
|
63749
63884
|
}
|
|
@@ -63761,7 +63896,7 @@ function startOrganize(id, requestId) {
|
|
|
63761
63896
|
const generationId = mintGenerationId();
|
|
63762
63897
|
const manifest = readManifest(id);
|
|
63763
63898
|
const baseRevision = manifest.revision;
|
|
63764
|
-
(0,
|
|
63899
|
+
(0, import_node_fs32.mkdirSync)(generationWikiDir(id, generationId), { recursive: true });
|
|
63765
63900
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
63766
63901
|
for (const row of manifest.sources) {
|
|
63767
63902
|
if (row.useAsKb) {
|
|
@@ -63782,8 +63917,8 @@ function finishOrganize(id, requestId, opts) {
|
|
|
63782
63917
|
throw new KnowledgeError("generation id mismatch");
|
|
63783
63918
|
}
|
|
63784
63919
|
const wikiDir = generationWikiDir(id, org.generationId);
|
|
63785
|
-
if (!(0,
|
|
63786
|
-
if ((0,
|
|
63920
|
+
if (!(0, import_node_fs32.existsSync)(wikiDir)) throw new KnowledgeError("generation not found");
|
|
63921
|
+
if ((0, import_node_fs32.readdirSync)(wikiDir).length === 0) {
|
|
63787
63922
|
throw new KnowledgeError("nothing to publish \u2014 generation is empty");
|
|
63788
63923
|
}
|
|
63789
63924
|
publishGeneration(id, org.generationId);
|
|
@@ -63824,14 +63959,14 @@ function failOrganize(id, requestId, opts) {
|
|
|
63824
63959
|
}
|
|
63825
63960
|
function gcOldGenerations(id, currentGenerationId) {
|
|
63826
63961
|
const dir = generationsDir(id);
|
|
63827
|
-
if (!(0,
|
|
63828
|
-
const entries2 = (0,
|
|
63962
|
+
if (!(0, import_node_fs32.existsSync)(dir)) return;
|
|
63963
|
+
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
63964
|
const keep = new Set(entries2.slice(0, GEN_KEEP).map((e) => e.name));
|
|
63830
63965
|
keep.add(currentGenerationId);
|
|
63831
63966
|
for (const e of entries2) {
|
|
63832
63967
|
if (keep.has(e.name)) continue;
|
|
63833
63968
|
try {
|
|
63834
|
-
(0,
|
|
63969
|
+
(0, import_node_fs32.rmSync)((0, import_node_path30.join)(dir, e.name), { recursive: true, force: true });
|
|
63835
63970
|
} catch (err2) {
|
|
63836
63971
|
console.warn(`knowledge-store: could not GC stale generation dir ${e.name}: ${err2 instanceof Error ? err2.message : err2}`);
|
|
63837
63972
|
}
|
|
@@ -63947,7 +64082,7 @@ function registerKnowledgeRoutes(app) {
|
|
|
63947
64082
|
const blobPath = blobPathFor(project.id, row.blobSha256);
|
|
63948
64083
|
let fd2;
|
|
63949
64084
|
try {
|
|
63950
|
-
fd2 = (0,
|
|
64085
|
+
fd2 = (0, import_node_fs33.openSync)(blobPath, "r");
|
|
63951
64086
|
} catch (e) {
|
|
63952
64087
|
const code = e.code;
|
|
63953
64088
|
if (code === "ENOENT" || code === "ENOTDIR") {
|
|
@@ -63957,17 +64092,17 @@ function registerKnowledgeRoutes(app) {
|
|
|
63957
64092
|
}
|
|
63958
64093
|
let streamOwnsFd = false;
|
|
63959
64094
|
try {
|
|
63960
|
-
const st = (0,
|
|
64095
|
+
const st = (0, import_node_fs33.fstatSync)(fd2);
|
|
63961
64096
|
if (!st.isFile()) {
|
|
63962
64097
|
return reply.status(404).send({ ok: false, error: "source bytes are missing" });
|
|
63963
64098
|
}
|
|
63964
64099
|
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
64100
|
if (req.method === "HEAD") return reply.send();
|
|
63966
|
-
const stream = (0,
|
|
64101
|
+
const stream = (0, import_node_fs33.createReadStream)(blobPath, { fd: fd2, autoClose: true });
|
|
63967
64102
|
streamOwnsFd = true;
|
|
63968
64103
|
return reply.send(stream);
|
|
63969
64104
|
} finally {
|
|
63970
|
-
if (!streamOwnsFd) (0,
|
|
64105
|
+
if (!streamOwnsFd) (0, import_node_fs33.closeSync)(fd2);
|
|
63971
64106
|
}
|
|
63972
64107
|
} catch (e) {
|
|
63973
64108
|
if (e instanceof ProjectError) return reply.status(400).send({ ok: false, error: e.message });
|
|
@@ -64933,21 +65068,21 @@ function viewOf(p, facts) {
|
|
|
64933
65068
|
|
|
64934
65069
|
// project-sources-store.ts
|
|
64935
65070
|
var import_node_crypto19 = require("node:crypto");
|
|
64936
|
-
var
|
|
65071
|
+
var import_node_fs34 = require("node:fs");
|
|
64937
65072
|
var import_node_path31 = require("node:path");
|
|
64938
65073
|
var sourcesDir = (id) => (0, import_node_path31.join)(projectDir(id), "sources");
|
|
64939
65074
|
var safeExt = (ext) => typeof ext === "string" && /^[a-z0-9]{1,8}$/i.test(ext) ? ext.toLowerCase() : "bin";
|
|
64940
65075
|
function writeAtomic2(path, buf) {
|
|
64941
65076
|
const tmp = `${path}.${process.pid}.tmp`;
|
|
64942
|
-
(0,
|
|
64943
|
-
(0,
|
|
65077
|
+
(0, import_node_fs34.writeFileSync)(tmp, buf);
|
|
65078
|
+
(0, import_node_fs34.renameSync)(tmp, path);
|
|
64944
65079
|
}
|
|
64945
65080
|
function saveSource(id, file) {
|
|
64946
|
-
(0,
|
|
65081
|
+
(0, import_node_fs34.mkdirSync)(sourcesDir(id), { recursive: true });
|
|
64947
65082
|
const sha2563 = (0, import_node_crypto19.createHash)("sha256").update(file.buf).digest("hex");
|
|
64948
65083
|
const ext = safeExt(file.ext);
|
|
64949
65084
|
const p = (0, import_node_path31.join)(sourcesDir(id), `${sha2563}.${ext}`);
|
|
64950
|
-
if (!(0,
|
|
65085
|
+
if (!(0, import_node_fs34.existsSync)(p)) writeAtomic2(p, file.buf);
|
|
64951
65086
|
return { name: String(file.name), sha256: sha2563, ext, bytes: file.buf.length };
|
|
64952
65087
|
}
|
|
64953
65088
|
|
|
@@ -64997,6 +65132,22 @@ function cutToBooleanCut(part) {
|
|
|
64997
65132
|
}
|
|
64998
65133
|
return { id: part.id, kind: "boolean-cut", targetId: part.member, tool: box };
|
|
64999
65134
|
}
|
|
65135
|
+
function connectionsFromParts(parts) {
|
|
65136
|
+
const byId = /* @__PURE__ */ new Map();
|
|
65137
|
+
const order = [];
|
|
65138
|
+
for (const p of parts ?? []) {
|
|
65139
|
+
if (!p || !p.conn) continue;
|
|
65140
|
+
let c = byId.get(p.conn);
|
|
65141
|
+
if (!c) {
|
|
65142
|
+
c = { id: p.conn, kind: p.connKind, memberIds: [], childIds: [] };
|
|
65143
|
+
byId.set(p.conn, c);
|
|
65144
|
+
order.push(p.conn);
|
|
65145
|
+
}
|
|
65146
|
+
if (p.id) c.childIds.push(p.id);
|
|
65147
|
+
if (p.kind === "cut" && p.member && !c.memberIds.includes(p.member)) c.memberIds.push(p.member);
|
|
65148
|
+
}
|
|
65149
|
+
return order.map((id) => byId.get(id));
|
|
65150
|
+
}
|
|
65000
65151
|
var GROUPS = {
|
|
65001
65152
|
"base-plate": { key: "base-plate", label: "Base plates", color: "#6b7a8d" },
|
|
65002
65153
|
// darkest plate grey
|
|
@@ -65969,6 +66120,63 @@ function expandJoints(joints, memberGeo) {
|
|
|
65969
66120
|
return { elements, operations, viewOperations, memberTrims, groups, skipped, diagnostics };
|
|
65970
66121
|
}
|
|
65971
66122
|
|
|
66123
|
+
// steel-part-coverage.ts
|
|
66124
|
+
function coverageOk(c) {
|
|
66125
|
+
return c.fail.neverBuilt.length === 0 && c.fail.fused.length === 0 && c.fail.duplicatePartIds.length === 0;
|
|
66126
|
+
}
|
|
66127
|
+
var specifiedId = (j, i) => j && j.id ? j.id : `joint#${i}`;
|
|
66128
|
+
function partCoverage(joints, built) {
|
|
66129
|
+
const rows2 = joints ?? [];
|
|
66130
|
+
const elements = built.elements ?? [];
|
|
66131
|
+
const skipped = new Set(built.skippedJointIds ?? []);
|
|
66132
|
+
const claims = /* @__PURE__ */ new Map();
|
|
66133
|
+
const order = [];
|
|
66134
|
+
rows2.forEach((j, i) => {
|
|
66135
|
+
const id = specifiedId(j, i);
|
|
66136
|
+
if (!claims.has(id)) order.push(id);
|
|
66137
|
+
claims.set(id, (claims.get(id) ?? 0) + 1);
|
|
66138
|
+
});
|
|
66139
|
+
const builtIds = new Set(connectionsFromParts(elements).map((c) => c.id));
|
|
66140
|
+
const neverBuilt = order.filter((id) => !builtIds.has(id) && !skipped.has(id));
|
|
66141
|
+
const fused = order.filter((id) => (claims.get(id) ?? 0) > 1 && builtIds.has(id));
|
|
66142
|
+
const orphanedParts = [];
|
|
66143
|
+
const unattributedParts = [];
|
|
66144
|
+
for (const p of elements) {
|
|
66145
|
+
if (!p) continue;
|
|
66146
|
+
if (!p.conn) {
|
|
66147
|
+
unattributedParts.push(p.id || "<anonymous>");
|
|
66148
|
+
continue;
|
|
66149
|
+
}
|
|
66150
|
+
if (!claims.has(p.conn)) orphanedParts.push({ partId: p.id ?? null, conn: p.conn });
|
|
66151
|
+
}
|
|
66152
|
+
const seen = /* @__PURE__ */ new Set();
|
|
66153
|
+
const dupes = /* @__PURE__ */ new Set();
|
|
66154
|
+
for (const p of elements) {
|
|
66155
|
+
const id = p?.id;
|
|
66156
|
+
if (!id) continue;
|
|
66157
|
+
if (seen.has(id)) dupes.add(id);
|
|
66158
|
+
seen.add(id);
|
|
66159
|
+
}
|
|
66160
|
+
return {
|
|
66161
|
+
specified: rows2.length,
|
|
66162
|
+
builtOfSpecified: order.filter((id) => builtIds.has(id)).length,
|
|
66163
|
+
fail: { neverBuilt, fused, duplicatePartIds: [...dupes] },
|
|
66164
|
+
warn: { orphanedParts, unattributedParts }
|
|
66165
|
+
};
|
|
66166
|
+
}
|
|
66167
|
+
function describeCoverage(c) {
|
|
66168
|
+
const fails = [];
|
|
66169
|
+
if (c.fail.neverBuilt.length) fails.push(`${c.fail.neverBuilt.length} specified but never built (${c.fail.neverBuilt.join(", ")})`);
|
|
66170
|
+
if (c.fail.fused.length) fails.push(`${c.fail.fused.length} fused onto one connection (${c.fail.fused.join(", ")})`);
|
|
66171
|
+
if (c.fail.duplicatePartIds.length) fails.push(`${c.fail.duplicatePartIds.length} duplicate part id(s)`);
|
|
66172
|
+
const warns = [];
|
|
66173
|
+
if (c.warn.orphanedParts.length) warns.push(`${c.warn.orphanedParts.length} part(s) name a connection that was never specified`);
|
|
66174
|
+
if (c.warn.unattributedParts.length) warns.push(`${c.warn.unattributedParts.length} part(s) belong to no connection at all`);
|
|
66175
|
+
const head = coverageOk(c) ? c.specified === 0 ? "coverage: no connections specified \u2014 nothing to reconcile" : `coverage ok \u2014 ${c.builtOfSpecified}/${c.specified} specified connection(s) built` : `coverage FAILED \u2014 ${fails.join("; ")}`;
|
|
66176
|
+
const warned = warns.length ? `${head} (warning: ${warns.join("; ")})` : head;
|
|
66177
|
+
return `${warned}. Proves what was built matches what was specified, never that enough was specified.`;
|
|
66178
|
+
}
|
|
66179
|
+
|
|
65972
66180
|
// export-identity.ts
|
|
65973
66181
|
var import_node_crypto20 = require("node:crypto");
|
|
65974
66182
|
function deriveExportSourceId(kind, ownerId, installation = installId()) {
|
|
@@ -67515,6 +67723,8 @@ function contractToScene(contractInput) {
|
|
|
67515
67723
|
color: pickColor(profile, paletteRank.indexOf(profile), contract)
|
|
67516
67724
|
}));
|
|
67517
67725
|
const joints = expandJoints(contract.joints, memberGeo);
|
|
67726
|
+
const coverage = partCoverage(contract.joints, { elements: joints.elements, skippedJointIds: joints.skipped });
|
|
67727
|
+
if (!coverageOk(coverage)) console.warn(`[steel] ${describeCoverage(coverage)}`);
|
|
67518
67728
|
applyBeamClearance(elements, beamClears, refusedJointIds(contract.joints, joints.skipped));
|
|
67519
67729
|
for (const id of applyMemberTrims(elements, joints.memberTrims)) skipped.push(`trim:${id}`);
|
|
67520
67730
|
for (const part of joints.elements) {
|
|
@@ -67538,7 +67748,8 @@ function contractToScene(contractInput) {
|
|
|
67538
67748
|
scene: { meta: { name: contract.title || "Steel Model", units: "mm", up: "z" }, groups, elements, ...weldOperations.length ? { operations: weldOperations } : {} },
|
|
67539
67749
|
skipped,
|
|
67540
67750
|
operations: joints.operations,
|
|
67541
|
-
diagnostics: joints.diagnostics
|
|
67751
|
+
diagnostics: joints.diagnostics,
|
|
67752
|
+
coverage
|
|
67542
67753
|
};
|
|
67543
67754
|
}
|
|
67544
67755
|
var SceneContractError = class extends Error {
|
|
@@ -67810,7 +68021,7 @@ function contractToAwareScene(contractInput, sourceId) {
|
|
|
67810
68021
|
referenceSystems: grids.referenceSystems
|
|
67811
68022
|
};
|
|
67812
68023
|
scene.meta.sceneHash = sceneHash(scene);
|
|
67813
|
-
return { scene, skipped: legacy.skipped, producerUnsupported };
|
|
68024
|
+
return { scene, skipped: legacy.skipped, producerUnsupported, coverage: legacy.coverage };
|
|
67814
68025
|
}
|
|
67815
68026
|
function sceneFromModel(view) {
|
|
67816
68027
|
const blocked = membersBlockingExport(view.doc);
|
|
@@ -67905,6 +68116,8 @@ function sceneFromModel(view) {
|
|
|
67905
68116
|
color: pickColor(profile, paletteRank.indexOf(profile), view.doc)
|
|
67906
68117
|
}));
|
|
67907
68118
|
const joints = expandJoints(view.doc.joints, memberGeo);
|
|
68119
|
+
const coverage = partCoverage(view.doc.joints, { elements: joints.elements, skippedJointIds: joints.skipped });
|
|
68120
|
+
if (!coverageOk(coverage)) console.warn(`[steel] ${describeCoverage(coverage)}`);
|
|
67908
68121
|
applyBeamClearance(elements, beamClears, refusedJointIds(view.doc.joints, joints.skipped));
|
|
67909
68122
|
for (const id of applyMemberTrims(elements, joints.memberTrims)) skipped.push(`trim:${id}`);
|
|
67910
68123
|
for (const part of joints.elements) elements.push(part);
|
|
@@ -67916,7 +68129,8 @@ function sceneFromModel(view) {
|
|
|
67916
68129
|
scene: { meta: { name: "Steel Model", units: "mm", up: "z" }, groups, elements },
|
|
67917
68130
|
skipped,
|
|
67918
68131
|
operations: joints.operations,
|
|
67919
|
-
diagnostics: joints.diagnostics
|
|
68132
|
+
diagnostics: joints.diagnostics,
|
|
68133
|
+
coverage
|
|
67920
68134
|
};
|
|
67921
68135
|
}
|
|
67922
68136
|
function modelGridRecords(grid) {
|
|
@@ -68052,7 +68266,7 @@ function awareSceneFromModel(contractInput, sourceId) {
|
|
|
68052
68266
|
};
|
|
68053
68267
|
assertExportIdentityNamespace(scene, producerUnsupported);
|
|
68054
68268
|
scene.meta.sceneHash = sceneHash(scene);
|
|
68055
|
-
return { scene, skipped: legacy.skipped, producerUnsupported };
|
|
68269
|
+
return { scene, skipped: legacy.skipped, producerUnsupported, coverage: legacy.coverage };
|
|
68056
68270
|
}
|
|
68057
68271
|
|
|
68058
68272
|
// ../web/steel-detail-refs.js
|
|
@@ -68710,6 +68924,17 @@ function registerRevisionRoutes(app) {
|
|
|
68710
68924
|
return { ok: true, version: version2, contractType: STEEL_V2 };
|
|
68711
68925
|
} catch (error) {
|
|
68712
68926
|
if (error instanceof ContractTransactionError) {
|
|
68927
|
+
const expectedRace = error.code === "contract-changed" || error.code === "history-already-exists";
|
|
68928
|
+
req.log[expectedRace ? "warn" : "error"](
|
|
68929
|
+
{
|
|
68930
|
+
projectId: project.id,
|
|
68931
|
+
requestId: request.id,
|
|
68932
|
+
code: error.code,
|
|
68933
|
+
reason: error.message,
|
|
68934
|
+
...error.details === void 0 ? {} : { details: error.details }
|
|
68935
|
+
},
|
|
68936
|
+
`initial read refused: ${error.code}`
|
|
68937
|
+
);
|
|
68713
68938
|
return reply.status(400).send({ ok: false, error: error.message, code: error.code });
|
|
68714
68939
|
}
|
|
68715
68940
|
throw error;
|
|
@@ -69063,13 +69288,33 @@ function registerSteelPrepassRoute(app, deps) {
|
|
|
69063
69288
|
var import_node_crypto22 = require("node:crypto");
|
|
69064
69289
|
|
|
69065
69290
|
// reference-import.ts
|
|
69066
|
-
var
|
|
69291
|
+
var import_node_fs35 = require("node:fs");
|
|
69067
69292
|
var import_node_path32 = require("node:path");
|
|
69068
69293
|
var AGENT2 = "ifc-reference-reader";
|
|
69069
69294
|
var WARN_BYTES = 50 * 1024 * 1024;
|
|
69070
69295
|
var MAX_BYTES5 = 150 * 1024 * 1024;
|
|
69071
69296
|
var MAX_VERTICES2 = 8e6;
|
|
69297
|
+
var MAX_OBJECTS = 2e4;
|
|
69298
|
+
var WARN_OBJECTS = 11e3;
|
|
69299
|
+
function objectVerdict(objects) {
|
|
69300
|
+
if (!Number.isFinite(objects)) return "ok";
|
|
69301
|
+
if (objects > MAX_OBJECTS) return "refuse";
|
|
69302
|
+
return objects >= WARN_OBJECTS ? "warn" : "ok";
|
|
69303
|
+
}
|
|
69072
69304
|
var ReferenceImportError = class extends Error {
|
|
69305
|
+
/**
|
|
69306
|
+
* A stable discriminator for the refusals a CALLER has to tell apart.
|
|
69307
|
+
*
|
|
69308
|
+
* Added for the unconfirmed-filter refusal: without it every `ReferenceImportError` reaches the
|
|
69309
|
+
* browser as a bare message, and the import modal — which keeps the storey picker on screen only for
|
|
69310
|
+
* refusals it recognises — threw the user's whole selection away on the one refusal whose remedy is
|
|
69311
|
+
* to try again.
|
|
69312
|
+
*/
|
|
69313
|
+
constructor(message, code) {
|
|
69314
|
+
super(message);
|
|
69315
|
+
this.code = code;
|
|
69316
|
+
}
|
|
69317
|
+
code;
|
|
69073
69318
|
};
|
|
69074
69319
|
var mb2 = (bytes) => `${Math.round(bytes / (1024 * 1024))} MB`;
|
|
69075
69320
|
function dataUrlBytes(dataUrl) {
|
|
@@ -69144,16 +69389,74 @@ function toPropertySets(raw) {
|
|
|
69144
69389
|
function offersPropertySets(raw) {
|
|
69145
69390
|
return Array.isArray(raw) && raw.some((s) => !!s && typeof s === "object" && Array.isArray(s.properties));
|
|
69146
69391
|
}
|
|
69147
|
-
|
|
69148
|
-
|
|
69149
|
-
|
|
69150
|
-
const
|
|
69151
|
-
|
|
69152
|
-
|
|
69153
|
-
|
|
69154
|
-
|
|
69392
|
+
function toProbeBreakdown(raw) {
|
|
69393
|
+
if (!Array.isArray(raw)) return null;
|
|
69394
|
+
const rows2 = [];
|
|
69395
|
+
for (const r of raw) {
|
|
69396
|
+
const q = r;
|
|
69397
|
+
if (!q || typeof q !== "object" || Array.isArray(q)) return null;
|
|
69398
|
+
if (!("name" in q) || q.name !== null && typeof q.name !== "string") return null;
|
|
69399
|
+
if (!Number.isInteger(q.elements) || q.elements < 0) return null;
|
|
69400
|
+
rows2.push({ name: q.name ?? null, elements: q.elements });
|
|
69401
|
+
}
|
|
69402
|
+
return rows2;
|
|
69403
|
+
}
|
|
69404
|
+
var sumRows = (rows2) => rows2 === null ? null : rows2.reduce((n, r) => n + r.elements, 0);
|
|
69405
|
+
function readPopulation(probe) {
|
|
69406
|
+
const sums = [sumRows(probe.storeys), sumRows(probe.types)].filter((n) => n !== null);
|
|
69407
|
+
const known = sums.length ? Math.max(...sums) : null;
|
|
69408
|
+
return known ? known : null;
|
|
69409
|
+
}
|
|
69410
|
+
function selectedPopulation(probe, filter) {
|
|
69411
|
+
if (!emittedFilter(filter)) return readPopulation(probe);
|
|
69412
|
+
const sumOf = (rows2, want) => {
|
|
69413
|
+
if (rows2 === null || !want?.length) return null;
|
|
69414
|
+
const lower = new Set(want.map((s) => s.toLowerCase()));
|
|
69415
|
+
const hit = rows2.filter((r) => r.name !== null && lower.has(r.name.toLowerCase()));
|
|
69416
|
+
return hit.length ? hit.reduce((n, r) => n + r.elements, 0) : null;
|
|
69417
|
+
};
|
|
69418
|
+
const both = [sumOf(probe.storeys, filter?.storeys), sumOf(probe.types, filter?.ifcTypes)].filter((n) => n !== null);
|
|
69419
|
+
return both.length ? Math.min(...both) : null;
|
|
69420
|
+
}
|
|
69421
|
+
function emittedFilter(filter) {
|
|
69422
|
+
const storeys = filter?.storeys?.length ? filter.storeys : void 0;
|
|
69423
|
+
const ifcTypes = filter?.ifcTypes?.length ? filter.ifcTypes : void 0;
|
|
69424
|
+
return storeys || ifcTypes ? { ...storeys ? { storeys } : {}, ...ifcTypes ? { ifcTypes } : {} } : null;
|
|
69425
|
+
}
|
|
69426
|
+
function assertSelectionConfirmed(selected, filter) {
|
|
69427
|
+
const asked = emittedFilter(filter);
|
|
69428
|
+
if (!asked) return;
|
|
69429
|
+
if (!selected) {
|
|
69430
|
+
throw new ReferenceImportError(
|
|
69431
|
+
"the reader did not confirm which storeys it loaded, so FloLess stopped rather than show you the whole model by mistake.",
|
|
69432
|
+
"reference-filter-unconfirmed"
|
|
69433
|
+
);
|
|
69434
|
+
}
|
|
69435
|
+
for (const axis of ["storeys", "ifcTypes"]) {
|
|
69436
|
+
if (asked[axis]?.length && !selected[axis]?.length) {
|
|
69437
|
+
throw new ReferenceImportError(
|
|
69438
|
+
"the reader confirmed only part of what you chose, so FloLess stopped rather than show you more of the model than you asked for.",
|
|
69439
|
+
"reference-filter-unconfirmed"
|
|
69440
|
+
);
|
|
69441
|
+
}
|
|
69155
69442
|
}
|
|
69156
|
-
|
|
69443
|
+
}
|
|
69444
|
+
function toSelection(raw) {
|
|
69445
|
+
const q = raw;
|
|
69446
|
+
if (!q || typeof q !== "object" || Array.isArray(q)) return null;
|
|
69447
|
+
if (!Number.isInteger(q.candidates) || q.candidates < 0) return null;
|
|
69448
|
+
if (!Array.isArray(q.unmatched)) return null;
|
|
69449
|
+
const names = (v) => Array.isArray(v) && v.every((s) => typeof s === "string") ? v : void 0;
|
|
69450
|
+
const storeys = names(q.storeys);
|
|
69451
|
+
const ifcTypes = names(q.ifcTypes);
|
|
69452
|
+
const ids = names(q.ids);
|
|
69453
|
+
return {
|
|
69454
|
+
...storeys ? { storeys } : {},
|
|
69455
|
+
...ifcTypes ? { ifcTypes } : {},
|
|
69456
|
+
...ids ? { ids } : {},
|
|
69457
|
+
candidates: q.candidates,
|
|
69458
|
+
unmatched: q.unmatched.filter((u) => !!u && typeof u === "object" && !Array.isArray(u))
|
|
69459
|
+
};
|
|
69157
69460
|
}
|
|
69158
69461
|
function toReferenceObjects(raw) {
|
|
69159
69462
|
if (!raw || !Array.isArray(raw.objects)) {
|
|
@@ -69225,7 +69528,12 @@ function toReferenceObjects(raw) {
|
|
|
69225
69528
|
* the truth is that we refused what arrived. Counting the validated output makes that case report
|
|
69226
69529
|
* `null` instead, which is the state whose remedy ("Reload its geometry") is the right one.
|
|
69227
69530
|
*/
|
|
69228
|
-
propertySetsAvailable: objects.some((o) => o.propertySets) ? true : null
|
|
69531
|
+
propertySetsAvailable: objects.some((o) => o.propertySets) ? true : null,
|
|
69532
|
+
/**
|
|
69533
|
+
* THE FILTER RECEIPT, carried verbatim so the caller can check the run it asked for is the run it
|
|
69534
|
+
* got. Null for an unfiltered read — which is a fact about the reader, not a shortfall.
|
|
69535
|
+
*/
|
|
69536
|
+
selected: toSelection(raw.selected)
|
|
69229
69537
|
};
|
|
69230
69538
|
}
|
|
69231
69539
|
var REFERENCE_DIR = "references";
|
|
@@ -69245,9 +69553,9 @@ function projectRelativeReferencePath(fileName, taken = /* @__PURE__ */ new Set(
|
|
|
69245
69553
|
return candidate;
|
|
69246
69554
|
}
|
|
69247
69555
|
var readerChain2 = Promise.resolve();
|
|
69248
|
-
function writeReaderApp2(companionId, command, ifcPath) {
|
|
69556
|
+
function writeReaderApp2(companionId, command, ifcPath, filter) {
|
|
69249
69557
|
const dir = appPath(companionId);
|
|
69250
|
-
(0,
|
|
69558
|
+
(0, import_node_fs35.mkdirSync)(dir, { recursive: true });
|
|
69251
69559
|
const flo = (0, import_node_path32.join)(dir, `${companionId}.flo`);
|
|
69252
69560
|
const lines = [
|
|
69253
69561
|
`app: ${companionId}`,
|
|
@@ -69256,13 +69564,23 @@ function writeReaderApp2(companionId, command, ifcPath) {
|
|
|
69256
69564
|
`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
69565
|
"exposes-as-agent: false",
|
|
69258
69566
|
"requires:",
|
|
69259
|
-
//
|
|
69260
|
-
//
|
|
69261
|
-
//
|
|
69262
|
-
//
|
|
69263
|
-
//
|
|
69264
|
-
//
|
|
69265
|
-
`
|
|
69567
|
+
// UNPINNED, DELIBERATELY — and this is not laziness, it is the only true statement
|
|
69568
|
+
// available. floless supports BOTH reader lines and tells them apart by the `frame` in
|
|
69569
|
+
// the response, because the agent and the BRIDGE BINARY that actually produces the
|
|
69570
|
+
// coordinates are versioned independently: the bridge installs separately and a stale one
|
|
69571
|
+
// only warns. So no version pin describes what you will actually get, and AWARE's pin
|
|
69572
|
+
// grammar has no way to say "either line" — it takes `maj.min.pat`, `maj.min.x` or
|
|
69573
|
+
// `maj.x`, with no ranges and no alternation. An entry with no `@` is legal and means
|
|
69574
|
+
// exactly what we mean: this app needs the agent, and judges its output itself.
|
|
69575
|
+
//
|
|
69576
|
+
// Measured against the real binary (aware-aeco/aware @ b6084d5d9): `@0.1.x` against the
|
|
69577
|
+
// shipped 1.0.0 agent fails compile with E_APP_AGENT_PIN_UNSATISFIED, and `@>=0.1.0` fails
|
|
69578
|
+
// with E_APP_REQUIRES_MALFORMED because `>=` is not in the grammar at all. Both were
|
|
69579
|
+
// harmless while pins were enforced nowhere; aware-aeco/aware#349 made them enforced at
|
|
69580
|
+
// compile AND run, so both would have broken IFC import outright on the next AWARE release.
|
|
69581
|
+
// (This line previously read `@>=0.1.0`, reaching for the right meaning with a spelling the
|
|
69582
|
+
// grammar does not have. The intent was right; the syntax was never parsed.)
|
|
69583
|
+
` - ${AGENT2}`,
|
|
69266
69584
|
"layout: linear",
|
|
69267
69585
|
"nodes:",
|
|
69268
69586
|
` - id: ${command}`,
|
|
@@ -69271,9 +69589,14 @@ function writeReaderApp2(companionId, command, ifcPath) {
|
|
|
69271
69589
|
" config:",
|
|
69272
69590
|
` ifc-path: ${JSON.stringify(ifcPath)}`
|
|
69273
69591
|
];
|
|
69274
|
-
if (command === "read-model")
|
|
69592
|
+
if (command === "read-model") {
|
|
69593
|
+
lines.push(` max-vertices: ${MAX_VERTICES2}`);
|
|
69594
|
+
const emit = emittedFilter(filter);
|
|
69595
|
+
if (emit?.storeys) lines.push(` storeys: ${JSON.stringify(emit.storeys)}`);
|
|
69596
|
+
if (emit?.ifcTypes) lines.push(` ifc-types: ${JSON.stringify(emit.ifcTypes)}`);
|
|
69597
|
+
}
|
|
69275
69598
|
lines.push("");
|
|
69276
|
-
(0,
|
|
69599
|
+
(0, import_node_fs35.writeFileSync)(flo, lines.join("\n"));
|
|
69277
69600
|
return flo;
|
|
69278
69601
|
}
|
|
69279
69602
|
function nodeOutput2(traceText, node) {
|
|
@@ -69299,7 +69622,7 @@ async function runReader2(companionId, command, ifcPath, opts = {}) {
|
|
|
69299
69622
|
await prev.catch(() => {
|
|
69300
69623
|
});
|
|
69301
69624
|
try {
|
|
69302
|
-
const flo = writeReaderApp2(companionId, command, ifcPath);
|
|
69625
|
+
const flo = writeReaderApp2(companionId, command, ifcPath, opts.filter);
|
|
69303
69626
|
try {
|
|
69304
69627
|
await aware.compile(flo);
|
|
69305
69628
|
} catch (e) {
|
|
@@ -69330,18 +69653,24 @@ async function probeReference(companionId, ifcPath, opts = {}) {
|
|
|
69330
69653
|
elements: typeof out.elements === "number" ? out.elements : 0,
|
|
69331
69654
|
// null is meaningful here and must survive: it means the reader could not establish an extent, and
|
|
69332
69655
|
// 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
|
|
69656
|
+
bbox: bbox && Array.isArray(bbox.min) && Array.isArray(bbox.max) ? bbox : null,
|
|
69657
|
+
// The picker's whole data source. Null here means the bridge could not answer, never that the file
|
|
69658
|
+
// has no storeys — see `ReferenceProbe`.
|
|
69659
|
+
storeys: toProbeBreakdown(out.storeys),
|
|
69660
|
+
types: toProbeBreakdown(out.types)
|
|
69334
69661
|
};
|
|
69335
69662
|
}
|
|
69336
69663
|
async function readReferenceModel(companionId, ifcPath, opts = {}) {
|
|
69337
69664
|
await ensureReferenceReader();
|
|
69338
69665
|
const out = await runReader2(companionId, "read-model", ifcPath, opts);
|
|
69339
|
-
|
|
69666
|
+
const read = toReferenceObjects(out);
|
|
69667
|
+
assertSelectionConfirmed(read.selected, opts.filter);
|
|
69668
|
+
return read;
|
|
69340
69669
|
}
|
|
69341
69670
|
|
|
69342
69671
|
// reference-store.ts
|
|
69343
69672
|
var import_node_crypto21 = require("node:crypto");
|
|
69344
|
-
var
|
|
69673
|
+
var import_node_fs36 = require("node:fs");
|
|
69345
69674
|
var import_promises4 = require("node:stream/promises");
|
|
69346
69675
|
var import_node_path33 = require("node:path");
|
|
69347
69676
|
function insideProject(projectId, relPath) {
|
|
@@ -69363,7 +69692,7 @@ function insideProject(projectId, relPath) {
|
|
|
69363
69692
|
}
|
|
69364
69693
|
function realish(p) {
|
|
69365
69694
|
try {
|
|
69366
|
-
return
|
|
69695
|
+
return import_node_fs36.realpathSync.native((0, import_node_path33.resolve)(p));
|
|
69367
69696
|
} catch {
|
|
69368
69697
|
return (0, import_node_path33.resolve)(p);
|
|
69369
69698
|
}
|
|
@@ -69377,20 +69706,20 @@ function safeId2(refId2) {
|
|
|
69377
69706
|
}
|
|
69378
69707
|
async function hashFile(path) {
|
|
69379
69708
|
const h = (0, import_node_crypto21.createHash)("sha256");
|
|
69380
|
-
await (0, import_promises4.pipeline)((0,
|
|
69709
|
+
await (0, import_promises4.pipeline)((0, import_node_fs36.createReadStream)(path), h);
|
|
69381
69710
|
return h.digest("hex");
|
|
69382
69711
|
}
|
|
69383
69712
|
function copyOriginal(projectId, relPath, sourceAbs, tag) {
|
|
69384
69713
|
const abs = insideProject(projectId, relPath);
|
|
69385
|
-
(0,
|
|
69714
|
+
(0, import_node_fs36.mkdirSync)((0, import_node_path33.dirname)(abs), { recursive: true });
|
|
69386
69715
|
const tmp = `${abs}.${safeId2(tag)}.part`;
|
|
69387
|
-
(0,
|
|
69388
|
-
(0,
|
|
69716
|
+
(0, import_node_fs36.copyFileSync)(sourceAbs, tmp);
|
|
69717
|
+
(0, import_node_fs36.renameSync)(tmp, abs);
|
|
69389
69718
|
return abs;
|
|
69390
69719
|
}
|
|
69391
69720
|
function referenceFilesOnDisk(projectId) {
|
|
69392
69721
|
try {
|
|
69393
|
-
return (0,
|
|
69722
|
+
return (0, import_node_fs36.readdirSync)((0, import_node_path33.join)(projectDir(projectId), REFERENCE_DIR)).map((f) => `${REFERENCE_DIR}/${f}`);
|
|
69394
69723
|
} catch (e) {
|
|
69395
69724
|
if (e.code === "ENOENT") return [];
|
|
69396
69725
|
throw new ReferenceImportError(
|
|
@@ -69400,32 +69729,39 @@ function referenceFilesOnDisk(projectId) {
|
|
|
69400
69729
|
}
|
|
69401
69730
|
function originalPath(projectId, relPath) {
|
|
69402
69731
|
const abs = insideProject(projectId, relPath);
|
|
69403
|
-
return (0,
|
|
69732
|
+
return (0, import_node_fs36.existsSync)(abs) ? abs : null;
|
|
69404
69733
|
}
|
|
69405
69734
|
function writeCache2(projectId, refId2, cache2) {
|
|
69406
69735
|
const p = cachePath2(projectId, refId2);
|
|
69407
69736
|
const tmp = `${p}.part`;
|
|
69408
|
-
(0,
|
|
69409
|
-
(0,
|
|
69737
|
+
(0, import_node_fs36.writeFileSync)(tmp, JSON.stringify(cache2));
|
|
69738
|
+
(0, import_node_fs36.renameSync)(tmp, p);
|
|
69410
69739
|
}
|
|
69411
|
-
function
|
|
69740
|
+
function filterKey(filter) {
|
|
69741
|
+
const part = (v) => v?.length ? [...v].sort() : [];
|
|
69742
|
+
const s = part(filter?.storeys);
|
|
69743
|
+
const t = part(filter?.ifcTypes);
|
|
69744
|
+
return s.length || t.length ? JSON.stringify([s, t]) : null;
|
|
69745
|
+
}
|
|
69746
|
+
function cachedGeometry(projectId, refId2, expectHash, expectFilter) {
|
|
69412
69747
|
const p = cachePath2(projectId, refId2);
|
|
69413
|
-
if (!(0,
|
|
69748
|
+
if (!(0, import_node_fs36.existsSync)(p)) return null;
|
|
69414
69749
|
try {
|
|
69415
|
-
const parsed = JSON.parse((0,
|
|
69750
|
+
const parsed = JSON.parse((0, import_node_fs36.readFileSync)(p, "utf8"));
|
|
69416
69751
|
if (!parsed || parsed.v !== REFERENCE_CACHE_VERSION || !Array.isArray(parsed.objects)) return null;
|
|
69417
69752
|
if (parsed.sourceHash !== expectHash) return null;
|
|
69753
|
+
if (filterKey(parsed.filter) !== filterKey(expectFilter)) return null;
|
|
69418
69754
|
return parsed;
|
|
69419
69755
|
} catch {
|
|
69420
69756
|
return null;
|
|
69421
69757
|
}
|
|
69422
69758
|
}
|
|
69423
69759
|
function dropCache(projectId, refId2) {
|
|
69424
|
-
(0,
|
|
69760
|
+
(0, import_node_fs36.rmSync)(cachePath2(projectId, refId2), { force: true });
|
|
69425
69761
|
}
|
|
69426
69762
|
function removeReference(projectId, refId2, relPath) {
|
|
69427
69763
|
dropCache(projectId, refId2);
|
|
69428
|
-
if (relPath) (0,
|
|
69764
|
+
if (relPath) (0, import_node_fs36.rmSync)(insideProject(projectId, relPath), { force: true });
|
|
69429
69765
|
}
|
|
69430
69766
|
function takenReferencePaths(refs) {
|
|
69431
69767
|
return new Set((refs ?? []).map((r) => r.file).filter((f) => typeof f === "string"));
|
|
@@ -69534,13 +69870,31 @@ function spanOf(objects) {
|
|
|
69534
69870
|
const span = Math.max(hi[0] - lo[0], hi[1] - lo[1], hi[2] - lo[2]);
|
|
69535
69871
|
return Number.isFinite(span) && span > 0 ? span : 0;
|
|
69536
69872
|
}
|
|
69873
|
+
function tooMany(what, probe) {
|
|
69874
|
+
const limit = `${what}, and the limit is ${MAX_OBJECTS.toLocaleString("en-US")}. `;
|
|
69875
|
+
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.");
|
|
69876
|
+
}
|
|
69877
|
+
function pickerCanExist(probe) {
|
|
69878
|
+
if (probe.storeys === null || probe.types === null) return false;
|
|
69879
|
+
const selectable = (rows2) => rows2.filter((r) => r.name !== null).length;
|
|
69880
|
+
return selectable(probe.storeys) > 1 || selectable(probe.types) > 1;
|
|
69881
|
+
}
|
|
69882
|
+
function unmatchedNames(selected) {
|
|
69883
|
+
return (selected?.unmatched ?? []).map((u) => u.storey ?? u.ifcType ?? u.id).filter((n) => typeof n === "string" && !!n);
|
|
69884
|
+
}
|
|
69885
|
+
var hasUnmatched = (selected) => !!selected?.unmatched?.length;
|
|
69886
|
+
function unmatchedMessage(name, missed, remedy) {
|
|
69887
|
+
const what = missed.length ? `has nothing under ${missed.map((m) => `"${m}"`).join(", ")}` : "has nothing under the storeys or types it was loaded with";
|
|
69888
|
+
return `"${name}" ${what}. The file may have been re-exported with different names \u2014 ${remedy}`;
|
|
69889
|
+
}
|
|
69537
69890
|
function referencesOf(doc) {
|
|
69538
69891
|
const refs = doc.reference_models;
|
|
69539
69892
|
return Array.isArray(refs) ? refs : [];
|
|
69540
69893
|
}
|
|
69541
69894
|
function importRefusal(e) {
|
|
69542
69895
|
if (e instanceof ReferenceImportError || e instanceof VisualInputError) {
|
|
69543
|
-
|
|
69896
|
+
const code = e instanceof ReferenceImportError ? e.code : void 0;
|
|
69897
|
+
return { status: 400, body: { ok: false, error: e.message, ...code ? { code } : {} } };
|
|
69544
69898
|
}
|
|
69545
69899
|
return null;
|
|
69546
69900
|
}
|
|
@@ -69567,7 +69921,20 @@ function registerReferenceRoutes(app, deps) {
|
|
|
69567
69921
|
const scope = runScope(deps, reply);
|
|
69568
69922
|
try {
|
|
69569
69923
|
const probe = await deps.reader.probe(companion(g.appId), stored2.path, { ticket: scope.ticket() });
|
|
69570
|
-
|
|
69924
|
+
const population = readPopulation(probe);
|
|
69925
|
+
return {
|
|
69926
|
+
ok: true,
|
|
69927
|
+
sha: stored2.sha256,
|
|
69928
|
+
bytes: stored2.bytes,
|
|
69929
|
+
warn,
|
|
69930
|
+
probe,
|
|
69931
|
+
verdict: verdictFor(probe, req.body?.nativeSpan, req.body?.nativeCenter),
|
|
69932
|
+
// The number the confirm stage shows and the gate judges — the READ population, never
|
|
69933
|
+
// `probe.elements`, which counts a different thing and is smaller (measured 10 against 16).
|
|
69934
|
+
// Null means the bridge offered no breakdown, so no estimate exists and none is invented.
|
|
69935
|
+
population,
|
|
69936
|
+
objectVerdict: population === null ? null : objectVerdict(population)
|
|
69937
|
+
};
|
|
69571
69938
|
} catch (e) {
|
|
69572
69939
|
const r = importRefusal(e);
|
|
69573
69940
|
if (r) return reply.status(r.status).send(r.body);
|
|
@@ -69586,6 +69953,16 @@ function registerReferenceRoutes(app, deps) {
|
|
|
69586
69953
|
if (!g.ok) return reply.status(g.refusal.status).send(g.refusal.body);
|
|
69587
69954
|
const { sha, name, placement } = req.body ?? {};
|
|
69588
69955
|
if (!sha) return reply.status(400).send({ ok: false, error: "probe the file first \u2014 its sha is required" });
|
|
69956
|
+
const asked = req.body?.filter;
|
|
69957
|
+
const names = (v) => Array.isArray(v) ? v.filter((s) => typeof s === "string" && !!s.trim()) : [];
|
|
69958
|
+
const filter = emittedFilter({ storeys: names(asked?.storeys), ifcTypes: names(asked?.ifcTypes) }) ?? void 0;
|
|
69959
|
+
if (asked !== void 0 && !filter) {
|
|
69960
|
+
return reply.status(400).send({
|
|
69961
|
+
ok: false,
|
|
69962
|
+
code: "reference-empty-filter",
|
|
69963
|
+
error: "choose at least one storey or type to load, or clear the selection to load the whole file"
|
|
69964
|
+
});
|
|
69965
|
+
}
|
|
69589
69966
|
const source = ifcInputPath(g.appId, sha);
|
|
69590
69967
|
if (!source) {
|
|
69591
69968
|
return reply.status(404).send({ ok: false, error: "the uploaded IFC is no longer available \u2014 drop the file again" });
|
|
@@ -69621,18 +69998,46 @@ function registerReferenceRoutes(app, deps) {
|
|
|
69621
69998
|
if (!abs) throw new ReferenceImportError("the copied file vanished before it could be read");
|
|
69622
69999
|
const probe = await deps.reader.probe(companion(g.appId), abs, { ticket: scope.ticket() });
|
|
69623
70000
|
const sourceHash = await hashFile(abs);
|
|
69624
|
-
const
|
|
70001
|
+
const estimate = selectedPopulation(probe, filter);
|
|
70002
|
+
if (estimate !== null && objectVerdict(estimate) === "refuse") {
|
|
70003
|
+
rollback();
|
|
70004
|
+
return reply.status(400).send({
|
|
70005
|
+
ok: false,
|
|
70006
|
+
code: "reference-too-many-objects",
|
|
70007
|
+
error: tooMany(`"${displayName}" would load about ${estimate.toLocaleString("en-US")} objects`, probe)
|
|
70008
|
+
});
|
|
70009
|
+
}
|
|
70010
|
+
const geometry = await deps.reader.readModel(companion(g.appId), abs, { ticket: scope.ticket(), filter });
|
|
69625
70011
|
if (scope.gone()) throw new ReferenceImportError("cancelled");
|
|
70012
|
+
const missed = unmatchedNames(geometry.selected);
|
|
70013
|
+
if (!geometry.objects.length && hasUnmatched(geometry.selected)) {
|
|
70014
|
+
rollback();
|
|
70015
|
+
return reply.status(400).send({
|
|
70016
|
+
ok: false,
|
|
70017
|
+
code: "reference-filter-unmatched",
|
|
70018
|
+
error: unmatchedMessage(displayName, missed, "pick from the list above and try again.")
|
|
70019
|
+
});
|
|
70020
|
+
}
|
|
69626
70021
|
if (!geometry.objects.length) {
|
|
69627
70022
|
rollback();
|
|
69628
70023
|
return reply.status(400).send({ ok: false, error: `"${displayName}" has no geometry we can draw` });
|
|
69629
70024
|
}
|
|
69630
|
-
|
|
70025
|
+
if (objectVerdict(geometry.objects.length) === "refuse") {
|
|
70026
|
+
rollback();
|
|
70027
|
+
return reply.status(400).send({
|
|
70028
|
+
ok: false,
|
|
70029
|
+
code: "reference-too-many-objects",
|
|
70030
|
+
error: tooMany(`"${displayName}" read ${geometry.objects.length.toLocaleString("en-US")} objects`, probe)
|
|
70031
|
+
});
|
|
70032
|
+
}
|
|
70033
|
+
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
70034
|
const entry2 = {
|
|
69632
70035
|
id,
|
|
69633
70036
|
file: rel,
|
|
69634
70037
|
name: displayName,
|
|
69635
70038
|
...placement ? { placement } : {},
|
|
70039
|
+
// STORED, so a later re-read reproduces this reference rather than the whole building.
|
|
70040
|
+
...filter ? { filter } : {},
|
|
69636
70041
|
units: { declared: probe.units.declared, override: null },
|
|
69637
70042
|
// Half-opacity by default, because a reference that arrives looking like our own steel is the
|
|
69638
70043
|
// one mistake this feature must never make.
|
|
@@ -69651,7 +70056,7 @@ function registerReferenceRoutes(app, deps) {
|
|
|
69651
70056
|
});
|
|
69652
70057
|
committed = true;
|
|
69653
70058
|
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) };
|
|
70059
|
+
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
70060
|
} catch (e) {
|
|
69656
70061
|
rollback();
|
|
69657
70062
|
const r = importRefusal(e);
|
|
@@ -69689,10 +70094,26 @@ function registerReferenceRoutes(app, deps) {
|
|
|
69689
70094
|
return reply.status(409).send({ ok: false, code: "reference-unresolved", error: `"${entry2.name}" could not be read` });
|
|
69690
70095
|
}
|
|
69691
70096
|
const rebuild = /^(1|true)$/i.test(String(req.query?.rebuild ?? ""));
|
|
69692
|
-
|
|
70097
|
+
if (entry2.filter && !emittedFilter(entry2.filter)) {
|
|
70098
|
+
return reply.status(409).send({
|
|
70099
|
+
ok: false,
|
|
70100
|
+
code: "reference-filter-unreadable",
|
|
70101
|
+
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.`
|
|
70102
|
+
});
|
|
70103
|
+
}
|
|
70104
|
+
const stored2 = entry2.filter;
|
|
70105
|
+
const hit = rebuild ? null : cachedGeometry(g.project, entry2.id, sourceHash, stored2);
|
|
69693
70106
|
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
70107
|
try {
|
|
69695
|
-
const geometry = await deps.reader.readModel(companion(g.appId), abs, { ticket: scope.ticket() });
|
|
70108
|
+
const geometry = await deps.reader.readModel(companion(g.appId), abs, { ticket: scope.ticket(), filter: stored2 });
|
|
70109
|
+
const missed = unmatchedNames(geometry.selected);
|
|
70110
|
+
if (!geometry.objects.length && hasUnmatched(geometry.selected)) {
|
|
70111
|
+
return reply.status(409).send({
|
|
70112
|
+
ok: false,
|
|
70113
|
+
code: "reference-filter-unmatched",
|
|
70114
|
+
error: unmatchedMessage(entry2.name, missed, "remove the reference and add it again to pick from the current list.")
|
|
70115
|
+
});
|
|
70116
|
+
}
|
|
69696
70117
|
if (!geometry.objects.length) {
|
|
69697
70118
|
return reply.status(409).send({
|
|
69698
70119
|
ok: false,
|
|
@@ -69700,8 +70121,19 @@ function registerReferenceRoutes(app, deps) {
|
|
|
69700
70121
|
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
70122
|
});
|
|
69702
70123
|
}
|
|
69703
|
-
|
|
69704
|
-
|
|
70124
|
+
if (objectVerdict(geometry.objects.length) === "refuse") {
|
|
70125
|
+
return reply.status(409).send({
|
|
70126
|
+
ok: false,
|
|
70127
|
+
code: "reference-too-many-objects",
|
|
70128
|
+
// ITS OWN SENTENCE, not `tooMany`'s. This path never probes, so it has no breakdown to judge
|
|
70129
|
+
// and no picker to offer — and routing it through a fabricated empty probe made the message
|
|
70130
|
+
// blame the user's IFC reader for a reference that may already carry a filter. The remedy
|
|
70131
|
+
// here is to re-add the reference and choose less of it.
|
|
70132
|
+
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.`
|
|
70133
|
+
});
|
|
70134
|
+
}
|
|
70135
|
+
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 });
|
|
70136
|
+
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
70137
|
} catch (e) {
|
|
69706
70138
|
const r = importRefusal(e);
|
|
69707
70139
|
if (r) return reply.status(r.status).send(r.body);
|
|
@@ -69770,7 +70202,7 @@ var import_node_os18 = require("node:os");
|
|
|
69770
70202
|
var import_node_path34 = require("node:path");
|
|
69771
70203
|
|
|
69772
70204
|
// node_modules/write-excel-file/modules/export/writeXlsxFileNode.js
|
|
69773
|
-
var
|
|
70205
|
+
var import_node_fs37 = __toESM(require("node:fs"), 1);
|
|
69774
70206
|
|
|
69775
70207
|
// node_modules/write-excel-file/modules/xlsx/helpers/features/getAdditionalContent.js
|
|
69776
70208
|
function _createForOfIteratorHelperLoose(r, e) {
|
|
@@ -72870,7 +73302,7 @@ function writeXlsxFile(arg1, arg2, arg3) {
|
|
|
72870
73302
|
},
|
|
72871
73303
|
toFile: function toFile(filePath) {
|
|
72872
73304
|
return createReadableStream().then(function(readableStream) {
|
|
72873
|
-
return pipe(readableStream,
|
|
73305
|
+
return pipe(readableStream, import_node_fs37.default.createWriteStream(filePath));
|
|
72874
73306
|
});
|
|
72875
73307
|
}
|
|
72876
73308
|
};
|
|
@@ -73526,7 +73958,7 @@ function replyLifecycleLockBusyError(error, logger, reply) {
|
|
|
73526
73958
|
}
|
|
73527
73959
|
|
|
73528
73960
|
// project-export-files.ts
|
|
73529
|
-
var
|
|
73961
|
+
var import_node_fs38 = require("node:fs");
|
|
73530
73962
|
var import_node_path35 = require("node:path");
|
|
73531
73963
|
function projectExportFiles(appId, kindOf2 = appId) {
|
|
73532
73964
|
if (kindOf2 === "vectorize") {
|
|
@@ -73556,23 +73988,25 @@ function exportFileBase(projectId, appId, now = /* @__PURE__ */ new Date()) {
|
|
|
73556
73988
|
}
|
|
73557
73989
|
function uniqueProjectExportFilename(projectId, preferred) {
|
|
73558
73990
|
const dir = projectExportsDir(projectId);
|
|
73559
|
-
if (!(0,
|
|
73991
|
+
if (!(0, import_node_fs38.existsSync)((0, import_node_path35.join)(dir, preferred))) return preferred;
|
|
73560
73992
|
const extension = (0, import_node_path35.extname)(preferred);
|
|
73561
73993
|
const stem = preferred.slice(0, preferred.length - extension.length);
|
|
73562
73994
|
for (let suffix = 2; suffix <= 9999; suffix += 1) {
|
|
73563
73995
|
const candidate = `${stem}-${suffix}${extension}`;
|
|
73564
|
-
if (!(0,
|
|
73996
|
+
if (!(0, import_node_fs38.existsSync)((0, import_node_path35.join)(dir, candidate))) return candidate;
|
|
73565
73997
|
}
|
|
73566
73998
|
throw new Error("could not allocate a unique project export filename");
|
|
73567
73999
|
}
|
|
73568
74000
|
|
|
73569
74001
|
// workspace-approved-snapshot.ts
|
|
73570
74002
|
var WorkspaceSnapshotError = class extends Error {
|
|
73571
|
-
constructor(status, message) {
|
|
74003
|
+
constructor(status, message, notReviewable) {
|
|
73572
74004
|
super(message);
|
|
73573
74005
|
this.status = status;
|
|
74006
|
+
this.notReviewable = notReviewable;
|
|
73574
74007
|
}
|
|
73575
74008
|
status;
|
|
74009
|
+
notReviewable;
|
|
73576
74010
|
};
|
|
73577
74011
|
function approvedRows(projectId) {
|
|
73578
74012
|
const project = getProject(projectId);
|
|
@@ -74279,16 +74713,16 @@ function buildApprovalReview(input) {
|
|
|
74279
74713
|
|
|
74280
74714
|
// working-revision-manifest.ts
|
|
74281
74715
|
var import_node_crypto24 = require("node:crypto");
|
|
74282
|
-
var
|
|
74716
|
+
var import_node_fs40 = require("node:fs");
|
|
74283
74717
|
var import_node_path36 = require("node:path");
|
|
74284
74718
|
|
|
74285
74719
|
// write-json-atomic.ts
|
|
74286
74720
|
var import_node_crypto23 = require("node:crypto");
|
|
74287
|
-
var
|
|
74721
|
+
var import_node_fs39 = require("node:fs");
|
|
74288
74722
|
function writeJsonAtomic(path, value) {
|
|
74289
74723
|
const tmp = `${path}.${process.pid}.${(0, import_node_crypto23.randomUUID)()}.tmp`;
|
|
74290
|
-
(0,
|
|
74291
|
-
(0,
|
|
74724
|
+
(0, import_node_fs39.writeFileSync)(tmp, canonicalJson(value));
|
|
74725
|
+
(0, import_node_fs39.renameSync)(tmp, path);
|
|
74292
74726
|
}
|
|
74293
74727
|
|
|
74294
74728
|
// working-revision-manifest.ts
|
|
@@ -74305,7 +74739,7 @@ function assertProject(project) {
|
|
|
74305
74739
|
function readWorkingRevisionManifest(project) {
|
|
74306
74740
|
const uuid = assertProject(project);
|
|
74307
74741
|
try {
|
|
74308
|
-
const value = JSON.parse((0,
|
|
74742
|
+
const value = JSON.parse((0, import_node_fs40.readFileSync)(pathOf(project.id), "utf8"));
|
|
74309
74743
|
if (value?.schema !== 1 || value.projectUuid !== uuid || !Number.isInteger(value.epoch) || value.epoch < 0) return null;
|
|
74310
74744
|
return checksumOf(bodyOf(value)) === value.checksum ? value : null;
|
|
74311
74745
|
} catch {
|
|
@@ -74327,8 +74761,8 @@ function ensureWorkingRevisionManifest(input) {
|
|
|
74327
74761
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
74328
74762
|
};
|
|
74329
74763
|
const value = { ...body, checksum: checksumOf(body) };
|
|
74330
|
-
(0,
|
|
74331
|
-
if (!(0,
|
|
74764
|
+
(0, import_node_fs40.mkdirSync)(projectDir(input.project.id), { recursive: true });
|
|
74765
|
+
if (!(0, import_node_fs40.existsSync)(pathOf(input.project.id))) writeJsonAtomic(pathOf(input.project.id), value);
|
|
74332
74766
|
return readWorkingRevisionManifest(input.project) ?? value;
|
|
74333
74767
|
}
|
|
74334
74768
|
function advanceWorkingRevisionManifest(input) {
|
|
@@ -74438,9 +74872,21 @@ function mergeContractForward(base, latest, draft, resolutions = {}) {
|
|
|
74438
74872
|
function prepareProjectApprovalReview(projectId, deps) {
|
|
74439
74873
|
const project = getProject(projectId);
|
|
74440
74874
|
if (!project) throw new WorkspaceSnapshotError(404, `unknown project: ${projectId}`);
|
|
74441
|
-
if (!project.uuid) throw new WorkspaceSnapshotError(
|
|
74875
|
+
if (!project.uuid) throw new WorkspaceSnapshotError(
|
|
74876
|
+
409,
|
|
74877
|
+
"This project can\u2019t be approved \u2014 duplicate it from the Workspaces list to sign off",
|
|
74878
|
+
"no-incarnation"
|
|
74879
|
+
);
|
|
74442
74880
|
const draft = readAcceptedForRequest(project.app, projectId, "read");
|
|
74443
|
-
if (draft == null)
|
|
74881
|
+
if (draft == null) {
|
|
74882
|
+
if (storedContractBytesExist(project.app, projectId)) {
|
|
74883
|
+
throw new WorkspaceSnapshotError(
|
|
74884
|
+
409,
|
|
74885
|
+
"This project\u2019s saved model is there but could not be read. Close anything that has it open, then reload."
|
|
74886
|
+
);
|
|
74887
|
+
}
|
|
74888
|
+
throw new WorkspaceSnapshotError(404, "Nothing to approve yet \u2014 read a drawing into this project first", "no-contract");
|
|
74889
|
+
}
|
|
74444
74890
|
const row = latestApprovedVersion(projectId);
|
|
74445
74891
|
const manifest = readWorkingRevisionManifest(project);
|
|
74446
74892
|
let baseContract = null;
|
|
@@ -74580,7 +75026,7 @@ function projectApprovalCandidateAccepted(appId, projectId, candidate) {
|
|
|
74580
75026
|
|
|
74581
75027
|
// project-checkpoints-store.ts
|
|
74582
75028
|
var import_node_crypto25 = require("node:crypto");
|
|
74583
|
-
var
|
|
75029
|
+
var import_node_fs41 = require("node:fs");
|
|
74584
75030
|
var import_node_path37 = require("node:path");
|
|
74585
75031
|
var HASH_RE2 = /^[0-9a-f]{64}$/;
|
|
74586
75032
|
function root4(projectId) {
|
|
@@ -74590,7 +75036,7 @@ var objectsDir2 = (projectId) => (0, import_node_path37.join)(root4(projectId),
|
|
|
74590
75036
|
var eventsPath = (projectId) => (0, import_node_path37.join)(root4(projectId), "events.json");
|
|
74591
75037
|
function readEvents(projectId) {
|
|
74592
75038
|
try {
|
|
74593
|
-
const parsed = JSON.parse((0,
|
|
75039
|
+
const parsed = JSON.parse((0, import_node_fs41.readFileSync)(eventsPath(projectId), "utf8"));
|
|
74594
75040
|
if (parsed?.schema !== 1 || !Array.isArray(parsed.events)) return { schema: 1, events: [] };
|
|
74595
75041
|
return { schema: 1, events: parsed.events.filter(validEvent) };
|
|
74596
75042
|
} catch {
|
|
@@ -74605,7 +75051,7 @@ function validEvent(value) {
|
|
|
74605
75051
|
function readContent(projectId, id) {
|
|
74606
75052
|
if (!HASH_RE2.test(id)) return null;
|
|
74607
75053
|
try {
|
|
74608
|
-
const value = JSON.parse((0,
|
|
75054
|
+
const value = JSON.parse((0, import_node_fs41.readFileSync)((0, import_node_path37.join)(objectsDir2(projectId), `${id}.json`), "utf8"));
|
|
74609
75055
|
if (value?.schema !== 1 || value.id !== id || hashCheckpoint(value) !== id) return null;
|
|
74610
75056
|
return value;
|
|
74611
75057
|
} catch {
|
|
@@ -74621,7 +75067,7 @@ function requireIdentity(project) {
|
|
|
74621
75067
|
return project.uuid;
|
|
74622
75068
|
}
|
|
74623
75069
|
function appendEvent(projectId, event) {
|
|
74624
|
-
(0,
|
|
75070
|
+
(0, import_node_fs41.mkdirSync)(root4(projectId), { recursive: true });
|
|
74625
75071
|
const log2 = readEvents(projectId);
|
|
74626
75072
|
const row = { ...event, eventId: (0, import_node_crypto25.randomUUID)(), at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
74627
75073
|
log2.events.push(row);
|
|
@@ -74639,9 +75085,9 @@ function captureProjectCheckpoint(input) {
|
|
|
74639
75085
|
contract: input.contract
|
|
74640
75086
|
};
|
|
74641
75087
|
const id = hashCheckpoint(withoutId);
|
|
74642
|
-
(0,
|
|
75088
|
+
(0, import_node_fs41.mkdirSync)(objectsDir2(input.project.id), { recursive: true });
|
|
74643
75089
|
const path = (0, import_node_path37.join)(objectsDir2(input.project.id), `${id}.json`);
|
|
74644
|
-
if (!(0,
|
|
75090
|
+
if (!(0, import_node_fs41.existsSync)(path)) writeJsonAtomic(path, { ...withoutId, id });
|
|
74645
75091
|
const event = appendEvent(input.project.id, {
|
|
74646
75092
|
checkpointId: id,
|
|
74647
75093
|
kind: "captured",
|
|
@@ -74684,7 +75130,7 @@ function markProjectCheckpoint(project, checkpointId, kind, expectedEventId) {
|
|
|
74684
75130
|
|
|
74685
75131
|
// export-source.ts
|
|
74686
75132
|
var import_node_crypto26 = require("node:crypto");
|
|
74687
|
-
var
|
|
75133
|
+
var import_node_fs42 = require("node:fs");
|
|
74688
75134
|
var import_node_os19 = require("node:os");
|
|
74689
75135
|
var import_node_path38 = require("node:path");
|
|
74690
75136
|
var HANDLE_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
@@ -74707,7 +75153,7 @@ function validId(id) {
|
|
|
74707
75153
|
function readExportHandle(handleId) {
|
|
74708
75154
|
if (!validId(handleId)) return null;
|
|
74709
75155
|
try {
|
|
74710
|
-
const value = JSON.parse((0,
|
|
75156
|
+
const value = JSON.parse((0, import_node_fs42.readFileSync)(handlePath(handleId), "utf8"));
|
|
74711
75157
|
if (value?.schema !== 1 || value.handleId !== handleId || value.checksum !== hashOf(withoutChecksum(value))) return null;
|
|
74712
75158
|
return value;
|
|
74713
75159
|
} catch {
|
|
@@ -74716,7 +75162,7 @@ function readExportHandle(handleId) {
|
|
|
74716
75162
|
}
|
|
74717
75163
|
function captureExportSource(projectId, selector = { kind: "latest-approved" }, isDerivedEligible) {
|
|
74718
75164
|
collectExpiredExportHandles();
|
|
74719
|
-
if ((0,
|
|
75165
|
+
if ((0, import_node_fs42.existsSync)(storeRoot()) && (0, import_node_fs42.readdirSync)(storeRoot()).filter((name) => name.endsWith(".json")).length >= MAX_STORED_HANDLES) {
|
|
74720
75166
|
throw new Error("too many frozen export sources are waiting; finish or retry older exports first");
|
|
74721
75167
|
}
|
|
74722
75168
|
const project = getProject(projectId);
|
|
@@ -74802,7 +75248,7 @@ function captureExportSource(projectId, selector = { kind: "latest-approved" },
|
|
|
74802
75248
|
expiresAt: new Date(Date.now() + HANDLE_TTL_MS).toISOString(),
|
|
74803
75249
|
resultRefs: []
|
|
74804
75250
|
};
|
|
74805
|
-
(0,
|
|
75251
|
+
(0, import_node_fs42.mkdirSync)(storeRoot(), { recursive: true });
|
|
74806
75252
|
writeJsonAtomic(handlePath(handleId), stored(body));
|
|
74807
75253
|
const { contract: _contract, lease: _lease, expiresAt: _expiresAt, resultRefs: _refs, checksum: _checksum, ...resolved } = readExportHandle(handleId);
|
|
74808
75254
|
return resolved;
|
|
@@ -74814,7 +75260,7 @@ function cloneExportHandle(handleId, copies) {
|
|
|
74814
75260
|
if (!original || original.lease !== "active" || Date.parse(original.expiresAt) <= Date.now()) {
|
|
74815
75261
|
throw new Error("export source handle is unavailable");
|
|
74816
75262
|
}
|
|
74817
|
-
const storedCount = (0,
|
|
75263
|
+
const storedCount = (0, import_node_fs42.existsSync)(storeRoot()) ? (0, import_node_fs42.readdirSync)(storeRoot()).filter((name) => name.endsWith(".json")).length : 0;
|
|
74818
75264
|
if (storedCount + copies - 1 > MAX_STORED_HANDLES) throw new Error("too many frozen export sources are waiting");
|
|
74819
75265
|
const results = [];
|
|
74820
75266
|
const created = [];
|
|
@@ -74829,7 +75275,7 @@ function cloneExportHandle(handleId, copies) {
|
|
|
74829
75275
|
results.push(resolved);
|
|
74830
75276
|
}
|
|
74831
75277
|
} catch (error) {
|
|
74832
|
-
for (const id of created) (0,
|
|
75278
|
+
for (const id of created) (0, import_node_fs42.rmSync)(handlePath(id), { force: true });
|
|
74833
75279
|
throw error;
|
|
74834
75280
|
}
|
|
74835
75281
|
return results;
|
|
@@ -74869,21 +75315,21 @@ function releaseUnusedExportHandle(handleId, projectId, projectUuid) {
|
|
|
74869
75315
|
}
|
|
74870
75316
|
function projectIdHasActiveExportLeases(projectId) {
|
|
74871
75317
|
collectExpiredExportHandles();
|
|
74872
|
-
if (!(0,
|
|
74873
|
-
return (0,
|
|
75318
|
+
if (!(0, import_node_fs42.existsSync)(storeRoot())) return false;
|
|
75319
|
+
return (0, import_node_fs42.readdirSync)(storeRoot()).some((name) => {
|
|
74874
75320
|
const handle = name.endsWith(".json") ? readExportHandle(name.slice(0, -5)) : null;
|
|
74875
75321
|
return handle?.projectId === projectId && handle.lease === "active" && Date.parse(handle.expiresAt) > Date.now();
|
|
74876
75322
|
});
|
|
74877
75323
|
}
|
|
74878
75324
|
function collectExpiredExportHandles(now = Date.now()) {
|
|
74879
|
-
if (!(0,
|
|
75325
|
+
if (!(0, import_node_fs42.existsSync)(storeRoot())) return 0;
|
|
74880
75326
|
let removed = 0;
|
|
74881
|
-
for (const name of (0,
|
|
75327
|
+
for (const name of (0, import_node_fs42.readdirSync)(storeRoot())) {
|
|
74882
75328
|
if (!name.endsWith(".json")) continue;
|
|
74883
75329
|
const id = name.slice(0, -5);
|
|
74884
75330
|
const handle = readExportHandle(id);
|
|
74885
75331
|
if (!handle || Date.parse(handle.expiresAt) <= now && handle.resultRefs.length === 0) {
|
|
74886
|
-
(0,
|
|
75332
|
+
(0, import_node_fs42.rmSync)(handlePath(id), { force: true });
|
|
74887
75333
|
removed++;
|
|
74888
75334
|
}
|
|
74889
75335
|
}
|
|
@@ -74892,7 +75338,7 @@ function collectExpiredExportHandles(now = Date.now()) {
|
|
|
74892
75338
|
|
|
74893
75339
|
// file-publication.ts
|
|
74894
75340
|
var import_node_crypto27 = require("node:crypto");
|
|
74895
|
-
var
|
|
75341
|
+
var import_node_fs43 = require("node:fs");
|
|
74896
75342
|
var import_node_path39 = require("node:path");
|
|
74897
75343
|
var FilePublicationError = class extends Error {
|
|
74898
75344
|
constructor(message, code, paths = []) {
|
|
@@ -74910,7 +75356,7 @@ var proofOfBytes = (bytes) => ({
|
|
|
74910
75356
|
});
|
|
74911
75357
|
function readFileProof2(path) {
|
|
74912
75358
|
try {
|
|
74913
|
-
return proofOfBytes((0,
|
|
75359
|
+
return proofOfBytes((0, import_node_fs43.readFileSync)(path));
|
|
74914
75360
|
} catch (error) {
|
|
74915
75361
|
if (error.code === "ENOENT") return null;
|
|
74916
75362
|
throw error;
|
|
@@ -74920,38 +75366,38 @@ function fileProofEquals2(a, b) {
|
|
|
74920
75366
|
return a === null || b === null ? a === b : a.bytes === b.bytes && a.sha256 === b.sha256;
|
|
74921
75367
|
}
|
|
74922
75368
|
function syncFile3(path) {
|
|
74923
|
-
const fd2 = (0,
|
|
75369
|
+
const fd2 = (0, import_node_fs43.openSync)(path, "r+");
|
|
74924
75370
|
try {
|
|
74925
|
-
(0,
|
|
75371
|
+
(0, import_node_fs43.fsyncSync)(fd2);
|
|
74926
75372
|
} finally {
|
|
74927
|
-
(0,
|
|
75373
|
+
(0, import_node_fs43.closeSync)(fd2);
|
|
74928
75374
|
}
|
|
74929
75375
|
}
|
|
74930
75376
|
function syncDirectoryBestEffort3(path) {
|
|
74931
75377
|
try {
|
|
74932
|
-
const fd2 = (0,
|
|
75378
|
+
const fd2 = (0, import_node_fs43.openSync)(path, "r");
|
|
74933
75379
|
try {
|
|
74934
|
-
(0,
|
|
75380
|
+
(0, import_node_fs43.fsyncSync)(fd2);
|
|
74935
75381
|
} finally {
|
|
74936
|
-
(0,
|
|
75382
|
+
(0, import_node_fs43.closeSync)(fd2);
|
|
74937
75383
|
}
|
|
74938
75384
|
} catch {
|
|
74939
75385
|
}
|
|
74940
75386
|
}
|
|
74941
75387
|
function durableCanonicalJson(path, value) {
|
|
74942
75388
|
const dir = (0, import_node_path39.dirname)(path);
|
|
74943
|
-
(0,
|
|
75389
|
+
(0, import_node_fs43.mkdirSync)(dir, { recursive: true });
|
|
74944
75390
|
const temp = (0, import_node_path39.join)(dir, `.${(0, import_node_path39.basename)(path)}.${process.pid}.${(0, import_node_crypto27.randomUUID)()}.tmp`);
|
|
74945
75391
|
try {
|
|
74946
|
-
(0,
|
|
75392
|
+
(0, import_node_fs43.writeFileSync)(temp, `${canonicalJson(value)}
|
|
74947
75393
|
`, { encoding: "utf8", flag: "wx" });
|
|
74948
75394
|
syncFile3(temp);
|
|
74949
|
-
(0,
|
|
75395
|
+
(0, import_node_fs43.renameSync)(temp, path);
|
|
74950
75396
|
syncFile3(path);
|
|
74951
75397
|
syncDirectoryBestEffort3(dir);
|
|
74952
75398
|
} finally {
|
|
74953
75399
|
try {
|
|
74954
|
-
(0,
|
|
75400
|
+
(0, import_node_fs43.rmSync)(temp, { force: true });
|
|
74955
75401
|
} catch {
|
|
74956
75402
|
}
|
|
74957
75403
|
}
|
|
@@ -74970,7 +75416,7 @@ function mappedError(error, paths) {
|
|
|
74970
75416
|
}
|
|
74971
75417
|
function linkExclusive(source, destination) {
|
|
74972
75418
|
try {
|
|
74973
|
-
(0,
|
|
75419
|
+
(0, import_node_fs43.linkSync)(source, destination);
|
|
74974
75420
|
} catch (error) {
|
|
74975
75421
|
throw mappedError(error, [source, destination]);
|
|
74976
75422
|
}
|
|
@@ -74979,27 +75425,27 @@ function assertSameVolume(a, b) {
|
|
|
74979
75425
|
let aDev;
|
|
74980
75426
|
let bDev;
|
|
74981
75427
|
try {
|
|
74982
|
-
aDev = (0,
|
|
74983
|
-
bDev = (0,
|
|
75428
|
+
aDev = (0, import_node_fs43.statSync)(a, { bigint: true }).dev;
|
|
75429
|
+
bDev = (0, import_node_fs43.statSync)(b, { bigint: true }).dev;
|
|
74984
75430
|
} catch (error) {
|
|
74985
75431
|
throw mappedError(error, [a, b]);
|
|
74986
75432
|
}
|
|
74987
75433
|
if (aDev !== bDev) throw new FilePublicationError("publication paths are not on the same volume", "different-volume", [a, b]);
|
|
74988
75434
|
}
|
|
74989
75435
|
function uniqueArtifact(dir, label2, livePath) {
|
|
74990
|
-
(0,
|
|
75436
|
+
(0, import_node_fs43.mkdirSync)(dir, { recursive: true });
|
|
74991
75437
|
return (0, import_node_path39.join)(dir, `.floless-${label2}-${(0, import_node_crypto27.randomUUID)()}-${(0, import_node_path39.basename)(livePath)}`);
|
|
74992
75438
|
}
|
|
74993
75439
|
function publishFileExclusive(input) {
|
|
74994
75440
|
const { livePath, stagedPath, expectedLive, artifactDir } = input;
|
|
74995
|
-
assertSameVolume(stagedPath, (0,
|
|
75441
|
+
assertSameVolume(stagedPath, (0, import_node_fs43.existsSync)(livePath) ? livePath : (0, import_node_path39.dirname)(livePath));
|
|
74996
75442
|
const stagedProof = readFileProof2(stagedPath);
|
|
74997
75443
|
if (!stagedProof) throw new FilePublicationError("staged publication file is missing", "io-failure", [stagedPath]);
|
|
74998
75444
|
let beforeImage = null;
|
|
74999
75445
|
if (expectedLive) {
|
|
75000
75446
|
beforeImage = uniqueArtifact(artifactDir, "before", livePath);
|
|
75001
75447
|
try {
|
|
75002
|
-
(0,
|
|
75448
|
+
(0, import_node_fs43.renameSync)(livePath, beforeImage);
|
|
75003
75449
|
} catch (error) {
|
|
75004
75450
|
throw mappedError(error, [livePath, beforeImage]);
|
|
75005
75451
|
}
|
|
@@ -75011,19 +75457,19 @@ function publishFileExclusive(input) {
|
|
|
75011
75457
|
}
|
|
75012
75458
|
throw new FilePublicationError("the live file changed before publication", "live-changed", [livePath, beforeImage]);
|
|
75013
75459
|
}
|
|
75014
|
-
} else if ((0,
|
|
75460
|
+
} else if ((0, import_node_fs43.existsSync)(livePath)) {
|
|
75015
75461
|
throw new FilePublicationError("the live destination appeared before publication", "destination-exists", [livePath]);
|
|
75016
75462
|
}
|
|
75017
75463
|
try {
|
|
75018
75464
|
input.onFaultPoint?.("after-live-move", { livePath, stagedPath, beforeImage });
|
|
75019
75465
|
linkExclusive(stagedPath, livePath);
|
|
75020
75466
|
input.onFaultPoint?.("after-live-link", { livePath, stagedPath, beforeImage });
|
|
75021
|
-
(0,
|
|
75467
|
+
(0, import_node_fs43.unlinkSync)(stagedPath);
|
|
75022
75468
|
input.onFaultPoint?.("after-staged-unlink", { livePath, stagedPath, beforeImage });
|
|
75023
75469
|
syncFile3(livePath);
|
|
75024
75470
|
syncDirectoryBestEffort3((0, import_node_path39.dirname)(livePath));
|
|
75025
75471
|
} catch (error) {
|
|
75026
|
-
if (beforeImage && !(0,
|
|
75472
|
+
if (beforeImage && !(0, import_node_fs43.existsSync)(livePath)) {
|
|
75027
75473
|
try {
|
|
75028
75474
|
linkExclusive(beforeImage, livePath);
|
|
75029
75475
|
} catch {
|
|
@@ -75046,7 +75492,7 @@ function publishFileExclusive(input) {
|
|
|
75046
75492
|
var import_node_path41 = require("node:path");
|
|
75047
75493
|
|
|
75048
75494
|
// app-source-lock.ts
|
|
75049
|
-
var
|
|
75495
|
+
var import_node_fs44 = require("node:fs");
|
|
75050
75496
|
var import_node_os20 = require("node:os");
|
|
75051
75497
|
var import_node_path40 = require("node:path");
|
|
75052
75498
|
var AppSourcePublicationBusyError = class extends Error {
|
|
@@ -75059,9 +75505,9 @@ var AppSourcePublicationBusyError = class extends Error {
|
|
|
75059
75505
|
function activeApprovalTransaction(appId) {
|
|
75060
75506
|
const home = process.env.AWARE_HOME || (0, import_node_path40.join)((0, import_node_os20.homedir)(), ".aware");
|
|
75061
75507
|
const path = (0, import_node_path40.join)(home, "apps", appId, ".floless-approval-publication-journal-v1.json");
|
|
75062
|
-
if (!(0,
|
|
75508
|
+
if (!(0, import_node_fs44.existsSync)(path)) return null;
|
|
75063
75509
|
try {
|
|
75064
|
-
const stored2 = JSON.parse((0,
|
|
75510
|
+
const stored2 = JSON.parse((0, import_node_fs44.readFileSync)(path, "utf8"));
|
|
75065
75511
|
return typeof stored2?.journal?.id === "string" && stored2.journal.id ? stored2.journal.id : "__invalid__";
|
|
75066
75512
|
} catch {
|
|
75067
75513
|
return "__invalid__";
|
|
@@ -75077,7 +75523,7 @@ function withAppSourceLock(appId, label2, fn, options = {}) {
|
|
|
75077
75523
|
|
|
75078
75524
|
// app-publication-manifest.ts
|
|
75079
75525
|
var import_node_crypto28 = require("node:crypto");
|
|
75080
|
-
var
|
|
75526
|
+
var import_node_fs45 = require("node:fs");
|
|
75081
75527
|
var import_yaml7 = __toESM(require_dist6(), 1);
|
|
75082
75528
|
var APP_PUBLICATION_MANIFEST_SCHEMA = 1;
|
|
75083
75529
|
var AppPublicationManifestError = class extends Error {
|
|
@@ -75094,7 +75540,7 @@ function observeAppPublication(sourcePath, lockPath2) {
|
|
|
75094
75540
|
let lockSourceHash = null;
|
|
75095
75541
|
if (lock) {
|
|
75096
75542
|
try {
|
|
75097
|
-
const parsed = (0, import_yaml7.parse)((0,
|
|
75543
|
+
const parsed = (0, import_yaml7.parse)((0, import_node_fs45.readFileSync)(lockPath2, "utf8"));
|
|
75098
75544
|
lockSourceHash = typeof parsed?.["source-hash"] === "string" ? parsed["source-hash"] : null;
|
|
75099
75545
|
} catch {
|
|
75100
75546
|
}
|
|
@@ -75119,10 +75565,10 @@ function validManifest(value) {
|
|
|
75119
75565
|
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
75566
|
}
|
|
75121
75567
|
function readAppPublicationManifest(path) {
|
|
75122
|
-
if (!(0,
|
|
75568
|
+
if (!(0, import_node_fs45.existsSync)(path)) return null;
|
|
75123
75569
|
let stored2;
|
|
75124
75570
|
try {
|
|
75125
|
-
stored2 = JSON.parse((0,
|
|
75571
|
+
stored2 = JSON.parse((0, import_node_fs45.readFileSync)(path, "utf8"));
|
|
75126
75572
|
} catch {
|
|
75127
75573
|
throw new AppPublicationManifestError(`app publication manifest is unreadable: ${path}`, "corrupt");
|
|
75128
75574
|
}
|
|
@@ -75315,7 +75761,7 @@ function withAppPublicationWhileProjectLocked(input) {
|
|
|
75315
75761
|
|
|
75316
75762
|
// approval-app-publication.ts
|
|
75317
75763
|
var import_node_crypto29 = require("node:crypto");
|
|
75318
|
-
var
|
|
75764
|
+
var import_node_fs46 = require("node:fs");
|
|
75319
75765
|
var import_node_path42 = require("node:path");
|
|
75320
75766
|
var JOURNAL = ".floless-approval-publication-journal-v1.json";
|
|
75321
75767
|
var MANIFEST = ".floless-app-publication-state-v1.json";
|
|
@@ -75342,7 +75788,7 @@ function storeJournal(journal) {
|
|
|
75342
75788
|
}
|
|
75343
75789
|
function readApprovalPublicationJournal(sourcePath) {
|
|
75344
75790
|
try {
|
|
75345
|
-
const stored2 = JSON.parse((0,
|
|
75791
|
+
const stored2 = JSON.parse((0, import_node_fs46.readFileSync)(approvalPublicationJournalPath(sourcePath), "utf8"));
|
|
75346
75792
|
const value = stored2?.journal;
|
|
75347
75793
|
const expectedLiveLock = sourcePath.replace(/\.[^.]+$/, ".lock");
|
|
75348
75794
|
const expectedStageDir = (0, import_node_path42.join)(stagingRoot2(sourcePath), `${value?.appId ?? ""}-${value?.id ?? ""}`);
|
|
@@ -75368,8 +75814,8 @@ async function stageApprovalPublication(input) {
|
|
|
75368
75814
|
const beforeSource = readFileProof2(input.sourcePath);
|
|
75369
75815
|
const beforeLock = readFileProof2(input.liveLockPath);
|
|
75370
75816
|
try {
|
|
75371
|
-
(0,
|
|
75372
|
-
(0,
|
|
75817
|
+
(0, import_node_fs46.mkdirSync)(stageDir, { recursive: true });
|
|
75818
|
+
(0, import_node_fs46.cpSync)(appRoot, stagedAppRoot, {
|
|
75373
75819
|
recursive: true,
|
|
75374
75820
|
filter: (path) => ![JOURNAL, MANIFEST].includes((0, import_node_path42.basename)(path))
|
|
75375
75821
|
});
|
|
@@ -75382,7 +75828,7 @@ async function stageApprovalPublication(input) {
|
|
|
75382
75828
|
throw new Error("live workflow changed while the approval was being staged");
|
|
75383
75829
|
}
|
|
75384
75830
|
} catch (error) {
|
|
75385
|
-
(0,
|
|
75831
|
+
(0, import_node_fs46.rmSync)(stageDir, { recursive: true, force: true });
|
|
75386
75832
|
throw error;
|
|
75387
75833
|
}
|
|
75388
75834
|
const journal = {
|
|
@@ -75415,12 +75861,12 @@ function publishOne(livePath, stagedPath, before, staged, artifactDir) {
|
|
|
75415
75861
|
const live = readFileProof2(livePath);
|
|
75416
75862
|
if (fileProofEquals2(live, staged)) return;
|
|
75417
75863
|
if (!fileProofEquals2(live, before)) throw new Error(`live publication changed outside the approval transaction: ${livePath}`);
|
|
75418
|
-
if (!(0,
|
|
75864
|
+
if (!(0, import_node_fs46.existsSync)(stagedPath)) throw new Error(`staged publication bytes are unavailable: ${stagedPath}`);
|
|
75419
75865
|
publishFileExclusive({ livePath, stagedPath, expectedLive: before, artifactDir });
|
|
75420
75866
|
}
|
|
75421
75867
|
function completeApprovalPublication(journal) {
|
|
75422
75868
|
if (journal.phase !== "authorized" && journal.phase !== "published") throw new Error("approval publication is not authorized");
|
|
75423
|
-
(0,
|
|
75869
|
+
(0, import_node_fs46.mkdirSync)(journal.artifactDir, { recursive: true });
|
|
75424
75870
|
publishOne(journal.liveSourcePath, journal.stagedSourcePath, journal.beforeSource, journal.stagedSource, journal.artifactDir);
|
|
75425
75871
|
publishOne(journal.liveLockPath, journal.stagedLockPath, journal.beforeLock, journal.stagedLock, journal.artifactDir);
|
|
75426
75872
|
if (!fileProofEquals2(readFileProof2(journal.liveSourcePath), journal.stagedSource) || !fileProofEquals2(readFileProof2(journal.liveLockPath), journal.stagedLock)) {
|
|
@@ -75433,17 +75879,17 @@ function finalizeApprovalPublication(journal) {
|
|
|
75433
75879
|
if (!current || current.id !== journal.id || current.phase !== "published") {
|
|
75434
75880
|
throw new Error("published approval recovery authority is unavailable");
|
|
75435
75881
|
}
|
|
75436
|
-
(0,
|
|
75437
|
-
(0,
|
|
75882
|
+
(0, import_node_fs46.rmSync)(journal.stageDir, { recursive: true, force: true });
|
|
75883
|
+
(0, import_node_fs46.rmSync)(approvalPublicationJournalPath(journal.liveSourcePath), { force: true });
|
|
75438
75884
|
}
|
|
75439
75885
|
function abandonApprovalPublication(journal) {
|
|
75440
75886
|
if (journal.phase !== "staged") throw new Error("an authorized approval publication must be completed, not abandoned");
|
|
75441
|
-
(0,
|
|
75442
|
-
(0,
|
|
75887
|
+
(0, import_node_fs46.rmSync)(approvalPublicationJournalPath(journal.liveSourcePath), { force: true });
|
|
75888
|
+
(0, import_node_fs46.rmSync)(journal.stageDir, { recursive: true, force: true });
|
|
75443
75889
|
}
|
|
75444
75890
|
|
|
75445
75891
|
// workspace-data.ts
|
|
75446
|
-
var
|
|
75892
|
+
var import_node_fs47 = require("node:fs");
|
|
75447
75893
|
var VALID_INCLUDES = /* @__PURE__ */ new Set(["contract", "exports"]);
|
|
75448
75894
|
var VALID_EXPORT_KINDS = /* @__PURE__ */ new Set([
|
|
75449
75895
|
"bom-csv",
|
|
@@ -75504,15 +75950,15 @@ function exportBody(projectId, receipt, opts) {
|
|
|
75504
75950
|
};
|
|
75505
75951
|
if (opts.includePaths) body.path = path;
|
|
75506
75952
|
if (opts.exportContents) {
|
|
75507
|
-
const st = (0,
|
|
75953
|
+
const st = (0, import_node_fs47.statSync)(path);
|
|
75508
75954
|
if (st.size > opts.maxBytes) {
|
|
75509
75955
|
body.contentOmitted = true;
|
|
75510
75956
|
body.omittedReason = `export is ${st.size} bytes, over max-bytes ${opts.maxBytes}`;
|
|
75511
75957
|
} else if (receipt.encoding === "base64") {
|
|
75512
|
-
body.content = (0,
|
|
75958
|
+
body.content = (0, import_node_fs47.readFileSync)(path).toString("base64");
|
|
75513
75959
|
} else {
|
|
75514
75960
|
body.encoding = receipt.encoding ?? "utf8";
|
|
75515
|
-
body.content = (0,
|
|
75961
|
+
body.content = (0, import_node_fs47.readFileSync)(path, "utf8");
|
|
75516
75962
|
}
|
|
75517
75963
|
}
|
|
75518
75964
|
return body;
|
|
@@ -75791,7 +76237,7 @@ function registerMigrationCommitRoute(app, deps) {
|
|
|
75791
76237
|
}
|
|
75792
76238
|
|
|
75793
76239
|
// workspace-agent-manifest.ts
|
|
75794
|
-
var
|
|
76240
|
+
var import_node_fs48 = require("node:fs");
|
|
75795
76241
|
var import_node_os21 = require("node:os");
|
|
75796
76242
|
var import_node_path43 = require("node:path");
|
|
75797
76243
|
function awareHome() {
|
|
@@ -75802,7 +76248,7 @@ function workspaceAgentDir() {
|
|
|
75802
76248
|
}
|
|
75803
76249
|
function syncWorkspaceAgentManifest(port) {
|
|
75804
76250
|
const dir = workspaceAgentDir();
|
|
75805
|
-
(0,
|
|
76251
|
+
(0, import_node_fs48.mkdirSync)(dir, { recursive: true });
|
|
75806
76252
|
const manifest = `agent: floless-workspace
|
|
75807
76253
|
version: 0.2.0
|
|
75808
76254
|
sdk-target: 2.4.0
|
|
@@ -75933,7 +76379,7 @@ commands:
|
|
|
75933
76379
|
body: object
|
|
75934
76380
|
`;
|
|
75935
76381
|
const path = (0, import_node_path43.join)(dir, "manifest.yaml");
|
|
75936
|
-
if (!(0,
|
|
76382
|
+
if (!(0, import_node_fs48.existsSync)(path) || manifest !== "") (0, import_node_fs48.writeFileSync)(path, manifest, "utf8");
|
|
75937
76383
|
return path;
|
|
75938
76384
|
}
|
|
75939
76385
|
|
|
@@ -77028,7 +77474,7 @@ function computeVersionDiff(id, n, base) {
|
|
|
77028
77474
|
}
|
|
77029
77475
|
|
|
77030
77476
|
// contract-bake.ts
|
|
77031
|
-
var
|
|
77477
|
+
var import_node_fs49 = require("node:fs");
|
|
77032
77478
|
var import_yaml8 = __toESM(require_dist6(), 1);
|
|
77033
77479
|
function isSteelType(t) {
|
|
77034
77480
|
return t === STEEL_V1 || t === STEEL_V2;
|
|
@@ -77052,7 +77498,7 @@ function bakedV2(contract) {
|
|
|
77052
77498
|
return stripConfidentialImages(baked);
|
|
77053
77499
|
}
|
|
77054
77500
|
function bakeContractIntoApp(sourcePath, contract) {
|
|
77055
|
-
const doc = (0, import_yaml8.parseDocument)((0,
|
|
77501
|
+
const doc = (0, import_yaml8.parseDocument)((0, import_node_fs49.readFileSync)(sourcePath, "utf8"));
|
|
77056
77502
|
if (doc.errors.length > 0) {
|
|
77057
77503
|
throw new Error(`contract bake: source is not valid YAML: ${doc.errors[0]?.message ?? "parse error"}`);
|
|
77058
77504
|
}
|
|
@@ -77076,7 +77522,7 @@ function bakeContractIntoApp(sourcePath, contract) {
|
|
|
77076
77522
|
throw new InvalidModelV2Error(`refusing to bake: contract declares steel.model/v2 but is not valid v2: ${issues[0] ?? "unknown"}`, issues);
|
|
77077
77523
|
}
|
|
77078
77524
|
doc.setIn(["nodes", idx, "config", "takeoff"], bakedV2(contract));
|
|
77079
|
-
(0,
|
|
77525
|
+
(0, import_node_fs49.writeFileSync)(sourcePath, doc.toString());
|
|
77080
77526
|
return;
|
|
77081
77527
|
}
|
|
77082
77528
|
const baked = { ...contract };
|
|
@@ -77121,7 +77567,7 @@ function bakeContractIntoApp(sourcePath, contract) {
|
|
|
77121
77567
|
);
|
|
77122
77568
|
}
|
|
77123
77569
|
doc.setIn(["nodes", idx, "config", "takeoff"], baked);
|
|
77124
|
-
(0,
|
|
77570
|
+
(0, import_node_fs49.writeFileSync)(sourcePath, doc.toString());
|
|
77125
77571
|
}
|
|
77126
77572
|
|
|
77127
77573
|
// vectorize.ts
|
|
@@ -77543,11 +77989,11 @@ function awareFailureMessage(e, fallback2) {
|
|
|
77543
77989
|
}
|
|
77544
77990
|
|
|
77545
77991
|
// scene-bake.ts
|
|
77546
|
-
var
|
|
77992
|
+
var import_node_fs50 = require("node:fs");
|
|
77547
77993
|
var import_node_path44 = require("node:path");
|
|
77548
77994
|
var import_yaml9 = __toESM(require_dist6(), 1);
|
|
77549
77995
|
function bakeSceneIntoApp(sourcePath, scene, agent = "viewer-3d") {
|
|
77550
|
-
const doc = (0, import_yaml9.parseDocument)((0,
|
|
77996
|
+
const doc = (0, import_yaml9.parseDocument)((0, import_node_fs50.readFileSync)(sourcePath, "utf8"));
|
|
77551
77997
|
if (doc.errors.length > 0) {
|
|
77552
77998
|
throw new Error(`scene bake: source is not valid YAML: ${doc.errors[0]?.message ?? "parse error"}`);
|
|
77553
77999
|
}
|
|
@@ -77556,10 +78002,10 @@ function bakeSceneIntoApp(sourcePath, scene, agent = "viewer-3d") {
|
|
|
77556
78002
|
const idx = items.findIndex((it) => ((0, import_yaml9.isMap)(it) ? it.toJSON() : null)?.agent === agent);
|
|
77557
78003
|
if (idx < 0) throw new Error(`no ${agent} render node to bake the scene into`);
|
|
77558
78004
|
doc.setIn(["nodes", idx, "config", "scene"], scene);
|
|
77559
|
-
(0,
|
|
78005
|
+
(0, import_node_fs50.writeFileSync)(sourcePath, doc.toString());
|
|
77560
78006
|
}
|
|
77561
78007
|
function bakeNodeConfigById(sourcePath, nodeId, patch2) {
|
|
77562
|
-
const doc = (0, import_yaml9.parseDocument)((0,
|
|
78008
|
+
const doc = (0, import_yaml9.parseDocument)((0, import_node_fs50.readFileSync)(sourcePath, "utf8"));
|
|
77563
78009
|
if (doc.errors.length > 0) {
|
|
77564
78010
|
throw new Error(`node bake: source is not valid YAML: ${doc.errors[0]?.message ?? "parse error"}`);
|
|
77565
78011
|
}
|
|
@@ -77568,12 +78014,12 @@ function bakeNodeConfigById(sourcePath, nodeId, patch2) {
|
|
|
77568
78014
|
const idx = items.findIndex((it) => ((0, import_yaml9.isMap)(it) ? it.toJSON() : null)?.id === nodeId);
|
|
77569
78015
|
if (idx < 0) throw new Error(`no node with id "${nodeId}"`);
|
|
77570
78016
|
for (const [key, value] of Object.entries(patch2)) doc.setIn(["nodes", idx, "config", key], value);
|
|
77571
|
-
(0,
|
|
78017
|
+
(0, import_node_fs50.writeFileSync)(sourcePath, doc.toString());
|
|
77572
78018
|
}
|
|
77573
78019
|
function writeViewer3dApp(dir, appId, scene) {
|
|
77574
|
-
(0,
|
|
78020
|
+
(0, import_node_fs50.mkdirSync)(dir, { recursive: true });
|
|
77575
78021
|
const flo = (0, import_node_path44.join)(dir, `${appId}.flo`);
|
|
77576
|
-
(0,
|
|
78022
|
+
(0, import_node_fs50.writeFileSync)(flo, [
|
|
77577
78023
|
`app: ${appId}`,
|
|
77578
78024
|
"version: 0.1.0",
|
|
77579
78025
|
"display-name: Steel 3D",
|
|
@@ -77596,18 +78042,18 @@ function writeViewer3dApp(dir, appId, scene) {
|
|
|
77596
78042
|
var COMPANION_MARKER = "# floless-companion: generated by FloLess \u2014 overwritten on every export";
|
|
77597
78043
|
function isCompanionApp(flo) {
|
|
77598
78044
|
try {
|
|
77599
|
-
return (0,
|
|
78045
|
+
return (0, import_node_fs50.readFileSync)(flo, "utf8").split(/\r?\n/, 1)[0]?.trim() === COMPANION_MARKER;
|
|
77600
78046
|
} catch (e) {
|
|
77601
78047
|
return e?.code === "ENOENT";
|
|
77602
78048
|
}
|
|
77603
78049
|
}
|
|
77604
78050
|
function writeBomReportApp(dir, appId, table) {
|
|
77605
|
-
(0,
|
|
78051
|
+
(0, import_node_fs50.mkdirSync)(dir, { recursive: true });
|
|
77606
78052
|
const flo = (0, import_node_path44.join)(dir, `${appId}.flo`);
|
|
77607
78053
|
if (!isCompanionApp(flo)) {
|
|
77608
78054
|
throw new Error(`refusing to overwrite "${appId}": an app of that name exists and FloLess did not write it`);
|
|
77609
78055
|
}
|
|
77610
|
-
(0,
|
|
78056
|
+
(0, import_node_fs50.writeFileSync)(flo, [
|
|
77611
78057
|
COMPANION_MARKER,
|
|
77612
78058
|
`app: ${appId}`,
|
|
77613
78059
|
"version: 0.1.0",
|
|
@@ -77634,9 +78080,9 @@ function writeBomReportApp(dir, appId, table) {
|
|
|
77634
78080
|
return flo;
|
|
77635
78081
|
}
|
|
77636
78082
|
function writeRevitApp(dir, appId, scene, hostPid, revitVersion = "2026") {
|
|
77637
|
-
(0,
|
|
78083
|
+
(0, import_node_fs50.mkdirSync)(dir, { recursive: true });
|
|
77638
78084
|
const flo = (0, import_node_path44.join)(dir, `${appId}.flo`);
|
|
77639
|
-
(0,
|
|
78085
|
+
(0, import_node_fs50.writeFileSync)(flo, [
|
|
77640
78086
|
`app: ${appId}`,
|
|
77641
78087
|
"version: 0.1.0",
|
|
77642
78088
|
"display-name: Steel to Revit",
|
|
@@ -77670,9 +78116,9 @@ function writeRevitApp(dir, appId, scene, hostPid, revitVersion = "2026") {
|
|
|
77670
78116
|
return flo;
|
|
77671
78117
|
}
|
|
77672
78118
|
function writeSketchupApp(dir, appId, scene) {
|
|
77673
|
-
(0,
|
|
78119
|
+
(0, import_node_fs50.mkdirSync)(dir, { recursive: true });
|
|
77674
78120
|
const flo = (0, import_node_path44.join)(dir, `${appId}.flo`);
|
|
77675
|
-
(0,
|
|
78121
|
+
(0, import_node_fs50.writeFileSync)(flo, [
|
|
77676
78122
|
`app: ${appId}`,
|
|
77677
78123
|
"version: 0.1.0",
|
|
77678
78124
|
"display-name: Steel to SketchUp",
|
|
@@ -77699,10 +78145,10 @@ function writeSketchupApp(dir, appId, scene) {
|
|
|
77699
78145
|
return flo;
|
|
77700
78146
|
}
|
|
77701
78147
|
function writeRhinoApp(dir, appId, scene, rhinoId, hostPid) {
|
|
77702
|
-
(0,
|
|
78148
|
+
(0, import_node_fs50.mkdirSync)(dir, { recursive: true });
|
|
77703
78149
|
const flo = (0, import_node_path44.join)(dir, `${appId}.flo`);
|
|
77704
78150
|
const exactRhinoId = typeof rhinoId === "string" && rhinoId.trim() ? rhinoId.trim() : null;
|
|
77705
|
-
(0,
|
|
78151
|
+
(0, import_node_fs50.writeFileSync)(flo, [
|
|
77706
78152
|
`app: ${appId}`,
|
|
77707
78153
|
"version: 0.1.0",
|
|
77708
78154
|
"display-name: Steel to Rhino",
|
|
@@ -77729,9 +78175,9 @@ function writeRhinoApp(dir, appId, scene, rhinoId, hostPid) {
|
|
|
77729
78175
|
return flo;
|
|
77730
78176
|
}
|
|
77731
78177
|
function writeTeklaApp(dir, appId, scene, teklaVersion = "2026.0") {
|
|
77732
|
-
(0,
|
|
78178
|
+
(0, import_node_fs50.mkdirSync)(dir, { recursive: true });
|
|
77733
78179
|
const flo = (0, import_node_path44.join)(dir, `${appId}.flo`);
|
|
77734
|
-
(0,
|
|
78180
|
+
(0, import_node_fs50.writeFileSync)(flo, [
|
|
77735
78181
|
`app: ${appId}`,
|
|
77736
78182
|
"version: 0.1.0",
|
|
77737
78183
|
"display-name: Steel to Tekla",
|
|
@@ -77895,7 +78341,7 @@ async function teklaVersionToBake() {
|
|
|
77895
78341
|
|
|
77896
78342
|
// export-companion.ts
|
|
77897
78343
|
var import_node_crypto30 = require("node:crypto");
|
|
77898
|
-
var
|
|
78344
|
+
var import_node_fs51 = require("node:fs");
|
|
77899
78345
|
var import_node_path45 = require("node:path");
|
|
77900
78346
|
var PREFIX = "floless-export-tmp-";
|
|
77901
78347
|
var LEASE = ".floless-export-lease.json";
|
|
@@ -77921,7 +78367,7 @@ function assertScratchPath(path, appsRoot) {
|
|
|
77921
78367
|
}
|
|
77922
78368
|
function removeScratch(path, appsRoot) {
|
|
77923
78369
|
assertScratchPath(path, appsRoot);
|
|
77924
|
-
(0,
|
|
78370
|
+
(0, import_node_fs51.rmSync)(path, { recursive: true, force: true });
|
|
77925
78371
|
}
|
|
77926
78372
|
function createExportCompanion(ownerId, sink, appsRoot = defaultAppsRoot()) {
|
|
77927
78373
|
const safeOwner = ownerId.replace(/[^a-z0-9._-]/gi, "-").slice(0, 80) || "app";
|
|
@@ -77934,10 +78380,10 @@ function createExportCompanion(ownerId, sink, appsRoot = defaultAppsRoot()) {
|
|
|
77934
78380
|
path,
|
|
77935
78381
|
token: token2,
|
|
77936
78382
|
cleanup: () => {
|
|
77937
|
-
if (!(0,
|
|
78383
|
+
if (!(0, import_node_fs51.existsSync)(path)) return;
|
|
77938
78384
|
let current = null;
|
|
77939
78385
|
try {
|
|
77940
|
-
current = JSON.parse((0,
|
|
78386
|
+
current = JSON.parse((0, import_node_fs51.readFileSync)((0, import_node_path45.resolve)(path, LEASE), "utf8"));
|
|
77941
78387
|
} catch {
|
|
77942
78388
|
}
|
|
77943
78389
|
if (current && current.token !== token2) throw new Error(`export companion lease changed for ${id}`);
|
|
@@ -77946,7 +78392,7 @@ function createExportCompanion(ownerId, sink, appsRoot = defaultAppsRoot()) {
|
|
|
77946
78392
|
};
|
|
77947
78393
|
}
|
|
77948
78394
|
function stampExportCompanionLease(companion2) {
|
|
77949
|
-
(0,
|
|
78395
|
+
(0, import_node_fs51.writeFileSync)((0, import_node_path45.resolve)(companion2.path, LEASE), JSON.stringify({
|
|
77950
78396
|
pid: process.pid,
|
|
77951
78397
|
token: companion2.token,
|
|
77952
78398
|
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -77954,19 +78400,19 @@ function stampExportCompanionLease(companion2) {
|
|
|
77954
78400
|
}
|
|
77955
78401
|
function sweepStaleExportCompanions(now = Date.now(), appsRoot = defaultAppsRoot()) {
|
|
77956
78402
|
const root5 = (0, import_node_path45.resolve)(appsRoot);
|
|
77957
|
-
if (!(0,
|
|
78403
|
+
if (!(0, import_node_fs51.existsSync)(root5)) return [];
|
|
77958
78404
|
const removed = [];
|
|
77959
|
-
for (const entry2 of (0,
|
|
78405
|
+
for (const entry2 of (0, import_node_fs51.readdirSync)(root5, { withFileTypes: true })) {
|
|
77960
78406
|
if (!entry2.isDirectory() || !entry2.name.startsWith(PREFIX)) continue;
|
|
77961
78407
|
const path = (0, import_node_path45.resolve)(root5, entry2.name);
|
|
77962
78408
|
let lease = null;
|
|
77963
78409
|
try {
|
|
77964
|
-
lease = JSON.parse((0,
|
|
78410
|
+
lease = JSON.parse((0, import_node_fs51.readFileSync)((0, import_node_path45.resolve)(path, LEASE), "utf8"));
|
|
77965
78411
|
} catch {
|
|
77966
78412
|
}
|
|
77967
78413
|
let created;
|
|
77968
78414
|
try {
|
|
77969
|
-
created = lease ? Date.parse(lease.createdAt) : (0,
|
|
78415
|
+
created = lease ? Date.parse(lease.createdAt) : (0, import_node_fs51.statSync)(path).mtimeMs;
|
|
77970
78416
|
} catch {
|
|
77971
78417
|
continue;
|
|
77972
78418
|
}
|
|
@@ -78540,14 +78986,14 @@ function looksLikeHostUnavailable(host, ...messages) {
|
|
|
78540
78986
|
}
|
|
78541
78987
|
|
|
78542
78988
|
// render-readiness.ts
|
|
78543
|
-
var
|
|
78989
|
+
var import_node_fs52 = require("node:fs");
|
|
78544
78990
|
var import_node_path46 = require("node:path");
|
|
78545
78991
|
var import_node_os22 = require("node:os");
|
|
78546
78992
|
var RENDER_AWARE_FLOOR = "0.103.0";
|
|
78547
78993
|
var RENDER_AGENT_ID = "blender";
|
|
78548
78994
|
function isFile(path) {
|
|
78549
78995
|
try {
|
|
78550
|
-
return (0,
|
|
78996
|
+
return (0, import_node_fs52.existsSync)(path) && (0, import_node_fs52.statSync)(path).isFile();
|
|
78551
78997
|
} catch {
|
|
78552
78998
|
return false;
|
|
78553
78999
|
}
|
|
@@ -78581,7 +79027,7 @@ function windowsCandidates(env2) {
|
|
|
78581
79027
|
for (const root5 of roots) {
|
|
78582
79028
|
let entries2;
|
|
78583
79029
|
try {
|
|
78584
|
-
entries2 = (0,
|
|
79030
|
+
entries2 = (0, import_node_fs52.readdirSync)(root5);
|
|
78585
79031
|
} catch {
|
|
78586
79032
|
continue;
|
|
78587
79033
|
}
|
|
@@ -78760,16 +79206,16 @@ function nothingToApprove(contract) {
|
|
|
78760
79206
|
}
|
|
78761
79207
|
|
|
78762
79208
|
// app-lifecycle.ts
|
|
78763
|
-
var
|
|
79209
|
+
var import_node_fs55 = require("node:fs");
|
|
78764
79210
|
var import_node_os24 = require("node:os");
|
|
78765
79211
|
var import_node_path49 = require("node:path");
|
|
78766
79212
|
|
|
78767
79213
|
// routines.ts
|
|
78768
|
-
var
|
|
79214
|
+
var import_node_fs54 = require("node:fs");
|
|
78769
79215
|
var import_node_path48 = require("node:path");
|
|
78770
79216
|
|
|
78771
79217
|
// trigger-sessions.ts
|
|
78772
|
-
var
|
|
79218
|
+
var import_node_fs53 = require("node:fs");
|
|
78773
79219
|
var import_node_os23 = require("node:os");
|
|
78774
79220
|
var import_node_path47 = require("node:path");
|
|
78775
79221
|
var import_yaml10 = __toESM(require_dist6(), 1);
|
|
@@ -78791,9 +79237,9 @@ function isHostBacked(agent, agentsDir = AGENTS_DIR2) {
|
|
|
78791
79237
|
const safe2 = (n) => !n.includes("/") && !n.includes("\\") && !n.includes("..");
|
|
78792
79238
|
if (!safe2(agent)) return false;
|
|
78793
79239
|
const manifestPath2 = (0, import_node_path47.join)(agentsDir, agent, "manifest.yaml");
|
|
78794
|
-
if (!(0,
|
|
79240
|
+
if (!(0, import_node_fs53.existsSync)(manifestPath2)) return false;
|
|
78795
79241
|
try {
|
|
78796
|
-
const doc = (0, import_yaml10.parse)((0,
|
|
79242
|
+
const doc = (0, import_yaml10.parse)((0, import_node_fs53.readFileSync)(manifestPath2, "utf8"));
|
|
78797
79243
|
const transport = doc?.transport;
|
|
78798
79244
|
return !!(transport && typeof transport === "object" && "cli" in transport);
|
|
78799
79245
|
} catch {
|
|
@@ -79137,10 +79583,10 @@ function sanitizeRoutine(raw) {
|
|
|
79137
79583
|
};
|
|
79138
79584
|
}
|
|
79139
79585
|
function loadFromDisk() {
|
|
79140
|
-
if (!(0,
|
|
79586
|
+
if (!(0, import_node_fs54.existsSync)(ROUTINES_FILE)) return [];
|
|
79141
79587
|
let text3;
|
|
79142
79588
|
try {
|
|
79143
|
-
text3 = (0,
|
|
79589
|
+
text3 = (0, import_node_fs54.readFileSync)(ROUTINES_FILE, "utf8");
|
|
79144
79590
|
} catch {
|
|
79145
79591
|
return [];
|
|
79146
79592
|
}
|
|
@@ -79149,17 +79595,17 @@ function loadFromDisk() {
|
|
|
79149
79595
|
return Array.isArray(parsed) ? parsed.map(sanitizeRoutine).filter((r) => r !== null) : [];
|
|
79150
79596
|
} catch {
|
|
79151
79597
|
try {
|
|
79152
|
-
(0,
|
|
79598
|
+
(0, import_node_fs54.renameSync)(ROUTINES_FILE, `${ROUTINES_FILE}.corrupt-${Date.now()}`);
|
|
79153
79599
|
} catch {
|
|
79154
79600
|
}
|
|
79155
79601
|
return [];
|
|
79156
79602
|
}
|
|
79157
79603
|
}
|
|
79158
79604
|
function saveRoutines() {
|
|
79159
|
-
if (!(0,
|
|
79605
|
+
if (!(0, import_node_fs54.existsSync)(flolessRoot)) (0, import_node_fs54.mkdirSync)(flolessRoot, { recursive: true });
|
|
79160
79606
|
const tmp = `${ROUTINES_FILE}.${process.pid}.tmp`;
|
|
79161
|
-
(0,
|
|
79162
|
-
(0,
|
|
79607
|
+
(0, import_node_fs54.writeFileSync)(tmp, JSON.stringify(routines, null, 2));
|
|
79608
|
+
(0, import_node_fs54.renameSync)(tmp, ROUTINES_FILE);
|
|
79163
79609
|
}
|
|
79164
79610
|
function listRoutines() {
|
|
79165
79611
|
ensureLoaded();
|
|
@@ -79585,7 +80031,7 @@ function appDirPath(id) {
|
|
|
79585
80031
|
return (0, import_node_path49.join)(appsDir(), id);
|
|
79586
80032
|
}
|
|
79587
80033
|
function appInstalled(id) {
|
|
79588
|
-
return APP_ID4.test(id) && (0,
|
|
80034
|
+
return APP_ID4.test(id) && (0, import_node_fs55.existsSync)(appDirPath(id));
|
|
79589
80035
|
}
|
|
79590
80036
|
function logCascade(what, e) {
|
|
79591
80037
|
console.error(`[app-lifecycle] cascade step failed (${what}):`, e instanceof Error ? e.message : e);
|
|
@@ -79823,7 +80269,7 @@ function isGatedAwareRoute(url, method) {
|
|
|
79823
80269
|
|
|
79824
80270
|
// autostart.mjs
|
|
79825
80271
|
var import_node_child_process8 = require("node:child_process");
|
|
79826
|
-
var
|
|
80272
|
+
var import_node_fs56 = require("node:fs");
|
|
79827
80273
|
var import_node_os25 = require("node:os");
|
|
79828
80274
|
var import_node_path50 = require("node:path");
|
|
79829
80275
|
|
|
@@ -79937,8 +80383,8 @@ function removeLegacyRunKey() {
|
|
|
79937
80383
|
}
|
|
79938
80384
|
function logLine(msg) {
|
|
79939
80385
|
try {
|
|
79940
|
-
(0,
|
|
79941
|
-
(0,
|
|
80386
|
+
(0, import_node_fs56.mkdirSync)(logDir(), { recursive: true });
|
|
80387
|
+
(0, import_node_fs56.appendFileSync)(logFilePath(), `${(/* @__PURE__ */ new Date()).toISOString()} ${msg}
|
|
79942
80388
|
`);
|
|
79943
80389
|
} catch {
|
|
79944
80390
|
}
|
|
@@ -79947,7 +80393,7 @@ function registerAutostart(exePath) {
|
|
|
79947
80393
|
if (!isWin) return;
|
|
79948
80394
|
const xml = buildAutostartTaskXml(exePath, currentUserId());
|
|
79949
80395
|
const tmp = (0, import_node_path50.join)((0, import_node_os25.tmpdir)(), `floless-autostart-${process.pid}-${Date.now()}.xml`);
|
|
79950
|
-
(0,
|
|
80396
|
+
(0, import_node_fs56.writeFileSync)(tmp, "\uFEFF" + xml, { encoding: "utf16le" });
|
|
79951
80397
|
try {
|
|
79952
80398
|
(0, import_node_child_process8.execFileSync)("schtasks", ["/Create", "/TN", TASK_NAME, "/XML", tmp, "/F"], {
|
|
79953
80399
|
stdio: ["ignore", "ignore", "ignore"],
|
|
@@ -79958,7 +80404,7 @@ function registerAutostart(exePath) {
|
|
|
79958
80404
|
throw err2;
|
|
79959
80405
|
} finally {
|
|
79960
80406
|
try {
|
|
79961
|
-
(0,
|
|
80407
|
+
(0, import_node_fs56.rmSync)(tmp, { force: true });
|
|
79962
80408
|
} catch {
|
|
79963
80409
|
}
|
|
79964
80410
|
}
|
|
@@ -79993,13 +80439,13 @@ function unregisterAutostart() {
|
|
|
79993
80439
|
// updater.ts
|
|
79994
80440
|
var import_node_child_process9 = require("node:child_process");
|
|
79995
80441
|
var import_node_crypto31 = require("node:crypto");
|
|
79996
|
-
var
|
|
80442
|
+
var import_node_fs58 = require("node:fs");
|
|
79997
80443
|
var import_node_stream3 = require("node:stream");
|
|
79998
80444
|
var import_promises5 = require("node:stream/promises");
|
|
79999
80445
|
var import_node_path52 = require("node:path");
|
|
80000
80446
|
|
|
80001
80447
|
// post-update-marker.mjs
|
|
80002
|
-
var
|
|
80448
|
+
var import_node_fs57 = require("node:fs");
|
|
80003
80449
|
var import_node_os26 = require("node:os");
|
|
80004
80450
|
var import_node_path51 = require("node:path");
|
|
80005
80451
|
var FRESH_MS = 12e4;
|
|
@@ -80022,7 +80468,7 @@ function writePostUpdateMarker() {
|
|
|
80022
80468
|
for (const p of [markerPath(), legacyMarkerPath()]) {
|
|
80023
80469
|
if (!p) continue;
|
|
80024
80470
|
try {
|
|
80025
|
-
(0,
|
|
80471
|
+
(0, import_node_fs57.writeFileSync)(p, (/* @__PURE__ */ new Date()).toISOString());
|
|
80026
80472
|
wrote = true;
|
|
80027
80473
|
} catch {
|
|
80028
80474
|
}
|
|
@@ -80034,9 +80480,9 @@ function consumePostUpdateMarker() {
|
|
|
80034
80480
|
for (const p of [markerPath(), legacyMarkerPath()]) {
|
|
80035
80481
|
if (!p) continue;
|
|
80036
80482
|
try {
|
|
80037
|
-
if (!(0,
|
|
80038
|
-
const ageMs = Date.now() - (0,
|
|
80039
|
-
(0,
|
|
80483
|
+
if (!(0, import_node_fs57.existsSync)(p)) continue;
|
|
80484
|
+
const ageMs = Date.now() - (0, import_node_fs57.statSync)(p).mtimeMs;
|
|
80485
|
+
(0, import_node_fs57.rmSync)(p, { force: true });
|
|
80040
80486
|
if (ageMs < FRESH_MS) fresh = true;
|
|
80041
80487
|
} catch {
|
|
80042
80488
|
}
|
|
@@ -80161,22 +80607,22 @@ async function checkForUpdate() {
|
|
|
80161
80607
|
}
|
|
80162
80608
|
async function sha1OfFile(path) {
|
|
80163
80609
|
const hash2 = (0, import_node_crypto31.createHash)("sha1");
|
|
80164
|
-
await (0, import_promises5.pipeline)((0,
|
|
80610
|
+
await (0, import_promises5.pipeline)((0, import_node_fs58.createReadStream)(path), hash2);
|
|
80165
80611
|
return hash2.digest("hex").toUpperCase();
|
|
80166
80612
|
}
|
|
80167
80613
|
async function downloadPackage(asset) {
|
|
80168
80614
|
if (!NUPKG_NAME.test(asset.FileName)) throw new Error(`refusing suspicious package name: ${asset.FileName}`);
|
|
80169
80615
|
const want = asset.SHA1.toUpperCase();
|
|
80170
80616
|
const dir = packagesDir();
|
|
80171
|
-
(0,
|
|
80617
|
+
(0, import_node_fs58.mkdirSync)(dir, { recursive: true });
|
|
80172
80618
|
const dest = (0, import_node_path52.join)(dir, asset.FileName);
|
|
80173
|
-
if ((0,
|
|
80619
|
+
if ((0, import_node_fs58.existsSync)(dest) && await sha1OfFile(dest) === want) return dest;
|
|
80174
80620
|
const res = await authedFetch(`${feedUrl()}/${encodeURIComponent(asset.FileName)}`, {
|
|
80175
80621
|
redirect: "follow",
|
|
80176
80622
|
signal: AbortSignal.timeout(DOWNLOAD_TIMEOUT_MS)
|
|
80177
80623
|
});
|
|
80178
80624
|
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,
|
|
80625
|
+
await (0, import_promises5.pipeline)(import_node_stream3.Readable.fromWeb(res.body), (0, import_node_fs58.createWriteStream)(dest));
|
|
80180
80626
|
const got = await sha1OfFile(dest);
|
|
80181
80627
|
if (got !== want) throw new Error(`SHA1 mismatch for ${asset.FileName}: feed=${want} got=${got}`);
|
|
80182
80628
|
return dest;
|
|
@@ -80185,7 +80631,7 @@ async function applyUpdate(check, opts) {
|
|
|
80185
80631
|
if (!check.supported) return { applied: false, message: check.reason ?? "auto-update not supported in this runtime" };
|
|
80186
80632
|
if (!check.updateAvailable || !check.asset) return { applied: false, message: check.reason ?? "no update available" };
|
|
80187
80633
|
const exe = updateExePath();
|
|
80188
|
-
if (!(0,
|
|
80634
|
+
if (!(0, import_node_fs58.existsSync)(exe)) {
|
|
80189
80635
|
return { applied: false, message: `Update.exe not found at ${exe} \u2014 is this a Velopack install?` };
|
|
80190
80636
|
}
|
|
80191
80637
|
const pkg = await downloadPackage(check.asset);
|
|
@@ -80427,7 +80873,7 @@ function isTraceCorrupt(events) {
|
|
|
80427
80873
|
var import_node_child_process10 = require("node:child_process");
|
|
80428
80874
|
var import_node_path53 = require("node:path");
|
|
80429
80875
|
var import_node_url3 = require("node:url");
|
|
80430
|
-
var
|
|
80876
|
+
var import_node_fs59 = require("node:fs");
|
|
80431
80877
|
var import_node_http = __toESM(require("node:http"), 1);
|
|
80432
80878
|
var import_node_readline = require("node:readline");
|
|
80433
80879
|
var __dirname2 = (0, import_node_path53.dirname)((0, import_node_url3.fileURLToPath)(__import_meta_url));
|
|
@@ -80509,7 +80955,7 @@ function resolveServerStart() {
|
|
|
80509
80955
|
const packaged = /flolessapp\.exe$/i.test(process.execPath);
|
|
80510
80956
|
if (packaged) return { cmd: process.execPath, args: ["--serve"], shell: false };
|
|
80511
80957
|
const bundle = (0, import_node_path53.join)(__dirname2, "dist", "floless-server.cjs");
|
|
80512
|
-
if ((0,
|
|
80958
|
+
if ((0, import_node_fs59.existsSync)(bundle)) return { cmd: process.execPath, args: [bundle, "--serve"], shell: false };
|
|
80513
80959
|
return { cmd: "npm", args: ["run", "start"], shell: isWin2 };
|
|
80514
80960
|
}
|
|
80515
80961
|
function startServerDetached() {
|
|
@@ -82121,7 +82567,7 @@ function registerAwareUpdateRoutes(app, manager) {
|
|
|
82121
82567
|
}
|
|
82122
82568
|
|
|
82123
82569
|
// skill-sync.ts
|
|
82124
|
-
var
|
|
82570
|
+
var import_node_fs60 = require("node:fs");
|
|
82125
82571
|
var import_node_os27 = require("node:os");
|
|
82126
82572
|
var import_node_path56 = require("node:path");
|
|
82127
82573
|
var import_node_url4 = require("node:url");
|
|
@@ -82177,7 +82623,7 @@ function bundledSkillsRoot() {
|
|
|
82177
82623
|
(0, import_node_path56.join)((0, import_node_path56.dirname)(process.execPath), "skills"),
|
|
82178
82624
|
(0, import_node_path56.join)(__dirname3, "..", ".claude", "skills")
|
|
82179
82625
|
];
|
|
82180
|
-
return candidates.find((p) => (0,
|
|
82626
|
+
return candidates.find((p) => (0, import_node_fs60.existsSync)(p)) ?? null;
|
|
82181
82627
|
}
|
|
82182
82628
|
function targetConfigDirs() {
|
|
82183
82629
|
const override = process.env.FLOLESS_SKILL_TARGETS;
|
|
@@ -82193,7 +82639,7 @@ function targetConfigDirs() {
|
|
|
82193
82639
|
}
|
|
82194
82640
|
function skillVersion(skillMdPath) {
|
|
82195
82641
|
try {
|
|
82196
|
-
const text3 = (0,
|
|
82642
|
+
const text3 = (0, import_node_fs60.readFileSync)(skillMdPath, "utf8");
|
|
82197
82643
|
const m = /^---\r?\n([\s\S]*?)\r?\n---/.exec(text3);
|
|
82198
82644
|
if (!m || m[1] === void 0) return null;
|
|
82199
82645
|
const fm = (0, import_yaml11.parse)(m[1]);
|
|
@@ -82233,7 +82679,7 @@ function decideAction(installed, bundled) {
|
|
|
82233
82679
|
function bundledSkills(root5) {
|
|
82234
82680
|
let entries2 = [];
|
|
82235
82681
|
try {
|
|
82236
|
-
entries2 = selectShippedSkillNames((0,
|
|
82682
|
+
entries2 = selectShippedSkillNames((0, import_node_fs60.readdirSync)(root5));
|
|
82237
82683
|
} catch {
|
|
82238
82684
|
return [];
|
|
82239
82685
|
}
|
|
@@ -82242,7 +82688,7 @@ function bundledSkills(root5) {
|
|
|
82242
82688
|
const dir = (0, import_node_path56.join)(root5, name);
|
|
82243
82689
|
let isDir = false;
|
|
82244
82690
|
try {
|
|
82245
|
-
isDir = (0,
|
|
82691
|
+
isDir = (0, import_node_fs60.statSync)(dir).isDirectory();
|
|
82246
82692
|
} catch {
|
|
82247
82693
|
isDir = false;
|
|
82248
82694
|
}
|
|
@@ -82260,17 +82706,17 @@ function syncSkills() {
|
|
|
82260
82706
|
const skills = bundledSkills(root5);
|
|
82261
82707
|
if (!skills.length) return results;
|
|
82262
82708
|
for (const { runtime, dir: cfg } of targetConfigDirs()) {
|
|
82263
|
-
if (!(0,
|
|
82709
|
+
if (!(0, import_node_fs60.existsSync)(cfg)) continue;
|
|
82264
82710
|
const skillsDir = (0, import_node_path56.join)(cfg, "skills");
|
|
82265
82711
|
for (const s of skills) {
|
|
82266
82712
|
const dest = (0, import_node_path56.join)(skillsDir, s.name);
|
|
82267
82713
|
const installedMd = (0, import_node_path56.join)(dest, "SKILL.md");
|
|
82268
|
-
const installed = (0,
|
|
82714
|
+
const installed = (0, import_node_fs60.existsSync)(installedMd) ? skillVersion(installedMd) : null;
|
|
82269
82715
|
const action = decideAction(installed, s.version);
|
|
82270
82716
|
if (action === "installed" || action === "updated") {
|
|
82271
82717
|
try {
|
|
82272
|
-
if (action === "updated") (0,
|
|
82273
|
-
(0,
|
|
82718
|
+
if (action === "updated") (0, import_node_fs60.rmSync)(dest, { recursive: true, force: true });
|
|
82719
|
+
(0, import_node_fs60.cpSync)(s.dir, dest, { recursive: true });
|
|
82274
82720
|
results.push({ runtime, skill: s.name, action, from: installed, to: s.version });
|
|
82275
82721
|
} catch {
|
|
82276
82722
|
}
|
|
@@ -82285,7 +82731,7 @@ function syncSkills() {
|
|
|
82285
82731
|
// watch.ts
|
|
82286
82732
|
var import_node_os28 = require("node:os");
|
|
82287
82733
|
var import_node_path58 = require("node:path");
|
|
82288
|
-
var
|
|
82734
|
+
var import_node_fs61 = require("node:fs");
|
|
82289
82735
|
|
|
82290
82736
|
// node_modules/chokidar/esm/index.js
|
|
82291
82737
|
var import_fs2 = require("fs");
|
|
@@ -83998,20 +84444,20 @@ function underDir(path, dir) {
|
|
|
83998
84444
|
function startWatcher() {
|
|
83999
84445
|
const awareDir = process.env.AWARE_HOME ?? (0, import_node_path58.join)((0, import_node_os28.homedir)(), ".aware");
|
|
84000
84446
|
const credentialsDir = (0, import_node_path58.join)(awareDir, "credentials");
|
|
84001
|
-
if (!(0,
|
|
84447
|
+
if (!(0, import_node_fs61.existsSync)(credentialsDir)) {
|
|
84002
84448
|
try {
|
|
84003
|
-
(0,
|
|
84449
|
+
(0, import_node_fs61.mkdirSync)(credentialsDir, { recursive: true });
|
|
84004
84450
|
} catch {
|
|
84005
84451
|
}
|
|
84006
84452
|
}
|
|
84007
|
-
if (!(0,
|
|
84453
|
+
if (!(0, import_node_fs61.existsSync)(uiDir)) {
|
|
84008
84454
|
try {
|
|
84009
|
-
(0,
|
|
84455
|
+
(0, import_node_fs61.mkdirSync)(uiDir, { recursive: true });
|
|
84010
84456
|
} catch {
|
|
84011
84457
|
}
|
|
84012
84458
|
}
|
|
84013
|
-
const targets = ["apps", "logs", "credentials"].map((d) => (0, import_node_path58.join)(awareDir, d)).filter((p) => (0,
|
|
84014
|
-
if ((0,
|
|
84459
|
+
const targets = ["apps", "logs", "credentials"].map((d) => (0, import_node_path58.join)(awareDir, d)).filter((p) => (0, import_node_fs61.existsSync)(p));
|
|
84460
|
+
if ((0, import_node_fs61.existsSync)(uiDir)) targets.push(uiDir);
|
|
84015
84461
|
if (targets.length === 0) {
|
|
84016
84462
|
return null;
|
|
84017
84463
|
}
|
|
@@ -84040,11 +84486,11 @@ function startWatcher() {
|
|
|
84040
84486
|
const isCredential = path.split(/[\\/]/).includes("credentials");
|
|
84041
84487
|
const kind = isCredential ? "credential" : path.endsWith(".jsonl") ? "trace" : path.endsWith(".lock") ? "lock" : path.endsWith(".flo") || path.endsWith(".app") ? "source" : "file";
|
|
84042
84488
|
broadcast({ type: "fs-change", kind, event, path });
|
|
84043
|
-
if (kind === "trace" && event !== "unlink" && (0,
|
|
84489
|
+
if (kind === "trace" && event !== "unlink" && (0, import_node_fs61.existsSync)(path)) {
|
|
84044
84490
|
const id = appIdFromLogPath(path);
|
|
84045
84491
|
if (!id) return;
|
|
84046
84492
|
try {
|
|
84047
|
-
broadcast({ type: "trace-file", id, runId: path.split(import_node_path58.sep).pop()?.replace(/\.jsonl$/, "") ?? null, events: parseTrace((0,
|
|
84493
|
+
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
84494
|
} catch {
|
|
84049
84495
|
}
|
|
84050
84496
|
}
|
|
@@ -84055,7 +84501,7 @@ function startWatcher() {
|
|
|
84055
84501
|
// index.ts
|
|
84056
84502
|
var __dirname4 = (0, import_node_path59.dirname)((0, import_node_url5.fileURLToPath)(__import_meta_url));
|
|
84057
84503
|
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,
|
|
84504
|
+
(p) => (0, import_node_fs62.existsSync)(p)
|
|
84059
84505
|
) ?? (0, import_node_path59.join)(__dirname4, "..", "web");
|
|
84060
84506
|
var PORT2 = Number(process.env.PORT ?? 4317);
|
|
84061
84507
|
var HOST = "127.0.0.1";
|
|
@@ -84072,7 +84518,7 @@ function installCrashHandlers() {
|
|
|
84072
84518
|
${stack}
|
|
84073
84519
|
`;
|
|
84074
84520
|
try {
|
|
84075
|
-
(0,
|
|
84521
|
+
(0, import_node_fs62.appendFileSync)(logFilePath(), line);
|
|
84076
84522
|
} catch {
|
|
84077
84523
|
}
|
|
84078
84524
|
if (process.stderr.isTTY) process.stderr.write(line);
|
|
@@ -84722,10 +85168,10 @@ async function startServer() {
|
|
|
84722
85168
|
const bdir = backupDir(id, fromVersion, Date.now());
|
|
84723
85169
|
let backedUp = false;
|
|
84724
85170
|
try {
|
|
84725
|
-
(0,
|
|
84726
|
-
(0,
|
|
85171
|
+
(0, import_node_fs62.mkdirSync)((0, import_node_path59.dirname)(bdir), { recursive: true });
|
|
85172
|
+
(0, import_node_fs62.cpSync)(appDirPath2, bdir, { recursive: true });
|
|
84727
85173
|
backedUp = true;
|
|
84728
|
-
(0,
|
|
85174
|
+
(0, import_node_fs62.cpSync)(templatePath, srcPath);
|
|
84729
85175
|
if (id !== templateId) stampSourceAppId(srcPath, id);
|
|
84730
85176
|
if (contract != null) {
|
|
84731
85177
|
bakeContractIntoApp(srcPath, contract);
|
|
@@ -84739,8 +85185,8 @@ async function startServer() {
|
|
|
84739
85185
|
throw new TemplateSwapError(`${verb} failed before any change was made (${msg}) \u2014 the workflow is untouched`, `${verb}-not-started`);
|
|
84740
85186
|
}
|
|
84741
85187
|
try {
|
|
84742
|
-
(0,
|
|
84743
|
-
(0,
|
|
85188
|
+
(0, import_node_fs62.rmSync)(appDirPath2, { recursive: true, force: true });
|
|
85189
|
+
(0, import_node_fs62.cpSync)(bdir, appDirPath2, { recursive: true });
|
|
84744
85190
|
} catch (re) {
|
|
84745
85191
|
const rmsg = re instanceof Error ? re.message : String(re);
|
|
84746
85192
|
throw new TemplateSwapError(`${verb} failed (${msg}) AND rollback failed (${rmsg}) \u2014 restore manually from ${bdir}`, "rollback-failed", bdir);
|
|
@@ -84752,7 +85198,7 @@ async function startServer() {
|
|
|
84752
85198
|
function readSwapContract(id, verb) {
|
|
84753
85199
|
const gerund = verb === "update" ? "updating" : "restoring";
|
|
84754
85200
|
const contract = readAcceptedForRequest(id, void 0);
|
|
84755
|
-
if (contract == null && (0,
|
|
85201
|
+
if (contract == null && (0, import_node_fs62.existsSync)(contractPath(id))) {
|
|
84756
85202
|
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
85203
|
}
|
|
84758
85204
|
if (contract != null && !validateContract(contract).valid) {
|
|
@@ -84968,7 +85414,19 @@ async function startServer() {
|
|
|
84968
85414
|
projectExportsDir(req.params.id),
|
|
84969
85415
|
{ kind: "project", key: req.params.id }
|
|
84970
85416
|
);
|
|
84971
|
-
|
|
85417
|
+
const before = getProject(req.params.id);
|
|
85418
|
+
const project = renameProject(req.params.id, req.body?.name);
|
|
85419
|
+
if (!before) {
|
|
85420
|
+
req.log.error({ id: req.params.id }, "rename: pre-read missing \u2014 other tabs cannot reconcile this rename");
|
|
85421
|
+
} else if (before.id !== project.id) {
|
|
85422
|
+
broadcast({
|
|
85423
|
+
type: "projects-changed",
|
|
85424
|
+
appId: project.app,
|
|
85425
|
+
projectId: project.id,
|
|
85426
|
+
previousProjectId: before.id
|
|
85427
|
+
});
|
|
85428
|
+
}
|
|
85429
|
+
return { ok: true, project: projectView(project) };
|
|
84972
85430
|
});
|
|
84973
85431
|
} catch (e) {
|
|
84974
85432
|
if (e instanceof ProjectError) return reply.status(400).send({ ok: false, error: e.message });
|
|
@@ -85052,7 +85510,7 @@ async function startServer() {
|
|
|
85052
85510
|
}
|
|
85053
85511
|
let data;
|
|
85054
85512
|
try {
|
|
85055
|
-
data = (0,
|
|
85513
|
+
data = (0, import_node_fs62.readFileSync)(thumb.path);
|
|
85056
85514
|
} catch {
|
|
85057
85515
|
return reply.status(404).send({ ok: false, error: "no thumbnail" });
|
|
85058
85516
|
}
|
|
@@ -85572,8 +86030,8 @@ async function startServer() {
|
|
|
85572
86030
|
if (bad) return reply.status(404).send({ ok: false, error: bad });
|
|
85573
86031
|
const safe2 = req.params.sheet.replace(/[^A-Za-z0-9._-]/g, "");
|
|
85574
86032
|
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,
|
|
86033
|
+
if (!(0, import_node_fs62.existsSync)(file)) return reply.status(404).send({ ok: false, error: "no vector for this sheet" });
|
|
86034
|
+
return reply.type("image/svg+xml").send((0, import_node_fs62.readFileSync)(file, "utf8"));
|
|
85577
86035
|
}
|
|
85578
86036
|
);
|
|
85579
86037
|
app.put(
|
|
@@ -85611,10 +86069,13 @@ async function startServer() {
|
|
|
85611
86069
|
try {
|
|
85612
86070
|
return await withLifecycleLock("project", req.params.id, () => {
|
|
85613
86071
|
const prepared = prepareProjectApprovalReview(req.params.id, { validateCandidate: projectApprovalCandidateAccepted });
|
|
85614
|
-
return { ok: true,
|
|
86072
|
+
return { ...prepared.review, ok: true, reviewable: true };
|
|
85615
86073
|
}, { label: "preparing approval review" });
|
|
85616
86074
|
} catch (error) {
|
|
85617
|
-
if (error instanceof WorkspaceSnapshotError)
|
|
86075
|
+
if (error instanceof WorkspaceSnapshotError) {
|
|
86076
|
+
if (error.notReviewable) return { ok: true, reviewable: false, reason: error.notReviewable, message: error.message };
|
|
86077
|
+
return reply.status(error.status).send({ ok: false, error: error.message });
|
|
86078
|
+
}
|
|
85618
86079
|
throw error;
|
|
85619
86080
|
}
|
|
85620
86081
|
});
|
|
@@ -86059,7 +86520,7 @@ async function startServer() {
|
|
|
86059
86520
|
}
|
|
86060
86521
|
const statedAt = (filename) => {
|
|
86061
86522
|
try {
|
|
86062
|
-
const st = (0,
|
|
86523
|
+
const st = (0, import_node_fs62.statSync)((0, import_node_path59.join)(dir, filename));
|
|
86063
86524
|
return st.isFile() ? st.mtime.toISOString() : null;
|
|
86064
86525
|
} catch {
|
|
86065
86526
|
return null;
|
|
@@ -86231,10 +86692,10 @@ async function startServer() {
|
|
|
86231
86692
|
scene,
|
|
86232
86693
|
"output-path": tempPath
|
|
86233
86694
|
});
|
|
86234
|
-
if (!(0,
|
|
86695
|
+
if (!(0, import_node_fs62.existsSync)(tempPath) || (0, import_node_fs62.statSync)(tempPath).size === 0) {
|
|
86235
86696
|
throw new ReceiptReconciliationError("AWARE reported a successful export but wrote no IFC file.");
|
|
86236
86697
|
}
|
|
86237
|
-
const artifactBytes = (0,
|
|
86698
|
+
const artifactBytes = (0, import_node_fs62.readFileSync)(tempPath);
|
|
86238
86699
|
const receipt = reconcileIfcExportReceipt(scene, rawReceipt, producerUnsupported, {
|
|
86239
86700
|
index: parseStepData(artifactBytes),
|
|
86240
86701
|
bytes: artifactBytes
|
|
@@ -86290,7 +86751,7 @@ async function startServer() {
|
|
|
86290
86751
|
ok: false,
|
|
86291
86752
|
error: awareFailureMessage(error, "IFC export failed"),
|
|
86292
86753
|
...reason ? { reason } : {},
|
|
86293
|
-
preservedPrevious: project && priorProjectIfc ? receiptHasFile(project, priorProjectIfc) : (0,
|
|
86754
|
+
preservedPrevious: project && priorProjectIfc ? receiptHasFile(project, priorProjectIfc) : (0, import_node_fs62.existsSync)(finalPath)
|
|
86294
86755
|
});
|
|
86295
86756
|
} finally {
|
|
86296
86757
|
cleanupIfcTemp(tempPath);
|
|
@@ -86334,10 +86795,10 @@ async function startServer() {
|
|
|
86334
86795
|
const receipt = wanted ? stills.find((row) => row.variant === wanted) : [...stills].sort((a, b) => b.exportedAt.localeCompare(a.exportedAt))[0];
|
|
86335
86796
|
if (!receipt) return reply.status(404).send({ ok: false, error: "nothing rendered yet" });
|
|
86336
86797
|
const path = resolveProjectExportReceiptPath(project, receipt);
|
|
86337
|
-
if (!path || !(0,
|
|
86798
|
+
if (!path || !(0, import_node_fs62.existsSync)(path)) {
|
|
86338
86799
|
return reply.status(404).send({ ok: false, error: "the rendered image is no longer on disk" });
|
|
86339
86800
|
}
|
|
86340
|
-
return reply.header("content-type", "image/png").header("cache-control", "private, max-age=31536000, immutable").send((0,
|
|
86801
|
+
return reply.header("content-type", "image/png").header("cache-control", "private, max-age=31536000, immutable").send((0, import_node_fs62.readFileSync)(path));
|
|
86341
86802
|
});
|
|
86342
86803
|
const RENDER_VIEWPOINTS = /* @__PURE__ */ new Set(["hero", "iso", "front", "back", "left", "right", "top"]);
|
|
86343
86804
|
app.post("/api/contract/:appId/render", async (req, reply) => {
|
|
@@ -86397,7 +86858,7 @@ async function startServer() {
|
|
|
86397
86858
|
}
|
|
86398
86859
|
const kind = output === "turntable" ? "render-mp4" : "render-png";
|
|
86399
86860
|
const extension = output === "turntable" ? ".mp4" : ".png";
|
|
86400
|
-
const scratch = (0,
|
|
86861
|
+
const scratch = (0, import_node_fs62.mkdtempSync)((0, import_node_path59.join)((0, import_node_os29.tmpdir)(), "floless-render-"));
|
|
86401
86862
|
const ifcPath = (0, import_node_path59.join)(scratch, "model.ifc");
|
|
86402
86863
|
const rendered = [];
|
|
86403
86864
|
const progress = (stage, extra = {}) => {
|
|
@@ -86409,7 +86870,7 @@ async function startServer() {
|
|
|
86409
86870
|
try {
|
|
86410
86871
|
progress("preparing");
|
|
86411
86872
|
await aware.agentInvoke("ifc", "write", { scene: built.scene, "output-path": ifcPath });
|
|
86412
|
-
if (!(0,
|
|
86873
|
+
if (!(0, import_node_fs62.existsSync)(ifcPath) || (0, import_node_fs62.statSync)(ifcPath).size === 0) {
|
|
86413
86874
|
throw new Error("AWARE reported a successful IFC write but produced no file to render");
|
|
86414
86875
|
}
|
|
86415
86876
|
const renderBudgetMs = output === "turntable" ? 30 * 6e4 : 10 * 6e4;
|
|
@@ -86427,10 +86888,10 @@ async function startServer() {
|
|
|
86427
86888
|
environment: "studio",
|
|
86428
86889
|
...output === "turntable" ? { "duration-seconds": 12, fps: 24, "width-pixels": 1280, "height-pixels": 720 } : { quality, "width-pixels": 1920, "height-pixels": 1080 }
|
|
86429
86890
|
}, { timeoutMs: renderBudgetMs });
|
|
86430
|
-
if (!(0,
|
|
86891
|
+
if (!(0, import_node_fs62.existsSync)(artifactPath) || (0, import_node_fs62.statSync)(artifactPath).size === 0) {
|
|
86431
86892
|
throw new Error(`the ${viewpoint} render reported success but produced no image`);
|
|
86432
86893
|
}
|
|
86433
|
-
const bytes = (0,
|
|
86894
|
+
const bytes = (0, import_node_fs62.readFileSync)(artifactPath);
|
|
86434
86895
|
const sourceSuffix = "source" in projectSnapshot && projectSnapshot.source ? `-${projectSnapshot.source.filenameLabel.replace(/[^A-Za-z0-9._-]+/g, "-")}` : "";
|
|
86435
86896
|
const preferred = `${exportFileBase(project, appId)}-${viewpoint}${sourceSuffix}${extension}`;
|
|
86436
86897
|
const filename = uniqueProjectExportFilename(project, preferred);
|
|
@@ -86486,7 +86947,7 @@ async function startServer() {
|
|
|
86486
86947
|
rendered
|
|
86487
86948
|
});
|
|
86488
86949
|
} finally {
|
|
86489
|
-
(0,
|
|
86950
|
+
(0, import_node_fs62.rmSync)(scratch, { recursive: true, force: true });
|
|
86490
86951
|
}
|
|
86491
86952
|
}, {
|
|
86492
86953
|
// What anyone blocked on this project is told, and for how long to expect it. Erring long
|
|
@@ -86727,7 +87188,7 @@ async function startServer() {
|
|
|
86727
87188
|
const outPath = project ? (0, import_node_path59.join)(projectExportsDir(project), filename) : bomExportPath(appId, format);
|
|
86728
87189
|
const dir = (0, import_node_path59.dirname)(outPath);
|
|
86729
87190
|
try {
|
|
86730
|
-
(0,
|
|
87191
|
+
(0, import_node_fs62.mkdirSync)(dir, { recursive: true });
|
|
86731
87192
|
const kind = BOM_EXPORT_KIND[format];
|
|
86732
87193
|
let text3 = null;
|
|
86733
87194
|
let buf;
|
|
@@ -86755,8 +87216,8 @@ async function startServer() {
|
|
|
86755
87216
|
sourceKind: projectSnapshot.source?.kind ?? "approved",
|
|
86756
87217
|
contractHash: projectSnapshot.contractHash
|
|
86757
87218
|
}, buf);
|
|
86758
|
-
} else if (text3 != null) (0,
|
|
86759
|
-
else (0,
|
|
87219
|
+
} else if (text3 != null) (0, import_node_fs62.writeFileSync)(outPath, text3, "utf8");
|
|
87220
|
+
else (0, import_node_fs62.writeFileSync)(outPath, buf);
|
|
86760
87221
|
return {
|
|
86761
87222
|
ok: true,
|
|
86762
87223
|
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 +87257,7 @@ async function startServer() {
|
|
|
86796
87257
|
const filename = project ? uniqueProjectExportFilename(project, preferredFilename) : preferredFilename;
|
|
86797
87258
|
const outPath = project ? (0, import_node_path59.join)(projectExportsDir(project), filename) : (0, import_node_path59.join)(appPath(appId), filename);
|
|
86798
87259
|
try {
|
|
86799
|
-
(0,
|
|
87260
|
+
(0, import_node_fs62.mkdirSync)((0, import_node_path59.dirname)(outPath), { recursive: true });
|
|
86800
87261
|
if (project && projectSnapshot) {
|
|
86801
87262
|
publishProjectExportArtifact(project, {
|
|
86802
87263
|
kind: "svg",
|
|
@@ -86807,7 +87268,7 @@ async function startServer() {
|
|
|
86807
87268
|
sourceKind: projectSnapshot.source?.kind ?? "approved",
|
|
86808
87269
|
contractHash: projectSnapshot.contractHash
|
|
86809
87270
|
}, Buffer.from(svg, "utf8"));
|
|
86810
|
-
} else (0,
|
|
87271
|
+
} else (0, import_node_fs62.writeFileSync)(outPath, svg, "utf8");
|
|
86811
87272
|
return { ok: true, filename, encoding: "utf8", content: svg, bytes: Buffer.byteLength(svg), savedTo: outPath };
|
|
86812
87273
|
} catch (e) {
|
|
86813
87274
|
app.log.error({ appId, err: e instanceof Error ? e.message : e }, "export-svg: write failed");
|
|
@@ -86989,11 +87450,11 @@ async function startServer() {
|
|
|
86989
87450
|
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
87451
|
}
|
|
86991
87452
|
await deleteOrigin(id);
|
|
86992
|
-
const stageRoot = (0,
|
|
87453
|
+
const stageRoot = (0, import_node_fs62.mkdtempSync)((0, import_node_path59.join)((0, import_node_os29.tmpdir)(), "floless-import-"));
|
|
86993
87454
|
try {
|
|
86994
87455
|
const stageDir = (0, import_node_path59.join)(stageRoot, id);
|
|
86995
|
-
(0,
|
|
86996
|
-
(0,
|
|
87456
|
+
(0, import_node_fs62.mkdirSync)(stageDir);
|
|
87457
|
+
(0, import_node_fs62.writeFileSync)((0, import_node_path59.join)(stageDir, `${id}.flo`), content);
|
|
86997
87458
|
await aware.install(stageDir);
|
|
86998
87459
|
} catch (err2) {
|
|
86999
87460
|
try {
|
|
@@ -87004,7 +87465,7 @@ async function startServer() {
|
|
|
87004
87465
|
const reason = awareStderr(err2);
|
|
87005
87466
|
return reply.status(502).send({ ok: false, error: `import failed: ${msg}`, code: "install-failed", reason, agentsUnavailable: unavailableAgents(reason) });
|
|
87006
87467
|
} finally {
|
|
87007
|
-
(0,
|
|
87468
|
+
(0, import_node_fs62.rmSync)(stageRoot, { recursive: true, force: true });
|
|
87008
87469
|
}
|
|
87009
87470
|
broadcast({ type: "apps-changed", id });
|
|
87010
87471
|
return { ok: true, id };
|
|
@@ -87020,13 +87481,13 @@ async function startServer() {
|
|
|
87020
87481
|
}
|
|
87021
87482
|
const inputs = appData.inputs.map((i) => ({ name: i.name, type: i.type }));
|
|
87022
87483
|
const baked = bakeFloSource(appData.source.text, inputs);
|
|
87023
|
-
const tmpRoot = (0,
|
|
87484
|
+
const tmpRoot = (0, import_node_fs62.mkdtempSync)((0, import_node_path59.join)((0, import_node_os29.tmpdir)(), "floless-bake-"));
|
|
87024
87485
|
const backupDir2 = (0, import_node_path59.join)(tmpRoot, `${id}-backup`);
|
|
87025
87486
|
const bakeDir = (0, import_node_path59.join)(tmpRoot, id);
|
|
87026
|
-
(0,
|
|
87027
|
-
(0,
|
|
87487
|
+
(0, import_node_fs62.cpSync)(appDir(id), backupDir2, { recursive: true });
|
|
87488
|
+
(0, import_node_fs62.cpSync)(appDir(id), bakeDir, { recursive: true });
|
|
87028
87489
|
const floName = appData.source.path.split(/[\\/]/).pop();
|
|
87029
|
-
(0,
|
|
87490
|
+
(0, import_node_fs62.writeFileSync)((0, import_node_path59.join)(bakeDir, floName), baked);
|
|
87030
87491
|
let appInstalled2 = true;
|
|
87031
87492
|
try {
|
|
87032
87493
|
await aware.uninstall(id);
|
|
@@ -87055,7 +87516,7 @@ async function startServer() {
|
|
|
87055
87516
|
broadcast({ type: "baked", id });
|
|
87056
87517
|
return { ok: true, id, agent: id, inputs };
|
|
87057
87518
|
} finally {
|
|
87058
|
-
if (appInstalled2) (0,
|
|
87519
|
+
if (appInstalled2) (0, import_node_fs62.rmSync)(tmpRoot, { recursive: true, force: true });
|
|
87059
87520
|
}
|
|
87060
87521
|
});
|
|
87061
87522
|
});
|
|
@@ -87076,7 +87537,7 @@ async function startServer() {
|
|
|
87076
87537
|
if (!sourceKind || !sourceRef) {
|
|
87077
87538
|
return reply.status(400).send({ ok: false, error: "sourceKind and sourceRef required" });
|
|
87078
87539
|
}
|
|
87079
|
-
const tempHome = (0,
|
|
87540
|
+
const tempHome = (0, import_node_fs62.mkdtempSync)((0, import_node_path59.join)((0, import_node_os29.tmpdir)(), "floless-graft-"));
|
|
87080
87541
|
let result;
|
|
87081
87542
|
try {
|
|
87082
87543
|
result = await aware.build({
|
|
@@ -87089,19 +87550,19 @@ async function startServer() {
|
|
|
87089
87550
|
awareHome: tempHome
|
|
87090
87551
|
});
|
|
87091
87552
|
} catch (err2) {
|
|
87092
|
-
(0,
|
|
87553
|
+
(0, import_node_fs62.rmSync)(tempHome, { recursive: true, force: true });
|
|
87093
87554
|
const msg = err2 instanceof AwareError ? err2.message : String(err2?.message ?? err2);
|
|
87094
87555
|
return reply.status(422).send({ ok: false, error: msg });
|
|
87095
87556
|
}
|
|
87096
87557
|
const manifest = readStagedManifest(result.agentDir);
|
|
87097
87558
|
if (!manifest) {
|
|
87098
|
-
(0,
|
|
87559
|
+
(0, import_node_fs62.rmSync)(tempHome, { recursive: true, force: true });
|
|
87099
87560
|
return reply.status(502).send({ ok: false, error: `build produced output at ${result.agentDir} but no manifest.yaml` });
|
|
87100
87561
|
}
|
|
87101
87562
|
const token2 = (0, import_node_crypto33.randomUUID)();
|
|
87102
87563
|
registerStage(token2, tempHome, result.agentId);
|
|
87103
87564
|
const preview2 = buildPreview(manifest, sourceKind, sourceRef, token2);
|
|
87104
|
-
if ((0,
|
|
87565
|
+
if ((0, import_node_fs62.existsSync)((0, import_node_path59.join)(graftAgentsDir(), result.agentId))) {
|
|
87105
87566
|
preview2.warnings.unshift(`An agent named "${result.agentId}" is already installed \u2014 creating it will overwrite it.`);
|
|
87106
87567
|
}
|
|
87107
87568
|
return { ok: true, preview: preview2 };
|
|
@@ -87120,7 +87581,7 @@ async function startServer() {
|
|
|
87120
87581
|
registerStage(stagedRef, stage.tempDir, stage.agentId);
|
|
87121
87582
|
return reply.status(409).send({ ok: false, error: err2.message, agentId: stage.agentId, collision: true });
|
|
87122
87583
|
}
|
|
87123
|
-
(0,
|
|
87584
|
+
(0, import_node_fs62.rmSync)(stage.tempDir, { recursive: true, force: true });
|
|
87124
87585
|
throw err2;
|
|
87125
87586
|
}
|
|
87126
87587
|
broadcast({ type: "grafted", id: stage.agentId });
|
|
@@ -87442,11 +87903,11 @@ async function startServer() {
|
|
|
87442
87903
|
app.get("/api/requests/:id/snapshot/:n", async (req, reply) => {
|
|
87443
87904
|
const n = Number.parseInt(req.params.n, 10);
|
|
87444
87905
|
const p = Number.isInteger(n) ? snapshotPathFor(req.params.id, n) : null;
|
|
87445
|
-
if (!p || !(0,
|
|
87906
|
+
if (!p || !(0, import_node_fs62.existsSync)(p)) return reply.status(404).send({ ok: false, error: "snapshot not found" });
|
|
87446
87907
|
const ext = p.split(".").pop().toLowerCase();
|
|
87447
87908
|
reply.header("Content-Type", ext === "png" ? "image/png" : ext === "webp" ? "image/webp" : ext === "pdf" ? "application/pdf" : "image/jpeg");
|
|
87448
87909
|
reply.header("Cache-Control", "no-store");
|
|
87449
|
-
return (0,
|
|
87910
|
+
return (0, import_node_fs62.readFileSync)(p);
|
|
87450
87911
|
});
|
|
87451
87912
|
app.post(
|
|
87452
87913
|
"/api/tweak",
|
|
@@ -87675,7 +88136,7 @@ async function startServer() {
|
|
|
87675
88136
|
warn(`last-run-status:${ref} \u2014 trace exists but couldn't be parsed (corrupt/truncated)`);
|
|
87676
88137
|
let finishedAt2 = null;
|
|
87677
88138
|
try {
|
|
87678
|
-
finishedAt2 = (0,
|
|
88139
|
+
finishedAt2 = (0, import_node_fs62.statSync)(latest.path).mtime.toISOString();
|
|
87679
88140
|
} catch {
|
|
87680
88141
|
finishedAt2 = null;
|
|
87681
88142
|
}
|
|
@@ -87685,7 +88146,7 @@ async function startServer() {
|
|
|
87685
88146
|
let finishedAt = typeof runEnd?.ts === "string" ? runEnd.ts : null;
|
|
87686
88147
|
if (!finishedAt) {
|
|
87687
88148
|
try {
|
|
87688
|
-
finishedAt = (0,
|
|
88149
|
+
finishedAt = (0, import_node_fs62.statSync)(latest.path).mtime.toISOString();
|
|
87689
88150
|
} catch {
|
|
87690
88151
|
finishedAt = null;
|
|
87691
88152
|
}
|