@floless/app 0.170.0 → 0.171.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/dist/floless-server.cjs +33000 -22928
  2. package/dist/schemas/steel.model.v2.schema.json +194 -3
  3. package/dist/skills/floless-app-bridge/SKILL.md +3 -3
  4. package/dist/skills/floless-app-knowledge/SKILL.md +4 -3
  5. package/dist/skills/floless-app-onboarding/SKILL.md +5 -4
  6. package/dist/skills/floless-app-onboarding/references/floless-surfaces.md +0 -3
  7. package/dist/skills/floless-app-queue/SKILL.md +2 -3
  8. package/dist/skills/floless-app-report-issue/SKILL.md +2 -2
  9. package/dist/skills/floless-app-steel-model/SKILL.md +35 -35
  10. package/dist/skills/floless-app-steel-model/references/custom-connections.md +47 -0
  11. package/dist/skills/floless-app-steel-model/references/custom-sections.md +32 -0
  12. package/dist/skills/floless-app-ui/SKILL.md +71 -126
  13. package/dist/web/add-ons.js +407 -0
  14. package/dist/web/analytics.js +1 -1
  15. package/dist/web/app.css +108 -189
  16. package/dist/web/app.js +11 -12
  17. package/dist/web/aware.js +49 -29
  18. package/dist/web/chat.css +6 -1
  19. package/dist/web/chat.js +133 -18
  20. package/dist/web/commands-filter.js +23 -0
  21. package/dist/web/commands-shell.js +39 -67
  22. package/dist/web/commands-steel.js +9 -1
  23. package/dist/web/commands-tekla-parser.js +23 -0
  24. package/dist/web/connections.js +14 -3
  25. package/dist/web/failure-copy.js +1 -0
  26. package/dist/web/guide.js +3 -3
  27. package/dist/web/index.html +29 -56
  28. package/dist/web/instructor.js +2 -2
  29. package/dist/web/kb-categories.js +64 -7
  30. package/dist/web/model-change-findings.js +430 -0
  31. package/dist/web/model-change-review.js +414 -0
  32. package/dist/web/model-editor-steel-adapter.js +2 -2
  33. package/dist/web/project-history.js +7 -1
  34. package/dist/web/revit-editor.css +85 -0
  35. package/dist/web/revit-editor.js +36 -1
  36. package/dist/web/sha256-sync.js +62 -0
  37. package/dist/web/steel-3d-core.js +7 -0
  38. package/dist/web/steel-3d-flo.js +127 -3
  39. package/dist/web/steel-3d-view.js +25 -2
  40. package/dist/web/steel-custom-connection.js +161 -0
  41. package/dist/web/steel-custom-sections.js +1796 -0
  42. package/dist/web/steel-editor.html +279 -41
  43. package/dist/web/steel-filter-usage.js +299 -0
  44. package/dist/web/steel-filter.html +101 -4
  45. package/dist/web/steel-model-v2-client-validation.js +3 -0
  46. package/dist/web/steel-model-v2-commands.js +95 -6
  47. package/dist/web/steel-model-v2-projection.js +1 -1
  48. package/dist/web/steel-read-confidence.js +1 -56
  49. package/dist/web/tekla-editor.html +1 -0
  50. package/dist/web/workspaces.js +263 -28
  51. package/launch.mjs +87 -9
  52. package/package.json +1 -1
  53. package/dist/web/panels.js +0 -831
@@ -16,6 +16,7 @@ import { memberPresence, projectionLink } from './steel-model-v2-projection.js';
16
16
  import { gridLabelPatch, parseSpacings } from './grid-core.js';
17
17
  import { IN_TO_MM as IN_MM } from './steel-units.js';
18
18
  import { defaultGradeFor } from './steel-environments.js';
