@floless/app 0.167.0 → 0.168.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 (257) hide show
  1. package/autostart.mjs +169 -63
  2. package/desktop-shell.mjs +335 -0
  3. package/dist/floless-server.cjs +14518 -11361
  4. package/dist/schemas/steel.model.v2.schema.json +2 -1
  5. package/dist/skills/floless-app-onboarding/SKILL.md +13 -4
  6. package/dist/skills/floless-app-onboarding/references/floless-surfaces.md +3 -0
  7. package/dist/skills/floless-app-steel-takeoff/SKILL.md +21 -2
  8. package/dist/skills/floless-app-ui/SKILL.md +2 -2
  9. package/dist/skills/floless-app-workflows/SKILL.md +2 -2
  10. package/dist/web/agents.js +1 -1
  11. package/dist/web/app.css +165 -8
  12. package/dist/web/app.js +53 -13
  13. package/dist/web/aware-update-client.js +13 -5
  14. package/dist/web/aware.js +183 -39
  15. package/dist/web/chat.css +2 -1
  16. package/dist/web/chat.js +410 -80
  17. package/dist/web/commands-filter.js +5 -5
  18. package/dist/web/commands-shell.js +172 -10
  19. package/dist/web/commands-steel.js +1 -1
  20. package/dist/web/desktop-window.js +435 -0
  21. package/dist/web/drawing-check-editor.js +18 -10
  22. package/dist/web/failure-copy.js +14 -1
  23. package/dist/web/guide.js +75 -9
  24. package/dist/web/index.html +64 -6
  25. package/dist/web/instructor.js +1 -1
  26. package/dist/web/leave-guard.js +347 -14
  27. package/dist/web/pages.js +5 -1
  28. package/dist/web/panels.js +5 -2
  29. package/dist/web/pdf-view.js +421 -0
  30. package/dist/web/project-history.js +2 -1
  31. package/dist/web/project-modules.js +3 -1
  32. package/dist/web/project-rfis.js +3 -1
  33. package/dist/web/project-workflows.js +4 -2
  34. package/dist/web/reference-geometry-worker.js +11 -2
  35. package/dist/web/revit-editor.html +1 -0
  36. package/dist/web/revit-editor.js +37 -8
  37. package/dist/web/shared-prefs.js +364 -0
  38. package/dist/web/steel-editor.html +204 -43
  39. package/dist/web/steel-filter-flo.js +74 -18
  40. package/dist/web/steel-filter.html +22 -6
  41. package/dist/web/tab-signal.js +36 -1
  42. package/dist/web/tekla-editor.html +1 -0
  43. package/dist/web/tool-updates.js +159 -38
  44. package/dist/web/vector-3d.html +14 -3
  45. package/dist/web/vector-editor.html +10 -2
  46. package/dist/web/vendor/README.md +23 -0
  47. package/dist/web/vendor/pdfjs/LICENSE +177 -0
  48. package/dist/web/vendor/pdfjs/cmaps/78-EUC-H.bcmap +0 -0
  49. package/dist/web/vendor/pdfjs/cmaps/78-EUC-V.bcmap +0 -0
  50. package/dist/web/vendor/pdfjs/cmaps/78-H.bcmap +0 -0
  51. package/dist/web/vendor/pdfjs/cmaps/78-RKSJ-H.bcmap +0 -0
  52. package/dist/web/vendor/pdfjs/cmaps/78-RKSJ-V.bcmap +0 -0
  53. package/dist/web/vendor/pdfjs/cmaps/78-V.bcmap +0 -0
  54. package/dist/web/vendor/pdfjs/cmaps/78ms-RKSJ-H.bcmap +0 -0
  55. package/dist/web/vendor/pdfjs/cmaps/78ms-RKSJ-V.bcmap +0 -0
  56. package/dist/web/vendor/pdfjs/cmaps/83pv-RKSJ-H.bcmap +0 -0
  57. package/dist/web/vendor/pdfjs/cmaps/90ms-RKSJ-H.bcmap +0 -0
  58. package/dist/web/vendor/pdfjs/cmaps/90ms-RKSJ-V.bcmap +0 -0
  59. package/dist/web/vendor/pdfjs/cmaps/90msp-RKSJ-H.bcmap +0 -0
  60. package/dist/web/vendor/pdfjs/cmaps/90msp-RKSJ-V.bcmap +0 -0
  61. package/dist/web/vendor/pdfjs/cmaps/90pv-RKSJ-H.bcmap +0 -0
  62. package/dist/web/vendor/pdfjs/cmaps/90pv-RKSJ-V.bcmap +0 -0
  63. package/dist/web/vendor/pdfjs/cmaps/Add-H.bcmap +0 -0
  64. package/dist/web/vendor/pdfjs/cmaps/Add-RKSJ-H.bcmap +0 -0
  65. package/dist/web/vendor/pdfjs/cmaps/Add-RKSJ-V.bcmap +0 -0
  66. package/dist/web/vendor/pdfjs/cmaps/Add-V.bcmap +0 -0
  67. package/dist/web/vendor/pdfjs/cmaps/Adobe-CNS1-0.bcmap +0 -0
  68. package/dist/web/vendor/pdfjs/cmaps/Adobe-CNS1-1.bcmap +0 -0
  69. package/dist/web/vendor/pdfjs/cmaps/Adobe-CNS1-2.bcmap +0 -0
  70. package/dist/web/vendor/pdfjs/cmaps/Adobe-CNS1-3.bcmap +0 -0
  71. package/dist/web/vendor/pdfjs/cmaps/Adobe-CNS1-4.bcmap +0 -0
  72. package/dist/web/vendor/pdfjs/cmaps/Adobe-CNS1-5.bcmap +0 -0
  73. package/dist/web/vendor/pdfjs/cmaps/Adobe-CNS1-6.bcmap +0 -0
  74. package/dist/web/vendor/pdfjs/cmaps/Adobe-CNS1-UCS2.bcmap +0 -0
  75. package/dist/web/vendor/pdfjs/cmaps/Adobe-GB1-0.bcmap +0 -0
  76. package/dist/web/vendor/pdfjs/cmaps/Adobe-GB1-1.bcmap +0 -0
  77. package/dist/web/vendor/pdfjs/cmaps/Adobe-GB1-2.bcmap +0 -0
  78. package/dist/web/vendor/pdfjs/cmaps/Adobe-GB1-3.bcmap +0 -0
  79. package/dist/web/vendor/pdfjs/cmaps/Adobe-GB1-4.bcmap +0 -0
  80. package/dist/web/vendor/pdfjs/cmaps/Adobe-GB1-5.bcmap +0 -0
  81. package/dist/web/vendor/pdfjs/cmaps/Adobe-GB1-UCS2.bcmap +0 -0
  82. package/dist/web/vendor/pdfjs/cmaps/Adobe-Japan1-0.bcmap +0 -0
  83. package/dist/web/vendor/pdfjs/cmaps/Adobe-Japan1-1.bcmap +0 -0
  84. package/dist/web/vendor/pdfjs/cmaps/Adobe-Japan1-2.bcmap +0 -0
  85. package/dist/web/vendor/pdfjs/cmaps/Adobe-Japan1-3.bcmap +0 -0
  86. package/dist/web/vendor/pdfjs/cmaps/Adobe-Japan1-4.bcmap +0 -0
  87. package/dist/web/vendor/pdfjs/cmaps/Adobe-Japan1-5.bcmap +0 -0
  88. package/dist/web/vendor/pdfjs/cmaps/Adobe-Japan1-6.bcmap +0 -0
  89. package/dist/web/vendor/pdfjs/cmaps/Adobe-Japan1-UCS2.bcmap +0 -0
  90. package/dist/web/vendor/pdfjs/cmaps/Adobe-Korea1-0.bcmap +0 -0
  91. package/dist/web/vendor/pdfjs/cmaps/Adobe-Korea1-1.bcmap +0 -0
  92. package/dist/web/vendor/pdfjs/cmaps/Adobe-Korea1-2.bcmap +0 -0
  93. package/dist/web/vendor/pdfjs/cmaps/Adobe-Korea1-UCS2.bcmap +0 -0
  94. package/dist/web/vendor/pdfjs/cmaps/B5-H.bcmap +0 -0
  95. package/dist/web/vendor/pdfjs/cmaps/B5-V.bcmap +0 -0
  96. package/dist/web/vendor/pdfjs/cmaps/B5pc-H.bcmap +0 -0
  97. package/dist/web/vendor/pdfjs/cmaps/B5pc-V.bcmap +0 -0
  98. package/dist/web/vendor/pdfjs/cmaps/CNS-EUC-H.bcmap +0 -0
  99. package/dist/web/vendor/pdfjs/cmaps/CNS-EUC-V.bcmap +0 -0
  100. package/dist/web/vendor/pdfjs/cmaps/CNS1-H.bcmap +0 -0
  101. package/dist/web/vendor/pdfjs/cmaps/CNS1-V.bcmap +0 -0
  102. package/dist/web/vendor/pdfjs/cmaps/CNS2-H.bcmap +0 -0
  103. package/dist/web/vendor/pdfjs/cmaps/CNS2-V.bcmap +3 -0
  104. package/dist/web/vendor/pdfjs/cmaps/ETHK-B5-H.bcmap +0 -0
  105. package/dist/web/vendor/pdfjs/cmaps/ETHK-B5-V.bcmap +0 -0
  106. package/dist/web/vendor/pdfjs/cmaps/ETen-B5-H.bcmap +0 -0
  107. package/dist/web/vendor/pdfjs/cmaps/ETen-B5-V.bcmap +0 -0
  108. package/dist/web/vendor/pdfjs/cmaps/ETenms-B5-H.bcmap +3 -0
  109. package/dist/web/vendor/pdfjs/cmaps/ETenms-B5-V.bcmap +0 -0
  110. package/dist/web/vendor/pdfjs/cmaps/EUC-H.bcmap +0 -0
  111. package/dist/web/vendor/pdfjs/cmaps/EUC-V.bcmap +0 -0
  112. package/dist/web/vendor/pdfjs/cmaps/Ext-H.bcmap +0 -0
  113. package/dist/web/vendor/pdfjs/cmaps/Ext-RKSJ-H.bcmap +0 -0
  114. package/dist/web/vendor/pdfjs/cmaps/Ext-RKSJ-V.bcmap +0 -0
  115. package/dist/web/vendor/pdfjs/cmaps/Ext-V.bcmap +0 -0
  116. package/dist/web/vendor/pdfjs/cmaps/GB-EUC-H.bcmap +0 -0
  117. package/dist/web/vendor/pdfjs/cmaps/GB-EUC-V.bcmap +0 -0
  118. package/dist/web/vendor/pdfjs/cmaps/GB-H.bcmap +4 -0
  119. package/dist/web/vendor/pdfjs/cmaps/GB-V.bcmap +0 -0
  120. package/dist/web/vendor/pdfjs/cmaps/GBK-EUC-H.bcmap +0 -0
  121. package/dist/web/vendor/pdfjs/cmaps/GBK-EUC-V.bcmap +0 -0
  122. package/dist/web/vendor/pdfjs/cmaps/GBK2K-H.bcmap +0 -0
  123. package/dist/web/vendor/pdfjs/cmaps/GBK2K-V.bcmap +0 -0
  124. package/dist/web/vendor/pdfjs/cmaps/GBKp-EUC-H.bcmap +0 -0
  125. package/dist/web/vendor/pdfjs/cmaps/GBKp-EUC-V.bcmap +0 -0
  126. package/dist/web/vendor/pdfjs/cmaps/GBT-EUC-H.bcmap +0 -0
  127. package/dist/web/vendor/pdfjs/cmaps/GBT-EUC-V.bcmap +0 -0
  128. package/dist/web/vendor/pdfjs/cmaps/GBT-H.bcmap +0 -0
  129. package/dist/web/vendor/pdfjs/cmaps/GBT-V.bcmap +0 -0
  130. package/dist/web/vendor/pdfjs/cmaps/GBTpc-EUC-H.bcmap +0 -0
  131. package/dist/web/vendor/pdfjs/cmaps/GBTpc-EUC-V.bcmap +0 -0
  132. package/dist/web/vendor/pdfjs/cmaps/GBpc-EUC-H.bcmap +0 -0
  133. package/dist/web/vendor/pdfjs/cmaps/GBpc-EUC-V.bcmap +0 -0
  134. package/dist/web/vendor/pdfjs/cmaps/H.bcmap +0 -0
  135. package/dist/web/vendor/pdfjs/cmaps/HKdla-B5-H.bcmap +0 -0
  136. package/dist/web/vendor/pdfjs/cmaps/HKdla-B5-V.bcmap +0 -0
  137. package/dist/web/vendor/pdfjs/cmaps/HKdlb-B5-H.bcmap +0 -0
  138. package/dist/web/vendor/pdfjs/cmaps/HKdlb-B5-V.bcmap +0 -0
  139. package/dist/web/vendor/pdfjs/cmaps/HKgccs-B5-H.bcmap +0 -0
  140. package/dist/web/vendor/pdfjs/cmaps/HKgccs-B5-V.bcmap +0 -0
  141. package/dist/web/vendor/pdfjs/cmaps/HKm314-B5-H.bcmap +0 -0
  142. package/dist/web/vendor/pdfjs/cmaps/HKm314-B5-V.bcmap +0 -0
  143. package/dist/web/vendor/pdfjs/cmaps/HKm471-B5-H.bcmap +0 -0
  144. package/dist/web/vendor/pdfjs/cmaps/HKm471-B5-V.bcmap +0 -0
  145. package/dist/web/vendor/pdfjs/cmaps/HKscs-B5-H.bcmap +0 -0
  146. package/dist/web/vendor/pdfjs/cmaps/HKscs-B5-V.bcmap +0 -0
  147. package/dist/web/vendor/pdfjs/cmaps/Hankaku.bcmap +0 -0
  148. package/dist/web/vendor/pdfjs/cmaps/Hiragana.bcmap +0 -0
  149. package/dist/web/vendor/pdfjs/cmaps/KSC-EUC-H.bcmap +0 -0
  150. package/dist/web/vendor/pdfjs/cmaps/KSC-EUC-V.bcmap +0 -0
  151. package/dist/web/vendor/pdfjs/cmaps/KSC-H.bcmap +0 -0
  152. package/dist/web/vendor/pdfjs/cmaps/KSC-Johab-H.bcmap +0 -0
  153. package/dist/web/vendor/pdfjs/cmaps/KSC-Johab-V.bcmap +0 -0
  154. package/dist/web/vendor/pdfjs/cmaps/KSC-V.bcmap +0 -0
  155. package/dist/web/vendor/pdfjs/cmaps/KSCms-UHC-H.bcmap +0 -0
  156. package/dist/web/vendor/pdfjs/cmaps/KSCms-UHC-HW-H.bcmap +0 -0
  157. package/dist/web/vendor/pdfjs/cmaps/KSCms-UHC-HW-V.bcmap +0 -0
  158. package/dist/web/vendor/pdfjs/cmaps/KSCms-UHC-V.bcmap +0 -0
  159. package/dist/web/vendor/pdfjs/cmaps/KSCpc-EUC-H.bcmap +0 -0
  160. package/dist/web/vendor/pdfjs/cmaps/KSCpc-EUC-V.bcmap +0 -0
  161. package/dist/web/vendor/pdfjs/cmaps/Katakana.bcmap +0 -0
  162. package/dist/web/vendor/pdfjs/cmaps/LICENSE +36 -0
  163. package/dist/web/vendor/pdfjs/cmaps/NWP-H.bcmap +0 -0
  164. package/dist/web/vendor/pdfjs/cmaps/NWP-V.bcmap +0 -0
  165. package/dist/web/vendor/pdfjs/cmaps/RKSJ-H.bcmap +0 -0
  166. package/dist/web/vendor/pdfjs/cmaps/RKSJ-V.bcmap +0 -0
  167. package/dist/web/vendor/pdfjs/cmaps/Roman.bcmap +0 -0
  168. package/dist/web/vendor/pdfjs/cmaps/UniCNS-UCS2-H.bcmap +0 -0
  169. package/dist/web/vendor/pdfjs/cmaps/UniCNS-UCS2-V.bcmap +0 -0
  170. package/dist/web/vendor/pdfjs/cmaps/UniCNS-UTF16-H.bcmap +0 -0
  171. package/dist/web/vendor/pdfjs/cmaps/UniCNS-UTF16-V.bcmap +0 -0
  172. package/dist/web/vendor/pdfjs/cmaps/UniCNS-UTF32-H.bcmap +0 -0
  173. package/dist/web/vendor/pdfjs/cmaps/UniCNS-UTF32-V.bcmap +0 -0
  174. package/dist/web/vendor/pdfjs/cmaps/UniCNS-UTF8-H.bcmap +0 -0
  175. package/dist/web/vendor/pdfjs/cmaps/UniCNS-UTF8-V.bcmap +0 -0
  176. package/dist/web/vendor/pdfjs/cmaps/UniGB-UCS2-H.bcmap +0 -0
  177. package/dist/web/vendor/pdfjs/cmaps/UniGB-UCS2-V.bcmap +0 -0
  178. package/dist/web/vendor/pdfjs/cmaps/UniGB-UTF16-H.bcmap +0 -0
  179. package/dist/web/vendor/pdfjs/cmaps/UniGB-UTF16-V.bcmap +0 -0
  180. package/dist/web/vendor/pdfjs/cmaps/UniGB-UTF32-H.bcmap +0 -0
  181. package/dist/web/vendor/pdfjs/cmaps/UniGB-UTF32-V.bcmap +0 -0
  182. package/dist/web/vendor/pdfjs/cmaps/UniGB-UTF8-H.bcmap +0 -0
  183. package/dist/web/vendor/pdfjs/cmaps/UniGB-UTF8-V.bcmap +0 -0
  184. package/dist/web/vendor/pdfjs/cmaps/UniJIS-UCS2-H.bcmap +0 -0
  185. package/dist/web/vendor/pdfjs/cmaps/UniJIS-UCS2-HW-H.bcmap +0 -0
  186. package/dist/web/vendor/pdfjs/cmaps/UniJIS-UCS2-HW-V.bcmap +0 -0
  187. package/dist/web/vendor/pdfjs/cmaps/UniJIS-UCS2-V.bcmap +0 -0
  188. package/dist/web/vendor/pdfjs/cmaps/UniJIS-UTF16-H.bcmap +0 -0
  189. package/dist/web/vendor/pdfjs/cmaps/UniJIS-UTF16-V.bcmap +0 -0
  190. package/dist/web/vendor/pdfjs/cmaps/UniJIS-UTF32-H.bcmap +0 -0
  191. package/dist/web/vendor/pdfjs/cmaps/UniJIS-UTF32-V.bcmap +0 -0
  192. package/dist/web/vendor/pdfjs/cmaps/UniJIS-UTF8-H.bcmap +0 -0
  193. package/dist/web/vendor/pdfjs/cmaps/UniJIS-UTF8-V.bcmap +0 -0
  194. package/dist/web/vendor/pdfjs/cmaps/UniJIS2004-UTF16-H.bcmap +0 -0
  195. package/dist/web/vendor/pdfjs/cmaps/UniJIS2004-UTF16-V.bcmap +0 -0
  196. package/dist/web/vendor/pdfjs/cmaps/UniJIS2004-UTF32-H.bcmap +0 -0
  197. package/dist/web/vendor/pdfjs/cmaps/UniJIS2004-UTF32-V.bcmap +0 -0
  198. package/dist/web/vendor/pdfjs/cmaps/UniJIS2004-UTF8-H.bcmap +0 -0
  199. package/dist/web/vendor/pdfjs/cmaps/UniJIS2004-UTF8-V.bcmap +0 -0
  200. package/dist/web/vendor/pdfjs/cmaps/UniJISPro-UCS2-HW-V.bcmap +0 -0
  201. package/dist/web/vendor/pdfjs/cmaps/UniJISPro-UCS2-V.bcmap +0 -0
  202. package/dist/web/vendor/pdfjs/cmaps/UniJISPro-UTF8-V.bcmap +0 -0
  203. package/dist/web/vendor/pdfjs/cmaps/UniJISX0213-UTF32-H.bcmap +0 -0
  204. package/dist/web/vendor/pdfjs/cmaps/UniJISX0213-UTF32-V.bcmap +0 -0
  205. package/dist/web/vendor/pdfjs/cmaps/UniJISX02132004-UTF32-H.bcmap +0 -0
  206. package/dist/web/vendor/pdfjs/cmaps/UniJISX02132004-UTF32-V.bcmap +0 -0
  207. package/dist/web/vendor/pdfjs/cmaps/UniKS-UCS2-H.bcmap +0 -0
  208. package/dist/web/vendor/pdfjs/cmaps/UniKS-UCS2-V.bcmap +0 -0
  209. package/dist/web/vendor/pdfjs/cmaps/UniKS-UTF16-H.bcmap +0 -0
  210. package/dist/web/vendor/pdfjs/cmaps/UniKS-UTF16-V.bcmap +0 -0
  211. package/dist/web/vendor/pdfjs/cmaps/UniKS-UTF32-H.bcmap +0 -0
  212. package/dist/web/vendor/pdfjs/cmaps/UniKS-UTF32-V.bcmap +0 -0
  213. package/dist/web/vendor/pdfjs/cmaps/UniKS-UTF8-H.bcmap +0 -0
  214. package/dist/web/vendor/pdfjs/cmaps/UniKS-UTF8-V.bcmap +0 -0
  215. package/dist/web/vendor/pdfjs/cmaps/V.bcmap +0 -0
  216. package/dist/web/vendor/pdfjs/cmaps/WP-Symbol.bcmap +0 -0
  217. package/dist/web/vendor/pdfjs/iccs/CGATS001Compat-v2-micro.icc +0 -0
  218. package/dist/web/vendor/pdfjs/iccs/LICENSE +116 -0
  219. package/dist/web/vendor/pdfjs/pdf.min.mjs +28 -0
  220. package/dist/web/vendor/pdfjs/pdf.worker.mjs +64908 -0
  221. package/dist/web/vendor/pdfjs/standard_fonts/FoxitDingbats.pfb +0 -0
  222. package/dist/web/vendor/pdfjs/standard_fonts/FoxitFixed.pfb +0 -0
  223. package/dist/web/vendor/pdfjs/standard_fonts/FoxitFixedBold.pfb +0 -0
  224. package/dist/web/vendor/pdfjs/standard_fonts/FoxitFixedBoldItalic.pfb +0 -0
  225. package/dist/web/vendor/pdfjs/standard_fonts/FoxitFixedItalic.pfb +0 -0
  226. package/dist/web/vendor/pdfjs/standard_fonts/FoxitSerif.pfb +0 -0
  227. package/dist/web/vendor/pdfjs/standard_fonts/FoxitSerifBold.pfb +0 -0
  228. package/dist/web/vendor/pdfjs/standard_fonts/FoxitSerifBoldItalic.pfb +0 -0
  229. package/dist/web/vendor/pdfjs/standard_fonts/FoxitSerifItalic.pfb +0 -0
  230. package/dist/web/vendor/pdfjs/standard_fonts/FoxitSymbol.pfb +0 -0
  231. package/dist/web/vendor/pdfjs/standard_fonts/LICENSE_FOXIT +27 -0
  232. package/dist/web/vendor/pdfjs/standard_fonts/LICENSE_LIBERATION +363 -0
  233. package/dist/web/vendor/pdfjs/standard_fonts/LiberationSans-Bold.ttf +0 -0
  234. package/dist/web/vendor/pdfjs/standard_fonts/LiberationSans-BoldItalic.ttf +0 -0
  235. package/dist/web/vendor/pdfjs/standard_fonts/LiberationSans-Italic.ttf +0 -0
  236. package/dist/web/vendor/pdfjs/standard_fonts/LiberationSans-Regular.ttf +0 -0
  237. package/dist/web/vendor/pdfjs/wasm/LICENSE_JBIG2 +196 -0
  238. package/dist/web/vendor/pdfjs/wasm/LICENSE_OPENJPEG +39 -0
  239. package/dist/web/vendor/pdfjs/wasm/LICENSE_PDFJS_JBIG2 +13 -0
  240. package/dist/web/vendor/pdfjs/wasm/LICENSE_PDFJS_OPENJPEG +22 -0
  241. package/dist/web/vendor/pdfjs/wasm/LICENSE_PDFJS_QCMS +19 -0
  242. package/dist/web/vendor/pdfjs/wasm/LICENSE_QCMS +21 -0
  243. package/dist/web/vendor/pdfjs/wasm/jbig2.wasm +0 -0
  244. package/dist/web/vendor/pdfjs/wasm/jbig2_nowasm_fallback.js +15 -0
  245. package/dist/web/vendor/pdfjs/wasm/openjpeg.wasm +0 -0
  246. package/dist/web/vendor/pdfjs/wasm/openjpeg_nowasm_fallback.js +17 -0
  247. package/dist/web/vendor/pdfjs/wasm/qcms_bg.wasm +0 -0
  248. package/dist/web/workspaces.js +167 -26
  249. package/home-env.mjs +28 -0
  250. package/install-path.mjs +59 -3
  251. package/launch-starting-page.mjs +35 -15
  252. package/launch.mjs +358 -51
  253. package/package.json +2 -1
  254. package/pin-home.mjs +6 -0
  255. package/post-update-marker.mjs +14 -0
  256. package/preferences-file.mjs +289 -0
  257. package/supervisor-lock.mjs +195 -0
