@bendyline/gezel-service 1.0.7 → 1.1.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 (237) hide show
  1. package/dist/bin/gezeld.js +6253 -3616
  2. package/dist/handboek-content/whats-new/1.26224.md +1 -0
  3. package/dist/handboek-content/whats-new/1.26226.md +1 -0
  4. package/dist/handboek-content/whats-new/1.26231.md +1 -0
  5. package/dist/handboek-content/whats-new/1.26234.md +1 -0
  6. package/dist/handboek-content/whats-new/1.26237.md +1 -0
  7. package/dist/handboek-content/whats-new/1.26244.md +2 -1
  8. package/dist/handboek-content/whats-new/1.26247.md +88 -0
  9. package/dist/handboek-content/whats-new/whats-new-index.md +1 -0
  10. package/dist/index-store/static-index-worker.js +17 -1
  11. package/dist/index.d.ts +473 -209
  12. package/dist/index.js +6251 -3614
  13. package/dist/memory/embed-worker.js +58 -2
  14. package/dist/memory/image-embed-worker.js +8 -0
  15. package/dist/providers/llama-cpp/gguf-metadata-worker.js +2 -0
  16. package/dist/providers/mlx/python/gezel_mlx_server.py +18 -18
  17. package/dist/ui/assets/AmbientDashboardCard-Cf5fi_fY.js +1 -0
  18. package/dist/ui/assets/{AudioEngineSettings-BDrNIGGm.js → AudioEngineSettings-D3L7HOHe.js} +1 -1
  19. package/dist/ui/assets/{BenchmarksView-CHyujjs8.js → BenchmarksView-B68hrLCl.js} +1 -1
  20. package/dist/ui/assets/CatalogBrowser-DEM9t7Es.js +1 -0
  21. package/dist/ui/assets/{ChannelsSettings-Be_W1mr8.js → ChannelsSettings-DtK_k0Ul.js} +1 -1
  22. package/dist/ui/assets/ChatTimelineView-CQ4Sf4Ip.js +7 -0
  23. package/dist/ui/assets/ConfirmDialog-Dt1ed4Fh.js +1 -0
  24. package/dist/ui/assets/ConnectedAppsPanel-Cl8LEkrt.js +1 -0
  25. package/dist/ui/assets/CraftbookEditor-DEQRlQ2p.js +1 -0
  26. package/dist/ui/assets/{CraftbookScriptEditorView-DXIZYZT3.js → CraftbookScriptEditorView-DhXkkIdK.js} +1 -1
  27. package/dist/ui/assets/{CraftbookTabContent-Bm7t_b37.js → CraftbookTabContent-_oIdpQTG.js} +1 -1
  28. package/dist/ui/assets/{CraftbookToolsetSetup-DTEA-3K3.js → CraftbookToolsetSetup-BKg136L1.js} +1 -1
  29. package/dist/ui/assets/{CraftbooksView-C4X99TTe.js → CraftbooksView-Dm2zH-nW.js} +2 -2
  30. package/dist/ui/assets/{DiffpackReviewView-ClcNxtmF.js → DiffpackReviewView-EFLGJnwr.js} +1 -1
  31. package/dist/ui/assets/DocumentDetail-ClDRj2N-.js +1 -0
  32. package/dist/ui/assets/DocumentsView-ny9oieg2.js +1 -0
  33. package/dist/ui/assets/DropdownMenu-S4d9-3j3.js +1 -0
  34. package/dist/ui/assets/Ds4Settings-CeWlm5Vf.js +1 -0
  35. package/dist/ui/assets/EmbeddedChat-Hjrrgpao.js +1 -0
  36. package/dist/ui/assets/{FaceRecognitionCard-D3hdc7uU.js → FaceRecognitionCard-D7ufKqjI.js} +1 -1
  37. package/dist/ui/assets/FileMapView-DRjf59RH.js +1 -0
  38. package/dist/ui/assets/{FoldersSettings-BcNzl4vT.js → FoldersSettings-DDUhaFio.js} +1 -1
  39. package/dist/ui/assets/GezelDetail-Cph6pVGb.js +1 -0
  40. package/dist/ui/assets/{GezelJsonEditor-fOvYclu9.js → GezelJsonEditor-7vDGyBib.js} +1 -1
  41. package/dist/ui/assets/{GezellenView-BTzhHrxi.js → GezellenView-DQhcO1CP.js} +1 -1
  42. package/dist/ui/assets/{GildeUpdatesCard-Bq6XEpLP.js → GildeUpdatesCard-UKKNm_U8.js} +1 -1
  43. package/dist/ui/assets/{GithubSignInChip-CnlTCG8G.js → GithubSignInChip-DjM3qZsL.js} +1 -1
  44. package/dist/ui/assets/{HandboekMediaProvider-BfQW8_Nr.js → HandboekMediaProvider-DixaXTAH.js} +1 -1
  45. package/dist/ui/assets/HandboekView-BeNQqho9.js +1 -0
  46. package/dist/ui/assets/HistoryView-E2szGNGS.js +1 -0
  47. package/dist/ui/assets/{HomeView-CB_5TJIp.css → HomeView-CNeqCFPc.css} +1 -1
  48. package/dist/ui/assets/HomeView-CkiS3DXy.js +1 -0
  49. package/dist/ui/assets/{ImageEngineSettings-BpMfQy4f.js → ImageEngineSettings-BCKT7Gvi.js} +1 -1
  50. package/dist/ui/assets/{ImageRecognitionSettings-Ct-7-Oas.js → ImageRecognitionSettings-DD6syFez.js} +1 -1
  51. package/dist/ui/assets/IncompleteDownloads-BiPaaahS.js +1 -0
  52. package/dist/ui/assets/InstallProgressRow-DyKOI4MU.js +1 -0
  53. package/dist/ui/assets/KnowledgeCatalogsCard-B132vzRa.js +1 -0
  54. package/dist/ui/assets/KnowledgeView-CtPuIlN4.js +1 -0
  55. package/dist/ui/assets/LlamaCppSettings-D6zHcu4W.js +1 -0
  56. package/dist/ui/assets/{MarkdownField-D-0Zw7gM.js → MarkdownField-CK8K3fzj.js} +1 -1
  57. package/dist/ui/assets/MemoriesTree-DzjXzIrM.js +1 -0
  58. package/dist/ui/assets/{MicrophoneSettings-BIaFxyY_.js → MicrophoneSettings-1FH83SCq.js} +1 -1
  59. package/dist/ui/assets/MlxSettings-BYxUqFnJ.js +1 -0
  60. package/dist/ui/assets/ModelPicker-DoXPfQkQ.js +1 -0
  61. package/dist/ui/assets/{NewScriptDialog-D-gkY8TS.js → NewScriptDialog-C5X-7PMt.js} +1 -1
  62. package/dist/ui/assets/NewTaskDialog-Cyqtmigv.js +2 -0
  63. package/dist/ui/assets/{OllamaSettings-oIE2Mech.js → OllamaSettings-DkjmA-sB.js} +1 -1
  64. package/dist/ui/assets/ProjectChat-YEqUME6k.js +5 -0
  65. package/dist/ui/assets/{ProjectConnectionsTab-BZqp-oKI.js → ProjectConnectionsTab-dFCJpW93.js} +1 -1
  66. package/dist/ui/assets/ProjectGitStatusBar-CjZxG54t.js +1 -0
  67. package/dist/ui/assets/{ProjectGithubView-w8suLCsA.js → ProjectGithubView-CQ4-tmPx.js} +1 -1
  68. package/dist/ui/assets/{ProjectMailTab-DGo7eyB8.js → ProjectMailTab-NaScsZJf.js} +1 -1
  69. package/dist/ui/assets/ProjectOverviewView-ChjxbQas.js +1 -0
  70. package/dist/ui/assets/{ProjectTimeline-DRe3D9qY.js → ProjectTimeline-BZpdCisR.js} +1 -1
  71. package/dist/ui/assets/ProjectsView-J77ECk6V.js +7 -0
  72. package/dist/ui/assets/{RecommendedBadge-BKiDixnB.js → RecommendedBadge-D0m68PAu.js} +1 -1
  73. package/dist/ui/assets/{RemoteServersPanel-DGyl6-Rg.js → RemoteServersPanel-BdLOoORu.js} +1 -1
  74. package/dist/ui/assets/ScriptEditorTabs-BFvIiDFZ.js +2 -0
  75. package/dist/ui/assets/ScriptEditorView-B09rm1vz.js +5 -0
  76. package/dist/ui/assets/{ScriptsView-WQc28TmQ.js → ScriptsView-BvNAJXpo.js} +1 -1
  77. package/dist/ui/assets/{SecurityComplianceSettings-DsMEA4J3.js → SecurityComplianceSettings-DzGOnptO.js} +1 -1
  78. package/dist/ui/assets/SessionSwitcher-6okzcxT7.js +1 -0
  79. package/dist/ui/assets/SettingsView-Dur4dLhW.js +3 -0
  80. package/dist/ui/assets/SquisqIntegration-6v3yNOIP.js +2 -0
  81. package/dist/ui/assets/{StorageCleanupDialog-DHqwyMZZ.js → StorageCleanupDialog-OQlomMJD.js} +1 -1
  82. package/dist/ui/assets/{StorageUsageCard-CdT6SU51.js → StorageUsageCard-f6c6qTbM.js} +1 -1
  83. package/dist/ui/assets/Tabs-jE0Z5Tzd.js +1 -0
  84. package/dist/ui/assets/TaskTabContent-0w3kAUWR.js +1 -0
  85. package/dist/ui/assets/TasksView-BVMT4BAY.js +1 -0
  86. package/dist/ui/assets/{TerminalCodeEditor-77pBm6f3.js → TerminalCodeEditor-DO7zLKy-.js} +2 -2
  87. package/dist/ui/assets/ToolsetsEditor-Bb1wD5mV.js +8 -0
  88. package/dist/ui/assets/TransformToolbarButton-BWYkEB0d.js +5 -0
  89. package/dist/ui/assets/UnrecognizedModels-HtdMZUqK.js +1 -0
  90. package/dist/ui/assets/{VideoEngineSettings-DzMeINuv.js → VideoEngineSettings-Dq8Nw_tK.js} +1 -1
  91. package/dist/ui/assets/{WorkspaceIndexPane-DU4yd4Ai.js → WorkspaceIndexPane-fpDz4MwZ.js} +1 -1
  92. package/dist/ui/assets/{api-BX5xXiFs.js → api-BPraLwsh.js} +1 -1
  93. package/dist/ui/assets/chat-thread-memory-Be48zsyG.js +1 -0
  94. package/dist/ui/assets/chunk-6ECMNUIP-DDVjPyfK.js +15 -0
  95. package/dist/ui/assets/{chunk-6N2J7C2B-B5QIrD9m.js → chunk-6N2J7C2B-CsppiLVr.js} +1 -1
  96. package/dist/ui/assets/{chunk-A6N6IN3I-DXok09eC.js → chunk-A6N6IN3I-ofeM4l8g.js} +1 -1
  97. package/dist/ui/assets/chunk-B7GEAZBI-Divd2h1k.js +1 -0
  98. package/dist/ui/assets/chunk-DXYWKZ52-BXcAlClu.js +1 -0
  99. package/dist/ui/assets/chunk-FLR2ARKC-D7wrvQgT.js +2 -0
  100. package/dist/ui/assets/chunk-IIQYS2YH-DKZhWMpn.js +1 -0
  101. package/dist/ui/assets/{chunk-ILCJ3WFD-WRukZ7R1.js → chunk-ILCJ3WFD-CLZxw4Ge.js} +3 -3
  102. package/dist/ui/assets/chunk-OBADJV7C-CDVOcmYt.js +1 -0
  103. package/dist/ui/assets/chunk-Q77KNJIN-BIDRf0aP.js +6 -0
  104. package/dist/ui/assets/chunk-S5PCVMKU-Df5XzhSE.js +6 -0
  105. package/dist/ui/assets/chunk-UBFT2CDQ-FexGDigd.js +31 -0
  106. package/dist/ui/assets/{chunk-USU6HTKB-D5FmDzJU.js → chunk-USU6HTKB-B_p-YcDp.js} +1 -1
  107. package/dist/ui/assets/chunk-VKXOZTYP-BoVvWSBR.js +5 -0
  108. package/dist/ui/assets/{chunk-6RQOV3B3-CwvKotJw.js → chunk-VPWPEMZJ-DRKoa_j0.js} +1 -1
  109. package/dist/ui/assets/{chunk-WATAOG4Y-DXg2lov5.js → chunk-WATAOG4Y-C1EXVPmG.js} +1 -1
  110. package/dist/ui/assets/{container-B7jJtK5V.js → container-Ce94efbg.js} +1 -1
  111. package/dist/ui/assets/csv-62UGQMzZ.js +1 -0
  112. package/dist/ui/assets/data-B2kHjlc5.js +1 -0
  113. package/dist/ui/assets/dist-B9-VrAP8.js +2 -0
  114. package/dist/ui/assets/dist-BaHut5iX.js +2 -0
  115. package/dist/ui/assets/dist-BqGwkOe5.js +225 -0
  116. package/dist/ui/assets/dist-ZnIgkoEi.js +4 -0
  117. package/dist/ui/assets/{dist-BHl1ZAVG.js → dist-l6uUFZMV.js} +2 -2
  118. package/dist/ui/assets/dist-pLLFUPO-.js +1 -0
  119. package/dist/ui/assets/{doc-s6H7T0IO.js → doc-Dr5K49bx.js} +28 -28
  120. package/dist/ui/assets/document-companion-BQk2kS0F.js +1 -0
  121. package/dist/ui/assets/document-import-QoM9UxJr.js +1 -0
  122. package/dist/ui/assets/docx-sXa1Rf41.js +2 -0
  123. package/dist/ui/assets/{epub-B98SgHBz.js → epub-RopMP0ec.js} +4 -4
  124. package/dist/ui/assets/{export-options-Bu-tI6og.js → export-options-f7PKjEBb.js} +1 -1
  125. package/dist/ui/assets/extract-UTAOG7LV-4WDRw1o4.js +1 -0
  126. package/dist/ui/assets/file-browser-c2tf4MIb.js +5 -0
  127. package/dist/ui/assets/html-BGVOMhkv.js +253 -0
  128. package/dist/ui/assets/icons-DWaUNQbT.js +1 -0
  129. package/dist/ui/assets/images-JLBFCDD4-6JitW0hD.js +1 -0
  130. package/dist/ui/assets/index-B8NcxqcR.css +1 -0
  131. package/dist/ui/assets/index-C0DYtvfg.js +34 -0
  132. package/dist/ui/assets/index-J8TOMdvV.js +2 -0
  133. package/dist/ui/assets/{infer-kCLH1C8z.js → infer-LEGOsu64.js} +2 -2
  134. package/dist/ui/assets/ironcalc-BAi5gOlE.js +3 -0
  135. package/dist/ui/assets/layouts-2A7QNF6Y-CVwP7noP.js +1 -0
  136. package/dist/ui/assets/{mail-link-CI6YD6k2.js → mail-link-DXkmCd5b.js} +1 -1
  137. package/dist/ui/assets/markdown-baseline-9B52XlX2.js +1 -0
  138. package/dist/ui/assets/{markdown-Bi9b5f5Y.js → markdown-ryKA_OmY.js} +1 -1
  139. package/dist/ui/assets/materialize-A34OZGEU-xNNKzytx.js +1 -0
  140. package/dist/ui/assets/model-inventory-ykSm_IT5.js +1 -0
  141. package/dist/ui/assets/{model-quantization-BDzrELN_.js → model-quantization-CLO7XLoF.js} +1 -1
  142. package/dist/ui/assets/{monaco-base-BiVSa1J-.js → monaco-base-B1H1U1Sw.js} +1 -1
  143. package/dist/ui/assets/{monaco-setup-UeltVkg_.js → monaco-setup-DjhrGQui.js} +1 -1
  144. package/dist/ui/assets/{new-project-meta-0xhggGA_.js → new-project-meta-_f9sfcRX.js} +1 -1
  145. package/dist/ui/assets/outside-in-D73N1g_b.js +3 -0
  146. package/dist/ui/assets/{pdf-DgTjy3rN.js → pdf-BOjVDlCK.js} +3 -3
  147. package/dist/ui/assets/{pending-drafts-YVW6X55O.js → pending-drafts-B11MKQ9R.js} +1 -1
  148. package/dist/ui/assets/{poppetje-Ce-02Aqi.js → poppetje-DLB8uevw.js} +2 -2
  149. package/dist/ui/assets/pptx-BuxyNxQh.js +6 -0
  150. package/dist/ui/assets/primitives-CWrGZpPI.js +41 -0
  151. package/dist/ui/assets/run-export-ChaMXrKS.js +23 -0
  152. package/dist/ui/assets/squisq-formats-aAdypXoy.js +1 -0
  153. package/dist/ui/assets/standalone-source-q_Zzd1bd.js +11 -0
  154. package/dist/ui/assets/storage-D8pE2zg0.js +1 -0
  155. package/dist/ui/assets/styles-BhnF3s2q.css +1 -0
  156. package/dist/ui/assets/styles-CKVKwqoQ.js +550 -0
  157. package/dist/ui/assets/table-fcouR4db.js +1 -0
  158. package/dist/ui/assets/{terminal-monaco-setup-DNoK2tN4.js → terminal-monaco-setup-BAzrVzeR.js} +1 -1
  159. package/dist/ui/assets/{useCompactLayout-BarJPYcv.js → useCompactLayout-Dtolvzye.js} +0 -0
  160. package/dist/ui/assets/{useCopilotAvailability-BH1nLXQI.js → useCopilotAvailability-3xZvKgTF.js} +1 -1
  161. package/dist/ui/assets/{useDiffpacks-CK8W_OD_.js → useDiffpacks-Dsnr0wtX.js} +1 -1
  162. package/dist/ui/assets/{useGitSync-DWxX5-7K.js → useGitSync-BCTptQsp.js} +1 -1
  163. package/dist/ui/assets/{useShowWorkInProgressFeatures-DwwviLRO.js → useShowWorkInProgressFeatures-BhDNuQiU.js} +1 -1
  164. package/dist/ui/assets/{useTotalRamBytes-WoN_mi-V.js → useTotalRamBytes-DIx-_pf8.js} +1 -1
  165. package/dist/ui/assets/wasm-DdxEDD2H.js +1 -0
  166. package/dist/ui/assets/wasm_bg-DW9Xt_vt.wasm +0 -0
  167. package/dist/ui/assets/xlsx-DyBGuAO1.js +4 -0
  168. package/dist/ui/index.html +19 -18
  169. package/package.json +11 -11
  170. package/dist/ui/assets/AmbientDashboardCard-C1Ee-FKZ.js +0 -1
  171. package/dist/ui/assets/CatalogBrowser-Bz8ZtxPn.js +0 -1
  172. package/dist/ui/assets/ChatTimelineView-Do9EryEH.js +0 -7
  173. package/dist/ui/assets/ConfirmDialog-BHFs6vmJ.js +0 -1
  174. package/dist/ui/assets/ConnectedAppsPanel-BtMayq0R.js +0 -1
  175. package/dist/ui/assets/CraftbookEditor-D5jTzWwF.js +0 -1
  176. package/dist/ui/assets/DocumentDetail-CPU51d04.js +0 -1
  177. package/dist/ui/assets/DocumentsView-B6OyjvJ0.js +0 -1
  178. package/dist/ui/assets/DropdownMenu-D5fCzIrh.js +0 -1
  179. package/dist/ui/assets/Ds4Settings-CrUM_KGP.js +0 -1
  180. package/dist/ui/assets/EmbeddedChat-ue9ia-WY.js +0 -1
  181. package/dist/ui/assets/FileMapView-CxvfDLGA.js +0 -1
  182. package/dist/ui/assets/GezelDetail-DHuqBK55.js +0 -1
  183. package/dist/ui/assets/HandboekView-CPnnyj29.js +0 -1
  184. package/dist/ui/assets/HistoryView-B4VAfEMe.js +0 -1
  185. package/dist/ui/assets/HomeView-ccH60J6f.js +0 -1
  186. package/dist/ui/assets/KnowledgeCatalogsCard-Bi5Rx9Iz.js +0 -1
  187. package/dist/ui/assets/KnowledgeView-DAwjwLZo.js +0 -1
  188. package/dist/ui/assets/LlamaCppSettings-Ceyk9pDP.js +0 -1
  189. package/dist/ui/assets/MemoriesTree-BKZEPJpm.js +0 -1
  190. package/dist/ui/assets/MlxSettings-CG3wfuc3.js +0 -1
  191. package/dist/ui/assets/ModelPicker-CCBVjLMS.js +0 -1
  192. package/dist/ui/assets/NewPathDialog-D4jnNBfP.js +0 -1
  193. package/dist/ui/assets/NewTaskDialog-Ox9D612Z.js +0 -2
  194. package/dist/ui/assets/ProjectChat-DMwKnkW-.js +0 -5
  195. package/dist/ui/assets/ProjectGitStatusBar-C6bkCSby.js +0 -1
  196. package/dist/ui/assets/ProjectOverviewView-NNwXd_QQ.js +0 -1
  197. package/dist/ui/assets/ProjectsView-SBPgYOq8.js +0 -7
  198. package/dist/ui/assets/ScriptEditorTabs-paocQ6dj.js +0 -2
  199. package/dist/ui/assets/ScriptEditorView-N9zSLqqi.js +0 -5
  200. package/dist/ui/assets/SessionSwitcher-C8te7YSe.js +0 -1
  201. package/dist/ui/assets/SettingsView-Brl4JQkW.js +0 -3
  202. package/dist/ui/assets/Tabs-BAY1Q79B.js +0 -1
  203. package/dist/ui/assets/TaskTabContent-CNPJ4DQj.js +0 -1
  204. package/dist/ui/assets/TasksView-DuMjFS8S.js +0 -1
  205. package/dist/ui/assets/ToolsetsEditor-BdxHnIBj.js +0 -8
  206. package/dist/ui/assets/TransformToolbarButton-CVg5nz36.js +0 -5
  207. package/dist/ui/assets/UnrecognizedModels-Cw9Ku_bW.js +0 -1
  208. package/dist/ui/assets/chat-thread-memory-CZGcwgGo.js +0 -1
  209. package/dist/ui/assets/chunk-6ECMNUIP-C1kohb1U.js +0 -15
  210. package/dist/ui/assets/chunk-AONELFLA-Cv2nS9ga.js +0 -1
  211. package/dist/ui/assets/chunk-IIQYS2YH-Dxg6MAfT.js +0 -1
  212. package/dist/ui/assets/chunk-MIKKUKOD-XIkmalSN.js +0 -31
  213. package/dist/ui/assets/chunk-NNJLSQPW-DJA6camf.js +0 -5
  214. package/dist/ui/assets/chunk-S5PCVMKU-DbCZ5AUH.js +0 -6
  215. package/dist/ui/assets/csv-xmd1_Aqd.js +0 -4
  216. package/dist/ui/assets/dist-BPx-FyRH.js +0 -222
  217. package/dist/ui/assets/dist-Bvo52IGx.js +0 -1
  218. package/dist/ui/assets/dist-D5aoNQwk.js +0 -2
  219. package/dist/ui/assets/docx-Cj4A9MhC.js +0 -2
  220. package/dist/ui/assets/extract-UTAOG7LV-C4b7ycaL.js +0 -1
  221. package/dist/ui/assets/file-browser-80qWoVju.js +0 -5
  222. package/dist/ui/assets/html-C9TlzI57.js +0 -253
  223. package/dist/ui/assets/icons-C9dD-bDi.js +0 -1
  224. package/dist/ui/assets/images-ESPQKVTW-D7SgdVJ_.js +0 -1
  225. package/dist/ui/assets/index-D1m4Wx8V.css +0 -1
  226. package/dist/ui/assets/index-DXWR4qW1.js +0 -34
  227. package/dist/ui/assets/layouts-2A7QNF6Y-De2t-YXl.js +0 -1
  228. package/dist/ui/assets/markdown-baseline-HMqF2ChK.js +0 -1
  229. package/dist/ui/assets/outside-in-BFVUUcLa.js +0 -3
  230. package/dist/ui/assets/pptx-6ChgUEf4.js +0 -6
  231. package/dist/ui/assets/primitives-DEsn1shf.js +0 -41
  232. package/dist/ui/assets/run-export-BrYhHj1O.js +0 -23
  233. package/dist/ui/assets/standalone-source-D6mbpa3h.js +0 -11
  234. package/dist/ui/assets/storage-fn4FCEVK.js +0 -1
  235. package/dist/ui/assets/styles-C0EoNJbk.css +0 -1
  236. package/dist/ui/assets/styles-CKr_yrbn.js +0 -541
  237. package/dist/ui/assets/xlsx-DH7sTb3W.js +0 -4