19
+ import { resultDigest, resolveCustomSection } from './steel-custom-sections.js';
19
20
  import {
20
21
  basisFromAxes, endpointPlacementCompensation, effectiveDepthPosition, effectiveWidthPosition, outlineFor, partFrame,
21
22
  positionOffsetVector, reversePlacement, sectionExtents,
@@ -109,9 +110,19 @@ const withoutAnswer = (z) => (z && z.answered ? { known: z.known }
109
110
  * and a key order that differs while the value is identical must compare EQUAL. Rejecting that would
110
111
  * refuse a perfectly valid move for a reason no user could ever act on.
111
112
  */
113
+ /** The root keys a custom section lives in (add-ons S1a); the undo snapshot captures both under `customSections`. */
114
+ export const CUSTOM_SECTION_ROOT_KEYS = Object.freeze(['section_definitions', 'custom_sections']);
115
+
116
+ /** What an undo snapshot records of the custom sections: each key present with its value, or absent. */
117
+ export function captureCustomSections(doc) {
118
+ const out = {};
119
+ for (const key of CUSTOM_SECTION_ROOT_KEYS) if (doc && doc[key] !== undefined) out[key] = doc[key];
120
+ return out;
121
+ }
122
+
112
123
  const FINGERPRINT_KEYS = [
113
124
  'role', 'memberType', 'brace', 'position', 'positionH', 'positionOffset', 'positionHOffset',
114
- 'positionBasis', 'rot', 'profile', 'section',
125
+ 'positionBasis', 'rot', 'profile', 'section', 'customSectionId',
115
126
  ];
116
127
  function stableKey(v) {
117
128
  if (v === null || typeof v !== 'object') return JSON.stringify(v ?? null);
@@ -697,7 +708,16 @@ const inferredMaterial = (profile, defaultMaterial) => (defaultMaterial ? defaul
697
708
  const effectiveMemberType = (m) => typeof m.memberType === 'string' && m.memberType.trim()
698
709
  ? m.memberType.trim().toLowerCase() : (m.role === 'column' ? 'column' : 'beam');
699
710
 
700
- function mergeSection(member, resolveSection) {
711
+ function mergeSection(member, resolveSection, doc) {
712
+ // Add-ons S1a: a custom section is the member's section outright, read from the document being edited, never
713
+ // from a catalogue row of the same name. One FloLess cannot vouch for has no shape to place.
714
+ const custom = resolveCustomSection(doc, member);
715
+ if (custom) {
716
+ const s = custom.usable ? custom.section : null;
717
+ if (!s || !(s.width > 0) || !(s.depth > 0) || !Array.isArray(s.outline)) return null;
718
+ const outline = { outer: s.outline.map(([x, y]) => [x, y]) };
719
+ return { w: s.width, d: s.depth, round: false, outline, extents: sectionExtents(outline), roundRadius: null, roundInnerRadius: null };
720
+ }
701
721
  const standard = resolveSection ? resolveSection(member) : null;
702
722
  const explicit = member.section && member.section.w > 0 && member.section.d > 0
703
723
  ? { w: member.section.w, d: member.section.d, round: false } : null;
@@ -731,7 +751,7 @@ function mergePlacedSection(member, from, to, section) {
731
751
  };
732
752
  }
733
753
 
734
- function physicalMergePreflight(sources, resolveSection, defaultMaterial) {
754
+ function physicalMergePreflight(sources, resolveSection, defaultMaterial, doc) {
735
755
  const rows = sources.map((m) => ({ m, a: vec3(m.from, `${m.id}.from`), b: vec3(m.to, `${m.id}.to`) }));
736
756
  const points = rows.flatMap((r, ri) => [{ p: r.a, ri, end: 0 }, { p: r.b, ri, end: 1 }]).sort((a,b)=>lex3(a.p,b.p));
737
757
  const parent=points.map((_,i)=>i),find=i=>parent[i]===i?i:(parent[i]=find(parent[i])),join=(a,b)=>{a=find(a);b=find(b);if(a!==b)parent[b]=a;};
@@ -759,11 +779,14 @@ function physicalMergePreflight(sources, resolveSection, defaultMaterial) {
759
779
  let reference=null;
760
780
  for(const item of ordered){const m=item.row.m,p=canonProfile(m.profile),r=m.role==='column'?'column':'beam',t=effectiveMemberType(m),mat=(m.material&&m.material.trim())||inferredMaterial(p, defaultMaterial);
761
781
  if(p!==profile||r!==role||t!==memberType||mat!==material)throw new V2CommandError('merge-member-conflict','merge sources must agree on effective profile, material, role, and member type');
782
+ // Add-ons S1a: two custom sections may share a designation and differ in shape, and a custom member is never
783
+ // the same section as a catalogue one, so the section identity must agree too.
784
+ if((m.customSectionId??null)!==(ordered[0].row.m.customSectionId??null))throw new V2CommandError('merge-member-conflict','merge sources must agree on their custom section');
762
785
  let physicalMember=m,physicalFrom=item.row.a,physicalTo=item.row.b;
763
786
  if(!item.forward){const basis=m.positionBasis?basisFromAxes(m.positionBasis.x,m.positionBasis.y):{x:[1,0,0],y:[0,1,0],z:[0,0,1]};const sourceFrame=basis&&partFrame(item.row.a,item.row.b,basis.z,basis.x);
764
787
  if(!sourceFrame)throw new V2CommandError('merge-section-unresolved',`cannot normalize the direction of "${m.id}"`);
765
788
  physicalMember=Object.assign(clone(m),reversePlacement(m,sourceFrame.degenerate));physicalFrom=item.row.b;physicalTo=item.row.a;}
766
- const sec=mergeSection(physicalMember,resolveSection);if(!sec)throw new V2CommandError('merge-section-unresolved',`cannot compute the section placement for "${m.id}"`);
789
+ const sec=mergeSection(physicalMember,resolveSection,doc);if(!sec)throw new V2CommandError('merge-section-unresolved',`cannot compute the section placement for "${m.id}"`);
767
790
  const placed=mergePlacedSection(physicalMember,physicalFrom,physicalTo,sec);if(!placed)throw new V2CommandError('merge-section-unresolved',`cannot compute the section frame for "${m.id}"`);
768
791
  const signature={m:physicalMember,sec,placed};
769
792
  // Every source is compared with the survivor inherited from the FIRST source. Advancing this
@@ -800,7 +823,7 @@ function mergeMemberGroup(doc, sheet, memberIds, mergedPx, mintId, resolveSectio
800
823
  if (oldIds.size < 2) throw new V2CommandError('merge-needs-two', 'merge needs at least two members');
801
824
  assertNoWholeMemberRefs(doc, oldIds);
802
825
  const sources = [...oldIds].map((id) => memberById(doc, id));
803
- const physical=physicalMergePreflight(sources,resolveSection,defaultMaterial);
826
+ const physical=physicalMergePreflight(sources,resolveSection,defaultMaterial,doc);
804
827
  const merged = physical.survivor;
805
828
  merged.id = mintId();
806
829
  // MERGE is split's inverse and needs the same rule: if either source end was placed rather than
@@ -972,6 +995,15 @@ export function createV2CommandSession(model, options = {}) {
972
995
  if (Object.hasOwn(saved, 'details')) draft.detail_placements = clone(saved.details || []);
973
996
  draft.views = clone(saved.views || []);
974
997
  if (Object.hasOwn(saved, 'member_types')) draft.member_types = clone(saved.member_types || []);
998
+ // Add-ons S1a. Only a snapshot that CAPTURED them restores them (a partial member-end snapshot does not),
999
+ // and then by presence: a model that had none gets none back, never `[]`.
1000
+ if (Object.hasOwn(saved, 'customSections')) {
1001
+ const captured = saved.customSections || {};
1002
+ for (const key of CUSTOM_SECTION_ROOT_KEYS) {
1003
+ if (Object.hasOwn(captured, key) && captured[key] !== undefined) draft[key] = clone(captured[key]);
1004
+ else delete draft[key];
1005
+ }
1006
+ }
975
1007
  if (Object.hasOwn(saved, 'dim_style')) draft.dim_style = clone(saved.dim_style || {});
976
1008
  if (Object.hasOwn(saved, 'member_styles')) draft.member_styles = clone(saved.member_styles || {});
977
1009
  if (Object.hasOwn(saved, 'reference_models')) draft.reference_models = clone(saved.reference_models || []);
@@ -1192,7 +1224,7 @@ export function createV2CommandSession(model, options = {}) {
1192
1224
  id, profile: projected.profile || '', from, to,
1193
1225
  provenance: 'manual',
1194
1226
  };
1195
- for (const key of ['material', 'role', 'memberType', 'position', 'positionH', 'positionOffset', 'positionHOffset', 'positionBasis', 'rot', 'section', 'bf', 'rfi', 'mf', 'verified', 'source', 'brace']) {
1227
+ for (const key of ['material', 'role', 'memberType', 'position', 'positionH', 'positionOffset', 'positionHOffset', 'positionBasis', 'rot', 'section', 'customSectionId', 'bf', 'rfi', 'mf', 'verified', 'source', 'brace']) {
1196
1228
  if (projected[key] !== undefined) member[key] = clone(projected[key]);
1197
1229
  }
1198
1230
  if (Array.isArray(projected.ends)) {
@@ -1278,15 +1310,72 @@ export function createV2CommandSession(model, options = {}) {
1278
1310
  // `profileBasis` is the reader's evidence for the profile this member HAD; a different profile
1279
1311
  // is not covered by it, so it goes unless the same patch restates it.
1280
1312
  const profileChanged = Object.prototype.hasOwnProperty.call(patch, 'profile') && patch.profile !== member.profile;
1313
+ // A patch that names a profile is a person choosing one (the Browse picker, the profile field, a size pick),
1314
+ // even when the text matches what the member already shows: a custom welded W12X65 and catalogue W12X65
1315
+ // share a designation, so the choice itself, not a change of text, is what says "the catalogue one".
1316
+ const profileChosen = Object.prototype.hasOwnProperty.call(patch, 'profile') && patch.profile !== undefined;
1281
1317
  for (const [key, value] of Object.entries(patch)) {
1282
1318
  if (value === undefined) delete member[key];
1283
1319
  else member[key] = clone(value);
1284
1320
  }
1285
1321
  if (profileChanged && !Object.prototype.hasOwnProperty.call(patch, 'profileBasis')) delete member.profileBasis;
1322
+ // A catalogue profile chosen for a custom member wins (add-ons S1a): the member stops pointing at its custom
1323
+ // section unless the same patch names one. An edit that names no profile (material, verified, placement)
1324
+ // keeps the pointer. The section itself stays in the model for undo and reuse.
1325
+ if (profileChosen && !Object.prototype.hasOwnProperty.call(patch, 'customSectionId')) delete member.customSectionId;
1286
1326
  return { changedIds: [memberId] };
1287
1327
  });
1288
1328
  },
1289
1329
 
1330
+ /**
1331
+ * Add-ons S1a. Put a custom section on members in ONE undo step: insert its definition when the model does not
1332
+ * hold it yet, insert the evaluated section when absent, and point every member at it with its designation as
1333
+ * the profile. All or nothing: the draft is validated as a whole.
1334
+ *
1335
+ * A definition id is immutable: an id already in the model with another digest is `definition-id-taken`. A
1336
+ * section already in the model is reused only when it says exactly what the fresh evaluation says, so a stored
1337
+ * section that no longer matches its recipe is never adopted (`section-conflict`).
1338
+ */
1339
+ placeCustomSection({ definition, section, memberIds }) {
1340
+ return session.transact('place custom section', (doc) => {
1341
+ if (!definition || typeof definition.id !== 'string' || !section || typeof section.sectionId !== 'string') {
1342
+ throw new V2CommandError('custom-section-invalid', 'That custom section is missing its definition or its shape, so it cannot be placed. Ask the AI to rebuild it.');
1343
+ }
1344
+ const ids = [...new Set(memberIds || [])];
1345
+ if (!ids.length) throw new V2CommandError('custom-section-invalid', 'Select at least one member to put the custom section on.');
1346
+ const members = ids.map((id) => memberById(doc, id));
1347
+ const defs = Array.isArray(doc.section_definitions) ? doc.section_definitions : (doc.section_definitions = []);
1348
+ const storedDef = defs.find((d) => d && d.id === definition.id);
1349
+ if (storedDef && storedDef.digest !== definition.digest) {
1350
+ throw new V2CommandError('definition-id-taken', `The name ${definition.id} already belongs to a different custom section definition in this model. Ask the AI to save it under a new name.`);
1351
+ }
1352
+ if (!storedDef) defs.push(clone(definition));
1353
+ const sections = Array.isArray(doc.custom_sections) ? doc.custom_sections : (doc.custom_sections = []);
1354
+ const storedSection = sections.find((s) => s && s.sectionId === section.sectionId);
1355
+ if (storedSection && resultDigest(storedSection) !== resultDigest(section)) {
1356
+ throw new V2CommandError('section-conflict', 'This model already holds that custom section with a different shape. Ask the AI to check which one is right.');
1357
+ }
1358
+ if (!storedSection) sections.push(clone(section));
1359
+ for (const member of members) {
1360
+ member.customSectionId = section.sectionId;
1361
+ if (member.profile !== section.designation) delete member.profileBasis;
1362
+ member.profile = section.designation;
1363
+ }
1364
+ return { changedIds: ids, structural: true, value: section.sectionId };
1365
+ });
1366
+ },
1367
+
1368
+ /** Add-ons S1a. Record (or withdraw) the person's "Proceed on assumption" for a section FloLess cannot vouch for. */
1369
+ setCustomSectionAssumption(sectionId, assumption) {
1370
+ return session.transact('custom section assumption', (doc) => {
1371
+ const section = (doc.custom_sections || []).find((s) => s && s.sectionId === sectionId);
1372
+ if (!section) throw new V2CommandError('custom-section-missing', 'That custom section is no longer in this model. Reopen the member and try again.');
1373
+ if (assumption) section.assumption = clone(assumption);
1374
+ else delete section.assumption;
1375
+ return { structural: true };
1376
+ });
1377
+ },
1378
+
1290
1379
  patchMemberBrace(memberId, patch) {
1291
1380
  return session.transact('patch member brace', (doc) => {
1292
1381
  const member = memberById(doc, memberId);
@@ -228,7 +228,7 @@ export function memberProperties(member) {
228
228
  role: member.role || 'beam',
229
229
  provenance: member.provenance,
230
230
  };
231
- for (const key of ['profileBasis', 'material', 'memberType', 'position', 'positionH', 'positionOffset', 'positionHOffset', 'positionBasis', 'rot', 'section', 'bf', 'rfi', 'mf', 'verified', 'source', 'brace']) {
231
+ for (const key of ['profileBasis', 'material', 'memberType', 'position', 'positionH', 'positionOffset', 'positionHOffset', 'positionBasis', 'rot', 'section', 'customSectionId', 'bf', 'rfi', 'mf', 'verified', 'source', 'brace']) {
232
232
  if (member[key] !== undefined) meta[key] = clone(member[key]);
233
233
  }
234
234
  const endMeta = Array.isArray(member.ends) ? member.ends : [{}, {}];
@@ -6,62 +6,7 @@
6
6
  */
7
7
 
8
8
  import { rawPlanViewId } from './steel-plan-view-id.js';
9
-
10
- const SHA256_K = Object.freeze([
11
- 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
12
- 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
13
- 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
14
- 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
15
- 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
16
- 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
17
- 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
18
- 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2,
19
- ]);
20
-
21
- const rotateRight = (value, bits) => (value >>> bits) | (value << (32 - bits));
22
-
23
- /** Synchronous SHA-256 for the two tiny lineage tokens projected during a render. */
24
- function sha256Hex(text) {
25
- const input = new TextEncoder().encode(text);
26
- const byteLength = Math.ceil((input.length + 9) / 64) * 64;
27
- const bytes = new Uint8Array(byteLength);
28
- bytes.set(input);
29
- bytes[input.length] = 0x80;
30
- const view = new DataView(bytes.buffer);
31
- const bitLength = input.length * 8;
32
- view.setUint32(byteLength - 8, Math.floor(bitLength / 0x100000000));
33
- view.setUint32(byteLength - 4, bitLength >>> 0);
34
- const hash = new Uint32Array([
35
- 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a,
36
- 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19,
37
- ]);
38
- const words = new Uint32Array(64);
39
- for (let offset = 0; offset < byteLength; offset += 64) {
40
- for (let i = 0; i < 16; i++) words[i] = view.getUint32(offset + i * 4);
41
- for (let i = 16; i < 64; i++) {
42
- const a = words[i - 15];
43
- const b = words[i - 2];
44
- const s0 = rotateRight(a, 7) ^ rotateRight(a, 18) ^ (a >>> 3);
45
- const s1 = rotateRight(b, 17) ^ rotateRight(b, 19) ^ (b >>> 10);
46
- words[i] = (words[i - 16] + s0 + words[i - 7] + s1) >>> 0;
47
- }
48
- let [a, b, c, d, e, f, g, h] = hash;
49
- for (let i = 0; i < 64; i++) {
50
- const s1 = rotateRight(e, 6) ^ rotateRight(e, 11) ^ rotateRight(e, 25);
51
- const choice = (e & f) ^ (~e & g);
52
- const t1 = (h + s1 + choice + SHA256_K[i] + words[i]) >>> 0;
53
- const s0 = rotateRight(a, 2) ^ rotateRight(a, 13) ^ rotateRight(a, 22);
54
- const majority = (a & b) ^ (a & c) ^ (b & c);
55
- const t2 = (s0 + majority) >>> 0;
56
- h = g; g = f; f = e; e = (d + t1) >>> 0; d = c; c = b; b = a; a = (t1 + t2) >>> 0;
57
- }
58
- hash[0] = (hash[0] + a) >>> 0; hash[1] = (hash[1] + b) >>> 0;
59
- hash[2] = (hash[2] + c) >>> 0; hash[3] = (hash[3] + d) >>> 0;
60
- hash[4] = (hash[4] + e) >>> 0; hash[5] = (hash[5] + f) >>> 0;
61
- hash[6] = (hash[6] + g) >>> 0; hash[7] = (hash[7] + h) >>> 0;
62
- }
63
- return [...hash].map((word) => word.toString(16).padStart(8, '0')).join('');
64
- }
9
+ import { sha256Hex } from './sha256-sync.js';
65
10
 
66
11
  const endpointLineageId = (observationId, observationEnd) =>
67
12
  `sha256:${sha256Hex(`floless:endpoint-lineage:v1\0${JSON.stringify([observationId, observationEnd])}`)}`;
@@ -45,6 +45,7 @@
45
45
  <div id="revitPanelTabs" hidden>
46
46
  <div id="revitClipListHost" class="revit-clip-list-host"></div>
47
47
  <div id="teklaAuditHost" class="tekla-audit-host" hidden></div>
48
+ <div id="teklaChangesHost" class="tekla-audit-host tekla-changes-host" aria-label="Changes between saved states" hidden></div>
48
49
  </div>
49
50
  <div id="loadingState" class="viewport-state" aria-live="polite">
50
51
  <span class="state-spinner" aria-hidden="true"></span>