package/launch.mjs CHANGED
@@ -2,14 +2,16 @@
2
2
  // Dependency-free (Node built-ins only), Windows-first (the project is Windows).
3
3
  //
4
4
  // node launch.mjs open (default) start-if-needed, then open the browser
5
+ // node launch.mjs window same, but in the FloLess window when it is installed
5
6
  // node launch.mjs stop kill whatever is serving the port
6
7
  // node launch.mjs restart stop, then open
7
8
  //
8
9
  // Health is checked on 127.0.0.1 (Node's resolver doesn't do the browser's
9
10
  // *.localhost trick); the BROWSER is pointed at the branded host, which Chrome/
10
11
  // Edge/Firefox resolve to 127.0.0.1 with no hosts-file edit.
12
+ import './pin-home.mjs'; // a relative FLOLESS_HOME becomes absolute before any module (or child) reads it (#3080)
11
13
  import { spawn, execSync, execFileSync } from 'node:child_process';
12
- import { dirname, join, basename } from 'node:path';
14
+ import { dirname, join, basename, win32 } from 'node:path';
13
15
  import { fileURLToPath } from 'node:url';
14
16
  import { distributionProfile } from './distribution-profile-active.mjs';
15
17
  import { existsSync, readFileSync } from 'node:fs';
@@ -19,9 +21,16 @@ import { createInterface } from 'node:readline';
19
21
  import { rotateLog, openLogFd, logDir } from './log.mjs';
