@floless/app 0.111.3 → 0.112.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -50822,7 +50822,7 @@ function deriveSandboxLicenseDir() {
50822
50822
  deriveSandboxLicenseDir();
50823
50823
 
50824
50824
  // main.ts
50825
- var import_node_child_process11 = require("node:child_process");
50825
+ var import_node_child_process12 = require("node:child_process");
50826
50826
  var import_node_readline2 = require("node:readline");
50827
50827
 
50828
50828
  // index.ts
@@ -50830,7 +50830,7 @@ var import_node_url5 = require("node:url");
50830
50830
  var import_node_path45 = require("node:path");
50831
50831
  var import_node_os26 = require("node:os");
50832
50832
  var import_node_fs48 = require("node:fs");
50833
- var import_node_child_process9 = require("node:child_process");
50833
+ var import_node_child_process10 = require("node:child_process");
50834
50834
 
50835
50835
  // log.mjs
50836
50836
  var import_node_path = require("node:path");
@@ -52191,7 +52191,7 @@ function awareNpmVersion() {
52191
52191
  }
52192
52192
  }
52193
52193
  var SHELL_META = /[&|;<>^"'`$()%\r\n\0]/;
52194
- function runRaw(args, onSpawn) {
52194
+ function runRaw(args, onSpawn, envOverride) {
52195
52195
  const invoker = currentInvoker();
52196
52196
  const [bin, ...preArgs] = invoker.head;
52197
52197
  if (!bin) throw new AwareError("aware CLI invoker not resolved");
@@ -52201,7 +52201,11 @@ function runRaw(args, onSpawn) {
52201
52201
  }
52202
52202
  const argv = [...preArgs, ...args];
52203
52203
  return new Promise((resolve11, reject) => {
52204
- const child = (0, import_node_child_process2.spawn)(bin, argv, { shell: invoker.shell, windowsHide: true });
52204
+ const child = (0, import_node_child_process2.spawn)(bin, argv, {
52205
+ shell: invoker.shell,
52206
+ windowsHide: true,
52207
+ ...envOverride ? { env: { ...process.env, ...envOverride } } : {}
52208
+ });
52205
52209
  onSpawn?.(child);
52206
52210
  let stdout = "";
52207
52211
  let stderr = "";
@@ -52290,6 +52294,95 @@ function teklaBridgeStatus() {
52290
52294
  }
52291
52295
  return { path, version };
52292
52296
  }
52297
+ function resolveHostBridge(host) {
52298
+ const invoker = currentInvoker();
52299
+ const exe = `aware-${host}.exe`;
52300
+ const candidates = [
52301
+ (0, import_node_path6.join)((0, import_node_os6.homedir)(), ".aware", "bridges", exe),
52302
+ invoker.pkgDir ? (0, import_node_path6.join)(invoker.pkgDir, "binaries", exe) : null
52303
+ ].filter((p) => !!p);
52304
+ return candidates.find((p) => (0, import_node_fs7.existsSync)(p)) ?? null;
52305
+ }
52306
+ function hostBridgeStatus(host) {
52307
+ const path = resolveHostBridge(host);
52308
+ if (!path) return { path: null, version: null };
52309
+ let version = null;
52310
+ try {
52311
+ version = (0, import_node_fs7.readFileSync)((0, import_node_path6.join)((0, import_node_path6.dirname)(path), `aware-${host}.version`), "utf8").trim() || null;
52312
+ } catch {
52313
+ }
52314
+ return { path, version };
52315
+ }
52316
+ function standardUserTempDir() {
52317
+ return process.env.LOCALAPPDATA ? (0, import_node_path6.join)(process.env.LOCALAPPDATA, "Temp") : (0, import_node_path6.join)((0, import_node_os6.homedir)(), "AppData", "Local", "Temp");
52318
+ }
52319
+ async function hostInstances(host) {
52320
+ const bin = resolveHostBridge(host);
52321
+ if (!bin) return { ok: false, instances: [], probeFailed: true, error: `aware-${host} bridge not found (run \`aware sidecar install ${host}\`)` };
52322
+ const probe = (env3) => new Promise((resolve11) => {
52323
+ const child = (0, import_node_child_process2.spawn)(bin, ["list-instances"], { windowsHide: true, env: env3 ? { ...process.env, ...env3 } : process.env });
52324
+ let stdout = "";
52325
+ let stderr = "";
52326
+ const timer = setTimeout(() => child.kill(), 3e4);
52327
+ child.stdout.on("data", (d) => stdout += d.toString());
52328
+ child.stderr.on("data", (d) => stderr += d.toString());
52329
+ child.on("error", () => {
52330
+ clearTimeout(timer);
52331
+ resolve11({ code: -1, stdout: "", stderr: "spawn failed" });
52332
+ });
52333
+ child.on("close", (code) => {
52334
+ clearTimeout(timer);
52335
+ resolve11({ code, stdout, stderr });
52336
+ });
52337
+ });
52338
+ const parse = (stdout) => {
52339
+ try {
52340
+ const body = JSON.parse(stdout.trim());
52341
+ const rows2 = Array.isArray(body.instances) ? body.instances : [];
52342
+ return rows2.map((raw) => {
52343
+ const r = raw ?? {};
52344
+ return {
52345
+ pid: typeof r.pid === "number" ? r.pid : null,
52346
+ version: typeof r.version === "string" ? r.version : null,
52347
+ addinLoaded: typeof r.addin_loaded === "boolean" ? r.addin_loaded : null
52348
+ };
52349
+ });
52350
+ } catch {
52351
+ return [];
52352
+ }
52353
+ };
52354
+ let out = await probe();
52355
+ let answered = spoke(out.stdout);
52356
+ let instances = parse(out.stdout);
52357
+ let env2;
52358
+ if (host === "sketchup" && instances.length === 0) {
52359
+ const override = sketchupDiscoveryEnv();
52360
+ out = await probe(override);
52361
+ answered = answered || spoke(out.stdout);
52362
+ instances = parse(out.stdout);
52363
+ if (instances.length > 0) env2 = override;
52364
+ }
52365
+ if (instances.length === 0) {
52366
+ return {
52367
+ ok: false,
52368
+ instances: [],
52369
+ probeFailed: !answered,
52370
+ error: (out.stderr || out.stdout).trim().slice(0, 400) || void 0
52371
+ };
52372
+ }
52373
+ return { ok: true, instances, env: env2 };
52374
+ }
52375
+ function spoke(stdout) {
52376
+ try {
52377
+ const body = JSON.parse(stdout.trim());
52378
+ return !!body && typeof body === "object" && Array.isArray(body.instances);
52379
+ } catch {
52380
+ return false;
52381
+ }
52382
+ }
52383
+ function sketchupDiscoveryEnv() {
52384
+ return { AWARE_SKETCHUP_DISCOVERY_DIR: (0, import_node_path6.join)(standardUserTempDir(), "aware-sketchup") };
52385
+ }
52293
52386
  function resolveConnectionReaderBridge() {
52294
52387
  const p = (0, import_node_path6.join)((0, import_node_os6.homedir)(), ".aware", "bridges", "aware-connection-reader.exe");
52295
52388
  return (0, import_node_fs7.existsSync)(p) ? p : null;
@@ -52747,6 +52840,8 @@ var aware = {
52747
52840
  },
52748
52841
  refresh: refreshInvoker,
52749
52842
  teklaBridgeStatus,
52843
+ hostBridgeStatus,
52844
+ hostInstances,
52750
52845
  /** GET /api/apps */
52751
52846
  async list() {
52752
52847
  const { data } = await runJson(["app", "list"]);
@@ -53026,7 +53121,7 @@ var aware = {
53026
53121
  const { code, stdout, stderr } = await runRaw(args, (child) => {
53027
53122
  reg2 = { child, cancelled: false };
53028
53123
  activeRun = reg2;
53029
- });
53124
+ }, opts.env);
53030
53125
  if (reg2 && reg2.cancelled) {
53031
53126
  throw new AwareError("Run cancelled", { cancelled: true });
53032
53127
  }
@@ -53792,7 +53887,7 @@ function appVersion() {
53792
53887
  return resolveVersion({
53793
53888
  isSea: isSea2(),
53794
53889
  sqVersionXml: readSqVersionXml(),
53795
- define: true ? "0.111.3" : void 0,
53890
+ define: true ? "0.112.1" : void 0,
53796
53891
  pkgVersion: readPkgVersion()
53797
53892
  });
53798
53893
  }
@@ -53808,7 +53903,7 @@ function resolveChannel(s) {
53808
53903
  function appChannel() {
53809
53904
  return resolveChannel({
53810
53905
  isSea: isSea2(),
53811
- define: true ? "0.111.3" : void 0,
53906
+ define: true ? "0.112.1" : void 0,
53812
53907
  // argv[1] is the entry the runtime actually loaded (…/dist/floless-server.cjs), which is what
53813
53908
  // carries the npx cache prefix. Absent under the SEA exe, which never reaches the npx branch.
53814
53909
  modulePath: process.argv[1]
@@ -55117,8 +55212,11 @@ var SEC = Object.fromEntries(
55117
55212
  ([k, v]) => !k.startsWith("_") && Array.isArray(v)
55118
55213
  )
55119
55214
  );
55215
+ function canonicalDesignation(designation) {
55216
+ return (designation ?? "").trim().toUpperCase().replace(/[×✕✖]/g, "X").replace(/[‐-―−]/g, "-").replace(/[‘’ʹ′]/g, "'").replace(/[“”ʺ″]/g, '"').replace(/ /g, " ").replace(/\s+/g, "");
55217
+ }
55120
55218
  function sectionDimsIn(designation) {
55121
- const row = SEC[designation.trim().toUpperCase().replace(/\s+/g, "")];
55219
+ const row = SEC[canonicalDesignation(designation)];
55122
55220
  return row ? { d: row[0], bf: row[1] } : void 0;
55123
55221
  }
55124
55222
  var SECTION_DIMS_IN = Object.fromEntries(
@@ -55135,9 +55233,9 @@ function parseDim(tok) {
55135
55233
  }
55136
55234
  function xsectionFor(profile, dims) {
55137
55235
  const rect = { shape: "rect", w: dims.w, d: dims.d };
55138
- const raw = (profile ?? "").trim().toUpperCase().replace(/×/g, "X");
55236
+ const raw = (profile ?? "").trim().toUpperCase().replace(/[×✕✖]/g, "X").replace(/ /g, " ");
55139
55237
  if (!raw) return rect;
55140
- const key = raw.replace(/\s+/g, "");
55238
+ const key = canonicalDesignation(profile);
55141
55239
  const m = raw.match(/^([A-Z]+)\s*(.+)$/);
55142
55240
  if (!m) return rect;
55143
55241
  const prefix = m[1];
@@ -59709,6 +59807,11 @@ function canonicalHash(doc) {
59709
59807
  };
59710
59808
  return (0, import_node_crypto14.createHash)("sha256").update(JSON.stringify(norm(doc))).digest("hex");
59711
59809
  }
59810
+ function decisionsDigest(issues, docHash) {
59811
+ const decisions = issues.filter((i) => i.severity === "decision").map((i) => [i.code, i.sheet ?? null, i.path ?? null, i.message]);
59812
+ return (0, import_node_crypto14.createHash)("sha256").update(`${docHash}
59813
+ ${JSON.stringify(decisions)}`).digest("hex");
59814
+ }
59712
59815
  var KNOWN_READ_KINDS = /* @__PURE__ */ new Set(["steel-filter-segment"]);
59713
59816
  function previewMigration(v1, ctx) {
59714
59817
  const doc = isObj2(v1) ? v1 : {};
@@ -59971,7 +60074,11 @@ function previewMigration(v1, ctx) {
59971
60074
  survivor: { sheet: p.survivor.sheet, id: p.survivor.v1Id },
59972
60075
  conflicts: p.conflicts
59973
60076
  })),
59974
- pendingColMetadata: mat.pendingColMetadata
60077
+ pendingColMetadata: mat.pendingColMetadata,
60078
+ // Computed here, so preview and commit read the same field of the same function's output and there
60079
+ // is no second implementation to drift. `issues` is complete by this line — the last push is the
60080
+ // reference check above — and `ok` on the first line reads the same array.
60081
+ decisionsDigest: decisionsDigest(issues, contractHash(doc))
59975
60082
  };
59976
60083
  return { candidate: issues.some((i) => i.severity === "block") ? null : candidate, report, remap };
59977
60084
  }
@@ -60160,6 +60267,13 @@ async function runMigration(opts) {
60160
60267
  }
60161
60268
  const { candidate, report, remap } = previewMigration(current);
60162
60269
  if (!candidate) throw new ContractTransactionError("this contract cannot be migrated \u2014 see the preview report", "contract-not-migratable");
60270
+ if (report.decisionsDigest !== opts.expectDecisions) {
60271
+ throw new ContractTransactionError(
60272
+ "the decisions you confirmed are not the decisions this migration would commit \u2014 preview it again and re-confirm",
60273
+ "precondition-failed"
60274
+ );
60275
+ }
60276
+ const acknowledgedDecisions = report.issues.filter((i) => i.severity === "decision").map((i) => i.code);
60163
60277
  const uuid = getProject(projectId)?.uuid ?? null;
60164
60278
  const storeKey = uuid ?? (0, import_node_crypto15.randomUUID)();
60165
60279
  const generation = lastGeneration(projectId) + 1;
@@ -60174,7 +60288,8 @@ async function runMigration(opts) {
60174
60288
  from,
60175
60289
  to: STEEL_V2,
60176
60290
  expectContractHash: hash2,
60177
- expectLedgerHead: head
60291
+ expectLedgerHead: head,
60292
+ acknowledgedDecisions
60178
60293
  };
60179
60294
  writePhase(dir, "000-begin", begin);
60180
60295
  const before = {
@@ -61527,6 +61642,20 @@ function registerKnowledgeRoutes(app) {
61527
61642
  );
61528
61643
  }
61529
61644
 
61645
+ // mutation-id.ts
61646
+ var MUTATION_ID_RE = /^[A-Za-z0-9._~-]{1,64}$/;
61647
+ function sanitizeMutationId(raw) {
61648
+ if (typeof raw !== "string") return void 0;
61649
+ return MUTATION_ID_RE.test(raw) ? raw : void 0;
61650
+ }
61651
+ function contractChangedEvent(appId, project, etag, rawMutationId) {
61652
+ const mutationId = sanitizeMutationId(rawMutationId);
61653
+ return { type: "contract-changed", appId, project, etag, ...mutationId ? { mutationId } : {} };
61654
+ }
61655
+ function contractChangedWithReason(appId, project, reason) {
61656
+ return { type: "contract-changed", appId, project, reason };
61657
+ }
61658
+
61530
61659
  // steel-revision-registry.ts
61531
61660
  var IGNORED_INPUT = /* @__PURE__ */ new Set([
61532
61661
  "$.read_notes",
@@ -61634,7 +61763,74 @@ var REGISTRY = /* @__PURE__ */ new Map([
61634
61763
  // `continue`s on this key before `entryFor` is ever called, and that `continue` is the load-bearing
61635
61764
  // line (removing it fails 19 tests, while changing this disposition fails none). Not `descend`, so
61636
61765
  // the coverage test does not demand an entry per observation field.
61637
- ["$.plans[].memberObservations", { disposition: "auto", note: "drawing evidence, classified per observation rather than as a plan field" }]
61766
+ ["$.plans[].memberObservations", { disposition: "auto", note: "drawing evidence, classified per observation rather than as a plan field" }],
61767
+ // ── the document ROOT (P7c-2) ────────────────────────────────────────────────
61768
+ //
61769
+ // THERE IS NO `$.members` OR `$.plans` ROW HERE, AND ADDING ONE WOULD BE A DISASTER. That is not a
61770
+ // style note — it is measured. `entryFor`'s ancestor veto matches `key + '['` as well as `key + '.'`,
61771
+ // so `$.members` is an ANCESTOR of `$.members[]` and of every path beneath it. A single
61772
+ // `['$.members', { disposition: 'issue' }]` therefore refuses `$.members[].profile`,
61773
+ // `$.members[].ends[].conn` and every other MEMBER field — every member proposal in the product
61774
+ // becomes a refusal. `$.plans` does the same to plans.
61775
+ //
61776
+ // EACH ROW VETOES ITS OWN SUBTREE AND ONLY ITS OWN, which is worth stating exactly, because the
61777
+ // sentence here first said one `$.members` row refuses "every member and plan field" and a review
61778
+ // caught it: the veto is a path-prefix rule, so `$.members` cannot reach `$.plans[]`. It takes both
61779
+ // rows to lose both halves — and "completing the root for consistency" is precisely the edit that
61780
+ // adds both at once, which is why the pair is named together.
61781
+ //
61782
+ // (Not the whole feature either way: evidence and binding updates do not go through this table and
61783
+ // would still flow. The damage is to the confirmable half, which is the half this unit exists for.)
61784
+ // Probed directly before this block was written, and pinned by a test in
61785
+ // `steel-revision-registry.test.ts` — one that drives EACH row separately — so the next author fails
61786
+ // loudly instead of shipping it.
61787
+ //
61788
+ // Those two keys need no entry anyway: the classifier's `HANDLED_ROOT` walks them through their own
61789
+ // loops, and the root coverage test exempts them the same way. `$.read_notes` is likewise absent —
61790
+ // it is revision-PRODUCED output and lives in `IGNORED_INPUT`.
61791
+ //
61792
+ // Everything else at the root is enumerated EXPLICITLY, including the refusals, for the reason the
61793
+ // plan block above gives: the coverage test then reads a decision rather than an omission, and the
61794
+ // refusal a user sees carries a `note` saying why instead of one generic sentence for 24 keys.
61795
+ // THE ONE ROOT FIELD A REVISION READ MAY MOVE — the parent plan's §4.3 list, finally implemented.
61796
+ // A revised drawing set whose printed grid moved is a canonical change to an existing model, which
61797
+ // is precisely what the diff-review UI exists to show. Compared WHOLE (no `descend`): you propose a
61798
+ // grid, not `grid.x` independently, because a partial grid is not a thing the classifier can produce
61799
+ // or a human can sensibly confirm.
61800
+ ["$.grid", { disposition: "propose", note: "the one model-wide structural grid" }],
61801
+ // Contract identity and provenance — stamped by whatever created or migrated the model.
61802
+ ["$.type", { disposition: "issue", note: "which contract this is, is decided when the model is created or migrated" }],
61803
+ ["$.origin", { disposition: "issue", note: "whether the model was migrated or authored natively is a fact about its history" }],
61804
+ ["$.migration", { disposition: "issue", note: "the v1 to v2 provenance block is written by the migration that produced it" }],
61805
+ ["$.source", { disposition: "issue", note: "where the model was read from is stamped by the server, not asserted by the document" }],
61806
+ // The user's own settings and the pre-read pass's output.
61807
+ ["$.target_confidence", { disposition: "issue", note: "the confidence target is the user's setting, not the read's to change" }],
61808
+ ["$.filter", { disposition: "issue", note: "the layer and colour filter is written by the pre-read pass" }],
61809
+ ["$.active", { disposition: "issue", note: "which sheet is open is the user's place in the editor" }],
61810
+ // Engineering structure beyond members. Refused for the same reason plan-level fields were before
61811
+ // P6b — revising these is a later unit's subject, and a PR that widens write authority as a side
61812
+ // effect of another change is how the authority this unit spent six sub-units narrowing leaks back.
61813
+ ["$.connections", { disposition: "issue", note: "the connection library is authored in the editor, not read off a framing plan" }],
61814
+ ["$.joints", { disposition: "issue", note: "placed connections are authored in the editor" }],
61815
+ ["$.moment_frames", { disposition: "issue", note: "the moment-frame schedule is not among the fields a revision read stages" }],
61816
+ // Derived by a server-side lookup — asserting it from a document would let an AI claim work it did
61817
+ // not do, which is the same argument `$.plans[].autofilled` makes one level down.
61818
+ ["$.weights", { disposition: "issue", note: "section weights are looked up from the section tables, not read off a drawing" }],
61819
+ // Draft-only editor and display state. Authored by a HUMAN in the editor, and a revision read has no
61820
+ // view on any of it.
61821
+ ["$.palette", { disposition: "issue", note: "display colours are chosen in the editor" }],
61822
+ ["$.profile_colors", { disposition: "issue", note: "display colours are chosen in the editor" }],
61823
+ ["$.member_styles", { disposition: "issue", note: "line styles are chosen in the editor" }],
61824
+ ["$.member_types", { disposition: "issue", note: "the member-type registry is authored in the editor" }],
61825
+ ["$.views", { disposition: "issue", note: "saved views are the user's own camera bookmarks" }],
61826
+ ["$.dims3d", { disposition: "issue", note: "3D dimensions are drawn by the user" }],
61827
+ ["$.dim_overlays", { disposition: "issue", note: "dimension overlay toggles are editor state" }],
61828
+ ["$.dim_style", { disposition: "issue", note: "dimension styling is editor state" }],
61829
+ ["$.prop_labels", { disposition: "issue", note: "which properties render as chips is editor state" }],
61830
+ ["$.detail_placements", { disposition: "issue", note: "placed details are authored in the editor" }],
61831
+ ["$.detail_bubbles", { disposition: "issue", note: "detail bubble anchors are authored in the editor" }],
61832
+ ["$.custom_details", { disposition: "issue", note: "user-created detail images are uploaded in the editor" }],
61833
+ ["$.sheet_previews", { disposition: "issue", note: "sheet previews are generated from the source pages, not authored by a read" }]
61638
61834
  ]);
61639
61835
  function entryFor(registryKey, registry2 = REGISTRY) {
61640
61836
  const isAncestor = (key) => key !== registryKey && (registryKey.startsWith(key + ".") || registryKey.startsWith(key + "["));
@@ -61969,15 +62165,26 @@ function stageRevisionRead(current, incoming) {
61969
62165
  const HANDLED_ROOT = /* @__PURE__ */ new Set(["members", "plans"]);
61970
62166
  const curRoot = current;
61971
62167
  const incRoot = incoming;
61972
- for (const key of /* @__PURE__ */ new Set([...Object.keys(curRoot), ...Object.keys(incRoot)])) {
62168
+ for (const key of [.../* @__PURE__ */ new Set([...Object.keys(curRoot), ...Object.keys(incRoot)])].sort()) {
61973
62169
  if (HANDLED_ROOT.has(key)) continue;
61974
62170
  if (IGNORED_INPUT.has(registryKeyOf(`$.${key}`))) continue;
61975
- if (!valuesDiffer(curRoot[key], incRoot[key])) continue;
61976
- add(
61977
- `$.${key}`,
61978
- "path-refused",
61979
- `"${key}" is model-level structure a revision read may not change \u2014 only members and their drawing evidence are staged here`
61980
- );
62171
+ const entry2 = entryFor(`$.${key}`);
62172
+ if (!valuesDiffer(curRoot[key], incRoot[key], entry2)) continue;
62173
+ if (entry2?.disposition === "propose" && incRoot[key] !== void 0 && incRoot[key] !== null) {
62174
+ proposals.push({ kind: "model-changed", key, before: curRoot[key], after: incRoot[key] });
62175
+ } else if (entry2?.disposition === "propose") {
62176
+ add(
62177
+ `$.${key}`,
62178
+ "path-refused",
62179
+ `"${key}" is missing from this read, and a revision read may not remove model-level structure \u2014 omitting a key is not a request to delete it. Remove it in the editor if that is what you want.`
62180
+ );
62181
+ } else {
62182
+ add(
62183
+ `$.${key}`,
62184
+ "path-refused",
62185
+ `"${key}" is model-level structure a revision read may not change${entry2?.note ? ` \u2014 ${entry2.note}` : ""}`
62186
+ );
62187
+ }
61981
62188
  }
61982
62189
  return { accepted, bindingUpdates, bindingProposals, proposals, issues };
61983
62190
  }
@@ -62080,6 +62287,20 @@ function applyStagedRevision(current, staged, selection = SELECT_NOTHING) {
62080
62287
  }
62081
62288
  break;
62082
62289
  }
62290
+ case "model-changed": {
62291
+ if (!writableLeaf(`$.${p.key}`)) {
62292
+ throw new RevisionApplyError(
62293
+ `applyStagedRevision: "${p.key}" is not a model field a revision read may change \u2014 the staged proposal does not match the registry`
62294
+ );
62295
+ }
62296
+ if (p.after === void 0 || p.after === null) {
62297
+ throw new RevisionApplyError(
62298
+ `applyStagedRevision: "${p.key}" carries no value \u2014 a revision read may not remove model-level structure, and staging does not produce this`
62299
+ );
62300
+ }
62301
+ writeField(next, p.key, p.after);
62302
+ break;
62303
+ }
62083
62304
  }
62084
62305
  }
62085
62306
  const bySheet = /* @__PURE__ */ new Map();
@@ -64057,7 +64278,7 @@ function sceneRelationships(scene) {
64057
64278
  return { boltParentById, gridParentById, gridChildrenByParent, trimmedGridIds, teklaOmittableMeshIds };
64058
64279
  }
64059
64280
  function sinkKind(sink, canonicalKind) {
64060
- if (sink === "tekla") {
64281
+ if (sink === "tekla" || sink === "host-members") {
64061
64282
  if (canonicalKind === "plate-hole" || canonicalKind === "bolt-hole-effect") return "opening";
64062
64283
  return canonicalKind;
64063
64284
  }
@@ -64075,6 +64296,15 @@ function validateProducerUnsupported(row) {
64075
64296
  }
64076
64297
  }
64077
64298
  function validateSinkUnsupported(sink, unsupported, relationships) {
64299
+ if (sink === "host-members") {
64300
+ const member = unsupported.find((row) => row.kind === "member");
64301
+ if (member) {
64302
+ throw new ReceiptReconciliationError(
64303
+ `member "${member.id}" came back unsupported ("${String(member.code)}") \u2014 a dragged member must be built or fail, never silently skipped.`
64304
+ );
64305
+ }
64306
+ return;
64307
+ }
64078
64308
  if (sink === "ifc") {
64079
64309
  if (unsupported.length > 0) {
64080
64310
  throw new ReceiptReconciliationError(
@@ -64194,10 +64424,11 @@ function reconcileReceipt(sceneInput, rawReceipt, producerUnsupported = [], sink
64194
64424
  }
64195
64425
  const missing = [...expected.keys()].filter((id) => !seen.has(id));
64196
64426
  if (missing.length) throw new ReceiptReconciliationError(`receipt omitted ${missing.length} scene record(s): ${missing.slice(0, 5).join(", ")}`);
64197
- if (sink === "tekla" || receipt.sourceId !== void 0) {
64427
+ const identityRequired = sink === "tekla" || sink === "host-members";
64428
+ if (identityRequired || receipt.sourceId !== void 0) {
64198
64429
  if (receipt.sourceId !== meta.sourceId) throw new ReceiptReconciliationError("receipt sourceId does not match the exported scene.");
64199
64430
  }
64200
- if (sink === "tekla" || receipt.sceneHash !== void 0) {
64431
+ if (identityRequired || receipt.sceneHash !== void 0) {
64201
64432
  if (receipt.sceneHash !== meta.sceneHash) throw new ReceiptReconciliationError("receipt sceneHash does not match the exported scene.");
64202
64433
  }
64203
64434
  if (receipt.ok !== true || failed.length) {
@@ -64241,6 +64472,9 @@ function reconcileReceipt(sceneInput, rawReceipt, producerUnsupported = [], sink
64241
64472
  function reconcileExportReceipt(sceneInput, rawReceipt, producerUnsupported = []) {
64242
64473
  return reconcileReceipt(sceneInput, rawReceipt, producerUnsupported, "tekla");
64243
64474
  }
64475
+ function reconcileHostExportReceipt(sceneInput, rawReceipt, producerUnsupported = []) {
64476
+ return reconcileReceipt(sceneInput, rawReceipt, producerUnsupported, "host-members");
64477
+ }
64244
64478
  function reconcileIfcExportReceipt(sceneInput, rawReceipt, producerUnsupported = [], artifact) {
64245
64479
  const receipt = reconcileReceipt(sceneInput, rawReceipt, producerUnsupported, "ifc");
64246
64480
  checkIfcArtifact(sceneInput, record(rawReceipt, "receipt"), receipt.emitted, artifact.index, artifact.bytes);
@@ -64317,7 +64551,7 @@ function foldedWeight(weights, profile) {
64317
64551
  }
64318
64552
  function profileDimsIn(profile) {
64319
64553
  if (!profile) return null;
64320
- const p = profile.trim().toUpperCase().replace(/×/g, "X");
64554
+ const p = profile.trim().toUpperCase().replace(/[×✕✖]/g, "X").replace(/ /g, " ");
64321
64555
  if (p === "" || /(^|[^A-Z])MF($|[^A-Z])/.test(p)) return null;
64322
64556
  const m = p.match(/^([A-Z]+)\s*(.+)$/);
64323
64557
  if (!m) return null;
@@ -64359,13 +64593,13 @@ function dispToMm(pt, ptPerFt) {
64359
64593
  return [pt[0] * k, -pt[1] * k];
64360
64594
  }
64361
64595
  function inferMaterial(profile) {
64362
- const P = profile.toUpperCase().replace(/×/g, "X").replace(/\s+/g, "");
64596
+ const P = canonicalDesignation(profile);
64363
64597
  if (P.startsWith("HSS")) return "A500-GR.B";
64364
64598
  if (/^W\d/.test(P)) return "A992";
64365
64599
  return "A36";
64366
64600
  }
64367
64601
  function teklaClassFor(profile, role) {
64368
- const P = profile.toUpperCase().replace(/×/g, "X").replace(/\s+/g, "");
64602
+ const P = canonicalDesignation(profile);
64369
64603
  if (/^L\d/.test(P)) return "7";
64370
64604
  if (/^M?C\d/.test(P)) return "8";
64371
64605
  const isHSS = P.startsWith("HSS");
@@ -65709,7 +65943,7 @@ function registerRevisionRoutes(app) {
65709
65943
  const message = typeof req.body?.message === "string" && req.body.message.trim() ? req.body.message.trim() : "Re-read a revised drawing set";
65710
65944
  const source = request.sourceRefs && request.sourceRefs.length ? { files: request.sourceRefs, requestId: request.id } : void 0;
65711
65945
  const version = createVersion(project.id, req.body.contract, { author: "AI", message, gate: null, kind: "revision-read", source });
65712
- broadcast({ type: "contract-changed", appId: project.app, project: project.id });
65946
+ broadcast(contractChangedWithReason(project.app, project.id, "revision-read"));
65713
65947
  deleteRequest(request.id);
65714
65948
  return { ok: true, version };
65715
65949
  }
@@ -65853,7 +66087,7 @@ function registerRevisionRoutes(app) {
65853
66087
  const message = typeof req.body?.message === "string" && req.body.message.trim() ? req.body.message.trim() : "Re-read a revised drawing set";
65854
66088
  const source = request.sourceRefs && request.sourceRefs.length ? { files: request.sourceRefs, requestId: request.id } : void 0;
65855
66089
  const version = createVersion(project.id, next, { author: "AI", message, gate: null, kind: "revision-read", source });
65856
- broadcast({ type: "contract-changed", appId: project.app, project: project.id });
66090
+ broadcast(contractChangedWithReason(project.app, project.id, "revision-read"));
65857
66091
  dropStagingFor(stagingKey);
65858
66092
  deleteRequest(request.id);
65859
66093
  return { ok: true, version };
@@ -65887,7 +66121,7 @@ var DATUM_ON_V2 = `A ${STEEL_V2} model has no root \`datum\`: v1's chose which g
65887
66121
  var PLAN_KEYS_V1 = ["grid", "datum_at", "datum_ref", "control2_at", "control2_ref", "elevation_in"];
65888
66122
  var PLAN_KEYS_V2 = ["datum_at", "datum_ref", "control2_at", "control2_ref", "elevation_in"];
65889
66123
  var planKeysFor = (declared) => declared === STEEL_V2 ? PLAN_KEYS_V2 : PLAN_KEYS_V1;
65890
- var NOT_WRITABLE_FROM_A_READ = "The model grid is not writable from a read: a human moves it in the editor's Grid panel, and a grid change a re-read finds is reported for them to act on.";
66124
+ var NOT_WRITABLE_FROM_A_READ = "The model grid is not writable from a read: a human moves it in the editor's Grid panel, and a revision read that finds the grid moved stages it as a proposal for them to accept.";
65891
66125
  var GRID_ON_V2 = `A ${STEEL_V2} model keeps ONE grid for the whole model rather than one per sheet, so a sheet's \`grid\` has nowhere to go. ` + NOT_WRITABLE_FROM_A_READ;
65892
66126
  var GRID_AT_ROOT_ON_V2 = `A ${STEEL_V2} model does keep its grid at the root, but it is canonical model structure rather than a pre-read block. ` + NOT_WRITABLE_FROM_A_READ;
65893
66127
  var isObj5 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
@@ -66668,7 +66902,8 @@ function registerMigrationPreviewRoute(app, deps) {
66668
66902
  if (bad) return reply.status(404).send({ ok: false, error: bad });
66669
66903
  }
66670
66904
  const body = isObj2(req.body) ? req.body : null;
66671
- const doc = body && "contract" in body ? body.contract : project ? deps.readContract(req.params.appId, project) : deps.readContractForApp(req.params.appId);
66905
+ const posted = !!(body && "contract" in body);
66906
+ const doc = posted ? body.contract : project ? deps.readContract(req.params.appId, project) : deps.readContractForApp(req.params.appId);
66672
66907
  if (doc == null) return reply.status(404).send({ ok: false, error: "no contract to migrate" });
66673
66908
  const v = validateSteelTakeoff(doc);
66674
66909
  if (!v.valid) {
@@ -66677,7 +66912,15 @@ function registerMigrationPreviewRoute(app, deps) {
66677
66912
  }
66678
66913
  const { candidate, report, remap } = previewMigration(doc);
66679
66914
  const slim = candidate ? stripConfidentialImages(candidate) : null;
66680
- return reply.send({ ok: report.ok, candidate: slim, report: { ...report, rastersOmitted: true }, remap });
66915
+ const shown = { ...report, rastersOmitted: true };
66916
+ if (posted) delete shown.decisionsDigest;
66917
+ return reply.send({
66918
+ ok: report.ok,
66919
+ candidate: slim,
66920
+ previewOf: posted ? "posted" : "stored",
66921
+ report: shown,
66922
+ remap
66923
+ });
66681
66924
  }
66682
66925
  );
66683
66926
  }
@@ -66734,6 +66977,14 @@ function registerMigrationCommitRoute(app, deps) {
66734
66977
  code: "precondition-required"
66735
66978
  });
66736
66979
  }
66980
+ const decisions = req.body?.acknowledgeDecisions;
66981
+ if (typeof decisions !== "string" || !decisions) {
66982
+ return reply.status(428).send({
66983
+ ok: false,
66984
+ error: "a migration must name the decisions you confirmed: send `acknowledgeDecisions: <the decisionsDigest from the preview>`",
66985
+ code: "precondition-required"
66986
+ });
66987
+ }
66737
66988
  try {
66738
66989
  const res = await runMigration({
66739
66990
  appId: req.params.appId,
@@ -66741,8 +66992,10 @@ function registerMigrationCommitRoute(app, deps) {
66741
66992
  // Unquoted, because `etagOf` quotes per HTTP while `contractHash` does not. Comparing the two
66742
66993
  // spellings would refuse every correct precondition.
66743
66994
  expectContractHash: tag.replace(/^"|"$/g, ""),
66744
- expectLedgerHead: head
66995
+ expectLedgerHead: head,
66996
+ expectDecisions: decisions
66745
66997
  });
66998
+ deps.broadcast(contractChangedWithReason(req.params.appId, project, "migration"));
66746
66999
  return reply.send(res);
66747
67000
  } catch (e) {
66748
67001
  if (e instanceof RecoveryPendingError) {
@@ -71557,6 +71810,71 @@ function writeViewer3dApp(dir, appId, scene) {
71557
71810
  bakeSceneIntoApp(flo, scene);
71558
71811
  return flo;
71559
71812
  }
71813
+ function writeRevitApp(dir, appId, scene, hostPid, revitVersion = "2026") {
71814
+ (0, import_node_fs35.mkdirSync)(dir, { recursive: true });
71815
+ const flo = (0, import_node_path31.join)(dir, `${appId}.flo`);
71816
+ (0, import_node_fs35.writeFileSync)(flo, [
71817
+ `app: ${appId}`,
71818
+ "version: 0.1.0",
71819
+ "display-name: Steel to Revit",
71820
+ "description: Native Revit elements created from an approved steel.takeoff/v1 contract (a companion bake; the contract is the source of truth). Needs Revit open with a document.",
71821
+ "exposes-as-agent: false",
71822
+ "requires:",
71823
+ " - revit-2026@0.1.x",
71824
+ "layout: linear",
71825
+ "nodes:",
71826
+ " - id: bake-revit",
71827
+ " agent: revit-2026",
71828
+ " command: bake-scene",
71829
+ " mode: write",
71830
+ " safety:",
71831
+ " snapshot: true",
71832
+ // the bake is one Revit Transaction, so one Undo reverts it
71833
+ " config:",
71834
+ ` version: ${JSON.stringify(revitVersion)}`,
71835
+ // The PID of the Revit window the user actually released over. Without it the bridge picks
71836
+ // among matching sessions itself, so with two Revit 2026 windows open a drag aimed at one
71837
+ // could materialize in the other — the members appear, just not where the user pointed. The
71838
+ // whole gesture is "it goes where you dropped it", so the target has to travel with the bake.
71839
+ ...hostPid != null && Number.isInteger(hostPid) && hostPid > 0 ? [` host_pid: ${hostPid}`] : [],
71840
+ // Deliberately NO `label`: Tekla's bake announces itself in the status bar, but Revit has no
71841
+ // status bar and its TaskDialog is modal — an announcement would block the bake it announces.
71842
+ // The UI toast carries the feedback instead.
71843
+ " scene: {}",
71844
+ ""
71845
+ ].join("\n"));
71846
+ bakeSceneIntoApp(flo, scene, "revit-2026");
71847
+ return flo;
71848
+ }
71849
+ function writeSketchupApp(dir, appId, scene) {
71850
+ (0, import_node_fs35.mkdirSync)(dir, { recursive: true });
71851
+ const flo = (0, import_node_path31.join)(dir, `${appId}.flo`);
71852
+ (0, import_node_fs35.writeFileSync)(flo, [
71853
+ `app: ${appId}`,
71854
+ "version: 0.1.0",
71855
+ "display-name: Steel to SketchUp",
71856
+ "description: Native SketchUp groups created from an approved steel.takeoff/v1 contract (a companion bake; the contract is the source of truth). Needs SketchUp open with the AWARE bridge loaded.",
71857
+ "exposes-as-agent: false",
71858
+ "requires:",
71859
+ " - sketchup-2026@0.1.x",
71860
+ "layout: linear",
71861
+ "nodes:",
71862
+ " - id: bake-sketchup",
71863
+ " agent: sketchup-2026",
71864
+ " command: bake-scene",
71865
+ " mode: write",
71866
+ " safety:",
71867
+ " snapshot: true",
71868
+ // the bake is one start_operation, so one SketchUp Undo reverts it
71869
+ " config:",
71870
+ " label: FloLess",
71871
+ // SketchUp DOES have a status bar, so the bake can say who is writing
71872
+ " scene: {}",
71873
+ ""
71874
+ ].join("\n"));
71875
+ bakeSceneIntoApp(flo, scene, "sketchup-2026");
71876
+ return flo;
71877
+ }
71560
71878
  function writeTeklaApp(dir, appId, scene, teklaVersion = "2026.0") {
71561
71879
  (0, import_node_fs35.mkdirSync)(dir, { recursive: true });
71562
71880
  const flo = (0, import_node_path31.join)(dir, `${appId}.flo`);
@@ -72428,6 +72746,408 @@ async function teklaReadiness(deps = DEFAULT_DEPS) {
72428
72746
  }
72429
72747
  }
72430
72748
 
72749
+ // host-window.ts
72750
+ var import_node_child_process6 = require("node:child_process");
72751
+ var HOST_PROCESS_NAMES = {
72752
+ teklastructures: "tekla",
72753
+ revit: "revit",
72754
+ sketchup: "sketchup"
72755
+ };
72756
+ var DEFAULT_DEPS2 = {
72757
+ runPowerShell: (script) => new Promise((resolve11, reject) => {
72758
+ (0, import_node_child_process6.execFile)(
72759
+ "powershell.exe",
72760
+ ["-NoProfile", "-NonInteractive", "-ExecutionPolicy", "Bypass", "-Command", script],
72761
+ { encoding: "utf8", windowsHide: true, timeout: 5e3, maxBuffer: 1 << 20 },
72762
+ (error, stdout) => error ? reject(error) : resolve11(stdout)
72763
+ );
72764
+ }),
72765
+ platform: process.platform
72766
+ };
72767
+ function probeScript(x, y) {
72768
+ return `
72769
+ $ErrorActionPreference = 'Stop'
72770
+ Add-Type -TypeDefinition @'
72771
+ using System;
72772
+ using System.Runtime.InteropServices;
72773
+ public static class AwareHitTest {
72774
+ [StructLayout(LayoutKind.Sequential)] public struct POINT { public int X; public int Y; }
72775
+ [DllImport("user32.dll")] public static extern IntPtr WindowFromPoint(POINT p);
72776
+ [DllImport("user32.dll")] public static extern IntPtr GetAncestor(IntPtr hwnd, uint flags);
72777
+ [DllImport("user32.dll")] public static extern uint GetWindowThreadProcessId(IntPtr hwnd, out uint pid);
72778
+ [DllImport("user32.dll")] public static extern bool SetProcessDPIAware();
72779
+ }
72780
+ '@
72781
+ [void][AwareHitTest]::SetProcessDPIAware()
72782
+ $pt = New-Object 'AwareHitTest+POINT'
72783
+ $pt.X = ${x}
72784
+ $pt.Y = ${y}
72785
+ $h = [AwareHitTest]::WindowFromPoint($pt)
72786
+ if ($h -eq [IntPtr]::Zero) { Write-Output '{"pid":null,"name":null}'; exit 0 }
72787
+ $root = [AwareHitTest]::GetAncestor($h, 2)
72788
+ if ($root -eq [IntPtr]::Zero) { $root = $h }
72789
+ [uint32]$owner = 0
72790
+ [void][AwareHitTest]::GetWindowThreadProcessId($root, [ref]$owner)
72791
+ if ($owner -eq 0) { Write-Output '{"pid":null,"name":null}'; exit 0 }
72792
+ $proc = Get-Process -Id $owner -ErrorAction SilentlyContinue
72793
+ $name = if ($proc) { $proc.ProcessName } else { $null }
72794
+ [Console]::Out.Write((ConvertTo-Json -Compress ([ordered]@{ pid = $owner; name = $name })))
72795
+ `.trim();
72796
+ }
72797
+ function candidatePoints(cssX, cssY, dpr) {
72798
+ const ratio = Number.isFinite(dpr) && dpr > 0 ? dpr : 1;
72799
+ const scaled = [Math.round(cssX * ratio), Math.round(cssY * ratio)];
72800
+ const raw = [Math.round(cssX), Math.round(cssY)];
72801
+ if (scaled[0] === raw[0] && scaled[1] === raw[1]) return [scaled];
72802
+ return [scaled, raw];
72803
+ }
72804
+ function hostForProcessName(processName) {
72805
+ if (!processName) return null;
72806
+ return HOST_PROCESS_NAMES[processName.trim().toLowerCase().replace(/\.exe$/, "")] ?? null;
72807
+ }
72808
+ async function hostAtScreenPoint(x, y, deps = DEFAULT_DEPS2) {
72809
+ const miss = { probed: false, host: null, processName: null, pid: null };
72810
+ if (deps.platform !== "win32") return miss;
72811
+ if (!Number.isFinite(x) || !Number.isFinite(y)) return miss;
72812
+ const px = Math.round(x);
72813
+ const py = Math.round(y);
72814
+ if (!Number.isSafeInteger(px) || !Number.isSafeInteger(py)) return miss;
72815
+ let stdout;
72816
+ try {
72817
+ stdout = await deps.runPowerShell(probeScript(px, py));
72818
+ } catch {
72819
+ return miss;
72820
+ }
72821
+ let parsed;
72822
+ try {
72823
+ parsed = JSON.parse(stdout.trim());
72824
+ } catch {
72825
+ return miss;
72826
+ }
72827
+ if (!parsed || typeof parsed !== "object") return miss;
72828
+ const row = parsed;
72829
+ if (!("pid" in row)) return miss;
72830
+ const pid = typeof row.pid === "number" && Number.isFinite(row.pid) ? row.pid : null;
72831
+ const processName = typeof row.name === "string" && row.name.trim() ? row.name.trim() : null;
72832
+ return { probed: true, host: hostForProcessName(processName), processName, pid };
72833
+ }
72834
+ async function hostWindowRects(deps = DEFAULT_DEPS2) {
72835
+ if (deps.platform !== "win32") return [];
72836
+ let stdout;
72837
+ try {
72838
+ stdout = await deps.runPowerShell(HOST_RECTS_SCRIPT);
72839
+ } catch {
72840
+ return [];
72841
+ }
72842
+ let parsed;
72843
+ try {
72844
+ parsed = JSON.parse(stdout.trim() || "[]");
72845
+ } catch {
72846
+ return [];
72847
+ }
72848
+ const rows2 = Array.isArray(parsed) ? parsed : parsed && typeof parsed === "object" ? [parsed] : [];
72849
+ const out = [];
72850
+ for (const raw of rows2) {
72851
+ if (!raw || typeof raw !== "object") continue;
72852
+ const row = raw;
72853
+ const nums = ["pid", "left", "top", "right", "bottom"].map(
72854
+ (k) => typeof row[k] === "number" && Number.isFinite(row[k]) ? row[k] : null
72855
+ );
72856
+ if (nums.some((n) => n === null)) continue;
72857
+ const [pid, left, top, right, bottom] = nums;
72858
+ if (right <= left || bottom <= top) continue;
72859
+ const host = hostForProcessName(typeof row.name === "string" ? row.name : null);
72860
+ out.push(host ? { host, pid, left, top, right, bottom } : { host: null, left, top, right, bottom });
72861
+ }
72862
+ return out;
72863
+ }
72864
+ var HOST_RECTS_SCRIPT = `
72865
+ $ErrorActionPreference = 'Stop'
72866
+ Add-Type -TypeDefinition @'
72867
+ using System;
72868
+ using System.Collections.Generic;
72869
+ using System.Runtime.InteropServices;
72870
+ public static class AwareHostRects {
72871
+ [StructLayout(LayoutKind.Sequential)] public struct RECT { public int L, T, R, B; }
72872
+ public delegate bool EnumProc(IntPtr hwnd, IntPtr param);
72873
+ [DllImport("user32.dll")] public static extern bool EnumWindows(EnumProc cb, IntPtr param);
72874
+ [DllImport("user32.dll")] public static extern bool IsWindowVisible(IntPtr hwnd);
72875
+ [DllImport("user32.dll")] public static extern bool IsIconic(IntPtr hwnd);
72876
+ [DllImport("user32.dll")] public static extern bool GetWindowRect(IntPtr hwnd, out RECT r);
72877
+ [DllImport("user32.dll")] public static extern uint GetWindowThreadProcessId(IntPtr hwnd, out uint pid);
72878
+ [DllImport("user32.dll")] public static extern bool SetProcessDPIAware();
72879
+ public static List<int[]> Collect() {
72880
+ var rows = new List<int[]>();
72881
+ EnumWindows(delegate(IntPtr h, IntPtr p) {
72882
+ if (!IsWindowVisible(h) || IsIconic(h)) return true;
72883
+ RECT r;
72884
+ if (!GetWindowRect(h, out r)) return true;
72885
+ if (r.R <= r.L || r.B <= r.T) return true;
72886
+ uint owner; GetWindowThreadProcessId(h, out owner);
72887
+ if (owner == 0) return true;
72888
+ rows.Add(new int[] { (int)owner, r.L, r.T, r.R, r.B });
72889
+ return true;
72890
+ }, IntPtr.Zero);
72891
+ return rows;
72892
+ }
72893
+ }
72894
+ '@
72895
+ [void][AwareHostRects]::SetProcessDPIAware()
72896
+ # EVERY visible window is kept. De-duplicating by owning PROCESS would drop a second Chrome or
72897
+ # Explorer window from the stack, and if that omitted window covers Revit the badge would promise a
72898
+ # drop the authoritative hit-test then refuses. Only the pid->name lookup is cached.
72899
+ $names = @{}
72900
+ $out = New-Object System.Collections.ArrayList
72901
+ foreach ($row in [AwareHostRects]::Collect()) {
72902
+ $owner = $row[0]
72903
+ if (-not $names.ContainsKey($owner)) {
72904
+ $proc = Get-Process -Id $owner -ErrorAction SilentlyContinue
72905
+ $names[$owner] = if ($proc) { $proc.ProcessName } else { $null }
72906
+ }
72907
+ if (-not $names[$owner]) { continue }
72908
+ [void]$out.Add([ordered]@{ pid = $owner; name = $names[$owner]; left = $row[1]; top = $row[2]; right = $row[3]; bottom = $row[4] })
72909
+ }
72910
+ [Console]::Out.Write((ConvertTo-Json -Compress @($out)))
72911
+ `.trim();
72912
+ async function runningKnownHosts(deps = DEFAULT_DEPS2) {
72913
+ if (deps.platform !== "win32") return [];
72914
+ let stdout;
72915
+ try {
72916
+ stdout = await deps.runPowerShell(
72917
+ "[Console]::Out.Write((Get-Process -ErrorAction SilentlyContinue | Select-Object -ExpandProperty ProcessName | ConvertTo-Json -Compress))"
72918
+ );
72919
+ } catch {
72920
+ return [];
72921
+ }
72922
+ let names;
72923
+ try {
72924
+ names = JSON.parse(stdout.trim() || "[]");
72925
+ } catch {
72926
+ return [];
72927
+ }
72928
+ const list = Array.isArray(names) ? names : typeof names === "string" ? [names] : [];
72929
+ const found = /* @__PURE__ */ new Set();
72930
+ for (const raw of list) {
72931
+ const host = hostForProcessName(typeof raw === "string" ? raw : null);
72932
+ if (host) found.add(host);
72933
+ }
72934
+ return [...found];
72935
+ }
72936
+ async function resolveHostAtPoint(cssX, cssY, dpr, probe) {
72937
+ let hit = { probed: false, host: null, processName: null, pid: null };
72938
+ for (const [px, py] of candidatePoints(cssX, cssY, dpr)) {
72939
+ hit = await probe(px, py);
72940
+ if (hit.probed) break;
72941
+ }
72942
+ return hit;
72943
+ }
72944
+
72945
+ // host-readiness.ts
72946
+ var HOST_BAKE_AWARE_FLOOR = "0.104.0";
72947
+ var SUPPORTED_REVIT_VERSIONS = /* @__PURE__ */ new Set(["2026"]);
72948
+ var HOST_LABELS = {
72949
+ tekla: "Tekla Structures",
72950
+ revit: "Revit",
72951
+ sketchup: "SketchUp"
72952
+ };
72953
+ var DEFAULT_DEPS3 = {
72954
+ npmVersion: () => aware.npmVersion(),
72955
+ bridgeStatus: (host) => aware.hostBridgeStatus(host),
72956
+ instances: (host) => aware.hostInstances(host),
72957
+ runningHosts: () => runningKnownHosts()
72958
+ };
72959
+ async function hostReadiness(host, deps = DEFAULT_DEPS3, targetPid) {
72960
+ const label2 = HOST_LABELS[host];
72961
+ const awareVersion = deps.npmVersion();
72962
+ const awareCurrent = !!awareVersion && compareSemver(awareVersion, HOST_BAKE_AWARE_FLOOR) >= 0;
72963
+ const bridge = deps.bridgeStatus(host);
72964
+ const bridgeCurrent = !!bridge.path && bridge.version === awareVersion;
72965
+ const base = {
72966
+ host,
72967
+ aware: { version: awareVersion, floor: HOST_BAKE_AWARE_FLOOR, current: awareCurrent },
72968
+ bridge: { present: !!bridge.path, version: bridge.version, current: bridgeCurrent },
72969
+ session: { open: false, version: null, pid: null }
72970
+ };
72971
+ if (!awareCurrent) {
72972
+ return {
72973
+ ...base,
72974
+ ok: false,
72975
+ state: "aware-update-required",
72976
+ message: `Couldn\u2019t send \u2014 this needs AWARE ${HOST_BAKE_AWARE_FLOOR} or newer. Update it, then try again.`,
72977
+ recovery: { action: "update-aware", label: "Update AWARE" }
72978
+ };
72979
+ }
72980
+ if (!bridge.path) {
72981
+ return {
72982
+ ...base,
72983
+ ok: false,
72984
+ state: "bridge-missing",
72985
+ message: `Couldn\u2019t send \u2014 the connection to ${label2} isn\u2019t installed yet. Install it, then try again.`,
72986
+ recovery: { action: "install-bridge", label: `Install ${label2} bridge` }
72987
+ };
72988
+ }
72989
+ if (!bridgeCurrent) {
72990
+ return {
72991
+ ...base,
72992
+ ok: false,
72993
+ state: "bridge-update-required",
72994
+ message: `Couldn\u2019t send \u2014 the connection to ${label2} is stale (${bridge.version || "unversioned"}, needs ${awareVersion}). Update it, then try again.`,
72995
+ recovery: { action: "install-bridge", label: `Update ${label2} bridge` }
72996
+ };
72997
+ }
72998
+ let probe;
72999
+ try {
73000
+ probe = await deps.instances(host);
73001
+ } catch (error) {
73002
+ return {
73003
+ ...base,
73004
+ ok: false,
73005
+ state: "error",
73006
+ message: error instanceof Error ? error.message : `Couldn\u2019t check whether ${label2} is ready.`,
73007
+ recovery: { action: "retry", label: "Check again" }
73008
+ };
73009
+ }
73010
+ const session = targetPid != null ? probe.instances.find((i) => i.pid === targetPid) : probe.instances[0];
73011
+ if (probe.probeFailed) {
73012
+ return {
73013
+ ...base,
73014
+ ok: false,
73015
+ state: "error",
73016
+ message: `Couldn\u2019t send \u2014 the ${label2} connection isn\u2019t responding${probe.error ? ` (${probe.error.slice(0, 120)})` : ""}. Try again, and reinstall the ${label2} bridge if it keeps happening.`,
73017
+ recovery: { action: "retry", label: "Check again" }
73018
+ };
73019
+ }
73020
+ if (targetPid != null && !session) {
73021
+ return {
73022
+ ...base,
73023
+ ok: false,
73024
+ state: "host-closed",
73025
+ message: probe.instances.length ? `Couldn\u2019t send \u2014 that ${label2} window isn\u2019t open any more. Try the drag again.` : `Couldn\u2019t send \u2014 ${label2} isn\u2019t open. Start it and try again.`,
73026
+ recovery: probe.instances.length ? { action: "retry", label: "Check again" } : { action: "open-host", label: `Open ${label2}` }
73027
+ };
73028
+ }
73029
+ if (!probe.ok || !session) {
73030
+ let alsoRunning = [];
73031
+ try {
73032
+ alsoRunning = await deps.runningHosts();
73033
+ } catch {
73034
+ }
73035
+ if (alsoRunning.includes(host)) {
73036
+ return {
73037
+ ...base,
73038
+ ok: false,
73039
+ state: "error",
73040
+ message: `Couldn\u2019t send \u2014 ${label2} is running, but FloLess can\u2019t reach it. Restart ${label2} so its FloLess connection reloads, then try again.`,
73041
+ recovery: { action: "retry", label: "Check again" }
73042
+ };
73043
+ }
73044
+ return {
73045
+ ...base,
73046
+ ok: false,
73047
+ state: "host-closed",
73048
+ message: `Couldn\u2019t send \u2014 ${label2} isn\u2019t open. Start it and try again.`,
73049
+ recovery: { action: "open-host", label: `Open ${label2}` }
73050
+ };
73051
+ }
73052
+ const found = { open: true, version: session.version, pid: session.pid };
73053
+ if (targetPid == null && probe.instances.length > 1) {
73054
+ return {
73055
+ ...base,
73056
+ ok: false,
73057
+ state: "ambiguous-session",
73058
+ message: `Couldn\u2019t send \u2014 ${probe.instances.length} ${label2} windows are open and there\u2019s no way to tell which model you meant. Close all but one, or drag the members onto the window you want.`,
73059
+ recovery: { action: "retry", label: "Check again" }
73060
+ };
73061
+ }
73062
+ if (host === "sketchup" && probe.instances.length > 1) {
73063
+ return {
73064
+ ...base,
73065
+ session: found,
73066
+ ok: false,
73067
+ state: "ambiguous-session",
73068
+ message: `Couldn\u2019t send \u2014 ${probe.instances.length} SketchUp windows are open and there\u2019s no way to tell which model you meant. Close all but one and try again.`,
73069
+ recovery: { action: "retry", label: "Check again" }
73070
+ };
73071
+ }
73072
+ if (host === "revit" && session.version && !SUPPORTED_REVIT_VERSIONS.has(session.version)) {
73073
+ return {
73074
+ ...base,
73075
+ session: found,
73076
+ ok: false,
73077
+ state: "host-version-unsupported",
73078
+ message: `Couldn\u2019t send \u2014 FloLess can only build into Revit 2026, and the open session is Revit ${session.version}.`,
73079
+ recovery: null
73080
+ };
73081
+ }
73082
+ if (host === "revit" && session.addinLoaded === false) {
73083
+ return {
73084
+ ...base,
73085
+ session: found,
73086
+ ok: false,
73087
+ state: "addin-missing",
73088
+ message: "Couldn\u2019t send \u2014 Revit is open, but the FloLess add-in isn\u2019t loaded. Install it, then restart Revit.",
73089
+ recovery: { action: "install-addin", label: "Install Revit add-in" }
73090
+ };
73091
+ }
73092
+ return {
73093
+ ...base,
73094
+ session: found,
73095
+ bakeEnv: probe.env,
73096
+ ok: true,
73097
+ state: "ready",
73098
+ message: `Ready to send to ${label2}${session.version ? ` ${session.version}` : ""}.`,
73099
+ recovery: null
73100
+ };
73101
+ }
73102
+
73103
+ // host-bake.ts
73104
+ var GENERIC_BAKE_HOSTS = ["revit", "sketchup"];
73105
+ function isGenericBakeHost(value) {
73106
+ return typeof value === "string" && GENERIC_BAKE_HOSTS.includes(value);
73107
+ }
73108
+ var DESCRIPTORS = {
73109
+ revit: {
73110
+ host: "revit",
73111
+ label: HOST_LABELS.revit,
73112
+ writeApp: (dir, appId, scene, hostPid) => writeRevitApp(dir, appId, scene, hostPid),
73113
+ nodeId: "bake-revit",
73114
+ unavailable: "Revit must be open with a document, and the FloLess add-in loaded, to receive this."
73115
+ },
73116
+ sketchup: {
73117
+ host: "sketchup",
73118
+ label: HOST_LABELS.sketchup,
73119
+ // SketchUp takes no target: readiness refuses outright when more than one session is open,
73120
+ // because its bake has no instance selector and must never guess between two models.
73121
+ writeApp: (dir, appId, scene) => writeSketchupApp(dir, appId, scene),
73122
+ nodeId: "bake-sketchup",
73123
+ unavailable: "SketchUp must be open with a model to receive this."
73124
+ }
73125
+ };
73126
+ function hostBakeDescriptor(host) {
73127
+ return DESCRIPTORS[host];
73128
+ }
73129
+ function looksLikeHostUnavailable(host, ...messages) {
73130
+ const haystack = messages.filter(Boolean).join(" ").toLowerCase();
73131
+ if (!haystack) return false;
73132
+ const signals = [
73133
+ "no " + host + " instance",
73134
+ "not running",
73135
+ "no instance",
73136
+ "no running",
73137
+ "addin_loaded",
73138
+ "add-in isn",
73139
+ "named pipe",
73140
+ "did not appear",
73141
+ "bridge not found",
73142
+ "bridge i/o",
73143
+ "host-unavailable",
73144
+ "launch " + host,
73145
+ "no document is open",
73146
+ "no model is open"
73147
+ ];
73148
+ return signals.some((s) => haystack.includes(s));
73149
+ }
73150
+
72431
73151
  // render-readiness.ts
72432
73152
  var import_node_fs38 = require("node:fs");
72433
73153
  var import_node_path34 = require("node:path");
@@ -72509,12 +73229,12 @@ function findBlender(env2 = process.env) {
72509
73229
  }
72510
73230
  return null;
72511
73231
  }
72512
- var DEFAULT_DEPS2 = {
73232
+ var DEFAULT_DEPS4 = {
72513
73233
  npmVersion: () => aware.npmVersion(),
72514
73234
  installedAgentIds: async () => (await aware.agentList()).map((row) => row.id),
72515
73235
  locateBlender: () => findBlender()
72516
73236
  };
72517
- async function renderReadiness(deps = DEFAULT_DEPS2) {
73237
+ async function renderReadiness(deps = DEFAULT_DEPS4) {
72518
73238
  try {
72519
73239
  const version = deps.npmVersion();
72520
73240
  const current = !!version && compareSemver(version, RENDER_AWARE_FLOOR) >= 0;
@@ -73605,7 +74325,11 @@ function isGatedAwareRoute(url, method) {
73605
74325
  if (path === "/api/trigger-run") return m === "POST";
73606
74326
  if (path.startsWith("/api/app/")) return m === "PATCH" || m === "POST" || m === "DELETE";
73607
74327
  if (path.startsWith("/api/contract/")) {
73608
- 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
74328
+ return m === "POST" && (path.endsWith("/approve") || path.endsWith("/export-3d") || path.endsWith("/export-ifc") || path.endsWith("/export-tekla") || // Revit/SketchUp. Matched as a SEGMENT, not a suffix: the host is the last path component,
74329
+ // so `/export-host/revit` ends with "/revit" and every endsWith test above sails past it.
74330
+ // It compiles and runs a companion exactly like /export-tekla, so a half-installed AWARE
74331
+ // must stop it here rather than surface as a spawn failure mid-bake.
74332
+ path.includes("/export-host/") || // `aware agent invoke` twice (ifc/write then the blender render). The `m === 'POST'` test
73609
74333
  // above is what keeps the `render-preview` GET out of here — that one only reads a file
73610
74334
  // off disk and must stay available while AWARE is still installing.
73611
74335
  path.endsWith("/render"));
@@ -73614,7 +74338,7 @@ function isGatedAwareRoute(url, method) {
73614
74338
  }
73615
74339
 
73616
74340
  // autostart.mjs
73617
- var import_node_child_process6 = require("node:child_process");
74341
+ var import_node_child_process7 = require("node:child_process");
73618
74342
  var import_node_fs42 = require("node:fs");
73619
74343
  var import_node_os22 = require("node:os");
73620
74344
  var import_node_path38 = require("node:path");
@@ -73723,7 +74447,7 @@ function currentUserId() {
73723
74447
  }
73724
74448
  function removeLegacyRunKey() {
73725
74449
  try {
73726
- (0, import_node_child_process6.execFileSync)("reg", ["delete", RUN_KEY, "/v", RUN_VALUE, "/f"], { stdio: "ignore", windowsHide: true });
74450
+ (0, import_node_child_process7.execFileSync)("reg", ["delete", RUN_KEY, "/v", RUN_VALUE, "/f"], { stdio: "ignore", windowsHide: true });
73727
74451
  } catch {
73728
74452
  }
73729
74453
  }
@@ -73741,7 +74465,7 @@ function registerAutostart(exePath) {
73741
74465
  const tmp = (0, import_node_path38.join)((0, import_node_os22.tmpdir)(), `floless-autostart-${process.pid}-${Date.now()}.xml`);
73742
74466
  (0, import_node_fs42.writeFileSync)(tmp, "\uFEFF" + xml, { encoding: "utf16le" });
73743
74467
  try {
73744
- (0, import_node_child_process6.execFileSync)("schtasks", ["/Create", "/TN", TASK_NAME, "/XML", tmp, "/F"], {
74468
+ (0, import_node_child_process7.execFileSync)("schtasks", ["/Create", "/TN", TASK_NAME, "/XML", tmp, "/F"], {
73745
74469
  stdio: ["ignore", "ignore", "ignore"],
73746
74470
  windowsHide: true
73747
74471
  });
@@ -73759,7 +74483,7 @@ function registerAutostart(exePath) {
73759
74483
  function autostartPresent() {
73760
74484
  if (!isWin) return false;
73761
74485
  try {
73762
- (0, import_node_child_process6.execFileSync)("schtasks", ["/query", "/tn", TASK_NAME], { stdio: "ignore", windowsHide: true });
74486
+ (0, import_node_child_process7.execFileSync)("schtasks", ["/query", "/tn", TASK_NAME], { stdio: "ignore", windowsHide: true });
73763
74487
  return true;
73764
74488
  } catch {
73765
74489
  return false;
@@ -73776,14 +74500,14 @@ function ensureAutostart(exePath) {
73776
74500
  function unregisterAutostart() {
73777
74501
  if (!isWin) return;
73778
74502
  try {
73779
- (0, import_node_child_process6.execFileSync)("schtasks", ["/delete", "/tn", TASK_NAME, "/f"], { stdio: "ignore", windowsHide: true });
74503
+ (0, import_node_child_process7.execFileSync)("schtasks", ["/delete", "/tn", TASK_NAME, "/f"], { stdio: "ignore", windowsHide: true });
73780
74504
  } catch {
73781
74505
  }
73782
74506
  removeLegacyRunKey();
73783
74507
  }
73784
74508
 
73785
74509
  // updater.ts
73786
- var import_node_child_process7 = require("node:child_process");
74510
+ var import_node_child_process8 = require("node:child_process");
73787
74511
  var import_node_crypto22 = require("node:crypto");
73788
74512
  var import_node_fs44 = require("node:fs");
73789
74513
  var import_node_stream3 = require("node:stream");
@@ -73981,7 +74705,7 @@ async function applyUpdate(check, opts) {
73981
74705
  const pkg = await downloadPackage(check.asset);
73982
74706
  if (opts?.onBeforeApply) await opts.onBeforeApply();
73983
74707
  await new Promise((resolve11, reject) => {
73984
- const child = (0, import_node_child_process7.spawn)(exe, ["apply", "--package", pkg, "--waitPid", String(process.pid)], {
74708
+ const child = (0, import_node_child_process8.spawn)(exe, ["apply", "--package", pkg, "--waitPid", String(process.pid)], {
73985
74709
  cwd: installRoot(),
73986
74710
  detached: true,
73987
74711
  stdio: "ignore",
@@ -74214,7 +74938,7 @@ function isTraceCorrupt(events) {
74214
74938
  }
74215
74939
 
74216
74940
  // launch.mjs
74217
- var import_node_child_process8 = require("node:child_process");
74941
+ var import_node_child_process9 = require("node:child_process");
74218
74942
  var import_node_path41 = require("node:path");
74219
74943
  var import_node_url3 = require("node:url");
74220
74944
  var import_node_fs45 = require("node:fs");
@@ -74306,7 +75030,7 @@ function startServerDetached() {
74306
75030
  const { cmd, args, shell } = resolveServerStart();
74307
75031
  rotateLog();
74308
75032
  const fd2 = openLogFd();
74309
- const child = (0, import_node_child_process8.spawn)(cmd, args, {
75033
+ const child = (0, import_node_child_process9.spawn)(cmd, args, {
74310
75034
  cwd: __dirname2,
74311
75035
  detached: true,
74312
75036
  stdio: fd2 == null ? "ignore" : ["ignore", fd2, fd2],
@@ -74316,13 +75040,13 @@ function startServerDetached() {
74316
75040
  child.unref();
74317
75041
  }
74318
75042
  function openBrowser2(url) {
74319
- if (isWin2) (0, import_node_child_process8.spawn)("cmd", ["/c", "start", "", url], { windowsHide: true }).unref();
74320
- else (0, import_node_child_process8.spawn)(process.platform === "darwin" ? "open" : "xdg-open", [url], { detached: true }).unref();
75043
+ if (isWin2) (0, import_node_child_process9.spawn)("cmd", ["/c", "start", "", url], { windowsHide: true }).unref();
75044
+ else (0, import_node_child_process9.spawn)(process.platform === "darwin" ? "open" : "xdg-open", [url], { detached: true }).unref();
74321
75045
  }
74322
75046
  function stopServer() {
74323
75047
  if (!isWin2) {
74324
75048
  try {
74325
- (0, import_node_child_process8.execSync)(`bash -lc "fuser -k ${PORT}/tcp"`, { stdio: "ignore" });
75049
+ (0, import_node_child_process9.execSync)(`bash -lc "fuser -k ${PORT}/tcp"`, { stdio: "ignore" });
74326
75050
  return true;
74327
75051
  } catch {
74328
75052
  return false;
@@ -74330,7 +75054,7 @@ function stopServer() {
74330
75054
  }
74331
75055
  try {
74332
75056
  const ps = `$p = Get-NetTCPConnection -LocalPort ${PORT} -State Listen -ErrorAction SilentlyContinue | Select-Object -Expand OwningProcess -Unique; if ($p) { $p | ForEach-Object { taskkill /PID $_ /T /F } } else { exit 9 }`;
74333
- (0, import_node_child_process8.execSync)(`powershell -NoProfile -Command "${ps}"`, { stdio: "ignore" });
75057
+ (0, import_node_child_process9.execSync)(`powershell -NoProfile -Command "${ps}"`, { stdio: "ignore" });
74334
75058
  return true;
74335
75059
  } catch {
74336
75060
  return false;
@@ -74382,7 +75106,7 @@ async function cmdSupervise() {
74382
75106
  if (isSeaChannel && !process.env[SUPERVISE_RESPAWN_ENV]) {
74383
75107
  rotateLog();
74384
75108
  const fd2 = openLogFd();
74385
- const child = (0, import_node_child_process8.spawn)(process.execPath, ["--supervise"], {
75109
+ const child = (0, import_node_child_process9.spawn)(process.execPath, ["--supervise"], {
74386
75110
  detached: true,
74387
75111
  stdio: fd2 == null ? "ignore" : ["ignore", fd2, fd2],
74388
75112
  windowsHide: true,
@@ -74437,7 +75161,7 @@ function enumerateProcesses() {
74437
75161
  if (!isWin2) return [];
74438
75162
  try {
74439
75163
  const ps = "Get-CimInstance Win32_Process | Select-Object ProcessId,CommandLine | ConvertTo-Json -Compress";
74440
- const out = (0, import_node_child_process8.execSync)(`powershell -NoProfile -Command "${ps}"`, {
75164
+ const out = (0, import_node_child_process9.execSync)(`powershell -NoProfile -Command "${ps}"`, {
74441
75165
  encoding: "utf8",
74442
75166
  windowsHide: true,
74443
75167
  maxBuffer: 16 * 1024 * 1024
@@ -74460,7 +75184,7 @@ function killSupervisor({ tree = true } = {}) {
74460
75184
  for (const pid of pids) {
74461
75185
  log(`stopping supervisor (pid ${pid})\u2026`);
74462
75186
  try {
74463
- (0, import_node_child_process8.execFileSync)("taskkill", taskkillArgs(pid, { tree }), { stdio: "ignore", windowsHide: true });
75187
+ (0, import_node_child_process9.execFileSync)("taskkill", taskkillArgs(pid, { tree }), { stdio: "ignore", windowsHide: true });
74464
75188
  } catch {
74465
75189
  }
74466
75190
  }
@@ -74556,11 +75280,11 @@ async function cmdUpdate() {
74556
75280
  function removeRegistryFootprint() {
74557
75281
  if (!isWin2) return;
74558
75282
  try {
74559
- (0, import_node_child_process8.execFileSync)("reg", ["delete", RUN_KEY, "/v", RUN_VALUE, "/f"], { stdio: "ignore", windowsHide: true });
75283
+ (0, import_node_child_process9.execFileSync)("reg", ["delete", RUN_KEY, "/v", RUN_VALUE, "/f"], { stdio: "ignore", windowsHide: true });
74560
75284
  } catch {
74561
75285
  }
74562
75286
  try {
74563
- (0, import_node_child_process8.execFileSync)("reg", ["delete", PROTOCOL_KEY, "/f"], { stdio: "ignore", windowsHide: true });
75287
+ (0, import_node_child_process9.execFileSync)("reg", ["delete", PROTOCOL_KEY, "/f"], { stdio: "ignore", windowsHide: true });
74564
75288
  } catch {
74565
75289
  }
74566
75290
  }
@@ -74586,13 +75310,13 @@ async function cmdUninstall(flags = {}) {
74586
75310
  if (removeAware) {
74587
75311
  log("removing the AWARE runtime \u2014 this will affect ANY other tool that uses @aware-aeco/cli.");
74588
75312
  try {
74589
- (0, import_node_child_process8.execSync)("npm uninstall -g @aware-aeco/cli", { stdio: "inherit", shell: isWin2 });
75313
+ (0, import_node_child_process9.execSync)("npm uninstall -g @aware-aeco/cli", { stdio: "inherit", shell: isWin2 });
74590
75314
  } catch {
74591
75315
  log('warning: "npm uninstall -g @aware-aeco/cli" failed \u2014 see the output above.');
74592
75316
  }
74593
75317
  let lsJson = "";
74594
75318
  try {
74595
- lsJson = (0, import_node_child_process8.execSync)("npm ls -g @aware-aeco/cli --depth=0 --json", {
75319
+ lsJson = (0, import_node_child_process9.execSync)("npm ls -g @aware-aeco/cli --depth=0 --json", {
74596
75320
  encoding: "utf8",
74597
75321
  stdio: ["ignore", "pipe", "ignore"],
74598
75322
  shell: isWin2
@@ -74857,17 +75581,6 @@ function syncSkills() {
74857
75581
  return results;
74858
75582
  }
74859
75583
 
74860
- // mutation-id.ts
74861
- var MUTATION_ID_RE = /^[A-Za-z0-9._~-]{1,64}$/;
74862
- function sanitizeMutationId(raw) {
74863
- if (typeof raw !== "string") return void 0;
74864
- return MUTATION_ID_RE.test(raw) ? raw : void 0;
74865
- }
74866
- function contractChangedEvent(appId, project, etag, rawMutationId) {
74867
- const mutationId = sanitizeMutationId(rawMutationId);
74868
- return { type: "contract-changed", appId, project, etag, ...mutationId ? { mutationId } : {} };
74869
- }
74870
-
74871
75584
  // watch.ts
74872
75585
  var import_node_os25 = require("node:os");
74873
75586
  var import_node_path44 = require("node:path");
@@ -76710,7 +77423,7 @@ async function startServer() {
76710
77423
  const isWin3 = process.platform === "win32";
76711
77424
  const has = (cmd) => {
76712
77425
  try {
76713
- (0, import_node_child_process9.execFileSync)(isWin3 ? "where" : "which", [cmd], { stdio: "ignore", windowsHide: true, timeout: 5e3 });
77426
+ (0, import_node_child_process10.execFileSync)(isWin3 ? "where" : "which", [cmd], { stdio: "ignore", windowsHide: true, timeout: 5e3 });
76714
77427
  return true;
76715
77428
  } catch {
76716
77429
  return false;
@@ -76719,7 +77432,7 @@ async function startServer() {
76719
77432
  function installAwareGlobal(spec, onLine = () => {
76720
77433
  }) {
76721
77434
  return new Promise((resolve11, reject) => {
76722
- const child = (0, import_node_child_process9.spawn)("npm", ["i", "-g", `@aware-aeco/cli@${spec}`], { shell: isWin3, windowsHide: true });
77435
+ const child = (0, import_node_child_process10.spawn)("npm", ["i", "-g", `@aware-aeco/cli@${spec}`], { shell: isWin3, windowsHide: true });
76723
77436
  let stderrTail = "";
76724
77437
  let combinedTail = "";
76725
77438
  const tail = (buf, s) => (buf + s).slice(-4e3);
@@ -77393,7 +78106,7 @@ async function startServer() {
77393
78106
  if (currentDoc != null && declaredTypeOf(currentDoc) === STEEL_V2 && declaredTypeOf(doc) === STEEL_V1) {
77394
78107
  try {
77395
78108
  const res = await runRollbackToV1({ appId: project.app, projectId: project.id, doc, versionN: n });
77396
- broadcast({ type: "contract-changed", appId: project.app, project: project.id });
78109
+ broadcast(contractChangedWithReason(project.app, project.id, "rollback"));
77397
78110
  return { ok: true, version: listVersions(project.id).find((v) => v.n === res.versionN) ?? null };
77398
78111
  } catch (e) {
77399
78112
  if (e instanceof RecoveryPendingError) return reply.status(409).send({ ok: false, error: e.message, code: e.code });
@@ -77412,7 +78125,7 @@ async function startServer() {
77412
78125
  }
77413
78126
  clearApproval(project.id);
77414
78127
  const row = createVersion(project.id, doc, { author: "You", message: `Rolled back to v${n}`, gate: null, kind: "rollback" });
77415
- broadcast({ type: "contract-changed", appId: project.app, project: project.id });
78128
+ broadcast(contractChangedWithReason(project.app, project.id, "rollback"));
77416
78129
  return { ok: true, version: row };
77417
78130
  });
77418
78131
  registerRevisionRoutes(app);
@@ -77440,7 +78153,7 @@ async function startServer() {
77440
78153
  readContractForApp: (appId) => readUnacceptedContract(appId),
77441
78154
  projectAppMismatch
77442
78155
  });
77443
- registerMigrationCommitRoute(app, { projectAppMismatch });
78156
+ registerMigrationCommitRoute(app, { projectAppMismatch, broadcast });
77444
78157
  app.get("/api/contract/:appId", async (req, reply) => {
77445
78158
  const project = req.query.project || void 0;
77446
78159
  if (project) {
@@ -78155,6 +78868,132 @@ async function startServer() {
78155
78868
  }
78156
78869
  }, { label: "sending the model to Tekla" });
78157
78870
  });
78871
+ app.post(
78872
+ "/api/contract/:appId/export-host/:host",
78873
+ async (req, reply) => {
78874
+ const { appId } = req.params;
78875
+ const project = req.query.project || void 0;
78876
+ if (!isGenericBakeHost(req.params.host)) {
78877
+ return reply.status(404).send({ ok: false, error: `no bake target called "${req.params.host}"` });
78878
+ }
78879
+ const target = hostBakeDescriptor(req.params.host);
78880
+ const parsed = readSelectionFromBody(req.body);
78881
+ if (parsed === "invalid") {
78882
+ return reply.status(400).send({
78883
+ ok: false,
78884
+ error: "Could not read which members to send. Try again, and if it keeps happening, reload the editor."
78885
+ });
78886
+ }
78887
+ const selection = parsed;
78888
+ const rawPid = (req.body ?? {}).hostPid;
78889
+ const hostPid = typeof rawPid === "number" && Number.isInteger(rawPid) && rawPid > 0 ? rawPid : void 0;
78890
+ return withLifecycleLock(project ? "project" : "app", project || appId, async () => {
78891
+ let projectSnapshot;
78892
+ if (project) {
78893
+ const gate = projectExportGate(appId, project);
78894
+ if (gate) return reply.status(gate.status).send({ ok: false, error: gate.error });
78895
+ try {
78896
+ projectSnapshot = currentApprovedSnapshot(project);
78897
+ } catch (error) {
78898
+ if (error instanceof WorkspaceSnapshotError) return reply.status(error.status).send({ ok: false, error: error.message });
78899
+ throw error;
78900
+ }
78901
+ }
78902
+ const readiness = await hostReadiness(target.host, void 0, hostPid);
78903
+ if (!readiness.ok) {
78904
+ return reply.status(409).send({
78905
+ ok: false,
78906
+ needsHost: readiness.state === "host-closed" || readiness.state === "addin-missing",
78907
+ host: target.host,
78908
+ error: readiness.message,
78909
+ readiness
78910
+ });
78911
+ }
78912
+ const candidate = projectSnapshot ? projectSnapshot.contract : readAcceptedForRequest(appId, void 0);
78913
+ if (candidate == null) return reply.status(404).send({ ok: false, error: "no contract to bake" });
78914
+ const steel = acceptSteelForRoute(candidate, { appId, projectId: project }, "stored", "v1-or-v2");
78915
+ if (!steel.accepted) return reply.status(400).send(steel.refusal);
78916
+ const doc = steel.doc;
78917
+ const sourceId = selection ? await dropExportSourceId(appId, project) : await stableExportSourceId(appId, project);
78918
+ const scoped = selection ? contractForMemberSelection(doc, selection) : doc;
78919
+ if (selection && selectionMemberCount(scoped) === 0) {
78920
+ return reply.status(422).send({ ok: false, error: "those members aren\u2019t in the model any more \u2014 reload the editor and try again" });
78921
+ }
78922
+ const built = contractToAwareScene(scoped, sourceId);
78923
+ if (!hasExportableSceneRecords(built.scene)) {
78924
+ return reply.status(422).send({
78925
+ ok: false,
78926
+ error: selection ? `nothing to bake in that selection \u2014 every member you dragged is an RFI (no AISC size yet)` : "no resolvable members to bake \u2014 every member is an RFI (no AISC size yet)",
78927
+ skipped: built.skipped
78928
+ });
78929
+ }
78930
+ const companion = createExportCompanion(appId, target.host);
78931
+ try {
78932
+ const flo = target.writeApp(companion.path, companion.id, built.scene, hostPid);
78933
+ stampExportCompanionLease(companion);
78934
+ await aware.compile(flo);
78935
+ const env2 = readiness.bakeEnv;
78936
+ let runResult;
78937
+ try {
78938
+ runResult = await aware.run(companion.id, { env: env2 });
78939
+ } catch (error) {
78940
+ const recoverable = error instanceof AwareError && /timeout|timed out|lost response|connection reset/i.test(`${error.message} ${awareStderr(error) || ""}`);
78941
+ if (!recoverable) throw error;
78942
+ runResult = await aware.run(companion.id, { env: env2 });
78943
+ }
78944
+ const events = runResult.traceText ? parseTrace(runResult.traceText) : [];
78945
+ const output = [...events].reverse().find((event) => event.kind === "node-output" && event.node === target.nodeId);
78946
+ const envelope = output?.data && typeof output.data === "object" ? output.data : null;
78947
+ const rawReceipt = envelope?.result && typeof envelope.result === "object" ? envelope.result : envelope;
78948
+ const receipt = reconcileHostExportReceipt(built.scene, rawReceipt, built.producerUnsupported);
78949
+ return {
78950
+ ok: true,
78951
+ host: target.host,
78952
+ message: `${receipt.counts.emitted} emitted${receipt.counts.native != null ? ` \xB7 ${receipt.counts.native} native` : ""}${receipt.counts.unsupported ? ` \xB7 ${receipt.counts.unsupported} unsupported` : ""}${receipt.counts.warnings ? ` \xB7 ${receipt.counts.warnings} warning${receipt.counts.warnings === 1 ? "" : "s"}` : ""}`,
78953
+ elements: receipt.counts.emitted,
78954
+ skipped: built.skipped,
78955
+ receipt,
78956
+ counts: receipt.counts,
78957
+ warnings: receipt.warnings
78958
+ };
78959
+ } catch (error) {
78960
+ const reason = error instanceof AwareError ? awareStderr(error) : void 0;
78961
+ const message = error instanceof Error ? error.message : `${target.label} export failed`;
78962
+ const needsHost = looksLikeHostUnavailable(target.host, message, reason);
78963
+ app.log.warn({ appId, project, host: target.host, error: message, reason }, "host export failed");
78964
+ return reply.status(error instanceof ReceiptReconciliationError ? 422 : 502).send({
78965
+ ok: false,
78966
+ needsHost,
78967
+ host: target.host,
78968
+ error: needsHost ? target.unavailable : message,
78969
+ reason
78970
+ });
78971
+ } finally {
78972
+ try {
78973
+ companion.cleanup();
78974
+ } catch (error) {
78975
+ app.log.error({ companionId: companion.id, error: error instanceof Error ? error.message : error }, "could not remove host export companion");
78976
+ }
78977
+ }
78978
+ }, { label: `sending the model to ${target.label}` });
78979
+ }
78980
+ );
78981
+ app.post("/api/host-at-point", async (req, reply) => {
78982
+ const body = req.body ?? {};
78983
+ const x = typeof body.screenX === "number" ? body.screenX : NaN;
78984
+ const y = typeof body.screenY === "number" ? body.screenY : NaN;
78985
+ if (!Number.isFinite(x) || !Number.isFinite(y)) {
78986
+ return reply.status(400).send({ ok: false, error: "screenX and screenY must be numbers" });
78987
+ }
78988
+ const dpr = typeof body.dpr === "number" ? body.dpr : 1;
78989
+ const hit = await resolveHostAtPoint(x, y, dpr, (px, py) => hostAtScreenPoint(px, py));
78990
+ const running = await runningKnownHosts();
78991
+ return { ok: true, resolved: hit.probed, host: hit.host, pid: hit.pid, processName: hit.processName, running };
78992
+ });
78993
+ app.get("/api/host-windows", async () => {
78994
+ const [stack, running] = await Promise.all([hostWindowRects(), runningKnownHosts()]);
78995
+ return { ok: true, stack, running };
78996
+ });
78158
78997
  app.post("/api/contract/:appId/export-bom/:format", async (req, reply) => {
78159
78998
  const { appId, format } = req.params;
78160
78999
  const project = req.query.project || void 0;
@@ -79264,10 +80103,10 @@ async function startServer() {
79264
80103
  }
79265
80104
 
79266
80105
  // protocol.ts
79267
- var import_node_child_process10 = require("node:child_process");
80106
+ var import_node_child_process11 = require("node:child_process");
79268
80107
  var BASE = PROTOCOL_KEY;
79269
80108
  function reg(args) {
79270
- (0, import_node_child_process10.execFileSync)("reg", args, { stdio: "ignore", windowsHide: true });
80109
+ (0, import_node_child_process11.execFileSync)("reg", args, { stdio: "ignore", windowsHide: true });
79271
80110
  }
79272
80111
  function registerProtocol(exePath) {
79273
80112
  if (process.platform !== "win32") return;
@@ -79307,13 +80146,13 @@ async function removeAwarePerDecision(removeAwareFlag, prompt) {
79307
80146
  );
79308
80147
  const shell = process.platform === "win32" ? process.env.ComSpec || "cmd.exe" : "/bin/sh";
79309
80148
  try {
79310
- (0, import_node_child_process11.execSync)("npm uninstall -g @aware-aeco/cli", { stdio: "inherit", shell });
80149
+ (0, import_node_child_process12.execSync)("npm uninstall -g @aware-aeco/cli", { stdio: "inherit", shell });
79311
80150
  } catch {
79312
80151
  process.stdout.write('floless: warning: "npm uninstall -g @aware-aeco/cli" failed \u2014 see the output above.\n');
79313
80152
  }
79314
80153
  let lsJson = "";
79315
80154
  try {
79316
- lsJson = (0, import_node_child_process11.execSync)("npm ls -g @aware-aeco/cli --depth=0 --json", {
80155
+ lsJson = (0, import_node_child_process12.execSync)("npm ls -g @aware-aeco/cli --depth=0 --json", {
79317
80156
  encoding: "utf8",
79318
80157
  stdio: ["ignore", "pipe", "ignore"],
79319
80158
  shell