@@ -1,7 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dist-D5aoNQwk.js","assets/rolldown-runtime-aKtaBQYM.js","assets/dist-BPx-FyRH.js"])))=>i.map(i=>d[i]);
2
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{n as t,t as n}from"./jsx-runtime-CEpd2cAX.js";import{_ as r,g as i,o as a,v as o}from"./primitives-DEsn1shf.js";import{$t as s,H as c,L as l,Mt as u,Qt as d,R as f,V as p,et as m,gt as h,jt as g,tt as _}from"./dist-BPx-FyRH.js";import{a as v}from"./dist-D5aoNQwk.js";import{t as y}from"./api-BX5xXiFs.js";import{n as ee,t as te}from"./relative-time-B2kBaekd.js";import{t as ne}from"./preload-helper-Czpn1I53.js";import{c as b,i as re,l as x,n as S,o as C,s as ie}from"./styles-CKr_yrbn.js";import{Bt as w,C as ae,E as oe,Lt as se,S as ce,T as le,_t as ue,b as de,bt as fe,d as pe,ft as me,gt as he,ht as ge,i as _e,lt as ve,vt as ye,w as be,x as xe,yt as Se}from"./index-DXWR4qW1.js";import{n as T,t as Ce}from"./microphone-input-5gqW_NKf.js";import{r as we,t as E}from"./composer-prefill-CbG_i1Rx.js";var D=e(t(),1),O=n();function k(e){return e.replace(/\.[^.]+$/,``).replace(/[-_]/g,` `)}function Te(e){return e.replace(/([\\\[\]])/g,`\\$1`)}function Ee(){return(0,O.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,fill:`none`,"aria-hidden":`true`,children:[(0,O.jsx)(`rect`,{x:`2`,y:`2.5`,width:`12`,height:`11`,rx:`1.5`,stroke:`currentColor`,strokeWidth:`1.35`}),(0,O.jsx)(`circle`,{cx:`5.25`,cy:`5.75`,r:`1.1`,stroke:`currentColor`,strokeWidth:`1.2`}),(0,O.jsx)(`path`,{d:`m3.5 12 3.1-3.25 2.05 1.9 1.55-1.55 2.3 2.9`,stroke:`currentColor`,strokeWidth:`1.35`,strokeLinecap:`round`,strokeLinejoin:`round`})]})}function A(){return(0,O.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,fill:`none`,"aria-hidden":`true`,children:(0,O.jsx)(`path`,{d:`m5.25 8.7 4.2-4.2a2.1 2.1 0 0 1 2.97 2.97l-5.1 5.1a3.2 3.2 0 0 1-4.53-4.52l5-5`,stroke:`currentColor`,strokeWidth:`1.4`,strokeLinecap:`round`,strokeLinejoin:`round`})})}function De({mediaProvider:e,onError:t}){let{bumpMediaRevision:n,insertAtCursor:r}=re(),i=(0,D.useRef)(null),a=(0,D.useRef)(null),[o,s]=(0,D.useState)(null),c=(0,D.useCallback)(async(i,a)=>{s(a),t(null);try{let t=i.type||`application/octet-stream`,o=await e.addMedia(i.name,await i.arrayBuffer(),t);n();let s=Te(k(i.name));r(a===`image`?`![${s}](${o})`:`[${s}](${o})`)}catch(e){t(e instanceof Error?e.message:`Could not attach that file.`)}finally{s(null)}},[n,r,e,t]),l=(0,D.useCallback)((e,t)=>{let n=e.target.files?.[0];e.target.value=``,n&&c(n,t)},[c]);return(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`div`,{className:`chat-composer-attachment-actions`,children:[(0,O.jsx)(`input`,{ref:i,type:`file`,accept:`image/*`,hidden:!0,onChange:e=>l(e,`image`)}),(0,O.jsx)(`input`,{ref:a,type:`file`,hidden:!0,onChange:e=>l(e,`file`)}),(0,O.jsx)(`button`,{type:`button`,className:`squisq-toolbar-button`,onClick:()=>i.current?.click(),disabled:o!==null,"aria-label":o===`image`?`Inserting image…`:`Insert image`,"aria-busy":o===`image`,title:`Insert image`,"data-tooltip":`Insert image`,children:(0,O.jsx)(Ee,{})}),(0,O.jsx)(`button`,{type:`button`,className:`squisq-toolbar-button`,onClick:()=>a.current?.click(),disabled:o!==null,"aria-label":o===`file`?`Attaching file…`:`Attach file`,"aria-busy":o===`file`,title:`Attach file`,"data-tooltip":`Attach file`,children:(0,O.jsx)(A,{})})]}),(0,O.jsx)(`span`,{className:`chat-composer-toolbar-spacer`,"aria-hidden":`true`})]})}var j=50;function Oe(e){return typeof AudioContext>`u`?null:new M(e)}var M=class{stream;context=null;source=null;analyser=null;timer=null;samples=null;noiseFloor=.004;speaking=!1;constructor(e){this.stream=e}start(e){if(this.timer!==null)return;let t=new AudioContext;this.context=t;try{let e=t.createMediaStreamSource(this.stream),n=t.createAnalyser();n.fftSize=1024,n.smoothingTimeConstant=.15,e.connect(n),this.source=e,this.analyser=n,this.samples=new Float32Array(n.fftSize),t.resume().catch(()=>void 0)}catch(e){throw this.stop(),e}this.timer=setInterval(()=>{if(!this.analyser||!this.samples)return;this.analyser.getFloatTimeDomainData(this.samples);let t=N(this.samples),n=Math.max(.012,this.noiseFloor*2.8),r=Math.max(.008,this.noiseFloor*1.8);this.speaking=t>=(this.speaking?r:n),this.speaking||(this.noiseFloor=Math.min(.03,this.noiseFloor*.95+t*.05)),e(this.speaking,t)},j)}stop(){this.timer!==null&&(clearInterval(this.timer),this.timer=null),this.source?.disconnect(),this.analyser?.disconnect(),this.source=null,this.analyser=null,this.samples=null;let e=this.context;this.context=null,e&&e.close().catch(()=>void 0)}};function N(e){if(e.length===0)return 0;let t=0;for(let n of e)t+=n*n;return Math.sqrt(t/e.length)}var P=2500,ke=350,F=650,Ae=1e4,je=1e3,Me=class{stream;mimeType;segmentMs;speechPauseMs;minSegmentMs;longPauseMs;transcribe;onTranscript;onError;onLongPause;onAudioLevel;abortController=new AbortController;activityMonitor;activityMonitorStarted=!1;recorder=null;chunks=[];segmentTimer=null;transcriptionQueue=Promise.resolve();stopPromise=null;resolveStop=null;finalSegmentRequested=!1;segmentStartedAt=0;segmentHasSpeech=!1;currentlySpeaking=!1;lastSpeechAt=null;confirmedSilenceMs=0;recognitionPrompt=``;hasTranscript=!1;longPauseNotified=!1;disposed=!1;constructor(e){this.stream=e.stream,this.mimeType=e.mimeType??``,this.segmentMs=e.segmentMs??P,this.speechPauseMs=e.speechPauseMs??ke,this.minSegmentMs=e.minSegmentMs??F,this.longPauseMs=e.longPauseMs??Ae,this.activityMonitor=e.activityMonitor===void 0?Oe(e.stream):e.activityMonitor,this.transcribe=e.transcribe,this.onTranscript=e.onTranscript,this.onError=e.onError,this.onLongPause=e.onLongPause,this.onAudioLevel=e.onAudioLevel}start(){this.disposed||this.recorder||(this.startSegment(),this.startActivityMonitor())}stop(){if(this.stopPromise)return this.stopPromise;this.finalSegmentRequested=!0,this.stopActivityMonitor(),this.clearSegmentTimer(),this.stopPromise=new Promise(e=>{this.resolveStop=e});let e=this.recorder;return e?.state===`recording`?e.stop():e||this.finish(),this.stopPromise}cancel(){if(this.disposed)return;this.disposed=!0,this.abortController.abort(),this.stopActivityMonitor(),this.clearSegmentTimer();let e=this.recorder;if(this.recorder=null,e&&(e.ondataavailable=null,e.onstop=null,e.onerror=null,e.state!==`inactive`))try{e.stop()}catch{}this.releaseStream(),this.resolveStop?.(),this.resolveStop=null}startSegment(){if(this.disposed||this.finalSegmentRequested)return;let e=this.mimeType?{mimeType:this.mimeType}:void 0,t=new MediaRecorder(this.stream,e);this.recorder=t,this.chunks=[],this.segmentStartedAt=Date.now(),this.segmentHasSpeech=this.currentlySpeaking,t.ondataavailable=e=>{!this.disposed&&e.data.size>0&&this.chunks.push(e.data)},t.onerror=e=>{let t=e.error;this.onError(t??Error(`Microphone recording failed.`)),this.finalSegmentRequested=!0,this.clearSegmentTimer()},t.onstop=()=>{if(this.disposed||this.recorder!==t)return;this.recorder=null;let e=t.mimeType||this.mimeType||`audio/webm`,n=new Blob(this.chunks,{type:e}),r=Math.max(0,Date.now()-this.segmentStartedAt);this.chunks=[],this.finalSegmentRequested||this.startSegment(),n.size>0&&this.enqueueTranscription(n,e,r),this.finalSegmentRequested&&this.finish()},t.start(),this.segmentTimer=setTimeout(()=>{this.segmentTimer=null,!this.disposed&&!this.finalSegmentRequested&&t.state===`recording`&&t.stop()},this.segmentMs)}startActivityMonitor(){if(!(!this.activityMonitor||this.activityMonitorStarted))try{this.activityMonitor.start((e,t)=>{this.onAudioLevel?.(t),this.onSpeechActivity(e)}),this.activityMonitorStarted=!0}catch{this.activityMonitor.stop(),this.activityMonitor=null}}stopActivityMonitor(){this.activityMonitor?.stop()}onSpeechActivity(e){if(this.disposed||this.finalSegmentRequested)return;let t=Date.now();if(this.currentlySpeaking=e,e){this.segmentHasSpeech=!0,this.lastSpeechAt=t,this.longPauseNotified=!1;return}if(this.lastSpeechAt===null)return;let n=t-this.lastSpeechAt;this.segmentHasSpeech&&t-this.segmentStartedAt>=this.minSegmentMs&&n>=this.speechPauseMs&&this.flushCurrentSegment()}flushCurrentSegment(){let e=this.recorder;!e||e.state!==`recording`||(this.clearSegmentTimer(),e.stop())}enqueueTranscription(e,t,n){this.transcriptionQueue=this.transcriptionQueue.then(async()=>{if(!this.disposed)try{let r=Ne(await this.transcribe(e,t,this.abortController.signal,this.recognitionPrompt));if(this.disposed)return;if(r){this.confirmedSilenceMs=0,this.hasTranscript=!0,this.longPauseNotified=!1,this.recognitionPrompt=Pe(this.recognitionPrompt,r),this.onTranscript(r);return}this.confirmedSilenceMs+=n,!this.longPauseNotified&&this.onLongPause&&this.confirmedSilenceMs>=this.longPauseMs&&(this.longPauseNotified=!0,this.onLongPause(this.hasTranscript))}catch(e){if(this.disposed||this.abortController.signal.aborted)return;this.onError(e instanceof Error?e:Error(String(e)))}})}async finish(){this.clearSegmentTimer(),this.stopActivityMonitor(),this.releaseStream(),await this.transcriptionQueue,!this.disposed&&(this.disposed=!0,this.resolveStop?.(),this.resolveStop=null)}clearSegmentTimer(){this.segmentTimer!==null&&(clearTimeout(this.segmentTimer),this.segmentTimer=null)}releaseStream(){for(let e of this.stream.getTracks())e.stop()}};function Ne(e){let t=e.trim();return/^\[\s*BLANK_AUDIO\s*\]$/i.test(t)?``:t}function Pe(e,t){let n=`${e.trim()} ${t.trim()}`.trim();if(n.length<=je)return n;let r=n.slice(-1e3),i=r.search(/\s/);return(i>=0?r.slice(i+1):r).trim()}async function I(e){if(/^audio\/(?:wav|wave|x-wav)(?:;|$)/i.test(e.type))return e;if(typeof AudioContext>`u`)throw Error(`This recording could not be prepared for speech-to-text.`);let t=new AudioContext;try{let n=await t.decodeAudioData(await e.arrayBuffer()),r=Fe(Array.from({length:n.numberOfChannels},(e,t)=>n.getChannelData(t)),n.sampleRate);return new Blob([r.buffer],{type:`audio/wav`})}catch(e){let t=e instanceof Error&&e.message?` (${e.message})`:``;throw Error(`This recording could not be prepared for speech-to-text${t}`)}finally{await t.close().catch(()=>void 0)}}function Fe(e,t){let n=e[0]?.length??0;if(e.length===0||n===0)throw Error(`The microphone recording was empty.`);if(!Number.isFinite(t)||t<=0)throw Error(`The microphone recording has an invalid sample rate.`);if(e.some(e=>e.length!==n))throw Error(`The microphone recording channels have different lengths.`);let r=n*2,i=new ArrayBuffer(44+r),a=new DataView(i);Ie(a,0,`RIFF`),a.setUint32(4,36+r,!0),Ie(a,8,`WAVE`),Ie(a,12,`fmt `),a.setUint32(16,16,!0),a.setUint16(20,1,!0),a.setUint16(22,1,!0),a.setUint32(24,Math.round(t),!0),a.setUint32(28,Math.round(t)*2,!0),a.setUint16(32,2,!0),a.setUint16(34,16,!0),Ie(a,36,`data`),a.setUint32(40,r,!0);for(let t=0;t<n;t+=1){let n=0;for(let r of e)n+=r[t]??0;n=Math.max(-1,Math.min(1,n/e.length));let r=Math.round(n<0?n*32768:n*32767);a.setInt16(44+t*2,r,!0)}return new Uint8Array(i)}function Ie(e,t,n){for(let r=0;r<n.length;r+=1)e.setUint8(t+r,n.charCodeAt(r))}var Le=12;function Re({projectId:e,disabled:t=!1,onTranscript:n,onError:r}){let[i,a]=(0,D.useState)(`idle`),[o,s]=(0,D.useState)(()=>ze()),c=(0,D.useRef)(null),l=(0,D.useRef)(!0),u=(0,D.useRef)(!1),d=(0,D.useRef)(0),f=(0,D.useRef)(e),p=x()&&b();(0,D.useEffect)(()=>(l.current=!0,()=>{l.current=!1,d.current+=1,c.current?.cancel(),c.current=null}),[]),(0,D.useEffect)(()=>{f.current!==e&&(f.current=e,d.current+=1,c.current?.cancel(),c.current=null,u.current=!1,a(`idle`),s(ze()))},[e]);let m=(0,D.useCallback)(async()=>{let e=c.current;if(e){a(`transcribing`);try{await e.stop()}finally{c.current===e&&(c.current=null),l.current&&a(`idle`)}}},[]),h=(0,D.useCallback)(async()=>{if(!p||t||u.current||c.current)return;u.current=!0;let i=d.current;a(`requesting`),s(ze()),r(null);let o=null;try{let t=await y.getConfig().catch(()=>void 0),u={...t?.microphoneDeviceId?{deviceId:t.microphoneDeviceId}:{},...t?.microphoneDeviceLabel?{label:t.microphoneDeviceLabel}:{}},f=T(u.deviceId||u.label?await Ce().catch(()=>[]):[],u),p=f?.deviceId??u.deviceId;if(o=await C({echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0,...p?{deviceId:{exact:p}}:{}}),!l.current||i!==d.current){for(let e of o.getTracks())e.stop();return}let h=o.getAudioTracks?.()[0]?.label?.trim()||f?.label||u.label,g=ie(`audio`),_=new Me({stream:o,...g.mimeType?{mimeType:g.mimeType}:{},transcribe:async(t,n,i,a)=>{let o=await I(t),s=Ne((await y.transcribeAudio({audio:{data:await L(o),mimeType:o.type||n},projectId:e,signal:i,...a?{prompt:a}:{}})).text);return s?(r(null),s):``},onTranscript:n,onAudioLevel:e=>{if(!l.current||i!==d.current)return;let t=Be(e);s(e=>[...e.slice(1),t])},onLongPause:e=>{e||r(`No speech detected${h?` from ${h}`:``}. Choose the microphone in Settings → Device Integration if this isn't the expected input.`),m()},onError:e=>{_.cancel(),c.current===_&&(c.current=null,l.current&&i===d.current&&(a(`idle`),r(R(e))))}});c.current=_,_.start(),o=null,a(`recording`)}catch(e){if(o)for(let e of o.getTracks())e.stop();l.current&&i===d.current&&(a(`idle`),r(R(e)))}finally{i===d.current&&(u.current=!1)}},[t,r,n,e,m,p]),g=i===`recording`,_=!p;return(0,O.jsxs)(`button`,{type:`button`,className:`chat-narrate-btn${g?` chat-narrate-btn-recording`:``}`,"data-testid":`chat-narrate`,onClick:g?()=>void m():()=>void h(),disabled:i===`requesting`||i===`transcribing`||i===`idle`&&(t||_),"aria-label":i===`requesting`?`Starting microphone…`:g?`Stop narrating`:i===`transcribing`?`Finishing transcription…`:`Narrate prompt`,"aria-pressed":g,"aria-busy":i===`requesting`||i===`transcribing`,title:_?`Voice input is unavailable in this browser`:g?`Listening — short pauses add speech; click to finish now`:i===`transcribing`?`Adding the remaining speech to this prompt`:`Narrate this prompt with your microphone`,children:[(0,O.jsx)(He,{}),g&&(0,O.jsx)(Ve,{levels:o}),g&&(0,O.jsx)(`span`,{className:`chat-narrate-live-dot`,"aria-hidden":`true`})]})}function ze(){return Array.from({length:Le},()=>0)}function Be(e){return Math.min(1,Math.max(0,e*14))}function Ve({levels:e}){return(0,O.jsx)(`span`,{className:`chat-narrate-waveform`,"data-testid":`microphone-waveform`,"aria-hidden":`true`,children:e.map((e,t)=>(0,O.jsx)(`span`,{className:`chat-narrate-waveform-bar`,style:{height:`${2+e*14}px`}},t))})}async function L(e){let t=new Uint8Array(await e.arrayBuffer()),n=``,r=32768;for(let e=0;e<t.length;e+=r)n+=String.fromCharCode(...t.subarray(e,e+r));return btoa(n)}function R(e){let t=e instanceof Error?e:Error(String(e)),n=z(t)??t.message;return t.name===`NotAllowedError`||/permission|not allowed|denied/i.test(n)?`Microphone access was not granted. Allow it in your system settings, then try again.`:t.name===`OverconstrainedError`||/constraint|selected microphone/i.test(n)?`The selected microphone is unavailable. Choose another in Settings → Device Integration.`:t.name===`NotFoundError`||/requested device not found|no microphone/i.test(n)?`No microphone is available.`:/speech_to_text_not_ready|no stt model|download one from settings|speech-to-text model/i.test(n)?`Speech-to-text is not ready. Download a model in Settings → Audio, then try again.`:/speech_to_text_failed/i.test(n)?`Speech-to-text could not transcribe this recording. Check Settings → Audio, then try again.`:`Could not narrate this prompt: ${n}`}function z(e){let t=e.details;if(t&&typeof t==`object`&&`error`in t){let e=t.error;if(typeof e==`string`&&e.trim())return e.trim()}return typeof t==`string`&&t.trim()?t.trim():null}function He(){return(0,O.jsxs)(`svg`,{viewBox:`0 0 16 16`,fill:`none`,"aria-hidden":`true`,focusable:`false`,children:[(0,O.jsx)(`rect`,{x:`5.25`,y:`1.5`,width:`5.5`,height:`8`,rx:`2.75`,stroke:`currentColor`}),(0,O.jsx)(`path`,{d:`M3.5 7.5a4.5 4.5 0 0 0 9 0M8 12v2.5M5.75 14.5h4.5`,stroke:`currentColor`})]})}function B({gezels:e,primaryGezelId:t,additionalRecipientIds:n,roleBasedNameOnlyMode:a,onSelectPrimary:s,onAddRecipient:c}){let[l,u]=(0,D.useState)(!1),[d,p]=(0,D.useState)(``),m=(0,D.useMemo)(()=>{let t=new Set;return e.filter(e=>t.has(e.id)?!1:(t.add(e.id),!0)).map(e=>({gezel:e,rendered:f({name:e.name,roleBasedName:e.roleBasedName},a)}))},[e,a]),h=m.length>8,g=d.trim().toLowerCase(),_=h&&g?m.filter(({gezel:e,rendered:t})=>t.toLowerCase().includes(g)||(e.role??``).toLowerCase().includes(g)):m,v=new Set(n);return(0,O.jsxs)(r,{open:l,onOpenChange:e=>{u(e),e||p(``)},children:[(0,O.jsx)(o,{asChild:!0,children:(0,O.jsx)(`button`,{type:`button`,className:`chat-composer-recipient-trigger`,"aria-label":`Choose recipients`,title:`Add or change recipients`,children:(0,O.jsx)(`span`,{className:`chat-recipient-plus-glyph`,"aria-hidden":`true`,children:`+`})})}),(0,O.jsxs)(i,{className:`chat-recipient-popover`,align:`end`,side:`top`,"aria-label":`Choose a gezel`,children:[(0,O.jsx)(`span`,{className:`chat-recipient-popover-label`,children:`Choose a gezel`}),h&&(0,O.jsx)(`input`,{className:`chat-recipient-search`,type:`search`,value:d,placeholder:`Search by name or role`,"aria-label":`Search gezels`,onChange:e=>p(e.target.value)}),(0,O.jsxs)(`div`,{className:`chat-recipient-list`,children:[_.map(({gezel:e,rendered:n})=>{let r=e.id===t,i=v.has(e.id);return(0,O.jsxs)(`div`,{className:`chat-recipient-option${r?` chat-recipient-option-primary`:``}`,children:[(0,O.jsxs)(`button`,{type:`button`,className:`chat-recipient-select`,"aria-current":r?`true`:void 0,"aria-label":`Talk to ${n}`,onClick:()=>{s(e.id),u(!1)},children:[(0,O.jsx)(se,{svg:e.icon??null,poppetje:e.poppetje,iconOverride:e.iconOverride,name:n,size:26}),(0,O.jsxs)(`span`,{className:`chat-recipient-option-text`,children:[(0,O.jsx)(`span`,{className:`chat-recipient-option-name`,children:n}),e.role&&(0,O.jsx)(`span`,{className:`chat-recipient-option-role`,children:e.role})]})]}),r||i?(0,O.jsx)(`span`,{className:`chat-recipient-option-state`,children:r?`To`:`Added`}):(0,O.jsx)(`button`,{type:`button`,className:`chat-recipient-add`,"aria-label":`Add ${n} to recipients`,title:`Add ${n}`,onClick:()=>c(e.id),children:(0,O.jsx)(`span`,{className:`chat-recipient-plus-glyph`,"aria-hidden":`true`,children:`+`})})]},e.id)}),_.length===0&&(0,O.jsx)(`p`,{className:`muted small chat-recipient-empty`,children:`No matches.`})]})]})]})}var V=new Map,Ue=`data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=`;function H(e){let t=e.trim();return/^(?:data|blob):/i.test(t)?!1:t.startsWith(`//`)||/^[a-z][a-z0-9+.-]*:/i.test(t)}function We(e,t){let n=`${e}:${t}`,r=V.get(n);return r||(r=Ge({projectId:e,legacySessionId:t}),V.set(n,r)),r}function Ge(e){let t=new Map,n=new Map,r=async(e,t)=>{if(e instanceof Blob)return e;let n=e instanceof Uint8Array?e:new Uint8Array(e),r=new Uint8Array(n.byteLength);return r.set(n),new Blob([r.buffer],{type:t})},i=e=>{let t=/^attachments\/([^/]+)$/.exec(e);if(t)return{scope:`attachments`,filename:t[1]};let n=/^images\/([^/]+)$/.exec(e);if(n)return{scope:`images`,filename:n[1]};let r=/^artifacts\/(.+)$/.exec(e);return r?{scope:`artifact`,path:r[1]}:/^generated\/[^/].*\.(png|jpe?g|gif|webp|svg)$/i.test(e)?{scope:`artifact`,path:e}:null};return{async addMedia(n,i,a){let o=await r(i,a),s=await y.uploadProjectAttachment(e.projectId,o,a,n);return t.set(s.relativePath,URL.createObjectURL(o)),s.relativePath},async resolveUrl(r){if(H(r))return Ue;if(/^(?:data|blob):/i.test(r.trim()))return r;let a=t.get(r);if(a)return a;let o=n.get(r);if(o)return o;let s=i(r);if(!s)return r;let c=(async()=>{try{let n;if(s.scope===`attachments`)n=await y.fetchProjectAttachment(e.projectId,s.filename);else if(s.scope===`artifact`)n=await y.fetchProjectArtifactBlob(e.projectId,s.path);else{if(!e.legacySessionId)return r;n=await y.fetchSessionImage(e.projectId,e.legacySessionId,s.filename)}let i=URL.createObjectURL(n);return t.set(r,i),i}finally{n.delete(r)}})();return n.set(r,c),c},async listMedia(){return(await y.listProjectAttachments(e.projectId)).attachments.map(e=>({name:`attachments/${e.filename}`,mimeType:e.mimeType,size:e.size}))},async removeMedia(n){let r=i(n);if(!r)return;r.scope===`attachments`?await y.deleteProjectAttachment(e.projectId,r.filename):r.scope===`images`&&e.legacySessionId&&await y.deleteSessionImage(e.projectId,e.legacySessionId,r.filename);let a=t.get(n);a&&(URL.revokeObjectURL(a),t.delete(n))},dispose(){for(let e of t.values())URL.revokeObjectURL(e);t.clear(),n.clear()}}}function U(e){if(e.includes(`
3
- `)||e.includes(`\r`))return null;let t=e.trim().match(/^\/open(?:[ \t]+(.*))?$/i);return t?(t[1]??``).trim():null}function Ke(e,t,n=8){let r=W(e),i=[`workspace`,`artifacts`].map(e=>({key:`folder:${e}`,label:e,description:`Open the project ${e} folder`,target:{type:`folder`,folder:e}})).filter(e=>G(r,e.label)),a=new Set,o=[];for(let e of t){let t=`${e.projectId??``}:${e.kind}:${W(e.path)}`;if(!a.has(t)&&(a.add(t),!(!G(r,e.path)&&!G(r,K(e.path)))&&(o.push({key:`reference:${e.key}`,label:e.path,description:`Open recent ${e.kind}`,target:{type:`reference`,reference:e}}),o.length>=n)))break}return[...i,...o]}function qe(e,t){let n=W(e);if(n===`workspace`||n===`artifacts`)return{type:`folder`,folder:n};if(!n)return null;let r=t.find(e=>W(e.path)===n);if(r)return{type:`reference`,reference:r};let i=t.filter(e=>W(K(e.path))===n);return i.length===1?{type:`reference`,reference:i[0]}:null}function W(e){return e.trim().replaceAll(`\\`,`/`).toLowerCase()}function G(e,t){return!e||W(t).includes(e)}function K(e){let t=e.replaceAll(`\\`,`/`);return t.slice(t.lastIndexOf(`/`)+1)}var q=new Set;function Je(e){for(let t of q)t(e)}function Ye(e){return q.add(e),()=>{q.delete(e)}}var Xe=64,J=new Map;function Ze(e){return[e.scope??`chat`,e.projectId,e.gezelId,e.taskRef??``,e.craftbookRef??``].join(`|`)}function Qe(e){return J.get(e)??``}function $e(e,t){if(!t.trim()){J.delete(e);return}for(J.delete(e),J.set(e,t);J.size>Xe;){let e=J.keys().next();if(e.done)break;J.delete(e.value)}}function et(e){J.delete(e)}function tt(e,t,n){e!==t&&(J.delete(e),$e(t,n))}function nt(){let e=window.__GEZEL__?.platform??(typeof navigator>`u`?``:navigator.platform||navigator.userAgent);return e===`darwin`||/Mac/i.test(e)?`⌘⏎`:`Ctrl+Enter`}var rt={showFilesWhenNotEmpty:!0};function it({projectId:e,disabled:t,onAppendTranscript:n,onError:r}){let{replaceAll:i}=re();return(0,O.jsx)(Re,{projectId:e,disabled:t,onTranscript:(0,D.useCallback)(e=>{let t=n(e);t!==null&&i(t)},[n,i]),onError:r})}function at({gezelId:e,gezelName:t,gezelRoleBasedName:n,gezelRole:r,gezelIcon:i,gezelPoppetje:o,gezelIconOverride:s,focusRequestKey:l,recipientGezels:d,onPrimaryRecipientChange:m,projectId:h,sessionId:g,onSessionCreated:_,onToolActivity:ee,recentReferences:te=[],onOpenReference:ne,craftbookRef:b,onTurnStateChange:re,placeholder:x,taskRef:C,stepId:ie,belowAddressLine:w,addressLineTrailing:ae,onPivotToMention:oe,passiveCcGezelIds:ce,onPassiveCcConsumed:le,onTerminalEscape:ue,draftScope:fe}){let pe=(0,D.useRef)(null);(0,D.useEffect)(()=>{if(!l)return;let e=window.requestAnimationFrame(()=>{pe.current?.querySelector(`.squisq-wysiwyg-editor`)?.focus({preventScroll:!0})});return()=>window.cancelAnimationFrame(e)},[l]);let he=me(),ge=de(),_e=f({name:t,roleBasedName:n},ge),[ve,ye]=(0,D.useState)(!1),[be,xe]=(0,D.useState)(!1),[Se,T]=(0,D.useState)(null),Ce=(0,D.useRef)(!1),[k,Te]=(0,D.useState)(!1),[Ee,A]=(0,D.useState)(null),[j,Oe]=(0,D.useState)(null),M=(0,D.useMemo)(()=>Ze({...fe?{scope:fe}:{},projectId:h,gezelId:e,...C?{taskRef:C}:{},...b?{craftbookRef:b}:{}}),[b,fe,e,h,C]),N=(0,D.useRef)(M),P=(0,D.useRef)(Qe(M));(0,D.useEffect)(()=>{let e=N.current;e!==M&&(N.current=M,tt(e,M,P.current))},[M]);let ke=(0,D.useRef)(0),F=(0,D.useRef)(P.current.length),[Ae,je]=(0,D.useState)(()=>P.current.trim().length>0),[Me,Ne]=(0,D.useState)(()=>U(P.current)),[Pe,I]=(0,D.useState)(0),Fe=(0,D.useCallback)(()=>{let e=we(h);if(!e)return;let t=P.current.trim(),n=t?`${t}\n\n${e}`:e;P.current=n,$e(N.current,n),ke.current+=1,F.current=n.length,je(n.trim().length>0),Ne(U(n)),I(e=>e+1)},[h]);(0,D.useEffect)(()=>{Fe();let e=e=>{e.detail?.projectId===h&&Fe()};return window.addEventListener(E,e),()=>window.removeEventListener(E,e)},[Fe,h]);let[Ie,Le]=(0,D.useState)(()=>p(P.current)),[Re,ze]=(0,D.useState)([]);(0,D.useEffect)(()=>{ze([])},[e,h]);let Be=(0,D.useMemo)(()=>{let e=new Map((d??[]).map(e=>[e.id,e]));return Re.flatMap(t=>{let n=e.get(t);return n?[n]:[]})},[Re,d]),[Ve,L]=(0,D.useState)(`proactive`);(0,D.useEffect)(()=>{y.getConfig().then(e=>L(e.aiEngagementMode??`proactive`)).catch(()=>{});let e=e=>{let t=e.detail;t?.aiEngagementMode&&L(t.aiEngagementMode)};return window.addEventListener(`gezel:config-updated`,e),()=>window.removeEventListener(`gezel:config-updated`,e)},[]);let R=Ve===`off`,z=(0,D.useRef)(null),He=(0,D.useRef)(0),V=(0,D.useRef)(g??null),[Ue,H]=(0,D.useState)(g??null);(0,D.useEffect)(()=>{V.current=g??null,H(g??null)},[g]);let We=(0,D.useCallback)(async()=>{if(V.current)return V.current;try{if(C){let t=u(C);if(t){let n=(await y.listTaskSessions(t.projectId,t.num)).sessions.find(t=>!t.archived&&t.gezelId===e);if(n)return V.current=n.id,H(n.id),_?.(n.id),n.id}}else{let t=(await y.listChatSessions({gezelId:e,projectId:h})).sessions.find(e=>!e.archived&&!e.taskRef);if(t)return V.current=t.id,H(t.id),_?.(t.id),t.id}}catch{}let t={gezelId:e,projectId:h,...C?{taskRef:C}:{},...ie?{stepId:ie}:{},...b?{craftbookRef:b}:{}},n=await y.createChatSession(t);return V.current=n.id,H(n.id),_?.(n.id),n.id},[e,h,C,ie,b,_]),W=(0,D.useMemo)(()=>Ge({projectId:h}),[h]);(0,D.useEffect)(()=>()=>{z.current?.controller.abort(),z.current=null,W.dispose()},[W]);let G=(0,D.useCallback)((e,t={})=>{let n=z.current;!n||n.id!==e||(z.current=null,t.abort&&n.controller.abort(),ye(!1),A(null),t.serverIdle&&xe(!1))},[]),K=(0,D.useCallback)(async(e,t)=>{let n=z.current,r=n?.sessionId===e&&n.accepted?n.id:null,i=await y.getChatSessionInflight(e);if(t&&!t()||V.current!==e||r!==null&&z.current?.id!==r)return;let a=i.inflight!==null;xe(a),!a&&r!==null&&G(r,{abort:!0,serverIdle:!0})},[G]);(0,D.useEffect)(()=>{if(!Ue){xe(!1);return}let e=!1,t=async()=>{try{e||await K(Ue,()=>!e)}catch{}};t();let n=window.setInterval(()=>void t(),2e3);return()=>{e=!0,window.clearInterval(n)}},[Ue,K]);let q=ve||be,Ye=(0,D.useRef)(q);Ye.current=q;let Xe=(0,D.useCallback)(async e=>{try{return(await y.listMentionCandidates({projectId:h,query:e})).candidates.map(e=>({id:e.id,label:ge&&e.roleBasedName?e.roleBasedName:e.label,scheme:`gezel`,...e.description?{description:e.description}:{},...e.group?{group:e.group}:{}}))}catch{return[]}},[h,ge]);(0,D.useEffect)(()=>{re?.(Se?`error`:Ee===null?q?`streaming`:`idle`:`queued`,Se??void 0)},[q,Ee,Se,re]);let J=(0,D.useCallback)(e=>{let t=F.current;F.current=e.length;let n=P.current!==e;if(P.current=e,$e(N.current,e),n&&(ke.current+=1),je(e.trim().length>0),Ne(U(e)),ue&&t<=2){let t=e.trimStart().match(/^>\s+([^\n]*)/);if(t){et(N.current),ue((t[1]??``).trim());return}}let r=p(e);Le(e=>Y(e,r)?e:r)},[ue]),at=(0,D.useCallback)(e=>{let t=e.trim();if(!t)return null;let n=P.current,r=`${n}${n&&!/\s$/.test(n)?` `:``}${t}`;P.current=r,$e(N.current,r),ke.current+=1,F.current=r.length,je(!0),Ne(U(r));let i=p(r);return Le(e=>Y(e,i)?e:i),r},[]),Z=(0,D.useCallback)(()=>{if(Ce.current)return null;let e=P.current;return e.trim()?(Ce.current=!0,Te(!0),{source:e,editVersion:ke.current}):null},[]),Q=(0,D.useCallback)(()=>{Ce.current=!1,Te(!1)},[]),ct=(0,D.useCallback)(e=>{ke.current!==e.editVersion||P.current!==e.source||(P.current=``,et(N.current),F.current=0,je(!1),Ne(null),I(e=>e+1),Le([]))},[]),lt=(0,D.useMemo)(()=>Me===null?[]:Ke(Me,te),[Me,te]),ut=(0,D.useCallback)(async e=>{let t=Z();if(!t)return;let n=U(t.source),r=e??(n===null?null:qe(n,te));if(!r){T(n?`No recent file matches “${n}”. Choose a suggestion or use workspace or artifacts.`:`Choose workspace, artifacts, or a recent file.`),Q();return}T(null);try{if(r.type===`folder`)await y.revealProject(h,r.folder);else if(ne)ne(r.reference);else throw Error(`Recent file opening is unavailable in this chat.`);ct(t)}catch(e){T(`Open failed: ${e instanceof Error?e.message:String(e)}`)}finally{Q()}},[Z,ct,Q,ne,h,te]),dt=(0,D.useRef)(null);(0,D.useEffect)(()=>{if(!oe){dt.current=null;return}let t=Ie.find(t=>t.id!==e&&(!t.projectId||t.projectId===h));if(!t){dt.current=null;return}dt.current!==t.id&&(dt.current=t.id,oe(t.id))},[Ie,e,h,oe]);let ft=(0,D.useCallback)(async()=>{if(U(P.current)!==null){await ut();return}if(!e||q||R)return;let t=Z();if(!t)return;let n=t.source.trim();T(null),A(null);let r;try{r=await We()}catch(e){T(st(e.message)),Q();return}let i=++He.current,a=new AbortController;z.current={id:i,sessionId:r,controller:a,accepted:!1};let o=(async()=>{let e=0,t=0;for(;;){let n=0;try{for await(let e of v({url:y.sessionEventsUrl(r),headers:y.authHeader(),signal:a.signal,fetch:y.getFetch(),keepaliveTimeoutMs:1e4})){if(z.current?.id!==i)return;if(e.type===`tool`){if(n+=1,n<=t)continue;t=n;let r={name:e.name,durationMs:e.durationMs,success:e.success,...e.errorMessage?{errorMessage:e.errorMessage}:{},...e.path?{path:e.path}:{},...e.paths&&e.paths.length>0?{paths:e.paths}:{},...e.argsSummary?{argsSummary:e.argsSummary}:{},...e.argsFull?{argsFull:e.argsFull}:{},...e.resultText?{resultText:e.resultText}:{},...e.resultTruncated?{resultTruncated:!0}:{},...e.diff===void 0?{}:{diff:e.diff},...e.addedLines===void 0?{}:{addedLines:e.addedLines},...e.removedLines===void 0?{}:{removedLines:e.removedLines},...e.card?{card:e.card}:{},projectId:h};ee?.(r)}else if(e.type===`error`)T(ot(e.error)),A(null);else if(e.type===`done`){G(i,{serverIdle:!0});return}else e.type===`queued`?A(e.aheadOf):e.type===`delta`&&A(null)}return}catch(t){if(t.name===`AbortError`){G(i);return}if(z.current?.id!==i)return;if(e+=1,e>5){console.warn(`[ChatComposer] chat event stream lost, giving up:`,t),T(st(t.message)),G(i);return}let n=Math.min(500*2**(e-1),5e3);if(console.warn(`[ChatComposer] chat event stream lost (reconnect ${e}/5 in ${n}ms):`,t),await new Promise(e=>setTimeout(e,n)),a.signal.aborted||z.current?.id!==i)return}}})();try{let a=[...new Set([...c(n),...Re])].filter(t=>t!==e),o=(ce??[]).filter(t=>t&&t!==e),s={message:n};a.length>0&&(s.mentions=a),o.length>0&&(s.passiveCcGezelIds=o),await y.sendToChatSession(r,s);let l=z.current;l?.id===i&&(l.accepted=!0,ye(!0),K(r).catch(()=>{})),ct(t),Je({sessionId:r,gezelId:e,projectId:h,content:n,at:new Date().toISOString()}),o.length>0&&le?.()}catch(e){a.abort(),G(i);let t=e.message??String(e);if(/already in flight/i.test(t))try{let{inflight:e}=await y.getChatSessionInflight(r);e?(Oe({userText:e.userText,elapsedMs:e.elapsedMs,sessionId:r}),T(null)):T(ot(t))}catch{T(ot(t))}else T(st(t))}finally{Q()}await o},[e,h,q,R,Z,ct,We,Q,G,K,ee,Re,ce,le,ut]),pt=(0,D.useCallback)(async()=>{if(j){try{await y.cancelChatSessionTurn(j.sessionId)}catch(e){T(`Cancel failed: ${e.message}`);return}Oe(null),T(null)}},[j]),mt=(0,D.useCallback)(async()=>{let e=V.current,t=z.current;if(t?(t.controller.abort(),G(t.id)):(ye(!1),A(null)),!e){xe(!1);return}try{await y.cancelChatSessionTurn(e),xe(!1),T(null)}catch(e){T(`Cancel failed: ${e.message}`)}},[G]);(0,D.useEffect)(()=>{let e=e=>{!Ye.current||Ce.current||e.key!==`Escape`||e.defaultPrevented||(e.preventDefault(),mt())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[mt]);let ht=(0,D.useCallback)(async()=>{let t=V.current;if(!e||!t||R)return;let n=Z();if(!n)return;let r=n.source.trim();T(null);try{await y.sendToChatSession(t,{message:r,nudge:!0}),ct(n)}catch(e){T(ot(e.message??String(e)))}finally{Q()}},[e,R,Z,ct,Q]),gt=(0,D.useCallback)(async()=>{let t=V.current;if(!e||!t||R)return;let n=Z();if(!n)return;let r=n.source.trim();T(null),xe(!0);try{await y.interruptChatSession(t,{message:r}),ct(n),K(t).catch(()=>{})}catch(e){T(ot(e.message??String(e)))}finally{Q()}},[e,R,Z,ct,Q,K]),_t=(0,D.useRef)(()=>{});return _t.current=k?()=>{}:Me===null?q?()=>void ht():()=>void ft():()=>void ut(),(0,O.jsxs)(`div`,{ref:pe,className:`chat-composer`,"data-testid":`chat-composer`,children:[R&&(0,O.jsxs)(`div`,{className:`chat-composer-disabled-banner`,role:`alert`,children:[(0,O.jsx)(`span`,{children:`AI disabled in Settings → General. Chat is paused.`}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>window.dispatchEvent(new CustomEvent(`gezel:navigate`,{detail:{view:`settings`}})),children:`Open Settings`})]}),j&&(0,O.jsxs)(`div`,{className:`chat-composer-wedged`,children:[(0,O.jsxs)(`div`,{className:`chat-composer-wedged-head`,children:[(0,O.jsx)(`strong`,{children:`Previous turn still running`}),(0,O.jsxs)(`span`,{className:`muted`,children:[` · `,X(j.elapsedMs)]})]}),(0,O.jsx)(`div`,{className:`chat-composer-wedged-preview`,children:j.userText.length>180?`${j.userText.slice(0,177)}…`:j.userText}),(0,O.jsxs)(`div`,{className:`chat-composer-wedged-actions`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:()=>void pt(),children:`Cancel stuck turn`}),(0,O.jsx)(`button`,{type:`button`,className:`subtle`,onClick:()=>Oe(null),children:`Dismiss`})]})]}),Se&&(0,O.jsxs)(`div`,{className:`chat-composer-error`,role:`alert`,children:[(0,O.jsx)(`span`,{className:`chat-composer-error-mark`,"aria-hidden":`true`,children:`✗`}),(0,O.jsx)(`span`,{className:`chat-composer-error-text`,children:Se})]}),(0,O.jsxs)(`div`,{className:`chat-composer-to`,children:[(0,O.jsx)(`span`,{className:`chat-composer-to-label muted`,children:`To:`}),(0,O.jsx)(se,{svg:i??null,poppetje:o,iconOverride:s,name:_e,size:18}),(0,O.jsxs)(`span`,{className:`chat-composer-to-text`,children:[(0,O.jsx)(`span`,{className:`chat-composer-to-name`,children:_e}),!ge&&r&&(0,O.jsx)(`span`,{className:`chat-composer-to-role`,children:r})]}),Be.map(e=>{let t=f({name:e.name,roleBasedName:e.roleBasedName},ge);return(0,O.jsxs)(`span`,{className:`chat-composer-to-recipient`,children:[(0,O.jsx)(se,{svg:e.icon??null,poppetje:e.poppetje,iconOverride:e.iconOverride,name:t,size:18}),(0,O.jsxs)(`span`,{className:`chat-composer-to-text`,children:[(0,O.jsx)(`span`,{className:`chat-composer-to-name`,children:t}),!ge&&e.role&&(0,O.jsx)(`span`,{className:`chat-composer-to-role`,children:e.role})]}),(0,O.jsx)(`button`,{type:`button`,className:`chat-composer-recipient-remove`,"aria-label":`Remove ${t} from recipients`,title:`Remove ${t}`,onClick:()=>ze(t=>t.filter(t=>t!==e.id)),children:`×`})]},e.id)}),Ie.filter(t=>(t.id!==e||t.projectId!==void 0)&&!Re.includes(t.id)).map(e=>(0,O.jsxs)(`span`,{className:`chat-composer-to-mention`,title:e.projectId?`@${e.label} re: ${e.projectId}`:`@${e.label}`,children:[`@`,e.label]},e.rawId)),d&&m&&d.length>0&&(0,O.jsx)(B,{gezels:d,primaryGezelId:e,additionalRecipientIds:Re,roleBasedNameOnlyMode:ge,onSelectPrimary:e=>{ze([]),m(e)},onAddRecipient:t=>ze(n=>t===e||n.includes(t)?n:[...n,t])}),ae]}),w,(0,O.jsxs)(`div`,{className:`chat-editor-wrap`,children:[Me!==null&&(0,O.jsxs)(`div`,{className:`chat-open-command-menu`,role:`menu`,"aria-label":`Open targets`,children:[(0,O.jsxs)(`div`,{className:`chat-open-command-heading`,children:[(0,O.jsx)(`code`,{children:`/open`}),(0,O.jsx)(`span`,{children:`Project folders and recent chat files`})]}),lt.length>0?(0,O.jsx)(`div`,{className:`chat-open-command-items`,children:lt.map(e=>(0,O.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`chat-open-command-item`,"aria-label":e.target.type===`folder`?`Open ${e.target.folder} folder`:`Open ${e.label}`,onMouseDown:e=>e.preventDefault(),onClick:()=>void ut(e.target),children:[(0,O.jsx)(`code`,{children:e.label}),(0,O.jsx)(`span`,{children:e.description})]},e.key))}):(0,O.jsx)(`p`,{className:`chat-open-command-empty`,children:`No matching recent files.`})]}),(0,O.jsx)(S,{initialMarkdown:P.current,hostMode:`chat`,mediaProvider:W,mentionProvider:Xe,...x?{placeholder:x}:{},imageDisplayMode:`thumbnail`,onChange:J,minHeight:`120px`,maxHeight:`50vh`,colorScheme:he,uxFont:`var(--font-ui)`,showPlayTab:!1,showStatusBar:!1,showFilesToggle:!0,...rt,fullWidth:!0,thinMargins:!0,submitOnEnter:()=>_t.current(),toolbarSlotAfterActions:(0,O.jsx)(De,{mediaProvider:W,onError:T}),toolbarSlotRight:(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(it,{projectId:h,disabled:!e||R||k,onAppendTranscript:at,onError:T}),Me===null?q?(0,O.jsxs)(O.Fragment,{children:[Ae&&!R&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`button`,{type:`button`,className:`chat-send-btn chat-nudge-btn`,"data-testid":`chat-nudge`,onClick:()=>void ht(),disabled:k,title:`Queue for after this turn (Enter)`,children:`Nudge`}),(0,O.jsx)(`button`,{type:`button`,className:`chat-interrupt-btn`,"data-testid":`chat-interrupt`,onClick:()=>void gt(),disabled:k,title:`Stop this turn and send now`,children:`Interrupt`})]}),(0,O.jsx)(`button`,{type:`button`,className:`chat-stop-btn`,onClick:()=>void mt(),disabled:k,title:`Stop generating (Escape)`,children:`■ Stop`})]}):(0,O.jsx)(`button`,{type:`button`,className:`chat-send-btn chat-send-btn-icon`,"data-testid":`chat-send`,onClick:ft,disabled:!e||R||k,"aria-label":k?`Sending…`:`Send`,"aria-busy":k,title:R?`AI is disabled in Settings → General`:`Enter to send, ${nt()} for newline`,children:(0,O.jsx)(a,{})}):(0,O.jsx)(`button`,{type:`button`,className:`chat-send-btn`,"data-testid":`chat-open`,onClick:()=>void ut(),disabled:k,title:`Open this folder or recent file (Enter)`,children:k?`Opening…`:`Open`})]})},`${Pe}:${e}:${x??``}`)]})]})}function Y(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],i=t[n];if(!r||!i||r.rawId!==i.rawId||r.label!==i.label)return!1}return!0}function X(e){let t=Math.floor(e/1e3);return t<60?`${t}s elapsed`:`${Math.floor(t/60)}m ${t%60}s elapsed`}function Z(e){let t=/"error"\s*:\s*"model_not_loaded"/.test(e)||/model_not_loaded/.test(e),n=/is not available locally for provider/i.test(e),r=/"error"\s*:\s*"model_not_found"/.test(e);if(!t&&!n&&!r)return;let i=/"model"\s*:\s*"([^"]+)"/.exec(e)?.[1],a=/Model\s+"([^"]+)"/i.exec(e)?.[1],o=i??a??``,s=o.indexOf(`:`);return s===-1?o:o.slice(s+1)}function ot(e){if(!e)return e;let t=Z(e);return t===void 0?/Timeout\s+after\s+\d+ms\s+waiting\s+for\s+session\.idle/i.test(e)?`Copilot stalled without streaming a reply — this usually means the SDK lost its connection. Your message is saved; try Send again, or pick a different model in Settings → Defaults.`:/timed out after \d+s/i.test(e)?`The model didn't respond in time. Your message is saved — try Send again.`:e:`The model ${t?`"${t}" `:``}isn't available on this device — it may never have finished downloading. Pick a model that is installed, or download this one, in Settings → Artificial Intelligence.`}function st(e){return/network\s?error/i.test(e)||/failed to fetch/i.test(e)||/load failed/i.test(e)||/transport unavailable/i.test(e)||/SSE stream (stale|failed)/i.test(e)||/ended before a terminal event/i.test(e)?`Lost the connection to the gezel service and could not reconnect. Your message is saved — if no reply appears, check that the service is running and try Send again.`:ot(e)}function Q(e){let t=lt(e);return t===``?`/`:t.startsWith(`/`)||/^[A-Za-z]:[\\/]/.test(t)?t:`/${t}`}var ct=/\x1b\[[0-9;?]*[ -/]*[@-~]|\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)|\x1b[@-_]|\uFFFD\[[0-9;?]*[ -/]*[@-~]/g;function lt(e){let t=``;for(let n of e.replace(ct,``)){let e=n.charCodeAt(0);e>=32&&e!==127&&(t+=n)}return t.trim()}function ut(e){return e===`dispatching`?`Starting`:e===`night-shift`||e===`night-quota`?`Scheduled`:e===`engagement-off`||e===`engagement-paused`?`On hold`:`In the queue`}function dt(e,t){switch(e){case`dispatching`:return`${t} is picking it up now.`;case`provider-busy`:return`Waiting for a free slot — other work is using the model right now.`;case`night-shift`:return`Parked for Night Shift — it starts when tonight's window opens.`;case`night-quota`:return`Held back by the cloud quota reserve — it starts once the quota frees up.`;case`engagement-off`:return`Held because AI engagement is off. Turn it back on in Settings to let it start.`;case`engagement-paused`:return`Held because AI work is paused. Resume to let it start.`;default:return`Waiting its turn — it starts as soon as ${t} is free.`}}function ft({task:e,wait:t,gezel:n,onTaskReference:r}){let i=de(),a=n?f({name:n.name,roleBasedName:n.roleBasedName},i):`the assigned gezel`,o=ee(t.since,{style:`long`,fallback:t.since});return(0,O.jsx)(`div`,{className:`msg msg-user msg-system msg-queued-task`,"data-task-ref":e.ref,children:(0,O.jsxs)(`div`,{className:`msg-queued-task-card`,children:[(0,O.jsxs)(`div`,{className:`msg-queued-task-head`,children:[(0,O.jsx)(pe,{area:`tasks`,size:12,className:`msg-queued-task-icon`}),(0,O.jsx)(`span`,{className:`msg-queued-task-kind`,children:ut(t.reason)}),(0,O.jsxs)(`span`,{className:`msg-role-time`,title:te(t.since),children:[`· `,o]})]}),(0,O.jsxs)(`p`,{className:`msg-queued-task-headline`,children:[(0,O.jsxs)(`span`,{className:`msg-queued-task-number`,children:[`#`,e.num]}),` `,e.title]}),(0,O.jsxs)(`p`,{className:`msg-queued-task-context`,children:[n&&(0,O.jsx)(se,{svg:n.icon??null,poppetje:n.poppetje,iconOverride:n.iconOverride,name:a,size:14}),dt(t.reason,a)]}),(0,O.jsx)(`div`,{className:`msg-queued-task-actions`,children:r?(0,O.jsxs)(`button`,{type:`button`,className:`msg-ref-chip`,onClick:()=>r(e.ref),title:`Open this task`,children:[`Task `,e.ref]}):(0,O.jsxs)(`span`,{className:`msg-queued-task-ref`,children:[`Task `,e.ref]})})]})})}var pt=[`black`,`red`,`green`,`yellow`,`blue`,`magenta`,`cyan`,`white`,`bright-black`,`bright-red`,`bright-green`,`bright-yellow`,`bright-blue`,`bright-magenta`,`bright-cyan`,`bright-white`];function mt(){return{fg:null,bg:null,bold:!1,dim:!1,italic:!1,underline:!1,reverse:!1,hidden:!1}}function ht(e){let t=[],n=e.reverse?e.bg:e.fg,r=e.reverse?e.fg:e.bg;return n!==null&&t.push(`ansi-fg-${pt[n]}`),r!==null&&t.push(`ansi-bg-${pt[r]}`),e.bold&&t.push(`ansi-bold`),e.dim&&t.push(`ansi-dim`),e.italic&&t.push(`ansi-italic`),e.underline&&t.push(`ansi-underline`),e.reverse&&t.push(`ansi-reverse`),e.hidden&&t.push(`ansi-hidden`),t.join(` `)}function gt(e,t){if(t+1>=e.length)return null;let n=e[t+1];if(n===`[`){let n=t+2;for(;n<e.length;){let t=e.charCodeAt(n);if(t>=48&&t<=63)n++;else break}for(;n<e.length;){let t=e.charCodeAt(n);if(t>=32&&t<=47)n++;else break}if(n>=e.length)return null;let r=e.charCodeAt(n);if(r<64||r>126)return{end:t+1};if(e[n]===`m`){let r=e.slice(t+2,n),i=r===``?[0]:r.split(`;`).map(e=>{let t=Number.parseInt(e,10);return Number.isFinite(t)?t:0});return{end:n+1,sgrParams:i}}if(e[n]===`H`||e[n]===`f`){let r=e.slice(t+2,n).split(`;`).map(e=>Number.parseInt(e,10)),i=Number.isFinite(r[0])&&r[0]>0?r[0]:1,a=Number.isFinite(r[1])&&r[1]>0?r[1]:1;return{end:n+1,transcriptLineBreak:i>1&&a===1}}return{end:n+1}}if(n===`]`){let n=t+2;for(;n<e.length;){let t=e[n];if(t===`\x07`)return{end:n+1};if(t===`\x1B`&&n+1<e.length&&e[n+1]===`\\`)return{end:n+2};n++}return null}return{end:t+2}}function _t(e,t){let n={...e},r=0;for(;r<t.length;){let e=t[r];e===0?(n.fg=null,n.bg=null,n.bold=!1,n.dim=!1,n.italic=!1,n.underline=!1,n.reverse=!1,n.hidden=!1):e===1?n.bold=!0:e===2?n.dim=!0:e===3?n.italic=!0:e===4?n.underline=!0:e===7?n.reverse=!0:e===8?n.hidden=!0:e===22?(n.bold=!1,n.dim=!1):e===23?n.italic=!1:e===24?n.underline=!1:e===27?n.reverse=!1:e===28?n.hidden=!1:e>=30&&e<=37?n.fg=e-30:e===38?t[r+1]===5?r+=2:t[r+1]===2&&(r+=4):e===39?n.fg=null:e>=40&&e<=47?n.bg=e-40:e===48?t[r+1]===5?r+=2:t[r+1]===2&&(r+=4):e===49?n.bg=null:e>=90&&e<=97?n.fg=e-90+8:e>=100&&e<=107&&(n.bg=e-100+8),r++}return n}function vt(e){let t=mt(),n=``,r=!1,i=0;return{feed(a){let o=n+a;n=``;let s=[],c=0,l=0,u=n=>{if(n<=l)return;let a=o.slice(l,n);if(a===``)return;r&&/\S/.test(a)&&(s.push(`
4
-
5
- `),r=!1);let c=e?e(a):a,u=ht(t);u===``?s.push(c):s.push((0,O.jsx)(`span`,{className:u,children:c},i++))};for(;c<o.length;){if(o.charCodeAt(c)!==27){c++;continue}let e=gt(o,c);if(e===null)return u(c),n=o.slice(c),s;u(c),e.sgrParams&&(t=_t(t,e.sgrParams)),e.transcriptLineBreak&&yt(o,e.end)?(s.push(`
6
-
7
- `),r=!1):e.transcriptLineBreak&&(r=!0),c=e.end,l=c}return u(o.length),s}}}function yt(e,t){let n=t;for(;n<e.length;){if(e.charCodeAt(n)===27){let t=gt(e,n);if(t===null)return!1;n=t.end;continue}if(!/\s/.test(e[n]))return!0;n++}return!1}function bt({text:e,renderText:t}){return(0,O.jsx)(O.Fragment,{children:(0,D.useMemo)(()=>vt(t).feed(e),[e,t])})}var xt={tabIndex:0};function St({entry:e,onOpenWorkspaceFile:t}){let n=Q(e.cwd===void 0?e.workingDir:e.cwd);if(e.msgKind===`command`)return(0,O.jsxs)(`div`,{className:`msg msg-user terminal-group terminal-group-command`,"data-terminal-message-id":e.messageId,"data-terminal-thread-id":e.threadId,children:[(0,O.jsxs)(`div`,{className:`msg-header terminal-group-header`,children:[(0,O.jsx)(`span`,{className:`terminal-folder-pill`,title:`Working folder`,children:n}),(0,O.jsx)(`span`,{className:`msg-author`,children:`You · terminal`})]}),(0,O.jsxs)(`div`,{className:`msg-body terminal-cmd-body`,children:[(0,O.jsx)(`span`,{className:`terminal-prompt-sigil`,children:`>`}),` `,(0,O.jsx)(`code`,{className:`terminal-cmd-code`,children:e.content})]}),e.resolvedFrom&&e.resolvedFrom!==e.content&&(0,O.jsxs)(`div`,{className:`terminal-resolved-hint`,children:[`from: `,e.resolvedFrom]})]});let r=e.exitCode!==void 0&&e.exitCode!==0,i=e.exitCode===void 0?null:e.exitCode===0?`exit 0`:`exit ${e.exitCode}`,a=n=>Ct(n,e.fileReferences??[],t);return(0,O.jsxs)(`div`,{className:`msg msg-assistant terminal-group terminal-group-output`,"data-terminal-message-id":e.messageId,"data-terminal-thread-id":e.threadId,children:[(0,O.jsxs)(`div`,{className:`msg-header terminal-group-header`,children:[(0,O.jsx)(`span`,{className:`terminal-folder-pill`,title:`Working folder`,children:n}),(0,O.jsx)(`span`,{className:`msg-author`,children:`Terminal output`}),i&&(0,O.jsx)(`span`,{className:`terminal-exit-pill ${r?`terminal-exit-fail`:`terminal-exit-ok`}`,children:i}),typeof e.durationMs==`number`&&(0,O.jsx)(`span`,{className:`terminal-duration`,children:Tt(e.durationMs)}),e.truncated&&(0,O.jsx)(`span`,{className:`terminal-truncated-pill`,title:`200KB output cap reached`,children:`truncated`})]}),e.errorMessage&&e.exitCode===-1&&(0,O.jsx)(`div`,{className:`terminal-error-banner`,children:e.errorMessage}),(0,O.jsx)(`section`,{className:`terminal-output-viewport`,"aria-label":`Terminal output`,...xt,children:(0,O.jsx)(`pre`,{className:`terminal-output-body`,children:e.content?(0,O.jsx)(bt,{text:e.content,renderText:a}):r?`(no output)`:``})})]})}function Ct(e,t,n){if(!n||t.length===0||!e)return e;let r=[...t].sort((e,t)=>t.label.length-e.label.length),i=e.toLowerCase(),a=[],o=0,s=0;for(;o<e.length;){let t=null;for(let n of r){let r=n.label.toLowerCase(),a=i.indexOf(r,o);for(;a>=0&&!wt(e,a,n.label.length);)a=i.indexOf(r,a+Math.max(1,r.length));a>=0&&(!t||a<t.at)&&(t={at:a,reference:n})}if(!t)break;t.at>o&&a.push(e.slice(o,t.at));let c=e.slice(t.at,t.at+t.reference.label.length);a.push((0,O.jsx)(`button`,{type:`button`,className:`terminal-file-link`,title:`Preview ${t.reference.path}`,onClick:()=>n(t.reference.path),children:c},`${t.reference.path}:${s++}`)),o=t.at+t.reference.label.length}return o===0?e:(o<e.length&&a.push(e.slice(o)),a)}function wt(e,t,n){let r=t===0?``:e[t-1],i=t+n,a=i>=e.length?``:e[i];return(r===``||/[\s"'([{<]/.test(r))&&(a===``||/[\s"')\]}>:,;]/.test(a))}function Tt(e){if(e<1e3)return`${e}ms`;let t=e/1e3;if(t<60)return`${t.toFixed(1)}s`;let n=Math.floor(t/60);return`${n}m${Math.round(t-n*60).toString().padStart(2,`0`)}s`}var Et=24,Dt={tabIndex:0};function Ot({content:e,cwd:t,startedAt:n,onCancel:r,awaitingInput:i,onSendInput:a}){let o=Q(t),s=(0,D.useRef)(null),c=(0,D.useRef)(!0);(0,D.useLayoutEffect)(()=>{let e=s.current;!e||!c.current||(e.scrollTop=e.scrollHeight)},[e]);let l=()=>{let e=s.current;if(!e)return;let t=e.scrollHeight-e.clientHeight-e.scrollTop;c.current=t<=Et};return(0,O.jsxs)(`div`,{className:`msg msg-assistant terminal-group terminal-group-output terminal-group-streaming`,children:[(0,O.jsxs)(`div`,{className:`msg-header terminal-group-header`,children:[(0,O.jsx)(`span`,{className:`terminal-folder-pill`,title:`Working folder`,children:o}),(0,O.jsx)(`span`,{className:`msg-author`,children:`Terminal output`}),(0,O.jsx)(At,{startedAt:n}),r&&(0,O.jsx)(`button`,{type:`button`,className:`terminal-cancel-btn`,onClick:r,title:`Stop the running command (Ctrl+C)`,children:`■ Stop`})]}),(0,O.jsx)(`section`,{ref:s,className:`terminal-output-viewport`,"aria-label":`Live terminal output`,"aria-busy":`true`,...Dt,onScroll:l,children:(0,O.jsx)(`pre`,{className:`terminal-output-body`,children:(0,O.jsx)(bt,{text:e})})}),i&&a&&(0,O.jsx)(kt,{awaitingInput:i,onSubmit:a})]})}function kt({awaitingInput:e,onSubmit:t}){let[n,r]=(0,D.useState)(``),i=e=>{t(e),r(``)},a=e=>{e.key===`Enter`&&(e.preventDefault(),i(n))};if(e.mode===`yes-no`)return(0,O.jsxs)(`div`,{className:`terminal-input-prompt`,children:[(0,O.jsx)(`div`,{className:`terminal-input-prompt-line`,children:e.promptLine}),(0,O.jsxs)(`div`,{className:`terminal-input-prompt-row`,children:[(0,O.jsx)(`button`,{type:`button`,className:`terminal-input-yesno-btn`,onClick:()=>i(`y`),children:`Yes`}),(0,O.jsx)(`button`,{type:`button`,className:`terminal-input-yesno-btn`,onClick:()=>i(`n`),children:`No`}),(0,O.jsx)(`input`,{type:`text`,className:`terminal-input-reply`,value:n,onChange:e=>r(e.target.value),onKeyDown:a,placeholder:`or type a custom reply`,autoCapitalize:`off`,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1})]})]});let o=e.mode===`password`;return(0,O.jsxs)(`div`,{className:`terminal-input-prompt`,children:[(0,O.jsx)(`div`,{className:`terminal-input-prompt-line`,children:e.promptLine}),(0,O.jsxs)(`div`,{className:`terminal-input-prompt-row`,children:[(0,O.jsx)(`input`,{type:o?`password`:`text`,className:`terminal-input-reply`,value:n,onChange:e=>r(e.target.value),onKeyDown:a,placeholder:o?`password (not echoed or saved)`:`reply…`,autoFocus:!0,autoCapitalize:`off`,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1}),(0,O.jsx)(`button`,{type:`button`,className:`terminal-input-send-btn`,onClick:()=>i(n),children:`Send`})]}),o&&(0,O.jsx)(`div`,{className:`terminal-input-hint`,children:`Your input is hidden and isn't kept in the timeline.`})]})}function At({startedAt:e}){let[,t]=(0,D.useState)(0);(0,D.useEffect)(()=>{let e=setInterval(()=>t(e=>e+1),1e3);return()=>clearInterval(e)},[]);let n=(0,D.useMemo)(()=>new Date(e).getTime(),[e]);return(0,O.jsxs)(`span`,{className:`terminal-running-pill`,title:`Running…`,children:[`running `,jt(Math.max(0,Date.now()-n))]})}function jt(e){if(e<1e3)return`${e}ms`;let t=Math.floor(e/1e3);return t<60?`${t}s`:`${Math.floor(t/60)}m${(t%60).toString().padStart(2,`0`)}s`}var Mt=1440*60*1e3;function Nt(e,t){if(!e)return!1;let n=Date.parse(e);return Number.isFinite(n)&&t-n<=864e5}var Pt=300*1e3;function Ft(e){let t=Date.parse(e);return Number.isFinite(t)?t+Pt:void 0}function It(e,t){let n;for(let r of e){let e=Ft(r.at);e===void 0||e<t||(n===void 0||e<n)&&(n=e)}return n}function Lt(e,t){if(e.kind===`terminal-streaming`)return!0;if(e.kind!==`terminal`)return!1;let n=Ft(e.at);return n!==void 0&&t<=n}function Rt(e,t){return Lt(e,t)?2:+(e.kind===`streaming`)}function zt(e,t,n){let r=Rt(e,n)-Rt(t,n);return r===0?e.at<t.at?-1:+(e.at>t.at):r}function Bt(e){let t=-1/0,n=e.root?[e.root,...e.replies]:e.replies;for(let e of n){let n=Date.parse(e.at);Number.isFinite(n)&&n>t&&(t=n)}return t}function Vt(e,t,n){if(!t)return e;let r=-1;for(let n=e.length-1;n>=0;n--){let i=e[n];if(i?.kind===`thread`&&i.sessionId===t){r=n;break}}if(r===-1)return e;let i=e[r],a=Bt(i);if(!Number.isFinite(a)||n-a>864e5)return e;let o=e.length;for(;o>0;){let t=e[o-1];if(!t||!Lt(t,n))break;o--}let s=o-1;if(s<=r)return e;let c=[...e];return c.splice(r,1),c.splice(s,0,i),c}var Ht=280;function Ut(e,t){t?.current&&(t.current.abort(),t.current=null);let n=e.current;if(n){try{n.pause(),n.removeAttribute(`src`),n.load()}catch{}e.current=null}}function Wt(e){let t=e.trim();if(t.length<=Ht)return t;let n=t.slice(0,Ht),r=Math.max(n.lastIndexOf(`. `),n.lastIndexOf(`! `),n.lastIndexOf(`? `));return r>=Ht/2?n.slice(0,r+1).trim():`${n.trim()}…`}async function Gt(e,t,n,r,i){Ut(r,i);let a=new AbortController;i.current=a;let o=Wt(e);console.debug(`[narrate] synth start chars=${o.length} (of ${e.length}) gezelId=${t}`);let s;try{s=await y.synthesizeSpeech({text:o,gezelId:t,projectId:n,inline:!0,signal:a.signal})}catch(e){if(a.signal.aborted){console.debug(`[narrate] synth aborted (superseded by newer turn)`);return}console.warn(`[narrate] synth failed:`,e);return}if(a.signal.aborted){console.debug(`[narrate] synth resolved but aborted — dropping`);return}if(console.debug(`[narrate] synth ok b64Len=${s.b64Wav?.length??0} meta=`,s.meta),!s.b64Wav){console.warn(`[narrate] synth returned no b64Wav — narration skipped`);return}let c=new Audio(`data:audio/wav;base64,${s.b64Wav}`);r.current=c,c.addEventListener(`ended`,()=>{console.debug(`[narrate] playback ended`),r.current===c&&(r.current=null),i.current===a&&(i.current=null)});try{await c.play(),console.debug(`[narrate] playback started`)}catch(e){console.warn(`[narrate] playback rejected:`,e),r.current===c&&(r.current=null),i.current===a&&(i.current=null)}}function Kt(e){let{branch:t,phase:n}=e,r=t.ancestorContinuationLevels.filter(e=>e>=2&&e<=4);return(0,O.jsxs)(O.Fragment,{children:[(n===`thread`&&t.hasFollowingSibling?[1,...r]:r).map(e=>(0,O.jsx)(`span`,{className:`timeline-tree-guide timeline-tree-guide-${n} timeline-tree-guide-up-${e}`,"aria-hidden":`true`},`${n}:${e}`)),n===`divider`&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`span`,{className:`timeline-tree-parent-line timeline-tree-guide-up-1${t.hasFollowingSibling?` timeline-tree-parent-line-continues`:``}`,"aria-hidden":`true`}),(0,O.jsx)(`span`,{className:`timeline-tree-elbow timeline-tree-guide-up-1`,"aria-hidden":`true`})]})]})}function qt(e){let{row:t,gezels:n,projects:r,showProjectName:i,activeSessionId:a,onFocusSession:o,continuing:s,depth:c=0,treeBranch:l,key:u,roleBasedNameOnlyMode:d}=e,p=t.kind===`streaming`?t.sessionId:t.msg.sessionId,m=t.kind===`streaming`?t.slot.gezelId:t.msg.gezelId,h=t.kind===`streaming`?t.slot.projectId:t.msg.projectId,g=n.get(m),_=i&&h!=="default"?r.get(h):void 0,v=p===a,y=t.kind===`message`?t.msg.sessionCreatedAt:t.slot.sessionCreatedAt??new Date(t.slot.startedAt).toISOString(),ne=t.kind===`message`?t.msg.taskRef:t.slot.taskRef,b=t.kind===`message`?t.msg.sessionSource:t.slot.sessionSource,re=t.kind===`message`?t.msg.parentSession:t.slot.parentSession,x=t.kind===`message`?t.msg.handoffFrom:t.slot.handoffFrom,S=re??(x?{...x,kind:`task-handoff`}:void 0),C=S?(()=>{let e=n.get(S.gezelId);return e?f({name:e.name,roleBasedName:e.roleBasedName},d):void 0})():void 0,ie=x?(()=>{let e=n.get(x.gezelId);return e?f({name:e.name,roleBasedName:e.roleBasedName},d):void 0})():void 0,w=g?f({name:g.name,roleBasedName:g.roleBasedName},d):`Gezel`;if(t.kind===`streaming`&&p.startsWith(`one-shot:`)){let e=t.slot.activity?.trim()||`Background work`;return(0,O.jsxs)(`output`,{className:`timeline-session-divider timeline-session-divider-activity`,children:[(0,O.jsx)(se,{svg:g?.icon??null,poppetje:g?.poppetje,iconOverride:g?.iconOverride,name:w,size:16}),(0,O.jsxs)(`span`,{className:`timeline-divider-meta`,title:te(y),children:[w,` · `,e,_&&(0,O.jsxs)(O.Fragment,{children:[` · in `,_.name]}),` · `,`started `,ee(y)]})]},u)}return(0,O.jsxs)(`button`,{type:`button`,className:`timeline-session-divider${v?` timeline-session-divider-active`:``}${s?` timeline-session-divider-continuing`:``}${c>0?` timeline-session-divider-child timeline-session-depth-${Math.min(c,4)}`:``}`,onClick:()=>o?.(p,m,h),title:b?`View this read-only thread from ${b.appName}`:`Focus this thread — composer will post here`,children:[c>0&&l&&(0,O.jsx)(Kt,{branch:l,phase:`divider`}),(0,O.jsx)(se,{svg:g?.icon??null,poppetje:g?.poppetje,iconOverride:g?.iconOverride,name:w,size:16}),(0,O.jsxs)(`span`,{className:`timeline-divider-meta`,title:te(y),children:[s?(0,O.jsxs)(O.Fragment,{children:[`↩ continuing with `,w,_&&(0,O.jsxs)(O.Fragment,{children:[` · in `,_.name]}),b&&(0,O.jsxs)(O.Fragment,{children:[` · from `,b.appName,` · read-only`]})]}):b?(0,O.jsxs)(O.Fragment,{children:[`external thread with `,w,` · from `,b.appName,` · read-only`,_&&(0,O.jsxs)(O.Fragment,{children:[` · in `,_.name]}),` · `,`started `,ee(y)]}):S?(0,O.jsxs)(O.Fragment,{children:[S.kind===`consultation`?`consultation with ${w}`:S.kind===`task-handoff`?`task hand-off to ${w}`:`delegated to ${w}`,_&&(0,O.jsxs)(O.Fragment,{children:[` · in `,_.name]}),` · `,`started `,ee(y)]}):(0,O.jsxs)(O.Fragment,{children:[`new thread with `,w,_&&(0,O.jsxs)(O.Fragment,{children:[` · in `,_.name]}),` · `,`started `,ee(y)]}),ne&&(0,O.jsxs)(O.Fragment,{children:[` · task `,ne]})]}),S&&(S.kind===`task-handoff`?ie??C:C)&&(0,O.jsxs)(`span`,{className:`timeline-divider-handoff`,children:[(0,O.jsxs)(`svg`,{className:`timeline-divider-handoff-icon`,viewBox:`0 0 16 16`,fill:`none`,"aria-hidden":`true`,focusable:`false`,children:[(0,O.jsx)(`path`,{d:`M2.5 4.25v2.1a4.4 4.4 0 0 0 4.4 4.4H13`}),(0,O.jsx)(`path`,{d:`m10.5 8.25 2.75 2.5-2.75 2.5`})]}),S.kind===`task-handoff`?`from`:`by`,` `,S.kind===`task-handoff`?ie??C:C]})]},u)}function Jt(e){let{entry:t,key:n}=e;return(0,O.jsxs)(`div`,{className:`timeline-session-divider timeline-terminal-session-divider`,children:[(0,O.jsx)(`span`,{className:`terminal-folder-pill`,title:`Working folder`,children:t.workingDir===``?`/`:t.workingDir}),(0,O.jsxs)(`span`,{className:`timeline-divider-meta`,title:te(t.at),children:[`terminal session · started `,ee(t.at)]})]},n)}var Yt={request(e){return typeof requestAnimationFrame==`function`?requestAnimationFrame(e):window.setTimeout(()=>e(performance.now()),16)},cancel(e){typeof cancelAnimationFrame==`function`?cancelAnimationFrame(e):window.clearTimeout(e)}},Xt=class{scheduler;items=new Map;structureVersion=0;itemVersions=new Map;structureListeners=new Set;itemListeners=new Map;pendingItems=new Set;pendingStructure=!1;frameHandle=null;constructor(e=Yt){this.scheduler=e}getStructureSnapshot=()=>this.structureVersion;subscribeStructure=e=>(this.structureListeners.add(e),()=>this.structureListeners.delete(e));getItemSnapshot(e){return this.itemVersions.get(e)??0}subscribeItem(e,t){let n=this.itemListeners.get(e);return n||(n=new Set,this.itemListeners.set(e,n)),n.add(t),()=>{n?.delete(t),n?.size===0&&this.itemListeners.delete(e)}}markItemChanged(e){this.pendingItems.add(e),this.scheduleFlush()}markStructureChanged(){this.pendingStructure=!0,this.scheduleFlush()}scheduleFlush(){this.frameHandle===null&&(this.frameHandle=this.scheduler.request(()=>this.flush()))}flush(){this.frameHandle=null;let e=this.pendingStructure,t=[...this.pendingItems];if(this.pendingStructure=!1,this.pendingItems.clear(),e){this.structureVersion+=1;for(let e of this.structureListeners)e()}for(let e of t){this.itemVersions.set(e,(this.itemVersions.get(e)??0)+1);for(let t of this.itemListeners.get(e)??[])t()}}dispose(){this.frameHandle!==null&&this.scheduler.cancel(this.frameHandle),this.frameHandle=null,this.pendingStructure=!1,this.pendingItems.clear(),this.structureListeners.clear(),this.itemListeners.clear()}};function Zt(e){let t=e.root?[e.root,...e.replies]:e.replies;for(let e of t)if(e.kind===`message`&&e.msg.parentSession?.sessionId)return e.msg.parentSession.sessionId}function Qt(e){let t=new Map,n=new Map,r=new Map;for(let i=0;i<e.length;i++){let a=e[i];if(!a||a.kind!==`thread`)continue;let o=t.get(a.sessionId)??[];o.push(a),t.set(a.sessionId,o),n.has(a.sessionId)||n.set(a.sessionId,i);let s=Zt(a);s&&s!==a.sessionId&&r.set(a.sessionId,s)}let i=new Set(t.keys()),a=new Map;for(let[e,t]of r){if(!i.has(t))continue;let n=a.get(t)??[];n.push(e),a.set(t,n)}for(let e of a.values())e.sort((e,t)=>(n.get(e)??0)-(n.get(t)??0));let o=new Map;for(let e of a.values())for(let t=0;t<e.length;t++){let n=e[t];n&&o.set(n,t<e.length-1)}let s=new Map,c=(e,t=new Set)=>{let n=s.get(e);if(n!==void 0)return n;if(t.has(e))return 0;let a=r.get(e);if(!a||!i.has(a))return s.set(e,0),0;let o=new Set(t);o.add(e);let l=Math.min(4,c(a,o)+1);return s.set(e,l),l};for(let e of i)c(e);let l=new Map;for(let e of i){let t=[];if((s.get(e)??0)>0){let n=r.get(e),i=2;for(;n&&r.has(n);)o.get(n)===!0&&t.push(i),n=r.get(n),i+=1}l.set(e,{hasChildren:(a.get(e)?.length??0)>0,hasFollowingSibling:o.get(e)===!0,ancestorContinuationLevels:t})}let u=new Set;for(let[e,t]of r)i.has(t)&&(s.get(e)??0)>0&&u.add(e);let d=[],f=new Set,p=(e,n=new Set)=>{if(f.has(e)||n.has(e))return;f.add(e);for(let n of t.get(e)??[])d.push(n);let r=new Set(n);r.add(e);for(let t of a.get(e)??[])p(t,r)},m=new Map;for(let t=0;t<e.length;t++){let n=e[t];n?.kind===`thread`&&!u.has(n.sessionId)&&m.set(n.sessionId,t)}for(let t=0;t<e.length;t++){let n=e[t];if(n){if(n.kind!==`thread`){d.push(n);continue}if(!u.has(n.sessionId)&&(d.push(n),m.get(n.sessionId)===t)){f.add(n.sessionId);for(let e of a.get(n.sessionId)??[])p(e)}}}for(let e of i)f.has(e)||p(e);return{items:d,depthBySession:s,branchBySession:l}}function $t(e){let t=new Map,n=new Map;for(let r of e){if(r.role!==`user`)continue;let e=r.content.trim(),i=Date.parse(r.at),a=t.get(e);if(a&&a.sessionId!==r.sessionId&&i-a.atMs<=5e3){n.set(r,a.row);continue}t.set(e,{atMs:i,sessionId:r.sessionId,row:r})}return n}function en(e){let t=$t(e.flatMap(e=>e.kind===`message`&&e.msg.role===`user`?[{at:e.msg.at,role:e.msg.role,content:e.msg.content,sessionId:e.msg.sessionId,ref:e}]:[])),n=new Map;for(let[e,r]of t)n.set(e.ref,r.ref);let r=[],i=new Map,a=new Map;for(let t of e){if(t.kind===`terminal`||t.kind===`terminal-streaming`){r.push(t);continue}if(t.kind===`message`&&t.msg.role===`user`){let e=n.get(t);if(e){let n=a.get(e);if(n){i.set(t.msg.sessionId,n);continue}}let o={kind:`thread`,sessionId:t.msg.sessionId,at:t.at,root:t,replies:[]};r.push(o),i.set(t.msg.sessionId,o),a.set(t,o);continue}let e=t.kind===`message`?t.msg.sessionId:t.sessionId,o=i.get(e);o||(o={kind:`thread`,sessionId:e,at:t.kind===`streaming`?t.threadAt??t.at:t.at,replies:[]},r.push(o),i.set(e,o)),o.replies.push(t);let s=r.indexOf(o);s>=0&&s!==r.length-1&&(r.splice(s,1),r.push(o))}return r}function tn(){let[e,t]=(0,D.useState)(!1);return(0,D.useEffect)(()=>{let e=!1;y.getConfig().then(n=>{e||t(n.narrateAssistantReplies??!1)}).catch(()=>{});let n=e=>{let n=e.detail;n&&typeof n.narrateAssistantReplies==`boolean`&&t(n.narrateAssistantReplies)};return window.addEventListener(`gezel:config-updated`,n),()=>{e=!0,window.removeEventListener(`gezel:config-updated`,n)}},[]),e}var nn=100,rn=new Set([`ollama`,`llama-cpp`,`mlx`,`ds4`]),an=180*1e3,on=80,sn=80,cn=700,ln=2e3;function un(e){return e.replace(/["\\]/g,`\\$&`)}var dn=7200*1e3,fn=4;function pn(e,t){let n=new Map((e??[]).map(e=>[e.messageId,e]));for(let e of t)n.set(e.messageId,e);return[...n.values()].sort((e,t)=>e.at<t.at?-1:+(e.at>t.at))}function mn(e,t){let n=t.filter(e=>e.role===`user`),r=e.filter(e=>{if(!e.optimistic)return!0;let t=Date.parse(e.at);return!n.some(n=>{if(n.sessionId!==e.sessionId||n.content!==e.content)return!1;let r=Date.parse(n.at);return Number.isFinite(t)&&Number.isFinite(r)?Math.abs(r-t)<2*6e4:!0})}),i=new Set,a=[];for(let e of[...r,...t]){let t=`${e.sessionId}:${e.at}:${e.role}`;i.has(t)||(i.add(t),a.push(e))}return a.sort((e,t)=>e.at<t.at?-1:+(e.at>t.at)),a}var hn={starting:`Starting engine`,loading_model:`Loading model`,prefill:`Thinking it through`,generating:`Generating`,ready:`Ready`};function gn(e){return e.replace(/!\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/@\[([^\]]+)\]\([^)]+\)/g,`@$1`).replace(/\[([^\]]+)\]\([^)]+\)/g,`$1`).replace(/\*\*([^*]+)\*\*/g,`$1`).replace(/__([^_]+)__/g,`$1`).replace(/(?<!\*)\*([^*]+)\*(?!\*)/g,`$1`).replace(/(?<!_)_([^_]+)_(?!_)/g,`$1`).replace(/~~([^~]+)~~/g,`$1`).replace(/`+([^`]+)`+/g,`$1`).replace(/^\s*#+\s+/gm,``).replace(/^\s*>\s+/gm,``).replace(/^\s*[-*+]\s+/gm,``).replace(/^\s*\d+\.\s+/gm,``).replace(/\s+/g,` `).trim()}function _n({store:e,itemKey:t,render:n,onRendered:r}){let i=(0,D.useCallback)(n=>e.subscribeItem(t,n),[e,t]),a=(0,D.useCallback)(()=>e.getItemSnapshot(t),[e,t]),o=(0,D.useSyncExternalStore)(i,a,a),s=e.items.get(t);return(0,D.useLayoutEffect)(()=>{s&&r?.()},[s,r,o]),s?(0,O.jsx)(O.Fragment,{children:n(s)}):null}function vn({store:e,sessionId:t,userMsg:n,gezels:r}){return(0,O.jsx)(_n,{store:e,itemKey:t,render:e=>(0,O.jsx)(Dn,{payload:{userMsg:n,assistantInfo:{kind:`live`,sessionId:t,slot:e}},gezels:r})})}function yn({scopeKey:e,activeSessionId:t,onFocusSession:n,onToolActivity:r,onArtifactReference:i,onArtifactSeen:a,onWorkspaceReference:o,onWorkspaceSeen:c,onOpenReference:u,onTaskReference:p,queuedTasks:m,emptyPlaceholder:g,emptyContent:_,loadTimeline:v,streamUrl:te,terminalStreamUrl:b,terminalRefreshKey:re,terminalSubmission:x,terminalFocusRequest:S,sessionFocusRequest:C,onTerminalWorkingDirChanged:ie,showProjectName:ae,inflightScope:oe,scopedSessionIds:se,onUnknownSession:le}){let pe=de(),me=(0,D.useRef)(se);me.current=se;let ge=(0,D.useRef)(le);ge.current=le;let ye=tn(),Se=(0,D.useRef)(ye);Se.current=ye;let T=(0,D.useRef)(null),Ce=(0,D.useRef)(null),we=(0,D.useRef)(new Map);(0,D.useEffect)(()=>()=>{Ut(T,Ce)},[]);let[E,k]=(0,D.useState)([]),Te=(0,D.useRef)([]),Ee=(0,D.useRef)(new Set);(0,D.useEffect)(()=>{Te.current=E},[E]),(0,D.useEffect)(()=>{if(p)for(let e of E){if(e.taskRef){let n=!!t&&e.sessionId===t;p(e.taskRef,{scoped:n})}if(e.referencedTasks)for(let t of e.referencedTasks)p(t)}},[E,t,p]),(0,D.useEffect)(()=>{if(!(!a&&!c))for(let e of E){let t=`${e.sessionId}\u0000${e.at}\u0000${e.role}`,n=(n,r)=>{let i=n===`workspace`?c:a;if(!i)return;let o=`${t}\u0000${n}\u0000${r}`;Ee.current.has(o)||(Ee.current.add(o),i(r,e.projectId))};for(let t of Tn(e))n(t.kind,t.path);for(let t of e.toolCalls??[]){if(!t.success)continue;for(let e of[...t.images??[],...t.audios??[],...t.videos??[]])n(`artifact`,e.path);let e=t.paths?.length?t.paths:t.path?[t.path]:[];for(let r of e)t.name===`read_artifact`||t.name===`write_artifact`?n(`artifact`,r):(t.name===`read_file`||t.name===`read_files`||t.name===`write_file`)&&n(`workspace`,r)}}},[E,a,c]);let[A,De]=(0,D.useState)([]),[j,Oe]=(0,D.useState)(0),[M,N]=(0,D.useState)(!1),[P,ke]=(0,D.useState)();(0,D.useEffect)(()=>{let e=It(A,Date.now());if(e===void 0)return;let t=window.setTimeout(()=>Oe(e=>e+1),Math.max(0,e-Date.now()+1));return()=>window.clearTimeout(t)},[A,j]),(0,D.useEffect)(()=>{t&&y.warmSessionCache(t).catch(()=>{})},[t]);let[F,Ae]=(0,D.useState)(!0),[je,Me]=(0,D.useState)(null),[Ne,Pe]=(0,D.useState)(new Map),[I,Fe]=(0,D.useState)(new Map),Ie=(0,D.useRef)(I);Ie.current=I;let[Le,Re]=(0,D.useState)(new Map),[ze,Be]=(0,D.useState)(new Map),Ve=(0,D.useRef)(null);Ve.current||=new Xt;let L=Ve.current,R=(0,D.useRef)(L.items),z=(0,D.useSyncExternalStore)(L.subscribeStructure,L.getStructureSnapshot,L.getStructureSnapshot),He=(0,D.useRef)(null);He.current||=new Xt;let B=He.current,V=(0,D.useRef)(B.items),Ue=(0,D.useSyncExternalStore)(B.subscribeStructure,B.getStructureSnapshot,B.getStructureSnapshot),H=(0,D.useRef)(new Map),Ge=(0,D.useRef)(new Map),U=(0,D.useRef)(null),Ke=(0,D.useRef)(null),[qe,W]=(0,D.useState)(!0),G=(0,D.useRef)(!0);G.current=qe;let[K,q]=(0,D.useState)(null),[Je,Xe]=(0,D.useState)(null),J=(0,D.useRef)(null),Ze=(0,D.useRef)(null),Qe=(0,D.useRef)(!1),[$e,et]=(0,D.useState)(null),tt=(0,D.useRef)(null),nt=(0,D.useRef)(60),rt=(0,D.useRef)(0),it=(0,D.useRef)(0),at=(0,D.useRef)(null),Y=oe?.projectId,X=oe?.gezelId;(0,D.useEffect)(()=>{let e=!1;return Ae(!0),Me(null),Pe(new Map),k([]),De([]),N(!1),ke(void 0),Ee.current.clear(),R.current.clear(),L.markStructureChanged(),V.current.clear(),B.markStructureChanged(),H.current.clear(),Ge.current.clear(),G.current=!0,W(!0),q(null),Xe(null),rt.current=0,it.current=0,(async()=>{try{let t=await v({limit:nn});if(e)return;k(t.messages),N(t.hasMore),ke(t.nextCursor),De(e=>pn(t.terminalEntries,e));try{let n=await y.listInflightTurns({...Y===void 0?{}:{projectId:Y},...X===void 0?{}:{gezelId:X}});if(e)return;for(let e of n.inflight){if(R.current.has(e.sessionId)||me.current&&!me.current.has(e.sessionId))continue;let n=bn(t.messages,e.sessionId);R.current.set(e.sessionId,{gezelId:e.gezelId,projectId:e.projectId,segments:[],startedAt:e.startedAt,lastActivityAt:e.lastProgressAgoMs==null?e.startedAt:Date.now()-e.lastProgressAgoMs,hasProgress:e.lastProgressAgoMs!=null,...n?{sessionTitle:n.sessionTitle,sessionCreatedAt:n.sessionCreatedAt,sessionProviderName:n.sessionProviderName,...n.sessionModel?{sessionModel:n.sessionModel}:{},...n.taskRef?{taskRef:n.taskRef}:{}}:{}})}n.inflight.length>0&&L.markStructureChanged()}catch{}try{let t=await y.getQueueStatus();if(e)return;for(let e of t.sessions)me.current&&!me.current.has(e.sessionId)||H.current.set(e.sessionId,e.entries.map(e=>({id:e.queueId,preview:e.preview,enqueuedAt:e.enqueuedAt,...e.nudge?{nudge:!0}:{}})));t.sessions.length>0&&L.markStructureChanged()}catch{}try{let t=await v({limit:nn});if(e)return;k(e=>mn(e,t.messages)),De(e=>pn(t.terminalEntries,e))}catch{}}catch(t){e||Me(t.message)}finally{e||Ae(!1)}})(),()=>{e=!0}},[e,v,Y,X]);let[Z,ot]=(0,D.useState)(`copilot`),[st,Q]=(0,D.useState)({}),[ct,lt]=(0,D.useState)(!1);(0,D.useEffect)(()=>{let e=!1;return(async()=>{try{let t=await y.getConfig();if(e)return;ot(t.provider),Q(t.defaultModel??{}),lt(t.debugMode===!0)}catch{}})(),()=>{e=!0}},[]);let ut=(0,D.useCallback)((e,t,n=!1)=>{let r=bn(e,t.sessionId);return{sessionId:t.sessionId,gezelId:t.gezelId,projectId:t.projectId,sessionTitle:r?.sessionTitle??l(t.content),sessionCreatedAt:r?.sessionCreatedAt??t.at,sessionLastActivityAt:t.at,sessionProviderName:r?.sessionProviderName??Z,...r?.sessionModel?{sessionModel:r.sessionModel}:{},...r?.taskRef?{taskRef:r.taskRef}:{},...r?.stepId?{stepId:r.stepId}:{},role:`user`,content:t.content,at:t.at,...t.from?{from:t.from}:{},...n?{optimistic:!0}:{}}},[Z]),dt=(0,D.useCallback)(e=>I.get(e)?.provider??Z,[I,Z]),pt=(0,D.useCallback)(e=>{let t=I.get(e),n=dt(e),r=t?.model;return r?`Provider: ${On(n)} (${r})`:`Provider: ${On(n)}`},[I,dt]),mt=(0,D.useCallback)((e,t)=>{let n=st[Z],r=rn.has(e);if(e!==Z)return t&&!r?`${On(e)} · ${t}`:On(e);if(!r&&t&&n&&t!==n)return t},[Z,st]),ht=(0,D.useRef)(null),gt=(0,D.useCallback)(()=>{if(ht.current)return ht.current;let e=(async()=>{try{let e=await y.listGezels(),t=new Map;for(let n of e.gezels)t.set(n.id,n);Fe(t)}catch{}finally{ht.current=null}})();return ht.current=e,e},[]);(0,D.useEffect)(()=>{gt()},[gt]),(0,D.useEffect)(()=>{let e=e=>{let t=e.detail;t?.id&&Fe(e=>{let n=new Map(e);return n.set(t.id,{...n.get(t.id),...t}),n})};return window.addEventListener(`gezel:gezel-updated`,e),()=>window.removeEventListener(`gezel:gezel-updated`,e)},[]),(0,D.useEffect)(()=>{if(!ae)return;let e=!1;return(async()=>{try{let t=await y.listProjects();if(e)return;let n=new Map;for(let e of t.projects)n.set(e.id,e);Re(n)}catch{}})(),()=>{e=!0}},[ae]);let _t=(0,D.useCallback)(async()=>{try{let e=await y.listQuestions({pending:!0});Be(t=>{let n=new Map(t);for(let[e,t]of n)t.answer||n.delete(e);for(let t of e.questions)n.set(t.id,t);return n})}catch{}},[]);(0,D.useEffect)(()=>{_t()},[e,_t]),(0,D.useEffect)(()=>{let e=new AbortController,t=!1,n=250;return(async()=>{for(;!t;){try{let r={url:te(),headers:y.authHeader(),signal:e.signal,fetch:y.getFetch()};for await(let e of w(r)){if(t)return;yt(e),n=250}}catch(e){if(t||e.name===`AbortError`)return;console.warn(`[ChatTimelineView] envelope stream error (reconnecting in ${n}ms):`,e)}if(t)return;await new Promise(e=>setTimeout(e,n)),n=Math.min(n*2,5e3)}})(),()=>{t=!0,e.abort()}},[e,te]),(0,D.useEffect)(()=>{if(!b)return;let e=new AbortController,t=!1,n=250;return(async()=>{let{streamTerminalEvents:r}=await ne(async()=>{let{streamTerminalEvents:e}=await import(`./dist-D5aoNQwk.js`).then(e=>e.r);return{streamTerminalEvents:e}},__vite__mapDeps([0,1,2]));for(;!t;){try{for await(let i of r({url:b(),headers:y.authHeader(),signal:e.signal,fetch:y.getFetch()})){if(t)return;if(i.kind===`workingDirChanged`){ie?.(i.threadId,i.newWorkingDir),n=250;continue}if(i.kind===`openFile`){o?.(i.path,i.projectId),n=250;continue}if(i.kind===`runStarted`){V.current.set(i.runId,{projectId:i.projectId,threadId:i.threadId,commandMessageId:i.commandMessageId,startedAt:i.at,cwd:i.cwd,content:``}),B.markStructureChanged(),n=250;continue}if(i.kind===`outputChunk`){let e=V.current.get(i.runId);e&&(e.content+=i.chunk,e.awaitingInput&&delete e.awaitingInput,B.markItemChanged(i.runId)),n=250;continue}if(i.kind===`inputRequested`){let e=V.current.get(i.runId);e&&(e.awaitingInput={promptLine:i.promptLine,mode:i.mode},B.markItemChanged(i.runId)),n=250;continue}i.runId&&(V.current.delete(i.runId),B.markStructureChanged()),De(e=>{if(e.some(e=>e.messageId===i.message.id))return e;let t={threadId:i.threadId,projectId:i.projectId,workingDir:i.workingDir,threadCreatedAt:i.message.at,threadLastActivityAt:i.message.at,messageId:i.message.id,msgKind:i.message.kind,content:i.message.content,at:i.message.at,...i.message.resolvedFrom?{resolvedFrom:i.message.resolvedFrom}:{},...i.message.stdout===void 0?{}:{stdout:i.message.stdout},...i.message.stderr===void 0?{}:{stderr:i.message.stderr},...i.message.exitCode===void 0?{}:{exitCode:i.message.exitCode},...i.message.durationMs===void 0?{}:{durationMs:i.message.durationMs},...i.message.truncated?{truncated:!0}:{},...i.message.errorMessage?{errorMessage:i.message.errorMessage}:{},...i.message.fileReferences?{fileReferences:i.message.fileReferences}:{},...i.message.cwd===void 0?{}:{cwd:i.message.cwd}},n=[...e,t];return n.sort((e,t)=>e.at<t.at?-1:+(e.at>t.at)),n}),n=250}}catch(e){if(t||e.name===`AbortError`)return;console.warn(`[ChatTimelineView] terminal stream error (reconnecting in ${n}ms):`,e)}if(t)return;await new Promise(e=>setTimeout(e,n)),n=Math.min(n*2,5e3)}})(),()=>{t=!0,e.abort()}},[e,b,o]),(0,D.useEffect)(()=>{if(!re)return;let e=!1;return v({limit:nn}).then(t=>{e||De(e=>pn(t.terminalEntries,e))}).catch(()=>{}),()=>{e=!0}},[re,v]),(0,D.useEffect)(()=>{x&&(q({kind:`terminal`,key:`terminal:${x.runId}`,runId:x.runId,threadId:x.threadId,input:x.input}),Xe(null))},[x]);let vt=(0,D.useCallback)(async()=>{try{let e=await v({limit:nn});k(t=>mn(t,e.messages));let t=he(R.current,e.messages);for(let e of t)R.current.delete(e);t.length>0&&L.markStructureChanged()}catch{}},[v,L.markStructureChanged]);(0,D.useEffect)(()=>{let e=!1,t=!1,n=async()=>{if(t||R.current.size===0)return;t=!0;let n=new Map(R.current);try{let t=await y.listInflightTurns({...Y===void 0?{}:{projectId:Y},...X===void 0?{}:{gezelId:X}});if(e)return;let r=new Set(t.inflight.map(e=>e.sessionId)),i=fe(R.current,n,r);if(i.length===0)return;for(let e of i)R.current.delete(e),we.current.delete(e);L.markStructureChanged(),vt()}catch{}finally{t=!1}},r=window.setInterval(()=>{n()},5e3);return()=>{e=!0,window.clearInterval(r)}},[Y,X,vt,L.markStructureChanged]),(0,D.useEffect)(()=>Ye(e=>{if(Y!==void 0&&e.projectId!==Y||X!==void 0&&e.gezelId!==X||me.current&&!me.current.has(e.sessionId))return;let t=Date.parse(e.at);if(k(n=>{if(n.some(n=>{if(n.sessionId!==e.sessionId||n.role!==`user`||n.content!==e.content)return!1;let r=Date.parse(n.at);return Number.isFinite(t)&&Number.isFinite(r)?Math.abs(r-t)<2*6e4:!0}))return n;let r=[...n,ut(n,e,!0)];return r.sort((e,t)=>e.at<t.at?-1:+(e.at>t.at)),r}),!R.current.has(e.sessionId)){let n=bn(Te.current,e.sessionId),r=Number.isFinite(t)?t:Date.now();R.current.set(e.sessionId,{gezelId:e.gezelId,projectId:e.projectId,segments:[],startedAt:r,lastActivityAt:r,hasProgress:!1,...n?{sessionTitle:n.sessionTitle}:{sessionTitle:l(e.content)},...n?{sessionCreatedAt:n.sessionCreatedAt}:{sessionCreatedAt:e.at},...n?{sessionProviderName:n.sessionProviderName,...n.sessionModel?{sessionModel:n.sessionModel}:{}}:{},...n?.taskRef?{taskRef:n.taskRef}:{},...n?.stepId?{stepId:n.stepId}:{}}),L.markStructureChanged()}q({kind:`chat`,key:`chat:${e.sessionId}:${e.at}`,sessionId:e.sessionId,content:e.content,at:e.at}),Xe(null)}),[Y,X,ut,L.markStructureChanged]);let yt=(0,D.useCallback)(e=>{let{sessionId:t,gezelId:n,projectId:i,event:a}=e;if(Y!==void 0&&i!==Y||X!==void 0&&n!==X)return;let o=me.current;if(o&&!o.has(t)){ge.current?.(t);return}if(Ie.current.has(n)||gt(),a.type===`user_message`){!a.message.hidden&&!a.message.from&&(Ut(T,Ce),we.current.delete(t));let r=bn(E,t),o={sessionId:t,gezelId:n,projectId:i,sessionTitle:r?.sessionTitle??l(a.message.content),sessionCreatedAt:r?.sessionCreatedAt??a.message.at,sessionLastActivityAt:a.message.at,sessionProviderName:r?.sessionProviderName??Z,...r?.sessionSource?{sessionSource:r.sessionSource}:e.sessionSource?{sessionSource:e.sessionSource}:{},...r?.sessionModel?{sessionModel:r.sessionModel}:{},...r?.taskRef?{taskRef:r.taskRef}:{},...r?.stepId?{stepId:r.stepId}:{},...r?.parentSession?{parentSession:r.parentSession}:e.parentSession?{parentSession:e.parentSession}:{},...r?.handoffFrom?{handoffFrom:r.handoffFrom}:e.handoffFrom?{handoffFrom:e.handoffFrom}:{},role:a.message.role,content:a.message.content,at:a.message.at,...a.message.from?{from:a.message.from}:{},...a.message.nudge?{nudge:!0}:{},...a.message.origin===`system`?{origin:`system`}:{}},s=`${t}:${a.message.at}:${a.message.role}`;if(k(e=>{if(a.message.hidden)return e;let n=e.filter(e=>!e.optimistic||!(e.sessionId===t&&e.role===a.message.role&&e.content===a.message.content));if(n.some(e=>`${e.sessionId}:${e.at}:${e.role}`===s))return n;let r=[...n,o];return r.sort((e,t)=>e.at<t.at?-1:+(e.at>t.at)),r}),a.message.role===`user`&&R.current.get(t)?.error&&R.current.delete(t),a.message.role===`user`&&!R.current.has(t)){let s=Date.parse(a.message.at),c=Number.isFinite(s)?s:Date.now();R.current.set(t,{gezelId:n,projectId:i,segments:[],startedAt:c,lastActivityAt:c,hasProgress:!1,...r?{sessionTitle:r.sessionTitle}:{sessionTitle:o.sessionTitle},...r?{sessionCreatedAt:r.sessionCreatedAt}:{sessionCreatedAt:o.sessionCreatedAt},...r?{sessionProviderName:r.sessionProviderName,...r.sessionModel?{sessionModel:r.sessionModel}:{}}:{},...r?.sessionSource?{sessionSource:r.sessionSource}:e.sessionSource?{sessionSource:e.sessionSource}:{},...r?.taskRef?{taskRef:r.taskRef}:{},...r?.parentSession?{parentSession:r.parentSession}:e.parentSession?{parentSession:e.parentSession}:{},...r?.handoffFrom?{handoffFrom:r.handoffFrom}:e.handoffFrom?{handoffFrom:e.handoffFrom}:{}}),L.markStructureChanged()}}else if(a.type===`delta`){let e=R.current.get(t)??s(n,i,t),r=e.segments[e.segments.length-1],o=Date.now(),c=o-e.lastActivityAt<5e3;r?.kind===`text`&&c?r.content+=a.content:e.segments.push({kind:`text`,content:a.content}),e.lastActivityAt=o,e.hasProgress=!0,delete e.queueAhead,delete e.queuedAt,e.wirePulseCount=0,e.thinkingLabel=void 0,delete e.thinkingProgress,delete e.thinkingDetail,delete e.liveToolArgs,R.current.set(t,e),L.markItemChanged(t)}else if(a.type===`reasoning_delta`){let e=R.current.get(t)??s(n,i,t),r=e.segments[e.segments.length-1];r?.kind===`reasoning`?r.content+=a.content:e.segments.push({kind:`reasoning`,content:a.content}),e.lastActivityAt=Date.now(),e.hasProgress=!0,delete e.queueAhead,delete e.queuedAt,e.wirePulseCount=0,delete e.thinkingProgress,delete e.thinkingDetail,R.current.set(t,e),L.markItemChanged(t)}else if(a.type===`tool_args_delta`){let e=R.current.get(t)??s(n,i,t),r=e.liveToolArgs,o=a.name.length>0?a.name:r?.name??``,c=((r?.head??``)+a.content).slice(0,400),l=((r?.tail??``)+a.content).slice(-2e3);e.liveToolArgs={name:o,chars:(r?.chars??0)+a.content.length,head:c,tail:l},e.lastActivityAt=Date.now(),e.hasProgress=!0,delete e.queueAhead,delete e.queuedAt,R.current.set(t,e),L.markItemChanged(t)}else if(a.type===`wire_pulse`){let e=R.current.get(t)??s(n,i,t);e.wirePulseCount=(e.wirePulseCount??0)+1,e.lastActivityAt=Date.now(),e.hasProgress=!0,R.current.set(t,e),L.markItemChanged(t)}else if(a.type===`intent`){let e=R.current.get(t)??s(n,i,t);e.segments.push({kind:`intent`,label:a.label}),e.lastActivityAt=Date.now(),e.hasProgress=!0,e.wirePulseCount=0,delete e.queueAhead,delete e.queuedAt,R.current.set(t,e),L.markItemChanged(t)}else if(a.type===`heartbeat`){let e=R.current.get(t)??s(n,i,t);e.lastActivityAt=Date.now(),e.hasProgress=!0,e.wirePulseCount=0,e.thinkingLabel=a.label,R.current.set(t,e),L.markItemChanged(t)}else if(a.type===`warning`){let e=R.current.get(t)??s(n,i,t);e.warnings=[...e.warnings??[],a],R.current.set(t,e),L.markItemChanged(t)}else if(a.type===`queued`){let e=R.current.get(t)??s(n,i,t);e.queueAhead=a.aheadOf,e.queuedAt=Date.now(),R.current.set(t,e),L.markItemChanged(t)}else if(a.type===`queue_enqueued`){let e=H.current.get(t)??[],n={id:a.queueId,preview:a.preview,enqueuedAt:a.enqueuedAt,...a.nudge?{nudge:!0}:{}},r=e.findIndex(e=>e.id===a.queueId);r>=0?e[r]=n:e.push(n),H.current.set(t,e),L.markStructureChanged()}else if(a.type===`queue_removed`){let e=H.current.get(t);if(e){let n=e.filter(e=>e.id!==a.queueId);n.length===0?H.current.delete(t):H.current.set(t,n),L.markStructureChanged()}}else if(a.type===`tool`){let e=R.current.get(t)??s(n,i,t),o={name:a.name,durationMs:a.durationMs,success:a.success,...a.errorMessage?{errorMessage:a.errorMessage}:{},...a.path?{path:a.path}:{},...a.paths&&a.paths.length>0?{paths:a.paths}:{},...a.argsSummary?{argsSummary:a.argsSummary}:{},...a.argsFull?{argsFull:a.argsFull}:{},...a.resultText?{resultText:a.resultText}:{},...a.resultTruncated?{resultTruncated:!0}:{},...a.images&&a.images.length>0?{images:a.images}:{},...a.diff===void 0?{}:{diff:a.diff},...a.addedLines===void 0?{}:{addedLines:a.addedLines},...a.removedLines===void 0?{}:{removedLines:a.removedLines},...a.card?{card:a.card}:{},projectId:i};e.segments.push({kind:`tool`,tool:o}),e.lastActivityAt=Date.now(),e.hasProgress=!0,e.wirePulseCount=0,delete e.liveToolArgs,delete e.queueAhead,delete e.queuedAt,R.current.set(t,e),L.markItemChanged(t),r?.(o)}else if(a.type===`complete`){k(e=>e.map(e=>e.sessionId===t?{...e,sessionLastTurnError:void 0,sessionLastTurnErrorDetail:void 0}:e)),Pe(e=>{if(!e.has(t))return e;let n=new Map(e);return n.delete(t),n});let e=R.current.get(t);e&&(e.segments=[],e.lastActivityAt=Date.now(),e.hasProgress=!0,e.wirePulseCount=0,delete e.liveToolArgs,delete e.queueAhead,delete e.error,R.current.set(t,e)),L.markItemChanged(t),vt();let r=a.message.content.trim().length;console.debug(`[narrate] complete event — contentLen=${r} gezelId=${n} projectId=${i} sessionId=${t} (buffering for done)`),r>0&&we.current.set(t,{content:a.message.content,gezelId:n,projectId:i})}else if(a.type===`error`){k(e=>e.map(e=>e.sessionId===t?{...e,sessionLastTurnError:a.error,sessionLastTurnErrorDetail:a.errorDetail}:e)),Pe(e=>{if(!e.has(t))return e;let n=new Map(e);return n.delete(t),n});let e=R.current.get(t);e&&(e.error=a.error,e.errorDetail=a.errorDetail,R.current.set(t,e),L.markItemChanged(t))}else if(a.type===`cancelled`)R.current.delete(t)&&L.markStructureChanged(),vt();else if(a.type===`done`){let e=R.current.get(t);e&&!e.error&&(R.current.delete(t),L.markStructureChanged());let n=we.current.get(t);n&&(we.current.delete(t),Se.current&&(console.debug(`[narrate] done event — playing buffered narration chars=${n.content.length} sessionId=${t}`),Gt(n.content,n.gezelId,n.projectId,T,Ce))),vt()}else if(a.type===`engine_phase`){let e=R.current.get(t)??s(n,i,t);if(e.lastActivityAt=Date.now(),e.hasProgress=!0,a.activity?.trim()&&(e.activity=a.activity.trim()),a.phase===`ready`)delete e.thinkingLabel,delete e.thinkingProgress,delete e.thinkingDetail,delete e.thinkingPhase;else{let t=hn[a.phase];a.progress===void 0?(e.thinkingLabel=a.detail??t,e.thinkingPhase!==a.phase&&(delete e.thinkingProgress,delete e.thinkingDetail)):(e.thinkingLabel=t,e.thinkingProgress=a.progress,a.detail?e.thinkingDetail=a.detail:delete e.thinkingDetail),e.thinkingPhase=a.phase}R.current.set(t,e),L.markItemChanged(t)}else if(a.type===`gpu_swap`){let e=R.current.get(t)??s(n,i,t);e.lastActivityAt=Date.now(),a.state===`ended`?(delete e.gpuSwapTask,delete e.gpuSwapDetail,delete e.gpuSwapPrompt,delete e.gpuSwapProgress,delete e.gpuSwapStep,delete e.gpuSwapTotalSteps,delete e.gpuSwapSecondsPerStep):(e.gpuSwapTask=a.task,a.detail?e.gpuSwapDetail=a.detail:a.state===`started`&&delete e.gpuSwapDetail,a.prompt&&(e.gpuSwapPrompt=a.prompt),typeof a.progress==`number`&&(e.gpuSwapProgress=a.progress),typeof a.step==`number`&&(e.gpuSwapStep=a.step),typeof a.totalSteps==`number`&&(e.gpuSwapTotalSteps=a.totalSteps),typeof a.secondsPerStep==`number`&&(e.gpuSwapSecondsPerStep=a.secondsPerStep)),R.current.set(t,e),L.markItemChanged(t)}else if(a.type===`awaiting_gezel`){let e=R.current.get(t)??s(n,i,t);e.lastActivityAt=Date.now(),a.state===`ended`?delete e.awaitingGezelName:e.awaitingGezelName=a.targetGezelName,R.current.set(t,e),L.markItemChanged(t)}else a.type===`context_warning`?Ge.current.get(t)?.kind!==`compacted`&&(Ge.current.set(t,{kind:`warning`,estimatedTokens:a.estimatedTokens,numCtx:a.numCtx,model:a.model,at:Date.now()}),L.markStructureChanged()):a.type===`context_compacted`?(Ge.current.set(t,{kind:`compacted`,model:a.model,removedCount:a.removedCount,at:Date.now()}),vt(),L.markStructureChanged()):(a.type===`question_asked`||a.type===`question_answered`)&&(Be(e=>{let t=new Map(e);return a.type===`question_answered`&&!a.question.answer?t.delete(a.question.id):t.set(a.question.id,a.question),t}),a.type===`question_asked`&&vt());function s(t,n,r){let i=bn(E,r);L.markStructureChanged();let a=Date.now();return{gezelId:t,projectId:n,segments:[],startedAt:a,lastActivityAt:a,hasProgress:!1,...i?{sessionTitle:i.sessionTitle}:{},...i?{sessionCreatedAt:i.sessionCreatedAt}:{},...i?.taskRef?{taskRef:i.taskRef}:{},...i?.parentSession?{parentSession:i.parentSession}:e.parentSession?{parentSession:e.parentSession}:{},...i?.handoffFrom?{handoffFrom:i.handoffFrom}:e.handoffFrom?{handoffFrom:e.handoffFrom}:{},...i?.sessionSource?{sessionSource:i.sessionSource}:e.sessionSource?{sessionSource:e.sessionSource}:{}}}},[E,r,vt,gt,Z,Y,X,L.markItemChanged,L.markStructureChanged]),bt=(0,D.useMemo)(()=>{let e=[];for(let[t,n]of R.current.entries())e.push({kind:`streaming`,sessionId:t,slot:n});let t=E.map(e=>({kind:`message`,msg:e,at:e.at})),n=e.map(e=>({kind:`streaming`,sessionId:e.sessionId,slot:e.slot,at:new Date(e.slot.lastActivityAt).toISOString(),threadAt:new Date(e.slot.startedAt).toISOString()})),r=A.map(e=>({kind:`terminal`,entry:e,at:e.at})),i=[];for(let[e,t]of V.current.entries())i.push({kind:`terminal-streaming`,runId:e,slot:t,at:t.startedAt});let a=[...t,...n,...r,...i],o=Date.now();return a.sort((e,t)=>zt(e,t,o)),a},[E,A,z,Ue,j]),xt=(0,D.useMemo)(()=>Qt(Vt(en(bt),t,Date.now())),[bt,t,j]),Ct=xt.items,wt=xt.depthBySession,Tt=xt.branchBySession,Et=(0,D.useMemo)(()=>{if(!m?.length)return[];let e=new Set;for(let[t,n]of R.current.entries()){let r=n.taskRef??bn(E,t)?.taskRef;r&&e.add(r)}return m.filter(t=>{if(e.has(t.task.ref))return!1;let n=t.wait.sessionId;return!n||!R.current.has(n)&&!E.some(e=>e.sessionId===n)})},[m,E,z]);(0,D.useEffect)(()=>{let e=U.current;if(!e)return;let t=bt.length>rt.current,n=e.scrollHeight>it.current;rt.current=bt.length,it.current=e.scrollHeight,!(!t&&!n)&&qe&&e.scrollTo({top:e.scrollHeight,behavior:`instant`})},[bt,qe]);let Dt=(0,D.useCallback)(()=>{at.current===null&&(at.current=requestAnimationFrame(()=>{at.current=null;let e=U.current;if(!e)return;let t=e.scrollHeight,n=t>it.current;it.current=t,!(!n||!G.current)&&e.scrollTo({top:t,behavior:`instant`})}))},[]);(0,D.useEffect)(()=>{let e=U.current;if(!e||!K||Je===K.key)return;let t=null;if(K.kind===`chat`){let n=Date.parse(K.at),r=E.filter(e=>e.sessionId===K.sessionId&&e.role===`user`&&e.content===K.content).sort((e,t)=>Math.abs(Date.parse(e.at)-n)-Math.abs(Date.parse(t.at)-n))[0];if(r){let n=un(`msg:${r.sessionId}:${r.at}:${r.role}`);t=e.querySelector(`[data-msg-id="${n}"]`)}}else{let n=[...A].reverse().find(e=>e.threadId===K.threadId&&e.msgKind===`command`&&(e.content===K.input||e.resolvedFrom===K.input));if(n){let r=un(n.messageId);t=e.querySelector(`[data-terminal-message-id="${r}"]`)}}if(!t)return;let n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i=Math.max(0,e.scrollTop+r.top-n.top-12);G.current=!0,W(!0),e.scrollTo({top:i}),Xe(K.key)},[E,A,K,Je]),(0,D.useEffect)(()=>{if(!S||J.current===S.requestKey)return;let e=U.current;if(!e)return;let t=un(S.threadId),n=e.querySelectorAll(`[data-terminal-thread-id="${t}"]`),r=n[n.length-1];r&&(J.current=S.requestKey,G.current=!1,W(!1),typeof r.scrollIntoView==`function`&&r.scrollIntoView({block:`center`}),r.classList.add(`timeline-focus-flash`),window.setTimeout(()=>r.classList.remove(`timeline-focus-flash`),ln))},[S,A]);let kt=(0,D.useCallback)((e,t)=>{let r=U.current;if(!r)return!1;let i=un(e),a=r.querySelector(`[data-session-error="${i}"]`),o=r.querySelectorAll(`[data-session-id="${i}"]`),s=null;if(t?.messageIndex!==void 0){let n=Te.current.filter(t=>t.sessionId===e),i=n[Math.max(0,Math.min(t.messageIndex-1,n.length-1))];i&&(s=r.querySelector(`[data-msg-id="${un(`msg:${i.sessionId}:${i.at}:${i.role}`)}"]`))}let c=s??a??o[o.length-1]??null;if(!c)return!1;if(G.current=!1,W(!1),typeof c.scrollIntoView==`function`&&c.scrollIntoView({block:`center`}),c.classList.add(`timeline-focus-flash`),window.setTimeout(()=>c.classList.remove(`timeline-focus-flash`),ln),t?.notifyParent!==!1){let t=Te.current.find(t=>t.sessionId===e);t&&n?.(e,t.gezelId,t.projectId)}return!0},[n]),At=(0,D.useRef)(null),[jt,Nt]=(0,D.useState)(0),Pt=(0,D.useCallback)((e,t)=>{At.current={sessionId:e,notifyParent:t?.notifyParent!==!1,...t?.messageIndex===void 0?{}:{messageIndex:t.messageIndex}},Nt(e=>e+1)},[]);(0,D.useEffect)(()=>{let e=At.current;if(e){if(kt(e.sessionId,{notifyParent:e.notifyParent,...e.messageIndex===void 0?{}:{messageIndex:e.messageIndex}})){At.current=null;return}if(!(F||Qe.current)){if(!M||!P){At.current=null;return}Qe.current=!0,(async()=>{try{let t=await v({limit:nn,before:P});if(At.current!==e)return;k(e=>[...t.messages,...e]),N(t.hasMore),ke(t.nextCursor)}catch{At.current===e&&(At.current=null)}finally{Qe.current=!1,Nt(e=>e+1)}})()}}},[bt,jt,kt,F,M,P,v]),(0,D.useEffect)(()=>{let e=e=>{let t=e.detail;t?.sessionId&&t.projectId===Y&&(Y&&_e(Y),Pt(t.sessionId))};return window.addEventListener(`gezel:focus-session-error`,e),()=>window.removeEventListener(`gezel:focus-session-error`,e)},[Y,Pt]);let Ft=(0,D.useRef)(void 0);(0,D.useEffect)(()=>{if(Ft.current!==Y&&(Ft.current=Y,At.current=null),!Y)return;let e=_e(Y);e&&Pt(e.sessionId)},[Y,Pt]),(0,D.useEffect)(()=>{C&&Ze.current!==C.requestKey&&(Ze.current=C.requestKey,Pt(C.sessionId,{notifyParent:!1,...C.messageIndex===void 0?{}:{messageIndex:C.messageIndex}}))},[C,Pt]);let Lt=(0,D.useCallback)(()=>{let e=U.current;if(!e){et(e=>e===null?e:null);return}let t=e.getBoundingClientRect(),n=e.parentElement;if(n){let t=e.offsetWidth-e.clientWidth;n.style.setProperty(`--chat-timeline-sb-width`,`${t}px`)}let r=e.parentElement?.querySelector(`.chat-sticky-header`);if(r){let e=r.getBoundingClientRect().height;e>0&&(nt.current=e)}let i=nt.current,a=t.top,o=t.top+i,s=null,c=0,l=null,u=null,d=null,f=e.querySelectorAll(`[data-msg-id]`);for(let e of f){let t=e.dataset.msgId,n=e.dataset.sessionId;if(!t)continue;let r=e.getBoundingClientRect(),i=r.top<a&&r.bottom>o,d=e.classList.contains(`msg-assistant`)||e.classList.contains(`msg-from-gezel`);i&&d&&(s=t,c=r.top,l=n??null,u=r)}if(n&&u){let e=n.getBoundingClientRect(),t=u.left-e.left;n.style.setProperty(`--chat-sticky-left`,`${t}px`),n.style.setProperty(`--chat-sticky-width`,`${u.width}px`)}if(s&&l)for(let e of f){let t=e.dataset.msgId,n=e.dataset.sessionId;!t||n!==l||e.classList.contains(`msg-user`)&&e.getBoundingClientRect().bottom<=c&&(d=t)}let p=s&&d?{userMessageId:d,assistantMessageId:s}:null;et(e=>e===p||e&&p&&e.userMessageId===p.userMessageId&&e.assistantMessageId===p.assistantMessageId?e:p)},[]),Rt=(0,D.useCallback)(()=>{tt.current===null&&(tt.current=requestAnimationFrame(()=>{tt.current=null,Lt()}))},[Lt]);(0,D.useEffect)(()=>{Rt()},[bt,Rt]),(0,D.useEffect)(()=>{let e=U.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(Rt);return t.observe(e),()=>t.disconnect()},[Rt]),(0,D.useEffect)(()=>()=>{tt.current!==null&&(cancelAnimationFrame(tt.current),tt.current=null),at.current!==null&&(cancelAnimationFrame(at.current),at.current=null),Ke.current!==null&&(window.clearTimeout(Ke.current),Ke.current=null)},[]);let Bt=(0,D.useCallback)(()=>{Rt();let e=U.current;if(!e)return;e.classList.add(`chat-timeline-scrolling`),Ke.current!==null&&window.clearTimeout(Ke.current),Ke.current=window.setTimeout(()=>{U.current?.classList.remove(`chat-timeline-scrolling`),Ke.current=null},cn);let t=e.scrollHeight-(e.scrollTop+e.clientHeight)<=on;if(G.current=t,W(e=>e===t?e:t),e.scrollTop<=sn&&M&&!F&&!Qe.current&&P){Qe.current=!0;let t=e.scrollHeight,n=e.scrollTop;(async()=>{try{let e=await v({limit:nn,before:P});k(t=>[...e.messages,...t]),N(e.hasMore),ke(e.nextCursor),requestAnimationFrame(()=>{let e=U.current;e&&e.scrollTo({top:e.scrollHeight-t+n,behavior:`instant`}),Qe.current=!1,At.current&&Nt(e=>e+1)})}catch{Qe.current=!1,At.current&&Nt(e=>e+1)}})()}},[M,F,P,v,Rt]),Ht=(0,D.useCallback)(()=>{W(e=>{let t=!e;if(G.current=t,t){let e=U.current;e&&e.scrollTo({top:e.scrollHeight,behavior:`instant`})}return t})},[]),Wt=(0,D.useMemo)(()=>{if(!$e)return null;let e=E.find(e=>`msg:${e.sessionId}:${e.at}:${e.role}`===$e.userMessageId);if(!e)return null;let t=null;if($e.assistantMessageId.startsWith(`live:`)){let e=$e.assistantMessageId.slice(5);R.current.has(e)&&(t={kind:`live`,sessionId:e})}else{let e=E.find(e=>`msg:${e.sessionId}:${e.at}:${e.role}`===$e.assistantMessageId);e&&(t={kind:`message`,msg:e})}return t?{userMsg:e,assistantInfo:t}:null},[$e,E,z]),Yt=Et.slice(0,fn),Zt=Et.length-Yt.length,$t=(0,O.jsxs)(O.Fragment,{children:[Yt.map(e=>(0,O.jsx)(ft,{task:e.task,wait:e.wait,gezel:I.get(e.wait.gezelId),onTaskReference:e=>window.dispatchEvent(new CustomEvent(`gezel:open-tab`,{detail:{kind:`task`,ref:e}}))},`queued-task:${e.task.ref}`)),Zt>0&&(0,O.jsxs)(`p`,{className:`msg-queued-task-overflow muted small`,children:[`+ `,Zt,` more task`,Zt===1?``:`s`,` waiting in the queue.`]})]}),gn=(e,t)=>{Pe(n=>{let r=new Map(n);return t?r.set(e,t):r.delete(e),r})},yn=async(e,t)=>{gn(e,{busy:`acknowledge`});try{await y.clearProjectErrors(t),k(e=>e.map(e=>e.projectId===t?{...e,sessionLastTurnError:void 0,sessionLastTurnErrorDetail:void 0}:e));let e=!1;for(let[n,r]of R.current)r.projectId!==t||!r.error||(R.current.delete(n),e=!0);e&&(L.markStructureChanged(),vt()),Pe(e=>{let n=new Map(e);for(let e of Te.current)e.projectId===t&&n.delete(e.sessionId);return n}),window.dispatchEvent(new CustomEvent(`gezel:session-error-cleared`,{detail:{projectId:t}}))}catch{gn(e,{error:`Could not clear the alert. Check the connection and try again.`})}},wn=async e=>{gn(e,{busy:`retry`});try{await y.retryChatSessionTurn(e)}catch{gn(e,{error:`Retry could not start. Check the connection or settings, then try again.`})}},kn=(e,t,n,r,i)=>{let a=Ne.get(e),o=a?.busy;return(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`div`,{className:`timeline-session-error-actions`,"aria-label":`Failed turn actions`,children:[Cn(t,n)&&(0,O.jsx)(`button`,{type:`button`,className:`timeline-session-error-action timeline-session-error-action-primary`,disabled:o!==void 0,onClick:()=>void wn(e),children:o===`retry`?`Retrying…`:`Retry`}),xn(t)&&(0,O.jsx)(`button`,{type:`button`,className:`timeline-session-error-action secondary`,disabled:o!==void 0,onClick:()=>window.dispatchEvent(new CustomEvent(`gezel:navigate`,{detail:{view:`settings`,section:`defaults`}})),children:`Open Settings`}),r&&(0,O.jsx)(`button`,{type:`button`,className:`timeline-session-error-action secondary`,title:`Clear this project's failed-turn alerts without rerunning the work`,disabled:o!==void 0,onClick:()=>void yn(e,r),children:o===`acknowledge`?`Acknowledging…`:`Acknowledge`}),!h(t)&&!Sn(n)&&(0,O.jsx)(ve,{className:`timeline-session-error-link`,report:{surface:i,message:t,detail:n}})]}),a?.error&&(0,O.jsx)(`p`,{className:`timeline-session-error-action-error`,role:`alert`,children:a.error})]})};if(F&&E.length===0)return(0,O.jsx)(`div`,{className:`chat-timeline chat-timeline-loading`,children:(0,O.jsx)(`p`,{className:`muted small`,children:`Loading…`})});if(je)return(0,O.jsx)(`div`,{className:`chat-timeline chat-timeline-error`,children:(0,O.jsx)(`p`,{className:`error`,children:je})});if(bt.length===0)return(0,O.jsxs)(`div`,{className:`chat-timeline`,ref:U,"data-testid":`chat-timeline`,children:[_??(g?(0,O.jsx)(`p`,{className:`placeholder`,children:g}):null),$t]});let An=null,jn=null,Mn,Nn=null,Pn=new Set,Fn=new Map,In=new Set;for(let e of E)e.pendingQuestionId&&In.add(e.pendingQuestionId);let Ln=new Map;for(let e of ze.values()){if(e.answer||In.has(e.id))continue;let t=Ln.get(e.sessionId);(!t||e.createdAt>t.createdAt)&&Ln.set(e.sessionId,e)}let Rn=[],zn=(e,t,n,r)=>{Rn.push((0,O.jsxs)(`div`,{className:`timeline-session-error-banner`,"data-session-error":e,role:`alert`,children:[(0,O.jsxs)(`div`,{className:`timeline-session-error-body`,children:[(0,O.jsx)(`span`,{"aria-hidden":`true`,children:`✗`}),(0,O.jsxs)(`span`,{children:[(0,O.jsx)(`strong`,{children:`Last turn failed.`}),` `,t]})]}),kn(e,t,n,r,`session-error`)]},`session-error:${e}`))},Bn=e=>{p?p(e,{focus:!0}):window.dispatchEvent(new CustomEvent(`gezel:open-tab`,{detail:{kind:`task`,ref:e}}))},Vn=(e,n)=>{let r=I.get(e.gezelId),a=e.sessionId===t,c=En(e.sessionLastActivityAt,Mt),l=!a&&!c,p=ae&&e.projectId!=="default"?Le.get(e.projectId):void 0,m=e.from?e.from.gezelId:e.gezelId,h=I.get(m)?.font,g=d(h),_=s(h),v=Tn(e);return(0,O.jsx)(ce,{dataMsgId:`msg:${e.sessionId}:${e.at}:${e.role}`,dataSessionId:e.sessionId,debugMode:ct,sessionId:e.sessionId,messageAt:e.at,role:e.role,content:e.content,authorLabel:r?f({name:r.name,roleBasedName:r.roleBasedName},pe):`Gezel`,authorIcon:r?.icon??null,...r?.poppetje?{authorPoppetje:r.poppetje}:{},...r?.iconOverride?{authorIconOverride:!0}:{},authorTooltip:pt(e.gezelId),...(()=>{let t=mt(e.sessionProviderName,e.sessionModel);return t?{driftLabel:t}:{}})(),...!pe&&r?.role?{authorRole:r.role}:{},...e.from?{from:e.from}:{},...e.nudge?{nudge:!0}:{},...e.origin===`system`?{origin:`system`}:{},receiverLabel:r?f({name:r.name,roleBasedName:r.roleBasedName},pe):`Gezel`,...g?{fontFamily:g}:{},..._===1?{}:{fontScale:_},...p?{projectLabel:p.name}:{},extraClass:l?`timeline-msg-faded`:void 0,mediaProvider:We(e.projectId,e.sessionId),...v.length>0?{referencedFiles:v}:{},...e.retrieval&&e.retrieval.hits.length>0?{retrieval:e.retrieval}:{},...e.referencedTasks?{referencedTasks:e.referencedTasks}:{},...e.toolCalls&&e.toolCalls.length>0?{toolCalls:e.toolCalls,projectId:e.projectId}:{},...u?{onOpenReference:u}:{},...e.reasoning?{reasoning:e.reasoning}:{},...e.reasoningDurationMs===void 0?{}:{reasoningDurationMs:e.reasoningDurationMs},...e.attemptedToolCalls&&e.attemptedToolCalls.length>0?{attemptedToolCalls:e.attemptedToolCalls}:{},...n?.recoveredInNextTurn?{recoveredInNextTurn:!0}:{},...n?.suppressHeader?{suppressHeader:!0}:{},...n?.timestampLabel?{timestampLabel:n.timestampLabel}:{},...e.intents&&e.intents.length>0?{intents:e.intents}:{},...e.warnings&&e.warnings.length>0?{warnings:e.warnings}:{},...e.synthetic?{synthetic:e.synthetic}:{},...e.pendingQuestionId&&ze.get(e.pendingQuestionId)?{question:ze.get(e.pendingQuestionId),onQuestionAnswered:e=>Be(t=>{let n=new Map(t);return n.set(e.id,e),n})}:{},...i||o?{onFileReference:t=>{t.kind===`workspace`?o?.(t.path,e.projectId):i?.(t.path,e.projectId)}}:{},onTaskReference:e=>window.dispatchEvent(new CustomEvent(`gezel:open-tab`,{detail:{kind:`task`,ref:e}})),onFocusTask:Bn},`msg:${e.sessionId}:${e.at}:${e.role}`)},Hn=(e,t)=>{let n=[],r=I.get(t.gezelId),i=d(r?.font),a=s(r?.font);n.push((0,O.jsx)(be,{dataMsgId:`live:${e}`,dataSessionId:e,authorLabel:r?f({name:r.name,roleBasedName:r.roleBasedName},pe):`Gezel`,authorIcon:r?.icon??null,...r?.poppetje?{authorPoppetje:r.poppetje}:{},...r?.iconOverride?{authorIconOverride:!0}:{},authorTooltip:pt(t.gezelId),...(()=>{if(!t.sessionProviderName)return{};let e=mt(t.sessionProviderName,t.sessionModel);return e?{driftLabel:e}:{}})(),...!pe&&r?.role?{authorRole:r.role}:{},segments:t.segments,...u?{onOpenReference:u}:{},onFocusTask:Bn,startedAt:t.startedAt,lastActivityAt:t.lastActivityAt,hasProgress:t.hasProgress,...dt(t.gezelId)===`ollama`?{onProbeOllama:()=>y.ollamaProbe()}:{},...dt(t.gezelId)===`ollama`?{localEngine:`ollama`}:dt(t.gezelId)===`llama-cpp`?{localEngine:`llama-cpp`}:dt(t.gezelId)===`ds4`?{localEngine:`ds4`}:{},...t.sessionSource||e.startsWith(`one-shot:`)?{}:{onCancel:async()=>{try{await y.cancelChatSessionTurn(e)}catch(e){console.warn(`[timeline] failed to cancel turn:`,e)}},onReEngage:async()=>{try{await y.cancelChatSessionTurn(e)}catch(e){console.warn(`[timeline] re-engage: cancel failed:`,e)}try{await y.sendToChatSession(e,{message:`Please continue where you left off and finish the work you started.`})}catch(e){console.warn(`[timeline] re-engage: send failed:`,e)}}},...i?{fontFamily:i}:{},...a===1?{}:{fontScale:a},...t.error?{error:t.error}:{},...t.errorDetail?{errorDetail:t.errorDetail}:{},...t.error?{errorActions:kn(e,t.error,t.errorDetail,t.projectId,`chat-turn`)}:{},...t.queueAhead===void 0?{}:{queueAhead:t.queueAhead},...t.queuedAt===void 0?{}:{queuedAt:t.queuedAt},...t.wirePulseCount&&t.wirePulseCount>0?{wirePulseCount:t.wirePulseCount}:{},...ue(t)?{thinkingLabel:ue(t)}:{},...t.thinkingProgress===void 0?{}:{thinkingProgress:t.thinkingProgress},...t.thinkingDetail?{thinkingDetail:t.thinkingDetail}:{},...t.liveToolArgs?{liveToolArgs:t.liveToolArgs}:{},...t.gpuSwapTask?{gpuSwapTask:t.gpuSwapTask}:{},...t.gpuSwapDetail?{gpuSwapDetail:t.gpuSwapDetail}:{},...t.gpuSwapPrompt?{gpuSwapPrompt:t.gpuSwapPrompt}:{},...t.gpuSwapProgress===void 0?{}:{gpuSwapProgress:t.gpuSwapProgress},...t.gpuSwapStep===void 0?{}:{gpuSwapStep:t.gpuSwapStep},...t.gpuSwapTotalSteps===void 0?{}:{gpuSwapTotalSteps:t.gpuSwapTotalSteps},...t.gpuSwapSecondsPerStep===void 0?{}:{gpuSwapSecondsPerStep:t.gpuSwapSecondsPerStep},...t.awaitingGezelName?{awaitingGezelName:t.awaitingGezelName}:{},...t.warnings&&t.warnings.length>0?{warnings:t.warnings}:{},...Ln.get(e)?{question:Ln.get(e),onQuestionAnswered:e=>Be(t=>{let n=new Map(t);return n.set(e.id,e),n})}:{},debugMode:ct,sessionId:e},`live:${e}`));let o=H.current.get(e);if(o&&o.length>0)for(let r of o)n.push((0,O.jsx)(xe,{sessionId:e,queueId:r.id,preview:r.preview,enqueuedAt:r.enqueuedAt,mediaProvider:We(t.projectId,e),...r.nudge?{nudge:!0}:{},onDiscard:async()=>{try{await y.cancelQueuedMessage(e,r.id)}catch(e){console.warn(`[timeline] failed to discard queued message:`,e)}},onCancelCurrent:async()=>{try{await y.cancelChatSessionTurn(e)}catch(e){console.warn(`[timeline] failed to cancel current turn:`,e)}},onLoadText:async()=>{try{return(await y.listSessionQueue(e)).entries.find(e=>e.queueId===r.id)?.text??null}catch{return null}},onSaveEdit:async t=>{try{return await y.updateQueuedMessage(e,r.id,{message:t}),!0}catch(e){if(/not found/i.test(e.message??``))return!1;throw e}}},`ghost:${r.id}`));return n};for(let e of Ct){if(e.kind===`terminal`){let t=e.entry,n=Fn.get(t.threadId),r=!n,i=n?Math.max(0,new Date(t.at).getTime()-new Date(n.at).getTime()):0;(r||i>dn)&&Rn.push(Jt({entry:t,key:`terminal-divider:${t.threadId}:${t.messageId}`})),Rn.push((0,O.jsx)(St,{entry:t,...o?{onOpenWorkspaceFile:e=>o(e,t.projectId)}:{}},`terminal:${t.threadId}:${t.messageId}`)),Fn.set(t.threadId,t);continue}if(e.kind===`terminal-streaming`){let t=e.slot.projectId,n=e.runId;Rn.push((0,O.jsx)(_n,{store:B,itemKey:n,onRendered:Dt,render:e=>(0,O.jsx)(Ot,{content:e.content,cwd:e.cwd,startedAt:e.startedAt,...e.awaitingInput?{awaitingInput:e.awaitingInput}:{},onCancel:()=>{y.cancelTerminalRun(t,n).catch(()=>{})},onSendInput:e=>{let r=V.current.get(n);r&&(delete r.awaitingInput,B.markItemChanged(n)),y.sendTerminalInput(t,n,e).catch(e=>{console.warn(`[ChatTimelineView] sendTerminalInput failed`,e)})}})},`terminal-streaming:${n}`));continue}let r=e.sessionId,i=wt.get(r)??0,a=Tt.get(r),s=e.root??e.replies[0];if(!s)continue;if(r!==An){An&&jn&&!R.current.has(An)&&zn(An,jn,Mn,Nn);let o=Pn.has(r);Rn.push(qt({row:s,gezels:I,projects:Le,showProjectName:ae,activeSessionId:t,onFocusSession:n,continuing:o,depth:i,...a?{treeBranch:a}:{},key:`divider:${r}:${e.at}`,roleBasedNameOnlyMode:pe})),Pn.add(r),An=r,jn=null,Mn=void 0,Nn=null}let c=e.root??e.replies.find(e=>e.kind===`message`);c&&c.kind===`message`&&c.msg.sessionLastTurnError&&(jn=c.msg.sessionLastTurnError,Mn=c.msg.sessionLastTurnErrorDetail,Nn=c.msg.projectId);let l=[];if(e.root&&l.push(Vn(e.root.msg,{timestampLabel:ee(e.root.at)})),e.replies.length>0){let t=[];for(let n=0;n<e.replies.length;n++){let r=e.replies[n];if(r.kind===`streaming`){t.push((0,O.jsx)(_n,{store:L,itemKey:r.sessionId,onRendered:Dt,render:e=>Hn(r.sessionId,e)},`live-slot:${r.sessionId}`));continue}let i=r.msg,a=n>0?e.replies[n-1]:void 0,o=a?a.at:e.root?.at,s=(o?Math.max(0,Date.parse(i.at)-Date.parse(o)):0)>an,c=a?.kind===`message`&&a.msg.gezelId===i.gezelId,l=e.replies[n+1],u=i.role===`assistant`&&i.content.trim().length===0&&!!i.toolCalls&&i.toolCalls.length>0&&l!==void 0&&l.kind===`message`&&l.msg.sessionId===i.sessionId&&l.msg.role===`assistant`&&l.msg.content.trim().length>0;t.push(Vn(i,{...c&&!s?{suppressHeader:!0}:{},...s?{timestampLabel:ee(i.at)}:{},...u?{recoveredInNextTurn:!0}:{}}))}l.push((0,O.jsx)(`div`,{className:`timeline-thread-replies`,children:t},`replies`))}let u=a?.hasChildren===!0||i===0&&e.replies.length>0&&(!e.root||!e.root.msg.from);Rn.push((0,O.jsxs)(`div`,{className:`timeline-thread${i>0?` timeline-session-subthread timeline-session-depth-${Math.min(i,4)}`:``}${a?.hasChildren?` timeline-session-parent`:``}${e.root?``:` timeline-thread-rootless`}${u?` timeline-thread-railed`:``}`,children:[i>0&&a&&(0,O.jsx)(Kt,{branch:a,phase:`thread`}),l]},`thread:${r}:${e.at}`))}An&&jn&&!R.current.has(An)&&zn(An,jn,Mn,Nn);let $=t?Ge.current.get(t):void 0,Un=$?.kind===`warning`&&typeof $.estimatedTokens==`number`&&typeof $.numCtx==`number`&&$.numCtx>0?Math.round(100*$.estimatedTokens/$.numCtx):null,Wn=K?.kind===`chat`?R.current.has(K.sessionId):K?.kind===`terminal`&&V.current.has(K.runId),Gn=K!==null&&(Je!==K.key||Wn);return(0,O.jsxs)(`div`,{className:`chat-timeline-viewport`,children:[$&&(0,O.jsx)(`output`,{className:`chat-context-banner chat-context-banner-${$.kind}`,children:$.kind===`warning`?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`span`,{className:`chat-context-banner-icon`,"aria-hidden":!0,children:`⚠`}),(0,O.jsxs)(`span`,{className:`chat-context-banner-body`,children:[(0,O.jsx)(`strong`,{children:`Context window getting full`}),` — this thread`,` `,Un===null?`is approaching`:Un>100?`has exceeded`:`has used about ${Un}% of`,` `,`the model's available context. Earlier context may become less reliable — consider starting fresh for better recall.`]})]}):(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`span`,{className:`chat-context-banner-icon`,"aria-hidden":!0,children:`✦`}),(0,O.jsxs)(`span`,{className:`chat-context-banner-body`,children:[(0,O.jsx)(`strong`,{children:`Compacted older messages`}),` to fit the model context.`,` `,$.removedCount??0,` earlier turn`,$.removedCount===1?``:`s`,` were summarized into a single bubble; the gezel will continue from the synthesis.`]})]})}),Wt&&(Wt.assistantInfo.kind===`live`?(0,O.jsx)(vn,{store:L,sessionId:Wt.assistantInfo.sessionId,userMsg:Wt.userMsg,gezels:I}):(0,O.jsx)(Dn,{payload:{userMsg:Wt.userMsg,assistantInfo:{kind:`message`,msg:Wt.assistantInfo.msg}},gezels:I})),(0,O.jsxs)(`div`,{className:`chat-timeline`,ref:U,onScroll:Bt,"data-testid":`chat-timeline`,children:[M&&(0,O.jsx)(`div`,{className:`timeline-loading-pill muted small`,children:Qe.current?`Loading older messages…`:`Scroll up for older messages`}),Rn.length===0?_??(g?(0,O.jsx)(`p`,{className:`placeholder`,children:g}):null):Rn,$t,Gn&&(0,O.jsx)(`div`,{className:`timeline-response-runway`,"aria-hidden":`true`})]}),!qe&&(0,O.jsx)(`button`,{type:`button`,className:`chat-timeline-pin-toggle`,onClick:Ht,title:`Jump to newest and follow`,"aria-label":`Jump to newest and follow`,children:(0,O.jsxs)(`svg`,{className:`chat-timeline-pin-glyph`,width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,role:`img`,"aria-hidden":!0,children:[(0,O.jsx)(`title`,{children:`Jump to newest`}),(0,O.jsx)(`line`,{x1:`12`,y1:`4`,x2:`12`,y2:`15`}),(0,O.jsx)(`polyline`,{points:`6 10 12 16 18 10`}),(0,O.jsx)(`line`,{x1:`5`,y1:`20`,x2:`19`,y2:`20`})]})})]})}function bn(e,t){for(let n=e.length-1;n>=0;n--)if(e[n].sessionId===t)return e[n];return null}function xn(e){return/model\s+.*\bnot available\b/i.test(e)||/\bunknown model\b/i.test(e)}function Sn(e){return e?.code===`capacity-denied`||e?.code===`engine-busy`}function Cn(e,t){return h(e)||xn(e)||/\bdo not retry\b|\bcannot run on this machine\b/i.test(e)?!1:t?.code===`engine-busy`||t?.code===`capacity-denied`||t?.code===`native-engine-crash`||/\bretry the turn\b|\bsend (?:the )?message again\b|\bretry \(the cache is warm now\)|\btry a shorter prompt, retry\b/i.test(e)}var wn=[];function Tn(e){return e.referencedFiles?.length?e.referencedFiles:e.referencedArtifacts?.length?e.referencedArtifacts.map(e=>({kind:`artifact`,path:e})):wn}function En(e,t){if(!e)return!1;try{let n=new Date(e).getTime();return Date.now()-n<=t}catch{return!1}}function Dn({payload:e,gezels:t}){let{userMsg:n,assistantInfo:r}=e,i=r.kind===`live`,a=i?r.slot:null,o=oe(i?a?.startedAt??null:null),s=i?r.sessionId:r.msg.gezelId,c=t.get(i?a?.gezelId??``:r.msg.gezelId),l=de(),u=c?f({name:c.name,roleBasedName:c.roleBasedName},l):`Gezel`,d=n.origin===`system`?g(n.content):null,p=d?m(d,u):gn(n.content);return(0,O.jsxs)(`div`,{className:`chat-sticky-header`,"aria-live":`polite`,children:[(0,O.jsxs)(`div`,{className:`chat-sticky-header-user`,title:n.content,children:[(0,O.jsx)(`span`,{className:`chat-sticky-header-author`,children:d?_(d).toUpperCase():n.origin===`system`?`SYSTEM`:`YOU`}),(0,O.jsx)(`span`,{className:`chat-sticky-header-preview`,children:p})]}),(0,O.jsxs)(`div`,{className:`chat-sticky-header-assistant`,children:[(0,O.jsx)(se,{svg:c?.icon??null,poppetje:c?.poppetje,iconOverride:c?.iconOverride,name:u,size:18}),(0,O.jsx)(`span`,{className:`chat-sticky-header-author`,children:u}),!l&&c?.role&&(0,O.jsx)(ae,{role:c.role}),i&&a&&(0,O.jsx)(le,{failed:!!a.error,queued:a.queueAhead!==void 0&&ye(a.queuedAt,Date.now())&&!Se(a.segments),queueAhead:a.queueAhead,elapsedSeconds:o,toolCount:ge(a.segments),wirePulseCount:a.wirePulseCount,...ue(a)?{thinkingLabel:ue(a)}:{},...a.thinkingProgress===void 0?{}:{thinkingProgress:a.thinkingProgress},...a.thinkingDetail?{thinkingDetail:a.thinkingDetail}:{},...a.awaitingGezelName?{awaitingGezelName:a.awaitingGezelName}:{}})]},s)]})}function On(e){switch(e){case`copilot`:return`Copilot`;case`openai`:return`OpenAI`;case`anthropic`:return`Claude`;case`anthropic-cli`:return`Claude CLI`;case`codex-cli`:return`Codex CLI`;case`ollama`:return`Ollama`;case`llama-cpp`:return`On-device`;case`mlx`:return`MLX`;case`ds4`:return`DwarfStar`;case`remote`:return`Remote`}}export{at as i,Nt as n,Q as r,yn as t};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{n as t,t as n}from"./jsx-runtime-CEpd2cAX.js";import{C as r,D as i,E as a,O as o,S as s,T as c,b as l,w as u,x as d}from"./primitives-DEsn1shf.js";var f=e(t(),1),p=n();function m({open:e,title:t,message:n,confirmLabel:m=`Confirm`,cancelLabel:h=`Cancel`,danger:g=!1,onConfirm:_,onCancel:v}){let[y,b]=(0,f.useState)(!1),x=async()=>{if(!y){b(!0);try{await _()}finally{b(!1)}}};return(0,p.jsx)(i,{open:e,onOpenChange:e=>{!e&&!y&&v()},children:(0,p.jsxs)(a,{children:[(0,p.jsx)(c,{}),(0,p.jsxs)(r,{children:[(0,p.jsx)(o,{asChild:!0,children:(0,p.jsx)(`h3`,{children:t})}),n&&(0,p.jsx)(u,{className:`muted small`,children:n}),(0,p.jsxs)(d,{children:[(0,p.jsx)(s,{asChild:!0,children:(0,p.jsx)(`button`,{type:`button`,disabled:y,children:h})}),(0,p.jsx)(l,{asChild:!0,children:(0,p.jsx)(`button`,{type:`button`,className:g?`danger`:`primary`,onClick:e=>{e.preventDefault(),x()},disabled:y,children:y?`Working…`:m})})]})]})]})})}export{m as t};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{n as t,t as n}from"./jsx-runtime-CEpd2cAX.js";import{c as r,d as i,f as a,l as o,m as s,p as c,s as l,u}from"./primitives-DEsn1shf.js";import{t as d}from"./api-BX5xXiFs.js";import{n as f,t as p}from"./relative-time-B2kBaekd.js";import{t as m}from"./ConfirmDialog-BHFs6vmJ.js";import{At as h,jt as g,kt as _}from"./index-DXWR4qW1.js";import"./provider-default-BLsHrgzI.js";var v=e(t(),1);function y(e){let t=(0,v.useRef)(null),[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(``),[o,s]=(0,v.useState)(null),[c,l]=(0,v.useState)(null),[u,d]=(0,v.useState)(null),[f,p]=(0,v.useState)(!1),[m,h]=(0,v.useState)(!1),g=(0,v.useRef)(e);g.current=e;let _=(0,v.useCallback)(e=>{r(e);let t=g.current.backupNotice?.(e);t&&l(t),a(t=>{let n=new Set(e.models.map(e=>e.id));return t&&n.has(t)?t:e.configuredModel&&n.has(e.configuredModel)?e.configuredModel:e.recommendedModel&&n.has(e.recommendedModel)?e.recommendedModel:e.models[0]?.id??``})},[]),y=(0,v.useCallback)(async()=>{s(null);try{_(await g.current.fetchStatus())}catch(e){s(`Could not check the ${g.current.label} setup — ${S(e)}`)}},[_]);(0,v.useEffect)(()=>(y(),()=>{t.current!==null&&window.clearTimeout(t.current)}),[y]);let b=window.__GEZEL__?.mode,x=b===`local-adopt`||b===`local-spawn-packaged`||b===`local-spawn-dev`||b===`embedded`,C=b===`remote`,w=n?.state===`configured`||n?.state===`update-needed`,T=n?.state===`configured`&&n.bridge.listening&&e.endpointsEnabled&&x,E=e.modelSelection!==!1,D=E&&w&&i!==n?.configuredModel,O=n?.state===`conflict`&&n.canRepair,k=n?.state===`not-configured`||n?.state===`update-needed`||D||O,A=n?.state===`conflict`?n.canRepair:n?.canConfigure??!1,j=f||!x||!e.endpointsEnabled||!A||E&&!i,M=f||!x||!e.endpointsEnabled||!A;return{status:n,model:i,setModel:a,error:o,setError:s,notice:c,confirmation:u,setConfirmation:d,busy:f,copied:m,refresh:y,runConfirmedAction:(0,v.useCallback)(async()=>{if(!(!u||f)){p(!0),s(null),l(null);try{_(await g.current.runAction(u,i)),d(null),Promise.resolve(g.current.onChanged?.()).catch(()=>{})}catch(e){d(null),s(`${g.current.errorPrefix(u,n?.state)} — ${S(e)}`)}finally{p(!1)}}},[_,f,u,i,n?.state]),copyLaunchCommand:(0,v.useCallback)(async()=>{if(n?.launchCommand){s(null);try{if(!navigator.clipboard?.writeText)throw Error(`clipboard access is unavailable`);await navigator.clipboard.writeText(n.launchCommand),h(!0),t.current!==null&&window.clearTimeout(t.current),t.current=window.setTimeout(()=>{t.current=null,h(!1)},2e3)}catch(e){s(`Could not copy the ${g.current.label} command — ${S(e)}`)}}},[n?.launchCommand]),localDesktopMode:x,remoteMode:C,configured:w,canLaunch:T,modelChanged:D,repairable:O,needsConfigure:k,configureDisabled:j,selectionDisabled:M}}function b(e){switch(e){case`not-configured`:return`Not configured`;case`configured`:return`Configured`;case`update-needed`:return`Update needed`;case`conflict`:return`Needs attention`;case`unavailable`:return`Unavailable`}}function x(e){return e.kind===`gezel`||e.id.startsWith(`gezel:`)}function S(e){if(e&&typeof e==`object`&&`details`in e){let t=e.details;if(typeof t==`string`&&t)return t;if(t&&typeof t==`object`){let e=t;if(typeof e.message==`string`&&e.message)return e.message;if(typeof e.error==`string`&&e.error)return e.error}}return e instanceof Error?e.message:String(e)}var C=n();function w({headingId:e,title:t,status:n,intro:d,notInstalledNote:f,repairExplainer:p,notice:m,reasonsIntro:h,configuredNote:g,commandRow:_,modelRow:y,extraRows:S,actions:w,error:E,emptyModelsNote:D,remoteMode:O,localDesktopMode:k,endpointsEnabled:A,repairable:j,children:M}){let N=(0,v.useId)(),P=n?b(n.state):`Checking…`,F=n?.models.filter(x)??[],I=n?.models.filter(e=>!x(e))??[];return(0,C.jsxs)(`section`,{className:`settings-subsection provider-card harness-setup-card`,"aria-labelledby":e,children:[(0,C.jsxs)(`div`,{className:`settings-card-header`,children:[(0,C.jsx)(`h3`,{id:e,children:t}),(0,C.jsx)(`span`,{className:`harness-setup-state harness-setup-state--${n?.state??`checking`}`,"aria-live":`polite`,children:P})]}),(0,C.jsx)(`p`,{className:`muted small harness-setup-intro`,children:d}),!n&&!E&&(0,C.jsx)(`p`,{className:`muted small`,children:`Checking the setup…`}),n&&(0,C.jsxs)(C.Fragment,{children:[n.message&&(0,C.jsx)(`p`,{className:n.state===`conflict`||n.state===`unavailable`?`harness-setup-caution small`:`muted small`,children:n.message}),j&&p&&(0,C.jsx)(`p`,{className:`muted small`,children:p}),m&&(0,C.jsx)(`p`,{className:`muted small`,children:m}),f&&n.state!==`unavailable`&&(0,C.jsx)(`p`,{className:`muted small`,children:f}),O&&(0,C.jsx)(`p`,{className:`harness-setup-caution small`,children:`One-click setup is unavailable while this app is connected to a remote Gezel service. Set it up on the computer where you plan to run it.`}),!O&&!k&&(0,C.jsx)(`p`,{className:`harness-setup-caution small`,children:`One-click setup is available in the Gezel desktop app when it is connected to your user service on this computer.`}),!A&&(0,C.jsxs)(`p`,{className:`harness-setup-caution small`,children:[`Turn on `,(0,C.jsx)(`strong`,{children:`Allow apps to connect`}),` above before setting up or updating this.`]}),n.state===`update-needed`&&n.reasons.length>0&&(0,C.jsxs)(`div`,{className:`harness-setup-reasons`,children:[(0,C.jsx)(`span`,{className:`small`,children:h}),(0,C.jsx)(`ul`,{className:`muted small`,children:n.reasons.map(e=>(0,C.jsx)(`li`,{children:e},e))})]}),g&&(0,C.jsx)(`p`,{className:`muted small`,children:g}),_,y&&n.models.length>0&&(n.state!==`conflict`||j)&&(0,C.jsxs)(`div`,{className:`harness-setup-model-row`,children:[(0,C.jsx)(`span`,{id:N,children:y.label}),(0,C.jsxs)(i,{value:y.value,onValueChange:y.onChange,disabled:y.disabled,children:[(0,C.jsx)(c,{"aria-labelledby":N,children:(0,C.jsx)(s,{})}),(0,C.jsxs)(l,{children:[F.length>0&&(0,C.jsxs)(r,{children:[(0,C.jsx)(u,{children:`Gezels`}),F.map(e=>(0,C.jsx)(o,{value:e.id,children:T(e)},e.id))]}),F.length>0&&I.length>0&&(0,C.jsx)(a,{}),I.length>0&&(0,C.jsxs)(r,{children:[(0,C.jsx)(u,{children:`Raw models`}),I.map(e=>(0,C.jsx)(o,{value:e.id,children:T(e)},e.id))]})]})]})]}),n.models.length===0&&n.state!==`conflict`&&(0,C.jsx)(`p`,{className:`harness-setup-caution small`,children:D}),S,(0,C.jsx)(`div`,{className:`harness-setup-actions`,children:w})]}),E&&(0,C.jsx)(`p`,{className:`error small harness-setup-error`,role:`alert`,children:E}),M]})}function T(e){return e.description?`${e.label} — ${e.description}`:e.label}function E({endpointsEnabled:e,onChanged:t}){let n=y({label:`Codex`,endpointsEnabled:e,fetchStatus:()=>d.getCodexSetupStatus(),runAction:(0,v.useCallback)((e,t)=>e===`remove`?d.removeCodexSetup():d.configureCodex({model:t,...e===`repair`?{backupConflictingProfile:!0}:{}}),[]),errorPrefix:D,backupNotice:e=>e.profileBackupPath?`The previous file was saved as ${e.profileBackupPath}.`:null,...t?{onChanged:t}:{}}),{status:r,confirmation:i,setConfirmation:a,setError:o,busy:s,copied:c}=n,l=r?.models.find(e=>e.id===n.model),u=r?.models.find(e=>e.id===r.configuredModel),f=n.repairable?`Repair Codex setup…`:r?.state===`not-configured`?`Set up Codex…`:`Update Codex…`;return(0,C.jsxs)(w,{headingId:`codex-setup-heading`,title:`Use Gezel in Codex`,status:r,remoteMode:n.remoteMode,localDesktopMode:n.localDesktopMode,endpointsEnabled:e,repairable:!!n.repairable,notice:n.notice,error:n.error,reasonsIntro:`The managed setup needs an update:`,emptyModelsNote:`No gezels or inference models compatible with the Codex tool loop are available yet.`,intro:(0,C.jsx)(C.Fragment,{children:`Codex keeps its coding tools, sandbox, approvals, and conversation loop while a gezel supplies the character, model, and tuning. Your whole eligible crew is offered to Codex — the gezel you pick here is the one it starts with, and you can switch to any other from Codex's own model picker. Raw local models remain available when you want inference without a gezel persona.`}),...r?{repairExplainer:(0,C.jsxs)(C.Fragment,{children:[`Repair writes a fresh `,(0,C.jsx)(`code`,{children:r.profileName}),` profile for this Gezel and keeps a copy of the existing file next to it.`]})}:{},...r&&!r.codexInstalled?{notInstalledNote:`Codex was not found on this computer. You can prepare the setup now and use it after installing Codex.`}:{},...n.configured&&u&&!n.modelChanged?{configuredNote:(0,C.jsxs)(C.Fragment,{children:[`Codex starts with `,(0,C.jsx)(`strong`,{children:u.label}),`.`,r?.codexVersion?` Codex ${r.codexVersion} was found.`:``]})}:{},...n.canLaunch&&r?{commandRow:(0,C.jsxs)(`div`,{className:`harness-setup-command-row`,children:[(0,C.jsx)(`span`,{className:`muted small`,children:`Start it with`}),(0,C.jsx)(`code`,{children:r.launchCommand}),(0,C.jsx)(`button`,{type:`button`,onClick:()=>void n.copyLaunchCommand(),children:c?`Copied`:`Copy command`}),(0,C.jsx)(`output`,{className:`sr-only`,"aria-live":`polite`,children:c?`Codex launch command copied.`:``}),(0,C.jsx)(`span`,{className:`muted small`,children:`Keep Gezel running while you use Codex.`})]})}:{},modelRow:{label:`Default gezel`,value:n.model,onChange:n.setModel,disabled:n.selectionDisabled},actions:(0,C.jsxs)(C.Fragment,{children:[n.needsConfigure&&(0,C.jsx)(`button`,{type:`button`,className:`primary`,disabled:n.configureDisabled,onClick:()=>{o(null),a(n.repairable?`repair`:`configure`)},children:f}),r?.canRemove&&(0,C.jsx)(`button`,{type:`button`,disabled:s||!n.localDesktopMode,onClick:()=>{o(null),a(`remove`)},children:r.state===`conflict`?`Clear Gezel setup…`:`Remove setup…`}),n.error&&(0,C.jsx)(`button`,{type:`button`,onClick:()=>void n.refresh(),disabled:s,children:`Try again`})]}),children:[(0,C.jsx)(m,{open:i===`configure`,title:r?.state===`not-configured`?`Set up Codex with Gezel?`:`Update Codex setup?`,message:(0,C.jsxs)(C.Fragment,{children:[`Gezel will `,r?.state===`not-configured`?`create`:`update`,` its managed Codex profile for `,(0,C.jsx)(`strong`,{children:l?.label??n.model}),`.`,` `,l&&x(l)?(0,C.jsxs)(C.Fragment,{children:[`This gezel's character, `,l.modelLabel??`model`,`, and tuning will guide Codex.`,` `]}):(0,C.jsx)(C.Fragment,{children:`Codex will use it as a raw inference model without a gezel persona. `}),`The profile includes the local connection and app-scoped credential`,r?.profilePath?(0,C.jsxs)(C.Fragment,{children:[` `,`at `,(0,C.jsx)(`code`,{children:r.profilePath})]}):null,`. Your other Codex settings and conversations stay untouched.`]}),confirmLabel:r?.state===`not-configured`?`Set up Codex`:`Update Codex`,onConfirm:n.runConfirmedAction,onCancel:()=>a(null)}),(0,C.jsx)(m,{open:i===`repair`,title:`Repair the Codex setup?`,message:(0,C.jsxs)(C.Fragment,{children:[`Gezel will write a working `,(0,C.jsx)(`code`,{children:r?.profileName}),` profile for`,` `,(0,C.jsx)(`strong`,{children:l?.label??n.model}),`, connected to this copy of Gezel.`,r?.profilePath?(0,C.jsxs)(C.Fragment,{children:[` `,`The file now at `,(0,C.jsx)(`code`,{children:r.profilePath}),` is kept as a `,(0,C.jsx)(`code`,{children:`.backup`}),` `,`copy beside it, so nothing is lost.`]}):(0,C.jsx)(C.Fragment,{children:` The file it replaces is kept as a .backup copy beside it, so nothing is lost.`}),` `,`Your other Codex settings and conversations stay untouched.`]}),confirmLabel:`Repair setup`,onConfirm:n.runConfirmedAction,onCancel:()=>a(null)}),(0,C.jsx)(m,{open:i===`remove`,title:r?.state===`conflict`?`Clear Gezel setup for Codex?`:`Remove Gezel setup from Codex?`,message:(0,C.jsxs)(C.Fragment,{children:[`This removes only Gezel's managed Codex profile, catalog, state, and credential. It does not uninstall Codex or delete your other settings and conversations.`,r?.state===`conflict`?` Any Codex profile not managed by Gezel will be preserved.`:``]}),confirmLabel:r?.state===`conflict`?`Clear Gezel setup`:`Remove setup`,danger:!0,onConfirm:n.runConfirmedAction,onCancel:()=>a(null)})]})}function D(e,t){switch(e){case`remove`:return`Could not remove the Codex setup`;case`repair`:return`Could not repair the Codex setup`;default:return t===`not-configured`?`Could not set up the Codex setup`:`Could not update the Codex setup`}}function O({endpointsEnabled:e,onChanged:t}){let n=y({label:`OpenCode`,endpointsEnabled:e,fetchStatus:()=>d.getOpenCodeSetupStatus(),runAction:(0,v.useCallback)((e,t)=>{switch(e){case`remove`:return d.removeOpenCodeSetup();case`install-plugin`:return d.installOpenCodePlugin();case`replace-plugin`:return d.installOpenCodePlugin({backupConflictingPlugin:!0});case`remove-plugin`:return d.removeOpenCodePlugin();default:return d.configureOpenCode({model:t,...e===`repair`?{backupConflictingConfig:!0}:{}})}},[]),errorPrefix:k,backupNotice:e=>e.pluginBackupPath?`The previous plugin file was saved as ${e.pluginBackupPath}.`:e.configBackupPath?`The previous file was saved as ${e.configBackupPath}.`:null,...t?{onChanged:t}:{}}),{status:r,confirmation:i,setConfirmation:a,setError:o,busy:s,copied:c}=n,l=r?.models.find(e=>e.id===n.model),u=r?.models.find(e=>e.id===r.configuredModel),f=n.configured&&n.localDesktopMode&&r?.state!==`conflict`&&r?.plugin.state!==`unsupported`,p=n.repairable?`Repair OpenCode setup…`:r?.state===`not-configured`?`Set up OpenCode…`:`Update OpenCode…`;return(0,C.jsxs)(w,{headingId:`opencode-setup-heading`,title:`Use Gezel in OpenCode`,status:r,remoteMode:n.remoteMode,localDesktopMode:n.localDesktopMode,endpointsEnabled:e,repairable:!!n.repairable,notice:n.notice,error:n.error,reasonsIntro:`The managed setup needs an update:`,emptyModelsNote:`No gezels or inference models compatible with the OpenCode tool loop are available yet.`,intro:(0,C.jsx)(C.Fragment,{children:`OpenCode keeps its own tools, permissions, and conversation loop while a gezel supplies the character, model, and tuning. Gezel writes its own settings file and points OpenCode at it with one command. You can also let Gezel add a small plugin of its own to OpenCode, so the gezel provider is simply there in every session. Either way, your own OpenCode settings, conversations, and permissions are never edited. Your whole eligible crew is offered, so you can switch between them from OpenCode's model picker.`}),repairExplainer:`Repair writes a fresh settings file for this Gezel and keeps a copy of the existing one next to it.`,...r&&!r.opencodeInstalled?{notInstalledNote:`OpenCode was not found on this computer. You can prepare the setup now and use it after installing OpenCode.`}:{},...n.configured&&u&&!n.modelChanged?{configuredNote:(0,C.jsxs)(C.Fragment,{children:[`OpenCode starts with `,(0,C.jsx)(`strong`,{children:u.label}),`.`,r?.opencodeVersion?` OpenCode ${r.opencodeVersion} was found.`:``]})}:{},...n.canLaunch&&r?{commandRow:(0,C.jsxs)(`div`,{className:`harness-setup-command-row`,children:[(0,C.jsx)(`span`,{className:`muted small`,children:`Start it with`}),(0,C.jsx)(`code`,{children:r.launchCommand}),(0,C.jsx)(`button`,{type:`button`,onClick:()=>void n.copyLaunchCommand(),children:c?`Copied`:`Copy command`}),(0,C.jsx)(`output`,{className:`sr-only`,"aria-live":`polite`,children:c?`OpenCode launch command copied.`:``}),(0,C.jsx)(`span`,{className:`muted small`,children:`Keep Gezel running while you use OpenCode.`})]})}:{},modelRow:{label:`Default gezel`,value:n.model,onChange:n.setModel,disabled:n.selectionDisabled},...f&&r?{extraRows:(0,C.jsx)(`p`,{className:`muted small`,children:r.plugin.state===`installed`||r.plugin.state===`stale`?(0,C.jsxs)(C.Fragment,{children:[`Gezel is in OpenCode's provider list without the command, through`,` `,(0,C.jsx)(`code`,{children:r.plugin.path}),`.`]}):r.plugin.state===`conflict`?r.plugin.message:(0,C.jsx)(C.Fragment,{children:`Rather not use the command every time? Gezel can add its own plugin file to OpenCode so the crew shows up in every session.`})})}:{},actions:(0,C.jsxs)(C.Fragment,{children:[n.needsConfigure&&(0,C.jsx)(`button`,{type:`button`,className:`primary`,disabled:n.configureDisabled,onClick:()=>{o(null),a(n.repairable?`repair`:`configure`)},children:p}),f&&r&&(r.plugin.canInstall||r.plugin.canReplace)&&(0,C.jsx)(`button`,{type:`button`,disabled:s||!n.localDesktopMode,onClick:()=>{o(null),a(r.plugin.canReplace?`replace-plugin`:`install-plugin`)},children:r.plugin.canReplace?`Replace OpenCode plugin…`:`Add to OpenCode…`}),f&&r?.plugin.canRemove&&(0,C.jsx)(`button`,{type:`button`,disabled:s||!n.localDesktopMode,onClick:()=>{o(null),a(`remove-plugin`)},children:`Remove from OpenCode…`}),r?.canRemove&&(0,C.jsx)(`button`,{type:`button`,disabled:s||!n.localDesktopMode,onClick:()=>{o(null),a(`remove`)},children:r.state===`conflict`?`Clear Gezel setup…`:`Remove setup…`}),n.error&&(0,C.jsx)(`button`,{type:`button`,onClick:()=>void n.refresh(),disabled:s,children:`Try again`})]}),children:[(0,C.jsx)(m,{open:i===`configure`,title:r?.state===`not-configured`?`Set up OpenCode with Gezel?`:`Update OpenCode setup?`,message:(0,C.jsxs)(C.Fragment,{children:[`Gezel will `,r?.state===`not-configured`?`create`:`update`,` its own OpenCode settings file for `,(0,C.jsx)(`strong`,{children:l?.label??n.model}),`.`,` `,l&&x(l)?(0,C.jsxs)(C.Fragment,{children:[`This gezel's character, `,l.modelLabel??`model`,`, and tuning will guide OpenCode.`,` `]}):(0,C.jsx)(C.Fragment,{children:`OpenCode will use it as a raw inference model without a gezel persona. `}),`The file holds the local connection and app-scoped credential`,r?.configPath?(0,C.jsxs)(C.Fragment,{children:[` `,`at `,(0,C.jsx)(`code`,{children:r.configPath})]}):null,`. Your own OpenCode configuration, sessions, and permissions stay untouched.`]}),confirmLabel:r?.state===`not-configured`?`Set up OpenCode`:`Update OpenCode`,onConfirm:n.runConfirmedAction,onCancel:()=>a(null)}),(0,C.jsx)(m,{open:i===`repair`,title:`Repair the OpenCode setup?`,message:(0,C.jsxs)(C.Fragment,{children:[`Gezel will write a working settings file for`,` `,(0,C.jsx)(`strong`,{children:l?.label??n.model}),`, connected to this copy of Gezel.`,r?.configPath?(0,C.jsxs)(C.Fragment,{children:[` `,`The file now at `,(0,C.jsx)(`code`,{children:r.configPath}),` is kept as a `,(0,C.jsx)(`code`,{children:`.backup`}),` `,`copy beside it, so nothing is lost.`]}):(0,C.jsx)(C.Fragment,{children:` The file it replaces is kept as a .backup copy beside it, so nothing is lost.`}),` `,`Your own OpenCode configuration stays untouched.`]}),confirmLabel:`Repair setup`,onConfirm:n.runConfirmedAction,onCancel:()=>a(null)}),(0,C.jsx)(m,{open:i===`remove`,title:r?.state===`conflict`?`Clear Gezel setup for OpenCode?`:`Remove Gezel setup from OpenCode?`,message:(0,C.jsxs)(C.Fragment,{children:[`This removes only Gezel's own OpenCode settings file, state, and credential`,r?.plugin.canRemove?(0,C.jsxs)(C.Fragment,{children:[`, along with the plugin file Gezel added at `,(0,C.jsx)(`code`,{children:r.plugin.path})]}):null,`. It does not uninstall OpenCode or touch your own configuration and sessions.`]}),confirmLabel:r?.state===`conflict`?`Clear Gezel setup`:`Remove setup`,danger:!0,onConfirm:n.runConfirmedAction,onCancel:()=>a(null)}),(0,C.jsx)(m,{open:i===`install-plugin`||i===`replace-plugin`,title:i===`replace-plugin`?`Replace the plugin file in OpenCode?`:`Add Gezel to OpenCode?`,message:(0,C.jsxs)(C.Fragment,{children:[`Gezel will add one file of its own`,r?.plugin.path?(0,C.jsxs)(C.Fragment,{children:[` `,`at `,(0,C.jsx)(`code`,{children:r.plugin.path})]}):null,`, so every OpenCode session on this computer offers the `,(0,C.jsx)(`strong`,{children:`gezel`}),` provider without the command above. It holds no password — it reads Gezel's own settings when OpenCode starts, and does nothing at all when Gezel is not running. It does not change which model OpenCode starts with; pick a gezel from OpenCode's own model picker. Your own OpenCode configuration, sessions, and permissions stay untouched, and`,` `,(0,C.jsx)(`code`,{children:`opencode --pure`}),` always starts without it.`,i===`replace-plugin`?(0,C.jsx)(C.Fragment,{children:` The file it replaces is kept as a .backup copy beside it, so nothing is lost.`}):null]}),confirmLabel:i===`replace-plugin`?`Replace plugin`:`Add to OpenCode`,onConfirm:n.runConfirmedAction,onCancel:()=>a(null)}),(0,C.jsx)(m,{open:i===`remove-plugin`,title:`Remove Gezel from OpenCode?`,message:(0,C.jsxs)(C.Fragment,{children:[`This deletes the plugin file Gezel added`,r?.plugin.path?(0,C.jsxs)(C.Fragment,{children:[` `,`at `,(0,C.jsx)(`code`,{children:r.plugin.path})]}):null,`. OpenCode stops offering the gezel provider unless you start it with the command on this card. The rest of the setup, and everything of your own, stays as it is.`]}),confirmLabel:`Remove from OpenCode`,onConfirm:n.runConfirmedAction,onCancel:()=>a(null)})]})}function k(e,t){switch(e){case`remove`:return`Could not remove the OpenCode setup`;case`repair`:return`Could not repair the OpenCode setup`;case`install-plugin`:case`replace-plugin`:return`Could not add Gezel to OpenCode`;case`remove-plugin`:return`Could not remove Gezel from OpenCode`;default:return t===`not-configured`?`Could not set up the OpenCode setup`:`Could not update the OpenCode setup`}}function A({endpointsEnabled:e,onChanged:t}){let n=y({label:`pi`,endpointsEnabled:e,fetchStatus:()=>d.getPiSetupStatus(),runAction:(0,v.useCallback)((e,t)=>{switch(e){case`remove`:return d.removePiSetup();case`install-extension`:return d.installPiExtension();case`replace-extension`:return d.installPiExtension({backupConflictingExtension:!0});case`remove-extension`:return d.removePiExtension();default:return d.configurePi({model:t,...e===`repair`?{backupConflictingConfig:!0}:{}})}},[]),errorPrefix:j,backupNotice:e=>e.extensionBackupPath?`The previous extension file was saved as ${e.extensionBackupPath}.`:e.configBackupPath?`The previous file was saved as ${e.configBackupPath}.`:null,...t?{onChanged:t}:{}}),{status:r,confirmation:i,setConfirmation:a,setError:o,busy:s,copied:c}=n,l=r?.models.find(e=>e.id===n.model),u=r?.models.find(e=>e.id===r.configuredModel),f=n.configured&&n.localDesktopMode&&r?.state!==`conflict`&&r?.extension.state!==`unsupported`,p=n.repairable?`Repair pi setup…`:r?.state===`not-configured`?`Set up pi…`:`Update pi…`;return(0,C.jsxs)(w,{headingId:`pi-setup-heading`,title:`Use Gezel in pi`,status:r,remoteMode:n.remoteMode,localDesktopMode:n.localDesktopMode,endpointsEnabled:e,repairable:!!n.repairable,notice:n.notice,error:n.error,reasonsIntro:`The managed setup needs an update:`,emptyModelsNote:`No gezels or inference models compatible with the pi tool loop are available yet.`,intro:(0,C.jsx)(C.Fragment,{children:`pi keeps its own tools, permissions, and conversation loop while a gezel supplies the character, model, and tuning. Gezel writes an extension of its own and hands you a command that loads it for that run. You can also let Gezel add that same file to pi, so the gezel provider is simply there in every session. Either way, your own pi settings, sessions, and models are never edited.`}),repairExplainer:`Repair writes a fresh model list for this Gezel and keeps a copy of the existing one next to it.`,...r&&!r.piInstalled?{notInstalledNote:`pi was not found on this computer. You can prepare the setup now and use it after installing pi.`}:{},...n.configured&&u&&!n.modelChanged?{configuredNote:(0,C.jsxs)(C.Fragment,{children:[`pi starts with `,(0,C.jsx)(`strong`,{children:u.label}),`, and offers the whole crew in its own model picker.`,r?.piVersion?` pi ${r.piVersion} was found.`:``]})}:{},...n.canLaunch&&r?{commandRow:(0,C.jsxs)(`div`,{className:`harness-setup-command-row`,children:[(0,C.jsx)(`span`,{className:`muted small`,children:`Start it with`}),(0,C.jsx)(`code`,{children:r.launchCommand}),(0,C.jsx)(`button`,{type:`button`,onClick:()=>void n.copyLaunchCommand(),children:c?`Copied`:`Copy command`}),(0,C.jsx)(`output`,{className:`sr-only`,"aria-live":`polite`,children:c?`pi launch command copied.`:``}),(0,C.jsx)(`span`,{className:`muted small`,children:`Keep Gezel running while you use pi.`})]})}:{},modelRow:{label:`Default gezel`,value:n.model,onChange:n.setModel,disabled:n.selectionDisabled},...f&&r?{extraRows:(0,C.jsx)(`p`,{className:`muted small`,children:r.extension.state===`installed`||r.extension.state===`stale`?(0,C.jsxs)(C.Fragment,{children:[`Gezel is in pi's provider list without the command, through`,` `,(0,C.jsx)(`code`,{children:r.extension.path}),`.`]}):r.extension.state===`conflict`?r.extension.message:(0,C.jsx)(C.Fragment,{children:`Rather not use the command every time? Gezel can add the same extension to pi so the crew shows up in every session.`})})}:{},actions:(0,C.jsxs)(C.Fragment,{children:[n.needsConfigure&&(0,C.jsx)(`button`,{type:`button`,className:`primary`,disabled:n.configureDisabled,onClick:()=>{o(null),a(n.repairable?`repair`:`configure`)},children:p}),f&&r&&(r.extension.canInstall||r.extension.canReplace)&&(0,C.jsx)(`button`,{type:`button`,disabled:s||!n.localDesktopMode,onClick:()=>{o(null),a(r.extension.canReplace?`replace-extension`:`install-extension`)},children:r.extension.canReplace?`Replace pi extension…`:`Add to pi…`}),f&&r?.extension.canRemove&&(0,C.jsx)(`button`,{type:`button`,disabled:s||!n.localDesktopMode,onClick:()=>{o(null),a(`remove-extension`)},children:`Remove from pi…`}),r?.canRemove&&(0,C.jsx)(`button`,{type:`button`,disabled:s||!n.localDesktopMode,onClick:()=>{o(null),a(`remove`)},children:r.state===`conflict`?`Clear Gezel setup…`:`Remove setup…`}),n.error&&(0,C.jsx)(`button`,{type:`button`,onClick:()=>void n.refresh(),disabled:s,children:`Try again`})]}),children:[(0,C.jsx)(m,{open:i===`configure`,title:r?.state===`not-configured`?`Set up pi with Gezel?`:`Update pi setup?`,message:(0,C.jsxs)(C.Fragment,{children:[`Gezel will `,r?.state===`not-configured`?`create`:`update`,` its own pi extension and model list for `,(0,C.jsx)(`strong`,{children:l?.label??n.model}),`.`,` `,l&&x(l)?(0,C.jsxs)(C.Fragment,{children:[`This gezel's character, `,l.modelLabel??`model`,`, and tuning will guide pi.`,` `]}):(0,C.jsx)(C.Fragment,{children:`pi will use it as a raw inference model without a gezel persona. `}),`Both files live in Gezel's own folder`,r?.extensionPath?(0,C.jsxs)(C.Fragment,{children:[`, at `,(0,C.jsx)(`code`,{children:r.extensionPath})]}):null,`, and the command above points pi at them for that run. Your own pi settings, sessions, and models stay untouched.`]}),confirmLabel:r?.state===`not-configured`?`Set up pi`:`Update pi`,onConfirm:n.runConfirmedAction,onCancel:()=>a(null)}),(0,C.jsx)(m,{open:i===`repair`,title:`Repair the pi setup?`,message:(0,C.jsxs)(C.Fragment,{children:[`Gezel will write a working model list for`,` `,(0,C.jsx)(`strong`,{children:l?.label??n.model}),`, connected to this copy of Gezel.`,r?.configPath?(0,C.jsxs)(C.Fragment,{children:[` `,`The file now at `,(0,C.jsx)(`code`,{children:r.configPath}),` is kept as a `,(0,C.jsx)(`code`,{children:`.backup`}),` `,`copy beside it, so nothing is lost.`]}):(0,C.jsx)(C.Fragment,{children:` The file it replaces is kept as a .backup copy beside it, so nothing is lost.`}),` `,`Your own pi configuration stays untouched.`]}),confirmLabel:`Repair setup`,onConfirm:n.runConfirmedAction,onCancel:()=>a(null)}),(0,C.jsx)(m,{open:i===`remove`,title:r?.state===`conflict`?`Clear Gezel setup for pi?`:`Remove Gezel setup from pi?`,message:(0,C.jsxs)(C.Fragment,{children:[`This removes only Gezel's own pi extension, model list, state, and credential`,r?.extension.canRemove?(0,C.jsxs)(C.Fragment,{children:[`, along with the copy Gezel added at `,(0,C.jsx)(`code`,{children:r.extension.path})]}):null,`. It does not uninstall pi or touch your own settings and sessions.`]}),confirmLabel:r?.state===`conflict`?`Clear Gezel setup`:`Remove setup`,danger:!0,onConfirm:n.runConfirmedAction,onCancel:()=>a(null)}),(0,C.jsx)(m,{open:i===`install-extension`||i===`replace-extension`,title:i===`replace-extension`?`Replace the extension file in pi?`:`Add Gezel to pi?`,message:(0,C.jsxs)(C.Fragment,{children:[`Gezel will add its extension`,r?.extension.path?(0,C.jsxs)(C.Fragment,{children:[` `,`at `,(0,C.jsx)(`code`,{children:r.extension.path})]}):null,`, so every pi session on this computer offers the `,(0,C.jsx)(`strong`,{children:`gezel`}),` provider without the command above. It holds no password — it reads Gezel's own model list when pi starts, and does nothing at all when Gezel is not running. It does not change which model pi starts with; pick a gezel from pi's own model picker. Your own pi settings, sessions, and models stay untouched, and `,(0,C.jsx)(`code`,{children:`pi -ne`}),` always starts without it.`,r?.extension.agentDirSource==="default"?(0,C.jsxs)(C.Fragment,{children:[` `,`Gezel found pi's folder in its usual place. If you point pi elsewhere with`,` `,(0,C.jsx)(`code`,{children:`PI_CODING_AGENT_DIR`}),` in your shell, it will not be picked up.`]}):null,i===`replace-extension`?(0,C.jsx)(C.Fragment,{children:` The file it replaces is kept as a .backup copy beside it, so nothing is lost.`}):null]}),confirmLabel:i===`replace-extension`?`Replace extension`:`Add to pi`,onConfirm:n.runConfirmedAction,onCancel:()=>a(null)}),(0,C.jsx)(m,{open:i===`remove-extension`,title:`Remove Gezel from pi?`,message:(0,C.jsxs)(C.Fragment,{children:[`This deletes the extension Gezel added`,r?.extension.path?(0,C.jsxs)(C.Fragment,{children:[` `,`at `,(0,C.jsx)(`code`,{children:r.extension.path})]}):null,`. pi stops offering the gezel provider unless you start it with the command on this card. The rest of the setup, and everything of your own, stays as it is.`]}),confirmLabel:`Remove from pi`,onConfirm:n.runConfirmedAction,onCancel:()=>a(null)})]})}function j(e,t){switch(e){case`remove`:return`Could not remove the pi setup`;case`repair`:return`Could not repair the pi setup`;case`install-extension`:case`replace-extension`:return`Could not add Gezel to pi`;case`remove-extension`:return`Could not remove Gezel from pi`;default:return t===`not-configured`?`Could not set up pi`:`Could not update the pi setup`}}function M({endpointsEnabled:e,onChanged:t}){let[n,r]=(0,v.useState)(``),a=(0,v.useId)(),u=y({label:`VS Code`,endpointsEnabled:e,fetchStatus:()=>d.getVSCodeSetupStatus(),runAction:(0,v.useCallback)(e=>e===`remove`?d.removeVSCodeSetup():d.configureVSCode({profileId:n,...e===`repair`?{backupConflictingConfig:!0}:{}}),[n]),modelSelection:!1,errorPrefix:N,backupNotice:e=>e.configBackupPath?`The previous file was saved as ${e.configBackupPath}.`:null,...t?{onChanged:t}:{}}),{status:f,confirmation:p,setConfirmation:h,setError:g,busy:_}=u;(0,v.useEffect)(()=>{f&&r(e=>f.profiles.some(t=>t.id===e)?e:f.configuredProfileId??f.profiles[0]?.id??``)},[f]);let b=f?.profiles.find(e=>e.id===n),x=P(f?.vscodeVersion),S=!!f?.configuredProfileId,T=u.repairable?`Repair VS Code setup…`:f?.state===`not-configured`?`Set up VS Code…`:`Update VS Code…`;return(0,C.jsxs)(w,{headingId:`vscode-setup-heading`,title:`Use Gezel in VS Code`,status:f,remoteMode:u.remoteMode,localDesktopMode:u.localDesktopMode,endpointsEnabled:e,repairable:!!u.repairable,notice:u.notice,error:u.error,reasonsIntro:`The managed setup needs an update:`,emptyModelsNote:`No gezels or inference models compatible with VS Code's agent tool loop are available yet.`,intro:(0,C.jsx)(C.Fragment,{children:`VS Code keeps its native agent tools, permissions, and conversation loop. Gezel adds your eligible crew and raw local models through VS Code's built-in custom endpoint — no extension is installed. Setup edits only the Gezel provider in the selected profile.`}),repairExplainer:(0,C.jsxs)(C.Fragment,{children:[`Repair keeps a copy of `,(0,C.jsx)(`code`,{children:f?.configPath}),`, then replaces only the conflicting Gezel provider entry. Other providers stay in place.`]}),...f&&!f.vscodeInstalled?{notInstalledNote:`VS Code was not found on PATH. You can prepare its conventional profile now and use it after installing VS Code.`}:{},...u.configured&&b?{configuredNote:(0,C.jsxs)(C.Fragment,{children:[`Gezel is available in `,(0,C.jsx)(`strong`,{children:b.label}),`.`,x?` VS Code ${x} was found.`:``,` Keep Gezel running while you use the models.`]})}:{},extraRows:f&&(f.state!==`conflict`||u.repairable)?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(`div`,{className:`harness-setup-model-row`,children:[(0,C.jsx)(`span`,{id:a,children:`VS Code profile`}),(0,C.jsxs)(i,{value:n,onValueChange:r,disabled:_||!u.localDesktopMode||!e||S,children:[(0,C.jsx)(c,{"aria-labelledby":a,children:(0,C.jsx)(s,{})}),(0,C.jsx)(l,{children:f.profiles.map(e=>(0,C.jsx)(o,{value:e.id,children:e.label},e.id))})]})]}),S&&(0,C.jsx)(`p`,{className:`muted small`,children:`Clear this setup before choosing a different profile.`}),(0,C.jsxs)(`p`,{className:`muted small`,children:[`If VS Code is already open, you may need to run`,` `,(0,C.jsx)(`strong`,{children:`Developer: Reload Window`}),` or restart VS Code after setup before the models work.`]})]}):null,actions:(0,C.jsxs)(C.Fragment,{children:[u.needsConfigure&&(0,C.jsx)(`button`,{type:`button`,className:`primary`,disabled:u.configureDisabled||!n,onClick:()=>{g(null),h(u.repairable?`repair`:`configure`)},children:T}),f?.canRemove&&(0,C.jsx)(`button`,{type:`button`,disabled:_||!u.localDesktopMode,onClick:()=>{g(null),h(`remove`)},children:f.state===`conflict`?`Clear Gezel setup…`:`Remove setup…`}),u.error&&(0,C.jsx)(`button`,{type:`button`,onClick:()=>void u.refresh(),disabled:_,children:`Try again`})]}),children:[(0,C.jsx)(m,{open:p===`configure`,title:f?.state===`not-configured`?`Set up VS Code with Gezel?`:`Update VS Code setup?`,message:(0,C.jsxs)(C.Fragment,{children:[`Gezel will add or update one provider in `,(0,C.jsx)(`code`,{children:b?.configPath}),`. VS Code will show every eligible gezel and raw local model in its native model picker and keep control of agent tools and permissions. Other custom endpoint providers are preserved.`,(0,C.jsx)(`br`,{}),(0,C.jsx)(`br`,{}),`Because no extension is involved, the dedicated inference-only credential is stored as plain text in this profile file. It works only through Gezel's loopback inference bridge and can be revoked by clearing this setup. If VS Code is already open, reload its window or restart it after setup so it picks up the new credential.`]}),confirmLabel:f?.state===`not-configured`?`Set up VS Code`:`Update VS Code`,onConfirm:u.runConfirmedAction,onCancel:()=>h(null)}),(0,C.jsx)(m,{open:p===`repair`,title:`Repair the VS Code setup?`,message:(0,C.jsxs)(C.Fragment,{children:[`Gezel will save the current `,(0,C.jsx)(`code`,{children:f?.configPath}),` beside it as a backup, then publish a working Gezel provider for this installation. Providers that are not named Gezel remain untouched. The replacement contains a new plain-text, inference-only loopback credential.`]}),confirmLabel:`Repair setup`,onConfirm:u.runConfirmedAction,onCancel:()=>h(null)}),(0,C.jsx)(m,{open:p===`remove`,title:`Remove Gezel setup from VS Code?`,message:(0,C.jsx)(C.Fragment,{children:`This removes only the Gezel provider entry, setup state, and dedicated credential. It does not uninstall VS Code, touch other endpoint providers, or delete conversations. A Gezel entry changed outside this setup is preserved, but its credential is revoked.`}),confirmLabel:`Remove setup`,danger:!0,onConfirm:u.runConfirmedAction,onCancel:()=>h(null)})]})}function N(e,t){return e===`remove`?`Could not remove the VS Code setup`:e===`repair`?`Could not repair the VS Code setup`:t===`not-configured`?`Could not set up the VS Code setup`:`Could not update the VS Code setup`}function P(e){if(!e)return;let t=e.split(/\s+/).filter(e=>e&&!/^[a-f\d]{40}$/i.test(e));return t.length>0?t.join(` `):void 0}function F(e){return e?f(e):`never`}var I=`__AUTOMATIC__`,L=new Set([`copilot`,`anthropic-cli`,`codex-cli`]);function R(){let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)(null),[a,u]=(0,v.useState)(null),[f,y]=(0,v.useState)(null),[b,x]=(0,v.useState)({}),[S,w]=(0,v.useState)({}),[T,D]=(0,v.useState)([]),[k,j]=(0,v.useState)(null),[N,P]=(0,v.useState)(0),[R,z]=(0,v.useState)(`copilot`),[B,V]=(0,v.useState)(),H=(0,v.useCallback)(async()=>{try{let e=await fetch(`${d.getBaseUrl()}/v1/apps`,{headers:d.authHeader()});if(!e.ok){r(`Failed to load apps: HTTP ${e.status}`);return}r(null),t(await e.json())}catch(e){r(e instanceof Error?e.message:String(e))}},[]);(0,v.useEffect)(()=>{H();let e=window.setInterval(()=>void H(),4e3);return()=>window.clearInterval(e)},[H]),(0,v.useEffect)(()=>{d.getConfig().then(e=>{w(e.openaiEndpoints??{}),z(e.provider??`llama-cpp`),V(e.meesterGezelId)}).catch(()=>{}),d.listGezels().then(e=>D(e.gezels.map(({id:e,name:t,role:n,provider:r})=>({id:e,name:t,role:n,provider:r})))).catch(()=>{})},[]);let U=(0,v.useCallback)(async e=>{let t=S,n=e.emulateOllama===t.emulateOllama?`endpoints`:`ollama`;w(e),j({scope:n,text:`saving…`});try{let t=await d.updateConfig({openaiEndpoints:e});w(t.openaiEndpoints??{}),P(e=>e+1),j(null)}catch(e){w(t);let r=e&&typeof e==`object`&&`details`in e?e.details?.message:void 0;j({scope:n,text:`save failed: ${r??(e instanceof Error?e.message:String(e))}`})}},[S]),W=S.enabled!==!1,G=T.find(e=>e.id===S.servingGezelId),K=T.find(e=>e.id===B)??T[0],q=G??K,J=e=>e.provider??R,Y=q!==void 0&&L.has(J(q)),X=(0,v.useCallback)(async(t,n)=>{if(a)return;let i=e?.grants.find(e=>e.id===t),o=b[t]??``;u(`${n}:${t}`);try{let e=await fetch(`${d.getBaseUrl()}/v1/apps/grant/${encodeURIComponent(t)}/${n}`,{method:`POST`,headers:{...d.authHeader(),...n===`approve`&&i?.verificationRequired?{"Content-Type":`application/json`}:{}},...n===`approve`&&i?.verificationRequired?{body:JSON.stringify({verificationCode:o})}:{}});if(!e.ok){r(await _(e,`Failed to ${n} grant`));return}x(e=>{let n={...e};return delete n[t],n}),await H()}catch(e){r(e instanceof Error?e.message:String(e))}finally{u(null)}},[a,H,e?.grants,b]),Z=(0,v.useCallback)(async()=>{if(f){u(`revoke:${f.appId}`);try{let e=await fetch(`${d.getBaseUrl()}/v1/apps/${encodeURIComponent(f.appId)}/token`,{method:`DELETE`,headers:d.authHeader()});if(!e.ok){r(`Failed to revoke ${f.appId}: HTTP ${e.status}`);return}y(null),await H(),P(e=>e+1)}finally{u(null)}}},[f,H]),Q=(e?.grants??[]).filter(e=>e.status===`pending`),$=e?.apps??[];return(0,C.jsxs)(`section`,{className:`settings-section`,children:[(0,C.jsx)(`h2`,{children:`Connected Apps`}),(0,C.jsx)(`p`,{className:`muted small`,children:`Apps and command-line clients that have asked for access to your Gezel service. Each client is granted only the scopes it requested. Revoke any time.`}),n&&(0,C.jsx)(`p`,{className:`settings-error`,role:`alert`,children:n}),(0,C.jsxs)(`div`,{className:`settings-subsection`,children:[(0,C.jsx)(`h3`,{children:`OpenAI-compatible endpoints`}),(0,C.jsx)(`p`,{className:`muted small`,children:`Other apps (editors, browser tools) can use your gezellen and models through standard OpenAI-style endpoints. Each app still needs your approval below before it gets access.`}),(0,C.jsxs)(`label`,{className:`debug-toggle`,children:[(0,C.jsx)(`input`,{type:`checkbox`,checked:W,onChange:e=>void U({...S,enabled:e.target.checked?void 0:!1})}),(0,C.jsx)(`span`,{children:`Allow apps to connect`})]}),W?(0,C.jsxs)(`p`,{className:`muted small`,children:[`Point apps at `,(0,C.jsxs)(`code`,{children:[d.getBaseUrl(),`/v1`]})]}):(0,C.jsx)(`p`,{className:`muted small`,children:`Turned off — connected apps are refused and new apps cannot ask for access until this is back on.`}),(0,C.jsxs)(`div`,{className:`connected-apps-serving`,children:[(0,C.jsx)(`span`,{id:`serving-gezel-label`,children:`Fallback gezel`}),(0,C.jsxs)(i,{value:G?G.id:I,onValueChange:e=>void U({...S,servingGezelId:e===I?void 0:e}),disabled:!W,children:[(0,C.jsx)(c,{"aria-labelledby":`serving-gezel-label`,children:(0,C.jsx)(s,{})}),(0,C.jsxs)(l,{children:[(0,C.jsxs)(o,{value:I,children:[`Automatic`,K?` — ${K.name}`:``]}),T.map(e=>(0,C.jsxs)(o,{value:e.id,children:[e.name,e.role?` — ${e.role}`:``,` (${J(e)})`]},e.id))]})]})]}),(0,C.jsxs)(`p`,{className:`muted small`,children:[`Apps receive your gezellen as model choices, including their names and roles. If an app asks for something else, `,q?.name??`your default gezel`,` answers with their character and model settings.`]}),q&&Y&&(0,C.jsxs)(`p`,{className:`small connected-apps-caution`,children:[q.name,` runs on `,J(q),`, which can't accept tools sent by apps — editors that use tools will get an error. For full compatibility, pick a gezel on a local model or a direct API provider.`]}),(0,C.jsxs)(`label`,{className:`debug-toggle`,children:[(0,C.jsx)(`input`,{type:`checkbox`,checked:S.supportingBehaviors!==!1,onChange:e=>void U({...S,supportingBehaviors:e.target.checked?void 0:!1}),disabled:!W}),(0,C.jsx)(`span`,{children:`Supporting behaviors`})]}),(0,C.jsx)(`p`,{className:`muted small`,children:`Gezel knows how to get the best out of each model — catching runaway rambling, folding leaked reasoning, and applying model-specific fixes. Turn this off for plain serving: apps still get the gezel's character and each model's tuned settings (sampling, thinking mode), but no runtime interventions.`}),k?.scope===`endpoints`&&(0,C.jsx)(`output`,{className:`muted small`,children:k.text})]}),(0,C.jsx)(E,{endpointsEnabled:W,onChanged:H},`codex-${N}`),(0,C.jsx)(M,{endpointsEnabled:W,onChanged:H},`vscode-${N}`),(0,C.jsx)(O,{endpointsEnabled:W,onChanged:H},`opencode-${N}`),(0,C.jsx)(A,{endpointsEnabled:W,onChanged:H},`pi-${N}`),(0,C.jsxs)(`div`,{className:`settings-subsection`,children:[(0,C.jsx)(`h3`,{children:`Ollama emulation`}),(0,C.jsxs)(`label`,{className:`debug-toggle`,children:[(0,C.jsx)(`input`,{type:`checkbox`,checked:S.emulateOllama===!0,onChange:e=>void U({...S,emulateOllama:e.target.checked?!0:void 0}),disabled:!W}),(0,C.jsx)(`span`,{children:`Emulate Ollama (port 11434)`})]}),(0,C.jsx)(`p`,{className:`muted small`,children:`Apps that auto-discover Ollama will find gezel instead — no setup needed in each app. Security note: Ollama's convention is no password, so while this is on, any program on this computer can use your models without asking first. Gezel refuses to take the port if Ollama itself is already running.`}),k?.scope===`ollama`&&(0,C.jsx)(`output`,{className:`muted small`,children:k.text})]}),Q.length>0&&(0,C.jsxs)(`div`,{className:`settings-subsection`,children:[(0,C.jsx)(`h3`,{children:`Pending requests`}),(0,C.jsx)(`ul`,{className:`settings-list`,children:Q.map(e=>(0,C.jsxs)(`li`,{className:`connected-app-row connected-app-row--pending`,children:[(0,C.jsxs)(`div`,{className:`connected-app-meta`,children:[(0,C.jsxs)(`div`,{className:`connected-app-name`,children:[e.appName,e.kind===`device`&&(0,C.jsx)(`span`,{className:`badge`,children:` device`})]}),(0,C.jsx)(`div`,{className:`muted small`,children:e.kind===`device`?`wants to run models on this device`:e.scopes.includes(`cli`)?`${e.appId} — wants command-line control of this Gezel service`:e.scopes.includes(`product`)?`${e.appId} — wants access to Gezel features and data`:`${e.appId} — wants: ${e.scopes.join(`, `)}`})]}),(0,C.jsxs)(`div`,{className:`connected-app-actions`,children:[e.verificationRequired&&(0,C.jsxs)(`label`,{className:`connected-app-code`,children:[(0,C.jsx)(`span`,{children:`Connection code`}),(0,C.jsx)(`input`,{value:b[e.id]??``,onChange:t=>{let n=h(t.currentTarget.value);x(t=>({...t,[e.id]:n}))},placeholder:`___-___`,maxLength:7,autoComplete:`off`,autoCapitalize:`characters`,spellCheck:!1,"aria-label":`Connection code for ${e.appName}`})]}),(0,C.jsx)(`button`,{type:`button`,onClick:()=>void X(e.id,`deny`),disabled:a!==null,children:`Deny`}),(0,C.jsx)(`button`,{type:`button`,className:`primary`,onClick:()=>void X(e.id,`approve`),disabled:a!==null||e.verificationRequired&&!g(b[e.id]??``),children:a===`approve:${e.id}`?`Approving…`:`Approve`})]})]},e.id))})]}),(0,C.jsxs)(`div`,{className:`settings-subsection`,children:[(0,C.jsx)(`h3`,{children:`Connected`}),$.length===0?(0,C.jsx)(`p`,{className:`muted small`,children:`No apps connected. Apps that use the gezel SDK appear here after you approve them.`}):(0,C.jsx)(`div`,{className:`connected-apps-table-wrap`,children:(0,C.jsxs)(`table`,{className:`connected-apps-table`,"aria-label":`Connected apps`,children:[(0,C.jsx)(`thead`,{children:(0,C.jsxs)(`tr`,{children:[(0,C.jsx)(`th`,{scope:`col`,children:`App`}),(0,C.jsx)(`th`,{scope:`col`,children:`Scopes`}),(0,C.jsx)(`th`,{scope:`col`,children:`Last used`}),(0,C.jsx)(`th`,{scope:`col`,children:(0,C.jsx)(`span`,{className:`sr-only`,children:`Actions`})})]})}),(0,C.jsx)(`tbody`,{children:$.map(e=>(0,C.jsxs)(`tr`,{children:[(0,C.jsxs)(`td`,{"data-label":`App`,children:[(0,C.jsxs)(`div`,{className:`connected-apps-identity`,children:[(0,C.jsx)(`span`,{className:`connected-apps-name`,children:e.appName}),e.kind===`device`&&(0,C.jsx)(`span`,{className:`connected-apps-kind`,children:`Device`})]}),(0,C.jsx)(`span`,{className:`connected-apps-id`,children:e.appId})]}),(0,C.jsx)(`td`,{"data-label":`Scopes`,children:e.scopes.length>0?(0,C.jsx)(`ul`,{className:`connected-apps-scopes`,children:e.scopes.map(e=>(0,C.jsx)(`li`,{children:e},e))}):(0,C.jsx)(`span`,{className:`connected-apps-empty`,children:`None`})}),(0,C.jsx)(`td`,{"data-label":`Last used`,children:(0,C.jsx)(`span`,{className:`connected-apps-last-used`,title:e.lastUsedAt?p(e.lastUsedAt):void 0,children:F(e.lastUsedAt)})}),(0,C.jsx)(`td`,{className:`connected-apps-action`,children:(0,C.jsx)(`button`,{type:`button`,className:`connected-apps-revoke`,"aria-label":`Revoke ${e.appName}`,onClick:()=>y(e),disabled:a!==null,children:`Revoke`})})]},e.appId))})]})})]}),(0,C.jsx)(m,{open:f!==null,title:f?`Revoke ${f.appName}?`:`Revoke app`,message:f?(0,C.jsxs)(C.Fragment,{children:[`The next time `,(0,C.jsx)(`strong`,{children:f.appName}),` tries to use gezel it will be denied. The app can reconnect later by going through the consent flow again.`]}):null,confirmLabel:`Revoke`,danger:!0,onConfirm:Z,onCancel:()=>y(null)})]})}export{R as ConnectedAppsPanel};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{n as t,t as n}from"./jsx-runtime-CEpd2cAX.js";import{i as r,n as i,r as a}from"./Tabs-BAY1Q79B.js";import{d as o,l as s,m as c,p as l,s as u}from"./primitives-DEsn1shf.js";import{D as d,Et as f,R as p,Tt as m,Yt as h,pn as g,qt as _}from"./dist-BPx-FyRH.js";import{t as v}from"./api-BX5xXiFs.js";import{Y as y,b}from"./index-DXWR4qW1.js";import{i as x}from"./ChatTimelineView-Do9EryEH.js";import{t as S}from"./ProjectTimeline-DRe3D9qY.js";import{t as C}from"./MarkdownField-D-0Zw7gM.js";var w=e(t(),1),T=n(),E=`default`;function D({craftbookId:e,craftbookName:t,readOnly:n}){let r=b(),[i,a]=(0,w.useState)([]),[o,s]=(0,w.useState)(``);(0,w.useEffect)(()=>{v.listGezels().then(e=>a(e.gezels)).catch(()=>{})},[]),(0,w.useEffect)(()=>{s(``)},[e]);let c=(0,w.useMemo)(()=>i.find(e=>e.role===`voorman`)??i.find(e=>e.role===`meester`)??i[0],[i]),l=t=>{t?.startsWith(`craftbook_`)&&window.dispatchEvent(new CustomEvent(`gezel:craftbook-edited`,{detail:{id:e}}))};if(n)return(0,T.jsx)(`div`,{className:`craftbook-chat-pane muted small`,children:`This craftbook is read-only — fork it to a local copy to edit it with AI.`});if(!c)return(0,T.jsx)(`div`,{className:`craftbook-chat-pane muted small`,children:`No gezel available yet. Create a voorman or the Meester first, then come back.`});let u=p(c,r);return(0,T.jsxs)(`div`,{className:`craftbook-chat-pane task-detail-chat`,children:[(0,T.jsx)(S,{projectId:E,activeSessionId:o||void 0,onFocusSession:(e,t)=>{t===c.id&&s(e)},onToolActivity:e=>l(e.name)}),(0,T.jsx)(x,{gezelId:c.id,gezelName:c.name,gezelRoleBasedName:c.roleBasedName,gezelRole:c.role,gezelIcon:c.icon??null,...c.poppetje?{gezelPoppetje:c.poppetje}:{},...c.iconOverride?{gezelIconOverride:c.iconOverride}:{},projectId:E,sessionId:o||void 0,onSessionCreated:e=>s(e),onToolActivity:e=>l(e.name),craftbookRef:e,placeholder:`Ask ${u} to shape “${t}” — add steps, set roles, wire gates…`})]})}function O(e){window.dispatchEvent(new CustomEvent(`gezel:open-tab`,{detail:e}))}function k({craftbookId:e,steps:t,stepId:n,entryStepId:r,gezels:i,readOnly:a,busy:d,onPatch:p,onRemove:h,onSetEntry:g}){let _=n?t.find(e=>e.id===n)??null:null,[v,y]=(0,w.useState)(n),b=(0,w.useRef)(_?.name??``),x=(0,w.useRef)(_?.description??``),S=(0,w.useRef)(_?.prompt??``),E=(0,w.useRef)(_?.suggestedRole??``);if((0,w.useEffect)(()=>{b.current=_?.name??``,x.current=_?.description??``,S.current=_?.prompt??``,E.current=_?.suggestedRole??``,y(_?.id??null)},[_?.id,_?.name,_?.description,_?.prompt,_?.suggestedRole]),!_)return(0,T.jsx)(`section`,{className:`task-step-panel empty`,children:(0,T.jsx)(`p`,{className:`muted small`,children:t.length===0?`No steps yet — add one with the + button to begin.`:`Select a step above to view and edit it.`})});let D=_.id===r,k=e=>{a||p(_.id,e)},A=()=>{let e=b.current.trim();!e||e===_.name||k({name:e})},j=()=>{x.current!==(_.description??``)&&k({description:x.current})},M=()=>{S.current!==(_.prompt??``)&&k({prompt:S.current})},N=()=>{let e=E.current.trim();e!==(_.suggestedRole??``)&&k({suggestedRole:e||null})},P=_.assignee?_.assignee.kind===`user`?`__user`:_.assignee.gezelId:_.suggestedGezelId?_.suggestedGezelId:`__none`,F=e=>{k(e===`__user`?{assignee:{kind:`user`},suggestedGezelId:null}:e===`__none`?{assignee:null,suggestedGezelId:null}:{assignee:null,suggestedGezelId:e})},I=_.terminal?`__terminal`:_.next??`__linear`,L=e=>{k(e===`__terminal`?{terminal:!0,next:null}:e===`__linear`?{terminal:!1,next:null}:{terminal:!1,next:e})},R=t=>{let n=m(t===`enter`?_.onEnter:_.onExit),r=t===`enter`?`onEnter`:`onExit`,i=e=>k({[r]:e.length>0?e:null});return(0,T.jsxs)(`div`,{className:`step-script-row`,children:[(0,T.jsx)(`span`,{className:`step-script-moment muted small`,children:t===`enter`?`when it starts`:`when it finishes`}),n.length===0&&a&&(0,T.jsx)(`span`,{className:`muted small`,children:`—`}),n.map((t,r)=>(0,T.jsxs)(`span`,{className:`step-script-chip`,children:[(0,T.jsxs)(`button`,{type:`button`,className:`link-button`,onClick:()=>{(t.scope===void 0||t.scope===`craftbook`)&&O({kind:`craftbook-script`,craftbookId:e,name:t.name})},title:t.scope?`${t.scope} script`:`Open this script in the editor`,children:[`⚙ `,t.name,t.scope&&t.scope!==`craftbook`?` (${t.scope})`:``]}),!a&&(0,T.jsx)(`button`,{type:`button`,className:`link-button muted`,onClick:()=>i(n.filter((e,t)=>t!==r)),children:`detach`})]},`${t.scope??`craftbook`}:${t.name}:${r}`)),!a&&(0,T.jsx)(`button`,{type:`button`,className:`link-button`,onClick:()=>{let r=`${_.id}-${t}${n.length>0?`-${n.length+1}`:``}`;i([...n,{name:r}]),O({kind:`craftbook-script`,craftbookId:e,name:r})},children:`+ attach script`})]})},z=[];if(_.gate){let e=f(_.gate),t=[...e.checks.length>0?[`${e.checks.length} check(s)`]:[],...e.scripts.length>0?[`${e.scripts.length} script(s)`]:[]];z.push(`gate at ${e.at}: ${t.join(` + `)||`empty`}`)}return _.advanceWhen&&z.push(`auto-advance on ${_.advanceWhen.file}`),_.branches&&_.branches.length>0&&z.push(`${_.branches.length} branch(es)`),(0,T.jsxs)(`section`,{className:`task-step-panel`,children:[(0,T.jsxs)(`header`,{className:`task-step-panel-header`,children:[(0,T.jsxs)(`div`,{className:`task-step-panel-title`,children:[(0,T.jsx)(`h4`,{children:_.name}),D&&(0,T.jsx)(`span`,{className:`step-status-pill status-active`,children:`Entry`})]}),!a&&(0,T.jsxs)(`div`,{className:`task-step-panel-actions`,children:[(0,T.jsx)(`button`,{type:`button`,className:`secondary`,onClick:()=>void g(_.id),disabled:d||D,title:`Make this the craftbook's entry step`,children:`Set as entry`}),(0,T.jsx)(`button`,{type:`button`,className:`danger`,onClick:()=>void h(_.id),disabled:d||t.length<=1,title:t.length<=1?`A craftbook needs at least one step`:`Delete this step`,children:`Delete`})]})]}),(0,T.jsxs)(`div`,{className:`task-step-panel-grid`,children:[(0,T.jsxs)(`label`,{className:`task-step-field`,children:[(0,T.jsx)(`span`,{className:`task-step-field-label`,children:`Name`}),(0,T.jsx)(`input`,{defaultValue:_.name,disabled:a,onChange:e=>{b.current=e.target.value},onBlur:A},`name-${v}`)]}),(0,T.jsxs)(`label`,{className:`task-step-field`,children:[(0,T.jsx)(`span`,{className:`task-step-field-label`,children:`Indexed context`}),(0,T.jsxs)(o,{value:_.retrieval?.mode??`__inherit`,disabled:a||d,onValueChange:e=>k(e===`__inherit`?{retrieval:null}:{retrieval:{mode:e,..._.retrieval?.maxTokens?{maxTokens:_.retrieval.maxTokens}:{},..._.retrieval?.sources?{sources:_.retrieval.sources}:{}}}),children:[(0,T.jsx)(l,{children:(0,T.jsx)(c,{})}),(0,T.jsxs)(u,{children:[(0,T.jsx)(s,{value:`__inherit`,children:`Inherit from gezel`}),(0,T.jsx)(s,{value:`off`,children:`Off — tools only`}),(0,T.jsx)(s,{value:`lean`,children:`Lean — paths and hints`}),(0,T.jsx)(s,{value:`balanced`,children:`Balanced — a few excerpts`}),(0,T.jsx)(s,{value:`deep`,children:`Deep — broad evidence`})]})]})]}),(0,T.jsxs)(`label`,{className:`task-step-field`,children:[(0,T.jsx)(`span`,{className:`task-step-field-label`,children:`Context token cap`}),(0,T.jsx)(`input`,{type:`number`,min:0,max:16e3,defaultValue:_.retrieval?.maxTokens??``,disabled:a||d||!_.retrieval||_.retrieval.mode===`off`,placeholder:`Mode default`,onBlur:e=>{if(!_.retrieval)return;let t=e.currentTarget.value.trim(),n=t?Number.parseInt(t,10):void 0;if(n!==void 0&&!Number.isFinite(n)||n===_.retrieval.maxTokens)return;let{maxTokens:r,...i}=_.retrieval;k({retrieval:n===void 0?i:{...i,maxTokens:n}})}},`retrieval-budget-${v}`)]}),(0,T.jsxs)(`label`,{className:`task-step-field`,children:[(0,T.jsx)(`span`,{className:`task-step-field-label`,children:`Suggested role`}),(0,T.jsx)(`input`,{defaultValue:_.suggestedRole??``,disabled:a,placeholder:`developer, reviewer, designer…`,onChange:e=>{E.current=e.target.value},onBlur:N},`role-${v}`)]}),(0,T.jsxs)(`label`,{className:`task-step-field`,children:[(0,T.jsx)(`span`,{className:`task-step-field-label`,children:`Assignee (override)`}),(0,T.jsxs)(o,{value:P,disabled:a||d,onValueChange:F,children:[(0,T.jsx)(l,{children:(0,T.jsx)(c,{})}),(0,T.jsxs)(u,{children:[(0,T.jsx)(s,{value:`__none`,children:`— by role —`}),(0,T.jsx)(s,{value:`__user`,children:`→ You`}),i.map(e=>(0,T.jsxs)(s,{value:e.id,children:[`→ `,e.name]},e.id))]})]})]}),(0,T.jsxs)(`label`,{className:`task-step-field`,children:[(0,T.jsx)(`span`,{className:`task-step-field-label`,children:`Next step`}),(0,T.jsxs)(o,{value:I,disabled:a||d,onValueChange:L,children:[(0,T.jsx)(l,{children:(0,T.jsx)(c,{})}),(0,T.jsxs)(u,{children:[(0,T.jsx)(s,{value:`__linear`,children:`→ next in order`}),(0,T.jsx)(s,{value:`__terminal`,children:`■ terminal (ends here)`}),t.filter(e=>e.id!==_.id).map(e=>(0,T.jsxs)(s,{value:e.id,children:[`→ `,e.name]},e.id))]})]})]}),(0,T.jsxs)(`div`,{className:`task-step-field full-width`,children:[(0,T.jsx)(`span`,{className:`task-step-field-label`,children:`Description`}),(0,T.jsx)(C,{value:_.description??``,readOnly:a,placeholder:`What this step produces, who it's for, what 'done' looks like.`,onCommit:e=>{x.current=e,j()}},`desc-${v}`)]}),(0,T.jsxs)(`div`,{className:`task-step-field full-width`,children:[(0,T.jsxs)(`span`,{className:`task-step-field-label`,children:[`Prompt `,(0,T.jsx)(`span`,{className:`muted small`,children:`— step-specific guidance for the assignee`})]}),(0,T.jsx)(C,{value:_.prompt??``,readOnly:a,placeholder:`Instructions the assignee can lean on for this step.`,onCommit:e=>{S.current=e,M()}},`prompt-${v}`)]}),(0,T.jsxs)(`div`,{className:`task-step-field full-width`,children:[(0,T.jsx)(`span`,{className:`task-step-field-label`,children:`Scripts`}),(0,T.jsxs)(`div`,{className:`step-scripts`,children:[R(`enter`),R(`exit`)]})]}),z.length>0&&(0,T.jsxs)(`div`,{className:`task-step-field full-width`,children:[(0,T.jsx)(`span`,{className:`task-step-field-label`,children:`Routing`}),(0,T.jsxs)(`p`,{className:`muted small`,children:[z.join(` · `),` — edit gates/branches/auto-advance via the AI assist.`]})]})]})]})}function A(e){window.dispatchEvent(new CustomEvent(`gezel:open-tab`,{detail:e}))}function j(e){return{name:e.name,description:e.description??null,plan:e.plan??null,defaultAssignee:e.defaultAssignee??null,steps:e.steps,entryStepId:e.entryStepId}}function M({craftbookId:e,source:t,onChanged:n}){let[o,s]=(0,w.useState)(null),[c,l]=(0,w.useState)(t??`local`),[u,f]=(0,w.useState)([]),[p,m]=(0,w.useState)(null),[b,x]=(0,w.useState)(`editor`),[S,E]=(0,w.useState)(!1),[O,M]=(0,w.useState)(null),N=(0,w.useRef)(``),P=(0,w.useRef)(``),F=c!==`local`,I=(0,w.useCallback)(async()=>{try{let n=await v.getCraftbook(e,t?{source:t}:{});s(n.craftbook),N.current=n.craftbook.name,P.current=n.craftbook.description??``,m(e=>e&&n.craftbook.steps.some(t=>t.id===e)?e:n.craftbook.entryStepId??n.craftbook.steps[0]?.id??null)}catch(e){M(e.message)}},[e,t]);(0,w.useEffect)(()=>{I()},[I]),(0,w.useEffect)(()=>{v.listGezels().then(e=>f(e.gezels)).catch(()=>{})},[]),(0,w.useEffect)(()=>{if(t){l(t);return}v.listCraftbooks({source:`all`}).then(t=>{let n=t.craftbooks.find(t=>t.id===e);n&&l(n.source)}).catch(()=>{})},[e,t]),(0,w.useEffect)(()=>{let t=t=>{let n=t.detail;(!n?.id||n.id===e)&&I()};return window.addEventListener(`gezel:craftbook-edited`,t),()=>window.removeEventListener(`gezel:craftbook-edited`,t)},[e,I]);let L=(0,w.useCallback)(async e=>{if(s(e),!F){E(!0),M(null);try{let t=await v.updateCraftbook(e.id,j(e));s(t.craftbook),n?.()}catch(e){M(e.message),await I()}finally{E(!1)}}},[F,n,I]);if(O&&!o)return(0,T.jsx)(`p`,{className:`error`,children:O});if(!o)return(0,T.jsx)(`p`,{className:`placeholder`,children:`Loading…`});let R=(e,t)=>{L({...o,steps:o.steps.map(n=>n.id===e?d(n,t):n)})},z=e=>{L({...o,steps:h(o.steps,e)})},B=e=>{try{let t=_(o.steps,e),n=o.entryStepId===e?t[0].id:o.entryStepId;p===e&&m(n),L({...o,steps:t,entryStepId:n})}catch(e){M(e.message)}},V=e=>{L({...o,entryStepId:e})},H=()=>{let e=g(o.steps,`New step`),t={id:e,name:`New step`};m(e),L({...o,steps:[...o.steps,t]})},U=()=>{let e=N.current.trim();!e||e===o.name||L({...o,name:e})},W=()=>{P.current!==(o.description??``)&&L({...o,description:P.current||void 0})},G=async()=>{E(!0),M(null);try{A({kind:`craftbook`,id:(await v.createCraftbook({name:`${o.name} (copy)`,...o.description?{description:o.description}:{},...o.plan?{plan:o.plan}:{},steps:o.steps,entryStepId:o.entryStepId})).craftbook.id,source:`local`})}catch(e){M(e.message)}finally{E(!1)}};return(0,T.jsxs)(`div`,{className:`craftbook-editor`,"data-testid":`craftbook-editor`,children:[(0,T.jsxs)(`header`,{className:`craftbook-editor-header`,children:[(0,T.jsxs)(`div`,{className:`craftbook-editor-title`,children:[F?(0,T.jsx)(`h3`,{children:o.name}):(0,T.jsx)(`input`,{className:`craftbook-name-input`,defaultValue:o.name,onChange:e=>{N.current=e.target.value},onBlur:U,"aria-label":`Craftbook name`}),(0,T.jsx)(`span`,{className:`task-ref`,children:o.id}),(0,T.jsx)(`span`,{className:`task-badge task-badge-${c}`,children:c}),F&&(0,T.jsx)(`button`,{type:`button`,className:`primary`,onClick:()=>void G(),disabled:S,children:`Copy to edit`})]}),O&&(0,T.jsx)(`p`,{className:`error small`,children:O})]}),(0,T.jsx)(`div`,{className:`task-bench-row craftbook-bench-row${p===null?``:` has-docked-panel has-selected-step`}`,children:(0,T.jsx)(y,{steps:o.steps,selectedStepId:p,onSelect:m,entryStepId:o.entryStepId,busy:S,ariaLabel:`Craftbook steps`,addLabel:`Add step`,variant:`bench`,...F?{}:{onAddStep:H,onReorder:z}})}),(0,T.jsx)(k,{craftbookId:o.id,steps:o.steps,stepId:p,entryStepId:o.entryStepId,gezels:u,readOnly:F,busy:S,onPatch:R,onRemove:B,onSetEntry:V}),(0,T.jsx)(`div`,{className:`craftbook-editor-tabs`,children:(0,T.jsx)(a,{value:b,onValueChange:e=>x(e),children:(0,T.jsxs)(i,{children:[(0,T.jsx)(r,{value:`editor`,children:`Overview`}),(0,T.jsx)(r,{value:`chat`,children:`AI assist`})]})})}),b===`editor`&&(0,T.jsxs)(`div`,{className:`craftbook-overview`,children:[(0,T.jsxs)(`div`,{className:`task-step-field full-width`,children:[(0,T.jsx)(`span`,{className:`task-step-field-label`,children:`Description`}),(0,T.jsx)(C,{value:o.description??``,readOnly:F,placeholder:`What this craftbook is for and when to reach for it.`,onCommit:e=>{P.current=e,W()}},`cbdesc-${o.id}`)]}),o.plan&&(0,T.jsxs)(`div`,{className:`task-step-field full-width`,children:[(0,T.jsx)(`span`,{className:`task-step-field-label`,children:`Plan`}),(0,T.jsx)(`p`,{className:`muted small`,children:o.plan})]})]}),b===`chat`&&(0,T.jsx)(D,{craftbookId:o.id,craftbookName:o.name,readOnly:F})]})}export{M as t};
@@ -1 +0,0 @@
1
- import{i as e,n as t}from"./rolldown-runtime-aKtaBQYM.js";import{n,t as r}from"./jsx-runtime-CEpd2cAX.js";import{t as i}from"./api-BX5xXiFs.js";import{t as a}from"./preload-helper-Czpn1I53.js";import{n as o}from"./styles-CKr_yrbn.js";import{ft as s,v as c}from"./index-DXWR4qW1.js";import{c as l,d as u,f as d,h as f,i as p,m,p as h,s as g}from"./file-browser-80qWoVju.js";import{a as _,c as v,l as y,n as b,o as x,r as S,s as C,t as w,u as T}from"./outside-in-BFVUUcLa.js";import{r as E,t as D}from"./TransformToolbarButton-CVg5nz36.js";import{t as O}from"./markdown-baseline-HMqF2ChK.js";var k={md:`text/markdown`,markdown:`text/markdown`,txt:`text/plain`,json:`application/json`,jpg:`image/jpeg`,jpeg:`image/jpeg`,png:`image/png`,gif:`image/gif`,svg:`image/svg+xml`,webp:`image/webp`,avif:`image/avif`,bmp:`image/bmp`,mp4:`video/mp4`,webm:`video/webm`,mp3:`audio/mpeg`,wav:`audio/wav`,ogg:`audio/ogg`,css:`text/css`,html:`text/html`,js:`application/javascript`};function A(e){let t=e.lastIndexOf(`.`);return t===-1?`application/octet-stream`:k[e.slice(t+1).toLowerCase()]??`application/octet-stream`}function j(e){return e===`text/markdown`||e===`text/plain`||e===`application/json`||e===`text/css`||e===`text/html`||e===`application/javascript`||e===`image/svg+xml`}function M(e,t){return e?t?`${e.replace(/\/+$/,``)}/${t.replace(/^\/+/,``)}`:e:t}function N(e){let t=e.lastIndexOf(`/`);return t===-1?e:e.slice(t+1)}function P(e){let{root:t,client:n,primaryDocumentFilename:r}=e;return{async readFile(e){let r=M(t,e),i=A(e);try{if(j(i)){let e=await n.readDocument(r);return new TextEncoder().encode(e.content).buffer}return await(await n.fetchDocumentBlob(r)).arrayBuffer()}catch{return null}},async writeFile(e,r,i){let a=M(t,e),o=i??A(e);if(j(o)){let e=new TextDecoder().decode(r);await n.writeDocument(a,e);return}await n.writeDocumentBinary(a,r,o)},async removeFile(e){let r=M(t,e);try{await n.deleteDocument(r)}catch{}},async listFiles(e){let r=e?M(t,e):t||void 0,i=await n.listDocuments(r,!0),a=[],o=t?`${t.replace(/\/+$/,``)}/`:``;for(let e of i.files){if(e.isDirectory)continue;let t=o&&e.path.startsWith(o)?e.path.slice(o.length):e.path;a.push({path:t,mimeType:A(t),size:0})}return a},async exists(e){return await this.readFile(e)!==null},async getDocumentPath(){if(r)return r;let e=(await this.listFiles()).filter(e=>!e.path.includes(`/`));for(let t of[`index.md`,`doc.md`,`document.md`]){let n=e.find(e=>e.path.toLowerCase()===t);if(n)return n.path}return e.find(e=>e.path.toLowerCase().endsWith(`.md`))?.path??null},async readDocument(){let e=await this.getDocumentPath();if(!e)return null;let t=await this.readFile(e);return t?new TextDecoder().decode(t):null},async writeDocument(e,t){let n=t??r??`index.md`,i=new TextEncoder().encode(e);await this.writeFile(n,i,`text/markdown`)}}}function F(e){let t=e.replace(/^\/+/,``),n=t.lastIndexOf(`/`);return n===-1?{root:``,primaryDocumentFilename:t}:{root:t.slice(0,n),primaryDocumentFilename:N(t)}}var I=e(n(),1),L=r();function R(e){let t=e.lastIndexOf(`/`);return t<0?e:e.slice(t+1)}async function z(e,t){let n=w(t,(await i.listDocuments(``,!0)).files.filter(e=>!e.isDirectory).map(e=>e.path)),r;if(n)r=(await i.readDocument(n)).content;else{let a=await b(await(await i.fetchDocumentBlob(e)).arrayBuffer(),t),o=P({root:t.companionDirectory,client:i,primaryDocumentFilename:t.markdownFilename});for(let t of await a.container.listFiles()){if(/\.md$/i.test(t.path)||R(t.path).toLocaleLowerCase(`en-US`)===R(e).toLocaleLowerCase(`en-US`))continue;let n=await a.container.readFile(t.path);n&&await o.writeFile(t.path,n,t.mimeType)}r=T(a.markdown,t),await o.writeDocument(r,t.markdownFilename),n=t.markdownPath}let a=T(r,t);return a!==r&&(await i.writeDocument(n,a),r=a),{sourcePath:n,content:r,editingEnabled:S(r)}}function B({path:e,layout:t}){let[n,r]=(0,I.useState)(null),[a,o]=(0,I.useState)(null),[s,c]=(0,I.useState)(null),[l,u]=(0,I.useState)(!1);(0,I.useEffect)(()=>{let n=!1;return r(null),o(null),c(null),z(e,t).then(e=>{n||r(e)}).catch(e=>{n||o(e instanceof Error?e.message:String(e))}),()=>{n=!0}},[t,e]);let d=(0,I.useCallback)(async()=>{if(!(!n||l)){u(!0),c(null);try{if(!(await i.listDocuments(``,!0)).files.some(e=>e.path===t.backupPath)){let e=await i.fetchDocumentBlob(t.targetPath);await i.writeDocumentBinary(t.backupPath,e,e.type||`application/octet-stream`)}let e=y(n.content,t);await i.writeDocument(n.sourcePath,e),r({...n,content:e,editingEnabled:!0})}catch(e){c(e instanceof Error?e.message:String(e))}finally{u(!1)}}},[l,t,n]);return a?(0,L.jsx)(`div`,{className:`placeholder`,children:(0,L.jsxs)(`p`,{children:[`Couldn't open `,(0,L.jsx)(`code`,{children:e}),`: `,a]})}):n?(0,L.jsx)(V,{path:e,layout:t,prepared:n,enabling:l,enableError:s,onEnableEditing:d},`${n.sourcePath}:${n.editingEnabled?`editable`:`readonly`}`):(0,L.jsxs)(`p`,{className:`placeholder`,children:[`Importing `,e,` for viewing…`]})}function V({path:e,layout:t,prepared:n,enabling:r,enableError:l,onEnableEditing:f}){let p=s(),g=u(),y=(0,I.useMemo)(()=>P({root:t.companionDirectory,client:i,primaryDocumentFilename:R(n.sourcePath)}),[t.companionDirectory,n.sourcePath]),b=(0,I.useMemo)(()=>h({client:i,currentDocumentPath:n.sourcePath}),[n.sourcePath]),S=(0,I.useCallback)(async e=>{let r=T(e,t),o=await i.listDocuments(``,!0),s=t.format===`html`?v(t.targetPath,new Set(o.files.filter(e=>e.isDirectory).map(e=>e.path.replace(/^\/+/,``)))):void 0,c=await x(r,t,y,s?_(t.parentDirectory,s):void 0);if(await i.writeDocument(n.sourcePath,r),s){let{PLAYER_BUNDLE:e}=await a(async()=>{let{PLAYER_BUNDLE:e}=await import(`./standalone-source-D6mbpa3h.js`);return{PLAYER_BUNDLE:e}},[]);await i.writeDocument(s,e)}await i.writeDocumentBinary(t.targetPath,c.bytes,c.mimeType)},[y,t,n.sourcePath]),C=(0,I.useMemo)(()=>O(n.content),[n.content]),w=c({resourceKey:`outside-in:documents:${n.sourcePath}`,initialValue:C,save:S}),k=(0,I.useCallback)(e=>{w.update(e)},[w.update]);return(0,L.jsxs)(`section`,{className:`document-detail`,"data-testid":`document-detail`,children:[!n.editingEnabled&&(0,L.jsxs)(`output`,{className:`outside-in-readonly-banner`,children:[(0,L.jsxs)(`span`,{children:[(0,L.jsxs)(`strong`,{children:[t.format.toUpperCase(),` preview · read-only.`]}),` If you enable editing via markdown, the structure of your `,t.format.toUpperCase(),` will not be fully preserved.`]}),l&&(0,L.jsxs)(`span`,{className:`error`,children:[`Could not enable editing: `,l]}),(0,L.jsx)(`button`,{type:`button`,disabled:r,onClick:()=>void f(),children:r?`Preparing…`:`Enable editing`})]}),(0,L.jsx)(`div`,{className:`editor-wrap`,children:(0,L.jsx)(o,{initialMarkdown:w.desiredValue(),fileName:e,readOnly:!n.editingEnabled,onChange:n.editingEnabled?k:void 0,height:`100%`,colorScheme:p,fullWidth:!0,workspaceContainer:y,documentLinkProvider:b,proofing:g,proofingIgnoreStore:d,allowVersioning:n.editingEnabled,versionBasename:R(n.sourcePath),toolbarSlotAfterActions:(0,L.jsxs)(L.Fragment,{children:[n.editingEnabled&&(0,L.jsx)(D,{context:`generic`}),(0,L.jsx)(m,{fileName:e})]}),statusBarSlotRight:n.editingEnabled?(0,L.jsx)(E,{autosave:w}):void 0})})]})}var H=t({DocumentDetail:()=>W});function U(e){let t=e.slice(e.lastIndexOf(`/`)+1);return!t.includes(`.`)||/\.(md|markdown|mdx)$/i.test(t)}function W({path:e}){let t=(0,I.useMemo)(()=>C(e),[e]);return t?(0,L.jsx)(B,{path:e,layout:t}):(0,L.jsx)(K,{path:e})}var G=e=>i.fetchDocumentBlob(e);function K({path:e}){let t=s(),n=u(),[r,a]=(0,I.useState)(null),[_,v]=(0,I.useState)(void 0),[y,b]=(0,I.useState)(null),x=(0,I.useCallback)(t=>i.writeDocument(e,t),[e]),S=c({resourceKey:`document:${e}`,initialValue:r??``,save:x}),{root:C,primaryDocumentFilename:w}=(0,I.useMemo)(()=>F(e),[e]),T=(0,I.useMemo)(()=>P({root:C,client:i,primaryDocumentFilename:w}),[C,w]),k=(0,I.useMemo)(()=>h({client:i,currentDocumentPath:e}),[e]);(0,I.useEffect)(()=>{let t=!1;return a(null),v(void 0),b(null),(async()=>{try{let n=await i.readDocument(e);if(t)return;v(n.size);let r=U(e)?O(n.content):n.content;a(S.hydrate(r))}catch(e){t||b(e.message)}})(),()=>{t=!0}},[e,S.hydrate]);let A=(0,I.useCallback)(e=>{S.update(e)},[S.update]);if(y)return(0,L.jsx)(`div`,{className:`placeholder`,children:(0,L.jsxs)(`p`,{children:[`Couldn't open `,(0,L.jsx)(`code`,{children:e}),`: `,y]})});if(r===null)return(0,L.jsxs)(`p`,{className:`placeholder`,children:[`Loading `,e,`…`]});if(l(r))return(0,L.jsx)(g,{content:p,path:e,fetchBlob:G,..._===void 0?{}:{sizeBytes:_}});let j=U(e);return(0,L.jsx)(`section`,{className:`document-detail`,"data-testid":`document-detail`,children:(0,L.jsx)(`div`,{className:`editor-wrap`,children:(0,L.jsx)(o,{initialMarkdown:r,fileName:e,onChange:A,height:`100%`,colorScheme:t,fullWidth:!0,workspaceContainer:j?T:null,documentLinkProvider:j?k:null,proofing:j?n:null,proofingIgnoreStore:d,allowVersioning:j,versionBasename:w,toolbarSlotAfterActions:j?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(D,{context:`generic`}),(0,L.jsx)(m,{fileName:e})]}):void 0,toolbarSlotRight:j?(0,L.jsx)(f,{selectedFile:e,mediaContainer:T,mediaSource:{kind:`documents`}}):void 0,statusBarSlotRight:(0,L.jsx)(E,{autosave:S})})})})}export{H as n,W as t};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{n as t,t as n}from"./jsx-runtime-CEpd2cAX.js";import{ft as r,ht as i}from"./dist-BPx-FyRH.js";import{t as a}from"./api-BX5xXiFs.js";import{a as o,o as s,s as c,u as l}from"./NewPathDialog-D4jnNBfP.js";import"./schemas-JY4jmLbC.js";import{ft as u,o as d,y as f}from"./index-DXWR4qW1.js";import{l as p,n as m,s as h,t as g,u as _}from"./file-browser-80qWoVju.js";import{t as v}from"./ProjectGitStatusBar-C6bkCSby.js";import{t as ee}from"./DocumentDetail-CPU51d04.js";var y=n(),b=e(t(),1);function x({name:e,entries:t,onOpenFile:n,onOpenFolder:r,onNewDocument:i,onNewFolder:a,theme:o=`light`,height:s=`100%`,iconFor:c=C}){let l=[...t].sort((e,t)=>e.isDirectory===t.isDirectory?e.name.localeCompare(t.name,void 0,{sensitivity:`base`}):e.isDirectory?-1:1);return(0,y.jsxs)(`div`,{className:`squisq-folder-view`,"data-theme":o,style:{height:s},children:[(0,y.jsxs)(`div`,{className:`squisq-folder-view-header`,children:[(0,y.jsx)(`i`,{className:`fa-regular fa-folder-open squisq-folder-view-header-icon`,"aria-hidden":`true`}),(0,y.jsx)(`span`,{className:`squisq-folder-view-title`,children:e}),(0,y.jsxs)(`span`,{className:`squisq-folder-view-count`,children:[t.length,` `,t.length===1?`item`:`items`]})]}),(0,y.jsx)(`div`,{className:`squisq-folder-view-body`,children:l.length===0?(0,y.jsx)(`p`,{className:`squisq-folder-view-empty`,children:`This folder is empty.`}):(0,y.jsx)(`ul`,{className:`squisq-folder-view-list`,children:l.map(e=>(0,y.jsx)(`li`,{children:(0,y.jsxs)(`button`,{type:`button`,className:`squisq-folder-view-item`,onClick:()=>e.isDirectory?r(e):n(e),children:[(0,y.jsx)(`span`,{className:`squisq-folder-view-item-icon`,children:c(e)}),(0,y.jsx)(`span`,{className:`squisq-folder-view-item-name`,children:e.name}),e.isDirectory&&(0,y.jsx)(`i`,{className:`fa-solid fa-chevron-right squisq-folder-view-item-chevron`,"aria-hidden":`true`})]})},e.path))})}),(0,y.jsxs)(`div`,{className:`squisq-folder-view-actions`,children:[(0,y.jsxs)(`button`,{type:`button`,className:`squisq-folder-view-new`,onClick:i,children:[(0,y.jsx)(`i`,{className:`fa-solid fa-plus`,"aria-hidden":`true`}),` New document`]}),a&&(0,y.jsxs)(`button`,{type:`button`,className:`squisq-folder-view-new-folder`,onClick:a,children:[(0,y.jsx)(`i`,{className:`fa-regular fa-folder`,"aria-hidden":`true`}),` New folder`]})]})]})}var S=/\.(png|jpe?g|gif|svg|webp|bmp|avif)$/i;function C(e){return e.isDirectory?(0,y.jsx)(`i`,{className:`fa-regular fa-folder fa-fw`,"aria-hidden":`true`}):S.test(e.name)?(0,y.jsx)(`i`,{className:`fa-regular fa-file-image fa-fw`,"aria-hidden":`true`}):(0,y.jsx)(`i`,{className:`fa-regular fa-file-lines fa-fw`,"aria-hidden":`true`})}var w=2,T=200;function E(){let[e,t]=(0,b.useState)(``),[n,r]=(0,b.useState)(null),[i,o]=(0,b.useState)(``),[s,c]=(0,b.useState)(!1),[l,u]=(0,b.useState)(!1);return(0,b.useEffect)(()=>{let t=e.trim();if(t.length<w){r(null),o(``),c(!1),u(!1);return}let n=!1;c(!0);let i=window.setTimeout(()=>{a.searchDocuments({q:t}).then(e=>{n||(u(e.engine===`unavailable`),o(t),r(e.results.map(e=>({entry:{name:e.path.split(`/`).pop()??e.path,path:e.path,isDirectory:!1},snippet:e.snippet,line:e.lineStart,related:e.source===`vector`}))))}).catch(()=>{n||(o(t),r([]))}).finally(()=>{n||c(!1)})},T);return()=>{n=!0,window.clearTimeout(i)}},[e]),{query:e,setQuery:t,hits:n,matchedQuery:i,searching:s,unavailable:l,clear:()=>t(``)}}var D=`gezel:documents:selectedPath`;function O(){try{return window.localStorage.getItem(D)}catch{return null}}function k(e){try{e?window.localStorage.setItem(D,e):window.localStorage.removeItem(D)}catch{}}function A(e){try{return window.localStorage.getItem(e)}catch{return null}}function j(e,t){try{window.localStorage.setItem(e,t)}catch{}}function M(){let e=u(),t=(0,b.useMemo)(()=>m(),[]),n=E(),[S,C]=(0,b.useState)([]),[w,T]=(0,b.useState)(!1),[D,M]=(0,b.useState)(!1),[N,te]=(0,b.useState)(null),[P,F]=(0,b.useState)(()=>l(A(s),`documents`)),[I,L]=(0,b.useState)(()=>A(o)===`1`),[R,z]=(0,b.useState)(()=>O()),[B,V]=(0,b.useState)(null);(0,b.useEffect)(()=>{let e=!1;return a.listProjects().then(t=>{if(e)return;let n=t.projects.find(e=>i(e));V(n?.id??null)}).catch(()=>{}),()=>{e=!0}},[]);let H=(0,b.useCallback)(e=>{z(e),k(e)},[]),U=(0,b.useCallback)(e=>{F(e),j(s,e)},[]),W=(0,b.useCallback)(e=>{L(e),j(o,e?`1`:`0`)},[]),G=(0,b.useCallback)(async()=>{try{let e=await t.list({hidden:I});C(e.files),T(e.truncated===!0),M(!0)}catch(e){te(e.message)}},[I,t]);(0,b.useEffect)(()=>{G()},[G]);let K=(0,b.useMemo)(()=>I?S:S.filter(e=>!r(e.path)),[S,I]),q=g({source:t,entries:S,selectedPath:R,onSelectPath:H,refresh:G});(0,b.useEffect)(()=>{if(K.length===0)return;let e=K.find(e=>!e.isDirectory)??K[0];e&&z(t=>t&&K.some(e=>e.path===t)?t:e.path)},[K]);let J=(0,b.useMemo)(()=>R?K.find(e=>e.path===R)??null:null,[K,R]),Y=J?.isDirectory??!1,X=R?R.slice(R.lastIndexOf(`/`)+1):``,Z=(0,b.useMemo)(()=>{if(!R||!Y)return[];let e=`${R}/`;return K.filter(t=>t.path.startsWith(e)&&!t.path.slice(e.length).includes(`/`))},[K,R,Y]),Q=R&&!Y?p(R):null,$;$=R?Y?(0,y.jsx)(x,{name:X,entries:Z,theme:e,onOpenFile:e=>H(e.path),onOpenFolder:e=>H(e.path),onNewDocument:()=>q.newFile?.(`${R}/`),onNewFolder:()=>q.newFolder?.(`${R}/`)}):Q?(0,y.jsx)(h,{content:Q,path:R,fetchBlob:t.fetchBlob}):J?(0,y.jsx)(ee,{path:R},R):D?(0,y.jsx)(`p`,{className:`placeholder`,children:`Select a document or folder on the left to view it.`}):(0,y.jsx)(`p`,{className:`placeholder`,children:`Loading…`}):(0,y.jsx)(`p`,{className:`placeholder`,children:`Select a document or folder on the left to view it.`});let ne=n.hits?{entries:n.hits.map(e=>e.entry),emptyMessage:n.unavailable?`The library is still being indexed — search will work shortly.`:`Nothing in the library mentions “${n.query.trim()}”.`,detailForEntry:e=>{let t=n.hits?.find(t=>t.entry.path===e.path);return t?(0,y.jsxs)(`span`,{className:`documents-search-snippet`,children:[t.related&&(0,y.jsx)(`span`,{className:`documents-search-related`,children:`related`}),f(t.snippet,n.matchedQuery)]}):null}}:null;return(0,y.jsxs)(`div`,{className:`documents-listing`,"data-testid":`documents-view`,children:[(0,y.jsx)(_,{source:t,titleReplacement:(0,y.jsxs)(`div`,{className:`documents-search`,children:[(0,y.jsx)(`input`,{type:`search`,className:`documents-search-input`,placeholder:`${t.title} - search`,"aria-label":`Search document contents`,value:n.query,onChange:e=>n.setQuery(e.target.value),onKeyDown:e=>{e.key===`Escape`&&n.clear()}}),n.searching&&(0,y.jsx)(`span`,{className:`muted documents-search-status`,children:`searching…`})]}),customList:ne,layoutClassName:`project-files-layout-documents`,entries:K,truncated:w,viewMode:P,modes:c,onViewModeChange:U,showHidden:I,onShowHiddenChange:W,selectedPath:R??void 0,onSelect:e=>H(e.path),selectableFolders:!0,labelFor:e=>d(e.name),emptyMessage:`No documents yet. Create a mission statement, coding guidelines, or any shared reference.`,mutations:q,viewer:$}),N&&(0,y.jsx)(`p`,{className:`error`,children:N}),B?(0,y.jsx)(v,{projectId:B}):null]})}export{M as DocumentsView};
@@ -1 +0,0 @@
1
- import{a as e,i as t,n,o as r,r as i,t as a}from"./dist-Bvo52IGx.js";var o=t,s=r,c=i,l=a,u=n,d=e;export{d as a,o as i,u as n,s as o,c as r,l as t};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{n as t,t as n}from"./jsx-runtime-CEpd2cAX.js";import{mt as r,u as i}from"./dist-BPx-FyRH.js";import{t as a}from"./api-BX5xXiFs.js";import{t as o}from"./model-context-DBqdK0PS.js";import{n as s,r as c,t as l}from"./model-memory-copy-CeuXAj-T.js";import{t as u}from"./ConfirmDialog-BHFs6vmJ.js";import{Et as d,Tt as f,wt as p,xt as m}from"./index-DXWR4qW1.js";import{a as ee,i as te,n as h,o as ne,r as re,s as g,t as _}from"./UnrecognizedModels-Cw9Ku_bW.js";import{t as v}from"./useTotalRamBytes-WoN_mi-V.js";import{t as y}from"./ds4-availability-TaGRbP_O.js";import{t as b}from"./local-engine-label-BR-PGVFE.js";var x=e(t(),1),S=n();function C(e){return e.kind!==`chat-model`||!e.ds4?null:e}function w({onModelsChanged:e}){let[t,n]=(0,x.useState)(null),[v,y]=(0,x.useState)(new Set),[b,w]=(0,x.useState)(new Map),[T,E]=(0,x.useState)(new Set),[D,O]=(0,x.useState)(new Map),[k,A]=(0,x.useState)(null),[j,M]=(0,x.useState)(!1),[N,ie]=(0,x.useState)(null),[ae,P]=(0,x.useState)(!1),[F,I]=(0,x.useState)(new Map),[L,R]=(0,x.useState)(null),[z,B]=(0,x.useState)([]),[V,H]=(0,x.useState)([]),[U,W]=(0,x.useState)(null),[G,oe]=(0,x.useState)(new Map),[K,se]=(0,x.useState)([]),q=(0,x.useRef)([]),J=(0,x.useCallback)(async()=>{try{let e=await a.listModelFitness();oe(new Map(e.records.map(e=>[e.key,e]))),se(e.probing),q.current=e.probing}catch{}},[]),Y=(0,x.useCallback)(async()=>{try{let e=await a.listIncompleteDs4Models();B(e.incomplete??[])}catch{}},[]),X=(0,x.useCallback)(async()=>{try{let e=await a.listDs4Models();y(new Set(e.models.map(e=>e.id))),w(new Map(e.models.map(e=>[e.id,e]))),E(new Set(e.models.filter(e=>e.readOnly).map(e=>e.id))),H(e.unrecognized??[])}catch{}try{let e=await a.listDs4ContextPlans();O(new Map(Object.entries(e.plans??{})))}catch{}Y()},[Y]),Z=(0,x.useCallback)(async()=>{R(null);try{let[e,t]=await Promise.all([a.listCatalogItems(`chat-model`),a.getMemoryProfile()]);n(e.items),A({totalRamBytes:t.totalRamBytes,usableBytes:t.usableBytes})}catch(e){R(e instanceof Error?e.message:String(e))}},[]);(0,x.useEffect)(()=>{Z(),X(),a.getModelContextOverrides(`ds4`).then(()=>P(!0)).catch(()=>P(!1))},[Z,X]),(0,x.useEffect)(()=>{let e=e=>{d(e)===`ds4`&&X()};return window.addEventListener(p,e),()=>window.removeEventListener(p,e)},[X]),(0,x.useEffect)(()=>{let e=!1,t,n=async()=>{await J(),!e&&(t=setTimeout(()=>void n(),q.current.length>0?2e3:15e3))};return n(),()=>{e=!0,t&&clearTimeout(t)}},[J]),(0,x.useEffect)(()=>{let e=!1,t=async()=>{try{let t=await a.listDs4ActiveInstalls();if(e)return;I(e=>{let n=new Map(e),r=new Set;for(let e of t.installs){r.add(e.catalogId);let t=n.get(e.catalogId);t?.origin===`local`&&!t.error||n.set(e.catalogId,{bytesWritten:e.bytesWritten,totalBytes:e.totalBytes,phase:e.phase===`extracting-metadata`?`finalizing`:e.phase,origin:`remote`})}for(let[e,t]of n)t.origin===`remote`&&!r.has(e)&&n.delete(e);return n}),t.installs.length===0&&X()}catch{}};t();let n=setInterval(()=>void t(),2e3);return()=>{e=!0,clearInterval(n)}},[X]);let Q=(0,x.useCallback)(t=>{I(e=>new Map(e).set(t,{bytesWritten:0,totalBytes:0,phase:`downloading`,origin:`local`})),(async()=>{try{await a.installDs4Model(t,e=>{I(n=>{let r=new Map(n),i=r.get(t)??{bytesWritten:0,totalBytes:0,phase:`downloading`,origin:`local`};return e.type===`progress`?r.set(t,{...i,bytesWritten:e.bytesWritten,totalBytes:e.totalBytes,phase:`downloading`}):e.type===`verifying`?r.set(t,{...i,phase:`verifying`}):e.type===`extracting-metadata`?r.set(t,{...i,phase:`finalizing`}):e.type===`error`&&r.set(t,{...i,error:e.error}),r})}),f(`ds4`)}catch(e){I(n=>{let r=new Map(n),i=r.get(t);return i&&r.set(t,{...i,error:e instanceof Error?e.message:String(e)}),r});return}finally{I(e=>{let n=new Map(e);return n.get(t)?.error||n.delete(t),n}),await X(),e?.()}})()},[X,e]),ce=(0,x.useCallback)(async t=>{R(null),y(e=>{let n=new Set(e);return n.delete(t),n}),B(e=>e.filter(e=>e.id!==t)),H(e=>e.filter(e=>e.id!==t));try{await a.deleteDs4Model(t),f(`ds4`),await X(),e?.()}catch(e){R(`delete failed: ${e instanceof Error?e.message:String(e)}`),X()}},[X,e]),$=(0,x.useMemo)(()=>(t??[]).map(e=>({it:e,m:C(e.manifest)})).filter(e=>e.m!==null),[t]);if(L)return(0,S.jsxs)(`div`,{className:`new-row`,style:{alignItems:`center`,gap:`0.6rem`},children:[(0,S.jsxs)(`span`,{className:`gz-status-pill gz-status-pill--warn`,children:[`Couldn't load models: `,L]}),(0,S.jsx)(`button`,{type:`button`,onClick:()=>void Z(),children:`Retry`})]});if(t===null)return(0,S.jsx)(`p`,{className:`muted small`,children:`Loading models…`});if($.length===0)return(0,S.jsx)(`p`,{className:`muted small`,children:`No DwarfStar models in the catalog.`});let le=new Set(V.map(e=>e.id)),ue=$.filter(({m:e})=>!le.has(e.id)||F.has(e.id)).filter(({m:e})=>j||v.has(e.id)||!r(e)).map((e,t)=>({entry:e,index:t})).sort((e,t)=>{let n=Number(v.has(t.entry.m.id))-Number(v.has(e.entry.m.id));return n===0?e.index-t.index:n}).map(({entry:e})=>e),de=e=>D.get(e.id)?.projectedResidentBytes??e.ds4.residentBytes,fe=Math.min(...ue.map(({m:e})=>de(e)??1/0));return(0,S.jsxs)(`div`,{children:[(0,S.jsx)(h,{engine:`ds4`,onModelsChanged:e}),(0,S.jsx)(_,{items:V.filter(e=>!F.has(e.id)),onUpdate:Q,onRemove:W}),(0,S.jsx)(g,{items:z.filter(e=>!F.has(e.id)),onResume:e=>Q(e),onDelete:W}),(0,S.jsxs)(`div`,{className:`ollama-section`,children:[(0,S.jsxs)(`p`,{className:`muted small`,style:{marginTop:0},children:[`Retired models are hidden by default.`,` `,(0,S.jsx)(`button`,{type:`button`,className:`gz-link-button`,onClick:()=>M(e=>!e),children:j?`Hide retired models`:`Show all models`})]}),(0,S.jsx)(`div`,{className:`ollama-model-table-wrap`,children:(0,S.jsxs)(`table`,{className:`ollama-model-table ds4-model-table`,children:[(0,S.jsxs)(`colgroup`,{children:[(0,S.jsx)(`col`,{className:`model-name-column`}),(0,S.jsx)(`col`,{}),(0,S.jsx)(`col`,{}),(0,S.jsx)(`col`,{}),(0,S.jsx)(`col`,{})]}),(0,S.jsx)(`thead`,{children:(0,S.jsxs)(`tr`,{children:[(0,S.jsx)(`th`,{children:`Name`}),(0,S.jsx)(`th`,{title:`Download size, and the memory working set this device would run the model at. A streaming engine keeps far less resident than it downloads.`,children:`Size`}),(0,S.jsx)(`th`,{title:`Effective per-turn context size after Gezel's settings and memory limits`,children:`Context size`}),(0,S.jsx)(`th`,{title:`Reading and writing speed, measured against an approximately 20K-token prompt`,children:`Fitness`}),(0,S.jsx)(`th`,{})]})}),(0,S.jsx)(`tbody`,{children:ue.map(({m:e})=>{let t=D.get(e.id),n=de(e),u=e.ds4.cacheExpertsBytes??0,d=k?Math.max(0,k.totalRamBytes-i):0,f=k&&n?n<=d:!0,p=n?Math.max(0,n-u):0,m=!k||p+1024**3<=d,h=n===fe,g=v.has(e.id),_=r(e),y=F.get(e.id),C=y&&y.totalBytes>0?Math.floor(y.bytesWritten/y.totalBytes*100):0,w=t?.fullyResident===!0,E=w?(0,S.jsx)(`span`,{className:`gz-status-pill gz-status-pill--ok ds4-model-fit`,title:`This device holds the whole model in memory — no expert streaming from SSD. That is roughly ten times faster to generate than the streaming fallback${n?`, and costs about ${c(e.ds4.approxSizeBytes)} of memory while loaded`:``}.`,children:`runs fully in memory · fastest`}):n?f?(0,S.jsx)(`span`,{className:`gz-status-pill gz-status-pill--info ds4-model-fit`,title:`Too large to hold in memory on this device, so DwarfStar keeps about ${c(n)} resident and reads the remaining experts from SSD as it goes. That works, but generates roughly ten times slower than a model that fits in memory. A smaller quant that fits will be much faster.`,children:h?`streams from SSD · lightest option`:`streams from SSD · slower`}):m?(0,S.jsx)(`span`,{className:`gz-status-pill gz-status-pill--warn ds4-model-fit`,title:`Gezel will reduce this model's expert cache below its ${c(n)} target to preserve ${c(i)} for the system and other apps. It should run, but will read from SSD even more often than a normal streaming launch.`,children:`reduced cache · much slower`}):(0,S.jsx)(`span`,{className:`gz-status-pill gz-status-pill--warn ds4-model-fit`,title:`The model's fixed memory requirement leaves too little room for the system, even with the expert cache reduced.`,children:`needs more memory`}):null,O=e.name,A=b.get(e.id),j=A?{...A,...t?.effectiveContextWindow!==void 0&&!A.effectiveContextWindow?{effectiveContextWindow:t.effectiveContextWindow}:{},...t?.contextCeilingTokens!==void 0&&A.contextCeilingTokens===void 0?{contextCeilingTokens:t.contextCeilingTokens}:{},...t?.kvBytesPerToken!==void 0&&A.kvBytesPerTokenPerSlot===void 0?{kvBytesPerTokenPerSlot:t.kvBytesPerToken,kvFixedBytesPerSlot:0}:{},...t?.contextFreeResidentBytes!==void 0&&A.weightsResidentBytes===void 0?{weightsResidentBytes:t.contextFreeResidentBytes}:{}}:void 0,M=j?.effectiveContextWindow??t?.effectiveContextWindow,P=j?.overrideContextTokens??t?.overrideContextTokens,I=j?.contextSizingStatus===`restart-required`,L={approxSizeBytes:e.ds4.approxSizeBytes,residentBytes:n,...t?.kvBytesPerToken!==void 0&&t.contextFreeResidentBytes!==void 0&&M!==void 0?{contextFreeBytes:t.contextFreeResidentBytes}:{},...M===void 0?{}:{effectiveContextWindow:M},...w?{fullyResident:!0}:{}},R=l(L),z=j?.updateAvailable===!0,B=`ds4:${e.id}`;return(0,S.jsxs)(x.Fragment,{children:[(0,S.jsxs)(`tr`,{children:[(0,S.jsx)(`td`,{className:`model-name-table-cell`,children:(0,S.jsxs)(`div`,{className:`model-name-cell`,children:[(0,S.jsx)(`strong`,{className:`ds4-model-name`,children:O}),(0,S.jsxs)(`div`,{className:`model-name-meta`,children:[(0,S.jsx)(`span`,{className:`muted small`,children:e.parameterSize}),g&&(0,S.jsx)(`span`,{className:`gz-status-pill gz-status-pill--ok`,children:`on device`}),_&&(0,S.jsx)(`span`,{className:`catalog-item-tag catalog-item-tag--retired`,title:`This model is kept for compatibility but is no longer recommended for new downloads.`,children:`retired`}),z&&(0,S.jsx)(`span`,{className:`gz-status-pill gz-status-pill--warn`,title:j?.updateReason??(j?.availableVersion?`A newer build is available in the catalog (→ v${j.availableVersion}). Updating downloads only the files that differ.`:`A newer build is available in the catalog. Updating downloads only the files that differ.`),children:`update available`})]}),E]})}),(0,S.jsx)(`td`,{children:(0,S.jsxs)(`span`,{className:`model-size-cell`,title:s(L),children:[c(e.ds4.approxSizeBytes),R?(0,S.jsx)(`span`,{className:`muted small model-memory-headline`,children:R}):null]})}),(0,S.jsx)(`td`,{title:I?`This model is running with a different context window than the current sizing settings resolve to. Restart the local engine (or let it go idle) so Gezel can re-admit it — no memory change needed.`:M===void 0?void 0:P===void 0?`Gezel will grant up to ${M.toLocaleString()} tokens per turn.`:`You've set this model to ${P.toLocaleString()} tokens per turn.`,children:I?`Restart needed`:M===void 0?(0,S.jsx)(`span`,{className:`muted`,children:`—`}):(0,S.jsxs)(S.Fragment,{children:[o(M),P!==void 0&&(0,S.jsx)(`span`,{className:`gz-budget-tag gz-budget-tag-custom model-context-custom-tag`,children:`custom`})]})}),g?(0,S.jsx)(re,{entry:G.get(B),probing:K.includes(B)}):(0,S.jsx)(`td`,{className:`model-fitness-table-cell`,children:(0,S.jsx)(`span`,{className:`muted small`,title:`The fitness check measures this model on THIS machine, so it runs once the download lands.`,children:`after download`})}),(0,S.jsx)(`td`,{className:`model-actions-table-cell`,children:y?y.error?(0,S.jsxs)(`div`,{className:`ds4-model-progress`,children:[(0,S.jsx)(`span`,{className:`gz-status-pill gz-status-pill--warn`,children:y.error}),(0,S.jsx)(`button`,{type:`button`,onClick:()=>Q(e.id),children:`Retry`})]}):(0,S.jsx)(`span`,{className:`muted small ds4-model-progress-label`,children:y.phase===`downloading`?`downloading… ${C}%`:y.phase===`verifying`?`verifying sha256…`:`finalizing…`}):g?(0,S.jsxs)(`div`,{className:`model-actions-cell`,children:[(0,S.jsx)(`div`,{className:`model-action-status`,children:T.has(e.id)&&(0,S.jsx)(`span`,{className:`muted small`,title:`Provided by the machine-wide install (shared asset store). It can't be removed from here — manage it with the machine installer, or install a user-owned copy to shadow it.`,children:`Machine model`})}),(0,S.jsx)(`div`,{className:`model-action-links`,children:(0,S.jsx)(ee,{engine:`ds4`,model:j??{id:e.id,approxSizeBytes:e.ds4.approxSizeBytes,readOnly:T.has(e.id)},contextSupported:ae,contextEditorOpen:N===e.id,onToggleContextEditor:()=>ie(t=>t===e.id?null:e.id),fitnessAction:te(G.get(B),K.includes(B),()=>{a.runModelFitnessProbe(`ds4`,e.id).then(()=>J()).catch(()=>{})}),onUpdate:()=>Q(e.id),onDelete:T.has(e.id)?void 0:()=>W(e.id)})})]}):m?(0,S.jsx)(`button`,{type:`button`,onClick:()=>Q(e.id),children:`Download`}):null})]}),N===e.id&&j&&(0,S.jsx)(`tr`,{className:`model-context-editor-row`,children:(0,S.jsx)(`td`,{colSpan:5,children:(0,S.jsx)(ne,{engine:`ds4`,model:j,onSaved:X})})})]},e.id)})})]})})]}),(0,S.jsxs)(`div`,{style:{marginTop:`1.25rem`},children:[(0,S.jsx)(m,{}),(0,S.jsx)(`span`,{className:`muted small`,style:{marginLeft:`0.75rem`},children:`Import from a gezel local model package`})]}),(0,S.jsx)(u,{open:U!==null,title:`Remove ${U??`model`}?`,message:`This permanently removes the model files from this device. The model stays available in the catalog, so you can download a current build later.`,confirmLabel:`Remove`,danger:!0,onConfirm:()=>{let e=U;W(null),e&&ce(e)},onCancel:()=>W(null)})]})}function T({config:e,onConfigChanged:t,health:n,title:r}){let i=v(),[o,s]=(0,x.useState)([]),[c,l]=(0,x.useState)(`idle`),u=(0,x.useCallback)(async()=>{try{let e=await a.listDs4Models();s(e.models)}catch{}},[]);(0,x.useEffect)(()=>{u()},[u]);let d=(0,x.useCallback)(async n=>{l(`saving`);try{t(await a.updateConfig({defaultModel:{...e?.defaultModel,ds4:n??void 0}})),l(`saved`),setTimeout(()=>l(`idle`),1200)}catch{l(`idle`)}},[e?.defaultModel,t]),f=(0,x.useCallback)(async e=>{l(`saving`);try{t(await a.updateConfig({ds4SsdStreaming:e?!0:void 0})),l(`saved`),setTimeout(()=>l(`idle`),1200)}catch{l(`idle`)}},[t]),p=e?.ds4SsdStreaming===!0,m=y({externalBaseUrl:e?.ds4BaseUrl,totalRamBytes:i??void 0,ds4ServerBundled:n?.ds4ServerBundled,serverPlatform:n?.platform,detectedBackend:n?.llamaCppDetectedBackend,gpuVendor:n?.llamaCppDetectedVendor});return(0,S.jsxs)(`div`,{children:[(0,S.jsxs)(`section`,{style:{marginBottom:`2rem`},children:[(0,S.jsx)(`h3`,{children:r??b(`ds4`,n?.platform)}),(0,S.jsx)(`p`,{className:`muted`,style:{marginTop:0},children:`DwarfStar (ds4) is an inference engine built for a handful of very large mixture-of-experts models — DeepSeek V4 and GLM 5.2. They may not fit in memory; DwarfStar keeps a bounded expert cache in RAM and reads the other experts from SSD as they are needed.`}),(0,S.jsxs)(`div`,{className:`new-row`,style:{marginTop:`0.75rem`,alignItems:`center`},children:[(0,S.jsx)(`span`,{className:`muted small`,children:`Status:`}),m.status===`available`&&(0,S.jsxs)(`span`,{className:`gz-status-pill gz-status-pill--ok`,children:[`engine available · `,m.backend]}),m.status===`external`&&(0,S.jsx)(`span`,{className:`gz-status-pill gz-status-pill--warn`,title:`Using an external ds4-server at: ${e?.ds4BaseUrl}`,children:`using external DwarfStar server`}),m.status===`requires-cuda`&&(0,S.jsx)(`span`,{className:`gz-status-pill gz-status-pill--warn`,children:`requires NVIDIA / CUDA`}),m.status===`unavailable`&&(0,S.jsx)(`span`,{className:`gz-status-pill gz-status-pill--warn`,children:`unavailable on this device`}),c===`saved`&&(0,S.jsx)(`span`,{className:`muted small`,children:`saved ✓`})]}),m.status===`available`&&(0,S.jsxs)(`p`,{className:`muted small`,style:{marginTop:`0.4rem`},children:[`This means the engine can launch on this`,` `,m.backend===`metal`?`Mac`:`machine`,`. Each model below still has its own disk and memory requirements.`]}),(m.status===`unavailable`||m.status===`requires-cuda`)&&(0,S.jsx)(`p`,{className:`muted small`,style:{marginTop:`0.4rem`},children:m.reason})]}),m.status!==`unavailable`&&m.status!==`external`&&o.length>1&&(0,S.jsxs)(`section`,{style:{marginBottom:`2rem`},children:[(0,S.jsx)(`h4`,{children:`Default model`}),(0,S.jsx)(`p`,{className:`muted small`,style:{marginTop:0},children:`Which DwarfStar model new chat sessions use when a gezel doesn't pin one.`}),(0,S.jsx)(`div`,{className:`new-row`,style:{marginTop:`0.5rem`},children:(0,S.jsxs)(`select`,{"aria-label":`Default model`,value:e?.defaultModel?.ds4??``,onChange:e=>void d(e.target.value||void 0),children:[(0,S.jsx)(`option`,{value:``,children:`First local model`}),o.map(e=>(0,S.jsxs)(`option`,{value:e.id,children:[e.name,` (`,e.id,`)`]},e.id))]})})]}),m.status!==`unavailable`&&m.status!==`external`&&(0,S.jsxs)(`section`,{style:{marginBottom:`2rem`},children:[(0,S.jsx)(`h4`,{children:`DwarfStar models`}),(0,S.jsx)(`p`,{className:`muted small`,style:{marginTop:0},children:`Lower quantizations (Q2) start faster and need less disk and memory; higher ones (Q4) keep more model detail but can need several times the disk space and a larger memory working set. Check the size on each row before starting — these downloads run to hundreds of gigabytes.`}),(0,S.jsx)(w,{onModelsChanged:u}),(0,S.jsx)(E,{})]}),m.status!==`unavailable`&&m.status!==`external`&&(0,S.jsxs)(`section`,{style:{marginBottom:`2rem`},children:[(0,S.jsx)(`h4`,{children:`Memory use`}),(0,S.jsx)(`p`,{className:`muted small`,style:{marginTop:0},children:`A model held entirely in memory generates roughly ten times faster than one whose experts are read from SSD as they're needed. Gezel keeps a model in memory whenever this machine has room for it, and falls back to streaming when it doesn't — the model list shows which each one will do.`}),(0,S.jsxs)(`div`,{className:`gz-tray`,role:`radiogroup`,"aria-label":`Memory use`,style:{marginTop:`0.6rem`},children:[(0,S.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":!p,className:`gz-key gz-key--stacked${p?``:` gz-key-active`}`,onClick:()=>void f(!1),children:[(0,S.jsx)(`span`,{className:`gz-key-label`,children:`Keep in memory when it fits`}),(0,S.jsx)(`span`,{className:`gz-key-hint`,children:`Fastest. Falls back to streaming automatically.`})]}),(0,S.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":p,className:`gz-key gz-key--stacked${p?` gz-key-active`:``}`,onClick:()=>void f(!0),children:[(0,S.jsx)(`span`,{className:`gz-key-label`,children:`Always stream from SSD`}),(0,S.jsx)(`span`,{className:`gz-key-hint`,children:`Much slower, but leaves memory free for other apps.`})]})]}),(0,S.jsx)(`p`,{className:`muted small`,style:{marginTop:`0.6rem`},children:`Gezel never holds a model in memory that wouldn't leave enough for the system and your other apps — a model too large for this machine streams regardless of this setting.`})]}),m.status===`external`&&(0,S.jsx)(`p`,{className:`muted small`,children:`This external DwarfStar server manages its own model files and memory settings. Local downloads are not used while the external server is configured.`})]})}function E(){let[e,t]=(0,x.useState)({kind:`idle`}),n=(0,x.useCallback)(async()=>{t({kind:`loading`});try{t({kind:`loaded`,...await a.getDs4Log(4096)})}catch(e){t({kind:`error`,message:e instanceof Error?e.message:String(e)})}},[]);return(0,S.jsxs)(`details`,{style:{marginTop:`1rem`},children:[(0,S.jsxs)(`summary`,{style:{cursor:`pointer`,userSelect:`none`},children:[`Diagnostics`,` `,(0,S.jsx)(`span`,{className:`muted small`,children:`— DwarfStar engine output retained for troubleshooting.`})]}),(0,S.jsxs)(`div`,{style:{marginTop:`0.5rem`},children:[(0,S.jsxs)(`div`,{className:`new-row`,style:{alignItems:`center`,gap:`0.5rem`},children:[(0,S.jsx)(`button`,{type:`button`,onClick:()=>void n(),disabled:e.kind===`loading`,children:e.kind===`loading`?`Loading…`:`Refresh engine log`}),e.kind===`loaded`&&e.path&&(0,S.jsx)(`span`,{className:`muted small`,title:e.path,children:e.path}),e.kind===`loaded`&&!e.path&&(0,S.jsx)(`span`,{className:`muted small`,children:`No DwarfStar engine log yet.`})]}),e.kind===`error`&&(0,S.jsxs)(`div`,{className:`muted small`,style:{marginTop:`0.5rem`,color:`#ff9b9b`},children:[`Couldn't load log: `,e.message]}),e.kind===`loaded`&&e.tail&&(0,S.jsx)(`pre`,{style:{marginTop:`0.5rem`,padding:`0.5rem`,background:`rgba(255,255,255,0.04)`,border:`1px solid rgba(255,255,255,0.1)`,borderRadius:4,maxHeight:`18rem`,overflow:`auto`,fontSize:`0.75rem`,fontFamily:`ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace`,whiteSpace:`pre-wrap`,wordBreak:`break-all`},children:e.tail}),e.kind===`loaded`&&e.path&&!e.tail&&(0,S.jsx)(`div`,{className:`muted small`,style:{marginTop:`0.5rem`},children:`The log exists but is empty. Start a DwarfStar chat, then refresh.`})]})]})}export{T as Ds4Settings};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{n as t,t as n}from"./jsx-runtime-CEpd2cAX.js";import{t as r}from"./ProjectsView-SBPgYOq8.js";var i=e(t(),1),a=n();function o({projectId:e,theme:t,accent:n,bg:o,fg:s,fontFamily:c,compact:l=!1}){return(0,i.useEffect)(()=>{let e=document.documentElement;return n&&e.style.setProperty(`--accent`,n),o&&e.style.setProperty(`--bg`,o),s&&e.style.setProperty(`--fg`,s),c&&e.style.setProperty(`--font-ui`,c),t&&e.setAttribute(`data-host-theme`,t),e.classList.add(`embedded-chat`),()=>{e.classList.remove(`embedded-chat`),e.removeAttribute(`data-host-theme`)}},[t,n,o,s,c]),(0,a.jsx)(`div`,{className:`embedded-chat-root`,children:(0,a.jsx)(r,{projectId:e,compact:l})})}export{o as EmbeddedChat};