20
22
  import { startingPageDir, writeStartingPage } from './launch-starting-page.mjs';
21
23
  import { supervisorPidsToKill, teardownDecision, awareIsPresent, RUN_KEY, RUN_VALUE, PROTOCOL_KEY } from './teardown.mjs';
22
- import { resolveRealInstallExe } from './install-path.mjs';
23
- import { consumePostUpdateMarker } from './post-update-marker.mjs';
24
+ import { resolveOwnInstallExe } from './install-path.mjs';
25
+ import { consumePostUpdateMarker, peekPostUpdateMarker } from './post-update-marker.mjs';
24
26
  import { ACTIONS_CLI_COMMANDS, runActionsCli } from './cli-actions.mjs';
27
+ import {
28
+ shellInfo, shellExe, launchShell, closeShellGracefully, readInventory, joinRestore, claimRestore, restoreAgeMs,
29
+ beginUpdate, endUpdate, updateInProgress, removeFromRestore, STALE_RESTORE_MS,
30
+ beginTeardown, endTeardown, trayHeld, createTrayKeeper, launchTray,
31
+ } from './desktop-shell.mjs';
32
+ import { resolveClientForOpen, readTrayPreference } from './preferences-file.mjs';
33
+ import { createSupervisorOwnership } from './supervisor-lock.mjs';
25
34
 
