@floless/app 0.109.1 → 0.109.3
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
CHANGED
|
@@ -1055,7 +1055,7 @@ var require_boot = __commonJS({
|
|
|
1055
1055
|
};
|
|
1056
1056
|
this._doStart = null;
|
|
1057
1057
|
const instance = this;
|
|
1058
|
-
this._root = new Plugin(fastq(this, this._loadPluginNextTick, 1), function
|
|
1058
|
+
this._root = new Plugin(fastq(this, this._loadPluginNextTick, 1), function root4(server2, opts2, done2) {
|
|
1059
1059
|
instance._doStart = done2;
|
|
1060
1060
|
opts2.autostart && instance.start();
|
|
1061
1061
|
}, opts, false, 0);
|
|
@@ -5489,7 +5489,7 @@ var require_thread_stream = __commonJS({
|
|
|
5489
5489
|
var { version } = require_package();
|
|
5490
5490
|
var { EventEmitter: EventEmitter2 } = require("events");
|
|
5491
5491
|
var { Worker: Worker2 } = require("worker_threads");
|
|
5492
|
-
var { join:
|
|
5492
|
+
var { join: join42 } = require("path");
|
|
5493
5493
|
var { pathToFileURL } = require("url");
|
|
5494
5494
|
var { wait } = require_wait();
|
|
5495
5495
|
var {
|
|
@@ -5540,7 +5540,7 @@ var require_thread_stream = __commonJS({
|
|
|
5540
5540
|
function createWorker(stream, opts) {
|
|
5541
5541
|
const { filename, workerData } = opts;
|
|
5542
5542
|
const bundlerOverrides = "__bundlerPathsOverrides" in globalThis ? globalThis.__bundlerPathsOverrides : {};
|
|
5543
|
-
const toExecute = bundlerOverrides["thread-stream-worker"] ||
|
|
5543
|
+
const toExecute = bundlerOverrides["thread-stream-worker"] || join42(__dirname, "lib", "worker.js");
|
|
5544
5544
|
const worker = new Worker2(toExecute, {
|
|
5545
5545
|
...opts.workerOpts,
|
|
5546
5546
|
name: opts.workerOpts?.name || "thread-stream",
|
|
@@ -6006,9 +6006,9 @@ var require_transport = __commonJS({
|
|
|
6006
6006
|
"node_modules/pino/lib/transport.js"(exports2, module2) {
|
|
6007
6007
|
"use strict";
|
|
6008
6008
|
var { createRequire: createRequire5 } = require("module");
|
|
6009
|
-
var { existsSync:
|
|
6009
|
+
var { existsSync: existsSync38 } = require("node:fs");
|
|
6010
6010
|
var getCallers = require_caller();
|
|
6011
|
-
var { join:
|
|
6011
|
+
var { join: join42, isAbsolute: isAbsolute2, sep: sep6 } = require("node:path");
|
|
6012
6012
|
var { fileURLToPath: fileURLToPath6 } = require("node:url");
|
|
6013
6013
|
var sleep2 = require_atomic_sleep();
|
|
6014
6014
|
var onExit = require_on_exit_leak_free();
|
|
@@ -6080,7 +6080,7 @@ var require_transport = __commonJS({
|
|
|
6080
6080
|
return false;
|
|
6081
6081
|
}
|
|
6082
6082
|
}
|
|
6083
|
-
return isAbsolute2(path) && !
|
|
6083
|
+
return isAbsolute2(path) && !existsSync38(path);
|
|
6084
6084
|
}
|
|
6085
6085
|
function stripQuotes(value) {
|
|
6086
6086
|
const first = value[0];
|
|
@@ -6161,7 +6161,7 @@ var require_transport = __commonJS({
|
|
|
6161
6161
|
throw new Error("only one of target or targets can be specified");
|
|
6162
6162
|
}
|
|
6163
6163
|
if (targets) {
|
|
6164
|
-
target = bundlerOverrides["pino-worker"] ||
|
|
6164
|
+
target = bundlerOverrides["pino-worker"] || join42(__dirname, "worker.js");
|
|
6165
6165
|
options.targets = targets.filter((dest) => dest.target).map((dest) => {
|
|
6166
6166
|
return {
|
|
6167
6167
|
...dest,
|
|
@@ -6179,7 +6179,7 @@ var require_transport = __commonJS({
|
|
|
6179
6179
|
});
|
|
6180
6180
|
});
|
|
6181
6181
|
} else if (pipeline2) {
|
|
6182
|
-
target = bundlerOverrides["pino-worker"] ||
|
|
6182
|
+
target = bundlerOverrides["pino-worker"] || join42(__dirname, "worker.js");
|
|
6183
6183
|
options.pipelines = [pipeline2.map((dest) => {
|
|
6184
6184
|
return {
|
|
6185
6185
|
...dest,
|
|
@@ -6202,7 +6202,7 @@ var require_transport = __commonJS({
|
|
|
6202
6202
|
return origin;
|
|
6203
6203
|
}
|
|
6204
6204
|
if (origin === "pino/file") {
|
|
6205
|
-
return
|
|
6205
|
+
return join42(__dirname, "..", "file.js");
|
|
6206
6206
|
}
|
|
6207
6207
|
let fixTarget2;
|
|
6208
6208
|
for (const filePath of callers) {
|
|
@@ -7182,7 +7182,7 @@ var require_safe_stable_stringify = __commonJS({
|
|
|
7182
7182
|
return circularValue;
|
|
7183
7183
|
}
|
|
7184
7184
|
let res = "";
|
|
7185
|
-
let
|
|
7185
|
+
let join42 = ",";
|
|
7186
7186
|
const originalIndentation = indentation;
|
|
7187
7187
|
if (Array.isArray(value)) {
|
|
7188
7188
|
if (value.length === 0) {
|
|
@@ -7196,7 +7196,7 @@ var require_safe_stable_stringify = __commonJS({
|
|
|
7196
7196
|
indentation += spacer;
|
|
7197
7197
|
res += `
|
|
7198
7198
|
${indentation}`;
|
|
7199
|
-
|
|
7199
|
+
join42 = `,
|
|
7200
7200
|
${indentation}`;
|
|
7201
7201
|
}
|
|
7202
7202
|
const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
|
|
@@ -7204,13 +7204,13 @@ ${indentation}`;
|
|
|
7204
7204
|
for (; i < maximumValuesToStringify - 1; i++) {
|
|
7205
7205
|
const tmp2 = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
|
|
7206
7206
|
res += tmp2 !== void 0 ? tmp2 : "null";
|
|
7207
|
-
res +=
|
|
7207
|
+
res += join42;
|
|
7208
7208
|
}
|
|
7209
7209
|
const tmp = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
|
|
7210
7210
|
res += tmp !== void 0 ? tmp : "null";
|
|
7211
7211
|
if (value.length - 1 > maximumBreadth) {
|
|
7212
7212
|
const removedKeys = value.length - maximumBreadth - 1;
|
|
7213
|
-
res += `${
|
|
7213
|
+
res += `${join42}"... ${getItemCount(removedKeys)} not stringified"`;
|
|
7214
7214
|
}
|
|
7215
7215
|
if (spacer !== "") {
|
|
7216
7216
|
res += `
|
|
@@ -7231,7 +7231,7 @@ ${originalIndentation}`;
|
|
|
7231
7231
|
let separator = "";
|
|
7232
7232
|
if (spacer !== "") {
|
|
7233
7233
|
indentation += spacer;
|
|
7234
|
-
|
|
7234
|
+
join42 = `,
|
|
7235
7235
|
${indentation}`;
|
|
7236
7236
|
whitespace = " ";
|
|
7237
7237
|
}
|
|
@@ -7245,13 +7245,13 @@ ${indentation}`;
|
|
|
7245
7245
|
const tmp = stringifyFnReplacer(key3, value, stack, replacer, spacer, indentation);
|
|
7246
7246
|
if (tmp !== void 0) {
|
|
7247
7247
|
res += `${separator}${strEscape(key3)}:${whitespace}${tmp}`;
|
|
7248
|
-
separator =
|
|
7248
|
+
separator = join42;
|
|
7249
7249
|
}
|
|
7250
7250
|
}
|
|
7251
7251
|
if (keyLength > maximumBreadth) {
|
|
7252
7252
|
const removedKeys = keyLength - maximumBreadth;
|
|
7253
7253
|
res += `${separator}"...":${whitespace}"${getItemCount(removedKeys)} not stringified"`;
|
|
7254
|
-
separator =
|
|
7254
|
+
separator = join42;
|
|
7255
7255
|
}
|
|
7256
7256
|
if (spacer !== "" && separator.length > 1) {
|
|
7257
7257
|
res = `
|
|
@@ -7292,7 +7292,7 @@ ${originalIndentation}`;
|
|
|
7292
7292
|
}
|
|
7293
7293
|
const originalIndentation = indentation;
|
|
7294
7294
|
let res = "";
|
|
7295
|
-
let
|
|
7295
|
+
let join42 = ",";
|
|
7296
7296
|
if (Array.isArray(value)) {
|
|
7297
7297
|
if (value.length === 0) {
|
|
7298
7298
|
return "[]";
|
|
@@ -7305,7 +7305,7 @@ ${originalIndentation}`;
|
|
|
7305
7305
|
indentation += spacer;
|
|
7306
7306
|
res += `
|
|
7307
7307
|
${indentation}`;
|
|
7308
|
-
|
|
7308
|
+
join42 = `,
|
|
7309
7309
|
${indentation}`;
|
|
7310
7310
|
}
|
|
7311
7311
|
const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
|
|
@@ -7313,13 +7313,13 @@ ${indentation}`;
|
|
|
7313
7313
|
for (; i < maximumValuesToStringify - 1; i++) {
|
|
7314
7314
|
const tmp2 = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
|
|
7315
7315
|
res += tmp2 !== void 0 ? tmp2 : "null";
|
|
7316
|
-
res +=
|
|
7316
|
+
res += join42;
|
|
7317
7317
|
}
|
|
7318
7318
|
const tmp = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
|
|
7319
7319
|
res += tmp !== void 0 ? tmp : "null";
|
|
7320
7320
|
if (value.length - 1 > maximumBreadth) {
|
|
7321
7321
|
const removedKeys = value.length - maximumBreadth - 1;
|
|
7322
|
-
res += `${
|
|
7322
|
+
res += `${join42}"... ${getItemCount(removedKeys)} not stringified"`;
|
|
7323
7323
|
}
|
|
7324
7324
|
if (spacer !== "") {
|
|
7325
7325
|
res += `
|
|
@@ -7332,7 +7332,7 @@ ${originalIndentation}`;
|
|
|
7332
7332
|
let whitespace = "";
|
|
7333
7333
|
if (spacer !== "") {
|
|
7334
7334
|
indentation += spacer;
|
|
7335
|
-
|
|
7335
|
+
join42 = `,
|
|
7336
7336
|
${indentation}`;
|
|
7337
7337
|
whitespace = " ";
|
|
7338
7338
|
}
|
|
@@ -7341,7 +7341,7 @@ ${indentation}`;
|
|
|
7341
7341
|
const tmp = stringifyArrayReplacer(key3, value[key3], stack, replacer, spacer, indentation);
|
|
7342
7342
|
if (tmp !== void 0) {
|
|
7343
7343
|
res += `${separator}${strEscape(key3)}:${whitespace}${tmp}`;
|
|
7344
|
-
separator =
|
|
7344
|
+
separator = join42;
|
|
7345
7345
|
}
|
|
7346
7346
|
}
|
|
7347
7347
|
if (spacer !== "" && separator.length > 1) {
|
|
@@ -7399,20 +7399,20 @@ ${originalIndentation}`;
|
|
|
7399
7399
|
indentation += spacer;
|
|
7400
7400
|
let res2 = `
|
|
7401
7401
|
${indentation}`;
|
|
7402
|
-
const
|
|
7402
|
+
const join43 = `,
|
|
7403
7403
|
${indentation}`;
|
|
7404
7404
|
const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
|
|
7405
7405
|
let i = 0;
|
|
7406
7406
|
for (; i < maximumValuesToStringify - 1; i++) {
|
|
7407
7407
|
const tmp2 = stringifyIndent(String(i), value[i], stack, spacer, indentation);
|
|
7408
7408
|
res2 += tmp2 !== void 0 ? tmp2 : "null";
|
|
7409
|
-
res2 +=
|
|
7409
|
+
res2 += join43;
|
|
7410
7410
|
}
|
|
7411
7411
|
const tmp = stringifyIndent(String(i), value[i], stack, spacer, indentation);
|
|
7412
7412
|
res2 += tmp !== void 0 ? tmp : "null";
|
|
7413
7413
|
if (value.length - 1 > maximumBreadth) {
|
|
7414
7414
|
const removedKeys = value.length - maximumBreadth - 1;
|
|
7415
|
-
res2 += `${
|
|
7415
|
+
res2 += `${join43}"... ${getItemCount(removedKeys)} not stringified"`;
|
|
7416
7416
|
}
|
|
7417
7417
|
res2 += `
|
|
7418
7418
|
${originalIndentation}`;
|
|
@@ -7428,16 +7428,16 @@ ${originalIndentation}`;
|
|
|
7428
7428
|
return '"[Object]"';
|
|
7429
7429
|
}
|
|
7430
7430
|
indentation += spacer;
|
|
7431
|
-
const
|
|
7431
|
+
const join42 = `,
|
|
7432
7432
|
${indentation}`;
|
|
7433
7433
|
let res = "";
|
|
7434
7434
|
let separator = "";
|
|
7435
7435
|
let maximumPropertiesToStringify = Math.min(keyLength, maximumBreadth);
|
|
7436
7436
|
if (isTypedArrayWithEntries(value)) {
|
|
7437
|
-
res += stringifyTypedArray(value,
|
|
7437
|
+
res += stringifyTypedArray(value, join42, maximumBreadth);
|
|
7438
7438
|
keys = keys.slice(value.length);
|
|
7439
7439
|
maximumPropertiesToStringify -= value.length;
|
|
7440
|
-
separator =
|
|
7440
|
+
separator = join42;
|
|
7441
7441
|
}
|
|
7442
7442
|
if (deterministic) {
|
|
7443
7443
|
keys = sort(keys, comparator);
|
|
@@ -7448,13 +7448,13 @@ ${indentation}`;
|
|
|
7448
7448
|
const tmp = stringifyIndent(key3, value[key3], stack, spacer, indentation);
|
|
7449
7449
|
if (tmp !== void 0) {
|
|
7450
7450
|
res += `${separator}${strEscape(key3)}: ${tmp}`;
|
|
7451
|
-
separator =
|
|
7451
|
+
separator = join42;
|
|
7452
7452
|
}
|
|
7453
7453
|
}
|
|
7454
7454
|
if (keyLength > maximumBreadth) {
|
|
7455
7455
|
const removedKeys = keyLength - maximumBreadth;
|
|
7456
7456
|
res += `${separator}"...": "${getItemCount(removedKeys)} not stringified"`;
|
|
7457
|
-
separator =
|
|
7457
|
+
separator = join42;
|
|
7458
7458
|
}
|
|
7459
7459
|
if (separator !== "") {
|
|
7460
7460
|
res = `
|
|
@@ -9843,7 +9843,7 @@ var require_forwarded = __commonJS({
|
|
|
9843
9843
|
// node_modules/ipaddr.js/lib/ipaddr.js
|
|
9844
9844
|
var require_ipaddr = __commonJS({
|
|
9845
9845
|
"node_modules/ipaddr.js/lib/ipaddr.js"(exports2, module2) {
|
|
9846
|
-
(function(
|
|
9846
|
+
(function(root4) {
|
|
9847
9847
|
"use strict";
|
|
9848
9848
|
const ipv4Part = "(0?\\d+|0x[a-f0-9]+)";
|
|
9849
9849
|
const ipv4Regexes = {
|
|
@@ -10637,7 +10637,7 @@ var require_ipaddr = __commonJS({
|
|
|
10637
10637
|
if (typeof module2 !== "undefined" && module2.exports) {
|
|
10638
10638
|
module2.exports = ipaddr;
|
|
10639
10639
|
} else {
|
|
10640
|
-
|
|
10640
|
+
root4.ipaddr = ipaddr;
|
|
10641
10641
|
}
|
|
10642
10642
|
})(exports2);
|
|
10643
10643
|
}
|
|
@@ -15303,22 +15303,22 @@ var require_compile = __commonJS({
|
|
|
15303
15303
|
}
|
|
15304
15304
|
}
|
|
15305
15305
|
exports2.compileSchema = compileSchema;
|
|
15306
|
-
function resolveRef2(
|
|
15306
|
+
function resolveRef2(root4, baseId, ref) {
|
|
15307
15307
|
var _a2;
|
|
15308
15308
|
ref = (0, resolve_1.resolveUrl)(this.opts.uriResolver, baseId, ref);
|
|
15309
|
-
const schOrFunc =
|
|
15309
|
+
const schOrFunc = root4.refs[ref];
|
|
15310
15310
|
if (schOrFunc)
|
|
15311
15311
|
return schOrFunc;
|
|
15312
|
-
let _sch = resolve11.call(this,
|
|
15312
|
+
let _sch = resolve11.call(this, root4, ref);
|
|
15313
15313
|
if (_sch === void 0) {
|
|
15314
|
-
const schema = (_a2 =
|
|
15314
|
+
const schema = (_a2 = root4.localRefs) === null || _a2 === void 0 ? void 0 : _a2[ref];
|
|
15315
15315
|
const { schemaId } = this.opts;
|
|
15316
15316
|
if (schema)
|
|
15317
|
-
_sch = new SchemaEnv({ schema, schemaId, root:
|
|
15317
|
+
_sch = new SchemaEnv({ schema, schemaId, root: root4, baseId });
|
|
15318
15318
|
}
|
|
15319
15319
|
if (_sch === void 0)
|
|
15320
15320
|
return;
|
|
15321
|
-
return
|
|
15321
|
+
return root4.refs[ref] = inlineOrCompile.call(this, _sch);
|
|
15322
15322
|
}
|
|
15323
15323
|
exports2.resolveRef = resolveRef2;
|
|
15324
15324
|
function inlineOrCompile(sch) {
|
|
@@ -15336,23 +15336,23 @@ var require_compile = __commonJS({
|
|
|
15336
15336
|
function sameSchemaEnv(s1, s2) {
|
|
15337
15337
|
return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
|
|
15338
15338
|
}
|
|
15339
|
-
function resolve11(
|
|
15339
|
+
function resolve11(root4, ref) {
|
|
15340
15340
|
let sch;
|
|
15341
15341
|
while (typeof (sch = this.refs[ref]) == "string")
|
|
15342
15342
|
ref = sch;
|
|
15343
|
-
return sch || this.schemas[ref] || resolveSchema.call(this,
|
|
15343
|
+
return sch || this.schemas[ref] || resolveSchema.call(this, root4, ref);
|
|
15344
15344
|
}
|
|
15345
|
-
function resolveSchema(
|
|
15345
|
+
function resolveSchema(root4, ref) {
|
|
15346
15346
|
const p = this.opts.uriResolver.parse(ref);
|
|
15347
15347
|
const refPath = (0, resolve_1._getFullPath)(this.opts.uriResolver, p);
|
|
15348
|
-
let baseId = (0, resolve_1.getFullPath)(this.opts.uriResolver,
|
|
15349
|
-
if (Object.keys(
|
|
15350
|
-
return getJsonPointer.call(this, p,
|
|
15348
|
+
let baseId = (0, resolve_1.getFullPath)(this.opts.uriResolver, root4.baseId, void 0);
|
|
15349
|
+
if (Object.keys(root4.schema).length > 0 && refPath === baseId) {
|
|
15350
|
+
return getJsonPointer.call(this, p, root4);
|
|
15351
15351
|
}
|
|
15352
15352
|
const id = (0, resolve_1.normalizeId)(refPath);
|
|
15353
15353
|
const schOrRef = this.refs[id] || this.schemas[id];
|
|
15354
15354
|
if (typeof schOrRef == "string") {
|
|
15355
|
-
const sch = resolveSchema.call(this,
|
|
15355
|
+
const sch = resolveSchema.call(this, root4, schOrRef);
|
|
15356
15356
|
if (typeof (sch === null || sch === void 0 ? void 0 : sch.schema) !== "object")
|
|
15357
15357
|
return;
|
|
15358
15358
|
return getJsonPointer.call(this, p, sch);
|
|
@@ -15367,7 +15367,7 @@ var require_compile = __commonJS({
|
|
|
15367
15367
|
const schId = schema[schemaId];
|
|
15368
15368
|
if (schId)
|
|
15369
15369
|
baseId = (0, resolve_1.resolveUrl)(this.opts.uriResolver, baseId, schId);
|
|
15370
|
-
return new SchemaEnv({ schema, schemaId, root:
|
|
15370
|
+
return new SchemaEnv({ schema, schemaId, root: root4, baseId });
|
|
15371
15371
|
}
|
|
15372
15372
|
return getJsonPointer.call(this, p, schOrRef);
|
|
15373
15373
|
}
|
|
@@ -15379,7 +15379,7 @@ var require_compile = __commonJS({
|
|
|
15379
15379
|
"dependencies",
|
|
15380
15380
|
"definitions"
|
|
15381
15381
|
]);
|
|
15382
|
-
function getJsonPointer(parsedRef, { baseId, schema, root:
|
|
15382
|
+
function getJsonPointer(parsedRef, { baseId, schema, root: root4 }) {
|
|
15383
15383
|
var _a2;
|
|
15384
15384
|
if (((_a2 = parsedRef.fragment) === null || _a2 === void 0 ? void 0 : _a2[0]) !== "/")
|
|
15385
15385
|
return;
|
|
@@ -15398,10 +15398,10 @@ var require_compile = __commonJS({
|
|
|
15398
15398
|
let env2;
|
|
15399
15399
|
if (typeof schema != "boolean" && schema.$ref && !(0, util_1.schemaHasRulesButRef)(schema, this.RULES)) {
|
|
15400
15400
|
const $ref = (0, resolve_1.resolveUrl)(this.opts.uriResolver, baseId, schema.$ref);
|
|
15401
|
-
env2 = resolveSchema.call(this,
|
|
15401
|
+
env2 = resolveSchema.call(this, root4, $ref);
|
|
15402
15402
|
}
|
|
15403
15403
|
const { schemaId } = this.opts;
|
|
15404
|
-
env2 = env2 || new SchemaEnv({ schema, schemaId, root:
|
|
15404
|
+
env2 = env2 || new SchemaEnv({ schema, schemaId, root: root4, baseId });
|
|
15405
15405
|
if (env2.schema !== env2.root.schema)
|
|
15406
15406
|
return env2;
|
|
15407
15407
|
return void 0;
|
|
@@ -16530,8 +16530,8 @@ var require_core = __commonJS({
|
|
|
16530
16530
|
keyRef = sch;
|
|
16531
16531
|
if (sch === void 0) {
|
|
16532
16532
|
const { schemaId } = this.opts;
|
|
16533
|
-
const
|
|
16534
|
-
sch = compile_1.resolveSchema.call(this,
|
|
16533
|
+
const root4 = new compile_1.SchemaEnv({ schema: {}, schemaId });
|
|
16534
|
+
sch = compile_1.resolveSchema.call(this, root4, keyRef);
|
|
16535
16535
|
if (!sch)
|
|
16536
16536
|
return;
|
|
16537
16537
|
this.refs[keyRef] = sch;
|
|
@@ -16892,20 +16892,20 @@ var require_ref = __commonJS({
|
|
|
16892
16892
|
code(cxt) {
|
|
16893
16893
|
const { gen, schema: $ref, it } = cxt;
|
|
16894
16894
|
const { baseId, schemaEnv: env2, validateName, opts, self } = it;
|
|
16895
|
-
const { root:
|
|
16896
|
-
if (($ref === "#" || $ref === "#/") && baseId ===
|
|
16895
|
+
const { root: root4 } = env2;
|
|
16896
|
+
if (($ref === "#" || $ref === "#/") && baseId === root4.baseId)
|
|
16897
16897
|
return callRootRef();
|
|
16898
|
-
const schOrEnv = compile_1.resolveRef.call(self,
|
|
16898
|
+
const schOrEnv = compile_1.resolveRef.call(self, root4, baseId, $ref);
|
|
16899
16899
|
if (schOrEnv === void 0)
|
|
16900
16900
|
throw new ref_error_1.default(it.opts.uriResolver, baseId, $ref);
|
|
16901
16901
|
if (schOrEnv instanceof compile_1.SchemaEnv)
|
|
16902
16902
|
return callValidate(schOrEnv);
|
|
16903
16903
|
return inlineRefSchema(schOrEnv);
|
|
16904
16904
|
function callRootRef() {
|
|
16905
|
-
if (env2 ===
|
|
16905
|
+
if (env2 === root4)
|
|
16906
16906
|
return callRef(cxt, validateName, env2, env2.$async);
|
|
16907
|
-
const rootName = gen.scopeValue("root", { ref:
|
|
16908
|
-
return callRef(cxt, (0, codegen_1._)`${rootName}.validate`,
|
|
16907
|
+
const rootName = gen.scopeValue("root", { ref: root4 });
|
|
16908
|
+
return callRef(cxt, (0, codegen_1._)`${rootName}.validate`, root4, root4.$async);
|
|
16909
16909
|
}
|
|
16910
16910
|
function callValidate(sch) {
|
|
16911
16911
|
const v = getValidate(cxt, sch);
|
|
@@ -18945,7 +18945,7 @@ var require_ref2 = __commonJS({
|
|
|
18945
18945
|
code(cxt) {
|
|
18946
18946
|
(0, metadata_1.checkMetadata)(cxt);
|
|
18947
18947
|
const { gen, data, schema: ref, parentSchema, it } = cxt;
|
|
18948
|
-
const { schemaEnv: { root:
|
|
18948
|
+
const { schemaEnv: { root: root4 } } = it;
|
|
18949
18949
|
const valid = gen.name("valid");
|
|
18950
18950
|
if (parentSchema.nullable) {
|
|
18951
18951
|
gen.var(valid, (0, codegen_1._)`${data} === null`);
|
|
@@ -18957,7 +18957,7 @@ var require_ref2 = __commonJS({
|
|
|
18957
18957
|
cxt.ok(valid);
|
|
18958
18958
|
function validateJtdRef() {
|
|
18959
18959
|
var _a2;
|
|
18960
|
-
const refSchema = (_a2 =
|
|
18960
|
+
const refSchema = (_a2 = root4.schema.definitions) === null || _a2 === void 0 ? void 0 : _a2[ref];
|
|
18961
18961
|
if (!refSchema) {
|
|
18962
18962
|
throw new ref_error_1.default(it.opts.uriResolver, "", ref, `No definition ${ref}`);
|
|
18963
18963
|
}
|
|
@@ -18967,7 +18967,7 @@ var require_ref2 = __commonJS({
|
|
|
18967
18967
|
inlineRefSchema(refSchema);
|
|
18968
18968
|
}
|
|
18969
18969
|
function callValidate(schema) {
|
|
18970
|
-
const sch = compile_1.compileSchema.call(it.self, new compile_1.SchemaEnv({ schema, root:
|
|
18970
|
+
const sch = compile_1.compileSchema.call(it.self, new compile_1.SchemaEnv({ schema, root: root4, schemaPath: `/definitions/${ref}` }));
|
|
18971
18971
|
const v = (0, ref_1.getValidate)(cxt, sch);
|
|
18972
18972
|
const errsCount = gen.const("_errs", names_1.default.errors);
|
|
18973
18973
|
(0, ref_1.callRef)(cxt, v, sch, sch.$async);
|
|
@@ -19573,7 +19573,7 @@ var require_jtd_schema = __commonJS({
|
|
|
19573
19573
|
"node_modules/ajv/dist/refs/jtd-schema.js"(exports2) {
|
|
19574
19574
|
"use strict";
|
|
19575
19575
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
19576
|
-
var shared = (
|
|
19576
|
+
var shared = (root4) => {
|
|
19577
19577
|
const sch = {
|
|
19578
19578
|
nullable: { type: "boolean" },
|
|
19579
19579
|
metadata: {
|
|
@@ -19583,20 +19583,20 @@ var require_jtd_schema = __commonJS({
|
|
|
19583
19583
|
additionalProperties: true
|
|
19584
19584
|
}
|
|
19585
19585
|
};
|
|
19586
|
-
if (
|
|
19586
|
+
if (root4)
|
|
19587
19587
|
sch.definitions = { values: { ref: "schema" } };
|
|
19588
19588
|
return sch;
|
|
19589
19589
|
};
|
|
19590
|
-
var emptyForm = (
|
|
19591
|
-
optionalProperties: shared(
|
|
19590
|
+
var emptyForm = (root4) => ({
|
|
19591
|
+
optionalProperties: shared(root4)
|
|
19592
19592
|
});
|
|
19593
|
-
var refForm = (
|
|
19593
|
+
var refForm = (root4) => ({
|
|
19594
19594
|
properties: {
|
|
19595
19595
|
ref: { type: "string" }
|
|
19596
19596
|
},
|
|
19597
|
-
optionalProperties: shared(
|
|
19597
|
+
optionalProperties: shared(root4)
|
|
19598
19598
|
});
|
|
19599
|
-
var typeForm = (
|
|
19599
|
+
var typeForm = (root4) => ({
|
|
19600
19600
|
properties: {
|
|
19601
19601
|
type: {
|
|
19602
19602
|
enum: [
|
|
@@ -19614,40 +19614,40 @@ var require_jtd_schema = __commonJS({
|
|
|
19614
19614
|
]
|
|
19615
19615
|
}
|
|
19616
19616
|
},
|
|
19617
|
-
optionalProperties: shared(
|
|
19617
|
+
optionalProperties: shared(root4)
|
|
19618
19618
|
});
|
|
19619
|
-
var enumForm = (
|
|
19619
|
+
var enumForm = (root4) => ({
|
|
19620
19620
|
properties: {
|
|
19621
19621
|
enum: { elements: { type: "string" } }
|
|
19622
19622
|
},
|
|
19623
|
-
optionalProperties: shared(
|
|
19623
|
+
optionalProperties: shared(root4)
|
|
19624
19624
|
});
|
|
19625
|
-
var elementsForm = (
|
|
19625
|
+
var elementsForm = (root4) => ({
|
|
19626
19626
|
properties: {
|
|
19627
19627
|
elements: { ref: "schema" }
|
|
19628
19628
|
},
|
|
19629
|
-
optionalProperties: shared(
|
|
19629
|
+
optionalProperties: shared(root4)
|
|
19630
19630
|
});
|
|
19631
|
-
var propertiesForm = (
|
|
19631
|
+
var propertiesForm = (root4) => ({
|
|
19632
19632
|
properties: {
|
|
19633
19633
|
properties: { values: { ref: "schema" } }
|
|
19634
19634
|
},
|
|
19635
19635
|
optionalProperties: {
|
|
19636
19636
|
optionalProperties: { values: { ref: "schema" } },
|
|
19637
19637
|
additionalProperties: { type: "boolean" },
|
|
19638
|
-
...shared(
|
|
19638
|
+
...shared(root4)
|
|
19639
19639
|
}
|
|
19640
19640
|
});
|
|
19641
|
-
var optionalPropertiesForm = (
|
|
19641
|
+
var optionalPropertiesForm = (root4) => ({
|
|
19642
19642
|
properties: {
|
|
19643
19643
|
optionalProperties: { values: { ref: "schema" } }
|
|
19644
19644
|
},
|
|
19645
19645
|
optionalProperties: {
|
|
19646
19646
|
additionalProperties: { type: "boolean" },
|
|
19647
|
-
...shared(
|
|
19647
|
+
...shared(root4)
|
|
19648
19648
|
}
|
|
19649
19649
|
});
|
|
19650
|
-
var discriminatorForm = (
|
|
19650
|
+
var discriminatorForm = (root4) => ({
|
|
19651
19651
|
properties: {
|
|
19652
19652
|
discriminator: { type: "string" },
|
|
19653
19653
|
mapping: {
|
|
@@ -19658,15 +19658,15 @@ var require_jtd_schema = __commonJS({
|
|
|
19658
19658
|
}
|
|
19659
19659
|
}
|
|
19660
19660
|
},
|
|
19661
|
-
optionalProperties: shared(
|
|
19661
|
+
optionalProperties: shared(root4)
|
|
19662
19662
|
});
|
|
19663
|
-
var valuesForm = (
|
|
19663
|
+
var valuesForm = (root4) => ({
|
|
19664
19664
|
properties: {
|
|
19665
19665
|
values: { ref: "schema" }
|
|
19666
19666
|
},
|
|
19667
|
-
optionalProperties: shared(
|
|
19667
|
+
optionalProperties: shared(root4)
|
|
19668
19668
|
});
|
|
19669
|
-
var schema = (
|
|
19669
|
+
var schema = (root4) => ({
|
|
19670
19670
|
metadata: {
|
|
19671
19671
|
union: [
|
|
19672
19672
|
emptyForm,
|
|
@@ -19678,7 +19678,7 @@ var require_jtd_schema = __commonJS({
|
|
|
19678
19678
|
optionalPropertiesForm,
|
|
19679
19679
|
discriminatorForm,
|
|
19680
19680
|
valuesForm
|
|
19681
|
-
].map((s) => s(
|
|
19681
|
+
].map((s) => s(root4))
|
|
19682
19682
|
}
|
|
19683
19683
|
});
|
|
19684
19684
|
var jtdMetaSchema = {
|
|
@@ -19954,8 +19954,8 @@ var require_serialize = __commonJS({
|
|
|
19954
19954
|
throw new ref_error_1.default(self.opts.uriResolver, "", ref, `No definition ${ref}`);
|
|
19955
19955
|
if (!(0, ref_1.hasRef)(refSchema))
|
|
19956
19956
|
return serializeCode({ ...cxt, schema: refSchema });
|
|
19957
|
-
const { root:
|
|
19958
|
-
const sch = compileSerializer.call(self, new __1.SchemaEnv({ schema: refSchema, root:
|
|
19957
|
+
const { root: root4 } = schemaEnv;
|
|
19958
|
+
const sch = compileSerializer.call(self, new __1.SchemaEnv({ schema: refSchema, root: root4 }), definitions);
|
|
19959
19959
|
gen.add(names_1.default.json, (0, codegen_1._)`${getSerialize(gen, sch)}(${data})`);
|
|
19960
19960
|
}
|
|
19961
19961
|
function getSerialize(gen, sch) {
|
|
@@ -20452,8 +20452,8 @@ var require_parse = __commonJS({
|
|
|
20452
20452
|
throw new ref_error_1.default(self.opts.uriResolver, "", ref, `No definition ${ref}`);
|
|
20453
20453
|
if (!(0, ref_1.hasRef)(refSchema))
|
|
20454
20454
|
return parseCode({ ...cxt, schema: refSchema });
|
|
20455
|
-
const { root:
|
|
20456
|
-
const sch = compileParser.call(self, new __1.SchemaEnv({ schema: refSchema, root:
|
|
20455
|
+
const { root: root4 } = schemaEnv;
|
|
20456
|
+
const sch = compileParser.call(self, new __1.SchemaEnv({ schema: refSchema, root: root4 }), definitions);
|
|
20457
20457
|
partialParse(cxt, getParser(gen, sch), true);
|
|
20458
20458
|
}
|
|
20459
20459
|
function getParser(gen, sch) {
|
|
@@ -28323,9 +28323,9 @@ ${prefix}`);
|
|
|
28323
28323
|
buildObjectTree(node.wildcardChild, tree, "*", options);
|
|
28324
28324
|
}
|
|
28325
28325
|
}
|
|
28326
|
-
function prettyPrintTree(
|
|
28326
|
+
function prettyPrintTree(root4, options) {
|
|
28327
28327
|
const objectTree = {};
|
|
28328
|
-
buildObjectTree(
|
|
28328
|
+
buildObjectTree(root4, objectTree, root4.prefix, options);
|
|
28329
28329
|
return printObjectTree(objectTree);
|
|
28330
28330
|
}
|
|
28331
28331
|
module2.exports = { prettyPrintTree };
|
|
@@ -38131,13 +38131,13 @@ var require_commonjs5 = __commonJS({
|
|
|
38131
38131
|
*
|
|
38132
38132
|
* @internal
|
|
38133
38133
|
*/
|
|
38134
|
-
constructor(name, type = UNKNOWN,
|
|
38134
|
+
constructor(name, type = UNKNOWN, root4, roots, nocase, children, opts) {
|
|
38135
38135
|
this.name = name;
|
|
38136
38136
|
this.#matchName = nocase ? normalizeNocase(name) : normalize2(name);
|
|
38137
38137
|
this.#type = type & TYPEMASK;
|
|
38138
38138
|
this.nocase = nocase;
|
|
38139
38139
|
this.roots = roots;
|
|
38140
|
-
this.root =
|
|
38140
|
+
this.root = root4 || this;
|
|
38141
38141
|
this.#children = children;
|
|
38142
38142
|
this.#fullpath = opts.fullpath;
|
|
38143
38143
|
this.#relative = opts.relative;
|
|
@@ -38916,8 +38916,8 @@ var require_commonjs5 = __commonJS({
|
|
|
38916
38916
|
*
|
|
38917
38917
|
* @internal
|
|
38918
38918
|
*/
|
|
38919
|
-
constructor(name, type = UNKNOWN,
|
|
38920
|
-
super(name, type,
|
|
38919
|
+
constructor(name, type = UNKNOWN, root4, roots, nocase, children, opts) {
|
|
38920
|
+
super(name, type, root4, roots, nocase, children, opts);
|
|
38921
38921
|
}
|
|
38922
38922
|
/**
|
|
38923
38923
|
* @internal
|
|
@@ -38939,9 +38939,9 @@ var require_commonjs5 = __commonJS({
|
|
|
38939
38939
|
if (rootPath === this.root.name) {
|
|
38940
38940
|
return this.root;
|
|
38941
38941
|
}
|
|
38942
|
-
for (const [compare,
|
|
38942
|
+
for (const [compare, root4] of Object.entries(this.roots)) {
|
|
38943
38943
|
if (this.sameRoot(rootPath, compare)) {
|
|
38944
|
-
return this.roots[rootPath] =
|
|
38944
|
+
return this.roots[rootPath] = root4;
|
|
38945
38945
|
}
|
|
38946
38946
|
}
|
|
38947
38947
|
return this.roots[rootPath] = new PathScurryWin32(rootPath, this).root;
|
|
@@ -38970,8 +38970,8 @@ var require_commonjs5 = __commonJS({
|
|
|
38970
38970
|
*
|
|
38971
38971
|
* @internal
|
|
38972
38972
|
*/
|
|
38973
|
-
constructor(name, type = UNKNOWN,
|
|
38974
|
-
super(name, type,
|
|
38973
|
+
constructor(name, type = UNKNOWN, root4, roots, nocase, children, opts) {
|
|
38974
|
+
super(name, type, root4, roots, nocase, children, opts);
|
|
38975
38975
|
}
|
|
38976
38976
|
/**
|
|
38977
38977
|
* @internal
|
|
@@ -40004,10 +40004,10 @@ var require_processor = __commonJS({
|
|
|
40004
40004
|
const processingSet = patterns.map((p) => [target, p]);
|
|
40005
40005
|
for (let [t, pattern] of processingSet) {
|
|
40006
40006
|
this.hasWalkedCache.storeWalked(t, pattern);
|
|
40007
|
-
const
|
|
40007
|
+
const root4 = pattern.root();
|
|
40008
40008
|
const absolute = pattern.isAbsolute() && this.opts.absolute !== false;
|
|
40009
|
-
if (
|
|
40010
|
-
t = t.resolve(
|
|
40009
|
+
if (root4) {
|
|
40010
|
+
t = t.resolve(root4 === "/" && this.opts.root !== void 0 ? this.opts.root : root4);
|
|
40011
40011
|
const rest2 = pattern.rest();
|
|
40012
40012
|
if (!rest2) {
|
|
40013
40013
|
this.matches.add(t, true, false);
|
|
@@ -41991,7 +41991,7 @@ var require_send = __commonJS({
|
|
|
41991
41991
|
var { parseTokenList } = require_parseTokenList();
|
|
41992
41992
|
var { createHttpError } = require_createHttpError();
|
|
41993
41993
|
var extname4 = path.extname;
|
|
41994
|
-
var
|
|
41994
|
+
var join42 = path.join;
|
|
41995
41995
|
var normalize2 = path.normalize;
|
|
41996
41996
|
var resolve11 = path.resolve;
|
|
41997
41997
|
var sep6 = path.sep;
|
|
@@ -42040,7 +42040,7 @@ var require_send = __commonJS({
|
|
|
42040
42040
|
const lastModified = options.lastModified !== void 0 ? Boolean(options.lastModified) : true;
|
|
42041
42041
|
const maxage = normalizeMaxAge(options.maxAge ?? options.maxage);
|
|
42042
42042
|
const maxContentRangeChunkSize = options.maxContentRangeChunkSize !== void 0 ? Number(options.maxContentRangeChunkSize) : null;
|
|
42043
|
-
const
|
|
42043
|
+
const root4 = options.root ? resolve11(options.root) : null;
|
|
42044
42044
|
const highWaterMark = Number.isSafeInteger(options.highWaterMark) && options.highWaterMark > 0 ? options.highWaterMark : null;
|
|
42045
42045
|
return {
|
|
42046
42046
|
acceptRanges,
|
|
@@ -42054,13 +42054,13 @@ var require_send = __commonJS({
|
|
|
42054
42054
|
lastModified,
|
|
42055
42055
|
maxage,
|
|
42056
42056
|
maxContentRangeChunkSize,
|
|
42057
|
-
root:
|
|
42057
|
+
root: root4,
|
|
42058
42058
|
highWaterMark,
|
|
42059
42059
|
start: options.start,
|
|
42060
42060
|
end: options.end
|
|
42061
42061
|
};
|
|
42062
42062
|
}
|
|
42063
|
-
function normalizePath2(_path,
|
|
42063
|
+
function normalizePath2(_path, root4) {
|
|
42064
42064
|
let path2 = decode(_path);
|
|
42065
42065
|
if (path2 == null) {
|
|
42066
42066
|
return { statusCode: 400 };
|
|
@@ -42069,7 +42069,7 @@ var require_send = __commonJS({
|
|
|
42069
42069
|
return { statusCode: 400 };
|
|
42070
42070
|
}
|
|
42071
42071
|
let parts;
|
|
42072
|
-
if (
|
|
42072
|
+
if (root4 !== null) {
|
|
42073
42073
|
if (path2) {
|
|
42074
42074
|
path2 = normalize2("." + sep6 + path2);
|
|
42075
42075
|
}
|
|
@@ -42078,7 +42078,7 @@ var require_send = __commonJS({
|
|
|
42078
42078
|
return { statusCode: 403 };
|
|
42079
42079
|
}
|
|
42080
42080
|
parts = path2.split(sep6);
|
|
42081
|
-
path2 = normalize2(
|
|
42081
|
+
path2 = normalize2(join42(root4, path2));
|
|
42082
42082
|
} else {
|
|
42083
42083
|
if (UP_PATH_REGEXP.test(path2)) {
|
|
42084
42084
|
debug('malicious path "%s"', path2);
|
|
@@ -42361,7 +42361,7 @@ var require_send = __commonJS({
|
|
|
42361
42361
|
let err2;
|
|
42362
42362
|
for (let i = 0; i < options.index.length; i++) {
|
|
42363
42363
|
const index = options.index[i];
|
|
42364
|
-
const p =
|
|
42364
|
+
const p = join42(path2, index);
|
|
42365
42365
|
const { error, stat: stat4 } = await tryStat(p);
|
|
42366
42366
|
if (error) {
|
|
42367
42367
|
err2 = error;
|
|
@@ -42973,9 +42973,9 @@ var require_dirList = __commonJS({
|
|
|
42973
42973
|
* @param {string} root fs root path
|
|
42974
42974
|
* @param {string} route request route
|
|
42975
42975
|
*/
|
|
42976
|
-
path: function(
|
|
42976
|
+
path: function(root4, route) {
|
|
42977
42977
|
const _route = route[route.length - 1] === "/" ? route + "none" : route;
|
|
42978
|
-
return path.dirname(path.join(
|
|
42978
|
+
return path.dirname(path.join(root4, _route));
|
|
42979
42979
|
},
|
|
42980
42980
|
/**
|
|
42981
42981
|
* validate options
|
|
@@ -43075,12 +43075,12 @@ var require_static = __commonJS({
|
|
|
43075
43075
|
if (opts.decorateReply !== false) {
|
|
43076
43076
|
fastify.decorateReply("sendFile", function(filePath, rootPath, options) {
|
|
43077
43077
|
const opts2 = typeof rootPath === "object" ? rootPath : options;
|
|
43078
|
-
const
|
|
43078
|
+
const root4 = typeof rootPath === "string" ? rootPath : opts2?.root;
|
|
43079
43079
|
pumpSendToReply(
|
|
43080
43080
|
this.request,
|
|
43081
43081
|
this,
|
|
43082
43082
|
filePath,
|
|
43083
|
-
|
|
43083
|
+
root4 || sendOptions.root,
|
|
43084
43084
|
0,
|
|
43085
43085
|
opts2
|
|
43086
43086
|
);
|
|
@@ -43089,10 +43089,10 @@ var require_static = __commonJS({
|
|
|
43089
43089
|
fastify.decorateReply(
|
|
43090
43090
|
"download",
|
|
43091
43091
|
function(filePath, fileName, options = {}) {
|
|
43092
|
-
const { root:
|
|
43092
|
+
const { root: root4, ...opts2 } = typeof fileName === "object" ? fileName : options;
|
|
43093
43093
|
fileName = typeof fileName === "string" ? fileName : filePath;
|
|
43094
43094
|
this.header("content-disposition", contentDisposition(fileName));
|
|
43095
|
-
pumpSendToReply(this.request, this, filePath,
|
|
43095
|
+
pumpSendToReply(this.request, this, filePath, root4, 0, opts2);
|
|
43096
43096
|
return this;
|
|
43097
43097
|
}
|
|
43098
43098
|
);
|
|
@@ -43325,25 +43325,25 @@ var require_static = __commonJS({
|
|
|
43325
43325
|
return pumpSendToReply(req, reply, routeConfig.file, routeConfig.rootPath);
|
|
43326
43326
|
}
|
|
43327
43327
|
}
|
|
43328
|
-
function normalizeRoot(
|
|
43329
|
-
if (
|
|
43330
|
-
return
|
|
43328
|
+
function normalizeRoot(root4) {
|
|
43329
|
+
if (root4 === void 0) {
|
|
43330
|
+
return root4;
|
|
43331
43331
|
}
|
|
43332
|
-
if (
|
|
43333
|
-
return fileURLToPath6(
|
|
43332
|
+
if (root4 instanceof URL && root4.protocol === "file:") {
|
|
43333
|
+
return fileURLToPath6(root4);
|
|
43334
43334
|
}
|
|
43335
|
-
if (Array.isArray(
|
|
43335
|
+
if (Array.isArray(root4)) {
|
|
43336
43336
|
const result = [];
|
|
43337
|
-
for (let i = 0, il =
|
|
43338
|
-
if (
|
|
43339
|
-
result.push(fileURLToPath6(
|
|
43337
|
+
for (let i = 0, il = root4.length; i < il; ++i) {
|
|
43338
|
+
if (root4[i] instanceof URL && root4[i].protocol === "file:") {
|
|
43339
|
+
result.push(fileURLToPath6(root4[i]));
|
|
43340
43340
|
} else {
|
|
43341
|
-
result.push(
|
|
43341
|
+
result.push(root4[i]);
|
|
43342
43342
|
}
|
|
43343
43343
|
}
|
|
43344
43344
|
return result;
|
|
43345
43345
|
}
|
|
43346
|
-
return
|
|
43346
|
+
return root4;
|
|
43347
43347
|
}
|
|
43348
43348
|
function checkRootPathForErrors(fastify, rootPath) {
|
|
43349
43349
|
if (rootPath === void 0) {
|
|
@@ -43394,10 +43394,10 @@ var require_static = __commonJS({
|
|
|
43394
43394
|
}
|
|
43395
43395
|
return `${type}; charset=utf-8`;
|
|
43396
43396
|
}
|
|
43397
|
-
function findIndexFile(pathname,
|
|
43397
|
+
function findIndexFile(pathname, root4, indexFiles = ["index.html"]) {
|
|
43398
43398
|
if (Array.isArray(indexFiles)) {
|
|
43399
43399
|
return indexFiles.find((filename) => {
|
|
43400
|
-
const p = path.join(
|
|
43400
|
+
const p = path.join(root4, pathname, filename);
|
|
43401
43401
|
try {
|
|
43402
43402
|
const stats = statSync17(p);
|
|
43403
43403
|
return !stats.isDirectory();
|
|
@@ -43841,9 +43841,9 @@ var require_anchors = __commonJS({
|
|
|
43841
43841
|
}
|
|
43842
43842
|
return true;
|
|
43843
43843
|
}
|
|
43844
|
-
function anchorNames(
|
|
43844
|
+
function anchorNames(root4) {
|
|
43845
43845
|
const anchors = /* @__PURE__ */ new Set();
|
|
43846
|
-
visit.visit(
|
|
43846
|
+
visit.visit(root4, {
|
|
43847
43847
|
Value(_key, node) {
|
|
43848
43848
|
if (node.anchor)
|
|
43849
43849
|
anchors.add(node.anchor);
|
|
@@ -50827,9 +50827,9 @@ var import_node_readline2 = require("node:readline");
|
|
|
50827
50827
|
|
|
50828
50828
|
// index.ts
|
|
50829
50829
|
var import_node_url5 = require("node:url");
|
|
50830
|
-
var
|
|
50831
|
-
var
|
|
50832
|
-
var
|
|
50830
|
+
var import_node_path43 = require("node:path");
|
|
50831
|
+
var import_node_os26 = require("node:os");
|
|
50832
|
+
var import_node_fs46 = require("node:fs");
|
|
50833
50833
|
var import_node_child_process9 = require("node:child_process");
|
|
50834
50834
|
|
|
50835
50835
|
// log.mjs
|
|
@@ -50904,8 +50904,8 @@ var MAX_BYTES2 = 100 * 1024 * 1024;
|
|
|
50904
50904
|
var VisualInputError = class extends Error {
|
|
50905
50905
|
};
|
|
50906
50906
|
function inputsDir() {
|
|
50907
|
-
const
|
|
50908
|
-
return (0, import_node_path2.join)(
|
|
50907
|
+
const root4 = process.env.FLOLESS_HOME ?? (0, import_node_path2.join)((0, import_node_os2.homedir)(), ".floless");
|
|
50908
|
+
return (0, import_node_path2.join)(root4, "inputs");
|
|
50909
50909
|
}
|
|
50910
50910
|
function sniffExt(buf) {
|
|
50911
50911
|
if (buf.length >= 8 && buf[0] === 137 && buf[1] === 80 && buf[2] === 78 && buf[3] === 71) return "png";
|
|
@@ -50937,9 +50937,9 @@ function storeVisualInput(appId, dataUrl) {
|
|
|
50937
50937
|
const sha2563 = (0, import_node_crypto.createHash)("sha256").update(buf).digest("hex");
|
|
50938
50938
|
const dir = (0, import_node_path2.join)(inputsDir(), appId);
|
|
50939
50939
|
const path = (0, import_node_path2.join)(dir, `${sha2563}.${ext}`);
|
|
50940
|
-
const
|
|
50940
|
+
const root4 = (0, import_node_path2.resolve)(inputsDir());
|
|
50941
50941
|
const target = (0, import_node_path2.resolve)(path);
|
|
50942
|
-
if (target !==
|
|
50942
|
+
if (target !== root4 && !target.startsWith(root4 + import_node_path2.sep)) {
|
|
50943
50943
|
throw new VisualInputError("refusing to write outside the inputs root");
|
|
50944
50944
|
}
|
|
50945
50945
|
(0, import_node_fs3.mkdirSync)(dir, { recursive: true });
|
|
@@ -50970,9 +50970,9 @@ function storeIfcInput(appId, dataUrl) {
|
|
|
50970
50970
|
const sha2563 = (0, import_node_crypto.createHash)("sha256").update(buf).digest("hex");
|
|
50971
50971
|
const dir = (0, import_node_path2.join)(inputsDir(), appId);
|
|
50972
50972
|
const path = (0, import_node_path2.join)(dir, `${sha2563}.${ext}`);
|
|
50973
|
-
const
|
|
50973
|
+
const root4 = (0, import_node_path2.resolve)(inputsDir());
|
|
50974
50974
|
const target = (0, import_node_path2.resolve)(path);
|
|
50975
|
-
if (target !==
|
|
50975
|
+
if (target !== root4 && !target.startsWith(root4 + import_node_path2.sep)) {
|
|
50976
50976
|
throw new VisualInputError("refusing to write outside the inputs root");
|
|
50977
50977
|
}
|
|
50978
50978
|
(0, import_node_fs3.mkdirSync)(dir, { recursive: true });
|
|
@@ -50985,10 +50985,10 @@ function storeIfcInput(appId, dataUrl) {
|
|
|
50985
50985
|
}
|
|
50986
50986
|
function ifcInputPath(appId, sha2563) {
|
|
50987
50987
|
if (!safeSegment(appId) || !safeSegment(sha2563) || !/^[a-f0-9]{64}$/i.test(sha2563)) return null;
|
|
50988
|
-
const
|
|
50988
|
+
const root4 = (0, import_node_path2.resolve)(inputsDir());
|
|
50989
50989
|
for (const ext of ["ifc", "ifczip"]) {
|
|
50990
50990
|
const path = (0, import_node_path2.resolve)((0, import_node_path2.join)(inputsDir(), appId, `${sha2563}.${ext}`));
|
|
50991
|
-
if ((path ===
|
|
50991
|
+
if ((path === root4 || path.startsWith(root4 + import_node_path2.sep)) && (0, import_node_fs3.existsSync)(path)) return path;
|
|
50992
50992
|
}
|
|
50993
50993
|
return null;
|
|
50994
50994
|
}
|
|
@@ -51414,12 +51414,12 @@ async function withLifecycleLock(kind, key, fn, options = {}) {
|
|
|
51414
51414
|
|
|
51415
51415
|
// app-origin-store.ts
|
|
51416
51416
|
function storeFile() {
|
|
51417
|
-
const
|
|
51418
|
-
return (0, import_node_path4.join)(
|
|
51417
|
+
const root4 = process.env.FLOLESS_HOME ?? (0, import_node_path4.join)((0, import_node_os4.homedir)(), ".floless");
|
|
51418
|
+
return (0, import_node_path4.join)(root4, "app-origin.json");
|
|
51419
51419
|
}
|
|
51420
51420
|
function renameJournalDir() {
|
|
51421
|
-
const
|
|
51422
|
-
return (0, import_node_path4.join)(
|
|
51421
|
+
const root4 = process.env.FLOLESS_HOME ?? (0, import_node_path4.join)((0, import_node_os4.homedir)(), ".floless");
|
|
51422
|
+
return (0, import_node_path4.join)(root4, "app-origin-renames");
|
|
51423
51423
|
}
|
|
51424
51424
|
function syncDirectoryBestEffort(dir) {
|
|
51425
51425
|
try {
|
|
@@ -52164,8 +52164,8 @@ function resolveInvoker() {
|
|
|
52164
52164
|
return { head: [nodeExe(), (0, import_node_path6.join)(envDir, "scripts/bin/aware.js")], shell: false, pkgDir: envDir };
|
|
52165
52165
|
}
|
|
52166
52166
|
try {
|
|
52167
|
-
const
|
|
52168
|
-
const pkgDir = (0, import_node_path6.join)(
|
|
52167
|
+
const root4 = (0, import_node_child_process2.execFileSync)("npm", ["root", "-g"], { encoding: "utf8", shell: process.platform === "win32", windowsHide: true, timeout: 1e4 }).trim();
|
|
52168
|
+
const pkgDir = (0, import_node_path6.join)(root4, "@aware-aeco", "cli");
|
|
52169
52169
|
const bin = (0, import_node_path6.join)(pkgDir, "scripts/bin/aware.js");
|
|
52170
52170
|
if ((0, import_node_fs7.existsSync)(bin)) return { head: [nodeExe(), bin], shell: false, pkgDir };
|
|
52171
52171
|
} catch {
|
|
@@ -53792,7 +53792,7 @@ function appVersion() {
|
|
|
53792
53792
|
return resolveVersion({
|
|
53793
53793
|
isSea: isSea2(),
|
|
53794
53794
|
sqVersionXml: readSqVersionXml(),
|
|
53795
|
-
define: true ? "0.109.
|
|
53795
|
+
define: true ? "0.109.3" : void 0,
|
|
53796
53796
|
pkgVersion: readPkgVersion()
|
|
53797
53797
|
});
|
|
53798
53798
|
}
|
|
@@ -53802,7 +53802,7 @@ function resolveChannel(s) {
|
|
|
53802
53802
|
return "dev";
|
|
53803
53803
|
}
|
|
53804
53804
|
function appChannel() {
|
|
53805
|
-
return resolveChannel({ isSea: isSea2(), define: true ? "0.109.
|
|
53805
|
+
return resolveChannel({ isSea: isSea2(), define: true ? "0.109.3" : void 0 });
|
|
53806
53806
|
}
|
|
53807
53807
|
|
|
53808
53808
|
// workflow-update.ts
|
|
@@ -53905,12 +53905,12 @@ function loadTemplates(roots) {
|
|
|
53905
53905
|
return out;
|
|
53906
53906
|
}
|
|
53907
53907
|
function backupDir(id, version, ts) {
|
|
53908
|
-
const
|
|
53908
|
+
const root4 = process.env.FLOLESS_HOME ?? (0, import_node_path10.join)((0, import_node_os10.homedir)(), ".floless");
|
|
53909
53909
|
const safe2 = (s) => {
|
|
53910
53910
|
const c = String(s).replace(/[^0-9A-Za-z._-]/g, "_");
|
|
53911
53911
|
return /^\.+$/.test(c) ? "_" : c || "_";
|
|
53912
53912
|
};
|
|
53913
|
-
return (0, import_node_path10.join)(
|
|
53913
|
+
return (0, import_node_path10.join)(root4, "app-backups", safe2(id), `${safe2(version)}-${ts}`);
|
|
53914
53914
|
}
|
|
53915
53915
|
|
|
53916
53916
|
// oauth-presets.ts
|
|
@@ -54022,10 +54022,10 @@ function validate(doc, schema) {
|
|
|
54022
54022
|
function isPlainObject(v) {
|
|
54023
54023
|
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
54024
54024
|
}
|
|
54025
|
-
function resolveRef(
|
|
54025
|
+
function resolveRef(root4, ref) {
|
|
54026
54026
|
const m = /^#\/\$defs\/(.+)$/.exec(ref);
|
|
54027
54027
|
if (!m) return null;
|
|
54028
|
-
return
|
|
54028
|
+
return root4.$defs?.[m[1]] ?? null;
|
|
54029
54029
|
}
|
|
54030
54030
|
function typeMatches(value, t) {
|
|
54031
54031
|
switch (t) {
|
|
@@ -54061,14 +54061,14 @@ function deepEqual(a, b) {
|
|
|
54061
54061
|
}
|
|
54062
54062
|
return false;
|
|
54063
54063
|
}
|
|
54064
|
-
function walk(value, node,
|
|
54064
|
+
function walk(value, node, root4, path, errors) {
|
|
54065
54065
|
if (node.$ref) {
|
|
54066
|
-
const target = resolveRef(
|
|
54066
|
+
const target = resolveRef(root4, node.$ref);
|
|
54067
54067
|
if (!target) {
|
|
54068
54068
|
errors.push({ path, message: `unresolved $ref ${node.$ref}` });
|
|
54069
54069
|
return;
|
|
54070
54070
|
}
|
|
54071
|
-
walk(value, target,
|
|
54071
|
+
walk(value, target, root4, path, errors);
|
|
54072
54072
|
return;
|
|
54073
54073
|
}
|
|
54074
54074
|
if (node.oneOf) {
|
|
@@ -54076,7 +54076,7 @@ function walk(value, node, root3, path, errors) {
|
|
|
54076
54076
|
let closest = null;
|
|
54077
54077
|
for (const candidate of node.oneOf) {
|
|
54078
54078
|
const candidateErrors = [];
|
|
54079
|
-
walk(value, candidate,
|
|
54079
|
+
walk(value, candidate, root4, path, candidateErrors);
|
|
54080
54080
|
if (candidateErrors.length === 0) matches++;
|
|
54081
54081
|
else if (!closest || candidateErrors.length < closest.length) closest = candidateErrors;
|
|
54082
54082
|
}
|
|
@@ -54117,11 +54117,11 @@ function walk(value, node, root3, path, errors) {
|
|
|
54117
54117
|
const ap = node.additionalProperties;
|
|
54118
54118
|
for (const key of Object.keys(value)) {
|
|
54119
54119
|
if (Object.hasOwn(props, key)) {
|
|
54120
|
-
walk(value[key], props[key],
|
|
54120
|
+
walk(value[key], props[key], root4, `${path}.${key}`, errors);
|
|
54121
54121
|
} else if (ap === false) {
|
|
54122
54122
|
errors.push({ path: `${path}.${key}`, message: "additional property not allowed" });
|
|
54123
54123
|
} else if (ap && typeof ap === "object") {
|
|
54124
|
-
walk(value[key], ap,
|
|
54124
|
+
walk(value[key], ap, root4, `${path}.${key}`, errors);
|
|
54125
54125
|
}
|
|
54126
54126
|
}
|
|
54127
54127
|
}
|
|
@@ -54133,7 +54133,7 @@ function walk(value, node, root3, path, errors) {
|
|
|
54133
54133
|
errors.push({ path, message: `expected at most ${node.maxItems} items, got ${value.length}` });
|
|
54134
54134
|
}
|
|
54135
54135
|
if (node.items) {
|
|
54136
|
-
value.forEach((el, i) => walk(el, node.items,
|
|
54136
|
+
value.forEach((el, i) => walk(el, node.items, root4, `${path}[${i}]`, errors));
|
|
54137
54137
|
}
|
|
54138
54138
|
}
|
|
54139
54139
|
}
|
|
@@ -54343,9 +54343,9 @@ function gridLines(g) {
|
|
|
54343
54343
|
for (let i = 0; i < g.lines.length; i++) {
|
|
54344
54344
|
const l = g.lines[i] || {}, a = pt2(l.a), b = pt2(l.b);
|
|
54345
54345
|
if (!a || !b || Math.hypot(b[0] - a[0], b[1] - a[1]) < 1e-6) continue;
|
|
54346
|
-
const
|
|
54347
|
-
let id =
|
|
54348
|
-
while (used.has(id)) id =
|
|
54346
|
+
const root4 = String(l.id || "line-" + (i + 1));
|
|
54347
|
+
let id = root4, suffix = 2;
|
|
54348
|
+
while (used.has(id)) id = root4 + "-" + suffix++;
|
|
54349
54349
|
used.add(id);
|
|
54350
54350
|
out.push({ id, label: String(l.label || i + 1), a, b });
|
|
54351
54351
|
}
|
|
@@ -54523,10 +54523,10 @@ function checkModelReferences(doc) {
|
|
|
54523
54523
|
const evidence = entry2 && isObj(entry2.obs.evidence) ? entry2.obs.evidence : null;
|
|
54524
54524
|
return arr(evidence?.supersedes).map(str).filter((e) => e !== null && e !== id && obsById.has(e));
|
|
54525
54525
|
};
|
|
54526
|
-
for (const
|
|
54527
|
-
if ((colour.get(
|
|
54528
|
-
colour.set(
|
|
54529
|
-
const stack = [{ id:
|
|
54526
|
+
for (const root4 of obsById.keys()) {
|
|
54527
|
+
if ((colour.get(root4) ?? WHITE) !== WHITE) continue;
|
|
54528
|
+
colour.set(root4, GREY);
|
|
54529
|
+
const stack = [{ id: root4, edges: edgesOf(root4), i: 0 }];
|
|
54530
54530
|
while (stack.length) {
|
|
54531
54531
|
const top = stack[stack.length - 1];
|
|
54532
54532
|
if (top.i >= top.edges.length) {
|
|
@@ -56261,15 +56261,15 @@ function readContractForApp(appId, readAppFn = readApp) {
|
|
|
56261
56261
|
|
|
56262
56262
|
// project-versions-store.ts
|
|
56263
56263
|
var import_node_crypto10 = require("node:crypto");
|
|
56264
|
-
var
|
|
56264
|
+
var import_node_fs23 = require("node:fs");
|
|
56265
56265
|
var import_promises2 = require("node:fs/promises");
|
|
56266
|
-
var
|
|
56266
|
+
var import_node_path21 = require("node:path");
|
|
56267
56267
|
|
|
56268
56268
|
// projects-store.ts
|
|
56269
|
-
var
|
|
56269
|
+
var import_node_fs22 = require("node:fs");
|
|
56270
56270
|
var import_promises = require("node:fs/promises");
|
|
56271
|
-
var
|
|
56272
|
-
var
|
|
56271
|
+
var import_node_path20 = require("node:path");
|
|
56272
|
+
var import_node_os15 = require("node:os");
|
|
56273
56273
|
var import_node_crypto9 = require("node:crypto");
|
|
56274
56274
|
|
|
56275
56275
|
// node_modules/fflate/esm/index.mjs
|
|
@@ -57614,17 +57614,40 @@ function unzipSync(data, opts) {
|
|
|
57614
57614
|
return files2;
|
|
57615
57615
|
}
|
|
57616
57616
|
|
|
57617
|
+
// revision-staging-store.ts
|
|
57618
|
+
var import_node_fs21 = require("node:fs");
|
|
57619
|
+
var import_node_os14 = require("node:os");
|
|
57620
|
+
var import_node_path19 = require("node:path");
|
|
57621
|
+
function root2() {
|
|
57622
|
+
return process.env.FLOLESS_HOME ?? (0, import_node_path19.join)((0, import_node_os14.homedir)(), ".floless");
|
|
57623
|
+
}
|
|
57624
|
+
function stagingRoot() {
|
|
57625
|
+
return (0, import_node_path19.join)(root2(), ".staged-revisions");
|
|
57626
|
+
}
|
|
57627
|
+
var STAGING_KEY = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
57628
|
+
var safeStagingKey = (v) => {
|
|
57629
|
+
if (!STAGING_KEY.test(v)) throw new Error(`invalid project staging key: ${v}`);
|
|
57630
|
+
return v;
|
|
57631
|
+
};
|
|
57632
|
+
var stagingDir = (key) => (0, import_node_path19.join)(stagingRoot(), safeStagingKey(key));
|
|
57633
|
+
function dropStagingFor(stagingKey) {
|
|
57634
|
+
try {
|
|
57635
|
+
(0, import_node_fs21.rmSync)(stagingDir(stagingKey), { recursive: true, force: true });
|
|
57636
|
+
} catch {
|
|
57637
|
+
}
|
|
57638
|
+
}
|
|
57639
|
+
|
|
57617
57640
|
// projects-store.ts
|
|
57618
57641
|
var ProjectError = class extends Error {
|
|
57619
57642
|
};
|
|
57620
|
-
function
|
|
57621
|
-
return process.env.FLOLESS_HOME ?? (0,
|
|
57643
|
+
function root3() {
|
|
57644
|
+
return process.env.FLOLESS_HOME ?? (0, import_node_path20.join)((0, import_node_os15.homedir)(), ".floless");
|
|
57622
57645
|
}
|
|
57623
57646
|
function projectsRoot() {
|
|
57624
|
-
return (0,
|
|
57647
|
+
return (0, import_node_path20.join)(root3(), "projects");
|
|
57625
57648
|
}
|
|
57626
57649
|
function archiveRoot() {
|
|
57627
|
-
return (0,
|
|
57650
|
+
return (0, import_node_path20.join)(projectsRoot(), ".archive");
|
|
57628
57651
|
}
|
|
57629
57652
|
var RESERVED_PROJECT_INTERNAL = /(^|[\\/])\.floless-(?:txn|cleanup|tmp|backup)-/i;
|
|
57630
57653
|
function isReservedProjectInternalPath(path) {
|
|
@@ -57645,22 +57668,27 @@ function slugify(name) {
|
|
|
57645
57668
|
return s || "project";
|
|
57646
57669
|
}
|
|
57647
57670
|
function projectDir(id) {
|
|
57648
|
-
return (0,
|
|
57671
|
+
return (0, import_node_path20.join)(projectsRoot(), safeProjectId(id));
|
|
57649
57672
|
}
|
|
57650
57673
|
function archiveDir(id) {
|
|
57651
|
-
return (0,
|
|
57674
|
+
return (0, import_node_path20.join)(archiveRoot(), safeProjectId(id));
|
|
57675
|
+
}
|
|
57676
|
+
function mintProjectId(name, draw = () => (0, import_node_crypto9.randomBytes)(3).toString("hex")) {
|
|
57677
|
+
let id = `${slugify(name)}-${draw()}`;
|
|
57678
|
+
while ((0, import_node_fs22.existsSync)(projectDir(id)) || (0, import_node_fs22.existsSync)(archiveDir(id))) id = `${slugify(name)}-${draw()}`;
|
|
57679
|
+
return id;
|
|
57652
57680
|
}
|
|
57653
57681
|
function projectExportsDir(id) {
|
|
57654
|
-
return (0,
|
|
57682
|
+
return (0, import_node_path20.join)(projectDir(id), "exports");
|
|
57655
57683
|
}
|
|
57656
57684
|
function projectKnowledgeDir(id) {
|
|
57657
|
-
return (0,
|
|
57685
|
+
return (0, import_node_path20.join)(projectDir(id), "knowledge");
|
|
57658
57686
|
}
|
|
57659
|
-
var metaPath = (id) => (0,
|
|
57687
|
+
var metaPath = (id) => (0, import_node_path20.join)(projectDir(id), "project.json");
|
|
57660
57688
|
function readMetaFile(jsonPath, id) {
|
|
57661
|
-
if (!(0,
|
|
57689
|
+
if (!(0, import_node_fs22.existsSync)(jsonPath)) return null;
|
|
57662
57690
|
try {
|
|
57663
|
-
const meta = JSON.parse((0,
|
|
57691
|
+
const meta = JSON.parse((0, import_node_fs22.readFileSync)(jsonPath, "utf8"));
|
|
57664
57692
|
if (meta && meta.id === id) return meta;
|
|
57665
57693
|
console.warn(`projects-store: ignoring ${jsonPath} \u2014 its id "${String(meta?.id)}" does not match the folder "${id}"`);
|
|
57666
57694
|
return null;
|
|
@@ -57673,16 +57701,16 @@ function readMeta(id) {
|
|
|
57673
57701
|
return readMetaFile(metaPath(id), id);
|
|
57674
57702
|
}
|
|
57675
57703
|
function writeMetaTo(dir, meta) {
|
|
57676
|
-
const path = (0,
|
|
57704
|
+
const path = (0, import_node_path20.join)(dir, "project.json");
|
|
57677
57705
|
const tmp = `${path}.${process.pid}.${(0, import_node_crypto9.randomUUID)()}.tmp`;
|
|
57678
|
-
(0,
|
|
57679
|
-
(0,
|
|
57706
|
+
(0, import_node_fs22.writeFileSync)(tmp, JSON.stringify(meta, null, 2));
|
|
57707
|
+
(0, import_node_fs22.renameSync)(tmp, path);
|
|
57680
57708
|
}
|
|
57681
57709
|
var writeMeta = (meta) => writeMetaTo(projectDir(meta.id), meta);
|
|
57682
57710
|
function listProjects() {
|
|
57683
|
-
if (!(0,
|
|
57711
|
+
if (!(0, import_node_fs22.existsSync)(projectsRoot())) return [];
|
|
57684
57712
|
const out = [];
|
|
57685
|
-
for (const entry2 of (0,
|
|
57713
|
+
for (const entry2 of (0, import_node_fs22.readdirSync)(projectsRoot(), { withFileTypes: true })) {
|
|
57686
57714
|
if (!isProjectDir(entry2)) continue;
|
|
57687
57715
|
const meta = readMeta(entry2.name);
|
|
57688
57716
|
if (meta) out.push(meta);
|
|
@@ -57707,9 +57735,8 @@ function createProject(input) {
|
|
|
57707
57735
|
const app = typeof input.app === "string" ? input.app.trim() : "";
|
|
57708
57736
|
if (!name) throw new ProjectError("project name required");
|
|
57709
57737
|
if (!/^[a-z0-9][a-z0-9._-]*$/i.test(app)) throw new ProjectError(`invalid app id: ${app || "(empty)"}`);
|
|
57710
|
-
|
|
57711
|
-
|
|
57712
|
-
(0, import_node_fs21.mkdirSync)(projectDir(id), { recursive: true });
|
|
57738
|
+
const id = mintProjectId(name);
|
|
57739
|
+
(0, import_node_fs22.mkdirSync)(projectDir(id), { recursive: true });
|
|
57713
57740
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
57714
57741
|
const meta = { id, uuid: (0, import_node_crypto9.randomUUID)(), name, app, createdAt: now, updatedAt: now };
|
|
57715
57742
|
writeMeta(meta);
|
|
@@ -57721,11 +57748,10 @@ function renameProject(id, name) {
|
|
|
57721
57748
|
if (typeof name !== "string" || !name.trim()) throw new ProjectError("project name required");
|
|
57722
57749
|
const nextName = name.trim();
|
|
57723
57750
|
if (nextName === meta.name) return meta;
|
|
57724
|
-
|
|
57725
|
-
while ((0, import_node_fs21.existsSync)(projectDir(newId)) || (0, import_node_fs21.existsSync)((0, import_node_path19.join)(archiveRoot(), newId))) newId = `${slugify(nextName)}-${(0, import_node_crypto9.randomBytes)(3).toString("hex")}`;
|
|
57751
|
+
const newId = mintProjectId(nextName);
|
|
57726
57752
|
const from = projectDir(id), to = projectDir(newId);
|
|
57727
57753
|
try {
|
|
57728
|
-
(0,
|
|
57754
|
+
(0, import_node_fs22.renameSync)(from, to);
|
|
57729
57755
|
} catch {
|
|
57730
57756
|
throw new ProjectError("couldn\u2019t rename the project folder \u2014 it may be open or in use. Close the project and try again.");
|
|
57731
57757
|
}
|
|
@@ -57735,7 +57761,7 @@ function renameProject(id, name) {
|
|
|
57735
57761
|
return next;
|
|
57736
57762
|
} catch (e) {
|
|
57737
57763
|
try {
|
|
57738
|
-
(0,
|
|
57764
|
+
(0, import_node_fs22.renameSync)(to, from);
|
|
57739
57765
|
} catch {
|
|
57740
57766
|
}
|
|
57741
57767
|
throw e;
|
|
@@ -57762,7 +57788,7 @@ function duplicateProject(id, name) {
|
|
|
57762
57788
|
name: typeof name === "string" && name.trim() ? name.trim() : `${src.name} (copy)`,
|
|
57763
57789
|
app: src.app
|
|
57764
57790
|
});
|
|
57765
|
-
(0,
|
|
57791
|
+
(0, import_node_fs22.cpSync)(projectDir(src.id), projectDir(copy.id), {
|
|
57766
57792
|
recursive: true,
|
|
57767
57793
|
filter: (p) => !p.endsWith("project.json") && !isReservedProjectInternalPath(p)
|
|
57768
57794
|
});
|
|
@@ -57781,56 +57807,58 @@ function repointProjects(oldId, newId) {
|
|
|
57781
57807
|
console.warn(`repointProjects: leaving project ${meta.id} on "${oldId}" \u2014 ${e instanceof Error ? e.message : e}`);
|
|
57782
57808
|
}
|
|
57783
57809
|
};
|
|
57784
|
-
if ((0,
|
|
57785
|
-
for (const entry2 of (0,
|
|
57810
|
+
if ((0, import_node_fs22.existsSync)(projectsRoot())) {
|
|
57811
|
+
for (const entry2 of (0, import_node_fs22.readdirSync)(projectsRoot(), { withFileTypes: true })) {
|
|
57786
57812
|
if (!isProjectDir(entry2)) continue;
|
|
57787
57813
|
const meta = readMeta(entry2.name);
|
|
57788
57814
|
if (meta && meta.app === oldId) repoint(meta, () => projectDir(meta.id));
|
|
57789
57815
|
}
|
|
57790
57816
|
}
|
|
57791
|
-
if ((0,
|
|
57792
|
-
for (const entry2 of (0,
|
|
57817
|
+
if ((0, import_node_fs22.existsSync)(archiveRoot())) {
|
|
57818
|
+
for (const entry2 of (0, import_node_fs22.readdirSync)(archiveRoot(), { withFileTypes: true })) {
|
|
57793
57819
|
if (!isProjectDir(entry2)) continue;
|
|
57794
|
-
const meta = readMetaFile((0,
|
|
57795
|
-
if (meta && meta.app === oldId) repoint(meta, () => (0,
|
|
57820
|
+
const meta = readMetaFile((0, import_node_path20.join)(archiveRoot(), entry2.name, "project.json"), entry2.name);
|
|
57821
|
+
if (meta && meta.app === oldId) repoint(meta, () => (0, import_node_path20.join)(archiveRoot(), safeProjectId(meta.id)));
|
|
57796
57822
|
}
|
|
57797
57823
|
}
|
|
57798
57824
|
return { changed, skipped };
|
|
57799
57825
|
}
|
|
57800
57826
|
function archiveProject(id) {
|
|
57801
57827
|
const dir = projectDir(id);
|
|
57802
|
-
if (!(0,
|
|
57803
|
-
(0,
|
|
57804
|
-
const dest = (0,
|
|
57805
|
-
if ((0,
|
|
57828
|
+
if (!(0, import_node_fs22.existsSync)(dir)) throw new ProjectError(`unknown project: ${id}`);
|
|
57829
|
+
(0, import_node_fs22.mkdirSync)(archiveRoot(), { recursive: true });
|
|
57830
|
+
const dest = (0, import_node_path20.join)(archiveRoot(), id);
|
|
57831
|
+
if ((0, import_node_fs22.existsSync)(dest)) throw new ProjectError(`already archived: ${id}`);
|
|
57806
57832
|
const meta = readMeta(id);
|
|
57807
57833
|
if (meta) writeMeta({ ...meta, updatedAt: (/* @__PURE__ */ new Date()).toISOString() });
|
|
57808
|
-
(0,
|
|
57834
|
+
(0, import_node_fs22.renameSync)(dir, dest);
|
|
57809
57835
|
}
|
|
57810
57836
|
function listArchivedProjects() {
|
|
57811
|
-
if (!(0,
|
|
57837
|
+
if (!(0, import_node_fs22.existsSync)(archiveRoot())) return [];
|
|
57812
57838
|
const out = [];
|
|
57813
|
-
for (const entry2 of (0,
|
|
57839
|
+
for (const entry2 of (0, import_node_fs22.readdirSync)(archiveRoot(), { withFileTypes: true })) {
|
|
57814
57840
|
if (!isProjectDir(entry2)) continue;
|
|
57815
|
-
const meta = readMetaFile((0,
|
|
57841
|
+
const meta = readMetaFile((0, import_node_path20.join)(archiveRoot(), entry2.name, "project.json"), entry2.name);
|
|
57816
57842
|
if (meta) out.push(meta);
|
|
57817
57843
|
}
|
|
57818
57844
|
return out.sort((a, b) => a.updatedAt < b.updatedAt ? 1 : -1);
|
|
57819
57845
|
}
|
|
57820
57846
|
function unarchiveProject(id) {
|
|
57821
57847
|
const src = archiveDir(id);
|
|
57822
|
-
if (!(0,
|
|
57823
|
-
const meta = readMetaFile((0,
|
|
57848
|
+
if (!(0, import_node_fs22.existsSync)(src)) throw new ProjectError(`not archived: ${id}`);
|
|
57849
|
+
const meta = readMetaFile((0, import_node_path20.join)(src, "project.json"), id);
|
|
57824
57850
|
if (!meta) throw new ProjectError(`archived project has missing or unreadable metadata: ${id}`);
|
|
57825
57851
|
const dest = projectDir(id);
|
|
57826
|
-
if ((0,
|
|
57827
|
-
(0,
|
|
57852
|
+
if ((0, import_node_fs22.existsSync)(dest)) throw new ProjectError(`a live project with that id already exists: ${id}`);
|
|
57853
|
+
(0, import_node_fs22.renameSync)(src, dest);
|
|
57828
57854
|
return meta;
|
|
57829
57855
|
}
|
|
57830
57856
|
function deleteArchivedProject(id) {
|
|
57831
57857
|
const dir = archiveDir(id);
|
|
57832
|
-
if (!(0,
|
|
57833
|
-
(0,
|
|
57858
|
+
if (!(0, import_node_fs22.existsSync)(dir)) throw new ProjectError(`not archived: ${id}`);
|
|
57859
|
+
const stagingId = readMetaFile((0, import_node_path20.join)(dir, "project.json"), id)?.stagingId;
|
|
57860
|
+
(0, import_node_fs22.rmSync)(dir, { recursive: true, force: true });
|
|
57861
|
+
if (stagingId) dropStagingFor(stagingId);
|
|
57834
57862
|
}
|
|
57835
57863
|
function exportFilename(name) {
|
|
57836
57864
|
const clean = name.replace(/[^a-z0-9\-_. ]+/gi, " ").replace(/\s+/g, " ").trim().slice(0, 60);
|
|
@@ -57871,7 +57899,7 @@ async function exportProjectZip(id) {
|
|
|
57871
57899
|
const walk2 = async (abs, rel) => {
|
|
57872
57900
|
const entries2 = await (0, import_promises.readdir)(abs, { withFileTypes: true });
|
|
57873
57901
|
await Promise.all(entries2.map(async (e) => {
|
|
57874
|
-
const childAbs = (0,
|
|
57902
|
+
const childAbs = (0, import_node_path20.join)(abs, e.name);
|
|
57875
57903
|
const childRel = rel ? `${rel}/${e.name}` : e.name;
|
|
57876
57904
|
if (e.isDirectory()) await walk2(childAbs, childRel);
|
|
57877
57905
|
else if (e.isFile() && !isReservedProjectInternalPath(childRel)) files2[`${id}/${childRel}`] = await (0, import_promises.readFile)(childAbs);
|
|
@@ -57921,8 +57949,7 @@ function importProjectZip(data) {
|
|
|
57921
57949
|
for (let n = 1; takenNames.has(name); n++) name = n === 1 ? `${rawName} (imported)` : `${rawName} (imported ${n})`;
|
|
57922
57950
|
const app = typeof srcMeta.app === "string" ? srcMeta.app.trim() : "";
|
|
57923
57951
|
if (!/^[a-z0-9][a-z0-9._-]*$/i.test(app)) throw new ProjectError(`archive names an invalid app id: ${app || "(empty)"}`);
|
|
57924
|
-
|
|
57925
|
-
while ((0, import_node_fs21.existsSync)(projectDir(id)) || (0, import_node_fs21.existsSync)((0, import_node_path19.join)(archiveRoot(), id))) id = `${slugify(name)}-${(0, import_node_crypto9.randomBytes)(3).toString("hex")}`;
|
|
57952
|
+
const id = mintProjectId(name);
|
|
57926
57953
|
const relOf = (entryPath) => rootPrefix && entryPath.startsWith(rootPrefix) ? entryPath.slice(rootPrefix.length) : entryPath;
|
|
57927
57954
|
const contractEntries = Object.keys(entries2).filter((p) => relOf(p) === "contract.json");
|
|
57928
57955
|
if (contractEntries.length > 1) {
|
|
@@ -57945,19 +57972,19 @@ function importProjectZip(data) {
|
|
|
57945
57972
|
}
|
|
57946
57973
|
}
|
|
57947
57974
|
const dest = projectDir(id);
|
|
57948
|
-
const destResolved = (0,
|
|
57949
|
-
(0,
|
|
57975
|
+
const destResolved = (0, import_node_path20.resolve)(dest);
|
|
57976
|
+
(0, import_node_fs22.mkdirSync)(dest, { recursive: true });
|
|
57950
57977
|
try {
|
|
57951
57978
|
for (const [entryPath, bytes] of Object.entries(entries2)) {
|
|
57952
57979
|
if (entryPath === metaEntry) continue;
|
|
57953
57980
|
const rel = rootPrefix && entryPath.startsWith(rootPrefix) ? entryPath.slice(rootPrefix.length) : entryPath;
|
|
57954
57981
|
if (!rel || rel.endsWith("/")) continue;
|
|
57955
|
-
const target = (0,
|
|
57956
|
-
if (target !== destResolved && !target.startsWith(destResolved +
|
|
57982
|
+
const target = (0, import_node_path20.resolve)(dest, rel);
|
|
57983
|
+
if (target !== destResolved && !target.startsWith(destResolved + import_node_path20.sep)) {
|
|
57957
57984
|
throw new ProjectError(`archive entry escapes the project dir: ${entryPath}`);
|
|
57958
57985
|
}
|
|
57959
|
-
(0,
|
|
57960
|
-
(0,
|
|
57986
|
+
(0, import_node_fs22.mkdirSync)((0, import_node_path20.dirname)(target), { recursive: true });
|
|
57987
|
+
(0, import_node_fs22.writeFileSync)(target, bytes);
|
|
57961
57988
|
}
|
|
57962
57989
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
57963
57990
|
const meta = {
|
|
@@ -57972,7 +57999,7 @@ function importProjectZip(data) {
|
|
|
57972
57999
|
writeMeta(meta);
|
|
57973
58000
|
return meta;
|
|
57974
58001
|
} catch (e) {
|
|
57975
|
-
(0,
|
|
58002
|
+
(0, import_node_fs22.rmSync)(dest, { recursive: true, force: true });
|
|
57976
58003
|
throw e;
|
|
57977
58004
|
}
|
|
57978
58005
|
}
|
|
@@ -57981,13 +58008,13 @@ function importProjectZip(data) {
|
|
|
57981
58008
|
var BLOB_MIN = 8192;
|
|
57982
58009
|
var BLOB_KEY = "__blobRef__";
|
|
57983
58010
|
var HASH_RE = /^[0-9a-f]{64}$/;
|
|
57984
|
-
var versionsDir = (id) => (0,
|
|
57985
|
-
var objectsDir = (id) => (0,
|
|
57986
|
-
var logPath = (id) => (0,
|
|
58011
|
+
var versionsDir = (id) => (0, import_node_path21.join)(projectDir(id), "versions");
|
|
58012
|
+
var objectsDir = (id) => (0, import_node_path21.join)(projectDir(id), "objects");
|
|
58013
|
+
var logPath = (id) => (0, import_node_path21.join)(versionsDir(id), "log.json");
|
|
57987
58014
|
function writeAtomic(path, text3) {
|
|
57988
58015
|
const tmp = `${path}.${process.pid}.tmp`;
|
|
57989
|
-
(0,
|
|
57990
|
-
(0,
|
|
58016
|
+
(0, import_node_fs23.writeFileSync)(tmp, text3);
|
|
58017
|
+
(0, import_node_fs23.renameSync)(tmp, path);
|
|
57991
58018
|
}
|
|
57992
58019
|
function isVersionMeta(v) {
|
|
57993
58020
|
if (!v || typeof v !== "object") return false;
|
|
@@ -58002,7 +58029,7 @@ function isValidSource(s) {
|
|
|
58002
58029
|
}
|
|
58003
58030
|
function loadLog(id) {
|
|
58004
58031
|
try {
|
|
58005
|
-
const parsed = JSON.parse((0,
|
|
58032
|
+
const parsed = JSON.parse((0, import_node_fs23.readFileSync)(logPath(id), "utf8"));
|
|
58006
58033
|
const raw = parsed && typeof parsed === "object" && Array.isArray(parsed.versions) ? parsed.versions : [];
|
|
58007
58034
|
return { versions: raw.filter(isVersionMeta) };
|
|
58008
58035
|
} catch {
|
|
@@ -58037,7 +58064,7 @@ function rehydrate(node, id) {
|
|
|
58037
58064
|
if (Array.isArray(node)) return node.map((x) => rehydrate(x, id));
|
|
58038
58065
|
if (node && typeof node === "object") {
|
|
58039
58066
|
const hash2 = blobHashOf(node);
|
|
58040
|
-
if (hash2 !== null) return (0,
|
|
58067
|
+
if (hash2 !== null) return (0, import_node_fs23.readFileSync)((0, import_node_path21.join)(objectsDir(id), hash2), "utf8");
|
|
58041
58068
|
const out = {};
|
|
58042
58069
|
for (const [k, v] of Object.entries(node)) out[k] = rehydrate(v, id);
|
|
58043
58070
|
return out;
|
|
@@ -58069,13 +58096,13 @@ function rehydrateFrom(node, blobs) {
|
|
|
58069
58096
|
return node;
|
|
58070
58097
|
}
|
|
58071
58098
|
function createVersion(id, contract, meta) {
|
|
58072
|
-
(0,
|
|
58073
|
-
(0,
|
|
58099
|
+
(0, import_node_fs23.mkdirSync)(versionsDir(id), { recursive: true });
|
|
58100
|
+
(0, import_node_fs23.mkdirSync)(objectsDir(id), { recursive: true });
|
|
58074
58101
|
const blobs = /* @__PURE__ */ new Map();
|
|
58075
58102
|
const skeleton = dehydrate(contract, blobs);
|
|
58076
58103
|
for (const [hash2, text3] of blobs) {
|
|
58077
|
-
const p = (0,
|
|
58078
|
-
if (!(0,
|
|
58104
|
+
const p = (0, import_node_path21.join)(objectsDir(id), hash2);
|
|
58105
|
+
if (!(0, import_node_fs23.existsSync)(p)) writeAtomic(p, text3);
|
|
58079
58106
|
}
|
|
58080
58107
|
const log2 = loadLog(id);
|
|
58081
58108
|
const n = (log2.versions.at(-1)?.n ?? 0) + 1;
|
|
@@ -58089,7 +58116,7 @@ function createVersion(id, contract, meta) {
|
|
|
58089
58116
|
...meta.source ? { source: meta.source } : {}
|
|
58090
58117
|
// revision-read provenance (small metadata; not dehydrated)
|
|
58091
58118
|
};
|
|
58092
|
-
writeAtomic((0,
|
|
58119
|
+
writeAtomic((0, import_node_path21.join)(versionsDir(id), `${n}.json`), JSON.stringify({ meta: row, contract: skeleton }, null, 2));
|
|
58093
58120
|
log2.versions.push(row);
|
|
58094
58121
|
writeAtomic(logPath(id), JSON.stringify(log2, null, 2));
|
|
58095
58122
|
return row;
|
|
@@ -58101,7 +58128,7 @@ function listVersions(id) {
|
|
|
58101
58128
|
}
|
|
58102
58129
|
function readVersion(id, n) {
|
|
58103
58130
|
try {
|
|
58104
|
-
const snap = JSON.parse((0,
|
|
58131
|
+
const snap = JSON.parse((0, import_node_fs23.readFileSync)((0, import_node_path21.join)(versionsDir(id), `${n}.json`), "utf8"));
|
|
58105
58132
|
return rehydrate(snap.contract, id);
|
|
58106
58133
|
} catch {
|
|
58107
58134
|
return null;
|
|
@@ -58109,13 +58136,13 @@ function readVersion(id, n) {
|
|
|
58109
58136
|
}
|
|
58110
58137
|
async function readVersionAsync(id, n) {
|
|
58111
58138
|
try {
|
|
58112
|
-
const snap = JSON.parse(await (0, import_promises2.readFile)((0,
|
|
58139
|
+
const snap = JSON.parse(await (0, import_promises2.readFile)((0, import_node_path21.join)(versionsDir(id), `${n}.json`), "utf8"));
|
|
58113
58140
|
const refs = /* @__PURE__ */ new Set();
|
|
58114
58141
|
collectBlobRefs(snap.contract, refs);
|
|
58115
58142
|
if (refs.size === 0) return snap.contract;
|
|
58116
58143
|
const blobs = /* @__PURE__ */ new Map();
|
|
58117
58144
|
await Promise.all([...refs].map(async (hash2) => {
|
|
58118
|
-
blobs.set(hash2, await (0, import_promises2.readFile)((0,
|
|
58145
|
+
blobs.set(hash2, await (0, import_promises2.readFile)((0, import_node_path21.join)(objectsDir(id), hash2), "utf8"));
|
|
58119
58146
|
}));
|
|
58120
58147
|
return rehydrateFrom(snap.contract, blobs);
|
|
58121
58148
|
} catch {
|
|
@@ -58124,7 +58151,7 @@ async function readVersionAsync(id, n) {
|
|
|
58124
58151
|
}
|
|
58125
58152
|
function readVersionSkeleton(id, n) {
|
|
58126
58153
|
try {
|
|
58127
|
-
const snap = JSON.parse((0,
|
|
58154
|
+
const snap = JSON.parse((0, import_node_fs23.readFileSync)((0, import_node_path21.join)(versionsDir(id), `${n}.json`), "utf8"));
|
|
58128
58155
|
return snap.contract;
|
|
58129
58156
|
} catch {
|
|
58130
58157
|
return null;
|
|
@@ -58132,7 +58159,7 @@ function readVersionSkeleton(id, n) {
|
|
|
58132
58159
|
}
|
|
58133
58160
|
async function readVersionSkeletonAsync(id, n) {
|
|
58134
58161
|
try {
|
|
58135
|
-
const snap = JSON.parse(await (0, import_promises2.readFile)((0,
|
|
58162
|
+
const snap = JSON.parse(await (0, import_promises2.readFile)((0, import_node_path21.join)(versionsDir(id), `${n}.json`), "utf8"));
|
|
58136
58163
|
return snap.contract;
|
|
58137
58164
|
} catch {
|
|
58138
58165
|
return null;
|
|
@@ -58300,7 +58327,7 @@ function acceptSteelForRoute(doc, ctx, from) {
|
|
|
58300
58327
|
}
|
|
58301
58328
|
|
|
58302
58329
|
// knowledge-routes.ts
|
|
58303
|
-
var
|
|
58330
|
+
var import_node_fs25 = require("node:fs");
|
|
58304
58331
|
|
|
58305
58332
|
// sse.ts
|
|
58306
58333
|
var clients = /* @__PURE__ */ new Set();
|
|
@@ -58338,8 +58365,8 @@ function clientCount() {
|
|
|
58338
58365
|
|
|
58339
58366
|
// knowledge-store.ts
|
|
58340
58367
|
var import_node_crypto12 = require("node:crypto");
|
|
58341
|
-
var
|
|
58342
|
-
var
|
|
58368
|
+
var import_node_fs24 = require("node:fs");
|
|
58369
|
+
var import_node_path22 = require("node:path");
|
|
58343
58370
|
var import_yaml6 = __toESM(require_dist6(), 1);
|
|
58344
58371
|
var KnowledgeError = class extends Error {
|
|
58345
58372
|
code;
|
|
@@ -58349,8 +58376,8 @@ var KnowledgeError = class extends Error {
|
|
|
58349
58376
|
}
|
|
58350
58377
|
};
|
|
58351
58378
|
var EMPTY_MANIFEST = { revision: 0, currentGeneration: null, sources: [] };
|
|
58352
|
-
var manifestPath = (id) => (0,
|
|
58353
|
-
var blobsDir = (id) => (0,
|
|
58379
|
+
var manifestPath = (id) => (0, import_node_path22.join)(projectKnowledgeDir(id), "manifest.json");
|
|
58380
|
+
var blobsDir = (id) => (0, import_node_path22.join)(projectKnowledgeDir(id), "blobs");
|
|
58354
58381
|
var BLOB_SHA256_RE = /^[0-9a-f]{64}$/;
|
|
58355
58382
|
function isSourceRow(row) {
|
|
58356
58383
|
if (!row || typeof row !== "object") return false;
|
|
@@ -58359,9 +58386,9 @@ function isSourceRow(row) {
|
|
|
58359
58386
|
}
|
|
58360
58387
|
function readManifest(id) {
|
|
58361
58388
|
const p = manifestPath(id);
|
|
58362
|
-
if (!(0,
|
|
58389
|
+
if (!(0, import_node_fs24.existsSync)(p)) return { ...EMPTY_MANIFEST, sources: [] };
|
|
58363
58390
|
try {
|
|
58364
|
-
const parsed = JSON.parse((0,
|
|
58391
|
+
const parsed = JSON.parse((0, import_node_fs24.readFileSync)(p, "utf8"));
|
|
58365
58392
|
if (!parsed || typeof parsed !== "object" || !Array.isArray(parsed.sources)) {
|
|
58366
58393
|
console.warn(`knowledge-store: ignoring schema-invalid manifest.json at ${p} (missing/invalid sources array)`);
|
|
58367
58394
|
return { ...EMPTY_MANIFEST, sources: [] };
|
|
@@ -58385,11 +58412,11 @@ function readManifest(id) {
|
|
|
58385
58412
|
}
|
|
58386
58413
|
function writeManifest(id, manifest) {
|
|
58387
58414
|
const dir = projectKnowledgeDir(id);
|
|
58388
|
-
(0,
|
|
58415
|
+
(0, import_node_fs24.mkdirSync)(dir, { recursive: true });
|
|
58389
58416
|
const dest = manifestPath(id);
|
|
58390
|
-
const tmp = (0,
|
|
58391
|
-
(0,
|
|
58392
|
-
(0,
|
|
58417
|
+
const tmp = (0, import_node_path22.join)(dir, `.manifest.json.${process.pid}.${(0, import_node_crypto12.randomUUID)()}.tmp`);
|
|
58418
|
+
(0, import_node_fs24.writeFileSync)(tmp, JSON.stringify(manifest, null, 2));
|
|
58419
|
+
(0, import_node_fs24.renameSync)(tmp, dest);
|
|
58393
58420
|
}
|
|
58394
58421
|
var MAX_FILES = 50;
|
|
58395
58422
|
var MAX_FILE_BYTES = 100 * 1024 * 1024;
|
|
@@ -58408,9 +58435,9 @@ function blobPathFor(id, blobSha256) {
|
|
|
58408
58435
|
if (typeof blobSha256 !== "string" || !BLOB_SHA256_RE.test(blobSha256)) {
|
|
58409
58436
|
throw new KnowledgeError(`invalid blob address: ${blobSha256}`);
|
|
58410
58437
|
}
|
|
58411
|
-
const full = (0,
|
|
58412
|
-
const
|
|
58413
|
-
if (full !== (0,
|
|
58438
|
+
const full = (0, import_node_path22.resolve)((0, import_node_path22.join)(dir, blobSha256));
|
|
58439
|
+
const root4 = (0, import_node_path22.resolve)(dir);
|
|
58440
|
+
if (full !== (0, import_node_path22.join)(root4, blobSha256) || !full.startsWith(root4 + import_node_path22.sep)) {
|
|
58414
58441
|
throw new KnowledgeError(`blob path escapes the blobs directory: ${blobSha256}`);
|
|
58415
58442
|
}
|
|
58416
58443
|
return full;
|
|
@@ -58466,12 +58493,12 @@ function addSource(id, input) {
|
|
|
58466
58493
|
const { buf, mime, filename } = input;
|
|
58467
58494
|
const sha2563 = (0, import_node_crypto12.createHash)("sha256").update(buf).digest("hex");
|
|
58468
58495
|
const dir = blobsDir(id);
|
|
58469
|
-
(0,
|
|
58496
|
+
(0, import_node_fs24.mkdirSync)(dir, { recursive: true });
|
|
58470
58497
|
const blobPath = blobPathFor(id, sha2563);
|
|
58471
|
-
if (!(0,
|
|
58498
|
+
if (!(0, import_node_fs24.existsSync)(blobPath)) {
|
|
58472
58499
|
const tmp = `${blobPath}.${process.pid}.${(0, import_node_crypto12.randomUUID)()}.tmp`;
|
|
58473
|
-
(0,
|
|
58474
|
-
(0,
|
|
58500
|
+
(0, import_node_fs24.writeFileSync)(tmp, buf);
|
|
58501
|
+
(0, import_node_fs24.renameSync)(tmp, blobPath);
|
|
58475
58502
|
}
|
|
58476
58503
|
const manifest = readManifest(id);
|
|
58477
58504
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -58514,27 +58541,27 @@ function removeSource(id, sourceId) {
|
|
|
58514
58541
|
if (!stillReferenced) {
|
|
58515
58542
|
const blobPath = blobPathFor(id, removed.blobSha256);
|
|
58516
58543
|
try {
|
|
58517
|
-
if ((0,
|
|
58544
|
+
if ((0, import_node_fs24.existsSync)(blobPath)) (0, import_node_fs24.unlinkSync)(blobPath);
|
|
58518
58545
|
} catch (e) {
|
|
58519
58546
|
console.warn(`knowledge-store: could not GC blob ${removed.blobSha256} for ${id}: ${e instanceof Error ? e.message : e}`);
|
|
58520
58547
|
}
|
|
58521
58548
|
}
|
|
58522
58549
|
}
|
|
58523
58550
|
var LOCK_STALE_MS = 10 * 60 * 1e3;
|
|
58524
|
-
var lockPath = (id) => (0,
|
|
58551
|
+
var lockPath = (id) => (0, import_node_path22.join)(projectKnowledgeDir(id), "lock.json");
|
|
58525
58552
|
function writeLockFile(id, lock) {
|
|
58526
58553
|
const dir = projectKnowledgeDir(id);
|
|
58527
|
-
(0,
|
|
58554
|
+
(0, import_node_fs24.mkdirSync)(dir, { recursive: true });
|
|
58528
58555
|
const dest = lockPath(id);
|
|
58529
|
-
const tmp = (0,
|
|
58530
|
-
(0,
|
|
58531
|
-
(0,
|
|
58556
|
+
const tmp = (0, import_node_path22.join)(dir, `.lock.json.${process.pid}.${(0, import_node_crypto12.randomUUID)()}.tmp`);
|
|
58557
|
+
(0, import_node_fs24.writeFileSync)(tmp, JSON.stringify(lock, null, 2));
|
|
58558
|
+
(0, import_node_fs24.renameSync)(tmp, dest);
|
|
58532
58559
|
}
|
|
58533
58560
|
function readLock(id) {
|
|
58534
58561
|
const p = lockPath(id);
|
|
58535
|
-
if (!(0,
|
|
58562
|
+
if (!(0, import_node_fs24.existsSync)(p)) return null;
|
|
58536
58563
|
try {
|
|
58537
|
-
const parsed = JSON.parse((0,
|
|
58564
|
+
const parsed = JSON.parse((0, import_node_fs24.readFileSync)(p, "utf8"));
|
|
58538
58565
|
if (!parsed || typeof parsed !== "object" || typeof parsed.requestId !== "string" || typeof parsed.createdAt !== "number" || !Number.isFinite(parsed.createdAt)) {
|
|
58539
58566
|
console.warn(`knowledge-store: ignoring schema-invalid lock.json at ${p}`);
|
|
58540
58567
|
return null;
|
|
@@ -58570,7 +58597,7 @@ function releaseLock(id, requestId) {
|
|
|
58570
58597
|
if (existing.requestId !== requestId) return false;
|
|
58571
58598
|
const p = lockPath(id);
|
|
58572
58599
|
try {
|
|
58573
|
-
if ((0,
|
|
58600
|
+
if ((0, import_node_fs24.existsSync)(p)) (0, import_node_fs24.unlinkSync)(p);
|
|
58574
58601
|
} catch (e) {
|
|
58575
58602
|
console.warn(`knowledge-store: could not release lock.json at ${p}: ${e instanceof Error ? e.message : e}`);
|
|
58576
58603
|
}
|
|
@@ -58578,9 +58605,9 @@ function releaseLock(id, requestId) {
|
|
|
58578
58605
|
}
|
|
58579
58606
|
var GENERATION_ID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
58580
58607
|
var GEN_KEEP = 3;
|
|
58581
|
-
var vaultDir = (id) => (0,
|
|
58582
|
-
var generationsDir = (id) => (0,
|
|
58583
|
-
var currentGenerationPath = (id) => (0,
|
|
58608
|
+
var vaultDir = (id) => (0, import_node_path22.join)(projectKnowledgeDir(id), "vault");
|
|
58609
|
+
var generationsDir = (id) => (0, import_node_path22.join)(vaultDir(id), "generations");
|
|
58610
|
+
var currentGenerationPath = (id) => (0, import_node_path22.join)(vaultDir(id), "current-generation.json");
|
|
58584
58611
|
function assertGenerationId(generationId) {
|
|
58585
58612
|
if (typeof generationId !== "string" || !GENERATION_ID_RE.test(generationId)) {
|
|
58586
58613
|
throw new KnowledgeError("invalid generation id");
|
|
@@ -58591,18 +58618,18 @@ function mintGenerationId() {
|
|
|
58591
58618
|
}
|
|
58592
58619
|
function generationWikiDir(id, generationId) {
|
|
58593
58620
|
assertGenerationId(generationId);
|
|
58594
|
-
return (0,
|
|
58621
|
+
return (0, import_node_path22.join)(generationsDir(id), generationId, "wiki");
|
|
58595
58622
|
}
|
|
58596
58623
|
function publishGeneration(id, generationId) {
|
|
58597
58624
|
assertGenerationId(generationId);
|
|
58598
|
-
if (!(0,
|
|
58625
|
+
if (!(0, import_node_fs24.existsSync)(generationWikiDir(id, generationId))) throw new KnowledgeError("generation not found");
|
|
58599
58626
|
const pointer = { generationId, publishedAt: (/* @__PURE__ */ new Date()).toISOString() };
|
|
58600
58627
|
const dir = vaultDir(id);
|
|
58601
|
-
(0,
|
|
58628
|
+
(0, import_node_fs24.mkdirSync)(dir, { recursive: true });
|
|
58602
58629
|
const dest = currentGenerationPath(id);
|
|
58603
|
-
const tmp = (0,
|
|
58604
|
-
(0,
|
|
58605
|
-
(0,
|
|
58630
|
+
const tmp = (0, import_node_path22.join)(dir, `.current-generation.json.${process.pid}.${(0, import_node_crypto12.randomUUID)()}.tmp`);
|
|
58631
|
+
(0, import_node_fs24.writeFileSync)(tmp, JSON.stringify(pointer, null, 2));
|
|
58632
|
+
(0, import_node_fs24.renameSync)(tmp, dest);
|
|
58606
58633
|
const manifest = readManifest(id);
|
|
58607
58634
|
manifest.currentGeneration = generationId;
|
|
58608
58635
|
writeManifest(id, manifest);
|
|
@@ -58611,9 +58638,9 @@ function publishGeneration(id, generationId) {
|
|
|
58611
58638
|
}
|
|
58612
58639
|
function readCurrentGeneration(id) {
|
|
58613
58640
|
const p = currentGenerationPath(id);
|
|
58614
|
-
if (!(0,
|
|
58641
|
+
if (!(0, import_node_fs24.existsSync)(p)) return null;
|
|
58615
58642
|
try {
|
|
58616
|
-
const parsed = JSON.parse((0,
|
|
58643
|
+
const parsed = JSON.parse((0, import_node_fs24.readFileSync)(p, "utf8"));
|
|
58617
58644
|
if (typeof parsed?.generationId !== "string" || !GENERATION_ID_RE.test(parsed.generationId) || typeof parsed.publishedAt !== "string") {
|
|
58618
58645
|
console.warn(`knowledge-store: ignoring schema-invalid current-generation.json at ${p}`);
|
|
58619
58646
|
return null;
|
|
@@ -58628,7 +58655,7 @@ function currentGenerationWikiDir(id) {
|
|
|
58628
58655
|
const current = readCurrentGeneration(id);
|
|
58629
58656
|
if (!current) return null;
|
|
58630
58657
|
const dir = generationWikiDir(id, current.generationId);
|
|
58631
|
-
return (0,
|
|
58658
|
+
return (0, import_node_fs24.existsSync)(dir) ? dir : null;
|
|
58632
58659
|
}
|
|
58633
58660
|
var WIKI_SLUG_RE = /^[a-z0-9][a-z0-9._-]*$/;
|
|
58634
58661
|
var KB_MAX_NODES = 300;
|
|
@@ -58636,9 +58663,9 @@ var KB_MAX_TOTAL_BYTES = 8 * 1024 * 1024;
|
|
|
58636
58663
|
var KB_MAX_VISITS = 5e3;
|
|
58637
58664
|
var KB_MAX_PAGE_BYTES = 512 * 1024;
|
|
58638
58665
|
var REAL_IO = {
|
|
58639
|
-
readdir: (dir) => (0,
|
|
58640
|
-
readFile: (path) => (0,
|
|
58641
|
-
statSize: (path) => (0,
|
|
58666
|
+
readdir: (dir) => (0, import_node_fs24.readdirSync)(dir, { withFileTypes: true }),
|
|
58667
|
+
readFile: (path) => (0, import_node_fs24.readFileSync)(path, "utf8"),
|
|
58668
|
+
statSize: (path) => (0, import_node_fs24.statSync)(path).size
|
|
58642
58669
|
};
|
|
58643
58670
|
var VAULT_START = "<!-- vault:generated:start -->";
|
|
58644
58671
|
var VAULT_END = "<!-- vault:generated:end -->";
|
|
@@ -58668,14 +58695,14 @@ function eachPage(wikiDir, io, onPage) {
|
|
|
58668
58695
|
return "stop";
|
|
58669
58696
|
}
|
|
58670
58697
|
if (ent.isDirectory()) {
|
|
58671
|
-
if (walk2((0,
|
|
58698
|
+
if (walk2((0, import_node_path22.join)(dir, ent.name)) === "stop") return "stop";
|
|
58672
58699
|
} else if (ent.isFile() && ent.name.endsWith(".md")) {
|
|
58673
58700
|
const slug = ent.name.slice(0, -3);
|
|
58674
58701
|
if (!WIKI_SLUG_RE.test(slug)) {
|
|
58675
|
-
console.warn(`knowledge-store: skipping non-canonical wiki basename "${slug}" (${(0,
|
|
58702
|
+
console.warn(`knowledge-store: skipping non-canonical wiki basename "${slug}" (${(0, import_node_path22.join)(dir, ent.name)})`);
|
|
58676
58703
|
continue;
|
|
58677
58704
|
}
|
|
58678
|
-
if (onPage(slug, (0,
|
|
58705
|
+
if (onPage(slug, (0, import_node_path22.join)(dir, ent.name))) {
|
|
58679
58706
|
found = true;
|
|
58680
58707
|
return "stop";
|
|
58681
58708
|
}
|
|
@@ -58852,8 +58879,8 @@ function readPage(wikiDir, slug, io = REAL_IO) {
|
|
|
58852
58879
|
if (status === "io-error") throw new KnowledgeError("failed to read the knowledge base", "io-error");
|
|
58853
58880
|
return null;
|
|
58854
58881
|
}
|
|
58855
|
-
const full = (0,
|
|
58856
|
-
if (full !==
|
|
58882
|
+
const full = (0, import_node_path22.resolve)(found), root4 = (0, import_node_path22.resolve)(wikiDir);
|
|
58883
|
+
if (full !== root4 && !full.startsWith(root4 + import_node_path22.sep)) return null;
|
|
58857
58884
|
const pp = splitPage(full, io);
|
|
58858
58885
|
if (!pp.ok) {
|
|
58859
58886
|
if (pp.reason === "oversize") throw new KnowledgeError("knowledge page too large to serve", "too-large");
|
|
@@ -58935,20 +58962,20 @@ function readKnowledgeSummaries(wikiDir, opts = {}, io = REAL_IO) {
|
|
|
58935
58962
|
truncated
|
|
58936
58963
|
};
|
|
58937
58964
|
}
|
|
58938
|
-
var organizePath = (id) => (0,
|
|
58965
|
+
var organizePath = (id) => (0, import_node_path22.join)(projectKnowledgeDir(id), "organize.json");
|
|
58939
58966
|
function writeOrganizeFile(id, org) {
|
|
58940
58967
|
const dir = projectKnowledgeDir(id);
|
|
58941
|
-
(0,
|
|
58968
|
+
(0, import_node_fs24.mkdirSync)(dir, { recursive: true });
|
|
58942
58969
|
const dest = organizePath(id);
|
|
58943
|
-
const tmp = (0,
|
|
58944
|
-
(0,
|
|
58945
|
-
(0,
|
|
58970
|
+
const tmp = (0, import_node_path22.join)(dir, `.organize.json.${process.pid}.${(0, import_node_crypto12.randomUUID)()}.tmp`);
|
|
58971
|
+
(0, import_node_fs24.writeFileSync)(tmp, JSON.stringify(org, null, 2));
|
|
58972
|
+
(0, import_node_fs24.renameSync)(tmp, dest);
|
|
58946
58973
|
}
|
|
58947
58974
|
function readOrganize(id) {
|
|
58948
58975
|
const p = organizePath(id);
|
|
58949
|
-
if (!(0,
|
|
58976
|
+
if (!(0, import_node_fs24.existsSync)(p)) return null;
|
|
58950
58977
|
try {
|
|
58951
|
-
const parsed = JSON.parse((0,
|
|
58978
|
+
const parsed = JSON.parse((0, import_node_fs24.readFileSync)(p, "utf8"));
|
|
58952
58979
|
if (!parsed || typeof parsed !== "object" || typeof parsed.requestId !== "string" || typeof parsed.generationId !== "string" || !GENERATION_ID_RE.test(parsed.generationId) || typeof parsed.baseRevision !== "number" || !Number.isFinite(parsed.baseRevision)) {
|
|
58953
58980
|
console.warn(`knowledge-store: ignoring schema-invalid organize.json at ${p}`);
|
|
58954
58981
|
return null;
|
|
@@ -58967,7 +58994,7 @@ function readOrganize(id) {
|
|
|
58967
58994
|
function deleteOrganizeFile(id) {
|
|
58968
58995
|
const p = organizePath(id);
|
|
58969
58996
|
try {
|
|
58970
|
-
if ((0,
|
|
58997
|
+
if ((0, import_node_fs24.existsSync)(p)) (0, import_node_fs24.unlinkSync)(p);
|
|
58971
58998
|
} catch (e) {
|
|
58972
58999
|
console.warn(`knowledge-store: could not delete organize.json at ${p}: ${e instanceof Error ? e.message : e}`);
|
|
58973
59000
|
}
|
|
@@ -58985,7 +59012,7 @@ function startOrganize(id, requestId) {
|
|
|
58985
59012
|
const generationId = mintGenerationId();
|
|
58986
59013
|
const manifest = readManifest(id);
|
|
58987
59014
|
const baseRevision = manifest.revision;
|
|
58988
|
-
(0,
|
|
59015
|
+
(0, import_node_fs24.mkdirSync)(generationWikiDir(id, generationId), { recursive: true });
|
|
58989
59016
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
58990
59017
|
for (const row of manifest.sources) {
|
|
58991
59018
|
if (row.useAsKb) {
|
|
@@ -59006,8 +59033,8 @@ function finishOrganize(id, requestId, opts) {
|
|
|
59006
59033
|
throw new KnowledgeError("generation id mismatch");
|
|
59007
59034
|
}
|
|
59008
59035
|
const wikiDir = generationWikiDir(id, org.generationId);
|
|
59009
|
-
if (!(0,
|
|
59010
|
-
if ((0,
|
|
59036
|
+
if (!(0, import_node_fs24.existsSync)(wikiDir)) throw new KnowledgeError("generation not found");
|
|
59037
|
+
if ((0, import_node_fs24.readdirSync)(wikiDir).length === 0) {
|
|
59011
59038
|
throw new KnowledgeError("nothing to publish \u2014 generation is empty");
|
|
59012
59039
|
}
|
|
59013
59040
|
publishGeneration(id, org.generationId);
|
|
@@ -59048,14 +59075,14 @@ function failOrganize(id, requestId, opts) {
|
|
|
59048
59075
|
}
|
|
59049
59076
|
function gcOldGenerations(id, currentGenerationId) {
|
|
59050
59077
|
const dir = generationsDir(id);
|
|
59051
|
-
if (!(0,
|
|
59052
|
-
const entries2 = (0,
|
|
59078
|
+
if (!(0, import_node_fs24.existsSync)(dir)) return;
|
|
59079
|
+
const entries2 = (0, import_node_fs24.readdirSync)(dir, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => ({ name: e.name, mtimeMs: (0, import_node_fs24.statSync)((0, import_node_path22.join)(dir, e.name)).mtimeMs })).sort((a, b) => b.mtimeMs - a.mtimeMs);
|
|
59053
59080
|
const keep = new Set(entries2.slice(0, GEN_KEEP).map((e) => e.name));
|
|
59054
59081
|
keep.add(currentGenerationId);
|
|
59055
59082
|
for (const e of entries2) {
|
|
59056
59083
|
if (keep.has(e.name)) continue;
|
|
59057
59084
|
try {
|
|
59058
|
-
(0,
|
|
59085
|
+
(0, import_node_fs24.rmSync)((0, import_node_path22.join)(dir, e.name), { recursive: true, force: true });
|
|
59059
59086
|
} catch (err2) {
|
|
59060
59087
|
console.warn(`knowledge-store: could not GC stale generation dir ${e.name}: ${err2 instanceof Error ? err2.message : err2}`);
|
|
59061
59088
|
}
|
|
@@ -59171,7 +59198,7 @@ function registerKnowledgeRoutes(app) {
|
|
|
59171
59198
|
const blobPath = blobPathFor(project.id, row.blobSha256);
|
|
59172
59199
|
let fd2;
|
|
59173
59200
|
try {
|
|
59174
|
-
fd2 = (0,
|
|
59201
|
+
fd2 = (0, import_node_fs25.openSync)(blobPath, "r");
|
|
59175
59202
|
} catch (e) {
|
|
59176
59203
|
const code = e.code;
|
|
59177
59204
|
if (code === "ENOENT" || code === "ENOTDIR") {
|
|
@@ -59181,17 +59208,17 @@ function registerKnowledgeRoutes(app) {
|
|
|
59181
59208
|
}
|
|
59182
59209
|
let streamOwnsFd = false;
|
|
59183
59210
|
try {
|
|
59184
|
-
const st = (0,
|
|
59211
|
+
const st = (0, import_node_fs25.fstatSync)(fd2);
|
|
59185
59212
|
if (!st.isFile()) {
|
|
59186
59213
|
return reply.status(404).send({ ok: false, error: "source bytes are missing" });
|
|
59187
59214
|
}
|
|
59188
59215
|
reply.header("Content-Type", row.mime).header("Content-Length", String(st.size)).header("X-Content-Type-Options", "nosniff").header("Content-Disposition", "inline").header("Cache-Control", "private, no-store").header("Content-Security-Policy", "default-src 'none'; sandbox; frame-ancestors 'self'").header("Cross-Origin-Resource-Policy", "same-origin");
|
|
59189
59216
|
if (req.method === "HEAD") return reply.send();
|
|
59190
|
-
const stream = (0,
|
|
59217
|
+
const stream = (0, import_node_fs25.createReadStream)(blobPath, { fd: fd2, autoClose: true });
|
|
59191
59218
|
streamOwnsFd = true;
|
|
59192
59219
|
return reply.send(stream);
|
|
59193
59220
|
} finally {
|
|
59194
|
-
if (!streamOwnsFd) (0,
|
|
59221
|
+
if (!streamOwnsFd) (0, import_node_fs25.closeSync)(fd2);
|
|
59195
59222
|
}
|
|
59196
59223
|
} catch (e) {
|
|
59197
59224
|
if (e instanceof ProjectError) return reply.status(400).send({ ok: false, error: e.message });
|
|
@@ -59354,21 +59381,21 @@ function registerKnowledgeRoutes(app) {
|
|
|
59354
59381
|
|
|
59355
59382
|
// project-sources-store.ts
|
|
59356
59383
|
var import_node_crypto13 = require("node:crypto");
|
|
59357
|
-
var
|
|
59358
|
-
var
|
|
59359
|
-
var sourcesDir = (id) => (0,
|
|
59384
|
+
var import_node_fs26 = require("node:fs");
|
|
59385
|
+
var import_node_path23 = require("node:path");
|
|
59386
|
+
var sourcesDir = (id) => (0, import_node_path23.join)(projectDir(id), "sources");
|
|
59360
59387
|
var safeExt = (ext) => typeof ext === "string" && /^[a-z0-9]{1,8}$/i.test(ext) ? ext.toLowerCase() : "bin";
|
|
59361
59388
|
function writeAtomic2(path, buf) {
|
|
59362
59389
|
const tmp = `${path}.${process.pid}.tmp`;
|
|
59363
|
-
(0,
|
|
59364
|
-
(0,
|
|
59390
|
+
(0, import_node_fs26.writeFileSync)(tmp, buf);
|
|
59391
|
+
(0, import_node_fs26.renameSync)(tmp, path);
|
|
59365
59392
|
}
|
|
59366
59393
|
function saveSource(id, file) {
|
|
59367
|
-
(0,
|
|
59394
|
+
(0, import_node_fs26.mkdirSync)(sourcesDir(id), { recursive: true });
|
|
59368
59395
|
const sha2563 = (0, import_node_crypto13.createHash)("sha256").update(file.buf).digest("hex");
|
|
59369
59396
|
const ext = safeExt(file.ext);
|
|
59370
|
-
const p = (0,
|
|
59371
|
-
if (!(0,
|
|
59397
|
+
const p = (0, import_node_path23.join)(sourcesDir(id), `${sha2563}.${ext}`);
|
|
59398
|
+
if (!(0, import_node_fs26.existsSync)(p)) writeAtomic2(p, file.buf);
|
|
59372
59399
|
return { name: String(file.name), sha256: sha2563, ext, bytes: file.buf.length };
|
|
59373
59400
|
}
|
|
59374
59401
|
|
|
@@ -61582,7 +61609,7 @@ function structuralGridRecords(contract) {
|
|
|
61582
61609
|
if (!Array.isArray(grid.origin) || grid.origin.length < 2 || !grid.origin.every((n) => typeof n === "number" && isFinite(n))) {
|
|
61583
61610
|
throw new SceneContractError(`Grid on ${where} has an invalid origin.`);
|
|
61584
61611
|
}
|
|
61585
|
-
const
|
|
61612
|
+
const root4 = `grid:${planIndex + 1}:${String(plan.sheet || plan.title || "main").trim().replace(/\s+/g, "-")}`;
|
|
61586
61613
|
const k = mmPerPx(ptPerFt);
|
|
61587
61614
|
const [ox, oy] = grid.origin;
|
|
61588
61615
|
const toX = (x) => (x - ox) * k;
|
|
@@ -61599,7 +61626,7 @@ function structuralGridRecords(contract) {
|
|
|
61599
61626
|
const start = Math.min(toY(axis.lo), toY(axis.hi));
|
|
61600
61627
|
const end = Math.max(toY(axis.lo), toY(axis.hi));
|
|
61601
61628
|
axes.push({
|
|
61602
|
-
id: `${
|
|
61629
|
+
id: `${root4}:x:${index + 1}`,
|
|
61603
61630
|
direction: "x",
|
|
61604
61631
|
offsetMm: toX(axis.x),
|
|
61605
61632
|
label: String(axis.label).trim(),
|
|
@@ -61612,7 +61639,7 @@ function structuralGridRecords(contract) {
|
|
|
61612
61639
|
const start = Math.min(toX(axis.lo), toX(axis.hi));
|
|
61613
61640
|
const end = Math.max(toX(axis.lo), toX(axis.hi));
|
|
61614
61641
|
axes.push({
|
|
61615
|
-
id: `${
|
|
61642
|
+
id: `${root4}:y:${index + 1}`,
|
|
61616
61643
|
direction: "y",
|
|
61617
61644
|
offsetMm: toY(axis.y),
|
|
61618
61645
|
label: String(axis.label).trim(),
|
|
@@ -61622,10 +61649,10 @@ function structuralGridRecords(contract) {
|
|
|
61622
61649
|
});
|
|
61623
61650
|
const levels = geometry.zs.map((level, index) => {
|
|
61624
61651
|
if (!String(level.label || "").trim()) throw new SceneContractError(`Grid on ${where} has a blank elevation label.`);
|
|
61625
|
-
return { id: `${
|
|
61652
|
+
return { id: `${root4}:level:${level.sourceIndex ?? index}`, elevationMm: level.mm, label: String(level.label).trim() };
|
|
61626
61653
|
});
|
|
61627
61654
|
const record2 = {
|
|
61628
|
-
id:
|
|
61655
|
+
id: root4,
|
|
61629
61656
|
kind: "structural-grid",
|
|
61630
61657
|
name: String(plan.title || plan.sheet || `Grid ${planIndex + 1}`).trim(),
|
|
61631
61658
|
origin: [ox * k, -oy * k, 0],
|
|
@@ -61643,7 +61670,7 @@ function structuralGridRecords(contract) {
|
|
|
61643
61670
|
referenceSystems.push(record2);
|
|
61644
61671
|
}
|
|
61645
61672
|
geometry.lines.forEach((line) => unsupported.push({
|
|
61646
|
-
id: `${
|
|
61673
|
+
id: `${root4}:free:${line.id}`,
|
|
61647
61674
|
kind: "grid-axis",
|
|
61648
61675
|
status: "unsupported",
|
|
61649
61676
|
code: "free-angle-grid-axis-unrepresentable",
|
|
@@ -61901,7 +61928,7 @@ function modelGridRecords(grid) {
|
|
|
61901
61928
|
zip("X", xAxes, X.offsets.length);
|
|
61902
61929
|
zip("Y", yAxes, Y.offsets.length);
|
|
61903
61930
|
zip("Z", zAxes, Z.levels.length);
|
|
61904
|
-
const
|
|
61931
|
+
const root4 = "grid:model";
|
|
61905
61932
|
const labelX = labelsFor(grid.labels_x, "num", X.offsets.length);
|
|
61906
61933
|
const labelY = labelsFor(grid.labels_y, "alpha", Y.offsets.length);
|
|
61907
61934
|
const ends = grid.ends ?? {};
|
|
@@ -61914,7 +61941,7 @@ function modelGridRecords(grid) {
|
|
|
61914
61941
|
const start = span ? Math.min(span[0], span[1]) - oy : bounds.minY;
|
|
61915
61942
|
const end = span ? Math.max(span[0], span[1]) - oy : bounds.maxY;
|
|
61916
61943
|
axes.push({
|
|
61917
|
-
id: `${
|
|
61944
|
+
id: `${root4}:${axis.id}`,
|
|
61918
61945
|
direction: "x",
|
|
61919
61946
|
offsetMm,
|
|
61920
61947
|
label,
|
|
@@ -61930,7 +61957,7 @@ function modelGridRecords(grid) {
|
|
|
61930
61957
|
const start = span ? Math.min(span[0], span[1]) - ox : bounds.minX;
|
|
61931
61958
|
const end = span ? Math.max(span[0], span[1]) - ox : bounds.maxX;
|
|
61932
61959
|
axes.push({
|
|
61933
|
-
id: `${
|
|
61960
|
+
id: `${root4}:${axis.id}`,
|
|
61934
61961
|
direction: "y",
|
|
61935
61962
|
offsetMm,
|
|
61936
61963
|
label,
|
|
@@ -61945,10 +61972,10 @@ function modelGridRecords(grid) {
|
|
|
61945
61972
|
const axis = axisBySourceIndex.get(level.sourceIndex);
|
|
61946
61973
|
const label = (axis.label ?? "").trim() || level.label;
|
|
61947
61974
|
if (!label) throw new SceneContractError("The model grid has a blank elevation label.");
|
|
61948
|
-
return { id: `${
|
|
61975
|
+
return { id: `${root4}:${axis.id}`, elevationMm: level.mm, label };
|
|
61949
61976
|
});
|
|
61950
61977
|
const record2 = {
|
|
61951
|
-
id:
|
|
61978
|
+
id: root4,
|
|
61952
61979
|
kind: "structural-grid",
|
|
61953
61980
|
name: "Model Grid",
|
|
61954
61981
|
origin: [ox, oy, 0],
|
|
@@ -61957,7 +61984,7 @@ function modelGridRecords(grid) {
|
|
|
61957
61984
|
bounds
|
|
61958
61985
|
};
|
|
61959
61986
|
const unsupported = lines.map((line) => ({
|
|
61960
|
-
id: `${
|
|
61987
|
+
id: `${root4}:free:${line.id}`,
|
|
61961
61988
|
kind: "grid-axis",
|
|
61962
61989
|
status: "unsupported",
|
|
61963
61990
|
code: "free-angle-grid-axis-unrepresentable",
|
|
@@ -62619,8 +62646,8 @@ function registerRevisionRoutes(app) {
|
|
|
62619
62646
|
}
|
|
62620
62647
|
|
|
62621
62648
|
// project-export-files.ts
|
|
62622
|
-
var
|
|
62623
|
-
var
|
|
62649
|
+
var import_node_fs27 = require("node:fs");
|
|
62650
|
+
var import_node_path24 = require("node:path");
|
|
62624
62651
|
function projectExportFiles(appId, kindOf2 = appId) {
|
|
62625
62652
|
if (kindOf2 === "vectorize") {
|
|
62626
62653
|
return [{ kind: "svg", filename: `${appId}.svg` }];
|
|
@@ -62648,26 +62675,26 @@ function exportFileBase(projectId, appId, now = /* @__PURE__ */ new Date()) {
|
|
|
62648
62675
|
}
|
|
62649
62676
|
function uniqueProjectExportFilename(projectId, preferred) {
|
|
62650
62677
|
const dir = projectExportsDir(projectId);
|
|
62651
|
-
if (!(0,
|
|
62652
|
-
const extension = (0,
|
|
62678
|
+
if (!(0, import_node_fs27.existsSync)((0, import_node_path24.join)(dir, preferred))) return preferred;
|
|
62679
|
+
const extension = (0, import_node_path24.extname)(preferred);
|
|
62653
62680
|
const stem = preferred.slice(0, preferred.length - extension.length);
|
|
62654
62681
|
for (let suffix = 2; suffix <= 9999; suffix += 1) {
|
|
62655
62682
|
const candidate = `${stem}-${suffix}${extension}`;
|
|
62656
|
-
if (!(0,
|
|
62683
|
+
if (!(0, import_node_fs27.existsSync)((0, import_node_path24.join)(dir, candidate))) return candidate;
|
|
62657
62684
|
}
|
|
62658
62685
|
throw new Error("could not allocate a unique project export filename");
|
|
62659
62686
|
}
|
|
62660
62687
|
|
|
62661
62688
|
// project-export-receipts.ts
|
|
62662
62689
|
var import_node_crypto15 = require("node:crypto");
|
|
62663
|
-
var
|
|
62664
|
-
var
|
|
62690
|
+
var import_node_fs28 = require("node:fs");
|
|
62691
|
+
var import_node_path26 = require("node:path");
|
|
62665
62692
|
|
|
62666
62693
|
// safe-filename.ts
|
|
62667
|
-
var
|
|
62694
|
+
var import_node_path25 = require("node:path");
|
|
62668
62695
|
var WINDOWS_DEVICE = /^(?:con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\.|$)/i;
|
|
62669
62696
|
function isPortablePlainFilename(name) {
|
|
62670
|
-
return !!name && (0,
|
|
62697
|
+
return !!name && (0, import_node_path25.basename)(name) === name && name !== "." && name !== ".." && !/[\\/\u0000-\u001f\u007f<>:"|?*]/.test(name) && !/[. ]$/.test(name) && !WINDOWS_DEVICE.test(name) && Buffer.byteLength(name, "utf8") <= 255;
|
|
62671
62698
|
}
|
|
62672
62699
|
|
|
62673
62700
|
// project-export-receipts.ts
|
|
@@ -62686,7 +62713,7 @@ var EXTENSIONS = {
|
|
|
62686
62713
|
"render-mp4": ".mp4"
|
|
62687
62714
|
};
|
|
62688
62715
|
var RESERVED2 = /^\.floless-(?:txn|cleanup|tmp|backup)-/i;
|
|
62689
|
-
var projectExportIndexPath = (projectId) => (0,
|
|
62716
|
+
var projectExportIndexPath = (projectId) => (0, import_node_path26.join)(projectExportsDir(projectId), "index.json");
|
|
62690
62717
|
function hash(bytes) {
|
|
62691
62718
|
return (0, import_node_crypto15.createHash)("sha256").update(bytes).digest("hex");
|
|
62692
62719
|
}
|
|
@@ -62694,13 +62721,13 @@ function proof(bytes) {
|
|
|
62694
62721
|
return bytes ? { exists: true, bytes: bytes.length, sha256: hash(bytes) } : { exists: false, bytes: 0, sha256: null };
|
|
62695
62722
|
}
|
|
62696
62723
|
function readFileProof(path) {
|
|
62697
|
-
return (0,
|
|
62724
|
+
return (0, import_node_fs28.existsSync)(path) ? proof((0, import_node_fs28.readFileSync)(path)) : proof(null);
|
|
62698
62725
|
}
|
|
62699
62726
|
function fileProofEquals(a, b) {
|
|
62700
62727
|
return a.exists === b.exists && a.bytes === b.bytes && a.sha256 === b.sha256;
|
|
62701
62728
|
}
|
|
62702
62729
|
function validReceiptFilename(kind, filename) {
|
|
62703
|
-
if (!isPortablePlainFilename(filename) || filename === "index.json" || RESERVED2.test(filename) || (0,
|
|
62730
|
+
if (!isPortablePlainFilename(filename) || filename === "index.json" || RESERVED2.test(filename) || (0, import_node_path26.basename)(filename) !== filename) return false;
|
|
62704
62731
|
return filename.toLowerCase().endsWith(EXTENSIONS[kind]);
|
|
62705
62732
|
}
|
|
62706
62733
|
function isExportKind(v) {
|
|
@@ -62793,45 +62820,45 @@ function indexBytes(body) {
|
|
|
62793
62820
|
`, "utf8");
|
|
62794
62821
|
}
|
|
62795
62822
|
function syncFile(path) {
|
|
62796
|
-
const fd2 = (0,
|
|
62823
|
+
const fd2 = (0, import_node_fs28.openSync)(path, "r+");
|
|
62797
62824
|
try {
|
|
62798
|
-
(0,
|
|
62825
|
+
(0, import_node_fs28.fsyncSync)(fd2);
|
|
62799
62826
|
} finally {
|
|
62800
|
-
(0,
|
|
62827
|
+
(0, import_node_fs28.closeSync)(fd2);
|
|
62801
62828
|
}
|
|
62802
62829
|
}
|
|
62803
62830
|
function syncDirectory(path) {
|
|
62804
62831
|
try {
|
|
62805
|
-
const fd2 = (0,
|
|
62832
|
+
const fd2 = (0, import_node_fs28.openSync)(path, "r");
|
|
62806
62833
|
try {
|
|
62807
|
-
(0,
|
|
62834
|
+
(0, import_node_fs28.fsyncSync)(fd2);
|
|
62808
62835
|
} finally {
|
|
62809
|
-
(0,
|
|
62836
|
+
(0, import_node_fs28.closeSync)(fd2);
|
|
62810
62837
|
}
|
|
62811
62838
|
} catch {
|
|
62812
62839
|
}
|
|
62813
62840
|
}
|
|
62814
62841
|
function durableReplace(path, bytes) {
|
|
62815
|
-
const dir = (0,
|
|
62816
|
-
(0,
|
|
62817
|
-
const tmp = (0,
|
|
62842
|
+
const dir = (0, import_node_path26.dirname)(path);
|
|
62843
|
+
(0, import_node_fs28.mkdirSync)(dir, { recursive: true });
|
|
62844
|
+
const tmp = (0, import_node_path26.join)(dir, `.floless-tmp-receipt-${(0, import_node_crypto15.randomUUID)()}`);
|
|
62818
62845
|
try {
|
|
62819
|
-
(0,
|
|
62846
|
+
(0, import_node_fs28.writeFileSync)(tmp, bytes, { flag: "wx" });
|
|
62820
62847
|
syncFile(tmp);
|
|
62821
|
-
(0,
|
|
62848
|
+
(0, import_node_fs28.renameSync)(tmp, path);
|
|
62822
62849
|
syncFile(path);
|
|
62823
62850
|
syncDirectory(dir);
|
|
62824
62851
|
} finally {
|
|
62825
62852
|
try {
|
|
62826
|
-
(0,
|
|
62853
|
+
(0, import_node_fs28.rmSync)(tmp, { force: true });
|
|
62827
62854
|
} catch {
|
|
62828
62855
|
}
|
|
62829
62856
|
}
|
|
62830
62857
|
}
|
|
62831
62858
|
function strictCurrent(projectId) {
|
|
62832
62859
|
const path = projectExportIndexPath(projectId);
|
|
62833
|
-
if (!(0,
|
|
62834
|
-
const bytes = (0,
|
|
62860
|
+
if (!(0, import_node_fs28.existsSync)(path)) return { bytes: null, body: { exports: [], opaque: [] } };
|
|
62861
|
+
const bytes = (0, import_node_fs28.readFileSync)(path);
|
|
62835
62862
|
return { bytes, body: parseIndexBytes(bytes) };
|
|
62836
62863
|
}
|
|
62837
62864
|
function listProjectExportReceipts(projectId) {
|
|
@@ -62843,14 +62870,14 @@ function listProjectExportReceipts(projectId) {
|
|
|
62843
62870
|
}
|
|
62844
62871
|
function resolveProjectExportReceiptPath(projectId, receipt) {
|
|
62845
62872
|
if (!validReceiptFilename(receipt.kind, receipt.filename)) return null;
|
|
62846
|
-
const dir = (0,
|
|
62847
|
-
const path = (0,
|
|
62848
|
-
return (0,
|
|
62873
|
+
const dir = (0, import_node_path26.resolve)(projectExportsDir(projectId));
|
|
62874
|
+
const path = (0, import_node_path26.resolve)(dir, receipt.filename);
|
|
62875
|
+
return (0, import_node_path26.dirname)(path) === dir ? path : null;
|
|
62849
62876
|
}
|
|
62850
62877
|
function prepareProjectExport(projectId, receipt) {
|
|
62851
62878
|
validateInput(receipt);
|
|
62852
62879
|
const dir = projectExportsDir(projectId);
|
|
62853
|
-
(0,
|
|
62880
|
+
(0, import_node_fs28.mkdirSync)(dir, { recursive: true });
|
|
62854
62881
|
const current = strictCurrent(projectId);
|
|
62855
62882
|
const key = receiptKey(receipt.kind, receipt.variant);
|
|
62856
62883
|
const prior = current.body.exports.find((row) => receiptKey(row.kind, row.variant) === key) ?? null;
|
|
@@ -62919,8 +62946,8 @@ function restoreProjectExportTransition(transition) {
|
|
|
62919
62946
|
}
|
|
62920
62947
|
durableReplace(transition.indexPath, Buffer.from(transition.beforeBytesBase64, "base64"));
|
|
62921
62948
|
} else {
|
|
62922
|
-
(0,
|
|
62923
|
-
syncDirectory((0,
|
|
62949
|
+
(0, import_node_fs28.rmSync)(transition.indexPath, { force: true });
|
|
62950
|
+
syncDirectory((0, import_node_path26.dirname)(transition.indexPath));
|
|
62924
62951
|
}
|
|
62925
62952
|
if (!currentMatches(transition.indexPath, transition.before)) {
|
|
62926
62953
|
throw new ProjectExportReceiptError("project export index did not match the restored proof.");
|
|
@@ -62942,8 +62969,8 @@ function cleanupSupersededProjectExport(transition) {
|
|
|
62942
62969
|
const path = resolveProjectExportReceiptPath(transition.projectId, superseded);
|
|
62943
62970
|
if (!path) return;
|
|
62944
62971
|
try {
|
|
62945
|
-
(0,
|
|
62946
|
-
syncDirectory((0,
|
|
62972
|
+
(0, import_node_fs28.rmSync)(path, { force: true });
|
|
62973
|
+
syncDirectory((0, import_node_path26.dirname)(path));
|
|
62947
62974
|
} catch {
|
|
62948
62975
|
}
|
|
62949
62976
|
}
|
|
@@ -62956,7 +62983,7 @@ function publishProjectExportArtifact(projectId, receipt, bytes) {
|
|
|
62956
62983
|
if (!path) throw new ProjectExportReceiptError("project export artifact path is unsafe.");
|
|
62957
62984
|
let wroteArtifact = false;
|
|
62958
62985
|
try {
|
|
62959
|
-
(0,
|
|
62986
|
+
(0, import_node_fs28.writeFileSync)(path, bytes, { flag: "wx" });
|
|
62960
62987
|
wroteArtifact = true;
|
|
62961
62988
|
syncFile(path);
|
|
62962
62989
|
commitProjectExportTransition(transition);
|
|
@@ -62971,8 +62998,8 @@ function publishProjectExportArtifact(projectId, receipt, bytes) {
|
|
|
62971
62998
|
}
|
|
62972
62999
|
if (!restoreError && wroteArtifact) {
|
|
62973
63000
|
try {
|
|
62974
|
-
(0,
|
|
62975
|
-
syncDirectory((0,
|
|
63001
|
+
(0, import_node_fs28.rmSync)(path, { force: true });
|
|
63002
|
+
syncDirectory((0, import_node_path26.dirname)(path));
|
|
62976
63003
|
} catch {
|
|
62977
63004
|
}
|
|
62978
63005
|
}
|
|
@@ -62986,7 +63013,7 @@ function publishProjectExportArtifact(projectId, receipt, bytes) {
|
|
|
62986
63013
|
}
|
|
62987
63014
|
function receiptHasFile(projectId, receipt) {
|
|
62988
63015
|
const path = resolveProjectExportReceiptPath(projectId, receipt);
|
|
62989
|
-
return path !== null && (0,
|
|
63016
|
+
return path !== null && (0, import_node_fs28.existsSync)(path);
|
|
62990
63017
|
}
|
|
62991
63018
|
function matchingProjectExportReceipts(projectId, version, contractHash2, kinds) {
|
|
62992
63019
|
const wanted = kinds ? new Set(kinds) : null;
|
|
@@ -63033,7 +63060,7 @@ function currentApprovedSnapshot(projectId, version) {
|
|
|
63033
63060
|
}
|
|
63034
63061
|
|
|
63035
63062
|
// workspace-data.ts
|
|
63036
|
-
var
|
|
63063
|
+
var import_node_fs29 = require("node:fs");
|
|
63037
63064
|
var VALID_INCLUDES = /* @__PURE__ */ new Set(["contract", "exports"]);
|
|
63038
63065
|
var VALID_EXPORT_KINDS = /* @__PURE__ */ new Set([
|
|
63039
63066
|
"bom-csv",
|
|
@@ -63093,15 +63120,15 @@ function exportBody(projectId, receipt, opts) {
|
|
|
63093
63120
|
};
|
|
63094
63121
|
if (opts.includePaths) body.path = path;
|
|
63095
63122
|
if (opts.exportContents) {
|
|
63096
|
-
const st = (0,
|
|
63123
|
+
const st = (0, import_node_fs29.statSync)(path);
|
|
63097
63124
|
if (st.size > opts.maxBytes) {
|
|
63098
63125
|
body.contentOmitted = true;
|
|
63099
63126
|
body.omittedReason = `export is ${st.size} bytes, over max-bytes ${opts.maxBytes}`;
|
|
63100
63127
|
} else if (receipt.encoding === "base64") {
|
|
63101
|
-
body.content = (0,
|
|
63128
|
+
body.content = (0, import_node_fs29.readFileSync)(path).toString("base64");
|
|
63102
63129
|
} else {
|
|
63103
63130
|
body.encoding = receipt.encoding ?? "utf8";
|
|
63104
|
-
body.content = (0,
|
|
63131
|
+
body.content = (0, import_node_fs29.readFileSync)(path, "utf8");
|
|
63105
63132
|
}
|
|
63106
63133
|
}
|
|
63107
63134
|
return body;
|
|
@@ -64517,18 +64544,18 @@ function registerMigrationPreviewRoute(app, deps) {
|
|
|
64517
64544
|
}
|
|
64518
64545
|
|
|
64519
64546
|
// workspace-agent-manifest.ts
|
|
64520
|
-
var
|
|
64521
|
-
var
|
|
64522
|
-
var
|
|
64547
|
+
var import_node_fs30 = require("node:fs");
|
|
64548
|
+
var import_node_os16 = require("node:os");
|
|
64549
|
+
var import_node_path27 = require("node:path");
|
|
64523
64550
|
function awareHome() {
|
|
64524
|
-
return process.env.AWARE_HOME || (0,
|
|
64551
|
+
return process.env.AWARE_HOME || (0, import_node_path27.join)((0, import_node_os16.homedir)(), ".aware");
|
|
64525
64552
|
}
|
|
64526
64553
|
function workspaceAgentDir() {
|
|
64527
|
-
return (0,
|
|
64554
|
+
return (0, import_node_path27.join)(awareHome(), "agents", "floless-workspace");
|
|
64528
64555
|
}
|
|
64529
64556
|
function syncWorkspaceAgentManifest(port) {
|
|
64530
64557
|
const dir = workspaceAgentDir();
|
|
64531
|
-
(0,
|
|
64558
|
+
(0, import_node_fs30.mkdirSync)(dir, { recursive: true });
|
|
64532
64559
|
const manifest = `agent: floless-workspace
|
|
64533
64560
|
version: 0.2.0
|
|
64534
64561
|
sdk-target: 2.4.0
|
|
@@ -64658,8 +64685,8 @@ commands:
|
|
|
64658
64685
|
headers: object
|
|
64659
64686
|
body: object
|
|
64660
64687
|
`;
|
|
64661
|
-
const path = (0,
|
|
64662
|
-
if (!(0,
|
|
64688
|
+
const path = (0, import_node_path27.join)(dir, "manifest.yaml");
|
|
64689
|
+
if (!(0, import_node_fs30.existsSync)(path) || manifest !== "") (0, import_node_fs30.writeFileSync)(path, manifest, "utf8");
|
|
64663
64690
|
return path;
|
|
64664
64691
|
}
|
|
64665
64692
|
|
|
@@ -65652,7 +65679,7 @@ function computeVersionDiff(id, n, base) {
|
|
|
65652
65679
|
}
|
|
65653
65680
|
|
|
65654
65681
|
// contract-bake.ts
|
|
65655
|
-
var
|
|
65682
|
+
var import_node_fs31 = require("node:fs");
|
|
65656
65683
|
var import_yaml7 = __toESM(require_dist6(), 1);
|
|
65657
65684
|
function bakedV2(contract) {
|
|
65658
65685
|
const baked = { ...contract };
|
|
@@ -65672,7 +65699,7 @@ function bakedV2(contract) {
|
|
|
65672
65699
|
return stripConfidentialImages(baked);
|
|
65673
65700
|
}
|
|
65674
65701
|
function bakeContractIntoApp(sourcePath, contract) {
|
|
65675
|
-
const doc = (0, import_yaml7.parseDocument)((0,
|
|
65702
|
+
const doc = (0, import_yaml7.parseDocument)((0, import_node_fs31.readFileSync)(sourcePath, "utf8"));
|
|
65676
65703
|
if (doc.errors.length > 0) {
|
|
65677
65704
|
throw new Error(`contract bake: source is not valid YAML: ${doc.errors[0]?.message ?? "parse error"}`);
|
|
65678
65705
|
}
|
|
@@ -65689,7 +65716,7 @@ function bakeContractIntoApp(sourcePath, contract) {
|
|
|
65689
65716
|
throw new InvalidModelV2Error(`refusing to bake: contract declares steel.model/v2 but is not valid v2: ${issues[0] ?? "unknown"}`, issues);
|
|
65690
65717
|
}
|
|
65691
65718
|
doc.setIn(["nodes", idx, "config", "takeoff"], bakedV2(contract));
|
|
65692
|
-
(0,
|
|
65719
|
+
(0, import_node_fs31.writeFileSync)(sourcePath, doc.toString());
|
|
65693
65720
|
return;
|
|
65694
65721
|
}
|
|
65695
65722
|
const baked = { ...contract };
|
|
@@ -65734,7 +65761,7 @@ function bakeContractIntoApp(sourcePath, contract) {
|
|
|
65734
65761
|
);
|
|
65735
65762
|
}
|
|
65736
65763
|
doc.setIn(["nodes", idx, "config", "takeoff"], baked);
|
|
65737
|
-
(0,
|
|
65764
|
+
(0, import_node_fs31.writeFileSync)(sourcePath, doc.toString());
|
|
65738
65765
|
}
|
|
65739
65766
|
|
|
65740
65767
|
// vectorize.ts
|
|
@@ -66091,11 +66118,11 @@ function viewsToScene(contractInput) {
|
|
|
66091
66118
|
}
|
|
66092
66119
|
|
|
66093
66120
|
// bom-export.ts
|
|
66094
|
-
var
|
|
66095
|
-
var
|
|
66121
|
+
var import_node_os17 = require("node:os");
|
|
66122
|
+
var import_node_path28 = require("node:path");
|
|
66096
66123
|
|
|
66097
66124
|
// node_modules/write-excel-file/modules/export/writeXlsxFileNode.js
|
|
66098
|
-
var
|
|
66125
|
+
var import_node_fs32 = __toESM(require("node:fs"), 1);
|
|
66099
66126
|
|
|
66100
66127
|
// node_modules/write-excel-file/modules/xlsx/helpers/features/getAdditionalContent.js
|
|
66101
66128
|
function _createForOfIteratorHelperLoose(r, e) {
|
|
@@ -69195,7 +69222,7 @@ function writeXlsxFile(arg1, arg2, arg3) {
|
|
|
69195
69222
|
},
|
|
69196
69223
|
toFile: function toFile(filePath) {
|
|
69197
69224
|
return createReadableStream().then(function(readableStream) {
|
|
69198
|
-
return pipe(readableStream,
|
|
69225
|
+
return pipe(readableStream, import_node_fs32.default.createWriteStream(filePath));
|
|
69199
69226
|
});
|
|
69200
69227
|
}
|
|
69201
69228
|
};
|
|
@@ -69220,8 +69247,8 @@ function pipe(readableStream, writableStream) {
|
|
|
69220
69247
|
|
|
69221
69248
|
// bom-export.ts
|
|
69222
69249
|
function bomExportPath(appId, format) {
|
|
69223
|
-
const
|
|
69224
|
-
return (0,
|
|
69250
|
+
const root4 = process.env.FLOLESS_HOME ?? (0, import_node_path28.join)((0, import_node_os17.homedir)(), ".floless");
|
|
69251
|
+
return (0, import_node_path28.join)(root4, "exports", appId, `${appId}-bom.${format}`);
|
|
69225
69252
|
}
|
|
69226
69253
|
function csvField(v) {
|
|
69227
69254
|
let s = String(v);
|
|
@@ -69266,11 +69293,11 @@ async function bomToXlsx(bom) {
|
|
|
69266
69293
|
}
|
|
69267
69294
|
|
|
69268
69295
|
// scene-bake.ts
|
|
69269
|
-
var
|
|
69270
|
-
var
|
|
69296
|
+
var import_node_fs33 = require("node:fs");
|
|
69297
|
+
var import_node_path29 = require("node:path");
|
|
69271
69298
|
var import_yaml8 = __toESM(require_dist6(), 1);
|
|
69272
69299
|
function bakeSceneIntoApp(sourcePath, scene, agent = "viewer-3d") {
|
|
69273
|
-
const doc = (0, import_yaml8.parseDocument)((0,
|
|
69300
|
+
const doc = (0, import_yaml8.parseDocument)((0, import_node_fs33.readFileSync)(sourcePath, "utf8"));
|
|
69274
69301
|
if (doc.errors.length > 0) {
|
|
69275
69302
|
throw new Error(`scene bake: source is not valid YAML: ${doc.errors[0]?.message ?? "parse error"}`);
|
|
69276
69303
|
}
|
|
@@ -69279,10 +69306,10 @@ function bakeSceneIntoApp(sourcePath, scene, agent = "viewer-3d") {
|
|
|
69279
69306
|
const idx = items.findIndex((it) => ((0, import_yaml8.isMap)(it) ? it.toJSON() : null)?.agent === agent);
|
|
69280
69307
|
if (idx < 0) throw new Error(`no ${agent} render node to bake the scene into`);
|
|
69281
69308
|
doc.setIn(["nodes", idx, "config", "scene"], scene);
|
|
69282
|
-
(0,
|
|
69309
|
+
(0, import_node_fs33.writeFileSync)(sourcePath, doc.toString());
|
|
69283
69310
|
}
|
|
69284
69311
|
function bakeNodeConfigById(sourcePath, nodeId, patch2) {
|
|
69285
|
-
const doc = (0, import_yaml8.parseDocument)((0,
|
|
69312
|
+
const doc = (0, import_yaml8.parseDocument)((0, import_node_fs33.readFileSync)(sourcePath, "utf8"));
|
|
69286
69313
|
if (doc.errors.length > 0) {
|
|
69287
69314
|
throw new Error(`node bake: source is not valid YAML: ${doc.errors[0]?.message ?? "parse error"}`);
|
|
69288
69315
|
}
|
|
@@ -69291,12 +69318,12 @@ function bakeNodeConfigById(sourcePath, nodeId, patch2) {
|
|
|
69291
69318
|
const idx = items.findIndex((it) => ((0, import_yaml8.isMap)(it) ? it.toJSON() : null)?.id === nodeId);
|
|
69292
69319
|
if (idx < 0) throw new Error(`no node with id "${nodeId}"`);
|
|
69293
69320
|
for (const [key, value] of Object.entries(patch2)) doc.setIn(["nodes", idx, "config", key], value);
|
|
69294
|
-
(0,
|
|
69321
|
+
(0, import_node_fs33.writeFileSync)(sourcePath, doc.toString());
|
|
69295
69322
|
}
|
|
69296
69323
|
function writeViewer3dApp(dir, appId, scene) {
|
|
69297
|
-
(0,
|
|
69298
|
-
const flo = (0,
|
|
69299
|
-
(0,
|
|
69324
|
+
(0, import_node_fs33.mkdirSync)(dir, { recursive: true });
|
|
69325
|
+
const flo = (0, import_node_path29.join)(dir, `${appId}.flo`);
|
|
69326
|
+
(0, import_node_fs33.writeFileSync)(flo, [
|
|
69300
69327
|
`app: ${appId}`,
|
|
69301
69328
|
"version: 0.1.0",
|
|
69302
69329
|
"display-name: Steel 3D",
|
|
@@ -69317,9 +69344,9 @@ function writeViewer3dApp(dir, appId, scene) {
|
|
|
69317
69344
|
return flo;
|
|
69318
69345
|
}
|
|
69319
69346
|
function writeTeklaApp(dir, appId, scene, teklaVersion = "2026.0") {
|
|
69320
|
-
(0,
|
|
69321
|
-
const flo = (0,
|
|
69322
|
-
(0,
|
|
69347
|
+
(0, import_node_fs33.mkdirSync)(dir, { recursive: true });
|
|
69348
|
+
const flo = (0, import_node_path29.join)(dir, `${appId}.flo`);
|
|
69349
|
+
(0, import_node_fs33.writeFileSync)(flo, [
|
|
69323
69350
|
`app: ${appId}`,
|
|
69324
69351
|
"version: 0.1.0",
|
|
69325
69352
|
"display-name: Steel to Tekla",
|
|
@@ -69423,9 +69450,9 @@ async function teklaVersionToBake() {
|
|
|
69423
69450
|
|
|
69424
69451
|
// ifc-publication.ts
|
|
69425
69452
|
var import_node_crypto17 = require("node:crypto");
|
|
69426
|
-
var
|
|
69427
|
-
var
|
|
69428
|
-
var
|
|
69453
|
+
var import_node_fs34 = require("node:fs");
|
|
69454
|
+
var import_node_os18 = require("node:os");
|
|
69455
|
+
var import_node_path30 = require("node:path");
|
|
69429
69456
|
var IfcPublicationError = class extends Error {
|
|
69430
69457
|
constructor(message) {
|
|
69431
69458
|
super(message);
|
|
@@ -69457,37 +69484,37 @@ function sameProof(path, expected) {
|
|
|
69457
69484
|
return fileProofEquals(readFileProof(path), expected);
|
|
69458
69485
|
}
|
|
69459
69486
|
function syncFile2(path) {
|
|
69460
|
-
const fd2 = (0,
|
|
69487
|
+
const fd2 = (0, import_node_fs34.openSync)(path, "r+");
|
|
69461
69488
|
try {
|
|
69462
|
-
(0,
|
|
69489
|
+
(0, import_node_fs34.fsyncSync)(fd2);
|
|
69463
69490
|
} finally {
|
|
69464
|
-
(0,
|
|
69491
|
+
(0, import_node_fs34.closeSync)(fd2);
|
|
69465
69492
|
}
|
|
69466
69493
|
}
|
|
69467
69494
|
function syncDirectory2(path) {
|
|
69468
69495
|
try {
|
|
69469
|
-
const fd2 = (0,
|
|
69496
|
+
const fd2 = (0, import_node_fs34.openSync)(path, "r");
|
|
69470
69497
|
try {
|
|
69471
|
-
(0,
|
|
69498
|
+
(0, import_node_fs34.fsyncSync)(fd2);
|
|
69472
69499
|
} finally {
|
|
69473
|
-
(0,
|
|
69500
|
+
(0, import_node_fs34.closeSync)(fd2);
|
|
69474
69501
|
}
|
|
69475
69502
|
} catch {
|
|
69476
69503
|
}
|
|
69477
69504
|
}
|
|
69478
69505
|
function durableReplace2(path, bytes) {
|
|
69479
|
-
const dir = (0,
|
|
69480
|
-
(0,
|
|
69481
|
-
const tmp = (0,
|
|
69506
|
+
const dir = (0, import_node_path30.dirname)(path);
|
|
69507
|
+
(0, import_node_fs34.mkdirSync)(dir, { recursive: true });
|
|
69508
|
+
const tmp = (0, import_node_path30.join)(dir, `.floless-tmp-recovery-${(0, import_node_crypto17.randomUUID)()}`);
|
|
69482
69509
|
try {
|
|
69483
|
-
(0,
|
|
69510
|
+
(0, import_node_fs34.writeFileSync)(tmp, bytes, { flag: "wx" });
|
|
69484
69511
|
syncFile2(tmp);
|
|
69485
|
-
(0,
|
|
69512
|
+
(0, import_node_fs34.renameSync)(tmp, path);
|
|
69486
69513
|
syncFile2(path);
|
|
69487
69514
|
syncDirectory2(dir);
|
|
69488
69515
|
} finally {
|
|
69489
69516
|
try {
|
|
69490
|
-
(0,
|
|
69517
|
+
(0, import_node_fs34.rmSync)(tmp, { force: true });
|
|
69491
69518
|
} catch {
|
|
69492
69519
|
}
|
|
69493
69520
|
}
|
|
@@ -69499,26 +69526,26 @@ function plainIfcFilename(name) {
|
|
|
69499
69526
|
return isPortablePlainFilename(name) && name.toLowerCase().endsWith(".ifc") && !name.toLowerCase().startsWith(".floless-");
|
|
69500
69527
|
}
|
|
69501
69528
|
function canonicalPath(path) {
|
|
69502
|
-
return (0,
|
|
69529
|
+
return (0, import_node_path30.resolve)(path);
|
|
69503
69530
|
}
|
|
69504
69531
|
function validateRequestPaths(tempPath, finalPath) {
|
|
69505
69532
|
const final = canonicalPath(finalPath);
|
|
69506
69533
|
const temp = canonicalPath(tempPath);
|
|
69507
|
-
const dir = (0,
|
|
69508
|
-
if ((0,
|
|
69509
|
-
if (!plainIfcFilename((0,
|
|
69510
|
-
if (!TEMP_RE.test((0,
|
|
69534
|
+
const dir = (0, import_node_path30.dirname)(final);
|
|
69535
|
+
if ((0, import_node_path30.dirname)(temp) !== dir) throw new IfcPublicationError("IFC temp and final paths must share one directory.");
|
|
69536
|
+
if (!plainIfcFilename((0, import_node_path30.basename)(final))) throw new IfcPublicationError("IFC final filename is unsafe.");
|
|
69537
|
+
if (!TEMP_RE.test((0, import_node_path30.basename)(temp))) throw new IfcPublicationError("IFC temp filename is not request-scoped.");
|
|
69511
69538
|
return { dir, temp, final };
|
|
69512
69539
|
}
|
|
69513
69540
|
function requestIfcTempPath(finalPath) {
|
|
69514
69541
|
const final = canonicalPath(finalPath);
|
|
69515
|
-
if (!plainIfcFilename((0,
|
|
69516
|
-
(0,
|
|
69517
|
-
return (0,
|
|
69542
|
+
if (!plainIfcFilename((0, import_node_path30.basename)(final))) throw new IfcPublicationError("IFC final filename is unsafe.");
|
|
69543
|
+
(0, import_node_fs34.mkdirSync)((0, import_node_path30.dirname)(final), { recursive: true });
|
|
69544
|
+
return (0, import_node_path30.join)((0, import_node_path30.dirname)(final), `.floless-tmp-ifc-${(0, import_node_crypto17.randomUUID)()}.ifc`);
|
|
69518
69545
|
}
|
|
69519
69546
|
function validateIfc(path) {
|
|
69520
|
-
if (!(0,
|
|
69521
|
-
const bytes = (0,
|
|
69547
|
+
if (!(0, import_node_fs34.existsSync)(path) || (0, import_node_fs34.statSync)(path).size === 0) throw new IfcPublicationError("the IFC export produced no file");
|
|
69548
|
+
const bytes = (0, import_node_fs34.readFileSync)(path);
|
|
69522
69549
|
const prefix = bytes.subarray(0, Math.min(bytes.length, 128)).toString("utf8");
|
|
69523
69550
|
if (!prefix.includes("ISO-10303-21")) throw new IfcPublicationError("the IFC export did not produce a valid STEP envelope");
|
|
69524
69551
|
return { bytes, proof: proof2(bytes) };
|
|
@@ -69531,21 +69558,21 @@ function metadataEqual(a, b) {
|
|
|
69531
69558
|
function writePhase(txnDir, journal) {
|
|
69532
69559
|
const index = PHASES.indexOf(journal.phase);
|
|
69533
69560
|
if (index < 0) throw new IfcPublicationError(`unknown IFC publication phase "${journal.phase}".`);
|
|
69534
|
-
const destination = (0,
|
|
69535
|
-
if ((0,
|
|
69536
|
-
const temp = (0,
|
|
69561
|
+
const destination = (0, import_node_path30.join)(txnDir, `${String(index).padStart(3, "0")}-${journal.phase}.json`);
|
|
69562
|
+
if ((0, import_node_fs34.existsSync)(destination)) throw new IfcPublicationError(`IFC publication phase "${journal.phase}" already exists.`);
|
|
69563
|
+
const temp = (0, import_node_path30.join)(txnDir, `.phase-${(0, import_node_crypto17.randomUUID)()}.tmp`);
|
|
69537
69564
|
const bytes = Buffer.from(`${JSON.stringify(journal, null, 2)}
|
|
69538
69565
|
`, "utf8");
|
|
69539
69566
|
try {
|
|
69540
|
-
(0,
|
|
69567
|
+
(0, import_node_fs34.writeFileSync)(temp, bytes, { flag: "wx" });
|
|
69541
69568
|
syncFile2(temp);
|
|
69542
|
-
(0,
|
|
69569
|
+
(0, import_node_fs34.renameSync)(temp, destination);
|
|
69543
69570
|
syncFile2(destination);
|
|
69544
69571
|
syncDirectory2(txnDir);
|
|
69545
|
-
syncDirectory2((0,
|
|
69572
|
+
syncDirectory2((0, import_node_path30.dirname)(txnDir));
|
|
69546
69573
|
} finally {
|
|
69547
69574
|
try {
|
|
69548
|
-
(0,
|
|
69575
|
+
(0, import_node_fs34.rmSync)(temp, { force: true });
|
|
69549
69576
|
} catch {
|
|
69550
69577
|
}
|
|
69551
69578
|
}
|
|
@@ -69565,12 +69592,12 @@ function validateJournal(raw, txnDir, expectedTxnId) {
|
|
|
69565
69592
|
const resource = j.resource;
|
|
69566
69593
|
if (!validResource(resource)) throw new IfcPublicationError("IFC journal resource is invalid.");
|
|
69567
69594
|
const exportDir = canonicalPath(String(j.exportDir));
|
|
69568
|
-
const actualDir = canonicalPath((0,
|
|
69595
|
+
const actualDir = canonicalPath((0, import_node_path30.dirname)(txnDir));
|
|
69569
69596
|
if (exportDir !== actualDir) throw new IfcPublicationError("IFC journal export directory is not canonical.");
|
|
69570
69597
|
const finalPath = canonicalPath(String(j.finalPath));
|
|
69571
69598
|
const tempPath = canonicalPath(String(j.tempPath));
|
|
69572
69599
|
const backupPath = canonicalPath(String(j.backupPath));
|
|
69573
|
-
if ((0,
|
|
69600
|
+
if ((0, import_node_path30.dirname)(finalPath) !== exportDir || (0, import_node_path30.dirname)(tempPath) !== exportDir || (0, import_node_path30.dirname)(backupPath) !== exportDir || !plainIfcFilename((0, import_node_path30.basename)(finalPath)) || !TEMP_RE.test((0, import_node_path30.basename)(tempPath)) || !BACKUP_RE.test((0, import_node_path30.basename)(backupPath))) throw new IfcPublicationError("IFC journal contains an unsafe artifact path.");
|
|
69574
69601
|
const journal = {
|
|
69575
69602
|
version: 1,
|
|
69576
69603
|
txnId: expectedTxnId,
|
|
@@ -69590,7 +69617,7 @@ function validateJournal(raw, txnDir, expectedTxnId) {
|
|
|
69590
69617
|
}
|
|
69591
69618
|
if (journal.mode === "artifact-with-receipt") {
|
|
69592
69619
|
const indexPath = canonicalPath(String(j.indexPath));
|
|
69593
|
-
if ((0,
|
|
69620
|
+
if ((0, import_node_path30.dirname)(indexPath) !== exportDir || (0, import_node_path30.basename)(indexPath) !== "index.json") {
|
|
69594
69621
|
throw new IfcPublicationError("IFC journal receipt index path is unsafe.");
|
|
69595
69622
|
}
|
|
69596
69623
|
journal.indexPath = indexPath;
|
|
@@ -69608,10 +69635,10 @@ function validateJournal(raw, txnDir, expectedTxnId) {
|
|
|
69608
69635
|
return journal;
|
|
69609
69636
|
}
|
|
69610
69637
|
function loadJournal(txnDir) {
|
|
69611
|
-
const match = (0,
|
|
69612
|
-
if (!match) throw new IfcPublicationError(`unsafe IFC transaction directory "${(0,
|
|
69638
|
+
const match = (0, import_node_path30.basename)(txnDir).match(ACTIVE_RE);
|
|
69639
|
+
if (!match) throw new IfcPublicationError(`unsafe IFC transaction directory "${(0, import_node_path30.basename)(txnDir)}".`);
|
|
69613
69640
|
const txnId = match[1];
|
|
69614
|
-
const entries2 = (0,
|
|
69641
|
+
const entries2 = (0, import_node_fs34.readdirSync)(txnDir, { withFileTypes: true });
|
|
69615
69642
|
if (!entries2.length) return null;
|
|
69616
69643
|
const phaseFiles = entries2.filter((entry2) => entry2.isFile() && PHASE_RE.test(entry2.name)).sort((a, b) => a.name.localeCompare(b.name));
|
|
69617
69644
|
const unknown = entries2.filter((entry2) => !(entry2.isFile() && (PHASE_RE.test(entry2.name) || /^\.phase-[a-f0-9-]+\.tmp$/i.test(entry2.name))));
|
|
@@ -69625,11 +69652,11 @@ function loadJournal(txnDir) {
|
|
|
69625
69652
|
const declaredIndex = Number(phaseMatch[1]);
|
|
69626
69653
|
const declaredPhase = phaseMatch[2];
|
|
69627
69654
|
if (declaredIndex !== index || PHASES[index] !== declaredPhase) break;
|
|
69628
|
-
const path = (0,
|
|
69629
|
-
if ((0,
|
|
69655
|
+
const path = (0, import_node_path30.join)(txnDir, entry2.name);
|
|
69656
|
+
if ((0, import_node_fs34.statSync)(path).size > MAX_PHASE_BYTES) break;
|
|
69630
69657
|
let parsed;
|
|
69631
69658
|
try {
|
|
69632
|
-
parsed = JSON.parse((0,
|
|
69659
|
+
parsed = JSON.parse((0, import_node_fs34.readFileSync)(path, "utf8"));
|
|
69633
69660
|
} catch {
|
|
69634
69661
|
break;
|
|
69635
69662
|
}
|
|
@@ -69656,8 +69683,8 @@ function restoreIndex(journal) {
|
|
|
69656
69683
|
if (journal.priorIndex.exists) {
|
|
69657
69684
|
durableReplace2(indexPath, Buffer.from(journal.priorIndexBase64, "base64"));
|
|
69658
69685
|
} else {
|
|
69659
|
-
(0,
|
|
69660
|
-
syncDirectory2((0,
|
|
69686
|
+
(0, import_node_fs34.rmSync)(indexPath, { force: true });
|
|
69687
|
+
syncDirectory2((0, import_node_path30.dirname)(indexPath));
|
|
69661
69688
|
}
|
|
69662
69689
|
if (!sameProof(indexPath, journal.priorIndex)) {
|
|
69663
69690
|
throw new IfcPublicationError("receipt index restore did not match its recorded proof.");
|
|
@@ -69672,14 +69699,14 @@ function restoreArtifact(journal) {
|
|
|
69672
69699
|
if (!fileProofEquals(backup, journal.priorArtifact)) {
|
|
69673
69700
|
throw new IfcPublicationError("IFC backup does not match the recorded prior artifact.");
|
|
69674
69701
|
}
|
|
69675
|
-
(0,
|
|
69702
|
+
(0, import_node_fs34.rmSync)(journal.backupPath, { force: true });
|
|
69676
69703
|
}
|
|
69677
69704
|
} else if (!final.exists || fileProofEquals(final, journal.newArtifact)) {
|
|
69678
69705
|
if (!fileProofEquals(backup, journal.priorArtifact)) {
|
|
69679
69706
|
throw new IfcPublicationError("IFC prior artifact cannot be proven for rollback.");
|
|
69680
69707
|
}
|
|
69681
|
-
if (final.exists) (0,
|
|
69682
|
-
(0,
|
|
69708
|
+
if (final.exists) (0, import_node_fs34.rmSync)(journal.finalPath, { force: true });
|
|
69709
|
+
(0, import_node_fs34.renameSync)(journal.backupPath, journal.finalPath);
|
|
69683
69710
|
syncFile2(journal.finalPath);
|
|
69684
69711
|
} else {
|
|
69685
69712
|
throw new IfcPublicationError("IFC final artifact is in an unknown state; recovery retained evidence.");
|
|
@@ -69692,25 +69719,25 @@ function restoreArtifact(journal) {
|
|
|
69692
69719
|
if (!fileProofEquals(final, journal.newArtifact)) {
|
|
69693
69720
|
throw new IfcPublicationError("IFC final artifact is in an unknown state; recovery retained evidence.");
|
|
69694
69721
|
}
|
|
69695
|
-
(0,
|
|
69722
|
+
(0, import_node_fs34.rmSync)(journal.finalPath, { force: true });
|
|
69696
69723
|
}
|
|
69697
69724
|
if (backup.exists) throw new IfcPublicationError("unexpected IFC backup exists for a no-prior transaction.");
|
|
69698
69725
|
}
|
|
69699
|
-
if ((0,
|
|
69726
|
+
if ((0, import_node_fs34.existsSync)(journal.tempPath)) {
|
|
69700
69727
|
if (!sameProof(journal.tempPath, journal.newArtifact)) {
|
|
69701
69728
|
throw new IfcPublicationError("IFC temp artifact does not match its recorded proof.");
|
|
69702
69729
|
}
|
|
69703
|
-
(0,
|
|
69730
|
+
(0, import_node_fs34.rmSync)(journal.tempPath, { force: true });
|
|
69704
69731
|
}
|
|
69705
69732
|
syncDirectory2(journal.exportDir);
|
|
69706
69733
|
}
|
|
69707
69734
|
function retireTransaction(txnDir) {
|
|
69708
|
-
const match = (0,
|
|
69735
|
+
const match = (0, import_node_path30.basename)(txnDir).match(ACTIVE_RE);
|
|
69709
69736
|
if (!match) throw new IfcPublicationError("cannot retire an unsafe IFC transaction directory.");
|
|
69710
|
-
const cleanupDir = (0,
|
|
69711
|
-
if ((0,
|
|
69712
|
-
(0,
|
|
69713
|
-
syncDirectory2((0,
|
|
69737
|
+
const cleanupDir = (0, import_node_path30.join)((0, import_node_path30.dirname)(txnDir), `.floless-cleanup-ifc-${match[1]}`);
|
|
69738
|
+
if ((0, import_node_fs34.existsSync)(cleanupDir)) throw new IfcPublicationError("IFC cleanup directory already exists.");
|
|
69739
|
+
(0, import_node_fs34.renameSync)(txnDir, cleanupDir);
|
|
69740
|
+
syncDirectory2((0, import_node_path30.dirname)(txnDir));
|
|
69714
69741
|
return cleanupDir;
|
|
69715
69742
|
}
|
|
69716
69743
|
function finishCommitted(txnDir, journal, allowMissingBackup) {
|
|
@@ -69726,7 +69753,7 @@ function finishCommitted(txnDir, journal, allowMissingBackup) {
|
|
|
69726
69753
|
if (!fileProofEquals(backup, journal.priorArtifact)) {
|
|
69727
69754
|
throw new IfcPublicationError("committed IFC backup does not match the recorded prior artifact.");
|
|
69728
69755
|
}
|
|
69729
|
-
(0,
|
|
69756
|
+
(0, import_node_fs34.rmSync)(journal.backupPath, { force: true });
|
|
69730
69757
|
syncDirectory2(journal.exportDir);
|
|
69731
69758
|
} else if (!allowMissingBackup) {
|
|
69732
69759
|
throw new IfcPublicationError("committed IFC backup disappeared before verified cleanup.");
|
|
@@ -69735,18 +69762,18 @@ function finishCommitted(txnDir, journal, allowMissingBackup) {
|
|
|
69735
69762
|
throw new IfcPublicationError("unexpected committed IFC backup exists for a no-prior transaction.");
|
|
69736
69763
|
}
|
|
69737
69764
|
const cleanupDir = retireTransaction(txnDir);
|
|
69738
|
-
(0,
|
|
69765
|
+
(0, import_node_fs34.rmSync)(cleanupDir, { recursive: true, force: true });
|
|
69739
69766
|
syncDirectory2(journal.exportDir);
|
|
69740
69767
|
}
|
|
69741
69768
|
function rollbackTransaction(txnDir, journal) {
|
|
69742
69769
|
restoreArtifact(journal);
|
|
69743
69770
|
restoreIndex(journal);
|
|
69744
69771
|
const cleanupDir = retireTransaction(txnDir);
|
|
69745
|
-
(0,
|
|
69772
|
+
(0, import_node_fs34.rmSync)(cleanupDir, { recursive: true, force: true });
|
|
69746
69773
|
syncDirectory2(journal.exportDir);
|
|
69747
69774
|
}
|
|
69748
69775
|
function safeTransactionDirectory(path) {
|
|
69749
|
-
const st = (0,
|
|
69776
|
+
const st = (0, import_node_fs34.lstatSync)(path);
|
|
69750
69777
|
if (!st.isDirectory() || st.isSymbolicLink()) {
|
|
69751
69778
|
throw new IfcPublicationError(`IFC transaction path is not a plain directory: ${path}`);
|
|
69752
69779
|
}
|
|
@@ -69756,7 +69783,7 @@ async function recoverActive(txnDir, expected) {
|
|
|
69756
69783
|
const journal = loadJournal(txnDir);
|
|
69757
69784
|
if (!journal) {
|
|
69758
69785
|
const cleanupDir = retireTransaction(txnDir);
|
|
69759
|
-
(0,
|
|
69786
|
+
(0, import_node_fs34.rmSync)(cleanupDir, { recursive: true, force: true });
|
|
69760
69787
|
return;
|
|
69761
69788
|
}
|
|
69762
69789
|
if (expected && (journal.resource.kind !== expected.kind || journal.resource.key !== expected.key)) {
|
|
@@ -69769,18 +69796,18 @@ async function recoverActive(txnDir, expected) {
|
|
|
69769
69796
|
}
|
|
69770
69797
|
async function recoverIfcPublicationsInDirectory(exportDir, expected) {
|
|
69771
69798
|
const dir = canonicalPath(exportDir);
|
|
69772
|
-
if (!(0,
|
|
69799
|
+
if (!(0, import_node_fs34.existsSync)(dir)) return [];
|
|
69773
69800
|
safeTransactionDirectory(dir);
|
|
69774
|
-
const entries2 = (0,
|
|
69801
|
+
const entries2 = (0, import_node_fs34.readdirSync)(dir, { withFileTypes: true }).filter((entry2) => ACTIVE_RE.test(entry2.name) || CLEANUP_RE.test(entry2.name));
|
|
69775
69802
|
if (entries2.length > MAX_TRANSACTIONS) {
|
|
69776
69803
|
throw new IfcPublicationError(`IFC recovery refused ${entries2.length} transaction directories (limit ${MAX_TRANSACTIONS}).`);
|
|
69777
69804
|
}
|
|
69778
69805
|
const recovered = [];
|
|
69779
69806
|
for (const entry2 of entries2) {
|
|
69780
|
-
const path = (0,
|
|
69807
|
+
const path = (0, import_node_path30.join)(dir, entry2.name);
|
|
69781
69808
|
safeTransactionDirectory(path);
|
|
69782
69809
|
if (CLEANUP_RE.test(entry2.name)) {
|
|
69783
|
-
(0,
|
|
69810
|
+
(0, import_node_fs34.rmSync)(path, { recursive: true, force: true });
|
|
69784
69811
|
syncDirectory2(dir);
|
|
69785
69812
|
recovered.push(entry2.name);
|
|
69786
69813
|
continue;
|
|
@@ -69792,32 +69819,32 @@ async function recoverIfcPublicationsInDirectory(exportDir, expected) {
|
|
|
69792
69819
|
}
|
|
69793
69820
|
async function recoverAllIfcPublications() {
|
|
69794
69821
|
const recovered = [];
|
|
69795
|
-
const rootHome = process.env.FLOLESS_HOME ?? (0,
|
|
69796
|
-
const projectsRoot2 = (0,
|
|
69797
|
-
if ((0,
|
|
69822
|
+
const rootHome = process.env.FLOLESS_HOME ?? (0, import_node_path30.join)((0, import_node_os18.homedir)(), ".floless");
|
|
69823
|
+
const projectsRoot2 = (0, import_node_path30.join)(rootHome, "projects");
|
|
69824
|
+
if ((0, import_node_fs34.existsSync)(projectsRoot2)) {
|
|
69798
69825
|
safeTransactionDirectory(projectsRoot2);
|
|
69799
|
-
for (const entry2 of (0,
|
|
69826
|
+
for (const entry2 of (0, import_node_fs34.readdirSync)(projectsRoot2, { withFileTypes: true })) {
|
|
69800
69827
|
if (entry2.name.startsWith(".")) continue;
|
|
69801
69828
|
if (entry2.isSymbolicLink()) throw new IfcPublicationError(`project recovery root is a link: ${entry2.name}`);
|
|
69802
69829
|
if (!entry2.isDirectory() || !/^[a-z0-9][a-z0-9-]*$/.test(entry2.name)) continue;
|
|
69803
|
-
const projectPath = (0,
|
|
69830
|
+
const projectPath = (0, import_node_path30.join)(projectsRoot2, entry2.name);
|
|
69804
69831
|
safeTransactionDirectory(projectPath);
|
|
69805
69832
|
const dir = projectExportsDir(entry2.name);
|
|
69806
69833
|
const names = await recoverIfcPublicationsInDirectory(dir, { kind: "project", key: entry2.name });
|
|
69807
69834
|
recovered.push(...names.map((name) => `${entry2.name}/${name}`));
|
|
69808
69835
|
}
|
|
69809
69836
|
}
|
|
69810
|
-
const
|
|
69811
|
-
if ((0,
|
|
69812
|
-
safeTransactionDirectory(
|
|
69813
|
-
for (const entry2 of (0,
|
|
69837
|
+
const root4 = (0, import_node_path30.join)(rootHome, "exports");
|
|
69838
|
+
if ((0, import_node_fs34.existsSync)(root4)) {
|
|
69839
|
+
safeTransactionDirectory(root4);
|
|
69840
|
+
for (const entry2 of (0, import_node_fs34.readdirSync)(root4, { withFileTypes: true })) {
|
|
69814
69841
|
if (entry2.name.startsWith(".")) continue;
|
|
69815
69842
|
if (entry2.isSymbolicLink()) throw new IfcPublicationError(`workflow recovery root is a link: ${entry2.name}`);
|
|
69816
69843
|
if (!entry2.isDirectory()) continue;
|
|
69817
69844
|
if (!/^[A-Za-z0-9._-]+$/.test(entry2.name)) continue;
|
|
69818
|
-
safeTransactionDirectory((0,
|
|
69845
|
+
safeTransactionDirectory((0, import_node_path30.join)(root4, entry2.name));
|
|
69819
69846
|
const names = await recoverIfcPublicationsInDirectory(
|
|
69820
|
-
(0,
|
|
69847
|
+
(0, import_node_path30.join)(root4, entry2.name),
|
|
69821
69848
|
{ kind: "app", key: entry2.name }
|
|
69822
69849
|
);
|
|
69823
69850
|
recovered.push(...names.map((name) => `${entry2.name}/${name}`));
|
|
@@ -69827,8 +69854,8 @@ async function recoverAllIfcPublications() {
|
|
|
69827
69854
|
}
|
|
69828
69855
|
function assertReceiptOptions(receipt, resource, exportDir, finalPath, artifact) {
|
|
69829
69856
|
const transition = receipt.transition;
|
|
69830
|
-
if (resource.kind !== "project" || transition.projectId !== resource.key || transition.next.kind !== "ifc" || transition.next.filename !== (0,
|
|
69831
|
-
if ((0,
|
|
69857
|
+
if (resource.kind !== "project" || transition.projectId !== resource.key || transition.next.kind !== "ifc" || transition.next.filename !== (0, import_node_path30.basename)(finalPath) || transition.next.bytes !== artifact.bytes || canonicalPath(transition.indexPath) !== canonicalPath(projectExportIndexPath(transition.projectId))) throw new IfcPublicationError("project receipt transition does not match the IFC publication target.");
|
|
69858
|
+
if ((0, import_node_path30.dirname)(canonicalPath(transition.indexPath)) !== exportDir || (0, import_node_path30.basename)(transition.indexPath) !== "index.json") throw new IfcPublicationError("project receipt index is outside the IFC export directory.");
|
|
69832
69859
|
const beforeSnapshot = transition.beforeBytesBase64 === null ? null : Buffer.from(transition.beforeBytesBase64, "base64");
|
|
69833
69860
|
if (beforeSnapshot && beforeSnapshot.length > MAX_INDEX_SNAPSHOT_BYTES || transition.before.exists !== (beforeSnapshot !== null) || beforeSnapshot !== null && !fileProofEquals(proof2(beforeSnapshot), transition.before) || !fileProofEquals(proof2(Buffer.from(transition.afterBytesBase64, "base64")), transition.after)) throw new IfcPublicationError("project receipt transition proofs are inconsistent.");
|
|
69834
69861
|
if (!fileProofEquals(readFileProof(transition.indexPath), transition.before)) {
|
|
@@ -69841,7 +69868,7 @@ function promiseLike(value) {
|
|
|
69841
69868
|
async function publishIfcAtomically(tempPath, finalPath, options) {
|
|
69842
69869
|
if (!options || !validResource(options.resource)) throw new IfcPublicationError("IFC publication resource is invalid.");
|
|
69843
69870
|
const paths = validateRequestPaths(tempPath, finalPath);
|
|
69844
|
-
const tempStat = (0,
|
|
69871
|
+
const tempStat = (0, import_node_fs34.lstatSync)(paths.temp);
|
|
69845
69872
|
if (!tempStat.isFile()) throw new IfcPublicationError("the IFC to publish is not a regular file.");
|
|
69846
69873
|
const validated = validateIfc(paths.temp);
|
|
69847
69874
|
if (options.expectedContentSha256 !== void 0 && validated.proof.sha256 !== options.expectedContentSha256) {
|
|
@@ -69854,8 +69881,8 @@ async function publishIfcAtomically(tempPath, finalPath, options) {
|
|
|
69854
69881
|
return withLifecycleLock(options.resource.kind, options.resource.key, async () => {
|
|
69855
69882
|
await recoverIfcPublicationsInDirectory(paths.dir, options.resource);
|
|
69856
69883
|
const txnId = (0, import_node_crypto17.randomUUID)();
|
|
69857
|
-
const txnDir = (0,
|
|
69858
|
-
const backupPath = (0,
|
|
69884
|
+
const txnDir = (0, import_node_path30.join)(paths.dir, `.floless-txn-ifc-${txnId}`);
|
|
69885
|
+
const backupPath = (0, import_node_path30.join)(paths.dir, `.floless-backup-ifc-${txnId}.ifc`);
|
|
69859
69886
|
const priorArtifact = readFileProof(paths.final);
|
|
69860
69887
|
const transition = options.receipt?.transition;
|
|
69861
69888
|
const base = {
|
|
@@ -69879,7 +69906,7 @@ async function publishIfcAtomically(tempPath, finalPath, options) {
|
|
|
69879
69906
|
};
|
|
69880
69907
|
let journal = { ...base, phase: "prepared" };
|
|
69881
69908
|
let committed = false;
|
|
69882
|
-
(0,
|
|
69909
|
+
(0, import_node_fs34.mkdirSync)(txnDir);
|
|
69883
69910
|
syncDirectory2(paths.dir);
|
|
69884
69911
|
const hit = (point) => {
|
|
69885
69912
|
options.fault?.(point);
|
|
@@ -69895,11 +69922,11 @@ async function publishIfcAtomically(tempPath, finalPath, options) {
|
|
|
69895
69922
|
phase("prepared");
|
|
69896
69923
|
phase("backing-up");
|
|
69897
69924
|
if (priorArtifact.exists) {
|
|
69898
|
-
(0,
|
|
69925
|
+
(0, import_node_fs34.renameSync)(paths.final, backupPath);
|
|
69899
69926
|
syncDirectory2(paths.dir);
|
|
69900
69927
|
}
|
|
69901
69928
|
phase("promoting");
|
|
69902
|
-
(0,
|
|
69929
|
+
(0, import_node_fs34.renameSync)(paths.temp, paths.final);
|
|
69903
69930
|
syncFile2(paths.final);
|
|
69904
69931
|
syncDirectory2(paths.dir);
|
|
69905
69932
|
if (!sameProof(paths.final, validated.proof)) {
|
|
@@ -69928,7 +69955,7 @@ async function publishIfcAtomically(tempPath, finalPath, options) {
|
|
|
69928
69955
|
if (!fileProofEquals(backup, priorArtifact)) {
|
|
69929
69956
|
throw new IfcPublicationError("IFC backup did not match the recorded prior artifact before cleanup.");
|
|
69930
69957
|
}
|
|
69931
|
-
(0,
|
|
69958
|
+
(0, import_node_fs34.rmSync)(backupPath, { force: true });
|
|
69932
69959
|
syncDirectory2(paths.dir);
|
|
69933
69960
|
} else if (backup.exists) {
|
|
69934
69961
|
throw new IfcPublicationError("unexpected IFC backup exists for a no-prior transaction.");
|
|
@@ -69938,7 +69965,7 @@ async function publishIfcAtomically(tempPath, finalPath, options) {
|
|
|
69938
69965
|
const cleanupDir = retireTransaction(txnDir);
|
|
69939
69966
|
hit("after-retire");
|
|
69940
69967
|
hit("before-cleanup-remove");
|
|
69941
|
-
(0,
|
|
69968
|
+
(0, import_node_fs34.rmSync)(cleanupDir, { recursive: true, force: true });
|
|
69942
69969
|
syncDirectory2(paths.dir);
|
|
69943
69970
|
return { bytes: validated.bytes, cleanupPending: false };
|
|
69944
69971
|
} catch (error) {
|
|
@@ -69981,14 +70008,14 @@ async function publishIfcAtomically(tempPath, finalPath, options) {
|
|
|
69981
70008
|
});
|
|
69982
70009
|
}
|
|
69983
70010
|
function cleanupIfcTemp(path) {
|
|
69984
|
-
if (!TEMP_RE.test((0,
|
|
70011
|
+
if (!TEMP_RE.test((0, import_node_path30.basename)(path))) return;
|
|
69985
70012
|
const canonical = canonicalPath(path);
|
|
69986
|
-
const dir = (0,
|
|
69987
|
-
if ((0,
|
|
69988
|
-
for (const entry2 of (0,
|
|
70013
|
+
const dir = (0, import_node_path30.dirname)(canonical);
|
|
70014
|
+
if ((0, import_node_fs34.existsSync)(dir)) {
|
|
70015
|
+
for (const entry2 of (0, import_node_fs34.readdirSync)(dir, { withFileTypes: true })) {
|
|
69989
70016
|
if (!entry2.isDirectory() || !ACTIVE_RE.test(entry2.name)) continue;
|
|
69990
70017
|
try {
|
|
69991
|
-
const journal = loadJournal((0,
|
|
70018
|
+
const journal = loadJournal((0, import_node_path30.join)(dir, entry2.name));
|
|
69992
70019
|
if (!journal || journal.tempPath === canonical) return;
|
|
69993
70020
|
} catch {
|
|
69994
70021
|
return;
|
|
@@ -69996,15 +70023,15 @@ function cleanupIfcTemp(path) {
|
|
|
69996
70023
|
}
|
|
69997
70024
|
}
|
|
69998
70025
|
try {
|
|
69999
|
-
(0,
|
|
70026
|
+
(0, import_node_fs34.rmSync)(path, { force: true });
|
|
70000
70027
|
} catch {
|
|
70001
70028
|
}
|
|
70002
70029
|
}
|
|
70003
70030
|
|
|
70004
70031
|
// export-companion.ts
|
|
70005
70032
|
var import_node_crypto18 = require("node:crypto");
|
|
70006
|
-
var
|
|
70007
|
-
var
|
|
70033
|
+
var import_node_fs35 = require("node:fs");
|
|
70034
|
+
var import_node_path31 = require("node:path");
|
|
70008
70035
|
var PREFIX = "floless-export-tmp-";
|
|
70009
70036
|
var LEASE = ".floless-export-lease.json";
|
|
70010
70037
|
var STALE_MS2 = 30 * 6e4;
|
|
@@ -70018,70 +70045,70 @@ function processAlive2(pid) {
|
|
|
70018
70045
|
}
|
|
70019
70046
|
}
|
|
70020
70047
|
function defaultAppsRoot() {
|
|
70021
|
-
return (0,
|
|
70048
|
+
return (0, import_node_path31.dirname)(appPath("placeholder"));
|
|
70022
70049
|
}
|
|
70023
70050
|
function assertScratchPath(path, appsRoot) {
|
|
70024
|
-
const
|
|
70025
|
-
const target = (0,
|
|
70026
|
-
if ((0,
|
|
70051
|
+
const root4 = (0, import_node_path31.resolve)(appsRoot);
|
|
70052
|
+
const target = (0, import_node_path31.resolve)(path);
|
|
70053
|
+
if ((0, import_node_path31.dirname)(target) !== root4 || !(0, import_node_path31.basename)(target).startsWith(PREFIX)) {
|
|
70027
70054
|
throw new Error(`refusing to remove a non-export companion path: ${target}`);
|
|
70028
70055
|
}
|
|
70029
70056
|
}
|
|
70030
70057
|
function removeScratch(path, appsRoot) {
|
|
70031
70058
|
assertScratchPath(path, appsRoot);
|
|
70032
|
-
(0,
|
|
70059
|
+
(0, import_node_fs35.rmSync)(path, { recursive: true, force: true });
|
|
70033
70060
|
}
|
|
70034
70061
|
function createExportCompanion(ownerId, sink, appsRoot = defaultAppsRoot()) {
|
|
70035
70062
|
const safeOwner = ownerId.replace(/[^a-z0-9._-]/gi, "-").slice(0, 80) || "app";
|
|
70036
70063
|
const token = (0, import_node_crypto18.randomUUID)();
|
|
70037
70064
|
const id = `${PREFIX}${safeOwner}-${sink}-${token}`;
|
|
70038
|
-
const
|
|
70039
|
-
const path = (0,
|
|
70065
|
+
const root4 = (0, import_node_path31.resolve)(appsRoot);
|
|
70066
|
+
const path = (0, import_node_path31.resolve)(root4, id);
|
|
70040
70067
|
const lease = { pid: process.pid, token, createdAt: (/* @__PURE__ */ new Date()).toISOString() };
|
|
70041
70068
|
return {
|
|
70042
70069
|
id,
|
|
70043
70070
|
path,
|
|
70044
70071
|
token,
|
|
70045
70072
|
cleanup: () => {
|
|
70046
|
-
if (!(0,
|
|
70073
|
+
if (!(0, import_node_fs35.existsSync)(path)) return;
|
|
70047
70074
|
let current = null;
|
|
70048
70075
|
try {
|
|
70049
|
-
current = JSON.parse((0,
|
|
70076
|
+
current = JSON.parse((0, import_node_fs35.readFileSync)((0, import_node_path31.resolve)(path, LEASE), "utf8"));
|
|
70050
70077
|
} catch {
|
|
70051
70078
|
}
|
|
70052
70079
|
if (current && current.token !== token) throw new Error(`export companion lease changed for ${id}`);
|
|
70053
|
-
removeScratch(path,
|
|
70080
|
+
removeScratch(path, root4);
|
|
70054
70081
|
}
|
|
70055
70082
|
};
|
|
70056
70083
|
}
|
|
70057
70084
|
function stampExportCompanionLease(companion) {
|
|
70058
|
-
(0,
|
|
70085
|
+
(0, import_node_fs35.writeFileSync)((0, import_node_path31.resolve)(companion.path, LEASE), JSON.stringify({
|
|
70059
70086
|
pid: process.pid,
|
|
70060
70087
|
token: companion.token,
|
|
70061
70088
|
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
70062
70089
|
}));
|
|
70063
70090
|
}
|
|
70064
70091
|
function sweepStaleExportCompanions(now = Date.now(), appsRoot = defaultAppsRoot()) {
|
|
70065
|
-
const
|
|
70066
|
-
if (!(0,
|
|
70092
|
+
const root4 = (0, import_node_path31.resolve)(appsRoot);
|
|
70093
|
+
if (!(0, import_node_fs35.existsSync)(root4)) return [];
|
|
70067
70094
|
const removed = [];
|
|
70068
|
-
for (const entry2 of (0,
|
|
70095
|
+
for (const entry2 of (0, import_node_fs35.readdirSync)(root4, { withFileTypes: true })) {
|
|
70069
70096
|
if (!entry2.isDirectory() || !entry2.name.startsWith(PREFIX)) continue;
|
|
70070
|
-
const path = (0,
|
|
70097
|
+
const path = (0, import_node_path31.resolve)(root4, entry2.name);
|
|
70071
70098
|
let lease = null;
|
|
70072
70099
|
try {
|
|
70073
|
-
lease = JSON.parse((0,
|
|
70100
|
+
lease = JSON.parse((0, import_node_fs35.readFileSync)((0, import_node_path31.resolve)(path, LEASE), "utf8"));
|
|
70074
70101
|
} catch {
|
|
70075
70102
|
}
|
|
70076
70103
|
let created;
|
|
70077
70104
|
try {
|
|
70078
|
-
created = lease ? Date.parse(lease.createdAt) : (0,
|
|
70105
|
+
created = lease ? Date.parse(lease.createdAt) : (0, import_node_fs35.statSync)(path).mtimeMs;
|
|
70079
70106
|
} catch {
|
|
70080
70107
|
continue;
|
|
70081
70108
|
}
|
|
70082
70109
|
if (Number.isFinite(created) && now - created < STALE_MS2) continue;
|
|
70083
70110
|
if (lease && processAlive2(lease.pid)) continue;
|
|
70084
|
-
removeScratch(path,
|
|
70111
|
+
removeScratch(path, root4);
|
|
70085
70112
|
removed.push(entry2.name);
|
|
70086
70113
|
}
|
|
70087
70114
|
return removed;
|
|
@@ -70188,14 +70215,14 @@ async function teklaReadiness(deps = DEFAULT_DEPS) {
|
|
|
70188
70215
|
}
|
|
70189
70216
|
|
|
70190
70217
|
// render-readiness.ts
|
|
70191
|
-
var
|
|
70192
|
-
var
|
|
70193
|
-
var
|
|
70218
|
+
var import_node_fs36 = require("node:fs");
|
|
70219
|
+
var import_node_path32 = require("node:path");
|
|
70220
|
+
var import_node_os19 = require("node:os");
|
|
70194
70221
|
var RENDER_AWARE_FLOOR = "0.103.0";
|
|
70195
70222
|
var RENDER_AGENT_ID = "blender";
|
|
70196
70223
|
function isFile(path) {
|
|
70197
70224
|
try {
|
|
70198
|
-
return (0,
|
|
70225
|
+
return (0, import_node_fs36.existsSync)(path) && (0, import_node_fs36.statSync)(path).isFile();
|
|
70199
70226
|
} catch {
|
|
70200
70227
|
return false;
|
|
70201
70228
|
}
|
|
@@ -70203,9 +70230,9 @@ function isFile(path) {
|
|
|
70203
70230
|
function lookupOnPath(command, env2) {
|
|
70204
70231
|
const path = env2.PATH ?? env2.Path;
|
|
70205
70232
|
if (!path) return null;
|
|
70206
|
-
for (const dir of path.split(
|
|
70233
|
+
for (const dir of path.split(import_node_path32.delimiter)) {
|
|
70207
70234
|
if (!dir) continue;
|
|
70208
|
-
const candidate = (0,
|
|
70235
|
+
const candidate = (0, import_node_path32.join)(dir, command);
|
|
70209
70236
|
if (isFile(candidate)) return candidate;
|
|
70210
70237
|
}
|
|
70211
70238
|
return null;
|
|
@@ -70222,21 +70249,21 @@ function windowsCandidates(env2) {
|
|
|
70222
70249
|
for (const variable of ["ProgramFiles", "ProgramW6432", "ProgramFiles(x86)"]) {
|
|
70223
70250
|
const value = env2[variable];
|
|
70224
70251
|
if (!value) continue;
|
|
70225
|
-
const
|
|
70226
|
-
if (!roots.includes(
|
|
70252
|
+
const root4 = (0, import_node_path32.join)(value, "Blender Foundation");
|
|
70253
|
+
if (!roots.includes(root4)) roots.push(root4);
|
|
70227
70254
|
}
|
|
70228
70255
|
const found = [];
|
|
70229
|
-
for (const
|
|
70256
|
+
for (const root4 of roots) {
|
|
70230
70257
|
let entries2;
|
|
70231
70258
|
try {
|
|
70232
|
-
entries2 = (0,
|
|
70259
|
+
entries2 = (0, import_node_fs36.readdirSync)(root4);
|
|
70233
70260
|
} catch {
|
|
70234
70261
|
continue;
|
|
70235
70262
|
}
|
|
70236
70263
|
for (const name of entries2) {
|
|
70237
70264
|
const match = /^Blender\s+(\d+(?:\.\d+)*)$/i.exec(name);
|
|
70238
70265
|
if (!match) continue;
|
|
70239
|
-
const binary = (0,
|
|
70266
|
+
const binary = (0, import_node_path32.join)(root4, name, "blender.exe");
|
|
70240
70267
|
if (isFile(binary)) {
|
|
70241
70268
|
found.push({ version: match[1].split(".").map(Number), name, binary });
|
|
70242
70269
|
}
|
|
@@ -70250,7 +70277,7 @@ function platformDefaults(env2, isWin3) {
|
|
|
70250
70277
|
if (process.platform === "darwin") {
|
|
70251
70278
|
return [
|
|
70252
70279
|
"/Applications/Blender.app/Contents/MacOS/Blender",
|
|
70253
|
-
(0,
|
|
70280
|
+
(0, import_node_path32.join)((0, import_node_os19.homedir)(), "Applications/Blender.app/Contents/MacOS/Blender")
|
|
70254
70281
|
];
|
|
70255
70282
|
}
|
|
70256
70283
|
return ["/usr/bin/blender", "/usr/local/bin/blender", "/snap/bin/blender"];
|
|
@@ -70370,20 +70397,20 @@ async function bakeDownstream(sourcePath, appId, contract) {
|
|
|
70370
70397
|
}
|
|
70371
70398
|
|
|
70372
70399
|
// app-lifecycle.ts
|
|
70400
|
+
var import_node_fs39 = require("node:fs");
|
|
70401
|
+
var import_node_os21 = require("node:os");
|
|
70402
|
+
var import_node_path35 = require("node:path");
|
|
70403
|
+
|
|
70404
|
+
// routines.ts
|
|
70373
70405
|
var import_node_fs38 = require("node:fs");
|
|
70374
|
-
var import_node_os20 = require("node:os");
|
|
70375
70406
|
var import_node_path34 = require("node:path");
|
|
70376
70407
|
|
|
70377
|
-
//
|
|
70408
|
+
// trigger-sessions.ts
|
|
70378
70409
|
var import_node_fs37 = require("node:fs");
|
|
70410
|
+
var import_node_os20 = require("node:os");
|
|
70379
70411
|
var import_node_path33 = require("node:path");
|
|
70380
|
-
|
|
70381
|
-
// trigger-sessions.ts
|
|
70382
|
-
var import_node_fs36 = require("node:fs");
|
|
70383
|
-
var import_node_os19 = require("node:os");
|
|
70384
|
-
var import_node_path32 = require("node:path");
|
|
70385
70412
|
var import_yaml9 = __toESM(require_dist6(), 1);
|
|
70386
|
-
var AGENTS_DIR2 = process.env.AWARE_HOME ? (0,
|
|
70413
|
+
var AGENTS_DIR2 = process.env.AWARE_HOME ? (0, import_node_path33.join)(process.env.AWARE_HOME, "agents") : (0, import_node_path33.join)((0, import_node_os20.homedir)(), ".aware", "agents");
|
|
70387
70414
|
function summarizeFire(data) {
|
|
70388
70415
|
if (!data) return "event";
|
|
70389
70416
|
const type = typeof data.type === "string" ? data.type : "";
|
|
@@ -70400,10 +70427,10 @@ function mapTriggerState(phase) {
|
|
|
70400
70427
|
function isHostBacked(agent, agentsDir = AGENTS_DIR2) {
|
|
70401
70428
|
const safe2 = (n) => !n.includes("/") && !n.includes("\\") && !n.includes("..");
|
|
70402
70429
|
if (!safe2(agent)) return false;
|
|
70403
|
-
const manifestPath2 = (0,
|
|
70404
|
-
if (!(0,
|
|
70430
|
+
const manifestPath2 = (0, import_node_path33.join)(agentsDir, agent, "manifest.yaml");
|
|
70431
|
+
if (!(0, import_node_fs37.existsSync)(manifestPath2)) return false;
|
|
70405
70432
|
try {
|
|
70406
|
-
const doc = (0, import_yaml9.parse)((0,
|
|
70433
|
+
const doc = (0, import_yaml9.parse)((0, import_node_fs37.readFileSync)(manifestPath2, "utf8"));
|
|
70407
70434
|
const transport = doc?.transport;
|
|
70408
70435
|
return !!(transport && typeof transport === "object" && "cli" in transport);
|
|
70409
70436
|
} catch {
|
|
@@ -70688,7 +70715,7 @@ var RoutineError = class extends Error {
|
|
|
70688
70715
|
}
|
|
70689
70716
|
status;
|
|
70690
70717
|
};
|
|
70691
|
-
var ROUTINES_FILE = (0,
|
|
70718
|
+
var ROUTINES_FILE = (0, import_node_path34.join)(flolessRoot, "routines.json");
|
|
70692
70719
|
var routines = [];
|
|
70693
70720
|
var loaded = false;
|
|
70694
70721
|
function ensureLoaded() {
|
|
@@ -70724,10 +70751,10 @@ function sanitizeRoutine(raw) {
|
|
|
70724
70751
|
};
|
|
70725
70752
|
}
|
|
70726
70753
|
function loadFromDisk() {
|
|
70727
|
-
if (!(0,
|
|
70754
|
+
if (!(0, import_node_fs38.existsSync)(ROUTINES_FILE)) return [];
|
|
70728
70755
|
let text3;
|
|
70729
70756
|
try {
|
|
70730
|
-
text3 = (0,
|
|
70757
|
+
text3 = (0, import_node_fs38.readFileSync)(ROUTINES_FILE, "utf8");
|
|
70731
70758
|
} catch {
|
|
70732
70759
|
return [];
|
|
70733
70760
|
}
|
|
@@ -70736,17 +70763,17 @@ function loadFromDisk() {
|
|
|
70736
70763
|
return Array.isArray(parsed) ? parsed.map(sanitizeRoutine).filter((r) => r !== null) : [];
|
|
70737
70764
|
} catch {
|
|
70738
70765
|
try {
|
|
70739
|
-
(0,
|
|
70766
|
+
(0, import_node_fs38.renameSync)(ROUTINES_FILE, `${ROUTINES_FILE}.corrupt-${Date.now()}`);
|
|
70740
70767
|
} catch {
|
|
70741
70768
|
}
|
|
70742
70769
|
return [];
|
|
70743
70770
|
}
|
|
70744
70771
|
}
|
|
70745
70772
|
function saveRoutines() {
|
|
70746
|
-
if (!(0,
|
|
70773
|
+
if (!(0, import_node_fs38.existsSync)(flolessRoot)) (0, import_node_fs38.mkdirSync)(flolessRoot, { recursive: true });
|
|
70747
70774
|
const tmp = `${ROUTINES_FILE}.${process.pid}.tmp`;
|
|
70748
|
-
(0,
|
|
70749
|
-
(0,
|
|
70775
|
+
(0, import_node_fs38.writeFileSync)(tmp, JSON.stringify(routines, null, 2));
|
|
70776
|
+
(0, import_node_fs38.renameSync)(tmp, ROUTINES_FILE);
|
|
70750
70777
|
}
|
|
70751
70778
|
function listRoutines() {
|
|
70752
70779
|
ensureLoaded();
|
|
@@ -71154,13 +71181,13 @@ var AppLifecycleError = class extends Error {
|
|
|
71154
71181
|
}
|
|
71155
71182
|
};
|
|
71156
71183
|
function appsDir() {
|
|
71157
|
-
return process.env.AWARE_HOME ? (0,
|
|
71184
|
+
return process.env.AWARE_HOME ? (0, import_node_path35.join)(process.env.AWARE_HOME, "apps") : (0, import_node_path35.join)((0, import_node_os21.homedir)(), ".aware", "apps");
|
|
71158
71185
|
}
|
|
71159
71186
|
function appDirPath(id) {
|
|
71160
|
-
return (0,
|
|
71187
|
+
return (0, import_node_path35.join)(appsDir(), id);
|
|
71161
71188
|
}
|
|
71162
71189
|
function appInstalled(id) {
|
|
71163
|
-
return APP_ID3.test(id) && (0,
|
|
71190
|
+
return APP_ID3.test(id) && (0, import_node_fs39.existsSync)(appDirPath(id));
|
|
71164
71191
|
}
|
|
71165
71192
|
function logCascade(what, e) {
|
|
71166
71193
|
console.error(`[app-lifecycle] cascade step failed (${what}):`, e instanceof Error ? e.message : e);
|
|
@@ -71339,9 +71366,9 @@ function isGatedAwareRoute(url, method) {
|
|
|
71339
71366
|
|
|
71340
71367
|
// autostart.mjs
|
|
71341
71368
|
var import_node_child_process6 = require("node:child_process");
|
|
71342
|
-
var
|
|
71343
|
-
var
|
|
71344
|
-
var
|
|
71369
|
+
var import_node_fs40 = require("node:fs");
|
|
71370
|
+
var import_node_os22 = require("node:os");
|
|
71371
|
+
var import_node_path36 = require("node:path");
|
|
71345
71372
|
|
|
71346
71373
|
// teardown.mjs
|
|
71347
71374
|
var RUN_KEY = "HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Run";
|
|
@@ -71453,8 +71480,8 @@ function removeLegacyRunKey() {
|
|
|
71453
71480
|
}
|
|
71454
71481
|
function logLine(msg) {
|
|
71455
71482
|
try {
|
|
71456
|
-
(0,
|
|
71457
|
-
(0,
|
|
71483
|
+
(0, import_node_fs40.mkdirSync)(logDir(), { recursive: true });
|
|
71484
|
+
(0, import_node_fs40.appendFileSync)(logFilePath(), `${(/* @__PURE__ */ new Date()).toISOString()} ${msg}
|
|
71458
71485
|
`);
|
|
71459
71486
|
} catch {
|
|
71460
71487
|
}
|
|
@@ -71462,8 +71489,8 @@ function logLine(msg) {
|
|
|
71462
71489
|
function registerAutostart(exePath) {
|
|
71463
71490
|
if (!isWin) return;
|
|
71464
71491
|
const xml = buildAutostartTaskXml(exePath, currentUserId());
|
|
71465
|
-
const tmp = (0,
|
|
71466
|
-
(0,
|
|
71492
|
+
const tmp = (0, import_node_path36.join)((0, import_node_os22.tmpdir)(), `floless-autostart-${process.pid}-${Date.now()}.xml`);
|
|
71493
|
+
(0, import_node_fs40.writeFileSync)(tmp, "\uFEFF" + xml, { encoding: "utf16le" });
|
|
71467
71494
|
try {
|
|
71468
71495
|
(0, import_node_child_process6.execFileSync)("schtasks", ["/Create", "/TN", TASK_NAME, "/XML", tmp, "/F"], {
|
|
71469
71496
|
stdio: ["ignore", "ignore", "ignore"],
|
|
@@ -71474,7 +71501,7 @@ function registerAutostart(exePath) {
|
|
|
71474
71501
|
throw err2;
|
|
71475
71502
|
} finally {
|
|
71476
71503
|
try {
|
|
71477
|
-
(0,
|
|
71504
|
+
(0, import_node_fs40.rmSync)(tmp, { force: true });
|
|
71478
71505
|
} catch {
|
|
71479
71506
|
}
|
|
71480
71507
|
}
|
|
@@ -71509,26 +71536,26 @@ function unregisterAutostart() {
|
|
|
71509
71536
|
// updater.ts
|
|
71510
71537
|
var import_node_child_process7 = require("node:child_process");
|
|
71511
71538
|
var import_node_crypto19 = require("node:crypto");
|
|
71512
|
-
var
|
|
71539
|
+
var import_node_fs42 = require("node:fs");
|
|
71513
71540
|
var import_node_stream3 = require("node:stream");
|
|
71514
71541
|
var import_promises3 = require("node:stream/promises");
|
|
71515
|
-
var
|
|
71542
|
+
var import_node_path38 = require("node:path");
|
|
71516
71543
|
|
|
71517
71544
|
// post-update-marker.mjs
|
|
71518
|
-
var
|
|
71519
|
-
var
|
|
71520
|
-
var
|
|
71545
|
+
var import_node_fs41 = require("node:fs");
|
|
71546
|
+
var import_node_os23 = require("node:os");
|
|
71547
|
+
var import_node_path37 = require("node:path");
|
|
71521
71548
|
var FRESH_MS = 12e4;
|
|
71522
71549
|
function markerPath() {
|
|
71523
71550
|
const override = (process.env.FLOLESS_POST_UPDATE_MARKER ?? "").trim();
|
|
71524
71551
|
if (override) return override;
|
|
71525
|
-
const
|
|
71526
|
-
return (0,
|
|
71552
|
+
const root4 = process.env.FLOLESS_HOME ?? (0, import_node_path37.join)((0, import_node_os23.homedir)(), ".floless");
|
|
71553
|
+
return (0, import_node_path37.join)(root4, ".post-update");
|
|
71527
71554
|
}
|
|
71528
71555
|
function legacyMarkerPath() {
|
|
71529
71556
|
if ((process.env.FLOLESS_POST_UPDATE_MARKER ?? "").trim()) return null;
|
|
71530
71557
|
try {
|
|
71531
|
-
return (0,
|
|
71558
|
+
return (0, import_node_path37.join)((0, import_node_path37.dirname)((0, import_node_path37.dirname)(process.execPath)), ".floless-post-update");
|
|
71532
71559
|
} catch {
|
|
71533
71560
|
return null;
|
|
71534
71561
|
}
|
|
@@ -71538,7 +71565,7 @@ function writePostUpdateMarker() {
|
|
|
71538
71565
|
for (const p of [markerPath(), legacyMarkerPath()]) {
|
|
71539
71566
|
if (!p) continue;
|
|
71540
71567
|
try {
|
|
71541
|
-
(0,
|
|
71568
|
+
(0, import_node_fs41.writeFileSync)(p, (/* @__PURE__ */ new Date()).toISOString());
|
|
71542
71569
|
wrote = true;
|
|
71543
71570
|
} catch {
|
|
71544
71571
|
}
|
|
@@ -71550,9 +71577,9 @@ function consumePostUpdateMarker() {
|
|
|
71550
71577
|
for (const p of [markerPath(), legacyMarkerPath()]) {
|
|
71551
71578
|
if (!p) continue;
|
|
71552
71579
|
try {
|
|
71553
|
-
if (!(0,
|
|
71554
|
-
const ageMs = Date.now() - (0,
|
|
71555
|
-
(0,
|
|
71580
|
+
if (!(0, import_node_fs41.existsSync)(p)) continue;
|
|
71581
|
+
const ageMs = Date.now() - (0, import_node_fs41.statSync)(p).mtimeMs;
|
|
71582
|
+
(0, import_node_fs41.rmSync)(p, { force: true });
|
|
71556
71583
|
if (ageMs < FRESH_MS) fresh = true;
|
|
71557
71584
|
} catch {
|
|
71558
71585
|
}
|
|
@@ -71569,13 +71596,13 @@ function currentVersion() {
|
|
|
71569
71596
|
return appVersion();
|
|
71570
71597
|
}
|
|
71571
71598
|
function installRoot() {
|
|
71572
|
-
return (0,
|
|
71599
|
+
return (0, import_node_path38.dirname)((0, import_node_path38.dirname)(process.execPath));
|
|
71573
71600
|
}
|
|
71574
71601
|
function updateExePath() {
|
|
71575
|
-
return (0,
|
|
71602
|
+
return (0, import_node_path38.join)(installRoot(), "Update.exe");
|
|
71576
71603
|
}
|
|
71577
71604
|
function packagesDir() {
|
|
71578
|
-
return (0,
|
|
71605
|
+
return (0, import_node_path38.join)(installRoot(), "packages");
|
|
71579
71606
|
}
|
|
71580
71607
|
function feedUrl() {
|
|
71581
71608
|
const env2 = (process.env.FLOLESS_UPDATE_URL ?? "").trim().replace(/\/+$/, "");
|
|
@@ -71668,22 +71695,22 @@ async function checkForUpdate() {
|
|
|
71668
71695
|
}
|
|
71669
71696
|
async function sha1OfFile(path) {
|
|
71670
71697
|
const hash2 = (0, import_node_crypto19.createHash)("sha1");
|
|
71671
|
-
await (0, import_promises3.pipeline)((0,
|
|
71698
|
+
await (0, import_promises3.pipeline)((0, import_node_fs42.createReadStream)(path), hash2);
|
|
71672
71699
|
return hash2.digest("hex").toUpperCase();
|
|
71673
71700
|
}
|
|
71674
71701
|
async function downloadPackage(asset) {
|
|
71675
71702
|
if (!NUPKG_NAME.test(asset.FileName)) throw new Error(`refusing suspicious package name: ${asset.FileName}`);
|
|
71676
71703
|
const want = asset.SHA1.toUpperCase();
|
|
71677
71704
|
const dir = packagesDir();
|
|
71678
|
-
(0,
|
|
71679
|
-
const dest = (0,
|
|
71680
|
-
if ((0,
|
|
71705
|
+
(0, import_node_fs42.mkdirSync)(dir, { recursive: true });
|
|
71706
|
+
const dest = (0, import_node_path38.join)(dir, asset.FileName);
|
|
71707
|
+
if ((0, import_node_fs42.existsSync)(dest) && await sha1OfFile(dest) === want) return dest;
|
|
71681
71708
|
const res = await authedFetch(`${feedUrl()}/${encodeURIComponent(asset.FileName)}`, {
|
|
71682
71709
|
redirect: "follow",
|
|
71683
71710
|
signal: AbortSignal.timeout(DOWNLOAD_TIMEOUT_MS)
|
|
71684
71711
|
});
|
|
71685
71712
|
if (!res.ok || !res.body) throw new Error(`download failed: HTTP ${res.status} for ${asset.FileName}`);
|
|
71686
|
-
await (0, import_promises3.pipeline)(import_node_stream3.Readable.fromWeb(res.body), (0,
|
|
71713
|
+
await (0, import_promises3.pipeline)(import_node_stream3.Readable.fromWeb(res.body), (0, import_node_fs42.createWriteStream)(dest));
|
|
71687
71714
|
const got = await sha1OfFile(dest);
|
|
71688
71715
|
if (got !== want) throw new Error(`SHA1 mismatch for ${asset.FileName}: feed=${want} got=${got}`);
|
|
71689
71716
|
return dest;
|
|
@@ -71692,7 +71719,7 @@ async function applyUpdate(check, opts) {
|
|
|
71692
71719
|
if (!check.supported) return { applied: false, message: check.reason ?? "auto-update not supported in this runtime" };
|
|
71693
71720
|
if (!check.updateAvailable || !check.asset) return { applied: false, message: check.reason ?? "no update available" };
|
|
71694
71721
|
const exe = updateExePath();
|
|
71695
|
-
if (!(0,
|
|
71722
|
+
if (!(0, import_node_fs42.existsSync)(exe)) {
|
|
71696
71723
|
return { applied: false, message: `Update.exe not found at ${exe} \u2014 is this a Velopack install?` };
|
|
71697
71724
|
}
|
|
71698
71725
|
const pkg = await downloadPackage(check.asset);
|
|
@@ -71932,12 +71959,12 @@ function isTraceCorrupt(events) {
|
|
|
71932
71959
|
|
|
71933
71960
|
// launch.mjs
|
|
71934
71961
|
var import_node_child_process8 = require("node:child_process");
|
|
71935
|
-
var
|
|
71962
|
+
var import_node_path39 = require("node:path");
|
|
71936
71963
|
var import_node_url3 = require("node:url");
|
|
71937
|
-
var
|
|
71964
|
+
var import_node_fs43 = require("node:fs");
|
|
71938
71965
|
var import_node_http = __toESM(require("node:http"), 1);
|
|
71939
71966
|
var import_node_readline = require("node:readline");
|
|
71940
|
-
var __dirname2 = (0,
|
|
71967
|
+
var __dirname2 = (0, import_node_path39.dirname)((0, import_node_url3.fileURLToPath)(__import_meta_url));
|
|
71941
71968
|
var PORT = Number(process.env.PORT ?? 4317);
|
|
71942
71969
|
var HEALTH_URL = `http://127.0.0.1:${PORT}/api/health`;
|
|
71943
71970
|
var BROWSER_URL = `http://floless.localhost:${PORT}`;
|
|
@@ -72009,8 +72036,8 @@ async function waitHealthy(timeoutMs = 3e4) {
|
|
|
72009
72036
|
function resolveServerStart() {
|
|
72010
72037
|
const packaged = /flolessapp\.exe$/i.test(process.execPath);
|
|
72011
72038
|
if (packaged) return { cmd: process.execPath, args: ["--serve"], shell: false };
|
|
72012
|
-
const bundle = (0,
|
|
72013
|
-
if ((0,
|
|
72039
|
+
const bundle = (0, import_node_path39.join)(__dirname2, "dist", "floless-server.cjs");
|
|
72040
|
+
if ((0, import_node_fs43.existsSync)(bundle)) return { cmd: process.execPath, args: [bundle, "--serve"], shell: false };
|
|
72014
72041
|
return { cmd: "npm", args: ["run", "start"], shell: isWin2 };
|
|
72015
72042
|
}
|
|
72016
72043
|
function startServerDetached() {
|
|
@@ -72163,8 +72190,8 @@ function taskkillArgs(pid, { tree = true } = {}) {
|
|
|
72163
72190
|
}
|
|
72164
72191
|
function killSupervisor({ tree = true } = {}) {
|
|
72165
72192
|
if (!isWin2) return;
|
|
72166
|
-
const isNpmChannel = /^node(\.exe)?$/i.test((0,
|
|
72167
|
-
const scriptMatch = isNpmChannel ? (0,
|
|
72193
|
+
const isNpmChannel = /^node(\.exe)?$/i.test((0, import_node_path39.basename)(process.execPath));
|
|
72194
|
+
const scriptMatch = isNpmChannel ? (0, import_node_path39.basename)((0, import_node_url3.fileURLToPath)(__import_meta_url)) : void 0;
|
|
72168
72195
|
const realExe = resolveRealInstallExe(process.execPath);
|
|
72169
72196
|
const exeMatch = realExe === process.execPath ? process.execPath : [process.execPath, realExe];
|
|
72170
72197
|
const pids = supervisorPidsToKill(enumerateProcesses(), process.pid, exeMatch, scriptMatch);
|
|
@@ -72329,7 +72356,7 @@ async function runAction(arg, flagArgv = [], selfVersion = null) {
|
|
|
72329
72356
|
}
|
|
72330
72357
|
await action(parseTeardownFlags(flagArgv));
|
|
72331
72358
|
}
|
|
72332
|
-
var entry = (0,
|
|
72359
|
+
var entry = (0, import_node_path39.basename)(process.argv[1] ?? "").toLowerCase();
|
|
72333
72360
|
if (entry === "launch.mjs") {
|
|
72334
72361
|
runAction(process.argv[2], process.argv.slice(3)).catch((e) => {
|
|
72335
72362
|
log(`error: ${e?.message ?? e}`);
|
|
@@ -72403,9 +72430,9 @@ function awareUpgradeBlockReason(s) {
|
|
|
72403
72430
|
}
|
|
72404
72431
|
|
|
72405
72432
|
// skill-sync.ts
|
|
72406
|
-
var
|
|
72407
|
-
var
|
|
72408
|
-
var
|
|
72433
|
+
var import_node_fs44 = require("node:fs");
|
|
72434
|
+
var import_node_os24 = require("node:os");
|
|
72435
|
+
var import_node_path40 = require("node:path");
|
|
72409
72436
|
var import_node_url4 = require("node:url");
|
|
72410
72437
|
var import_yaml10 = __toESM(require_dist6(), 1);
|
|
72411
72438
|
|
|
@@ -72450,30 +72477,30 @@ function selectShippedSkillNames(names) {
|
|
|
72450
72477
|
}
|
|
72451
72478
|
|
|
72452
72479
|
// skill-sync.ts
|
|
72453
|
-
var __dirname3 = (0,
|
|
72480
|
+
var __dirname3 = (0, import_node_path40.dirname)((0, import_node_url4.fileURLToPath)(__import_meta_url));
|
|
72454
72481
|
function bundledSkillsRoot() {
|
|
72455
72482
|
const candidates = [
|
|
72456
|
-
(0,
|
|
72457
|
-
(0,
|
|
72458
|
-
(0,
|
|
72483
|
+
(0, import_node_path40.join)(__dirname3, "skills"),
|
|
72484
|
+
(0, import_node_path40.join)((0, import_node_path40.dirname)(process.execPath), "skills"),
|
|
72485
|
+
(0, import_node_path40.join)(__dirname3, "..", ".claude", "skills")
|
|
72459
72486
|
];
|
|
72460
|
-
return candidates.find((p) => (0,
|
|
72487
|
+
return candidates.find((p) => (0, import_node_fs44.existsSync)(p)) ?? null;
|
|
72461
72488
|
}
|
|
72462
72489
|
function targetConfigDirs() {
|
|
72463
72490
|
const override = process.env.FLOLESS_SKILL_TARGETS;
|
|
72464
72491
|
if (override) {
|
|
72465
72492
|
return override.split(";").map((d) => d.trim()).filter(Boolean).map((dir) => ({ runtime: "custom", dir }));
|
|
72466
72493
|
}
|
|
72467
|
-
const home = (0,
|
|
72494
|
+
const home = (0, import_node_os24.homedir)();
|
|
72468
72495
|
return [
|
|
72469
|
-
{ runtime: "claude", dir: (0,
|
|
72470
|
-
{ runtime: "codex", dir: (0,
|
|
72471
|
-
{ runtime: "opencode", dir: (0,
|
|
72496
|
+
{ runtime: "claude", dir: (0, import_node_path40.join)(home, ".claude") },
|
|
72497
|
+
{ runtime: "codex", dir: (0, import_node_path40.join)(home, ".codex") },
|
|
72498
|
+
{ runtime: "opencode", dir: (0, import_node_path40.join)(home, ".opencode") }
|
|
72472
72499
|
];
|
|
72473
72500
|
}
|
|
72474
72501
|
function skillVersion(skillMdPath) {
|
|
72475
72502
|
try {
|
|
72476
|
-
const text3 = (0,
|
|
72503
|
+
const text3 = (0, import_node_fs44.readFileSync)(skillMdPath, "utf8");
|
|
72477
72504
|
const m = /^---\r?\n([\s\S]*?)\r?\n---/.exec(text3);
|
|
72478
72505
|
if (!m || m[1] === void 0) return null;
|
|
72479
72506
|
const fm = (0, import_yaml10.parse)(m[1]);
|
|
@@ -72510,24 +72537,24 @@ function decideAction(installed, bundled) {
|
|
|
72510
72537
|
if (c === 0) return "skipped-current";
|
|
72511
72538
|
return "skipped-newer";
|
|
72512
72539
|
}
|
|
72513
|
-
function bundledSkills(
|
|
72540
|
+
function bundledSkills(root4) {
|
|
72514
72541
|
let entries2 = [];
|
|
72515
72542
|
try {
|
|
72516
|
-
entries2 = selectShippedSkillNames((0,
|
|
72543
|
+
entries2 = selectShippedSkillNames((0, import_node_fs44.readdirSync)(root4));
|
|
72517
72544
|
} catch {
|
|
72518
72545
|
return [];
|
|
72519
72546
|
}
|
|
72520
72547
|
const out = [];
|
|
72521
72548
|
for (const name of entries2) {
|
|
72522
|
-
const dir = (0,
|
|
72549
|
+
const dir = (0, import_node_path40.join)(root4, name);
|
|
72523
72550
|
let isDir = false;
|
|
72524
72551
|
try {
|
|
72525
|
-
isDir = (0,
|
|
72552
|
+
isDir = (0, import_node_fs44.statSync)(dir).isDirectory();
|
|
72526
72553
|
} catch {
|
|
72527
72554
|
isDir = false;
|
|
72528
72555
|
}
|
|
72529
72556
|
if (!isDir) continue;
|
|
72530
|
-
const v = skillVersion((0,
|
|
72557
|
+
const v = skillVersion((0, import_node_path40.join)(dir, "SKILL.md"));
|
|
72531
72558
|
if (!v) continue;
|
|
72532
72559
|
out.push({ name, dir, version: v });
|
|
72533
72560
|
}
|
|
@@ -72535,22 +72562,22 @@ function bundledSkills(root3) {
|
|
|
72535
72562
|
}
|
|
72536
72563
|
function syncSkills() {
|
|
72537
72564
|
const results = [];
|
|
72538
|
-
const
|
|
72539
|
-
if (!
|
|
72540
|
-
const skills = bundledSkills(
|
|
72565
|
+
const root4 = bundledSkillsRoot();
|
|
72566
|
+
if (!root4) return results;
|
|
72567
|
+
const skills = bundledSkills(root4);
|
|
72541
72568
|
if (!skills.length) return results;
|
|
72542
72569
|
for (const { runtime, dir: cfg } of targetConfigDirs()) {
|
|
72543
|
-
if (!(0,
|
|
72544
|
-
const skillsDir = (0,
|
|
72570
|
+
if (!(0, import_node_fs44.existsSync)(cfg)) continue;
|
|
72571
|
+
const skillsDir = (0, import_node_path40.join)(cfg, "skills");
|
|
72545
72572
|
for (const s of skills) {
|
|
72546
|
-
const dest = (0,
|
|
72547
|
-
const installedMd = (0,
|
|
72548
|
-
const installed = (0,
|
|
72573
|
+
const dest = (0, import_node_path40.join)(skillsDir, s.name);
|
|
72574
|
+
const installedMd = (0, import_node_path40.join)(dest, "SKILL.md");
|
|
72575
|
+
const installed = (0, import_node_fs44.existsSync)(installedMd) ? skillVersion(installedMd) : null;
|
|
72549
72576
|
const action = decideAction(installed, s.version);
|
|
72550
72577
|
if (action === "installed" || action === "updated") {
|
|
72551
72578
|
try {
|
|
72552
|
-
if (action === "updated") (0,
|
|
72553
|
-
(0,
|
|
72579
|
+
if (action === "updated") (0, import_node_fs44.rmSync)(dest, { recursive: true, force: true });
|
|
72580
|
+
(0, import_node_fs44.cpSync)(s.dir, dest, { recursive: true });
|
|
72554
72581
|
results.push({ runtime, skill: s.name, action, from: installed, to: s.version });
|
|
72555
72582
|
} catch {
|
|
72556
72583
|
}
|
|
@@ -72574,9 +72601,9 @@ function contractChangedEvent(appId, project, etag, rawMutationId) {
|
|
|
72574
72601
|
}
|
|
72575
72602
|
|
|
72576
72603
|
// watch.ts
|
|
72577
|
-
var
|
|
72578
|
-
var
|
|
72579
|
-
var
|
|
72604
|
+
var import_node_os25 = require("node:os");
|
|
72605
|
+
var import_node_path42 = require("node:path");
|
|
72606
|
+
var import_node_fs45 = require("node:fs");
|
|
72580
72607
|
|
|
72581
72608
|
// node_modules/chokidar/esm/index.js
|
|
72582
72609
|
var import_fs2 = require("fs");
|
|
@@ -72587,7 +72614,7 @@ var sysPath2 = __toESM(require("path"), 1);
|
|
|
72587
72614
|
// node_modules/readdirp/esm/index.js
|
|
72588
72615
|
var import_promises4 = require("node:fs/promises");
|
|
72589
72616
|
var import_node_stream4 = require("node:stream");
|
|
72590
|
-
var
|
|
72617
|
+
var import_node_path41 = require("node:path");
|
|
72591
72618
|
var EntryTypes = {
|
|
72592
72619
|
FILE_TYPE: "files",
|
|
72593
72620
|
DIR_TYPE: "directories",
|
|
@@ -72649,7 +72676,7 @@ var ReaddirpStream = class extends import_node_stream4.Readable {
|
|
|
72649
72676
|
highWaterMark: options.highWaterMark
|
|
72650
72677
|
});
|
|
72651
72678
|
const opts = { ...defaultOptions, ...options };
|
|
72652
|
-
const { root:
|
|
72679
|
+
const { root: root4, type } = opts;
|
|
72653
72680
|
this._fileFilter = normalizeFilter(opts.fileFilter);
|
|
72654
72681
|
this._directoryFilter = normalizeFilter(opts.directoryFilter);
|
|
72655
72682
|
const statMethod = opts.lstat ? import_promises4.lstat : import_promises4.stat;
|
|
@@ -72662,11 +72689,11 @@ var ReaddirpStream = class extends import_node_stream4.Readable {
|
|
|
72662
72689
|
this._wantsDir = type ? DIR_TYPES.has(type) : false;
|
|
72663
72690
|
this._wantsFile = type ? FILE_TYPES.has(type) : false;
|
|
72664
72691
|
this._wantsEverything = type === EntryTypes.EVERYTHING_TYPE;
|
|
72665
|
-
this._root = (0,
|
|
72692
|
+
this._root = (0, import_node_path41.resolve)(root4);
|
|
72666
72693
|
this._isDirent = !opts.alwaysStat;
|
|
72667
72694
|
this._statsProp = this._isDirent ? "dirent" : "stats";
|
|
72668
72695
|
this._rdOptions = { encoding: "utf8", withFileTypes: this._isDirent };
|
|
72669
|
-
this.parents = [this._exploreDir(
|
|
72696
|
+
this.parents = [this._exploreDir(root4, 1)];
|
|
72670
72697
|
this.reading = false;
|
|
72671
72698
|
this.parent = void 0;
|
|
72672
72699
|
}
|
|
@@ -72733,8 +72760,8 @@ var ReaddirpStream = class extends import_node_stream4.Readable {
|
|
|
72733
72760
|
let entry2;
|
|
72734
72761
|
const basename9 = this._isDirent ? dirent.name : dirent;
|
|
72735
72762
|
try {
|
|
72736
|
-
const fullPath = (0,
|
|
72737
|
-
entry2 = { path: (0,
|
|
72763
|
+
const fullPath = (0, import_node_path41.resolve)((0, import_node_path41.join)(path, basename9));
|
|
72764
|
+
entry2 = { path: (0, import_node_path41.relative)(this._root, fullPath), fullPath, basename: basename9 };
|
|
72738
72765
|
entry2[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
|
|
72739
72766
|
} catch (err2) {
|
|
72740
72767
|
this._onError(err2);
|
|
@@ -72768,7 +72795,7 @@ var ReaddirpStream = class extends import_node_stream4.Readable {
|
|
|
72768
72795
|
}
|
|
72769
72796
|
if (entryRealPathStats.isDirectory()) {
|
|
72770
72797
|
const len = entryRealPath.length;
|
|
72771
|
-
if (full.startsWith(entryRealPath) && full.substr(len, 1) ===
|
|
72798
|
+
if (full.startsWith(entryRealPath) && full.substr(len, 1) === import_node_path41.sep) {
|
|
72772
72799
|
const recursiveError = new Error(`Circular symlink detected: "${full}" points to "${entryRealPath}"`);
|
|
72773
72800
|
recursiveError.code = RECURSIVE_ERROR_CODE;
|
|
72774
72801
|
return this._onError(recursiveError);
|
|
@@ -72786,20 +72813,20 @@ var ReaddirpStream = class extends import_node_stream4.Readable {
|
|
|
72786
72813
|
return stats && this._wantsEverything && !stats.isDirectory();
|
|
72787
72814
|
}
|
|
72788
72815
|
};
|
|
72789
|
-
function readdirp(
|
|
72816
|
+
function readdirp(root4, options = {}) {
|
|
72790
72817
|
let type = options.entryType || options.type;
|
|
72791
72818
|
if (type === "both")
|
|
72792
72819
|
type = EntryTypes.FILE_DIR_TYPE;
|
|
72793
72820
|
if (type)
|
|
72794
72821
|
options.type = type;
|
|
72795
|
-
if (!
|
|
72822
|
+
if (!root4) {
|
|
72796
72823
|
throw new Error("readdirp: root argument is required. Usage: readdirp(root, options)");
|
|
72797
|
-
} else if (typeof
|
|
72824
|
+
} else if (typeof root4 !== "string") {
|
|
72798
72825
|
throw new TypeError("readdirp: root argument must be a string. Usage: readdirp(root, options)");
|
|
72799
72826
|
} else if (type && !ALL_TYPES.includes(type)) {
|
|
72800
72827
|
throw new Error(`readdirp: Invalid type passed. Use one of ${ALL_TYPES.join(", ")}`);
|
|
72801
72828
|
}
|
|
72802
|
-
options.root =
|
|
72829
|
+
options.root = root4;
|
|
72803
72830
|
return new ReaddirpStream(options);
|
|
72804
72831
|
}
|
|
72805
72832
|
|
|
@@ -74244,11 +74271,11 @@ var FSWatcher = class extends import_events.EventEmitter {
|
|
|
74244
74271
|
}
|
|
74245
74272
|
list.push(closer);
|
|
74246
74273
|
}
|
|
74247
|
-
_readdirp(
|
|
74274
|
+
_readdirp(root4, opts) {
|
|
74248
74275
|
if (this.closed)
|
|
74249
74276
|
return;
|
|
74250
74277
|
const options = { type: EVENTS.ALL, alwaysStat: true, lstat: true, ...opts, depth: 0 };
|
|
74251
|
-
let stream = readdirp(
|
|
74278
|
+
let stream = readdirp(root4, options);
|
|
74252
74279
|
this._streams.add(stream);
|
|
74253
74280
|
stream.once(STR_CLOSE, () => {
|
|
74254
74281
|
stream = void 0;
|
|
@@ -74276,33 +74303,33 @@ function appIdFromLogPath(path) {
|
|
|
74276
74303
|
return i >= 0 && parts[i + 1] ? parts[i + 1] : null;
|
|
74277
74304
|
}
|
|
74278
74305
|
function samePath(a, b) {
|
|
74279
|
-
const ra = (0,
|
|
74280
|
-
const rb = (0,
|
|
74306
|
+
const ra = (0, import_node_path42.resolve)(a);
|
|
74307
|
+
const rb = (0, import_node_path42.resolve)(b);
|
|
74281
74308
|
return process.platform === "win32" ? ra.toLowerCase() === rb.toLowerCase() : ra === rb;
|
|
74282
74309
|
}
|
|
74283
74310
|
function underDir(path, dir) {
|
|
74284
|
-
const rp = (0,
|
|
74285
|
-
const rd = (0,
|
|
74311
|
+
const rp = (0, import_node_path42.resolve)(path);
|
|
74312
|
+
const rd = (0, import_node_path42.resolve)(dir);
|
|
74286
74313
|
const [p, d] = process.platform === "win32" ? [rp.toLowerCase(), rd.toLowerCase()] : [rp, rd];
|
|
74287
|
-
return p === d || p.startsWith(d +
|
|
74314
|
+
return p === d || p.startsWith(d + import_node_path42.sep);
|
|
74288
74315
|
}
|
|
74289
74316
|
function startWatcher() {
|
|
74290
|
-
const awareDir = process.env.AWARE_HOME ?? (0,
|
|
74291
|
-
const credentialsDir = (0,
|
|
74292
|
-
if (!(0,
|
|
74317
|
+
const awareDir = process.env.AWARE_HOME ?? (0, import_node_path42.join)((0, import_node_os25.homedir)(), ".aware");
|
|
74318
|
+
const credentialsDir = (0, import_node_path42.join)(awareDir, "credentials");
|
|
74319
|
+
if (!(0, import_node_fs45.existsSync)(credentialsDir)) {
|
|
74293
74320
|
try {
|
|
74294
|
-
(0,
|
|
74321
|
+
(0, import_node_fs45.mkdirSync)(credentialsDir, { recursive: true });
|
|
74295
74322
|
} catch {
|
|
74296
74323
|
}
|
|
74297
74324
|
}
|
|
74298
|
-
if (!(0,
|
|
74325
|
+
if (!(0, import_node_fs45.existsSync)(uiDir)) {
|
|
74299
74326
|
try {
|
|
74300
|
-
(0,
|
|
74327
|
+
(0, import_node_fs45.mkdirSync)(uiDir, { recursive: true });
|
|
74301
74328
|
} catch {
|
|
74302
74329
|
}
|
|
74303
74330
|
}
|
|
74304
|
-
const targets = ["apps", "logs", "credentials"].map((d) => (0,
|
|
74305
|
-
if ((0,
|
|
74331
|
+
const targets = ["apps", "logs", "credentials"].map((d) => (0, import_node_path42.join)(awareDir, d)).filter((p) => (0, import_node_fs45.existsSync)(p));
|
|
74332
|
+
if ((0, import_node_fs45.existsSync)(uiDir)) targets.push(uiDir);
|
|
74306
74333
|
if (targets.length === 0) {
|
|
74307
74334
|
return null;
|
|
74308
74335
|
}
|
|
@@ -74331,11 +74358,11 @@ function startWatcher() {
|
|
|
74331
74358
|
const isCredential = path.split(/[\\/]/).includes("credentials");
|
|
74332
74359
|
const kind = isCredential ? "credential" : path.endsWith(".jsonl") ? "trace" : path.endsWith(".lock") ? "lock" : path.endsWith(".flo") || path.endsWith(".app") ? "source" : "file";
|
|
74333
74360
|
broadcast({ type: "fs-change", kind, event, path });
|
|
74334
|
-
if (kind === "trace" && event !== "unlink" && (0,
|
|
74361
|
+
if (kind === "trace" && event !== "unlink" && (0, import_node_fs45.existsSync)(path)) {
|
|
74335
74362
|
const id = appIdFromLogPath(path);
|
|
74336
74363
|
if (!id) return;
|
|
74337
74364
|
try {
|
|
74338
|
-
broadcast({ type: "trace-file", id, runId: path.split(
|
|
74365
|
+
broadcast({ type: "trace-file", id, runId: path.split(import_node_path42.sep).pop()?.replace(/\.jsonl$/, "") ?? null, events: parseTrace((0, import_node_fs45.readFileSync)(path, "utf8")) });
|
|
74339
74366
|
} catch {
|
|
74340
74367
|
}
|
|
74341
74368
|
}
|
|
@@ -74344,10 +74371,10 @@ function startWatcher() {
|
|
|
74344
74371
|
}
|
|
74345
74372
|
|
|
74346
74373
|
// index.ts
|
|
74347
|
-
var __dirname4 = (0,
|
|
74348
|
-
var WEB_ROOT = [(0,
|
|
74349
|
-
(p) => (0,
|
|
74350
|
-
) ?? (0,
|
|
74374
|
+
var __dirname4 = (0, import_node_path43.dirname)((0, import_node_url5.fileURLToPath)(__import_meta_url));
|
|
74375
|
+
var WEB_ROOT = [(0, import_node_path43.join)(__dirname4, "web"), (0, import_node_path43.join)((0, import_node_path43.dirname)(process.execPath), "web"), (0, import_node_path43.join)(__dirname4, "..", "web")].find(
|
|
74376
|
+
(p) => (0, import_node_fs46.existsSync)(p)
|
|
74377
|
+
) ?? (0, import_node_path43.join)(__dirname4, "..", "web");
|
|
74351
74378
|
var PORT2 = Number(process.env.PORT ?? 4317);
|
|
74352
74379
|
var HOST = "127.0.0.1";
|
|
74353
74380
|
var crashHandlersInstalled = false;
|
|
@@ -74363,7 +74390,7 @@ function installCrashHandlers() {
|
|
|
74363
74390
|
${stack}
|
|
74364
74391
|
`;
|
|
74365
74392
|
try {
|
|
74366
|
-
(0,
|
|
74393
|
+
(0, import_node_fs46.appendFileSync)(logFilePath(), line);
|
|
74367
74394
|
} catch {
|
|
74368
74395
|
}
|
|
74369
74396
|
if (process.stderr.isTTY) process.stderr.write(line);
|
|
@@ -74719,9 +74746,9 @@ async function startServer() {
|
|
|
74719
74746
|
const { id, templateId, templatePath, srcPath, appDirPath: appDirPath2, fromVersion, contract, verb } = opts;
|
|
74720
74747
|
const bdir = backupDir(id, fromVersion, Date.now());
|
|
74721
74748
|
try {
|
|
74722
|
-
(0,
|
|
74723
|
-
(0,
|
|
74724
|
-
(0,
|
|
74749
|
+
(0, import_node_fs46.mkdirSync)((0, import_node_path43.dirname)(bdir), { recursive: true });
|
|
74750
|
+
(0, import_node_fs46.cpSync)(appDirPath2, bdir, { recursive: true });
|
|
74751
|
+
(0, import_node_fs46.cpSync)(templatePath, srcPath);
|
|
74725
74752
|
if (id !== templateId) stampSourceAppId(srcPath, id);
|
|
74726
74753
|
if (contract != null) {
|
|
74727
74754
|
bakeContractIntoApp(srcPath, contract);
|
|
@@ -74732,8 +74759,8 @@ async function startServer() {
|
|
|
74732
74759
|
} catch (e) {
|
|
74733
74760
|
const msg = e instanceof Error ? e.message : String(e);
|
|
74734
74761
|
try {
|
|
74735
|
-
(0,
|
|
74736
|
-
(0,
|
|
74762
|
+
(0, import_node_fs46.rmSync)(appDirPath2, { recursive: true, force: true });
|
|
74763
|
+
(0, import_node_fs46.cpSync)(bdir, appDirPath2, { recursive: true });
|
|
74737
74764
|
} catch (re) {
|
|
74738
74765
|
const rmsg = re instanceof Error ? re.message : String(re);
|
|
74739
74766
|
throw new TemplateSwapError(`${verb} failed (${msg}) AND rollback failed (${rmsg}) \u2014 restore manually from ${bdir}`, "rollback-failed", bdir);
|
|
@@ -74765,7 +74792,7 @@ async function startServer() {
|
|
|
74765
74792
|
return reply.status(409).send({ ok: false, error: `"${id}" is already at ${fromVersion}`, code: "up-to-date" });
|
|
74766
74793
|
}
|
|
74767
74794
|
const contract = readAcceptedForRequest(id, void 0);
|
|
74768
|
-
if (contract == null && (0,
|
|
74795
|
+
if (contract == null && (0, import_node_fs46.existsSync)(contractPath(id))) {
|
|
74769
74796
|
return reply.status(409).send({ ok: false, error: `"${id}"'s saved data is unreadable \u2014 open it in the editor and re-save before updating`, code: "contract-corrupt" });
|
|
74770
74797
|
}
|
|
74771
74798
|
if (contract != null) {
|
|
@@ -74899,16 +74926,16 @@ async function startServer() {
|
|
|
74899
74926
|
app.get("/api/app/:id", async (req) => {
|
|
74900
74927
|
return { ok: true, app: readApp(req.params.id) };
|
|
74901
74928
|
});
|
|
74902
|
-
const withTemplateId = (p,
|
|
74929
|
+
const withTemplateId = (p, root4) => ({ ...p, templateId: root4(p.app) });
|
|
74903
74930
|
const projectView = (p) => withTemplateId(p, resolveTemplateId);
|
|
74904
74931
|
const projectViews = (list) => {
|
|
74905
|
-
const
|
|
74906
|
-
return list.map((p) => withTemplateId(p,
|
|
74932
|
+
const root4 = templateIdResolver();
|
|
74933
|
+
return list.map((p) => withTemplateId(p, root4));
|
|
74907
74934
|
};
|
|
74908
74935
|
const requestView2 = (r) => r === null ? null : { ...r, appTemplateId: r.appId ? resolveTemplateId(r.appId) : void 0 };
|
|
74909
74936
|
const requestViews = (list) => {
|
|
74910
|
-
const
|
|
74911
|
-
return list.map((r) => ({ ...r, appTemplateId: r.appId ?
|
|
74937
|
+
const root4 = templateIdResolver();
|
|
74938
|
+
return list.map((r) => ({ ...r, appTemplateId: r.appId ? root4(r.appId) : void 0 }));
|
|
74912
74939
|
};
|
|
74913
74940
|
app.get("/api/projects", async () => ({ ok: true, projects: projectViews(listProjects()) }));
|
|
74914
74941
|
app.post(
|
|
@@ -75145,9 +75172,9 @@ async function startServer() {
|
|
|
75145
75172
|
const bad = projectAppMismatch(req.params.appId, project);
|
|
75146
75173
|
if (bad) return reply.status(404).send({ ok: false, error: bad });
|
|
75147
75174
|
const safe2 = req.params.sheet.replace(/[^A-Za-z0-9._-]/g, "");
|
|
75148
|
-
const file = (0,
|
|
75149
|
-
if (!(0,
|
|
75150
|
-
return reply.type("image/svg+xml").send((0,
|
|
75175
|
+
const file = (0, import_node_path43.join)((0, import_node_path43.dirname)(contractPath(req.params.appId, project)), "details", `${safe2}.svg`);
|
|
75176
|
+
if (!(0, import_node_fs46.existsSync)(file)) return reply.status(404).send({ ok: false, error: "no vector for this sheet" });
|
|
75177
|
+
return reply.type("image/svg+xml").send((0, import_node_fs46.readFileSync)(file, "utf8"));
|
|
75151
75178
|
}
|
|
75152
75179
|
);
|
|
75153
75180
|
app.put(
|
|
@@ -75305,7 +75332,7 @@ async function startServer() {
|
|
|
75305
75332
|
}
|
|
75306
75333
|
const statedAt = (filename) => {
|
|
75307
75334
|
try {
|
|
75308
|
-
const st = (0,
|
|
75335
|
+
const st = (0, import_node_fs46.statSync)((0, import_node_path43.join)(dir, filename));
|
|
75309
75336
|
return st.isFile() ? st.mtime.toISOString() : null;
|
|
75310
75337
|
} catch {
|
|
75311
75338
|
return null;
|
|
@@ -75315,14 +75342,14 @@ async function startServer() {
|
|
|
75315
75342
|
const rows2 = (byKind.get(kind) ?? []).map((receipt) => ({
|
|
75316
75343
|
variant: receipt.variant ?? null,
|
|
75317
75344
|
filename: receipt.filename,
|
|
75318
|
-
path: (0,
|
|
75345
|
+
path: (0, import_node_path43.join)(dir, receipt.filename),
|
|
75319
75346
|
exportedAt: statedAt(receipt.filename)
|
|
75320
75347
|
})).sort((a, b) => String(b.exportedAt ?? "").localeCompare(String(a.exportedAt ?? "")));
|
|
75321
75348
|
const headline = rows2[0];
|
|
75322
75349
|
return {
|
|
75323
75350
|
kind,
|
|
75324
75351
|
filename: headline?.filename ?? legacy,
|
|
75325
|
-
path: headline?.path ?? (0,
|
|
75352
|
+
path: headline?.path ?? (0, import_node_path43.join)(dir, legacy),
|
|
75326
75353
|
exportedAt: headline?.exportedAt ?? null,
|
|
75327
75354
|
...rows2.length ? { variants: rows2 } : {}
|
|
75328
75355
|
};
|
|
@@ -75461,7 +75488,7 @@ async function startServer() {
|
|
|
75461
75488
|
}
|
|
75462
75489
|
if (!hasExportableSceneRecords(scene)) return reply.status(422).send({ ok: false, error: emptyError, skipped });
|
|
75463
75490
|
const filename = `${exportFileBase(project, appId)}.ifc`;
|
|
75464
|
-
const finalPath = (0,
|
|
75491
|
+
const finalPath = (0, import_node_path43.join)(project ? projectExportsDir(project) : (0, import_node_path43.dirname)(bomExportPath(appId, "csv")), filename);
|
|
75465
75492
|
const priorProjectIfc = project ? listProjectExportReceipts(project).find((row) => row.kind === "ifc") : void 0;
|
|
75466
75493
|
const tempPath = requestIfcTempPath(finalPath);
|
|
75467
75494
|
try {
|
|
@@ -75469,10 +75496,10 @@ async function startServer() {
|
|
|
75469
75496
|
scene,
|
|
75470
75497
|
"output-path": tempPath
|
|
75471
75498
|
});
|
|
75472
|
-
if (!(0,
|
|
75499
|
+
if (!(0, import_node_fs46.existsSync)(tempPath) || (0, import_node_fs46.statSync)(tempPath).size === 0) {
|
|
75473
75500
|
throw new ReceiptReconciliationError("AWARE reported a successful export but wrote no IFC file.");
|
|
75474
75501
|
}
|
|
75475
|
-
const artifactBytes = (0,
|
|
75502
|
+
const artifactBytes = (0, import_node_fs46.readFileSync)(tempPath);
|
|
75476
75503
|
const receipt = reconcileIfcExportReceipt(scene, rawReceipt, producerUnsupported, {
|
|
75477
75504
|
index: parseStepData(artifactBytes),
|
|
75478
75505
|
bytes: artifactBytes
|
|
@@ -75525,7 +75552,7 @@ async function startServer() {
|
|
|
75525
75552
|
return reply.status(status).send({
|
|
75526
75553
|
ok: false,
|
|
75527
75554
|
error: error instanceof Error ? error.message : "IFC export failed",
|
|
75528
|
-
preservedPrevious: project && priorProjectIfc ? receiptHasFile(project, priorProjectIfc) : (0,
|
|
75555
|
+
preservedPrevious: project && priorProjectIfc ? receiptHasFile(project, priorProjectIfc) : (0, import_node_fs46.existsSync)(finalPath)
|
|
75529
75556
|
});
|
|
75530
75557
|
} finally {
|
|
75531
75558
|
cleanupIfcTemp(tempPath);
|
|
@@ -75570,10 +75597,10 @@ async function startServer() {
|
|
|
75570
75597
|
const receipt = wanted ? stills.find((row) => row.variant === wanted) : [...stills].sort((a, b) => b.exportedAt.localeCompare(a.exportedAt))[0];
|
|
75571
75598
|
if (!receipt) return reply.status(404).send({ ok: false, error: "nothing rendered yet" });
|
|
75572
75599
|
const path = resolveProjectExportReceiptPath(project, receipt);
|
|
75573
|
-
if (!path || !(0,
|
|
75600
|
+
if (!path || !(0, import_node_fs46.existsSync)(path)) {
|
|
75574
75601
|
return reply.status(404).send({ ok: false, error: "the rendered image is no longer on disk" });
|
|
75575
75602
|
}
|
|
75576
|
-
return reply.header("content-type", "image/png").header("cache-control", "private, max-age=31536000, immutable").send((0,
|
|
75603
|
+
return reply.header("content-type", "image/png").header("cache-control", "private, max-age=31536000, immutable").send((0, import_node_fs46.readFileSync)(path));
|
|
75577
75604
|
});
|
|
75578
75605
|
const RENDER_VIEWPOINTS = /* @__PURE__ */ new Set(["hero", "iso", "front", "back", "left", "right", "top"]);
|
|
75579
75606
|
app.post("/api/contract/:appId/render", async (req, reply) => {
|
|
@@ -75630,8 +75657,8 @@ async function startServer() {
|
|
|
75630
75657
|
}
|
|
75631
75658
|
const kind = output === "turntable" ? "render-mp4" : "render-png";
|
|
75632
75659
|
const extension = output === "turntable" ? ".mp4" : ".png";
|
|
75633
|
-
const scratch = (0,
|
|
75634
|
-
const ifcPath = (0,
|
|
75660
|
+
const scratch = (0, import_node_fs46.mkdtempSync)((0, import_node_path43.join)((0, import_node_os26.tmpdir)(), "floless-render-"));
|
|
75661
|
+
const ifcPath = (0, import_node_path43.join)(scratch, "model.ifc");
|
|
75635
75662
|
const rendered = [];
|
|
75636
75663
|
const progress = (stage, extra = {}) => {
|
|
75637
75664
|
try {
|
|
@@ -75642,13 +75669,13 @@ async function startServer() {
|
|
|
75642
75669
|
try {
|
|
75643
75670
|
progress("preparing");
|
|
75644
75671
|
await aware.agentInvoke("ifc", "write", { scene: built.scene, "output-path": ifcPath });
|
|
75645
|
-
if (!(0,
|
|
75672
|
+
if (!(0, import_node_fs46.existsSync)(ifcPath) || (0, import_node_fs46.statSync)(ifcPath).size === 0) {
|
|
75646
75673
|
throw new Error("AWARE reported a successful IFC write but produced no file to render");
|
|
75647
75674
|
}
|
|
75648
75675
|
const renderBudgetMs = output === "turntable" ? 30 * 6e4 : 10 * 6e4;
|
|
75649
75676
|
for (const [i, viewpoint] of viewpoints.entries()) {
|
|
75650
75677
|
progress("rendering", { viewpoint, index: i + 1, output });
|
|
75651
|
-
const artifactPath = (0,
|
|
75678
|
+
const artifactPath = (0, import_node_path43.join)(scratch, `render-${viewpoint}${extension}`);
|
|
75652
75679
|
const receipt = await aware.agentInvoke(RENDER_AGENT_ID, output === "turntable" ? "render.turntable" : "render.still", {
|
|
75653
75680
|
"ifc-path": ifcPath,
|
|
75654
75681
|
"output-path": artifactPath,
|
|
@@ -75660,10 +75687,10 @@ async function startServer() {
|
|
|
75660
75687
|
environment: "studio",
|
|
75661
75688
|
...output === "turntable" ? { "duration-seconds": 12, fps: 24, "width-pixels": 1280, "height-pixels": 720 } : { quality, "width-pixels": 1920, "height-pixels": 1080 }
|
|
75662
75689
|
}, { timeoutMs: renderBudgetMs });
|
|
75663
|
-
if (!(0,
|
|
75690
|
+
if (!(0, import_node_fs46.existsSync)(artifactPath) || (0, import_node_fs46.statSync)(artifactPath).size === 0) {
|
|
75664
75691
|
throw new Error(`the ${viewpoint} render reported success but produced no image`);
|
|
75665
75692
|
}
|
|
75666
|
-
const bytes = (0,
|
|
75693
|
+
const bytes = (0, import_node_fs46.readFileSync)(artifactPath);
|
|
75667
75694
|
const preferred = `${exportFileBase(project, appId)}-${viewpoint}${extension}`;
|
|
75668
75695
|
const filename = uniqueProjectExportFilename(project, preferred);
|
|
75669
75696
|
publishProjectExportArtifact(project, {
|
|
@@ -75699,7 +75726,7 @@ async function startServer() {
|
|
|
75699
75726
|
// Kept for a single-viewpoint caller so the existing shape still reads naturally.
|
|
75700
75727
|
filename: rendered[0]?.filename,
|
|
75701
75728
|
viewpoint: rendered[0]?.viewpoint,
|
|
75702
|
-
savedTo: rendered[0] ? (0,
|
|
75729
|
+
savedTo: rendered[0] ? (0, import_node_path43.join)(projectExportsDir(project), rendered[0].filename) : void 0
|
|
75703
75730
|
};
|
|
75704
75731
|
} catch (error) {
|
|
75705
75732
|
app.log.warn(
|
|
@@ -75715,7 +75742,7 @@ async function startServer() {
|
|
|
75715
75742
|
rendered
|
|
75716
75743
|
});
|
|
75717
75744
|
} finally {
|
|
75718
|
-
(0,
|
|
75745
|
+
(0, import_node_fs46.rmSync)(scratch, { recursive: true, force: true });
|
|
75719
75746
|
}
|
|
75720
75747
|
}, {
|
|
75721
75748
|
// What anyone blocked on this project is told, and for how long to expect it. Erring long
|
|
@@ -75857,10 +75884,10 @@ async function startServer() {
|
|
|
75857
75884
|
}
|
|
75858
75885
|
const preferredFilename = `${exportFileBase(project, appId)}-bom.${format}`;
|
|
75859
75886
|
const filename = project ? uniqueProjectExportFilename(project, preferredFilename) : preferredFilename;
|
|
75860
|
-
const outPath = project ? (0,
|
|
75861
|
-
const dir = (0,
|
|
75887
|
+
const outPath = project ? (0, import_node_path43.join)(projectExportsDir(project), filename) : bomExportPath(appId, format);
|
|
75888
|
+
const dir = (0, import_node_path43.dirname)(outPath);
|
|
75862
75889
|
try {
|
|
75863
|
-
(0,
|
|
75890
|
+
(0, import_node_fs46.mkdirSync)(dir, { recursive: true });
|
|
75864
75891
|
if (format === "csv") {
|
|
75865
75892
|
const text3 = bomToCsv(bom);
|
|
75866
75893
|
if (project && projectSnapshot) {
|
|
@@ -75872,7 +75899,7 @@ async function startServer() {
|
|
|
75872
75899
|
version: projectSnapshot.version.n,
|
|
75873
75900
|
contractHash: projectSnapshot.contractHash
|
|
75874
75901
|
}, Buffer.from(text3, "utf8"));
|
|
75875
|
-
} else (0,
|
|
75902
|
+
} else (0, import_node_fs46.writeFileSync)(outPath, text3, "utf8");
|
|
75876
75903
|
return { ok: true, filename, encoding: "utf8", content: text3, bytes: Buffer.byteLength(text3), savedTo: outPath };
|
|
75877
75904
|
}
|
|
75878
75905
|
const buf = await bomToXlsx(bom);
|
|
@@ -75885,7 +75912,7 @@ async function startServer() {
|
|
|
75885
75912
|
version: projectSnapshot.version.n,
|
|
75886
75913
|
contractHash: projectSnapshot.contractHash
|
|
75887
75914
|
}, buf);
|
|
75888
|
-
} else (0,
|
|
75915
|
+
} else (0, import_node_fs46.writeFileSync)(outPath, buf);
|
|
75889
75916
|
return { ok: true, filename, encoding: "base64", content: buf.toString("base64"), bytes: buf.length, savedTo: outPath };
|
|
75890
75917
|
} catch (e) {
|
|
75891
75918
|
app.log.error({ appId, format, err: e instanceof Error ? e.message : e }, "export-bom: generation failed");
|
|
@@ -75923,9 +75950,9 @@ async function startServer() {
|
|
|
75923
75950
|
const svg = contractToSvg(cleaned);
|
|
75924
75951
|
const preferredFilename = `${exportFileBase(project, req.params.appId)}.svg`;
|
|
75925
75952
|
const filename = project ? uniqueProjectExportFilename(project, preferredFilename) : preferredFilename;
|
|
75926
|
-
const outPath = project ? (0,
|
|
75953
|
+
const outPath = project ? (0, import_node_path43.join)(projectExportsDir(project), filename) : (0, import_node_path43.join)(appPath(req.params.appId), filename);
|
|
75927
75954
|
try {
|
|
75928
|
-
(0,
|
|
75955
|
+
(0, import_node_fs46.mkdirSync)((0, import_node_path43.dirname)(outPath), { recursive: true });
|
|
75929
75956
|
if (project && projectSnapshot) {
|
|
75930
75957
|
publishProjectExportArtifact(project, {
|
|
75931
75958
|
kind: "svg",
|
|
@@ -75935,7 +75962,7 @@ async function startServer() {
|
|
|
75935
75962
|
version: projectSnapshot.version.n,
|
|
75936
75963
|
contractHash: projectSnapshot.contractHash
|
|
75937
75964
|
}, Buffer.from(svg, "utf8"));
|
|
75938
|
-
} else (0,
|
|
75965
|
+
} else (0, import_node_fs46.writeFileSync)(outPath, svg, "utf8");
|
|
75939
75966
|
return { ok: true, filename, encoding: "utf8", content: svg, bytes: Buffer.byteLength(svg), savedTo: outPath };
|
|
75940
75967
|
} catch (e) {
|
|
75941
75968
|
app.log.error({ appId: req.params.appId, err: e instanceof Error ? e.message : e }, "export-svg: write failed");
|
|
@@ -76018,7 +76045,7 @@ async function startServer() {
|
|
|
76018
76045
|
return reply.status(404).send({ ok: false, error: `"${id}" is not installed`, code: "not-installed" });
|
|
76019
76046
|
}
|
|
76020
76047
|
const contract = readAcceptedForRequest(id, void 0);
|
|
76021
|
-
if (contract == null && (0,
|
|
76048
|
+
if (contract == null && (0, import_node_fs46.existsSync)(contractPath(id))) {
|
|
76022
76049
|
return reply.status(409).send({ ok: false, error: `"${id}"'s saved data is unreadable \u2014 open it in the editor and re-save before restoring`, code: "contract-corrupt" });
|
|
76023
76050
|
}
|
|
76024
76051
|
if (contract != null) {
|
|
@@ -76099,11 +76126,11 @@ async function startServer() {
|
|
|
76099
76126
|
return reply.status(409).send({ ok: false, error: `a workflow named "${id}" is already installed \u2014 remove it first, or rename the file's app: id`, code: "exists", id });
|
|
76100
76127
|
}
|
|
76101
76128
|
await deleteOrigin(id);
|
|
76102
|
-
const stageRoot = (0,
|
|
76129
|
+
const stageRoot = (0, import_node_fs46.mkdtempSync)((0, import_node_path43.join)((0, import_node_os26.tmpdir)(), "floless-import-"));
|
|
76103
76130
|
try {
|
|
76104
|
-
const stageDir = (0,
|
|
76105
|
-
(0,
|
|
76106
|
-
(0,
|
|
76131
|
+
const stageDir = (0, import_node_path43.join)(stageRoot, id);
|
|
76132
|
+
(0, import_node_fs46.mkdirSync)(stageDir);
|
|
76133
|
+
(0, import_node_fs46.writeFileSync)((0, import_node_path43.join)(stageDir, `${id}.flo`), content);
|
|
76107
76134
|
await aware.install(stageDir);
|
|
76108
76135
|
} catch (err2) {
|
|
76109
76136
|
try {
|
|
@@ -76114,7 +76141,7 @@ async function startServer() {
|
|
|
76114
76141
|
const reason = awareStderr(err2);
|
|
76115
76142
|
return reply.status(502).send({ ok: false, error: `import failed: ${msg}`, code: "install-failed", reason, agentsUnavailable: unavailableAgents(reason) });
|
|
76116
76143
|
} finally {
|
|
76117
|
-
(0,
|
|
76144
|
+
(0, import_node_fs46.rmSync)(stageRoot, { recursive: true, force: true });
|
|
76118
76145
|
}
|
|
76119
76146
|
broadcast({ type: "apps-changed", id });
|
|
76120
76147
|
return { ok: true, id };
|
|
@@ -76129,13 +76156,13 @@ async function startServer() {
|
|
|
76129
76156
|
}
|
|
76130
76157
|
const inputs = appData.inputs.map((i) => ({ name: i.name, type: i.type }));
|
|
76131
76158
|
const baked = bakeFloSource(appData.source.text, inputs);
|
|
76132
|
-
const tmpRoot = (0,
|
|
76133
|
-
const backupDir2 = (0,
|
|
76134
|
-
const bakeDir = (0,
|
|
76135
|
-
(0,
|
|
76136
|
-
(0,
|
|
76159
|
+
const tmpRoot = (0, import_node_fs46.mkdtempSync)((0, import_node_path43.join)((0, import_node_os26.tmpdir)(), "floless-bake-"));
|
|
76160
|
+
const backupDir2 = (0, import_node_path43.join)(tmpRoot, `${id}-backup`);
|
|
76161
|
+
const bakeDir = (0, import_node_path43.join)(tmpRoot, id);
|
|
76162
|
+
(0, import_node_fs46.cpSync)(appDir(id), backupDir2, { recursive: true });
|
|
76163
|
+
(0, import_node_fs46.cpSync)(appDir(id), bakeDir, { recursive: true });
|
|
76137
76164
|
const floName = appData.source.path.split(/[\\/]/).pop();
|
|
76138
|
-
(0,
|
|
76165
|
+
(0, import_node_fs46.writeFileSync)((0, import_node_path43.join)(bakeDir, floName), baked);
|
|
76139
76166
|
let appInstalled2 = true;
|
|
76140
76167
|
try {
|
|
76141
76168
|
await aware.uninstall(id);
|
|
@@ -76157,17 +76184,17 @@ async function startServer() {
|
|
|
76157
76184
|
throw installErr;
|
|
76158
76185
|
}
|
|
76159
76186
|
try {
|
|
76160
|
-
await aware.compile((0,
|
|
76187
|
+
await aware.compile((0, import_node_path43.join)(appDir(id), floName));
|
|
76161
76188
|
} catch (compileErr) {
|
|
76162
76189
|
app.log.warn({ id, compileErr: String(compileErr) }, "bake: post-install recompile failed (app baked but may need a manual Compile)");
|
|
76163
76190
|
}
|
|
76164
76191
|
broadcast({ type: "baked", id });
|
|
76165
76192
|
return { ok: true, id, agent: id, inputs };
|
|
76166
76193
|
} finally {
|
|
76167
|
-
if (appInstalled2) (0,
|
|
76194
|
+
if (appInstalled2) (0, import_node_fs46.rmSync)(tmpRoot, { recursive: true, force: true });
|
|
76168
76195
|
}
|
|
76169
76196
|
});
|
|
76170
|
-
const graftAgentsDir = () => (0,
|
|
76197
|
+
const graftAgentsDir = () => (0, import_node_path43.join)((0, import_node_os26.homedir)(), ".aware", "agents");
|
|
76171
76198
|
app.post("/api/graft/match", async (req, reply) => {
|
|
76172
76199
|
const { glob } = req.body ?? {};
|
|
76173
76200
|
if (!glob) return reply.status(400).send({ ok: false, error: "glob required" });
|
|
@@ -76184,7 +76211,7 @@ async function startServer() {
|
|
|
76184
76211
|
if (!sourceKind || !sourceRef) {
|
|
76185
76212
|
return reply.status(400).send({ ok: false, error: "sourceKind and sourceRef required" });
|
|
76186
76213
|
}
|
|
76187
|
-
const tempHome = (0,
|
|
76214
|
+
const tempHome = (0, import_node_fs46.mkdtempSync)((0, import_node_path43.join)((0, import_node_os26.tmpdir)(), "floless-graft-"));
|
|
76188
76215
|
let result;
|
|
76189
76216
|
try {
|
|
76190
76217
|
result = await aware.build({
|
|
@@ -76197,19 +76224,19 @@ async function startServer() {
|
|
|
76197
76224
|
awareHome: tempHome
|
|
76198
76225
|
});
|
|
76199
76226
|
} catch (err2) {
|
|
76200
|
-
(0,
|
|
76227
|
+
(0, import_node_fs46.rmSync)(tempHome, { recursive: true, force: true });
|
|
76201
76228
|
const msg = err2 instanceof AwareError ? err2.message : String(err2?.message ?? err2);
|
|
76202
76229
|
return reply.status(422).send({ ok: false, error: msg });
|
|
76203
76230
|
}
|
|
76204
76231
|
const manifest = readStagedManifest(result.agentDir);
|
|
76205
76232
|
if (!manifest) {
|
|
76206
|
-
(0,
|
|
76233
|
+
(0, import_node_fs46.rmSync)(tempHome, { recursive: true, force: true });
|
|
76207
76234
|
return reply.status(502).send({ ok: false, error: `build produced output at ${result.agentDir} but no manifest.yaml` });
|
|
76208
76235
|
}
|
|
76209
76236
|
const token = (0, import_node_crypto20.randomUUID)();
|
|
76210
76237
|
registerStage(token, tempHome, result.agentId);
|
|
76211
76238
|
const preview2 = buildPreview(manifest, sourceKind, sourceRef, token);
|
|
76212
|
-
if ((0,
|
|
76239
|
+
if ((0, import_node_fs46.existsSync)((0, import_node_path43.join)(graftAgentsDir(), result.agentId))) {
|
|
76213
76240
|
preview2.warnings.unshift(`An agent named "${result.agentId}" is already installed \u2014 creating it will overwrite it.`);
|
|
76214
76241
|
}
|
|
76215
76242
|
return { ok: true, preview: preview2 };
|
|
@@ -76228,7 +76255,7 @@ async function startServer() {
|
|
|
76228
76255
|
registerStage(stagedRef, stage.tempDir, stage.agentId);
|
|
76229
76256
|
return reply.status(409).send({ ok: false, error: err2.message, agentId: stage.agentId, collision: true });
|
|
76230
76257
|
}
|
|
76231
|
-
(0,
|
|
76258
|
+
(0, import_node_fs46.rmSync)(stage.tempDir, { recursive: true, force: true });
|
|
76232
76259
|
throw err2;
|
|
76233
76260
|
}
|
|
76234
76261
|
broadcast({ type: "grafted", id: stage.agentId });
|
|
@@ -76545,11 +76572,11 @@ async function startServer() {
|
|
|
76545
76572
|
app.get("/api/requests/:id/snapshot/:n", async (req, reply) => {
|
|
76546
76573
|
const n = Number.parseInt(req.params.n, 10);
|
|
76547
76574
|
const p = Number.isInteger(n) ? snapshotPathFor(req.params.id, n) : null;
|
|
76548
|
-
if (!p || !(0,
|
|
76575
|
+
if (!p || !(0, import_node_fs46.existsSync)(p)) return reply.status(404).send({ ok: false, error: "snapshot not found" });
|
|
76549
76576
|
const ext = p.split(".").pop().toLowerCase();
|
|
76550
76577
|
reply.header("Content-Type", ext === "png" ? "image/png" : ext === "webp" ? "image/webp" : ext === "pdf" ? "application/pdf" : "image/jpeg");
|
|
76551
76578
|
reply.header("Cache-Control", "no-store");
|
|
76552
|
-
return (0,
|
|
76579
|
+
return (0, import_node_fs46.readFileSync)(p);
|
|
76553
76580
|
});
|
|
76554
76581
|
app.post(
|
|
76555
76582
|
"/api/tweak",
|
|
@@ -76776,7 +76803,7 @@ async function startServer() {
|
|
|
76776
76803
|
warn(`last-run-status:${ref} \u2014 trace exists but couldn't be parsed (corrupt/truncated)`);
|
|
76777
76804
|
let finishedAt2 = null;
|
|
76778
76805
|
try {
|
|
76779
|
-
finishedAt2 = (0,
|
|
76806
|
+
finishedAt2 = (0, import_node_fs46.statSync)(latest.path).mtime.toISOString();
|
|
76780
76807
|
} catch {
|
|
76781
76808
|
finishedAt2 = null;
|
|
76782
76809
|
}
|
|
@@ -76786,7 +76813,7 @@ async function startServer() {
|
|
|
76786
76813
|
let finishedAt = typeof runEnd?.ts === "string" ? runEnd.ts : null;
|
|
76787
76814
|
if (!finishedAt) {
|
|
76788
76815
|
try {
|
|
76789
|
-
finishedAt = (0,
|
|
76816
|
+
finishedAt = (0, import_node_fs46.statSync)(latest.path).mtime.toISOString();
|
|
76790
76817
|
} catch {
|
|
76791
76818
|
finishedAt = null;
|
|
76792
76819
|
}
|