@floless/app 0.109.3 → 0.110.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/floless-server.cjs +1120 -136
- package/dist/skills/floless-app-steel-model/SKILL.md +117 -2
- package/dist/web/app.css +51 -1
- package/dist/web/aware.js +125 -11
- package/dist/web/steel-3d-view.js +19 -6
- package/launch.mjs +63 -16
- package/package.json +2 -2
package/dist/floless-server.cjs
CHANGED
|
@@ -8628,69 +8628,69 @@ var require_error_serializer = __commonJS({
|
|
|
8628
8628
|
const obj2 = input && typeof input.toJSON === "function" ? input.toJSON() : input;
|
|
8629
8629
|
if (obj2 === null) return JSON_STR_EMPTY_OBJECT;
|
|
8630
8630
|
let value;
|
|
8631
|
-
let
|
|
8631
|
+
let json2 = JSON_STR_BEGIN_OBJECT;
|
|
8632
8632
|
let addComma = false;
|
|
8633
8633
|
value = obj2["statusCode"];
|
|
8634
8634
|
if (value !== void 0) {
|
|
8635
|
-
!addComma && (addComma = true) || (
|
|
8636
|
-
|
|
8637
|
-
|
|
8635
|
+
!addComma && (addComma = true) || (json2 += JSON_STR_COMMA);
|
|
8636
|
+
json2 += '"statusCode":';
|
|
8637
|
+
json2 += asNumber(value);
|
|
8638
8638
|
}
|
|
8639
8639
|
value = obj2["code"];
|
|
8640
8640
|
if (value !== void 0) {
|
|
8641
|
-
!addComma && (addComma = true) || (
|
|
8642
|
-
|
|
8641
|
+
!addComma && (addComma = true) || (json2 += JSON_STR_COMMA);
|
|
8642
|
+
json2 += '"code":';
|
|
8643
8643
|
if (typeof value !== "string") {
|
|
8644
8644
|
if (value === null) {
|
|
8645
|
-
|
|
8645
|
+
json2 += JSON_STR_EMPTY_STRING;
|
|
8646
8646
|
} else if (value instanceof Date) {
|
|
8647
|
-
|
|
8647
|
+
json2 += JSON_STR_QUOTE + value.toISOString() + JSON_STR_QUOTE;
|
|
8648
8648
|
} else if (value instanceof RegExp) {
|
|
8649
|
-
|
|
8649
|
+
json2 += asString(value.source);
|
|
8650
8650
|
} else {
|
|
8651
|
-
|
|
8651
|
+
json2 += asString(value.toString());
|
|
8652
8652
|
}
|
|
8653
8653
|
} else {
|
|
8654
|
-
|
|
8654
|
+
json2 += asString(value);
|
|
8655
8655
|
}
|
|
8656
8656
|
}
|
|
8657
8657
|
value = obj2["error"];
|
|
8658
8658
|
if (value !== void 0) {
|
|
8659
|
-
!addComma && (addComma = true) || (
|
|
8660
|
-
|
|
8659
|
+
!addComma && (addComma = true) || (json2 += JSON_STR_COMMA);
|
|
8660
|
+
json2 += '"error":';
|
|
8661
8661
|
if (typeof value !== "string") {
|
|
8662
8662
|
if (value === null) {
|
|
8663
|
-
|
|
8663
|
+
json2 += JSON_STR_EMPTY_STRING;
|
|
8664
8664
|
} else if (value instanceof Date) {
|
|
8665
|
-
|
|
8665
|
+
json2 += JSON_STR_QUOTE + value.toISOString() + JSON_STR_QUOTE;
|
|
8666
8666
|
} else if (value instanceof RegExp) {
|
|
8667
|
-
|
|
8667
|
+
json2 += asString(value.source);
|
|
8668
8668
|
} else {
|
|
8669
|
-
|
|
8669
|
+
json2 += asString(value.toString());
|
|
8670
8670
|
}
|
|
8671
8671
|
} else {
|
|
8672
|
-
|
|
8672
|
+
json2 += asString(value);
|
|
8673
8673
|
}
|
|
8674
8674
|
}
|
|
8675
8675
|
value = obj2["message"];
|
|
8676
8676
|
if (value !== void 0) {
|
|
8677
|
-
!addComma && (addComma = true) || (
|
|
8678
|
-
|
|
8677
|
+
!addComma && (addComma = true) || (json2 += JSON_STR_COMMA);
|
|
8678
|
+
json2 += '"message":';
|
|
8679
8679
|
if (typeof value !== "string") {
|
|
8680
8680
|
if (value === null) {
|
|
8681
|
-
|
|
8681
|
+
json2 += JSON_STR_EMPTY_STRING;
|
|
8682
8682
|
} else if (value instanceof Date) {
|
|
8683
|
-
|
|
8683
|
+
json2 += JSON_STR_QUOTE + value.toISOString() + JSON_STR_QUOTE;
|
|
8684
8684
|
} else if (value instanceof RegExp) {
|
|
8685
|
-
|
|
8685
|
+
json2 += asString(value.source);
|
|
8686
8686
|
} else {
|
|
8687
|
-
|
|
8687
|
+
json2 += asString(value.toString());
|
|
8688
8688
|
}
|
|
8689
8689
|
} else {
|
|
8690
|
-
|
|
8690
|
+
json2 += asString(value);
|
|
8691
8691
|
}
|
|
8692
8692
|
}
|
|
8693
|
-
return
|
|
8693
|
+
return json2 + JSON_STR_END_OBJECT;
|
|
8694
8694
|
}
|
|
8695
8695
|
const main2 = anonymous0;
|
|
8696
8696
|
return main2;
|
|
@@ -25193,7 +25193,7 @@ var require_cmp = __commonJS({
|
|
|
25193
25193
|
var gte = require_gte();
|
|
25194
25194
|
var lt = require_lt();
|
|
25195
25195
|
var lte = require_lte();
|
|
25196
|
-
var
|
|
25196
|
+
var cmp2 = (a, op, b, loose) => {
|
|
25197
25197
|
switch (op) {
|
|
25198
25198
|
case "===":
|
|
25199
25199
|
if (typeof a === "object") {
|
|
@@ -25229,7 +25229,7 @@ var require_cmp = __commonJS({
|
|
|
25229
25229
|
throw new TypeError(`Invalid operator: ${op}`);
|
|
25230
25230
|
}
|
|
25231
25231
|
};
|
|
25232
|
-
module2.exports =
|
|
25232
|
+
module2.exports = cmp2;
|
|
25233
25233
|
}
|
|
25234
25234
|
});
|
|
25235
25235
|
|
|
@@ -25796,7 +25796,7 @@ var require_comparator = __commonJS({
|
|
|
25796
25796
|
return false;
|
|
25797
25797
|
}
|
|
25798
25798
|
}
|
|
25799
|
-
return
|
|
25799
|
+
return cmp2(version, this.operator, this.semver, this.options);
|
|
25800
25800
|
}
|
|
25801
25801
|
intersects(comp, options) {
|
|
25802
25802
|
if (!(comp instanceof _Comparator)) {
|
|
@@ -25829,10 +25829,10 @@ var require_comparator = __commonJS({
|
|
|
25829
25829
|
if (this.semver.version === comp.semver.version && this.operator.includes("=") && comp.operator.includes("=")) {
|
|
25830
25830
|
return true;
|
|
25831
25831
|
}
|
|
25832
|
-
if (
|
|
25832
|
+
if (cmp2(this.semver, "<", comp.semver, options) && this.operator.startsWith(">") && comp.operator.startsWith("<")) {
|
|
25833
25833
|
return true;
|
|
25834
25834
|
}
|
|
25835
|
-
if (
|
|
25835
|
+
if (cmp2(this.semver, ">", comp.semver, options) && this.operator.startsWith("<") && comp.operator.startsWith(">")) {
|
|
25836
25836
|
return true;
|
|
25837
25837
|
}
|
|
25838
25838
|
return false;
|
|
@@ -25841,7 +25841,7 @@ var require_comparator = __commonJS({
|
|
|
25841
25841
|
module2.exports = Comparator;
|
|
25842
25842
|
var parseOptions = require_parse_options();
|
|
25843
25843
|
var { safeRe: re, t } = require_re();
|
|
25844
|
-
var
|
|
25844
|
+
var cmp2 = require_cmp();
|
|
25845
25845
|
var debug = require_debug2();
|
|
25846
25846
|
var SemVer = require_semver();
|
|
25847
25847
|
var Range = require_range();
|
|
@@ -26352,7 +26352,7 @@ var require_semver2 = __commonJS({
|
|
|
26352
26352
|
var neq = require_neq();
|
|
26353
26353
|
var gte = require_gte();
|
|
26354
26354
|
var lte = require_lte();
|
|
26355
|
-
var
|
|
26355
|
+
var cmp2 = require_cmp();
|
|
26356
26356
|
var coerce = require_coerce();
|
|
26357
26357
|
var truncate = require_truncate();
|
|
26358
26358
|
var Comparator = require_comparator();
|
|
@@ -26391,7 +26391,7 @@ var require_semver2 = __commonJS({
|
|
|
26391
26391
|
neq,
|
|
26392
26392
|
gte,
|
|
26393
26393
|
lte,
|
|
26394
|
-
cmp,
|
|
26394
|
+
cmp: cmp2,
|
|
26395
26395
|
coerce,
|
|
26396
26396
|
truncate,
|
|
26397
26397
|
Comparator,
|
|
@@ -32061,7 +32061,7 @@ var require_parse_url = __commonJS({
|
|
|
32061
32061
|
var require_form_data = __commonJS({
|
|
32062
32062
|
"node_modules/light-my-request/lib/form-data.js"(exports2, module2) {
|
|
32063
32063
|
"use strict";
|
|
32064
|
-
var { randomUUID:
|
|
32064
|
+
var { randomUUID: randomUUID13 } = require("node:crypto");
|
|
32065
32065
|
var { Readable: Readable3 } = require("node:stream");
|
|
32066
32066
|
var textEncoder;
|
|
32067
32067
|
function isFormDataLike(payload) {
|
|
@@ -32069,7 +32069,7 @@ var require_form_data = __commonJS({
|
|
|
32069
32069
|
}
|
|
32070
32070
|
function formDataToStream(formdata) {
|
|
32071
32071
|
textEncoder = textEncoder ?? new TextEncoder();
|
|
32072
|
-
const boundary = `----formdata-${
|
|
32072
|
+
const boundary = `----formdata-${randomUUID13()}`;
|
|
32073
32073
|
const prefix = `--${boundary}\r
|
|
32074
32074
|
Content-Disposition: form-data`;
|
|
32075
32075
|
const escape2 = (str5) => str5.replace(/\n/g, "%0A").replace(/\r/g, "%0D").replace(/"/g, "%22");
|
|
@@ -44566,27 +44566,27 @@ var require_stringifyString = __commonJS({
|
|
|
44566
44566
|
return true;
|
|
44567
44567
|
}
|
|
44568
44568
|
function doubleQuotedString(value, ctx) {
|
|
44569
|
-
const
|
|
44569
|
+
const json2 = JSON.stringify(value);
|
|
44570
44570
|
if (ctx.options.doubleQuotedAsJSON)
|
|
44571
|
-
return
|
|
44571
|
+
return json2;
|
|
44572
44572
|
const { implicitKey } = ctx;
|
|
44573
44573
|
const minMultiLineLength = ctx.options.doubleQuotedMinMultiLineLength;
|
|
44574
44574
|
const indent = ctx.indent || (containsDocumentMarker(value) ? " " : "");
|
|
44575
44575
|
let str5 = "";
|
|
44576
44576
|
let start = 0;
|
|
44577
|
-
for (let i = 0, ch2 =
|
|
44578
|
-
if (ch2 === " " &&
|
|
44579
|
-
str5 +=
|
|
44577
|
+
for (let i = 0, ch2 = json2[i]; ch2; ch2 = json2[++i]) {
|
|
44578
|
+
if (ch2 === " " && json2[i + 1] === "\\" && json2[i + 2] === "n") {
|
|
44579
|
+
str5 += json2.slice(start, i) + "\\ ";
|
|
44580
44580
|
i += 1;
|
|
44581
44581
|
start = i;
|
|
44582
44582
|
ch2 = "\\";
|
|
44583
44583
|
}
|
|
44584
44584
|
if (ch2 === "\\")
|
|
44585
|
-
switch (
|
|
44585
|
+
switch (json2[i + 1]) {
|
|
44586
44586
|
case "u":
|
|
44587
44587
|
{
|
|
44588
|
-
str5 +=
|
|
44589
|
-
const code =
|
|
44588
|
+
str5 += json2.slice(start, i);
|
|
44589
|
+
const code = json2.substr(i + 2, 4);
|
|
44590
44590
|
switch (code) {
|
|
44591
44591
|
case "0000":
|
|
44592
44592
|
str5 += "\\0";
|
|
@@ -44616,23 +44616,23 @@ var require_stringifyString = __commonJS({
|
|
|
44616
44616
|
if (code.substr(0, 2) === "00")
|
|
44617
44617
|
str5 += "\\x" + code.substr(2);
|
|
44618
44618
|
else
|
|
44619
|
-
str5 +=
|
|
44619
|
+
str5 += json2.substr(i, 6);
|
|
44620
44620
|
}
|
|
44621
44621
|
i += 5;
|
|
44622
44622
|
start = i + 1;
|
|
44623
44623
|
}
|
|
44624
44624
|
break;
|
|
44625
44625
|
case "n":
|
|
44626
|
-
if (implicitKey ||
|
|
44626
|
+
if (implicitKey || json2[i + 2] === '"' || json2.length < minMultiLineLength) {
|
|
44627
44627
|
i += 1;
|
|
44628
44628
|
} else {
|
|
44629
|
-
str5 +=
|
|
44630
|
-
while (
|
|
44629
|
+
str5 += json2.slice(start, i) + "\n\n";
|
|
44630
|
+
while (json2[i + 2] === "\\" && json2[i + 3] === "n" && json2[i + 4] !== '"') {
|
|
44631
44631
|
str5 += "\n";
|
|
44632
44632
|
i += 2;
|
|
44633
44633
|
}
|
|
44634
44634
|
str5 += indent;
|
|
44635
|
-
if (
|
|
44635
|
+
if (json2[i + 2] === " ")
|
|
44636
44636
|
str5 += "\\";
|
|
44637
44637
|
i += 1;
|
|
44638
44638
|
start = i + 1;
|
|
@@ -44642,7 +44642,7 @@ var require_stringifyString = __commonJS({
|
|
|
44642
44642
|
i += 1;
|
|
44643
44643
|
}
|
|
44644
44644
|
}
|
|
44645
|
-
str5 = start ? str5 +
|
|
44645
|
+
str5 = start ? str5 + json2.slice(start) : json2;
|
|
44646
44646
|
return implicitKey ? str5 : foldFlowLines.foldFlowLines(str5, indent, foldFlowLines.FOLD_QUOTED, getFoldOptions(ctx, false));
|
|
44647
44647
|
}
|
|
44648
44648
|
function singleQuotedString(value, ctx) {
|
|
@@ -47064,11 +47064,11 @@ var require_Document = __commonJS({
|
|
|
47064
47064
|
throw new Error(`With a null YAML version, the { schema: Schema } option is required`);
|
|
47065
47065
|
}
|
|
47066
47066
|
// json & jsonArg are only used from toJSON()
|
|
47067
|
-
toJS({ json, jsonArg, mapAsMap, maxAliasCount, onAnchor, reviver } = {}) {
|
|
47067
|
+
toJS({ json: json2, jsonArg, mapAsMap, maxAliasCount, onAnchor, reviver } = {}) {
|
|
47068
47068
|
const ctx = {
|
|
47069
47069
|
anchors: /* @__PURE__ */ new Map(),
|
|
47070
47070
|
doc: this,
|
|
47071
|
-
keep: !
|
|
47071
|
+
keep: !json2,
|
|
47072
47072
|
mapAsMap: mapAsMap === true,
|
|
47073
47073
|
mapKeyWarned: false,
|
|
47074
47074
|
maxAliasCount: typeof maxAliasCount === "number" ? maxAliasCount : 100
|
|
@@ -53792,17 +53792,27 @@ function appVersion() {
|
|
|
53792
53792
|
return resolveVersion({
|
|
53793
53793
|
isSea: isSea2(),
|
|
53794
53794
|
sqVersionXml: readSqVersionXml(),
|
|
53795
|
-
define: true ? "0.
|
|
53795
|
+
define: true ? "0.110.0" : void 0,
|
|
53796
53796
|
pkgVersion: readPkgVersion()
|
|
53797
53797
|
});
|
|
53798
53798
|
}
|
|
53799
|
+
function isNpxPath(modulePath) {
|
|
53800
|
+
if (!modulePath) return false;
|
|
53801
|
+
return /(^|[\\/])_npx([\\/]|$)/.test(modulePath);
|
|
53802
|
+
}
|
|
53799
53803
|
function resolveChannel(s) {
|
|
53800
53804
|
if (s.isSea) return "desktop";
|
|
53801
|
-
if (typeof s.define === "string") return "npm";
|
|
53805
|
+
if (typeof s.define === "string") return isNpxPath(s.modulePath) ? "npx" : "npm";
|
|
53802
53806
|
return "dev";
|
|
53803
53807
|
}
|
|
53804
53808
|
function appChannel() {
|
|
53805
|
-
return resolveChannel({
|
|
53809
|
+
return resolveChannel({
|
|
53810
|
+
isSea: isSea2(),
|
|
53811
|
+
define: true ? "0.110.0" : void 0,
|
|
53812
|
+
// argv[1] is the entry the runtime actually loaded (…/dist/floless-server.cjs), which is what
|
|
53813
|
+
// carries the npx cache prefix. Absent under the SEA exe, which never reaches the npx branch.
|
|
53814
|
+
modulePath: process.argv[1]
|
|
53815
|
+
});
|
|
53806
53816
|
}
|
|
53807
53817
|
|
|
53808
53818
|
// workflow-update.ts
|
|
@@ -55115,9 +55125,46 @@ function xsectionFor(profile, dims) {
|
|
|
55115
55125
|
}
|
|
55116
55126
|
return rect;
|
|
55117
55127
|
}
|
|
55128
|
+
function oneSidedPly(half, t, s) {
|
|
55129
|
+
if (!plyFitsSection(t, half)) return null;
|
|
55130
|
+
const outer = -s * half;
|
|
55131
|
+
const sideDir = outer >= 0 ? 1 : -1;
|
|
55132
|
+
return { lapN: outer, sideDir, plyFarN: outer + sideDir * -t, ply: t, derived: true };
|
|
55133
|
+
}
|
|
55134
|
+
function plyFitsSection(t, half) {
|
|
55135
|
+
return t > 0 && t < 2 * half;
|
|
55136
|
+
}
|
|
55137
|
+
function bearingFaces(x, uOnN, vOnN, requestedSide) {
|
|
55138
|
+
const side = requestedSide >= 0 ? 1 : -1;
|
|
55139
|
+
const onU = Math.abs(Math.abs(uOnN) - 1) < 1e-9;
|
|
55140
|
+
const onV = Math.abs(Math.abs(vOnN) - 1) < 1e-9;
|
|
55141
|
+
if (!onU && !onV) return null;
|
|
55142
|
+
const sU = uOnN >= 0 ? 1 : -1;
|
|
55143
|
+
const sV = vOnN >= 0 ? 1 : -1;
|
|
55144
|
+
switch (x.shape) {
|
|
55145
|
+
case "i": {
|
|
55146
|
+
if (!onU) return null;
|
|
55147
|
+
if (!plyFitsSection(x.tw, x.bf / 2)) return null;
|
|
55148
|
+
return { lapN: side * x.tw / 2, sideDir: side, plyFarN: -side * x.tw / 2, ply: x.tw, derived: false };
|
|
55149
|
+
}
|
|
55150
|
+
case "channel": {
|
|
55151
|
+
if (!onU) return null;
|
|
55152
|
+
return oneSidedPly(x.bf / 2, x.tw, sU);
|
|
55153
|
+
}
|
|
55154
|
+
case "angle": {
|
|
55155
|
+
return onU ? oneSidedPly(x.b / 2, x.t, sU) : oneSidedPly(x.d / 2, x.t, sV);
|
|
55156
|
+
}
|
|
55157
|
+
// A closed section cannot be through-bolted by this detail — refuse rather than bolt into a void.
|
|
55158
|
+
case "rhs":
|
|
55159
|
+
case "chs":
|
|
55160
|
+
return null;
|
|
55161
|
+
case "rect":
|
|
55162
|
+
return null;
|
|
55163
|
+
}
|
|
55164
|
+
}
|
|
55118
55165
|
|
|
55119
55166
|
// index.ts
|
|
55120
|
-
var
|
|
55167
|
+
var import_node_crypto22 = require("node:crypto");
|
|
55121
55168
|
|
|
55122
55169
|
// ifc-guid.ts
|
|
55123
55170
|
var import_node_crypto7 = require("node:crypto");
|
|
@@ -55861,6 +55908,10 @@ function deleteRequest(id) {
|
|
|
55861
55908
|
(0, import_node_fs18.rmSync)((0, import_node_path16.join)(REQUESTS_DIR, file));
|
|
55862
55909
|
return true;
|
|
55863
55910
|
}
|
|
55911
|
+
function hasRequestFile(id) {
|
|
55912
|
+
if (!(0, import_node_fs18.existsSync)(REQUESTS_DIR)) return false;
|
|
55913
|
+
return (0, import_node_fs18.readdirSync)(REQUESTS_DIR).some((f) => f.endsWith(`__${id}.json`));
|
|
55914
|
+
}
|
|
55864
55915
|
function getRequest(id) {
|
|
55865
55916
|
if (!(0, import_node_fs18.existsSync)(REQUESTS_DIR)) return null;
|
|
55866
55917
|
const file = (0, import_node_fs18.readdirSync)(REQUESTS_DIR).find((f) => f.endsWith(`__${id}.json`));
|
|
@@ -56260,7 +56311,7 @@ function readContractForApp(appId, readAppFn = readApp) {
|
|
|
56260
56311
|
}
|
|
56261
56312
|
|
|
56262
56313
|
// project-versions-store.ts
|
|
56263
|
-
var
|
|
56314
|
+
var import_node_crypto12 = require("node:crypto");
|
|
56264
56315
|
var import_node_fs23 = require("node:fs");
|
|
56265
56316
|
var import_promises2 = require("node:fs/promises");
|
|
56266
56317
|
var import_node_path21 = require("node:path");
|
|
@@ -56270,7 +56321,7 @@ var import_node_fs22 = require("node:fs");
|
|
|
56270
56321
|
var import_promises = require("node:fs/promises");
|
|
56271
56322
|
var import_node_path20 = require("node:path");
|
|
56272
56323
|
var import_node_os15 = require("node:os");
|
|
56273
|
-
var
|
|
56324
|
+
var import_node_crypto11 = require("node:crypto");
|
|
56274
56325
|
|
|
56275
56326
|
// node_modules/fflate/esm/index.mjs
|
|
56276
56327
|
var import_module = require("module");
|
|
@@ -57616,8 +57667,27 @@ function unzipSync(data, opts) {
|
|
|
57616
57667
|
|
|
57617
57668
|
// revision-staging-store.ts
|
|
57618
57669
|
var import_node_fs21 = require("node:fs");
|
|
57670
|
+
var import_node_crypto10 = require("node:crypto");
|
|
57619
57671
|
var import_node_os14 = require("node:os");
|
|
57620
57672
|
var import_node_path19 = require("node:path");
|
|
57673
|
+
|
|
57674
|
+
// canonical-json.ts
|
|
57675
|
+
var import_node_crypto9 = require("node:crypto");
|
|
57676
|
+
function canonicalJson(v) {
|
|
57677
|
+
const walk2 = (x) => {
|
|
57678
|
+
if (Array.isArray(x)) return x.map(walk2);
|
|
57679
|
+
if (x && typeof x === "object") {
|
|
57680
|
+
const out = {};
|
|
57681
|
+
for (const k of Object.keys(x).sort()) out[k] = walk2(x[k]);
|
|
57682
|
+
return out;
|
|
57683
|
+
}
|
|
57684
|
+
return x;
|
|
57685
|
+
};
|
|
57686
|
+
return JSON.stringify(walk2(v) ?? null);
|
|
57687
|
+
}
|
|
57688
|
+
var hashOf = (v) => (0, import_node_crypto9.createHash)("sha256").update(canonicalJson(v)).digest("hex");
|
|
57689
|
+
|
|
57690
|
+
// revision-staging-store.ts
|
|
57621
57691
|
function root2() {
|
|
57622
57692
|
return process.env.FLOLESS_HOME ?? (0, import_node_path19.join)((0, import_node_os14.homedir)(), ".floless");
|
|
57623
57693
|
}
|
|
@@ -57630,12 +57700,56 @@ var safeStagingKey = (v) => {
|
|
|
57630
57700
|
return v;
|
|
57631
57701
|
};
|
|
57632
57702
|
var stagingDir = (key) => (0, import_node_path19.join)(stagingRoot(), safeStagingKey(key));
|
|
57703
|
+
var metaPath = (stagingKey) => (0, import_node_path19.join)(stagingDir(stagingKey), "staged.json");
|
|
57704
|
+
var docPath = (stagingKey) => (0, import_node_path19.join)(stagingDir(stagingKey), "candidate.json");
|
|
57705
|
+
function stageCandidate(stagingKey, candidate, meta) {
|
|
57706
|
+
const dir = stagingDir(stagingKey);
|
|
57707
|
+
(0, import_node_fs21.mkdirSync)(dir, { recursive: true });
|
|
57708
|
+
const bytes = JSON.stringify(candidate ?? null);
|
|
57709
|
+
const record2 = { stageId: (0, import_node_crypto10.randomUUID)(), ...meta, candidateHash: hashOf(candidate ?? null) };
|
|
57710
|
+
(0, import_node_fs21.writeFileSync)(docPath(stagingKey), bytes);
|
|
57711
|
+
(0, import_node_fs21.writeFileSync)(metaPath(stagingKey), JSON.stringify(record2, null, 2));
|
|
57712
|
+
return record2;
|
|
57713
|
+
}
|
|
57714
|
+
function readStaged(stagingKey) {
|
|
57715
|
+
const record2 = readStagedRecord(stagingKey);
|
|
57716
|
+
if (!record2) return null;
|
|
57717
|
+
if (!(0, import_node_fs21.existsSync)(docPath(stagingKey))) return null;
|
|
57718
|
+
const candidate = readStagedCandidate(stagingKey);
|
|
57719
|
+
if (hashOf(candidate ?? null) !== record2.candidateHash) return null;
|
|
57720
|
+
return { record: record2, candidate };
|
|
57721
|
+
}
|
|
57722
|
+
function readStagedRecord(stagingKey) {
|
|
57723
|
+
try {
|
|
57724
|
+
if (!(0, import_node_fs21.existsSync)(metaPath(stagingKey))) return null;
|
|
57725
|
+
const r = JSON.parse((0, import_node_fs21.readFileSync)(metaPath(stagingKey), "utf8"));
|
|
57726
|
+
return typeof r?.stageId === "string" && typeof r?.requestId === "string" ? r : null;
|
|
57727
|
+
} catch {
|
|
57728
|
+
return null;
|
|
57729
|
+
}
|
|
57730
|
+
}
|
|
57731
|
+
function readStagedCandidate(stagingKey) {
|
|
57732
|
+
try {
|
|
57733
|
+
if (!(0, import_node_fs21.existsSync)(docPath(stagingKey))) return null;
|
|
57734
|
+
return JSON.parse((0, import_node_fs21.readFileSync)(docPath(stagingKey), "utf8"));
|
|
57735
|
+
} catch {
|
|
57736
|
+
return null;
|
|
57737
|
+
}
|
|
57738
|
+
}
|
|
57633
57739
|
function dropStagingFor(stagingKey) {
|
|
57634
57740
|
try {
|
|
57635
57741
|
(0, import_node_fs21.rmSync)(stagingDir(stagingKey), { recursive: true, force: true });
|
|
57636
57742
|
} catch {
|
|
57637
57743
|
}
|
|
57638
57744
|
}
|
|
57745
|
+
function listStagedKeys() {
|
|
57746
|
+
try {
|
|
57747
|
+
if (!(0, import_node_fs21.existsSync)(stagingRoot())) return [];
|
|
57748
|
+
return (0, import_node_fs21.readdirSync)(stagingRoot()).filter((d) => STAGING_KEY.test(d));
|
|
57749
|
+
} catch {
|
|
57750
|
+
return [];
|
|
57751
|
+
}
|
|
57752
|
+
}
|
|
57639
57753
|
|
|
57640
57754
|
// projects-store.ts
|
|
57641
57755
|
var ProjectError = class extends Error {
|
|
@@ -57673,7 +57787,7 @@ function projectDir(id) {
|
|
|
57673
57787
|
function archiveDir(id) {
|
|
57674
57788
|
return (0, import_node_path20.join)(archiveRoot(), safeProjectId(id));
|
|
57675
57789
|
}
|
|
57676
|
-
function mintProjectId(name, draw = () => (0,
|
|
57790
|
+
function mintProjectId(name, draw = () => (0, import_node_crypto11.randomBytes)(3).toString("hex")) {
|
|
57677
57791
|
let id = `${slugify(name)}-${draw()}`;
|
|
57678
57792
|
while ((0, import_node_fs22.existsSync)(projectDir(id)) || (0, import_node_fs22.existsSync)(archiveDir(id))) id = `${slugify(name)}-${draw()}`;
|
|
57679
57793
|
return id;
|
|
@@ -57684,7 +57798,7 @@ function projectExportsDir(id) {
|
|
|
57684
57798
|
function projectKnowledgeDir(id) {
|
|
57685
57799
|
return (0, import_node_path20.join)(projectDir(id), "knowledge");
|
|
57686
57800
|
}
|
|
57687
|
-
var
|
|
57801
|
+
var metaPath2 = (id) => (0, import_node_path20.join)(projectDir(id), "project.json");
|
|
57688
57802
|
function readMetaFile(jsonPath, id) {
|
|
57689
57803
|
if (!(0, import_node_fs22.existsSync)(jsonPath)) return null;
|
|
57690
57804
|
try {
|
|
@@ -57698,11 +57812,11 @@ function readMetaFile(jsonPath, id) {
|
|
|
57698
57812
|
}
|
|
57699
57813
|
}
|
|
57700
57814
|
function readMeta(id) {
|
|
57701
|
-
return readMetaFile(
|
|
57815
|
+
return readMetaFile(metaPath2(id), id);
|
|
57702
57816
|
}
|
|
57703
57817
|
function writeMetaTo(dir, meta) {
|
|
57704
57818
|
const path = (0, import_node_path20.join)(dir, "project.json");
|
|
57705
|
-
const tmp = `${path}.${process.pid}.${(0,
|
|
57819
|
+
const tmp = `${path}.${process.pid}.${(0, import_node_crypto11.randomUUID)()}.tmp`;
|
|
57706
57820
|
(0, import_node_fs22.writeFileSync)(tmp, JSON.stringify(meta, null, 2));
|
|
57707
57821
|
(0, import_node_fs22.renameSync)(tmp, path);
|
|
57708
57822
|
}
|
|
@@ -57725,11 +57839,25 @@ async function getOrCreateProjectExportSourceId(id) {
|
|
|
57725
57839
|
const meta = readMeta(id);
|
|
57726
57840
|
if (!meta) throw new ProjectError(`unknown project: ${id}`);
|
|
57727
57841
|
if (typeof meta.exportSourceId === "string" && meta.exportSourceId.trim()) return meta.exportSourceId;
|
|
57728
|
-
const exportSourceId = (0,
|
|
57842
|
+
const exportSourceId = (0, import_node_crypto11.randomUUID)();
|
|
57729
57843
|
writeMeta({ ...meta, exportSourceId });
|
|
57730
57844
|
return exportSourceId;
|
|
57731
57845
|
});
|
|
57732
57846
|
}
|
|
57847
|
+
function getProjectStagingId(id) {
|
|
57848
|
+
const meta = readMeta(id);
|
|
57849
|
+
return typeof meta?.stagingId === "string" && meta.stagingId.trim() ? meta.stagingId : void 0;
|
|
57850
|
+
}
|
|
57851
|
+
async function getOrCreateProjectStagingId(id) {
|
|
57852
|
+
return withLifecycleLock("project", safeProjectId(id), () => {
|
|
57853
|
+
const meta = readMeta(id);
|
|
57854
|
+
if (!meta) throw new ProjectError(`unknown project: ${id}`);
|
|
57855
|
+
if (typeof meta.stagingId === "string" && meta.stagingId.trim()) return meta.stagingId;
|
|
57856
|
+
const stagingId = (0, import_node_crypto11.randomUUID)();
|
|
57857
|
+
writeMeta({ ...meta, stagingId });
|
|
57858
|
+
return stagingId;
|
|
57859
|
+
});
|
|
57860
|
+
}
|
|
57733
57861
|
function createProject(input) {
|
|
57734
57862
|
const name = typeof input.name === "string" ? input.name.trim() : "";
|
|
57735
57863
|
const app = typeof input.app === "string" ? input.app.trim() : "";
|
|
@@ -57738,7 +57866,7 @@ function createProject(input) {
|
|
|
57738
57866
|
const id = mintProjectId(name);
|
|
57739
57867
|
(0, import_node_fs22.mkdirSync)(projectDir(id), { recursive: true });
|
|
57740
57868
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
57741
|
-
const meta = { id, uuid: (0,
|
|
57869
|
+
const meta = { id, uuid: (0, import_node_crypto11.randomUUID)(), name, app, createdAt: now, updatedAt: now };
|
|
57742
57870
|
writeMeta(meta);
|
|
57743
57871
|
return meta;
|
|
57744
57872
|
}
|
|
@@ -57989,7 +58117,7 @@ function importProjectZip(data) {
|
|
|
57989
58117
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
57990
58118
|
const meta = {
|
|
57991
58119
|
id,
|
|
57992
|
-
uuid: (0,
|
|
58120
|
+
uuid: (0, import_node_crypto11.randomUUID)(),
|
|
57993
58121
|
name,
|
|
57994
58122
|
app,
|
|
57995
58123
|
createdAt: now,
|
|
@@ -58039,7 +58167,7 @@ function loadLog(id) {
|
|
|
58039
58167
|
function dehydrate(node, blobs) {
|
|
58040
58168
|
if (typeof node === "string") {
|
|
58041
58169
|
if (node.length > BLOB_MIN) {
|
|
58042
|
-
const hash2 = (0,
|
|
58170
|
+
const hash2 = (0, import_node_crypto12.createHash)("sha256").update(node).digest("hex");
|
|
58043
58171
|
blobs.set(hash2, node);
|
|
58044
58172
|
return { [BLOB_KEY]: hash2 };
|
|
58045
58173
|
}
|
|
@@ -58167,7 +58295,7 @@ async function readVersionSkeletonAsync(id, n) {
|
|
|
58167
58295
|
}
|
|
58168
58296
|
|
|
58169
58297
|
// project-contract-hash.ts
|
|
58170
|
-
var
|
|
58298
|
+
var import_node_crypto13 = require("node:crypto");
|
|
58171
58299
|
function stableJson(value) {
|
|
58172
58300
|
if (value === null || typeof value !== "object") return JSON.stringify(value);
|
|
58173
58301
|
if (Array.isArray(value)) return `[${value.map((v) => stableJson(v)).join(",")}]`;
|
|
@@ -58175,7 +58303,7 @@ function stableJson(value) {
|
|
|
58175
58303
|
return `{${Object.keys(obj2).sort().map((k) => `${JSON.stringify(k)}:${stableJson(obj2[k])}`).join(",")}}`;
|
|
58176
58304
|
}
|
|
58177
58305
|
function contractHash(contract) {
|
|
58178
|
-
return (0,
|
|
58306
|
+
return (0, import_node_crypto13.createHash)("sha256").update(stableJson(contract)).digest("hex");
|
|
58179
58307
|
}
|
|
58180
58308
|
|
|
58181
58309
|
// contract-gateway.ts
|
|
@@ -58364,7 +58492,7 @@ function clientCount() {
|
|
|
58364
58492
|
}
|
|
58365
58493
|
|
|
58366
58494
|
// knowledge-store.ts
|
|
58367
|
-
var
|
|
58495
|
+
var import_node_crypto14 = require("node:crypto");
|
|
58368
58496
|
var import_node_fs24 = require("node:fs");
|
|
58369
58497
|
var import_node_path22 = require("node:path");
|
|
58370
58498
|
var import_yaml6 = __toESM(require_dist6(), 1);
|
|
@@ -58414,7 +58542,7 @@ function writeManifest(id, manifest) {
|
|
|
58414
58542
|
const dir = projectKnowledgeDir(id);
|
|
58415
58543
|
(0, import_node_fs24.mkdirSync)(dir, { recursive: true });
|
|
58416
58544
|
const dest = manifestPath(id);
|
|
58417
|
-
const tmp = (0, import_node_path22.join)(dir, `.manifest.json.${process.pid}.${(0,
|
|
58545
|
+
const tmp = (0, import_node_path22.join)(dir, `.manifest.json.${process.pid}.${(0, import_node_crypto14.randomUUID)()}.tmp`);
|
|
58418
58546
|
(0, import_node_fs24.writeFileSync)(tmp, JSON.stringify(manifest, null, 2));
|
|
58419
58547
|
(0, import_node_fs24.renameSync)(tmp, dest);
|
|
58420
58548
|
}
|
|
@@ -58491,19 +58619,19 @@ function decodeUpload(inputs) {
|
|
|
58491
58619
|
}
|
|
58492
58620
|
function addSource(id, input) {
|
|
58493
58621
|
const { buf, mime, filename } = input;
|
|
58494
|
-
const sha2563 = (0,
|
|
58622
|
+
const sha2563 = (0, import_node_crypto14.createHash)("sha256").update(buf).digest("hex");
|
|
58495
58623
|
const dir = blobsDir(id);
|
|
58496
58624
|
(0, import_node_fs24.mkdirSync)(dir, { recursive: true });
|
|
58497
58625
|
const blobPath = blobPathFor(id, sha2563);
|
|
58498
58626
|
if (!(0, import_node_fs24.existsSync)(blobPath)) {
|
|
58499
|
-
const tmp = `${blobPath}.${process.pid}.${(0,
|
|
58627
|
+
const tmp = `${blobPath}.${process.pid}.${(0, import_node_crypto14.randomUUID)()}.tmp`;
|
|
58500
58628
|
(0, import_node_fs24.writeFileSync)(tmp, buf);
|
|
58501
58629
|
(0, import_node_fs24.renameSync)(tmp, blobPath);
|
|
58502
58630
|
}
|
|
58503
58631
|
const manifest = readManifest(id);
|
|
58504
58632
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
58505
58633
|
const row = {
|
|
58506
|
-
sourceId: (0,
|
|
58634
|
+
sourceId: (0, import_node_crypto14.randomUUID)(),
|
|
58507
58635
|
blobSha256: sha2563,
|
|
58508
58636
|
kind: "file",
|
|
58509
58637
|
filename,
|
|
@@ -58553,7 +58681,7 @@ function writeLockFile(id, lock) {
|
|
|
58553
58681
|
const dir = projectKnowledgeDir(id);
|
|
58554
58682
|
(0, import_node_fs24.mkdirSync)(dir, { recursive: true });
|
|
58555
58683
|
const dest = lockPath(id);
|
|
58556
|
-
const tmp = (0, import_node_path22.join)(dir, `.lock.json.${process.pid}.${(0,
|
|
58684
|
+
const tmp = (0, import_node_path22.join)(dir, `.lock.json.${process.pid}.${(0, import_node_crypto14.randomUUID)()}.tmp`);
|
|
58557
58685
|
(0, import_node_fs24.writeFileSync)(tmp, JSON.stringify(lock, null, 2));
|
|
58558
58686
|
(0, import_node_fs24.renameSync)(tmp, dest);
|
|
58559
58687
|
}
|
|
@@ -58614,7 +58742,7 @@ function assertGenerationId(generationId) {
|
|
|
58614
58742
|
}
|
|
58615
58743
|
}
|
|
58616
58744
|
function mintGenerationId() {
|
|
58617
|
-
return (0,
|
|
58745
|
+
return (0, import_node_crypto14.randomUUID)();
|
|
58618
58746
|
}
|
|
58619
58747
|
function generationWikiDir(id, generationId) {
|
|
58620
58748
|
assertGenerationId(generationId);
|
|
@@ -58627,7 +58755,7 @@ function publishGeneration(id, generationId) {
|
|
|
58627
58755
|
const dir = vaultDir(id);
|
|
58628
58756
|
(0, import_node_fs24.mkdirSync)(dir, { recursive: true });
|
|
58629
58757
|
const dest = currentGenerationPath(id);
|
|
58630
|
-
const tmp = (0, import_node_path22.join)(dir, `.current-generation.json.${process.pid}.${(0,
|
|
58758
|
+
const tmp = (0, import_node_path22.join)(dir, `.current-generation.json.${process.pid}.${(0, import_node_crypto14.randomUUID)()}.tmp`);
|
|
58631
58759
|
(0, import_node_fs24.writeFileSync)(tmp, JSON.stringify(pointer, null, 2));
|
|
58632
58760
|
(0, import_node_fs24.renameSync)(tmp, dest);
|
|
58633
58761
|
const manifest = readManifest(id);
|
|
@@ -58967,7 +59095,7 @@ function writeOrganizeFile(id, org) {
|
|
|
58967
59095
|
const dir = projectKnowledgeDir(id);
|
|
58968
59096
|
(0, import_node_fs24.mkdirSync)(dir, { recursive: true });
|
|
58969
59097
|
const dest = organizePath(id);
|
|
58970
|
-
const tmp = (0, import_node_path22.join)(dir, `.organize.json.${process.pid}.${(0,
|
|
59098
|
+
const tmp = (0, import_node_path22.join)(dir, `.organize.json.${process.pid}.${(0, import_node_crypto14.randomUUID)()}.tmp`);
|
|
58971
59099
|
(0, import_node_fs24.writeFileSync)(tmp, JSON.stringify(org, null, 2));
|
|
58972
59100
|
(0, import_node_fs24.renameSync)(tmp, dest);
|
|
58973
59101
|
}
|
|
@@ -59379,8 +59507,669 @@ function registerKnowledgeRoutes(app) {
|
|
|
59379
59507
|
);
|
|
59380
59508
|
}
|
|
59381
59509
|
|
|
59510
|
+
// steel-revision-registry.ts
|
|
59511
|
+
var IGNORED_INPUT = /* @__PURE__ */ new Set([
|
|
59512
|
+
"$.read_notes",
|
|
59513
|
+
"$.plans[].read_notes"
|
|
59514
|
+
]);
|
|
59515
|
+
var registryKeyOf = (reportedPath) => reportedPath.replace(/\[[^\]]*\]/g, "[]");
|
|
59516
|
+
var REGISTRY = /* @__PURE__ */ new Map([
|
|
59517
|
+
// ── canonical members ────────────────────────────────────────────────────────
|
|
59518
|
+
["$.members[]", { disposition: "propose", note: "a canonical member" }],
|
|
59519
|
+
// The MATCH KEY. Members are paired by id before diffing, so this can never differ within a pair;
|
|
59520
|
+
// it is listed so the coverage test sees a decision rather than an omission.
|
|
59521
|
+
["$.members[].id", { disposition: "issue", note: "the member identity, which pairs the documents \u2014 a change to it is an add plus a remove, not an edit" }],
|
|
59522
|
+
// Identity, geometry, engineering. `GUARDED_FIELDS` plus from/to/section, unchanged in meaning.
|
|
59523
|
+
["$.members[].profile", { disposition: "propose" }],
|
|
59524
|
+
["$.members[].material", { disposition: "propose" }],
|
|
59525
|
+
["$.members[].role", { disposition: "propose" }],
|
|
59526
|
+
["$.members[].memberType", { disposition: "propose" }],
|
|
59527
|
+
["$.members[].rot", { disposition: "propose" }],
|
|
59528
|
+
["$.members[].position", { disposition: "propose" }],
|
|
59529
|
+
["$.members[].from", { disposition: "propose" }],
|
|
59530
|
+
["$.members[].to", { disposition: "propose" }],
|
|
59531
|
+
["$.members[].section", { disposition: "propose" }],
|
|
59532
|
+
// P4a MEASURED these as the unenumerated set — real fields on real members that the flat list neither
|
|
59533
|
+
// permitted nor refused. They simply lost. This is the hole the registry exists to close.
|
|
59534
|
+
["$.members[].bf", { disposition: "propose", absenceEquivalent: false }],
|
|
59535
|
+
["$.members[].rfi", { disposition: "propose", absenceEquivalent: false }],
|
|
59536
|
+
["$.members[].mf", { disposition: "propose", absenceEquivalent: false }],
|
|
59537
|
+
["$.members[].brace", { disposition: "propose" }],
|
|
59538
|
+
// An AUTHORITY claim, and `propose` rather than `issue` DELIBERATELY — see the note below the table.
|
|
59539
|
+
["$.members[].verified", { disposition: "propose", absenceEquivalent: false }],
|
|
59540
|
+
// Server-stamped at apply time; the AI may not supply either. `$.members[].provenance` is an ENUM
|
|
59541
|
+
// (`read | revision-read | manual | migrated`), not request metadata — see the design §6.1.
|
|
59542
|
+
["$.members[].source", { disposition: "issue", note: "how the member was created is recorded by whatever created it, not by a revision read" }],
|
|
59543
|
+
["$.members[].provenance", { disposition: "issue", note: "how a member came to exist is stamped by the server, not asserted by the document" }],
|
|
59544
|
+
// ── member ends ──────────────────────────────────────────────────────────────
|
|
59545
|
+
// The one member property the classifier walks INTO rather than comparing whole, because its keys
|
|
59546
|
+
// carry different authority: `conn` is engineering intent, `connVerified` is a human's confirmation.
|
|
59547
|
+
["$.members[].ends", { disposition: "propose", descend: true, note: "per-end connection metadata" }],
|
|
59548
|
+
["$.members[].ends[]", { disposition: "propose", descend: true }],
|
|
59549
|
+
["$.members[].ends[].conn", { disposition: "propose" }],
|
|
59550
|
+
["$.members[].ends[].note", { disposition: "propose" }],
|
|
59551
|
+
["$.members[].ends[].detail", { disposition: "propose" }],
|
|
59552
|
+
["$.members[].ends[].connVerified", { disposition: "propose", absenceEquivalent: false }],
|
|
59553
|
+
// ── plans (sheets) ───────────────────────────────────────────────────────────
|
|
59554
|
+
// P4c-3 REFUSED every field on an existing sheet and said so in its own comment: plan-level revision
|
|
59555
|
+
// belonged to P6's stage -> review -> confirm rewrite, so inventing a plan-proposal shape a PR early
|
|
59556
|
+
// would have meant redesigning it a PR later. This is that PR (P6b), and these are the entries that
|
|
59557
|
+
// turn "refused, but at least surfaced" into "proposed, so a human can take it".
|
|
59558
|
+
//
|
|
59559
|
+
// The permitted set is the parent plan's (§4.3) and NOT one field wider: *"plan `elevation_in`/datum/
|
|
59560
|
+
// control/title; `memberRefs`"*. Everything else on a plan gets an EXPLICIT `issue` entry rather than
|
|
59561
|
+
// being left to the default — not because the default is wrong, but because the coverage test then
|
|
59562
|
+
// reads a decision instead of an omission, and a reviewer can see that each refusal was chosen.
|
|
59563
|
+
// No `descend`, matching `$.members[]` — and that symmetry is the measured answer, not a guess. The
|
|
59564
|
+
// first cut marked this `descend: true` on the assumption the coverage walk needed it to demand an
|
|
59565
|
+
// entry per plan field. A mutation deleting the flag left the whole suite green: the walk
|
|
59566
|
+
// short-circuits on "this path's parent IS the root", so `descend` is never consulted for a direct
|
|
59567
|
+
// child, and no plan property is a composite the classifier walks INTO (unlike `ends`). An inert flag
|
|
59568
|
+
// that reads as load-bearing is worse than no flag.
|
|
59569
|
+
["$.plans[]", { disposition: "propose", note: "a sheet" }],
|
|
59570
|
+
// The MATCH KEY, exactly like `$.members[].id`: plans are paired by sheet before diffing, so this can
|
|
59571
|
+
// never differ within a pair. Listed so the coverage test sees a decision.
|
|
59572
|
+
["$.plans[].sheet", { disposition: "issue", note: "the sheet name, which pairs the documents \u2014 a change to it is an add plus a remove, not an edit" }],
|
|
59573
|
+
// The canonical registration a revision read may genuinely move: where the cut plane sits, which grid
|
|
59574
|
+
// intersection anchors the sheet, what it is called, and which members it presents.
|
|
59575
|
+
["$.plans[].title", { disposition: "propose" }],
|
|
59576
|
+
["$.plans[].elevation_in", { disposition: "propose" }],
|
|
59577
|
+
["$.plans[].datum_at", { disposition: "propose" }],
|
|
59578
|
+
["$.plans[].datum_ref", { disposition: "propose" }],
|
|
59579
|
+
["$.plans[].control2_at", { disposition: "propose" }],
|
|
59580
|
+
["$.plans[].control2_ref", { disposition: "propose" }],
|
|
59581
|
+
["$.plans[].memberRefs", { disposition: "propose" }],
|
|
59582
|
+
// Drawing evidence. Write-once by §5.2 — a re-read mints new evidence, it does not edit the old trace
|
|
59583
|
+
// in place — so a revision read changing what the source looked like is a defect, not a proposal.
|
|
59584
|
+
["$.plans[].raster_b64", { disposition: "issue", note: "the page image is the evidence a read was made against; a later read attaches its own rather than rewriting it" }],
|
|
59585
|
+
["$.plans[].segments", { disposition: "issue", note: "the traced linework is evidence, and evidence is written once" }],
|
|
59586
|
+
["$.plans[].labels", { disposition: "issue", note: "the text read off the sheet is evidence, and evidence is written once" }],
|
|
59587
|
+
["$.plans[].clip", { disposition: "issue", note: "the crop applied to the source page belongs to the read that made it" }],
|
|
59588
|
+
// Authored by a HUMAN in the editor, and a revision read has no view on any of it.
|
|
59589
|
+
["$.plans[].details", { disposition: "issue", note: "placed details are authored in the editor, not read off the drawing" }],
|
|
59590
|
+
["$.plans[].callouts", { disposition: "issue", note: "detail callouts are authored in the editor" }],
|
|
59591
|
+
["$.plans[].tos_callouts", { disposition: "issue", note: "top-of-steel callouts are authored in the editor" }],
|
|
59592
|
+
["$.plans[].dims", { disposition: "issue", note: "dimensions are drawn by the user" }],
|
|
59593
|
+
// Derived by the server or by the editor's own passes — asserting them from a document would let an AI
|
|
59594
|
+
// claim work it did not do.
|
|
59595
|
+
["$.plans[].autofilled", { disposition: "issue", note: "whether a pass filled this sheet in is recorded by that pass" }],
|
|
59596
|
+
["$.plans[].deduped", { disposition: "issue", note: "whether duplicates were resolved is recorded by the pass that resolved them" }],
|
|
59597
|
+
// `pt_per_ft` and `frame` are the sheet->world registration. Deliberately NOT proposed, and this is a
|
|
59598
|
+
// judgement worth stating: changing either silently rescales or re-registers every work point on the
|
|
59599
|
+
// sheet, so the effect is nothing like the per-field edits above — it is a transform of all of them.
|
|
59600
|
+
// The parent's permitted list does not include them, and a PR whose subject is "let plans be revised"
|
|
59601
|
+
// is the wrong place to widen the list beyond what was authorised. Refused AND surfaced, so a real
|
|
59602
|
+
// scale correction is visible to the user rather than lost.
|
|
59603
|
+
["$.plans[].pt_per_ft", { disposition: "issue", note: "the sheet scale re-projects every work point on the plan, so it is not a field-level revision" }],
|
|
59604
|
+
["$.plans[].frame", { disposition: "issue", note: "the sheet-to-world registration re-places everything on the plan, so it is not a field-level revision" }],
|
|
59605
|
+
// Evidence, and the ONE plan property the classifier does not diff here at all: observations run
|
|
59606
|
+
// through their own three-pass admissibility path, which is where they are actually decided. `auto`
|
|
59607
|
+
// names the path a CLEAN new trace takes; measured, an incoming observation can equally land in
|
|
59608
|
+
// `issues` (a dozen codes across those passes) or in `bindingProposals`, and one omitted from an
|
|
59609
|
+
// existing sheet produces nothing at all. So this entry describes the dominant route, not a promise
|
|
59610
|
+
// about every observation — the first draft of this note said "that is what actually happens to
|
|
59611
|
+
// them", which is the happy path stated as the whole truth.
|
|
59612
|
+
//
|
|
59613
|
+
// The entry is INERT at runtime and exists to satisfy the plan coverage test: the classifier
|
|
59614
|
+
// `continue`s on this key before `entryFor` is ever called, and that `continue` is the load-bearing
|
|
59615
|
+
// line (removing it fails 19 tests, while changing this disposition fails none). Not `descend`, so
|
|
59616
|
+
// the coverage test does not demand an entry per observation field.
|
|
59617
|
+
["$.plans[].memberObservations", { disposition: "auto", note: "drawing evidence, classified per observation rather than as a plan field" }]
|
|
59618
|
+
]);
|
|
59619
|
+
function entryFor(registryKey, registry2 = REGISTRY) {
|
|
59620
|
+
const isAncestor = (key) => key !== registryKey && (registryKey.startsWith(key + ".") || registryKey.startsWith(key + "["));
|
|
59621
|
+
for (const [key, entry2] of registry2) {
|
|
59622
|
+
if (isAncestor(key) && entry2.disposition === "issue") return entry2;
|
|
59623
|
+
}
|
|
59624
|
+
return registry2.get(registryKey);
|
|
59625
|
+
}
|
|
59626
|
+
function valuesDiffer(before, after, entry2) {
|
|
59627
|
+
const fold = (v) => v === void 0 || v === null || entry2?.absenceEquivalent !== void 0 && v === entry2.absenceEquivalent ? null : v;
|
|
59628
|
+
const fa = fold(before), fb = fold(after);
|
|
59629
|
+
const rawA = JSON.stringify(fa), rawB = JSON.stringify(fb);
|
|
59630
|
+
if (rawA === rawB) return false;
|
|
59631
|
+
return canonicalJson(fa) !== canonicalJson(fb);
|
|
59632
|
+
}
|
|
59633
|
+
|
|
59634
|
+
// steel-model-revision.ts
|
|
59635
|
+
var SELECT_NOTHING = Object.freeze({
|
|
59636
|
+
proposals: Object.freeze([]),
|
|
59637
|
+
bindingProposals: Object.freeze([])
|
|
59638
|
+
});
|
|
59639
|
+
function assertsVerification(u) {
|
|
59640
|
+
if (u.to.status !== "active") return false;
|
|
59641
|
+
return claimDiffers(u.from.verified, u.to.verified);
|
|
59642
|
+
}
|
|
59643
|
+
var json = canonicalJson;
|
|
59644
|
+
var claimed = (v) => v === true;
|
|
59645
|
+
function claimDiffers(a, b) {
|
|
59646
|
+
const odd = (v) => v !== void 0 && typeof v !== "boolean";
|
|
59647
|
+
if (odd(a) || odd(b)) return true;
|
|
59648
|
+
return claimed(a) !== claimed(b);
|
|
59649
|
+
}
|
|
59650
|
+
function observationsOf(doc) {
|
|
59651
|
+
const out = /* @__PURE__ */ new Map();
|
|
59652
|
+
for (const plan of doc.plans ?? []) {
|
|
59653
|
+
for (const obs of plan.memberObservations ?? []) {
|
|
59654
|
+
if (!out.has(obs.id)) out.set(obs.id, { obs, sheet: plan.sheet });
|
|
59655
|
+
}
|
|
59656
|
+
}
|
|
59657
|
+
return out;
|
|
59658
|
+
}
|
|
59659
|
+
function transitionKind(from, to) {
|
|
59660
|
+
const a = from.status, b = to.status;
|
|
59661
|
+
if (a === "active" && b === "archived") return "archive";
|
|
59662
|
+
if (a === "active" && b === "superseded") return "supersede";
|
|
59663
|
+
if (a !== b) return null;
|
|
59664
|
+
const before = from.memberIds ?? [], after = to.memberIds ?? [];
|
|
59665
|
+
if (json(before) !== json(after)) {
|
|
59666
|
+
return after.length > before.length ? "split" : "rebind";
|
|
59667
|
+
}
|
|
59668
|
+
if (from.verified !== to.verified) return "verify";
|
|
59669
|
+
return null;
|
|
59670
|
+
}
|
|
59671
|
+
function withoutForgedVerification(obs, bindingProposals) {
|
|
59672
|
+
const binding = obs.binding;
|
|
59673
|
+
if (!binding || binding.status !== "active" || binding.verified !== true) return obs;
|
|
59674
|
+
const stripped = { ...binding };
|
|
59675
|
+
delete stripped.verified;
|
|
59676
|
+
bindingProposals.push({ observationId: obs.id, kind: "verify", from: structuredClone(stripped), to: structuredClone(binding) });
|
|
59677
|
+
return { ...obs, binding: stripped };
|
|
59678
|
+
}
|
|
59679
|
+
function withoutMemberClaims(m) {
|
|
59680
|
+
const endClaimed = (m.ends ?? []).some((e) => e && claimed(e.connVerified));
|
|
59681
|
+
if (!claimed(m.verified) && !endClaimed) return m;
|
|
59682
|
+
const { verified: _v2, ...rest } = m;
|
|
59683
|
+
return {
|
|
59684
|
+
...rest,
|
|
59685
|
+
...m.ends ? { ends: m.ends.map((e) => {
|
|
59686
|
+
const { connVerified: _c, ...er } = e ?? {};
|
|
59687
|
+
return er;
|
|
59688
|
+
}) } : {}
|
|
59689
|
+
};
|
|
59690
|
+
}
|
|
59691
|
+
function stageRevisionRead(current, incoming) {
|
|
59692
|
+
const accepted = [];
|
|
59693
|
+
const bindingUpdates = [];
|
|
59694
|
+
const bindingProposals = [];
|
|
59695
|
+
const proposals = [];
|
|
59696
|
+
const issues = [];
|
|
59697
|
+
const add = (path, code, message) => issues.push({ path, code, message });
|
|
59698
|
+
const curObs = observationsOf(current);
|
|
59699
|
+
const incMembers = new Map((incoming.members ?? []).map((m) => [m.id, m]));
|
|
59700
|
+
const curMembers = new Map((current.members ?? []).map((m) => [m.id, m]));
|
|
59701
|
+
const currentSheets = new Set((current.plans ?? []).map((p) => p.sheet));
|
|
59702
|
+
const ownIssues = /* @__PURE__ */ new Map();
|
|
59703
|
+
const order = [];
|
|
59704
|
+
const seenIncoming = /* @__PURE__ */ new Set();
|
|
59705
|
+
for (const plan of incoming.plans ?? []) {
|
|
59706
|
+
for (const obs of plan.memberObservations ?? []) {
|
|
59707
|
+
const path = `$.plans[${plan.sheet}].memberObservations[${obs.id}]`;
|
|
59708
|
+
const mine = [];
|
|
59709
|
+
const bad = (p, code, message) => mine.push({ path: p, code, message });
|
|
59710
|
+
if (seenIncoming.has(obs.id)) {
|
|
59711
|
+
bad(path, "observation-id-duplicate", `observation id "${obs.id}" occurs more than once in the incoming read`);
|
|
59712
|
+
}
|
|
59713
|
+
seenIncoming.add(obs.id);
|
|
59714
|
+
const citedSheet = obs.evidence?.source?.sheet;
|
|
59715
|
+
if (citedSheet === void 0) {
|
|
59716
|
+
bad(`${path}.evidence.source.sheet`, "observation-sheet-missing", "evidence names no source sheet, so it cannot be filed against a plan");
|
|
59717
|
+
} else if (citedSheet !== plan.sheet) {
|
|
59718
|
+
bad(`${path}.evidence.source.sheet`, "observation-sheet-mismatch", `evidence cites sheet "${citedSheet}" but lives on plan "${plan.sheet}"`);
|
|
59719
|
+
} else if (!currentSheets.has(plan.sheet)) {
|
|
59720
|
+
bad(`${path}.evidence.source.sheet`, "observation-depends-on-proposal", `sheet "${plan.sheet}" does not exist yet; its evidence cannot be accepted until the plan is confirmed`);
|
|
59721
|
+
}
|
|
59722
|
+
for (const id of obs.binding?.memberIds ?? []) {
|
|
59723
|
+
if (curMembers.has(id)) continue;
|
|
59724
|
+
if (incMembers.has(id)) {
|
|
59725
|
+
bad(`${path}.binding.memberIds`, "observation-depends-on-proposal", `"${id}" is a proposed new member; its evidence cannot be accepted until that member is confirmed`);
|
|
59726
|
+
} else {
|
|
59727
|
+
bad(`${path}.binding.memberIds`, "observation-member-unresolved", `"${id}" does not name a member`);
|
|
59728
|
+
}
|
|
59729
|
+
}
|
|
59730
|
+
ownIssues.set(obs.id, mine);
|
|
59731
|
+
order.push({ plan, obs, path });
|
|
59732
|
+
}
|
|
59733
|
+
}
|
|
59734
|
+
const admissible = new Set([...ownIssues].filter(([, v]) => v.length === 0).map(([k]) => k));
|
|
59735
|
+
const landing = [];
|
|
59736
|
+
const pendingUpdates = [];
|
|
59737
|
+
for (const { obs, path } of order) {
|
|
59738
|
+
const mine = ownIssues.get(obs.id) ?? [];
|
|
59739
|
+
issues.push(...mine);
|
|
59740
|
+
if (mine.length) continue;
|
|
59741
|
+
let rejected = false;
|
|
59742
|
+
for (const target of obs.evidence?.supersedes ?? []) {
|
|
59743
|
+
if (!curObs.has(target) && !admissible.has(target)) {
|
|
59744
|
+
add(`${path}.evidence.supersedes`, "supersedes-unresolved", `"${target}" does not name an observation that will exist after this read`);
|
|
59745
|
+
rejected = true;
|
|
59746
|
+
}
|
|
59747
|
+
}
|
|
59748
|
+
if (rejected) continue;
|
|
59749
|
+
const existing = curObs.get(obs.id);
|
|
59750
|
+
if (!existing) {
|
|
59751
|
+
landing.push({ obs, path });
|
|
59752
|
+
continue;
|
|
59753
|
+
}
|
|
59754
|
+
if (json(existing.obs.evidence) !== json(obs.evidence)) {
|
|
59755
|
+
add(`${path}.evidence`, "evidence-mutated", `observation "${obs.id}" already exists and its evidence differs; a re-read must mint a new observation carrying \`supersedes\` rather than edit immutable evidence in place`);
|
|
59756
|
+
continue;
|
|
59757
|
+
}
|
|
59758
|
+
const sameBinding = (a, b) => !claimDiffers(a.verified, b.verified) && json({ memberIds: a.memberIds ?? [], status: a.status }) === json({ memberIds: b.memberIds ?? [], status: b.status });
|
|
59759
|
+
if (sameBinding(existing.obs.binding, obs.binding)) continue;
|
|
59760
|
+
const kind = transitionKind(existing.obs.binding, obs.binding);
|
|
59761
|
+
if (kind === null) {
|
|
59762
|
+
add(`${path}.binding`, "binding-transition-illegal", `"${existing.obs.binding.status}" -> "${obs.binding.status}" is not a permitted binding transition`);
|
|
59763
|
+
continue;
|
|
59764
|
+
}
|
|
59765
|
+
pendingUpdates.push({ obs, path, kind, from: existing.obs.binding });
|
|
59766
|
+
}
|
|
59767
|
+
const candidates = new Map(landing.map((l) => [l.obs.id, l]));
|
|
59768
|
+
const supersedesOf = (obs) => obs.evidence?.supersedes ?? [];
|
|
59769
|
+
const orphanedBy = /* @__PURE__ */ new Map();
|
|
59770
|
+
for (; ; ) {
|
|
59771
|
+
const authorized = /* @__PURE__ */ new Set();
|
|
59772
|
+
for (const { obs } of candidates.values()) for (const t of supersedesOf(obs)) authorized.add(t);
|
|
59773
|
+
const retiring = /* @__PURE__ */ new Set();
|
|
59774
|
+
for (const p of pendingUpdates) if (p.kind === "supersede" && authorized.has(p.obs.id)) retiring.add(p.obs.id);
|
|
59775
|
+
const willBeSuperseded = (t) => retiring.has(t) || candidates.get(t)?.obs.binding?.status === "superseded" || curObs.get(t)?.obs.binding.status === "superseded";
|
|
59776
|
+
const drop = [];
|
|
59777
|
+
for (const entry2 of candidates.values()) {
|
|
59778
|
+
const orphaned = supersedesOf(entry2.obs).filter((t) => !willBeSuperseded(t));
|
|
59779
|
+
if (orphaned.length) {
|
|
59780
|
+
orphanedBy.set(entry2.obs.id, orphaned);
|
|
59781
|
+
drop.push(entry2);
|
|
59782
|
+
}
|
|
59783
|
+
}
|
|
59784
|
+
if (!drop.length) break;
|
|
59785
|
+
for (const d of drop) candidates.delete(d.obs.id);
|
|
59786
|
+
}
|
|
59787
|
+
{
|
|
59788
|
+
const WHITE = 0, GREY = 1, BLACK = 2;
|
|
59789
|
+
const colour = /* @__PURE__ */ new Map();
|
|
59790
|
+
const inCycle = /* @__PURE__ */ new Set();
|
|
59791
|
+
for (const root4 of candidates.keys()) {
|
|
59792
|
+
if ((colour.get(root4) ?? WHITE) !== WHITE) continue;
|
|
59793
|
+
const stack = [{ id: root4, edges: [...supersedesOf(candidates.get(root4).obs)], i: 0 }];
|
|
59794
|
+
colour.set(root4, GREY);
|
|
59795
|
+
while (stack.length) {
|
|
59796
|
+
const top = stack[stack.length - 1];
|
|
59797
|
+
if (top.i >= top.edges.length) {
|
|
59798
|
+
colour.set(top.id, BLACK);
|
|
59799
|
+
stack.pop();
|
|
59800
|
+
continue;
|
|
59801
|
+
}
|
|
59802
|
+
const next = top.edges[top.i++];
|
|
59803
|
+
if (!candidates.has(next)) continue;
|
|
59804
|
+
const state2 = colour.get(next) ?? WHITE;
|
|
59805
|
+
if (state2 === GREY) {
|
|
59806
|
+
for (const f of stack) inCycle.add(f.id);
|
|
59807
|
+
inCycle.add(next);
|
|
59808
|
+
continue;
|
|
59809
|
+
}
|
|
59810
|
+
if (state2 === BLACK) continue;
|
|
59811
|
+
colour.set(next, GREY);
|
|
59812
|
+
stack.push({ id: next, edges: [...supersedesOf(candidates.get(next).obs)], i: 0 });
|
|
59813
|
+
}
|
|
59814
|
+
}
|
|
59815
|
+
for (const id of inCycle) {
|
|
59816
|
+
const entry2 = candidates.get(id);
|
|
59817
|
+
if (!entry2) continue;
|
|
59818
|
+
add(`${entry2.path}.evidence.supersedes`, "supersedes-cycle", `observation "${id}" is part of a supersedes cycle; a lineage must be a DAG or "which evidence is current" has no answer`);
|
|
59819
|
+
candidates.delete(id);
|
|
59820
|
+
}
|
|
59821
|
+
}
|
|
59822
|
+
for (const { obs, path } of landing) {
|
|
59823
|
+
if (candidates.has(obs.id)) {
|
|
59824
|
+
accepted.push(withoutForgedVerification(obs, bindingProposals));
|
|
59825
|
+
continue;
|
|
59826
|
+
}
|
|
59827
|
+
const orphaned = orphanedBy.get(obs.id);
|
|
59828
|
+
if (orphaned) {
|
|
59829
|
+
add(`${path}.evidence.supersedes`, "supersedes-status", `"${obs.id}" supersedes ${orphaned.map((t) => `"${t}"`).join(", ")}, but that observation will still be active after this read; a replacement and the retirement it justifies stand or fall together`);
|
|
59830
|
+
}
|
|
59831
|
+
}
|
|
59832
|
+
const finalAuthorized = /* @__PURE__ */ new Set();
|
|
59833
|
+
for (const { obs } of candidates.values()) for (const t of supersedesOf(obs)) finalAuthorized.add(t);
|
|
59834
|
+
for (const p of pendingUpdates) {
|
|
59835
|
+
if (p.kind === "supersede" && !finalAuthorized.has(p.obs.id)) {
|
|
59836
|
+
add(`${p.path}.binding.status`, "supersede-without-replacement", `observation "${p.obs.id}" is being superseded but no acceptable incoming observation names it in \`evidence.supersedes\`; superseding without a replacement removes evidence from scoring with nothing put in its place`);
|
|
59837
|
+
continue;
|
|
59838
|
+
}
|
|
59839
|
+
const update = {
|
|
59840
|
+
observationId: p.obs.id,
|
|
59841
|
+
kind: p.kind,
|
|
59842
|
+
from: structuredClone(p.from),
|
|
59843
|
+
to: structuredClone(p.obs.binding)
|
|
59844
|
+
};
|
|
59845
|
+
(assertsVerification(update) ? bindingProposals : bindingUpdates).push(update);
|
|
59846
|
+
}
|
|
59847
|
+
for (const [id, m] of incMembers) {
|
|
59848
|
+
const before = curMembers.get(id);
|
|
59849
|
+
if (!before) {
|
|
59850
|
+
proposals.push({ kind: "member-added", memberId: id, member: withoutMemberClaims(m) });
|
|
59851
|
+
continue;
|
|
59852
|
+
}
|
|
59853
|
+
const fields = [];
|
|
59854
|
+
for (const key of /* @__PURE__ */ new Set([...Object.keys(before), ...Object.keys(m)])) {
|
|
59855
|
+
if (key === "ends") continue;
|
|
59856
|
+
const b = before[key];
|
|
59857
|
+
const a = m[key];
|
|
59858
|
+
const entry2 = entryFor(`$.members[].${key}`);
|
|
59859
|
+
if (!valuesDiffer(b, a, entry2)) continue;
|
|
59860
|
+
if (entry2?.disposition === "propose") fields.push({ key, before: b, after: a });
|
|
59861
|
+
else {
|
|
59862
|
+
add(
|
|
59863
|
+
`$.members[${id}].${key}`,
|
|
59864
|
+
"path-refused",
|
|
59865
|
+
`"${key}" may not be changed by a revision read${entry2?.note ? ` \u2014 ${entry2.note}` : ""}`
|
|
59866
|
+
);
|
|
59867
|
+
}
|
|
59868
|
+
}
|
|
59869
|
+
const beEnds = Array.isArray(before.ends) ? before.ends : [];
|
|
59870
|
+
const aeEnds = Array.isArray(m.ends) ? m.ends : [];
|
|
59871
|
+
if (before.ends !== void 0 && !Array.isArray(before.ends) || m.ends !== void 0 && !Array.isArray(m.ends)) {
|
|
59872
|
+
if (valuesDiffer(before.ends, m.ends)) {
|
|
59873
|
+
add(
|
|
59874
|
+
`$.members[${id}].ends`,
|
|
59875
|
+
"path-refused",
|
|
59876
|
+
'"ends" must be an array of per-end metadata; a revision read may not replace it with something else'
|
|
59877
|
+
);
|
|
59878
|
+
}
|
|
59879
|
+
}
|
|
59880
|
+
for (let i = 0; i < Math.max(beEnds.length, aeEnds.length); i++) {
|
|
59881
|
+
const be = beEnds[i] ?? {};
|
|
59882
|
+
const ae = aeEnds[i] ?? {};
|
|
59883
|
+
for (const key of /* @__PURE__ */ new Set([...Object.keys(be), ...Object.keys(ae)])) {
|
|
59884
|
+
const entry2 = entryFor(`$.members[].ends[].${key}`);
|
|
59885
|
+
if (!valuesDiffer(be[key], ae[key], entry2)) continue;
|
|
59886
|
+
if (entry2?.disposition === "propose") fields.push({ key: `ends[${i}].${key}`, before: be[key], after: ae[key] });
|
|
59887
|
+
else {
|
|
59888
|
+
add(
|
|
59889
|
+
`$.members[${id}].ends[${i}].${key}`,
|
|
59890
|
+
"path-refused-descendant",
|
|
59891
|
+
`"ends[${i}].${key}" may not be changed by a revision read${entry2?.note ? ` \u2014 ${entry2.note}` : ""}`
|
|
59892
|
+
);
|
|
59893
|
+
}
|
|
59894
|
+
}
|
|
59895
|
+
}
|
|
59896
|
+
if (fields.length) proposals.push({ kind: "member-changed", memberId: id, fields });
|
|
59897
|
+
}
|
|
59898
|
+
const incomingSheets = new Set((incoming.plans ?? []).map((p) => p.sheet));
|
|
59899
|
+
for (const sheet of currentSheets) {
|
|
59900
|
+
if (!incomingSheets.has(sheet)) {
|
|
59901
|
+
add(
|
|
59902
|
+
`$.plans[${sheet}]`,
|
|
59903
|
+
"path-refused",
|
|
59904
|
+
`sheet "${sheet}" is missing from the revision read; a revision may not remove a sheet \u2014 plan-level revision is not staged yet`
|
|
59905
|
+
);
|
|
59906
|
+
}
|
|
59907
|
+
}
|
|
59908
|
+
for (const id of curMembers.keys()) {
|
|
59909
|
+
if (!incMembers.has(id)) proposals.push({ kind: "member-removed", memberId: id });
|
|
59910
|
+
}
|
|
59911
|
+
const curPlans = new Map((current.plans ?? []).map((p) => [p.sheet, p]));
|
|
59912
|
+
const sheetCounts = /* @__PURE__ */ new Map();
|
|
59913
|
+
for (const plan of incoming.plans ?? []) sheetCounts.set(plan.sheet, (sheetCounts.get(plan.sheet) ?? 0) + 1);
|
|
59914
|
+
for (const [sheet, n] of sheetCounts) {
|
|
59915
|
+
if (n < 2) continue;
|
|
59916
|
+
add(
|
|
59917
|
+
`$.plans[${sheet}]`,
|
|
59918
|
+
"plan-sheet-duplicate",
|
|
59919
|
+
`sheet "${sheet}" appears ${n} times in the revision read; a sheet names one plan, so which of the copies is the revision has no answer \u2014 none of them is staged`
|
|
59920
|
+
);
|
|
59921
|
+
}
|
|
59922
|
+
for (const plan of incoming.plans ?? []) {
|
|
59923
|
+
if ((sheetCounts.get(plan.sheet) ?? 0) > 1) continue;
|
|
59924
|
+
const existing = curPlans.get(plan.sheet);
|
|
59925
|
+
if (existing) {
|
|
59926
|
+
const planFields = [];
|
|
59927
|
+
for (const key of /* @__PURE__ */ new Set([...Object.keys(existing), ...Object.keys(plan)])) {
|
|
59928
|
+
if (key === "memberObservations") continue;
|
|
59929
|
+
if (IGNORED_INPUT.has(registryKeyOf(`$.plans[${plan.sheet}].${key}`))) continue;
|
|
59930
|
+
const b = existing[key];
|
|
59931
|
+
const a = plan[key];
|
|
59932
|
+
const entry2 = entryFor(`$.plans[].${key}`);
|
|
59933
|
+
if (!valuesDiffer(b, a, entry2)) continue;
|
|
59934
|
+
if (entry2?.disposition === "propose") planFields.push({ key, before: b, after: a });
|
|
59935
|
+
else {
|
|
59936
|
+
add(
|
|
59937
|
+
`$.plans[${plan.sheet}].${key}`,
|
|
59938
|
+
"path-refused",
|
|
59939
|
+
`"${key}" on an existing sheet may not be changed by a revision read${entry2?.note ? ` \u2014 ${entry2.note}` : ""}`
|
|
59940
|
+
);
|
|
59941
|
+
}
|
|
59942
|
+
}
|
|
59943
|
+
if (planFields.length) proposals.push({ kind: "plan-changed", sheet: plan.sheet, fields: planFields });
|
|
59944
|
+
continue;
|
|
59945
|
+
}
|
|
59946
|
+
const { memberObservations: _refused, ...sheetOnly } = plan;
|
|
59947
|
+
proposals.push({ kind: "plan-added", sheet: plan.sheet, plan: sheetOnly });
|
|
59948
|
+
}
|
|
59949
|
+
const HANDLED_ROOT = /* @__PURE__ */ new Set(["members", "plans"]);
|
|
59950
|
+
const curRoot = current;
|
|
59951
|
+
const incRoot = incoming;
|
|
59952
|
+
for (const key of /* @__PURE__ */ new Set([...Object.keys(curRoot), ...Object.keys(incRoot)])) {
|
|
59953
|
+
if (HANDLED_ROOT.has(key)) continue;
|
|
59954
|
+
if (IGNORED_INPUT.has(registryKeyOf(`$.${key}`))) continue;
|
|
59955
|
+
if (!valuesDiffer(curRoot[key], incRoot[key])) continue;
|
|
59956
|
+
add(
|
|
59957
|
+
`$.${key}`,
|
|
59958
|
+
"path-refused",
|
|
59959
|
+
`"${key}" is model-level structure a revision read may not change \u2014 only members and their drawing evidence are staged here`
|
|
59960
|
+
);
|
|
59961
|
+
}
|
|
59962
|
+
return { accepted, bindingUpdates, bindingProposals, proposals, issues };
|
|
59963
|
+
}
|
|
59964
|
+
var RevisionApplyError = class extends Error {
|
|
59965
|
+
constructor(message) {
|
|
59966
|
+
super(message);
|
|
59967
|
+
this.name = "RevisionApplyError";
|
|
59968
|
+
}
|
|
59969
|
+
};
|
|
59970
|
+
var END_FIELD = /^ends\[(\d+)\]\.(.+)$/;
|
|
59971
|
+
function memberFieldTarget(field) {
|
|
59972
|
+
const m = field.key.match(END_FIELD);
|
|
59973
|
+
if (m && writableLeaf(`$.members[].ends[].${m[2]}`)) return { end: Number(m[1]), key: m[2] };
|
|
59974
|
+
if (writableLeaf(`$.members[].${field.key}`)) return { key: field.key };
|
|
59975
|
+
throw new RevisionApplyError(
|
|
59976
|
+
`applyStagedRevision: "${field.key}" is not a member field a revision read may change \u2014 the staged proposal does not match the registry`
|
|
59977
|
+
);
|
|
59978
|
+
}
|
|
59979
|
+
var writableLeaf = (registryKey) => {
|
|
59980
|
+
const e = entryFor(registryKey);
|
|
59981
|
+
return e?.disposition === "propose" && !e.descend;
|
|
59982
|
+
};
|
|
59983
|
+
function writeField(target, key, after) {
|
|
59984
|
+
if (after === void 0) delete target[key];
|
|
59985
|
+
else target[key] = structuredClone(after);
|
|
59986
|
+
}
|
|
59987
|
+
function applyStagedRevision(current, staged, selection = SELECT_NOTHING) {
|
|
59988
|
+
const next = structuredClone(current);
|
|
59989
|
+
const pick = (bucket, idx, name) => {
|
|
59990
|
+
const seen = /* @__PURE__ */ new Set();
|
|
59991
|
+
return [...idx].sort((a, b) => a - b).map((i) => {
|
|
59992
|
+
if (!Number.isInteger(i) || i < 0 || i >= bucket.length) {
|
|
59993
|
+
throw new RevisionApplyError(`applyStagedRevision: ${name}[${i}] is not an index into the staged ${name} (${bucket.length} staged)`);
|
|
59994
|
+
}
|
|
59995
|
+
if (seen.has(i)) throw new RevisionApplyError(`applyStagedRevision: ${name}[${i}] is selected more than once`);
|
|
59996
|
+
seen.add(i);
|
|
59997
|
+
return bucket[i];
|
|
59998
|
+
});
|
|
59999
|
+
};
|
|
60000
|
+
next.members = next.members ?? [];
|
|
60001
|
+
next.plans = next.plans ?? [];
|
|
60002
|
+
for (const p of pick(staged.proposals, selection.proposals, "proposals")) {
|
|
60003
|
+
switch (p.kind) {
|
|
60004
|
+
case "member-added": {
|
|
60005
|
+
if (p.member?.id !== p.memberId) {
|
|
60006
|
+
throw new RevisionApplyError(`applyStagedRevision: the staged addition names "${p.memberId}" but carries a member with id "${p.member?.id}" \u2014 staging builds both from one member, so this envelope was not produced by it`);
|
|
60007
|
+
}
|
|
60008
|
+
if (next.members.some((m) => m.id === p.member.id)) {
|
|
60009
|
+
throw new RevisionApplyError(`applyStagedRevision: member "${p.memberId}" already exists, so the staged addition does not describe this document`);
|
|
60010
|
+
}
|
|
60011
|
+
next.members.push(structuredClone(p.member));
|
|
60012
|
+
break;
|
|
60013
|
+
}
|
|
60014
|
+
case "member-removed": {
|
|
60015
|
+
const before = next.members.length;
|
|
60016
|
+
next.members = next.members.filter((m) => m.id !== p.memberId);
|
|
60017
|
+
if (next.members.length === before) {
|
|
60018
|
+
throw new RevisionApplyError(`applyStagedRevision: member "${p.memberId}" is not in this document, so the staged removal does not describe it`);
|
|
60019
|
+
}
|
|
60020
|
+
break;
|
|
60021
|
+
}
|
|
60022
|
+
case "member-changed": {
|
|
60023
|
+
const m = next.members.find((x) => x.id === p.memberId);
|
|
60024
|
+
if (!m) throw new RevisionApplyError(`applyStagedRevision: member "${p.memberId}" is not in this document, so the staged change does not describe it`);
|
|
60025
|
+
const baseEnds = Array.isArray(m.ends) ? m.ends.length : 0;
|
|
60026
|
+
for (const f of p.fields) {
|
|
60027
|
+
const t = memberFieldTarget(f);
|
|
60028
|
+
if ("end" in t) {
|
|
60029
|
+
const ends = Array.isArray(m.ends) ? [...m.ends] : [];
|
|
60030
|
+
if (t.end > baseEnds) {
|
|
60031
|
+
throw new RevisionApplyError(`applyStagedRevision: "${f.key}" names end ${t.end} of a member with ${baseEnds} \u2014 a revision may fill the next end, never leave a gap`);
|
|
60032
|
+
}
|
|
60033
|
+
while (ends.length <= t.end) ends.push({});
|
|
60034
|
+
writeField(ends[t.end], t.key, f.after);
|
|
60035
|
+
m.ends = ends;
|
|
60036
|
+
} else {
|
|
60037
|
+
writeField(m, t.key, f.after);
|
|
60038
|
+
}
|
|
60039
|
+
}
|
|
60040
|
+
break;
|
|
60041
|
+
}
|
|
60042
|
+
case "plan-added": {
|
|
60043
|
+
if (p.plan?.sheet !== p.sheet) {
|
|
60044
|
+
throw new RevisionApplyError(`applyStagedRevision: the staged addition names sheet "${p.sheet}" but carries a plan for "${p.plan?.sheet}" \u2014 staging builds both from one plan, so this envelope was not produced by it`);
|
|
60045
|
+
}
|
|
60046
|
+
if (next.plans.some((pl2) => pl2.sheet === p.plan.sheet)) {
|
|
60047
|
+
throw new RevisionApplyError(`applyStagedRevision: sheet "${p.sheet}" already exists, so the staged addition does not describe this document`);
|
|
60048
|
+
}
|
|
60049
|
+
next.plans.push(structuredClone(p.plan));
|
|
60050
|
+
break;
|
|
60051
|
+
}
|
|
60052
|
+
case "plan-changed": {
|
|
60053
|
+
const pl2 = next.plans.find((x) => x.sheet === p.sheet);
|
|
60054
|
+
if (!pl2) throw new RevisionApplyError(`applyStagedRevision: sheet "${p.sheet}" is not in this document, so the staged change does not describe it`);
|
|
60055
|
+
for (const f of p.fields) {
|
|
60056
|
+
if (!writableLeaf(`$.plans[].${f.key}`)) {
|
|
60057
|
+
throw new RevisionApplyError(`applyStagedRevision: "${f.key}" is not a plan field a revision read may change \u2014 the staged proposal does not match the registry`);
|
|
60058
|
+
}
|
|
60059
|
+
writeField(pl2, f.key, f.after);
|
|
60060
|
+
}
|
|
60061
|
+
break;
|
|
60062
|
+
}
|
|
60063
|
+
}
|
|
60064
|
+
}
|
|
60065
|
+
const bySheet = /* @__PURE__ */ new Map();
|
|
60066
|
+
for (const obs of staged.accepted) {
|
|
60067
|
+
const sheet = obs.evidence.source.sheet;
|
|
60068
|
+
bySheet.set(sheet, [...bySheet.get(sheet) ?? [], obs]);
|
|
60069
|
+
}
|
|
60070
|
+
const updates = /* @__PURE__ */ new Map();
|
|
60071
|
+
for (const u of [...staged.bindingUpdates, ...pick(staged.bindingProposals, selection.bindingProposals, "bindingProposals")]) {
|
|
60072
|
+
if (updates.has(u.observationId)) {
|
|
60073
|
+
throw new RevisionApplyError(`applyStagedRevision: two binding updates for observation "${u.observationId}" \u2014 staging files each into exactly one bucket, so this envelope was not produced by it`);
|
|
60074
|
+
}
|
|
60075
|
+
updates.set(u.observationId, u.to);
|
|
60076
|
+
}
|
|
60077
|
+
for (const plan of next.plans) {
|
|
60078
|
+
const arriving = bySheet.get(plan.sheet);
|
|
60079
|
+
if (arriving?.length) {
|
|
60080
|
+
plan.memberObservations = [...plan.memberObservations ?? [], ...structuredClone(arriving)];
|
|
60081
|
+
bySheet.delete(plan.sheet);
|
|
60082
|
+
}
|
|
60083
|
+
for (const obs of plan.memberObservations ?? []) {
|
|
60084
|
+
const to = updates.get(obs.id);
|
|
60085
|
+
if (to) obs.binding = structuredClone(to);
|
|
60086
|
+
}
|
|
60087
|
+
}
|
|
60088
|
+
if (bySheet.size > 0) {
|
|
60089
|
+
throw new Error(`applyStagedRevision: accepted evidence for unknown sheet(s) ${[...bySheet.keys()].join(", ")} \u2014 staging should have refused these`);
|
|
60090
|
+
}
|
|
60091
|
+
return next;
|
|
60092
|
+
}
|
|
60093
|
+
|
|
60094
|
+
// revision-envelope.ts
|
|
60095
|
+
function canonicalEnvelope(staged) {
|
|
60096
|
+
return {
|
|
60097
|
+
accepted: staged.accepted,
|
|
60098
|
+
bindingUpdates: staged.bindingUpdates,
|
|
60099
|
+
bindingProposals: staged.bindingProposals,
|
|
60100
|
+
proposals: staged.proposals.map(withSortedFields),
|
|
60101
|
+
issues: [...staged.issues].sort(byIssue)
|
|
60102
|
+
};
|
|
60103
|
+
}
|
|
60104
|
+
var envelopeHashOf = (staged) => hashOf(canonicalEnvelope(staged));
|
|
60105
|
+
function withSortedFields(p) {
|
|
60106
|
+
if (p.kind !== "member-changed" && p.kind !== "plan-changed") return p;
|
|
60107
|
+
return { ...p, fields: [...p.fields].sort((a, b) => cmp(a.key, b.key)) };
|
|
60108
|
+
}
|
|
60109
|
+
var cmp = (a, b) => a < b ? -1 : a > b ? 1 : 0;
|
|
60110
|
+
var byIssue = (a, b) => cmp(a.path, b.path) || cmp(a.code, b.code) || cmp(a.message, b.message);
|
|
60111
|
+
function selectionOrError(staged, accept) {
|
|
60112
|
+
if (accept === void 0 || accept === null) return { selection: { proposals: [], bindingProposals: [] } };
|
|
60113
|
+
if (typeof accept !== "object" || Array.isArray(accept)) {
|
|
60114
|
+
return { error: "`accept` must be an object of the form { proposals: number[], bindingProposals: number[] }" };
|
|
60115
|
+
}
|
|
60116
|
+
const src = accept;
|
|
60117
|
+
const BUCKETS = ["proposals", "bindingProposals"];
|
|
60118
|
+
const unknown = Object.keys(src).filter((k) => !BUCKETS.includes(k));
|
|
60119
|
+
if (unknown.length) {
|
|
60120
|
+
return { error: `\`accept\` has no such field${unknown.length > 1 ? "s" : ""}: ${unknown.map((k) => `\`${k}\``).join(", ")} \u2014 it takes \`proposals\` and \`bindingProposals\`` };
|
|
60121
|
+
}
|
|
60122
|
+
const out = { proposals: [], bindingProposals: [] };
|
|
60123
|
+
for (const bucket of BUCKETS) {
|
|
60124
|
+
const raw = Object.hasOwn(src, bucket) ? src[bucket] : void 0;
|
|
60125
|
+
if (raw === void 0 || raw === null) continue;
|
|
60126
|
+
if (!Array.isArray(raw)) return { error: `\`accept.${bucket}\` must be an array of indices` };
|
|
60127
|
+
const size = staged[bucket].length;
|
|
60128
|
+
const seen = /* @__PURE__ */ new Set();
|
|
60129
|
+
for (const v of raw) {
|
|
60130
|
+
if (!Number.isInteger(v)) {
|
|
60131
|
+
return { error: `\`accept.${bucket}\` must contain whole numbers; got ${JSON.stringify(v)}` };
|
|
60132
|
+
}
|
|
60133
|
+
const i = v;
|
|
60134
|
+
if (i < 0 || i >= size) {
|
|
60135
|
+
return { error: `\`accept.${bucket}[${i}]\` is out of range \u2014 this review staged ${size} ${bucket}` };
|
|
60136
|
+
}
|
|
60137
|
+
if (seen.has(i)) return { error: `\`accept.${bucket}\` names index ${i} more than once` };
|
|
60138
|
+
seen.add(i);
|
|
60139
|
+
out[bucket].push(i);
|
|
60140
|
+
}
|
|
60141
|
+
}
|
|
60142
|
+
return { selection: out };
|
|
60143
|
+
}
|
|
60144
|
+
var PLAN_BULK_KEYS = ["raster_b64", "segments", "labels"];
|
|
60145
|
+
function stagedSummary(staged, record2) {
|
|
60146
|
+
return {
|
|
60147
|
+
stageId: record2.stageId,
|
|
60148
|
+
requestId: record2.requestId,
|
|
60149
|
+
accepted: staged.accepted.length,
|
|
60150
|
+
bindingUpdates: staged.bindingUpdates.length,
|
|
60151
|
+
proposals: staged.proposals.map(viewOf),
|
|
60152
|
+
bindingProposals: staged.bindingProposals,
|
|
60153
|
+
issues: staged.issues
|
|
60154
|
+
};
|
|
60155
|
+
}
|
|
60156
|
+
function viewOf(p) {
|
|
60157
|
+
if (p.kind !== "plan-added") return p;
|
|
60158
|
+
const plan = p.plan;
|
|
60159
|
+
const shown = {};
|
|
60160
|
+
const omitted = [];
|
|
60161
|
+
for (const k of Object.keys(plan)) {
|
|
60162
|
+
if (PLAN_BULK_KEYS.includes(k)) {
|
|
60163
|
+
if (plan[k] !== void 0) omitted.push(k);
|
|
60164
|
+
continue;
|
|
60165
|
+
}
|
|
60166
|
+
shown[k] = plan[k];
|
|
60167
|
+
}
|
|
60168
|
+
return { ...p, plan: shown, omitted };
|
|
60169
|
+
}
|
|
60170
|
+
|
|
59382
60171
|
// project-sources-store.ts
|
|
59383
|
-
var
|
|
60172
|
+
var import_node_crypto15 = require("node:crypto");
|
|
59384
60173
|
var import_node_fs26 = require("node:fs");
|
|
59385
60174
|
var import_node_path23 = require("node:path");
|
|
59386
60175
|
var sourcesDir = (id) => (0, import_node_path23.join)(projectDir(id), "sources");
|
|
@@ -59392,7 +60181,7 @@ function writeAtomic2(path, buf) {
|
|
|
59392
60181
|
}
|
|
59393
60182
|
function saveSource(id, file) {
|
|
59394
60183
|
(0, import_node_fs26.mkdirSync)(sourcesDir(id), { recursive: true });
|
|
59395
|
-
const sha2563 = (0,
|
|
60184
|
+
const sha2563 = (0, import_node_crypto15.createHash)("sha256").update(file.buf).digest("hex");
|
|
59396
60185
|
const ext = safeExt(file.ext);
|
|
59397
60186
|
const p = (0, import_node_path23.join)(sourcesDir(id), `${sha2563}.${ext}`);
|
|
59398
60187
|
if (!(0, import_node_fs26.existsSync)(p)) writeAtomic2(p, file.buf);
|
|
@@ -59653,6 +60442,37 @@ function expandBasePlate(joint, col) {
|
|
|
59653
60442
|
function webHalfThk(profile, w) {
|
|
59654
60443
|
return profileKind(profile) === "I" ? Math.min(w * 0.5, Math.max(w * 0.1, 5)) / 2 : 0;
|
|
59655
60444
|
}
|
|
60445
|
+
function sectionAxesOnNormal(rot, atEnd1) {
|
|
60446
|
+
const th = (rot ?? 0) * Math.PI / 180;
|
|
60447
|
+
const round = (n) => Math.abs(n) < 1e-9 ? 0 : Math.abs(Math.abs(n) - 1) < 1e-9 ? Math.sign(n) : n;
|
|
60448
|
+
const flip = atEnd1 ? -1 : 1;
|
|
60449
|
+
return { uOnN: round(-flip * Math.cos(th)), vOnN: round(flip * Math.sin(th)) };
|
|
60450
|
+
}
|
|
60451
|
+
function realWebThk(profile, w) {
|
|
60452
|
+
const x = xsectionFor(profile, { w, d: w });
|
|
60453
|
+
switch (x.shape) {
|
|
60454
|
+
case "i":
|
|
60455
|
+
case "channel":
|
|
60456
|
+
return x.tw;
|
|
60457
|
+
case "angle":
|
|
60458
|
+
case "rhs":
|
|
60459
|
+
return x.t;
|
|
60460
|
+
case "chs":
|
|
60461
|
+
return x.t;
|
|
60462
|
+
case "rect":
|
|
60463
|
+
return webHalfThk(profile, w) * 2;
|
|
60464
|
+
}
|
|
60465
|
+
}
|
|
60466
|
+
function lapFaces(member, requestedSide, atEnd1) {
|
|
60467
|
+
const { uOnN, vOnN } = sectionAxesOnNormal(member.rot, atEnd1);
|
|
60468
|
+
const faces = bearingFaces(xsectionFor(member.profile, member.dims), uOnN, vOnN, requestedSide);
|
|
60469
|
+
if (faces) return faces;
|
|
60470
|
+
if (profileKind(member.profile) === "I" && Math.abs(Math.abs(uOnN) - 1) < 1e-9) {
|
|
60471
|
+
const h = webHalfThk(member.profile, member.dims.w);
|
|
60472
|
+
return { lapN: requestedSide * h, sideDir: requestedSide, plyFarN: -requestedSide * h, ply: 2 * h, derived: false };
|
|
60473
|
+
}
|
|
60474
|
+
return null;
|
|
60475
|
+
}
|
|
59656
60476
|
function distPointSeg(p, a, b) {
|
|
59657
60477
|
const abx = b[0] - a[0], aby = b[1] - a[1], abz = b[2] - a[2];
|
|
59658
60478
|
const apx = p[0] - a[0], apy = p[1] - a[1], apz = p[2] - a[2];
|
|
@@ -59754,10 +60574,11 @@ function expandShearPlate(joint, beam, support, nativeSupport) {
|
|
|
59754
60574
|
const clearance = Math.max(0, num(p, "clearance", 12.7));
|
|
59755
60575
|
const stiffener = p?.["stiffener"] === true;
|
|
59756
60576
|
const height = pos(p, "plateHeight", (rows2 - 1) * pitch + 2 * edge);
|
|
59757
|
-
const twHalf = webHalfThk(beam.profile, beam.dims.w);
|
|
59758
60577
|
const webSide = num(p, "webSide", 1) >= 0 ? 1 : -1;
|
|
59759
|
-
const
|
|
59760
|
-
|
|
60578
|
+
const lap = lapFaces(beam, webSide, atEnd1);
|
|
60579
|
+
if (!lap) return { parts: [], operations: [], viewOperations: [] };
|
|
60580
|
+
const pOff = lap.lapN + lap.sideDir * (thickness / 2);
|
|
60581
|
+
const u0 = support && profileKind(support.profile) === "I" ? realWebThk(support.profile, support.dims.w) / 2 : 0;
|
|
59761
60582
|
const edgeV = Math.min(edge, height * 0.4);
|
|
59762
60583
|
const pV = rows2 > 1 ? Math.min(pitch, Math.max(0, height - 2 * edgeV) / (rows2 - 1)) : 0;
|
|
59763
60584
|
const vOffs = Array.from({ length: rows2 }, (_, i) => (i - (rows2 - 1) / 2) * pV);
|
|
@@ -59768,16 +60589,16 @@ function expandShearPlate(joint, beam, support, nativeSupport) {
|
|
|
59768
60589
|
const pU = cols > 1 ? Math.min(colPitch, (regHi - regLo) / (cols - 1)) : 0;
|
|
59769
60590
|
const uOffs = Array.from({ length: cols }, (_, j) => cU + (j - (cols - 1) / 2) * pU);
|
|
59770
60591
|
const nutH = 0.8 * boltDia, nutAF = 1.6 * boltDia;
|
|
59771
|
-
const plateOuterN =
|
|
59772
|
-
const webFarN =
|
|
59773
|
-
const headTipN = plateOuterN +
|
|
59774
|
-
const nutTipN = webFarN -
|
|
60592
|
+
const plateOuterN = lap.lapN + lap.sideDir * thickness;
|
|
60593
|
+
const webFarN = lap.plyFarN;
|
|
60594
|
+
const headTipN = plateOuterN + lap.sideDir * nutH;
|
|
60595
|
+
const nutTipN = webFarN - lap.sideDir * nutH;
|
|
59775
60596
|
const grade = p?.["boltGrade"] === "A490" ? "A490" : "A325";
|
|
59776
60597
|
const plateMaterial = authoredText(p, "plateMaterial");
|
|
59777
60598
|
const fastenerMaterial = authoredText(p, "fastenerMaterial");
|
|
59778
60599
|
const standard = text(p, "fastenerStandard", `${grade}N`);
|
|
59779
60600
|
const boltType = p?.["boltType"] === "site" ? "site" : "shop";
|
|
59780
|
-
const grip = thickness +
|
|
60601
|
+
const grip = thickness + lap.ply;
|
|
59781
60602
|
const boltLen = aiscBoltLength(grip, boltDia);
|
|
59782
60603
|
const callout = `\u2300${Math.round(boltDia)} ${grade} \xD7 ${Math.round(boltLen)}`;
|
|
59783
60604
|
const holes = [];
|
|
@@ -59790,7 +60611,10 @@ function expandShearPlate(joint, beam, support, nativeSupport) {
|
|
|
59790
60611
|
holes.push({ id: `${jid}:plate-hole${k}`, u: u - width / 2, v, d: boltDia + holeClr });
|
|
59791
60612
|
bolts.push(
|
|
59792
60613
|
// the shank = the AISC bolt LENGTH, from under the head (plate outer face) into the connection
|
|
59793
|
-
|
|
60614
|
+
// The shank runs from under the head INTO the connection — i.e. AGAINST the side the plate grows
|
|
60615
|
+
// on. It must follow the derived side, not the requested one: on a one-sided section those differ,
|
|
60616
|
+
// and using the request sent the bolt out into open air instead of through the plate and the ply.
|
|
60617
|
+
{ id: `${jid}:bolt${k}`, group: "bolt", kind: "rod", nativeKind: "bolt-shank", from: P(u0 + u, v, plateOuterN), to: P(u0 + u, v, plateOuterN - lap.sideDir * boltLen), d: boltDia, material: fastenerMaterial, fastener: { role: "shear-bolt" }, meta: { label: `Bolt ${callout}` } },
|
|
59794
60618
|
{ id: `${jid}:head${k}`, group: "nut", kind: "nut", nativeKind: "bolt-head", from: P(u0 + u, v, plateOuterN), to: P(u0 + u, v, headTipN), acrossFlats: nutAF, material: fastenerMaterial, fastener: { role: "bolt-head" }, meta: { label: `Bolt head ${callout}` } },
|
|
59795
60619
|
{ id: `${jid}:nut${k}`, group: "nut", kind: "nut", nativeKind: "nut", from: P(u0 + u, v, webFarN), to: P(u0 + u, v, nutTipN), acrossFlats: nutAF, material: fastenerMaterial, fastener: { role: "nut" }, meta: { label: `Bolt nut ${callout}` } }
|
|
59796
60620
|
);
|
|
@@ -59827,8 +60651,8 @@ function expandShearPlate(joint, beam, support, nativeSupport) {
|
|
|
59827
60651
|
meta: { label: `Shear plate ${Math.round(width)}\xD7${Math.round(height)}\xD7${Math.round(thickness)}` }
|
|
59828
60652
|
};
|
|
59829
60653
|
const weldSide = p?.["weldSide"] === "near" || p?.["weldSide"] === "far" ? p["weldSide"] : "both";
|
|
59830
|
-
const nOuter = pOff +
|
|
59831
|
-
const nInner = pOff -
|
|
60654
|
+
const nOuter = pOff + lap.sideDir * thickness / 2;
|
|
60655
|
+
const nInner = pOff - lap.sideDir * thickness / 2;
|
|
59832
60656
|
const faceWeld = (suffix, n) => ({
|
|
59833
60657
|
id: `${joint.id}:${suffix}`,
|
|
59834
60658
|
group: "weld",
|
|
@@ -59846,7 +60670,7 @@ function expandShearPlate(joint, beam, support, nativeSupport) {
|
|
|
59846
60670
|
if (stiffener) {
|
|
59847
60671
|
if (support && support.role === "beam" && !support.isBrace && finite3(support.from) && finite3(support.to) && support.dims && support.dims.d > 0 && support.dims.w > 0) {
|
|
59848
60672
|
const supPosOff = typeof support.posOffset === "number" && isFinite(support.posOffset) ? support.posOffset : 0;
|
|
59849
|
-
const twGirder =
|
|
60673
|
+
const twGirder = realWebThk(support.profile, support.dims.w);
|
|
59850
60674
|
const stiffH = support.dims.d * 0.9;
|
|
59851
60675
|
const stiffW = Math.max(support.dims.w / 2 - twGirder / 2, thickness * 2);
|
|
59852
60676
|
const girderCentZ = endPt[2] + supPosOff;
|
|
@@ -59856,7 +60680,7 @@ function expandShearPlate(joint, beam, support, nativeSupport) {
|
|
|
59856
60680
|
const wfx = endPt[0] - uDir[0] * (twGirder / 2), wfy = endPt[1] - uDir[1] * (twGirder / 2);
|
|
59857
60681
|
parts.push({ id: `${joint.id}:stiffweld`, group: "weld", kind: "weld", closed: false, path: [[wfx, wfy, girderCentZ - stiffH / 2], [wfx, wfy, girderCentZ + stiffH / 2]], leg: weldLeg, meta: { label: `Fillet ${weldLeg}` } });
|
|
59858
60682
|
} else {
|
|
59859
|
-
const oppOff = -
|
|
60683
|
+
const oppOff = lap.plyFarN - lap.sideDir * (thickness / 2);
|
|
59860
60684
|
parts.push({ id: `${joint.id}:stiff`, group: "stiffener", kind: "plate", center: P(u0 + width / 2, 0, oppOff), uDir, vDir, width, depth: height, thickness, holes: [], material: plateMaterial, meta: { label: `Stiffener ${Math.round(width)}\xD7${Math.round(height)}\xD7${Math.round(thickness)}` } });
|
|
59861
60685
|
parts.push({ id: `${joint.id}:stiffweld`, group: "weld", kind: "weld", closed: false, path: [P(u0, -height / 2, oppOff), P(u0, height / 2, oppOff)], leg: weldLeg, meta: { label: `Fillet ${weldLeg}` } });
|
|
59862
60686
|
}
|
|
@@ -60161,14 +60985,14 @@ function registerSheet(input) {
|
|
|
60161
60985
|
}
|
|
60162
60986
|
|
|
60163
60987
|
// export-identity.ts
|
|
60164
|
-
var
|
|
60988
|
+
var import_node_crypto16 = require("node:crypto");
|
|
60165
60989
|
function deriveExportSourceId(kind, ownerId, installation = installId()) {
|
|
60166
|
-
return `sha256:${(0,
|
|
60990
|
+
return `sha256:${(0, import_node_crypto16.createHash)("sha256").update(`floless-export-source-v1\0${kind}\0${installation}\0${ownerId}`, "utf8").digest("hex")}`;
|
|
60167
60991
|
}
|
|
60168
60992
|
function deriveDropExportSourceId(kind, ownerId, nonce, installation = installId()) {
|
|
60169
60993
|
return deriveExportSourceId(kind, `${ownerId}\0drop\0${nonce}`, installation);
|
|
60170
60994
|
}
|
|
60171
|
-
function
|
|
60995
|
+
function canonicalJson2(value) {
|
|
60172
60996
|
const visit = (v) => {
|
|
60173
60997
|
if (Array.isArray(v)) return v.map(visit);
|
|
60174
60998
|
if (!v || typeof v !== "object") return v;
|
|
@@ -60180,7 +61004,7 @@ function sceneHash(scene) {
|
|
|
60180
61004
|
const meta = scene.meta && typeof scene.meta === "object" ? { ...scene.meta } : {};
|
|
60181
61005
|
delete meta.sceneHash;
|
|
60182
61006
|
const projection = { ...scene, meta };
|
|
60183
|
-
return `sha256:${(0,
|
|
61007
|
+
return `sha256:${(0, import_node_crypto16.createHash)("sha256").update(`floless-scene-v1\0${canonicalJson2(projection)}`, "utf8").digest("hex")}`;
|
|
60184
61008
|
}
|
|
60185
61009
|
|
|
60186
61010
|
// steel-model-read.ts
|
|
@@ -62546,6 +63370,37 @@ function revisionReadContractError(appId, contract) {
|
|
|
62546
63370
|
|
|
62547
63371
|
// revision-routes.ts
|
|
62548
63372
|
var requestView = (r) => r === null ? null : { ...r, appTemplateId: r.appId ? resolveTemplateId(r.appId) : void 0 };
|
|
63373
|
+
function sweepOrphanedStaged() {
|
|
63374
|
+
for (const key of listStagedKeys()) {
|
|
63375
|
+
const rec = readStagedRecord(key);
|
|
63376
|
+
if (!rec || !hasRequestFile(rec.requestId)) dropStagingFor(key);
|
|
63377
|
+
}
|
|
63378
|
+
}
|
|
63379
|
+
async function stageForReview(reply, project, requestId, candidate) {
|
|
63380
|
+
const current = readAcceptedForRequest(project.app, project.id, "read");
|
|
63381
|
+
if (current == null) {
|
|
63382
|
+
return reply.status(409).send({ ok: false, error: "this project has no contract yet \u2014 a revision read revises an existing model" });
|
|
63383
|
+
}
|
|
63384
|
+
if (declaredTypeOf(current) !== STEEL_V2) {
|
|
63385
|
+
return reply.status(409).send({
|
|
63386
|
+
ok: false,
|
|
63387
|
+
error: `this project holds a "${declaredTypeOf(current)}" contract, and a "${STEEL_V2}" revision read revises a "${STEEL_V2}" model \u2014 migrate the project first`
|
|
63388
|
+
});
|
|
63389
|
+
}
|
|
63390
|
+
const stagingKey = await getOrCreateProjectStagingId(project.id);
|
|
63391
|
+
const staged = stageRevisionRead(current, candidate);
|
|
63392
|
+
const record2 = stageCandidate(stagingKey, candidate, {
|
|
63393
|
+
requestId,
|
|
63394
|
+
envelopeHash: envelopeHashOf(staged),
|
|
63395
|
+
// Carried only so a 409 can say the contract moved. Never a gate — an ordinary editor autosave
|
|
63396
|
+
// moves it constantly and must not starve a review.
|
|
63397
|
+
baseContractHash: etagOf(current),
|
|
63398
|
+
stagedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
63399
|
+
});
|
|
63400
|
+
const request = patchRequest(requestId, { status: "staged" });
|
|
63401
|
+
broadcast({ type: "request-added", request: requestView(request) });
|
|
63402
|
+
return reply.status(202).send({ ok: true, staged: stagedSummary(staged, record2) });
|
|
63403
|
+
}
|
|
62549
63404
|
function registerRevisionRoutes(app) {
|
|
62550
63405
|
app.post(
|
|
62551
63406
|
"/api/projects/:id/revision-requests",
|
|
@@ -62610,6 +63465,18 @@ function registerRevisionRoutes(app) {
|
|
|
62610
63465
|
error: guardError
|
|
62611
63466
|
});
|
|
62612
63467
|
}
|
|
63468
|
+
sweepOrphanedStaged();
|
|
63469
|
+
try {
|
|
63470
|
+
acceptContract(req.body.contract, { appId: project.app, projectId: project.id, operation: "put" });
|
|
63471
|
+
} catch (e) {
|
|
63472
|
+
if (e instanceof ContractPolicyError) {
|
|
63473
|
+
return reply.status(400).send({ ok: false, error: e.message, code: e.code });
|
|
63474
|
+
}
|
|
63475
|
+
throw e;
|
|
63476
|
+
}
|
|
63477
|
+
if (declaredTypeOf(req.body.contract) === STEEL_V2) {
|
|
63478
|
+
return stageForReview(reply, project, request.id, req.body.contract);
|
|
63479
|
+
}
|
|
62613
63480
|
try {
|
|
62614
63481
|
await writeContractChecked(project.app, req.body.contract, project.id, {
|
|
62615
63482
|
origin: "internal",
|
|
@@ -62628,6 +63495,97 @@ function registerRevisionRoutes(app) {
|
|
|
62628
63495
|
return { ok: true, version };
|
|
62629
63496
|
}
|
|
62630
63497
|
);
|
|
63498
|
+
app.post(
|
|
63499
|
+
"/api/projects/:id/revision-read/confirm",
|
|
63500
|
+
async (req, reply) => {
|
|
63501
|
+
const project = getProject(req.params.id);
|
|
63502
|
+
if (!project) return reply.status(404).send({ ok: false, error: `unknown project: ${req.params.id}` });
|
|
63503
|
+
const requestId = typeof req.body?.requestId === "string" ? req.body.requestId : "";
|
|
63504
|
+
const stageId = typeof req.body?.stageId === "string" ? req.body.stageId : "";
|
|
63505
|
+
if (!requestId || !stageId) {
|
|
63506
|
+
return reply.status(400).send({ ok: false, error: "requestId and stageId are both required \u2014 a confirm names the review it is confirming" });
|
|
63507
|
+
}
|
|
63508
|
+
return withLifecycleLock("project", project.id, async () => {
|
|
63509
|
+
const request = getRequest(requestId);
|
|
63510
|
+
if (!request || request.type !== "revision-read" || request.project !== project.id) {
|
|
63511
|
+
return reply.status(410).send({ ok: false, error: "that revision request no longer exists \u2014 re-attach the revised set and read it again" });
|
|
63512
|
+
}
|
|
63513
|
+
if (request.status !== "staged") {
|
|
63514
|
+
return reply.status(409).send({ ok: false, error: `that revision request is "${request.status}", not staged for review` });
|
|
63515
|
+
}
|
|
63516
|
+
const stagingKey = getProjectStagingId(project.id);
|
|
63517
|
+
const st = stagingKey ? readStaged(stagingKey) : null;
|
|
63518
|
+
if (!stagingKey || !st) {
|
|
63519
|
+
return reply.status(410).send({ ok: false, error: "the staged review is no longer available \u2014 read the revised set again" });
|
|
63520
|
+
}
|
|
63521
|
+
if (st.record.requestId !== requestId || st.record.stageId !== stageId) {
|
|
63522
|
+
return reply.status(409).send({
|
|
63523
|
+
ok: false,
|
|
63524
|
+
error: "this review was replaced by a newer read of the same set \u2014 reload the review and confirm that one",
|
|
63525
|
+
code: "stage-superseded"
|
|
63526
|
+
});
|
|
63527
|
+
}
|
|
63528
|
+
const current = readAcceptedForRequest(project.app, project.id, "read");
|
|
63529
|
+
if (current == null || declaredTypeOf(current) !== STEEL_V2) {
|
|
63530
|
+
return reply.status(409).send({ ok: false, error: "this project no longer holds the model this review was staged against" });
|
|
63531
|
+
}
|
|
63532
|
+
const head = listVersions(project.id)[0]?.n ?? 0;
|
|
63533
|
+
if ((request.baseVersion ?? 0) !== head) {
|
|
63534
|
+
return reply.status(409).send({ ok: false, error: `project changed since this read started (base v${request.baseVersion ?? 0}, now v${head}) \u2014 re-read the current version` });
|
|
63535
|
+
}
|
|
63536
|
+
let candidate;
|
|
63537
|
+
try {
|
|
63538
|
+
candidate = acceptContract(st.candidate, { appId: project.app, projectId: project.id, operation: "put" });
|
|
63539
|
+
} catch (e) {
|
|
63540
|
+
if (e instanceof ContractPolicyError) {
|
|
63541
|
+
return reply.status(409).send({ ok: false, error: `this staged review can no longer be applied \u2014 ${e.message}`, code: e.code });
|
|
63542
|
+
}
|
|
63543
|
+
throw e;
|
|
63544
|
+
}
|
|
63545
|
+
const fresh = stageRevisionRead(current, candidate);
|
|
63546
|
+
if (envelopeHashOf(fresh) !== st.record.envelopeHash) {
|
|
63547
|
+
const restaged = stageCandidate(stagingKey, candidate, {
|
|
63548
|
+
requestId: st.record.requestId,
|
|
63549
|
+
envelopeHash: envelopeHashOf(fresh),
|
|
63550
|
+
baseContractHash: etagOf(current),
|
|
63551
|
+
stagedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
63552
|
+
});
|
|
63553
|
+
return reply.status(409).send({
|
|
63554
|
+
ok: false,
|
|
63555
|
+
error: "the model changed while you were reviewing, so this read means something different now \u2014 here is the current review",
|
|
63556
|
+
code: "stage-restaged",
|
|
63557
|
+
staged: stagedSummary(fresh, restaged)
|
|
63558
|
+
});
|
|
63559
|
+
}
|
|
63560
|
+
const sel = selectionOrError(fresh, req.body?.accept);
|
|
63561
|
+
if ("error" in sel) return reply.status(400).send({ ok: false, error: sel.error });
|
|
63562
|
+
let next;
|
|
63563
|
+
try {
|
|
63564
|
+
next = applyStagedRevision(current, fresh, sel.selection);
|
|
63565
|
+
} catch (e) {
|
|
63566
|
+
if (e instanceof RevisionApplyError) return reply.status(400).send({ ok: false, error: e.message });
|
|
63567
|
+
throw e;
|
|
63568
|
+
}
|
|
63569
|
+
try {
|
|
63570
|
+
await writeContractChecked(project.app, next, project.id, {
|
|
63571
|
+
origin: "internal",
|
|
63572
|
+
why: "a human confirmed this revision review; the compare and this write share one lock (see above)"
|
|
63573
|
+
});
|
|
63574
|
+
} catch (e) {
|
|
63575
|
+
if (e instanceof ContractError) return reply.status(400).send({ ok: false, error: e.message, ...e.code ? { code: e.code } : {} });
|
|
63576
|
+
throw e;
|
|
63577
|
+
}
|
|
63578
|
+
clearApproval(project.id);
|
|
63579
|
+
const message = typeof req.body?.message === "string" && req.body.message.trim() ? req.body.message.trim() : "Re-read a revised drawing set";
|
|
63580
|
+
const source = request.sourceRefs && request.sourceRefs.length ? { files: request.sourceRefs, requestId: request.id } : void 0;
|
|
63581
|
+
const version = createVersion(project.id, next, { author: "AI", message, gate: null, kind: "revision-read", source });
|
|
63582
|
+
broadcast({ type: "contract-changed", appId: project.app, project: project.id });
|
|
63583
|
+
dropStagingFor(stagingKey);
|
|
63584
|
+
deleteRequest(request.id);
|
|
63585
|
+
return { ok: true, version };
|
|
63586
|
+
});
|
|
63587
|
+
}
|
|
63588
|
+
);
|
|
62631
63589
|
app.post(
|
|
62632
63590
|
"/api/projects/:id/revision-requests/:reqId/fail",
|
|
62633
63591
|
async (req, reply) => {
|
|
@@ -62638,6 +63596,8 @@ function registerRevisionRoutes(app) {
|
|
|
62638
63596
|
return reply.status(404).send({ ok: false, error: `unknown revision request for this project: ${req.params.reqId}` });
|
|
62639
63597
|
}
|
|
62640
63598
|
const error = typeof req.body?.error === "string" && req.body.error.trim() ? req.body.error.trim().slice(0, 2e3) : "the read could not be completed";
|
|
63599
|
+
const key = getProjectStagingId(project.id);
|
|
63600
|
+
if (key && readStagedRecord(key)?.requestId === existing.id) dropStagingFor(key);
|
|
62641
63601
|
const request = patchRequest(existing.id, { status: "failed", error });
|
|
62642
63602
|
broadcast({ type: "request-added", request });
|
|
62643
63603
|
return { ok: true, request: requestView(request) };
|
|
@@ -62686,7 +63646,7 @@ function uniqueProjectExportFilename(projectId, preferred) {
|
|
|
62686
63646
|
}
|
|
62687
63647
|
|
|
62688
63648
|
// project-export-receipts.ts
|
|
62689
|
-
var
|
|
63649
|
+
var import_node_crypto17 = require("node:crypto");
|
|
62690
63650
|
var import_node_fs28 = require("node:fs");
|
|
62691
63651
|
var import_node_path26 = require("node:path");
|
|
62692
63652
|
|
|
@@ -62715,7 +63675,7 @@ var EXTENSIONS = {
|
|
|
62715
63675
|
var RESERVED2 = /^\.floless-(?:txn|cleanup|tmp|backup)-/i;
|
|
62716
63676
|
var projectExportIndexPath = (projectId) => (0, import_node_path26.join)(projectExportsDir(projectId), "index.json");
|
|
62717
63677
|
function hash(bytes) {
|
|
62718
|
-
return (0,
|
|
63678
|
+
return (0, import_node_crypto17.createHash)("sha256").update(bytes).digest("hex");
|
|
62719
63679
|
}
|
|
62720
63680
|
function proof(bytes) {
|
|
62721
63681
|
return bytes ? { exists: true, bytes: bytes.length, sha256: hash(bytes) } : { exists: false, bytes: 0, sha256: null };
|
|
@@ -62841,7 +63801,7 @@ function syncDirectory(path) {
|
|
|
62841
63801
|
function durableReplace(path, bytes) {
|
|
62842
63802
|
const dir = (0, import_node_path26.dirname)(path);
|
|
62843
63803
|
(0, import_node_fs28.mkdirSync)(dir, { recursive: true });
|
|
62844
|
-
const tmp = (0, import_node_path26.join)(dir, `.floless-tmp-receipt-${(0,
|
|
63804
|
+
const tmp = (0, import_node_path26.join)(dir, `.floless-tmp-receipt-${(0, import_node_crypto17.randomUUID)()}`);
|
|
62845
63805
|
try {
|
|
62846
63806
|
(0, import_node_fs28.writeFileSync)(tmp, bytes, { flag: "wx" });
|
|
62847
63807
|
syncFile(tmp);
|
|
@@ -63254,7 +64214,7 @@ function registerWorkspaceDataRoutes(app) {
|
|
|
63254
64214
|
}
|
|
63255
64215
|
|
|
63256
64216
|
// steel-model-migrate.ts
|
|
63257
|
-
var
|
|
64217
|
+
var import_node_crypto18 = require("node:crypto");
|
|
63258
64218
|
|
|
63259
64219
|
// steel-model-migrate-refs.ts
|
|
63260
64220
|
var key2 = (sheet, id) => JSON.stringify([sheet, id]);
|
|
@@ -64236,7 +65196,7 @@ function shortHash(s) {
|
|
|
64236
65196
|
return `${h1.toString(36)}${h2.toString(36)}`;
|
|
64237
65197
|
}
|
|
64238
65198
|
function blobDigest(s) {
|
|
64239
|
-
return `blob:${s.length}:${(0,
|
|
65199
|
+
return `blob:${s.length}:${(0, import_node_crypto18.createHash)("sha256").update(s).digest("base64url").slice(0, 22)}`;
|
|
64240
65200
|
}
|
|
64241
65201
|
function canonicalHash(doc) {
|
|
64242
65202
|
const norm = (v, key) => {
|
|
@@ -64246,7 +65206,7 @@ function canonicalHash(doc) {
|
|
|
64246
65206
|
if (isObj3(v)) return Object.fromEntries(Object.keys(v).sort().map((k) => [k, norm(v[k], k)]));
|
|
64247
65207
|
return v;
|
|
64248
65208
|
};
|
|
64249
|
-
return (0,
|
|
65209
|
+
return (0, import_node_crypto18.createHash)("sha256").update(JSON.stringify(norm(doc))).digest("hex");
|
|
64250
65210
|
}
|
|
64251
65211
|
var KNOWN_READ_KINDS = /* @__PURE__ */ new Set(["steel-filter-segment"]);
|
|
64252
65212
|
function previewMigration(v1, ctx) {
|
|
@@ -69449,7 +70409,7 @@ async function teklaVersionToBake() {
|
|
|
69449
70409
|
}
|
|
69450
70410
|
|
|
69451
70411
|
// ifc-publication.ts
|
|
69452
|
-
var
|
|
70412
|
+
var import_node_crypto19 = require("node:crypto");
|
|
69453
70413
|
var import_node_fs34 = require("node:fs");
|
|
69454
70414
|
var import_node_os18 = require("node:os");
|
|
69455
70415
|
var import_node_path30 = require("node:path");
|
|
@@ -69475,7 +70435,7 @@ var MAX_TRANSACTIONS = 256;
|
|
|
69475
70435
|
var MAX_PHASE_BYTES = 1024 * 1024;
|
|
69476
70436
|
var MAX_INDEX_SNAPSHOT_BYTES = 512 * 1024;
|
|
69477
70437
|
function sha2562(bytes) {
|
|
69478
|
-
return (0,
|
|
70438
|
+
return (0, import_node_crypto19.createHash)("sha256").update(bytes).digest("hex");
|
|
69479
70439
|
}
|
|
69480
70440
|
function proof2(bytes) {
|
|
69481
70441
|
return { exists: true, bytes: bytes.length, sha256: sha2562(bytes) };
|
|
@@ -69505,7 +70465,7 @@ function syncDirectory2(path) {
|
|
|
69505
70465
|
function durableReplace2(path, bytes) {
|
|
69506
70466
|
const dir = (0, import_node_path30.dirname)(path);
|
|
69507
70467
|
(0, import_node_fs34.mkdirSync)(dir, { recursive: true });
|
|
69508
|
-
const tmp = (0, import_node_path30.join)(dir, `.floless-tmp-recovery-${(0,
|
|
70468
|
+
const tmp = (0, import_node_path30.join)(dir, `.floless-tmp-recovery-${(0, import_node_crypto19.randomUUID)()}`);
|
|
69509
70469
|
try {
|
|
69510
70470
|
(0, import_node_fs34.writeFileSync)(tmp, bytes, { flag: "wx" });
|
|
69511
70471
|
syncFile2(tmp);
|
|
@@ -69541,7 +70501,7 @@ function requestIfcTempPath(finalPath) {
|
|
|
69541
70501
|
const final = canonicalPath(finalPath);
|
|
69542
70502
|
if (!plainIfcFilename((0, import_node_path30.basename)(final))) throw new IfcPublicationError("IFC final filename is unsafe.");
|
|
69543
70503
|
(0, import_node_fs34.mkdirSync)((0, import_node_path30.dirname)(final), { recursive: true });
|
|
69544
|
-
return (0, import_node_path30.join)((0, import_node_path30.dirname)(final), `.floless-tmp-ifc-${(0,
|
|
70504
|
+
return (0, import_node_path30.join)((0, import_node_path30.dirname)(final), `.floless-tmp-ifc-${(0, import_node_crypto19.randomUUID)()}.ifc`);
|
|
69545
70505
|
}
|
|
69546
70506
|
function validateIfc(path) {
|
|
69547
70507
|
if (!(0, import_node_fs34.existsSync)(path) || (0, import_node_fs34.statSync)(path).size === 0) throw new IfcPublicationError("the IFC export produced no file");
|
|
@@ -69560,7 +70520,7 @@ function writePhase(txnDir, journal) {
|
|
|
69560
70520
|
if (index < 0) throw new IfcPublicationError(`unknown IFC publication phase "${journal.phase}".`);
|
|
69561
70521
|
const destination = (0, import_node_path30.join)(txnDir, `${String(index).padStart(3, "0")}-${journal.phase}.json`);
|
|
69562
70522
|
if ((0, import_node_fs34.existsSync)(destination)) throw new IfcPublicationError(`IFC publication phase "${journal.phase}" already exists.`);
|
|
69563
|
-
const temp = (0, import_node_path30.join)(txnDir, `.phase-${(0,
|
|
70523
|
+
const temp = (0, import_node_path30.join)(txnDir, `.phase-${(0, import_node_crypto19.randomUUID)()}.tmp`);
|
|
69564
70524
|
const bytes = Buffer.from(`${JSON.stringify(journal, null, 2)}
|
|
69565
70525
|
`, "utf8");
|
|
69566
70526
|
try {
|
|
@@ -69880,7 +70840,7 @@ async function publishIfcAtomically(tempPath, finalPath, options) {
|
|
|
69880
70840
|
}
|
|
69881
70841
|
return withLifecycleLock(options.resource.kind, options.resource.key, async () => {
|
|
69882
70842
|
await recoverIfcPublicationsInDirectory(paths.dir, options.resource);
|
|
69883
|
-
const txnId = (0,
|
|
70843
|
+
const txnId = (0, import_node_crypto19.randomUUID)();
|
|
69884
70844
|
const txnDir = (0, import_node_path30.join)(paths.dir, `.floless-txn-ifc-${txnId}`);
|
|
69885
70845
|
const backupPath = (0, import_node_path30.join)(paths.dir, `.floless-backup-ifc-${txnId}.ifc`);
|
|
69886
70846
|
const priorArtifact = readFileProof(paths.final);
|
|
@@ -70029,7 +70989,7 @@ function cleanupIfcTemp(path) {
|
|
|
70029
70989
|
}
|
|
70030
70990
|
|
|
70031
70991
|
// export-companion.ts
|
|
70032
|
-
var
|
|
70992
|
+
var import_node_crypto20 = require("node:crypto");
|
|
70033
70993
|
var import_node_fs35 = require("node:fs");
|
|
70034
70994
|
var import_node_path31 = require("node:path");
|
|
70035
70995
|
var PREFIX = "floless-export-tmp-";
|
|
@@ -70060,7 +71020,7 @@ function removeScratch(path, appsRoot) {
|
|
|
70060
71020
|
}
|
|
70061
71021
|
function createExportCompanion(ownerId, sink, appsRoot = defaultAppsRoot()) {
|
|
70062
71022
|
const safeOwner = ownerId.replace(/[^a-z0-9._-]/gi, "-").slice(0, 80) || "app";
|
|
70063
|
-
const token = (0,
|
|
71023
|
+
const token = (0, import_node_crypto20.randomUUID)();
|
|
70064
71024
|
const id = `${PREFIX}${safeOwner}-${sink}-${token}`;
|
|
70065
71025
|
const root4 = (0, import_node_path31.resolve)(appsRoot);
|
|
70066
71026
|
const path = (0, import_node_path31.resolve)(root4, id);
|
|
@@ -71535,7 +72495,7 @@ function unregisterAutostart() {
|
|
|
71535
72495
|
|
|
71536
72496
|
// updater.ts
|
|
71537
72497
|
var import_node_child_process7 = require("node:child_process");
|
|
71538
|
-
var
|
|
72498
|
+
var import_node_crypto21 = require("node:crypto");
|
|
71539
72499
|
var import_node_fs42 = require("node:fs");
|
|
71540
72500
|
var import_node_stream3 = require("node:stream");
|
|
71541
72501
|
var import_promises3 = require("node:stream/promises");
|
|
@@ -71632,8 +72592,15 @@ function versionGt(a, b) {
|
|
|
71632
72592
|
}
|
|
71633
72593
|
var NPM_LATEST_URL = "https://registry.npmjs.org/@floless/app/latest";
|
|
71634
72594
|
var NPM_UPDATE_COMMAND = "npm i -g @floless/app@latest";
|
|
71635
|
-
async function checkNpmUpdate(cur) {
|
|
71636
|
-
const base = {
|
|
72595
|
+
async function checkNpmUpdate(cur, channel = "npm") {
|
|
72596
|
+
const base = {
|
|
72597
|
+
supported: true,
|
|
72598
|
+
channel,
|
|
72599
|
+
currentVersion: cur,
|
|
72600
|
+
// CHANNEL === 'win' + Update.exe: there is no desktop build for any other OS to point at.
|
|
72601
|
+
desktopAvailable: process.platform === "win32",
|
|
72602
|
+
...channel === "npx" ? { transient: true } : {}
|
|
72603
|
+
};
|
|
71637
72604
|
try {
|
|
71638
72605
|
const res = await fetch(NPM_LATEST_URL, { redirect: "follow", signal: AbortSignal.timeout(FEED_TIMEOUT_MS) });
|
|
71639
72606
|
if (!res.ok) return { ...base, updateAvailable: false, reason: `npm registry returned HTTP ${res.status}` };
|
|
@@ -71649,7 +72616,7 @@ async function checkNpmUpdate(cur) {
|
|
|
71649
72616
|
async function checkForUpdate() {
|
|
71650
72617
|
const cur = currentVersion();
|
|
71651
72618
|
const channel = appChannel();
|
|
71652
|
-
if (channel === "npm") return checkNpmUpdate(cur);
|
|
72619
|
+
if (channel === "npm" || channel === "npx") return checkNpmUpdate(cur, channel);
|
|
71653
72620
|
if (channel !== "desktop") {
|
|
71654
72621
|
return {
|
|
71655
72622
|
supported: false,
|
|
@@ -71694,7 +72661,7 @@ async function checkForUpdate() {
|
|
|
71694
72661
|
return { supported: true, currentVersion: cur, updateAvailable: true, targetVersion: latest.Version, asset: latest };
|
|
71695
72662
|
}
|
|
71696
72663
|
async function sha1OfFile(path) {
|
|
71697
|
-
const hash2 = (0,
|
|
72664
|
+
const hash2 = (0, import_node_crypto21.createHash)("sha1");
|
|
71698
72665
|
await (0, import_promises3.pipeline)((0, import_node_fs42.createReadStream)(path), hash2);
|
|
71699
72666
|
return hash2.digest("hex").toUpperCase();
|
|
71700
72667
|
}
|
|
@@ -71859,12 +72826,12 @@ var CACHE_TTL_MS = 5 * 6e4;
|
|
|
71859
72826
|
async function getJson(url, headers = {}) {
|
|
71860
72827
|
try {
|
|
71861
72828
|
const res = await fetch(url, { headers, signal: AbortSignal.timeout(FETCH_TIMEOUT_MS) });
|
|
71862
|
-
let
|
|
72829
|
+
let json2 = null;
|
|
71863
72830
|
try {
|
|
71864
|
-
|
|
72831
|
+
json2 = await res.json();
|
|
71865
72832
|
} catch {
|
|
71866
72833
|
}
|
|
71867
|
-
return { status: res.status, json };
|
|
72834
|
+
return { status: res.status, json: json2 };
|
|
71868
72835
|
} catch {
|
|
71869
72836
|
return null;
|
|
71870
72837
|
}
|
|
@@ -71989,7 +72956,7 @@ function ping() {
|
|
|
71989
72956
|
});
|
|
71990
72957
|
});
|
|
71991
72958
|
}
|
|
71992
|
-
function
|
|
72959
|
+
function probeRunning() {
|
|
71993
72960
|
return new Promise((resolve11) => {
|
|
71994
72961
|
const req = import_node_http.default.get(HEALTH_URL, { timeout: 1500 }, (res) => {
|
|
71995
72962
|
let body = "";
|
|
@@ -71998,16 +72965,17 @@ function probeVersion() {
|
|
|
71998
72965
|
});
|
|
71999
72966
|
res.on("end", () => {
|
|
72000
72967
|
try {
|
|
72001
|
-
|
|
72968
|
+
const j = JSON.parse(body);
|
|
72969
|
+
resolve11({ version: j.appVersion || null, channel: j.appChannel || null });
|
|
72002
72970
|
} catch {
|
|
72003
|
-
resolve11(null);
|
|
72971
|
+
resolve11({ version: null, channel: null });
|
|
72004
72972
|
}
|
|
72005
72973
|
});
|
|
72006
72974
|
});
|
|
72007
|
-
req.on("error", () => resolve11(null));
|
|
72975
|
+
req.on("error", () => resolve11({ version: null, channel: null }));
|
|
72008
72976
|
req.on("timeout", () => {
|
|
72009
72977
|
req.destroy();
|
|
72010
|
-
resolve11(null);
|
|
72978
|
+
resolve11({ version: null, channel: null });
|
|
72011
72979
|
});
|
|
72012
72980
|
});
|
|
72013
72981
|
}
|
|
@@ -72020,11 +72988,16 @@ function cmpVersion(a, b) {
|
|
|
72020
72988
|
}
|
|
72021
72989
|
return 0;
|
|
72022
72990
|
}
|
|
72023
|
-
|
|
72991
|
+
var EVICTABLE_CHANNELS = /* @__PURE__ */ new Set(["npm", "npx", "dev"]);
|
|
72992
|
+
function shouldTakeOver(runningVersion, selfVersion, channels = {}) {
|
|
72024
72993
|
if (!runningVersion || !selfVersion) return false;
|
|
72025
|
-
|
|
72994
|
+
const cmp2 = cmpVersion(selfVersion, runningVersion);
|
|
72995
|
+
if (cmp2 !== 0) return cmp2 > 0;
|
|
72996
|
+
const { running = null, self = null } = channels;
|
|
72997
|
+
return self === "desktop" && EVICTABLE_CHANNELS.has(running);
|
|
72026
72998
|
}
|
|
72027
72999
|
var _selfVersion = null;
|
|
73000
|
+
var _selfChannel = null;
|
|
72028
73001
|
async function waitHealthy(timeoutMs = 3e4) {
|
|
72029
73002
|
const deadline = Date.now() + timeoutMs;
|
|
72030
73003
|
while (Date.now() < deadline) {
|
|
@@ -72087,14 +73060,14 @@ async function ensureServerUp() {
|
|
|
72087
73060
|
async function cmdOpen() {
|
|
72088
73061
|
const postUpdate = consumePostUpdateMarker();
|
|
72089
73062
|
if (await ping()) {
|
|
72090
|
-
const running = await
|
|
72091
|
-
if (shouldTakeOver(running, _selfVersion)) {
|
|
72092
|
-
log(`floless.app v${running} is already running on ${PORT}; this build is v${_selfVersion} \u2014 taking over`);
|
|
73063
|
+
const running = await probeRunning();
|
|
73064
|
+
if (shouldTakeOver(running.version, _selfVersion, { running: running.channel, self: _selfChannel })) {
|
|
73065
|
+
log(`floless.app v${running.version} (${running.channel ?? "unknown"}) is already running on ${PORT}; this build is v${_selfVersion} (${_selfChannel ?? "unknown"}) \u2014 taking over`);
|
|
72093
73066
|
stopServer();
|
|
72094
73067
|
await new Promise((r) => setTimeout(r, 500));
|
|
72095
73068
|
await ensureServerUp();
|
|
72096
73069
|
} else {
|
|
72097
|
-
log(`already running${running ? ` (v${running})` : ""}`);
|
|
73070
|
+
log(`already running${running.version ? ` (v${running.version}${running.channel ? `, ${running.channel}` : ""})` : ""}`);
|
|
72098
73071
|
}
|
|
72099
73072
|
} else {
|
|
72100
73073
|
await ensureServerUp();
|
|
@@ -72161,10 +73134,10 @@ function parseTeardownFlags(argv = []) {
|
|
|
72161
73134
|
keepAware: argv.includes("--keep-aware")
|
|
72162
73135
|
};
|
|
72163
73136
|
}
|
|
72164
|
-
function parseProcessList(
|
|
73137
|
+
function parseProcessList(json2) {
|
|
72165
73138
|
let parsed;
|
|
72166
73139
|
try {
|
|
72167
|
-
parsed = JSON.parse(
|
|
73140
|
+
parsed = JSON.parse(json2 || "[]");
|
|
72168
73141
|
} catch {
|
|
72169
73142
|
return [];
|
|
72170
73143
|
}
|
|
@@ -72283,6 +73256,11 @@ function parseAction(arg) {
|
|
|
72283
73256
|
return cmd;
|
|
72284
73257
|
}
|
|
72285
73258
|
async function cmdUpdate() {
|
|
73259
|
+
if (/(^|[\\/])_npx([\\/]|$)/.test((0, import_node_url3.fileURLToPath)(__import_meta_url))) {
|
|
73260
|
+
log("this copy is temporary (started with npx), so it cannot update itself");
|
|
73261
|
+
log('install a permanent one with "npm i -g @floless/app@latest", then close FloLess and open it again');
|
|
73262
|
+
return;
|
|
73263
|
+
}
|
|
72286
73264
|
log('this is the npm build \u2014 update it with "npm i -g @floless/app"');
|
|
72287
73265
|
log('(the installer build self-updates via "floless-app update")');
|
|
72288
73266
|
}
|
|
@@ -72346,8 +73324,9 @@ async function cmdUninstall(flags = {}) {
|
|
|
72346
73324
|
log("done. Finally, remove floless.app itself with: npm uninstall -g @floless/app");
|
|
72347
73325
|
}
|
|
72348
73326
|
var ACTIONS = { open: cmdOpen, start: cmdStart, supervise: cmdSupervise, stop: cmdStop, restart: cmdRestart, login: cmdLogin, update: cmdUpdate, uninstall: cmdUninstall };
|
|
72349
|
-
async function runAction(arg, flagArgv = [], selfVersion = null) {
|
|
73327
|
+
async function runAction(arg, flagArgv = [], selfVersion = null, selfChannel = null) {
|
|
72350
73328
|
_selfVersion = selfVersion;
|
|
73329
|
+
_selfChannel = selfChannel;
|
|
72351
73330
|
const cmd = parseAction(arg);
|
|
72352
73331
|
const action = ACTIONS[cmd];
|
|
72353
73332
|
if (!action) {
|
|
@@ -74569,6 +75548,11 @@ async function startServer() {
|
|
|
74569
75548
|
refusedContractWrites,
|
|
74570
75549
|
appVersion: appVersion(),
|
|
74571
75550
|
// the installed build (sq.version), so it's scriptable
|
|
75551
|
+
// How this build is distributed. Published so ANOTHER build's launcher can tell whether the
|
|
75552
|
+
// instance already holding the port can self-update: on equal versions the desktop build takes
|
|
75553
|
+
// over one that cannot (see `shouldTakeOver`). Without this the two are indistinguishable over
|
|
75554
|
+
// HTTP and the weaker instance keeps the port.
|
|
75555
|
+
appChannel: appChannel(),
|
|
74572
75556
|
webBase: webBaseUrl(),
|
|
74573
75557
|
// channel-correct public site base, for the changelog deep-link
|
|
74574
75558
|
awareVersion: awareInstalledVersion() ?? bs.awareVersion,
|
|
@@ -75435,7 +76419,7 @@ async function startServer() {
|
|
|
75435
76419
|
}
|
|
75436
76420
|
async function dropExportSourceId(appId, project) {
|
|
75437
76421
|
const ownerId = project ? await getOrCreateProjectExportSourceId(project) : await getOrCreateWorkflowExportSourceId(appId);
|
|
75438
|
-
return deriveDropExportSourceId(project ? "project" : "workflow", ownerId, (0,
|
|
76422
|
+
return deriveDropExportSourceId(project ? "project" : "workflow", ownerId, (0, import_node_crypto22.randomUUID)());
|
|
75439
76423
|
}
|
|
75440
76424
|
app.post("/api/contract/:appId/export-ifc", async (req, reply) => {
|
|
75441
76425
|
const appId = req.params.appId;
|
|
@@ -75504,7 +76488,7 @@ async function startServer() {
|
|
|
75504
76488
|
index: parseStepData(artifactBytes),
|
|
75505
76489
|
bytes: artifactBytes
|
|
75506
76490
|
});
|
|
75507
|
-
const expectedContentSha256 = (0,
|
|
76491
|
+
const expectedContentSha256 = (0, import_node_crypto22.createHash)("sha256").update(artifactBytes).digest("hex");
|
|
75508
76492
|
const transition = project && projectSnapshot ? prepareProjectExport(project, {
|
|
75509
76493
|
kind: "ifc",
|
|
75510
76494
|
filename,
|
|
@@ -76233,7 +77217,7 @@ async function startServer() {
|
|
|
76233
77217
|
(0, import_node_fs46.rmSync)(tempHome, { recursive: true, force: true });
|
|
76234
77218
|
return reply.status(502).send({ ok: false, error: `build produced output at ${result.agentDir} but no manifest.yaml` });
|
|
76235
77219
|
}
|
|
76236
|
-
const token = (0,
|
|
77220
|
+
const token = (0, import_node_crypto22.randomUUID)();
|
|
76237
77221
|
registerStage(token, tempHome, result.agentId);
|
|
76238
77222
|
const preview2 = buildPreview(manifest, sourceKind, sourceRef, token);
|
|
76239
77223
|
if ((0, import_node_fs46.existsSync)((0, import_node_path43.join)(graftAgentsDir(), result.agentId))) {
|
|
@@ -77088,7 +78072,7 @@ async function main() {
|
|
|
77088
78072
|
if (/flolessapp\.exe$/i.test(process.execPath)) {
|
|
77089
78073
|
ensureAutostart(resolveRealInstallExe(process.execPath));
|
|
77090
78074
|
}
|
|
77091
|
-
await runAction(argv[0], [], appVersion());
|
|
78075
|
+
await runAction(argv[0], [], appVersion(), appChannel());
|
|
77092
78076
|
}
|
|
77093
78077
|
main().catch((err2) => {
|
|
77094
78078
|
const msg = err2 instanceof Error ? err2.message : String(err2);
|