@harperfast/harper 5.3.0-alpha.1 → 5.3.0-beta.2

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 (347) hide show
  1. package/bin/cliOperations.ts +12 -0
  2. package/bin/restart.ts +66 -6
  3. package/components/Application.ts +1134 -112
  4. package/components/DESIGN.md +421 -0
  5. package/components/OptionsWatcher.ts +368 -102
  6. package/components/Scope.ts +20 -1
  7. package/components/componentLoader.ts +43 -4
  8. package/components/deploymentOperations.ts +4 -1
  9. package/components/deploymentRecorder.ts +9 -2
  10. package/components/mcp/DESIGN.md +109 -0
  11. package/components/mcp/audit.ts +21 -17
  12. package/components/operations.js +284 -52
  13. package/components/operationsValidation.js +49 -2
  14. package/components/packageComponent.ts +25 -1
  15. package/components/requestRestart.ts +11 -0
  16. package/config/DESIGN.md +306 -0
  17. package/config/RootConfigWatcher.ts +191 -37
  18. package/config/configReadRetry.ts +62 -0
  19. package/config/configUtils.ts +78 -26
  20. package/config/parseConfigFile.ts +34 -0
  21. package/config/readConfigFileSync.ts +44 -0
  22. package/config/watcherArming.ts +59 -0
  23. package/config-root.schema.json +4 -0
  24. package/dataLayer/DESIGN.md +179 -0
  25. package/dataLayer/harperBridge/ResourceBridge.ts +28 -2
  26. package/dataLayer/restoreMarker.ts +92 -25
  27. package/dist/bin/cliOperations.js +13 -0
  28. package/dist/bin/cliOperations.js.map +1 -1
  29. package/dist/bin/restart.js +42 -6
  30. package/dist/bin/restart.js.map +1 -1
  31. package/dist/components/Application.d.ts +104 -9
  32. package/dist/components/Application.js +954 -102
  33. package/dist/components/Application.js.map +1 -1
  34. package/dist/components/OptionsWatcher.d.ts +4 -1
  35. package/dist/components/OptionsWatcher.js +378 -104
  36. package/dist/components/OptionsWatcher.js.map +1 -1
  37. package/dist/components/Scope.js +15 -1
  38. package/dist/components/Scope.js.map +1 -1
  39. package/dist/components/componentLoader.js +35 -3
  40. package/dist/components/componentLoader.js.map +1 -1
  41. package/dist/components/deploymentOperations.js +4 -1
  42. package/dist/components/deploymentOperations.js.map +1 -1
  43. package/dist/components/deploymentRecorder.d.ts +4 -2
  44. package/dist/components/deploymentRecorder.js +1 -0
  45. package/dist/components/deploymentRecorder.js.map +1 -1
  46. package/dist/components/mcp/audit.d.ts +2 -1
  47. package/dist/components/mcp/audit.js +21 -17
  48. package/dist/components/mcp/audit.js.map +1 -1
  49. package/dist/components/operations.d.ts +28 -0
  50. package/dist/components/operations.js +263 -54
  51. package/dist/components/operations.js.map +1 -1
  52. package/dist/components/operationsValidation.js +48 -2
  53. package/dist/components/operationsValidation.js.map +1 -1
  54. package/dist/components/packageComponent.js +24 -0
  55. package/dist/components/packageComponent.js.map +1 -1
  56. package/dist/components/requestRestart.d.ts +1 -0
  57. package/dist/components/requestRestart.js +7 -0
  58. package/dist/components/requestRestart.js.map +1 -1
  59. package/dist/config/RootConfigWatcher.d.ts +2 -0
  60. package/dist/config/RootConfigWatcher.js +189 -35
  61. package/dist/config/RootConfigWatcher.js.map +1 -1
  62. package/dist/config/configReadRetry.d.ts +8 -0
  63. package/dist/config/configReadRetry.js +62 -0
  64. package/dist/config/configReadRetry.js.map +1 -0
  65. package/dist/config/configUtils.d.ts +10 -9
  66. package/dist/config/configUtils.js +63 -27
  67. package/dist/config/configUtils.js.map +1 -1
  68. package/dist/config/parseConfigFile.d.ts +4 -0
  69. package/dist/config/parseConfigFile.js +35 -0
  70. package/dist/config/parseConfigFile.js.map +1 -0
  71. package/dist/config/readConfigFileSync.d.ts +1 -0
  72. package/dist/config/readConfigFileSync.js +47 -0
  73. package/dist/config/readConfigFileSync.js.map +1 -0
  74. package/dist/config/watcherArming.d.ts +15 -0
  75. package/dist/config/watcherArming.js +59 -0
  76. package/dist/config/watcherArming.js.map +1 -0
  77. package/dist/dataLayer/harperBridge/ResourceBridge.js +21 -2
  78. package/dist/dataLayer/harperBridge/ResourceBridge.js.map +1 -1
  79. package/dist/dataLayer/restoreMarker.d.ts +21 -8
  80. package/dist/dataLayer/restoreMarker.js +94 -27
  81. package/dist/dataLayer/restoreMarker.js.map +1 -1
  82. package/dist/index.d.ts +2 -0
  83. package/dist/index.js +9 -1
  84. package/dist/index.js.map +1 -1
  85. package/dist/json/systemSchema.json +3 -0
  86. package/dist/resources/DatabaseTransaction.d.ts +25 -0
  87. package/dist/resources/DatabaseTransaction.js +224 -18
  88. package/dist/resources/DatabaseTransaction.js.map +1 -1
  89. package/dist/resources/LMDBTransaction.d.ts +2 -1
  90. package/dist/resources/LMDBTransaction.js +22 -3
  91. package/dist/resources/LMDBTransaction.js.map +1 -1
  92. package/dist/resources/PrimaryRocksDatabase.js +22 -6
  93. package/dist/resources/PrimaryRocksDatabase.js.map +1 -1
  94. package/dist/resources/RecordEncoder.d.ts +1 -1
  95. package/dist/resources/RecordEncoder.js +46 -10
  96. package/dist/resources/RecordEncoder.js.map +1 -1
  97. package/dist/resources/Resource.js +97 -13
  98. package/dist/resources/Resource.js.map +1 -1
  99. package/dist/resources/ResourceInterface.d.ts +8 -0
  100. package/dist/resources/RocksIndexStore.js +2 -1
  101. package/dist/resources/RocksIndexStore.js.map +1 -1
  102. package/dist/resources/RocksTransactionLogStore.d.ts +10 -0
  103. package/dist/resources/RocksTransactionLogStore.js +104 -33
  104. package/dist/resources/RocksTransactionLogStore.js.map +1 -1
  105. package/dist/resources/Table.d.ts +58 -7
  106. package/dist/resources/Table.js +1143 -348
  107. package/dist/resources/Table.js.map +1 -1
  108. package/dist/resources/analytics/write.d.ts +3 -0
  109. package/dist/resources/analytics/write.js +49 -16
  110. package/dist/resources/analytics/write.js.map +1 -1
  111. package/dist/resources/auditStore.d.ts +170 -0
  112. package/dist/resources/auditStore.js +457 -11
  113. package/dist/resources/auditStore.js.map +1 -1
  114. package/dist/resources/crdt.d.ts +10 -0
  115. package/dist/resources/crdt.js +22 -0
  116. package/dist/resources/crdt.js.map +1 -1
  117. package/dist/resources/dataLoader.js +3 -4
  118. package/dist/resources/dataLoader.js.map +1 -1
  119. package/dist/resources/databases.d.ts +16 -13
  120. package/dist/resources/databases.js +625 -177
  121. package/dist/resources/databases.js.map +1 -1
  122. package/dist/resources/derivedIndexRegistry.d.ts +5 -0
  123. package/dist/resources/derivedIndexRegistry.js +68 -0
  124. package/dist/resources/derivedIndexRegistry.js.map +1 -0
  125. package/dist/resources/derivedIndexRuntime.d.ts +215 -0
  126. package/dist/resources/derivedIndexRuntime.js +2027 -0
  127. package/dist/resources/derivedIndexRuntime.js.map +1 -0
  128. package/dist/resources/graphql.js +3 -2
  129. package/dist/resources/graphql.js.map +1 -1
  130. package/dist/resources/indexes/HierarchicalNavigableSmallWorld.d.ts +102 -9
  131. package/dist/resources/indexes/HierarchicalNavigableSmallWorld.js +867 -39
  132. package/dist/resources/indexes/HierarchicalNavigableSmallWorld.js.map +1 -1
  133. package/dist/resources/indexes/fullTextDerivedIndex.d.ts +81 -0
  134. package/dist/resources/indexes/fullTextDerivedIndex.js +1004 -0
  135. package/dist/resources/indexes/fullTextDerivedIndex.js.map +1 -0
  136. package/dist/resources/indexes/fullTextNativeBinding.d.ts +78 -0
  137. package/dist/resources/indexes/fullTextNativeBinding.js +85 -0
  138. package/dist/resources/indexes/fullTextNativeBinding.js.map +1 -0
  139. package/dist/resources/indexes/hnswDerivedIndex.d.ts +67 -0
  140. package/dist/resources/indexes/hnswDerivedIndex.js +464 -0
  141. package/dist/resources/indexes/hnswDerivedIndex.js.map +1 -0
  142. package/dist/resources/indexes/hnswPlaneBinding.d.ts +65 -0
  143. package/dist/resources/indexes/hnswPlaneBinding.js +91 -0
  144. package/dist/resources/indexes/hnswPlaneBinding.js.map +1 -0
  145. package/dist/resources/indexes/nativeFullTextDerivedIndexLifecycle.d.ts +24 -0
  146. package/dist/resources/indexes/nativeFullTextDerivedIndexLifecycle.js +149 -0
  147. package/dist/resources/indexes/nativeFullTextDerivedIndexLifecycle.js.map +1 -0
  148. package/dist/resources/nodeIdMapping.d.ts +5 -0
  149. package/dist/resources/nodeIdMapping.js +49 -0
  150. package/dist/resources/nodeIdMapping.js.map +1 -1
  151. package/dist/resources/recordLock.d.ts +47 -4
  152. package/dist/resources/recordLock.js +138 -7
  153. package/dist/resources/recordLock.js.map +1 -1
  154. package/dist/resources/recordLockCoordinator.d.ts +557 -0
  155. package/dist/resources/recordLockCoordinator.js +2597 -0
  156. package/dist/resources/recordLockCoordinator.js.map +1 -0
  157. package/dist/resources/replayLogs.js +5 -0
  158. package/dist/resources/replayLogs.js.map +1 -1
  159. package/dist/resources/replicatedApplyFailure.d.ts +16 -0
  160. package/dist/resources/replicatedApplyFailure.js +63 -0
  161. package/dist/resources/replicatedApplyFailure.js.map +1 -0
  162. package/dist/resources/scheduler/scheduler.js +3 -3
  163. package/dist/resources/scheduler/scheduler.js.map +1 -1
  164. package/dist/resources/search.d.ts +10 -4
  165. package/dist/resources/search.js +160 -40
  166. package/dist/resources/search.js.map +1 -1
  167. package/dist/resources/tracked.d.ts +5 -1
  168. package/dist/resources/tracked.js +74 -23
  169. package/dist/resources/tracked.js.map +1 -1
  170. package/dist/resources/transactionBroadcast.js +4 -6
  171. package/dist/resources/transactionBroadcast.js.map +1 -1
  172. package/dist/security/auth.js +59 -23
  173. package/dist/security/auth.js.map +1 -1
  174. package/dist/security/deferredAuthentication.d.ts +11 -0
  175. package/dist/security/deferredAuthentication.js +25 -3
  176. package/dist/security/deferredAuthentication.js.map +1 -1
  177. package/dist/security/jsLoader.js +9 -4
  178. package/dist/security/jsLoader.js.map +1 -1
  179. package/dist/server/REST.js +39 -5
  180. package/dist/server/REST.js.map +1 -1
  181. package/dist/server/http.d.ts +5 -1
  182. package/dist/server/http.js +34 -2
  183. package/dist/server/http.js.map +1 -1
  184. package/dist/server/mqtt.js +5 -1
  185. package/dist/server/mqtt.js.map +1 -1
  186. package/dist/server/serverHelpers/Headers.d.ts +2 -0
  187. package/dist/server/serverHelpers/Headers.js +6 -0
  188. package/dist/server/serverHelpers/Headers.js.map +1 -1
  189. package/dist/server/serverHelpers/NodeAdapterResponse.d.ts +48 -0
  190. package/dist/server/serverHelpers/NodeAdapterResponse.js +220 -0
  191. package/dist/server/serverHelpers/NodeAdapterResponse.js.map +1 -0
  192. package/dist/server/serverHelpers/Request.d.ts +5 -10
  193. package/dist/server/serverHelpers/Request.js +38 -136
  194. package/dist/server/serverHelpers/Request.js.map +1 -1
  195. package/dist/server/serverHelpers/contentTypes.d.ts +2 -0
  196. package/dist/server/serverHelpers/contentTypes.js +189 -15
  197. package/dist/server/serverHelpers/contentTypes.js.map +1 -1
  198. package/dist/server/serverHelpers/serverUtilities.d.ts +3 -3
  199. package/dist/server/serverHelpers/serverUtilities.js +110 -20
  200. package/dist/server/serverHelpers/serverUtilities.js.map +1 -1
  201. package/dist/server/serverHelpers/uwsServer.js +4 -1
  202. package/dist/server/serverHelpers/uwsServer.js.map +1 -1
  203. package/dist/server/serverHelpers/webSocketCloseReason.d.ts +2 -0
  204. package/dist/server/serverHelpers/webSocketCloseReason.js +29 -0
  205. package/dist/server/serverHelpers/webSocketCloseReason.js.map +1 -0
  206. package/dist/server/storageReclamation.js +1 -1
  207. package/dist/server/storageReclamation.js.map +1 -1
  208. package/dist/server/threads/isolatedApplications.d.ts +47 -0
  209. package/dist/server/threads/isolatedApplications.js +171 -0
  210. package/dist/server/threads/isolatedApplications.js.map +1 -0
  211. package/dist/server/threads/logRotationTransport.d.ts +1 -0
  212. package/dist/server/threads/logRotationTransport.js +33 -0
  213. package/dist/server/threads/logRotationTransport.js.map +1 -0
  214. package/dist/server/threads/manageThreads.d.ts +64 -6
  215. package/dist/server/threads/manageThreads.js +261 -12
  216. package/dist/server/threads/manageThreads.js.map +1 -1
  217. package/dist/server/threads/socketRouter.d.ts +1 -0
  218. package/dist/server/threads/socketRouter.js +196 -13
  219. package/dist/server/threads/socketRouter.js.map +1 -1
  220. package/dist/server/threads/threadServer.js +30 -7
  221. package/dist/server/threads/threadServer.js.map +1 -1
  222. package/dist/utility/errors/hdbError.d.ts +24 -0
  223. package/dist/utility/errors/hdbError.js +58 -1
  224. package/dist/utility/errors/hdbError.js.map +1 -1
  225. package/dist/utility/hdbTerms.d.ts +2 -0
  226. package/dist/utility/hdbTerms.js +2 -0
  227. package/dist/utility/hdbTerms.js.map +1 -1
  228. package/dist/utility/logging/harper_logger.js +218 -38
  229. package/dist/utility/logging/harper_logger.js.map +1 -1
  230. package/dist/utility/logging/logGenerationCoordinator.d.ts +35 -0
  231. package/dist/utility/logging/logGenerationCoordinator.js +184 -0
  232. package/dist/utility/logging/logGenerationCoordinator.js.map +1 -0
  233. package/dist/utility/logging/logRotation.d.ts +46 -0
  234. package/dist/utility/logging/logRotation.js +365 -0
  235. package/dist/utility/logging/logRotation.js.map +1 -0
  236. package/dist/utility/logging/logRotator.d.ts +1 -1
  237. package/dist/utility/logging/logRotator.js +172 -92
  238. package/dist/utility/logging/logRotator.js.map +1 -1
  239. package/dist/utility/npmUtilities.js +6 -4
  240. package/dist/utility/npmUtilities.js.map +1 -1
  241. package/dist/utility/watcherFallback.d.ts +0 -45
  242. package/dist/utility/watcherFallback.js +1 -125
  243. package/dist/utility/watcherFallback.js.map +1 -1
  244. package/dist/validation/configValidator.js +6 -3
  245. package/dist/validation/configValidator.js.map +1 -1
  246. package/index.ts +9 -0
  247. package/json/systemSchema.json +3 -0
  248. package/npm-shrinkwrap.json +177 -87
  249. package/package.json +13 -5
  250. package/resources/DESIGN.md +689 -19
  251. package/resources/DatabaseTransaction.ts +230 -17
  252. package/resources/LMDBTransaction.ts +21 -3
  253. package/resources/PrimaryRocksDatabase.ts +20 -7
  254. package/resources/RecordEncoder.ts +52 -10
  255. package/resources/Resource.ts +97 -13
  256. package/resources/ResourceInterface.ts +8 -0
  257. package/resources/RocksIndexStore.ts +2 -1
  258. package/resources/RocksTransactionLogStore.ts +111 -31
  259. package/resources/Table.ts +1273 -396
  260. package/resources/analytics/DESIGN.md +38 -0
  261. package/resources/analytics/write.ts +50 -17
  262. package/resources/auditStore.ts +460 -11
  263. package/resources/crdt.ts +22 -0
  264. package/resources/dataLoader.ts +3 -4
  265. package/resources/databases.ts +611 -147
  266. package/resources/derivedIndexRegistry.ts +56 -0
  267. package/resources/derivedIndexRuntime.ts +2292 -0
  268. package/resources/graphql.ts +3 -2
  269. package/resources/indexes/DESIGN.md +833 -0
  270. package/resources/indexes/HierarchicalNavigableSmallWorld.ts +924 -46
  271. package/resources/indexes/fullTextDerivedIndex.ts +1165 -0
  272. package/resources/indexes/fullTextNativeBinding.ts +146 -0
  273. package/resources/indexes/hnswDerivedIndex.ts +531 -0
  274. package/resources/indexes/hnswPlaneBinding.ts +174 -0
  275. package/resources/indexes/nativeFullTextDerivedIndexLifecycle.ts +181 -0
  276. package/resources/nodeIdMapping.ts +50 -0
  277. package/resources/record-locks.md +1407 -0
  278. package/resources/recordLock.ts +173 -7
  279. package/resources/recordLockCoordinator.ts +3082 -0
  280. package/resources/replayLogs.ts +5 -0
  281. package/resources/replicatedApplyFailure.ts +77 -0
  282. package/resources/scheduler/DESIGN.md +40 -0
  283. package/resources/scheduler/scheduler.ts +4 -4
  284. package/resources/search.ts +169 -49
  285. package/resources/tracked.ts +73 -22
  286. package/resources/transactionBroadcast.ts +4 -4
  287. package/security/DESIGN.md +175 -0
  288. package/security/auth.ts +53 -24
  289. package/security/deferredAuthentication.ts +24 -2
  290. package/security/jsLoader.ts +9 -4
  291. package/server/DESIGN.md +275 -0
  292. package/server/REST.ts +42 -6
  293. package/server/http.ts +34 -2
  294. package/server/mqtt.ts +6 -4
  295. package/server/serverHelpers/Headers.ts +5 -1
  296. package/server/serverHelpers/NodeAdapterResponse.ts +221 -0
  297. package/server/serverHelpers/Request.ts +33 -131
  298. package/server/serverHelpers/contentTypes.ts +188 -15
  299. package/server/serverHelpers/serverUtilities.ts +157 -27
  300. package/server/serverHelpers/uwsServer.ts +4 -1
  301. package/server/serverHelpers/webSocketCloseReason.ts +25 -0
  302. package/server/storageReclamation.ts +2 -2
  303. package/server/threads/isolatedApplications.ts +157 -0
  304. package/server/threads/logRotationTransport.ts +40 -0
  305. package/server/threads/manageThreads.js +254 -12
  306. package/server/threads/socketRouter.ts +217 -11
  307. package/server/threads/threadServer.js +30 -7
  308. package/studio/web/assets/{Chat-BnCBegQz.js → Chat-DADFFGe_.js} +1 -1
  309. package/studio/web/assets/{FloatingChat-CoDW1ySS.js → FloatingChat-D_mI-rZ7.js} +3 -3
  310. package/studio/web/assets/{apiToken-Bwk5BLXW.js → apiToken-c2NiSDHa.js} +1 -1
  311. package/studio/web/assets/{applications-DHxGi7JH.js → applications-DktUqh7G.js} +1 -1
  312. package/studio/web/assets/{cssMode-s0cWI-_M.js → cssMode-Cs_75Xhw.js} +1 -1
  313. package/studio/web/assets/{editor-DNcRHK54.js → editor-19b-Y1IN.js} +1 -1
  314. package/studio/web/assets/{html-Bdssedlg.js → html-DiYEQMpB.js} +1 -1
  315. package/studio/web/assets/{htmlMode-CoDlJ3fw.js → htmlMode-CmR0y7P_.js} +1 -1
  316. package/studio/web/assets/{index-D6sxmFLR.js → index-Dm0rfkJ7.js} +5 -5
  317. package/studio/web/assets/{index.lazy-tmU5BS8s.js → index.lazy-7vqt2CC3.js} +1 -1
  318. package/studio/web/assets/{javascript-B8meVSTH.js → javascript-BWtCFuOt.js} +1 -1
  319. package/studio/web/assets/{jsonMode-DpIPd35T.js → jsonMode-Buzzbv9y.js} +1 -1
  320. package/studio/web/assets/{languageServices-C_5FMJzQ.js → languageServices-SqsFWfTM.js} +1 -1
  321. package/studio/web/assets/{lspLanguageFeatures-BIzNBzPK.js → lspLanguageFeatures-EMV5cmjo.js} +1 -1
  322. package/studio/web/assets/{notifications-CvZivSbh.js → notifications-CAB-LZWT.js} +1 -1
  323. package/studio/web/assets/{notifications-CQf18QKb.js → notifications-DRzmSRxM.js} +1 -1
  324. package/studio/web/assets/{profile-DdOwtntb.js → profile-BNKAl79n.js} +1 -1
  325. package/studio/web/assets/{regions-n69fwagr.js → regions-CUow_Zw2.js} +1 -1
  326. package/studio/web/assets/{register-PfWTCXWB.js → register-Dkt3WUMp.js} +2 -2
  327. package/studio/web/assets/{setComponentFile-Bg6O7X0S.js → setComponentFile-BZRfMD0N.js} +1 -1
  328. package/studio/web/assets/{setup-CUx_aUDl.js → setup-D_yiEPO2.js} +2 -2
  329. package/studio/web/assets/{status-D7BVKqX9.js → status-DhHh1Ge-.js} +1 -1
  330. package/studio/web/assets/{toggleHighContrast-DBSyXzMr.js → toggleHighContrast-D7L1PDtV.js} +1 -1
  331. package/studio/web/assets/{tsMode-BByKCjBS.js → tsMode-CCwLk1YS.js} +1 -1
  332. package/studio/web/assets/{typescript-DDLnLpw9.js → typescript-BP1j1mjn.js} +1 -1
  333. package/studio/web/assets/{useEntityRestURL-31CHGaHk.js → useEntityRestURL-D7bnYxLw.js} +1 -1
  334. package/studio/web/assets/{workers-pR3jRY9D.js → workers-tOuCNT17.js} +1 -1
  335. package/studio/web/assets/{xml-2iRnMhQO.js → xml-BSG_3mQT.js} +1 -1
  336. package/studio/web/assets/{yaml-Bf92gJpd.js → yaml-DxiLprBB.js} +1 -1
  337. package/studio/web/index.html +1 -1
  338. package/utility/DESIGN.md +55 -0
  339. package/utility/errors/hdbError.ts +54 -0
  340. package/utility/hdbTerms.ts +2 -0
  341. package/utility/logging/harper_logger.ts +210 -30
  342. package/utility/logging/logGenerationCoordinator.ts +196 -0
  343. package/utility/logging/logRotation.ts +367 -0
  344. package/utility/logging/logRotator.ts +196 -91
  345. package/utility/npmUtilities.ts +6 -4
  346. package/utility/watcherFallback.ts +0 -122
  347. package/validation/configValidator.ts +6 -3
