@floless/app 0.129.0 → 0.130.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/floless-server.cjs +1390 -651
- package/dist/schemas/steel.model.v2.schema.json +28 -8
- package/dist/web/steel-3d-view.js +339 -32
- package/dist/web/steel-editor.html +476 -148
- package/dist/web/vector-3d.html +80 -13
- package/dist/web/vector-editor.html +66 -21
- package/package.json +4 -1
package/dist/floless-server.cjs
CHANGED
|
@@ -11213,13 +11213,13 @@ var require_context = __commonJS({
|
|
|
11213
11213
|
this.server = server;
|
|
11214
11214
|
}
|
|
11215
11215
|
function defaultSchemaErrorFormatter(errors, dataVar) {
|
|
11216
|
-
let
|
|
11216
|
+
let text5 = "";
|
|
11217
11217
|
const separator = ", ";
|
|
11218
11218
|
for (let i = 0; i !== errors.length; ++i) {
|
|
11219
11219
|
const e = errors[i];
|
|
11220
|
-
|
|
11220
|
+
text5 += dataVar + (e.instancePath || "") + " " + e.message + separator;
|
|
11221
11221
|
}
|
|
11222
|
-
return new Error(
|
|
11222
|
+
return new Error(text5.slice(0, -separator.length));
|
|
11223
11223
|
}
|
|
11224
11224
|
module2.exports = Context;
|
|
11225
11225
|
}
|
|
@@ -11915,20 +11915,20 @@ var require_secure_json_parse = __commonJS({
|
|
|
11915
11915
|
var hasBuffer = typeof Buffer !== "undefined";
|
|
11916
11916
|
var suspectProtoRx = /"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/;
|
|
11917
11917
|
var suspectConstructorRx = /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;
|
|
11918
|
-
function _parse(
|
|
11918
|
+
function _parse(text5, reviver, options) {
|
|
11919
11919
|
if (options == null) {
|
|
11920
11920
|
if (reviver !== null && typeof reviver === "object") {
|
|
11921
11921
|
options = reviver;
|
|
11922
11922
|
reviver = void 0;
|
|
11923
11923
|
}
|
|
11924
11924
|
}
|
|
11925
|
-
if (hasBuffer && Buffer.isBuffer(
|
|
11926
|
-
|
|
11925
|
+
if (hasBuffer && Buffer.isBuffer(text5)) {
|
|
11926
|
+
text5 = text5.toString();
|
|
11927
11927
|
}
|
|
11928
|
-
if (
|
|
11929
|
-
|
|
11928
|
+
if (text5 && text5.charCodeAt(0) === 65279) {
|
|
11929
|
+
text5 = text5.slice(1);
|
|
11930
11930
|
}
|
|
11931
|
-
const obj3 = JSON.parse(
|
|
11931
|
+
const obj3 = JSON.parse(text5, reviver);
|
|
11932
11932
|
if (obj3 === null || typeof obj3 !== "object") {
|
|
11933
11933
|
return obj3;
|
|
11934
11934
|
}
|
|
@@ -11938,15 +11938,15 @@ var require_secure_json_parse = __commonJS({
|
|
|
11938
11938
|
return obj3;
|
|
11939
11939
|
}
|
|
11940
11940
|
if (protoAction !== "ignore" && constructorAction !== "ignore") {
|
|
11941
|
-
if (suspectProtoRx.test(
|
|
11941
|
+
if (suspectProtoRx.test(text5) === false && suspectConstructorRx.test(text5) === false) {
|
|
11942
11942
|
return obj3;
|
|
11943
11943
|
}
|
|
11944
11944
|
} else if (protoAction !== "ignore" && constructorAction === "ignore") {
|
|
11945
|
-
if (suspectProtoRx.test(
|
|
11945
|
+
if (suspectProtoRx.test(text5) === false) {
|
|
11946
11946
|
return obj3;
|
|
11947
11947
|
}
|
|
11948
11948
|
} else {
|
|
11949
|
-
if (suspectConstructorRx.test(
|
|
11949
|
+
if (suspectConstructorRx.test(text5) === false) {
|
|
11950
11950
|
return obj3;
|
|
11951
11951
|
}
|
|
11952
11952
|
}
|
|
@@ -11984,20 +11984,20 @@ var require_secure_json_parse = __commonJS({
|
|
|
11984
11984
|
}
|
|
11985
11985
|
return obj3;
|
|
11986
11986
|
}
|
|
11987
|
-
function parse2(
|
|
11987
|
+
function parse2(text5, reviver, options) {
|
|
11988
11988
|
const { stackTraceLimit } = Error;
|
|
11989
11989
|
Error.stackTraceLimit = 0;
|
|
11990
11990
|
try {
|
|
11991
|
-
return _parse(
|
|
11991
|
+
return _parse(text5, reviver, options);
|
|
11992
11992
|
} finally {
|
|
11993
11993
|
Error.stackTraceLimit = stackTraceLimit;
|
|
11994
11994
|
}
|
|
11995
11995
|
}
|
|
11996
|
-
function safeParse(
|
|
11996
|
+
function safeParse(text5, reviver) {
|
|
11997
11997
|
const { stackTraceLimit } = Error;
|
|
11998
11998
|
Error.stackTraceLimit = 0;
|
|
11999
11999
|
try {
|
|
12000
|
-
return _parse(
|
|
12000
|
+
return _parse(text5, reviver, { safe: true });
|
|
12001
12001
|
} catch {
|
|
12002
12002
|
return void 0;
|
|
12003
12003
|
} finally {
|
|
@@ -12406,10 +12406,10 @@ var require_code = __commonJS({
|
|
|
12406
12406
|
}
|
|
12407
12407
|
get names() {
|
|
12408
12408
|
var _a2;
|
|
12409
|
-
return (_a2 = this._names) !== null && _a2 !== void 0 ? _a2 : this._names = this._items.reduce((
|
|
12409
|
+
return (_a2 = this._names) !== null && _a2 !== void 0 ? _a2 : this._names = this._items.reduce((names2, c) => {
|
|
12410
12410
|
if (c instanceof Name)
|
|
12411
|
-
|
|
12412
|
-
return
|
|
12411
|
+
names2[c.str] = (names2[c.str] || 0) + 1;
|
|
12412
|
+
return names2;
|
|
12413
12413
|
}, {});
|
|
12414
12414
|
}
|
|
12415
12415
|
};
|
|
@@ -12735,11 +12735,11 @@ var require_codegen = __commonJS({
|
|
|
12735
12735
|
const rhs = this.rhs === void 0 ? "" : ` = ${this.rhs}`;
|
|
12736
12736
|
return `${varKind} ${this.name}${rhs};` + _n;
|
|
12737
12737
|
}
|
|
12738
|
-
optimizeNames(
|
|
12739
|
-
if (!
|
|
12738
|
+
optimizeNames(names2, constants2) {
|
|
12739
|
+
if (!names2[this.name.str])
|
|
12740
12740
|
return;
|
|
12741
12741
|
if (this.rhs)
|
|
12742
|
-
this.rhs = optimizeExpr(this.rhs,
|
|
12742
|
+
this.rhs = optimizeExpr(this.rhs, names2, constants2);
|
|
12743
12743
|
return this;
|
|
12744
12744
|
}
|
|
12745
12745
|
get names() {
|
|
@@ -12756,15 +12756,15 @@ var require_codegen = __commonJS({
|
|
|
12756
12756
|
render({ _n }) {
|
|
12757
12757
|
return `${this.lhs} = ${this.rhs};` + _n;
|
|
12758
12758
|
}
|
|
12759
|
-
optimizeNames(
|
|
12760
|
-
if (this.lhs instanceof code_1.Name && !
|
|
12759
|
+
optimizeNames(names2, constants2) {
|
|
12760
|
+
if (this.lhs instanceof code_1.Name && !names2[this.lhs.str] && !this.sideEffects)
|
|
12761
12761
|
return;
|
|
12762
|
-
this.rhs = optimizeExpr(this.rhs,
|
|
12762
|
+
this.rhs = optimizeExpr(this.rhs, names2, constants2);
|
|
12763
12763
|
return this;
|
|
12764
12764
|
}
|
|
12765
12765
|
get names() {
|
|
12766
|
-
const
|
|
12767
|
-
return addExprNames(
|
|
12766
|
+
const names2 = this.lhs instanceof code_1.Name ? {} : { ...this.lhs.names };
|
|
12767
|
+
return addExprNames(names2, this.rhs);
|
|
12768
12768
|
}
|
|
12769
12769
|
};
|
|
12770
12770
|
var AssignOp = class extends Assign {
|
|
@@ -12820,8 +12820,8 @@ var require_codegen = __commonJS({
|
|
|
12820
12820
|
optimizeNodes() {
|
|
12821
12821
|
return `${this.code}` ? this : void 0;
|
|
12822
12822
|
}
|
|
12823
|
-
optimizeNames(
|
|
12824
|
-
this.code = optimizeExpr(this.code,
|
|
12823
|
+
optimizeNames(names2, constants2) {
|
|
12824
|
+
this.code = optimizeExpr(this.code, names2, constants2);
|
|
12825
12825
|
return this;
|
|
12826
12826
|
}
|
|
12827
12827
|
get names() {
|
|
@@ -12850,20 +12850,20 @@ var require_codegen = __commonJS({
|
|
|
12850
12850
|
}
|
|
12851
12851
|
return nodes.length > 0 ? this : void 0;
|
|
12852
12852
|
}
|
|
12853
|
-
optimizeNames(
|
|
12853
|
+
optimizeNames(names2, constants2) {
|
|
12854
12854
|
const { nodes } = this;
|
|
12855
12855
|
let i = nodes.length;
|
|
12856
12856
|
while (i--) {
|
|
12857
12857
|
const n = nodes[i];
|
|
12858
|
-
if (n.optimizeNames(
|
|
12858
|
+
if (n.optimizeNames(names2, constants2))
|
|
12859
12859
|
continue;
|
|
12860
|
-
subtractNames(
|
|
12860
|
+
subtractNames(names2, n.names);
|
|
12861
12861
|
nodes.splice(i, 1);
|
|
12862
12862
|
}
|
|
12863
12863
|
return nodes.length > 0 ? this : void 0;
|
|
12864
12864
|
}
|
|
12865
12865
|
get names() {
|
|
12866
|
-
return this.nodes.reduce((
|
|
12866
|
+
return this.nodes.reduce((names2, n) => addNames(names2, n.names), {});
|
|
12867
12867
|
}
|
|
12868
12868
|
};
|
|
12869
12869
|
var BlockNode = class extends ParentNode {
|
|
@@ -12908,20 +12908,20 @@ var require_codegen = __commonJS({
|
|
|
12908
12908
|
return void 0;
|
|
12909
12909
|
return this;
|
|
12910
12910
|
}
|
|
12911
|
-
optimizeNames(
|
|
12911
|
+
optimizeNames(names2, constants2) {
|
|
12912
12912
|
var _a2;
|
|
12913
|
-
this.else = (_a2 = this.else) === null || _a2 === void 0 ? void 0 : _a2.optimizeNames(
|
|
12914
|
-
if (!(super.optimizeNames(
|
|
12913
|
+
this.else = (_a2 = this.else) === null || _a2 === void 0 ? void 0 : _a2.optimizeNames(names2, constants2);
|
|
12914
|
+
if (!(super.optimizeNames(names2, constants2) || this.else))
|
|
12915
12915
|
return;
|
|
12916
|
-
this.condition = optimizeExpr(this.condition,
|
|
12916
|
+
this.condition = optimizeExpr(this.condition, names2, constants2);
|
|
12917
12917
|
return this;
|
|
12918
12918
|
}
|
|
12919
12919
|
get names() {
|
|
12920
|
-
const
|
|
12921
|
-
addExprNames(
|
|
12920
|
+
const names2 = super.names;
|
|
12921
|
+
addExprNames(names2, this.condition);
|
|
12922
12922
|
if (this.else)
|
|
12923
|
-
addNames(
|
|
12924
|
-
return
|
|
12923
|
+
addNames(names2, this.else.names);
|
|
12924
|
+
return names2;
|
|
12925
12925
|
}
|
|
12926
12926
|
};
|
|
12927
12927
|
If.kind = "if";
|
|
@@ -12936,10 +12936,10 @@ var require_codegen = __commonJS({
|
|
|
12936
12936
|
render(opts) {
|
|
12937
12937
|
return `for(${this.iteration})` + super.render(opts);
|
|
12938
12938
|
}
|
|
12939
|
-
optimizeNames(
|
|
12940
|
-
if (!super.optimizeNames(
|
|
12939
|
+
optimizeNames(names2, constants2) {
|
|
12940
|
+
if (!super.optimizeNames(names2, constants2))
|
|
12941
12941
|
return;
|
|
12942
|
-
this.iteration = optimizeExpr(this.iteration,
|
|
12942
|
+
this.iteration = optimizeExpr(this.iteration, names2, constants2);
|
|
12943
12943
|
return this;
|
|
12944
12944
|
}
|
|
12945
12945
|
get names() {
|
|
@@ -12960,8 +12960,8 @@ var require_codegen = __commonJS({
|
|
|
12960
12960
|
return `for(${varKind} ${name}=${from}; ${name}<${to}; ${name}++)` + super.render(opts);
|
|
12961
12961
|
}
|
|
12962
12962
|
get names() {
|
|
12963
|
-
const
|
|
12964
|
-
return addExprNames(
|
|
12963
|
+
const names2 = addExprNames(super.names, this.from);
|
|
12964
|
+
return addExprNames(names2, this.to);
|
|
12965
12965
|
}
|
|
12966
12966
|
};
|
|
12967
12967
|
var ForIter = class extends For {
|
|
@@ -12975,10 +12975,10 @@ var require_codegen = __commonJS({
|
|
|
12975
12975
|
render(opts) {
|
|
12976
12976
|
return `for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})` + super.render(opts);
|
|
12977
12977
|
}
|
|
12978
|
-
optimizeNames(
|
|
12979
|
-
if (!super.optimizeNames(
|
|
12978
|
+
optimizeNames(names2, constants2) {
|
|
12979
|
+
if (!super.optimizeNames(names2, constants2))
|
|
12980
12980
|
return;
|
|
12981
|
-
this.iterable = optimizeExpr(this.iterable,
|
|
12981
|
+
this.iterable = optimizeExpr(this.iterable, names2, constants2);
|
|
12982
12982
|
return this;
|
|
12983
12983
|
}
|
|
12984
12984
|
get names() {
|
|
@@ -13020,20 +13020,20 @@ var require_codegen = __commonJS({
|
|
|
13020
13020
|
(_b2 = this.finally) === null || _b2 === void 0 ? void 0 : _b2.optimizeNodes();
|
|
13021
13021
|
return this;
|
|
13022
13022
|
}
|
|
13023
|
-
optimizeNames(
|
|
13023
|
+
optimizeNames(names2, constants2) {
|
|
13024
13024
|
var _a2, _b2;
|
|
13025
|
-
super.optimizeNames(
|
|
13026
|
-
(_a2 = this.catch) === null || _a2 === void 0 ? void 0 : _a2.optimizeNames(
|
|
13027
|
-
(_b2 = this.finally) === null || _b2 === void 0 ? void 0 : _b2.optimizeNames(
|
|
13025
|
+
super.optimizeNames(names2, constants2);
|
|
13026
|
+
(_a2 = this.catch) === null || _a2 === void 0 ? void 0 : _a2.optimizeNames(names2, constants2);
|
|
13027
|
+
(_b2 = this.finally) === null || _b2 === void 0 ? void 0 : _b2.optimizeNames(names2, constants2);
|
|
13028
13028
|
return this;
|
|
13029
13029
|
}
|
|
13030
13030
|
get names() {
|
|
13031
|
-
const
|
|
13031
|
+
const names2 = super.names;
|
|
13032
13032
|
if (this.catch)
|
|
13033
|
-
addNames(
|
|
13033
|
+
addNames(names2, this.catch.names);
|
|
13034
13034
|
if (this.finally)
|
|
13035
|
-
addNames(
|
|
13036
|
-
return
|
|
13035
|
+
addNames(names2, this.finally.names);
|
|
13036
|
+
return names2;
|
|
13037
13037
|
}
|
|
13038
13038
|
};
|
|
13039
13039
|
var Catch = class extends BlockNode {
|
|
@@ -13317,15 +13317,15 @@ var require_codegen = __commonJS({
|
|
|
13317
13317
|
}
|
|
13318
13318
|
};
|
|
13319
13319
|
exports2.CodeGen = CodeGen;
|
|
13320
|
-
function addNames(
|
|
13320
|
+
function addNames(names2, from) {
|
|
13321
13321
|
for (const n in from)
|
|
13322
|
-
|
|
13323
|
-
return
|
|
13322
|
+
names2[n] = (names2[n] || 0) + (from[n] || 0);
|
|
13323
|
+
return names2;
|
|
13324
13324
|
}
|
|
13325
|
-
function addExprNames(
|
|
13326
|
-
return from instanceof code_1._CodeOrName ? addNames(
|
|
13325
|
+
function addExprNames(names2, from) {
|
|
13326
|
+
return from instanceof code_1._CodeOrName ? addNames(names2, from.names) : names2;
|
|
13327
13327
|
}
|
|
13328
|
-
function optimizeExpr(expr,
|
|
13328
|
+
function optimizeExpr(expr, names2, constants2) {
|
|
13329
13329
|
if (expr instanceof code_1.Name)
|
|
13330
13330
|
return replaceName(expr);
|
|
13331
13331
|
if (!canOptimize(expr))
|
|
@@ -13341,18 +13341,18 @@ var require_codegen = __commonJS({
|
|
|
13341
13341
|
}, []));
|
|
13342
13342
|
function replaceName(n) {
|
|
13343
13343
|
const c = constants2[n.str];
|
|
13344
|
-
if (c === void 0 ||
|
|
13344
|
+
if (c === void 0 || names2[n.str] !== 1)
|
|
13345
13345
|
return n;
|
|
13346
|
-
delete
|
|
13346
|
+
delete names2[n.str];
|
|
13347
13347
|
return c;
|
|
13348
13348
|
}
|
|
13349
13349
|
function canOptimize(e) {
|
|
13350
|
-
return e instanceof code_1._Code && e._items.some((c) => c instanceof code_1.Name &&
|
|
13350
|
+
return e instanceof code_1._Code && e._items.some((c) => c instanceof code_1.Name && names2[c.str] === 1 && constants2[c.str] !== void 0);
|
|
13351
13351
|
}
|
|
13352
13352
|
}
|
|
13353
|
-
function subtractNames(
|
|
13353
|
+
function subtractNames(names2, from) {
|
|
13354
13354
|
for (const n in from)
|
|
13355
|
-
|
|
13355
|
+
names2[n] = (names2[n] || 0) - (from[n] || 0);
|
|
13356
13356
|
}
|
|
13357
13357
|
function not(x) {
|
|
13358
13358
|
return typeof x == "boolean" || typeof x == "number" || x === null ? !x : (0, code_1._)`!${par(x)}`;
|
|
@@ -13550,7 +13550,7 @@ var require_names = __commonJS({
|
|
|
13550
13550
|
"use strict";
|
|
13551
13551
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
13552
13552
|
var codegen_1 = require_codegen();
|
|
13553
|
-
var
|
|
13553
|
+
var names2 = {
|
|
13554
13554
|
// validation function arguments
|
|
13555
13555
|
data: new codegen_1.Name("data"),
|
|
13556
13556
|
// data passed to validation function
|
|
@@ -13579,7 +13579,7 @@ var require_names = __commonJS({
|
|
|
13579
13579
|
jsonLen: new codegen_1.Name("jsonLen"),
|
|
13580
13580
|
jsonPart: new codegen_1.Name("jsonPart")
|
|
13581
13581
|
};
|
|
13582
|
-
exports2.default =
|
|
13582
|
+
exports2.default = names2;
|
|
13583
13583
|
}
|
|
13584
13584
|
});
|
|
13585
13585
|
|
|
@@ -14545,20 +14545,20 @@ var require_resolve = __commonJS({
|
|
|
14545
14545
|
return false;
|
|
14546
14546
|
}
|
|
14547
14547
|
function countKeys(schema) {
|
|
14548
|
-
let
|
|
14548
|
+
let count2 = 0;
|
|
14549
14549
|
for (const key in schema) {
|
|
14550
14550
|
if (key === "$ref")
|
|
14551
14551
|
return Infinity;
|
|
14552
|
-
|
|
14552
|
+
count2++;
|
|
14553
14553
|
if (SIMPLE_INLINED.has(key))
|
|
14554
14554
|
continue;
|
|
14555
14555
|
if (typeof schema[key] == "object") {
|
|
14556
|
-
(0, util_1.eachItem)(schema[key], (sch) =>
|
|
14556
|
+
(0, util_1.eachItem)(schema[key], (sch) => count2 += countKeys(sch));
|
|
14557
14557
|
}
|
|
14558
|
-
if (
|
|
14558
|
+
if (count2 === Infinity)
|
|
14559
14559
|
return Infinity;
|
|
14560
14560
|
}
|
|
14561
|
-
return
|
|
14561
|
+
return count2;
|
|
14562
14562
|
}
|
|
14563
14563
|
function getFullPath(resolver, id = "", normalize2) {
|
|
14564
14564
|
if (normalize2 !== false)
|
|
@@ -16640,7 +16640,7 @@ var require_core = __commonJS({
|
|
|
16640
16640
|
errorsText(errors = this.errors, { separator = ", ", dataVar = "data" } = {}) {
|
|
16641
16641
|
if (!errors || errors.length === 0)
|
|
16642
16642
|
return "No errors";
|
|
16643
|
-
return errors.map((e) => `${dataVar}${e.instancePath} ${e.message}`).reduce((
|
|
16643
|
+
return errors.map((e) => `${dataVar}${e.instancePath} ${e.message}`).reduce((text5, msg) => text5 + separator + msg);
|
|
16644
16644
|
}
|
|
16645
16645
|
$dataMetaSchema(metaSchema, keywordsJsonPointers) {
|
|
16646
16646
|
const rules = this.RULES.all;
|
|
@@ -17730,8 +17730,8 @@ var require_contains = __commonJS({
|
|
|
17730
17730
|
cxt.result(valid, () => cxt.reset());
|
|
17731
17731
|
function validateItemsWithCount() {
|
|
17732
17732
|
const schValid = gen.name("_valid");
|
|
17733
|
-
const
|
|
17734
|
-
validateItems(schValid, () => gen.if(schValid, () => checkLimits(
|
|
17733
|
+
const count2 = gen.let("count", 0);
|
|
17734
|
+
validateItems(schValid, () => gen.if(schValid, () => checkLimits(count2)));
|
|
17735
17735
|
}
|
|
17736
17736
|
function validateItems(_valid, block) {
|
|
17737
17737
|
gen.forRange("i", 0, len, (i) => {
|
|
@@ -17744,16 +17744,16 @@ var require_contains = __commonJS({
|
|
|
17744
17744
|
block();
|
|
17745
17745
|
});
|
|
17746
17746
|
}
|
|
17747
|
-
function checkLimits(
|
|
17748
|
-
gen.code((0, codegen_1._)`${
|
|
17747
|
+
function checkLimits(count2) {
|
|
17748
|
+
gen.code((0, codegen_1._)`${count2}++`);
|
|
17749
17749
|
if (max2 === void 0) {
|
|
17750
|
-
gen.if((0, codegen_1._)`${
|
|
17750
|
+
gen.if((0, codegen_1._)`${count2} >= ${min}`, () => gen.assign(valid, true).break());
|
|
17751
17751
|
} else {
|
|
17752
|
-
gen.if((0, codegen_1._)`${
|
|
17752
|
+
gen.if((0, codegen_1._)`${count2} > ${max2}`, () => gen.assign(valid, false).break());
|
|
17753
17753
|
if (min === 1)
|
|
17754
17754
|
gen.assign(valid, true);
|
|
17755
17755
|
else
|
|
17756
|
-
gen.if((0, codegen_1._)`${
|
|
17756
|
+
gen.if((0, codegen_1._)`${count2} >= ${min}`, () => gen.assign(valid, true));
|
|
17757
17757
|
}
|
|
17758
17758
|
}
|
|
17759
17759
|
}
|
|
@@ -20100,9 +20100,9 @@ var require_parseJson = __commonJS({
|
|
|
20100
20100
|
pos2++;
|
|
20101
20101
|
} else if (c === "u") {
|
|
20102
20102
|
pos2++;
|
|
20103
|
-
let
|
|
20103
|
+
let count2 = 4;
|
|
20104
20104
|
let code = 0;
|
|
20105
|
-
while (
|
|
20105
|
+
while (count2--) {
|
|
20106
20106
|
code <<= 4;
|
|
20107
20107
|
c = s[pos2];
|
|
20108
20108
|
if (c === void 0) {
|
|
@@ -21076,8 +21076,8 @@ var require_standalone = __commonJS({
|
|
|
21076
21076
|
}
|
|
21077
21077
|
function setUsedState(name, state2) {
|
|
21078
21078
|
const { prefix } = name;
|
|
21079
|
-
const
|
|
21080
|
-
|
|
21079
|
+
const names2 = usedValues[prefix] = usedValues[prefix] || /* @__PURE__ */ new Map();
|
|
21080
|
+
names2.set(name, state2);
|
|
21081
21081
|
}
|
|
21082
21082
|
}
|
|
21083
21083
|
}
|
|
@@ -40846,7 +40846,7 @@ var require_plugin2 = __commonJS({
|
|
|
40846
40846
|
"use strict";
|
|
40847
40847
|
var getPluginName = require_getPluginName();
|
|
40848
40848
|
var toCamelCase = require_toCamelCase();
|
|
40849
|
-
var
|
|
40849
|
+
var count2 = 0;
|
|
40850
40850
|
function plugin(fn, options = {}) {
|
|
40851
40851
|
let autoName = false;
|
|
40852
40852
|
if (fn.default !== void 0) {
|
|
@@ -40870,7 +40870,7 @@ var require_plugin2 = __commonJS({
|
|
|
40870
40870
|
}
|
|
40871
40871
|
if (!options.name) {
|
|
40872
40872
|
autoName = true;
|
|
40873
|
-
options.name = getPluginName(fn) + "-auto-" +
|
|
40873
|
+
options.name = getPluginName(fn) + "-auto-" + count2++;
|
|
40874
40874
|
}
|
|
40875
40875
|
fn[/* @__PURE__ */ Symbol.for("skip-override")] = options.encapsulate !== true;
|
|
40876
40876
|
fn[/* @__PURE__ */ Symbol.for("fastify.display-name")] = options.name;
|
|
@@ -41333,8 +41333,8 @@ var require_depd = __commonJS({
|
|
|
41333
41333
|
return deprecate;
|
|
41334
41334
|
}
|
|
41335
41335
|
function eehaslisteners(emitter, type) {
|
|
41336
|
-
var
|
|
41337
|
-
return
|
|
41336
|
+
var count2 = typeof emitter.listenerCount !== "function" ? emitter.listeners(type).length : emitter.listenerCount(type);
|
|
41337
|
+
return count2 > 0;
|
|
41338
41338
|
}
|
|
41339
41339
|
function isignored(namespace) {
|
|
41340
41340
|
if (process.noDeprecation) {
|
|
@@ -42758,7 +42758,7 @@ var require_content_disposition = __commonJS({
|
|
|
42758
42758
|
var index = match[0].length;
|
|
42759
42759
|
var type = match[1].toLowerCase();
|
|
42760
42760
|
var key;
|
|
42761
|
-
var
|
|
42761
|
+
var names2 = [];
|
|
42762
42762
|
var params = {};
|
|
42763
42763
|
var value;
|
|
42764
42764
|
index = PARAM_REGEXP.lastIndex = match[0].substr(-1) === ";" ? index - 1 : index;
|
|
@@ -42769,10 +42769,10 @@ var require_content_disposition = __commonJS({
|
|
|
42769
42769
|
index += match[0].length;
|
|
42770
42770
|
key = match[1].toLowerCase();
|
|
42771
42771
|
value = match[2];
|
|
42772
|
-
if (
|
|
42772
|
+
if (names2.indexOf(key) !== -1) {
|
|
42773
42773
|
throw new TypeError("invalid duplicate parameter");
|
|
42774
42774
|
}
|
|
42775
|
-
|
|
42775
|
+
names2.push(key);
|
|
42776
42776
|
if (key.indexOf("*") + 1 === key.length) {
|
|
42777
42777
|
key = key.slice(0, -1);
|
|
42778
42778
|
value = decodefield(value);
|
|
@@ -43012,7 +43012,7 @@ var require_static = __commonJS({
|
|
|
43012
43012
|
"use strict";
|
|
43013
43013
|
var path = require("node:path");
|
|
43014
43014
|
var { fileURLToPath: fileURLToPath6 } = require("node:url");
|
|
43015
|
-
var { statSync:
|
|
43015
|
+
var { statSync: statSync31 } = require("node:fs");
|
|
43016
43016
|
var { glob } = require_commonjs6();
|
|
43017
43017
|
var fp = require_plugin2();
|
|
43018
43018
|
var send = require_send2();
|
|
@@ -43375,7 +43375,7 @@ var require_static = __commonJS({
|
|
|
43375
43375
|
}
|
|
43376
43376
|
let pathStat;
|
|
43377
43377
|
try {
|
|
43378
|
-
pathStat =
|
|
43378
|
+
pathStat = statSync31(rootPath);
|
|
43379
43379
|
} catch (e) {
|
|
43380
43380
|
if (e.code === "ENOENT") {
|
|
43381
43381
|
fastify.log.warn(`"root" path "${rootPath}" must exist`);
|
|
@@ -43399,7 +43399,7 @@ var require_static = __commonJS({
|
|
|
43399
43399
|
return indexFiles.find((filename) => {
|
|
43400
43400
|
const p = path.join(root6, pathname, filename);
|
|
43401
43401
|
try {
|
|
43402
|
-
const stats =
|
|
43402
|
+
const stats = statSync31(p);
|
|
43403
43403
|
return !stats.isDirectory();
|
|
43404
43404
|
} catch {
|
|
43405
43405
|
return false;
|
|
@@ -44009,8 +44009,8 @@ var require_Node = __commonJS({
|
|
|
44009
44009
|
};
|
|
44010
44010
|
const res = toJS.toJS(this, "", ctx);
|
|
44011
44011
|
if (typeof onAnchor === "function")
|
|
44012
|
-
for (const { count, res: res2 } of ctx.anchors.values())
|
|
44013
|
-
onAnchor(res2,
|
|
44012
|
+
for (const { count: count2, res: res2 } of ctx.anchors.values())
|
|
44013
|
+
onAnchor(res2, count2);
|
|
44014
44014
|
return typeof reviver === "function" ? applyReviver.applyReviver(reviver, { "": res }, "", res) : res;
|
|
44015
44015
|
}
|
|
44016
44016
|
};
|
|
@@ -44116,13 +44116,13 @@ var require_Alias = __commonJS({
|
|
|
44116
44116
|
const anchor = anchors2 && source && anchors2.get(source);
|
|
44117
44117
|
return anchor ? anchor.count * anchor.aliasCount : 0;
|
|
44118
44118
|
} else if (identity.isCollection(node)) {
|
|
44119
|
-
let
|
|
44119
|
+
let count2 = 0;
|
|
44120
44120
|
for (const item of node.items) {
|
|
44121
44121
|
const c = getAliasCount(doc, item, anchors2);
|
|
44122
|
-
if (c >
|
|
44123
|
-
|
|
44122
|
+
if (c > count2)
|
|
44123
|
+
count2 = c;
|
|
44124
44124
|
}
|
|
44125
|
-
return
|
|
44125
|
+
return count2;
|
|
44126
44126
|
} else if (identity.isPair(node)) {
|
|
44127
44127
|
const kc = getAliasCount(doc, node.key, anchors2);
|
|
44128
44128
|
const vc = getAliasCount(doc, node.value, anchors2);
|
|
@@ -44406,14 +44406,14 @@ var require_foldFlowLines = __commonJS({
|
|
|
44406
44406
|
var FOLD_FLOW = "flow";
|
|
44407
44407
|
var FOLD_BLOCK = "block";
|
|
44408
44408
|
var FOLD_QUOTED = "quoted";
|
|
44409
|
-
function foldFlowLines(
|
|
44409
|
+
function foldFlowLines(text5, indent, mode = "flow", { indentAtStart, lineWidth = 80, minContentWidth = 20, onFold, onOverflow } = {}) {
|
|
44410
44410
|
if (!lineWidth || lineWidth < 0)
|
|
44411
|
-
return
|
|
44411
|
+
return text5;
|
|
44412
44412
|
if (lineWidth < minContentWidth)
|
|
44413
44413
|
minContentWidth = 0;
|
|
44414
44414
|
const endStep = Math.max(1 + minContentWidth, 1 + lineWidth - indent.length);
|
|
44415
|
-
if (
|
|
44416
|
-
return
|
|
44415
|
+
if (text5.length <= endStep)
|
|
44416
|
+
return text5;
|
|
44417
44417
|
const folds = [];
|
|
44418
44418
|
const escapedFolds = {};
|
|
44419
44419
|
let end = lineWidth - indent.length;
|
|
@@ -44430,14 +44430,14 @@ var require_foldFlowLines = __commonJS({
|
|
|
44430
44430
|
let escStart = -1;
|
|
44431
44431
|
let escEnd = -1;
|
|
44432
44432
|
if (mode === FOLD_BLOCK) {
|
|
44433
|
-
i = consumeMoreIndentedLines(
|
|
44433
|
+
i = consumeMoreIndentedLines(text5, i, indent.length);
|
|
44434
44434
|
if (i !== -1)
|
|
44435
44435
|
end = i + endStep;
|
|
44436
44436
|
}
|
|
44437
|
-
for (let ch2; ch2 =
|
|
44437
|
+
for (let ch2; ch2 = text5[i += 1]; ) {
|
|
44438
44438
|
if (mode === FOLD_QUOTED && ch2 === "\\") {
|
|
44439
44439
|
escStart = i;
|
|
44440
|
-
switch (
|
|
44440
|
+
switch (text5[i + 1]) {
|
|
44441
44441
|
case "x":
|
|
44442
44442
|
i += 3;
|
|
44443
44443
|
break;
|
|
@@ -44454,12 +44454,12 @@ var require_foldFlowLines = __commonJS({
|
|
|
44454
44454
|
}
|
|
44455
44455
|
if (ch2 === "\n") {
|
|
44456
44456
|
if (mode === FOLD_BLOCK)
|
|
44457
|
-
i = consumeMoreIndentedLines(
|
|
44457
|
+
i = consumeMoreIndentedLines(text5, i, indent.length);
|
|
44458
44458
|
end = i + indent.length + endStep;
|
|
44459
44459
|
split = void 0;
|
|
44460
44460
|
} else {
|
|
44461
44461
|
if (ch2 === " " && prev && prev !== " " && prev !== "\n" && prev !== " ") {
|
|
44462
|
-
const next =
|
|
44462
|
+
const next = text5[i + 1];
|
|
44463
44463
|
if (next && next !== " " && next !== "\n" && next !== " ")
|
|
44464
44464
|
split = i;
|
|
44465
44465
|
}
|
|
@@ -44471,12 +44471,12 @@ var require_foldFlowLines = __commonJS({
|
|
|
44471
44471
|
} else if (mode === FOLD_QUOTED) {
|
|
44472
44472
|
while (prev === " " || prev === " ") {
|
|
44473
44473
|
prev = ch2;
|
|
44474
|
-
ch2 =
|
|
44474
|
+
ch2 = text5[i += 1];
|
|
44475
44475
|
overflow = true;
|
|
44476
44476
|
}
|
|
44477
44477
|
const j = i > escEnd + 1 ? i - 2 : escStart - 1;
|
|
44478
44478
|
if (escapedFolds[j])
|
|
44479
|
-
return
|
|
44479
|
+
return text5;
|
|
44480
44480
|
folds.push(j);
|
|
44481
44481
|
escapedFolds[j] = true;
|
|
44482
44482
|
end = j + endStep;
|
|
@@ -44491,39 +44491,39 @@ var require_foldFlowLines = __commonJS({
|
|
|
44491
44491
|
if (overflow && onOverflow)
|
|
44492
44492
|
onOverflow();
|
|
44493
44493
|
if (folds.length === 0)
|
|
44494
|
-
return
|
|
44494
|
+
return text5;
|
|
44495
44495
|
if (onFold)
|
|
44496
44496
|
onFold();
|
|
44497
|
-
let res =
|
|
44497
|
+
let res = text5.slice(0, folds[0]);
|
|
44498
44498
|
for (let i2 = 0; i2 < folds.length; ++i2) {
|
|
44499
44499
|
const fold = folds[i2];
|
|
44500
|
-
const end2 = folds[i2 + 1] ||
|
|
44500
|
+
const end2 = folds[i2 + 1] || text5.length;
|
|
44501
44501
|
if (fold === 0)
|
|
44502
44502
|
res = `
|
|
44503
|
-
${indent}${
|
|
44503
|
+
${indent}${text5.slice(0, end2)}`;
|
|
44504
44504
|
else {
|
|
44505
44505
|
if (mode === FOLD_QUOTED && escapedFolds[fold])
|
|
44506
|
-
res += `${
|
|
44506
|
+
res += `${text5[fold]}\\`;
|
|
44507
44507
|
res += `
|
|
44508
|
-
${indent}${
|
|
44508
|
+
${indent}${text5.slice(fold + 1, end2)}`;
|
|
44509
44509
|
}
|
|
44510
44510
|
}
|
|
44511
44511
|
return res;
|
|
44512
44512
|
}
|
|
44513
|
-
function consumeMoreIndentedLines(
|
|
44513
|
+
function consumeMoreIndentedLines(text5, i, indent) {
|
|
44514
44514
|
let end = i;
|
|
44515
44515
|
let start2 = i + 1;
|
|
44516
|
-
let ch2 =
|
|
44516
|
+
let ch2 = text5[start2];
|
|
44517
44517
|
while (ch2 === " " || ch2 === " ") {
|
|
44518
44518
|
if (i < start2 + indent) {
|
|
44519
|
-
ch2 =
|
|
44519
|
+
ch2 = text5[++i];
|
|
44520
44520
|
} else {
|
|
44521
44521
|
do {
|
|
44522
|
-
ch2 =
|
|
44522
|
+
ch2 = text5[++i];
|
|
44523
44523
|
} while (ch2 && ch2 !== "\n");
|
|
44524
44524
|
end = i;
|
|
44525
44525
|
start2 = i + 1;
|
|
44526
|
-
ch2 =
|
|
44526
|
+
ch2 = text5[start2];
|
|
44527
44527
|
}
|
|
44528
44528
|
}
|
|
44529
44529
|
return end;
|
|
@@ -47075,8 +47075,8 @@ var require_Document = __commonJS({
|
|
|
47075
47075
|
};
|
|
47076
47076
|
const res = toJS.toJS(this.contents, jsonArg ?? "", ctx);
|
|
47077
47077
|
if (typeof onAnchor === "function")
|
|
47078
|
-
for (const { count, res: res2 } of ctx.anchors.values())
|
|
47079
|
-
onAnchor(res2,
|
|
47078
|
+
for (const { count: count2, res: res2 } of ctx.anchors.values())
|
|
47079
|
+
onAnchor(res2, count2);
|
|
47080
47080
|
return typeof reviver === "function" ? applyReviver.applyReviver(reviver, { "": res }, "", res) : res;
|
|
47081
47081
|
}
|
|
47082
47082
|
/**
|
|
@@ -47153,12 +47153,12 @@ var require_errors5 = __commonJS({
|
|
|
47153
47153
|
lineStr = prev + lineStr;
|
|
47154
47154
|
}
|
|
47155
47155
|
if (/[^ ]/.test(lineStr)) {
|
|
47156
|
-
let
|
|
47156
|
+
let count2 = 1;
|
|
47157
47157
|
const end = error.linePos[1];
|
|
47158
47158
|
if (end?.line === line && end.col > col) {
|
|
47159
|
-
|
|
47159
|
+
count2 = Math.max(1, Math.min(end.col - col, 80 - ci));
|
|
47160
47160
|
}
|
|
47161
|
-
const pointer = " ".repeat(ci) + "^".repeat(
|
|
47161
|
+
const pointer = " ".repeat(ci) + "^".repeat(count2);
|
|
47162
47162
|
error.message += `:
|
|
47163
47163
|
|
|
47164
47164
|
${lineStr}
|
|
@@ -50770,7 +50770,7 @@ var require_dist6 = __commonJS({
|
|
|
50770
50770
|
|
|
50771
50771
|
// install-path.mjs
|
|
50772
50772
|
var import_node_fs = require("node:fs");
|
|
50773
|
-
function resolveRealInstallExePure(execPath, localAppData, exists,
|
|
50773
|
+
function resolveRealInstallExePure(execPath, localAppData, exists, readdir6, realpath3) {
|
|
50774
50774
|
if (!execPath) return execPath;
|
|
50775
50775
|
let resolved = execPath;
|
|
50776
50776
|
try {
|
|
@@ -50789,7 +50789,7 @@ function resolveRealInstallExePure(execPath, localAppData, exists, readdir5, rea
|
|
|
50789
50789
|
const packagesDir2 = `${laRoot}\\Packages`;
|
|
50790
50790
|
let packages;
|
|
50791
50791
|
try {
|
|
50792
|
-
packages =
|
|
50792
|
+
packages = readdir6(packagesDir2);
|
|
50793
50793
|
} catch {
|
|
50794
50794
|
return execPath;
|
|
50795
50795
|
}
|
|
@@ -50822,16 +50822,16 @@ function deriveSandboxLicenseDir() {
|
|
|
50822
50822
|
deriveSandboxLicenseDir();
|
|
50823
50823
|
|
|
50824
50824
|
// main.ts
|
|
50825
|
-
var
|
|
50825
|
+
var import_node_child_process19 = require("node:child_process");
|
|
50826
50826
|
var import_node_readline2 = require("node:readline");
|
|
50827
50827
|
|
|
50828
50828
|
// index.ts
|
|
50829
50829
|
var import_node_url5 = require("node:url");
|
|
50830
50830
|
var import_node_path70 = require("node:path");
|
|
50831
50831
|
var import_node_os38 = require("node:os");
|
|
50832
|
-
var
|
|
50833
|
-
var
|
|
50834
|
-
var
|
|
50832
|
+
var import_node_fs74 = require("node:fs");
|
|
50833
|
+
var import_node_child_process17 = require("node:child_process");
|
|
50834
|
+
var import_node_util7 = require("node:util");
|
|
50835
50835
|
|
|
50836
50836
|
// log.mjs
|
|
50837
50837
|
var import_node_path = require("node:path");
|
|
@@ -51667,16 +51667,16 @@ function cancelJournalState(journal, all) {
|
|
|
51667
51667
|
function pendingRenameJournals() {
|
|
51668
51668
|
const dir = renameJournalDir();
|
|
51669
51669
|
if (!(0, import_node_fs7.existsSync)(dir)) return [];
|
|
51670
|
-
const
|
|
51671
|
-
if (
|
|
51672
|
-
return
|
|
51670
|
+
const names2 = (0, import_node_fs7.readdirSync)(dir).filter((name) => name.endsWith(".json"));
|
|
51671
|
+
if (names2.length > 256) throw new Error(`app-origin rename recovery refused ${names2.length} journals`);
|
|
51672
|
+
return names2.map((name) => readRenameJournal(name.slice(0, -".json".length)));
|
|
51673
51673
|
}
|
|
51674
51674
|
function pendingDuplicateJournals() {
|
|
51675
51675
|
const dir = duplicateJournalDir();
|
|
51676
51676
|
if (!(0, import_node_fs7.existsSync)(dir)) return [];
|
|
51677
|
-
const
|
|
51678
|
-
if (
|
|
51679
|
-
return
|
|
51677
|
+
const names2 = (0, import_node_fs7.readdirSync)(dir).filter((name) => name.endsWith(".json"));
|
|
51678
|
+
if (names2.length > 256) throw new Error(`app-origin duplicate recovery refused ${names2.length} journals`);
|
|
51679
|
+
return names2.map((name) => readDuplicateJournal(name.slice(0, -".json".length)));
|
|
51680
51680
|
}
|
|
51681
51681
|
function assertNoPendingOriginOperation(...ids) {
|
|
51682
51682
|
const pending = pendingRenameJournals().find((journal) => ids.includes(journal.oldId) || ids.includes(journal.newId));
|
|
@@ -51987,13 +51987,13 @@ var APPS_DIR = process.env.AWARE_HOME ? (0, import_node_path6.join)(process.env.
|
|
|
51987
51987
|
function normalizeNote(n) {
|
|
51988
51988
|
if (n && typeof n === "object") {
|
|
51989
51989
|
const o = n;
|
|
51990
|
-
const
|
|
51990
|
+
const text6 = typeof o.text === "string" ? o.text : String(o.text ?? "");
|
|
51991
51991
|
const kind2 = o.kind === "warn" || o.kind === "error" ? o.kind : "info";
|
|
51992
|
-
return { kind: kind2, text:
|
|
51992
|
+
return { kind: kind2, text: text6 };
|
|
51993
51993
|
}
|
|
51994
|
-
const
|
|
51995
|
-
const kind = /defaulting to write-mode|not installed/i.test(
|
|
51996
|
-
return { kind, text:
|
|
51994
|
+
const text5 = String(n);
|
|
51995
|
+
const kind = /defaulting to write-mode|not installed/i.test(text5) ? "warn" : "info";
|
|
51996
|
+
return { kind, text: text5 };
|
|
51997
51997
|
}
|
|
51998
51998
|
function isVisualInput(i) {
|
|
51999
51999
|
return i.widget === "file" || i.type === "image" || i.type === "file";
|
|
@@ -52037,8 +52037,8 @@ function firstWithExt(dir, ext) {
|
|
|
52037
52037
|
const hit = (0, import_node_fs8.readdirSync)(dir).find((f) => f.toLowerCase().endsWith(ext));
|
|
52038
52038
|
return hit ? (0, import_node_path6.join)(dir, hit) : null;
|
|
52039
52039
|
}
|
|
52040
|
-
function sha256(
|
|
52041
|
-
return (0, import_node_crypto4.createHash)("sha256").update(
|
|
52040
|
+
function sha256(text5) {
|
|
52041
|
+
return (0, import_node_crypto4.createHash)("sha256").update(text5).digest("hex");
|
|
52042
52042
|
}
|
|
52043
52043
|
function asRecord(v) {
|
|
52044
52044
|
return v && typeof v === "object" && !Array.isArray(v) ? v : {};
|
|
@@ -52055,7 +52055,7 @@ function appMeta(id, bypassCache = false) {
|
|
|
52055
52055
|
const hit = bypassCache ? void 0 : metaCache.get(sourcePath2);
|
|
52056
52056
|
if (hit && hit.mtimeMs === st.mtimeMs && hit.size === st.size && hit.ino === st.ino) return hit.meta;
|
|
52057
52057
|
sourceParses++;
|
|
52058
|
-
const
|
|
52058
|
+
const text5 = (0, import_node_fs8.readFileSync)(sourcePath2, "utf8");
|
|
52059
52059
|
const after = (0, import_node_fs8.statSync)(sourcePath2);
|
|
52060
52060
|
const settled2 = after.mtimeMs === st.mtimeMs && after.size === st.size && after.ino === st.ino;
|
|
52061
52061
|
const remember = (meta2) => {
|
|
@@ -52064,7 +52064,7 @@ function appMeta(id, bypassCache = false) {
|
|
|
52064
52064
|
};
|
|
52065
52065
|
let src;
|
|
52066
52066
|
try {
|
|
52067
|
-
src = asRecord((0, import_yaml.parse)(
|
|
52067
|
+
src = asRecord((0, import_yaml.parse)(text5));
|
|
52068
52068
|
} catch {
|
|
52069
52069
|
return remember(META_DEFAULT);
|
|
52070
52070
|
}
|
|
@@ -52385,8 +52385,8 @@ function mergeConnectables(base, live, displayName) {
|
|
|
52385
52385
|
}
|
|
52386
52386
|
return [...base, ...extra].sort((a, b) => a.name.localeCompare(b.name));
|
|
52387
52387
|
}
|
|
52388
|
-
function parseTrace(
|
|
52389
|
-
return
|
|
52388
|
+
function parseTrace(text5) {
|
|
52389
|
+
return text5.split(/\r?\n/).filter((l) => l.trim()).map((l) => {
|
|
52390
52390
|
try {
|
|
52391
52391
|
return JSON.parse(l);
|
|
52392
52392
|
} catch {
|
|
@@ -53385,7 +53385,7 @@ function watchRunProgress(id, onProgress) {
|
|
|
53385
53385
|
}
|
|
53386
53386
|
if (size < offset) offset = 0;
|
|
53387
53387
|
if (size <= offset) return;
|
|
53388
|
-
let
|
|
53388
|
+
let text5;
|
|
53389
53389
|
let fd2 = -1;
|
|
53390
53390
|
try {
|
|
53391
53391
|
fd2 = (0, import_node_fs9.openSync)(tracePath, "r");
|
|
@@ -53393,7 +53393,7 @@ function watchRunProgress(id, onProgress) {
|
|
|
53393
53393
|
const read2 = (0, import_node_fs9.readSync)(fd2, buf, 0, buf.length, offset);
|
|
53394
53394
|
const nl = buf.lastIndexOf(10, read2 - 1);
|
|
53395
53395
|
if (nl < 0) return;
|
|
53396
|
-
|
|
53396
|
+
text5 = buf.subarray(0, nl + 1).toString("utf8");
|
|
53397
53397
|
offset += nl + 1;
|
|
53398
53398
|
} catch {
|
|
53399
53399
|
return;
|
|
@@ -53405,7 +53405,7 @@ function watchRunProgress(id, onProgress) {
|
|
|
53405
53405
|
}
|
|
53406
53406
|
}
|
|
53407
53407
|
}
|
|
53408
|
-
for (const line of
|
|
53408
|
+
for (const line of text5.split(/\r?\n/)) {
|
|
53409
53409
|
if (!line.trim()) continue;
|
|
53410
53410
|
let ev;
|
|
53411
53411
|
try {
|
|
@@ -53636,8 +53636,8 @@ function agentInvokeArgv(agent, command, inputsRef) {
|
|
|
53636
53636
|
function isInvokeUnsupported(detail) {
|
|
53637
53637
|
if (!detail || typeof detail !== "object") return false;
|
|
53638
53638
|
const d = detail;
|
|
53639
|
-
const
|
|
53640
|
-
return /unrecognized subcommand|unknown subcommand/i.test(
|
|
53639
|
+
const text5 = [d.stdout, d.stderr].filter((s) => typeof s === "string").join("\n");
|
|
53640
|
+
return /unrecognized subcommand|unknown subcommand/i.test(text5);
|
|
53641
53641
|
}
|
|
53642
53642
|
var inFlightConnects = /* @__PURE__ */ new Map();
|
|
53643
53643
|
function cancelAllConnects() {
|
|
@@ -54216,10 +54216,10 @@ function readExtensionsText() {
|
|
|
54216
54216
|
}
|
|
54217
54217
|
}
|
|
54218
54218
|
function readExtensions() {
|
|
54219
|
-
const
|
|
54220
|
-
if (
|
|
54219
|
+
const text5 = readExtensionsText();
|
|
54220
|
+
if (text5 === null) return null;
|
|
54221
54221
|
try {
|
|
54222
|
-
const parsed = JSON.parse(
|
|
54222
|
+
const parsed = JSON.parse(text5);
|
|
54223
54223
|
return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : null;
|
|
54224
54224
|
} catch {
|
|
54225
54225
|
return null;
|
|
@@ -54229,24 +54229,24 @@ function descriptorPanels(d) {
|
|
|
54229
54229
|
if (!d || !Array.isArray(d.panels)) return [];
|
|
54230
54230
|
return d.panels.filter((p) => !!p && typeof p === "object" && !Array.isArray(p));
|
|
54231
54231
|
}
|
|
54232
|
-
function panelsCountOf(
|
|
54233
|
-
if (
|
|
54232
|
+
function panelsCountOf(text5) {
|
|
54233
|
+
if (text5 === null) return 0;
|
|
54234
54234
|
try {
|
|
54235
|
-
const parsed = JSON.parse(
|
|
54235
|
+
const parsed = JSON.parse(text5);
|
|
54236
54236
|
return parsed && typeof parsed === "object" && Array.isArray(parsed.panels) ? parsed.panels.length : 0;
|
|
54237
54237
|
} catch {
|
|
54238
54238
|
return 0;
|
|
54239
54239
|
}
|
|
54240
54240
|
}
|
|
54241
54241
|
function loadTimeline() {
|
|
54242
|
-
let
|
|
54242
|
+
let text5;
|
|
54243
54243
|
try {
|
|
54244
|
-
|
|
54244
|
+
text5 = (0, import_node_fs10.readFileSync)(TIMELINE_FILE, "utf8");
|
|
54245
54245
|
} catch {
|
|
54246
54246
|
return { cursor: -1, entries: [] };
|
|
54247
54247
|
}
|
|
54248
54248
|
try {
|
|
54249
|
-
const parsed = JSON.parse(
|
|
54249
|
+
const parsed = JSON.parse(text5);
|
|
54250
54250
|
if (!parsed || typeof parsed !== "object") return { cursor: -1, entries: [] };
|
|
54251
54251
|
const p = parsed;
|
|
54252
54252
|
const rawEntries = Array.isArray(p.entries) ? p.entries : [];
|
|
@@ -54268,10 +54268,10 @@ function saveTimeline(t) {
|
|
|
54268
54268
|
(0, import_node_fs10.writeFileSync)(tmp, JSON.stringify(t, null, 2));
|
|
54269
54269
|
(0, import_node_fs10.renameSync)(tmp, TIMELINE_FILE);
|
|
54270
54270
|
}
|
|
54271
|
-
function writeExtensionsText(
|
|
54271
|
+
function writeExtensionsText(text5) {
|
|
54272
54272
|
ensureUiDir();
|
|
54273
54273
|
const tmp = `${extensionsFile}.${process.pid}.tmp`;
|
|
54274
|
-
(0, import_node_fs10.writeFileSync)(tmp,
|
|
54274
|
+
(0, import_node_fs10.writeFileSync)(tmp, text5);
|
|
54275
54275
|
(0, import_node_fs10.renameSync)(tmp, extensionsFile);
|
|
54276
54276
|
}
|
|
54277
54277
|
function applyState(entry2) {
|
|
@@ -54292,15 +54292,15 @@ function seedTimeline() {
|
|
|
54292
54292
|
if (t.entries.length > 0) return;
|
|
54293
54293
|
saveTimeline({ cursor: 0, entries: [{ content: readExtensionsText(), ts: (/* @__PURE__ */ new Date()).toISOString() }] });
|
|
54294
54294
|
}
|
|
54295
|
-
function recordChange(
|
|
54295
|
+
function recordChange(text5) {
|
|
54296
54296
|
const t = loadTimeline();
|
|
54297
54297
|
if (t.entries.length === 0) {
|
|
54298
|
-
saveTimeline({ cursor: 0, entries: [{ content:
|
|
54298
|
+
saveTimeline({ cursor: 0, entries: [{ content: text5, ts: (/* @__PURE__ */ new Date()).toISOString() }] });
|
|
54299
54299
|
return { recorded: true };
|
|
54300
54300
|
}
|
|
54301
|
-
if (
|
|
54301
|
+
if (text5 === currentContent(t)) return { recorded: false };
|
|
54302
54302
|
const entries = t.entries.slice(0, t.cursor + 1);
|
|
54303
|
-
entries.push({ content:
|
|
54303
|
+
entries.push({ content: text5, ts: (/* @__PURE__ */ new Date()).toISOString() });
|
|
54304
54304
|
let cursor = entries.length - 1;
|
|
54305
54305
|
while (entries.length > HISTORY_KEEP) {
|
|
54306
54306
|
entries.shift();
|
|
@@ -54372,8 +54372,8 @@ function isUiAgentMissing(err2) {
|
|
|
54372
54372
|
const detail = err2.detail ?? {};
|
|
54373
54373
|
const stdout = typeof detail.stdout === "string" ? detail.stdout : "";
|
|
54374
54374
|
const stderr = typeof detail.stderr === "string" ? detail.stderr : "";
|
|
54375
|
-
const
|
|
54376
|
-
return /not installed/i.test(
|
|
54375
|
+
const text5 = `${err2.message} ${stdout} ${stderr}`;
|
|
54376
|
+
return /not installed/i.test(text5);
|
|
54377
54377
|
}
|
|
54378
54378
|
function classifyValidateError(err2) {
|
|
54379
54379
|
if (err2 instanceof AwareUnsupportedError) {
|
|
@@ -54980,7 +54980,7 @@ function appVersion() {
|
|
|
54980
54980
|
return resolveVersion({
|
|
54981
54981
|
isSea: isSea2(),
|
|
54982
54982
|
sqVersionXml: readSqVersionXml(),
|
|
54983
|
-
define: true ? "0.
|
|
54983
|
+
define: true ? "0.130.1" : void 0,
|
|
54984
54984
|
pkgVersion: readPkgVersion()
|
|
54985
54985
|
});
|
|
54986
54986
|
}
|
|
@@ -54996,7 +54996,7 @@ function resolveChannel(s) {
|
|
|
54996
54996
|
function appChannel() {
|
|
54997
54997
|
return resolveChannel({
|
|
54998
54998
|
isSea: isSea2(),
|
|
54999
|
-
define: true ? "0.
|
|
54999
|
+
define: true ? "0.130.1" : void 0,
|
|
55000
55000
|
// argv[1] is the entry the runtime actually loaded (…/dist/floless-server.cjs), which is what
|
|
55001
55001
|
// carries the npx cache prefix. Absent under the SEA exe, which never reaches the npx branch.
|
|
55002
55002
|
modulePath: process.argv[1]
|
|
@@ -55660,9 +55660,9 @@ function checkModelReferences(doc) {
|
|
|
55660
55660
|
if (has("control2_at") && !has("control2_ref")) {
|
|
55661
55661
|
add(`$.plans[${pi}]`, "control-pair-incomplete", `sheet "${sheet ?? pi}" has control2_at with no control2_ref; a second control is never the model origin, so the intersection it names must be stated`);
|
|
55662
55662
|
}
|
|
55663
|
-
for (const
|
|
55664
|
-
if (has(`${
|
|
55665
|
-
add(`$.plans[${pi}]`, "control-pair-incomplete", `sheet "${sheet ?? pi}" has ${
|
|
55663
|
+
for (const side2 of ["datum", "control2"]) {
|
|
55664
|
+
if (has(`${side2}_ref`) && !has(`${side2}_at`)) {
|
|
55665
|
+
add(`$.plans[${pi}]`, "control-pair-incomplete", `sheet "${sheet ?? pi}" has ${side2}_ref with no ${side2}_at; naming an intersection without its point on the sheet registers nothing`);
|
|
55666
55666
|
}
|
|
55667
55667
|
}
|
|
55668
55668
|
});
|
|
@@ -55790,12 +55790,12 @@ function checkModelReferences(doc) {
|
|
|
55790
55790
|
if (declared !== parsedCount) add("$.grid.axes", "grid-axis-count", `${dir} has ${parsedCount} parsed entries but ${declared} declared axes`);
|
|
55791
55791
|
};
|
|
55792
55792
|
for (const dir of ["x", "y"]) {
|
|
55793
|
-
const
|
|
55794
|
-
if (
|
|
55793
|
+
const text5 = str(grid[dir]);
|
|
55794
|
+
if (text5 === null) {
|
|
55795
55795
|
compare(dir, 0);
|
|
55796
55796
|
continue;
|
|
55797
55797
|
}
|
|
55798
|
-
const parsed = parseSpacings(
|
|
55798
|
+
const parsed = parseSpacings(text5);
|
|
55799
55799
|
if (parsed.err) add(`$.grid.${dir}`, "grid-spacing-invalid", `${dir} grid string is unparseable: ${parsed.err}`);
|
|
55800
55800
|
else compare(dir, parsed.offsets.length);
|
|
55801
55801
|
}
|
|
@@ -58282,10 +58282,10 @@ var IMPORT_MAX_UNCOMPRESSED = 2 * 1024 * 1024 * 1024;
|
|
|
58282
58282
|
function importProjectZip(data) {
|
|
58283
58283
|
let entries;
|
|
58284
58284
|
try {
|
|
58285
|
-
let
|
|
58285
|
+
let count2 = 0, uncompressed = 0;
|
|
58286
58286
|
entries = unzipSync(data, {
|
|
58287
58287
|
filter: (f) => {
|
|
58288
|
-
if (++
|
|
58288
|
+
if (++count2 > IMPORT_MAX_FILES) throw new ProjectError("archive has too many entries");
|
|
58289
58289
|
uncompressed += f.originalSize;
|
|
58290
58290
|
if (uncompressed > IMPORT_MAX_UNCOMPRESSED) throw new ProjectError("archive is too large uncompressed");
|
|
58291
58291
|
return true;
|
|
@@ -59170,8 +59170,8 @@ async function recoverAllIfcPublications() {
|
|
|
59170
59170
|
const projectPath = (0, import_node_path20.join)(projectsRoot2, entry2.name);
|
|
59171
59171
|
safeTransactionDirectory(projectPath);
|
|
59172
59172
|
const dir = projectExportsDir(entry2.name);
|
|
59173
|
-
const
|
|
59174
|
-
recovered.push(...
|
|
59173
|
+
const names2 = await recoverIfcPublicationsInDirectory(dir, { kind: "project", key: entry2.name });
|
|
59174
|
+
recovered.push(...names2.map((name) => `${entry2.name}/${name}`));
|
|
59175
59175
|
}
|
|
59176
59176
|
}
|
|
59177
59177
|
const root6 = (0, import_node_path20.join)(rootHome, "exports");
|
|
@@ -59183,11 +59183,11 @@ async function recoverAllIfcPublications() {
|
|
|
59183
59183
|
if (!entry2.isDirectory()) continue;
|
|
59184
59184
|
if (!/^[A-Za-z0-9._-]+$/.test(entry2.name)) continue;
|
|
59185
59185
|
safeTransactionDirectory((0, import_node_path20.join)(root6, entry2.name));
|
|
59186
|
-
const
|
|
59186
|
+
const names2 = await recoverIfcPublicationsInDirectory(
|
|
59187
59187
|
(0, import_node_path20.join)(root6, entry2.name),
|
|
59188
59188
|
{ kind: "app", key: entry2.name }
|
|
59189
59189
|
);
|
|
59190
|
-
recovered.push(...
|
|
59190
|
+
recovered.push(...names2.map((name) => `${entry2.name}/${name}`));
|
|
59191
59191
|
}
|
|
59192
59192
|
}
|
|
59193
59193
|
return recovered;
|
|
@@ -59555,7 +59555,7 @@ function plyFitsSection(t, half) {
|
|
|
59555
59555
|
return t > 0 && t < 2 * half;
|
|
59556
59556
|
}
|
|
59557
59557
|
function bearingFaces(x, uOnN, vOnN, requestedSide) {
|
|
59558
|
-
const
|
|
59558
|
+
const side2 = requestedSide >= 0 ? 1 : -1;
|
|
59559
59559
|
const onU = Math.abs(Math.abs(uOnN) - 1) < 1e-9;
|
|
59560
59560
|
const onV = Math.abs(Math.abs(vOnN) - 1) < 1e-9;
|
|
59561
59561
|
if (!onU && !onV) return null;
|
|
@@ -59565,7 +59565,7 @@ function bearingFaces(x, uOnN, vOnN, requestedSide) {
|
|
|
59565
59565
|
case "i": {
|
|
59566
59566
|
if (!onU) return null;
|
|
59567
59567
|
if (!plyFitsSection(x.tw, x.bf / 2)) return null;
|
|
59568
|
-
return { lapN:
|
|
59568
|
+
return { lapN: side2 * x.tw / 2, sideDir: side2, plyFarN: -side2 * x.tw / 2, ply: x.tw, derived: false };
|
|
59569
59569
|
}
|
|
59570
59570
|
case "channel": {
|
|
59571
59571
|
if (!onU) return null;
|
|
@@ -59900,8 +59900,8 @@ function parseStepData(input) {
|
|
|
59900
59900
|
if (input.length > MAX_BYTES3) throw new StepParseError("IFC is larger than the supported maximum.");
|
|
59901
59901
|
assertAscii((i) => input[i], input.length);
|
|
59902
59902
|
}
|
|
59903
|
-
const
|
|
59904
|
-
const sc = new Scanner(
|
|
59903
|
+
const text5 = typeof input === "string" ? input : input.toString("utf8");
|
|
59904
|
+
const sc = new Scanner(text5);
|
|
59905
59905
|
sc.expectWord("ISO-10303-21");
|
|
59906
59906
|
sc.expect(";");
|
|
59907
59907
|
sc.expectWord("HEADER");
|
|
@@ -60486,9 +60486,44 @@ function releaseLease(leaseId) {
|
|
|
60486
60486
|
}
|
|
60487
60487
|
return false;
|
|
60488
60488
|
}
|
|
60489
|
+
function psRejectionIsEmptyMatch(err2) {
|
|
60490
|
+
return err2.code === 1 && !err2.signal && !err2.killed && typeof err2.stdout === "string" && !err2.stdout.trim() && typeof err2.stderr === "string" && !err2.stderr.trim();
|
|
60491
|
+
}
|
|
60492
|
+
function pidProvenDead(pid) {
|
|
60493
|
+
try {
|
|
60494
|
+
process.kill(pid, 0);
|
|
60495
|
+
return false;
|
|
60496
|
+
} catch (e) {
|
|
60497
|
+
return e.code === "ESRCH";
|
|
60498
|
+
}
|
|
60499
|
+
}
|
|
60500
|
+
async function posixStartTimes(wanted, queryPs, provenDead = pidProvenDead) {
|
|
60501
|
+
let stdout;
|
|
60502
|
+
try {
|
|
60503
|
+
stdout = await queryPs(wanted);
|
|
60504
|
+
} catch (err2) {
|
|
60505
|
+
if (!psRejectionIsEmptyMatch(err2)) return null;
|
|
60506
|
+
stdout = "";
|
|
60507
|
+
}
|
|
60508
|
+
const out = /* @__PURE__ */ new Map();
|
|
60509
|
+
const now = Date.now();
|
|
60510
|
+
for (const [pid, secs] of pairs(stdout)) out.set(pid, now - secs * 1e3);
|
|
60511
|
+
for (const pid of wanted) {
|
|
60512
|
+
if (out.has(pid)) continue;
|
|
60513
|
+
if (!provenDead(pid)) return null;
|
|
60514
|
+
}
|
|
60515
|
+
return out;
|
|
60516
|
+
}
|
|
60517
|
+
function psQuery(pids) {
|
|
60518
|
+
return run(
|
|
60519
|
+
"ps",
|
|
60520
|
+
["-o", "pid=,etimes=", "-p", pids.join(",")],
|
|
60521
|
+
{ encoding: "utf8", timeout: 1e4, maxBuffer: 8 * 1024 * 1024 }
|
|
60522
|
+
).then((r) => r.stdout);
|
|
60523
|
+
}
|
|
60489
60524
|
async function processStartTimes(pids) {
|
|
60490
60525
|
const out = /* @__PURE__ */ new Map();
|
|
60491
|
-
const wanted = [...new Set(pids)].filter((p) => Number.isInteger(p) && p > 0);
|
|
60526
|
+
const wanted = [...new Set(pids)].filter((p) => Number.isInteger(p) && p > 0 && p <= 2147483647);
|
|
60492
60527
|
if (!wanted.length) return out;
|
|
60493
60528
|
try {
|
|
60494
60529
|
if (WIN) {
|
|
@@ -60496,9 +60531,7 @@ async function processStartTimes(pids) {
|
|
|
60496
60531
|
const script = `Get-CimInstance Win32_Process -Filter '${filter}' | ForEach-Object { "$($_.ProcessId) $([int64]($_.CreationDate.ToUniversalTime() - [datetime]'1970-01-01').TotalMilliseconds)" }`;
|
|
60497
60532
|
for (const [pid, t] of pairs(await psLines(script))) out.set(pid, t);
|
|
60498
60533
|
} else {
|
|
60499
|
-
|
|
60500
|
-
const now = Date.now();
|
|
60501
|
-
for (const [pid, secs] of pairs(stdout)) out.set(pid, now - secs * 1e3);
|
|
60534
|
+
return await posixStartTimes(wanted, psQuery);
|
|
60502
60535
|
}
|
|
60503
60536
|
} catch {
|
|
60504
60537
|
return null;
|
|
@@ -60578,12 +60611,12 @@ function validateCompletion(value) {
|
|
|
60578
60611
|
if (outcome !== "applied" && outcome !== "needs-you" && outcome !== "refused") {
|
|
60579
60612
|
return { kind: "violation", why: `unrecognised outcome ${JSON.stringify(outcome)}` };
|
|
60580
60613
|
}
|
|
60581
|
-
const
|
|
60582
|
-
if (outcome === "needs-you" && !
|
|
60614
|
+
const text5 = typeof question === "string" ? question.trim().slice(0, MAX_QUESTION) : "";
|
|
60615
|
+
if (outcome === "needs-you" && !text5) {
|
|
60583
60616
|
return { kind: "violation", why: "outcome needs-you carried no question" };
|
|
60584
60617
|
}
|
|
60585
|
-
if (outcome === "needs-you") return { kind: "needs-you", question:
|
|
60586
|
-
if (outcome === "refused") return { kind: "refused", question:
|
|
60618
|
+
if (outcome === "needs-you") return { kind: "needs-you", question: text5 };
|
|
60619
|
+
if (outcome === "refused") return { kind: "refused", question: text5 };
|
|
60587
60620
|
return { kind: "applied" };
|
|
60588
60621
|
}
|
|
60589
60622
|
function readCompletion(terminal) {
|
|
@@ -60645,12 +60678,12 @@ function codexCompletion(stdout) {
|
|
|
60645
60678
|
return validateCompletion(value);
|
|
60646
60679
|
}
|
|
60647
60680
|
function eventDetail(value) {
|
|
60648
|
-
let
|
|
60649
|
-
if (typeof value === "string")
|
|
60681
|
+
let text5 = "";
|
|
60682
|
+
if (typeof value === "string") text5 = value;
|
|
60650
60683
|
else if (value && typeof value === "object" && typeof value.message === "string") {
|
|
60651
|
-
|
|
60684
|
+
text5 = String(value.message);
|
|
60652
60685
|
}
|
|
60653
|
-
return
|
|
60686
|
+
return text5.trim() ? `: ${text5.trim().slice(0, 200)}` : "";
|
|
60654
60687
|
}
|
|
60655
60688
|
function terminalEvent(stdout) {
|
|
60656
60689
|
const trimmed = stdout.trim();
|
|
@@ -60855,9 +60888,9 @@ function durableWrite2(path, bytes) {
|
|
|
60855
60888
|
(0, import_node_fs27.chmodSync)(path, 384);
|
|
60856
60889
|
syncDirectoryBestEffort((0, import_node_path25.dirname)(path));
|
|
60857
60890
|
}
|
|
60858
|
-
function durableReplace3(path,
|
|
60891
|
+
function durableReplace3(path, text5) {
|
|
60859
60892
|
const tmp = `${path}.${process.pid}.${(0, import_node_crypto15.randomUUID)()}.tmp`;
|
|
60860
|
-
durableWrite2(tmp,
|
|
60893
|
+
durableWrite2(tmp, text5);
|
|
60861
60894
|
(0, import_node_fs27.renameSync)(tmp, path);
|
|
60862
60895
|
const fd2 = (0, import_node_fs27.openSync)(path, "r+");
|
|
60863
60896
|
try {
|
|
@@ -61452,8 +61485,8 @@ function mcpConfigFor(token2, origin) {
|
|
|
61452
61485
|
function jsonRpc(id, result) {
|
|
61453
61486
|
return { jsonrpc: "2.0", id, result };
|
|
61454
61487
|
}
|
|
61455
|
-
function toolRefusal(
|
|
61456
|
-
return { content: [{ type: "text", text:
|
|
61488
|
+
function toolRefusal(text5) {
|
|
61489
|
+
return { content: [{ type: "text", text: text5 }], isError: true };
|
|
61457
61490
|
}
|
|
61458
61491
|
function sameBody(want, got) {
|
|
61459
61492
|
if (want === void 0 && got !== null && typeof got === "object" && Object.keys(got).length === 0) return true;
|
|
@@ -61571,9 +61604,9 @@ function registerRunRelay(app, deps, origin) {
|
|
|
61571
61604
|
}
|
|
61572
61605
|
try {
|
|
61573
61606
|
const result = await callCodexTool(deps, lease, params?.name, params?.arguments ?? {});
|
|
61574
|
-
const
|
|
61607
|
+
const text5 = boundedJson(result);
|
|
61575
61608
|
recordCodexTool(lease, params?.name, "allowed");
|
|
61576
|
-
return reply.send(jsonRpc(msg.id, { content: [{ type: "text", text:
|
|
61609
|
+
return reply.send(jsonRpc(msg.id, { content: [{ type: "text", text: text5 }] }));
|
|
61577
61610
|
} catch (err2) {
|
|
61578
61611
|
recordCodexTool(lease, params?.name, "denied");
|
|
61579
61612
|
const message = String(err2?.message ?? err2).slice(0, 1e3);
|
|
@@ -61752,9 +61785,9 @@ async function callCodexTool(deps, lease, name, args) {
|
|
|
61752
61785
|
throw new Error(`no such tool: ${String(name)}`);
|
|
61753
61786
|
}
|
|
61754
61787
|
function boundedJson(value) {
|
|
61755
|
-
const
|
|
61756
|
-
if (
|
|
61757
|
-
return
|
|
61788
|
+
const text5 = JSON.stringify(value);
|
|
61789
|
+
if (text5.length > 16 * 1024 * 1024) throw new Error("tool result exceeded the bounded relay response");
|
|
61790
|
+
return text5;
|
|
61758
61791
|
}
|
|
61759
61792
|
function onlyThisRequest(body, requestId) {
|
|
61760
61793
|
const b = body;
|
|
@@ -62476,14 +62509,14 @@ async function ensureManagedSidecarsForUserAction(deps = liveDeps) {
|
|
|
62476
62509
|
if (needsRepair(initial) === 0) return { supported: true, repaired: 0 };
|
|
62477
62510
|
return deps.withExclusive(async () => {
|
|
62478
62511
|
const before = await deps.inventory();
|
|
62479
|
-
const
|
|
62480
|
-
if (
|
|
62512
|
+
const count2 = needsRepair(before);
|
|
62513
|
+
if (count2 === 0) return { supported: true, repaired: 0 };
|
|
62481
62514
|
const after = await deps.repair();
|
|
62482
62515
|
const remaining2 = needsRepair(after);
|
|
62483
62516
|
if (remaining2 > 0) {
|
|
62484
62517
|
throw new AwareError(`AWARE left ${remaining2} managed runtime tool(s) needing repair.`);
|
|
62485
62518
|
}
|
|
62486
|
-
return { supported: true, repaired:
|
|
62519
|
+
return { supported: true, repaired: count2 };
|
|
62487
62520
|
});
|
|
62488
62521
|
}
|
|
62489
62522
|
|
|
@@ -62683,9 +62716,9 @@ var NEUTRAL_TEXT_PARAMS = {
|
|
|
62683
62716
|
};
|
|
62684
62717
|
function boundedNeutralText(value) {
|
|
62685
62718
|
if (typeof value !== "string") return null;
|
|
62686
|
-
const
|
|
62687
|
-
if (!
|
|
62688
|
-
return
|
|
62719
|
+
const text5 = value.trim();
|
|
62720
|
+
if (!text5 || Buffer.byteLength(text5, "utf8") > 64 || /[\u0000-\u001f\u007f]/.test(text5)) return null;
|
|
62721
|
+
return text5;
|
|
62689
62722
|
}
|
|
62690
62723
|
var gridCountsInteger = (p) => (!("boltCols" in p) || Number.isInteger(p.boltCols)) && (!("boltRows" in p) || Number.isInteger(p.boltRows));
|
|
62691
62724
|
function sanitizeRecipe(raw) {
|
|
@@ -62697,8 +62730,8 @@ function sanitizeRecipe(raw) {
|
|
|
62697
62730
|
for (const [k, v] of Object.entries(r.params)) {
|
|
62698
62731
|
if (typeof v === "number" && isFinite(v)) num4[k] = v;
|
|
62699
62732
|
if (NEUTRAL_TEXT_PARAMS[r.kind]?.has(k)) {
|
|
62700
|
-
const
|
|
62701
|
-
if (
|
|
62733
|
+
const text5 = boundedNeutralText(v);
|
|
62734
|
+
if (text5) neutral[k] = text5;
|
|
62702
62735
|
else if (v != null) return void 0;
|
|
62703
62736
|
}
|
|
62704
62737
|
}
|
|
@@ -62870,9 +62903,9 @@ var LOG_CLAIM_TOKEN = (0, import_node_crypto19.randomUUID)();
|
|
|
62870
62903
|
var versionsDir = (id) => (0, import_node_path34.join)(projectDir(id), "versions");
|
|
62871
62904
|
var objectsDir = (id) => (0, import_node_path34.join)(projectDir(id), "objects");
|
|
62872
62905
|
var logPath = (id) => (0, import_node_path34.join)(versionsDir(id), "log.json");
|
|
62873
|
-
function writeAtomic(path,
|
|
62906
|
+
function writeAtomic(path, text5) {
|
|
62874
62907
|
const tmp = `${path}.${process.pid}.tmp`;
|
|
62875
|
-
(0, import_node_fs34.writeFileSync)(tmp,
|
|
62908
|
+
(0, import_node_fs34.writeFileSync)(tmp, text5);
|
|
62876
62909
|
(0, import_node_fs34.renameSync)(tmp, path);
|
|
62877
62910
|
}
|
|
62878
62911
|
function isVersionMeta(v) {
|
|
@@ -63073,9 +63106,9 @@ function createVersion(id, contract, meta) {
|
|
|
63073
63106
|
(0, import_node_fs34.mkdirSync)(objectsDir(id), { recursive: true });
|
|
63074
63107
|
const blobs = /* @__PURE__ */ new Map();
|
|
63075
63108
|
const skeleton = dehydrate(contract, blobs);
|
|
63076
|
-
for (const [hash3,
|
|
63109
|
+
for (const [hash3, text5] of blobs) {
|
|
63077
63110
|
const p = (0, import_node_path34.join)(objectsDir(id), hash3);
|
|
63078
|
-
if (!(0, import_node_fs34.existsSync)(p)) writeAtomic(p,
|
|
63111
|
+
if (!(0, import_node_fs34.existsSync)(p)) writeAtomic(p, text5);
|
|
63079
63112
|
}
|
|
63080
63113
|
const log2 = loadLog(id);
|
|
63081
63114
|
const n = claimVersionNumber(id, (log2.versions.at(-1)?.n ?? 0) + 1);
|
|
@@ -63934,12 +63967,12 @@ function expandShearPlate(joint, beam, support, nativeSupport) {
|
|
|
63934
63967
|
const cope = beamCopes(beam, support, joint.at ?? "end0", p);
|
|
63935
63968
|
const copeRadius = pos(p, "copeRadius", 12.7);
|
|
63936
63969
|
const MIN_COPE = 1;
|
|
63937
|
-
const pushCope = (
|
|
63970
|
+
const pushCope = (side2, dec) => {
|
|
63938
63971
|
if (!(dec.depth > MIN_COPE)) return;
|
|
63939
63972
|
const lenU = dec.length + clearance;
|
|
63940
|
-
const vC =
|
|
63973
|
+
const vC = side2 === "top" ? beam.dims.d / 2 - dec.depth / 2 : -beam.dims.d / 2 + dec.depth / 2;
|
|
63941
63974
|
parts.push({
|
|
63942
|
-
id: `${joint.id}:cope-${
|
|
63975
|
+
id: `${joint.id}:cope-${side2}`,
|
|
63943
63976
|
group: "cope",
|
|
63944
63977
|
kind: "cut",
|
|
63945
63978
|
member: beam.id,
|
|
@@ -63950,9 +63983,9 @@ function expandShearPlate(joint, beam, support, nativeSupport) {
|
|
|
63950
63983
|
depth: dec.depth,
|
|
63951
63984
|
thickness: beam.dims.w + 2,
|
|
63952
63985
|
radius: copeRadius,
|
|
63953
|
-
reentrantV:
|
|
63986
|
+
reentrantV: side2 === "top" ? -1 : 1,
|
|
63954
63987
|
// web side = toward the beam centroid (top cope below, bottom above)
|
|
63955
|
-
meta: { label: `${
|
|
63988
|
+
meta: { label: `${side2 === "top" ? "Top" : "Bottom"} cope ${Math.round(dec.length)}\xD7${Math.round(dec.depth)}` }
|
|
63956
63989
|
});
|
|
63957
63990
|
};
|
|
63958
63991
|
if (cope.top) pushCope("top", cope.top);
|
|
@@ -64191,7 +64224,7 @@ function expandBraceGusset(joint, brace, support, nativeSupport) {
|
|
|
64191
64224
|
k++;
|
|
64192
64225
|
}
|
|
64193
64226
|
}
|
|
64194
|
-
const mkPlate = (suffix, uStart, mid, holes,
|
|
64227
|
+
const mkPlate = (suffix, uStart, mid, holes, side2) => ({
|
|
64195
64228
|
id: `${joint.id}:${suffix}`,
|
|
64196
64229
|
group: "gusset-plate",
|
|
64197
64230
|
kind: "plate",
|
|
@@ -64203,7 +64236,7 @@ function expandBraceGusset(joint, brace, support, nativeSupport) {
|
|
|
64203
64236
|
thickness,
|
|
64204
64237
|
holes,
|
|
64205
64238
|
material: plateMaterial,
|
|
64206
|
-
meta: { label: `Gusset plate ${Math.round(width)}\xD7${Math.round(height)}\xD7${Math.round(thickness)}${
|
|
64239
|
+
meta: { label: `Gusset plate ${Math.round(width)}\xD7${Math.round(height)}\xD7${Math.round(thickness)}${side2}`, setbackMm: trimMm }
|
|
64207
64240
|
});
|
|
64208
64241
|
const plateA = mkPlate("plateA", uA, aMid, holesA, plateCount === 2 ? " (near)" : "");
|
|
64209
64242
|
const parts = [plateA];
|
|
@@ -65411,8 +65444,8 @@ function checkSpatialStructure(index, manifest) {
|
|
|
65411
65444
|
}
|
|
65412
65445
|
const aggregates = index.byType("IFCRELAGGREGATES");
|
|
65413
65446
|
if (aggregates.length !== 3) fail2(`the IFC has ${aggregates.length} spatial aggregations, expected 3.`);
|
|
65414
|
-
const
|
|
65415
|
-
for (const [parentType, childType] of
|
|
65447
|
+
const chain2 = [["IFCPROJECT", "IFCSITE"], ["IFCSITE", "IFCBUILDING"], ["IFCBUILDING", "IFCBUILDINGSTOREY"]];
|
|
65448
|
+
for (const [parentType, childType] of chain2) {
|
|
65416
65449
|
const match = aggregates.find((rel) => {
|
|
65417
65450
|
const parent = index.byId.get(refId(argAt(rel, 4)) ?? -1);
|
|
65418
65451
|
const children = listItems(argAt(rel, 5)) ?? [];
|
|
@@ -70881,10 +70914,10 @@ function registerSteelPrepassRoute(app, deps) {
|
|
|
70881
70914
|
}
|
|
70882
70915
|
let doc = structuredClone(current);
|
|
70883
70916
|
const plans = Array.isArray(doc.plans) ? doc.plans.filter(isObj5) : [];
|
|
70884
|
-
const
|
|
70885
|
-
const missing = Object.keys(sheets).filter((sheet) => !
|
|
70917
|
+
const names2 = plans.map((plan) => String(plan.sheet ?? ""));
|
|
70918
|
+
const missing = Object.keys(sheets).filter((sheet) => !names2.includes(sheet));
|
|
70886
70919
|
if (missing.length) return reply.status(400).send({ ok: false, code: "prepass-unknown-sheet", error: `unknown sheet: ${missing.join(", ")}` });
|
|
70887
|
-
const duplicates = Object.keys(sheets).filter((sheet) =>
|
|
70920
|
+
const duplicates = Object.keys(sheets).filter((sheet) => names2.filter((name) => name === sheet).length > 1);
|
|
70888
70921
|
if (duplicates.length) return reply.status(400).send({ ok: false, code: "prepass-duplicate-sheet", error: `duplicate sheet: ${duplicates.join(", ")}` });
|
|
70889
70922
|
let applied = false;
|
|
70890
70923
|
if (body.filter !== void 0) {
|
|
@@ -70929,7 +70962,7 @@ function registerSteelPrepassRoute(app, deps) {
|
|
|
70929
70962
|
}
|
|
70930
70963
|
}
|
|
70931
70964
|
const filterSheets = filterSheetsOf(doc);
|
|
70932
|
-
const unregistered = filterSheets.map((sheet) => typeof sheet.sheet === "string" ? sheet.sheet.trim() : "").filter((sheet) => sheet && !
|
|
70965
|
+
const unregistered = filterSheets.map((sheet) => typeof sheet.sheet === "string" ? sheet.sheet.trim() : "").filter((sheet) => sheet && !names2.includes(sheet));
|
|
70933
70966
|
if (unregistered.length) {
|
|
70934
70967
|
return reply.status(400).send({
|
|
70935
70968
|
ok: false,
|
|
@@ -70978,6 +71011,7 @@ function registerSteelPrepassRoute(app, deps) {
|
|
|
70978
71011
|
|
|
70979
71012
|
// reference-routes.ts
|
|
70980
71013
|
var import_node_crypto29 = require("node:crypto");
|
|
71014
|
+
var import_node_fs44 = require("node:fs");
|
|
70981
71015
|
|
|
70982
71016
|
// reference-import.ts
|
|
70983
71017
|
var import_node_fs42 = require("node:fs");
|
|
@@ -71003,8 +71037,14 @@ var ReferenceImportError = class extends Error {
|
|
|
71003
71037
|
* refusals it recognises — threw the user's whole selection away on the one refusal whose remedy is
|
|
71004
71038
|
* to try again.
|
|
71005
71039
|
*/
|
|
71006
|
-
|
|
71007
|
-
|
|
71040
|
+
/**
|
|
71041
|
+
* `options` carries a `cause`, which matters wherever a message is REPLACED rather than passed on.
|
|
71042
|
+
* `compareReferences` rewrites the bridge's "unknown command" stderr into "update FloLess"; without a
|
|
71043
|
+
* cause, a wrong command name emitted by US would tell every user to update, forever, with the real
|
|
71044
|
+
* reason unrecoverable from the logs.
|
|
71045
|
+
*/
|
|
71046
|
+
constructor(message, code, options) {
|
|
71047
|
+
super(message, options);
|
|
71008
71048
|
this.code = code;
|
|
71009
71049
|
}
|
|
71010
71050
|
code;
|
|
@@ -71048,12 +71088,12 @@ function toColorRuns(raw, indexCount) {
|
|
|
71048
71088
|
if (!q || !Array.isArray(q.rgba) || q.rgba.length !== 4) return void 0;
|
|
71049
71089
|
if (!q.rgba.every((v) => typeof v === "number" && Number.isFinite(v) && v >= 0 && v <= 1)) return void 0;
|
|
71050
71090
|
if (!Number.isInteger(q.start) || !Number.isInteger(q.count)) return void 0;
|
|
71051
|
-
const start2 = q.start,
|
|
71052
|
-
if (start2 !== at ||
|
|
71053
|
-
if (start2 % 3 !== 0 ||
|
|
71054
|
-
at +=
|
|
71091
|
+
const start2 = q.start, count2 = q.count;
|
|
71092
|
+
if (start2 !== at || count2 <= 0) return void 0;
|
|
71093
|
+
if (start2 % 3 !== 0 || count2 % 3 !== 0) return void 0;
|
|
71094
|
+
at += count2;
|
|
71055
71095
|
if (at > indexCount) return void 0;
|
|
71056
|
-
runs.push({ rgba: [q.rgba[0], q.rgba[1], q.rgba[2], q.rgba[3]], start: start2, count });
|
|
71096
|
+
runs.push({ rgba: [q.rgba[0], q.rgba[1], q.rgba[2], q.rgba[3]], start: start2, count: count2 });
|
|
71057
71097
|
}
|
|
71058
71098
|
return at === indexCount ? runs : void 0;
|
|
71059
71099
|
}
|
|
@@ -71139,10 +71179,10 @@ function toSelection(raw) {
|
|
|
71139
71179
|
if (!q || typeof q !== "object" || Array.isArray(q)) return null;
|
|
71140
71180
|
if (!Number.isInteger(q.candidates) || q.candidates < 0) return null;
|
|
71141
71181
|
if (!Array.isArray(q.unmatched)) return null;
|
|
71142
|
-
const
|
|
71143
|
-
const storeys =
|
|
71144
|
-
const ifcTypes =
|
|
71145
|
-
const ids =
|
|
71182
|
+
const names2 = (v) => Array.isArray(v) && v.every((s) => typeof s === "string") ? v : void 0;
|
|
71183
|
+
const storeys = names2(q.storeys);
|
|
71184
|
+
const ifcTypes = names2(q.ifcTypes);
|
|
71185
|
+
const ids = names2(q.ids);
|
|
71146
71186
|
return {
|
|
71147
71187
|
...storeys ? { storeys } : {},
|
|
71148
71188
|
...ifcTypes ? { ifcTypes } : {},
|
|
@@ -71164,6 +71204,11 @@ function toReferenceObjects(raw) {
|
|
|
71164
71204
|
const all = raw.objects;
|
|
71165
71205
|
const objects = all.filter(renderable).map((o) => ({
|
|
71166
71206
|
id: typeof o.id === "string" ? o.id : "",
|
|
71207
|
+
// MAPPED EXPLICITLY, because this function maps a FIXED FIELD LIST — a field the reader adds and
|
|
71208
|
+
// this list does not name is silently dropped at the door, which is exactly how `globalId` would
|
|
71209
|
+
// have gone missing. `null` when the reader gave us nothing usable, so "the file has no id for
|
|
71210
|
+
// this" survives as a first-class answer instead of decaying into the expressID `id` holds.
|
|
71211
|
+
globalId: typeof o.globalId === "string" && o.globalId ? o.globalId : null,
|
|
71167
71212
|
name: typeof o.name === "string" ? o.name : null,
|
|
71168
71213
|
ifcType: typeof o.ifcType === "string" ? o.ifcType : null,
|
|
71169
71214
|
storey: typeof o.storey === "string" ? o.storey : null,
|
|
@@ -71269,9 +71314,9 @@ function createSegmentPump(companionId, sink) {
|
|
|
71269
71314
|
active2++;
|
|
71270
71315
|
void (async () => {
|
|
71271
71316
|
try {
|
|
71272
|
-
const
|
|
71317
|
+
const text5 = await aware.readRunArtifact(companionId, job.id, job.runId, { signal: controller.signal });
|
|
71273
71318
|
if (stopped) return;
|
|
71274
|
-
const objects = toPreviewObjects(JSON.parse(
|
|
71319
|
+
const objects = toPreviewObjects(JSON.parse(text5));
|
|
71275
71320
|
if (!objects.length) return;
|
|
71276
71321
|
if (painted + objects.length > PREVIEW_MAX_OBJECTS) {
|
|
71277
71322
|
stop("cap");
|
|
@@ -71337,15 +71382,15 @@ var readerChain2 = Promise.resolve();
|
|
|
71337
71382
|
function wantsSegments(command, filter) {
|
|
71338
71383
|
return command === "read-model" && !emittedFilter(filter);
|
|
71339
71384
|
}
|
|
71340
|
-
function
|
|
71385
|
+
function writeReaderAppFor(companionId, invocation) {
|
|
71341
71386
|
const dir = appPath(companionId);
|
|
71342
71387
|
(0, import_node_fs42.mkdirSync)(dir, { recursive: true });
|
|
71343
71388
|
const flo = (0, import_node_path39.join)(dir, `${companionId}.flo`);
|
|
71344
71389
|
const lines = [
|
|
71345
71390
|
`app: ${companionId}`,
|
|
71346
71391
|
"version: 0.1.0",
|
|
71347
|
-
`display-name: ${JSON.stringify(`Reference reader (${command})`)}`,
|
|
71348
|
-
`description: ${JSON.stringify(
|
|
71392
|
+
`display-name: ${JSON.stringify(`Reference reader (${invocation.command})`)}`,
|
|
71393
|
+
`description: ${JSON.stringify(invocation.description)}`,
|
|
71349
71394
|
"exposes-as-agent: false",
|
|
71350
71395
|
"requires:",
|
|
71351
71396
|
// UNPINNED, DELIBERATELY — and this is not laziness, it is the only true statement
|
|
@@ -71367,23 +71412,34 @@ function writeReaderApp2(companionId, command, ifcPath, filter, progressive = fa
|
|
|
71367
71412
|
` - ${AGENT2}`,
|
|
71368
71413
|
"layout: linear",
|
|
71369
71414
|
"nodes:",
|
|
71370
|
-
` - id: ${command}`,
|
|
71415
|
+
` - id: ${invocation.command}`,
|
|
71371
71416
|
` agent: ${AGENT2}`,
|
|
71372
|
-
` command: ${command}`,
|
|
71373
|
-
" config:"
|
|
71374
|
-
` ifc-path: ${JSON.stringify(ifcPath)}`
|
|
71417
|
+
` command: ${invocation.command}`,
|
|
71418
|
+
" config:"
|
|
71375
71419
|
];
|
|
71376
|
-
|
|
71377
|
-
|
|
71378
|
-
|
|
71379
|
-
if (emit?.storeys) lines.push(` storeys: ${JSON.stringify(emit.storeys)}`);
|
|
71380
|
-
if (emit?.ifcTypes) lines.push(` ifc-types: ${JSON.stringify(emit.ifcTypes)}`);
|
|
71381
|
-
if (progressive && wantsSegments(command, filter)) lines.push(` batch-size: ${PREVIEW_BATCH_SIZE}`);
|
|
71420
|
+
for (const [key, value] of Object.entries(invocation.config)) {
|
|
71421
|
+
if (value === void 0) continue;
|
|
71422
|
+
lines.push(` ${key}: ${JSON.stringify(value)}`);
|
|
71382
71423
|
}
|
|
71383
71424
|
lines.push("");
|
|
71384
71425
|
(0, import_node_fs42.writeFileSync)(flo, lines.join("\n"));
|
|
71385
71426
|
return flo;
|
|
71386
71427
|
}
|
|
71428
|
+
var READER_DESCRIPTION = {
|
|
71429
|
+
probe: "Check what an IFC file says about itself \u2014 its units, schema, element count and rough extent \u2014 without reading its geometry, so an oversized file can be refused before it is loaded.",
|
|
71430
|
+
"read-model": "Read a whole IFC file as reference geometry \u2014 every element as a mesh, with the name, type, storey, profile and material the file records for it."
|
|
71431
|
+
};
|
|
71432
|
+
function readerInvocation(command, ifcPath, filter, progressive = false) {
|
|
71433
|
+
const config = { "ifc-path": ifcPath };
|
|
71434
|
+
if (command === "read-model") {
|
|
71435
|
+
config["max-vertices"] = MAX_VERTICES2;
|
|
71436
|
+
const emit = emittedFilter(filter);
|
|
71437
|
+
if (emit?.storeys) config.storeys = emit.storeys;
|
|
71438
|
+
if (emit?.ifcTypes) config["ifc-types"] = emit.ifcTypes;
|
|
71439
|
+
if (progressive && wantsSegments(command, filter)) config["batch-size"] = PREVIEW_BATCH_SIZE;
|
|
71440
|
+
}
|
|
71441
|
+
return { command, description: READER_DESCRIPTION[command], config };
|
|
71442
|
+
}
|
|
71387
71443
|
async function ensureReferenceReader() {
|
|
71388
71444
|
try {
|
|
71389
71445
|
await ensureManagedSidecarsForUserAction();
|
|
@@ -71396,7 +71452,9 @@ async function ensureReferenceReader() {
|
|
|
71396
71452
|
}
|
|
71397
71453
|
}
|
|
71398
71454
|
function readerRunTimeout(command) {
|
|
71399
|
-
|
|
71455
|
+
if (command === "probe") return void 0;
|
|
71456
|
+
if (command === "compare") return READER_RUN_TIMEOUT_MS * 2;
|
|
71457
|
+
return READER_RUN_TIMEOUT_MS;
|
|
71400
71458
|
}
|
|
71401
71459
|
function readerArtifactId(output) {
|
|
71402
71460
|
if (!Object.hasOwn(output, "$aware-artifact")) return null;
|
|
@@ -71410,7 +71468,8 @@ function readerArtifactId(output) {
|
|
|
71410
71468
|
}
|
|
71411
71469
|
return id;
|
|
71412
71470
|
}
|
|
71413
|
-
async function runReader2(companionId,
|
|
71471
|
+
async function runReader2(companionId, invocation, opts = {}) {
|
|
71472
|
+
const command = invocation.command;
|
|
71414
71473
|
const prev = readerChain2;
|
|
71415
71474
|
let release;
|
|
71416
71475
|
readerChain2 = new Promise((r) => release = r);
|
|
@@ -71418,7 +71477,7 @@ async function runReader2(companionId, command, ifcPath, opts = {}) {
|
|
|
71418
71477
|
});
|
|
71419
71478
|
const pump = opts.preview && wantsSegments(command, opts.filter) ? createSegmentPump(companionId, opts.preview) : null;
|
|
71420
71479
|
try {
|
|
71421
|
-
const flo =
|
|
71480
|
+
const flo = writeReaderAppFor(companionId, pump ? { ...invocation, config: { ...invocation.config, "batch-size": PREVIEW_BATCH_SIZE } } : invocation);
|
|
71422
71481
|
try {
|
|
71423
71482
|
await aware.compile(flo);
|
|
71424
71483
|
} catch (e) {
|
|
@@ -71466,9 +71525,12 @@ async function runReader2(companionId, command, ifcPath, opts = {}) {
|
|
|
71466
71525
|
release();
|
|
71467
71526
|
}
|
|
71468
71527
|
}
|
|
71469
|
-
async function
|
|
71528
|
+
async function runReaderCommand(companionId, invocation, opts = {}) {
|
|
71470
71529
|
await ensureReferenceReader();
|
|
71471
|
-
|
|
71530
|
+
return runReader2(companionId, invocation, opts);
|
|
71531
|
+
}
|
|
71532
|
+
async function probeReference(companionId, ifcPath, opts = {}) {
|
|
71533
|
+
const out = await runReaderCommand(companionId, readerInvocation("probe", ifcPath), opts);
|
|
71472
71534
|
const units = out.units ?? {};
|
|
71473
71535
|
const bbox = out.bbox;
|
|
71474
71536
|
return {
|
|
@@ -71485,8 +71547,7 @@ async function probeReference(companionId, ifcPath, opts = {}) {
|
|
|
71485
71547
|
};
|
|
71486
71548
|
}
|
|
71487
71549
|
async function readReferenceModel(companionId, ifcPath, opts = {}) {
|
|
71488
|
-
await
|
|
71489
|
-
const out = await runReader2(companionId, "read-model", ifcPath, opts);
|
|
71550
|
+
const out = await runReaderCommand(companionId, readerInvocation("read-model", ifcPath, opts.filter), opts);
|
|
71490
71551
|
const read2 = toReferenceObjects(out);
|
|
71491
71552
|
assertSelectionConfirmed(read2.selected, opts.filter);
|
|
71492
71553
|
return read2;
|
|
@@ -71639,7 +71700,7 @@ function realish(p) {
|
|
|
71639
71700
|
return (0, import_node_path40.resolve)(p);
|
|
71640
71701
|
}
|
|
71641
71702
|
}
|
|
71642
|
-
var REFERENCE_CACHE_VERSION =
|
|
71703
|
+
var REFERENCE_CACHE_VERSION = 6;
|
|
71643
71704
|
var cachePath2 = (projectId, refId2) => (0, import_node_path40.join)(projectDir(projectId), `.floless-refcache-${safeId2(refId2)}.json`);
|
|
71644
71705
|
function safeId2(refId2) {
|
|
71645
71706
|
const s = String(refId2 ?? "").replace(/[^A-Za-z0-9._-]+/g, "_");
|
|
@@ -71705,10 +71766,290 @@ function removeReference(projectId, refId2, relPath) {
|
|
|
71705
71766
|
dropCache(projectId, refId2);
|
|
71706
71767
|
if (relPath) (0, import_node_fs43.rmSync)(insideProject(projectId, relPath), { force: true });
|
|
71707
71768
|
}
|
|
71769
|
+
function removeReferenceFile(projectId, relPath) {
|
|
71770
|
+
(0, import_node_fs43.rmSync)(insideProject(projectId, relPath), { force: true });
|
|
71771
|
+
}
|
|
71708
71772
|
function takenReferencePaths(refs) {
|
|
71709
71773
|
return new Set((refs ?? []).map((r) => r.file).filter((f) => typeof f === "string"));
|
|
71710
71774
|
}
|
|
71711
71775
|
|
|
71776
|
+
// reference-compare.ts
|
|
71777
|
+
var POSITION_TOLERANCE_MM = 1;
|
|
71778
|
+
var CompareRefusedError = class extends Error {
|
|
71779
|
+
reason;
|
|
71780
|
+
baseObjects;
|
|
71781
|
+
revisedObjects;
|
|
71782
|
+
/** Undrawable products per side. An "empty" side that is empty by skip is repairable; an empty file is not. */
|
|
71783
|
+
skipped;
|
|
71784
|
+
uncomparable;
|
|
71785
|
+
constructor(detail) {
|
|
71786
|
+
super(detail.reason);
|
|
71787
|
+
this.name = "CompareRefusedError";
|
|
71788
|
+
this.reason = detail.reason;
|
|
71789
|
+
this.baseObjects = detail.baseObjects;
|
|
71790
|
+
this.revisedObjects = detail.revisedObjects;
|
|
71791
|
+
this.skipped = detail.skipped;
|
|
71792
|
+
this.uncomparable = detail.uncomparable;
|
|
71793
|
+
}
|
|
71794
|
+
};
|
|
71795
|
+
var isRecord2 = (v) => !!v && typeof v === "object" && !Array.isArray(v);
|
|
71796
|
+
var isCount = (v) => typeof v === "number" && Number.isFinite(v) && v >= 0;
|
|
71797
|
+
var count = (v) => isCount(v) ? Math.floor(v) : 0;
|
|
71798
|
+
var tally = (v) => {
|
|
71799
|
+
if (!isRecord2(v)) return {};
|
|
71800
|
+
const out = {};
|
|
71801
|
+
for (const [k, n] of Object.entries(v)) if (typeof n === "number" && Number.isFinite(n)) out[k] = n;
|
|
71802
|
+
return out;
|
|
71803
|
+
};
|
|
71804
|
+
var side = (v) => {
|
|
71805
|
+
const s = isRecord2(v) ? v : {};
|
|
71806
|
+
const u = isRecord2(s.uncomparable) ? s.uncomparable : {};
|
|
71807
|
+
return {
|
|
71808
|
+
objects: count(s.objects),
|
|
71809
|
+
usableIds: count(s.usableIds),
|
|
71810
|
+
skipped: count(s.skipped),
|
|
71811
|
+
uncomparable: { count: count(u.count), blank: count(u.blank), duplicated: count(u.duplicated), byType: tally(u.byType), byStorey: tally(u.byStorey) }
|
|
71812
|
+
};
|
|
71813
|
+
};
|
|
71814
|
+
var STATUSES = /* @__PURE__ */ new Set(["added", "removed", "changed", "unchanged"]);
|
|
71815
|
+
var triple = (v) => Array.isArray(v) && v.length === 3 && v.every((n) => typeof n === "number" && Number.isFinite(n)) ? [v[0], v[1], v[2]] : null;
|
|
71816
|
+
var text4 = (v) => typeof v === "string" ? v : null;
|
|
71817
|
+
function toChange(raw, index) {
|
|
71818
|
+
if (!isRecord2(raw)) throw new ReferenceImportError(`the comparison returned a change row that is not an object (row ${index + 1})`);
|
|
71819
|
+
const status = raw.status;
|
|
71820
|
+
if (typeof status !== "string" || !STATUSES.has(status)) {
|
|
71821
|
+
throw new ReferenceImportError(`the comparison returned a change row with an unknown status "${String(status)}" (row ${index + 1})`);
|
|
71822
|
+
}
|
|
71823
|
+
const id = raw.id;
|
|
71824
|
+
if (typeof id !== "string" || !id) {
|
|
71825
|
+
throw new ReferenceImportError(`the comparison returned a change row with no id (row ${index + 1})`);
|
|
71826
|
+
}
|
|
71827
|
+
const out = {
|
|
71828
|
+
status,
|
|
71829
|
+
id,
|
|
71830
|
+
name: text4(raw.name),
|
|
71831
|
+
ifcType: text4(raw.ifcType),
|
|
71832
|
+
storey: text4(raw.storey),
|
|
71833
|
+
profile: text4(raw.profile),
|
|
71834
|
+
material: text4(raw.material),
|
|
71835
|
+
centroid: triple(raw.centroid)
|
|
71836
|
+
};
|
|
71837
|
+
if (Array.isArray(raw.changedBy)) out.changedBy = raw.changedBy.filter((c) => typeof c === "string");
|
|
71838
|
+
if (out.status === "changed" && !out.changedBy?.length) {
|
|
71839
|
+
throw new ReferenceImportError(`the comparison marked an object changed without saying what changed about it (row ${index + 1})`);
|
|
71840
|
+
}
|
|
71841
|
+
const delta = triple(raw.delta);
|
|
71842
|
+
if (delta) out.delta = delta;
|
|
71843
|
+
if (typeof raw.distance === "number" && Number.isFinite(raw.distance)) out.distance = raw.distance;
|
|
71844
|
+
if (Array.isArray(raw.fields)) {
|
|
71845
|
+
out.fields = raw.fields.filter(isRecord2).map((f) => ({ name: String(f.name ?? ""), from: f.from ?? null, to: f.to ?? null }));
|
|
71846
|
+
}
|
|
71847
|
+
return out;
|
|
71848
|
+
}
|
|
71849
|
+
function toSummary(raw) {
|
|
71850
|
+
const keys = ["added", "removed", "changed", "unchanged", "uncomparable"];
|
|
71851
|
+
if (!isRecord2(raw)) throw new ReferenceImportError("the comparison returned no summary, so its counts cannot be shown");
|
|
71852
|
+
for (const k of keys) {
|
|
71853
|
+
if (!isCount(raw[k]) || !Number.isInteger(raw[k])) {
|
|
71854
|
+
throw new ReferenceImportError(`the comparison returned a summary with no usable "${k}" count`);
|
|
71855
|
+
}
|
|
71856
|
+
}
|
|
71857
|
+
return { added: raw.added, removed: raw.removed, changed: raw.changed, unchanged: raw.unchanged, uncomparable: raw.uncomparable };
|
|
71858
|
+
}
|
|
71859
|
+
function parseCompareResult(raw) {
|
|
71860
|
+
if (!isRecord2(raw)) throw new ReferenceImportError("the comparison returned nothing we can read");
|
|
71861
|
+
if (raw.frame !== FILE_Z_UP) {
|
|
71862
|
+
throw new ReferenceImportError(
|
|
71863
|
+
`the comparison came back in the "${String(raw.frame ?? "unstated")}" frame rather than "${FILE_Z_UP}" \u2014 your IFC reader is out of date, so update FloLess and try again`
|
|
71864
|
+
);
|
|
71865
|
+
}
|
|
71866
|
+
if (!Array.isArray(raw.criteria)) {
|
|
71867
|
+
throw new ReferenceImportError("the comparison did not say which criteria it applied, so its result cannot be trusted or stored");
|
|
71868
|
+
}
|
|
71869
|
+
if (!raw.criteria.every((c) => typeof c === "string")) {
|
|
71870
|
+
throw new ReferenceImportError("the comparison listed a criterion FloLess cannot read, so its result cannot be trusted or stored");
|
|
71871
|
+
}
|
|
71872
|
+
const criteria = raw.criteria;
|
|
71873
|
+
const identity = isRecord2(raw.identity) ? raw.identity : null;
|
|
71874
|
+
if (!identity) {
|
|
71875
|
+
throw new ReferenceImportError("the comparison did not report what it matched, so its result cannot be shown");
|
|
71876
|
+
}
|
|
71877
|
+
const refused2 = isRecord2(identity.refused) ? identity.refused : null;
|
|
71878
|
+
if (refused2) {
|
|
71879
|
+
if (!isCount(refused2.baseObjects) || !isCount(refused2.revisedObjects)) {
|
|
71880
|
+
throw new ReferenceImportError("the comparison refused, but did not say how many objects it saw in either file, so there is nothing honest to report");
|
|
71881
|
+
}
|
|
71882
|
+
const skipped = isRecord2(refused2.skipped) ? refused2.skipped : {};
|
|
71883
|
+
throw new CompareRefusedError({
|
|
71884
|
+
reason: typeof refused2.reason === "string" && refused2.reason ? refused2.reason : "these two files could not be compared",
|
|
71885
|
+
baseObjects: count(refused2.baseObjects),
|
|
71886
|
+
revisedObjects: count(refused2.revisedObjects),
|
|
71887
|
+
// `skipped` and `uncomparable` DO default, and the asymmetry is deliberate: they qualify the
|
|
71888
|
+
// refusal ("…and everything in one file was undrawable") where the object counts ARE the
|
|
71889
|
+
// refusal. Absent means the bridge reported none, which is what zero says.
|
|
71890
|
+
skipped: { base: count(skipped.base), revised: count(skipped.revised) },
|
|
71891
|
+
uncomparable: count(refused2.uncomparable)
|
|
71892
|
+
});
|
|
71893
|
+
}
|
|
71894
|
+
if (!criteria.length) {
|
|
71895
|
+
throw new ReferenceImportError("the comparison reported no criteria, so there is no statement of what it compared");
|
|
71896
|
+
}
|
|
71897
|
+
if (!Array.isArray(raw.changes)) {
|
|
71898
|
+
throw new ReferenceImportError("the comparison returned no changes list and no refusal, so it cannot be shown either way");
|
|
71899
|
+
}
|
|
71900
|
+
const changes = raw.changes.map(toChange);
|
|
71901
|
+
const summary2 = toSummary(raw.summary);
|
|
71902
|
+
const matched = {
|
|
71903
|
+
paired: count(identity.paired),
|
|
71904
|
+
added: count(identity.added),
|
|
71905
|
+
removed: count(identity.removed),
|
|
71906
|
+
base: side(identity.base),
|
|
71907
|
+
revised: side(identity.revised)
|
|
71908
|
+
};
|
|
71909
|
+
reconcile(summary2, changes, matched);
|
|
71910
|
+
const sel = isRecord2(raw.selected) ? raw.selected : null;
|
|
71911
|
+
return {
|
|
71912
|
+
frame: FILE_Z_UP,
|
|
71913
|
+
identity: matched,
|
|
71914
|
+
changes,
|
|
71915
|
+
criteria,
|
|
71916
|
+
summary: summary2,
|
|
71917
|
+
selected: sel ? { base: toSelection(sel.base), revised: toSelection(sel.revised) } : null
|
|
71918
|
+
};
|
|
71919
|
+
}
|
|
71920
|
+
function reconcile(summary2, changes, identity) {
|
|
71921
|
+
for (const status of ["added", "removed", "changed"]) {
|
|
71922
|
+
const rows2 = changes.filter((c) => c.status === status).length;
|
|
71923
|
+
if (summary2[status] !== rows2) {
|
|
71924
|
+
throw new ReferenceImportError(
|
|
71925
|
+
`the comparison's summary disagrees with its own change list \u2014 it reports ${summary2[status]} ${status}, but lists ${rows2}`
|
|
71926
|
+
);
|
|
71927
|
+
}
|
|
71928
|
+
}
|
|
71929
|
+
if (identity.added !== summary2.added || identity.removed !== summary2.removed) {
|
|
71930
|
+
throw new ReferenceImportError(
|
|
71931
|
+
`the comparison's matching counts disagree with its summary \u2014 ${identity.added}/${identity.removed} added/removed against ${summary2.added}/${summary2.removed}`
|
|
71932
|
+
);
|
|
71933
|
+
}
|
|
71934
|
+
const perSide = identity.base.uncomparable.count + identity.revised.uncomparable.count;
|
|
71935
|
+
if (summary2.uncomparable !== perSide) {
|
|
71936
|
+
throw new ReferenceImportError(
|
|
71937
|
+
`the comparison reports ${summary2.uncomparable} objects it could not compare, but accounts for ${perSide}`
|
|
71938
|
+
);
|
|
71939
|
+
}
|
|
71940
|
+
}
|
|
71941
|
+
var names = (v) => {
|
|
71942
|
+
const list = Array.isArray(v) ? v.filter((s) => typeof s === "string" && !!s.trim()) : [];
|
|
71943
|
+
return list.length ? list : void 0;
|
|
71944
|
+
};
|
|
71945
|
+
function sidesDiffer(base, revised) {
|
|
71946
|
+
const key = (s) => JSON.stringify([[...s.storeys ?? []].sort(), [...s.ifcTypes ?? []].sort()]);
|
|
71947
|
+
return key(base) !== key(revised);
|
|
71948
|
+
}
|
|
71949
|
+
var statedBaseSide = (opts) => Object.hasOwn(opts, "baseFilter");
|
|
71950
|
+
function compareInvocation(basePath, revisedPath, opts = {}) {
|
|
71951
|
+
const config = {
|
|
71952
|
+
"base-ifc-path": basePath,
|
|
71953
|
+
"revised-ifc-path": revisedPath
|
|
71954
|
+
};
|
|
71955
|
+
const revised = { storeys: names(opts.filter?.storeys), ifcTypes: names(opts.filter?.ifcTypes) };
|
|
71956
|
+
const base = { storeys: names(opts.baseFilter?.storeys), ifcTypes: names(opts.baseFilter?.ifcTypes) };
|
|
71957
|
+
if (!statedBaseSide(opts) || !sidesDiffer(base, revised)) {
|
|
71958
|
+
if (revised.storeys) config.storeys = revised.storeys;
|
|
71959
|
+
if (revised.ifcTypes) config["ifc-types"] = revised.ifcTypes;
|
|
71960
|
+
} else {
|
|
71961
|
+
if (base.storeys) config["base-storeys"] = base.storeys;
|
|
71962
|
+
if (base.ifcTypes) config["base-ifc-types"] = base.ifcTypes;
|
|
71963
|
+
if (revised.storeys) config["revised-storeys"] = revised.storeys;
|
|
71964
|
+
if (revised.ifcTypes) config["revised-ifc-types"] = revised.ifcTypes;
|
|
71965
|
+
}
|
|
71966
|
+
config["position-tolerance-mm"] = typeof opts.toleranceMm === "number" && Number.isFinite(opts.toleranceMm) && opts.toleranceMm > 0 ? opts.toleranceMm : POSITION_TOLERANCE_MM;
|
|
71967
|
+
return {
|
|
71968
|
+
command: "compare",
|
|
71969
|
+
// Plain English, per CLAUDE.md's standing rule: this becomes the node's Inspect ▸ Description, and
|
|
71970
|
+
// it is written for somebody who does not read code.
|
|
71971
|
+
description: "Compare two versions of one IFC file and say what was added, removed and changed \u2014 matching each object by the identity the file itself gives it, and refusing to guess when the two files share no identities at all.",
|
|
71972
|
+
config
|
|
71973
|
+
};
|
|
71974
|
+
}
|
|
71975
|
+
async function compareReferences(companionId, basePath, revisedPath, opts = {}) {
|
|
71976
|
+
let out;
|
|
71977
|
+
try {
|
|
71978
|
+
out = await runReaderCommand(companionId, compareInvocation(basePath, revisedPath, opts), { ticket: opts.ticket });
|
|
71979
|
+
} catch (e) {
|
|
71980
|
+
if (e instanceof ReferenceImportError && /unknown command/i.test(e.message)) {
|
|
71981
|
+
throw new ReferenceImportError(
|
|
71982
|
+
"your IFC reader is too old to compare two versions of a file \u2014 update FloLess and try again",
|
|
71983
|
+
"reference-reader-too-old",
|
|
71984
|
+
{ cause: e }
|
|
71985
|
+
);
|
|
71986
|
+
}
|
|
71987
|
+
throw e;
|
|
71988
|
+
}
|
|
71989
|
+
const result = parseCompareResult(out);
|
|
71990
|
+
const baseAsked = statedBaseSide(opts) ? opts.baseFilter : opts.filter;
|
|
71991
|
+
if (emittedFilter(baseAsked)) assertSelectionConfirmed(result.selected?.base ?? null, baseAsked);
|
|
71992
|
+
if (emittedFilter(opts.filter)) assertSelectionConfirmed(result.selected?.revised ?? null, opts.filter);
|
|
71993
|
+
return result;
|
|
71994
|
+
}
|
|
71995
|
+
|
|
71996
|
+
// reference-versions.ts
|
|
71997
|
+
var chain = (e) => e.versions ?? [];
|
|
71998
|
+
var currentVersion = (e) => chain(e).at(-1) ?? null;
|
|
71999
|
+
var currentVersionId = (e) => currentVersion(e)?.id ?? null;
|
|
72000
|
+
function versionIdsAreUnique(e) {
|
|
72001
|
+
const v = chain(e);
|
|
72002
|
+
return new Set(v.map((x) => x.id)).size === v.length;
|
|
72003
|
+
}
|
|
72004
|
+
var normalizeFilter2 = (f) => {
|
|
72005
|
+
const part = (v) => v?.length ? [...v].sort() : [];
|
|
72006
|
+
const s = part(f?.storeys);
|
|
72007
|
+
const t = part(f?.ifcTypes);
|
|
72008
|
+
return s.length || t.length ? JSON.stringify([s, t]) : null;
|
|
72009
|
+
};
|
|
72010
|
+
var sameFilter = (a, b) => normalizeFilter2(a) === normalizeFilter2(b);
|
|
72011
|
+
function mirrorIsIntact(e) {
|
|
72012
|
+
const last = currentVersion(e);
|
|
72013
|
+
if (!last) return true;
|
|
72014
|
+
return e.file === last.file && e.name === last.name && sameFilter(e.filter, last.filter);
|
|
72015
|
+
}
|
|
72016
|
+
function withMirror(e, last, versions) {
|
|
72017
|
+
const out = { ...e, file: last.file, name: last.name, versions };
|
|
72018
|
+
if (last.filter === void 0) delete out.filter;
|
|
72019
|
+
else out.filter = last.filter;
|
|
72020
|
+
return out;
|
|
72021
|
+
}
|
|
72022
|
+
var refuseCollision = (versions, id) => {
|
|
72023
|
+
if (versions.some((v) => v.id === id)) throw new Error(`version id '${id}' already exists in this reference's chain`);
|
|
72024
|
+
};
|
|
72025
|
+
function adoptChain(e, opts) {
|
|
72026
|
+
if (chain(e).length) return e;
|
|
72027
|
+
const id = opts.mintId?.() ?? cryptoId();
|
|
72028
|
+
refuseCollision(chain(e), id);
|
|
72029
|
+
const v1 = {
|
|
72030
|
+
id,
|
|
72031
|
+
file: e.file,
|
|
72032
|
+
name: e.name,
|
|
72033
|
+
// The bytes are not knowable from the entry alone; the route hashes the retained original and
|
|
72034
|
+
// passes it. A zero-filled placeholder would satisfy the schema pattern and lie, so absence is
|
|
72035
|
+
// filled by the caller rather than invented here.
|
|
72036
|
+
sha256: opts.sha256 ?? "0".repeat(64),
|
|
72037
|
+
importedAt: opts.at,
|
|
72038
|
+
adopted: true,
|
|
72039
|
+
...e.filter === void 0 ? {} : { filter: e.filter }
|
|
72040
|
+
};
|
|
72041
|
+
return { ...e, versions: [v1] };
|
|
72042
|
+
}
|
|
72043
|
+
function appendVersion(e, version, opts = {}) {
|
|
72044
|
+
const base = adoptChain(e, { mintId: opts.mintId, at: opts.at ?? version.importedAt });
|
|
72045
|
+
const versions = chain(base);
|
|
72046
|
+
refuseCollision(versions, version.id);
|
|
72047
|
+
const next = [...versions, version];
|
|
72048
|
+
return withMirror(base, version, next);
|
|
72049
|
+
}
|
|
72050
|
+
var newVersionId = () => `v-${globalThis.crypto.randomUUID()}`;
|
|
72051
|
+
var cryptoId = newVersionId;
|
|
72052
|
+
|
|
71712
72053
|
// disconnect-guard.ts
|
|
71713
72054
|
function watchDisconnect(reply, onGone) {
|
|
71714
72055
|
let done = false;
|
|
@@ -71830,6 +72171,74 @@ function unmatchedMessage(name, missed, remedy) {
|
|
|
71830
72171
|
const what = missed.length ? `has nothing under ${missed.map((m) => `"${m}"`).join(", ")}` : "has nothing under the storeys or types it was loaded with";
|
|
71831
72172
|
return `"${name}" ${what}. The file may have been re-exported with different names \u2014 ${remedy}`;
|
|
71832
72173
|
}
|
|
72174
|
+
var PreconditionError = class extends Error {
|
|
72175
|
+
constructor(status, body) {
|
|
72176
|
+
super(body.error);
|
|
72177
|
+
this.status = status;
|
|
72178
|
+
this.body = body;
|
|
72179
|
+
}
|
|
72180
|
+
status;
|
|
72181
|
+
body;
|
|
72182
|
+
};
|
|
72183
|
+
function precondition(entry2, body, expect) {
|
|
72184
|
+
const refuse = (status, error, code, extra = {}) => ({ status, body: { ok: false, error, code, ...extra } });
|
|
72185
|
+
if (entry2.display?.locked) {
|
|
72186
|
+
return refuse(409, `"${entry2.name}" is locked \u2014 unlock it in the Reference models panel to load a new version of it`, "reference-locked");
|
|
72187
|
+
}
|
|
72188
|
+
if (!mirrorIsIntact(entry2)) {
|
|
72189
|
+
return refuse(409, `"${entry2.name}" records a version history that disagrees with the file it currently points at, so a new version cannot safely be added to it`, "reference-mirror-diverged");
|
|
72190
|
+
}
|
|
72191
|
+
if (!versionIdsAreUnique(entry2)) {
|
|
72192
|
+
return refuse(409, `"${entry2.name}" records two versions under the same id, so a new version cannot safely be added to it`, "reference-versions-ambiguous");
|
|
72193
|
+
}
|
|
72194
|
+
if (!("expectedVersionId" in body)) {
|
|
72195
|
+
return refuse(400, "a new version must say which version it believes is current", "reference-version-expected-missing");
|
|
72196
|
+
}
|
|
72197
|
+
const expected = body.expectedVersionId ?? null;
|
|
72198
|
+
if (expected !== null && typeof expected !== "string") {
|
|
72199
|
+
return refuse(400, "a new version must say which version it believes is current", "reference-version-expected-missing");
|
|
72200
|
+
}
|
|
72201
|
+
const actual = currentVersionId(entry2);
|
|
72202
|
+
if (expected !== actual) {
|
|
72203
|
+
return refuse(
|
|
72204
|
+
409,
|
|
72205
|
+
actual === null ? `"${entry2.name}" has no version history yet, but this upload expected one \u2014 reload the project and try again` : `"${entry2.name}" moved on to another version while this one was being prepared \u2014 reload the project and try again`,
|
|
72206
|
+
"reference-version-stale",
|
|
72207
|
+
{ currentVersionId: actual }
|
|
72208
|
+
);
|
|
72209
|
+
}
|
|
72210
|
+
if (expect && (entry2.file !== expect.file || !sameEmittedFilter(entry2.filter, expect.filter))) {
|
|
72211
|
+
return refuse(
|
|
72212
|
+
409,
|
|
72213
|
+
`"${entry2.name}" now points at a different file or a different part of it than the one this version was compared against \u2014 reload the project and try again`,
|
|
72214
|
+
"reference-version-stale",
|
|
72215
|
+
{ currentVersionId: actual }
|
|
72216
|
+
);
|
|
72217
|
+
}
|
|
72218
|
+
return null;
|
|
72219
|
+
}
|
|
72220
|
+
function sameEmittedFilter(a, b) {
|
|
72221
|
+
const key = (f) => {
|
|
72222
|
+
const e = emittedFilter(f);
|
|
72223
|
+
return e ? JSON.stringify([[...e.storeys ?? []].sort(), [...e.ifcTypes ?? []].sort()]) : null;
|
|
72224
|
+
};
|
|
72225
|
+
return key(a) === key(b);
|
|
72226
|
+
}
|
|
72227
|
+
function storeysMissingFrom(probe, filter) {
|
|
72228
|
+
if (!probe.storeys || !filter?.storeys?.length) return [];
|
|
72229
|
+
const have = new Set(probe.storeys.map((r) => r.name).filter((n) => typeof n === "string").map((n) => n.toLowerCase()));
|
|
72230
|
+
return filter.storeys.filter((s) => !have.has(s.toLowerCase()));
|
|
72231
|
+
}
|
|
72232
|
+
function filterUnmatchedBody(refName2, fileName, missed, probe) {
|
|
72233
|
+
const what = missed.length ? `has nothing under ${missed.map((m) => `"${m}"`).join(", ")}` : "has nothing under the storeys or types this reference was loaded with";
|
|
72234
|
+
return {
|
|
72235
|
+
ok: false,
|
|
72236
|
+
code: "reference-filter-unmatched",
|
|
72237
|
+
error: `"${fileName}" ${what}, which is what "${refName2}" is currently read under. It may have been re-exported with different names \u2014 load the new version unfiltered, pick a new filter, or cancel.`,
|
|
72238
|
+
unmatched: missed,
|
|
72239
|
+
probe
|
|
72240
|
+
};
|
|
72241
|
+
}
|
|
71833
72242
|
function referencesOf(doc) {
|
|
71834
72243
|
const refs = doc.reference_models;
|
|
71835
72244
|
return Array.isArray(refs) ? refs : [];
|
|
@@ -71952,8 +72361,8 @@ function registerReferenceRoutes(app, deps) {
|
|
|
71952
72361
|
const { sha, name, placement, progressId: sessionId } = req.body ?? {};
|
|
71953
72362
|
if (!sha) return reply.status(400).send({ ok: false, error: "probe the file first \u2014 its sha is required" });
|
|
71954
72363
|
const asked = req.body?.filter;
|
|
71955
|
-
const
|
|
71956
|
-
const filter = emittedFilter({ storeys:
|
|
72364
|
+
const names2 = (v) => Array.isArray(v) ? v.filter((s) => typeof s === "string" && !!s.trim()) : [];
|
|
72365
|
+
const filter = emittedFilter({ storeys: names2(asked?.storeys), ifcTypes: names2(asked?.ifcTypes) }) ?? void 0;
|
|
71957
72366
|
if (asked !== void 0 && !filter) {
|
|
71958
72367
|
return reply.status(400).send({
|
|
71959
72368
|
ok: false,
|
|
@@ -72045,7 +72454,20 @@ function registerReferenceRoutes(app, deps) {
|
|
|
72045
72454
|
units: { declared: probe.units.declared, override: null },
|
|
72046
72455
|
// Half-opacity by default, because a reference that arrives looking like our own steel is the
|
|
72047
72456
|
// one mistake this feature must never make.
|
|
72048
|
-
display: { visible: true, opacity: 0.5, locked: false, snap: true }
|
|
72457
|
+
display: { visible: true, opacity: 0.5, locked: false, snap: true },
|
|
72458
|
+
// BORN WITH A CHAIN, from this feature onward (#734). Without it every reference inserted
|
|
72459
|
+
// after ship is born chainless and immediately needs the legacy `expectedVersionId: null`
|
|
72460
|
+
// path — which would keep that path load-bearing forever instead of leaving it as the
|
|
72461
|
+
// migration it is meant to be. No `adopted` flag: this row's `importedAt` is a real import
|
|
72462
|
+
// date, which is precisely what an adopted row cannot claim.
|
|
72463
|
+
versions: [{
|
|
72464
|
+
id: newVersionId(),
|
|
72465
|
+
file: rel,
|
|
72466
|
+
name: displayName,
|
|
72467
|
+
sha256: sourceHash,
|
|
72468
|
+
importedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
72469
|
+
...filter ? { filter } : {}
|
|
72470
|
+
}]
|
|
72049
72471
|
};
|
|
72050
72472
|
const etag = await withLifecycleLock("project", g.project, async () => {
|
|
72051
72473
|
if (scope.gone()) throw new ReferenceImportError("cancelled");
|
|
@@ -72156,6 +72578,234 @@ function registerReferenceRoutes(app, deps) {
|
|
|
72156
72578
|
}
|
|
72157
72579
|
}
|
|
72158
72580
|
);
|
|
72581
|
+
app.post(
|
|
72582
|
+
"/api/steel/:appId/reference/:id/version",
|
|
72583
|
+
async (req, reply) => {
|
|
72584
|
+
const scope = runScope(deps, reply, { detachOnDisconnect: true });
|
|
72585
|
+
const g = gate2(deps, req.params.appId, req.query.project);
|
|
72586
|
+
if (!g.ok) return reply.status(g.refusal.status).send(g.refusal.body);
|
|
72587
|
+
const entry2 = referencesOf(g.doc).find((r) => r.id === req.params.id);
|
|
72588
|
+
if (!entry2) return reply.status(404).send({ ok: false, error: "no such reference model" });
|
|
72589
|
+
const pre = precondition(entry2, req.body ?? {});
|
|
72590
|
+
if (pre) return reply.status(pre.status).send(pre.body);
|
|
72591
|
+
const { sha, name, progressId: sessionId } = req.body ?? {};
|
|
72592
|
+
if (!sha) return reply.status(400).send({ ok: false, error: "probe the file first \u2014 its sha is required" });
|
|
72593
|
+
const displayName = String(name || entry2.name || "model.ifc");
|
|
72594
|
+
if (entry2.filter && !emittedFilter(entry2.filter)) {
|
|
72595
|
+
return reply.status(409).send({
|
|
72596
|
+
ok: false,
|
|
72597
|
+
code: "reference-filter-unreadable",
|
|
72598
|
+
error: `"${entry2.name}" records which part of the file to load, but not in a form FloLess can read. Remove the reference and add it again to choose the storeys afresh.`
|
|
72599
|
+
});
|
|
72600
|
+
}
|
|
72601
|
+
let filter;
|
|
72602
|
+
if (req.body?.filter === void 0) {
|
|
72603
|
+
filter = entry2.filter;
|
|
72604
|
+
} else if (req.body.filter === null) {
|
|
72605
|
+
filter = void 0;
|
|
72606
|
+
} else {
|
|
72607
|
+
const asked = req.body.filter;
|
|
72608
|
+
const names2 = (v) => Array.isArray(v) ? v.filter((s) => typeof s === "string" && !!s.trim()) : [];
|
|
72609
|
+
filter = emittedFilter({ storeys: names2(asked.storeys), ifcTypes: names2(asked.ifcTypes) }) ?? void 0;
|
|
72610
|
+
if (!filter) {
|
|
72611
|
+
return reply.status(400).send({
|
|
72612
|
+
ok: false,
|
|
72613
|
+
code: "reference-empty-filter",
|
|
72614
|
+
error: "choose at least one storey or type to load, or clear the selection to load the whole file"
|
|
72615
|
+
});
|
|
72616
|
+
}
|
|
72617
|
+
}
|
|
72618
|
+
const source = ifcInputPath(g.appId, String(sha));
|
|
72619
|
+
if (!source) {
|
|
72620
|
+
return reply.status(404).send({ ok: false, error: "the uploaded IFC is no longer available \u2014 drop the file again" });
|
|
72621
|
+
}
|
|
72622
|
+
const basePath = entry2.file ? originalPath(g.project, entry2.file) : null;
|
|
72623
|
+
if (!basePath) {
|
|
72624
|
+
return reply.status(409).send({
|
|
72625
|
+
ok: false,
|
|
72626
|
+
code: "reference-unresolved",
|
|
72627
|
+
error: `"${entry2.name}" is missing from this project, so there is no version to compare the new file against \u2014 relink it first`
|
|
72628
|
+
});
|
|
72629
|
+
}
|
|
72630
|
+
const versionId = newVersionId();
|
|
72631
|
+
let rel = null;
|
|
72632
|
+
let committed = false;
|
|
72633
|
+
let preview2 = null;
|
|
72634
|
+
const rollback = () => {
|
|
72635
|
+
if (committed || !rel) return;
|
|
72636
|
+
try {
|
|
72637
|
+
removeReferenceFile(g.project, rel);
|
|
72638
|
+
} catch (e) {
|
|
72639
|
+
app.log.error({ project: g.project, id: entry2.id, rel, err: e }, "reference version rollback failed \u2014 an orphaned original is left on disk");
|
|
72640
|
+
}
|
|
72641
|
+
};
|
|
72642
|
+
try {
|
|
72643
|
+
try {
|
|
72644
|
+
assertAcceptable((0, import_node_fs44.statSync)(source).size, displayName);
|
|
72645
|
+
} catch (e) {
|
|
72646
|
+
const r = importRefusal(e);
|
|
72647
|
+
if (r) return reply.status(r.status).send(r.body);
|
|
72648
|
+
throw e;
|
|
72649
|
+
}
|
|
72650
|
+
const probe = await deps.reader.probe(companion(g.appId), source, { ticket: scope.ticket() });
|
|
72651
|
+
const estimate = selectedPopulation(probe, filter);
|
|
72652
|
+
if (estimate !== null && objectVerdict(estimate) === "refuse") {
|
|
72653
|
+
return reply.status(400).send({
|
|
72654
|
+
ok: false,
|
|
72655
|
+
code: "reference-too-many-objects",
|
|
72656
|
+
error: tooMany(`"${displayName}" would load about ${estimate.toLocaleString("en-US")} objects`, probe)
|
|
72657
|
+
});
|
|
72658
|
+
}
|
|
72659
|
+
const missedInProbe = storeysMissingFrom(probe, filter);
|
|
72660
|
+
if (missedInProbe.length) {
|
|
72661
|
+
return reply.status(409).send(filterUnmatchedBody(entry2.name, displayName, missedInProbe, probe));
|
|
72662
|
+
}
|
|
72663
|
+
let comparison;
|
|
72664
|
+
try {
|
|
72665
|
+
comparison = await deps.reader.compare(companion(g.appId), basePath, source, {
|
|
72666
|
+
ticket: scope.ticket(),
|
|
72667
|
+
filter,
|
|
72668
|
+
// THE BASE SIDE KEEPS THE FILTER IT WAS READ UNDER. Identical on the ordinary path (where
|
|
72669
|
+
// `sidesDiffer` collapses it back to one shared filter), and load-bearing on §6.3's
|
|
72670
|
+
// remedy: applying a newly-chosen filter to the OLD file asks it for a storey it has never
|
|
72671
|
+
// had, resolves nothing there, and reports every object in the new file as `added`.
|
|
72672
|
+
baseFilter: entry2.filter
|
|
72673
|
+
});
|
|
72674
|
+
} catch (e) {
|
|
72675
|
+
if (e instanceof CompareRefusedError) {
|
|
72676
|
+
return reply.status(409).send({
|
|
72677
|
+
ok: false,
|
|
72678
|
+
code: "reference-compare-refused",
|
|
72679
|
+
error: e.reason,
|
|
72680
|
+
refused: {
|
|
72681
|
+
reason: e.reason,
|
|
72682
|
+
baseObjects: e.baseObjects,
|
|
72683
|
+
revisedObjects: e.revisedObjects,
|
|
72684
|
+
skipped: e.skipped,
|
|
72685
|
+
uncomparable: e.uncomparable,
|
|
72686
|
+
baseName: entry2.name,
|
|
72687
|
+
revisedName: displayName
|
|
72688
|
+
}
|
|
72689
|
+
});
|
|
72690
|
+
}
|
|
72691
|
+
throw e;
|
|
72692
|
+
}
|
|
72693
|
+
const missed = unmatchedNames(comparison.selected?.revised ?? null);
|
|
72694
|
+
if (hasUnmatched(comparison.selected?.revised ?? null)) {
|
|
72695
|
+
return reply.status(409).send(filterUnmatchedBody(entry2.name, displayName, missed, probe));
|
|
72696
|
+
}
|
|
72697
|
+
if (hasUnmatched(comparison.selected?.base ?? null)) {
|
|
72698
|
+
const baseMissed = unmatchedNames(comparison.selected?.base ?? null);
|
|
72699
|
+
return reply.status(409).send({
|
|
72700
|
+
ok: false,
|
|
72701
|
+
code: "reference-compare-base-unmatched",
|
|
72702
|
+
error: `The version of "${entry2.name}" you already have has nothing under ${baseMissed.map((m) => `"${m}"`).join(", ") || "the storeys or types it was loaded with"}, so there is nothing to compare the new file against. Load it as a separate reference instead.`,
|
|
72703
|
+
unmatched: baseMissed
|
|
72704
|
+
});
|
|
72705
|
+
}
|
|
72706
|
+
rel = await withLifecycleLock("project", g.project, () => {
|
|
72707
|
+
const doc = readAcceptedForRequest(g.appId, g.project);
|
|
72708
|
+
const taken = takenReferencePaths(referencesOf(doc ?? {}));
|
|
72709
|
+
for (const f of referenceFilesOnDisk(g.project)) taken.add(f);
|
|
72710
|
+
const claimed2 = projectRelativeReferencePath(displayName, taken);
|
|
72711
|
+
copyOriginal(g.project, claimed2, source, versionId);
|
|
72712
|
+
return claimed2;
|
|
72713
|
+
});
|
|
72714
|
+
const abs = originalPath(g.project, rel);
|
|
72715
|
+
if (!abs) throw new ReferenceImportError("the copied file vanished before it could be read");
|
|
72716
|
+
const sourceHash = await hashFile(abs);
|
|
72717
|
+
const adoptedSha = currentVersionId(entry2) === null ? await hashFile(basePath) : null;
|
|
72718
|
+
preview2 = previewFor(sessionId, g.appId, g.project);
|
|
72719
|
+
const geometry = await deps.reader.readModel(companion(g.appId), abs, {
|
|
72720
|
+
ticket: scope.ticket(),
|
|
72721
|
+
filter,
|
|
72722
|
+
...preview2 ? { preview: preview2.sink } : {}
|
|
72723
|
+
});
|
|
72724
|
+
if (scope.gone()) throw new ReferenceImportError("cancelled");
|
|
72725
|
+
if (!geometry.objects.length && hasUnmatched(geometry.selected)) {
|
|
72726
|
+
rollback();
|
|
72727
|
+
return reply.status(409).send(filterUnmatchedBody(entry2.name, displayName, unmatchedNames(geometry.selected), probe));
|
|
72728
|
+
}
|
|
72729
|
+
if (!geometry.objects.length) {
|
|
72730
|
+
rollback();
|
|
72731
|
+
return reply.status(400).send({ ok: false, error: `"${displayName}" has no geometry we can draw` });
|
|
72732
|
+
}
|
|
72733
|
+
if (objectVerdict(geometry.objects.length) === "refuse") {
|
|
72734
|
+
rollback();
|
|
72735
|
+
return reply.status(400).send({
|
|
72736
|
+
ok: false,
|
|
72737
|
+
code: "reference-too-many-objects",
|
|
72738
|
+
error: tooMany(`"${displayName}" read ${geometry.objects.length.toLocaleString("en-US")} objects`, probe)
|
|
72739
|
+
});
|
|
72740
|
+
}
|
|
72741
|
+
writeCache2(g.project, entry2.id, { v: REFERENCE_CACHE_VERSION, sourceHash, dropped: geometry.dropped, colorsAvailable: geometry.colorsAvailable, colorsDropped: geometry.colorsDropped, propertySetsAvailable: geometry.propertySetsAvailable, ...filter ? { filter } : {}, objects: geometry.objects });
|
|
72742
|
+
const version = {
|
|
72743
|
+
id: versionId,
|
|
72744
|
+
file: rel,
|
|
72745
|
+
name: displayName,
|
|
72746
|
+
sha256: sourceHash,
|
|
72747
|
+
importedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
72748
|
+
...filter ? { filter } : {}
|
|
72749
|
+
};
|
|
72750
|
+
let next;
|
|
72751
|
+
const etag = await withLifecycleLock("project", g.project, async () => {
|
|
72752
|
+
if (scope.gone()) throw new ReferenceImportError("cancelled");
|
|
72753
|
+
const current = readAcceptedForRequest(g.appId, g.project);
|
|
72754
|
+
if (current == null) throw new ReferenceImportError("this project has no model to attach a reference to");
|
|
72755
|
+
const now = referencesOf(current).find((r) => r.id === entry2.id);
|
|
72756
|
+
if (!now) throw new ReferenceImportError(`"${entry2.name}" was removed while its new version was being read`);
|
|
72757
|
+
const late = precondition(now, req.body ?? {}, { file: entry2.file, filter: entry2.filter });
|
|
72758
|
+
if (late) throw new PreconditionError(late.status, late.body);
|
|
72759
|
+
const adopted = adoptChain(now, {
|
|
72760
|
+
at: version.importedAt,
|
|
72761
|
+
...adoptedSha ? { sha256: adoptedSha } : {}
|
|
72762
|
+
});
|
|
72763
|
+
next = appendVersion(adopted, version);
|
|
72764
|
+
const written = await writeContractChecked(g.appId, {
|
|
72765
|
+
...current,
|
|
72766
|
+
reference_models: referencesOf(current).map((r) => r.id === entry2.id ? next : r)
|
|
72767
|
+
}, g.project, {
|
|
72768
|
+
origin: "internal",
|
|
72769
|
+
why: "appending a reference version rewrites one entry by id under a precondition the route re-checks inside this lock"
|
|
72770
|
+
});
|
|
72771
|
+
return written.etag;
|
|
72772
|
+
});
|
|
72773
|
+
committed = true;
|
|
72774
|
+
deps.broadcast(contractChangedEvent(g.appId, g.project, etag, req.headers["x-floless-mutation-id"]));
|
|
72775
|
+
return {
|
|
72776
|
+
ok: true,
|
|
72777
|
+
etag,
|
|
72778
|
+
reference: next,
|
|
72779
|
+
version,
|
|
72780
|
+
versions: next.versions ?? [version],
|
|
72781
|
+
// THE COMPARISON RIDES THE SUCCESS. It was computed before the copy and is the answer the
|
|
72782
|
+
// user asked for; recomputing it from a second request would compare the new version against
|
|
72783
|
+
// itself.
|
|
72784
|
+
comparison,
|
|
72785
|
+
objects: geometry.objects,
|
|
72786
|
+
dropped: geometry.dropped,
|
|
72787
|
+
colorsAvailable: geometry.colorsAvailable,
|
|
72788
|
+
colorsDropped: geometry.colorsDropped,
|
|
72789
|
+
propertySetsAvailable: geometry.propertySetsAvailable,
|
|
72790
|
+
spanMm: spanOf(geometry.objects),
|
|
72791
|
+
...hasUnmatched(geometry.selected) ? { unmatched: unmatchedNames(geometry.selected) } : {}
|
|
72792
|
+
};
|
|
72793
|
+
} catch (e) {
|
|
72794
|
+
rollback();
|
|
72795
|
+
if (e instanceof PreconditionError) return reply.status(e.status).send(e.body);
|
|
72796
|
+
const r = importRefusal(e);
|
|
72797
|
+
if (r) return reply.status(r.status).send(r.body);
|
|
72798
|
+
if (e instanceof ContractError) {
|
|
72799
|
+
return reply.status(400).send({ ok: false, error: e.message, ...e.code ? { code: e.code } : {} });
|
|
72800
|
+
}
|
|
72801
|
+
app.log.error({ appId: g.appId, id: entry2.id, versionId, rel, expectedVersionId: req.body?.expectedVersionId, err: e }, "reference version upload failed");
|
|
72802
|
+
return reply.status(500).send({ ok: false, error: `could not load a new version of "${entry2.name}"` });
|
|
72803
|
+
} finally {
|
|
72804
|
+
if (preview2) closeProgressSession(preview2.id, "done");
|
|
72805
|
+
scope.finish();
|
|
72806
|
+
}
|
|
72807
|
+
}
|
|
72808
|
+
);
|
|
72159
72809
|
app.delete(
|
|
72160
72810
|
"/api/steel/:appId/reference/:id",
|
|
72161
72811
|
async (req, reply) => {
|
|
@@ -72170,6 +72820,7 @@ function registerReferenceRoutes(app, deps) {
|
|
|
72170
72820
|
error: `"${entry2.name}" is locked \u2014 unlock it in the Reference models panel to remove it`
|
|
72171
72821
|
});
|
|
72172
72822
|
}
|
|
72823
|
+
let stillReferenced = [];
|
|
72173
72824
|
try {
|
|
72174
72825
|
const etag = await withLifecycleLock("project", g.project, async () => {
|
|
72175
72826
|
const current = readAcceptedForRequest(g.appId, g.project);
|
|
@@ -72177,6 +72828,7 @@ function registerReferenceRoutes(app, deps) {
|
|
|
72177
72828
|
const now = referencesOf(current).find((r) => r.id === entry2.id);
|
|
72178
72829
|
if (now?.display?.locked) throw new ReferenceLockedError(now.name || entry2.name);
|
|
72179
72830
|
const kept = referencesOf(current).filter((r) => r.id !== entry2.id);
|
|
72831
|
+
stillReferenced = kept;
|
|
72180
72832
|
const next = { ...current, reference_models: kept };
|
|
72181
72833
|
const written = await writeContractChecked(g.appId, next, g.project, {
|
|
72182
72834
|
origin: "internal",
|
|
@@ -72184,13 +72836,33 @@ function registerReferenceRoutes(app, deps) {
|
|
|
72184
72836
|
});
|
|
72185
72837
|
return written.etag;
|
|
72186
72838
|
});
|
|
72839
|
+
const owned = /* @__PURE__ */ new Set([...(entry2.versions ?? []).map((v) => v.file), ...entry2.file ? [entry2.file] : []]);
|
|
72840
|
+
const stillUsed = /* @__PURE__ */ new Set();
|
|
72841
|
+
for (const other of stillReferenced) {
|
|
72842
|
+
if (other.file) stillUsed.add(other.file);
|
|
72843
|
+
for (const v of other.versions ?? []) stillUsed.add(v.file);
|
|
72844
|
+
}
|
|
72187
72845
|
try {
|
|
72188
|
-
|
|
72846
|
+
dropCache(g.project, entry2.id);
|
|
72189
72847
|
} catch (e) {
|
|
72190
|
-
app.log.error(
|
|
72191
|
-
|
|
72192
|
-
|
|
72193
|
-
)
|
|
72848
|
+
app.log.error({ project: g.project, id: entry2.id, err: e }, "a removed reference left its geometry cache behind");
|
|
72849
|
+
}
|
|
72850
|
+
for (const file of owned) {
|
|
72851
|
+
if (stillUsed.has(file)) {
|
|
72852
|
+
app.log.warn(
|
|
72853
|
+
{ project: g.project, id: entry2.id, file },
|
|
72854
|
+
"a removed reference shared a file with another reference \u2014 the file is kept, so the survivor still resolves"
|
|
72855
|
+
);
|
|
72856
|
+
continue;
|
|
72857
|
+
}
|
|
72858
|
+
try {
|
|
72859
|
+
removeReferenceFile(g.project, file);
|
|
72860
|
+
} catch (e) {
|
|
72861
|
+
app.log.error(
|
|
72862
|
+
{ project: g.project, id: entry2.id, file, err: e instanceof Error ? e.message : e },
|
|
72863
|
+
"a removed reference kept one of its originals \u2014 an orphan is left on disk"
|
|
72864
|
+
);
|
|
72865
|
+
}
|
|
72194
72866
|
}
|
|
72195
72867
|
deps.broadcast(contractChangedEvent(g.appId, g.project, etag, req.headers["x-floless-mutation-id"]));
|
|
72196
72868
|
return { ok: true, etag };
|
|
@@ -72214,7 +72886,7 @@ var import_node_os25 = require("node:os");
|
|
|
72214
72886
|
var import_node_path41 = require("node:path");
|
|
72215
72887
|
|
|
72216
72888
|
// node_modules/write-excel-file/modules/export/writeXlsxFileNode.js
|
|
72217
|
-
var
|
|
72889
|
+
var import_node_fs45 = __toESM(require("node:fs"), 1);
|
|
72218
72890
|
|
|
72219
72891
|
// node_modules/write-excel-file/modules/xlsx/helpers/features/getAdditionalContent.js
|
|
72220
72892
|
function _createForOfIteratorHelperLoose(r, e) {
|
|
@@ -73340,13 +74012,13 @@ function getBorderXml(_ref) {
|
|
|
73340
74012
|
xml += "</border>";
|
|
73341
74013
|
return xml;
|
|
73342
74014
|
}
|
|
73343
|
-
function getSideBorderXml(
|
|
74015
|
+
function getSideBorderXml(side2, _ref2) {
|
|
73344
74016
|
var style = _ref2.style, color = _ref2.color;
|
|
73345
74017
|
if (color && !style) {
|
|
73346
74018
|
style = "thin";
|
|
73347
74019
|
}
|
|
73348
74020
|
var hasChildren = Boolean(color);
|
|
73349
|
-
return "<".concat(
|
|
74021
|
+
return "<".concat(side2) + (style ? ' style="'.concat(sanitizeAttributeValue(style), '"') : "") + (hasChildren ? ">" : "/>") + (color ? '<color rgb="'.concat(sanitizeAttributeValue(getXlsxColorForHexColor(color)), '"/>') : "") + (hasChildren ? "</".concat(side2, ">") : "");
|
|
73350
74022
|
}
|
|
73351
74023
|
|
|
73352
74024
|
// node_modules/write-excel-file/modules/xlsx/helpers/getFontXml.js
|
|
@@ -75008,7 +75680,7 @@ function generateXlsxFileContents(arg1, arg2, arg3) {
|
|
|
75008
75680
|
sheetsOptions = setConditionalFormattingRulesGlobalIndexes(sheetsOptions);
|
|
75009
75681
|
var features = getFeatures(options.features);
|
|
75010
75682
|
var files2 = {};
|
|
75011
|
-
var
|
|
75683
|
+
var readFile6 = function readFile7(path) {
|
|
75012
75684
|
return files2[path];
|
|
75013
75685
|
};
|
|
75014
75686
|
var writeFiles = function writeFiles2(filesToWrite) {
|
|
@@ -75075,7 +75747,7 @@ function generateXlsxFileContents(arg1, arg2, arg3) {
|
|
|
75075
75747
|
sheetIndex++;
|
|
75076
75748
|
}
|
|
75077
75749
|
writeFiles(getWrittenFiles(features, sheetsOptions, {
|
|
75078
|
-
read:
|
|
75750
|
+
read: readFile6
|
|
75079
75751
|
}));
|
|
75080
75752
|
files2["xl/styles.xml"] = generateStylesXml(getCellStyles(), sheetsOptions, features);
|
|
75081
75753
|
files2["xl/sharedStrings.xml"] = generateSharedStringsXml(getSharedStrings());
|
|
@@ -75314,7 +75986,7 @@ function writeXlsxFile(arg1, arg2, arg3) {
|
|
|
75314
75986
|
},
|
|
75315
75987
|
toFile: function toFile(filePath) {
|
|
75316
75988
|
return createReadableStream().then(function(readableStream) {
|
|
75317
|
-
return pipe(readableStream,
|
|
75989
|
+
return pipe(readableStream, import_node_fs45.default.createWriteStream(filePath));
|
|
75318
75990
|
});
|
|
75319
75991
|
}
|
|
75320
75992
|
};
|
|
@@ -75950,7 +76622,7 @@ function workspaceContractLifecycle(contract, hasHistory = false) {
|
|
|
75950
76622
|
}
|
|
75951
76623
|
|
|
75952
76624
|
// project-export-files.ts
|
|
75953
|
-
var
|
|
76625
|
+
var import_node_fs46 = require("node:fs");
|
|
75954
76626
|
var import_node_path42 = require("node:path");
|
|
75955
76627
|
function projectExportFiles(appId, kindOf2 = appId) {
|
|
75956
76628
|
if (kindOf2 === "vectorize") {
|
|
@@ -75980,12 +76652,12 @@ function exportFileBase(projectId, appId, now = /* @__PURE__ */ new Date()) {
|
|
|
75980
76652
|
}
|
|
75981
76653
|
function uniqueProjectExportFilename(projectId, preferred) {
|
|
75982
76654
|
const dir = projectExportsDir(projectId);
|
|
75983
|
-
if (!(0,
|
|
76655
|
+
if (!(0, import_node_fs46.existsSync)((0, import_node_path42.join)(dir, preferred))) return preferred;
|
|
75984
76656
|
const extension = (0, import_node_path42.extname)(preferred);
|
|
75985
76657
|
const stem = preferred.slice(0, preferred.length - extension.length);
|
|
75986
76658
|
for (let suffix = 2; suffix <= 9999; suffix += 1) {
|
|
75987
76659
|
const candidate = `${stem}-${suffix}${extension}`;
|
|
75988
|
-
if (!(0,
|
|
76660
|
+
if (!(0, import_node_fs46.existsSync)((0, import_node_path42.join)(dir, candidate))) return candidate;
|
|
75989
76661
|
}
|
|
75990
76662
|
throw new Error("could not allocate a unique project export filename");
|
|
75991
76663
|
}
|
|
@@ -76186,8 +76858,8 @@ var arr4 = (v) => Array.isArray(v) ? v : [];
|
|
|
76186
76858
|
var eq = (a, b) => canonicalJson(a) === canonicalJson(b);
|
|
76187
76859
|
var own = (o, k) => Object.prototype.hasOwnProperty.call(o, k);
|
|
76188
76860
|
function displayValue(value) {
|
|
76189
|
-
const
|
|
76190
|
-
return
|
|
76861
|
+
const text5 = canonicalJson(value);
|
|
76862
|
+
return text5.length <= 240 ? value : { summary: `Large value (${text5.length} characters)`, sha256: hashOf(value) };
|
|
76191
76863
|
}
|
|
76192
76864
|
function groupOf(opts) {
|
|
76193
76865
|
const keys = changedKeys(opts.before, opts.after);
|
|
@@ -76608,10 +77280,10 @@ function freezeApprovalReviewId(review) {
|
|
|
76608
77280
|
moveForward: review.moveForward ?? null
|
|
76609
77281
|
});
|
|
76610
77282
|
}
|
|
76611
|
-
function summary(
|
|
76612
|
-
if (
|
|
77283
|
+
function summary(count2, selective) {
|
|
77284
|
+
if (count2 === 0) return "No changes need approval.";
|
|
76613
77285
|
if (!selective) return "Review the model as one complete change.";
|
|
76614
|
-
return `${
|
|
77286
|
+
return `${count2} ${count2 === 1 ? "change needs" : "changes need"} review.`;
|
|
76615
77287
|
}
|
|
76616
77288
|
function buildApprovalReview(input) {
|
|
76617
77289
|
let partition = partitionContract(input.baseContract, input.draft);
|
|
@@ -76666,7 +77338,7 @@ function buildApprovalReview(input) {
|
|
|
76666
77338
|
|
|
76667
77339
|
// working-revision-manifest.ts
|
|
76668
77340
|
var import_node_crypto30 = require("node:crypto");
|
|
76669
|
-
var
|
|
77341
|
+
var import_node_fs47 = require("node:fs");
|
|
76670
77342
|
var import_node_path43 = require("node:path");
|
|
76671
77343
|
var pathOf = (projectId) => (0, import_node_path43.join)(projectDir(projectId), ".floless-working-revision-state-v1.json");
|
|
76672
77344
|
var checksumOf = (body) => hashOf(body);
|
|
@@ -76681,7 +77353,7 @@ function assertProject(project) {
|
|
|
76681
77353
|
function readWorkingRevisionManifest(project) {
|
|
76682
77354
|
const uuid = assertProject(project);
|
|
76683
77355
|
try {
|
|
76684
|
-
const value = JSON.parse((0,
|
|
77356
|
+
const value = JSON.parse((0, import_node_fs47.readFileSync)(pathOf(project.id), "utf8"));
|
|
76685
77357
|
if (value?.schema !== 1 || value.projectUuid !== uuid || !Number.isInteger(value.epoch) || value.epoch < 0) return null;
|
|
76686
77358
|
return checksumOf(bodyOf(value)) === value.checksum ? value : null;
|
|
76687
77359
|
} catch {
|
|
@@ -76703,8 +77375,8 @@ function ensureWorkingRevisionManifest(input) {
|
|
|
76703
77375
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
76704
77376
|
};
|
|
76705
77377
|
const value = { ...body, checksum: checksumOf(body) };
|
|
76706
|
-
(0,
|
|
76707
|
-
if (!(0,
|
|
77378
|
+
(0, import_node_fs47.mkdirSync)(projectDir(input.project.id), { recursive: true });
|
|
77379
|
+
if (!(0, import_node_fs47.existsSync)(pathOf(input.project.id))) writeJsonAtomic(pathOf(input.project.id), value);
|
|
76708
77380
|
return readWorkingRevisionManifest(input.project) ?? value;
|
|
76709
77381
|
}
|
|
76710
77382
|
function advanceWorkingRevisionManifest(input) {
|
|
@@ -76950,8 +77622,8 @@ function applyApprovalDiscard(review, partition, changes, validateCandidate) {
|
|
|
76950
77622
|
const chosen = new Set(discardedIds);
|
|
76951
77623
|
for (const group of review.groups) {
|
|
76952
77624
|
const component = review.groups.filter((candidate) => candidate.dependencyGroup === group.dependencyGroup);
|
|
76953
|
-
const
|
|
76954
|
-
if (
|
|
77625
|
+
const count2 = component.filter((candidate) => chosen.has(candidate.id)).length;
|
|
77626
|
+
if (count2 && count2 !== component.length) {
|
|
76955
77627
|
throw new ApprovalSelectionError("invalid-dependency", `discard all dependent changes together: ${component.map((candidate) => candidate.id).join(", ")}`);
|
|
76956
77628
|
}
|
|
76957
77629
|
}
|
|
@@ -76975,7 +77647,7 @@ function projectApprovalCandidateAccepted(appId, projectId, candidate) {
|
|
|
76975
77647
|
|
|
76976
77648
|
// project-checkpoints-store.ts
|
|
76977
77649
|
var import_node_crypto31 = require("node:crypto");
|
|
76978
|
-
var
|
|
77650
|
+
var import_node_fs48 = require("node:fs");
|
|
76979
77651
|
var import_node_path44 = require("node:path");
|
|
76980
77652
|
var HASH_RE3 = /^[0-9a-f]{64}$/;
|
|
76981
77653
|
function root5(projectId) {
|
|
@@ -76985,7 +77657,7 @@ var objectsDir2 = (projectId) => (0, import_node_path44.join)(root5(projectId),
|
|
|
76985
77657
|
var eventsPath = (projectId) => (0, import_node_path44.join)(root5(projectId), "events.json");
|
|
76986
77658
|
function readEvents(projectId) {
|
|
76987
77659
|
try {
|
|
76988
|
-
const parsed = JSON.parse((0,
|
|
77660
|
+
const parsed = JSON.parse((0, import_node_fs48.readFileSync)(eventsPath(projectId), "utf8"));
|
|
76989
77661
|
if (parsed?.schema !== 1 || !Array.isArray(parsed.events)) return { schema: 1, events: [] };
|
|
76990
77662
|
return { schema: 1, events: parsed.events.filter(validEvent) };
|
|
76991
77663
|
} catch {
|
|
@@ -77000,7 +77672,7 @@ function validEvent(value) {
|
|
|
77000
77672
|
function readContent(projectId, id) {
|
|
77001
77673
|
if (!HASH_RE3.test(id)) return null;
|
|
77002
77674
|
try {
|
|
77003
|
-
const value = JSON.parse((0,
|
|
77675
|
+
const value = JSON.parse((0, import_node_fs48.readFileSync)((0, import_node_path44.join)(objectsDir2(projectId), `${id}.json`), "utf8"));
|
|
77004
77676
|
if (value?.schema !== 1 || value.id !== id || hashCheckpoint(value) !== id) return null;
|
|
77005
77677
|
return value;
|
|
77006
77678
|
} catch {
|
|
@@ -77016,7 +77688,7 @@ function requireIdentity(project) {
|
|
|
77016
77688
|
return project.uuid;
|
|
77017
77689
|
}
|
|
77018
77690
|
function appendEvent(projectId, event) {
|
|
77019
|
-
(0,
|
|
77691
|
+
(0, import_node_fs48.mkdirSync)(root5(projectId), { recursive: true });
|
|
77020
77692
|
const log2 = readEvents(projectId);
|
|
77021
77693
|
const row = { ...event, eventId: (0, import_node_crypto31.randomUUID)(), at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
77022
77694
|
log2.events.push(row);
|
|
@@ -77034,9 +77706,9 @@ function captureProjectCheckpoint(input) {
|
|
|
77034
77706
|
contract: input.contract
|
|
77035
77707
|
};
|
|
77036
77708
|
const id = hashCheckpoint(withoutId);
|
|
77037
|
-
(0,
|
|
77709
|
+
(0, import_node_fs48.mkdirSync)(objectsDir2(input.project.id), { recursive: true });
|
|
77038
77710
|
const path = (0, import_node_path44.join)(objectsDir2(input.project.id), `${id}.json`);
|
|
77039
|
-
if (!(0,
|
|
77711
|
+
if (!(0, import_node_fs48.existsSync)(path)) writeJsonAtomic(path, { ...withoutId, id });
|
|
77040
77712
|
const event = appendEvent(input.project.id, {
|
|
77041
77713
|
checkpointId: id,
|
|
77042
77714
|
kind: "captured",
|
|
@@ -77079,7 +77751,7 @@ function markProjectCheckpoint(project, checkpointId, kind, expectedEventId) {
|
|
|
77079
77751
|
|
|
77080
77752
|
// export-source.ts
|
|
77081
77753
|
var import_node_crypto32 = require("node:crypto");
|
|
77082
|
-
var
|
|
77754
|
+
var import_node_fs49 = require("node:fs");
|
|
77083
77755
|
var import_node_os26 = require("node:os");
|
|
77084
77756
|
var import_node_path45 = require("node:path");
|
|
77085
77757
|
var HANDLE_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
@@ -77102,7 +77774,7 @@ function validId(id) {
|
|
|
77102
77774
|
function readExportHandle(handleId) {
|
|
77103
77775
|
if (!validId(handleId)) return null;
|
|
77104
77776
|
try {
|
|
77105
|
-
const value = JSON.parse((0,
|
|
77777
|
+
const value = JSON.parse((0, import_node_fs49.readFileSync)(handlePath(handleId), "utf8"));
|
|
77106
77778
|
if (value?.schema !== 1 || value.handleId !== handleId || value.checksum !== hashOf(withoutChecksum(value))) return null;
|
|
77107
77779
|
return value;
|
|
77108
77780
|
} catch {
|
|
@@ -77111,7 +77783,7 @@ function readExportHandle(handleId) {
|
|
|
77111
77783
|
}
|
|
77112
77784
|
function captureExportSource(projectId, selector = { kind: "latest-approved" }, isDerivedEligible) {
|
|
77113
77785
|
collectExpiredExportHandles();
|
|
77114
|
-
if ((0,
|
|
77786
|
+
if ((0, import_node_fs49.existsSync)(storeRoot()) && (0, import_node_fs49.readdirSync)(storeRoot()).filter((name) => name.endsWith(".json")).length >= MAX_STORED_HANDLES) {
|
|
77115
77787
|
throw new Error("too many frozen export sources are waiting; finish or retry older exports first");
|
|
77116
77788
|
}
|
|
77117
77789
|
const project = getProject(projectId);
|
|
@@ -77189,7 +77861,7 @@ function captureExportSource(projectId, selector = { kind: "latest-approved" },
|
|
|
77189
77861
|
expiresAt: new Date(Date.now() + HANDLE_TTL_MS).toISOString(),
|
|
77190
77862
|
resultRefs: []
|
|
77191
77863
|
};
|
|
77192
|
-
(0,
|
|
77864
|
+
(0, import_node_fs49.mkdirSync)(storeRoot(), { recursive: true });
|
|
77193
77865
|
writeJsonAtomic(handlePath(handleId), stored(body));
|
|
77194
77866
|
const { contract: _contract, lease: _lease, expiresAt: _expiresAt, resultRefs: _refs, checksum: _checksum, ...resolved } = readExportHandle(handleId);
|
|
77195
77867
|
return resolved;
|
|
@@ -77201,7 +77873,7 @@ function cloneExportHandle(handleId, copies) {
|
|
|
77201
77873
|
if (!original || original.lease !== "active" || Date.parse(original.expiresAt) <= Date.now()) {
|
|
77202
77874
|
throw new Error("export source handle is unavailable");
|
|
77203
77875
|
}
|
|
77204
|
-
const storedCount = (0,
|
|
77876
|
+
const storedCount = (0, import_node_fs49.existsSync)(storeRoot()) ? (0, import_node_fs49.readdirSync)(storeRoot()).filter((name) => name.endsWith(".json")).length : 0;
|
|
77205
77877
|
if (storedCount + copies - 1 > MAX_STORED_HANDLES) throw new Error("too many frozen export sources are waiting");
|
|
77206
77878
|
const results = [];
|
|
77207
77879
|
const created = [];
|
|
@@ -77216,7 +77888,7 @@ function cloneExportHandle(handleId, copies) {
|
|
|
77216
77888
|
results.push(resolved);
|
|
77217
77889
|
}
|
|
77218
77890
|
} catch (error) {
|
|
77219
|
-
for (const id of created) (0,
|
|
77891
|
+
for (const id of created) (0, import_node_fs49.rmSync)(handlePath(id), { force: true });
|
|
77220
77892
|
throw error;
|
|
77221
77893
|
}
|
|
77222
77894
|
return results;
|
|
@@ -77256,21 +77928,21 @@ function releaseUnusedExportHandle(handleId, projectId, projectUuid) {
|
|
|
77256
77928
|
}
|
|
77257
77929
|
function projectIdHasActiveExportLeases(projectId) {
|
|
77258
77930
|
collectExpiredExportHandles();
|
|
77259
|
-
if (!(0,
|
|
77260
|
-
return (0,
|
|
77931
|
+
if (!(0, import_node_fs49.existsSync)(storeRoot())) return false;
|
|
77932
|
+
return (0, import_node_fs49.readdirSync)(storeRoot()).some((name) => {
|
|
77261
77933
|
const handle = name.endsWith(".json") ? readExportHandle(name.slice(0, -5)) : null;
|
|
77262
77934
|
return handle?.projectId === projectId && handle.lease === "active" && Date.parse(handle.expiresAt) > Date.now();
|
|
77263
77935
|
});
|
|
77264
77936
|
}
|
|
77265
77937
|
function collectExpiredExportHandles(now = Date.now()) {
|
|
77266
|
-
if (!(0,
|
|
77938
|
+
if (!(0, import_node_fs49.existsSync)(storeRoot())) return 0;
|
|
77267
77939
|
let removed = 0;
|
|
77268
|
-
for (const name of (0,
|
|
77940
|
+
for (const name of (0, import_node_fs49.readdirSync)(storeRoot())) {
|
|
77269
77941
|
if (!name.endsWith(".json")) continue;
|
|
77270
77942
|
const id = name.slice(0, -5);
|
|
77271
77943
|
const handle = readExportHandle(id);
|
|
77272
77944
|
if (!handle || Date.parse(handle.expiresAt) <= now && handle.resultRefs.length === 0) {
|
|
77273
|
-
(0,
|
|
77945
|
+
(0, import_node_fs49.rmSync)(handlePath(id), { force: true });
|
|
77274
77946
|
removed++;
|
|
77275
77947
|
}
|
|
77276
77948
|
}
|
|
@@ -77279,7 +77951,7 @@ function collectExpiredExportHandles(now = Date.now()) {
|
|
|
77279
77951
|
|
|
77280
77952
|
// file-publication.ts
|
|
77281
77953
|
var import_node_crypto33 = require("node:crypto");
|
|
77282
|
-
var
|
|
77954
|
+
var import_node_fs50 = require("node:fs");
|
|
77283
77955
|
var import_node_path46 = require("node:path");
|
|
77284
77956
|
var FilePublicationError = class extends Error {
|
|
77285
77957
|
constructor(message, code, paths = []) {
|
|
@@ -77297,7 +77969,7 @@ var proofOfBytes = (bytes) => ({
|
|
|
77297
77969
|
});
|
|
77298
77970
|
function readFileProof2(path) {
|
|
77299
77971
|
try {
|
|
77300
|
-
return proofOfBytes((0,
|
|
77972
|
+
return proofOfBytes((0, import_node_fs50.readFileSync)(path));
|
|
77301
77973
|
} catch (error) {
|
|
77302
77974
|
if (error.code === "ENOENT") return null;
|
|
77303
77975
|
throw error;
|
|
@@ -77308,18 +77980,18 @@ function fileProofEquals2(a, b) {
|
|
|
77308
77980
|
}
|
|
77309
77981
|
function durableCanonicalJson(path, value) {
|
|
77310
77982
|
const dir = (0, import_node_path46.dirname)(path);
|
|
77311
|
-
(0,
|
|
77983
|
+
(0, import_node_fs50.mkdirSync)(dir, { recursive: true });
|
|
77312
77984
|
const temp = (0, import_node_path46.join)(dir, `.${(0, import_node_path46.basename)(path)}.${process.pid}.${(0, import_node_crypto33.randomUUID)()}.tmp`);
|
|
77313
77985
|
try {
|
|
77314
|
-
(0,
|
|
77986
|
+
(0, import_node_fs50.writeFileSync)(temp, `${canonicalJson(value)}
|
|
77315
77987
|
`, { encoding: "utf8", flag: "wx" });
|
|
77316
77988
|
syncFile(temp);
|
|
77317
|
-
(0,
|
|
77989
|
+
(0, import_node_fs50.renameSync)(temp, path);
|
|
77318
77990
|
syncFile(path);
|
|
77319
77991
|
syncDirectoryBestEffort(dir);
|
|
77320
77992
|
} finally {
|
|
77321
77993
|
try {
|
|
77322
|
-
(0,
|
|
77994
|
+
(0, import_node_fs50.rmSync)(temp, { force: true });
|
|
77323
77995
|
} catch {
|
|
77324
77996
|
}
|
|
77325
77997
|
}
|
|
@@ -77338,7 +78010,7 @@ function mappedError(error, paths) {
|
|
|
77338
78010
|
}
|
|
77339
78011
|
function linkExclusive(source, destination) {
|
|
77340
78012
|
try {
|
|
77341
|
-
(0,
|
|
78013
|
+
(0, import_node_fs50.linkSync)(source, destination);
|
|
77342
78014
|
} catch (error) {
|
|
77343
78015
|
throw mappedError(error, [source, destination]);
|
|
77344
78016
|
}
|
|
@@ -77347,27 +78019,27 @@ function assertSameVolume(a, b) {
|
|
|
77347
78019
|
let aDev;
|
|
77348
78020
|
let bDev;
|
|
77349
78021
|
try {
|
|
77350
|
-
aDev = (0,
|
|
77351
|
-
bDev = (0,
|
|
78022
|
+
aDev = (0, import_node_fs50.statSync)(a, { bigint: true }).dev;
|
|
78023
|
+
bDev = (0, import_node_fs50.statSync)(b, { bigint: true }).dev;
|
|
77352
78024
|
} catch (error) {
|
|
77353
78025
|
throw mappedError(error, [a, b]);
|
|
77354
78026
|
}
|
|
77355
78027
|
if (aDev !== bDev) throw new FilePublicationError("publication paths are not on the same volume", "different-volume", [a, b]);
|
|
77356
78028
|
}
|
|
77357
78029
|
function uniqueArtifact(dir, label2, livePath) {
|
|
77358
|
-
(0,
|
|
78030
|
+
(0, import_node_fs50.mkdirSync)(dir, { recursive: true });
|
|
77359
78031
|
return (0, import_node_path46.join)(dir, `.floless-${label2}-${(0, import_node_crypto33.randomUUID)()}-${(0, import_node_path46.basename)(livePath)}`);
|
|
77360
78032
|
}
|
|
77361
78033
|
function publishFileExclusive(input) {
|
|
77362
78034
|
const { livePath, stagedPath, expectedLive, artifactDir } = input;
|
|
77363
|
-
assertSameVolume(stagedPath, (0,
|
|
78035
|
+
assertSameVolume(stagedPath, (0, import_node_fs50.existsSync)(livePath) ? livePath : (0, import_node_path46.dirname)(livePath));
|
|
77364
78036
|
const stagedProof = readFileProof2(stagedPath);
|
|
77365
78037
|
if (!stagedProof) throw new FilePublicationError("staged publication file is missing", "io-failure", [stagedPath]);
|
|
77366
78038
|
let beforeImage = null;
|
|
77367
78039
|
if (expectedLive) {
|
|
77368
78040
|
beforeImage = uniqueArtifact(artifactDir, "before", livePath);
|
|
77369
78041
|
try {
|
|
77370
|
-
(0,
|
|
78042
|
+
(0, import_node_fs50.renameSync)(livePath, beforeImage);
|
|
77371
78043
|
} catch (error) {
|
|
77372
78044
|
throw mappedError(error, [livePath, beforeImage]);
|
|
77373
78045
|
}
|
|
@@ -77379,19 +78051,19 @@ function publishFileExclusive(input) {
|
|
|
77379
78051
|
}
|
|
77380
78052
|
throw new FilePublicationError("the live file changed before publication", "live-changed", [livePath, beforeImage]);
|
|
77381
78053
|
}
|
|
77382
|
-
} else if ((0,
|
|
78054
|
+
} else if ((0, import_node_fs50.existsSync)(livePath)) {
|
|
77383
78055
|
throw new FilePublicationError("the live destination appeared before publication", "destination-exists", [livePath]);
|
|
77384
78056
|
}
|
|
77385
78057
|
try {
|
|
77386
78058
|
input.onFaultPoint?.("after-live-move", { livePath, stagedPath, beforeImage });
|
|
77387
78059
|
linkExclusive(stagedPath, livePath);
|
|
77388
78060
|
input.onFaultPoint?.("after-live-link", { livePath, stagedPath, beforeImage });
|
|
77389
|
-
(0,
|
|
78061
|
+
(0, import_node_fs50.unlinkSync)(stagedPath);
|
|
77390
78062
|
input.onFaultPoint?.("after-staged-unlink", { livePath, stagedPath, beforeImage });
|
|
77391
78063
|
syncFile(livePath);
|
|
77392
78064
|
syncDirectoryBestEffort((0, import_node_path46.dirname)(livePath));
|
|
77393
78065
|
} catch (error) {
|
|
77394
|
-
if (beforeImage && !(0,
|
|
78066
|
+
if (beforeImage && !(0, import_node_fs50.existsSync)(livePath)) {
|
|
77395
78067
|
try {
|
|
77396
78068
|
linkExclusive(beforeImage, livePath);
|
|
77397
78069
|
} catch {
|
|
@@ -77414,7 +78086,7 @@ function publishFileExclusive(input) {
|
|
|
77414
78086
|
var import_node_path48 = require("node:path");
|
|
77415
78087
|
|
|
77416
78088
|
// app-source-lock.ts
|
|
77417
|
-
var
|
|
78089
|
+
var import_node_fs51 = require("node:fs");
|
|
77418
78090
|
var import_node_os27 = require("node:os");
|
|
77419
78091
|
var import_node_path47 = require("node:path");
|
|
77420
78092
|
var AppSourcePublicationBusyError = class extends Error {
|
|
@@ -77427,9 +78099,9 @@ var AppSourcePublicationBusyError = class extends Error {
|
|
|
77427
78099
|
function activeApprovalTransaction(appId) {
|
|
77428
78100
|
const home = process.env.AWARE_HOME || (0, import_node_path47.join)((0, import_node_os27.homedir)(), ".aware");
|
|
77429
78101
|
const path = (0, import_node_path47.join)(home, "apps", appId, ".floless-approval-publication-journal-v1.json");
|
|
77430
|
-
if (!(0,
|
|
78102
|
+
if (!(0, import_node_fs51.existsSync)(path)) return null;
|
|
77431
78103
|
try {
|
|
77432
|
-
const stored2 = JSON.parse((0,
|
|
78104
|
+
const stored2 = JSON.parse((0, import_node_fs51.readFileSync)(path, "utf8"));
|
|
77433
78105
|
return typeof stored2?.journal?.id === "string" && stored2.journal.id ? stored2.journal.id : "__invalid__";
|
|
77434
78106
|
} catch {
|
|
77435
78107
|
return "__invalid__";
|
|
@@ -77438,7 +78110,7 @@ function activeApprovalTransaction(appId) {
|
|
|
77438
78110
|
function activeCodexJournal(appId) {
|
|
77439
78111
|
const root6 = (0, import_node_path47.join)(process.env.FLOLESS_HOME ?? (0, import_node_path47.join)((0, import_node_os27.homedir)(), ".floless"), "run-journals");
|
|
77440
78112
|
for (const lease of listLeases()) {
|
|
77441
|
-
if (lease.runtime === "codex" && lease.appId === appId && (0,
|
|
78113
|
+
if (lease.runtime === "codex" && lease.appId === appId && (0, import_node_fs51.existsSync)((0, import_node_path47.join)(root6, lease.leaseId, "journal.json"))) return lease.leaseId;
|
|
77442
78114
|
}
|
|
77443
78115
|
return null;
|
|
77444
78116
|
}
|
|
@@ -77456,7 +78128,7 @@ function withAppSourceLock(appId, label2, fn, options = {}) {
|
|
|
77456
78128
|
|
|
77457
78129
|
// app-publication-manifest.ts
|
|
77458
78130
|
var import_node_crypto34 = require("node:crypto");
|
|
77459
|
-
var
|
|
78131
|
+
var import_node_fs52 = require("node:fs");
|
|
77460
78132
|
var import_yaml7 = __toESM(require_dist6(), 1);
|
|
77461
78133
|
var APP_PUBLICATION_MANIFEST_SCHEMA = 1;
|
|
77462
78134
|
var AppPublicationManifestError = class extends Error {
|
|
@@ -77473,7 +78145,7 @@ function observeAppPublication(sourcePath2, lockPath2) {
|
|
|
77473
78145
|
let lockSourceHash = null;
|
|
77474
78146
|
if (lock) {
|
|
77475
78147
|
try {
|
|
77476
|
-
const parsed = (0, import_yaml7.parse)((0,
|
|
78148
|
+
const parsed = (0, import_yaml7.parse)((0, import_node_fs52.readFileSync)(lockPath2, "utf8"));
|
|
77477
78149
|
lockSourceHash = typeof parsed?.["source-hash"] === "string" ? parsed["source-hash"] : null;
|
|
77478
78150
|
} catch {
|
|
77479
78151
|
}
|
|
@@ -77498,10 +78170,10 @@ function validManifest2(value) {
|
|
|
77498
78170
|
return m.schema === APP_PUBLICATION_MANIFEST_SCHEMA && typeof m.publicationId === "string" && !!m.publicationId && typeof m.appId === "string" && !!m.appId && Number.isSafeInteger(m.generation) && (m.generation ?? -1) >= 0 && (m.state === "ready-clean" || m.state === "ready-dirty" || m.state === "recovering") && validProof(m.source) && validProof(m.lock) && (m.lockSourceHash === null || typeof m.lockSourceHash === "string") && validTxn && typeof m.updatedAt === "string" && (m.state === "recovering" ? m.transaction !== null : m.transaction === null);
|
|
77499
78171
|
}
|
|
77500
78172
|
function readAppPublicationManifest(path) {
|
|
77501
|
-
if (!(0,
|
|
78173
|
+
if (!(0, import_node_fs52.existsSync)(path)) return null;
|
|
77502
78174
|
let stored2;
|
|
77503
78175
|
try {
|
|
77504
|
-
stored2 = JSON.parse((0,
|
|
78176
|
+
stored2 = JSON.parse((0, import_node_fs52.readFileSync)(path, "utf8"));
|
|
77505
78177
|
} catch {
|
|
77506
78178
|
throw new AppPublicationManifestError(`app publication manifest is unreadable: ${path}`, "corrupt");
|
|
77507
78179
|
}
|
|
@@ -77697,7 +78369,7 @@ function withAppPublicationWhileProjectLocked(input) {
|
|
|
77697
78369
|
|
|
77698
78370
|
// approval-app-publication.ts
|
|
77699
78371
|
var import_node_crypto35 = require("node:crypto");
|
|
77700
|
-
var
|
|
78372
|
+
var import_node_fs53 = require("node:fs");
|
|
77701
78373
|
var import_node_path49 = require("node:path");
|
|
77702
78374
|
var JOURNAL = ".floless-approval-publication-journal-v1.json";
|
|
77703
78375
|
var MANIFEST = ".floless-app-publication-state-v1.json";
|
|
@@ -77724,7 +78396,7 @@ function storeJournal(journal) {
|
|
|
77724
78396
|
}
|
|
77725
78397
|
function readApprovalPublicationJournal(sourcePath2) {
|
|
77726
78398
|
try {
|
|
77727
|
-
const stored2 = JSON.parse((0,
|
|
78399
|
+
const stored2 = JSON.parse((0, import_node_fs53.readFileSync)(approvalPublicationJournalPath(sourcePath2), "utf8"));
|
|
77728
78400
|
const value = stored2?.journal;
|
|
77729
78401
|
const expectedLiveLock = sourcePath2.replace(/\.[^.]+$/, ".lock");
|
|
77730
78402
|
const expectedStageDir = (0, import_node_path49.join)(stagingRoot2(sourcePath2), `${value?.appId ?? ""}-${value?.id ?? ""}`);
|
|
@@ -77750,8 +78422,8 @@ async function stageApprovalPublication(input) {
|
|
|
77750
78422
|
const beforeSource = readFileProof2(input.sourcePath);
|
|
77751
78423
|
const beforeLock = readFileProof2(input.liveLockPath);
|
|
77752
78424
|
try {
|
|
77753
|
-
(0,
|
|
77754
|
-
(0,
|
|
78425
|
+
(0, import_node_fs53.mkdirSync)(stageDir, { recursive: true });
|
|
78426
|
+
(0, import_node_fs53.cpSync)(appRoot, stagedAppRoot, {
|
|
77755
78427
|
recursive: true,
|
|
77756
78428
|
filter: (path) => ![JOURNAL, MANIFEST].includes((0, import_node_path49.basename)(path))
|
|
77757
78429
|
});
|
|
@@ -77764,7 +78436,7 @@ async function stageApprovalPublication(input) {
|
|
|
77764
78436
|
throw new Error("live workflow changed while the approval was being staged");
|
|
77765
78437
|
}
|
|
77766
78438
|
} catch (error) {
|
|
77767
|
-
(0,
|
|
78439
|
+
(0, import_node_fs53.rmSync)(stageDir, { recursive: true, force: true });
|
|
77768
78440
|
throw error;
|
|
77769
78441
|
}
|
|
77770
78442
|
const journal = {
|
|
@@ -77797,12 +78469,12 @@ function publishOne(livePath, stagedPath, before, staged, artifactDir) {
|
|
|
77797
78469
|
const live = readFileProof2(livePath);
|
|
77798
78470
|
if (fileProofEquals2(live, staged)) return;
|
|
77799
78471
|
if (!fileProofEquals2(live, before)) throw new Error(`live publication changed outside the approval transaction: ${livePath}`);
|
|
77800
|
-
if (!(0,
|
|
78472
|
+
if (!(0, import_node_fs53.existsSync)(stagedPath)) throw new Error(`staged publication bytes are unavailable: ${stagedPath}`);
|
|
77801
78473
|
publishFileExclusive({ livePath, stagedPath, expectedLive: before, artifactDir });
|
|
77802
78474
|
}
|
|
77803
78475
|
function completeApprovalPublication(journal) {
|
|
77804
78476
|
if (journal.phase !== "authorized" && journal.phase !== "published") throw new Error("approval publication is not authorized");
|
|
77805
|
-
(0,
|
|
78477
|
+
(0, import_node_fs53.mkdirSync)(journal.artifactDir, { recursive: true });
|
|
77806
78478
|
publishOne(journal.liveSourcePath, journal.stagedSourcePath, journal.beforeSource, journal.stagedSource, journal.artifactDir);
|
|
77807
78479
|
publishOne(journal.liveLockPath, journal.stagedLockPath, journal.beforeLock, journal.stagedLock, journal.artifactDir);
|
|
77808
78480
|
if (!fileProofEquals2(readFileProof2(journal.liveSourcePath), journal.stagedSource) || !fileProofEquals2(readFileProof2(journal.liveLockPath), journal.stagedLock)) {
|
|
@@ -77815,17 +78487,17 @@ function finalizeApprovalPublication(journal) {
|
|
|
77815
78487
|
if (!current || current.id !== journal.id || current.phase !== "published") {
|
|
77816
78488
|
throw new Error("published approval recovery authority is unavailable");
|
|
77817
78489
|
}
|
|
77818
|
-
(0,
|
|
77819
|
-
(0,
|
|
78490
|
+
(0, import_node_fs53.rmSync)(journal.stageDir, { recursive: true, force: true });
|
|
78491
|
+
(0, import_node_fs53.rmSync)(approvalPublicationJournalPath(journal.liveSourcePath), { force: true });
|
|
77820
78492
|
}
|
|
77821
78493
|
function abandonApprovalPublication(journal) {
|
|
77822
78494
|
if (journal.phase !== "staged") throw new Error("an authorized approval publication must be completed, not abandoned");
|
|
77823
|
-
(0,
|
|
77824
|
-
(0,
|
|
78495
|
+
(0, import_node_fs53.rmSync)(approvalPublicationJournalPath(journal.liveSourcePath), { force: true });
|
|
78496
|
+
(0, import_node_fs53.rmSync)(journal.stageDir, { recursive: true, force: true });
|
|
77825
78497
|
}
|
|
77826
78498
|
|
|
77827
78499
|
// workspace-data.ts
|
|
77828
|
-
var
|
|
78500
|
+
var import_node_fs54 = require("node:fs");
|
|
77829
78501
|
var VALID_INCLUDES = /* @__PURE__ */ new Set(["contract", "exports"]);
|
|
77830
78502
|
var VALID_EXPORT_KINDS = /* @__PURE__ */ new Set([
|
|
77831
78503
|
"bom-csv",
|
|
@@ -77883,15 +78555,15 @@ function exportBody(projectId, receipt, opts) {
|
|
|
77883
78555
|
};
|
|
77884
78556
|
if (opts.includePaths) body.path = path;
|
|
77885
78557
|
if (opts.exportContents) {
|
|
77886
|
-
const st = (0,
|
|
78558
|
+
const st = (0, import_node_fs54.statSync)(path);
|
|
77887
78559
|
if (st.size > opts.maxBytes) {
|
|
77888
78560
|
body.contentOmitted = true;
|
|
77889
78561
|
body.omittedReason = `export is ${st.size} bytes, over max-bytes ${opts.maxBytes}`;
|
|
77890
78562
|
} else if (receipt.encoding === "base64") {
|
|
77891
|
-
body.content = (0,
|
|
78563
|
+
body.content = (0, import_node_fs54.readFileSync)(path).toString("base64");
|
|
77892
78564
|
} else {
|
|
77893
78565
|
body.encoding = receipt.encoding ?? "utf8";
|
|
77894
|
-
body.content = (0,
|
|
78566
|
+
body.content = (0, import_node_fs54.readFileSync)(path, "utf8");
|
|
77895
78567
|
}
|
|
77896
78568
|
}
|
|
77897
78569
|
return body;
|
|
@@ -78029,7 +78701,7 @@ function registerWorkspaceDataRoutes(app) {
|
|
|
78029
78701
|
const generation = readCurrentGeneration(project.id);
|
|
78030
78702
|
if (!generation) return { ok: true, generation: null, pages: [], total: 0, truncated: false };
|
|
78031
78703
|
const wikiDir = generationWikiDir(project.id, generation.generationId);
|
|
78032
|
-
if (!(0,
|
|
78704
|
+
if (!(0, import_node_fs54.existsSync)(wikiDir)) return { ok: true, generation: null, pages: [], total: 0, truncated: false };
|
|
78033
78705
|
try {
|
|
78034
78706
|
const feed = readKnowledgeSummaries(wikiDir, { q, limit: limit ?? void 0 });
|
|
78035
78707
|
return { ok: true, generation, ...feed };
|
|
@@ -78102,7 +78774,7 @@ function readProjectPublicationState(appId, readLiveProjects, reportError) {
|
|
|
78102
78774
|
}
|
|
78103
78775
|
|
|
78104
78776
|
// workspace-agent-manifest.ts
|
|
78105
|
-
var
|
|
78777
|
+
var import_node_fs55 = require("node:fs");
|
|
78106
78778
|
var import_node_os28 = require("node:os");
|
|
78107
78779
|
var import_node_path50 = require("node:path");
|
|
78108
78780
|
var WORKSPACE_MANIFEST_VERSION = "0.2.1";
|
|
@@ -78118,7 +78790,7 @@ function ownerPath2(dir) {
|
|
|
78118
78790
|
}
|
|
78119
78791
|
function readOwner2(path) {
|
|
78120
78792
|
try {
|
|
78121
|
-
const parsed = JSON.parse((0,
|
|
78793
|
+
const parsed = JSON.parse((0, import_node_fs55.readFileSync)(path, "utf8"));
|
|
78122
78794
|
if (Number.isSafeInteger(parsed.pid) && parsed.pid > 0 && Number.isSafeInteger(parsed.port) && parsed.port > 0 && parsed.port <= 65535 && typeof parsed.manifestVersion === "string" && parsed.manifestVersion.length > 0) return {
|
|
78123
78795
|
pid: parsed.pid,
|
|
78124
78796
|
port: parsed.port,
|
|
@@ -78138,7 +78810,7 @@ function processIsAlive(pid) {
|
|
|
78138
78810
|
}
|
|
78139
78811
|
function syncWorkspaceAgentManifest(port, deps = {}) {
|
|
78140
78812
|
const dir = workspaceAgentDir();
|
|
78141
|
-
(0,
|
|
78813
|
+
(0, import_node_fs55.mkdirSync)(dir, { recursive: true });
|
|
78142
78814
|
const ownPath = ownerPath2(dir);
|
|
78143
78815
|
const pid = deps.pid ?? process.pid;
|
|
78144
78816
|
const isAlive = deps.isProcessAlive ?? processIsAlive;
|
|
@@ -78154,15 +78826,15 @@ function syncWorkspaceAgentManifest(port, deps = {}) {
|
|
|
78154
78826
|
break;
|
|
78155
78827
|
}
|
|
78156
78828
|
previousOwner = current;
|
|
78157
|
-
if ((0,
|
|
78829
|
+
if ((0, import_node_fs55.existsSync)(ownPath)) {
|
|
78158
78830
|
try {
|
|
78159
|
-
(0,
|
|
78831
|
+
(0, import_node_fs55.unlinkSync)(ownPath);
|
|
78160
78832
|
} catch {
|
|
78161
78833
|
continue;
|
|
78162
78834
|
}
|
|
78163
78835
|
}
|
|
78164
78836
|
try {
|
|
78165
|
-
(0,
|
|
78837
|
+
(0, import_node_fs55.writeFileSync)(ownPath, `${JSON.stringify(mine)}
|
|
78166
78838
|
`, { encoding: "utf8", flag: "wx" });
|
|
78167
78839
|
break;
|
|
78168
78840
|
} catch (err2) {
|
|
@@ -78321,12 +78993,12 @@ commands:
|
|
|
78321
78993
|
`;
|
|
78322
78994
|
const path = (0, import_node_path50.join)(dir, "manifest.yaml");
|
|
78323
78995
|
try {
|
|
78324
|
-
(0,
|
|
78996
|
+
(0, import_node_fs55.writeFileSync)(path, manifest, "utf8");
|
|
78325
78997
|
} catch (err2) {
|
|
78326
78998
|
const current = readOwner2(ownPath);
|
|
78327
78999
|
if (current?.pid === mine.pid && current.port === mine.port) {
|
|
78328
79000
|
try {
|
|
78329
|
-
(0,
|
|
79001
|
+
(0, import_node_fs55.unlinkSync)(ownPath);
|
|
78330
79002
|
} catch {
|
|
78331
79003
|
}
|
|
78332
79004
|
}
|
|
@@ -78542,16 +79214,16 @@ function diffContracts(from, to, ctx) {
|
|
|
78542
79214
|
}
|
|
78543
79215
|
|
|
78544
79216
|
// version-diff.ts
|
|
78545
|
-
var
|
|
79217
|
+
var isRecord3 = (value) => !!value && typeof value === "object" && !Array.isArray(value);
|
|
78546
79218
|
function loadDiffDocument(id, n, skeleton) {
|
|
78547
|
-
if (!
|
|
79219
|
+
if (!isRecord3(skeleton)) return { kind: "unsupported", reason: "not-record" };
|
|
78548
79220
|
if (!isModelV2(skeleton)) return { kind: "unsupported", reason: "unsupported-type" };
|
|
78549
79221
|
const doc = readVersion(id, n);
|
|
78550
79222
|
if (doc == null) return { kind: "unreadable", reason: "missing-v2-blob" };
|
|
78551
79223
|
return readModel(doc) ? { kind: "eligible", doc } : { kind: "unsupported", reason: "invalid-v2" };
|
|
78552
79224
|
}
|
|
78553
79225
|
async function loadDiffDocumentAsync(id, n, skeleton) {
|
|
78554
|
-
if (!
|
|
79226
|
+
if (!isRecord3(skeleton)) return { kind: "unsupported", reason: "not-record" };
|
|
78555
79227
|
if (!isModelV2(skeleton)) return { kind: "unsupported", reason: "unsupported-type" };
|
|
78556
79228
|
const doc = await readVersionAsync(id, n);
|
|
78557
79229
|
if (doc == null) return { kind: "unreadable", reason: "missing-v2-blob" };
|
|
@@ -78636,20 +79308,20 @@ var cautionsForWarnings = (warnings) => {
|
|
|
78636
79308
|
}
|
|
78637
79309
|
return cautions;
|
|
78638
79310
|
};
|
|
78639
|
-
var unavailableSummary = (from,
|
|
79311
|
+
var unavailableSummary = (from, side2) => ({
|
|
78640
79312
|
from,
|
|
78641
79313
|
headline: "Comparison unavailable",
|
|
78642
79314
|
detailCount: 0,
|
|
78643
|
-
bullets: [
|
|
79315
|
+
bullets: [side2 === "from" ? "The earlier version could not be compared because its saved model is not readable." : side2 === "to" ? "This version could not be compared because its saved model is not readable." : "Neither version could be compared because their saved models are not readable."],
|
|
78644
79316
|
cautions: []
|
|
78645
79317
|
});
|
|
78646
79318
|
function summarizeContractDiff(diff) {
|
|
78647
79319
|
const bullets = [];
|
|
78648
79320
|
let detailCount = 0;
|
|
78649
|
-
const add = (
|
|
78650
|
-
if (!
|
|
78651
|
-
detailCount +=
|
|
78652
|
-
bullets.push(
|
|
79321
|
+
const add = (count2, text5) => {
|
|
79322
|
+
if (!count2) return;
|
|
79323
|
+
detailCount += count2;
|
|
79324
|
+
bullets.push(text5);
|
|
78653
79325
|
};
|
|
78654
79326
|
add(diff.added.length, `Added ${countWord(diff.added.length, "member")}: ${preview(diff.added.map(refName))}.`);
|
|
78655
79327
|
add(diff.removed.length, `Removed ${countWord(diff.removed.length, "member")}: ${preview(diff.removed.map(refName))}.`);
|
|
@@ -78844,7 +79516,7 @@ function computeVersionDiff(id, n, base) {
|
|
|
78844
79516
|
}
|
|
78845
79517
|
|
|
78846
79518
|
// contract-bake.ts
|
|
78847
|
-
var
|
|
79519
|
+
var import_node_fs56 = require("node:fs");
|
|
78848
79520
|
var import_yaml8 = __toESM(require_dist6(), 1);
|
|
78849
79521
|
|
|
78850
79522
|
// confidential-images.ts
|
|
@@ -78888,7 +79560,7 @@ function bakedV2(contract) {
|
|
|
78888
79560
|
return stripConfidentialImages(baked);
|
|
78889
79561
|
}
|
|
78890
79562
|
function bakeContractIntoApp(sourcePath2, contract) {
|
|
78891
|
-
const doc = (0, import_yaml8.parseDocument)((0,
|
|
79563
|
+
const doc = (0, import_yaml8.parseDocument)((0, import_node_fs56.readFileSync)(sourcePath2, "utf8"));
|
|
78892
79564
|
if (doc.errors.length > 0) {
|
|
78893
79565
|
throw new Error(`contract bake: source is not valid YAML: ${doc.errors[0]?.message ?? "parse error"}`);
|
|
78894
79566
|
}
|
|
@@ -78912,7 +79584,7 @@ function bakeContractIntoApp(sourcePath2, contract) {
|
|
|
78912
79584
|
throw new InvalidModelV2Error(`refusing to bake: contract declares steel.model/v2 but is not valid v2: ${issues[0] ?? "unknown"}`, issues);
|
|
78913
79585
|
}
|
|
78914
79586
|
doc.setIn(["nodes", idx, "config", "takeoff"], bakedV2(contract));
|
|
78915
|
-
(0,
|
|
79587
|
+
(0, import_node_fs56.writeFileSync)(sourcePath2, doc.toString());
|
|
78916
79588
|
return;
|
|
78917
79589
|
}
|
|
78918
79590
|
const baked = { ...contract };
|
|
@@ -78957,7 +79629,7 @@ function bakeContractIntoApp(sourcePath2, contract) {
|
|
|
78957
79629
|
);
|
|
78958
79630
|
}
|
|
78959
79631
|
doc.setIn(["nodes", idx, "config", "takeoff"], baked);
|
|
78960
|
-
(0,
|
|
79632
|
+
(0, import_node_fs56.writeFileSync)(sourcePath2, doc.toString());
|
|
78961
79633
|
}
|
|
78962
79634
|
|
|
78963
79635
|
// vectorize.ts
|
|
@@ -79053,7 +79725,7 @@ function deriveLayers(elements, existing) {
|
|
|
79053
79725
|
if (!el.layer) continue;
|
|
79054
79726
|
counts.set(el.layer, (counts.get(el.layer) ?? 0) + 1);
|
|
79055
79727
|
}
|
|
79056
|
-
return [...counts.entries()].map(([name,
|
|
79728
|
+
return [...counts.entries()].map(([name, count2]) => onByName.has(name) ? { name, count: count2, on: onByName.get(name) } : { name, count: count2 }).sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
|
|
79057
79729
|
}
|
|
79058
79730
|
function pickSheet(contract, sheetId) {
|
|
79059
79731
|
const sheets = contract.sheets ?? [];
|
|
@@ -79387,11 +80059,11 @@ function agentUpdateFailureMessage(e, id) {
|
|
|
79387
80059
|
}
|
|
79388
80060
|
|
|
79389
80061
|
// scene-bake.ts
|
|
79390
|
-
var
|
|
80062
|
+
var import_node_fs57 = require("node:fs");
|
|
79391
80063
|
var import_node_path51 = require("node:path");
|
|
79392
80064
|
var import_yaml9 = __toESM(require_dist6(), 1);
|
|
79393
80065
|
function bakeSceneIntoApp(sourcePath2, scene, agent = "viewer-3d") {
|
|
79394
|
-
const doc = (0, import_yaml9.parseDocument)((0,
|
|
80066
|
+
const doc = (0, import_yaml9.parseDocument)((0, import_node_fs57.readFileSync)(sourcePath2, "utf8"));
|
|
79395
80067
|
if (doc.errors.length > 0) {
|
|
79396
80068
|
throw new Error(`scene bake: source is not valid YAML: ${doc.errors[0]?.message ?? "parse error"}`);
|
|
79397
80069
|
}
|
|
@@ -79400,10 +80072,10 @@ function bakeSceneIntoApp(sourcePath2, scene, agent = "viewer-3d") {
|
|
|
79400
80072
|
const idx = items.findIndex((it) => ((0, import_yaml9.isMap)(it) ? it.toJSON() : null)?.agent === agent);
|
|
79401
80073
|
if (idx < 0) throw new Error(`no ${agent} render node to bake the scene into`);
|
|
79402
80074
|
doc.setIn(["nodes", idx, "config", "scene"], scene);
|
|
79403
|
-
(0,
|
|
80075
|
+
(0, import_node_fs57.writeFileSync)(sourcePath2, doc.toString());
|
|
79404
80076
|
}
|
|
79405
80077
|
function bakeNodeConfigById(sourcePath2, nodeId, patch2) {
|
|
79406
|
-
const doc = (0, import_yaml9.parseDocument)((0,
|
|
80078
|
+
const doc = (0, import_yaml9.parseDocument)((0, import_node_fs57.readFileSync)(sourcePath2, "utf8"));
|
|
79407
80079
|
if (doc.errors.length > 0) {
|
|
79408
80080
|
throw new Error(`node bake: source is not valid YAML: ${doc.errors[0]?.message ?? "parse error"}`);
|
|
79409
80081
|
}
|
|
@@ -79412,12 +80084,12 @@ function bakeNodeConfigById(sourcePath2, nodeId, patch2) {
|
|
|
79412
80084
|
const idx = items.findIndex((it) => ((0, import_yaml9.isMap)(it) ? it.toJSON() : null)?.id === nodeId);
|
|
79413
80085
|
if (idx < 0) throw new Error(`no node with id "${nodeId}"`);
|
|
79414
80086
|
for (const [key, value] of Object.entries(patch2)) doc.setIn(["nodes", idx, "config", key], value);
|
|
79415
|
-
(0,
|
|
80087
|
+
(0, import_node_fs57.writeFileSync)(sourcePath2, doc.toString());
|
|
79416
80088
|
}
|
|
79417
80089
|
function writeViewer3dApp(dir, appId, scene) {
|
|
79418
|
-
(0,
|
|
80090
|
+
(0, import_node_fs57.mkdirSync)(dir, { recursive: true });
|
|
79419
80091
|
const flo = (0, import_node_path51.join)(dir, `${appId}.flo`);
|
|
79420
|
-
(0,
|
|
80092
|
+
(0, import_node_fs57.writeFileSync)(flo, [
|
|
79421
80093
|
`app: ${appId}`,
|
|
79422
80094
|
"version: 0.1.0",
|
|
79423
80095
|
"display-name: Steel 3D",
|
|
@@ -79440,18 +80112,18 @@ function writeViewer3dApp(dir, appId, scene) {
|
|
|
79440
80112
|
var COMPANION_MARKER = "# floless-companion: generated by FloLess \u2014 overwritten on every export";
|
|
79441
80113
|
function isCompanionApp(flo) {
|
|
79442
80114
|
try {
|
|
79443
|
-
return (0,
|
|
80115
|
+
return (0, import_node_fs57.readFileSync)(flo, "utf8").split(/\r?\n/, 1)[0]?.trim() === COMPANION_MARKER;
|
|
79444
80116
|
} catch (e) {
|
|
79445
80117
|
return e?.code === "ENOENT";
|
|
79446
80118
|
}
|
|
79447
80119
|
}
|
|
79448
80120
|
function writeBomReportApp(dir, appId, table) {
|
|
79449
|
-
(0,
|
|
80121
|
+
(0, import_node_fs57.mkdirSync)(dir, { recursive: true });
|
|
79450
80122
|
const flo = (0, import_node_path51.join)(dir, `${appId}.flo`);
|
|
79451
80123
|
if (!isCompanionApp(flo)) {
|
|
79452
80124
|
throw new Error(`refusing to overwrite "${appId}": an app of that name exists and FloLess did not write it`);
|
|
79453
80125
|
}
|
|
79454
|
-
(0,
|
|
80126
|
+
(0, import_node_fs57.writeFileSync)(flo, [
|
|
79455
80127
|
COMPANION_MARKER,
|
|
79456
80128
|
`app: ${appId}`,
|
|
79457
80129
|
"version: 0.1.0",
|
|
@@ -79478,9 +80150,9 @@ function writeBomReportApp(dir, appId, table) {
|
|
|
79478
80150
|
return flo;
|
|
79479
80151
|
}
|
|
79480
80152
|
function writeRevitApp(dir, appId, scene, hostPid, revitVersion = "2026") {
|
|
79481
|
-
(0,
|
|
80153
|
+
(0, import_node_fs57.mkdirSync)(dir, { recursive: true });
|
|
79482
80154
|
const flo = (0, import_node_path51.join)(dir, `${appId}.flo`);
|
|
79483
|
-
(0,
|
|
80155
|
+
(0, import_node_fs57.writeFileSync)(flo, [
|
|
79484
80156
|
`app: ${appId}`,
|
|
79485
80157
|
"version: 0.1.0",
|
|
79486
80158
|
"display-name: Steel to Revit",
|
|
@@ -79514,9 +80186,9 @@ function writeRevitApp(dir, appId, scene, hostPid, revitVersion = "2026") {
|
|
|
79514
80186
|
return flo;
|
|
79515
80187
|
}
|
|
79516
80188
|
function writeSketchupApp(dir, appId, scene) {
|
|
79517
|
-
(0,
|
|
80189
|
+
(0, import_node_fs57.mkdirSync)(dir, { recursive: true });
|
|
79518
80190
|
const flo = (0, import_node_path51.join)(dir, `${appId}.flo`);
|
|
79519
|
-
(0,
|
|
80191
|
+
(0, import_node_fs57.writeFileSync)(flo, [
|
|
79520
80192
|
`app: ${appId}`,
|
|
79521
80193
|
"version: 0.1.0",
|
|
79522
80194
|
"display-name: Steel to SketchUp",
|
|
@@ -79543,10 +80215,10 @@ function writeSketchupApp(dir, appId, scene) {
|
|
|
79543
80215
|
return flo;
|
|
79544
80216
|
}
|
|
79545
80217
|
function writeRhinoApp(dir, appId, scene, rhinoId, hostPid) {
|
|
79546
|
-
(0,
|
|
80218
|
+
(0, import_node_fs57.mkdirSync)(dir, { recursive: true });
|
|
79547
80219
|
const flo = (0, import_node_path51.join)(dir, `${appId}.flo`);
|
|
79548
80220
|
const exactRhinoId = typeof rhinoId === "string" && rhinoId.trim() ? rhinoId.trim() : null;
|
|
79549
|
-
(0,
|
|
80221
|
+
(0, import_node_fs57.writeFileSync)(flo, [
|
|
79550
80222
|
`app: ${appId}`,
|
|
79551
80223
|
"version: 0.1.0",
|
|
79552
80224
|
"display-name: Steel to Rhino",
|
|
@@ -79573,9 +80245,9 @@ function writeRhinoApp(dir, appId, scene, rhinoId, hostPid) {
|
|
|
79573
80245
|
return flo;
|
|
79574
80246
|
}
|
|
79575
80247
|
function writeTeklaApp(dir, appId, scene, teklaVersion = "2026.0") {
|
|
79576
|
-
(0,
|
|
80248
|
+
(0, import_node_fs57.mkdirSync)(dir, { recursive: true });
|
|
79577
80249
|
const flo = (0, import_node_path51.join)(dir, `${appId}.flo`);
|
|
79578
|
-
(0,
|
|
80250
|
+
(0, import_node_fs57.writeFileSync)(flo, [
|
|
79579
80251
|
`app: ${appId}`,
|
|
79580
80252
|
"version: 0.1.0",
|
|
79581
80253
|
"display-name: Steel to Tekla",
|
|
@@ -79739,7 +80411,7 @@ async function teklaVersionToBake() {
|
|
|
79739
80411
|
|
|
79740
80412
|
// export-companion.ts
|
|
79741
80413
|
var import_node_crypto36 = require("node:crypto");
|
|
79742
|
-
var
|
|
80414
|
+
var import_node_fs58 = require("node:fs");
|
|
79743
80415
|
var import_node_path52 = require("node:path");
|
|
79744
80416
|
var PREFIX2 = "floless-export-tmp-";
|
|
79745
80417
|
var LEASE = ".floless-export-lease.json";
|
|
@@ -79765,7 +80437,7 @@ function assertScratchPath(path, appsRoot) {
|
|
|
79765
80437
|
}
|
|
79766
80438
|
function removeScratch(path, appsRoot) {
|
|
79767
80439
|
assertScratchPath(path, appsRoot);
|
|
79768
|
-
(0,
|
|
80440
|
+
(0, import_node_fs58.rmSync)(path, { recursive: true, force: true });
|
|
79769
80441
|
}
|
|
79770
80442
|
function createExportCompanion(ownerId, sink, appsRoot = defaultAppsRoot()) {
|
|
79771
80443
|
const safeOwner = ownerId.replace(/[^a-z0-9._-]/gi, "-").slice(0, 80) || "app";
|
|
@@ -79778,10 +80450,10 @@ function createExportCompanion(ownerId, sink, appsRoot = defaultAppsRoot()) {
|
|
|
79778
80450
|
path,
|
|
79779
80451
|
token: token2,
|
|
79780
80452
|
cleanup: () => {
|
|
79781
|
-
if (!(0,
|
|
80453
|
+
if (!(0, import_node_fs58.existsSync)(path)) return;
|
|
79782
80454
|
let current = null;
|
|
79783
80455
|
try {
|
|
79784
|
-
current = JSON.parse((0,
|
|
80456
|
+
current = JSON.parse((0, import_node_fs58.readFileSync)((0, import_node_path52.resolve)(path, LEASE), "utf8"));
|
|
79785
80457
|
} catch {
|
|
79786
80458
|
}
|
|
79787
80459
|
if (current && current.token !== token2) throw new Error(`export companion lease changed for ${id}`);
|
|
@@ -79790,7 +80462,7 @@ function createExportCompanion(ownerId, sink, appsRoot = defaultAppsRoot()) {
|
|
|
79790
80462
|
};
|
|
79791
80463
|
}
|
|
79792
80464
|
function stampExportCompanionLease(companion2) {
|
|
79793
|
-
(0,
|
|
80465
|
+
(0, import_node_fs58.writeFileSync)((0, import_node_path52.resolve)(companion2.path, LEASE), JSON.stringify({
|
|
79794
80466
|
pid: process.pid,
|
|
79795
80467
|
token: companion2.token,
|
|
79796
80468
|
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -79798,19 +80470,19 @@ function stampExportCompanionLease(companion2) {
|
|
|
79798
80470
|
}
|
|
79799
80471
|
function sweepStaleExportCompanions(now = Date.now(), appsRoot = defaultAppsRoot()) {
|
|
79800
80472
|
const root6 = (0, import_node_path52.resolve)(appsRoot);
|
|
79801
|
-
if (!(0,
|
|
80473
|
+
if (!(0, import_node_fs58.existsSync)(root6)) return [];
|
|
79802
80474
|
const removed = [];
|
|
79803
|
-
for (const entry2 of (0,
|
|
80475
|
+
for (const entry2 of (0, import_node_fs58.readdirSync)(root6, { withFileTypes: true })) {
|
|
79804
80476
|
if (!entry2.isDirectory() || !entry2.name.startsWith(PREFIX2)) continue;
|
|
79805
80477
|
const path = (0, import_node_path52.resolve)(root6, entry2.name);
|
|
79806
80478
|
let lease = null;
|
|
79807
80479
|
try {
|
|
79808
|
-
lease = JSON.parse((0,
|
|
80480
|
+
lease = JSON.parse((0, import_node_fs58.readFileSync)((0, import_node_path52.resolve)(path, LEASE), "utf8"));
|
|
79809
80481
|
} catch {
|
|
79810
80482
|
}
|
|
79811
80483
|
let created;
|
|
79812
80484
|
try {
|
|
79813
|
-
created = lease ? Date.parse(lease.createdAt) : (0,
|
|
80485
|
+
created = lease ? Date.parse(lease.createdAt) : (0, import_node_fs58.statSync)(path).mtimeMs;
|
|
79814
80486
|
} catch {
|
|
79815
80487
|
continue;
|
|
79816
80488
|
}
|
|
@@ -80108,9 +80780,9 @@ async function scanRunningKnownHosts(deps = DEFAULT_DEPS2) {
|
|
|
80108
80780
|
if (!envelope || typeof envelope !== "object" || envelope.ok !== true) {
|
|
80109
80781
|
return { scanned: false, hosts: [] };
|
|
80110
80782
|
}
|
|
80111
|
-
const
|
|
80112
|
-
if (!Array.isArray(
|
|
80113
|
-
const list = Array.isArray(
|
|
80783
|
+
const names2 = envelope.names;
|
|
80784
|
+
if (!Array.isArray(names2) && typeof names2 !== "string") return { scanned: false, hosts: [] };
|
|
80785
|
+
const list = Array.isArray(names2) ? names2 : [names2];
|
|
80114
80786
|
const found = /* @__PURE__ */ new Set();
|
|
80115
80787
|
for (const raw of list) {
|
|
80116
80788
|
const host = hostForProcessName(typeof raw === "string" ? raw : null);
|
|
@@ -80384,14 +81056,14 @@ function looksLikeHostUnavailable(host, ...messages) {
|
|
|
80384
81056
|
}
|
|
80385
81057
|
|
|
80386
81058
|
// render-readiness.ts
|
|
80387
|
-
var
|
|
81059
|
+
var import_node_fs59 = require("node:fs");
|
|
80388
81060
|
var import_node_path53 = require("node:path");
|
|
80389
81061
|
var import_node_os29 = require("node:os");
|
|
80390
81062
|
var RENDER_AWARE_FLOOR = "0.103.0";
|
|
80391
81063
|
var RENDER_AGENT_ID = "blender";
|
|
80392
81064
|
function isFile(path) {
|
|
80393
81065
|
try {
|
|
80394
|
-
return (0,
|
|
81066
|
+
return (0, import_node_fs59.existsSync)(path) && (0, import_node_fs59.statSync)(path).isFile();
|
|
80395
81067
|
} catch {
|
|
80396
81068
|
return false;
|
|
80397
81069
|
}
|
|
@@ -80425,7 +81097,7 @@ function windowsCandidates(env2) {
|
|
|
80425
81097
|
for (const root6 of roots) {
|
|
80426
81098
|
let entries;
|
|
80427
81099
|
try {
|
|
80428
|
-
entries = (0,
|
|
81100
|
+
entries = (0, import_node_fs59.readdirSync)(root6);
|
|
80429
81101
|
} catch {
|
|
80430
81102
|
continue;
|
|
80431
81103
|
}
|
|
@@ -80748,16 +81420,16 @@ function rollUpModel(view) {
|
|
|
80748
81420
|
}
|
|
80749
81421
|
|
|
80750
81422
|
// app-lifecycle.ts
|
|
80751
|
-
var
|
|
81423
|
+
var import_node_fs63 = require("node:fs");
|
|
80752
81424
|
var import_node_os32 = require("node:os");
|
|
80753
81425
|
var import_node_path57 = require("node:path");
|
|
80754
81426
|
|
|
80755
81427
|
// routines.ts
|
|
80756
|
-
var
|
|
81428
|
+
var import_node_fs61 = require("node:fs");
|
|
80757
81429
|
var import_node_path55 = require("node:path");
|
|
80758
81430
|
|
|
80759
81431
|
// trigger-sessions.ts
|
|
80760
|
-
var
|
|
81432
|
+
var import_node_fs60 = require("node:fs");
|
|
80761
81433
|
var import_node_os30 = require("node:os");
|
|
80762
81434
|
var import_node_path54 = require("node:path");
|
|
80763
81435
|
var import_yaml10 = __toESM(require_dist6(), 1);
|
|
@@ -80779,9 +81451,9 @@ function isHostBacked(agent, agentsDir = AGENTS_DIR2) {
|
|
|
80779
81451
|
const safe2 = (n) => !n.includes("/") && !n.includes("\\") && !n.includes("..");
|
|
80780
81452
|
if (!safe2(agent)) return false;
|
|
80781
81453
|
const manifestPath2 = (0, import_node_path54.join)(agentsDir, agent, "manifest.yaml");
|
|
80782
|
-
if (!(0,
|
|
81454
|
+
if (!(0, import_node_fs60.existsSync)(manifestPath2)) return false;
|
|
80783
81455
|
try {
|
|
80784
|
-
const doc = (0, import_yaml10.parse)((0,
|
|
81456
|
+
const doc = (0, import_yaml10.parse)((0, import_node_fs60.readFileSync)(manifestPath2, "utf8"));
|
|
80785
81457
|
const transport = doc?.transport;
|
|
80786
81458
|
return !!(transport && typeof transport === "object" && "cli" in transport);
|
|
80787
81459
|
} catch {
|
|
@@ -81125,29 +81797,29 @@ function sanitizeRoutine(raw) {
|
|
|
81125
81797
|
};
|
|
81126
81798
|
}
|
|
81127
81799
|
function loadFromDisk() {
|
|
81128
|
-
if (!(0,
|
|
81129
|
-
let
|
|
81800
|
+
if (!(0, import_node_fs61.existsSync)(ROUTINES_FILE)) return [];
|
|
81801
|
+
let text5;
|
|
81130
81802
|
try {
|
|
81131
|
-
|
|
81803
|
+
text5 = (0, import_node_fs61.readFileSync)(ROUTINES_FILE, "utf8");
|
|
81132
81804
|
} catch {
|
|
81133
81805
|
return [];
|
|
81134
81806
|
}
|
|
81135
81807
|
try {
|
|
81136
|
-
const parsed = JSON.parse(
|
|
81808
|
+
const parsed = JSON.parse(text5);
|
|
81137
81809
|
return Array.isArray(parsed) ? parsed.map(sanitizeRoutine).filter((r) => r !== null) : [];
|
|
81138
81810
|
} catch {
|
|
81139
81811
|
try {
|
|
81140
|
-
(0,
|
|
81812
|
+
(0, import_node_fs61.renameSync)(ROUTINES_FILE, `${ROUTINES_FILE}.corrupt-${Date.now()}`);
|
|
81141
81813
|
} catch {
|
|
81142
81814
|
}
|
|
81143
81815
|
return [];
|
|
81144
81816
|
}
|
|
81145
81817
|
}
|
|
81146
81818
|
function saveRoutines() {
|
|
81147
|
-
if (!(0,
|
|
81819
|
+
if (!(0, import_node_fs61.existsSync)(flolessRoot)) (0, import_node_fs61.mkdirSync)(flolessRoot, { recursive: true });
|
|
81148
81820
|
const tmp = `${ROUTINES_FILE}.${process.pid}.tmp`;
|
|
81149
|
-
(0,
|
|
81150
|
-
(0,
|
|
81821
|
+
(0, import_node_fs61.writeFileSync)(tmp, JSON.stringify(routines, null, 2));
|
|
81822
|
+
(0, import_node_fs61.renameSync)(tmp, ROUTINES_FILE);
|
|
81151
81823
|
}
|
|
81152
81824
|
function listRoutines() {
|
|
81153
81825
|
ensureLoaded();
|
|
@@ -81557,7 +82229,7 @@ async function stopScheduler() {
|
|
|
81557
82229
|
}
|
|
81558
82230
|
|
|
81559
82231
|
// kb-pin-store.ts
|
|
81560
|
-
var
|
|
82232
|
+
var import_node_fs62 = require("node:fs");
|
|
81561
82233
|
var import_node_path56 = require("node:path");
|
|
81562
82234
|
var import_node_os31 = require("node:os");
|
|
81563
82235
|
var KbPinError = class extends Error {
|
|
@@ -81625,9 +82297,9 @@ function normalizePages(pages) {
|
|
|
81625
82297
|
}
|
|
81626
82298
|
function readPinUnlocked(appId) {
|
|
81627
82299
|
const p = pinPath(appId);
|
|
81628
|
-
if (!(0,
|
|
82300
|
+
if (!(0, import_node_fs62.existsSync)(p)) return null;
|
|
81629
82301
|
try {
|
|
81630
|
-
const parsed = JSON.parse((0,
|
|
82302
|
+
const parsed = JSON.parse((0, import_node_fs62.readFileSync)(p, "utf8"));
|
|
81631
82303
|
if (!parsed || typeof parsed !== "object") {
|
|
81632
82304
|
console.warn(`kb-pin-store: ignoring schema-invalid pin at ${p} (not an object)`);
|
|
81633
82305
|
return null;
|
|
@@ -81666,7 +82338,7 @@ function writePinUnlocked(appId, pin) {
|
|
|
81666
82338
|
pinnedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
81667
82339
|
pages: normalizePages(pin.pages)
|
|
81668
82340
|
};
|
|
81669
|
-
(0,
|
|
82341
|
+
(0, import_node_fs62.mkdirSync)((0, import_node_path56.dirname)(p), { recursive: true });
|
|
81670
82342
|
writeJsonAtomic(p, doc);
|
|
81671
82343
|
return doc;
|
|
81672
82344
|
}
|
|
@@ -81676,9 +82348,9 @@ function writePin(appId, pin) {
|
|
|
81676
82348
|
function movePinBytesUnlocked(fromAppId, toAppId) {
|
|
81677
82349
|
const from = pinPath(fromAppId);
|
|
81678
82350
|
const to = pinPath(toAppId);
|
|
81679
|
-
if (from === to || !(0,
|
|
81680
|
-
(0,
|
|
81681
|
-
(0,
|
|
82351
|
+
if (from === to || !(0, import_node_fs62.existsSync)(from)) return false;
|
|
82352
|
+
(0, import_node_fs62.mkdirSync)((0, import_node_path56.dirname)(to), { recursive: true });
|
|
82353
|
+
(0, import_node_fs62.renameSync)(from, to);
|
|
81682
82354
|
return true;
|
|
81683
82355
|
}
|
|
81684
82356
|
function movePinBytes(fromAppId, toAppId) {
|
|
@@ -81686,8 +82358,8 @@ function movePinBytes(fromAppId, toAppId) {
|
|
|
81686
82358
|
}
|
|
81687
82359
|
function dropPinBytesUnlocked(appId) {
|
|
81688
82360
|
const p = pinPath(appId);
|
|
81689
|
-
if (!(0,
|
|
81690
|
-
(0,
|
|
82361
|
+
if (!(0, import_node_fs62.existsSync)(p)) return false;
|
|
82362
|
+
(0, import_node_fs62.rmSync)(p, { force: true });
|
|
81691
82363
|
return true;
|
|
81692
82364
|
}
|
|
81693
82365
|
function dropPinBytes(appId) {
|
|
@@ -81697,9 +82369,9 @@ function repointProjectPinsUnlocked(fromProjectId, toProjectId) {
|
|
|
81697
82369
|
if (!isProjectId2(fromProjectId) || !isProjectId2(toProjectId)) {
|
|
81698
82370
|
throw new KbPinError("invalid project id for pin repoint", "invalid-project");
|
|
81699
82371
|
}
|
|
81700
|
-
if (fromProjectId === toProjectId || !(0,
|
|
82372
|
+
if (fromProjectId === toProjectId || !(0, import_node_fs62.existsSync)(pinsDir())) return 0;
|
|
81701
82373
|
const targets = [];
|
|
81702
|
-
for (const entry2 of (0,
|
|
82374
|
+
for (const entry2 of (0, import_node_fs62.readdirSync)(pinsDir(), { withFileTypes: true })) {
|
|
81703
82375
|
if (!entry2.isFile() || !entry2.name.endsWith(".json")) continue;
|
|
81704
82376
|
const appId = (0, import_node_path56.basename)(entry2.name, ".json");
|
|
81705
82377
|
let pin;
|
|
@@ -81749,7 +82421,7 @@ function appDirPath(id) {
|
|
|
81749
82421
|
return (0, import_node_path57.join)(appsDir(), id);
|
|
81750
82422
|
}
|
|
81751
82423
|
function appInstalled(id) {
|
|
81752
|
-
return APP_ID5.test(id) && (0,
|
|
82424
|
+
return APP_ID5.test(id) && (0, import_node_fs63.existsSync)(appDirPath(id));
|
|
81753
82425
|
}
|
|
81754
82426
|
function logCascade(what, e) {
|
|
81755
82427
|
console.error(`[app-lifecycle] cascade step failed (${what}):`, e instanceof Error ? e.message : e);
|
|
@@ -81958,11 +82630,11 @@ async function deleteApp(id, deps = defaultDeps2) {
|
|
|
81958
82630
|
}
|
|
81959
82631
|
|
|
81960
82632
|
// kb-pin-routes.ts
|
|
81961
|
-
var
|
|
82633
|
+
var import_node_fs64 = require("node:fs");
|
|
81962
82634
|
function driftOf(pin) {
|
|
81963
82635
|
const cur = readCurrentGeneration(pin.projectId);
|
|
81964
82636
|
if (cur === null) return true;
|
|
81965
|
-
if (!(0,
|
|
82637
|
+
if (!(0, import_node_fs64.existsSync)(generationWikiDir(pin.projectId, cur.generationId))) return true;
|
|
81966
82638
|
return cur.generationId !== pin.generationId;
|
|
81967
82639
|
}
|
|
81968
82640
|
function registerKbPinRoutes(app, deps) {
|
|
@@ -82078,7 +82750,7 @@ function isGatedAwareRoute(url, method) {
|
|
|
82078
82750
|
|
|
82079
82751
|
// autostart.mjs
|
|
82080
82752
|
var import_node_child_process10 = require("node:child_process");
|
|
82081
|
-
var
|
|
82753
|
+
var import_node_fs65 = require("node:fs");
|
|
82082
82754
|
var import_node_os33 = require("node:os");
|
|
82083
82755
|
var import_node_path58 = require("node:path");
|
|
82084
82756
|
|
|
@@ -82192,8 +82864,8 @@ function removeLegacyRunKey() {
|
|
|
82192
82864
|
}
|
|
82193
82865
|
function logLine(msg) {
|
|
82194
82866
|
try {
|
|
82195
|
-
(0,
|
|
82196
|
-
(0,
|
|
82867
|
+
(0, import_node_fs65.mkdirSync)(logDir(), { recursive: true });
|
|
82868
|
+
(0, import_node_fs65.appendFileSync)(logFilePath(), `${(/* @__PURE__ */ new Date()).toISOString()} ${msg}
|
|
82197
82869
|
`);
|
|
82198
82870
|
} catch {
|
|
82199
82871
|
}
|
|
@@ -82202,7 +82874,7 @@ function registerAutostart(exePath) {
|
|
|
82202
82874
|
if (!isWin) return;
|
|
82203
82875
|
const xml = buildAutostartTaskXml(exePath, currentUserId());
|
|
82204
82876
|
const tmp = (0, import_node_path58.join)((0, import_node_os33.tmpdir)(), `floless-autostart-${process.pid}-${Date.now()}.xml`);
|
|
82205
|
-
(0,
|
|
82877
|
+
(0, import_node_fs65.writeFileSync)(tmp, "\uFEFF" + xml, { encoding: "utf16le" });
|
|
82206
82878
|
try {
|
|
82207
82879
|
(0, import_node_child_process10.execFileSync)("schtasks", ["/Create", "/TN", TASK_NAME, "/XML", tmp, "/F"], {
|
|
82208
82880
|
stdio: ["ignore", "ignore", "ignore"],
|
|
@@ -82213,7 +82885,7 @@ function registerAutostart(exePath) {
|
|
|
82213
82885
|
throw err2;
|
|
82214
82886
|
} finally {
|
|
82215
82887
|
try {
|
|
82216
|
-
(0,
|
|
82888
|
+
(0, import_node_fs65.rmSync)(tmp, { force: true });
|
|
82217
82889
|
} catch {
|
|
82218
82890
|
}
|
|
82219
82891
|
}
|
|
@@ -82248,13 +82920,13 @@ function unregisterAutostart() {
|
|
|
82248
82920
|
// updater.ts
|
|
82249
82921
|
var import_node_child_process11 = require("node:child_process");
|
|
82250
82922
|
var import_node_crypto37 = require("node:crypto");
|
|
82251
|
-
var
|
|
82923
|
+
var import_node_fs67 = require("node:fs");
|
|
82252
82924
|
var import_node_stream3 = require("node:stream");
|
|
82253
82925
|
var import_promises5 = require("node:stream/promises");
|
|
82254
82926
|
var import_node_path60 = require("node:path");
|
|
82255
82927
|
|
|
82256
82928
|
// post-update-marker.mjs
|
|
82257
|
-
var
|
|
82929
|
+
var import_node_fs66 = require("node:fs");
|
|
82258
82930
|
var import_node_os34 = require("node:os");
|
|
82259
82931
|
var import_node_path59 = require("node:path");
|
|
82260
82932
|
var FRESH_MS = 12e4;
|
|
@@ -82277,7 +82949,7 @@ function writePostUpdateMarker() {
|
|
|
82277
82949
|
for (const p of [markerPath(), legacyMarkerPath()]) {
|
|
82278
82950
|
if (!p) continue;
|
|
82279
82951
|
try {
|
|
82280
|
-
(0,
|
|
82952
|
+
(0, import_node_fs66.writeFileSync)(p, (/* @__PURE__ */ new Date()).toISOString());
|
|
82281
82953
|
wrote = true;
|
|
82282
82954
|
} catch {
|
|
82283
82955
|
}
|
|
@@ -82289,9 +82961,9 @@ function consumePostUpdateMarker() {
|
|
|
82289
82961
|
for (const p of [markerPath(), legacyMarkerPath()]) {
|
|
82290
82962
|
if (!p) continue;
|
|
82291
82963
|
try {
|
|
82292
|
-
if (!(0,
|
|
82293
|
-
const ageMs = Date.now() - (0,
|
|
82294
|
-
(0,
|
|
82964
|
+
if (!(0, import_node_fs66.existsSync)(p)) continue;
|
|
82965
|
+
const ageMs = Date.now() - (0, import_node_fs66.statSync)(p).mtimeMs;
|
|
82966
|
+
(0, import_node_fs66.rmSync)(p, { force: true });
|
|
82295
82967
|
if (ageMs < FRESH_MS) fresh = true;
|
|
82296
82968
|
} catch {
|
|
82297
82969
|
}
|
|
@@ -82304,7 +82976,7 @@ var CHANNEL = "win";
|
|
|
82304
82976
|
var FEED_TIMEOUT_MS = 15e3;
|
|
82305
82977
|
var DOWNLOAD_TIMEOUT_MS = 3e5;
|
|
82306
82978
|
var NUPKG_NAME = /^[A-Za-z0-9][A-Za-z0-9._-]*\.nupkg$/;
|
|
82307
|
-
function
|
|
82979
|
+
function currentVersion2() {
|
|
82308
82980
|
return appVersion();
|
|
82309
82981
|
}
|
|
82310
82982
|
function installRoot() {
|
|
@@ -82357,7 +83029,7 @@ async function checkNpmUpdate(cur, channel = "npm") {
|
|
|
82357
83029
|
}
|
|
82358
83030
|
}
|
|
82359
83031
|
async function checkForUpdate() {
|
|
82360
|
-
const cur =
|
|
83032
|
+
const cur = currentVersion2();
|
|
82361
83033
|
const channel = appChannel();
|
|
82362
83034
|
if (channel === "npm" || channel === "npx") return checkNpmUpdate(cur, channel);
|
|
82363
83035
|
if (channel !== "desktop") {
|
|
@@ -82405,22 +83077,22 @@ async function checkForUpdate() {
|
|
|
82405
83077
|
}
|
|
82406
83078
|
async function sha1OfFile(path) {
|
|
82407
83079
|
const hash3 = (0, import_node_crypto37.createHash)("sha1");
|
|
82408
|
-
await (0, import_promises5.pipeline)((0,
|
|
83080
|
+
await (0, import_promises5.pipeline)((0, import_node_fs67.createReadStream)(path), hash3);
|
|
82409
83081
|
return hash3.digest("hex").toUpperCase();
|
|
82410
83082
|
}
|
|
82411
83083
|
async function downloadPackage(asset) {
|
|
82412
83084
|
if (!NUPKG_NAME.test(asset.FileName)) throw new Error(`refusing suspicious package name: ${asset.FileName}`);
|
|
82413
83085
|
const want = asset.SHA1.toUpperCase();
|
|
82414
83086
|
const dir = packagesDir();
|
|
82415
|
-
(0,
|
|
83087
|
+
(0, import_node_fs67.mkdirSync)(dir, { recursive: true });
|
|
82416
83088
|
const dest = (0, import_node_path60.join)(dir, asset.FileName);
|
|
82417
|
-
if ((0,
|
|
83089
|
+
if ((0, import_node_fs67.existsSync)(dest) && await sha1OfFile(dest) === want) return dest;
|
|
82418
83090
|
const res = await authedFetch(`${feedUrl()}/${encodeURIComponent(asset.FileName)}`, {
|
|
82419
83091
|
redirect: "follow",
|
|
82420
83092
|
signal: AbortSignal.timeout(DOWNLOAD_TIMEOUT_MS)
|
|
82421
83093
|
});
|
|
82422
83094
|
if (!res.ok || !res.body) throw new Error(`download failed: HTTP ${res.status} for ${asset.FileName}`);
|
|
82423
|
-
await (0, import_promises5.pipeline)(import_node_stream3.Readable.fromWeb(res.body), (0,
|
|
83095
|
+
await (0, import_promises5.pipeline)(import_node_stream3.Readable.fromWeb(res.body), (0, import_node_fs67.createWriteStream)(dest));
|
|
82424
83096
|
const got = await sha1OfFile(dest);
|
|
82425
83097
|
if (got !== want) throw new Error(`SHA1 mismatch for ${asset.FileName}: feed=${want} got=${got}`);
|
|
82426
83098
|
return dest;
|
|
@@ -82429,7 +83101,7 @@ async function applyUpdate(check, opts) {
|
|
|
82429
83101
|
if (!check.supported) return { applied: false, message: check.reason ?? "auto-update not supported in this runtime" };
|
|
82430
83102
|
if (!check.updateAvailable || !check.asset) return { applied: false, message: check.reason ?? "no update available" };
|
|
82431
83103
|
const exe2 = updateExePath();
|
|
82432
|
-
if (!(0,
|
|
83104
|
+
if (!(0, import_node_fs67.existsSync)(exe2)) {
|
|
82433
83105
|
return { applied: false, message: `Update.exe not found at ${exe2} \u2014 is this a Velopack install?` };
|
|
82434
83106
|
}
|
|
82435
83107
|
const pkg = await downloadPackage(check.asset);
|
|
@@ -82546,15 +83218,15 @@ function ccType(prefix) {
|
|
|
82546
83218
|
}
|
|
82547
83219
|
}
|
|
82548
83220
|
function parseBulletChanges(body) {
|
|
82549
|
-
const
|
|
83221
|
+
const text5 = body.replace(/\r\n?/g, "\n");
|
|
82550
83222
|
const styled = [];
|
|
82551
83223
|
let m;
|
|
82552
83224
|
STYLED_CHANGE_RE.lastIndex = 0;
|
|
82553
|
-
while ((m = STYLED_CHANGE_RE.exec(
|
|
83225
|
+
while ((m = STYLED_CHANGE_RE.exec(text5)) !== null) styled.push({ type: m[1].toLowerCase(), description: m[2].trim() });
|
|
82554
83226
|
if (styled.length) return styled;
|
|
82555
83227
|
const out = [];
|
|
82556
83228
|
COMMIT_BULLET_RE.lastIndex = 0;
|
|
82557
|
-
while ((m = COMMIT_BULLET_RE.exec(
|
|
83229
|
+
while ((m = COMMIT_BULLET_RE.exec(text5)) !== null) {
|
|
82558
83230
|
const raw = m[1].replace(GH_CREDIT_RE, "").trim();
|
|
82559
83231
|
if (!raw) continue;
|
|
82560
83232
|
if (raw.startsWith("@")) continue;
|
|
@@ -82671,7 +83343,7 @@ function isTraceCorrupt(events) {
|
|
|
82671
83343
|
var import_node_child_process12 = require("node:child_process");
|
|
82672
83344
|
var import_node_path61 = require("node:path");
|
|
82673
83345
|
var import_node_url3 = require("node:url");
|
|
82674
|
-
var
|
|
83346
|
+
var import_node_fs68 = require("node:fs");
|
|
82675
83347
|
var import_node_http = __toESM(require("node:http"), 1);
|
|
82676
83348
|
var import_node_readline = require("node:readline");
|
|
82677
83349
|
var __dirname2 = (0, import_node_path61.dirname)((0, import_node_url3.fileURLToPath)(__import_meta_url));
|
|
@@ -82753,7 +83425,7 @@ function resolveServerStart() {
|
|
|
82753
83425
|
const packaged = /flolessapp\.exe$/i.test(process.execPath);
|
|
82754
83426
|
if (packaged) return { cmd: process.execPath, args: ["--serve"], shell: false };
|
|
82755
83427
|
const bundle = (0, import_node_path61.join)(__dirname2, "dist", "floless-server.cjs");
|
|
82756
|
-
if ((0,
|
|
83428
|
+
if ((0, import_node_fs68.existsSync)(bundle)) return { cmd: process.execPath, args: [bundle, "--serve"], shell: false };
|
|
82757
83429
|
return { cmd: "npm", args: ["run", "start"], shell: isWin2 };
|
|
82758
83430
|
}
|
|
82759
83431
|
function startServerDetached() {
|
|
@@ -83109,13 +83781,13 @@ function pathInside(root6, candidate) {
|
|
|
83109
83781
|
return rel === "" || !rel.startsWith("..") && !(0, import_node_path62.isAbsolute)(rel);
|
|
83110
83782
|
}
|
|
83111
83783
|
async function snapshotPersistentBridges(bridgeDirectory, io = nodeBridgeIo) {
|
|
83112
|
-
let
|
|
83784
|
+
let names2;
|
|
83113
83785
|
try {
|
|
83114
83786
|
const directory = await io.lstat(bridgeDirectory);
|
|
83115
83787
|
if (!directory.isDirectory() || directory.isSymbolicLink()) {
|
|
83116
83788
|
throw new Error("persistent bridge directory is not a regular directory");
|
|
83117
83789
|
}
|
|
83118
|
-
|
|
83790
|
+
names2 = await io.readdir(bridgeDirectory);
|
|
83119
83791
|
} catch (error) {
|
|
83120
83792
|
if (error.code === "ENOENT") return Object.freeze([]);
|
|
83121
83793
|
throw new Error("Could not safely inspect installed AWARE bridges.", { cause: error });
|
|
@@ -83129,7 +83801,7 @@ async function snapshotPersistentBridges(bridgeDirectory, io = nodeBridgeIo) {
|
|
|
83129
83801
|
const installed = [];
|
|
83130
83802
|
for (const host of AWARE_BRIDGE_HOSTS) {
|
|
83131
83803
|
const fileName = `aware-${host}.exe`;
|
|
83132
|
-
if (!
|
|
83804
|
+
if (!names2.includes(fileName)) continue;
|
|
83133
83805
|
const candidate = (0, import_node_path62.join)(bridgeDirectory, fileName);
|
|
83134
83806
|
try {
|
|
83135
83807
|
const stat4 = await io.lstat(candidate);
|
|
@@ -83584,17 +84256,17 @@ function installAwareGlobal(spec, onLine = () => {
|
|
|
83584
84256
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
83585
84257
|
if (signal.aborted) onAbort();
|
|
83586
84258
|
child.stdout?.on("data", (data) => {
|
|
83587
|
-
const
|
|
83588
|
-
combinedTail = tail2(combinedTail,
|
|
83589
|
-
onLine(
|
|
83590
|
-
options.onLine?.(
|
|
84259
|
+
const text5 = data.toString();
|
|
84260
|
+
combinedTail = tail2(combinedTail, text5);
|
|
84261
|
+
onLine(text5.trimEnd());
|
|
84262
|
+
options.onLine?.(text5.trimEnd());
|
|
83591
84263
|
});
|
|
83592
84264
|
child.stderr?.on("data", (data) => {
|
|
83593
|
-
const
|
|
83594
|
-
stderrTail = tail2(stderrTail,
|
|
83595
|
-
combinedTail = tail2(combinedTail,
|
|
83596
|
-
onLine(
|
|
83597
|
-
options.onLine?.(
|
|
84265
|
+
const text5 = data.toString();
|
|
84266
|
+
stderrTail = tail2(stderrTail, text5);
|
|
84267
|
+
combinedTail = tail2(combinedTail, text5);
|
|
84268
|
+
onLine(text5.trimEnd());
|
|
84269
|
+
options.onLine?.(text5.trimEnd());
|
|
83598
84270
|
});
|
|
83599
84271
|
child.on("spawn", () => {
|
|
83600
84272
|
if (!child.pid || !options.onChild) return;
|
|
@@ -83615,6 +84287,90 @@ function installAwareGlobal(spec, onLine = () => {
|
|
|
83615
84287
|
});
|
|
83616
84288
|
}
|
|
83617
84289
|
|
|
84290
|
+
// installer-tree-probe.ts
|
|
84291
|
+
var import_node_child_process14 = require("node:child_process");
|
|
84292
|
+
var import_promises8 = require("node:fs/promises");
|
|
84293
|
+
var import_node_util6 = require("node:util");
|
|
84294
|
+
var execFileAsync3 = (0, import_node_util6.promisify)(import_node_child_process14.execFile);
|
|
84295
|
+
var INSTALLER_COMMAND_LINE_PATTERN = "@aware-aeco/cli@|\\baware(?:\\.cmd|\\.js)?\\W?\\s+sidecar\\s+install";
|
|
84296
|
+
var INSTALLER_RE = new RegExp(INSTALLER_COMMAND_LINE_PATTERN);
|
|
84297
|
+
function matchesInstallerCommandLine(commandLine) {
|
|
84298
|
+
return INSTALLER_RE.test(commandLine);
|
|
84299
|
+
}
|
|
84300
|
+
function procCmdlineToString(raw) {
|
|
84301
|
+
return raw.replace(/\0+$/, "").split("\0").join(" ");
|
|
84302
|
+
}
|
|
84303
|
+
function psOutputHasInstaller(stdout, selfPid) {
|
|
84304
|
+
for (const line of stdout.split("\n")) {
|
|
84305
|
+
const match = /^\s*(\d+)\s+(.*)$/.exec(line);
|
|
84306
|
+
if (!match) continue;
|
|
84307
|
+
if (Number(match[1]) === selfPid) continue;
|
|
84308
|
+
if (matchesInstallerCommandLine(match[2])) return true;
|
|
84309
|
+
}
|
|
84310
|
+
return false;
|
|
84311
|
+
}
|
|
84312
|
+
function isVanishedProcessError(err2) {
|
|
84313
|
+
const code = err2?.code;
|
|
84314
|
+
return code === "ENOENT" || code === "ESRCH";
|
|
84315
|
+
}
|
|
84316
|
+
function windowsProbe() {
|
|
84317
|
+
const script = [
|
|
84318
|
+
"$p=Get-CimInstance Win32_Process -ErrorAction Stop",
|
|
84319
|
+
`$m=$p|Where-Object {$_.ProcessId -ne $PID -and $_.CommandLine -match '${INSTALLER_COMMAND_LINE_PATTERN}'}`,
|
|
84320
|
+
"if($m){Write-Output true}else{Write-Output false}"
|
|
84321
|
+
].join(";");
|
|
84322
|
+
return (0, import_node_child_process14.execFileSync)("powershell.exe", ["-NoProfile", "-NonInteractive", "-Command", script], {
|
|
84323
|
+
encoding: "utf8",
|
|
84324
|
+
windowsHide: true,
|
|
84325
|
+
timeout: 5e3
|
|
84326
|
+
}).trim();
|
|
84327
|
+
}
|
|
84328
|
+
async function runPsDefault() {
|
|
84329
|
+
const { stdout } = await execFileAsync3("ps", ["-Awwo", "pid=,command="], {
|
|
84330
|
+
encoding: "utf8",
|
|
84331
|
+
timeout: 5e3,
|
|
84332
|
+
maxBuffer: 8 * 1024 * 1024
|
|
84333
|
+
});
|
|
84334
|
+
return stdout;
|
|
84335
|
+
}
|
|
84336
|
+
async function anyAwareInstallerTreeAlive(deps = {}) {
|
|
84337
|
+
const platform = deps.platform ?? process.platform;
|
|
84338
|
+
const selfPid = deps.selfPid ?? process.pid;
|
|
84339
|
+
if (platform === "win32") {
|
|
84340
|
+
try {
|
|
84341
|
+
return (deps.runWindowsProbe ?? windowsProbe)().toLowerCase() === "true";
|
|
84342
|
+
} catch {
|
|
84343
|
+
return true;
|
|
84344
|
+
}
|
|
84345
|
+
}
|
|
84346
|
+
if (platform === "linux") {
|
|
84347
|
+
let entries;
|
|
84348
|
+
try {
|
|
84349
|
+
entries = await (deps.listProcDir ?? (() => (0, import_promises8.readdir)("/proc")))();
|
|
84350
|
+
} catch {
|
|
84351
|
+
return true;
|
|
84352
|
+
}
|
|
84353
|
+
const read2 = deps.readProcCmdline ?? ((pid) => (0, import_promises8.readFile)(`/proc/${pid}/cmdline`, "utf8"));
|
|
84354
|
+
for (const entry2 of entries) {
|
|
84355
|
+
if (!/^\d+$/.test(entry2) || Number(entry2) === selfPid) continue;
|
|
84356
|
+
let raw;
|
|
84357
|
+
try {
|
|
84358
|
+
raw = await read2(entry2);
|
|
84359
|
+
} catch (err2) {
|
|
84360
|
+
if (isVanishedProcessError(err2)) continue;
|
|
84361
|
+
return true;
|
|
84362
|
+
}
|
|
84363
|
+
if (matchesInstallerCommandLine(procCmdlineToString(raw))) return true;
|
|
84364
|
+
}
|
|
84365
|
+
return false;
|
|
84366
|
+
}
|
|
84367
|
+
try {
|
|
84368
|
+
return psOutputHasInstaller(await (deps.runPs ?? runPsDefault)(), selfPid);
|
|
84369
|
+
} catch {
|
|
84370
|
+
return true;
|
|
84371
|
+
}
|
|
84372
|
+
}
|
|
84373
|
+
|
|
83618
84374
|
// aware-update-jobs.ts
|
|
83619
84375
|
var AwareUpdateConflictError = class extends Error {
|
|
83620
84376
|
status = 409;
|
|
@@ -84409,16 +85165,16 @@ function registerDebugNodeRoute(app, deps) {
|
|
|
84409
85165
|
}
|
|
84410
85166
|
|
|
84411
85167
|
// terminal-run.ts
|
|
84412
|
-
var import_node_child_process14 = require("node:child_process");
|
|
84413
85168
|
var import_node_child_process15 = require("node:child_process");
|
|
84414
|
-
var
|
|
85169
|
+
var import_node_child_process16 = require("node:child_process");
|
|
85170
|
+
var import_node_fs72 = require("node:fs");
|
|
84415
85171
|
var import_node_crypto40 = require("node:crypto");
|
|
84416
85172
|
var import_node_os36 = require("node:os");
|
|
84417
85173
|
var import_node_path67 = require("node:path");
|
|
84418
85174
|
|
|
84419
85175
|
// run-file-relay.ts
|
|
84420
85176
|
var import_node_crypto39 = require("node:crypto");
|
|
84421
|
-
var
|
|
85177
|
+
var import_node_fs69 = require("node:fs");
|
|
84422
85178
|
var import_node_path64 = require("node:path");
|
|
84423
85179
|
var import_yaml11 = __toESM(require_dist6(), 1);
|
|
84424
85180
|
var SAFE_APP_ID2 = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
|
|
@@ -84459,21 +85215,21 @@ function createRunFileRelay(options) {
|
|
|
84459
85215
|
const validateRoot = (0, import_node_path64.join)(options.journalRoot, `.validate-${safeLease2(options.leaseId)}-${(0, import_node_crypto39.randomUUID)()}`);
|
|
84460
85216
|
const validateAppDir = (0, import_node_path64.join)(validateRoot, options.appId);
|
|
84461
85217
|
const validateSourcePath = (0, import_node_path64.join)(validateAppDir, `${options.appId}.flo`);
|
|
84462
|
-
(0,
|
|
85218
|
+
(0, import_node_fs69.mkdirSync)(validateAppDir, { recursive: true, mode: 448 });
|
|
84463
85219
|
try {
|
|
84464
|
-
(0,
|
|
85220
|
+
(0, import_node_fs69.writeFileSync)(validateSourcePath, candidate, { encoding: "utf8", mode: 384, flag: "wx" });
|
|
84465
85221
|
await options.validateCandidate({ appDir: validateAppDir, sourcePath: validateSourcePath });
|
|
84466
85222
|
} finally {
|
|
84467
|
-
(0,
|
|
85223
|
+
(0, import_node_fs69.rmSync)(validateRoot, { recursive: true, force: true });
|
|
84468
85224
|
}
|
|
84469
85225
|
const afterValidation = readSnapshot(options);
|
|
84470
85226
|
if (afterValidation.sha256 !== before.sha256 || !sameIdentity(afterValidation.identity, before.identity)) {
|
|
84471
85227
|
throw new RunFileRelayError("the workflow changed while the proposal was being validated; read it again");
|
|
84472
85228
|
}
|
|
84473
|
-
(0,
|
|
85229
|
+
(0, import_node_fs69.mkdirSync)(options.journalRoot, { recursive: true, mode: 448 });
|
|
84474
85230
|
const journalDir = (0, import_node_path64.join)(options.journalRoot, safeLease2(options.leaseId));
|
|
84475
85231
|
try {
|
|
84476
|
-
(0,
|
|
85232
|
+
(0, import_node_fs69.mkdirSync)(journalDir, { mode: 448 });
|
|
84477
85233
|
} catch (err2) {
|
|
84478
85234
|
if (err2.code === "EEXIST") {
|
|
84479
85235
|
throw new RunFileRelayError("this run already has a staged candidate");
|
|
@@ -84511,7 +85267,7 @@ function createRunFileRelay(options) {
|
|
|
84511
85267
|
syncDirectoryBestEffort(options.journalRoot);
|
|
84512
85268
|
drainAuditOutbox(options, (0, import_node_path64.join)(journalDir, "journal.json"));
|
|
84513
85269
|
} catch (err2) {
|
|
84514
|
-
(0,
|
|
85270
|
+
(0, import_node_fs69.rmSync)(journalDir, { recursive: true, force: true });
|
|
84515
85271
|
throw err2;
|
|
84516
85272
|
}
|
|
84517
85273
|
return { baseSha256: before.sha256, candidateSha256, journalDir };
|
|
@@ -84543,7 +85299,7 @@ function createRunFileRelay(options) {
|
|
|
84543
85299
|
if (journal.value.state !== "final-ok") throw new RunFileRelayError("the staged candidate has no durable final-ok result");
|
|
84544
85300
|
const candidatePath = (0, import_node_path64.join)(journal.dir, "candidate.flo");
|
|
84545
85301
|
rejectLink2(candidatePath, "staged candidate");
|
|
84546
|
-
const candidateBytes = (0,
|
|
85302
|
+
const candidateBytes = (0, import_node_fs69.readFileSync)(candidatePath);
|
|
84547
85303
|
if (candidateBytes.length > MAX_SOURCE_BYTES) throw new RunFileRelayError("the staged candidate is too large");
|
|
84548
85304
|
new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(candidateBytes);
|
|
84549
85305
|
const candidateSha256 = hash2(candidateBytes);
|
|
@@ -84554,7 +85310,7 @@ function createRunFileRelay(options) {
|
|
|
84554
85310
|
}
|
|
84555
85311
|
const lockPath2 = live.sourcePath.replace(/\.(flo|app|flow|aware)$/i, ".lock");
|
|
84556
85312
|
const sourceBefore = Buffer.from(live.source, "utf8");
|
|
84557
|
-
const lockBefore = (0,
|
|
85313
|
+
const lockBefore = (0, import_node_fs69.existsSync)(lockPath2) ? readRegularFile(lockPath2, MAX_SOURCE_BYTES, "workflow lock") : null;
|
|
84558
85314
|
let mutated = false;
|
|
84559
85315
|
try {
|
|
84560
85316
|
durableWrite3((0, import_node_path64.join)(journal.dir, "source.before"), sourceBefore);
|
|
@@ -84575,12 +85331,12 @@ function createRunFileRelay(options) {
|
|
|
84575
85331
|
}, "source-written", { oldHash: journal.value.baseSha256, newHash: candidateSha256 }));
|
|
84576
85332
|
drainAuditOutbox(options, journal.path);
|
|
84577
85333
|
const compiled = await deps.compile(live.sourcePath);
|
|
84578
|
-
if (hash2((0,
|
|
85334
|
+
if (hash2((0, import_node_fs69.readFileSync)(live.sourcePath)) !== candidateSha256) {
|
|
84579
85335
|
throw new RunFileRelayError("the compiler did not compile the exact staged source bytes");
|
|
84580
85336
|
}
|
|
84581
85337
|
const producedLock = compiled.lockPath ?? lockPath2;
|
|
84582
85338
|
rejectLink2(producedLock, "compiled workflow lock");
|
|
84583
|
-
const realLock =
|
|
85339
|
+
const realLock = import_node_fs69.realpathSync.native(producedLock);
|
|
84584
85340
|
const expectedLock = (0, import_node_path64.resolve)(lockPath2);
|
|
84585
85341
|
const norm2 = (value) => process.platform === "win32" ? value.toLowerCase() : value;
|
|
84586
85342
|
if (norm2(realLock) !== norm2(expectedLock)) throw new RunFileRelayError("the compiler wrote an unexpected lock path");
|
|
@@ -84637,7 +85393,7 @@ function createRunFileRelay(options) {
|
|
|
84637
85393
|
try {
|
|
84638
85394
|
live = readSnapshot(options);
|
|
84639
85395
|
const lockPath2 = live.sourcePath.replace(/\.(flo|app|flow|aware)$/i, ".lock");
|
|
84640
|
-
currentLock = (0,
|
|
85396
|
+
currentLock = (0, import_node_fs69.existsSync)(lockPath2) ? readRegularFile(lockPath2, MAX_SOURCE_BYTES, "workflow lock") : null;
|
|
84641
85397
|
} catch (error) {
|
|
84642
85398
|
throw new RunFileRelayError(
|
|
84643
85399
|
`the live workflow generation cannot be verified; automatic recovery refused: ${String(error?.message ?? error)}`,
|
|
@@ -84654,7 +85410,7 @@ function createRunFileRelay(options) {
|
|
|
84654
85410
|
}
|
|
84655
85411
|
if (journal.value.state === "compiled") {
|
|
84656
85412
|
const receiptPath = (0, import_node_path64.join)(journal.dir, "receipt.json");
|
|
84657
|
-
if ((0,
|
|
85413
|
+
if ((0, import_node_fs69.existsSync)(receiptPath)) verifyReceipt(options, journal.dir, journal.value);
|
|
84658
85414
|
else writeReceipt(options, journal.dir, journal.value);
|
|
84659
85415
|
writeJournal(journal.path, withAudit(options, {
|
|
84660
85416
|
...readJournal(options).value,
|
|
@@ -84670,7 +85426,7 @@ function createRunFileRelay(options) {
|
|
|
84670
85426
|
};
|
|
84671
85427
|
const discardStage = () => {
|
|
84672
85428
|
const dir = (0, import_node_path64.join)(options.journalRoot, safeLease2(options.leaseId));
|
|
84673
|
-
if (!(0,
|
|
85429
|
+
if (!(0, import_node_fs69.existsSync)(dir)) return;
|
|
84674
85430
|
const journal = readJournal(options);
|
|
84675
85431
|
if (!["staged", "final-ok", "rolled-back"].includes(journal.value.state)) {
|
|
84676
85432
|
throw new RunFileRelayError(
|
|
@@ -84692,7 +85448,7 @@ function createRunFileRelay(options) {
|
|
|
84692
85448
|
}
|
|
84693
85449
|
drainAuditOutbox(options, journal.path);
|
|
84694
85450
|
if (readJournal(options).value.auditOutbox.length) return;
|
|
84695
|
-
(0,
|
|
85451
|
+
(0, import_node_fs69.rmSync)(dir, { recursive: true, force: true });
|
|
84696
85452
|
};
|
|
84697
85453
|
const cleanupCompleted = () => {
|
|
84698
85454
|
const journal = readJournal(options);
|
|
@@ -84703,7 +85459,7 @@ function createRunFileRelay(options) {
|
|
|
84703
85459
|
const drained = readJournal(options);
|
|
84704
85460
|
if (drained.value.auditOutbox.length) throw new RunFileRelayError("run audit outbox is not drained");
|
|
84705
85461
|
verifyReceipt(options, drained.dir, drained.value);
|
|
84706
|
-
(0,
|
|
85462
|
+
(0, import_node_fs69.rmSync)(drained.dir, { recursive: true, force: true });
|
|
84707
85463
|
syncDirectoryBestEffort(options.journalRoot);
|
|
84708
85464
|
};
|
|
84709
85465
|
const recordPublicationCommitted = () => {
|
|
@@ -84732,7 +85488,7 @@ function createRunFileRelay(options) {
|
|
|
84732
85488
|
}
|
|
84733
85489
|
function readRunFileJournalIdentity(journalRoot, leaseId) {
|
|
84734
85490
|
const dir = (0, import_node_path64.join)(journalRoot, safeLease2(leaseId));
|
|
84735
|
-
if (!(0,
|
|
85491
|
+
if (!(0, import_node_fs69.existsSync)(dir)) return null;
|
|
84736
85492
|
rejectLink2(dir, "run journal");
|
|
84737
85493
|
const path = (0, import_node_path64.join)(dir, "journal.json");
|
|
84738
85494
|
rejectLink2(path, "run journal record");
|
|
@@ -84754,7 +85510,7 @@ function readJournal(options) {
|
|
|
84754
85510
|
rejectLink2(path, "run journal record");
|
|
84755
85511
|
let value;
|
|
84756
85512
|
try {
|
|
84757
|
-
value = JSON.parse((0,
|
|
85513
|
+
value = JSON.parse((0, import_node_fs69.readFileSync)(path, "utf8"));
|
|
84758
85514
|
} catch {
|
|
84759
85515
|
throw new RunFileRelayError("run journal is missing or malformed");
|
|
84760
85516
|
}
|
|
@@ -84816,7 +85572,7 @@ function verifyReceipt(options, dir, journal) {
|
|
|
84816
85572
|
rejectLink2(path, "run settlement receipt");
|
|
84817
85573
|
let value;
|
|
84818
85574
|
try {
|
|
84819
|
-
value = JSON.parse((0,
|
|
85575
|
+
value = JSON.parse((0, import_node_fs69.readFileSync)(path, "utf8"));
|
|
84820
85576
|
} catch {
|
|
84821
85577
|
throw new RunFileRelayError("run settlement receipt is malformed");
|
|
84822
85578
|
}
|
|
@@ -84841,8 +85597,8 @@ function restoreBefore(options, journal) {
|
|
|
84841
85597
|
const lockPath2 = live.sourcePath.replace(/\.(flo|app|flow|aware)$/i, ".lock");
|
|
84842
85598
|
const beforeLock = (0, import_node_path64.join)(journal.dir, "lock.before");
|
|
84843
85599
|
const absent = (0, import_node_path64.join)(journal.dir, "lock.absent");
|
|
84844
|
-
const beforeLockBytes = (0,
|
|
84845
|
-
if (!beforeLockBytes && !(0,
|
|
85600
|
+
const beforeLockBytes = (0, import_node_fs69.existsSync)(beforeLock) ? readRegularFile(beforeLock, MAX_SOURCE_BYTES, "lock snapshot") : null;
|
|
85601
|
+
if (!beforeLockBytes && !(0, import_node_fs69.existsSync)(absent)) throw new RunFileRelayError("run journal has no prior lock snapshot");
|
|
84846
85602
|
const ownedSourceHashes = /* @__PURE__ */ new Set([journal.value.baseSha256, journal.value.candidateSha256]);
|
|
84847
85603
|
if (typeof journal.value.sourceSha256 === "string") ownedSourceHashes.add(journal.value.sourceSha256);
|
|
84848
85604
|
if (!ownedSourceHashes.has(live.sha256)) {
|
|
@@ -84850,7 +85606,7 @@ function restoreBefore(options, journal) {
|
|
|
84850
85606
|
}
|
|
84851
85607
|
let currentLock = null;
|
|
84852
85608
|
try {
|
|
84853
|
-
currentLock = (0,
|
|
85609
|
+
currentLock = (0, import_node_fs69.existsSync)(lockPath2) ? readRegularFile(lockPath2, MAX_SOURCE_BYTES, "workflow lock") : null;
|
|
84854
85610
|
} catch (error) {
|
|
84855
85611
|
throw new RunFileRelayError(
|
|
84856
85612
|
`the live workflow lock cannot be attributed to this transaction; automatic rollback refused: ${String(error?.message ?? error)}`,
|
|
@@ -84866,11 +85622,11 @@ function restoreBefore(options, journal) {
|
|
|
84866
85622
|
}
|
|
84867
85623
|
durableReplace4(live.sourcePath, sourceBefore);
|
|
84868
85624
|
if (beforeLockBytes) durableReplace4(lockPath2, beforeLockBytes);
|
|
84869
|
-
else if ((0,
|
|
84870
|
-
if ((0,
|
|
85625
|
+
else if ((0, import_node_fs69.existsSync)(absent)) {
|
|
85626
|
+
if ((0, import_node_fs69.existsSync)(lockPath2)) (0, import_node_fs69.rmSync)(lockPath2, { force: true });
|
|
84871
85627
|
}
|
|
84872
85628
|
try {
|
|
84873
|
-
(0,
|
|
85629
|
+
(0, import_node_fs69.rmSync)((0, import_node_path64.join)(journal.dir, "receipt.json"), { force: true });
|
|
84874
85630
|
} catch {
|
|
84875
85631
|
}
|
|
84876
85632
|
writeJournal(journal.path, withAudit(options, {
|
|
@@ -84883,21 +85639,21 @@ function restoreBefore(options, journal) {
|
|
|
84883
85639
|
function readSnapshot(options) {
|
|
84884
85640
|
assertIdentifiers(options);
|
|
84885
85641
|
const appsRootInput = (0, import_node_path64.resolve)(options.appsRoot);
|
|
84886
|
-
if (!(0,
|
|
85642
|
+
if (!(0, import_node_fs69.existsSync)(appsRootInput)) throw new RunFileRelayError("the AWARE apps root does not exist");
|
|
84887
85643
|
rejectLink2(appsRootInput, "AWARE apps root");
|
|
84888
|
-
const appsRoot =
|
|
85644
|
+
const appsRoot = import_node_fs69.realpathSync.native(appsRootInput);
|
|
84889
85645
|
const appDirInput = (0, import_node_path64.join)(appsRoot, options.appId);
|
|
84890
85646
|
rejectLink2(appDirInput, "app directory");
|
|
84891
|
-
const appDir2 =
|
|
85647
|
+
const appDir2 = import_node_fs69.realpathSync.native(appDirInput);
|
|
84892
85648
|
if (!isInside(appsRoot, appDir2)) throw new RunFileRelayError("the app directory escapes the AWARE apps root");
|
|
84893
85649
|
const sourceInput = (0, import_node_path64.join)(appDir2, `${options.appId}.flo`);
|
|
84894
85650
|
rejectLink2(sourceInput, "workflow source");
|
|
84895
|
-
const sourcePath2 =
|
|
85651
|
+
const sourcePath2 = import_node_fs69.realpathSync.native(sourceInput);
|
|
84896
85652
|
if (!isInside(appDir2, sourcePath2)) throw new RunFileRelayError("the workflow source escapes its app directory");
|
|
84897
|
-
const st = (0,
|
|
85653
|
+
const st = (0, import_node_fs69.statSync)(sourcePath2);
|
|
84898
85654
|
if (!st.isFile()) throw new RunFileRelayError("the workflow source is not a regular file");
|
|
84899
85655
|
if (st.size > MAX_SOURCE_BYTES) throw new RunFileRelayError("the workflow source is too large");
|
|
84900
|
-
const bytes = (0,
|
|
85656
|
+
const bytes = (0, import_node_fs69.readFileSync)(sourcePath2);
|
|
84901
85657
|
let source;
|
|
84902
85658
|
try {
|
|
84903
85659
|
source = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(bytes);
|
|
@@ -84986,7 +85742,7 @@ function safeLease2(value) {
|
|
|
84986
85742
|
function rejectLink2(path, label2) {
|
|
84987
85743
|
let st;
|
|
84988
85744
|
try {
|
|
84989
|
-
st = (0,
|
|
85745
|
+
st = (0, import_node_fs69.lstatSync)(path);
|
|
84990
85746
|
} catch {
|
|
84991
85747
|
throw new RunFileRelayError(`${label2} does not exist`);
|
|
84992
85748
|
}
|
|
@@ -85007,40 +85763,40 @@ function hash2(value) {
|
|
|
85007
85763
|
}
|
|
85008
85764
|
function readRegularFile(path, maxBytes, label2) {
|
|
85009
85765
|
rejectLink2(path, label2);
|
|
85010
|
-
const st = (0,
|
|
85766
|
+
const st = (0, import_node_fs69.statSync)(path);
|
|
85011
85767
|
if (!st.isFile()) throw new RunFileRelayError(`${label2} is not a regular file`);
|
|
85012
85768
|
if (st.size > maxBytes) throw new RunFileRelayError(`${label2} is too large`);
|
|
85013
|
-
return (0,
|
|
85769
|
+
return (0, import_node_fs69.readFileSync)(path);
|
|
85014
85770
|
}
|
|
85015
85771
|
function durableWrite3(path, value) {
|
|
85016
85772
|
const tmp = `${path}.${process.pid}.${(0, import_node_crypto39.randomUUID)()}.tmp`;
|
|
85017
|
-
const fd2 = (0,
|
|
85773
|
+
const fd2 = (0, import_node_fs69.openSync)(tmp, "wx", 384);
|
|
85018
85774
|
try {
|
|
85019
|
-
(0,
|
|
85020
|
-
(0,
|
|
85775
|
+
(0, import_node_fs69.writeFileSync)(fd2, value);
|
|
85776
|
+
(0, import_node_fs69.fsyncSync)(fd2);
|
|
85021
85777
|
} finally {
|
|
85022
|
-
(0,
|
|
85778
|
+
(0, import_node_fs69.closeSync)(fd2);
|
|
85023
85779
|
}
|
|
85024
|
-
(0,
|
|
85780
|
+
(0, import_node_fs69.renameSync)(tmp, path);
|
|
85025
85781
|
syncFile(path);
|
|
85026
85782
|
syncDirectoryBestEffort((0, import_node_path64.dirname)(path));
|
|
85027
85783
|
}
|
|
85028
85784
|
function durableReplace4(path, value) {
|
|
85029
85785
|
const tmp = `${path}.${process.pid}.${(0, import_node_crypto39.randomUUID)()}.tmp`;
|
|
85030
|
-
const fd2 = (0,
|
|
85786
|
+
const fd2 = (0, import_node_fs69.openSync)(tmp, "wx", 384);
|
|
85031
85787
|
try {
|
|
85032
|
-
(0,
|
|
85033
|
-
(0,
|
|
85788
|
+
(0, import_node_fs69.writeFileSync)(fd2, value);
|
|
85789
|
+
(0, import_node_fs69.fsyncSync)(fd2);
|
|
85034
85790
|
} finally {
|
|
85035
|
-
(0,
|
|
85791
|
+
(0, import_node_fs69.closeSync)(fd2);
|
|
85036
85792
|
}
|
|
85037
|
-
(0,
|
|
85793
|
+
(0, import_node_fs69.renameSync)(tmp, path);
|
|
85038
85794
|
syncFile(path);
|
|
85039
85795
|
syncDirectoryBestEffort((0, import_node_path64.dirname)(path));
|
|
85040
85796
|
}
|
|
85041
85797
|
|
|
85042
85798
|
// skill-sync.ts
|
|
85043
|
-
var
|
|
85799
|
+
var import_node_fs70 = require("node:fs");
|
|
85044
85800
|
var import_node_os35 = require("node:os");
|
|
85045
85801
|
var import_node_path65 = require("node:path");
|
|
85046
85802
|
var import_node_url4 = require("node:url");
|
|
@@ -85083,8 +85839,8 @@ var PRODUCT_SKILLS = [
|
|
|
85083
85839
|
"steel-drawing-abbreviations"
|
|
85084
85840
|
// default US/AISC abbreviations+shapes legend (non-namespace) the steel reader falls back to when a set omits its own legend sheet
|
|
85085
85841
|
];
|
|
85086
|
-
function selectShippedSkillNames(
|
|
85087
|
-
const present = new Set(
|
|
85842
|
+
function selectShippedSkillNames(names2) {
|
|
85843
|
+
const present = new Set(names2);
|
|
85088
85844
|
return PRODUCT_SKILLS.filter((name) => present.has(name));
|
|
85089
85845
|
}
|
|
85090
85846
|
|
|
@@ -85096,7 +85852,7 @@ function bundledSkillsRoot() {
|
|
|
85096
85852
|
(0, import_node_path65.join)((0, import_node_path65.dirname)(process.execPath), "skills"),
|
|
85097
85853
|
(0, import_node_path65.join)(__dirname3, "..", ".claude", "skills")
|
|
85098
85854
|
];
|
|
85099
|
-
return candidates.find((p) => (0,
|
|
85855
|
+
return candidates.find((p) => (0, import_node_fs70.existsSync)(p)) ?? null;
|
|
85100
85856
|
}
|
|
85101
85857
|
function targetConfigDirs() {
|
|
85102
85858
|
const override = process.env.FLOLESS_SKILL_TARGETS;
|
|
@@ -85112,8 +85868,8 @@ function targetConfigDirs() {
|
|
|
85112
85868
|
}
|
|
85113
85869
|
function skillVersion(skillMdPath) {
|
|
85114
85870
|
try {
|
|
85115
|
-
const
|
|
85116
|
-
const m = /^---\r?\n([\s\S]*?)\r?\n---/.exec(
|
|
85871
|
+
const text5 = (0, import_node_fs70.readFileSync)(skillMdPath, "utf8");
|
|
85872
|
+
const m = /^---\r?\n([\s\S]*?)\r?\n---/.exec(text5);
|
|
85117
85873
|
if (!m || m[1] === void 0) return null;
|
|
85118
85874
|
const fm = (0, import_yaml12.parse)(m[1]);
|
|
85119
85875
|
const meta = fm?.metadata;
|
|
@@ -85152,7 +85908,7 @@ function decideAction(installed, bundled) {
|
|
|
85152
85908
|
function bundledSkills(root6) {
|
|
85153
85909
|
let entries = [];
|
|
85154
85910
|
try {
|
|
85155
|
-
entries = selectShippedSkillNames((0,
|
|
85911
|
+
entries = selectShippedSkillNames((0, import_node_fs70.readdirSync)(root6));
|
|
85156
85912
|
} catch {
|
|
85157
85913
|
return [];
|
|
85158
85914
|
}
|
|
@@ -85161,7 +85917,7 @@ function bundledSkills(root6) {
|
|
|
85161
85917
|
const dir = (0, import_node_path65.join)(root6, name);
|
|
85162
85918
|
let isDir = false;
|
|
85163
85919
|
try {
|
|
85164
|
-
isDir = (0,
|
|
85920
|
+
isDir = (0, import_node_fs70.statSync)(dir).isDirectory();
|
|
85165
85921
|
} catch {
|
|
85166
85922
|
isDir = false;
|
|
85167
85923
|
}
|
|
@@ -85179,17 +85935,17 @@ function syncSkills() {
|
|
|
85179
85935
|
const skills = bundledSkills(root6);
|
|
85180
85936
|
if (!skills.length) return results;
|
|
85181
85937
|
for (const { runtime, dir: cfg } of targetConfigDirs()) {
|
|
85182
|
-
if (!(0,
|
|
85938
|
+
if (!(0, import_node_fs70.existsSync)(cfg)) continue;
|
|
85183
85939
|
const skillsDir = (0, import_node_path65.join)(cfg, "skills");
|
|
85184
85940
|
for (const s of skills) {
|
|
85185
85941
|
const dest = (0, import_node_path65.join)(skillsDir, s.name);
|
|
85186
85942
|
const installedMd = (0, import_node_path65.join)(dest, "SKILL.md");
|
|
85187
|
-
const installed = (0,
|
|
85943
|
+
const installed = (0, import_node_fs70.existsSync)(installedMd) ? skillVersion(installedMd) : null;
|
|
85188
85944
|
const action = decideAction(installed, s.version);
|
|
85189
85945
|
if (action === "installed" || action === "updated") {
|
|
85190
85946
|
try {
|
|
85191
|
-
if (action === "updated") (0,
|
|
85192
|
-
(0,
|
|
85947
|
+
if (action === "updated") (0, import_node_fs70.rmSync)(dest, { recursive: true, force: true });
|
|
85948
|
+
(0, import_node_fs70.cpSync)(s.dir, dest, { recursive: true });
|
|
85193
85949
|
results.push({ runtime, skill: s.name, action, from: installed, to: s.version });
|
|
85194
85950
|
} catch {
|
|
85195
85951
|
}
|
|
@@ -85202,7 +85958,7 @@ function syncSkills() {
|
|
|
85202
85958
|
}
|
|
85203
85959
|
|
|
85204
85960
|
// run-skill-relay.ts
|
|
85205
|
-
var
|
|
85961
|
+
var import_node_fs71 = require("node:fs");
|
|
85206
85962
|
var import_node_path66 = require("node:path");
|
|
85207
85963
|
var MAX_RESOURCE_BYTES = 256 * 1024;
|
|
85208
85964
|
var SAFE_SKILL = /^floless-app-[a-z0-9][a-z0-9-]*$/;
|
|
@@ -85239,15 +85995,15 @@ function createRunSkillReader(options) {
|
|
|
85239
85995
|
const candidate = (0, import_node_path66.resolve)(skillRoot, ...segments);
|
|
85240
85996
|
let real;
|
|
85241
85997
|
try {
|
|
85242
|
-
real =
|
|
85998
|
+
real = import_node_fs71.realpathSync.native(candidate);
|
|
85243
85999
|
} catch {
|
|
85244
86000
|
throw new RunSkillRelayError("skill resource not found");
|
|
85245
86001
|
}
|
|
85246
86002
|
if (!isInside(skillRoot, real)) throw new RunSkillRelayError("resource escapes the selected skill");
|
|
85247
|
-
const st = (0,
|
|
86003
|
+
const st = (0, import_node_fs71.statSync)(real);
|
|
85248
86004
|
if (!st.isFile()) throw new RunSkillRelayError("skill resource is not a regular file");
|
|
85249
86005
|
if (st.size > MAX_RESOURCE_BYTES) throw new RunSkillRelayError("skill resource is too large");
|
|
85250
|
-
const bytes = (0,
|
|
86006
|
+
const bytes = (0, import_node_fs71.readFileSync)(real);
|
|
85251
86007
|
try {
|
|
85252
86008
|
return new TextDecoder("utf-8", { fatal: true }).decode(bytes);
|
|
85253
86009
|
} catch {
|
|
@@ -85260,17 +86016,17 @@ function checkedDirectory(path, label2) {
|
|
|
85260
86016
|
rejectLink3(path, label2);
|
|
85261
86017
|
let real;
|
|
85262
86018
|
try {
|
|
85263
|
-
real =
|
|
86019
|
+
real = import_node_fs71.realpathSync.native(path);
|
|
85264
86020
|
} catch {
|
|
85265
86021
|
throw new RunSkillRelayError(`${label2} not found`);
|
|
85266
86022
|
}
|
|
85267
|
-
if (!(0,
|
|
86023
|
+
if (!(0, import_node_fs71.statSync)(real).isDirectory()) throw new RunSkillRelayError(`${label2} is not a directory`);
|
|
85268
86024
|
return real;
|
|
85269
86025
|
}
|
|
85270
86026
|
function rejectLink3(path, label2) {
|
|
85271
86027
|
let st;
|
|
85272
86028
|
try {
|
|
85273
|
-
st = (0,
|
|
86029
|
+
st = (0, import_node_fs71.lstatSync)(path);
|
|
85274
86030
|
} catch {
|
|
85275
86031
|
throw new RunSkillRelayError(`${label2} not found`);
|
|
85276
86032
|
}
|
|
@@ -85321,7 +86077,7 @@ async function killTreeAndVerify(pid, procStartedAt) {
|
|
|
85321
86077
|
}
|
|
85322
86078
|
if (WIN3) {
|
|
85323
86079
|
try {
|
|
85324
|
-
(0,
|
|
86080
|
+
(0, import_node_child_process16.execFileSync)("taskkill", ["/pid", String(pid), "/T", "/F"], { stdio: "ignore", windowsHide: true, timeout: 1e4 });
|
|
85325
86081
|
} catch {
|
|
85326
86082
|
}
|
|
85327
86083
|
} else {
|
|
@@ -85488,14 +86244,14 @@ async function finish(deps, lease, patch2, options = {}) {
|
|
|
85488
86244
|
var mcpDir = () => (0, import_node_path67.join)(process.env.FLOLESS_HOME ?? (0, import_node_path67.join)((0, import_node_os36.homedir)(), ".floless"), "run-mcp");
|
|
85489
86245
|
var mcpPath = (leaseId) => (0, import_node_path67.join)(mcpDir(), `${leaseId}.json`);
|
|
85490
86246
|
function writeMcpConfig(lease) {
|
|
85491
|
-
(0,
|
|
86247
|
+
(0, import_node_fs72.mkdirSync)(mcpDir(), { recursive: true });
|
|
85492
86248
|
const p = mcpPath(lease.leaseId);
|
|
85493
|
-
(0,
|
|
86249
|
+
(0, import_node_fs72.writeFileSync)(p, JSON.stringify(mcpConfigFor(lease.token, selfOrigin()), null, 2), { mode: 384 });
|
|
85494
86250
|
return p;
|
|
85495
86251
|
}
|
|
85496
86252
|
function cleanupMcpConfig(leaseId) {
|
|
85497
86253
|
try {
|
|
85498
|
-
(0,
|
|
86254
|
+
(0, import_node_fs72.rmSync)(mcpPath(leaseId));
|
|
85499
86255
|
} catch {
|
|
85500
86256
|
}
|
|
85501
86257
|
}
|
|
@@ -85566,8 +86322,8 @@ function verifyRevisionSources(deps, lease) {
|
|
|
85566
86322
|
req.sourceRefs.forEach((ref, index) => {
|
|
85567
86323
|
const path = (deps.sourcePathFor ?? snapshotPathFor)(req.id, index);
|
|
85568
86324
|
if (!path || ref.ext.toLowerCase() !== "pdf") throw new Error("the queued revision PDF set no longer matches this run");
|
|
85569
|
-
const data = (0,
|
|
85570
|
-
if (data.length !== ref.bytes || (0,
|
|
86325
|
+
const data = (0, import_node_fs72.readFileSync)(path);
|
|
86326
|
+
if (data.length !== ref.bytes || (0, import_node_fs72.statSync)(path).size !== ref.bytes || (0, import_node_crypto40.createHash)("sha256").update(data).digest("hex") !== ref.sha256) {
|
|
85571
86327
|
throw new Error("the queued PDF source changed after this run was claimed");
|
|
85572
86328
|
}
|
|
85573
86329
|
});
|
|
@@ -86087,7 +86843,7 @@ function start(deps, lease, plan) {
|
|
|
86087
86843
|
function defaultSpawn(file, args, cwd, env2) {
|
|
86088
86844
|
const batch = WIN3 && /\.(cmd|bat)$/i.test(file);
|
|
86089
86845
|
const [exe2, argv] = batch ? ["cmd.exe", ["/c", file, ...args]] : [file, [...args]];
|
|
86090
|
-
return (0,
|
|
86846
|
+
return (0, import_node_child_process15.spawn)(exe2, argv, {
|
|
86091
86847
|
cwd,
|
|
86092
86848
|
// `windowsHide` for the same reason `aware-adapter.ts` carries it: no console window flashes on
|
|
86093
86849
|
// the user's desktop. Its cost is F4's — a login prompt would be drawn on a window that does not
|
|
@@ -86104,7 +86860,7 @@ function defaultRuntimeVersion(file, args) {
|
|
|
86104
86860
|
const batch = WIN3 && /\.(cmd|bat)$/i.test(file);
|
|
86105
86861
|
const exe2 = batch ? "cmd.exe" : file;
|
|
86106
86862
|
const argv = batch ? ["/d", "/s", "/c", file, ...args] : [...args];
|
|
86107
|
-
return (0,
|
|
86863
|
+
return (0, import_node_child_process16.execFileSync)(exe2, argv, { encoding: "utf8", windowsHide: true, timeout: 1e4 }).trim();
|
|
86108
86864
|
}
|
|
86109
86865
|
var tail = (s) => (s.length > MAX_TAIL ? s.slice(-MAX_TAIL) : s).trim();
|
|
86110
86866
|
async function settle(deps, lease, code, out, err2, sessionCaptureError = null) {
|
|
@@ -86441,16 +87197,16 @@ async function stopAllRuns(deps) {
|
|
|
86441
87197
|
// watch.ts
|
|
86442
87198
|
var import_node_os37 = require("node:os");
|
|
86443
87199
|
var import_node_path69 = require("node:path");
|
|
86444
|
-
var
|
|
87200
|
+
var import_node_fs73 = require("node:fs");
|
|
86445
87201
|
|
|
86446
87202
|
// node_modules/chokidar/esm/index.js
|
|
86447
87203
|
var import_fs2 = require("fs");
|
|
86448
|
-
var
|
|
87204
|
+
var import_promises11 = require("fs/promises");
|
|
86449
87205
|
var import_events = require("events");
|
|
86450
87206
|
var sysPath2 = __toESM(require("path"), 1);
|
|
86451
87207
|
|
|
86452
87208
|
// node_modules/readdirp/esm/index.js
|
|
86453
|
-
var
|
|
87209
|
+
var import_promises9 = require("node:fs/promises");
|
|
86454
87210
|
var import_node_stream4 = require("node:stream");
|
|
86455
87211
|
var import_node_path68 = require("node:path");
|
|
86456
87212
|
var EntryTypes = {
|
|
@@ -86491,7 +87247,7 @@ var FILE_TYPES = /* @__PURE__ */ new Set([
|
|
|
86491
87247
|
var isNormalFlowError = (error) => NORMAL_FLOW_ERRORS.has(error.code);
|
|
86492
87248
|
var wantBigintFsStats = process.platform === "win32";
|
|
86493
87249
|
var emptyFn = (_entryInfo) => true;
|
|
86494
|
-
var
|
|
87250
|
+
var normalizeFilter3 = (filter) => {
|
|
86495
87251
|
if (filter === void 0)
|
|
86496
87252
|
return emptyFn;
|
|
86497
87253
|
if (typeof filter === "function")
|
|
@@ -86515,9 +87271,9 @@ var ReaddirpStream = class extends import_node_stream4.Readable {
|
|
|
86515
87271
|
});
|
|
86516
87272
|
const opts = { ...defaultOptions, ...options };
|
|
86517
87273
|
const { root: root6, type } = opts;
|
|
86518
|
-
this._fileFilter =
|
|
86519
|
-
this._directoryFilter =
|
|
86520
|
-
const statMethod = opts.lstat ?
|
|
87274
|
+
this._fileFilter = normalizeFilter3(opts.fileFilter);
|
|
87275
|
+
this._directoryFilter = normalizeFilter3(opts.directoryFilter);
|
|
87276
|
+
const statMethod = opts.lstat ? import_promises9.lstat : import_promises9.stat;
|
|
86521
87277
|
if (wantBigintFsStats) {
|
|
86522
87278
|
this._stat = (path) => statMethod(path, { bigint: true });
|
|
86523
87279
|
} else {
|
|
@@ -86588,7 +87344,7 @@ var ReaddirpStream = class extends import_node_stream4.Readable {
|
|
|
86588
87344
|
async _exploreDir(path, depth) {
|
|
86589
87345
|
let files2;
|
|
86590
87346
|
try {
|
|
86591
|
-
files2 = await (0,
|
|
87347
|
+
files2 = await (0, import_promises9.readdir)(path, this._rdOptions);
|
|
86592
87348
|
} catch (error) {
|
|
86593
87349
|
this._onError(error);
|
|
86594
87350
|
}
|
|
@@ -86626,8 +87382,8 @@ var ReaddirpStream = class extends import_node_stream4.Readable {
|
|
|
86626
87382
|
if (stats && stats.isSymbolicLink()) {
|
|
86627
87383
|
const full = entry2.fullPath;
|
|
86628
87384
|
try {
|
|
86629
|
-
const entryRealPath = await (0,
|
|
86630
|
-
const entryRealPathStats = await (0,
|
|
87385
|
+
const entryRealPath = await (0, import_promises9.realpath)(full);
|
|
87386
|
+
const entryRealPathStats = await (0, import_promises9.lstat)(entryRealPath);
|
|
86631
87387
|
if (entryRealPathStats.isFile()) {
|
|
86632
87388
|
return "file";
|
|
86633
87389
|
}
|
|
@@ -86670,7 +87426,7 @@ function readdirp(root6, options = {}) {
|
|
|
86670
87426
|
|
|
86671
87427
|
// node_modules/chokidar/esm/handler.js
|
|
86672
87428
|
var import_fs = require("fs");
|
|
86673
|
-
var
|
|
87429
|
+
var import_promises10 = require("fs/promises");
|
|
86674
87430
|
var sysPath = __toESM(require("path"), 1);
|
|
86675
87431
|
var import_os = require("os");
|
|
86676
87432
|
var STR_DATA = "data";
|
|
@@ -86697,7 +87453,7 @@ var EVENTS = {
|
|
|
86697
87453
|
};
|
|
86698
87454
|
var EV = EVENTS;
|
|
86699
87455
|
var THROTTLE_MODE_WATCH = "watch";
|
|
86700
|
-
var statMethods = { lstat:
|
|
87456
|
+
var statMethods = { lstat: import_promises10.lstat, stat: import_promises10.stat };
|
|
86701
87457
|
var KEY_LISTENERS = "listeners";
|
|
86702
87458
|
var KEY_ERR = "errHandlers";
|
|
86703
87459
|
var KEY_RAW = "rawEmitters";
|
|
@@ -87054,7 +87810,7 @@ var setFsWatchListener = (path, fullPath, options, handlers) => {
|
|
|
87054
87810
|
cont.watcherUnusable = true;
|
|
87055
87811
|
if (isWindows && error.code === "EPERM") {
|
|
87056
87812
|
try {
|
|
87057
|
-
const fd2 = await (0,
|
|
87813
|
+
const fd2 = await (0, import_promises10.open)(path, "r");
|
|
87058
87814
|
await fd2.close();
|
|
87059
87815
|
broadcastErr(error);
|
|
87060
87816
|
} catch (err2) {
|
|
@@ -87183,7 +87939,7 @@ var NodeFsHandler = class {
|
|
|
87183
87939
|
return;
|
|
87184
87940
|
if (!newStats || newStats.mtimeMs === 0) {
|
|
87185
87941
|
try {
|
|
87186
|
-
const newStats2 = await (0,
|
|
87942
|
+
const newStats2 = await (0, import_promises10.stat)(file);
|
|
87187
87943
|
if (this.fsw.closed)
|
|
87188
87944
|
return;
|
|
87189
87945
|
const at = newStats2.atimeMs;
|
|
@@ -87238,7 +87994,7 @@ var NodeFsHandler = class {
|
|
|
87238
87994
|
this.fsw._incrReadyCount();
|
|
87239
87995
|
let linkPath;
|
|
87240
87996
|
try {
|
|
87241
|
-
linkPath = await (0,
|
|
87997
|
+
linkPath = await (0, import_promises10.realpath)(path);
|
|
87242
87998
|
} catch (e) {
|
|
87243
87999
|
this.fsw._emitReady();
|
|
87244
88000
|
return true;
|
|
@@ -87386,7 +88142,7 @@ var NodeFsHandler = class {
|
|
|
87386
88142
|
let closer;
|
|
87387
88143
|
if (stats.isDirectory()) {
|
|
87388
88144
|
const absPath = sysPath.resolve(path);
|
|
87389
|
-
const targetPath = follow ? await (0,
|
|
88145
|
+
const targetPath = follow ? await (0, import_promises10.realpath)(path) : path;
|
|
87390
88146
|
if (this.fsw.closed)
|
|
87391
88147
|
return;
|
|
87392
88148
|
closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath);
|
|
@@ -87396,7 +88152,7 @@ var NodeFsHandler = class {
|
|
|
87396
88152
|
this.fsw._symlinkPaths.set(absPath, targetPath);
|
|
87397
88153
|
}
|
|
87398
88154
|
} else if (stats.isSymbolicLink()) {
|
|
87399
|
-
const targetPath = follow ? await (0,
|
|
88155
|
+
const targetPath = follow ? await (0, import_promises10.realpath)(path) : path;
|
|
87400
88156
|
if (this.fsw.closed)
|
|
87401
88157
|
return;
|
|
87402
88158
|
const parent = sysPath.dirname(wh.watchPath);
|
|
@@ -87557,7 +88313,7 @@ var DirEntry = class {
|
|
|
87557
88313
|
return;
|
|
87558
88314
|
const dir = this.path;
|
|
87559
88315
|
try {
|
|
87560
|
-
await (0,
|
|
88316
|
+
await (0, import_promises11.readdir)(dir);
|
|
87561
88317
|
} catch (err2) {
|
|
87562
88318
|
if (this._removeWatcher) {
|
|
87563
88319
|
this._removeWatcher(sysPath2.dirname(dir), sysPath2.basename(dir));
|
|
@@ -87882,7 +88638,7 @@ var FSWatcher = class extends import_events.EventEmitter {
|
|
|
87882
88638
|
const fullPath = opts.cwd ? sysPath2.join(opts.cwd, path) : path;
|
|
87883
88639
|
let stats2;
|
|
87884
88640
|
try {
|
|
87885
|
-
stats2 = await (0,
|
|
88641
|
+
stats2 = await (0, import_promises11.stat)(fullPath);
|
|
87886
88642
|
} catch (err2) {
|
|
87887
88643
|
}
|
|
87888
88644
|
if (!stats2 || this.closed)
|
|
@@ -87925,12 +88681,12 @@ var FSWatcher = class extends import_events.EventEmitter {
|
|
|
87925
88681
|
let timeoutObject;
|
|
87926
88682
|
const clear = () => {
|
|
87927
88683
|
const item = action.get(path);
|
|
87928
|
-
const
|
|
88684
|
+
const count2 = item ? item.count : 0;
|
|
87929
88685
|
action.delete(path);
|
|
87930
88686
|
clearTimeout(timeoutObject);
|
|
87931
88687
|
if (item)
|
|
87932
88688
|
clearTimeout(item.timeoutObject);
|
|
87933
|
-
return
|
|
88689
|
+
return count2;
|
|
87934
88690
|
};
|
|
87935
88691
|
timeoutObject = setTimeout(clear, timeout);
|
|
87936
88692
|
const thr = { timeoutObject, clear, count: 0 };
|
|
@@ -88154,20 +88910,20 @@ function underDir(path, dir) {
|
|
|
88154
88910
|
function startWatcher() {
|
|
88155
88911
|
const awareDir = process.env.AWARE_HOME ?? (0, import_node_path69.join)((0, import_node_os37.homedir)(), ".aware");
|
|
88156
88912
|
const credentialsDir = (0, import_node_path69.join)(awareDir, "credentials");
|
|
88157
|
-
if (!(0,
|
|
88913
|
+
if (!(0, import_node_fs73.existsSync)(credentialsDir)) {
|
|
88158
88914
|
try {
|
|
88159
|
-
(0,
|
|
88915
|
+
(0, import_node_fs73.mkdirSync)(credentialsDir, { recursive: true });
|
|
88160
88916
|
} catch {
|
|
88161
88917
|
}
|
|
88162
88918
|
}
|
|
88163
|
-
if (!(0,
|
|
88919
|
+
if (!(0, import_node_fs73.existsSync)(uiDir)) {
|
|
88164
88920
|
try {
|
|
88165
|
-
(0,
|
|
88921
|
+
(0, import_node_fs73.mkdirSync)(uiDir, { recursive: true });
|
|
88166
88922
|
} catch {
|
|
88167
88923
|
}
|
|
88168
88924
|
}
|
|
88169
|
-
const targets = ["apps", "logs", "credentials"].map((d) => (0, import_node_path69.join)(awareDir, d)).filter((p) => (0,
|
|
88170
|
-
if ((0,
|
|
88925
|
+
const targets = ["apps", "logs", "credentials"].map((d) => (0, import_node_path69.join)(awareDir, d)).filter((p) => (0, import_node_fs73.existsSync)(p));
|
|
88926
|
+
if ((0, import_node_fs73.existsSync)(uiDir)) targets.push(uiDir);
|
|
88171
88927
|
if (targets.length === 0) {
|
|
88172
88928
|
return null;
|
|
88173
88929
|
}
|
|
@@ -88196,11 +88952,11 @@ function startWatcher() {
|
|
|
88196
88952
|
const isCredential = path.split(/[\\/]/).includes("credentials");
|
|
88197
88953
|
const kind = isCredential ? "credential" : path.endsWith(".jsonl") ? "trace" : path.endsWith(".lock") ? "lock" : path.endsWith(".flo") || path.endsWith(".app") ? "source" : "file";
|
|
88198
88954
|
broadcast({ type: "fs-change", kind, event, path });
|
|
88199
|
-
if (kind === "trace" && event !== "unlink" && (0,
|
|
88955
|
+
if (kind === "trace" && event !== "unlink" && (0, import_node_fs73.existsSync)(path)) {
|
|
88200
88956
|
const id = appIdFromLogPath(path);
|
|
88201
88957
|
if (!id) return;
|
|
88202
88958
|
try {
|
|
88203
|
-
broadcast({ type: "trace-file", id, runId: path.split(import_node_path69.sep).pop()?.replace(/\.jsonl$/, "") ?? null, events: parseTrace((0,
|
|
88959
|
+
broadcast({ type: "trace-file", id, runId: path.split(import_node_path69.sep).pop()?.replace(/\.jsonl$/, "") ?? null, events: parseTrace((0, import_node_fs73.readFileSync)(path, "utf8")) });
|
|
88204
88960
|
} catch {
|
|
88205
88961
|
}
|
|
88206
88962
|
}
|
|
@@ -88211,7 +88967,7 @@ function startWatcher() {
|
|
|
88211
88967
|
// index.ts
|
|
88212
88968
|
var __dirname4 = (0, import_node_path70.dirname)((0, import_node_url5.fileURLToPath)(__import_meta_url));
|
|
88213
88969
|
var WEB_ROOT = [(0, import_node_path70.join)(__dirname4, "web"), (0, import_node_path70.join)((0, import_node_path70.dirname)(process.execPath), "web"), (0, import_node_path70.join)(__dirname4, "..", "web")].find(
|
|
88214
|
-
(p) => (0,
|
|
88970
|
+
(p) => (0, import_node_fs74.existsSync)(p)
|
|
88215
88971
|
) ?? (0, import_node_path70.join)(__dirname4, "..", "web");
|
|
88216
88972
|
var PORT2 = Number(process.env.PORT ?? 4317);
|
|
88217
88973
|
var HOST = "127.0.0.1";
|
|
@@ -88228,7 +88984,7 @@ function installCrashHandlers() {
|
|
|
88228
88984
|
${stack}
|
|
88229
88985
|
`;
|
|
88230
88986
|
try {
|
|
88231
|
-
(0,
|
|
88987
|
+
(0, import_node_fs74.appendFileSync)(logFilePath(), line);
|
|
88232
88988
|
} catch {
|
|
88233
88989
|
}
|
|
88234
88990
|
if (process.stderr.isTTY) process.stderr.write(line);
|
|
@@ -88292,8 +89048,8 @@ async function startServer() {
|
|
|
88292
89048
|
const MIN_AWARE = TEKLA_AWARE_FLOOR;
|
|
88293
89049
|
const SHARE_3D_AWARE_FLOOR = "0.96.0";
|
|
88294
89050
|
const isWin3 = process.platform === "win32";
|
|
88295
|
-
const
|
|
88296
|
-
const lookUpOnPath = toolchainLookup(
|
|
89051
|
+
const execFileAsync4 = (0, import_node_util7.promisify)(import_node_child_process17.execFile);
|
|
89052
|
+
const lookUpOnPath = toolchainLookup(execFileAsync4, {
|
|
88297
89053
|
isWin: isWin3,
|
|
88298
89054
|
onFailure: ({ cmd, attempt, outcome, err: err2 }) => {
|
|
88299
89055
|
const e = err2;
|
|
@@ -88346,23 +89102,6 @@ async function startServer() {
|
|
|
88346
89102
|
if (!child.pid) throw new Error("AWARE sidecar installer did not expose a child PID");
|
|
88347
89103
|
await context.childStarted(await maintenanceChildIdentity(child.pid));
|
|
88348
89104
|
}
|
|
88349
|
-
function anyAwareInstallerTreeAlive() {
|
|
88350
|
-
if (process.platform !== "win32") return false;
|
|
88351
|
-
try {
|
|
88352
|
-
const script = [
|
|
88353
|
-
"$p=Get-CimInstance Win32_Process -ErrorAction Stop",
|
|
88354
|
-
"$m=$p|Where-Object {$_.ProcessId -ne $PID -and $_.CommandLine -match '@aware-aeco/cli@|aware(?:\\.cmd)?\\s+sidecar\\s+install'}",
|
|
88355
|
-
"if($m){Write-Output true}else{Write-Output false}"
|
|
88356
|
-
].join(";");
|
|
88357
|
-
return (0, import_node_child_process16.execFileSync)("powershell.exe", ["-NoProfile", "-NonInteractive", "-Command", script], {
|
|
88358
|
-
encoding: "utf8",
|
|
88359
|
-
windowsHide: true,
|
|
88360
|
-
timeout: 5e3
|
|
88361
|
-
}).trim().toLowerCase() === "true";
|
|
88362
|
-
} catch {
|
|
88363
|
-
return true;
|
|
88364
|
-
}
|
|
88365
|
-
}
|
|
88366
89105
|
const awareUpdateJobs = new AwareUpdateJobManager({
|
|
88367
89106
|
resolveCurrentTarget: async () => {
|
|
88368
89107
|
const marker = await awareMaintenance.read();
|
|
@@ -88501,7 +89240,7 @@ async function startServer() {
|
|
|
88501
89240
|
maintenance: awareMaintenance,
|
|
88502
89241
|
withRecoveryExclusive: (work) => withAwareExclusive(() => work(upgradeOwner())),
|
|
88503
89242
|
matchingChildAlive: async (marker) => marker.child ? maintenanceChildMatches(marker.child) : false,
|
|
88504
|
-
anyInstallerTreeAlive:
|
|
89243
|
+
anyInstallerTreeAlive: () => anyAwareInstallerTreeAlive(),
|
|
88505
89244
|
repairAndVerify: repairInterruptedAwareMaintenance
|
|
88506
89245
|
});
|
|
88507
89246
|
}
|
|
@@ -88920,10 +89659,10 @@ async function startServer() {
|
|
|
88920
89659
|
const bdir = backupDir(id, fromVersion, Date.now());
|
|
88921
89660
|
let backedUp = false;
|
|
88922
89661
|
try {
|
|
88923
|
-
(0,
|
|
88924
|
-
(0,
|
|
89662
|
+
(0, import_node_fs74.mkdirSync)((0, import_node_path70.dirname)(bdir), { recursive: true });
|
|
89663
|
+
(0, import_node_fs74.cpSync)(appDirPath2, bdir, { recursive: true });
|
|
88925
89664
|
backedUp = true;
|
|
88926
|
-
(0,
|
|
89665
|
+
(0, import_node_fs74.cpSync)(templatePath, srcPath);
|
|
88927
89666
|
if (id !== templateId) stampSourceAppId(srcPath, id);
|
|
88928
89667
|
if (contract != null) {
|
|
88929
89668
|
bakeContractIntoApp(srcPath, contract);
|
|
@@ -88938,8 +89677,8 @@ async function startServer() {
|
|
|
88938
89677
|
throw new TemplateSwapError(`${verb} failed before any change was made (${msg}) \u2014 the workflow is untouched`, `${verb}-not-started`);
|
|
88939
89678
|
}
|
|
88940
89679
|
try {
|
|
88941
|
-
(0,
|
|
88942
|
-
(0,
|
|
89680
|
+
(0, import_node_fs74.rmSync)(appDirPath2, { recursive: true, force: true });
|
|
89681
|
+
(0, import_node_fs74.cpSync)(bdir, appDirPath2, { recursive: true });
|
|
88943
89682
|
} catch (re) {
|
|
88944
89683
|
const rmsg = re instanceof Error ? re.message : String(re);
|
|
88945
89684
|
throw new TemplateSwapError(`${verb} failed (${msg}) AND rollback failed (${rmsg}) \u2014 restore manually from ${bdir}`, "rollback-failed", bdir);
|
|
@@ -88951,7 +89690,7 @@ async function startServer() {
|
|
|
88951
89690
|
function readSwapContract(id, verb) {
|
|
88952
89691
|
const gerund = verb === "update" ? "updating" : "restoring";
|
|
88953
89692
|
const contract = readAcceptedForRequest(id, void 0);
|
|
88954
|
-
if (contract == null && (0,
|
|
89693
|
+
if (contract == null && (0, import_node_fs74.existsSync)(contractPath(id))) {
|
|
88955
89694
|
return { ok: false, body: { ok: false, error: `"${id}"'s saved data is unreadable \u2014 open it in the editor and re-save before ${gerund}`, code: "contract-corrupt" } };
|
|
88956
89695
|
}
|
|
88957
89696
|
if (contract != null && !validateContract(contract).valid) {
|
|
@@ -89309,7 +90048,7 @@ async function startServer() {
|
|
|
89309
90048
|
}
|
|
89310
90049
|
let data;
|
|
89311
90050
|
try {
|
|
89312
|
-
data = (0,
|
|
90051
|
+
data = (0, import_node_fs74.readFileSync)(thumb.path);
|
|
89313
90052
|
} catch {
|
|
89314
90053
|
return reply.status(404).send({ ok: false, error: "no thumbnail" });
|
|
89315
90054
|
}
|
|
@@ -89836,8 +90575,8 @@ async function startServer() {
|
|
|
89836
90575
|
if (bad) return reply.status(404).send({ ok: false, error: bad });
|
|
89837
90576
|
const safe2 = req.params.sheet.replace(/[^A-Za-z0-9._-]/g, "");
|
|
89838
90577
|
const file = (0, import_node_path70.join)((0, import_node_path70.dirname)(contractPath(req.params.appId, project)), "details", `${safe2}.svg`);
|
|
89839
|
-
if (!(0,
|
|
89840
|
-
return reply.type("image/svg+xml").send((0,
|
|
90578
|
+
if (!(0, import_node_fs74.existsSync)(file)) return reply.status(404).send({ ok: false, error: "no vector for this sheet" });
|
|
90579
|
+
return reply.type("image/svg+xml").send((0, import_node_fs74.readFileSync)(file, "utf8"));
|
|
89841
90580
|
}
|
|
89842
90581
|
);
|
|
89843
90582
|
app.put(
|
|
@@ -90378,7 +91117,7 @@ async function startServer() {
|
|
|
90378
91117
|
}
|
|
90379
91118
|
const statedAt = (filename) => {
|
|
90380
91119
|
try {
|
|
90381
|
-
const st = (0,
|
|
91120
|
+
const st = (0, import_node_fs74.statSync)((0, import_node_path70.join)(dir, filename));
|
|
90382
91121
|
return st.isFile() ? st.mtime.toISOString() : null;
|
|
90383
91122
|
} catch {
|
|
90384
91123
|
return null;
|
|
@@ -90551,10 +91290,10 @@ async function startServer() {
|
|
|
90551
91290
|
scene,
|
|
90552
91291
|
"output-path": tempPath
|
|
90553
91292
|
});
|
|
90554
|
-
if (!(0,
|
|
91293
|
+
if (!(0, import_node_fs74.existsSync)(tempPath) || (0, import_node_fs74.statSync)(tempPath).size === 0) {
|
|
90555
91294
|
throw new ReceiptReconciliationError("AWARE reported a successful export but wrote no IFC file.");
|
|
90556
91295
|
}
|
|
90557
|
-
const artifactBytes = (0,
|
|
91296
|
+
const artifactBytes = (0, import_node_fs74.readFileSync)(tempPath);
|
|
90558
91297
|
const receipt = reconcileIfcExportReceipt(scene, rawReceipt, producerUnsupported, {
|
|
90559
91298
|
index: parseStepData(artifactBytes),
|
|
90560
91299
|
bytes: artifactBytes
|
|
@@ -90610,7 +91349,7 @@ async function startServer() {
|
|
|
90610
91349
|
ok: false,
|
|
90611
91350
|
error: awareFailureMessage(error, "IFC export failed"),
|
|
90612
91351
|
...reason ? { reason } : {},
|
|
90613
|
-
preservedPrevious: project && priorProjectIfc ? receiptHasFile(project, priorProjectIfc) : (0,
|
|
91352
|
+
preservedPrevious: project && priorProjectIfc ? receiptHasFile(project, priorProjectIfc) : (0, import_node_fs74.existsSync)(finalPath)
|
|
90614
91353
|
});
|
|
90615
91354
|
} finally {
|
|
90616
91355
|
cleanupIfcTemp(tempPath);
|
|
@@ -90657,10 +91396,10 @@ async function startServer() {
|
|
|
90657
91396
|
const receipt = wanted ? stills.find((row) => row.variant === wanted) : [...stills].sort((a, b) => b.exportedAt.localeCompare(a.exportedAt))[0];
|
|
90658
91397
|
if (!receipt) return reply.status(404).send({ ok: false, error: "nothing rendered yet" });
|
|
90659
91398
|
const path = resolveProjectExportReceiptPath(project, receipt);
|
|
90660
|
-
if (!path || !(0,
|
|
91399
|
+
if (!path || !(0, import_node_fs74.existsSync)(path)) {
|
|
90661
91400
|
return reply.status(404).send({ ok: false, error: "the rendered image is no longer on disk" });
|
|
90662
91401
|
}
|
|
90663
|
-
return reply.header("content-type", "image/png").header("cache-control", "private, max-age=31536000, immutable").send((0,
|
|
91402
|
+
return reply.header("content-type", "image/png").header("cache-control", "private, max-age=31536000, immutable").send((0, import_node_fs74.readFileSync)(path));
|
|
90664
91403
|
});
|
|
90665
91404
|
const RENDER_VIEWPOINTS = /* @__PURE__ */ new Set(["hero", "iso", "front", "back", "left", "right", "top"]);
|
|
90666
91405
|
app.post("/api/contract/:appId/render", async (req, reply) => {
|
|
@@ -90721,7 +91460,7 @@ async function startServer() {
|
|
|
90721
91460
|
}
|
|
90722
91461
|
const kind = output === "turntable" ? "render-mp4" : "render-png";
|
|
90723
91462
|
const extension = output === "turntable" ? ".mp4" : ".png";
|
|
90724
|
-
const scratch = (0,
|
|
91463
|
+
const scratch = (0, import_node_fs74.mkdtempSync)((0, import_node_path70.join)((0, import_node_os38.tmpdir)(), "floless-render-"));
|
|
90725
91464
|
const ifcPath = (0, import_node_path70.join)(scratch, "model.ifc");
|
|
90726
91465
|
const rendered = [];
|
|
90727
91466
|
const progress = (stage, extra = {}) => {
|
|
@@ -90733,7 +91472,7 @@ async function startServer() {
|
|
|
90733
91472
|
try {
|
|
90734
91473
|
progress("preparing");
|
|
90735
91474
|
await aware.agentInvoke("ifc", "write", { scene: built.scene, "output-path": ifcPath });
|
|
90736
|
-
if (!(0,
|
|
91475
|
+
if (!(0, import_node_fs74.existsSync)(ifcPath) || (0, import_node_fs74.statSync)(ifcPath).size === 0) {
|
|
90737
91476
|
throw new Error("AWARE reported a successful IFC write but produced no file to render");
|
|
90738
91477
|
}
|
|
90739
91478
|
const renderBudgetMs = output === "turntable" ? 30 * 6e4 : 10 * 6e4;
|
|
@@ -90751,10 +91490,10 @@ async function startServer() {
|
|
|
90751
91490
|
environment: "studio",
|
|
90752
91491
|
...output === "turntable" ? { "duration-seconds": 12, fps: 24, "width-pixels": 1280, "height-pixels": 720 } : { quality, "width-pixels": 1920, "height-pixels": 1080 }
|
|
90753
91492
|
}, { timeoutMs: renderBudgetMs });
|
|
90754
|
-
if (!(0,
|
|
91493
|
+
if (!(0, import_node_fs74.existsSync)(artifactPath) || (0, import_node_fs74.statSync)(artifactPath).size === 0) {
|
|
90755
91494
|
throw new Error(`the ${viewpoint} render reported success but produced no image`);
|
|
90756
91495
|
}
|
|
90757
|
-
const bytes = (0,
|
|
91496
|
+
const bytes = (0, import_node_fs74.readFileSync)(artifactPath);
|
|
90758
91497
|
const sourceSuffix = "source" in projectSnapshot && projectSnapshot.source ? `-${projectSnapshot.source.filenameLabel.replace(/[^A-Za-z0-9._-]+/g, "-")}` : "";
|
|
90759
91498
|
const preferred = `${exportFileBase(project, appId)}-${viewpoint}${sourceSuffix}${extension}`;
|
|
90760
91499
|
const filename = uniqueProjectExportFilename(project, preferred);
|
|
@@ -90810,7 +91549,7 @@ async function startServer() {
|
|
|
90810
91549
|
rendered
|
|
90811
91550
|
});
|
|
90812
91551
|
} finally {
|
|
90813
|
-
(0,
|
|
91552
|
+
(0, import_node_fs74.rmSync)(scratch, { recursive: true, force: true });
|
|
90814
91553
|
}
|
|
90815
91554
|
}, {
|
|
90816
91555
|
// What anyone blocked on this project is told, and for how long to expect it. Erring long
|
|
@@ -91051,14 +91790,14 @@ async function startServer() {
|
|
|
91051
91790
|
const outPath = project ? (0, import_node_path70.join)(projectExportsDir(project), filename) : bomExportPath(appId, format);
|
|
91052
91791
|
const dir = (0, import_node_path70.dirname)(outPath);
|
|
91053
91792
|
try {
|
|
91054
|
-
(0,
|
|
91793
|
+
(0, import_node_fs74.mkdirSync)(dir, { recursive: true });
|
|
91055
91794
|
const kind = BOM_EXPORT_KIND[format];
|
|
91056
|
-
let
|
|
91795
|
+
let text5 = null;
|
|
91057
91796
|
let buf;
|
|
91058
91797
|
if (format === "xlsx") {
|
|
91059
91798
|
buf = await bomToXlsx(bom, columns);
|
|
91060
91799
|
} else {
|
|
91061
|
-
|
|
91800
|
+
text5 = format === "csv" ? bomToCsv(bom, columns) : await withLifecycleLock(
|
|
91062
91801
|
"app",
|
|
91063
91802
|
bomReportCompanionId(appId),
|
|
91064
91803
|
() => renderBomReport(appId, {
|
|
@@ -91067,23 +91806,23 @@ async function startServer() {
|
|
|
91067
91806
|
}),
|
|
91068
91807
|
{ label: "rendering the bill of materials report" }
|
|
91069
91808
|
);
|
|
91070
|
-
buf = Buffer.from(
|
|
91809
|
+
buf = Buffer.from(text5, "utf8");
|
|
91071
91810
|
}
|
|
91072
91811
|
if (project && projectSnapshot) {
|
|
91073
91812
|
publishProjectExportArtifact(project, {
|
|
91074
91813
|
kind,
|
|
91075
91814
|
filename,
|
|
91076
|
-
encoding:
|
|
91815
|
+
encoding: text5 != null ? "utf8" : "base64",
|
|
91077
91816
|
bytes: buf.length,
|
|
91078
91817
|
version: projectSnapshot.version.n,
|
|
91079
91818
|
sourceKind: projectSnapshot.source?.kind ?? "approved",
|
|
91080
91819
|
contractHash: projectSnapshot.contractHash
|
|
91081
91820
|
}, buf);
|
|
91082
|
-
} else if (
|
|
91083
|
-
else (0,
|
|
91821
|
+
} else if (text5 != null) (0, import_node_fs74.writeFileSync)(outPath, text5, "utf8");
|
|
91822
|
+
else (0, import_node_fs74.writeFileSync)(outPath, buf);
|
|
91084
91823
|
return {
|
|
91085
91824
|
ok: true,
|
|
91086
|
-
payload:
|
|
91825
|
+
payload: text5 != null ? { filename, encoding: "utf8", content: text5, bytes: buf.length, savedTo: outPath } : { filename, encoding: "base64", content: buf.toString("base64"), bytes: buf.length, savedTo: outPath }
|
|
91087
91826
|
};
|
|
91088
91827
|
} catch (e) {
|
|
91089
91828
|
if (e instanceof BomReportError) {
|
|
@@ -91120,7 +91859,7 @@ async function startServer() {
|
|
|
91120
91859
|
const filename = project ? uniqueProjectExportFilename(project, preferredFilename) : preferredFilename;
|
|
91121
91860
|
const outPath = project ? (0, import_node_path70.join)(projectExportsDir(project), filename) : (0, import_node_path70.join)(appPath(appId), filename);
|
|
91122
91861
|
try {
|
|
91123
|
-
(0,
|
|
91862
|
+
(0, import_node_fs74.mkdirSync)((0, import_node_path70.dirname)(outPath), { recursive: true });
|
|
91124
91863
|
if (project && projectSnapshot) {
|
|
91125
91864
|
publishProjectExportArtifact(project, {
|
|
91126
91865
|
kind: "svg",
|
|
@@ -91131,7 +91870,7 @@ async function startServer() {
|
|
|
91131
91870
|
sourceKind: projectSnapshot.source?.kind ?? "approved",
|
|
91132
91871
|
contractHash: projectSnapshot.contractHash
|
|
91133
91872
|
}, Buffer.from(svg, "utf8"));
|
|
91134
|
-
} else (0,
|
|
91873
|
+
} else (0, import_node_fs74.writeFileSync)(outPath, svg, "utf8");
|
|
91135
91874
|
return { ok: true, filename, encoding: "utf8", content: svg, bytes: Buffer.byteLength(svg), savedTo: outPath };
|
|
91136
91875
|
} catch (e) {
|
|
91137
91876
|
app.log.error({ appId, err: e instanceof Error ? e.message : e }, "export-svg: write failed");
|
|
@@ -91324,11 +92063,11 @@ async function startServer() {
|
|
|
91324
92063
|
id
|
|
91325
92064
|
});
|
|
91326
92065
|
}
|
|
91327
|
-
const stageRoot = (0,
|
|
92066
|
+
const stageRoot = (0, import_node_fs74.mkdtempSync)((0, import_node_path70.join)((0, import_node_os38.tmpdir)(), "floless-import-"));
|
|
91328
92067
|
try {
|
|
91329
92068
|
const stageDir = (0, import_node_path70.join)(stageRoot, id);
|
|
91330
|
-
(0,
|
|
91331
|
-
(0,
|
|
92069
|
+
(0, import_node_fs74.mkdirSync)(stageDir);
|
|
92070
|
+
(0, import_node_fs74.writeFileSync)((0, import_node_path70.join)(stageDir, `${id}.flo`), content);
|
|
91332
92071
|
await aware.install(stageDir);
|
|
91333
92072
|
} catch (err2) {
|
|
91334
92073
|
try {
|
|
@@ -91339,7 +92078,7 @@ async function startServer() {
|
|
|
91339
92078
|
const reason = awareStderr(err2);
|
|
91340
92079
|
return reply.status(502).send({ ok: false, error: `import failed: ${msg}`, code: "install-failed", reason, agentsUnavailable: unavailableAgents(reason) });
|
|
91341
92080
|
} finally {
|
|
91342
|
-
(0,
|
|
92081
|
+
(0, import_node_fs74.rmSync)(stageRoot, { recursive: true, force: true });
|
|
91343
92082
|
}
|
|
91344
92083
|
broadcast({ type: "apps-changed", id });
|
|
91345
92084
|
return { ok: true, id };
|
|
@@ -91355,13 +92094,13 @@ async function startServer() {
|
|
|
91355
92094
|
}
|
|
91356
92095
|
const inputs = appData.inputs.map((i) => ({ name: i.name, type: i.type }));
|
|
91357
92096
|
const baked = bakeFloSource(appData.source.text, inputs);
|
|
91358
|
-
const tmpRoot = (0,
|
|
92097
|
+
const tmpRoot = (0, import_node_fs74.mkdtempSync)((0, import_node_path70.join)((0, import_node_os38.tmpdir)(), "floless-bake-"));
|
|
91359
92098
|
const backupDir2 = (0, import_node_path70.join)(tmpRoot, `${id}-backup`);
|
|
91360
92099
|
const bakeDir = (0, import_node_path70.join)(tmpRoot, id);
|
|
91361
|
-
(0,
|
|
91362
|
-
(0,
|
|
92100
|
+
(0, import_node_fs74.cpSync)(appDir(id), backupDir2, { recursive: true });
|
|
92101
|
+
(0, import_node_fs74.cpSync)(appDir(id), bakeDir, { recursive: true });
|
|
91363
92102
|
const floName = appData.source.path.split(/[\\/]/).pop();
|
|
91364
|
-
(0,
|
|
92103
|
+
(0, import_node_fs74.writeFileSync)((0, import_node_path70.join)(bakeDir, floName), baked);
|
|
91365
92104
|
let appInstalled2 = true;
|
|
91366
92105
|
try {
|
|
91367
92106
|
await aware.uninstall(id);
|
|
@@ -91390,7 +92129,7 @@ async function startServer() {
|
|
|
91390
92129
|
broadcast({ type: "baked", id });
|
|
91391
92130
|
return { ok: true, id, agent: id, inputs };
|
|
91392
92131
|
} finally {
|
|
91393
|
-
if (appInstalled2) (0,
|
|
92132
|
+
if (appInstalled2) (0, import_node_fs74.rmSync)(tmpRoot, { recursive: true, force: true });
|
|
91394
92133
|
}
|
|
91395
92134
|
});
|
|
91396
92135
|
});
|
|
@@ -91411,7 +92150,7 @@ async function startServer() {
|
|
|
91411
92150
|
if (!sourceKind || !sourceRef) {
|
|
91412
92151
|
return reply.status(400).send({ ok: false, error: "sourceKind and sourceRef required" });
|
|
91413
92152
|
}
|
|
91414
|
-
const tempHome = (0,
|
|
92153
|
+
const tempHome = (0, import_node_fs74.mkdtempSync)((0, import_node_path70.join)((0, import_node_os38.tmpdir)(), "floless-graft-"));
|
|
91415
92154
|
let result;
|
|
91416
92155
|
try {
|
|
91417
92156
|
result = await aware.build({
|
|
@@ -91424,19 +92163,19 @@ async function startServer() {
|
|
|
91424
92163
|
awareHome: tempHome
|
|
91425
92164
|
});
|
|
91426
92165
|
} catch (err2) {
|
|
91427
|
-
(0,
|
|
92166
|
+
(0, import_node_fs74.rmSync)(tempHome, { recursive: true, force: true });
|
|
91428
92167
|
const msg = err2 instanceof AwareError ? err2.message : String(err2?.message ?? err2);
|
|
91429
92168
|
return reply.status(422).send({ ok: false, error: msg });
|
|
91430
92169
|
}
|
|
91431
92170
|
const manifest = readStagedManifest(result.agentDir);
|
|
91432
92171
|
if (!manifest) {
|
|
91433
|
-
(0,
|
|
92172
|
+
(0, import_node_fs74.rmSync)(tempHome, { recursive: true, force: true });
|
|
91434
92173
|
return reply.status(502).send({ ok: false, error: `build produced output at ${result.agentDir} but no manifest.yaml` });
|
|
91435
92174
|
}
|
|
91436
92175
|
const token2 = (0, import_node_crypto41.randomUUID)();
|
|
91437
92176
|
registerStage(token2, tempHome, result.agentId);
|
|
91438
92177
|
const preview2 = buildPreview(manifest, sourceKind, sourceRef, token2);
|
|
91439
|
-
if ((0,
|
|
92178
|
+
if ((0, import_node_fs74.existsSync)((0, import_node_path70.join)(graftAgentsDir(), result.agentId))) {
|
|
91440
92179
|
preview2.warnings.unshift(`An agent named "${result.agentId}" is already installed \u2014 creating it will overwrite it.`);
|
|
91441
92180
|
}
|
|
91442
92181
|
return { ok: true, preview: preview2 };
|
|
@@ -91455,7 +92194,7 @@ async function startServer() {
|
|
|
91455
92194
|
registerStage(stagedRef, stage.tempDir, stage.agentId);
|
|
91456
92195
|
return reply.status(409).send({ ok: false, error: err2.message, agentId: stage.agentId, collision: true });
|
|
91457
92196
|
}
|
|
91458
|
-
(0,
|
|
92197
|
+
(0, import_node_fs74.rmSync)(stage.tempDir, { recursive: true, force: true });
|
|
91459
92198
|
throw err2;
|
|
91460
92199
|
}
|
|
91461
92200
|
broadcast({ type: "grafted", id: stage.agentId });
|
|
@@ -91751,11 +92490,11 @@ async function startServer() {
|
|
|
91751
92490
|
app.get("/api/requests/:id/snapshot/:n", async (req, reply) => {
|
|
91752
92491
|
const n = Number.parseInt(req.params.n, 10);
|
|
91753
92492
|
const p = Number.isInteger(n) ? snapshotPathFor(req.params.id, n) : null;
|
|
91754
|
-
if (!p || !(0,
|
|
92493
|
+
if (!p || !(0, import_node_fs74.existsSync)(p)) return reply.status(404).send({ ok: false, error: "snapshot not found" });
|
|
91755
92494
|
const ext = p.split(".").pop().toLowerCase();
|
|
91756
92495
|
reply.header("Content-Type", ext === "png" ? "image/png" : ext === "webp" ? "image/webp" : ext === "pdf" ? "application/pdf" : "image/jpeg");
|
|
91757
92496
|
reply.header("Cache-Control", "no-store");
|
|
91758
|
-
return (0,
|
|
92497
|
+
return (0, import_node_fs74.readFileSync)(p);
|
|
91759
92498
|
});
|
|
91760
92499
|
app.post(
|
|
91761
92500
|
"/api/tweak",
|
|
@@ -91820,7 +92559,7 @@ async function startServer() {
|
|
|
91820
92559
|
registerReferenceRoutes(app, {
|
|
91821
92560
|
getProject,
|
|
91822
92561
|
broadcast,
|
|
91823
|
-
reader: { probe: probeReference, readModel: readReferenceModel },
|
|
92562
|
+
reader: { probe: probeReference, readModel: readReferenceModel, compare: compareReferences },
|
|
91824
92563
|
runControl: { newTicket: newRunTicket, cancel: cancelRun }
|
|
91825
92564
|
});
|
|
91826
92565
|
const CONN_APPID = /^[a-z0-9][a-z0-9._-]*$/i;
|
|
@@ -92016,7 +92755,7 @@ ${v.prompt}` : "";
|
|
|
92016
92755
|
warn(`last-run-status:${ref} \u2014 trace exists but couldn't be parsed (corrupt/truncated)`);
|
|
92017
92756
|
let finishedAt2 = null;
|
|
92018
92757
|
try {
|
|
92019
|
-
finishedAt2 = (0,
|
|
92758
|
+
finishedAt2 = (0, import_node_fs74.statSync)(latest.path).mtime.toISOString();
|
|
92020
92759
|
} catch {
|
|
92021
92760
|
finishedAt2 = null;
|
|
92022
92761
|
}
|
|
@@ -92026,7 +92765,7 @@ ${v.prompt}` : "";
|
|
|
92026
92765
|
let finishedAt = typeof runEnd?.ts === "string" ? runEnd.ts : null;
|
|
92027
92766
|
if (!finishedAt) {
|
|
92028
92767
|
try {
|
|
92029
|
-
finishedAt = (0,
|
|
92768
|
+
finishedAt = (0, import_node_fs74.statSync)(latest.path).mtime.toISOString();
|
|
92030
92769
|
} catch {
|
|
92031
92770
|
finishedAt = null;
|
|
92032
92771
|
}
|
|
@@ -92189,10 +92928,10 @@ ${v.prompt}` : "";
|
|
|
92189
92928
|
}
|
|
92190
92929
|
|
|
92191
92930
|
// protocol.ts
|
|
92192
|
-
var
|
|
92931
|
+
var import_node_child_process18 = require("node:child_process");
|
|
92193
92932
|
var BASE = PROTOCOL_KEY;
|
|
92194
92933
|
function reg(args) {
|
|
92195
|
-
(0,
|
|
92934
|
+
(0, import_node_child_process18.execFileSync)("reg", args, { stdio: "ignore", windowsHide: true });
|
|
92196
92935
|
}
|
|
92197
92936
|
function registerProtocol(exePath) {
|
|
92198
92937
|
if (process.platform !== "win32") return;
|
|
@@ -92232,13 +92971,13 @@ async function removeAwarePerDecision(removeAwareFlag, prompt) {
|
|
|
92232
92971
|
);
|
|
92233
92972
|
const shell = process.platform === "win32" ? process.env.ComSpec || "cmd.exe" : "/bin/sh";
|
|
92234
92973
|
try {
|
|
92235
|
-
(0,
|
|
92974
|
+
(0, import_node_child_process19.execSync)("npm uninstall -g @aware-aeco/cli", { stdio: "inherit", shell });
|
|
92236
92975
|
} catch {
|
|
92237
92976
|
process.stdout.write('floless: warning: "npm uninstall -g @aware-aeco/cli" failed \u2014 see the output above.\n');
|
|
92238
92977
|
}
|
|
92239
92978
|
let lsJson = "";
|
|
92240
92979
|
try {
|
|
92241
|
-
lsJson = (0,
|
|
92980
|
+
lsJson = (0, import_node_child_process19.execSync)("npm ls -g @aware-aeco/cli --depth=0 --json", {
|
|
92242
92981
|
encoding: "utf8",
|
|
92243
92982
|
stdio: ["ignore", "pipe", "ignore"],
|
|
92244
92983
|
shell
|