@floless/app 0.106.0 → 0.107.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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: join40 } = require("path");
5492
+ var { join: join41 } = 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"] || join40(__dirname, "lib", "worker.js");
5543
+ const toExecute = bundlerOverrides["thread-stream-worker"] || join41(__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: existsSync36 } = require("node:fs");
6009
+ var { existsSync: existsSync37 } = require("node:fs");
6010
6010
  var getCallers = require_caller();
6011
- var { join: join40, isAbsolute: isAbsolute2, sep: sep6 } = require("node:path");
6011
+ var { join: join41, 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) && !existsSync36(path);
6083
+ return isAbsolute2(path) && !existsSync37(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"] || join40(__dirname, "worker.js");
6164
+ target = bundlerOverrides["pino-worker"] || join41(__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"] || join40(__dirname, "worker.js");
6182
+ target = bundlerOverrides["pino-worker"] || join41(__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 join40(__dirname, "..", "file.js");
6205
+ return join41(__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 join40 = ",";
7185
+ let join41 = ",";
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
- join40 = `,
7199
+ join41 = `,
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 += join40;
7207
+ res += join41;
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 += `${join40}"... ${getItemCount(removedKeys)} not stringified"`;
7213
+ res += `${join41}"... ${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
- join40 = `,
7234
+ join41 = `,
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 = join40;
7248
+ separator = join41;
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 = join40;
7254
+ separator = join41;
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 join40 = ",";
7295
+ let join41 = ",";
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
- join40 = `,
7308
+ join41 = `,
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 += join40;
7316
+ res += join41;
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 += `${join40}"... ${getItemCount(removedKeys)} not stringified"`;
7322
+ res += `${join41}"... ${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
- join40 = `,
7335
+ join41 = `,
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 = join40;
7344
+ separator = join41;
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 join41 = `,
7402
+ const join42 = `,
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 += join41;
7409
+ res2 += join42;
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 += `${join41}"... ${getItemCount(removedKeys)} not stringified"`;
7415
+ res2 += `${join42}"... ${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 join40 = `,
7431
+ const join41 = `,
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, join40, maximumBreadth);
7437
+ res += stringifyTypedArray(value, join41, maximumBreadth);
7438
7438
  keys = keys.slice(value.length);
7439
7439
  maximumPropertiesToStringify -= value.length;
7440
- separator = join40;
7440
+ separator = join41;
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 = join40;
7451
+ separator = join41;
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 = join40;
7457
+ separator = join41;
7458
7458
  }
7459
7459
  if (separator !== "") {
7460
7460
  res = `
@@ -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 join40 = path.join;
41994
+ var join41 = path.join;
41995
41995
  var normalize2 = path.normalize;
41996
41996
  var resolve11 = path.resolve;
41997
41997
  var sep6 = path.sep;
@@ -42078,7 +42078,7 @@ var require_send = __commonJS({
42078
42078
  return { statusCode: 403 };
42079
42079
  }
42080
42080
  parts = path2.split(sep6);
42081
- path2 = normalize2(join40(root3, path2));
42081
+ path2 = normalize2(join41(root3, 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 = join40(path2, index);
42364
+ const p = join41(path2, index);
42365
42365
  const { error, stat: stat4 } = await tryStat(p);
42366
42366
  if (error) {
42367
42367
  err2 = error;
@@ -43012,7 +43012,7 @@ var require_static = __commonJS({
43012
43012
  "use strict";
43013
43013
  var path = require("node:path");
43014
43014
  var { fileURLToPath: fileURLToPath6 } = require("node:url");
43015
- var { statSync: statSync16 } = require("node:fs");
43015
+ var { statSync: statSync17 } = require("node:fs");
43016
43016
  var { glob } = require_commonjs6();
43017
43017
  var fp = require_plugin2();
43018
43018
  var send = require_send2();
@@ -43375,7 +43375,7 @@ var require_static = __commonJS({
43375
43375
  }
43376
43376
  let pathStat;
43377
43377
  try {
43378
- pathStat = statSync16(rootPath);
43378
+ pathStat = statSync17(rootPath);
43379
43379
  } catch (e) {
43380
43380
  if (e.code === "ENOENT") {
43381
43381
  fastify.log.warn(`"root" path "${rootPath}" must exist`);
@@ -43399,7 +43399,7 @@ var require_static = __commonJS({
43399
43399
  return indexFiles.find((filename) => {
43400
43400
  const p = path.join(root3, pathname, filename);
43401
43401
  try {
43402
- const stats = statSync16(p);
43402
+ const stats = statSync17(p);
43403
43403
  return !stats.isDirectory();
43404
43404
  } catch {
43405
43405
  return false;
@@ -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 import_node_path41 = require("node:path");
50831
- var import_node_os24 = require("node:os");
50832
- var import_node_fs44 = require("node:fs");
50830
+ var import_node_path42 = require("node:path");
50831
+ var import_node_os25 = require("node:os");
50832
+ var import_node_fs45 = require("node:fs");
50833
50833
  var import_node_child_process9 = require("node:child_process");
50834
50834
 
50835
50835
  // log.mjs
@@ -52108,8 +52108,8 @@ function runRawWithEnv(args, env2, timeoutMs) {
52108
52108
  });
52109
52109
  });
52110
52110
  }
52111
- async function runJson(args) {
52112
- const { code, stdout, stderr } = await runRaw([...args, "--json"]);
52111
+ async function runJson(args, timeoutMs) {
52112
+ const { code, stdout, stderr } = await runRawWithEnv([...args, "--json"], void 0, timeoutMs);
52113
52113
  let env2;
52114
52114
  try {
52115
52115
  env2 = JSON.parse(stdout);
@@ -52648,7 +52648,7 @@ var aware = {
52648
52648
  * SHELL_META) and a large descriptor could blow cmd.exe's argv limit. Throws
52649
52649
  * AwareUnsupportedError on a pre-0.63 CLI so callers can degrade ("update AWARE").
52650
52650
  */
52651
- async agentInvoke(agent, command, inputs) {
52651
+ async agentInvoke(agent, command, inputs, opts = {}) {
52652
52652
  let inputsFile = null;
52653
52653
  try {
52654
52654
  let ref;
@@ -52657,7 +52657,7 @@ var aware = {
52657
52657
  (0, import_node_fs7.writeFileSync)(inputsFile, JSON.stringify(inputs));
52658
52658
  ref = `@${inputsFile}`;
52659
52659
  }
52660
- const { data } = await runJson(agentInvokeArgv(agent, command, ref));
52660
+ const { data } = await runJson(agentInvokeArgv(agent, command, ref), opts.timeoutMs);
52661
52661
  return data;
52662
52662
  } catch (err2) {
52663
52663
  if (err2 instanceof AwareError && isInvokeUnsupported(err2.detail)) {
@@ -53633,7 +53633,7 @@ function appVersion() {
53633
53633
  return resolveVersion({
53634
53634
  isSea: isSea2(),
53635
53635
  sqVersionXml: readSqVersionXml(),
53636
- define: true ? "0.106.0" : void 0,
53636
+ define: true ? "0.107.0" : void 0,
53637
53637
  pkgVersion: readPkgVersion()
53638
53638
  });
53639
53639
  }
@@ -53643,7 +53643,7 @@ function resolveChannel(s) {
53643
53643
  return "dev";
53644
53644
  }
53645
53645
  function appChannel() {
53646
- return resolveChannel({ isSea: isSea2(), define: true ? "0.106.0" : void 0 });
53646
+ return resolveChannel({ isSea: isSea2(), define: true ? "0.107.0" : void 0 });
53647
53647
  }
53648
53648
 
53649
53649
  // workflow-update.ts
@@ -54836,7 +54836,7 @@ function extractReportHtml(events) {
54836
54836
  var import_node_child_process4 = require("node:child_process");
54837
54837
  var import_node_fs14 = require("node:fs");
54838
54838
  var import_node_path13 = require("node:path");
54839
- var OPEN_EXTS = /* @__PURE__ */ new Set([".xls", ".xlsx", ".html", ".htm", ".csv", ".svg"]);
54839
+ var OPEN_EXTS = /* @__PURE__ */ new Set([".xls", ".xlsx", ".html", ".htm", ".csv", ".svg", ".png", ".mp4"]);
54840
54840
  var REVEAL_EXTS = /* @__PURE__ */ new Set([...OPEN_EXTS, ".ifc", ".nc1", ".dstv"]);
54841
54841
  function hasOpenableExt(path) {
54842
54842
  return OPEN_EXTS.has((0, import_node_path13.extname)(path).toLowerCase());
@@ -54846,13 +54846,13 @@ function validateOpenable(path, mode = "open") {
54846
54846
  if (path.includes("%")) return { ok: false, error: "unsupported file path" };
54847
54847
  const allowed = mode === "reveal" ? REVEAL_EXTS.has((0, import_node_path13.extname)(path).toLowerCase()) : hasOpenableExt(path);
54848
54848
  if (!allowed) return { ok: false, error: "unsupported file type" };
54849
- let isFile = false;
54849
+ let isFile2 = false;
54850
54850
  try {
54851
- isFile = (0, import_node_fs14.existsSync)(path) && (0, import_node_fs14.statSync)(path).isFile();
54851
+ isFile2 = (0, import_node_fs14.existsSync)(path) && (0, import_node_fs14.statSync)(path).isFile();
54852
54852
  } catch {
54853
- isFile = false;
54853
+ isFile2 = false;
54854
54854
  }
54855
- if (!isFile) return { ok: false, error: "file not found" };
54855
+ if (!isFile2) return { ok: false, error: "file not found" };
54856
54856
  return { ok: true, path };
54857
54857
  }
54858
54858
  function openFileCommand(path, platform = process.platform) {
@@ -62434,7 +62434,9 @@ function projectExportFiles(appId, kindOf2 = appId) {
62434
62434
  return [
62435
62435
  { kind: "bom-csv", filename: `${appId}-bom.csv` },
62436
62436
  { kind: "bom-xlsx", filename: `${appId}-bom.xlsx` },
62437
- { kind: "ifc", filename: `${appId}.ifc` }
62437
+ { kind: "ifc", filename: `${appId}.ifc` },
62438
+ { kind: "render-png", filename: `${appId}-render.png` },
62439
+ { kind: "render-mp4", filename: `${appId}-turntable.mp4` }
62438
62440
  ];
62439
62441
  }
62440
62442
  function sanitizeExportName(name) {
@@ -62485,7 +62487,9 @@ var EXTENSIONS = {
62485
62487
  "bom-csv": ".csv",
62486
62488
  "bom-xlsx": ".xlsx",
62487
62489
  ifc: ".ifc",
62488
- svg: ".svg"
62490
+ svg: ".svg",
62491
+ "render-png": ".png",
62492
+ "render-mp4": ".mp4"
62489
62493
  };
62490
62494
  var RESERVED2 = /^\.floless-(?:txn|cleanup|tmp|backup)-/i;
62491
62495
  var projectExportIndexPath = (projectId) => (0, import_node_path25.join)(projectExportsDir(projectId), "index.json");
@@ -62505,12 +62509,22 @@ function validReceiptFilename(kind, filename) {
62505
62509
  if (!isPortablePlainFilename(filename) || filename === "index.json" || RESERVED2.test(filename) || (0, import_node_path25.basename)(filename) !== filename) return false;
62506
62510
  return filename.toLowerCase().endsWith(EXTENSIONS[kind]);
62507
62511
  }
62512
+ function isExportKind(v) {
62513
+ return typeof v === "string" && Object.prototype.hasOwnProperty.call(EXTENSIONS, v);
62514
+ }
62515
+ var VARIANT = /^[a-z0-9][a-z0-9-]{0,31}$/;
62516
+ function isValidVariant(v) {
62517
+ return v === void 0 || typeof v === "string" && VARIANT.test(v);
62518
+ }
62519
+ function receiptKey(kind, variant) {
62520
+ return `${kind}\0${variant ?? ""}`;
62521
+ }
62508
62522
  function isReceipt(v) {
62509
62523
  if (!v || typeof v !== "object" || Array.isArray(v)) return false;
62510
62524
  const r = v;
62511
62525
  const kind = r.kind;
62512
- if (kind !== "bom-csv" && kind !== "bom-xlsx" && kind !== "ifc" && kind !== "svg") return false;
62513
- return typeof r.filename === "string" && validReceiptFilename(kind, r.filename) && typeof r.exportId === "string" && !!r.exportId.trim() && typeof r.exportedAt === "string" && Number.isFinite(Date.parse(r.exportedAt)) && typeof r.bytes === "number" && Number.isSafeInteger(r.bytes) && r.bytes >= 0 && typeof r.version === "number" && Number.isSafeInteger(r.version) && r.version > 0 && typeof r.contractHash === "string" && /^[a-f0-9]{64}$/i.test(r.contractHash) && (r.encoding === void 0 || r.encoding === "utf8" || r.encoding === "base64");
62526
+ if (!isExportKind(kind)) return false;
62527
+ return isValidVariant(r.variant) && typeof r.filename === "string" && validReceiptFilename(kind, r.filename) && typeof r.exportId === "string" && !!r.exportId.trim() && typeof r.exportedAt === "string" && Number.isFinite(Date.parse(r.exportedAt)) && typeof r.bytes === "number" && Number.isSafeInteger(r.bytes) && r.bytes >= 0 && typeof r.version === "number" && Number.isSafeInteger(r.version) && r.version > 0 && typeof r.contractHash === "string" && /^[a-f0-9]{64}$/i.test(r.contractHash) && (r.encoding === void 0 || r.encoding === "utf8" || r.encoding === "base64");
62514
62528
  }
62515
62529
  function validateInput(receipt) {
62516
62530
  if (!validReceiptFilename(receipt.kind, receipt.filename)) {
@@ -62527,6 +62541,11 @@ function validateInput(receipt) {
62527
62541
  if (!/^[a-f0-9]{64}$/i.test(receipt.contractHash)) {
62528
62542
  throw new ProjectExportReceiptError("export receipt contractHash must be a SHA-256 hex digest.");
62529
62543
  }
62544
+ if (!isValidVariant(receipt.variant)) {
62545
+ throw new ProjectExportReceiptError(
62546
+ `invalid export receipt variant ${JSON.stringify(receipt.variant)}; expected a short lowercase slug.`
62547
+ );
62548
+ }
62530
62549
  }
62531
62550
  function parseIndexBytes(bytes) {
62532
62551
  let parsed;
@@ -62541,20 +62560,42 @@ function parseIndexBytes(bytes) {
62541
62560
  throw new ProjectExportReceiptError("project export index must be an object.");
62542
62561
  }
62543
62562
  const exportsValue = parsed.exports;
62544
- if (!Array.isArray(exportsValue) || !exportsValue.every(isReceipt)) {
62563
+ if (!Array.isArray(exportsValue)) {
62545
62564
  throw new ProjectExportReceiptError("project export index contains an invalid receipt.");
62546
62565
  }
62547
- const kinds = /* @__PURE__ */ new Set();
62548
- for (const receipt of exportsValue) {
62549
- if (kinds.has(receipt.kind)) {
62550
- throw new ProjectExportReceiptError(`project export index contains duplicate "${receipt.kind}" receipts.`);
62566
+ const kept = [];
62567
+ const opaque = [];
62568
+ const seen = /* @__PURE__ */ new Set();
62569
+ const dropped = [];
62570
+ for (const row of exportsValue) {
62571
+ const kind = row?.kind;
62572
+ if (!isExportKind(kind)) {
62573
+ dropped.push(`unknown kind ${JSON.stringify(kind)}`);
62574
+ opaque.push(row);
62575
+ continue;
62576
+ }
62577
+ if (!isReceipt(row)) {
62578
+ throw new ProjectExportReceiptError("project export index contains an invalid receipt.");
62579
+ }
62580
+ const key = receiptKey(row.kind, row.variant);
62581
+ if (seen.has(key)) {
62582
+ dropped.push(`duplicate "${key.trim()}"`);
62583
+ opaque.push(row);
62584
+ continue;
62551
62585
  }
62552
- kinds.add(receipt.kind);
62586
+ seen.add(key);
62587
+ kept.push(row);
62588
+ }
62589
+ if (dropped.length) {
62590
+ console.warn(
62591
+ `project export index: ignored ${dropped.length} unreadable receipt(s) \u2014 ${dropped.join(", ")}`
62592
+ );
62553
62593
  }
62554
- return { exports: exportsValue };
62594
+ return { exports: kept, opaque };
62555
62595
  }
62556
62596
  function indexBytes(body) {
62557
- return Buffer.from(`${JSON.stringify(body, null, 2)}
62597
+ const exports2 = [...body.exports, ...body.opaque];
62598
+ return Buffer.from(`${JSON.stringify({ exports: exports2 }, null, 2)}
62558
62599
  `, "utf8");
62559
62600
  }
62560
62601
  function syncFile(path) {
@@ -62595,7 +62636,7 @@ function durableReplace(path, bytes) {
62595
62636
  }
62596
62637
  function strictCurrent(projectId) {
62597
62638
  const path = projectExportIndexPath(projectId);
62598
- if (!(0, import_node_fs27.existsSync)(path)) return { bytes: null, body: { exports: [] } };
62639
+ if (!(0, import_node_fs27.existsSync)(path)) return { bytes: null, body: { exports: [], opaque: [] } };
62599
62640
  const bytes = (0, import_node_fs27.readFileSync)(path);
62600
62641
  return { bytes, body: parseIndexBytes(bytes) };
62601
62642
  }
@@ -62617,15 +62658,35 @@ function prepareProjectExport(projectId, receipt) {
62617
62658
  const dir = projectExportsDir(projectId);
62618
62659
  (0, import_node_fs27.mkdirSync)(dir, { recursive: true });
62619
62660
  const current = strictCurrent(projectId);
62620
- const prior = current.body.exports.find((row) => row.kind === receipt.kind) ?? null;
62661
+ const key = receiptKey(receipt.kind, receipt.variant);
62662
+ const prior = current.body.exports.find((row) => receiptKey(row.kind, row.variant) === key) ?? null;
62663
+ const rest = current.body.exports.filter((row) => receiptKey(row.kind, row.variant) !== key);
62664
+ const clash = rest.find((row) => row.filename === receipt.filename);
62665
+ if (clash) {
62666
+ throw new ProjectExportReceiptError(
62667
+ `export filename "${receipt.filename}" is already held by the "${receiptKey(clash.kind, clash.variant).trim()}" receipt.`
62668
+ );
62669
+ }
62670
+ if (current.body.opaque.some((row) => row?.filename === receipt.filename)) {
62671
+ throw new ProjectExportReceiptError(
62672
+ `export filename "${receipt.filename}" is already held by a receipt this version cannot read.`
62673
+ );
62674
+ }
62621
62675
  const next = {
62622
62676
  ...receipt,
62623
- exportId: `${receipt.version}-${receipt.kind}-${receipt.contractHash.slice(0, 12)}`,
62677
+ exportId: [receipt.version, receipt.kind, receipt.variant, receipt.contractHash.slice(0, 12)].filter(Boolean).join("-"),
62624
62678
  exportedAt: (/* @__PURE__ */ new Date()).toISOString()
62625
62679
  };
62626
- const rest = current.body.exports.filter((row) => row.kind !== receipt.kind);
62627
62680
  const afterBytes = indexBytes({
62628
- exports: [...rest, next].sort((a, b) => a.kind.localeCompare(b.kind))
62681
+ exports: [...rest, next].sort((a, b) => {
62682
+ const ka = receiptKey(a.kind, a.variant);
62683
+ const kb = receiptKey(b.kind, b.variant);
62684
+ return ka < kb ? -1 : ka > kb ? 1 : 0;
62685
+ }),
62686
+ // Carried, not dropped. `before` proves the ORIGINAL bytes and the CAS compares against them,
62687
+ // so building `after` from the filtered set would let the commit succeed while quietly deleting
62688
+ // every row this build could not read.
62689
+ opaque: current.body.opaque
62629
62690
  });
62630
62691
  return {
62631
62692
  projectId,
@@ -62675,6 +62736,15 @@ function restoreProjectExportTransition(transition) {
62675
62736
  function cleanupSupersededProjectExport(transition) {
62676
62737
  const superseded = transition.superseded;
62677
62738
  if (!superseded || superseded.filename === transition.next.filename) return;
62739
+ let stillReferenced = listProjectExportReceipts(transition.projectId).some((row) => row.filename === superseded.filename);
62740
+ if (!stillReferenced) {
62741
+ try {
62742
+ stillReferenced = strictCurrent(transition.projectId).body.opaque.some((row) => row?.filename === superseded.filename);
62743
+ } catch {
62744
+ stillReferenced = true;
62745
+ }
62746
+ }
62747
+ if (stillReferenced) return;
62678
62748
  const path = resolveProjectExportReceiptPath(transition.projectId, superseded);
62679
62749
  if (!path) return;
62680
62750
  try {
@@ -62771,7 +62841,14 @@ function currentApprovedSnapshot(projectId, version) {
62771
62841
  // workspace-data.ts
62772
62842
  var import_node_fs28 = require("node:fs");
62773
62843
  var VALID_INCLUDES = /* @__PURE__ */ new Set(["contract", "exports"]);
62774
- var VALID_EXPORT_KINDS = /* @__PURE__ */ new Set(["bom-csv", "bom-xlsx", "ifc", "svg"]);
62844
+ var VALID_EXPORT_KINDS = /* @__PURE__ */ new Set([
62845
+ "bom-csv",
62846
+ "bom-xlsx",
62847
+ "ifc",
62848
+ "svg",
62849
+ "render-png",
62850
+ "render-mp4"
62851
+ ]);
62775
62852
  var DEFAULT_MAX_BYTES = 1024 * 1024;
62776
62853
  function sendError(reply, status, error) {
62777
62854
  return reply.status(status).send({ ok: false, error });
@@ -62807,6 +62884,11 @@ function exportBody(projectId, receipt, opts) {
62807
62884
  if (!path) throw new Error(`invalid project export receipt path: ${receipt.filename}`);
62808
62885
  const body = {
62809
62886
  kind: receipt.kind,
62887
+ // A kind can now hold several artifacts — one render per viewpoint. Without the variant a
62888
+ // workflow asking for `render-png` receives rows it cannot tell apart, and picking "the hero
62889
+ // one" would mean parsing it back out of the filename. Omitted entirely for the single-artifact
62890
+ // kinds, so nothing gains an always-undefined field.
62891
+ ...receipt.variant ? { variant: receipt.variant } : {},
62810
62892
  filename: receipt.filename,
62811
62893
  exportId: receipt.exportId,
62812
62894
  exportedAt: receipt.exportedAt,
@@ -69911,6 +69993,154 @@ async function teklaReadiness(deps = DEFAULT_DEPS) {
69911
69993
  }
69912
69994
  }
69913
69995
 
69996
+ // render-readiness.ts
69997
+ var import_node_fs35 = require("node:fs");
69998
+ var import_node_path31 = require("node:path");
69999
+ var import_node_os18 = require("node:os");
70000
+ var RENDER_AWARE_FLOOR = "0.103.0";
70001
+ var RENDER_AGENT_ID = "blender";
70002
+ function isFile(path) {
70003
+ try {
70004
+ return (0, import_node_fs35.existsSync)(path) && (0, import_node_fs35.statSync)(path).isFile();
70005
+ } catch {
70006
+ return false;
70007
+ }
70008
+ }
70009
+ function lookupOnPath(command, env2) {
70010
+ const path = env2.PATH ?? env2.Path;
70011
+ if (!path) return null;
70012
+ for (const dir of path.split(import_node_path31.delimiter)) {
70013
+ if (!dir) continue;
70014
+ const candidate = (0, import_node_path31.join)(dir, command);
70015
+ if (isFile(candidate)) return candidate;
70016
+ }
70017
+ return null;
70018
+ }
70019
+ function compareVersionParts(a, b) {
70020
+ for (let i = 0; i < Math.max(a.length, b.length); i += 1) {
70021
+ const diff = (a[i] ?? 0) - (b[i] ?? 0);
70022
+ if (diff !== 0) return diff;
70023
+ }
70024
+ return 0;
70025
+ }
70026
+ function windowsCandidates(env2) {
70027
+ const roots = [];
70028
+ for (const variable of ["ProgramFiles", "ProgramW6432", "ProgramFiles(x86)"]) {
70029
+ const value = env2[variable];
70030
+ if (!value) continue;
70031
+ const root3 = (0, import_node_path31.join)(value, "Blender Foundation");
70032
+ if (!roots.includes(root3)) roots.push(root3);
70033
+ }
70034
+ const found = [];
70035
+ for (const root3 of roots) {
70036
+ let entries;
70037
+ try {
70038
+ entries = (0, import_node_fs35.readdirSync)(root3);
70039
+ } catch {
70040
+ continue;
70041
+ }
70042
+ for (const name of entries) {
70043
+ const match = /^Blender\s+(\d+(?:\.\d+)*)$/i.exec(name);
70044
+ if (!match) continue;
70045
+ const binary = (0, import_node_path31.join)(root3, name, "blender.exe");
70046
+ if (isFile(binary)) {
70047
+ found.push({ version: match[1].split(".").map(Number), name, binary });
70048
+ }
70049
+ }
70050
+ }
70051
+ found.sort((a, b) => compareVersionParts(b.version, a.version) || b.name.localeCompare(a.name));
70052
+ return found.map((row) => row.binary);
70053
+ }
70054
+ function platformDefaults(env2, isWin3) {
70055
+ if (isWin3) return windowsCandidates(env2);
70056
+ if (process.platform === "darwin") {
70057
+ return [
70058
+ "/Applications/Blender.app/Contents/MacOS/Blender",
70059
+ (0, import_node_path31.join)((0, import_node_os18.homedir)(), "Applications/Blender.app/Contents/MacOS/Blender")
70060
+ ];
70061
+ }
70062
+ return ["/usr/bin/blender", "/usr/local/bin/blender", "/snap/bin/blender"];
70063
+ }
70064
+ function findBlender(env2 = process.env) {
70065
+ const isWin3 = process.platform === "win32";
70066
+ const override = env2.AWARE_BLENDER?.trim();
70067
+ if (override) {
70068
+ return isFile(override) ? override : null;
70069
+ }
70070
+ const onPath = lookupOnPath(isWin3 ? "blender.exe" : "blender", env2);
70071
+ if (onPath) return onPath;
70072
+ for (const candidate of platformDefaults(env2, isWin3)) {
70073
+ if (isFile(candidate)) return candidate;
70074
+ }
70075
+ return null;
70076
+ }
70077
+ var DEFAULT_DEPS2 = {
70078
+ npmVersion: () => aware.npmVersion(),
70079
+ installedAgentIds: async () => (await aware.agentList()).map((row) => row.id),
70080
+ locateBlender: () => findBlender()
70081
+ };
70082
+ async function renderReadiness(deps = DEFAULT_DEPS2) {
70083
+ try {
70084
+ const version = deps.npmVersion();
70085
+ const current = !!version && compareSemver(version, RENDER_AWARE_FLOOR) >= 0;
70086
+ const base = {
70087
+ aware: { version, floor: RENDER_AWARE_FLOOR, current },
70088
+ agent: { installed: false },
70089
+ blender: { present: false, path: null }
70090
+ };
70091
+ if (!current) {
70092
+ return {
70093
+ ...base,
70094
+ ok: false,
70095
+ state: "aware-update-required",
70096
+ message: `AWARE ${RENDER_AWARE_FLOOR} or newer is required to render images.`,
70097
+ recovery: { action: "update-aware", label: "Update AWARE" }
70098
+ };
70099
+ }
70100
+ const installed = (await deps.installedAgentIds()).includes(RENDER_AGENT_ID);
70101
+ if (!installed) {
70102
+ return {
70103
+ ...base,
70104
+ ok: false,
70105
+ state: "agent-missing",
70106
+ message: "The Blender agent is not installed yet.",
70107
+ recovery: { action: "install-agent", label: "Install agent" }
70108
+ };
70109
+ }
70110
+ const blenderPath = deps.locateBlender();
70111
+ if (!blenderPath) {
70112
+ const override = process.env.AWARE_BLENDER?.trim();
70113
+ return {
70114
+ ...base,
70115
+ agent: { installed: true },
70116
+ ok: false,
70117
+ state: "blender-missing",
70118
+ message: override ? `AWARE_BLENDER is set to "${override}", but no file is readable there.` : "Blender was not found on this computer. It is a free download.",
70119
+ recovery: override ? { action: "retry", label: "Check again" } : { action: "install-blender", label: "How to install" }
70120
+ };
70121
+ }
70122
+ return {
70123
+ ...base,
70124
+ agent: { installed: true },
70125
+ blender: { present: true, path: blenderPath },
70126
+ ok: true,
70127
+ state: "ready",
70128
+ message: "Ready to render.",
70129
+ recovery: null
70130
+ };
70131
+ } catch (error) {
70132
+ return {
70133
+ ok: false,
70134
+ state: "error",
70135
+ message: error instanceof Error ? error.message : "Could not check whether rendering is available.",
70136
+ recovery: { action: "retry", label: "Check again" },
70137
+ aware: { version: null, floor: RENDER_AWARE_FLOOR, current: false },
70138
+ agent: { installed: false },
70139
+ blender: { present: false, path: null }
70140
+ };
70141
+ }
70142
+ }
70143
+
69914
70144
  // downstream-bake.ts
69915
70145
  async function bakeDownstream(sourcePath, appId, contract) {
69916
70146
  const { scene } = contractToScene(contract);
@@ -69935,20 +70165,20 @@ async function bakeDownstream(sourcePath, appId, contract) {
69935
70165
  }
69936
70166
 
69937
70167
  // app-lifecycle.ts
70168
+ var import_node_fs38 = require("node:fs");
70169
+ var import_node_os20 = require("node:os");
70170
+ var import_node_path34 = require("node:path");
70171
+
70172
+ // routines.ts
69938
70173
  var import_node_fs37 = require("node:fs");
69939
- var import_node_os19 = require("node:os");
69940
70174
  var import_node_path33 = require("node:path");
69941
70175
 
69942
- // routines.ts
70176
+ // trigger-sessions.ts
69943
70177
  var import_node_fs36 = require("node:fs");
70178
+ var import_node_os19 = require("node:os");
69944
70179
  var import_node_path32 = require("node:path");
69945
-
69946
- // trigger-sessions.ts
69947
- var import_node_fs35 = require("node:fs");
69948
- var import_node_os18 = require("node:os");
69949
- var import_node_path31 = require("node:path");
69950
70180
  var import_yaml9 = __toESM(require_dist6(), 1);
69951
- var AGENTS_DIR2 = process.env.AWARE_HOME ? (0, import_node_path31.join)(process.env.AWARE_HOME, "agents") : (0, import_node_path31.join)((0, import_node_os18.homedir)(), ".aware", "agents");
70181
+ var AGENTS_DIR2 = process.env.AWARE_HOME ? (0, import_node_path32.join)(process.env.AWARE_HOME, "agents") : (0, import_node_path32.join)((0, import_node_os19.homedir)(), ".aware", "agents");
69952
70182
  function summarizeFire(data) {
69953
70183
  if (!data) return "event";
69954
70184
  const type = typeof data.type === "string" ? data.type : "";
@@ -69965,10 +70195,10 @@ function mapTriggerState(phase) {
69965
70195
  function isHostBacked(agent, agentsDir = AGENTS_DIR2) {
69966
70196
  const safe2 = (n) => !n.includes("/") && !n.includes("\\") && !n.includes("..");
69967
70197
  if (!safe2(agent)) return false;
69968
- const manifestPath2 = (0, import_node_path31.join)(agentsDir, agent, "manifest.yaml");
69969
- if (!(0, import_node_fs35.existsSync)(manifestPath2)) return false;
70198
+ const manifestPath2 = (0, import_node_path32.join)(agentsDir, agent, "manifest.yaml");
70199
+ if (!(0, import_node_fs36.existsSync)(manifestPath2)) return false;
69970
70200
  try {
69971
- const doc = (0, import_yaml9.parse)((0, import_node_fs35.readFileSync)(manifestPath2, "utf8"));
70201
+ const doc = (0, import_yaml9.parse)((0, import_node_fs36.readFileSync)(manifestPath2, "utf8"));
69972
70202
  const transport = doc?.transport;
69973
70203
  return !!(transport && typeof transport === "object" && "cli" in transport);
69974
70204
  } catch {
@@ -70253,7 +70483,7 @@ var RoutineError = class extends Error {
70253
70483
  }
70254
70484
  status;
70255
70485
  };
70256
- var ROUTINES_FILE = (0, import_node_path32.join)(flolessRoot, "routines.json");
70486
+ var ROUTINES_FILE = (0, import_node_path33.join)(flolessRoot, "routines.json");
70257
70487
  var routines = [];
70258
70488
  var loaded = false;
70259
70489
  function ensureLoaded() {
@@ -70289,10 +70519,10 @@ function sanitizeRoutine(raw) {
70289
70519
  };
70290
70520
  }
70291
70521
  function loadFromDisk() {
70292
- if (!(0, import_node_fs36.existsSync)(ROUTINES_FILE)) return [];
70522
+ if (!(0, import_node_fs37.existsSync)(ROUTINES_FILE)) return [];
70293
70523
  let text2;
70294
70524
  try {
70295
- text2 = (0, import_node_fs36.readFileSync)(ROUTINES_FILE, "utf8");
70525
+ text2 = (0, import_node_fs37.readFileSync)(ROUTINES_FILE, "utf8");
70296
70526
  } catch {
70297
70527
  return [];
70298
70528
  }
@@ -70301,17 +70531,17 @@ function loadFromDisk() {
70301
70531
  return Array.isArray(parsed) ? parsed.map(sanitizeRoutine).filter((r) => r !== null) : [];
70302
70532
  } catch {
70303
70533
  try {
70304
- (0, import_node_fs36.renameSync)(ROUTINES_FILE, `${ROUTINES_FILE}.corrupt-${Date.now()}`);
70534
+ (0, import_node_fs37.renameSync)(ROUTINES_FILE, `${ROUTINES_FILE}.corrupt-${Date.now()}`);
70305
70535
  } catch {
70306
70536
  }
70307
70537
  return [];
70308
70538
  }
70309
70539
  }
70310
70540
  function saveRoutines() {
70311
- if (!(0, import_node_fs36.existsSync)(flolessRoot)) (0, import_node_fs36.mkdirSync)(flolessRoot, { recursive: true });
70541
+ if (!(0, import_node_fs37.existsSync)(flolessRoot)) (0, import_node_fs37.mkdirSync)(flolessRoot, { recursive: true });
70312
70542
  const tmp = `${ROUTINES_FILE}.${process.pid}.tmp`;
70313
- (0, import_node_fs36.writeFileSync)(tmp, JSON.stringify(routines, null, 2));
70314
- (0, import_node_fs36.renameSync)(tmp, ROUTINES_FILE);
70543
+ (0, import_node_fs37.writeFileSync)(tmp, JSON.stringify(routines, null, 2));
70544
+ (0, import_node_fs37.renameSync)(tmp, ROUTINES_FILE);
70315
70545
  }
70316
70546
  function listRoutines() {
70317
70547
  ensureLoaded();
@@ -70719,13 +70949,13 @@ var AppLifecycleError = class extends Error {
70719
70949
  }
70720
70950
  };
70721
70951
  function appsDir() {
70722
- return process.env.AWARE_HOME ? (0, import_node_path33.join)(process.env.AWARE_HOME, "apps") : (0, import_node_path33.join)((0, import_node_os19.homedir)(), ".aware", "apps");
70952
+ return process.env.AWARE_HOME ? (0, import_node_path34.join)(process.env.AWARE_HOME, "apps") : (0, import_node_path34.join)((0, import_node_os20.homedir)(), ".aware", "apps");
70723
70953
  }
70724
70954
  function appDirPath(id) {
70725
- return (0, import_node_path33.join)(appsDir(), id);
70955
+ return (0, import_node_path34.join)(appsDir(), id);
70726
70956
  }
70727
70957
  function appInstalled(id) {
70728
- return APP_ID3.test(id) && (0, import_node_fs37.existsSync)(appDirPath(id));
70958
+ return APP_ID3.test(id) && (0, import_node_fs38.existsSync)(appDirPath(id));
70729
70959
  }
70730
70960
  function logCascade(what, e) {
70731
70961
  console.error(`[app-lifecycle] cascade step failed (${what}):`, e instanceof Error ? e.message : e);
@@ -70874,7 +71104,11 @@ var AWARE_ROUTES = [
70874
71104
  "/api/graft",
70875
71105
  "/api/run",
70876
71106
  "/api/debug",
70877
- "/api/tekla-readiness"
71107
+ "/api/tekla-readiness",
71108
+ // Mirrors /api/tekla-readiness. `/api/render/readiness` shells `aware agent list` and fires
71109
+ // automatically on every Exports-tab open — not only on a deliberate click — and
71110
+ // `/api/render/install-agent` shells `aware agent install`. Both must wait for bootstrap.
71111
+ "/api/render"
70878
71112
  ];
70879
71113
  var GATE_EXEMPT = /* @__PURE__ */ new Set(["/api/run/stop"]);
70880
71114
  var GATE_EXEMPT_PREFIXES = ["/api/bootstrap/"];
@@ -70890,16 +71124,19 @@ function isGatedAwareRoute(url, method) {
70890
71124
  if (path === "/api/trigger-run") return m === "POST";
70891
71125
  if (path.startsWith("/api/app/")) return m === "PATCH" || m === "POST" || m === "DELETE";
70892
71126
  if (path.startsWith("/api/contract/")) {
70893
- return m === "POST" && (path.endsWith("/approve") || path.endsWith("/export-3d") || path.endsWith("/export-ifc") || path.endsWith("/export-tekla"));
71127
+ return m === "POST" && (path.endsWith("/approve") || path.endsWith("/export-3d") || path.endsWith("/export-ifc") || path.endsWith("/export-tekla") || // `aware agent invoke` twice (ifc/write then the blender render). The `m === 'POST'` test
71128
+ // above is what keeps the `render-preview` GET out of here — that one only reads a file
71129
+ // off disk and must stay available while AWARE is still installing.
71130
+ path.endsWith("/render"));
70894
71131
  }
70895
71132
  return AWARE_ROUTES.some((p) => path.startsWith(p));
70896
71133
  }
70897
71134
 
70898
71135
  // autostart.mjs
70899
71136
  var import_node_child_process6 = require("node:child_process");
70900
- var import_node_fs38 = require("node:fs");
70901
- var import_node_os20 = require("node:os");
70902
- var import_node_path34 = require("node:path");
71137
+ var import_node_fs39 = require("node:fs");
71138
+ var import_node_os21 = require("node:os");
71139
+ var import_node_path35 = require("node:path");
70903
71140
 
70904
71141
  // teardown.mjs
70905
71142
  var RUN_KEY = "HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Run";
@@ -71011,8 +71248,8 @@ function removeLegacyRunKey() {
71011
71248
  }
71012
71249
  function logLine(msg) {
71013
71250
  try {
71014
- (0, import_node_fs38.mkdirSync)(logDir(), { recursive: true });
71015
- (0, import_node_fs38.appendFileSync)(logFilePath(), `${(/* @__PURE__ */ new Date()).toISOString()} ${msg}
71251
+ (0, import_node_fs39.mkdirSync)(logDir(), { recursive: true });
71252
+ (0, import_node_fs39.appendFileSync)(logFilePath(), `${(/* @__PURE__ */ new Date()).toISOString()} ${msg}
71016
71253
  `);
71017
71254
  } catch {
71018
71255
  }
@@ -71020,8 +71257,8 @@ function logLine(msg) {
71020
71257
  function registerAutostart(exePath) {
71021
71258
  if (!isWin) return;
71022
71259
  const xml = buildAutostartTaskXml(exePath, currentUserId());
71023
- const tmp = (0, import_node_path34.join)((0, import_node_os20.tmpdir)(), `floless-autostart-${process.pid}-${Date.now()}.xml`);
71024
- (0, import_node_fs38.writeFileSync)(tmp, "\uFEFF" + xml, { encoding: "utf16le" });
71260
+ const tmp = (0, import_node_path35.join)((0, import_node_os21.tmpdir)(), `floless-autostart-${process.pid}-${Date.now()}.xml`);
71261
+ (0, import_node_fs39.writeFileSync)(tmp, "\uFEFF" + xml, { encoding: "utf16le" });
71025
71262
  try {
71026
71263
  (0, import_node_child_process6.execFileSync)("schtasks", ["/Create", "/TN", TASK_NAME, "/XML", tmp, "/F"], {
71027
71264
  stdio: ["ignore", "ignore", "ignore"],
@@ -71032,7 +71269,7 @@ function registerAutostart(exePath) {
71032
71269
  throw err2;
71033
71270
  } finally {
71034
71271
  try {
71035
- (0, import_node_fs38.rmSync)(tmp, { force: true });
71272
+ (0, import_node_fs39.rmSync)(tmp, { force: true });
71036
71273
  } catch {
71037
71274
  }
71038
71275
  }
@@ -71067,26 +71304,26 @@ function unregisterAutostart() {
71067
71304
  // updater.ts
71068
71305
  var import_node_child_process7 = require("node:child_process");
71069
71306
  var import_node_crypto19 = require("node:crypto");
71070
- var import_node_fs40 = require("node:fs");
71307
+ var import_node_fs41 = require("node:fs");
71071
71308
  var import_node_stream3 = require("node:stream");
71072
71309
  var import_promises3 = require("node:stream/promises");
71073
- var import_node_path36 = require("node:path");
71310
+ var import_node_path37 = require("node:path");
71074
71311
 
71075
71312
  // post-update-marker.mjs
71076
- var import_node_fs39 = require("node:fs");
71077
- var import_node_os21 = require("node:os");
71078
- var import_node_path35 = require("node:path");
71313
+ var import_node_fs40 = require("node:fs");
71314
+ var import_node_os22 = require("node:os");
71315
+ var import_node_path36 = require("node:path");
71079
71316
  var FRESH_MS = 12e4;
71080
71317
  function markerPath() {
71081
71318
  const override = (process.env.FLOLESS_POST_UPDATE_MARKER ?? "").trim();
71082
71319
  if (override) return override;
71083
- const root3 = process.env.FLOLESS_HOME ?? (0, import_node_path35.join)((0, import_node_os21.homedir)(), ".floless");
71084
- return (0, import_node_path35.join)(root3, ".post-update");
71320
+ const root3 = process.env.FLOLESS_HOME ?? (0, import_node_path36.join)((0, import_node_os22.homedir)(), ".floless");
71321
+ return (0, import_node_path36.join)(root3, ".post-update");
71085
71322
  }
71086
71323
  function legacyMarkerPath() {
71087
71324
  if ((process.env.FLOLESS_POST_UPDATE_MARKER ?? "").trim()) return null;
71088
71325
  try {
71089
- return (0, import_node_path35.join)((0, import_node_path35.dirname)((0, import_node_path35.dirname)(process.execPath)), ".floless-post-update");
71326
+ return (0, import_node_path36.join)((0, import_node_path36.dirname)((0, import_node_path36.dirname)(process.execPath)), ".floless-post-update");
71090
71327
  } catch {
71091
71328
  return null;
71092
71329
  }
@@ -71096,7 +71333,7 @@ function writePostUpdateMarker() {
71096
71333
  for (const p of [markerPath(), legacyMarkerPath()]) {
71097
71334
  if (!p) continue;
71098
71335
  try {
71099
- (0, import_node_fs39.writeFileSync)(p, (/* @__PURE__ */ new Date()).toISOString());
71336
+ (0, import_node_fs40.writeFileSync)(p, (/* @__PURE__ */ new Date()).toISOString());
71100
71337
  wrote = true;
71101
71338
  } catch {
71102
71339
  }
@@ -71108,9 +71345,9 @@ function consumePostUpdateMarker() {
71108
71345
  for (const p of [markerPath(), legacyMarkerPath()]) {
71109
71346
  if (!p) continue;
71110
71347
  try {
71111
- if (!(0, import_node_fs39.existsSync)(p)) continue;
71112
- const ageMs = Date.now() - (0, import_node_fs39.statSync)(p).mtimeMs;
71113
- (0, import_node_fs39.rmSync)(p, { force: true });
71348
+ if (!(0, import_node_fs40.existsSync)(p)) continue;
71349
+ const ageMs = Date.now() - (0, import_node_fs40.statSync)(p).mtimeMs;
71350
+ (0, import_node_fs40.rmSync)(p, { force: true });
71114
71351
  if (ageMs < FRESH_MS) fresh = true;
71115
71352
  } catch {
71116
71353
  }
@@ -71127,13 +71364,13 @@ function currentVersion() {
71127
71364
  return appVersion();
71128
71365
  }
71129
71366
  function installRoot() {
71130
- return (0, import_node_path36.dirname)((0, import_node_path36.dirname)(process.execPath));
71367
+ return (0, import_node_path37.dirname)((0, import_node_path37.dirname)(process.execPath));
71131
71368
  }
71132
71369
  function updateExePath() {
71133
- return (0, import_node_path36.join)(installRoot(), "Update.exe");
71370
+ return (0, import_node_path37.join)(installRoot(), "Update.exe");
71134
71371
  }
71135
71372
  function packagesDir() {
71136
- return (0, import_node_path36.join)(installRoot(), "packages");
71373
+ return (0, import_node_path37.join)(installRoot(), "packages");
71137
71374
  }
71138
71375
  function feedUrl() {
71139
71376
  const env2 = (process.env.FLOLESS_UPDATE_URL ?? "").trim().replace(/\/+$/, "");
@@ -71226,22 +71463,22 @@ async function checkForUpdate() {
71226
71463
  }
71227
71464
  async function sha1OfFile(path) {
71228
71465
  const hash2 = (0, import_node_crypto19.createHash)("sha1");
71229
- await (0, import_promises3.pipeline)((0, import_node_fs40.createReadStream)(path), hash2);
71466
+ await (0, import_promises3.pipeline)((0, import_node_fs41.createReadStream)(path), hash2);
71230
71467
  return hash2.digest("hex").toUpperCase();
71231
71468
  }
71232
71469
  async function downloadPackage(asset) {
71233
71470
  if (!NUPKG_NAME.test(asset.FileName)) throw new Error(`refusing suspicious package name: ${asset.FileName}`);
71234
71471
  const want = asset.SHA1.toUpperCase();
71235
71472
  const dir = packagesDir();
71236
- (0, import_node_fs40.mkdirSync)(dir, { recursive: true });
71237
- const dest = (0, import_node_path36.join)(dir, asset.FileName);
71238
- if ((0, import_node_fs40.existsSync)(dest) && await sha1OfFile(dest) === want) return dest;
71473
+ (0, import_node_fs41.mkdirSync)(dir, { recursive: true });
71474
+ const dest = (0, import_node_path37.join)(dir, asset.FileName);
71475
+ if ((0, import_node_fs41.existsSync)(dest) && await sha1OfFile(dest) === want) return dest;
71239
71476
  const res = await authedFetch(`${feedUrl()}/${encodeURIComponent(asset.FileName)}`, {
71240
71477
  redirect: "follow",
71241
71478
  signal: AbortSignal.timeout(DOWNLOAD_TIMEOUT_MS)
71242
71479
  });
71243
71480
  if (!res.ok || !res.body) throw new Error(`download failed: HTTP ${res.status} for ${asset.FileName}`);
71244
- await (0, import_promises3.pipeline)(import_node_stream3.Readable.fromWeb(res.body), (0, import_node_fs40.createWriteStream)(dest));
71481
+ await (0, import_promises3.pipeline)(import_node_stream3.Readable.fromWeb(res.body), (0, import_node_fs41.createWriteStream)(dest));
71245
71482
  const got = await sha1OfFile(dest);
71246
71483
  if (got !== want) throw new Error(`SHA1 mismatch for ${asset.FileName}: feed=${want} got=${got}`);
71247
71484
  return dest;
@@ -71250,7 +71487,7 @@ async function applyUpdate(check, opts) {
71250
71487
  if (!check.supported) return { applied: false, message: check.reason ?? "auto-update not supported in this runtime" };
71251
71488
  if (!check.updateAvailable || !check.asset) return { applied: false, message: check.reason ?? "no update available" };
71252
71489
  const exe = updateExePath();
71253
- if (!(0, import_node_fs40.existsSync)(exe)) {
71490
+ if (!(0, import_node_fs41.existsSync)(exe)) {
71254
71491
  return { applied: false, message: `Update.exe not found at ${exe} \u2014 is this a Velopack install?` };
71255
71492
  }
71256
71493
  const pkg = await downloadPackage(check.asset);
@@ -71490,12 +71727,12 @@ function isTraceCorrupt(events) {
71490
71727
 
71491
71728
  // launch.mjs
71492
71729
  var import_node_child_process8 = require("node:child_process");
71493
- var import_node_path37 = require("node:path");
71730
+ var import_node_path38 = require("node:path");
71494
71731
  var import_node_url3 = require("node:url");
71495
- var import_node_fs41 = require("node:fs");
71732
+ var import_node_fs42 = require("node:fs");
71496
71733
  var import_node_http = __toESM(require("node:http"), 1);
71497
71734
  var import_node_readline = require("node:readline");
71498
- var __dirname2 = (0, import_node_path37.dirname)((0, import_node_url3.fileURLToPath)(__import_meta_url));
71735
+ var __dirname2 = (0, import_node_path38.dirname)((0, import_node_url3.fileURLToPath)(__import_meta_url));
71499
71736
  var PORT = Number(process.env.PORT ?? 4317);
71500
71737
  var HEALTH_URL = `http://127.0.0.1:${PORT}/api/health`;
71501
71738
  var BROWSER_URL = `http://floless.localhost:${PORT}`;
@@ -71567,8 +71804,8 @@ async function waitHealthy(timeoutMs = 3e4) {
71567
71804
  function resolveServerStart() {
71568
71805
  const packaged = /flolessapp\.exe$/i.test(process.execPath);
71569
71806
  if (packaged) return { cmd: process.execPath, args: ["--serve"], shell: false };
71570
- const bundle = (0, import_node_path37.join)(__dirname2, "dist", "floless-server.cjs");
71571
- if ((0, import_node_fs41.existsSync)(bundle)) return { cmd: process.execPath, args: [bundle, "--serve"], shell: false };
71807
+ const bundle = (0, import_node_path38.join)(__dirname2, "dist", "floless-server.cjs");
71808
+ if ((0, import_node_fs42.existsSync)(bundle)) return { cmd: process.execPath, args: [bundle, "--serve"], shell: false };
71572
71809
  return { cmd: "npm", args: ["run", "start"], shell: isWin2 };
71573
71810
  }
71574
71811
  function startServerDetached() {
@@ -71721,8 +71958,8 @@ function taskkillArgs(pid, { tree = true } = {}) {
71721
71958
  }
71722
71959
  function killSupervisor({ tree = true } = {}) {
71723
71960
  if (!isWin2) return;
71724
- const isNpmChannel = /^node(\.exe)?$/i.test((0, import_node_path37.basename)(process.execPath));
71725
- const scriptMatch = isNpmChannel ? (0, import_node_path37.basename)((0, import_node_url3.fileURLToPath)(__import_meta_url)) : void 0;
71961
+ const isNpmChannel = /^node(\.exe)?$/i.test((0, import_node_path38.basename)(process.execPath));
71962
+ const scriptMatch = isNpmChannel ? (0, import_node_path38.basename)((0, import_node_url3.fileURLToPath)(__import_meta_url)) : void 0;
71726
71963
  const realExe = resolveRealInstallExe(process.execPath);
71727
71964
  const exeMatch = realExe === process.execPath ? process.execPath : [process.execPath, realExe];
71728
71965
  const pids = supervisorPidsToKill(enumerateProcesses(), process.pid, exeMatch, scriptMatch);
@@ -71887,7 +72124,7 @@ async function runAction(arg, flagArgv = [], selfVersion = null) {
71887
72124
  }
71888
72125
  await action(parseTeardownFlags(flagArgv));
71889
72126
  }
71890
- var entry = (0, import_node_path37.basename)(process.argv[1] ?? "").toLowerCase();
72127
+ var entry = (0, import_node_path38.basename)(process.argv[1] ?? "").toLowerCase();
71891
72128
  if (entry === "launch.mjs") {
71892
72129
  runAction(process.argv[2], process.argv.slice(3)).catch((e) => {
71893
72130
  log(`error: ${e?.message ?? e}`);
@@ -71961,9 +72198,9 @@ function awareUpgradeBlockReason(s) {
71961
72198
  }
71962
72199
 
71963
72200
  // skill-sync.ts
71964
- var import_node_fs42 = require("node:fs");
71965
- var import_node_os22 = require("node:os");
71966
- var import_node_path38 = require("node:path");
72201
+ var import_node_fs43 = require("node:fs");
72202
+ var import_node_os23 = require("node:os");
72203
+ var import_node_path39 = require("node:path");
71967
72204
  var import_node_url4 = require("node:url");
71968
72205
  var import_yaml10 = __toESM(require_dist6(), 1);
71969
72206
 
@@ -72008,30 +72245,30 @@ function selectShippedSkillNames(names) {
72008
72245
  }
72009
72246
 
72010
72247
  // skill-sync.ts
72011
- var __dirname3 = (0, import_node_path38.dirname)((0, import_node_url4.fileURLToPath)(__import_meta_url));
72248
+ var __dirname3 = (0, import_node_path39.dirname)((0, import_node_url4.fileURLToPath)(__import_meta_url));
72012
72249
  function bundledSkillsRoot() {
72013
72250
  const candidates = [
72014
- (0, import_node_path38.join)(__dirname3, "skills"),
72015
- (0, import_node_path38.join)((0, import_node_path38.dirname)(process.execPath), "skills"),
72016
- (0, import_node_path38.join)(__dirname3, "..", ".claude", "skills")
72251
+ (0, import_node_path39.join)(__dirname3, "skills"),
72252
+ (0, import_node_path39.join)((0, import_node_path39.dirname)(process.execPath), "skills"),
72253
+ (0, import_node_path39.join)(__dirname3, "..", ".claude", "skills")
72017
72254
  ];
72018
- return candidates.find((p) => (0, import_node_fs42.existsSync)(p)) ?? null;
72255
+ return candidates.find((p) => (0, import_node_fs43.existsSync)(p)) ?? null;
72019
72256
  }
72020
72257
  function targetConfigDirs() {
72021
72258
  const override = process.env.FLOLESS_SKILL_TARGETS;
72022
72259
  if (override) {
72023
72260
  return override.split(";").map((d) => d.trim()).filter(Boolean).map((dir) => ({ runtime: "custom", dir }));
72024
72261
  }
72025
- const home = (0, import_node_os22.homedir)();
72262
+ const home = (0, import_node_os23.homedir)();
72026
72263
  return [
72027
- { runtime: "claude", dir: (0, import_node_path38.join)(home, ".claude") },
72028
- { runtime: "codex", dir: (0, import_node_path38.join)(home, ".codex") },
72029
- { runtime: "opencode", dir: (0, import_node_path38.join)(home, ".opencode") }
72264
+ { runtime: "claude", dir: (0, import_node_path39.join)(home, ".claude") },
72265
+ { runtime: "codex", dir: (0, import_node_path39.join)(home, ".codex") },
72266
+ { runtime: "opencode", dir: (0, import_node_path39.join)(home, ".opencode") }
72030
72267
  ];
72031
72268
  }
72032
72269
  function skillVersion(skillMdPath) {
72033
72270
  try {
72034
- const text2 = (0, import_node_fs42.readFileSync)(skillMdPath, "utf8");
72271
+ const text2 = (0, import_node_fs43.readFileSync)(skillMdPath, "utf8");
72035
72272
  const m = /^---\r?\n([\s\S]*?)\r?\n---/.exec(text2);
72036
72273
  if (!m || m[1] === void 0) return null;
72037
72274
  const fm = (0, import_yaml10.parse)(m[1]);
@@ -72071,21 +72308,21 @@ function decideAction(installed, bundled) {
72071
72308
  function bundledSkills(root3) {
72072
72309
  let entries = [];
72073
72310
  try {
72074
- entries = selectShippedSkillNames((0, import_node_fs42.readdirSync)(root3));
72311
+ entries = selectShippedSkillNames((0, import_node_fs43.readdirSync)(root3));
72075
72312
  } catch {
72076
72313
  return [];
72077
72314
  }
72078
72315
  const out = [];
72079
72316
  for (const name of entries) {
72080
- const dir = (0, import_node_path38.join)(root3, name);
72317
+ const dir = (0, import_node_path39.join)(root3, name);
72081
72318
  let isDir = false;
72082
72319
  try {
72083
- isDir = (0, import_node_fs42.statSync)(dir).isDirectory();
72320
+ isDir = (0, import_node_fs43.statSync)(dir).isDirectory();
72084
72321
  } catch {
72085
72322
  isDir = false;
72086
72323
  }
72087
72324
  if (!isDir) continue;
72088
- const v = skillVersion((0, import_node_path38.join)(dir, "SKILL.md"));
72325
+ const v = skillVersion((0, import_node_path39.join)(dir, "SKILL.md"));
72089
72326
  if (!v) continue;
72090
72327
  out.push({ name, dir, version: v });
72091
72328
  }
@@ -72098,17 +72335,17 @@ function syncSkills() {
72098
72335
  const skills = bundledSkills(root3);
72099
72336
  if (!skills.length) return results;
72100
72337
  for (const { runtime, dir: cfg } of targetConfigDirs()) {
72101
- if (!(0, import_node_fs42.existsSync)(cfg)) continue;
72102
- const skillsDir = (0, import_node_path38.join)(cfg, "skills");
72338
+ if (!(0, import_node_fs43.existsSync)(cfg)) continue;
72339
+ const skillsDir = (0, import_node_path39.join)(cfg, "skills");
72103
72340
  for (const s of skills) {
72104
- const dest = (0, import_node_path38.join)(skillsDir, s.name);
72105
- const installedMd = (0, import_node_path38.join)(dest, "SKILL.md");
72106
- const installed = (0, import_node_fs42.existsSync)(installedMd) ? skillVersion(installedMd) : null;
72341
+ const dest = (0, import_node_path39.join)(skillsDir, s.name);
72342
+ const installedMd = (0, import_node_path39.join)(dest, "SKILL.md");
72343
+ const installed = (0, import_node_fs43.existsSync)(installedMd) ? skillVersion(installedMd) : null;
72107
72344
  const action = decideAction(installed, s.version);
72108
72345
  if (action === "installed" || action === "updated") {
72109
72346
  try {
72110
- if (action === "updated") (0, import_node_fs42.rmSync)(dest, { recursive: true, force: true });
72111
- (0, import_node_fs42.cpSync)(s.dir, dest, { recursive: true });
72347
+ if (action === "updated") (0, import_node_fs43.rmSync)(dest, { recursive: true, force: true });
72348
+ (0, import_node_fs43.cpSync)(s.dir, dest, { recursive: true });
72112
72349
  results.push({ runtime, skill: s.name, action, from: installed, to: s.version });
72113
72350
  } catch {
72114
72351
  }
@@ -72132,9 +72369,9 @@ function contractChangedEvent(appId, project, etag, rawMutationId) {
72132
72369
  }
72133
72370
 
72134
72371
  // watch.ts
72135
- var import_node_os23 = require("node:os");
72136
- var import_node_path40 = require("node:path");
72137
- var import_node_fs43 = require("node:fs");
72372
+ var import_node_os24 = require("node:os");
72373
+ var import_node_path41 = require("node:path");
72374
+ var import_node_fs44 = require("node:fs");
72138
72375
 
72139
72376
  // node_modules/chokidar/esm/index.js
72140
72377
  var import_fs2 = require("fs");
@@ -72145,7 +72382,7 @@ var sysPath2 = __toESM(require("path"), 1);
72145
72382
  // node_modules/readdirp/esm/index.js
72146
72383
  var import_promises4 = require("node:fs/promises");
72147
72384
  var import_node_stream4 = require("node:stream");
72148
- var import_node_path39 = require("node:path");
72385
+ var import_node_path40 = require("node:path");
72149
72386
  var EntryTypes = {
72150
72387
  FILE_TYPE: "files",
72151
72388
  DIR_TYPE: "directories",
@@ -72220,7 +72457,7 @@ var ReaddirpStream = class extends import_node_stream4.Readable {
72220
72457
  this._wantsDir = type ? DIR_TYPES.has(type) : false;
72221
72458
  this._wantsFile = type ? FILE_TYPES.has(type) : false;
72222
72459
  this._wantsEverything = type === EntryTypes.EVERYTHING_TYPE;
72223
- this._root = (0, import_node_path39.resolve)(root3);
72460
+ this._root = (0, import_node_path40.resolve)(root3);
72224
72461
  this._isDirent = !opts.alwaysStat;
72225
72462
  this._statsProp = this._isDirent ? "dirent" : "stats";
72226
72463
  this._rdOptions = { encoding: "utf8", withFileTypes: this._isDirent };
@@ -72291,8 +72528,8 @@ var ReaddirpStream = class extends import_node_stream4.Readable {
72291
72528
  let entry2;
72292
72529
  const basename9 = this._isDirent ? dirent.name : dirent;
72293
72530
  try {
72294
- const fullPath = (0, import_node_path39.resolve)((0, import_node_path39.join)(path, basename9));
72295
- entry2 = { path: (0, import_node_path39.relative)(this._root, fullPath), fullPath, basename: basename9 };
72531
+ const fullPath = (0, import_node_path40.resolve)((0, import_node_path40.join)(path, basename9));
72532
+ entry2 = { path: (0, import_node_path40.relative)(this._root, fullPath), fullPath, basename: basename9 };
72296
72533
  entry2[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
72297
72534
  } catch (err2) {
72298
72535
  this._onError(err2);
@@ -72326,7 +72563,7 @@ var ReaddirpStream = class extends import_node_stream4.Readable {
72326
72563
  }
72327
72564
  if (entryRealPathStats.isDirectory()) {
72328
72565
  const len = entryRealPath.length;
72329
- if (full.startsWith(entryRealPath) && full.substr(len, 1) === import_node_path39.sep) {
72566
+ if (full.startsWith(entryRealPath) && full.substr(len, 1) === import_node_path40.sep) {
72330
72567
  const recursiveError = new Error(`Circular symlink detected: "${full}" points to "${entryRealPath}"`);
72331
72568
  recursiveError.code = RECURSIVE_ERROR_CODE;
72332
72569
  return this._onError(recursiveError);
@@ -73834,33 +74071,33 @@ function appIdFromLogPath(path) {
73834
74071
  return i >= 0 && parts[i + 1] ? parts[i + 1] : null;
73835
74072
  }
73836
74073
  function samePath(a, b) {
73837
- const ra = (0, import_node_path40.resolve)(a);
73838
- const rb = (0, import_node_path40.resolve)(b);
74074
+ const ra = (0, import_node_path41.resolve)(a);
74075
+ const rb = (0, import_node_path41.resolve)(b);
73839
74076
  return process.platform === "win32" ? ra.toLowerCase() === rb.toLowerCase() : ra === rb;
73840
74077
  }
73841
74078
  function underDir(path, dir) {
73842
- const rp = (0, import_node_path40.resolve)(path);
73843
- const rd = (0, import_node_path40.resolve)(dir);
74079
+ const rp = (0, import_node_path41.resolve)(path);
74080
+ const rd = (0, import_node_path41.resolve)(dir);
73844
74081
  const [p, d] = process.platform === "win32" ? [rp.toLowerCase(), rd.toLowerCase()] : [rp, rd];
73845
- return p === d || p.startsWith(d + import_node_path40.sep);
74082
+ return p === d || p.startsWith(d + import_node_path41.sep);
73846
74083
  }
73847
74084
  function startWatcher() {
73848
- const awareDir = process.env.AWARE_HOME ?? (0, import_node_path40.join)((0, import_node_os23.homedir)(), ".aware");
73849
- const credentialsDir = (0, import_node_path40.join)(awareDir, "credentials");
73850
- if (!(0, import_node_fs43.existsSync)(credentialsDir)) {
74085
+ const awareDir = process.env.AWARE_HOME ?? (0, import_node_path41.join)((0, import_node_os24.homedir)(), ".aware");
74086
+ const credentialsDir = (0, import_node_path41.join)(awareDir, "credentials");
74087
+ if (!(0, import_node_fs44.existsSync)(credentialsDir)) {
73851
74088
  try {
73852
- (0, import_node_fs43.mkdirSync)(credentialsDir, { recursive: true });
74089
+ (0, import_node_fs44.mkdirSync)(credentialsDir, { recursive: true });
73853
74090
  } catch {
73854
74091
  }
73855
74092
  }
73856
- if (!(0, import_node_fs43.existsSync)(uiDir)) {
74093
+ if (!(0, import_node_fs44.existsSync)(uiDir)) {
73857
74094
  try {
73858
- (0, import_node_fs43.mkdirSync)(uiDir, { recursive: true });
74095
+ (0, import_node_fs44.mkdirSync)(uiDir, { recursive: true });
73859
74096
  } catch {
73860
74097
  }
73861
74098
  }
73862
- const targets = ["apps", "logs", "credentials"].map((d) => (0, import_node_path40.join)(awareDir, d)).filter((p) => (0, import_node_fs43.existsSync)(p));
73863
- if ((0, import_node_fs43.existsSync)(uiDir)) targets.push(uiDir);
74099
+ const targets = ["apps", "logs", "credentials"].map((d) => (0, import_node_path41.join)(awareDir, d)).filter((p) => (0, import_node_fs44.existsSync)(p));
74100
+ if ((0, import_node_fs44.existsSync)(uiDir)) targets.push(uiDir);
73864
74101
  if (targets.length === 0) {
73865
74102
  return null;
73866
74103
  }
@@ -73889,11 +74126,11 @@ function startWatcher() {
73889
74126
  const isCredential = path.split(/[\\/]/).includes("credentials");
73890
74127
  const kind = isCredential ? "credential" : path.endsWith(".jsonl") ? "trace" : path.endsWith(".lock") ? "lock" : path.endsWith(".flo") || path.endsWith(".app") ? "source" : "file";
73891
74128
  broadcast({ type: "fs-change", kind, event, path });
73892
- if (kind === "trace" && event !== "unlink" && (0, import_node_fs43.existsSync)(path)) {
74129
+ if (kind === "trace" && event !== "unlink" && (0, import_node_fs44.existsSync)(path)) {
73893
74130
  const id = appIdFromLogPath(path);
73894
74131
  if (!id) return;
73895
74132
  try {
73896
- broadcast({ type: "trace-file", id, runId: path.split(import_node_path40.sep).pop()?.replace(/\.jsonl$/, "") ?? null, events: parseTrace((0, import_node_fs43.readFileSync)(path, "utf8")) });
74133
+ broadcast({ type: "trace-file", id, runId: path.split(import_node_path41.sep).pop()?.replace(/\.jsonl$/, "") ?? null, events: parseTrace((0, import_node_fs44.readFileSync)(path, "utf8")) });
73897
74134
  } catch {
73898
74135
  }
73899
74136
  }
@@ -73902,10 +74139,10 @@ function startWatcher() {
73902
74139
  }
73903
74140
 
73904
74141
  // index.ts
73905
- var __dirname4 = (0, import_node_path41.dirname)((0, import_node_url5.fileURLToPath)(__import_meta_url));
73906
- var WEB_ROOT = [(0, import_node_path41.join)(__dirname4, "web"), (0, import_node_path41.join)((0, import_node_path41.dirname)(process.execPath), "web"), (0, import_node_path41.join)(__dirname4, "..", "web")].find(
73907
- (p) => (0, import_node_fs44.existsSync)(p)
73908
- ) ?? (0, import_node_path41.join)(__dirname4, "..", "web");
74142
+ var __dirname4 = (0, import_node_path42.dirname)((0, import_node_url5.fileURLToPath)(__import_meta_url));
74143
+ var WEB_ROOT = [(0, import_node_path42.join)(__dirname4, "web"), (0, import_node_path42.join)((0, import_node_path42.dirname)(process.execPath), "web"), (0, import_node_path42.join)(__dirname4, "..", "web")].find(
74144
+ (p) => (0, import_node_fs45.existsSync)(p)
74145
+ ) ?? (0, import_node_path42.join)(__dirname4, "..", "web");
73909
74146
  var PORT2 = Number(process.env.PORT ?? 4317);
73910
74147
  var HOST = "127.0.0.1";
73911
74148
  var crashHandlersInstalled = false;
@@ -73921,7 +74158,7 @@ function installCrashHandlers() {
73921
74158
  ${stack}
73922
74159
  `;
73923
74160
  try {
73924
- (0, import_node_fs44.appendFileSync)(logFilePath(), line);
74161
+ (0, import_node_fs45.appendFileSync)(logFilePath(), line);
73925
74162
  } catch {
73926
74163
  }
73927
74164
  if (process.stderr.isTTY) process.stderr.write(line);
@@ -74268,9 +74505,9 @@ async function startServer() {
74268
74505
  const { id, templateId, templatePath, srcPath, appDirPath: appDirPath2, fromVersion, contract, verb } = opts;
74269
74506
  const bdir = backupDir(id, fromVersion, Date.now());
74270
74507
  try {
74271
- (0, import_node_fs44.mkdirSync)((0, import_node_path41.dirname)(bdir), { recursive: true });
74272
- (0, import_node_fs44.cpSync)(appDirPath2, bdir, { recursive: true });
74273
- (0, import_node_fs44.cpSync)(templatePath, srcPath);
74508
+ (0, import_node_fs45.mkdirSync)((0, import_node_path42.dirname)(bdir), { recursive: true });
74509
+ (0, import_node_fs45.cpSync)(appDirPath2, bdir, { recursive: true });
74510
+ (0, import_node_fs45.cpSync)(templatePath, srcPath);
74274
74511
  if (id !== templateId) stampSourceAppId(srcPath, id);
74275
74512
  if (contract != null) {
74276
74513
  bakeContractIntoApp(srcPath, contract);
@@ -74281,8 +74518,8 @@ async function startServer() {
74281
74518
  } catch (e) {
74282
74519
  const msg = e instanceof Error ? e.message : String(e);
74283
74520
  try {
74284
- (0, import_node_fs44.rmSync)(appDirPath2, { recursive: true, force: true });
74285
- (0, import_node_fs44.cpSync)(bdir, appDirPath2, { recursive: true });
74521
+ (0, import_node_fs45.rmSync)(appDirPath2, { recursive: true, force: true });
74522
+ (0, import_node_fs45.cpSync)(bdir, appDirPath2, { recursive: true });
74286
74523
  } catch (re) {
74287
74524
  const rmsg = re instanceof Error ? re.message : String(re);
74288
74525
  throw new TemplateSwapError(`${verb} failed (${msg}) AND rollback failed (${rmsg}) \u2014 restore manually from ${bdir}`, "rollback-failed", bdir);
@@ -74314,7 +74551,7 @@ async function startServer() {
74314
74551
  return reply.status(409).send({ ok: false, error: `"${id}" is already at ${fromVersion}`, code: "up-to-date" });
74315
74552
  }
74316
74553
  const contract = readAcceptedForRequest(id, void 0);
74317
- if (contract == null && (0, import_node_fs44.existsSync)(contractPath(id))) {
74554
+ if (contract == null && (0, import_node_fs45.existsSync)(contractPath(id))) {
74318
74555
  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" });
74319
74556
  }
74320
74557
  if (contract != null) {
@@ -74694,9 +74931,9 @@ async function startServer() {
74694
74931
  const bad = projectAppMismatch(req.params.appId, project);
74695
74932
  if (bad) return reply.status(404).send({ ok: false, error: bad });
74696
74933
  const safe2 = req.params.sheet.replace(/[^A-Za-z0-9._-]/g, "");
74697
- const file = (0, import_node_path41.join)((0, import_node_path41.dirname)(contractPath(req.params.appId, project)), "details", `${safe2}.svg`);
74698
- if (!(0, import_node_fs44.existsSync)(file)) return reply.status(404).send({ ok: false, error: "no vector for this sheet" });
74699
- return reply.type("image/svg+xml").send((0, import_node_fs44.readFileSync)(file, "utf8"));
74934
+ const file = (0, import_node_path42.join)((0, import_node_path42.dirname)(contractPath(req.params.appId, project)), "details", `${safe2}.svg`);
74935
+ if (!(0, import_node_fs45.existsSync)(file)) return reply.status(404).send({ ok: false, error: "no vector for this sheet" });
74936
+ return reply.type("image/svg+xml").send((0, import_node_fs45.readFileSync)(file, "utf8"));
74700
74937
  }
74701
74938
  );
74702
74939
  app.put(
@@ -74849,20 +75086,35 @@ async function startServer() {
74849
75086
  throw error;
74850
75087
  }
74851
75088
  }
74852
- const byKind = new Map(currentReceipts.map((receipt) => [receipt.kind, receipt]));
74853
- const exports2 = projectExportFiles(req.params.appId, resolveTemplateId(req.params.appId)).map(({ kind, filename: legacy }) => {
74854
- const receipt = byKind.get(kind);
74855
- const filename = receipt?.filename ?? legacy;
74856
- const path = (0, import_node_path41.join)(dir, filename);
74857
- let exportedAt = null;
74858
- if (receipt) {
74859
- try {
74860
- const st = (0, import_node_fs44.statSync)(path);
74861
- if (st.isFile()) exportedAt = st.mtime.toISOString();
74862
- } catch {
74863
- }
75089
+ const byKind = /* @__PURE__ */ new Map();
75090
+ for (const receipt of currentReceipts) {
75091
+ const rows2 = byKind.get(receipt.kind);
75092
+ if (rows2) rows2.push(receipt);
75093
+ else byKind.set(receipt.kind, [receipt]);
75094
+ }
75095
+ const statedAt = (filename) => {
75096
+ try {
75097
+ const st = (0, import_node_fs45.statSync)((0, import_node_path42.join)(dir, filename));
75098
+ return st.isFile() ? st.mtime.toISOString() : null;
75099
+ } catch {
75100
+ return null;
74864
75101
  }
74865
- return { kind, filename, path, exportedAt };
75102
+ };
75103
+ const exports2 = projectExportFiles(req.params.appId, resolveTemplateId(req.params.appId)).map(({ kind, filename: legacy }) => {
75104
+ const rows2 = (byKind.get(kind) ?? []).map((receipt) => ({
75105
+ variant: receipt.variant ?? null,
75106
+ filename: receipt.filename,
75107
+ path: (0, import_node_path42.join)(dir, receipt.filename),
75108
+ exportedAt: statedAt(receipt.filename)
75109
+ })).sort((a, b) => String(b.exportedAt ?? "").localeCompare(String(a.exportedAt ?? "")));
75110
+ const headline = rows2[0];
75111
+ return {
75112
+ kind,
75113
+ filename: headline?.filename ?? legacy,
75114
+ path: headline?.path ?? (0, import_node_path42.join)(dir, legacy),
75115
+ exportedAt: headline?.exportedAt ?? null,
75116
+ ...rows2.length ? { variants: rows2 } : {}
75117
+ };
74866
75118
  });
74867
75119
  return { ok: true, approvedAt, exports: exports2 };
74868
75120
  });
@@ -74990,7 +75242,7 @@ async function startServer() {
74990
75242
  }
74991
75243
  if (!hasExportableSceneRecords(scene)) return reply.status(422).send({ ok: false, error: emptyError, skipped });
74992
75244
  const filename = `${exportFileBase(project, appId)}.ifc`;
74993
- const finalPath = (0, import_node_path41.join)(project ? projectExportsDir(project) : (0, import_node_path41.dirname)(bomExportPath(appId, "csv")), filename);
75245
+ const finalPath = (0, import_node_path42.join)(project ? projectExportsDir(project) : (0, import_node_path42.dirname)(bomExportPath(appId, "csv")), filename);
74994
75246
  const priorProjectIfc = project ? listProjectExportReceipts(project).find((row) => row.kind === "ifc") : void 0;
74995
75247
  const tempPath = requestIfcTempPath(finalPath);
74996
75248
  try {
@@ -74998,10 +75250,10 @@ async function startServer() {
74998
75250
  scene,
74999
75251
  "output-path": tempPath
75000
75252
  });
75001
- if (!(0, import_node_fs44.existsSync)(tempPath) || (0, import_node_fs44.statSync)(tempPath).size === 0) {
75253
+ if (!(0, import_node_fs45.existsSync)(tempPath) || (0, import_node_fs45.statSync)(tempPath).size === 0) {
75002
75254
  throw new ReceiptReconciliationError("AWARE reported a successful export but wrote no IFC file.");
75003
75255
  }
75004
- const artifactBytes = (0, import_node_fs44.readFileSync)(tempPath);
75256
+ const artifactBytes = (0, import_node_fs45.readFileSync)(tempPath);
75005
75257
  const receipt = reconcileIfcExportReceipt(scene, rawReceipt, producerUnsupported, {
75006
75258
  index: parseStepData(artifactBytes),
75007
75259
  bytes: artifactBytes
@@ -75054,13 +75306,200 @@ async function startServer() {
75054
75306
  return reply.status(status).send({
75055
75307
  ok: false,
75056
75308
  error: error instanceof Error ? error.message : "IFC export failed",
75057
- preservedPrevious: project && priorProjectIfc ? receiptHasFile(project, priorProjectIfc) : (0, import_node_fs44.existsSync)(finalPath)
75309
+ preservedPrevious: project && priorProjectIfc ? receiptHasFile(project, priorProjectIfc) : (0, import_node_fs45.existsSync)(finalPath)
75058
75310
  });
75059
75311
  } finally {
75060
75312
  cleanupIfcTemp(tempPath);
75061
75313
  }
75062
75314
  });
75063
75315
  });
75316
+ app.get("/api/render/readiness", async () => ({ ok: true, readiness: await renderReadiness() }));
75317
+ app.post("/api/render/install-agent", async (_req, reply) => {
75318
+ try {
75319
+ const { installed } = await aware.ensureAgentInstalled(RENDER_AGENT_ID);
75320
+ return { ok: true, installed, readiness: await renderReadiness() };
75321
+ } catch (error) {
75322
+ return reply.status(502).send({
75323
+ ok: false,
75324
+ error: error instanceof Error ? error.message : "installing the Blender agent failed"
75325
+ });
75326
+ }
75327
+ });
75328
+ app.get("/api/contract/:appId/render-preview", async (req, reply) => {
75329
+ const project = req.query.project;
75330
+ if (!project) return reply.status(400).send({ ok: false, error: "project is required" });
75331
+ const owner = getProject(project);
75332
+ if (!owner || owner.app !== req.params.appId) {
75333
+ return reply.status(404).send({ ok: false, error: "unknown project" });
75334
+ }
75335
+ let snapshot;
75336
+ try {
75337
+ snapshot = currentApprovedSnapshot(project);
75338
+ } catch (error) {
75339
+ if (error instanceof WorkspaceSnapshotError) {
75340
+ return reply.status(404).send({ ok: false, error: "nothing rendered for the approved version" });
75341
+ }
75342
+ throw error;
75343
+ }
75344
+ const stills = matchingProjectExportReceipts(
75345
+ project,
75346
+ snapshot.version.n,
75347
+ snapshot.contractHash,
75348
+ ["render-png"]
75349
+ );
75350
+ const wanted = typeof req.query.viewpoint === "string" ? req.query.viewpoint : null;
75351
+ const receipt = wanted ? stills.find((row) => row.variant === wanted) : [...stills].sort((a, b) => b.exportedAt.localeCompare(a.exportedAt))[0];
75352
+ if (!receipt) return reply.status(404).send({ ok: false, error: "nothing rendered yet" });
75353
+ const path = resolveProjectExportReceiptPath(project, receipt);
75354
+ if (!path || !(0, import_node_fs45.existsSync)(path)) {
75355
+ return reply.status(404).send({ ok: false, error: "the rendered image is no longer on disk" });
75356
+ }
75357
+ return reply.header("content-type", "image/png").header("cache-control", "private, max-age=31536000, immutable").send((0, import_node_fs45.readFileSync)(path));
75358
+ });
75359
+ const RENDER_VIEWPOINTS = /* @__PURE__ */ new Set(["hero", "iso", "front", "back", "left", "right", "top"]);
75360
+ app.post("/api/contract/:appId/render", async (req, reply) => {
75361
+ const appId = req.params.appId;
75362
+ const project = req.query.project || void 0;
75363
+ if (!/^[a-z0-9][a-z0-9._-]*$/i.test(appId)) {
75364
+ return reply.status(400).send({ ok: false, error: `invalid appId: ${appId}` });
75365
+ }
75366
+ if (!project) {
75367
+ return reply.status(400).send({ ok: false, error: "rendering is a project export \u2014 no project given" });
75368
+ }
75369
+ const body = req.body ?? {};
75370
+ const output = body.output === "turntable" ? "turntable" : "still";
75371
+ const quality = body.quality === "draft" ? "draft" : "production";
75372
+ const requested = Array.isArray(body.viewpoints) ? body.viewpoints : [typeof body.viewpoint === "string" ? body.viewpoint : "hero"];
75373
+ const viewpoints = [...new Set(requested.map((v) => String(v)))];
75374
+ if (!viewpoints.length) {
75375
+ return reply.status(400).send({ ok: false, error: "pick at least one viewpoint" });
75376
+ }
75377
+ const unknown = viewpoints.filter((v) => !RENDER_VIEWPOINTS.has(v));
75378
+ if (unknown.length) {
75379
+ return reply.status(400).send({ ok: false, error: `unknown viewpoint: ${unknown.join(", ")}` });
75380
+ }
75381
+ if (viewpoints.length > RENDER_VIEWPOINTS.size) {
75382
+ return reply.status(400).send({ ok: false, error: "too many viewpoints" });
75383
+ }
75384
+ const readiness = await renderReadiness();
75385
+ if (!readiness.ok) {
75386
+ return reply.status(409).send({ ok: false, error: readiness.message, readiness });
75387
+ }
75388
+ return withLifecycleLock("project", project, async () => {
75389
+ const gate = projectExportGate(appId, project);
75390
+ if (gate) return reply.status(gate.status).send({ ok: false, error: gate.error });
75391
+ let projectSnapshot;
75392
+ try {
75393
+ projectSnapshot = currentApprovedSnapshot(project);
75394
+ } catch (error) {
75395
+ if (error instanceof WorkspaceSnapshotError) {
75396
+ return reply.status(error.status).send({ ok: false, error: error.message });
75397
+ }
75398
+ throw error;
75399
+ }
75400
+ const steel = acceptSteelForRoute(projectSnapshot.contract, { appId, projectId: project }, "stored");
75401
+ if (!steel.accepted) return reply.status(400).send(steel.refusal);
75402
+ const doc = steel.doc;
75403
+ const sourceId = await stableExportSourceId(appId, project);
75404
+ const built = contractToAwareScene(doc, sourceId);
75405
+ if (!hasExportableSceneRecords(built.scene)) {
75406
+ return reply.status(422).send({
75407
+ ok: false,
75408
+ error: "no resolvable members to render \u2014 every member is an RFI (no AISC size yet)",
75409
+ skipped: built.skipped
75410
+ });
75411
+ }
75412
+ const kind = output === "turntable" ? "render-mp4" : "render-png";
75413
+ const extension = output === "turntable" ? ".mp4" : ".png";
75414
+ const scratch = (0, import_node_fs45.mkdtempSync)((0, import_node_path42.join)((0, import_node_os25.tmpdir)(), "floless-render-"));
75415
+ const ifcPath = (0, import_node_path42.join)(scratch, "model.ifc");
75416
+ const rendered = [];
75417
+ const progress = (stage, extra = {}) => {
75418
+ try {
75419
+ broadcast({ type: "render-progress", project, appId, stage, total: viewpoints.length, ...extra });
75420
+ } catch {
75421
+ }
75422
+ };
75423
+ try {
75424
+ progress("preparing");
75425
+ await aware.agentInvoke("ifc", "write", { scene: built.scene, "output-path": ifcPath });
75426
+ if (!(0, import_node_fs45.existsSync)(ifcPath) || (0, import_node_fs45.statSync)(ifcPath).size === 0) {
75427
+ throw new Error("AWARE reported a successful IFC write but produced no file to render");
75428
+ }
75429
+ const renderBudgetMs = output === "turntable" ? 30 * 6e4 : 10 * 6e4;
75430
+ for (const [i, viewpoint] of viewpoints.entries()) {
75431
+ progress("rendering", { viewpoint, index: i + 1, output });
75432
+ const artifactPath = (0, import_node_path42.join)(scratch, `render-${viewpoint}${extension}`);
75433
+ const receipt = await aware.agentInvoke(RENDER_AGENT_ID, output === "turntable" ? "render.turntable" : "render.still", {
75434
+ "ifc-path": ifcPath,
75435
+ "output-path": artifactPath,
75436
+ direction: viewpoint,
75437
+ "timeout-seconds": Math.round(renderBudgetMs / 1e3),
75438
+ // Lighting is deliberately fixed. Every environment renders the same neutral backdrop and
75439
+ // only changes the light, so exposing eight of them buys a decision with no visible
75440
+ // consequence and one more way for a project's renders to drift apart.
75441
+ environment: "studio",
75442
+ ...output === "turntable" ? { "duration-seconds": 12, fps: 24, "width-pixels": 1280, "height-pixels": 720 } : { quality, "width-pixels": 1920, "height-pixels": 1080 }
75443
+ }, { timeoutMs: renderBudgetMs });
75444
+ if (!(0, import_node_fs45.existsSync)(artifactPath) || (0, import_node_fs45.statSync)(artifactPath).size === 0) {
75445
+ throw new Error(`the ${viewpoint} render reported success but produced no image`);
75446
+ }
75447
+ const bytes = (0, import_node_fs45.readFileSync)(artifactPath);
75448
+ const preferred = `${exportFileBase(project, appId)}-${viewpoint}${extension}`;
75449
+ const filename = uniqueProjectExportFilename(project, preferred);
75450
+ publishProjectExportArtifact(project, {
75451
+ kind,
75452
+ variant: viewpoint,
75453
+ filename,
75454
+ encoding: "base64",
75455
+ bytes: bytes.length,
75456
+ version: projectSnapshot.version.n,
75457
+ contractHash: projectSnapshot.contractHash
75458
+ }, bytes);
75459
+ rendered.push({
75460
+ viewpoint,
75461
+ filename,
75462
+ bytes: bytes.length,
75463
+ // From the agent's OWN receipt, not from what was asked for. A turntable's frame count
75464
+ // and length are the difference between "it span twice as slowly" and "I set an input
75465
+ // and assumed", and only the receipt can settle that.
75466
+ ...output === "turntable" ? {
75467
+ frames: typeof receipt?.frames === "number" ? receipt.frames : null,
75468
+ seconds: typeof receipt?.["duration-seconds"] === "number" ? receipt["duration-seconds"] : null
75469
+ } : {}
75470
+ });
75471
+ progress("rendered", { viewpoint, index: i + 1, filename });
75472
+ }
75473
+ progress("done", { count: rendered.length });
75474
+ return {
75475
+ ok: true,
75476
+ kind,
75477
+ output,
75478
+ quality: output === "turntable" ? "draft" : quality,
75479
+ rendered,
75480
+ // Kept for a single-viewpoint caller so the existing shape still reads naturally.
75481
+ filename: rendered[0]?.filename,
75482
+ viewpoint: rendered[0]?.viewpoint,
75483
+ savedTo: rendered[0] ? (0, import_node_path42.join)(projectExportsDir(project), rendered[0].filename) : void 0
75484
+ };
75485
+ } catch (error) {
75486
+ app.log.warn(
75487
+ { appId, project, output, viewpoints, err: error instanceof Error ? error.message : error },
75488
+ "render failed"
75489
+ );
75490
+ progress("failed", { count: rendered.length });
75491
+ return reply.status(502).send({
75492
+ ok: false,
75493
+ error: error instanceof Error ? error.message : "rendering failed",
75494
+ // A partial batch is not a rollback: the viewpoints that DID render are published and on
75495
+ // disk, and pretending otherwise would leave the user unable to find them.
75496
+ rendered
75497
+ });
75498
+ } finally {
75499
+ (0, import_node_fs45.rmSync)(scratch, { recursive: true, force: true });
75500
+ }
75501
+ });
75502
+ });
75064
75503
  app.post("/api/contract/:appId/export-tekla", async (req, reply) => {
75065
75504
  const appId = req.params.appId;
75066
75505
  const project = req.query.project || void 0;
@@ -75193,10 +75632,10 @@ async function startServer() {
75193
75632
  }
75194
75633
  const preferredFilename = `${exportFileBase(project, appId)}-bom.${format}`;
75195
75634
  const filename = project ? uniqueProjectExportFilename(project, preferredFilename) : preferredFilename;
75196
- const outPath = project ? (0, import_node_path41.join)(projectExportsDir(project), filename) : bomExportPath(appId, format);
75197
- const dir = (0, import_node_path41.dirname)(outPath);
75635
+ const outPath = project ? (0, import_node_path42.join)(projectExportsDir(project), filename) : bomExportPath(appId, format);
75636
+ const dir = (0, import_node_path42.dirname)(outPath);
75198
75637
  try {
75199
- (0, import_node_fs44.mkdirSync)(dir, { recursive: true });
75638
+ (0, import_node_fs45.mkdirSync)(dir, { recursive: true });
75200
75639
  if (format === "csv") {
75201
75640
  const text2 = bomToCsv(bom);
75202
75641
  if (project && projectSnapshot) {
@@ -75208,7 +75647,7 @@ async function startServer() {
75208
75647
  version: projectSnapshot.version.n,
75209
75648
  contractHash: projectSnapshot.contractHash
75210
75649
  }, Buffer.from(text2, "utf8"));
75211
- } else (0, import_node_fs44.writeFileSync)(outPath, text2, "utf8");
75650
+ } else (0, import_node_fs45.writeFileSync)(outPath, text2, "utf8");
75212
75651
  return { ok: true, filename, encoding: "utf8", content: text2, bytes: Buffer.byteLength(text2), savedTo: outPath };
75213
75652
  }
75214
75653
  const buf = await bomToXlsx(bom);
@@ -75221,7 +75660,7 @@ async function startServer() {
75221
75660
  version: projectSnapshot.version.n,
75222
75661
  contractHash: projectSnapshot.contractHash
75223
75662
  }, buf);
75224
- } else (0, import_node_fs44.writeFileSync)(outPath, buf);
75663
+ } else (0, import_node_fs45.writeFileSync)(outPath, buf);
75225
75664
  return { ok: true, filename, encoding: "base64", content: buf.toString("base64"), bytes: buf.length, savedTo: outPath };
75226
75665
  } catch (e) {
75227
75666
  app.log.error({ appId, format, err: e instanceof Error ? e.message : e }, "export-bom: generation failed");
@@ -75259,9 +75698,9 @@ async function startServer() {
75259
75698
  const svg = contractToSvg(cleaned);
75260
75699
  const preferredFilename = `${exportFileBase(project, req.params.appId)}.svg`;
75261
75700
  const filename = project ? uniqueProjectExportFilename(project, preferredFilename) : preferredFilename;
75262
- const outPath = project ? (0, import_node_path41.join)(projectExportsDir(project), filename) : (0, import_node_path41.join)(appPath(req.params.appId), filename);
75701
+ const outPath = project ? (0, import_node_path42.join)(projectExportsDir(project), filename) : (0, import_node_path42.join)(appPath(req.params.appId), filename);
75263
75702
  try {
75264
- (0, import_node_fs44.mkdirSync)((0, import_node_path41.dirname)(outPath), { recursive: true });
75703
+ (0, import_node_fs45.mkdirSync)((0, import_node_path42.dirname)(outPath), { recursive: true });
75265
75704
  if (project && projectSnapshot) {
75266
75705
  publishProjectExportArtifact(project, {
75267
75706
  kind: "svg",
@@ -75271,7 +75710,7 @@ async function startServer() {
75271
75710
  version: projectSnapshot.version.n,
75272
75711
  contractHash: projectSnapshot.contractHash
75273
75712
  }, Buffer.from(svg, "utf8"));
75274
- } else (0, import_node_fs44.writeFileSync)(outPath, svg, "utf8");
75713
+ } else (0, import_node_fs45.writeFileSync)(outPath, svg, "utf8");
75275
75714
  return { ok: true, filename, encoding: "utf8", content: svg, bytes: Buffer.byteLength(svg), savedTo: outPath };
75276
75715
  } catch (e) {
75277
75716
  app.log.error({ appId: req.params.appId, err: e instanceof Error ? e.message : e }, "export-svg: write failed");
@@ -75354,7 +75793,7 @@ async function startServer() {
75354
75793
  return reply.status(404).send({ ok: false, error: `"${id}" is not installed`, code: "not-installed" });
75355
75794
  }
75356
75795
  const contract = readAcceptedForRequest(id, void 0);
75357
- if (contract == null && (0, import_node_fs44.existsSync)(contractPath(id))) {
75796
+ if (contract == null && (0, import_node_fs45.existsSync)(contractPath(id))) {
75358
75797
  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" });
75359
75798
  }
75360
75799
  if (contract != null) {
@@ -75435,11 +75874,11 @@ async function startServer() {
75435
75874
  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 });
75436
75875
  }
75437
75876
  await deleteOrigin(id);
75438
- const stageRoot = (0, import_node_fs44.mkdtempSync)((0, import_node_path41.join)((0, import_node_os24.tmpdir)(), "floless-import-"));
75877
+ const stageRoot = (0, import_node_fs45.mkdtempSync)((0, import_node_path42.join)((0, import_node_os25.tmpdir)(), "floless-import-"));
75439
75878
  try {
75440
- const stageDir = (0, import_node_path41.join)(stageRoot, id);
75441
- (0, import_node_fs44.mkdirSync)(stageDir);
75442
- (0, import_node_fs44.writeFileSync)((0, import_node_path41.join)(stageDir, `${id}.flo`), content);
75879
+ const stageDir = (0, import_node_path42.join)(stageRoot, id);
75880
+ (0, import_node_fs45.mkdirSync)(stageDir);
75881
+ (0, import_node_fs45.writeFileSync)((0, import_node_path42.join)(stageDir, `${id}.flo`), content);
75443
75882
  await aware.install(stageDir);
75444
75883
  } catch (err2) {
75445
75884
  try {
@@ -75450,7 +75889,7 @@ async function startServer() {
75450
75889
  const reason = awareStderr(err2);
75451
75890
  return reply.status(502).send({ ok: false, error: `import failed: ${msg}`, code: "install-failed", reason, agentsUnavailable: unavailableAgents(reason) });
75452
75891
  } finally {
75453
- (0, import_node_fs44.rmSync)(stageRoot, { recursive: true, force: true });
75892
+ (0, import_node_fs45.rmSync)(stageRoot, { recursive: true, force: true });
75454
75893
  }
75455
75894
  broadcast({ type: "apps-changed", id });
75456
75895
  return { ok: true, id };
@@ -75465,13 +75904,13 @@ async function startServer() {
75465
75904
  }
75466
75905
  const inputs = appData.inputs.map((i) => ({ name: i.name, type: i.type }));
75467
75906
  const baked = bakeFloSource(appData.source.text, inputs);
75468
- const tmpRoot = (0, import_node_fs44.mkdtempSync)((0, import_node_path41.join)((0, import_node_os24.tmpdir)(), "floless-bake-"));
75469
- const backupDir2 = (0, import_node_path41.join)(tmpRoot, `${id}-backup`);
75470
- const bakeDir = (0, import_node_path41.join)(tmpRoot, id);
75471
- (0, import_node_fs44.cpSync)(appDir(id), backupDir2, { recursive: true });
75472
- (0, import_node_fs44.cpSync)(appDir(id), bakeDir, { recursive: true });
75907
+ const tmpRoot = (0, import_node_fs45.mkdtempSync)((0, import_node_path42.join)((0, import_node_os25.tmpdir)(), "floless-bake-"));
75908
+ const backupDir2 = (0, import_node_path42.join)(tmpRoot, `${id}-backup`);
75909
+ const bakeDir = (0, import_node_path42.join)(tmpRoot, id);
75910
+ (0, import_node_fs45.cpSync)(appDir(id), backupDir2, { recursive: true });
75911
+ (0, import_node_fs45.cpSync)(appDir(id), bakeDir, { recursive: true });
75473
75912
  const floName = appData.source.path.split(/[\\/]/).pop();
75474
- (0, import_node_fs44.writeFileSync)((0, import_node_path41.join)(bakeDir, floName), baked);
75913
+ (0, import_node_fs45.writeFileSync)((0, import_node_path42.join)(bakeDir, floName), baked);
75475
75914
  let appInstalled2 = true;
75476
75915
  try {
75477
75916
  await aware.uninstall(id);
@@ -75493,17 +75932,17 @@ async function startServer() {
75493
75932
  throw installErr;
75494
75933
  }
75495
75934
  try {
75496
- await aware.compile((0, import_node_path41.join)(appDir(id), floName));
75935
+ await aware.compile((0, import_node_path42.join)(appDir(id), floName));
75497
75936
  } catch (compileErr) {
75498
75937
  app.log.warn({ id, compileErr: String(compileErr) }, "bake: post-install recompile failed (app baked but may need a manual Compile)");
75499
75938
  }
75500
75939
  broadcast({ type: "baked", id });
75501
75940
  return { ok: true, id, agent: id, inputs };
75502
75941
  } finally {
75503
- if (appInstalled2) (0, import_node_fs44.rmSync)(tmpRoot, { recursive: true, force: true });
75942
+ if (appInstalled2) (0, import_node_fs45.rmSync)(tmpRoot, { recursive: true, force: true });
75504
75943
  }
75505
75944
  });
75506
- const graftAgentsDir = () => (0, import_node_path41.join)((0, import_node_os24.homedir)(), ".aware", "agents");
75945
+ const graftAgentsDir = () => (0, import_node_path42.join)((0, import_node_os25.homedir)(), ".aware", "agents");
75507
75946
  app.post("/api/graft/match", async (req, reply) => {
75508
75947
  const { glob } = req.body ?? {};
75509
75948
  if (!glob) return reply.status(400).send({ ok: false, error: "glob required" });
@@ -75520,7 +75959,7 @@ async function startServer() {
75520
75959
  if (!sourceKind || !sourceRef) {
75521
75960
  return reply.status(400).send({ ok: false, error: "sourceKind and sourceRef required" });
75522
75961
  }
75523
- const tempHome = (0, import_node_fs44.mkdtempSync)((0, import_node_path41.join)((0, import_node_os24.tmpdir)(), "floless-graft-"));
75962
+ const tempHome = (0, import_node_fs45.mkdtempSync)((0, import_node_path42.join)((0, import_node_os25.tmpdir)(), "floless-graft-"));
75524
75963
  let result;
75525
75964
  try {
75526
75965
  result = await aware.build({
@@ -75533,19 +75972,19 @@ async function startServer() {
75533
75972
  awareHome: tempHome
75534
75973
  });
75535
75974
  } catch (err2) {
75536
- (0, import_node_fs44.rmSync)(tempHome, { recursive: true, force: true });
75975
+ (0, import_node_fs45.rmSync)(tempHome, { recursive: true, force: true });
75537
75976
  const msg = err2 instanceof AwareError ? err2.message : String(err2?.message ?? err2);
75538
75977
  return reply.status(422).send({ ok: false, error: msg });
75539
75978
  }
75540
75979
  const manifest = readStagedManifest(result.agentDir);
75541
75980
  if (!manifest) {
75542
- (0, import_node_fs44.rmSync)(tempHome, { recursive: true, force: true });
75981
+ (0, import_node_fs45.rmSync)(tempHome, { recursive: true, force: true });
75543
75982
  return reply.status(502).send({ ok: false, error: `build produced output at ${result.agentDir} but no manifest.yaml` });
75544
75983
  }
75545
75984
  const token = (0, import_node_crypto20.randomUUID)();
75546
75985
  registerStage(token, tempHome, result.agentId);
75547
75986
  const preview2 = buildPreview(manifest, sourceKind, sourceRef, token);
75548
- if ((0, import_node_fs44.existsSync)((0, import_node_path41.join)(graftAgentsDir(), result.agentId))) {
75987
+ if ((0, import_node_fs45.existsSync)((0, import_node_path42.join)(graftAgentsDir(), result.agentId))) {
75549
75988
  preview2.warnings.unshift(`An agent named "${result.agentId}" is already installed \u2014 creating it will overwrite it.`);
75550
75989
  }
75551
75990
  return { ok: true, preview: preview2 };
@@ -75564,7 +76003,7 @@ async function startServer() {
75564
76003
  registerStage(stagedRef, stage.tempDir, stage.agentId);
75565
76004
  return reply.status(409).send({ ok: false, error: err2.message, agentId: stage.agentId, collision: true });
75566
76005
  }
75567
- (0, import_node_fs44.rmSync)(stage.tempDir, { recursive: true, force: true });
76006
+ (0, import_node_fs45.rmSync)(stage.tempDir, { recursive: true, force: true });
75568
76007
  throw err2;
75569
76008
  }
75570
76009
  broadcast({ type: "grafted", id: stage.agentId });
@@ -75881,11 +76320,11 @@ async function startServer() {
75881
76320
  app.get("/api/requests/:id/snapshot/:n", async (req, reply) => {
75882
76321
  const n = Number.parseInt(req.params.n, 10);
75883
76322
  const p = Number.isInteger(n) ? snapshotPathFor(req.params.id, n) : null;
75884
- if (!p || !(0, import_node_fs44.existsSync)(p)) return reply.status(404).send({ ok: false, error: "snapshot not found" });
76323
+ if (!p || !(0, import_node_fs45.existsSync)(p)) return reply.status(404).send({ ok: false, error: "snapshot not found" });
75885
76324
  const ext = p.split(".").pop().toLowerCase();
75886
76325
  reply.header("Content-Type", ext === "png" ? "image/png" : ext === "webp" ? "image/webp" : ext === "pdf" ? "application/pdf" : "image/jpeg");
75887
76326
  reply.header("Cache-Control", "no-store");
75888
- return (0, import_node_fs44.readFileSync)(p);
76327
+ return (0, import_node_fs45.readFileSync)(p);
75889
76328
  });
75890
76329
  app.post(
75891
76330
  "/api/tweak",
@@ -76112,7 +76551,7 @@ async function startServer() {
76112
76551
  warn(`last-run-status:${ref} \u2014 trace exists but couldn't be parsed (corrupt/truncated)`);
76113
76552
  let finishedAt2 = null;
76114
76553
  try {
76115
- finishedAt2 = (0, import_node_fs44.statSync)(latest.path).mtime.toISOString();
76554
+ finishedAt2 = (0, import_node_fs45.statSync)(latest.path).mtime.toISOString();
76116
76555
  } catch {
76117
76556
  finishedAt2 = null;
76118
76557
  }
@@ -76122,7 +76561,7 @@ async function startServer() {
76122
76561
  let finishedAt = typeof runEnd?.ts === "string" ? runEnd.ts : null;
76123
76562
  if (!finishedAt) {
76124
76563
  try {
76125
- finishedAt = (0, import_node_fs44.statSync)(latest.path).mtime.toISOString();
76564
+ finishedAt = (0, import_node_fs45.statSync)(latest.path).mtime.toISOString();
76126
76565
  } catch {
76127
76566
  finishedAt = null;
76128
76567
  }