@@ -1,11 +1,26 @@
1
- import { startWorker, setMonitorListener, setMainIsWorker, threadsHaveStarted } from './manageThreads.js';
1
+ import {
2
+ startWorker,
3
+ setMonitorListener,
4
+ setMainIsWorker,
5
+ threadsHaveStarted,
6
+ setIsolatedWorkerReconciler,
7
+ setRunningIsolatedApplicationsGetter,
8
+ workersForApplication,
9
+ stopWorker,
10
+ } from './manageThreads.js';
11
+ import {
12
+ presentIsolatedApplicationNames,
13
+ isolatedApplicationRefusal,
14
+ isolatedApplicationCapacityRefusal,
15
+ } from './isolatedApplications.ts';
16
+ import { lifecycle as componentLifecycle } from '../../components/status/index.ts';
2
17
  import * as hdbTerms from '../../utility/hdbTerms.ts';
3
18
  import * as harperLogger from '../../utility/logging/harper_logger.ts';
4
19
  import { recordHostname } from '../../resources/analytics/write.ts';
5
20
  import { startTransactionLogCooling } from '../transactionLogCooling.ts';
6
21
  import { startLongLivedTransactionReporting } from '../../resources/longLivedTransactions.ts';
7
- import { isMainThread } from 'worker_threads';
8
- import { join } from 'path';
22
+ import { isMainThread } from 'node:worker_threads';
23
+ import { join } from 'node:path';
9
24
 
