@floless/app 0.167.0 → 0.169.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 (277) hide show
  1. package/autostart.mjs +169 -63
  2. package/cli-actions.mjs +8 -1
  3. package/desktop-shell.mjs +335 -0
  4. package/dist/floless-server.cjs +73121 -55759
  5. package/dist/schemas/steel.model.v2.schema.json +2 -1
  6. package/dist/skills/floless-app-onboarding/SKILL.md +13 -4
  7. package/dist/skills/floless-app-onboarding/references/floless-surfaces.md +3 -0
  8. package/dist/skills/floless-app-rfi/SKILL.md +4 -2
  9. package/dist/skills/floless-app-steel-takeoff/SKILL.md +21 -2
  10. package/dist/skills/floless-app-ui/SKILL.md +2 -2
  11. package/dist/skills/floless-app-workflows/SKILL.md +2 -2
  12. package/dist/templates/college-phase-exporter.flo +7 -2
  13. package/dist/templates/trimble-list-projects.flo +10 -2
  14. package/dist/web/agent-steps.js +2 -2
  15. package/dist/web/agents.js +50 -14
  16. package/dist/web/app.css +209 -11
  17. package/dist/web/app.js +99 -16
  18. package/dist/web/aware-update-client.js +14 -6
  19. package/dist/web/aware.js +583 -69
  20. package/dist/web/chat.css +12 -1
  21. package/dist/web/chat.js +627 -96
  22. package/dist/web/commands-drawing-check.js +3 -0
  23. package/dist/web/commands-filter.js +5 -5
  24. package/dist/web/commands-shell.js +283 -14
  25. package/dist/web/commands-steel.js +9 -2
  26. package/dist/web/commands-vector.js +69 -0
  27. package/dist/web/desktop-window.js +435 -0
  28. package/dist/web/drawing-check-editor.html +10 -0
  29. package/dist/web/drawing-check-editor.js +515 -187
  30. package/dist/web/failure-copy.js +33 -2
  31. package/dist/web/flo-3d.js +310 -0
  32. package/dist/web/flo-card.js +72 -0
  33. package/dist/web/guide.js +78 -10
  34. package/dist/web/index.html +90 -10
  35. package/dist/web/instructor.js +4 -1
  36. package/dist/web/leave-guard.js +347 -14
  37. package/dist/web/model-editor-steel-adapter.js +41 -1
  38. package/dist/web/model-viewport-toolbar.js +11 -0
  39. package/dist/web/pages.js +21 -14
  40. package/dist/web/panels.js +5 -2
  41. package/dist/web/pdf-view.js +421 -0
  42. package/dist/web/project-history.js +3 -2
  43. package/dist/web/project-modules.js +5 -3
  44. package/dist/web/project-reconciliation.js +1 -1
  45. package/dist/web/project-rfis.js +4 -2
  46. package/dist/web/project-workflows.js +8 -4
  47. package/dist/web/reference-geometry-worker.js +11 -2
  48. package/dist/web/renderers.js +6 -0
  49. package/dist/web/report-csp.js +68 -0
  50. package/dist/web/revit-editor.html +1 -0
  51. package/dist/web/revit-editor.js +37 -8
  52. package/dist/web/run-history.js +2 -3
  53. package/dist/web/shared-prefs.js +364 -0
  54. package/dist/web/steel-3d-flo.js +309 -0
  55. package/dist/web/steel-3d-view.js +159 -0
  56. package/dist/web/steel-editor.html +329 -47
  57. package/dist/web/steel-filter-flo.js +74 -18
  58. package/dist/web/steel-filter.html +22 -6
  59. package/dist/web/tab-signal.js +36 -1
  60. package/dist/web/tekla-editor.html +1 -0
  61. package/dist/web/terminal-requests.js +78 -0
  62. package/dist/web/tool-updates.js +160 -38
  63. package/dist/web/vector-3d.html +14 -3
  64. package/dist/web/vector-editor.html +60 -10
  65. package/dist/web/vendor/README.md +23 -0
  66. package/dist/web/vendor/pdfjs/LICENSE +177 -0
  67. package/dist/web/vendor/pdfjs/cmaps/78-EUC-H.bcmap +0 -0
  68. package/dist/web/vendor/pdfjs/cmaps/78-EUC-V.bcmap +0 -0
  69. package/dist/web/vendor/pdfjs/cmaps/78-H.bcmap +0 -0
  70. package/dist/web/vendor/pdfjs/cmaps/78-RKSJ-H.bcmap +0 -0
  71. package/dist/web/vendor/pdfjs/cmaps/78-RKSJ-V.bcmap +0 -0
  72. package/dist/web/vendor/pdfjs/cmaps/78-V.bcmap +0 -0
  73. package/dist/web/vendor/pdfjs/cmaps/78ms-RKSJ-H.bcmap +0 -0
  74. package/dist/web/vendor/pdfjs/cmaps/78ms-RKSJ-V.bcmap +0 -0
  75. package/dist/web/vendor/pdfjs/cmaps/83pv-RKSJ-H.bcmap +0 -0
  76. package/dist/web/vendor/pdfjs/cmaps/90ms-RKSJ-H.bcmap +0 -0
  77. package/dist/web/vendor/pdfjs/cmaps/90ms-RKSJ-V.bcmap +0 -0
  78. package/dist/web/vendor/pdfjs/cmaps/90msp-RKSJ-H.bcmap +0 -0
  79. package/dist/web/vendor/pdfjs/cmaps/90msp-RKSJ-V.bcmap +0 -0
  80. package/dist/web/vendor/pdfjs/cmaps/90pv-RKSJ-H.bcmap +0 -0
  81. package/dist/web/vendor/pdfjs/cmaps/90pv-RKSJ-V.bcmap +0 -0
  82. package/dist/web/vendor/pdfjs/cmaps/Add-H.bcmap +0 -0
  83. package/dist/web/vendor/pdfjs/cmaps/Add-RKSJ-H.bcmap +0 -0
  84. package/dist/web/vendor/pdfjs/cmaps/Add-RKSJ-V.bcmap +0 -0
  85. package/dist/web/vendor/pdfjs/cmaps/Add-V.bcmap +0 -0
  86. package/dist/web/vendor/pdfjs/cmaps/Adobe-CNS1-0.bcmap +0 -0
  87. package/dist/web/vendor/pdfjs/cmaps/Adobe-CNS1-1.bcmap +0 -0
  88. package/dist/web/vendor/pdfjs/cmaps/Adobe-CNS1-2.bcmap +0 -0
  89. package/dist/web/vendor/pdfjs/cmaps/Adobe-CNS1-3.bcmap +0 -0
  90. package/dist/web/vendor/pdfjs/cmaps/Adobe-CNS1-4.bcmap +0 -0
  91. package/dist/web/vendor/pdfjs/cmaps/Adobe-CNS1-5.bcmap +0 -0
  92. package/dist/web/vendor/pdfjs/cmaps/Adobe-CNS1-6.bcmap +0 -0
  93. package/dist/web/vendor/pdfjs/cmaps/Adobe-CNS1-UCS2.bcmap +0 -0
  94. package/dist/web/vendor/pdfjs/cmaps/Adobe-GB1-0.bcmap +0 -0
  95. package/dist/web/vendor/pdfjs/cmaps/Adobe-GB1-1.bcmap +0 -0
  96. package/dist/web/vendor/pdfjs/cmaps/Adobe-GB1-2.bcmap +0 -0
  97. package/dist/web/vendor/pdfjs/cmaps/Adobe-GB1-3.bcmap +0 -0
  98. package/dist/web/vendor/pdfjs/cmaps/Adobe-GB1-4.bcmap +0 -0
  99. package/dist/web/vendor/pdfjs/cmaps/Adobe-GB1-5.bcmap +0 -0
  100. package/dist/web/vendor/pdfjs/cmaps/Adobe-GB1-UCS2.bcmap +0 -0
  101. package/dist/web/vendor/pdfjs/cmaps/Adobe-Japan1-0.bcmap +0 -0
  102. package/dist/web/vendor/pdfjs/cmaps/Adobe-Japan1-1.bcmap +0 -0
  103. package/dist/web/vendor/pdfjs/cmaps/Adobe-Japan1-2.bcmap +0 -0
  104. package/dist/web/vendor/pdfjs/cmaps/Adobe-Japan1-3.bcmap +0 -0
  105. package/dist/web/vendor/pdfjs/cmaps/Adobe-Japan1-4.bcmap +0 -0
  106. package/dist/web/vendor/pdfjs/cmaps/Adobe-Japan1-5.bcmap +0 -0
  107. package/dist/web/vendor/pdfjs/cmaps/Adobe-Japan1-6.bcmap +0 -0
  108. package/dist/web/vendor/pdfjs/cmaps/Adobe-Japan1-UCS2.bcmap +0 -0
  109. package/dist/web/vendor/pdfjs/cmaps/Adobe-Korea1-0.bcmap +0 -0
  110. package/dist/web/vendor/pdfjs/cmaps/Adobe-Korea1-1.bcmap +0 -0
  111. package/dist/web/vendor/pdfjs/cmaps/Adobe-Korea1-2.bcmap +0 -0
  112. package/dist/web/vendor/pdfjs/cmaps/Adobe-Korea1-UCS2.bcmap +0 -0
  113. package/dist/web/vendor/pdfjs/cmaps/B5-H.bcmap +0 -0
  114. package/dist/web/vendor/pdfjs/cmaps/B5-V.bcmap +0 -0
  115. package/dist/web/vendor/pdfjs/cmaps/B5pc-H.bcmap +0 -0
  116. package/dist/web/vendor/pdfjs/cmaps/B5pc-V.bcmap +0 -0
  117. package/dist/web/vendor/pdfjs/cmaps/CNS-EUC-H.bcmap +0 -0
  118. package/dist/web/vendor/pdfjs/cmaps/CNS-EUC-V.bcmap +0 -0
  119. package/dist/web/vendor/pdfjs/cmaps/CNS1-H.bcmap +0 -0
  120. package/dist/web/vendor/pdfjs/cmaps/CNS1-V.bcmap +0 -0
  121. package/dist/web/vendor/pdfjs/cmaps/CNS2-H.bcmap +0 -0
  122. package/dist/web/vendor/pdfjs/cmaps/CNS2-V.bcmap +3 -0
  123. package/dist/web/vendor/pdfjs/cmaps/ETHK-B5-H.bcmap +0 -0
  124. package/dist/web/vendor/pdfjs/cmaps/ETHK-B5-V.bcmap +0 -0
  125. package/dist/web/vendor/pdfjs/cmaps/ETen-B5-H.bcmap +0 -0
  126. package/dist/web/vendor/pdfjs/cmaps/ETen-B5-V.bcmap +0 -0
  127. package/dist/web/vendor/pdfjs/cmaps/ETenms-B5-H.bcmap +3 -0
  128. package/dist/web/vendor/pdfjs/cmaps/ETenms-B5-V.bcmap +0 -0
  129. package/dist/web/vendor/pdfjs/cmaps/EUC-H.bcmap +0 -0
  130. package/dist/web/vendor/pdfjs/cmaps/EUC-V.bcmap +0 -0
  131. package/dist/web/vendor/pdfjs/cmaps/Ext-H.bcmap +0 -0
  132. package/dist/web/vendor/pdfjs/cmaps/Ext-RKSJ-H.bcmap +0 -0
  133. package/dist/web/vendor/pdfjs/cmaps/Ext-RKSJ-V.bcmap +0 -0
  134. package/dist/web/vendor/pdfjs/cmaps/Ext-V.bcmap +0 -0
  135. package/dist/web/vendor/pdfjs/cmaps/GB-EUC-H.bcmap +0 -0
  136. package/dist/web/vendor/pdfjs/cmaps/GB-EUC-V.bcmap +0 -0
  137. package/dist/web/vendor/pdfjs/cmaps/GB-H.bcmap +4 -0
  138. package/dist/web/vendor/pdfjs/cmaps/GB-V.bcmap +0 -0
  139. package/dist/web/vendor/pdfjs/cmaps/GBK-EUC-H.bcmap +0 -0
  140. package/dist/web/vendor/pdfjs/cmaps/GBK-EUC-V.bcmap +0 -0
  141. package/dist/web/vendor/pdfjs/cmaps/GBK2K-H.bcmap +0 -0
  142. package/dist/web/vendor/pdfjs/cmaps/GBK2K-V.bcmap +0 -0
  143. package/dist/web/vendor/pdfjs/cmaps/GBKp-EUC-H.bcmap +0 -0
  144. package/dist/web/vendor/pdfjs/cmaps/GBKp-EUC-V.bcmap +0 -0
  145. package/dist/web/vendor/pdfjs/cmaps/GBT-EUC-H.bcmap +0 -0
  146. package/dist/web/vendor/pdfjs/cmaps/GBT-EUC-V.bcmap +0 -0
  147. package/dist/web/vendor/pdfjs/cmaps/GBT-H.bcmap +0 -0
  148. package/dist/web/vendor/pdfjs/cmaps/GBT-V.bcmap +0 -0
  149. package/dist/web/vendor/pdfjs/cmaps/GBTpc-EUC-H.bcmap +0 -0
  150. package/dist/web/vendor/pdfjs/cmaps/GBTpc-EUC-V.bcmap +0 -0
  151. package/dist/web/vendor/pdfjs/cmaps/GBpc-EUC-H.bcmap +0 -0
  152. package/dist/web/vendor/pdfjs/cmaps/GBpc-EUC-V.bcmap +0 -0
  153. package/dist/web/vendor/pdfjs/cmaps/H.bcmap +0 -0
  154. package/dist/web/vendor/pdfjs/cmaps/HKdla-B5-H.bcmap +0 -0
  155. package/dist/web/vendor/pdfjs/cmaps/HKdla-B5-V.bcmap +0 -0
  156. package/dist/web/vendor/pdfjs/cmaps/HKdlb-B5-H.bcmap +0 -0
  157. package/dist/web/vendor/pdfjs/cmaps/HKdlb-B5-V.bcmap +0 -0
  158. package/dist/web/vendor/pdfjs/cmaps/HKgccs-B5-H.bcmap +0 -0
  159. package/dist/web/vendor/pdfjs/cmaps/HKgccs-B5-V.bcmap +0 -0
  160. package/dist/web/vendor/pdfjs/cmaps/HKm314-B5-H.bcmap +0 -0
  161. package/dist/web/vendor/pdfjs/cmaps/HKm314-B5-V.bcmap +0 -0
  162. package/dist/web/vendor/pdfjs/cmaps/HKm471-B5-H.bcmap +0 -0
  163. package/dist/web/vendor/pdfjs/cmaps/HKm471-B5-V.bcmap +0 -0
  164. package/dist/web/vendor/pdfjs/cmaps/HKscs-B5-H.bcmap +0 -0
  165. package/dist/web/vendor/pdfjs/cmaps/HKscs-B5-V.bcmap +0 -0
  166. package/dist/web/vendor/pdfjs/cmaps/Hankaku.bcmap +0 -0
  167. package/dist/web/vendor/pdfjs/cmaps/Hiragana.bcmap +0 -0
  168. package/dist/web/vendor/pdfjs/cmaps/KSC-EUC-H.bcmap +0 -0
  169. package/dist/web/vendor/pdfjs/cmaps/KSC-EUC-V.bcmap +0 -0
  170. package/dist/web/vendor/pdfjs/cmaps/KSC-H.bcmap +0 -0
  171. package/dist/web/vendor/pdfjs/cmaps/KSC-Johab-H.bcmap +0 -0
  172. package/dist/web/vendor/pdfjs/cmaps/KSC-Johab-V.bcmap +0 -0
  173. package/dist/web/vendor/pdfjs/cmaps/KSC-V.bcmap +0 -0
  174. package/dist/web/vendor/pdfjs/cmaps/KSCms-UHC-H.bcmap +0 -0
  175. package/dist/web/vendor/pdfjs/cmaps/KSCms-UHC-HW-H.bcmap +0 -0
  176. package/dist/web/vendor/pdfjs/cmaps/KSCms-UHC-HW-V.bcmap +0 -0
  177. package/dist/web/vendor/pdfjs/cmaps/KSCms-UHC-V.bcmap +0 -0
  178. package/dist/web/vendor/pdfjs/cmaps/KSCpc-EUC-H.bcmap +0 -0
  179. package/dist/web/vendor/pdfjs/cmaps/KSCpc-EUC-V.bcmap +0 -0
  180. package/dist/web/vendor/pdfjs/cmaps/Katakana.bcmap +0 -0
  181. package/dist/web/vendor/pdfjs/cmaps/LICENSE +36 -0
  182. package/dist/web/vendor/pdfjs/cmaps/NWP-H.bcmap +0 -0
  183. package/dist/web/vendor/pdfjs/cmaps/NWP-V.bcmap +0 -0
  184. package/dist/web/vendor/pdfjs/cmaps/RKSJ-H.bcmap +0 -0
  185. package/dist/web/vendor/pdfjs/cmaps/RKSJ-V.bcmap +0 -0
  186. package/dist/web/vendor/pdfjs/cmaps/Roman.bcmap +0 -0
  187. package/dist/web/vendor/pdfjs/cmaps/UniCNS-UCS2-H.bcmap +0 -0
  188. package/dist/web/vendor/pdfjs/cmaps/UniCNS-UCS2-V.bcmap +0 -0
  189. package/dist/web/vendor/pdfjs/cmaps/UniCNS-UTF16-H.bcmap +0 -0
  190. package/dist/web/vendor/pdfjs/cmaps/UniCNS-UTF16-V.bcmap +0 -0
  191. package/dist/web/vendor/pdfjs/cmaps/UniCNS-UTF32-H.bcmap +0 -0
  192. package/dist/web/vendor/pdfjs/cmaps/UniCNS-UTF32-V.bcmap +0 -0
  193. package/dist/web/vendor/pdfjs/cmaps/UniCNS-UTF8-H.bcmap +0 -0
  194. package/dist/web/vendor/pdfjs/cmaps/UniCNS-UTF8-V.bcmap +0 -0
  195. package/dist/web/vendor/pdfjs/cmaps/UniGB-UCS2-H.bcmap +0 -0
  196. package/dist/web/vendor/pdfjs/cmaps/UniGB-UCS2-V.bcmap +0 -0
  197. package/dist/web/vendor/pdfjs/cmaps/UniGB-UTF16-H.bcmap +0 -0
  198. package/dist/web/vendor/pdfjs/cmaps/UniGB-UTF16-V.bcmap +0 -0
  199. package/dist/web/vendor/pdfjs/cmaps/UniGB-UTF32-H.bcmap +0 -0
  200. package/dist/web/vendor/pdfjs/cmaps/UniGB-UTF32-V.bcmap +0 -0
  201. package/dist/web/vendor/pdfjs/cmaps/UniGB-UTF8-H.bcmap +0 -0
  202. package/dist/web/vendor/pdfjs/cmaps/UniGB-UTF8-V.bcmap +0 -0
  203. package/dist/web/vendor/pdfjs/cmaps/UniJIS-UCS2-H.bcmap +0 -0
  204. package/dist/web/vendor/pdfjs/cmaps/UniJIS-UCS2-HW-H.bcmap +0 -0
  205. package/dist/web/vendor/pdfjs/cmaps/UniJIS-UCS2-HW-V.bcmap +0 -0
  206. package/dist/web/vendor/pdfjs/cmaps/UniJIS-UCS2-V.bcmap +0 -0
  207. package/dist/web/vendor/pdfjs/cmaps/UniJIS-UTF16-H.bcmap +0 -0
  208. package/dist/web/vendor/pdfjs/cmaps/UniJIS-UTF16-V.bcmap +0 -0
  209. package/dist/web/vendor/pdfjs/cmaps/UniJIS-UTF32-H.bcmap +0 -0
  210. package/dist/web/vendor/pdfjs/cmaps/UniJIS-UTF32-V.bcmap +0 -0
  211. package/dist/web/vendor/pdfjs/cmaps/UniJIS-UTF8-H.bcmap +0 -0
  212. package/dist/web/vendor/pdfjs/cmaps/UniJIS-UTF8-V.bcmap +0 -0
  213. package/dist/web/vendor/pdfjs/cmaps/UniJIS2004-UTF16-H.bcmap +0 -0
  214. package/dist/web/vendor/pdfjs/cmaps/UniJIS2004-UTF16-V.bcmap +0 -0
  215. package/dist/web/vendor/pdfjs/cmaps/UniJIS2004-UTF32-H.bcmap +0 -0
  216. package/dist/web/vendor/pdfjs/cmaps/UniJIS2004-UTF32-V.bcmap +0 -0
  217. package/dist/web/vendor/pdfjs/cmaps/UniJIS2004-UTF8-H.bcmap +0 -0
  218. package/dist/web/vendor/pdfjs/cmaps/UniJIS2004-UTF8-V.bcmap +0 -0
  219. package/dist/web/vendor/pdfjs/cmaps/UniJISPro-UCS2-HW-V.bcmap +0 -0
  220. package/dist/web/vendor/pdfjs/cmaps/UniJISPro-UCS2-V.bcmap +0 -0
  221. package/dist/web/vendor/pdfjs/cmaps/UniJISPro-UTF8-V.bcmap +0 -0
  222. package/dist/web/vendor/pdfjs/cmaps/UniJISX0213-UTF32-H.bcmap +0 -0
  223. package/dist/web/vendor/pdfjs/cmaps/UniJISX0213-UTF32-V.bcmap +0 -0
  224. package/dist/web/vendor/pdfjs/cmaps/UniJISX02132004-UTF32-H.bcmap +0 -0
  225. package/dist/web/vendor/pdfjs/cmaps/UniJISX02132004-UTF32-V.bcmap +0 -0
  226. package/dist/web/vendor/pdfjs/cmaps/UniKS-UCS2-H.bcmap +0 -0
  227. package/dist/web/vendor/pdfjs/cmaps/UniKS-UCS2-V.bcmap +0 -0
  228. package/dist/web/vendor/pdfjs/cmaps/UniKS-UTF16-H.bcmap +0 -0
  229. package/dist/web/vendor/pdfjs/cmaps/UniKS-UTF16-V.bcmap +0 -0
  230. package/dist/web/vendor/pdfjs/cmaps/UniKS-UTF32-H.bcmap +0 -0
  231. package/dist/web/vendor/pdfjs/cmaps/UniKS-UTF32-V.bcmap +0 -0
  232. package/dist/web/vendor/pdfjs/cmaps/UniKS-UTF8-H.bcmap +0 -0
  233. package/dist/web/vendor/pdfjs/cmaps/UniKS-UTF8-V.bcmap +0 -0
  234. package/dist/web/vendor/pdfjs/cmaps/V.bcmap +0 -0
  235. package/dist/web/vendor/pdfjs/cmaps/WP-Symbol.bcmap +0 -0
  236. package/dist/web/vendor/pdfjs/iccs/CGATS001Compat-v2-micro.icc +0 -0
  237. package/dist/web/vendor/pdfjs/iccs/LICENSE +116 -0
  238. package/dist/web/vendor/pdfjs/pdf.min.mjs +28 -0
  239. package/dist/web/vendor/pdfjs/pdf.worker.mjs +64908 -0
  240. package/dist/web/vendor/pdfjs/standard_fonts/FoxitDingbats.pfb +0 -0
  241. package/dist/web/vendor/pdfjs/standard_fonts/FoxitFixed.pfb +0 -0
  242. package/dist/web/vendor/pdfjs/standard_fonts/FoxitFixedBold.pfb +0 -0
  243. package/dist/web/vendor/pdfjs/standard_fonts/FoxitFixedBoldItalic.pfb +0 -0
  244. package/dist/web/vendor/pdfjs/standard_fonts/FoxitFixedItalic.pfb +0 -0
  245. package/dist/web/vendor/pdfjs/standard_fonts/FoxitSerif.pfb +0 -0
  246. package/dist/web/vendor/pdfjs/standard_fonts/FoxitSerifBold.pfb +0 -0
  247. package/dist/web/vendor/pdfjs/standard_fonts/FoxitSerifBoldItalic.pfb +0 -0
  248. package/dist/web/vendor/pdfjs/standard_fonts/FoxitSerifItalic.pfb +0 -0
  249. package/dist/web/vendor/pdfjs/standard_fonts/FoxitSymbol.pfb +0 -0
  250. package/dist/web/vendor/pdfjs/standard_fonts/LICENSE_FOXIT +27 -0
  251. package/dist/web/vendor/pdfjs/standard_fonts/LICENSE_LIBERATION +363 -0
  252. package/dist/web/vendor/pdfjs/standard_fonts/LiberationSans-Bold.ttf +0 -0
  253. package/dist/web/vendor/pdfjs/standard_fonts/LiberationSans-BoldItalic.ttf +0 -0
  254. package/dist/web/vendor/pdfjs/standard_fonts/LiberationSans-Italic.ttf +0 -0
  255. package/dist/web/vendor/pdfjs/standard_fonts/LiberationSans-Regular.ttf +0 -0
  256. package/dist/web/vendor/pdfjs/wasm/LICENSE_JBIG2 +196 -0
  257. package/dist/web/vendor/pdfjs/wasm/LICENSE_OPENJPEG +39 -0
  258. package/dist/web/vendor/pdfjs/wasm/LICENSE_PDFJS_JBIG2 +13 -0
  259. package/dist/web/vendor/pdfjs/wasm/LICENSE_PDFJS_OPENJPEG +22 -0
  260. package/dist/web/vendor/pdfjs/wasm/LICENSE_PDFJS_QCMS +19 -0
  261. package/dist/web/vendor/pdfjs/wasm/LICENSE_QCMS +21 -0
  262. package/dist/web/vendor/pdfjs/wasm/jbig2.wasm +0 -0
  263. package/dist/web/vendor/pdfjs/wasm/jbig2_nowasm_fallback.js +15 -0
  264. package/dist/web/vendor/pdfjs/wasm/openjpeg.wasm +0 -0
  265. package/dist/web/vendor/pdfjs/wasm/openjpeg_nowasm_fallback.js +17 -0
  266. package/dist/web/vendor/pdfjs/wasm/qcms_bg.wasm +0 -0
  267. package/dist/web/workspace-root-management.js +1 -1
  268. package/dist/web/workspaces.js +792 -165
  269. package/home-env.mjs +28 -0
  270. package/install-path.mjs +59 -3
  271. package/launch-starting-page.mjs +35 -15
  272. package/launch.mjs +363 -51
  273. package/package.json +9 -8
  274. package/pin-home.mjs +6 -0
  275. package/post-update-marker.mjs +14 -0
  276. package/preferences-file.mjs +289 -0
  277. package/supervisor-lock.mjs +195 -0
