@floless/app 0.107.0 → 0.108.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/floless-server.cjs +269 -94
- package/dist/skills/floless-app-steel-model/SKILL.md +30 -1
- package/dist/skills/floless-app-workflows/references/dev-server-and-run-trace.md +11 -8
- package/dist/skills/reading-structural-drawings/SKILL.md +28 -0
- package/dist/web/grid-core.js +61 -0
- package/dist/web/steel-3d-core.js +145 -6
- package/dist/web/steel-detail-refs.js +116 -0
- package/dist/web/steel-editor.html +40 -16
- package/dist/web/steel-model-adapter.js +160 -10
- package/package.json +1 -1
package/dist/floless-server.cjs
CHANGED
|
@@ -51021,8 +51021,129 @@ var import_node_os3 = require("node:os");
|
|
|
51021
51021
|
var import_node_path3 = require("node:path");
|
|
51022
51022
|
var import_node_crypto2 = require("node:crypto");
|
|
51023
51023
|
var import_node_perf_hooks = require("node:perf_hooks");
|
|
51024
|
+
var MAX_EXPECTED_MS = 2 * 60 * 6e4;
|
|
51025
|
+
var MAX_LABEL_LENGTH = 60;
|
|
51026
|
+
function busyMeta(owner) {
|
|
51027
|
+
const label = typeof owner.label === "string" && owner.label.trim() && owner.label.length <= MAX_LABEL_LENGTH ? owner.label.trim() : null;
|
|
51028
|
+
const expectedMs = typeof owner.expectedMs === "number" && Number.isFinite(owner.expectedMs) && owner.expectedMs > 0 && owner.expectedMs <= MAX_EXPECTED_MS ? owner.expectedMs : null;
|
|
51029
|
+
return { label, expectedMs };
|
|
51030
|
+
}
|
|
51031
|
+
var LifecycleLockBusyError = class extends Error {
|
|
51032
|
+
constructor(message, busy) {
|
|
51033
|
+
super(message);
|
|
51034
|
+
this.busy = busy;
|
|
51035
|
+
this.name = "LifecycleLockBusyError";
|
|
51036
|
+
}
|
|
51037
|
+
busy;
|
|
51038
|
+
status = 409;
|
|
51039
|
+
};
|
|
51040
|
+
function subjectFor(kind) {
|
|
51041
|
+
if (kind === "project") return "This project";
|
|
51042
|
+
if (kind === "app") return "This workflow";
|
|
51043
|
+
return "This app";
|
|
51044
|
+
}
|
|
51045
|
+
function remainingPhrase(remainingMs) {
|
|
51046
|
+
if (remainingMs < 6e4) return "less than a minute left";
|
|
51047
|
+
const minutes = Math.round(remainingMs / 6e4);
|
|
51048
|
+
return `about ${minutes} minute${minutes === 1 ? "" : "s"} left`;
|
|
51049
|
+
}
|
|
51050
|
+
function busyDetail(kind, key, owner) {
|
|
51051
|
+
const { label, expectedMs } = busyMeta(owner);
|
|
51052
|
+
const startedMs = Date.parse(owner.acquiredAt);
|
|
51053
|
+
const elapsedMs = Number.isFinite(startedMs) ? Math.max(0, Date.now() - startedMs) : 0;
|
|
51054
|
+
const usableEta = expectedMs != null && Number.isFinite(startedMs) ? expectedMs : null;
|
|
51055
|
+
const remaining = usableEta == null ? null : usableEta - elapsedMs;
|
|
51056
|
+
return {
|
|
51057
|
+
kind,
|
|
51058
|
+
key,
|
|
51059
|
+
label,
|
|
51060
|
+
startedAt: owner.acquiredAt,
|
|
51061
|
+
expectedMs: usableEta,
|
|
51062
|
+
elapsedMs,
|
|
51063
|
+
remainingMs: remaining != null && remaining > 0 ? remaining : null
|
|
51064
|
+
};
|
|
51065
|
+
}
|
|
51066
|
+
function busyError(kind, key, owner) {
|
|
51067
|
+
const detail = owner ? busyDetail(kind, key, owner) : {
|
|
51068
|
+
kind,
|
|
51069
|
+
key,
|
|
51070
|
+
label: null,
|
|
51071
|
+
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
51072
|
+
expectedMs: null,
|
|
51073
|
+
elapsedMs: 0,
|
|
51074
|
+
remainingMs: null
|
|
51075
|
+
};
|
|
51076
|
+
const subject = subjectFor(kind);
|
|
51077
|
+
if (!detail.label) {
|
|
51078
|
+
return new LifecycleLockBusyError(`${subject} is busy with another operation. Try again when it finishes.`, detail);
|
|
51079
|
+
}
|
|
51080
|
+
if (detail.expectedMs == null) {
|
|
51081
|
+
return new LifecycleLockBusyError(`${subject} is busy ${detail.label}. Try again when it finishes.`, detail);
|
|
51082
|
+
}
|
|
51083
|
+
const clause = detail.remainingMs == null ? "taking longer than usual" : remainingPhrase(detail.remainingMs);
|
|
51084
|
+
return new LifecycleLockBusyError(`${subject} is busy ${detail.label} \u2014 ${clause}. Try again when it finishes.`, detail);
|
|
51085
|
+
}
|
|
51024
51086
|
var held = new import_node_async_hooks.AsyncLocalStorage();
|
|
51025
51087
|
var localTails = /* @__PURE__ */ new Map();
|
|
51088
|
+
var localIntents = /* @__PURE__ */ new Map();
|
|
51089
|
+
function registerIntent(token, options) {
|
|
51090
|
+
const { label, expectedMs } = busyMeta(options);
|
|
51091
|
+
const intent = { label, expectedMs, acquiredAt: null };
|
|
51092
|
+
const set2 = localIntents.get(token) ?? /* @__PURE__ */ new Set();
|
|
51093
|
+
set2.add(intent);
|
|
51094
|
+
localIntents.set(token, set2);
|
|
51095
|
+
return intent;
|
|
51096
|
+
}
|
|
51097
|
+
function forgetIntent(token, intent) {
|
|
51098
|
+
const set2 = localIntents.get(token);
|
|
51099
|
+
if (!set2) return;
|
|
51100
|
+
set2.delete(intent);
|
|
51101
|
+
if (!set2.size) localIntents.delete(token);
|
|
51102
|
+
}
|
|
51103
|
+
function localProjectedFreeAt(token, now, exclude) {
|
|
51104
|
+
const set2 = localIntents.get(token);
|
|
51105
|
+
if (!set2?.size) return { at: now, blocker: null };
|
|
51106
|
+
let at = now;
|
|
51107
|
+
let holding = null;
|
|
51108
|
+
let longest = null;
|
|
51109
|
+
for (const intent of set2) {
|
|
51110
|
+
if (intent === exclude) continue;
|
|
51111
|
+
if (intent.label) {
|
|
51112
|
+
if (intent.acquiredAt != null) holding = intent;
|
|
51113
|
+
if (!longest || (intent.expectedMs ?? 0) > (longest.expectedMs ?? 0)) longest = intent;
|
|
51114
|
+
}
|
|
51115
|
+
if (intent.expectedMs == null) continue;
|
|
51116
|
+
const start = intent.acquiredAt ?? Math.max(at, now);
|
|
51117
|
+
at = Math.max(now, start + intent.expectedMs);
|
|
51118
|
+
}
|
|
51119
|
+
return { at, blocker: holding ?? longest };
|
|
51120
|
+
}
|
|
51121
|
+
function localBusyError(kind, key, at, blocker, now) {
|
|
51122
|
+
const startedMs = blocker.acquiredAt ?? now;
|
|
51123
|
+
const expectedMs = blocker.expectedMs == null ? void 0 : Math.max(1, at - startedMs);
|
|
51124
|
+
return busyError(kind, key, {
|
|
51125
|
+
acquiredAt: new Date(startedMs).toISOString(),
|
|
51126
|
+
label: blocker.label ?? void 0,
|
|
51127
|
+
expectedMs
|
|
51128
|
+
});
|
|
51129
|
+
}
|
|
51130
|
+
function waitForTurn(previous, budget, onExpiry) {
|
|
51131
|
+
return new Promise((resolve11, reject) => {
|
|
51132
|
+
let settled = false;
|
|
51133
|
+
const timer = setTimeout(() => {
|
|
51134
|
+
if (settled) return;
|
|
51135
|
+
settled = true;
|
|
51136
|
+
reject(onExpiry());
|
|
51137
|
+
}, budget);
|
|
51138
|
+
previous.catch(() => {
|
|
51139
|
+
}).then(() => {
|
|
51140
|
+
if (settled) return;
|
|
51141
|
+
settled = true;
|
|
51142
|
+
clearTimeout(timer);
|
|
51143
|
+
resolve11();
|
|
51144
|
+
});
|
|
51145
|
+
});
|
|
51146
|
+
}
|
|
51026
51147
|
var PROCESS_TOKEN = (0, import_node_crypto2.randomUUID)();
|
|
51027
51148
|
var STALE_MS = 3e4;
|
|
51028
51149
|
var WAIT_MS = 50;
|
|
@@ -51203,9 +51324,10 @@ function retireStaleLock(path, generation) {
|
|
|
51203
51324
|
}
|
|
51204
51325
|
return true;
|
|
51205
51326
|
}
|
|
51206
|
-
async function acquire(path) {
|
|
51327
|
+
async function acquire(path, kind, key, options) {
|
|
51207
51328
|
(0, import_node_fs4.mkdirSync)(root(), { recursive: true });
|
|
51208
|
-
const
|
|
51329
|
+
const budget = options.timeoutMsForTest ?? TIMEOUT_MS;
|
|
51330
|
+
const deadline = Date.now() + budget;
|
|
51209
51331
|
while (true) {
|
|
51210
51332
|
try {
|
|
51211
51333
|
(0, import_node_fs4.mkdirSync)(path);
|
|
@@ -51213,7 +51335,11 @@ async function acquire(path) {
|
|
|
51213
51335
|
pid: process.pid,
|
|
51214
51336
|
token: PROCESS_TOKEN,
|
|
51215
51337
|
acquiredAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
51216
|
-
started: PROCESS_STARTED
|
|
51338
|
+
started: PROCESS_STARTED,
|
|
51339
|
+
// Omitted entirely when undefined, so an undeclared lock writes byte-identical bytes
|
|
51340
|
+
// to what every previous build wrote.
|
|
51341
|
+
...options.label ? { label: options.label } : {},
|
|
51342
|
+
...options.expectedMs != null ? { expectedMs: options.expectedMs } : {}
|
|
51217
51343
|
};
|
|
51218
51344
|
if (publishExclusive(ownerPath(path), JSON.stringify(owner))) {
|
|
51219
51345
|
const canonical = readOwner(path);
|
|
@@ -51226,16 +51352,30 @@ async function acquire(path) {
|
|
|
51226
51352
|
const generation = staleGeneration(path);
|
|
51227
51353
|
if (generation) {
|
|
51228
51354
|
if (retireStaleLock(path, generation)) continue;
|
|
51355
|
+
} else {
|
|
51356
|
+
const owner = readOwner(path);
|
|
51357
|
+
const startedMs = owner ? Date.parse(owner.acquiredAt) : NaN;
|
|
51358
|
+
const expected = owner ? busyMeta(owner).expectedMs : null;
|
|
51359
|
+
if (owner && expected != null && startedMs + expected > deadline) {
|
|
51360
|
+
throw busyError(kind, key, owner);
|
|
51361
|
+
}
|
|
51229
51362
|
}
|
|
51230
|
-
if (Date.now() >= deadline) throw
|
|
51363
|
+
if (Date.now() >= deadline) throw busyError(kind, key, readOwner(path));
|
|
51231
51364
|
await sleep(WAIT_MS);
|
|
51232
51365
|
}
|
|
51233
51366
|
}
|
|
51234
51367
|
}
|
|
51235
|
-
async function withLifecycleLock(kind, key, fn) {
|
|
51368
|
+
async function withLifecycleLock(kind, key, fn, options = {}) {
|
|
51236
51369
|
const token = `${kind}:${safe(key)}`;
|
|
51237
51370
|
const inherited = held.getStore();
|
|
51238
51371
|
if (inherited?.has(token)) return await fn();
|
|
51372
|
+
const budget = options.timeoutMsForTest ?? TIMEOUT_MS;
|
|
51373
|
+
const enteredAt = Date.now();
|
|
51374
|
+
const { at: freeAt, blocker } = localProjectedFreeAt(token, enteredAt);
|
|
51375
|
+
if (freeAt > enteredAt + budget) {
|
|
51376
|
+
throw blocker ? localBusyError(kind, key, freeAt, blocker, enteredAt) : busyError(kind, key, null);
|
|
51377
|
+
}
|
|
51378
|
+
const intent = registerIntent(token, options);
|
|
51239
51379
|
const previous = localTails.get(token) ?? Promise.resolve();
|
|
51240
51380
|
let releaseLocal;
|
|
51241
51381
|
const mine = new Promise((resolve11) => {
|
|
@@ -51244,11 +51384,15 @@ async function withLifecycleLock(kind, key, fn) {
|
|
|
51244
51384
|
const tail = previous.catch(() => {
|
|
51245
51385
|
}).then(() => mine);
|
|
51246
51386
|
localTails.set(token, tail);
|
|
51247
|
-
await previous.catch(() => {
|
|
51248
|
-
});
|
|
51249
51387
|
const path = pathFor(kind, key);
|
|
51250
51388
|
try {
|
|
51251
|
-
await
|
|
51389
|
+
await waitForTurn(previous, budget, () => {
|
|
51390
|
+
const now = Date.now();
|
|
51391
|
+
const late = localProjectedFreeAt(token, now, intent);
|
|
51392
|
+
return late.blocker ? localBusyError(kind, key, late.at, late.blocker, now) : busyError(kind, key, null);
|
|
51393
|
+
});
|
|
51394
|
+
await acquire(path, kind, key, options);
|
|
51395
|
+
intent.acquiredAt = Date.now();
|
|
51252
51396
|
const next = new Set(inherited ?? []);
|
|
51253
51397
|
next.add(token);
|
|
51254
51398
|
return await held.run(next, fn);
|
|
@@ -51262,6 +51406,7 @@ async function withLifecycleLock(kind, key, fn) {
|
|
|
51262
51406
|
}
|
|
51263
51407
|
}
|
|
51264
51408
|
}
|
|
51409
|
+
forgetIntent(token, intent);
|
|
51265
51410
|
releaseLocal();
|
|
51266
51411
|
if (localTails.get(token) === tail) localTails.delete(token);
|
|
51267
51412
|
}
|
|
@@ -53253,32 +53398,46 @@ function isSea() {
|
|
|
53253
53398
|
return false;
|
|
53254
53399
|
}
|
|
53255
53400
|
}
|
|
53256
|
-
function
|
|
53257
|
-
if (
|
|
53258
|
-
if (
|
|
53401
|
+
function resolveStoreDir(e = process.env) {
|
|
53402
|
+
if (e.FLOLESS_LICENSE_DIR) return e.FLOLESS_LICENSE_DIR;
|
|
53403
|
+
if (e.LOCALAPPDATA) return (0, import_node_path8.join)(e.LOCALAPPDATA, "FlolessApp-data");
|
|
53259
53404
|
return (0, import_node_path8.join)((0, import_node_os8.homedir)(), ".aware");
|
|
53260
53405
|
}
|
|
53406
|
+
function storeDir() {
|
|
53407
|
+
return resolveStoreDir(process.env);
|
|
53408
|
+
}
|
|
53261
53409
|
var tokenPath = () => (0, import_node_path8.join)(storeDir(), "floless-license.json");
|
|
53262
53410
|
var cachePath = () => (0, import_node_path8.join)(storeDir(), "floless-license-cache.json");
|
|
53411
|
+
function legacyStoreDirs(e = process.env, sea = isSea(), home = (0, import_node_os8.homedir)()) {
|
|
53412
|
+
const dirs = [];
|
|
53413
|
+
if (sea && e.LOCALAPPDATA) dirs.push((0, import_node_path8.join)(e.LOCALAPPDATA, "FlolessApp"));
|
|
53414
|
+
dirs.push((0, import_node_path8.join)(home, ".aware"));
|
|
53415
|
+
return dirs;
|
|
53416
|
+
}
|
|
53417
|
+
var STORE_FILES = ["floless-license.json", "floless-license-cache.json", "floless-install-id"];
|
|
53418
|
+
function adoptStore(oldDir, newDir) {
|
|
53419
|
+
try {
|
|
53420
|
+
if (oldDir === newDir) return false;
|
|
53421
|
+
if (!(0, import_node_fs9.existsSync)((0, import_node_path8.join)(oldDir, "floless-license.json"))) return false;
|
|
53422
|
+
if ((0, import_node_fs9.existsSync)((0, import_node_path8.join)(newDir, "floless-license.json"))) return false;
|
|
53423
|
+
(0, import_node_fs9.mkdirSync)(newDir, { recursive: true });
|
|
53424
|
+
for (const f of STORE_FILES) {
|
|
53425
|
+
const oldP = (0, import_node_path8.join)(oldDir, f);
|
|
53426
|
+
const newP = (0, import_node_path8.join)(newDir, f);
|
|
53427
|
+
if ((0, import_node_fs9.existsSync)(oldP) && !(0, import_node_fs9.existsSync)(newP)) (0, import_node_fs9.copyFileSync)(oldP, newP);
|
|
53428
|
+
}
|
|
53429
|
+
return true;
|
|
53430
|
+
} catch {
|
|
53431
|
+
return false;
|
|
53432
|
+
}
|
|
53433
|
+
}
|
|
53263
53434
|
var _migrated = false;
|
|
53264
53435
|
function migrateLegacyStore() {
|
|
53265
53436
|
if (_migrated) return;
|
|
53266
53437
|
_migrated = true;
|
|
53267
|
-
if (process.env.FLOLESS_LICENSE_DIR
|
|
53268
|
-
const oldDir = (0, import_node_path8.join)(process.env.LOCALAPPDATA, "FlolessApp");
|
|
53438
|
+
if (process.env.FLOLESS_LICENSE_DIR) return;
|
|
53269
53439
|
const newDir = storeDir();
|
|
53270
|
-
if (oldDir
|
|
53271
|
-
for (const f of ["floless-license.json", "floless-license-cache.json", "floless-install-id"]) {
|
|
53272
|
-
try {
|
|
53273
|
-
const oldP = (0, import_node_path8.join)(oldDir, f);
|
|
53274
|
-
const newP = (0, import_node_path8.join)(newDir, f);
|
|
53275
|
-
if ((0, import_node_fs9.existsSync)(oldP) && !(0, import_node_fs9.existsSync)(newP)) {
|
|
53276
|
-
(0, import_node_fs9.mkdirSync)(newDir, { recursive: true });
|
|
53277
|
-
(0, import_node_fs9.copyFileSync)(oldP, newP);
|
|
53278
|
-
}
|
|
53279
|
-
} catch {
|
|
53280
|
-
}
|
|
53281
|
-
}
|
|
53440
|
+
for (const oldDir of legacyStoreDirs()) if (adoptStore(oldDir, newDir)) return;
|
|
53282
53441
|
}
|
|
53283
53442
|
function readJson(path) {
|
|
53284
53443
|
try {
|
|
@@ -53633,7 +53792,7 @@ function appVersion() {
|
|
|
53633
53792
|
return resolveVersion({
|
|
53634
53793
|
isSea: isSea2(),
|
|
53635
53794
|
sqVersionXml: readSqVersionXml(),
|
|
53636
|
-
define: true ? "0.
|
|
53795
|
+
define: true ? "0.108.1" : void 0,
|
|
53637
53796
|
pkgVersion: readPkgVersion()
|
|
53638
53797
|
});
|
|
53639
53798
|
}
|
|
@@ -53643,7 +53802,7 @@ function resolveChannel(s) {
|
|
|
53643
53802
|
return "dev";
|
|
53644
53803
|
}
|
|
53645
53804
|
function appChannel() {
|
|
53646
|
-
return resolveChannel({ isSea: isSea2(), define: true ? "0.
|
|
53805
|
+
return resolveChannel({ isSea: isSea2(), define: true ? "0.108.1" : void 0 });
|
|
53647
53806
|
}
|
|
53648
53807
|
|
|
53649
53808
|
// workflow-update.ts
|
|
@@ -58044,13 +58203,6 @@ var PreconditionFailedError = class extends Error {
|
|
|
58044
58203
|
this.name = "PreconditionFailedError";
|
|
58045
58204
|
}
|
|
58046
58205
|
};
|
|
58047
|
-
var StoreBusyError = class extends Error {
|
|
58048
|
-
code = "store-busy";
|
|
58049
|
-
constructor(message) {
|
|
58050
|
-
super(message);
|
|
58051
|
-
this.name = "StoreBusyError";
|
|
58052
|
-
}
|
|
58053
|
-
};
|
|
58054
58206
|
var refused = /* @__PURE__ */ new Map();
|
|
58055
58207
|
var REFUSAL_STORES_MAX = 256;
|
|
58056
58208
|
function countRefusal(store) {
|
|
@@ -58116,17 +58268,9 @@ async function writeContractChecked(appId, doc, projectId, origin) {
|
|
|
58116
58268
|
return { etag: etagOf(doc), conditional: !!(pre.ifMatch || pre.ifNoneMatch) };
|
|
58117
58269
|
});
|
|
58118
58270
|
} catch (e) {
|
|
58119
|
-
if (e instanceof Error && /lifecycle lock/i.test(e.message)) {
|
|
58120
|
-
throw new StoreBusyError("this project is busy publishing an export \u2014 try saving again in a moment");
|
|
58121
|
-
}
|
|
58122
58271
|
throw e;
|
|
58123
58272
|
}
|
|
58124
|
-
return run
|
|
58125
|
-
if (e instanceof Error && /lifecycle lock/i.test(e.message)) {
|
|
58126
|
-
throw new StoreBusyError("this project is busy publishing an export \u2014 try saving again in a moment");
|
|
58127
|
-
}
|
|
58128
|
-
throw e;
|
|
58129
|
-
});
|
|
58273
|
+
return run;
|
|
58130
58274
|
}
|
|
58131
58275
|
function readAcceptedVersion(projectId, n, opts) {
|
|
58132
58276
|
const doc = readVersion(projectId, n);
|
|
@@ -70141,6 +70285,17 @@ async function renderReadiness(deps = DEFAULT_DEPS2) {
|
|
|
70141
70285
|
}
|
|
70142
70286
|
}
|
|
70143
70287
|
|
|
70288
|
+
// render-cost.ts
|
|
70289
|
+
var RENDER_COST_SECONDS = {
|
|
70290
|
+
still: { draft: [8, 15], production: [50, 115] },
|
|
70291
|
+
turntable: { draft: [390, 540], production: [390, 540] }
|
|
70292
|
+
};
|
|
70293
|
+
function renderExpectedMs(output, quality, viewpoints) {
|
|
70294
|
+
const effective = output === "turntable" ? "draft" : quality;
|
|
70295
|
+
const [, hi] = RENDER_COST_SECONDS[output][effective];
|
|
70296
|
+
return hi * 1e3 * Math.max(1, viewpoints);
|
|
70297
|
+
}
|
|
70298
|
+
|
|
70144
70299
|
// downstream-bake.ts
|
|
70145
70300
|
async function bakeDownstream(sourcePath, appId, contract) {
|
|
70146
70301
|
const { scene } = contractToScene(contract);
|
|
@@ -74271,6 +74426,15 @@ async function startServer() {
|
|
|
74271
74426
|
if (err2 instanceof ProjectError) {
|
|
74272
74427
|
return reply.status(400).send({ ok: false, error: err2.message });
|
|
74273
74428
|
}
|
|
74429
|
+
if (err2 instanceof LifecycleLockBusyError) {
|
|
74430
|
+
const retryAfter = err2.busy.remainingMs == null ? 5 : Math.min(60, Math.max(1, Math.ceil(err2.busy.remainingMs / 1e3)));
|
|
74431
|
+
return reply.status(err2.status).header("Retry-After", String(retryAfter)).send({
|
|
74432
|
+
ok: false,
|
|
74433
|
+
error: err2.message,
|
|
74434
|
+
code: "lifecycle-busy",
|
|
74435
|
+
busy: err2.busy
|
|
74436
|
+
});
|
|
74437
|
+
}
|
|
74274
74438
|
if (err2 instanceof RoutineError) {
|
|
74275
74439
|
return reply.status(err2.status).send({ ok: false, error: err2.message });
|
|
74276
74440
|
}
|
|
@@ -74958,9 +75122,6 @@ async function startServer() {
|
|
|
74958
75122
|
if (e instanceof PreconditionFailedError) {
|
|
74959
75123
|
return reply.status(412).send({ ok: false, error: e.message, code: e.code });
|
|
74960
75124
|
}
|
|
74961
|
-
if (e instanceof StoreBusyError) {
|
|
74962
|
-
return reply.status(503).header("Retry-After", "5").send({ ok: false, error: e.message, code: e.code });
|
|
74963
|
-
}
|
|
74964
75125
|
if (e instanceof ContractError) return reply.status(400).send({ ok: false, error: e.message, ...e.code ? { code: e.code } : {} });
|
|
74965
75126
|
throw e;
|
|
74966
75127
|
}
|
|
@@ -75132,56 +75293,64 @@ async function startServer() {
|
|
|
75132
75293
|
});
|
|
75133
75294
|
}
|
|
75134
75295
|
}
|
|
75135
|
-
return withLifecycleLock(
|
|
75136
|
-
|
|
75137
|
-
|
|
75138
|
-
|
|
75139
|
-
|
|
75296
|
+
return withLifecycleLock(
|
|
75297
|
+
project ? "project" : "app",
|
|
75298
|
+
project || appId,
|
|
75299
|
+
async () => withLifecycleLock("app", `${appId}-3d`, async () => {
|
|
75300
|
+
let projectSnapshot;
|
|
75301
|
+
if (project) {
|
|
75302
|
+
const gate = projectExportGate(appId, project);
|
|
75303
|
+
if (gate) return reply.status(gate.status).send({ ok: false, error: gate.error });
|
|
75304
|
+
try {
|
|
75305
|
+
projectSnapshot = currentApprovedSnapshot(project);
|
|
75306
|
+
} catch (error) {
|
|
75307
|
+
if (error instanceof WorkspaceSnapshotError) return reply.status(error.status).send({ ok: false, error: error.message });
|
|
75308
|
+
throw error;
|
|
75309
|
+
}
|
|
75310
|
+
}
|
|
75311
|
+
const candidate = projectSnapshot ? projectSnapshot.contract : readAcceptedForRequest(appId, void 0);
|
|
75312
|
+
if (candidate == null) return reply.status(404).send({ ok: false, error: "no contract to export" });
|
|
75313
|
+
const steel = acceptSteelForRoute(candidate, { appId, projectId: project }, "stored");
|
|
75314
|
+
if (!steel.accepted) return reply.status(400).send(steel.refusal);
|
|
75315
|
+
const { scene, skipped } = contractToScene(steel.doc);
|
|
75316
|
+
if (scene.elements.length === 0) {
|
|
75317
|
+
return reply.status(422).send({ ok: false, error: "no resolvable members to render \u2014 every member is an RFI (no AISC size yet)", skipped });
|
|
75318
|
+
}
|
|
75319
|
+
const companionId = `${appId}-3d`;
|
|
75320
|
+
let flo;
|
|
75140
75321
|
try {
|
|
75141
|
-
|
|
75142
|
-
} catch (
|
|
75143
|
-
|
|
75144
|
-
|
|
75322
|
+
flo = writeViewer3dApp(appPath(companionId), companionId, scene);
|
|
75323
|
+
} catch (e) {
|
|
75324
|
+
app.log.error({ companionId, err: e instanceof Error ? e.message : e }, "export-3d: companion app write failed");
|
|
75325
|
+
return reply.status(500).send({ ok: false, error: `could not write the 3D companion app: ${e instanceof Error ? e.message : "write error"}` });
|
|
75145
75326
|
}
|
|
75146
|
-
|
|
75147
|
-
|
|
75148
|
-
|
|
75149
|
-
|
|
75150
|
-
|
|
75151
|
-
const { scene, skipped } = contractToScene(steel.doc);
|
|
75152
|
-
if (scene.elements.length === 0) {
|
|
75153
|
-
return reply.status(422).send({ ok: false, error: "no resolvable members to render \u2014 every member is an RFI (no AISC size yet)", skipped });
|
|
75154
|
-
}
|
|
75155
|
-
const companionId = `${appId}-3d`;
|
|
75156
|
-
let flo;
|
|
75157
|
-
try {
|
|
75158
|
-
flo = writeViewer3dApp(appPath(companionId), companionId, scene);
|
|
75159
|
-
} catch (e) {
|
|
75160
|
-
app.log.error({ companionId, err: e instanceof Error ? e.message : e }, "export-3d: companion app write failed");
|
|
75161
|
-
return reply.status(500).send({ ok: false, error: `could not write the 3D companion app: ${e instanceof Error ? e.message : "write error"}` });
|
|
75162
|
-
}
|
|
75163
|
-
try {
|
|
75164
|
-
await aware.compile(flo);
|
|
75165
|
-
} catch (e) {
|
|
75166
|
-
app.log.warn({ companionId, detail: e instanceof AwareError ? e.detail : void 0 }, "3D compile failed");
|
|
75167
|
-
return reply.status(422).send({ ok: false, error: `3D compile failed: ${e instanceof Error ? e.message : "compile error"}`, reason: awareStderr(e) });
|
|
75168
|
-
}
|
|
75169
|
-
let result;
|
|
75170
|
-
try {
|
|
75171
|
-
result = await aware.run(companionId, {});
|
|
75172
|
-
} catch (e) {
|
|
75173
|
-
if (e instanceof AwareError) {
|
|
75174
|
-
app.log.warn({ companionId, detail: e.detail }, "3D render failed");
|
|
75175
|
-
return reply.send({ ok: false, error: e.message, reason: awareStderr(e) });
|
|
75327
|
+
try {
|
|
75328
|
+
await aware.compile(flo);
|
|
75329
|
+
} catch (e) {
|
|
75330
|
+
app.log.warn({ companionId, detail: e instanceof AwareError ? e.detail : void 0 }, "3D compile failed");
|
|
75331
|
+
return reply.status(422).send({ ok: false, error: `3D compile failed: ${e instanceof Error ? e.message : "compile error"}`, reason: awareStderr(e) });
|
|
75176
75332
|
}
|
|
75177
|
-
|
|
75178
|
-
|
|
75179
|
-
|
|
75180
|
-
|
|
75181
|
-
|
|
75182
|
-
|
|
75183
|
-
|
|
75184
|
-
|
|
75333
|
+
let result;
|
|
75334
|
+
try {
|
|
75335
|
+
result = await aware.run(companionId, {});
|
|
75336
|
+
} catch (e) {
|
|
75337
|
+
if (e instanceof AwareError) {
|
|
75338
|
+
app.log.warn({ companionId, detail: e.detail }, "3D render failed");
|
|
75339
|
+
return reply.send({ ok: false, error: e.message, reason: awareStderr(e) });
|
|
75340
|
+
}
|
|
75341
|
+
throw e;
|
|
75342
|
+
}
|
|
75343
|
+
const events = result.traceText ? parseTrace(result.traceText) : [];
|
|
75344
|
+
const extracted = extractReportHtml(events);
|
|
75345
|
+
if (!extracted) return reply.send({ ok: false, error: "the 3D render produced no html" });
|
|
75346
|
+
broadcast({ type: "apps-changed" });
|
|
75347
|
+
return { ok: true, report: { ...extracted, interactive: true }, skipped };
|
|
75348
|
+
}),
|
|
75349
|
+
// Names the job for anyone blocked on the project, with no countdown — same reasoning as the
|
|
75350
|
+
// Tekla bake: slow sometimes, not predictably so. The label goes on the OUTER (project) lock,
|
|
75351
|
+
// which is the one a sibling export contends with.
|
|
75352
|
+
{ label: "building the 3D view" }
|
|
75353
|
+
);
|
|
75185
75354
|
});
|
|
75186
75355
|
async function stableExportSourceId(appId, project) {
|
|
75187
75356
|
const ownerId = project ? await getOrCreateProjectExportSourceId(project) : await getOrCreateWorkflowExportSourceId(appId);
|
|
@@ -75498,6 +75667,12 @@ async function startServer() {
|
|
|
75498
75667
|
} finally {
|
|
75499
75668
|
(0, import_node_fs45.rmSync)(scratch, { recursive: true, force: true });
|
|
75500
75669
|
}
|
|
75670
|
+
}, {
|
|
75671
|
+
// What anyone blocked on this project is told, and for how long to expect it. Erring long
|
|
75672
|
+
// on purpose: over-declaring costs a waiter one needless refusal, under-declaring costs it
|
|
75673
|
+
// a silent multi-minute stall, which is the failure this exists to remove.
|
|
75674
|
+
label: "rendering",
|
|
75675
|
+
expectedMs: renderExpectedMs(output, quality, viewpoints.length)
|
|
75501
75676
|
});
|
|
75502
75677
|
});
|
|
75503
75678
|
app.post("/api/contract/:appId/export-tekla", async (req, reply) => {
|
|
@@ -75595,7 +75770,7 @@ async function startServer() {
|
|
|
75595
75770
|
app.log.error({ companionId: companion.id, error: error instanceof Error ? error.message : error }, "could not remove Tekla export companion");
|
|
75596
75771
|
}
|
|
75597
75772
|
}
|
|
75598
|
-
});
|
|
75773
|
+
}, { label: "sending the model to Tekla" });
|
|
75599
75774
|
});
|
|
75600
75775
|
app.post("/api/contract/:appId/export-bom/:format", async (req, reply) => {
|
|
75601
75776
|
const { appId, format } = req.params;
|
|
@@ -122,7 +122,14 @@ with an explicit OK at each kind (this is the interactive heart — never one-sh
|
|
|
122
122
|
- **Framing plans** — the sheets that get read into members. Confirm the list before reading.
|
|
123
123
|
- **Elevations / sections** — used for member heights (TOS/BOS), moment-frame schedules, and as
|
|
124
124
|
jump targets for clickable callouts (stage 6). Confirm which sheets these are.
|
|
125
|
-
- **Details
|
|
125
|
+
- **Details — CHASED TO A FIXED POINT, not one hop.** The plans' callouts get you to the first rank of
|
|
126
|
+
detail sheets; those details then reference further sheets, usually for the numbers (a schedule held
|
|
127
|
+
elsewhere, a related connection type drawn on another sheet), and those may reference on again. Walk the
|
|
128
|
+
references sheet-to-sheet until a pass turns up nothing new, and confirm the WHOLE resolved set with the
|
|
129
|
+
user, not just the sheets the plans happened to name. Follow references written as PROSE inside a detail,
|
|
130
|
+
not only drawn bubbles. If the chain leaves the set, say which sheet is missing and what it cost: a
|
|
131
|
+
connection whose schedule sheet is absent has an arrangement but no sizes, and must be reported that way
|
|
132
|
+
rather than read as complete. (See `reading-structural-drawings` → "The set is a GRAPH".)
|
|
126
133
|
- **A sample line + profile** — on the first plan, read ONE member (its segment + profile label)
|
|
127
134
|
and show it back; get an OK that the geometry + size mapping is right before reading the rest.
|
|
128
135
|
|
|
@@ -141,6 +148,28 @@ the user at the editor:
|
|
|
141
148
|
- **Pre-fill the connection library** from `company-rules.md` (stage 2): emit the firm's rows into
|
|
142
149
|
the contract's `connections[]` with `source:"company-rules"`; the user reviews/assigns them per
|
|
143
150
|
member end in the editor's **Connections** panel (the per-end picker + confidence card).
|
|
151
|
+
- **Read the CHASED details into that same library — this is the point of chasing them.** Once the
|
|
152
|
+
reference graph is resolved (stage 5), each terminal detail says how its connection is actually built.
|
|
153
|
+
Put that on the `connections[]` row it belongs to, with `source:"drawing"`:
|
|
154
|
+
- `detail` — the callout as drawn, in whatever form this set writes it; that string is what a member
|
|
155
|
+
end's callout is matched against, so keep it verbatim rather than normalising it to a house style;
|
|
156
|
+
- `recipe.kind` — what it builds (`shear-plate`, `base-plate`);
|
|
157
|
+
- `recipe.params` — the numbers on the typical figure itself (plate thickness, weld leg, bolt Ø);
|
|
158
|
+
- `recipe.schedule[]` — the table that varies those numbers by member size, **which often lives on the
|
|
159
|
+
sheet the detail points AT rather than the detail's own sheet**, so it only exists if the chain was
|
|
160
|
+
followed; one row per size band, matched by `profile` / `profilePrefix` / `depth`;
|
|
161
|
+
- `recipe.notes[]` — the rules written round the figure (material grades, oversize-hole notes, weld
|
|
162
|
+
callouts, finish requirements). Carry them verbatim; they are not decoration, and floless surfaces
|
|
163
|
+
them on every end that uses the detail.
|
|
164
|
+
|
|
165
|
+
A row with a `recipe` is what lets a member end carrying that callout be **built** (issue #386). A row
|
|
166
|
+
read from the drawing but whose schedule sheet was missing must be left WITHOUT a schedule and said so —
|
|
167
|
+
an invented size band is worse than an end that honestly refuses to build.
|
|
168
|
+
- **Bind callouts to member ends where the drawing shows it.** A detail bubble on a plan has a leader
|
|
169
|
+
pointing at a specific connection; that link is legible at read time and guesswork afterwards. Where the
|
|
170
|
+
leader clearly lands on a member end, set that end's `detail` to the callout text so the end is buildable
|
|
171
|
+
without the user re-picking it by hand. Where it is ambiguous, leave it unset — the editor's ⌖ pick is
|
|
172
|
+
the fallback, and a wrong binding is worse than none.
|
|
144
173
|
- **Point at the rest of the canvas:** the **filter** view (refine the kept linework), **Approve**
|
|
145
174
|
(bake the lock — the determinism gate), **3D** model, **IFC** / **Tekla** export, the **BOM**
|
|
146
175
|
(exportable to **CSV / Excel**), the **confidence report**, and the **callout bubbles** (click a
|
|
@@ -11,18 +11,21 @@ on **port 4317** and drive it with Playwright (the standing real-E2E rule).
|
|
|
11
11
|
script is `tsx watch …` (auto-reload) but the server is usually launched with **`start`
|
|
12
12
|
(NO watch)** — so **server TS edits (`index.ts`, `aware-adapter.ts`, `app-reader.ts`) need a
|
|
13
13
|
manual restart**; a 404 on a route you just added means the old process is still running.
|
|
14
|
-
- **License env
|
|
15
|
-
(`licensing.ts storeDir()`)
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
- **License — no env var needed on Windows:** the dev server's license dir
|
|
15
|
+
(`licensing.ts storeDir()`) resolves to `%LOCALAPPDATA%\FlolessApp-data` for dev/npm *and* the
|
|
16
|
+
packaged app alike, so it shares the **installed app's** token + `floless-install-id` out of the
|
|
17
|
+
box (no seat takeover — single-session/newest-login-wins). Token lives at
|
|
18
|
+
`%LOCALAPPDATA%\FlolessApp-data\floless-license.json`. Non-Windows falls back to `~/.aware`.
|
|
19
|
+
Set `FLOLESS_LICENSE_DIR` only to point somewhere *else* (tests, an isolated/mock store).
|
|
20
|
+
- **Never hardcode a license path in `.claude/launch.json`:** it performs **no variable
|
|
21
|
+
expansion** — `${env:VAR}`, `${VAR}`, `$VAR`, `%VAR%` and `~` all reach the child process
|
|
22
|
+
verbatim (probe-verified), so any absolute path there is correct on exactly one machine and
|
|
23
|
+
402s every `/api` route on every other one.
|
|
21
24
|
- **`web/` is served fresh from disk per request** — edits to `web/*.js|css|html` need only a
|
|
22
25
|
browser **reload**, no server restart. Only server TS needs a restart.
|
|
23
26
|
- **Restart recipe (Windows):** find the listener (`netstat -ano | grep :4317`), get its tree
|
|
24
27
|
(`Get-CimInstance Win32_Process`), `taskkill //PID <tsx-pid> //T //F`, then relaunch
|
|
25
|
-
`
|
|
28
|
+
`npx tsx main.ts --serve` in the background.
|
|
26
29
|
|
|
27
30
|
## The run trace (what `aware app run` emits)
|
|
28
31
|
|
|
@@ -71,6 +71,34 @@ The vector linework is ground truth; your judgement binds LABELS to it, it does
|
|
|
71
71
|
The same applies to the **linked detail/section sheets a callout points to** — extract each referenced
|
|
72
72
|
sheet to vector SVG (e.g. PyMuPDF `get_svg_image`, strip the embedded raster) so the callout opens crisp.
|
|
73
73
|
|
|
74
|
+
## The set is a GRAPH — follow every callout to a fixed point, not one hop
|
|
75
|
+
|
|
76
|
+
**A plan callout is the START of a chain, never the end.** It gets you to a sheet; the detail on that
|
|
77
|
+
sheet then points onward for the numbers — a schedule held on a different sheet, a related connection
|
|
78
|
+
type drawn elsewhere — and that sheet may point on again. Reading only the sheets the *plans* name leaves
|
|
79
|
+
you with a picture of the connection and none of its numbers: the arrangement without the sizes.
|
|
80
|
+
|
|
81
|
+
**Resolve the reference graph transitively:**
|
|
82
|
+
|
|
83
|
+
1. Start from every callout on every framing plan (detail bubbles, section marks — whatever form this set
|
|
84
|
+
uses; read the set's own conventions rather than assuming a numbering scheme).
|
|
85
|
+
2. Extract each referenced sheet, then **read ITS callouts and its in-detail cross-references too** —
|
|
86
|
+
including references written as PROSE inside a detail ("see schedule on …", "per detail …", "see sheet
|
|
87
|
+
… for …"), not just drawn bubbles. Those are the ones a bubble-only extractor misses.
|
|
88
|
+
3. Repeat until a pass adds no new sheets. That fixed point is the set you actually have to read.
|
|
89
|
+
4. **Record the edges** (which sheet/detail references which), so the chain is traceable afterwards and
|
|
90
|
+
a gap is visible rather than silent.
|
|
91
|
+
|
|
92
|
+
**A missing link is a FINDING, not a shrug.** If the chain reaches a sheet that is not in the PDF — or you
|
|
93
|
+
stop early — say so explicitly and name what it cost: *"this detail sizes its plate from a schedule sheet
|
|
94
|
+
that is not in this set, so the connection cannot be sized."* Silently keeping the one-hop read produces a
|
|
95
|
+
model that looks detailed and has no fabrication numbers behind it.
|
|
96
|
+
|
|
97
|
+
**Assume the plans under-name the set.** On a set measured while writing this rule, the framing plans'
|
|
98
|
+
callouts reached only a small minority of the connection-detail sheets directly — the rest were reachable
|
|
99
|
+
only on a second or third hop, and the sheet carrying the plate schedule was two hops from the plan. Let
|
|
100
|
+
the graph tell you the real extent; the plans' own callout list is a starting point, not an inventory.
|
|
101
|
+
|
|
74
102
|
## Symbols mean what THIS set's legend says — never a remembered mapping
|
|
75
103
|
|
|
76
104
|
A framing plan draws several things as "a line with marks on its ends", and they are not the same kind
|