10
25
  const workers = [];
11
26
  const HTTP_WORKER_STARTUP_DIAGNOSTIC_MS = 60000;
@@ -60,7 +75,9 @@ export async function startHTTPThreads(threadCount = 2, dynamicThreads?: boolean
60
75
  // does not bind ports in this mode, so on platforms without SO_REUSEPORT (macOS/Windows)
61
76
  // worker 0's exclusive HTTP bind would silently swallow an external EADDRINUSE — the
62
77
  // external-conflict detection in listenOnPorts() assumes the main thread binds first.
63
- workerSlots.push(startHTTPWorker(0, 1));
78
+ const slot = startHTTPWorker(0, 1);
79
+ workerSlots.push(slot);
80
+ poolSlots.push(slot);
64
81
  } else {
65
82
  const { loadRootComponents } = require('../loadRootComponents.js');
66
83
  if (threadCount === 0) {
@@ -78,17 +95,165 @@ export async function startHTTPThreads(threadCount = 2, dynamicThreads?: boolean
78
95
  // Windows does not support SO_REUSEPORT, so only a single HTTP worker is supported.
79
96
  if (process.platform === 'win32') threadCount = 1;
80
97
  }
98
+ poolSize = threadCount;
99
+ nextIsolatedIndex = Math.max(nextIsolatedIndex, threadCount);
100
+ const isolated = admittedIsolatedApplications([...isolatedSlots.keys()]);
101
+ const heapShareCount = threadCount + isolated.length;
81
102
  for (let i = 0; i < threadCount; i++) {
82
- workerSlots.push(startHTTPWorker(i, threadCount));
103
+ const slot = startHTTPWorker(i, threadCount, undefined, heapShareCount);
104
+ workerSlots.push(slot);
105
+ poolSlots.push(slot);
83
106
  }
84
- await Promise.all(workerSlots.map((slot) => slot.ready));
107
+ // One dedicated worker per isolated application, numbered past the pool so no pool-only duty
108
+ // (worker 0's startup log, the last worker's cleanup) ever lands on it.
109
+ for (const application of isolated) {
110
+ if (isolatedSlots.has(application)) continue;
111
+ const slot = startHTTPWorker(nextIsolatedIndex++, threadCount, application, heapShareCount);
112
+ isolatedSlots.set(application, slot);
113
+ workerSlots.push(slot);
114
+ void watchDedicatedStart(application, slot);
115
+ }
116
+ await Promise.all(workerSlots.filter((slot) => !slot.application).map((slot) => slot.ready));
85
117
  } finally {
86
- for (const slot of workerSlots) slot.finishStartup();
118
+ for (const slot of workerSlots) if (!slot.application) slot.finishStartup();
87
119
  threadsHaveStarted(undefined as any);
88
120
  }
89
121
  }