@@ -0,0 +1,364 @@
1
+ /*
2
+ * web/shared-prefs.js — the preferences that follow the person across the FloLess window and the browser tab (#2963, epic #2960).
3
+ *
4
+ * Shared through the server's preferences file (server/preferences-file.mjs, routes in server/desktop-routes.ts):
5
+ * theme, last project, "What's new" seen, chat read cursors. Everything else (folded panels, mode, guide notices, ...) stays in
6
+ * this browser's localStorage and never comes through here.
7
+ *
8
+ * localStorage stays a CACHE for the four shared values: first paint (web/frame-theme.js reads the theme key synchronously) and the
9
+ * fallback when the server cannot be reached. The server value wins whenever it is known. An unreachable server is never an error:
10
+ * every page keeps working from the cache, silently.
11
+ *
12
+ * Rules this file keeps (Codex-hardened, see docs/superpowers/specs/2026-11-03-desktop-s2-plan.md):
13
+ * - The legacy browser values are SNAPSHOTTED when this script loads, before anything can write a default into the cache.
14
+ * - The one-time migration runs only when `floless:prefs-migrated` differs from the server's `generation`, and the marker is written
15
+ * only after the server answered 200. A failed migration changes nothing and is tried again on the next load.
16
+ * - Writes go through ONE serial queue (one PUT/POST in flight), so two quick choices cannot arrive reversed.
17
+ * - An answer older than the newest revision already applied is ignored.
18
+ *
19
+ * Plain classic script, one global: window.flolessPrefs.
20
+ */
21
+ (function () {
22
+ 'use strict';
23
+
24
+ var KEYS = {
25
+ theme: { cache: 'floless-demo-theme-v1' }, // must match web/app.js THEME_KEY and web/frame-theme.js
26
+ lastProject: { cache: 'floless:last-project' },
27
+ whatsNewSeen: { cache: 'floless.whatsNew.seen' },
28
+ // Not browser-cached; read from the server only (the tray and the window preference live there).
29
+ client: { cache: null }, tray: { cache: null }, trayExplained: { cache: null },
30
+ };
31
+ var CHAT_PREFIX = 'floless:chat-read:';
32
+ var SEEDED_PREFIX = 'floless:chat-read-seeded:';
33
+ var MARKER = 'floless:prefs-migrated';
34
+ var THEMES = ['dark', 'light'];
35
+ var MAX_BATCH = 500;
36
+ var READY_LIMIT_MS = 5000;
37
+ var FLUSH_MS = 500;
38
+ var CALL_TIMEOUT_MS = 8000; // one hung request must not hold the serial queue (and what waits on it) forever
39
+
40
+ // ── localStorage, never throwing ─────────────────────────────────────────────────────────────────────────────────
41
+ function cacheGet(key) { try { return localStorage.getItem(key); } catch (e) { return null; } }
42
+ function cacheSet(key, value) { try { localStorage.setItem(key, String(value)); } catch (e) { /* private mode: no cache */ } }
43
+ function cacheKeys() {
44
+ var out = [];
45
+ try { for (var i = 0; i < localStorage.length; i++) out.push(localStorage.key(i)); } catch (e) { /* none */ }
46
+ return out;
47
+ }
48
+ function seq(n) { n = Number(n); return Number.isSafeInteger(n) && n >= 0 ? n : 0; }
49
+
50
+ // ── the snapshot: what this browser kept before the server ever held it. Taken NOW, before any cache write. ───────
51
+ var legacy = (function () {
52
+ var out = { theme: null, lastProject: null, whatsNewSeen: null, chatRead: {} };
53
+ var theme = cacheGet(KEYS.theme.cache);
54
+ if (THEMES.indexOf(theme) >= 0) out.theme = theme;
55
+ var project = cacheGet(KEYS.lastProject.cache);
56
+ if (typeof project === 'string' && project.length <= 200) out.lastProject = project;
57
+ var seen = cacheGet(KEYS.whatsNewSeen.cache);
58
+ if (typeof seen === 'string' && seen && seen.length <= 64) out.whatsNewSeen = seen;
59
+ cacheKeys().forEach(function (k) {
60
+ if (typeof k === 'string' && k.indexOf(CHAT_PREFIX) === 0) {
61
+ var n = seq(cacheGet(k));
62
+ if (n > 0) out.chatRead[k.slice(CHAT_PREFIX.length)] = n;
63
+ }
64
+ });
65
+ return out;
66
+ })();
67
+ function hasLegacy() {
68
+ return legacy.theme !== null || legacy.lastProject !== null || legacy.whatsNewSeen !== null || Object.keys(legacy.chatRead).length > 0;
69
+ }
70
+ function legacyBody() {
71
+ var body = {};
72
+ if (legacy.theme !== null) body.theme = legacy.theme;
73
+ if (legacy.lastProject !== null) body.lastProject = legacy.lastProject;
74
+ if (legacy.whatsNewSeen !== null) body.whatsNewSeen = legacy.whatsNewSeen;
75
+ if (Object.keys(legacy.chatRead).length) body.chatRead = legacy.chatRead;
76
+ return body;
77
+ }
78
+
79
+ // ── state ────────────────────────────────────────────────────────────────────────────────────────────────────────
80
+ var view = {}; // shared values as this page sees them (server value, with unacknowledged local choices on top)
81
+ var dirty = {}; // keys the person set that no PUT answer has confirmed yet
82
+ var chat = {}; // chatId -> read cursor, merged by maximum
83
+ var seededOwners = [];
84
+ var generation = null;
85
+ var applied = -1; // the highest revision applied so far
86
+ var hydrated = false;
87
+ var listeners = [];
88
+ var jobs = []; // the serial write queue
89
+ var busy = false;
90
+ var batch = {}; // read cursors waiting to be sent
91
+ var flushTimer = null;
92
+ var migrateTried = false;
93
+ var refetchAfter = false;
94
+ var readyPromise = null;
95
+ var lastFetchAt = 0;
96
+
97
+ Object.keys(legacy.chatRead).forEach(function (id) { chat[id] = legacy.chatRead[id]; });
98
+
99
+ function notify(keys) {
100
+ listeners.slice().forEach(function (cb) { try { cb(keys); } catch (e) { /* a page's listener must not break the others */ } });
101
+ }
102
+
103
+ // ── talking to the server ────────────────────────────────────────────────────────────────────────────────────────
104
+ function call(method, url, body) {
105
+ var init = { method: method, cache: 'no-store', headers: {} };
106
+ if (body !== undefined) { init.headers['Content-Type'] = 'application/json'; init.body = JSON.stringify(body); }
107
+ try {
108
+ var limit = window.flolessPrefs && window.flolessPrefs.callTimeoutMs > 0 ? window.flolessPrefs.callTimeoutMs : CALL_TIMEOUT_MS;
109
+ if (typeof AbortSignal !== 'undefined' && typeof AbortSignal.timeout === 'function') init.signal = AbortSignal.timeout(limit);
110
+ } catch (e) { /* an environment without it: the request simply has no limit */ }
111
+ return fetch(url, init).then(function (res) {
112
+ return res.json().then(function (json) { return { status: res.status, ok: res.ok && json && json.ok !== false, json: json }; },
113
+ function () { return { status: res.status, ok: false, json: null }; });
114
+ });
115
+ }
116
+
117
+ /** Apply a server answer to the page and the cache. Returns false when it was older than what was already applied. */
118
+ function applyAnswer(ans) {
119
+ if (!ans || typeof ans !== 'object' || !Number.isSafeInteger(ans.revision)) return false;
120
+ // The server could not read its file and answered with defaults: those are not the person's choices. Never write them in.
121
+ if (ans.degraded === true) return false;
122
+ // A different generation means the file was started over: its revisions count from zero again.
123
+ if (ans.generation && generation && ans.generation !== generation) applied = -1;
124
+ if (ans.revision < applied) return false;
125
+ applied = ans.revision;
126
+ if (ans.generation) generation = ans.generation;
127
+ var changed = [];
128
+ Object.keys(KEYS).forEach(function (key) {
129
+ var v = ans[key];
130
+ if (v === undefined || v === null) return; // never set on the server: keep what the page has
131
+ if (Object.prototype.hasOwnProperty.call(dirty, key)) return; // the person chose something newer, not yet saved
132
+ if (view[key] !== v) { view[key] = v; changed.push(key); }
133
+ if (KEYS[key].cache && cacheGet(KEYS[key].cache) !== String(v)) cacheSet(KEYS[key].cache, v);
134
+ });
135
+ if (ans.chatRead && typeof ans.chatRead === 'object') {
136
+ Object.keys(ans.chatRead).forEach(function (id) {
137
+ var n = seq(ans.chatRead[id]);
138
+ if (n > (chat[id] || 0)) { chat[id] = n; changed.push('chatRead'); }
139
+ if (seq(cacheGet(CHAT_PREFIX + id)) < n) cacheSet(CHAT_PREFIX + id, n);
140
+ });
141
+ }
142
+ if (Array.isArray(ans.seededOwners)) seededOwners = ans.seededOwners.slice();
143
+ hydrated = true;
144
+ if (changed.length) notify(changed);
145
+ return true;
146
+ }
147
+
148
+ // ── the serial queue ─────────────────────────────────────────────────────────────────────────────────────────────
149
+ function enqueue(job) {
150
+ if (job.type === 'put') {
151
+ var last = jobs[jobs.length - 1];
152
+ if (last && last.type === 'put') { Object.assign(last.patch, job.patch); return last.done; }
153
+ }
154
+ job.done = new Promise(function (resolve) { job.resolve = resolve; });
155
+ jobs.push(job);
156
+ pump();
157
+ return job.done;
158
+ }
159
+
160
+ function pump() {
161
+ if (busy) return;
162
+ var job = jobs.shift();
163
+ if (!job) {
164
+ // The deferred read. It does NOT re-send unsaved choices: a write that failed waits for the next focus, visibility or online
165
+ // event, so a failing server is never hit in a loop from the queue's own completion.
166
+ if (refetchAfter) { refetchAfter = false; refetch(true, true); }
167
+ return;
168
+ }
169
+ busy = true;
170
+ run(job).then(function (ok) { job.resolve(ok); }, function () { job.resolve(false); }).then(function () { busy = false; pump(); });
171
+ }
172
+
173
+ function run(job) {
174
+ if (job.type === 'put') {
175
+ var patch = job.patch;
176
+ return call('PUT', '/api/preferences', patch).then(function (r) {
177
+ if (r.ok) {
178
+ Object.keys(patch).forEach(function (k) { if (dirty[k] === patch[k]) delete dirty[k]; });
179
+ applyAnswer(r.json);
180
+ return true;
181
+ }
182
+ // A refusal (400) will never succeed: stop holding the value AND stop showing it, then read what the server really holds.
183
+ // A network or server fault keeps the choice for the next try.
184
+ if (r.status >= 400 && r.status < 500) {
185
+ var reverted = [];
186
+ Object.keys(patch).forEach(function (k) { if (dirty[k] === patch[k]) { delete dirty[k]; delete view[k]; reverted.push(k); } });
187
+ if (reverted.length) { refetchAfter = true; notify(reverted); }
188
+ }
189
+ return false;
190
+ }, function () { return false; });
191
+ }
192
+ if (job.type === 'read' || job.type === 'seed') {
193
+ var body = job.type === 'seed' ? { seedOwner: job.owner, cursors: job.cursors } : { cursors: job.cursors };
194
+ return call('POST', '/api/preferences/chat-read', body).then(function (r) {
195
+ if (r.ok) { applyAnswer(r.json); return true; }
196
+ if (job.type === 'read' && !(r.status >= 400 && r.status < 500)) Object.keys(job.cursors).forEach(function (id) { batch[id] = Math.max(batch[id] || 0, job.cursors[id]); });
197
+ return false;
198
+ }, function () {
199
+ if (job.type === 'read') Object.keys(job.cursors).forEach(function (id) { batch[id] = Math.max(batch[id] || 0, job.cursors[id]); });
200
+ return false;
201
+ });
202
+ }
203
+ if (job.type === 'migrate') {
204
+ return call('POST', '/api/preferences/migrate', job.body).then(function (r) {
205
+ // The marker is written ONLY after the server answered 200, and only for an answer that really holds a generation.
206
+ if (r.ok && r.json && r.json.generation && r.json.revision > 0) {
207
+ cacheSet(MARKER, r.json.generation);
208
+ applyAnswer(r.json);
209
+ return true;
210
+ }
211
+ return false;
212
+ }, function () { return false; });
213
+ }
214
+ return Promise.resolve(false);
215
+ }
216
+
217
+ // ── hydration, migration, refetch ────────────────────────────────────────────────────────────────────────────────
218
+ function flushUnsent() {
219
+ var patch = {};
220
+ Object.keys(dirty).forEach(function (k) { patch[k] = dirty[k]; });
221
+ if (Object.keys(patch).length && !jobs.some(function (j) { return j.type === 'put'; })) enqueue({ type: 'put', patch: patch });
222
+ }
223
+
224
+ function maybeMigrate(ans) {
225
+ if (migrateTried) return Promise.resolve();
226
+ var marker = cacheGet(MARKER);
227
+ if (ans.generation && marker === ans.generation) return Promise.resolve();
228
+ migrateTried = true;
229
+ if (!hasLegacy()) {
230
+ // Nothing to hand over: just remember which generation this browser has settled with.
231
+ if (ans.generation) cacheSet(MARKER, ans.generation);
232
+ return Promise.resolve();
233
+ }
234
+ return enqueue({ type: 'migrate', body: legacyBody() });
235
+ }
236
+
237
+ function refetch(force, deferredRead) {
238
+ var now = Date.now();
239
+ if (!force && now - lastFetchAt < 1000) return Promise.resolve();
240
+ if (!deferredRead) flushUnsent(); // a value that never reached the server goes first; the read follows once the queue is quiet
241
+ if (busy || jobs.length) { refetchAfter = true; return Promise.resolve(); }
242
+ lastFetchAt = now;
243
+ // At startup the server may still be recovering its stores: wait for the page's admission gate when there is one (it uses no connection).
244
+ var admit = window.flolessStartupAdmission && typeof window.flolessStartupAdmission.admit === 'function'
245
+ ? Promise.resolve().then(function () { return window.flolessStartupAdmission.admit('/api/preferences'); }).catch(function () { /* try anyway */ })
246
+ : Promise.resolve();
247
+ return admit.then(function () { return call('GET', '/api/preferences'); }).then(function (r) {
248
+ if (!r.ok || (r.json && r.json.degraded === true)) return; // a degraded answer is defaults: neither applied nor migrated onto
249
+ // Writes started while this read was out: its answer may be older than they make the truth. Revisions decide.
250
+ applyAnswer(r.json);
251
+ return maybeMigrate(r.json);
252
+ }, function () { /* offline: the cache keeps the page working */ });
253
+ }
254
+
255
+ function ready() {
256
+ if (readyPromise) return readyPromise;
257
+ var timer;
258
+ var limit = new Promise(function (resolve) { timer = setTimeout(resolve, READY_LIMIT_MS); });
259
+ readyPromise = Promise.race([refetch(true), limit]).then(function () { clearTimeout(timer); }, function () { clearTimeout(timer); });
260
+ return readyPromise;
261
+ }
262
+
263
+ // ── the public side ──────────────────────────────────────────────────────────────────────────────────────────────
264
+ function get(key) {
265
+ if (!Object.prototype.hasOwnProperty.call(KEYS, key)) return null;
266
+ var v = view[key];
267
+ if (v !== undefined && v !== null) return v;
268
+ return KEYS[key].cache ? cacheGet(KEYS[key].cache) : null;
269
+ }
270
+
271
+ /** Shows the choice at once and saves it in the background. Resolves true once the server confirmed it, false when it did not
272
+ * (never rejects): a refusal also takes the choice back off the page, a network or server fault keeps it to send later. */
273
+ function set(key, value) {
274
+ if (!Object.prototype.hasOwnProperty.call(KEYS, key)) return Promise.resolve(false);
275
+ view[key] = value;
276
+ dirty[key] = value;
277
+ if (KEYS[key].cache) cacheSet(KEYS[key].cache, value);
278
+ var patch = {}; patch[key] = value;
279
+ return enqueue({ type: 'put', patch: patch }).then(function (ok) { return ok === true; }, function () { return false; });
280
+ }
281
+
282
+ function flushReads() {
283
+ flushTimer = null;
284
+ var ids = Object.keys(batch);
285
+ if (!ids.length) return;
286
+ for (var i = 0; i < ids.length; i += MAX_BATCH) {
287
+ var cursors = {};
288
+ ids.slice(i, i + MAX_BATCH).forEach(function (id) { cursors[id] = batch[id]; delete batch[id]; });
289
+ enqueue({ type: 'read', cursors: cursors });
290
+ }
291
+ }
292
+
293
+ function markChatRead(chatId, sequence) {
294
+ var id = String(chatId); var n = seq(sequence);
295
+ if (!id || n <= (chat[id] || 0)) return;
296
+ chat[id] = n;
297
+ cacheSet(CHAT_PREFIX + id, n);
298
+ batch[id] = n;
299
+ if (!flushTimer) flushTimer = setTimeout(flushReads, FLUSH_MS);
300
+ }
301
+
302
+ function chatCursor(chatId) { return chat[String(chatId)] || 0; }
303
+
304
+ /**
305
+ * The first-visit baseline of an owner (a project, a workflow, the workspace): chats that already exist are not "unread". Once per owner,
306
+ * across the window and the browser; a client that finds the owner already seeded does nothing, so a chat the server has no cursor for
307
+ * counts as unread. Without a reachable server it falls back to this browser's own one-time baseline.
308
+ */
309
+ function seedOwner(ownerKey, cursors) {
310
+ var marker = SEEDED_PREFIX + ownerKey;
311
+ return ready().then(function () {
312
+ var localSeeded = Boolean(cacheGet(marker));
313
+ if (hydrated) {
314
+ if (seededOwners.indexOf(ownerKey) >= 0) return 'already';
315
+ // This browser seeded the owner before the server held the baseline: tell the server, without a new baseline.
316
+ var send = localSeeded ? {} : cursors;
317
+ return enqueue({ type: 'seed', owner: ownerKey, cursors: send }).then(function (ok) {
318
+ if (ok) return 'server';
319
+ return localSeed(marker, cursors, localSeeded);
320
+ });
321
+ }
322
+ return localSeed(marker, cursors, localSeeded);
323
+ });
324
+ }
325
+
326
+ function localSeed(marker, cursors, already) {
327
+ if (already) return 'local';
328
+ Object.keys(cursors).forEach(function (id) {
329
+ if (chat[id] === undefined) { chat[id] = seq(cursors[id]); cacheSet(CHAT_PREFIX + id, chat[id]); }
330
+ });
331
+ cacheSet(marker, '1');
332
+ return 'local';
333
+ }
334
+
335
+ function onChange(cb) { if (typeof cb === 'function') listeners.push(cb); return function () { listeners = listeners.filter(function (l) { return l !== cb; }); }; }
336
+
337
+ function snapshot() {
338
+ var out = {};
339
+ Object.keys(KEYS).forEach(function (k) { out[k] = get(k); });
340
+ return out;
341
+ }
342
+
343
+ /** Read cursors whose write failed stay in `batch` until the server acknowledges them; the same events that retry a save send them again. */
344
+ function retryReads() { if (Object.keys(batch).length && !flushTimer) flushReads(); }
345
+
346
+ // Refetch when the person comes back to this window or tab: the other client may have changed something meanwhile.
347
+ try {
348
+ window.addEventListener('focus', function () { retryReads(); refetch(false); });
349
+ document.addEventListener('visibilitychange', function () { if (!document.hidden) { retryReads(); refetch(false); } });
350
+ window.addEventListener('online', function () { retryReads(); refetch(true); });
351
+ } catch (e) { /* no events here */ }
352
+
353
+ window.flolessPrefs = {
354
+ get: get, set: set, onChange: onChange, snapshot: snapshot, ready: ready, refetch: refetch,
355
+ markChatRead: markChatRead, chatCursor: chatCursor, flushReads: flushReads,
356
+ seedOwner: seedOwner,
357
+ callTimeoutMs: CALL_TIMEOUT_MS, // tests shorten it
358
+ hydrated: function () { return hydrated; },
359
+ migrationMarkerKey: MARKER,
360
+ };
361
+
362
+ // Start hydrating now; pages that need the answer await ready().
363
+ ready();
364
+ })();
@@ -0,0 +1,309 @@
1
+ // Flo on the steel model (3D). web/flo-3d.js builds and moves Flo; this decides where Flo stands and which mood
2
+ // it shows, from what is already true in the editor:
3
+ // - it perches on the model: on load, on the top of the highest member nearest the middle;
4
+ // - when the person selects a member, Flo hops onto it;
5
+ // - when AI Chat is working on this project, Flo shows the same mood the chat's own Flo shows (thinking or
6
+ // working), and Your call while the AI waits for the person's answer or approval (the shell pushes this);
7
+ // - after the model changed underneath the editor (the AI wrote it), Flo visits each member that changed.
8
+ // Flo is decoration and decides nothing: it is never picked as a member, never in Fit or snapping, and a click on
9
+ // it only tips its hat. Flo is off until the person turns it on (3D toolbar → Labels → Show Flo); the page owns that switch
10
+ // and the Minimize beside Flo, and tells this module only whether Flo is shown.
11
+ //
12
+ // Where Flo stands is reported to the caller (onPerch), so the view can show Flo's card about that member: on
13
+ // landing on a member the person selected (for as long as it stays selected) and at each stop of a tour of what
14
+ // changed. Never on the first drop onto the model, which is not about any member.
15
+
16
+ import { createFlo3D } from './flo-3d.js';
17
+
18
+ const MODEL_R_OF_DIAG = 0.011; // Flo's ring radius as a share of the model's diagonal...
19
+ const MODEL_R_MIN = 140, MODEL_R_MAX = 900; // ...in mm: a toy on a beam, never a giant on a shed
20
+ const MIN_SCREEN_R_PX = 13; // and never smaller than this on screen
21
+ const VISIT_MAX = 10; // a big change is shown by its first ten members, not all of them
22
+ const VISIT_DWELL_S = 1.2; // long enough on each changed member to read Flo's card about it
23
+ const SUCCESS_S = 2.4;
24
+ const REMEMBER_KEY = 'flo3d:before:'; // sessionStorage, per editor URL: the model as it was before a reload
25
+ const REMEMBER_TTL_MS = 120_000;
26
+ const SETTLE_MS = 250; // a click-through of members moves Flo once, when it stops
27
+ const ALONG = 0.3; // a beam's perch: this far along it, clear of the label and the ends
28
+ const LEAVE_S = 0.2; // Minimize: Flo shrinks away this fast (instant under reduced motion)
29
+
30
+ export function createSteelFlo({ THREE, scene, meshById, getCamera, getSceneBox, pxToWorldAt, floPose, reducedMotion, enabled: startEnabled = false, onPerch = () => {} }) {
31
+ const now = () => performance.now() / 1000;
32
+ const flo = createFlo3D(THREE, {
33
+ floPose, up: new THREE.Vector3(0, 0, 1), reducedMotion,
34
+ });
35
+ let enabled = !!startEnabled;
36
+ let perched = null; // the member whose card is showing (onPerch), or null
37
+ let placed = false, standingOn = null, modelR = 300, sizeK = 1; // sizeK: the person's Flo size (Labels menu), 1 = as designed
38
+ let shellMood = 'idle';
39
+ let tour = null; // { ids, i, waitUntil }
40
+ let successUntil = 0;
41
+ let leaving = null; // { t0 } while Flo shrinks away after Minimize
42
+ let reduced = !!reducedMotion;
43
+ let prevSel = new Set(), settleTimer = null;
44
+ const ray = new THREE.Raycaster();
45
+ const down = new THREE.Vector3(0, 0, -1);
46
+
47
+ flo.object.visible = enabled;
48
+ scene.add(flo.object);
49
+
50
+ // The point on top of a member where Flo stands: straight down onto the member, on the cap of a column, and on a
51
+ // beam or brace a third of the way along it, so Flo stays clear of the member's label (at its middle) and of
52
+ // the connections at its ends that the person is looking at. Null for a member that is not drawn, or a
53
+ // connection part (Flo never lands on bolts and plates).
54
+ function perchOf(id) {
55
+ const mesh = meshById.get(id);
56
+ if (!mesh || !mesh.visible || String(id).startsWith('det:') || mesh.userData.derived) return null;
57
+ mesh.updateMatrixWorld(true);
58
+ const box = new THREE.Box3().setFromObject(mesh);
59
+ if (box.isEmpty()) return null;
60
+ const c = box.getCenter(new THREE.Vector3()), size = box.getSize(new THREE.Vector3());
61
+ if (size.x > size.z * 1.5 || size.y > size.z * 1.5) {
62
+ if (size.x >= size.y) c.x = box.min.x + size.x * ALONG; else c.y = box.min.y + size.y * ALONG;
63
+ // a sloping member: the footprint's diagonal, so the point stays on it
64
+ if (Math.min(size.x, size.y) > Math.max(size.x, size.y) * 0.25) { c.x = box.min.x + size.x * ALONG; c.y = box.min.y + size.y * ALONG; }
65
+ }
66
+ ray.set(new THREE.Vector3(c.x, c.y, box.max.z + 10), down);
67
+ const hit = ray.intersectObject(mesh, false)[0];
68
+ if (hit) return hit.point.clone();
69
+ // a diagonal whose footprint runs the other way
70
+ const flip = box.min.y + size.y * (1 - ALONG);
71
+ ray.set(new THREE.Vector3(c.x, flip, box.max.z + 10), down);
72
+ const hit2 = ray.intersectObject(mesh, false)[0];
73
+ return hit2 ? hit2.point.clone() : new THREE.Vector3(c.x, c.y, box.max.z);
74
+ }
75
+
76
+ // Where Flo starts: the highest member, and of those near the top the one nearest the middle of the model.
77
+ function home() {
78
+ const box = getSceneBox();
79
+ if (!box || box.isEmpty()) return null;
80
+ const mid = box.getCenter(new THREE.Vector3());
81
+ const span = Math.max(1, box.max.z - box.min.z);
82
+ let best = null, bestScore = Infinity;
83
+ for (const [id, mesh] of meshById) {
84
+ if (!mesh.visible || String(id).startsWith('det:') || mesh.userData.derived) continue;
85
+ const b = new THREE.Box3().setFromObject(mesh);
86
+ if (b.isEmpty()) continue;
87
+ const c = b.getCenter(new THREE.Vector3());
88
+ const score = (box.max.z - b.max.z) / span * 4 + Math.hypot(c.x - mid.x, c.y - mid.y) / Math.max(1, box.getSize(new THREE.Vector3()).length());
89
+ if (score < bestScore) { bestScore = score; best = id; }
90
+ }
91
+ return best;
92
+ }
93
+
94
+ function sizeFromModel() {
95
+ const box = getSceneBox();
96
+ if (!box || box.isEmpty()) return;
97
+ const diag = box.getSize(new THREE.Vector3()).length();
98
+ modelR = Math.min(MODEL_R_MAX, Math.max(MODEL_R_MIN, diag * MODEL_R_OF_DIAG));
99
+ }
100
+
101
+ function moodNow(t) {
102
+ if (tour) return 'working';
103
+ if (t < successUntil) return 'success';
104
+ return shellMood;
105
+ }
106
+
107
+ function perch(id, why) {
108
+ if (id === perched) return;
109
+ perched = id;
110
+ onPerch(id, why);
111
+ }
112
+
113
+ // Hop onto a member; `why` ('select' or 'tour') shows Flo's card about it on landing, none shows no card.
114
+ function goTo(id, t, onLand, why) {
115
+ const p = perchOf(id);
116
+ if (!p) { if (onLand) onLand(); return false; }
117
+ standingOn = id;
118
+ perch(null);
119
+ flo.hopTo(p, () => { if (why && enabled && (why !== 'select' || prevSel.has(id))) perch(id, why); if (onLand) onLand(); }, t);
120
+ return true;
121
+ }
122
+
123
+ // The geometry the person sees, per member, rounded to the millimetre: enough to tell which members a change
124
+ // touched without reading the contract.
125
+ function signature() {
126
+ const out = {};
127
+ const b = new THREE.Box3();
128
+ for (const [id, mesh] of meshById) {
129
+ if (String(id).startsWith('det:')) continue;
130
+ b.setFromObject(mesh);
131
+ if (b.isEmpty()) continue;
132
+ out[id] = [b.min.x, b.min.y, b.min.z, b.max.x, b.max.y, b.max.z].map(Math.round).join(',') + '|' + (mesh.userData.profile || '');
133
+ }
134
+ return out;
135
+ }
136
+
137
+ // Called just before the editor reloads for a change made elsewhere (the AI wrote the model): keep what the
138
+ // model looked like, so the reloaded Flo can visit what changed.
139
+ function remember() {
140
+ try { sessionStorage.setItem(REMEMBER_KEY + location.search, JSON.stringify({ at: Date.now(), sig: signature(), standingOn })); } catch { /* full or blocked: Flo just starts at home */ }
141
+ }
142
+
143
+ function takeRemembered() {
144
+ let saved = null;
145
+ try {
146
+ const raw = sessionStorage.getItem(REMEMBER_KEY + location.search);
147
+ sessionStorage.removeItem(REMEMBER_KEY + location.search);
148
+ saved = raw ? JSON.parse(raw) : null;
149
+ } catch { saved = null; }
150
+ if (!saved || typeof saved.sig !== 'object' || Date.now() - saved.at > REMEMBER_TTL_MS) return null;
151
+ const cur = signature();
152
+ const changed = Object.keys(cur).filter((id) => saved.sig[id] !== cur[id]);
153
+ return { changed, standingOn: typeof saved.standingOn === 'string' ? saved.standingOn : null };
154
+ }
155
+
156
+ // Visit members one hop at a time, nearest first from where Flo stands, then celebrate.
157
+ function startTour(ids, t) {
158
+ const left = ids.filter((id) => perchOf(id));
159
+ if (!left.length) return;
160
+ const order = [];
161
+ let at = flo.position.clone();
162
+ while (left.length && order.length < VISIT_MAX) {
163
+ let k = 0, d = Infinity;
164
+ left.forEach((id, i) => { const p = perchOf(id); const dd = p.distanceTo(at); if (dd < d) { d = dd; k = i; } });
165
+ const [id] = left.splice(k, 1); order.push(id); at = perchOf(id);
166
+ }
167
+ tour = { ids: order, i: 0, waitUntil: t };
168
+ }
169
+
170
+ function stepTour(t) {
171
+ if (!tour || flo.isBusy() || t < tour.waitUntil) return;
172
+ if (tour.i >= tour.ids.length) { tour = null; perch(null); successUntil = t + SUCCESS_S; flo.sayHello(t + SUCCESS_S - 0.9); return; }
173
+ const id = tour.ids[tour.i++];
174
+ if (!goTo(id, t, () => { if (tour) tour.waitUntil = now() + VISIT_DWELL_S; }, 'tour')) tour.waitUntil = t;
175
+ }
176
+
177
+ // After every rebuild: first time, arrive on the model; after a change, follow the member Flo stood on (or go
178
+ // home if it is gone) and visit whatever the change touched.
179
+ function modelChanged() {
180
+ sizeFromModel();
181
+ const t = now();
182
+ if (!placed) {
183
+ const was = takeRemembered();
184
+ const start = (was?.standingOn && perchOf(was.standingOn)) ? was.standingOn : home();
185
+ const p = start && perchOf(start);
186
+ if (!p) return;
187
+ placed = true; standingOn = start;
188
+ flo.setSize(modelR * sizeK);
189
+ if (was && was.changed.length) { flo.placeAt(p); startTour(was.changed, t + 0.4); }
190
+ else {
191
+ // drop in from above, so the first thing Flo does on the model is land on it
192
+ flo.placeAt(p.clone().add(new THREE.Vector3(0, 0, modelR * 7)));
193
+ flo.hopTo(p, null, t + 0.25, { drop: true });
194
+ }
195
+ return;
196
+ }
197
+ // the card says what the member is now (a new profile, a new length): ask the view to read it again
198
+ const p = standingOn && perchOf(standingOn);
199
+ if (p) {
200
+ const why = prevSel.has(standingOn) ? 'select' : null;
201
+ if (p.distanceTo(flo.position) > 1) goTo(standingOn, t, null, why);
202
+ else if (perched) onPerch(perched, 'refresh');
203
+ } else { const h = home(); if (h) goTo(h, t); }
204
+ }
205
+
206
+ function selectionChanged(set) {
207
+ const next = new Set(set);
208
+ const added = [...next].filter((id) => !prevSel.has(id) && !String(id).startsWith('det:'));
209
+ const prev = prevSel;
210
+ prevSel = next;
211
+ let target = added[added.length - 1];
212
+ // The member Flo stands on (or is hopping to) was deselected: its card goes, and Flo moves on to one still
213
+ // selected (the last), so it never stands over a member that is no longer part of the selection.
214
+ const on = perched || standingOn;
215
+ if (on && prev.has(on) && !next.has(on) && !tour) {
216
+ perch(null);
217
+ if (!target) target = [...next].filter((id) => !String(id).startsWith('det:')).pop();
218
+ }
219
+ if (!placed || !enabled || !target) return;
220
+ tour = null;
221
+ clearTimeout(settleTimer);
222
+ settleTimer = setTimeout(() => {
223
+ if (!prevSel.has(target)) return;
224
+ if (target === standingOn && !flo.isBusy()) perch(target, 'select'); // already standing on it: just say what it is
225
+ else goTo(target, now(), null, 'select');
226
+ }, SETTLE_MS);
227
+ }
228
+
229
+ function tick(cameraOverride) {
230
+ if ((!enabled && !leaving) || !placed) return;
231
+ const t = now();
232
+ stepTour(t);
233
+ flo.setMood(moodNow(t));
234
+ const camera = cameraOverride || getCamera();
235
+ let k = 1;
236
+ if (leaving) {
237
+ k = 1 - Math.min(1, (t - leaving.t0) / LEAVE_S);
238
+ if (k <= 0) { leaving = null; flo.object.visible = false; return; }
239
+ k = k * k;
240
+ }
241
+ flo.setSize(Math.max(modelR, pxToWorldAt(MIN_SCREEN_R_PX, flo.object.position)) * sizeK * k);
242
+ flo.tick(t, camera);
243
+ }
244
+
245
+ // Is the pointer on Flo? (The page shows its Minimize chip while it is.)
246
+ function hover(ndc, camera) {
247
+ if (!enabled || !placed || !flo.object.visible || leaving) return false;
248
+ ray.setFromCamera(ndc, camera);
249
+ return flo.hit(ray);
250
+ }
251
+
252
+ // Where the top of Flo's hat is on screen, in the canvas's own pixels (null when Flo is not drawn).
253
+ function hatScreen(camera, width, height) {
254
+ if (!enabled || !placed || !flo.object.visible) return null;
255
+ const p = flo.object.position.clone().add(new THREE.Vector3(0, 0, flo.r * 3.1)).project(camera);
256
+ if (p.z > 1) return null;
257
+ return { x: (p.x + 1) / 2 * width, y: (1 - p.y) / 2 * height };
258
+ }
259
+
260
+ // A press on Flo: true when it was Flo (the caller then leaves the selection alone). Any press in the view stops
261
+ // a tour of what changed: the person has started working, and Flo stays where it is.
262
+ function pointerDown(ndc, camera) {
263
+ if (!enabled || !placed || !flo.object.visible) return false;
264
+ if (tour) { tour = null; successUntil = 0; if (!prevSel.has(perched)) perch(null); }
265
+ ray.setFromCamera(ndc, camera);
266
+ if (!flo.hit(ray)) return false;
267
+ flo.sayHello(now());
268
+ return true;
269
+ }
270
+
271
+ // Minimize shrinks Flo away; bringing it back drops it onto the member it stood on, as on arrival.
272
+ function setEnabled(on, { animate = false } = {}) {
273
+ const was = enabled;
274
+ enabled = !!on;
275
+ if (enabled === was) return;
276
+ tour = null;
277
+ if (!enabled) {
278
+ perch(null);
279
+ if (animate && !reduced && placed && flo.object.visible) leaving = { t0: now() };
280
+ else { leaving = null; flo.object.visible = false; }
281
+ return;
282
+ }
283
+ leaving = null;
284
+ flo.object.visible = true;
285
+ const p = placed && standingOn && perchOf(standingOn);
286
+ if (!p) return;
287
+ // back on a member the person still has selected: its card comes back once Flo has landed
288
+ const land = prevSel.has(standingOn) ? () => perch(standingOn, 'select') : null;
289
+ if (animate && !reduced) {
290
+ flo.placeAt(p.clone().add(new THREE.Vector3(0, 0, modelR * 7)));
291
+ flo.hopTo(p, land, now(), { drop: true });
292
+ } else { flo.placeAt(p); if (land) land(); }
293
+ }
294
+
295
+ function setShellMood(m) { shellMood = ['idle', 'thinking', 'working', 'yourcall'].includes(m) ? m : 'idle'; }
296
+
297
+ function probe() {
298
+ const p = flo.object.position;
299
+ return { enabled, placed, standingOn, perched, mood: flo.mood, busy: flo.isBusy(), touring: !!tour, leaving: !!leaving, visible: flo.object.visible, r: flo.r, at: [p.x, p.y, p.z] };
300
+ }
301
+
302
+ return {
303
+ tick, modelChanged, selectionChanged, pointerDown, hover, hatScreen, remember, setEnabled, setShellMood, probe,
304
+ setScale(k) { sizeK = Number.isFinite(k) && k > 0 ? k : 1; },
305
+ setReducedMotion: (on) => { reduced = !!on; flo.setReducedMotion(on); },
306
+ get enabled() { return enabled; },
307
+ dispose: () => { clearTimeout(settleTimer); flo.dispose(); },
308
+ };
309
+ }