26
35
  const __dirname = dirname(fileURLToPath(import.meta.url));
27
36
  const PORT = Number(process.env.PORT ?? 4317);
@@ -191,6 +200,32 @@ export function resolveServerStart({
191
200
  return { cmd: 'npm', args: ['run', 'start'], shell: isWin };
192
201
  }
193
202
 
203
+ // How to run the `window` action from a running server (the "Open in app" menu item and its chat action): the same
204
+ // binary as the launcher, per build kind, exactly as resolveServerStart picks it.
205
+ export function resolveWindowStart({
206
+ packaged = isPackagedDistributionExe(),
207
+ sourceAvailable = existsSync(join(__dirname, 'launch.mjs')) && existsSync(join(__dirname, 'main.ts')),
208
+ bundleAvailable = existsSync(join(__dirname, 'dist', 'floless-server.cjs')),
209
+ } = {}) {
210
+ if (packaged) return { cmd: process.execPath, args: ['window'] };
211
+ if (sourceAvailable) return { cmd: process.execPath, args: [join(__dirname, 'launch.mjs'), 'window'] };
212
+ if (bundleAvailable) return { cmd: process.execPath, args: [join(__dirname, 'dist', 'floless-server.cjs'), 'window'] };
213
+ return null;
214
+ }
215
+
216
+ /** Start the `window` launcher action detached. { started } is false (with a reason) when there is no window to open. */
217
+ export function startWindowDetached({ spawnFn = (cmd, args, options) => spawn(cmd, args, { ...options, windowsHide: true }), info = shellInfo, resolve = resolveWindowStart } = {}) {
218
+ if (!info().installed) return { started: false, reason: 'not-installed' };
219
+ const how = resolve();
220
+ if (!how) return { started: false, reason: 'no-launcher' };
221
+ try {
222
+ const child = spawnFn(how.cmd, how.args, { cwd: __dirname, detached: true, stdio: 'ignore', windowsHide: true });
223
+ child.once?.('error', () => {});
224
+ child.unref();
225
+ return { started: true };
226
+ } catch { return { started: false, reason: 'could-not-start' }; }
227
+ }
228
+
194
229
  function startServerDetached() {
195
230
  const { cmd, args, shell } = resolveServerStart();
196
231
  // Route the detached daemon's stdout+stderr to the rotating logfile (not 'ignore')
@@ -274,6 +309,10 @@ export async function startAndOpen({
274
309
  now = Date.now,
275
310
  sleep = (ms) => new Promise((r) => setTimeout(r, ms)),
276
311
  say = log,
312
+ // The FloLess window (desktop shell) as the client instead of a browser tab: { show(state), close() }. `show` answers
313
+ // 'shown' once a window is on screen; anything else means the browser path below takes over, so a launch is never
314
+ // left with nothing on screen.
315
+ shell = null,
277
316
  } = {}) {
278
317
  say('starting server…');
279
318
  const attempt = createServerAttempt({ start, healthy, listening, now, say });
@@ -281,21 +320,43 @@ export async function startAndOpen({
281
320
  const startedAt = now();
282
321
  while (now() - startedAt < QUICK_START_MS) {
283
322
  result = await attempt.poll();
284
- if (result === 'ready') { say('server up'); say(`opening ${BROWSER_URL}`); open(BROWSER_URL); return 'opened'; }
323
+ if (result === 'ready') {
324
+ say('server up');
325
+ if (shell && (await shell.show('ready')) === 'shown') { say('opened the FloLess window'); return 'opened'; }
326
+ say(`opening ${BROWSER_URL}`); open(BROWSER_URL); return 'opened';
327
+ }
285
328
  if (attempt.exited || result === 'port-busy') break;
286
329
  await sleep(500);
287
330
  }
331
+ // The window shows its own starting screen while the server is still coming up; the browser page below is the
332
+ // fallback, and also how a final failure (stopped, busy, gave up) is explained, because the window only waits.
333
+ let windowShowing = !!shell && (await shell.show('starting')) === 'shown';
334
+ if (windowShowing) say('server still starting — the FloLess window shows its starting screen and switches to the app when it is ready');
288
335
  // The page is a convenience; a data folder it cannot be written to must not cost the person the app.
289
336
  let progress = null;
290
- try { progress = page(); }
291
- catch (error) { say(`could not write the starting page (${error?.message ?? error}); will open FloLess when it is ready`); }
292
- if (progress) {
293
- say(`server still starting — opened a page that switches to FloLess when it is ready (${progress.path})`);
294
- open(progress.url);
337
+ const makePage = () => {
338
+ try { progress = page(); }
339
+ catch (error) { say(`could not write the starting page (${error?.message ?? error}); will open FloLess when it is ready`); }
340
+ };
341
+ if (!windowShowing) {
342
+ makePage();
343
+ if (progress) {
344
+ say(`server still starting — opened a page that switches to FloLess when it is ready (${progress.path})`);
345
+ open(progress.url);
346
+ }
295
347
  }
296
348
  // A final state the page never receives would leave it spinning, so it is retried for a few seconds.
297
349
  // Returns whether the page got it.
298
350
  const settle = async (state) => {
351
+ if (windowShowing) {
352
+ // The window only waits for a healthy server: it cannot say "stopped". On success it switches by itself; on any
353
+ // other end it is closed and the browser starting page explains what happened.
354
+ if (state === 'ready') return true;
355
+ try { await shell.close(); } catch { /* the page below still explains */ }
356
+ windowShowing = false;
357
+ makePage();
358
+ if (progress) open(progress.url);
359
+ }
299
360
  if (!progress) return false;
300
361
  for (let i = 0; i < 5; i += 1) { if (progress.status(state) !== false) return true; await sleep(1000); }
301
362
  say(`could not tell the starting page "${state}"`);
@@ -339,7 +400,29 @@ export async function startAndOpen({
339
400
  }
340
401
 
341
402
  export async function cmdOpen({ marker = consumePostUpdateMarker, healthy = ping, ensure = ensureServerUp,
342
- startOpen = startAndOpen, say = log, open = openBrowser } = {}) {
403
+ startOpen = (deps) => startAndOpen(deps), say = log, open = openBrowser, client = undefined, shell = null,
404
+ restore = restoreWindows, updating = updateInProgress, peekMarker = peekPostUpdateMarker,
405
+ shellInstalled = () => shellInfo().installed, preferred = resolveClientForOpen } = {}) {
406
+ // The window (desktop shell) is a second client beside the browser tab, never a replacement for it: when it is not
407
+ // installed, or shows nothing, the tab opens instead and the log says why. `client` is 'window' for
408
+ // `FlolessApp.exe window` / floless://window (whatever is stored); a plain `open` follows the person's stored choice
409
+ // (preferences.json). With none stored, a new install gets the window and one that was in use before keeps the tab
410
+ // (resolveClientForOpen, #2964).
411
+ if (client === undefined) client = shellInstalled() ? preferred() : 'browser';
412
+ let win = null;
413
+ if (client === 'window') {
414
+ win = shell ?? windowClient({ say });
415
+ if (!win.available()) { say('the FloLess window is not installed on this computer — opening FloLess in the browser instead'); win = null; }
416
+ }
417
+ // While an update replaces the shell's folder, NO client may touch the server or the post-update marker: a plain `open`
418
+ // would restart the server from the directory being replaced, or consume the marker meant for the new build. The request
419
+ // is held and joins the restore list. Only people with the shell installed are affected (tab-only people are untouched),
420
+ // and the updater's own completed handoff (the marker is present) goes through and lifts the hold below.
421
+ if (updating() && !peekMarker() && (win ? win.available() : shellInstalled())) {
422
+ joinRestore(['/']);
423
+ say('FloLess is updating — it will open when the update is done');
424
+ return;
425
+ }
343
426
  // A post-self-update relaunch must start the server but NOT open a second browser tab —
344
427
  // Velopack relaunches FlolessApp.exe bare (→ this `open` action), while the user's existing
345
428
  // tab is still alive and reconnects via its 5s health poll (#37). Consume the one-shot
@@ -365,21 +448,126 @@ export async function cmdOpen({ marker = consumePostUpdateMarker, healthy = ping
365
448
  }
366
449
  if (postUpdate) {
367
450
  if (!serving && !(await ensure())) { process.exitCode = 1; return; }
451
+ // The update is over: lift the admission hold, or every `window` launch would wait out its 10-minute expiry.
452
+ endUpdate();
453
+ // The update closed the FloLess window first (so its leave guard could run); reopen what was open. Tab-only
454
+ // people have no list, so nothing changes for them: their tab reloads itself onto the new build.
455
+ if (await restore({ say })) { say('post-update relaunch — server up; reopened the FloLess window'); return; }
368
456
  say('post-update relaunch — server up; the existing tab reconnects via its health poll (no new tab)');
369
457
  return;
370
458
  }
371
- if (!serving) { await startOpen(); return; }
459
+ if (!serving) { await startOpen(win ? { shell: win } : {}); return; }
460
+ if (win && (await win.show('ready')) === 'shown') { log('opened the FloLess window'); return; }
372
461
  log(`opening ${BROWSER_URL}`);
373
462
  open(BROWSER_URL);
374
463
  }
375
464
 
465
+ // ── the FloLess window (desktop shell) ─────────────────────────────────────────────────────────────────────────────
466
+
467
+ // PIDs of every desktop shell process (main, GPU, renderers): matched by FULL exe path so no other Electron app is
468
+ // ever touched, and never this process.
469
+ export function shellPidList(enumerate = (name) => enumerateProcesses(name), exe = shellExe()) {
470
+ const needle = exe.toLowerCase();
471
+ // Process paths on Windows are Windows paths, whatever platform this code is running on (the tests run on Linux too).
472
+ return enumerate(win32.basename(exe)).filter((p) => p.pid !== process.pid && p.cmd.toLowerCase().includes(needle)).map((p) => p.pid);
473
+ }
474
+ export async function shellRunning() { return isWin && shellPidList().length > 0; }
475
+ function killShellTree() {
476
+ for (const pid of shellPidList()) {
477
+ try { execFileSync('taskkill', taskkillArgs(pid, { tree: true }), { stdio: 'ignore', windowsHide: true }); } catch { /* already gone */ }
478
+ }
479
+ }
480
+
481
+ /** The window as startAndOpen / cmdOpen use it. `show(state)` -> 'shown' | 'failed'; `close()` asks it to close. */
482
+ export function windowClient({ say = log, launch = launchShell, windows = ['/'] } = {}) {
483
+ return {
484
+ available: () => shellInfo().installed,
485
+ async show(state) {
486
+ const result = await launch({ windows, starting: state === 'starting', server: BROWSER_URL, say, killShell: killShellTree });
487
+ return result === 'shown' ? 'shown' : 'failed';
488
+ },
489
+ async close() {
490
+ const result = await closeShellGracefully({ running: shellRunning });
491
+ if (result === 'no-ack') killShellTree();
492
+ },
493
+ };
494
+ }
495
+
496
+ /** `FlolessApp.exe window` / floless://window: open the FloLess window whatever the stored preference says. */
497
+ export async function cmdWindow(deps = {}) { return cmdOpen({ ...deps, client: 'window' }); }
498
+
499
+ /** Reopen what an update closed. Safe from several callers at once: one wins the list (atomic claim), the rest get none. */
500
+ export async function restoreWindows({ say = log, shell = null, open = openBrowser, healthy = ping } = {}) {
501
+ const windows = claimRestore();
502
+ if (windows.length === 0) return 0;
503
+ const win = shell ?? windowClient({ say, windows });
504
+ // A server that is not answering yet (a failed update whose supervisor is still starting it) must not be handed to
505
+ // a window in the ready state: it would load the URL once and never retry. The starting screen switches by itself.
506
+ const state = (await healthy()) ? 'ready' : 'starting';
507
+ if (win.available() && (await win.show(state)) === 'shown') return windows.length;
508
+ say('could not reopen the FloLess window — opening FloLess in the browser instead');
509
+ open(BROWSER_URL);
510
+ return windows.length;
511
+ }
512
+
513
+ /**
514
+ * Before an update is applied: close the FloLess window the way a person would, so its leave guard runs and nothing
515
+ * is killed under it. { ok: true } to go on; { ok: false, reason } when the person chose to keep the window open
516
+ * (the update is paused, never forced). Only a window that does not answer at all (hung) is ended.
517
+ */
518
+ export async function prepareShellForUpdate({ say = log, installed = () => shellInfo().installed, closeShell = closeShellGracefully,
519
+ running = shellRunning, kill = killShellTree, inventory = readInventory } = {}) {
520
+ if (!installed()) return { ok: true };
521
+ beginUpdate();
522
+ // The inventory is the shell's last report of its windows. With no shell running it is stale (the person closed the window,
523
+ // used the browser, then updated): copying it would reopen windows nobody has open. Launches queued during the update stay.
524
+ const windows = (await running()) ? inventory() : [];
525
+ if (windows.length) joinRestore(windows); // persisted BEFORE closing: it survives a shell that is later ended
526
+ const result = await closeShell({ running });
527
+ if (result === 'cancelled') {
528
+ endUpdate();
529
+ removeFromRestore(windows); // only what this attempt added: a launch queued meanwhile is still wanted
530
+ return { ok: false, reason: 'The update was paused because you kept the FloLess window open. Update again when you are ready to close it.' };
531
+ }
532
+ if (result === 'no-ack') { say('the FloLess window is not responding — closing it so the update can go ahead'); kill(); }
533
+ return { ok: true };
534
+ }
535
+
536
+ /** After an update that did not happen (it could not start, or was paused): put the windows back. */
537
+ export async function recoverAfterFailedUpdate({ say = log } = {}) {
538
+ endUpdate();
539
+ if (!shellInfo().installed) return;
540
+ await restoreWindows({ say });
541
+ }
542
+
543
+ /**
544
+ * What every update entry point does when the apply failed or was paused. The supervisor is brought back FIRST: the
545
+ * teardown stopped the server, and a window reopened before it is on its way would load the URL once and never retry.
546
+ * (A paused update stopped nothing, so it has no supervisor to bring back.)
547
+ */
548
+ export async function handleFailedUpdate({ paused = false, supervise = cmdSupervise, recover = recoverAfterFailedUpdate } = {}) {
549
+ if (!paused) await supervise();
550
+ await recover();
551
+ }
552
+
553
+ // The supervisor's last resort: an update that closed the window and then never relaunched leaves a restore list
554
+ // behind. Once it is stale (and no update is running), reopen the windows.
555
+ export async function restoreIfStranded({ say = log, age = restoreAgeMs, updating = updateInProgress, restore = restoreWindows } = {}) {
556
+ const ageMs = age();
557
+ if (ageMs === null || ageMs < STALE_RESTORE_MS || updating()) return 0;
558
+ return restore({ say });
559
+ }
560
+
376
561
  // `start` (the in-tab recovery trigger, fired as floless://start from a tab whose
377
562
  // server died): start-if-needed but NEVER open a browser — the tab that fired this
378
563
  // is already open and heals itself via its 5s health poll. This is the headless
379
564
  // counterpart to `open`, and the action autostart-on-login uses too.
380
- export async function cmdStart() {
381
- if (await ping()) { log('already running'); return; }
382
- if (!(await ensureServerUp())) process.exitCode = 1;
565
+ // The ONE manual-start path (the stopped screen's Start link, floless://start, the tray's Start FloLess): server up, then
566
+ // exactly one supervisor (which also brings the tray back). Safe to run any number of times (#3069).
567
+ export async function cmdStart({ healthy = ping, ensure = ensureServerUp, supervisor = ensureSupervisor, say = log } = {}) {
568
+ if (await healthy()) say('already running');
569
+ else if (!(await ensure())) { process.exitCode = 1; return; }
570
+ try { supervisor({ say }); } catch (error) { say(`could not check the FloLess supervisor (${error?.message ?? error}); the server is running`); }
383
571
  }
384
572
 
385
573
  // `supervise` — the login-autostart entry: KEEP the local server alive. Starts it if
@@ -400,9 +588,58 @@ const SUPERVISE_POLL_MS = 3000;
400
588
  // set it from outside (a user-set value would short-circuit the detach step).
401
589
  const SUPERVISE_RESPAWN_ENV = 'FLOLESS_SUPERVISE_RESPAWNED';
402
590
 
591
+ /**
592
+ * Start the supervisor LOOP as a detached process of its own (the packaged exe with `--supervise`, marked so it runs the loop
593
+ * instead of handing itself off again). Output goes to the rotating logfile. Shared by the sign-in hand-off above and by a
594
+ * manual Start (`ensureSupervisor`). The loop takes ownership itself, so starting one too many is harmless: it steps aside.
595
+ */
596
+ export function startSupervisorLoopDetached({ spawnFn = (cmd, args, options) => spawn(cmd, args, { ...options, windowsHide: true }), exe = process.execPath, env = process.env } = {}) {
597
+ rotateLog();
598
+ const fd = openLogFd();
599
+ const child = spawnFn(exe, ['--supervise'], {
600
+ detached: true,
601
+ stdio: fd == null ? 'ignore' : ['ignore', fd, fd],
602
+ windowsHide: true,
603
+ env: { ...env, [SUPERVISE_RESPAWN_ENV]: '1' },
604
+ });
605
+ child.once?.('error', (error) => log(`the FloLess supervisor could not start (${error?.code ?? error?.message ?? 'unknown error'})`));
606
+ child.unref();
607
+ return child;
608
+ }
609
+
610
+ /**
611
+ * The supervisor half of a manual Start (#3069): make sure exactly one supervisor is keeping the server (and, through it,
612
+ * the tray) alive. Stop FloLess ends the supervisor on purpose, so without this a Start would bring the server back with
613
+ * nothing to bring it back after a crash until the next sign-in. Idempotent: it asks the supervisor's ownership file, not
614
+ * a process list, and a second loop that starts anyway steps aside. Answers what it did: 'not-packaged' (no supervisor in
615
+ * this channel), 'held' (an update or teardown is running and brings its own back), 'running', 'started'.
616
+ */
617
+ export function ensureSupervisor({ packaged = isPackagedDistributionExe(), held = () => trayHeld(),
618
+ ownership = createSupervisorOwnership(), startLoop = () => startSupervisorLoopDetached(), say = log } = {}) {
619
+ if (!packaged) return 'not-packaged';
620
+ if (held()) { say('FloLess is being updated or removed — not starting the supervisor now'); return 'held'; }
621
+ if (ownership.ownerAlive()) return 'running';
622
+ startLoop();
623
+ say('started the supervisor so FloLess recovers by itself if it stops');
624
+ return 'started';
625
+ }
626
+
403
627
  export async function cmdSupervise({ start = startServerDetached, healthy = ping, listening = portListening,
404
628
  now = Date.now, sleep = (ms) => new Promise((r) => setTimeout(r, ms)), say = log,
405
- packaged = isPackagedDistributionExe() } = {}) {
629
+ packaged = isPackagedDistributionExe(),
630
+ // The tray (the FloLess icon near the clock): kept alive beside the server when the window is installed and the person
631
+ // has not switched it off. Held during an update or a teardown; see createTrayKeeper.
632
+ tray = createTrayKeeper({
633
+ installed: () => shellInfo().installed, wanted: () => readTrayPreference(), healthy,
634
+ held: () => trayHeld(), spawn: () => launchTray({ server: BROWSER_URL, say }), now, say,
635
+ }),
636
+ // Headless start at logon can be the first process to touch the FloLess home on an install whose hook did not settle the
637
+ // client: settle it before the server's first writes (S3, #2964). Only where the window is installed.
638
+ settleClient = () => { if (shellInfo().installed) resolveClientForOpen(); },
639
+ // Only one supervisor loop may run (#3069): it owns <FLOLESS_HOME>/supervisor.json and touches it on every tick. Only the
640
+ // packaged exe has one (the npm channel runs a foreground loop for a developer and has nothing to share).
641
+ ownership = packaged ? createSupervisorOwnership() : null } = {}) {
642
+ try { settleClient(); } catch { /* never block the watchdog */ }
406
643
  // Only the packaged SEA exe (autostart-wired by the Velopack hook) takes the
407
644
  // detached-respawn path — its argv is `<exe> --supervise`, which the dispatcher in
408
645
  // main.ts handles. The npm channel has process.execPath = node.exe and respawning
@@ -420,19 +657,42 @@ export async function cmdSupervise({ start = startServerDetached, healthy = ping
420
657
  // 'ignore'` would silently swallow every log() line + any uncaught crash (dual-
421
658
  // review finding #1, 2026-05-30). If the logfile can't be opened we fall back to
422
659
  // 'ignore' rather than failing the respawn.
423
- rotateLog();
424
- const fd = openLogFd();
425
- const child = spawn(process.execPath, ['--supervise'], {
426
- detached: true,
427
- stdio: fd == null ? 'ignore' : ['ignore', fd, fd],
428
- windowsHide: true,
429
- env: { ...process.env, [SUPERVISE_RESPAWN_ENV]: '1' },
430
- });
431
- child.unref();
660
+ startSupervisorLoopDetached();
432
661
  log('supervisor re-spawned detached');
433
662
  return;
434
663
  }
664
+ // The named pipe first (#3091): it is the one signal that needs no file, so it still keeps two supervisors apart when
665
+ // supervisor.json cannot be written. The file follows, for the heartbeat and for a supervisor from an older release that has no pipe.
666
+ const pipe = ownership?.claimPipe ? await ownership.claimPipe() : 'unavailable';
667
+ if (pipe === 'unavailable' && ownership?.pipeProblem?.()) say('FloLess could not reserve its supervisor name (' + ownership.pipeProblem() + '); it relies on its ownership file alone');
668
+ const owned = pipe === 'taken' ? { held: false } : ownership ? ownership.acquire() : { held: true };
669
+ if (!owned.held) {
670
+ // A busy guard also steps aside (a contender is taking over, or a crashed holder's lock has not expired: bounded at 30 s, and the
671
+ // next Start recovers). A busy guard does not prove no live legacy owner exists, so it never starts a second loop.
672
+ ownership?.release?.(); // a pipe claimed here goes back at once; the file is left to whoever owns it
673
+ say('another FloLess supervisor is already keeping the server alive — this one is not needed');
674
+ return;
675
+ }
676
+ if (owned.degraded) {
677
+ say(pipe === 'held'
678
+ ? 'FloLess could not record that this supervisor is running (' + owned.reason + '); another supervisor is still kept from starting next to it'
679
+ : 'FloLess could not record that this supervisor is running (' + owned.reason + '); it keeps the server alive anyway, but a second one could start next to it');
680
+ }
435
681
  say('supervisor up — keeping the server alive');
682
+ const releaseAtExit = () => ownership.release();
683
+ if (ownership) process.once('exit', releaseAtExit);
684
+ // Every wait is cut into short slices that each touch the ownership file, so a long retry delay never reads as a dead owner.
685
+ const lost = new Error('supervisor ownership lost');
686
+ const baseSleep = sleep;
687
+ sleep = async (ms) => {
688
+ let left = Math.max(0, ms);
689
+ do {
690
+ if (ownership && !ownership.beat()) throw lost;
691
+ const slice = Math.min(left, 5000);
692
+ await baseSleep(slice);
693
+ left -= slice;
694
+ } while (left > 0);
695
+ };
436
696
  let lastStartAt = null;
437
697
  const beginAttempt = () => createServerAttempt({ healthy, listening, now, say, start: () => {
438
698
  lastStartAt = now();
@@ -440,17 +700,27 @@ export async function cmdSupervise({ start = startServerDetached, healthy = ping
440
700
  return start();
441
701
  } });
442
702
  let attempt = beginAttempt();
443
- for (;;) {
444
- const result = await waitForServerAttempt(attempt, { now, sleep });
445
- if (result === 'stopped') {
446
- say('the server stopped before it was ready — will retry');
447
- if (lastStartAt !== null) await sleep(Math.max(0, 30_000 - (now() - lastStartAt)));
448
- attempt = beginAttempt();
449
- } else if (result === 'port-busy') {
450
- say('FloLess’s connection is unavailable. Another program may be using it; waiting for it to close.');
451
- attempt = beginAttempt();
452
- } else if (result === 'waiting') say('server not healthy yet — will keep waiting');
453
- await sleep(SUPERVISE_POLL_MS);
703
+ try {
704
+ for (;;) {
705
+ const result = await waitForServerAttempt(attempt, { now, sleep });
706
+ if (result === 'stopped') {
707
+ say('the server stopped before it was ready — will retry');
708
+ if (lastStartAt !== null) await sleep(Math.max(0, 30_000 - (now() - lastStartAt)));
709
+ attempt = beginAttempt();
710
+ } else if (result === 'port-busy') {
711
+ say('FloLess’s connection is unavailable. Another program may be using it; waiting for it to close.');
712
+ attempt = beginAttempt();
713
+ } else if (result === 'waiting') say('server not healthy yet — will keep waiting');
714
+ else await restoreIfStranded({ say }).catch(() => 0);
715
+ await tray.tick().catch((error) => { say(`the FloLess tray check failed (${error?.message ?? error}); the server is not affected`); return 'off'; });
716
+ await sleep(SUPERVISE_POLL_MS);
717
+ }
718
+ } catch (error) {
719
+ if (error !== lost) throw error;
720
+ say('another FloLess supervisor took over — this one stops');
721
+ } finally {
722
+ // Ownership ends with the loop, not with the process: a handle that keeps the process alive must not keep the pipe.
723
+ if (ownership) { process.removeListener('exit', releaseAtExit); ownership.release(); }
454
724
  }
455
725
  }
456
726
 
@@ -496,12 +766,19 @@ export function parseProcessList(json) {
496
766
 
497
767
  // Enumerate running processes as [{pid, cmd}]. Win32-only (uses Win32_Process);
498
768
  // returns [] elsewhere or on any failure (best-effort — teardown must never throw).
499
- function enumerateProcesses() {
769
+ //
770
+ // Control characters are blanked INSIDE PowerShell: some programs on a real machine carry one in their command
771
+ // line, which makes the whole JSON unreadable, and an unreadable list reads as "nothing is running" — a window or a
772
+ // supervisor that is very much running would then be missed. `exeName` limits the query to one executable name
773
+ // (plain file-name characters only) so the shell lookup does not have to read every process on the machine.
774
+ function enumerateProcesses(exeName) {
500
775
  if (!isWin) return [];
501
776
  try {
777
+ if (exeName !== undefined && !/^[\w.-]{1,64}$/.test(exeName)) return [];
778
+ const filter = exeName === undefined ? '' : ` -Filter "Name='${exeName}'"`;
502
779
  const ps =
503
- 'Get-CimInstance Win32_Process | Select-Object ProcessId,CommandLine | ConvertTo-Json -Compress';
504
- const out = execSync(`powershell -NoProfile -Command "${ps}"`, {
780
+ `Get-CimInstance Win32_Process${filter} | Select-Object ProcessId,@{n='CommandLine';e={$_.CommandLine -replace '[\\x00-\\x1f]',' '}} | ConvertTo-Json -Compress`;
781
+ const out = execSync(`powershell -NoProfile -Command "${ps.replace(/"/g, '\\"')}"`, {
505
782
  encoding: 'utf8',
506
783
  windowsHide: true,
507
784
  maxBuffer: 16 * 1024 * 1024,
@@ -523,6 +800,18 @@ export function taskkillArgs(pid, { tree = true } = {}) {
523
800
  return tree ? ['/PID', String(pid), '/T', '/F'] : ['/PID', String(pid), '/F'];
524
801
  }
525
802
 
803
+ // The needle(s) that identify THIS install's supervisor in a process list. MSIX-container case: the
804
+ // uninstaller running INSIDE the container sees its own process.execPath as the bind-link VIRTUAL
805
+ // path, but a supervisor we launched at logon (via a Run key registered with the un-virtualized REAL
806
+ // path) shows the REAL path in its command line, so that path is added, but only when it is the very
807
+ // same file as the running binary. A second package can hold its own FlolessApp copy, and the
808
+ // package-enumerating remap could name that one, which would let Stop end another install's
809
+ // supervisor (#3088). Anything not proven to be this binary is not a needle.
810
+ export function supervisorExeMatch(execPath, resolve = resolveOwnInstallExe) {
811
+ const own = resolve(execPath);
812
+ return own === execPath ? execPath : [execPath, own];
813
+ }
814
+
526
815
  // Kill the --supervise watchdog FIRST (Codex B1) so it can't respawn the server in
527
816
  // the gap before stopServer(). Matches THIS app's exe + the supervise action, never
528
817
  // process.pid (self-kill guard lives in supervisorPidsToKill). Idempotent; win32-only.
@@ -541,15 +830,7 @@ export function killSupervisor({ tree = true } = {}) {
541
830
  if (!isWin) return [];
542
831
  const isNpmChannel = /^node(\.exe)?$/i.test(basename(process.execPath));
543
832
  const scriptMatch = isNpmChannel ? basename(fileURLToPath(import.meta.url)) : undefined; // 'launch.mjs'
544
- // MSIX-container case: the uninstaller running INSIDE the container sees its own
545
- // process.execPath as the bind-link VIRTUAL path, but a supervisor we launched at
546
- // logon (via a Run key registered with the un-virtualized REAL path) shows the
547
- // REAL path in its command line. supervisorPidsToKill accepts an array of needles
548
- // and matches if cmd contains ANY of them — pass both so the kill works whether
549
- // the supervisor was launched at the virtual or real path. (For non-container
550
- // installs the two paths are identical → unchanged behavior.)
551
- const realExe = resolveRealInstallExe(process.execPath);
552
- const exeMatch = realExe === process.execPath ? process.execPath : [process.execPath, realExe];
833
+ const exeMatch = supervisorExeMatch(process.execPath);
553
834
  const pids = supervisorPidsToKill(enumerateProcesses(), process.pid, exeMatch, scriptMatch);
554
835
  for (const pid of pids) {
555
836
  log(`stopping supervisor (pid ${pid})…`);
@@ -601,7 +882,33 @@ export async function stopSupervisorVerified({
601
882
  // Each step is idempotent + best-effort; cmdStop() is left untouched (the update flow
602
883
  // at main.ts depends on its port-only behavior).
603
884
  export async function cmdTeardown() {
604
- killSupervisor();
885
+ const hasShell = shellInfo().installed;
886
+ // Admission first, then the supervisor: nothing (the supervisor's tray rule, a shell that was just spawned) may start a
887
+ // shell while FloLess is being taken apart. A tray started a moment before this marker reads it at start-up and exits.
888
+ let marked = false;
889
+ if (hasShell) { try { beginTeardown(); marked = true; } catch (error) { log(`could not mark the teardown (${error?.message ?? error}); any FloLess window is ended right after the supervisor`); } }
890
+ try {
891
+ // With the window installed the supervisor's children include the tray process, which also hosts any window: a tree kill
892
+ // would end it BEFORE its leave guard could run. The server is stopped by its port below, so the tree is not needed.
893
+ killSupervisor({ tree: !hasShell });
894
+ if (hasShell && !marked) killShellTree(); // no marker to hold a tray that was just started: end it now, then ask the rest to close
895
+ // The FloLess window runs from the folder being removed or replaced. Ask it to close (its leave guard runs);
896
+ // whatever is still there afterwards is ended, because the folder has to go.
897
+ if (hasShell) {
898
+ try {
899
+ const result = await closeShellGracefully({ running: shellRunning, personMs: 30_000 });
900
+ if (result !== 'closed' && result !== 'no-shell') { log('the FloLess window is still open — closing it so FloLess can be removed'); killShellTree(); }
901
+ else if (await shellRunning()) killShellTree(); // a straggler that came up after the snapshot
902
+ } catch { /* teardown must never throw */ }
903
+ }
904
+ await stopAndVerifyServer({ tree: !hasShell });
905
+ } finally {
906
+ if (hasShell) endTeardown();
907
+ }
908
+ }
909
+
910
+ async function stopAndVerifyServer({ tree = true } = {}) {
911
+ killSupervisor({ tree });
605
912
  stopServer();
606
913
  // Bounded respawn-catch: poll the port for the full ~3s window. Do NOT break on a
607
914
  // miss — a respawn may bind a few hundred ms after a transient gap, and a fresh
@@ -611,7 +918,7 @@ export async function cmdTeardown() {
611
918
  await new Promise((r) => setTimeout(r, 300));
612
919
  if (await ping()) {
613
920
  log('server respawned after kill — re-killing supervisor and stopping again');
614
- killSupervisor(); // re-kill: a freshly-spawned watchdog is what brought it back
921
+ killSupervisor({ tree }); // re-kill: a freshly-spawned watchdog is what brought it back
615
922
  stopServer();
616
923
  }
617
924
  }
@@ -877,7 +1184,7 @@ export async function cmdActionsCli(argv) {
877
1184
  }
878
1185
  }
879
1186
 
880
- const ACTIONS = { open: cmdOpen, start: cmdStart, supervise: cmdSupervise, stop: cmdStop, restart: cmdRestart, login: cmdLogin, update: cmdUpdate, uninstall: cmdUninstall };
1187
+ const ACTIONS = { open: cmdOpen, window: cmdWindow, start: cmdStart, supervise: cmdSupervise, stop: cmdStop, restart: cmdRestart, login: cmdLogin, update: cmdUpdate, uninstall: cmdUninstall };
881
1188
 
882
1189
  // Run one launcher action by name/URI. Shared by the npm bin (CLI shim below) and
883
1190
  // the packaged exe dispatcher (main.ts), so both surfaces behave identically. The
@@ -896,7 +1203,7 @@ export async function runAction(arg, flagArgv = [], selfVersion = null, selfChan
896
1203
  log(`a link cannot make FloLess do anything — type "floless-app ${cmd} …" in a terminal instead`);
897
1204
  process.exit(2);
898
1205
  }
899
- if (!action) { log(`unknown command "${cmd}" — use: open | start | supervise | stop | restart | login | update | uninstall | actions | do`); process.exit(2); }
1206
+ if (!action) { log(`unknown command "${cmd}" — use: open | window | start | supervise | stop | restart | login | update | uninstall | actions | do`); process.exit(2); }
900
1207
  await action(parseTeardownFlags(flagArgv));
901
1208
  }
902
1209
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@floless/app",
3
- "version": "0.167.0",
3
+ "version": "0.168.0",
4
4
  "type": "module",
5
5
  "description": "Thin localhost host for floless.app — serves web/ and shells the aware CLI. No engine, no LLM.",
6
6
  "bin": {
@@ -44,6 +44,7 @@
44
44
  "verify:flo-naming": "node build/verify-flo-naming.mjs",
45
45
  "verify:forward-merge": "node build/verify-forward-merge.mjs",
46
46
  "verify:no-title": "node build/verify-no-title.mjs",
47
+ "verify:electron-support": "node build/verify-electron-support.mjs",
47
48
  "verify:web-syntax": "node build/verify-web-syntax.mjs",
48
49
  "verify:no-wallclock-asserts": "node build/verify-no-wallclock-asserts.mjs",
49
50
  "verify:windows-hide": "node build/verify-windows-hide.mjs",
package/pin-home.mjs ADDED
@@ -0,0 +1,6 @@
1
+ // Side-effect import: make FLOLESS_HOME absolute before anything else in this process reads it (#3080).
2
+ // Import it FIRST in every process entry (the dispatcher, the launcher CLI, the server): ESM evaluates imports in order,
3
+ // so no later module can see the relative value. See home-env.mjs for why.
4
+ import { pinFlolessHome } from './home-env.mjs';
5
+
6
+ pinFlolessHome();
@@ -62,6 +62,20 @@ export function writePostUpdateMarker() {
62
62
  return wrote;
63
63
  }
64
64
 
65
+ /** True iff a FRESH marker exists. Unlike consumePostUpdateMarker it deletes nothing, so a caller that must NOT
66
+ * take the marker (a launch held during an update) can still tell whether the updater's own handoff has arrived. */
67
+ export function peekPostUpdateMarker() {
68
+ for (const p of [markerPath(), legacyMarkerPath()]) {
69
+ if (!p) continue;
70
+ try {
71
+ if (existsSync(p) && Date.now() - statSync(p).mtimeMs < FRESH_MS) return true;
72
+ } catch {
73
+ /* best-effort */
74
+ }
75
+ }
76
+ return false;
77
+ }
78
+
65
79
  /**
66
80
  * Best-effort one-shot read: returns true iff a FRESH marker existed (dropped within FRESH_MS).
67
81
  * Always deletes any marker it finds so it fires at most once and never lingers.