90
122
 
91
- function startHTTPWorker(index, threadCount = 1) {
123
+ let poolSize = 0;
124
+ const refusedIsolated = new Set<string>(); // reported once, not on every reconcile
125
+ const ISOLATED_WORKER_READY_TIMEOUT_MS = 60_000; // the pool replacement path's backstop
126
+ let nextIsolatedIndex = 0;
127
+ type IsolatedSlot = {
128
+ ready: Promise<void>;
129
+ finishStartup: () => void;
130
+ shutdown: () => Promise<void>;
131
+ setHeapShareCount: (count: number) => void;
132
+ application?: string;
133
+ };
134
+ const isolatedSlots = new Map<string, IsolatedSlot>();
135
+ const poolSlots: IsolatedSlot[] = [];
136
+
137
+ /**
138
+ * The isolated applications that get a dedicated worker. Ones already running keep their place; new
139
+ * ones are admitted up to `threads.maxIsolated`, and only while a dedicated worker would be reachable
140
+ * at all. Everything refused is refused loudly and loaded nowhere -- never downgraded to the pool.
141
+ */
142
+ function admittedIsolatedApplications(running: string[]): string[] {
143
+ const names = presentIsolatedApplicationNames();
144
+ const admitted = [];
145
+ for (const name of running) {
146
+ if (!names.includes(name)) continue;
147
+ const refusal = isolatedApplicationRefusal(name);
148
+ if (refusal) {
149
+ reportIsolatedRefusal(name, refusal);
150
+ continue;
151
+ }
152
+ admitted.push(name);
153
+ }
154
+ for (const name of names) {
155
+ if (admitted.includes(name)) continue;
156
+ const refusal = isolatedApplicationRefusal(name) ?? isolatedApplicationCapacityRefusal(name, admitted);
157
+ if (refusal) {
158
+ reportIsolatedRefusal(name, refusal);
159
+ continue;
160
+ }
161
+ refusedIsolated.delete(name);
162
+ admitted.push(name);
163
+ }
164
+ return admitted;
165
+ }
166
+
167
+ function reportIsolatedRefusal(name: string, refusal: string) {
168
+ if (refusedIsolated.has(name)) return;
169
+ refusedIsolated.add(name);
170
+ const error = new Error(
171
+ `Application '${name}' is isolated but gets no dedicated worker: ${refusal}; it is not loaded anywhere`
172
+ );
173
+ harperLogger.error(error.message);
174
+ componentLifecycle.failed(name, error, `Component '${name}' failed to load`);
175
+ }
176
+
177
+ /**
178
+ * Wait for a dedicated worker to become ready, with the pool replacement path's backstop. A worker that
179
+ * fails, or stays alive without ever reporting ready, is recorded as a failed component, stopped, and
180
+ * only then has its slot freed, so the next reconcile retries against a worker that has exited.
181
+ * Resolves whether it became ready.
182
+ */
183
+ function watchDedicatedStart(application: string, slot: IsolatedSlot): Promise<boolean> {
184
+ return Promise.race([
185
+ slot.ready,
186
+ new Promise<never>((_, reject) =>
187
+ setTimeout(
188
+ () => reject(new Error(`Dedicated worker for '${application}' did not become ready in time`)),
189
+ ISOLATED_WORKER_READY_TIMEOUT_MS
190
+ ).unref()
191
+ ),
192
+ ])
193
+ .then(() => true)
194
+ .catch(async (error) => {
195
+ harperLogger.error(`Dedicated worker for isolated application '${application}' failed to start`, error);
196
+ componentLifecycle.failed(application, error, `Component '${application}' failed to load`);
197
+ // The slot IS the lease: holding it until the failed worker has actually exited is what stops a
198
+ // reconcile from starting a replacement over its still-bound UDS mirror and still-open stores,
199
+ // and what makes a concurrent drop's `await slot.shutdown()` cover this worker too.
200
+ await slot.shutdown();
201
+ if (isolatedSlots.get(application) !== slot) return false; // a drop already withdrew this lease
202
+ isolatedSlots.delete(application);
203
+ const { cleanupApplicationSockets } = await import('../http.ts');
204
+ // A reconcile may have installed a replacement while that import resolved. Never unlink its mirror.
205
+ if (!isolatedSlots.has(application)) cleanupApplicationSockets(application);
206
+ return false;
207
+ })
208
+ .finally(() => slot.finishStartup());
209
+ }
210
+
211
+ /**
212
+ * Bring the dedicated workers in line with the root config: start one for each isolated application
213
+ * that has none, stop the one of an application that is no longer isolated or no longer configured.
214
+ * Runs on the main thread after every root-component reload (deploy, drop, restart).
215
+ */
216
+ let reconciling: Promise<string[]> = Promise.resolve([]);
217
+ export function reconcileIsolatedWorkers(): Promise<string[]> {
218
+ // serialized: two reloads in flight must not compute `wanted` against each other's half-done work
219
+ reconciling = reconciling.then(reconcileIsolatedWorkersNow, reconcileIsolatedWorkersNow);
220
+ return reconciling;
221
+ }
222
+
223
+ async function reconcileIsolatedWorkersNow(): Promise<string[]> {
224
+ if (!isMainThread || poolSize === 0) return [];
225
+ const wanted = new Set(admittedIsolatedApplications([...isolatedSlots.keys()]));
226
+ const stopping = [];
227
+ for (const [application, slot] of isolatedSlots) {
228
+ if (wanted.has(application)) continue;
229
+ isolatedSlots.delete(application);
230
+ // awaited: a caller that goes on to remove the application's storage must see its worker gone
231
+ stopping.push(slot.shutdown().then(() => application));
232
+ }
233
+ const stoppedApplications = await Promise.all(stopping);
234
+ if (stoppedApplications.length > 0) {
235
+ const { cleanupApplicationSockets } = await import('../http.ts');
236
+ for (const application of stoppedApplications) cleanupApplicationSockets(application);
237
+ }
238
+ const started: string[] = [];
239
+ const heapShareCount = poolSize + wanted.size;
240
+ for (const slot of poolSlots) slot.setHeapShareCount(heapShareCount);
241
+ for (const slot of isolatedSlots.values()) slot.setHeapShareCount(heapShareCount);
242
+ for (const application of wanted) {
243
+ if (isolatedSlots.has(application)) continue;
244
+ const slot = startHTTPWorker(nextIsolatedIndex++, poolSize, application, heapShareCount);
245
+ isolatedSlots.set(application, slot);
246
+ started.push(application);
247
+ void watchDedicatedStart(application, slot);
248
+ }
249
+ return started;
250
+ }
251
+ if (isMainThread) {
252
+ setIsolatedWorkerReconciler(reconcileIsolatedWorkers);
253
+ setRunningIsolatedApplicationsGetter(() => [...isolatedSlots.keys()]);
254
+ }
255
+
256
+ function startHTTPWorker(index, threadCount = 1, application?: string, heapShareCount?: number) {
92
257
  const { promise: ready, resolve: resolveReady, reject: rejectReady } = Promise.withResolvers<void>();
93
258
  let waitingForInitialReady = true;
94
259
  let finishCurrentStartup = () => {};
@@ -96,6 +261,7 @@ function startHTTPWorker(index, threadCount = 1) {
96
261
  // A Worker's threadId reads back as -1 once it has exited, which is exactly when the diagnostics
97
262
  // below run, so each attempt records its id while the worker is still alive.
98
263
  let lastThreadId = -1;
264
+ let isolatedSlot: IsolatedSlot | undefined;
99
265
  const finishStartup = () => {
100
266
  waitingForInitialReady = false;
101
267
  finishCurrentStartup();
@@ -110,6 +276,11 @@ function startHTTPWorker(index, threadCount = 1) {
110
276
  name: hdbTerms.THREAD_TYPES.HTTP,
111
277
  workerIndex: index,
112
278
  threadCount,
279
+ application,
280
+ heapShareCount,
281
+ shouldAutoRestart: application
282
+ ? () => isolatedSlot !== undefined && isolatedSlots.get(application) === isolatedSlot
283
+ : undefined,
113
284
  onStarted(worker) {
114
285
  const attempt = ++startupAttempts;
115
286
  const threadId = (lastThreadId = worker.threadId);
@@ -125,7 +296,7 @@ function startHTTPWorker(index, threadCount = 1) {
125
296
  worker.off('message', onMessage);
126
297
  };
127
298
  const describeStartup = (event) =>
128
- `HTTP worker slot ${index} ${event} before ready (thread ${threadId}, attempt ${attempt}, phase ${startupPhase})`;
299
+ `HTTP worker slot ${index}${application ? ` (isolated application '${application}')` : ''} ${event} before ready (thread ${threadId}, attempt ${attempt}, phase ${startupPhase})`;
129
300
  const onMessage = (message) => {
130
301
  if (message.type === hdbTerms.ITC_EVENT_TYPES.CHILD_STARTUP_PHASE) {
131
302
  startupPhase = message.phase;
@@ -160,11 +331,46 @@ function startHTTPWorker(index, threadCount = 1) {
160
331
  }
161
332
  },
162
333
  onRestartExhausted() {
163
- failStartup(new Error(`HTTP worker slot ${index} exhausted restarts before ready (thread ${lastThreadId})`));
334
+ const error = new Error(`HTTP worker slot ${index} exhausted restarts (thread ${lastThreadId})`);
335
+ if (waitingForInitialReady) failStartup(error);
336
+ else if (application && isolatedSlot && isolatedSlots.get(application) === isolatedSlot) {
337
+ isolatedSlots.delete(application);
338
+ componentLifecycle.failed(application, error, `Component '${application}' worker failed`);
339
+ void import('../http.ts').then(
340
+ ({ cleanupApplicationSockets }) => {
341
+ // A config reconciliation may already have installed a replacement after the
342
+ // exhausted slot released its lease. Never unlink that replacement's mirror.
343
+ if (isolatedSlots.has(application)) return;
344
+ cleanupApplicationSockets(application);
345
+ },
346
+ (cleanupError) => {
347
+ harperLogger.error(
348
+ `Could not clean sockets for failed isolated application '${application}'`,
349
+ cleanupError
350
+ );
351
+ }
352
+ );
353
+ }
164
354
  },
165
355
  };
166
356
  startWorker(join(__dirname, './threadServer.js'), workerOptions);
167
- return { ready, finishStartup };
357
+ // Stop of a dedicated worker whose application is gone: every worker carrying the application,
358
+ // a crashed one's replacement still booting included, so none is left running the removed app.
359
+ let shutdownPromise: Promise<void> | undefined;
360
+ const shutdown = (): Promise<void> => {
361
+ if (!application) return Promise.resolve();
362
+ if (shutdownPromise) return shutdownPromise;
363
+ shutdownPromise = Promise.all(workersForApplication(application).map((worker) => stopWorker(worker))).then(
364
+ () => undefined
365
+ );
366
+ failStartup(new Error(`Dedicated worker for '${application}' was stopped before it became ready`));
367
+ return shutdownPromise;
368
+ };
369
+ const setHeapShareCount = (count: number) => {
370
+ workerOptions.heapShareCount = count;
371
+ };
372
+ isolatedSlot = { ready, finishStartup, shutdown, setHeapShareCount, application };
373
+ return isolatedSlot;
168
374
  }
169
375
 
170
376
  // basically, the amount of additional idleness to expect based on previous idleness (some work will continue, some
@@ -26,6 +26,11 @@ const {
26
26
  getShutdownDrainCeilingMs,
27
27
  } = require('../../components/shutdownDrain.ts');
28
28
  const { realExit } = require('./workerProcessGuard.ts');
29
+ const {
30
+ thisThreadsIsolatedApplication,
31
+ applicationSocketName,
32
+ shouldStartUwsListenerHere,
33
+ } = require('./isolatedApplications.ts');
29
34
  const { isBun } = require('../serverHelpers/Request.ts');
30
35
  const { getDomainSocketPathMaxBytes, isDomainSocketPathTooLong } = require('../../utility/domainSocket.ts');
31
36
  const { createTLSSelector, getEffectiveTlsCiphers } = require('../../security/keys.ts');
@@ -330,10 +335,15 @@ function listenOnPorts() {
330
335
  const server = SERVERS[port];
331
336
 
332
337
  // If server is unix domain socket
338
+ // A worker dedicated to an isolated application binds only its own per-thread mirrors: not the shared
339
+ // ports (the kernel would hand it every application's connections) and not a global domain socket
340
+ // such as the operations API's, which it would take from the main thread.
333
341
  if (port.includes?.('/')) {
334
- listening.push(listenOnDomainSocket(port, server));
342
+ if (!thisThreadsIsolatedApplication() || server.isPerThreadSocket)
343
+ listening.push(listenOnDomainSocket(port, server));
335
344
  continue;
336
345
  }
346
+ if (thisThreadsIsolatedApplication()) continue;
337
347
  let listen_on;
338
348
  let ownerWorkerIndex = 0; // lowest eligible worker index for this port
339
349
  const threadRange = env.get(terms.CONFIG_PARAMS.HTTP_THREADRANGE);
@@ -406,6 +416,7 @@ function listenOnPorts() {
406
416
  if (uwsServeConfigs) {
407
417
  for (const key in uwsServeConfigs) {
408
418
  const cfg = uwsServeConfigs[key];
419
+ if (!shouldStartUwsListenerHere(cfg)) continue; // dedicated worker: its own mirrors only
409
420
  if (cfg.socketPath && existsSync(cfg.socketPath)) unlinkSync(cfg.socketPath);
410
421
  const { createUwsServer } = require('../serverHelpers/uwsServer.ts');
411
422
  listening.push(
@@ -455,7 +466,7 @@ async function listenOnPortsBun() {
455
466
  for (let port in bunServeConfigs) {
456
467
  const config = bunServeConfigs[port];
457
468
  const threadRange = env.get(terms.CONFIG_PARAMS.HTTP_THREADRANGE);
458
- if (threadRange) {
469
+ if (threadRange && !thisThreadsIsolatedApplication()) {
459
470
  let threadRangeArray = typeof threadRange === 'string' ? threadRange.split('-') : threadRange;
460
471
  let threadIndex = getWorkerIndex();
461
472
  if (threadIndex < threadRangeArray[0] || threadIndex > threadRangeArray[1]) {
@@ -532,15 +543,22 @@ async function listenOnPortsBun() {
532
543
  delete serveOptions.port;
533
544
  }
534
545
  if (isNaN(serveOptions.port)) continue;
535
- const bunServer = Bun.serve(serveOptions);
536
- SERVERS[port] = bunServer;
537
- harperLogger.trace('Bun listening on port ' + port, threadId);
546
+ // Keep ownership independent of address syntax: adding a Bun UDS route later must not widen
547
+ // a dedicated worker's ingress beyond its application-addressed mirror below.
548
+ if (!thisThreadsIsolatedApplication()) {
549
+ const bunServer = Bun.serve(serveOptions);
550
+ SERVERS[port] = bunServer;
551
+ harperLogger.trace('Bun listening on port ' + port, threadId);
552
+ }
538
553
 
539
554
  // Create a corresponding Unix Domain Socket mirror for secure ports
540
555
  if (config.isSecure && env.get(terms.CONFIG_PARAMS.TLS_UNIXDOMAINSOCKETS)) {
541
556
  const socketsDir = join(env.getHdbBasePath(), 'sockets');
542
557
  mkdirSync(socketsDir, { recursive: true });
543
- const socketName = `${getWorkerIndex()}-${port}`;
558
+ const isolatedApplication = thisThreadsIsolatedApplication();
559
+ const socketName = isolatedApplication
560
+ ? applicationSocketName(isolatedApplication, port)
561
+ : `${getWorkerIndex()}-${port}`;
544
562
  const udsPath = join(socketsDir, `${socketName}.sock`);
545
563
  const yamlPath = join(socketsDir, `${socketName}.yaml`);
546
564
  if (existsSync(udsPath)) unlinkSync(udsPath);
@@ -564,6 +582,7 @@ async function listenOnPortsBun() {
564
582
  }
565
583
  } catch (error) {
566
584
  harperLogger.error(`Unable to start Bun server on port ${port}`, error);
585
+ if (thisThreadsIsolatedApplication()) throw error;
567
586
  }
568
587
  }
569
588
  // Also start any non-HTTP servers (raw socket servers) that were registered in SERVERS
@@ -574,6 +593,7 @@ async function listenOnPortsBun() {
574
593
  if (server?.stop || bunServeConfigs[port]) continue;
575
594
  if (server?.listen) {
576
595
  if (port.includes?.('/')) {
596
+ if (thisThreadsIsolatedApplication() && !server.isPerThreadSocket) continue; // as in listenOnPorts
577
597
  listening.push(listenOnDomainSocket(port, server));
578
598
  } else {
579
599
  const lastColon = String(port).lastIndexOf(':');
@@ -673,7 +693,10 @@ function onSocket(listener, options) {
673
693
  if (env.get(terms.CONFIG_PARAMS.TLS_UNIXDOMAINSOCKETS)) {
674
694
  const socketsDir = join(env.getHdbBasePath(), 'sockets');
675
695
  mkdirSync(socketsDir, { recursive: true });
676
- const socketName = `${getWorkerIndex()}-${options.securePort}`;
696
+ const isolatedApplication = thisThreadsIsolatedApplication();
697
+ const socketName = isolatedApplication
698
+ ? applicationSocketName(isolatedApplication, options.securePort)
699
+ : `${getWorkerIndex()}-${options.securePort}`;
677
700
  const udsPath = join(socketsDir, `${socketName}.sock`);
678
701
  const yamlPath = join(socketsDir, `${socketName}.yaml`);
679
702
 
@@ -1,4 +1,4 @@
1
- import{r as e,t}from"./rolldown-runtime-hePW80VL.js";import{S as n,_ as r,a as i,b as a,c as o,d as s,f as c,g as l,h as u,l as d,m as f,n as p,o as m,p as h,r as g,s as _,t as v,v as y,x as b,y as x}from"./vendor-core-c2JRRJpV.js";import{i as S,t as C}from"./button-BIsUKRZq.js";import{a as ee}from"./vendor-datadog-CLUcJXOo.js";import{r as te}from"./vendor-react-CJV_K1u4.js";import{L as ne,k as re,q as ie,z as ae}from"./vendor-tanstack-DxzraizX.js";import{n as oe}from"./setSessionStorage-B0bf71m4.js";import{It as se}from"./vendor-ui-BUjK0h8a.js";import{t as w}from"./createLucideIcon-CzW9508A.js";import{n as ce,r as le,t as ue}from"./chevron-up-DtKGqDn3.js";import{c as de,f as fe,g as pe,h as me,i as he,l as ge,m as _e,p as ve,r as ye,t as be,u as xe}from"./setComponentFile-Bg6O7X0S.js";import{t as Se}from"./x-DIzaLEdK.js";import{n as Ce}from"./setLocalStorage-D_kflv4U.js";import{t as we}from"./useLocalStorage-BqMR3D8_.js";import{An as Te,Dr as Ee,En as De,H as Oe,It as ke,Mr as Ae,Mt as je,Nt as Me,Or as Ne,Pt as Pe,Tr as Fe,V as Ie,Z as Le,br as Re,c as ze,cr as Be,d as Ve,f as He,fr as Ue,ft as We,hr as Ge,in as Ke,m as qe,or as Je,ur as Ye,ut as Xe,yr as Ze,yt as Qe}from"./index-D6sxmFLR.js";import{t as $e}from"./useEntityRestURL-31CHGaHk.js";import{n as et,t as tt}from"./FloatingChat-CoDW1ySS.js";import{n as nt}from"./getAnalytics-GHK8ORfM.js";var rt=w(`between-horizontal-start`,[[`rect`,{width:`13`,height:`7`,x:`8`,y:`3`,rx:`1`,key:`pkso9a`}],[`path`,{d:`m2 9 3 3-3 3`,key:`1agib5`}],[`rect`,{width:`13`,height:`7`,x:`8`,y:`14`,rx:`1`,key:`1q5fc1`}]]),it=w(`book`,[[`path`,{d:`M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20`,key:`k3hazp`}]]),at=w(`chart-area`,[[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`,key:`c24i48`}],[`path`,{d:`M7 11.207a.5.5 0 0 1 .146-.353l2-2a.5.5 0 0 1 .708 0l3.292 3.292a.5.5 0 0 0 .708 0l4.292-4.292a.5.5 0 0 1 .854.353V16a1 1 0 0 1-1 1H8a1 1 0 0 1-1-1z`,key:`q0gr47`}]]),ot=w(`circle-x`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]]),st=w(`file-pen`,[[`path`,{d:`M12.659 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v9.34`,key:`o6klzx`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10.378 12.622a1 1 0 0 1 3 3.003L8.36 20.637a2 2 0 0 1-.854.506l-2.867.837a.5.5 0 0 1-.62-.62l.836-2.869a2 2 0 0 1 .506-.853z`,key:`zhnas1`}]]),ct=w(`logs`,[[`path`,{d:`M3 5h1`,key:`1mv5vm`}],[`path`,{d:`M3 12h1`,key:`lp3yf2`}],[`path`,{d:`M3 19h1`,key:`w6f3n9`}],[`path`,{d:`M8 5h1`,key:`1nxr5w`}],[`path`,{d:`M8 12h1`,key:`1con00`}],[`path`,{d:`M8 19h1`,key:`k7p10e`}],[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}]]),lt=w(`message-square-heart`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M7.5 9.5c0 .687.265 1.383.697 1.844l3.009 3.264a1.14 1.14 0 0 0 .407.314 1 1 0 0 0 .783-.004 1.14 1.14 0 0 0 .398-.31l3.008-3.264A2.77 2.77 0 0 0 16.5 9.5 2.5 2.5 0 0 0 12 8a2.5 2.5 0 0 0-4.5 1.5`,key:`1faxuh`}]]),ut=w(`send`,[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]),dt=w(`wrench`,[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]);async function ft(){await S.delete(`/Chat/Messages/`)}var T=e(ee(),1),E=te();function pt({setMessages:e}){let[t,n]=(0,T.useState)(!1),r=(0,T.useCallback)(async()=>{if(!t){n(!0);try{await ft(),e([])}catch(e){console.error(`Failed to clear chat:`,e)}finally{n(!1)}}},[t,e]);return(0,E.jsxs)(`button`,{type:`button`,className:`clear-chat-button gap-1`,onClick:r,disabled:t,title:`Clear chat`,children:[t?(0,E.jsx)(Ze,{className:`animate-spin`,size:18}):(0,E.jsx)(Ye,{size:18}),`Clear`]})}async function mt(){let{data:e}=await S.get(`/Chat/Messages/`);return e}var ht=`vercel.ai.error`,gt=Symbol.for(ht),_t,vt,D=class e extends (vt=Error,_t=gt,vt){constructor({name:e,message:t,cause:n}){super(t),this[_t]=!0,this.name=e,this.cause=n}static isInstance(t){return e.hasMarker(t,ht)}static hasMarker(e,t){let n=Symbol.for(t);return typeof e==`object`&&!!e&&n in e&&typeof e[n]==`boolean`&&e[n]===!0}};function yt(e){return e==null?`unknown error`:typeof e==`string`?e:e instanceof Error?e.toString():JSON.stringify(e)}var bt=`AI_InvalidArgumentError`,xt=`vercel.ai.error.${bt}`,St=Symbol.for(xt),Ct,wt,Tt=class extends (wt=D,Ct=St,wt){constructor({message:e,cause:t,argument:n}){super({name:bt,message:e,cause:t}),this[Ct]=!0,this.argument=n}static isInstance(e){return D.hasMarker(e,xt)}},Et=`AI_JSONParseError`,Dt=`vercel.ai.error.${Et}`,Ot=Symbol.for(Dt),kt,At,jt=class extends (At=D,kt=Ot,At){constructor({text:e,cause:t}){super({name:Et,message:`JSON parsing failed: Text: ${e}.
1
+ import{r as e,t}from"./rolldown-runtime-hePW80VL.js";import{S as n,_ as r,a as i,b as a,c as o,d as s,f as c,g as l,h as u,l as d,m as f,n as p,o as m,p as h,r as g,s as _,t as v,v as y,x as b,y as x}from"./vendor-core-c2JRRJpV.js";import{i as S,t as C}from"./button-BIsUKRZq.js";import{a as ee}from"./vendor-datadog-CLUcJXOo.js";import{r as te}from"./vendor-react-CJV_K1u4.js";import{L as ne,k as re,q as ie,z as ae}from"./vendor-tanstack-DxzraizX.js";import{n as oe}from"./setSessionStorage-B0bf71m4.js";import{It as se}from"./vendor-ui-BUjK0h8a.js";import{t as w}from"./createLucideIcon-CzW9508A.js";import{n as ce,r as le,t as ue}from"./chevron-up-DtKGqDn3.js";import{c as de,f as fe,g as pe,h as me,i as he,l as ge,m as _e,p as ve,r as ye,t as be,u as xe}from"./setComponentFile-BZRfMD0N.js";import{t as Se}from"./x-DIzaLEdK.js";import{n as Ce}from"./setLocalStorage-D_kflv4U.js";import{t as we}from"./useLocalStorage-BqMR3D8_.js";import{An as Te,Dr as Ee,En as De,H as Oe,It as ke,Mr as Ae,Mt as je,Nt as Me,Or as Ne,Pt as Pe,Tr as Fe,V as Ie,Z as Le,br as Re,c as ze,cr as Be,d as Ve,f as He,fr as Ue,ft as We,hr as Ge,in as Ke,m as qe,or as Je,ur as Ye,ut as Xe,yr as Ze,yt as Qe}from"./index-Dm0rfkJ7.js";import{t as $e}from"./useEntityRestURL-D7bnYxLw.js";import{n as et,t as tt}from"./FloatingChat-D_mI-rZ7.js";import{n as nt}from"./getAnalytics-GHK8ORfM.js";var rt=w(`between-horizontal-start`,[[`rect`,{width:`13`,height:`7`,x:`8`,y:`3`,rx:`1`,key:`pkso9a`}],[`path`,{d:`m2 9 3 3-3 3`,key:`1agib5`}],[`rect`,{width:`13`,height:`7`,x:`8`,y:`14`,rx:`1`,key:`1q5fc1`}]]),it=w(`book`,[[`path`,{d:`M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20`,key:`k3hazp`}]]),at=w(`chart-area`,[[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`,key:`c24i48`}],[`path`,{d:`M7 11.207a.5.5 0 0 1 .146-.353l2-2a.5.5 0 0 1 .708 0l3.292 3.292a.5.5 0 0 0 .708 0l4.292-4.292a.5.5 0 0 1 .854.353V16a1 1 0 0 1-1 1H8a1 1 0 0 1-1-1z`,key:`q0gr47`}]]),ot=w(`circle-x`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]]),st=w(`file-pen`,[[`path`,{d:`M12.659 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v9.34`,key:`o6klzx`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10.378 12.622a1 1 0 0 1 3 3.003L8.36 20.637a2 2 0 0 1-.854.506l-2.867.837a.5.5 0 0 1-.62-.62l.836-2.869a2 2 0 0 1 .506-.853z`,key:`zhnas1`}]]),ct=w(`logs`,[[`path`,{d:`M3 5h1`,key:`1mv5vm`}],[`path`,{d:`M3 12h1`,key:`lp3yf2`}],[`path`,{d:`M3 19h1`,key:`w6f3n9`}],[`path`,{d:`M8 5h1`,key:`1nxr5w`}],[`path`,{d:`M8 12h1`,key:`1con00`}],[`path`,{d:`M8 19h1`,key:`k7p10e`}],[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}]]),lt=w(`message-square-heart`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M7.5 9.5c0 .687.265 1.383.697 1.844l3.009 3.264a1.14 1.14 0 0 0 .407.314 1 1 0 0 0 .783-.004 1.14 1.14 0 0 0 .398-.31l3.008-3.264A2.77 2.77 0 0 0 16.5 9.5 2.5 2.5 0 0 0 12 8a2.5 2.5 0 0 0-4.5 1.5`,key:`1faxuh`}]]),ut=w(`send`,[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]),dt=w(`wrench`,[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]);async function ft(){await S.delete(`/Chat/Messages/`)}var T=e(ee(),1),E=te();function pt({setMessages:e}){let[t,n]=(0,T.useState)(!1),r=(0,T.useCallback)(async()=>{if(!t){n(!0);try{await ft(),e([])}catch(e){console.error(`Failed to clear chat:`,e)}finally{n(!1)}}},[t,e]);return(0,E.jsxs)(`button`,{type:`button`,className:`clear-chat-button gap-1`,onClick:r,disabled:t,title:`Clear chat`,children:[t?(0,E.jsx)(Ze,{className:`animate-spin`,size:18}):(0,E.jsx)(Ye,{size:18}),`Clear`]})}async function mt(){let{data:e}=await S.get(`/Chat/Messages/`);return e}var ht=`vercel.ai.error`,gt=Symbol.for(ht),_t,vt,D=class e extends (vt=Error,_t=gt,vt){constructor({name:e,message:t,cause:n}){super(t),this[_t]=!0,this.name=e,this.cause=n}static isInstance(t){return e.hasMarker(t,ht)}static hasMarker(e,t){let n=Symbol.for(t);return typeof e==`object`&&!!e&&n in e&&typeof e[n]==`boolean`&&e[n]===!0}};function yt(e){return e==null?`unknown error`:typeof e==`string`?e:e instanceof Error?e.toString():JSON.stringify(e)}var bt=`AI_InvalidArgumentError`,xt=`vercel.ai.error.${bt}`,St=Symbol.for(xt),Ct,wt,Tt=class extends (wt=D,Ct=St,wt){constructor({message:e,cause:t,argument:n}){super({name:bt,message:e,cause:t}),this[Ct]=!0,this.argument=n}static isInstance(e){return D.hasMarker(e,xt)}},Et=`AI_JSONParseError`,Dt=`vercel.ai.error.${Et}`,Ot=Symbol.for(Dt),kt,At,jt=class extends (At=D,kt=Ot,At){constructor({text:e,cause:t}){super({name:Et,message:`JSON parsing failed: Text: ${e}.
2
2
  Error message: ${yt(t)}`,cause:t}),this[kt]=!0,this.text=e}static isInstance(e){return D.hasMarker(e,Dt)}},Mt=`AI_TypeValidationError`,Nt=`vercel.ai.error.${Mt}`,Pt=Symbol.for(Nt),Ft,It,O=class e extends (It=D,Ft=Pt,It){constructor({value:e,cause:t,context:n}){let r=`Type validation failed`;if(n?.field&&(r+=` for ${n.field}`),n?.entityName||n?.entityId){r+=` (`;let e=[];n.entityName&&e.push(n.entityName),n.entityId&&e.push(`id: "${n.entityId}"`),r+=e.join(`, `),r+=`)`}super({name:Mt,message:`${r}: Value: ${JSON.stringify(e)}.
3
3
  Error message: ${yt(t)}`,cause:t}),this[Ft]=!0,this.value=e,this.context=n}static isInstance(e){return D.hasMarker(e,Nt)}static wrap({value:t,cause:n,context:r}){return e.isInstance(n)&&n.value===t&&n.context?.field===r?.field&&n.context?.entityName===r?.entityName&&n.context?.entityId===r?.entityId?n:new e({value:t,cause:n,context:r})}},Lt=class extends Error{constructor(e,t){super(e),this.name=`ParseError`,this.type=t.type,this.field=t.field,this.value=t.value,this.line=t.line}},Rt=10,zt=13,k=32;function Bt(e){}function Vt(e){if(typeof e==`function`)throw TypeError("`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?");let{onEvent:t=Bt,onError:n=Bt,onRetry:r=Bt,onComment:i,maxBufferSize:a}=e,o=[],s=0,c=!0,l,u=``,d=0,f,p=!1;function m(e){if(p)throw Error("Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing.");if(c&&(c=!1,e.charCodeAt(0)===239&&e.charCodeAt(1)===187&&e.charCodeAt(2)===191&&(e=e.slice(3))),o.length===0){let t=g(e);t!==``&&(o.push(t),s=t.length),h();return}if(e.indexOf(`
4
4
  `)===-1&&e.indexOf(`\r`)===-1){o.push(e),s+=e.length,h();return}o.push(e);let t=o.join(``);o.length=0,s=0;let n=g(t);n!==``&&(o.push(n),s=n.length),h()}function h(){a!==void 0&&(s+u.length<=a||(p=!0,o.length=0,s=0,l=void 0,u=``,d=0,f=void 0,n(new Lt(`Buffered data exceeded max buffer size of ${a} characters`,{type:`max-buffer-size-exceeded`}))))}function g(e){let n=0;if(e.indexOf(`\r`)===-1){let r=e.indexOf(`