nolo-cli 0.98.0-alpha.4 → 0.98.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 (205) hide show
  1. package/README.md +1 -1
  2. package/{_executeModel-HYZ4NXRJ.js → _executeModel-GJK4ZVU6.js} +74 -67
  3. package/action-PNPQLJHG.js +20 -0
  4. package/{addContentAction-O7R66HEX.js → addContentAction-RBOUD7SJ.js} +12 -11
  5. package/{addDialogAgentAction-74OA7KYP.js → addDialogAgentAction-IODCR6TB.js} +18 -19
  6. package/{agentDeleteCommand-2YAHAZFJ.js → agentDeleteCommand-GHRF6CH5.js} +47 -42
  7. package/{agentEmailCommands-SLEQANTK.js → agentEmailCommands-O5BTHYZK.js} +97 -87
  8. package/agentListCommands-3REEM63V.js +742 -0
  9. package/{agentMachineCommands-KBI77S35.js → agentMachineCommands-2GW3CV7Q.js} +48 -43
  10. package/{agentProviderCommands-GNPTL5XR.js → agentProviderCommands-IRNZXVGE.js} +1 -1
  11. package/{agentPullCommand-O5MPVJ5E.js → agentPullCommand-B4T2DJ5H.js} +1 -1
  12. package/agentRecordCommands-WYQODWZE.js +138 -0
  13. package/agentRunCommand-KAN65WPY.js +167 -0
  14. package/{agentRunControl-AVJR4JW4.js → agentRunControl-3HWA2LLQ.js} +2 -2
  15. package/{agentRuntimeLocal-VXZSDIGT.js → agentRuntimeLocal-IOFBNVIL.js} +48 -39
  16. package/{agentSlice-ZOYISPZD.js → agentSlice-I45M32KO.js} +14 -13
  17. package/{appDeleteCommands-32MHLR4L.js → appDeleteCommands-SFS6IZEM.js} +46 -41
  18. package/{appDeployCommands-WCQOUSOB.js → appDeployCommands-YZQESVRQ.js} +46 -41
  19. package/{appDeployStatusCommands-6QKB7DYN.js → appDeployStatusCommands-FKUUDCKP.js} +46 -41
  20. package/{appGetCommands-SFAPP5PB.js → appGetCommands-QUE7OQZC.js} +46 -41
  21. package/{appListCommands-EKUBDRUO.js → appListCommands-QEETFKMH.js} +46 -41
  22. package/{authCommand-F4EFRRX6.js → authCommand-NHDLY3IB.js} +118 -24
  23. package/{authCommands-RGOGCPP6.js → authCommands-UDBJVSZU.js} +7 -5
  24. package/{builtinSkillRegistry-FUAVTRVZ.js → builtinSkillRegistry-MAR5LPAC.js} +10 -8
  25. package/{chromeCommands-FZYAU75D.js → chromeCommands-K27J4OVZ.js} +124 -28
  26. package/{chromeOpsCommands-62P2Q2YB.js → chromeOpsCommands-IXRLN57H.js} +4 -3
  27. package/{chunk-6OZ36FXI.js → chunk-27ONFIEY.js} +22 -4
  28. package/{chunk-JEDZAO7L.js → chunk-2SYTUTLI.js} +257 -37
  29. package/{chunk-53HEEOTT.js → chunk-2WJ57RJA.js} +83 -16
  30. package/{chunk-OIVSQH2O.js → chunk-3BXNTXYI.js} +299 -5
  31. package/{chunk-ABQYVJBJ.js → chunk-46Y5D2BZ.js} +5 -5
  32. package/{chunk-EYAQT56M.js → chunk-4DPP773Q.js} +2 -2
  33. package/{chunk-H62HCIUP.js → chunk-4FFUDT6D.js} +24 -21
  34. package/chunk-4LCOCOR5.js +50 -0
  35. package/{chunk-2GRGFCF6.js → chunk-4VJAC32I.js} +2 -1
  36. package/{chunk-IIVGDG4I.js → chunk-4YSOUKUR.js} +13 -7
  37. package/{chunk-MC4XLIJ7.js → chunk-523DITKR.js} +1 -1
  38. package/{chunk-G4EBXCWF.js → chunk-5AUJB66Z.js} +550 -515
  39. package/{chunk-E4MARS3Q.js → chunk-5GVBDNTO.js} +1 -1
  40. package/chunk-5J3PYNUP.js +255 -0
  41. package/chunk-5MMAK75Q.js +15 -0
  42. package/{chunk-JPGCXHNM.js → chunk-5OA5HMTL.js} +1 -1
  43. package/{chunk-42V6BK2E.js → chunk-62IL3KQV.js} +4 -34
  44. package/{chunk-3BMYXEUW.js → chunk-6O4IK4V2.js} +1 -1
  45. package/{chunk-34BLIAHQ.js → chunk-6XDD7N7P.js} +47 -67
  46. package/{chunk-GQBOR3G6.js → chunk-7KVZ5LDQ.js} +2 -2
  47. package/{chunk-DNCEALKX.js → chunk-7MMSLEPA.js} +22 -29
  48. package/chunk-A4SQRTZ6.js +15 -0
  49. package/{chunk-7S4YWN7P.js → chunk-ADBZWMFB.js} +4 -4
  50. package/chunk-AGIM7IMJ.js +147 -0
  51. package/{chunk-5UTFL4QJ.js → chunk-AOTBKDRK.js} +7 -0
  52. package/{chunk-Q554LLSI.js → chunk-AUDNYVRC.js} +1 -1
  53. package/{chunk-T37GTQYU.js → chunk-B2DEZY6J.js} +20 -11
  54. package/chunk-BMQ2MJUK.js +153 -0
  55. package/{chunk-6YTOJY35.js → chunk-BZ7NPA6G.js} +35 -2
  56. package/chunk-C4DVDM72.js +13536 -0
  57. package/chunk-CHOZJMJS.js +78 -0
  58. package/{chunk-ACTMNVHM.js → chunk-CYSYR67N.js} +1 -1
  59. package/{chunk-GBRG75BQ.js → chunk-D2MDMY2M.js} +1 -0
  60. package/chunk-DZ7R5V3Y.js +164 -0
  61. package/{chunk-3VNWWVKB.js → chunk-E3YWHWCR.js} +50 -18
  62. package/{chunk-V4MJDUSR.js → chunk-E73ON47R.js} +2 -2
  63. package/{chunk-XDJFSBVV.js → chunk-EIFYNGU4.js} +24 -5
  64. package/{chunk-KQ4ONNQD.js → chunk-EKPKW6RM.js} +155 -8
  65. package/{chunk-TRV2MIDW.js → chunk-EXAJ6DCR.js} +1 -0
  66. package/{chunk-HJUYAD4A.js → chunk-FJ5BGMNM.js} +5 -5
  67. package/{chunk-2F7RJC6L.js → chunk-FOXQ7BAB.js} +1 -1
  68. package/{chunk-6IG4XSS6.js → chunk-FY7DCYW7.js} +88 -17
  69. package/{chunk-J4MOO56S.js → chunk-GARACBQB.js} +10 -2
  70. package/{chunk-6VFARHZW.js → chunk-GDFA73QZ.js} +934 -1091
  71. package/chunk-GMZLP5DV.js +82 -0
  72. package/{chunk-FDTR4QJ6.js → chunk-H6A6X4EK.js} +32 -1
  73. package/{chunk-DVINR3PL.js → chunk-HDLLCBRF.js} +1 -1
  74. package/{chunk-QOKAKDPE.js → chunk-HIM3FCLF.js} +0 -1
  75. package/{chunk-ONXOABJR.js → chunk-HNGRBWYF.js} +3 -0
  76. package/{chunk-VLTIYV3X.js → chunk-HP57OUJO.js} +4 -4
  77. package/{chunk-YRPASJCG.js → chunk-I76SDF7A.js} +10 -10
  78. package/{chunk-2D66PZ54.js → chunk-I7BCBNWZ.js} +24 -77
  79. package/{chunk-GPCZ7UXG.js → chunk-K6U4NKFJ.js} +1 -1
  80. package/{chunk-4OEFYTWL.js → chunk-LDCAFLXD.js} +64 -48
  81. package/{chunk-OEVAY4J6.js → chunk-LNVJHIGA.js} +18 -20
  82. package/{chunk-LS2ZANRJ.js → chunk-LOCNXNOU.js} +1 -1
  83. package/{chunk-5H7KJX7J.js → chunk-LQ4PDQCI.js} +5 -5
  84. package/{chunk-PDIBG2WC.js → chunk-M33GWZIZ.js} +67 -45
  85. package/{chunk-PUOC4YRO.js → chunk-M7VLQGQP.js} +11 -0
  86. package/chunk-NHDMQZJM.js +7881 -0
  87. package/{chunk-BFU6C242.js → chunk-NMFV26UG.js} +1 -1
  88. package/{chunk-L5UXH3B2.js → chunk-NNCYNBYV.js} +22 -6
  89. package/{chunk-FZGV4FGK.js → chunk-NUHHBEJC.js} +378 -187
  90. package/chunk-NWENLDMM.js +42 -0
  91. package/{chunk-AEOE4Z6Q.js → chunk-NZWAO6LH.js} +13 -15
  92. package/chunk-OCZKATRC.js +129 -0
  93. package/{chunk-PKUGW3X6.js → chunk-OU36O6OR.js} +23 -28
  94. package/chunk-OW4APERY.js +870 -0
  95. package/{chunk-KQHGZWSV.js → chunk-OXME3PEE.js} +1 -1
  96. package/{chunk-ITM7D3UQ.js → chunk-P5L7VVMT.js} +11 -9
  97. package/{chunk-TOP2VXOR.js → chunk-PCF3QU5Q.js} +5 -5
  98. package/{chunk-WV42OMV7.js → chunk-PTDYOADJ.js} +8 -8
  99. package/{chunk-6D6VBVEW.js → chunk-SNMQMOD2.js} +80 -14
  100. package/{chunk-BYMV6QZG.js → chunk-TNIX77YM.js} +4 -0
  101. package/{chunk-Z77CRGTW.js → chunk-TVCAR26G.js} +1 -1
  102. package/chunk-TY3TIUJK.js +89 -0
  103. package/{chunk-I3TQJXQ7.js → chunk-U3C3IA32.js} +9 -2
  104. package/{chunk-RG6JBBX5.js → chunk-U7XXEI5R.js} +166 -13
  105. package/{chunk-UZGQNTVW.js → chunk-UA324D4O.js} +8 -6
  106. package/chunk-UJXNKP5V.js +760 -0
  107. package/{chunk-UKZDAFYT.js → chunk-UM4PH574.js} +6 -10
  108. package/{chunk-GEPUP7OO.js → chunk-UVKDJUTL.js} +3 -3
  109. package/{chunk-ZCYXJSTU.js → chunk-V5OWQOJZ.js} +19 -88
  110. package/{chunk-NA35QHCF.js → chunk-V7Y6KRAH.js} +1 -1
  111. package/{chunk-3DII57IT.js → chunk-VCAQFMVN.js} +1 -1
  112. package/{chunk-JRQFUXY7.js → chunk-VEYL5MO5.js} +99 -22
  113. package/chunk-VIWDGTDA.js +8 -0
  114. package/chunk-VJVNU77E.js +83 -0
  115. package/{chunk-UKWGR5SS.js → chunk-VY6VFGKR.js} +194 -1144
  116. package/{chunk-5ZYCLPXL.js → chunk-W3RFFFFF.js} +873 -227
  117. package/{chunk-BP4XNZRM.js → chunk-W72ISAKC.js} +4 -4
  118. package/{chunk-DHDMC6FO.js → chunk-WCGC6S77.js} +14 -9
  119. package/{chunk-QDSINZM3.js → chunk-WJ3B6FX6.js} +1 -14
  120. package/{chunk-V7BKTIF6.js → chunk-WXHAOL7Y.js} +19 -17
  121. package/{chunk-37NKTC3Q.js → chunk-X2B2C4XD.js} +1 -1
  122. package/{chunk-HVURBGF3.js → chunk-XFUBXRVI.js} +6 -6
  123. package/{chunk-O6OSWFZQ.js → chunk-XUWRURDF.js} +6 -0
  124. package/{chunk-Q67DOFOO.js → chunk-Y3PMXGLH.js} +2 -0
  125. package/{chunk-ETI2NYVF.js → chunk-YPOPJAKN.js} +4 -4
  126. package/{chunk-SH43IESU.js → chunk-YUNJN43V.js} +44 -9
  127. package/chunk-YV25TM3R.js +780 -0
  128. package/chunk-ZRAU6T47.js +56 -0
  129. package/commandRegistry-RZNZ37BN.js +833 -0
  130. package/{contentThunks-G55OKUFE.js → contentThunks-DF7ZNCAG.js} +36 -34
  131. package/{cooldownCommands-REAWYVTY.js → cooldownCommands-ZLEPIB4A.js} +2 -2
  132. package/{createAgentAutomationAction-D2J2O5GS.js → createAgentAutomationAction-KPMOZ53Y.js} +38 -36
  133. package/createDialogAction-I2UDVAXN.js +69 -0
  134. package/{createPageAction-FHZBN7DJ.js → createPageAction-IF5JXNKV.js} +45 -42
  135. package/{chunk-AJ3A3445.js → cursorProvider-YGGNMVWX.js} +2496 -9897
  136. package/{dbSlice-XVWBAGYN.js → dbSlice-Q25STFGJ.js} +11 -10
  137. package/{deleteFile-YG6QMJLU.js → deleteFile-AJ2EZMHT.js} +7 -6
  138. package/{dialogCommands-5J56DFWN.js → dialogCommands-LWHIIUQD.js} +49 -45
  139. package/{dialogSlice-D4V3HURH.js → dialogSlice-74DFPFRV.js} +40 -33
  140. package/{dist-VODFSGNG.js → dist-NJC2W7I4.js} +61 -54
  141. package/{docCreateCommands-KYI2DC2U.js → docCreateCommands-LVXQ6TNZ.js} +48 -43
  142. package/{docDeleteCommands-67REUSRY.js → docDeleteCommands-7TVIGCLP.js} +49 -44
  143. package/{docReadCommands-HOSVSBDJ.js → docReadCommands-KYAXFLQ5.js} +47 -42
  144. package/{docStore-5LROPEEP.js → docStore-2JDRAYXJ.js} +16 -12
  145. package/{docUpdateCommands-EMGCSMXY.js → docUpdateCommands-TVC5KWPK.js} +48 -43
  146. package/{fetchMessages-EIU7UFFK.js → fetchMessages-I5ICDDHM.js} +5 -5
  147. package/{getPricing-LUSEABA6.js → getPricing-NMMFT3YI.js} +4 -4
  148. package/{handleSendMessageAction-QBPDYSLZ.js → handleSendMessageAction-54GY3XOH.js} +110 -86
  149. package/index.js +87 -884
  150. package/{localDialogRead-BTFJ4V2I.js → localDialogRead-ZHZ3KXDM.js} +2 -2
  151. package/{localRuntimeAuthority-6IR6BBXE.js → localRuntimeAuthority-TU6OBC76.js} +9 -6
  152. package/{localRuntimeDb-SYQGUF4U.js → localRuntimeDb-VKWVOPPI.js} +1 -1
  153. package/{machineCommands-4ISPVTPN.js → machineCommands-54RNLVJE.js} +91 -81
  154. package/machineWsRunDispatch-WE3VTD57.js +154 -0
  155. package/{memberThunks-QGFLFVCI.js → memberThunks-R75S3RWP.js} +20 -18
  156. package/{models-T3SG6MJ5.js → models-ZPU5EDF4.js} +2 -2
  157. package/oauthTokenStore-ITEB663N.js +23 -0
  158. package/package.json +1 -1
  159. package/pdf-U6KSUEZZ.js +26435 -0
  160. package/processSpawn-SOAV3FEV.js +11 -0
  161. package/profileConfig-ZGOFORWV.js +43 -0
  162. package/{providerPresetApply-FG6NZ57W.js → providerPresetApply-TEBH7FDX.js} +7 -7
  163. package/{providerRegistry-757OWH3O.js → providerRegistry-CBJLNCET.js} +11 -7
  164. package/{read-COE3ZYR6.js → read-SRQMNO26.js} +7 -6
  165. package/{readDocTool-5USN4A6V.js → readDocTool-RC3JUNJ2.js} +5 -3
  166. package/{readlineWorkspace-JFADM567.js → readlineWorkspace-UK5M5CJI.js} +2704 -2060
  167. package/{removeDialogAgentAction-IX3MN2ZO.js → removeDialogAgentAction-46XQV5Q7.js} +21 -25
  168. package/{runAgentClientLoop-JFFIFP7N.js → runAgentClientLoop-MTI5OU2W.js} +75 -69
  169. package/{runtimeDoctorCommands-X6WDBEQX.js → runtimeDoctorCommands-PIVSBZRZ.js} +4 -4
  170. package/runtimeModeArgs-2Y7BALTO.js +31 -0
  171. package/{setDialogExtraReferencesAction-X4HCPNZL.js → setDialogExtraReferencesAction-J4V5ADQF.js} +15 -13
  172. package/{setPrimaryDialogAgentAction-4GMIQLOD.js → setPrimaryDialogAgentAction-UHHV2QZW.js} +22 -26
  173. package/{chunk-AFUORTY4.js → settingThunks-PPZZZOWN.js} +226 -940
  174. package/{skillDiscovery-CYUCJMAG.js → skillDiscovery-ZBU76COE.js} +3 -3
  175. package/{slateUtils-RIZES3PV.js → slateUtils-NGV2NMKM.js} +1 -1
  176. package/{spaceCommands-NKJVJCQQ.js → spaceCommands-446WWA73.js} +51 -46
  177. package/{streamAgentChatTurn-HFVTDCFD.js → streamAgentChatTurn-IANOWAKR.js} +199 -104
  178. package/{switchDialogAgentAction-N52LRPA3.js → switchDialogAgentAction-A2TMVGAE.js} +18 -19
  179. package/{tableCommands-O6NWHFKV.js → tableCommands-6U4BMLRR.js} +10 -10
  180. package/{toolApiClient-QVJ6HDNN.js → toolApiClient-EJT6TMFG.js} +3 -3
  181. package/tools-WZZYTUNF.js +116 -0
  182. package/{tuiSummaryLlmCaller-WFRWERGK.js → tuiSummaryLlmCaller-Q65IBDGO.js} +24 -21
  183. package/{updateCommands-2M74UL7P.js → updateCommands-4EHDLF5J.js} +3 -3
  184. package/{updateDialogTitleAction-PER2C6MR.js → updateDialogTitleAction-Z2JTYLXD.js} +82 -44
  185. package/action-YVYQEAAV.js +0 -31
  186. package/agentListCommands-KMS675GZ.js +0 -406
  187. package/agentRecordCommands-IPPPUHG4.js +0 -128
  188. package/agentRunCommand-24XO4RDT.js +0 -155
  189. package/browser-image-compression-MFDTD7K6.js +0 -1763
  190. package/chatQueueReduxAdapter-PMAMSHG7.js +0 -186
  191. package/chunk-M76ECQRD.js +0 -13658
  192. package/chunk-MEYIRKDN.js +0 -8967
  193. package/chunk-OCSGDPAT.js +0 -18885
  194. package/chunk-Q5FJJ6XI.js +0 -103
  195. package/chunk-S7Z2HMCN.js +0 -25
  196. package/chunk-Y5GCAMGP.js +0 -9
  197. package/chunk-YPREESF4.js +0 -225
  198. package/createDialogAction-E2EVICIE.js +0 -65
  199. package/machineWsRunDispatch-L4MKXQAO.js +0 -144
  200. package/settingSlice-ZQZVUPKK.js +0 -204
  201. package/syncMapping-N6RGXGBW.js +0 -437
  202. package/tools-BBBCUOUZ.js +0 -110
  203. package/{chunk-VMFTFOWF.js → chunk-3AH7LNUB.js} +7 -7
  204. package/{chunk-X7HHHIOZ.js → chunk-Y6ROFCZO.js} +0 -0
  205. package/{db-WK5MDZVN.js → db-VQSAOWAO.js} +1 -1
@@ -0,0 +1,760 @@
1
+ import {
2
+ isRecord
3
+ } from "./chunk-KUG52IAP.js";
4
+ import {
5
+ createSelector,
6
+ noloDeleteRequest,
7
+ noloPatchRequest,
8
+ noloUploadRequest,
9
+ noloWriteRequest,
10
+ syncWithServers
11
+ } from "./chunk-VY6VFGKR.js";
12
+ import {
13
+ getAllServers,
14
+ getIsDesktopApp
15
+ } from "./chunk-HIM3FCLF.js";
16
+ import {
17
+ selectIdentityToken,
18
+ selectIdentityUser,
19
+ selectIdentityUserId
20
+ } from "./chunk-SEJ5OS6F.js";
21
+ import {
22
+ asOptionalPositiveFiniteNumber
23
+ } from "./chunk-U6VC4MU4.js";
24
+ import {
25
+ asTrimmedString
26
+ } from "./chunk-3EUW3WEO.js";
27
+ import {
28
+ SERVERS,
29
+ normalizeKnownServerOrigin
30
+ } from "./chunk-LCBAMY2M.js";
31
+ import {
32
+ isLocalServerUrl
33
+ } from "./chunk-4SN6J65J.js";
34
+ import {
35
+ normalizeServerOrigin
36
+ } from "./chunk-CF7PE763.js";
37
+ import {
38
+ asOptionalTrimmedString
39
+ } from "./chunk-G3SUCT4W.js";
40
+
41
+ // packages/app/stateViews/runtime.ts
42
+ var selectCurrentToken = (state) => {
43
+ const token = selectIdentityToken(state);
44
+ return typeof token === "string" ? token : void 0;
45
+ };
46
+ var selectCurrentUserId = (state) => {
47
+ const userId = selectIdentityUserId(state);
48
+ return typeof userId === "string" ? userId : void 0;
49
+ };
50
+ var EMPTY_SYNC_SERVERS = [];
51
+ var selectRuntimeRemoteServer = (state) => {
52
+ const configuredServer = normalizeKnownServerOrigin(state.settings?.currentServer) ?? void 0;
53
+ if (!getIsDesktopApp()) return configuredServer || SERVERS.MAIN;
54
+ return isLocalServerUrl(configuredServer) ? SERVERS.MAIN : configuredServer || SERVERS.MAIN;
55
+ };
56
+ var selectConfiguredSyncServers = (state) => state.settings?.syncServers;
57
+ var selectRuntimeRemoteSyncServers = createSelector(
58
+ [selectConfiguredSyncServers],
59
+ (syncServers) => {
60
+ if (!Array.isArray(syncServers) || syncServers.length === 0) {
61
+ return EMPTY_SYNC_SERVERS;
62
+ }
63
+ const normalized = syncServers.map(normalizeKnownServerOrigin).filter((server) => !!server);
64
+ if (!getIsDesktopApp()) return normalized;
65
+ return normalized.filter((server) => !isLocalServerUrl(server));
66
+ }
67
+ );
68
+ var selectLocalRuntimeOrigin = () => {
69
+ if (typeof window !== "undefined" && typeof window.location?.origin === "string" && /^https?:\/\//.test(window.location.origin)) {
70
+ return window.location.origin.replace(/\/+$/, "");
71
+ }
72
+ return void 0;
73
+ };
74
+ var selectRuntimeSnapshot = createSelector(
75
+ [
76
+ selectCurrentToken,
77
+ selectCurrentUserId,
78
+ selectRuntimeRemoteServer,
79
+ selectRuntimeRemoteSyncServers,
80
+ selectLocalRuntimeOrigin
81
+ ],
82
+ (currentToken, currentUserId, currentServer, syncServers, localRuntimeOrigin) => ({
83
+ currentToken,
84
+ currentUserId,
85
+ currentServer,
86
+ syncServers,
87
+ localRuntimeOrigin
88
+ })
89
+ );
90
+ var selectRuntimeCurrentServer = createSelector(
91
+ [selectRuntimeSnapshot],
92
+ (runtime) => runtime.currentServer
93
+ );
94
+ var selectRuntimeRemoteServers = createSelector(
95
+ [selectRuntimeSnapshot],
96
+ (runtime) => getAllServers(runtime.currentServer, runtime.syncServers)
97
+ );
98
+
99
+ // packages/database/runtimeServerContext.ts
100
+ var getRuntimeServerContext = (state, preferredServerOrigin) => {
101
+ const {
102
+ currentToken,
103
+ currentUserId,
104
+ currentServer,
105
+ syncServers = []
106
+ } = selectRuntimeSnapshot(state);
107
+ return {
108
+ currentToken,
109
+ currentUserId,
110
+ currentServer,
111
+ syncServers,
112
+ userAuthorityRegistry: resolveRuntimeUserAuthorityRegistry(state),
113
+ remoteServers: getAllServers(
114
+ currentServer,
115
+ syncServers,
116
+ preferredServerOrigin
117
+ )
118
+ };
119
+ };
120
+ var resolveRuntimeUserAuthorityRegistry = (state) => {
121
+ const settingsRegistry = state.settings?.userAuthorityRegistry;
122
+ if (settingsRegistry && typeof settingsRegistry === "object") {
123
+ return settingsRegistry;
124
+ }
125
+ const userRegistry = selectIdentityUser(state)?.authorityRegistry;
126
+ if (userRegistry && typeof userRegistry === "object") {
127
+ return userRegistry;
128
+ }
129
+ return void 0;
130
+ };
131
+
132
+ // packages/database/authority/ownerKey.ts
133
+ var USER_OWNED_SECOND_SEGMENT_PREFIXES = /* @__PURE__ */ new Set([
134
+ "agent",
135
+ "dialog",
136
+ "page",
137
+ "doc",
138
+ "notification",
139
+ "email",
140
+ "meta",
141
+ "row",
142
+ "view",
143
+ "file",
144
+ "job"
145
+ ]);
146
+ var PUBLIC_OWNER_SENTINELS = /* @__PURE__ */ new Set(["pub", "id", "stats", "index"]);
147
+ var cleanSegment = (value) => {
148
+ const trimmed = asTrimmedString(value);
149
+ return trimmed.length > 0 ? trimmed : null;
150
+ };
151
+ var normalizeCandidateOwners = (candidateOwnerUserIds) => {
152
+ const out = [];
153
+ for (const candidate of candidateOwnerUserIds ?? []) {
154
+ const normalized = cleanSegment(candidate ?? void 0);
155
+ if (!normalized || PUBLIC_OWNER_SENTINELS.has(normalized)) continue;
156
+ if (!out.includes(normalized)) out.push(normalized);
157
+ }
158
+ return out.sort((left, right) => right.length - left.length);
159
+ };
160
+ var resolveCandidateOwnerFromKeyRemainder = (remainder, candidateOwnerUserIds) => {
161
+ const normalizedRemainder = cleanSegment(remainder);
162
+ if (!normalizedRemainder) return null;
163
+ for (const candidate of normalizeCandidateOwners(candidateOwnerUserIds)) {
164
+ if (normalizedRemainder === candidate || normalizedRemainder.startsWith(`${candidate}-`)) {
165
+ return candidate;
166
+ }
167
+ }
168
+ return null;
169
+ };
170
+ var parseOwnerUserIdFromDbKey = (dbKey, options = {}) => {
171
+ const normalized = cleanSegment(dbKey);
172
+ if (!normalized) return null;
173
+ const parts = normalized.split("-");
174
+ const [prefix] = parts;
175
+ if (!prefix) return null;
176
+ if (!USER_OWNED_SECOND_SEGMENT_PREFIXES.has(prefix)) {
177
+ if (prefix === "grant" && parts[1] === "agent" && parts.length >= 5) {
178
+ const ownerAndRest2 = normalized.slice(prefix.length + 1 + parts[1].length + 1);
179
+ const [owner2] = ownerAndRest2.split("-");
180
+ return cleanSegment(owner2);
181
+ }
182
+ return null;
183
+ }
184
+ if (parts[0] === "dialog" && parts[2] === "msg") {
185
+ return null;
186
+ }
187
+ const ownerAndRest = normalized.slice(prefix.length + 1);
188
+ const candidateOwner = resolveCandidateOwnerFromKeyRemainder(
189
+ ownerAndRest,
190
+ options.candidateOwnerUserIds
191
+ );
192
+ if (candidateOwner) return candidateOwner;
193
+ const [owner] = ownerAndRest.split("-");
194
+ const ownerUserId = cleanSegment(owner);
195
+ if (!ownerUserId) return null;
196
+ if (PUBLIC_OWNER_SENTINELS.has(ownerUserId)) return null;
197
+ return ownerUserId;
198
+ };
199
+
200
+ // packages/database/authority/userAuthorityRegistry.ts
201
+ var normalizeAuthorityServerOrigin = (value) => {
202
+ const normalized = normalizeServerOrigin(value);
203
+ return /^https?:\/\//i.test(normalized) ? normalized : null;
204
+ };
205
+ var normalizeUserId = (value) => asOptionalTrimmedString(value) ?? null;
206
+ var readEntryAuthorityServer = (entry) => {
207
+ if (typeof entry === "string") {
208
+ return normalizeAuthorityServerOrigin(entry);
209
+ }
210
+ if (!isRecord(entry)) {
211
+ return null;
212
+ }
213
+ return normalizeAuthorityServerOrigin(entry.authorityServer) ?? normalizeAuthorityServerOrigin(entry.homeServer) ?? normalizeAuthorityServerOrigin(entry.primaryServer);
214
+ };
215
+ var resolveUserAuthorityServer = ({
216
+ ownerUserId,
217
+ registry
218
+ }) => {
219
+ const normalizedOwner = normalizeUserId(ownerUserId);
220
+ if (!normalizedOwner || !registry || typeof registry !== "object") {
221
+ return null;
222
+ }
223
+ return readEntryAuthorityServer(registry[normalizedOwner]);
224
+ };
225
+
226
+ // packages/database/authority/recordAuthority.ts
227
+ var normalizeUserId2 = (value) => asOptionalTrimmedString(value) ?? null;
228
+ var getRegistryOwnerCandidates = (registry) => isRecord(registry) ? Object.keys(registry) : [];
229
+ var resolveRecordAuthority = ({
230
+ dbKey,
231
+ record,
232
+ currentUserId,
233
+ currentServer,
234
+ userAuthorityRegistry
235
+ }) => {
236
+ const ownerUserId = parseOwnerUserIdFromDbKey(dbKey, {
237
+ candidateOwnerUserIds: [
238
+ normalizeUserId2(record?.userId),
239
+ normalizeUserId2(currentUserId),
240
+ ...getRegistryOwnerCandidates(userAuthorityRegistry)
241
+ ]
242
+ }) ?? normalizeUserId2(record?.userId);
243
+ const serverOrigin = normalizeAuthorityServerOrigin(record?.serverOrigin);
244
+ const explicitAuthority = normalizeAuthorityServerOrigin(record?.authorityServer);
245
+ const registryAuthority = resolveUserAuthorityServer({
246
+ ownerUserId,
247
+ registry: userAuthorityRegistry
248
+ });
249
+ const currentUserAuthority = ownerUserId && ownerUserId === normalizeUserId2(currentUserId) ? normalizeAuthorityServerOrigin(currentServer) : null;
250
+ return {
251
+ ownerUserId,
252
+ authorityServer: explicitAuthority ?? registryAuthority ?? currentUserAuthority ?? serverOrigin,
253
+ serverOrigin
254
+ };
255
+ };
256
+
257
+ // packages/database/actions/readResolution.ts
258
+ var toComparableTimestamp = (data) => {
259
+ if (!data || typeof data !== "object") return 0;
260
+ const updatedAtMs = asOptionalPositiveFiniteNumber(
261
+ new Date(data.updatedAt).getTime()
262
+ );
263
+ if (updatedAtMs !== void 0) return updatedAtMs;
264
+ const createdAtMs = asOptionalPositiveFiniteNumber(
265
+ new Date(data.createdAt).getTime()
266
+ );
267
+ if (createdAtMs !== void 0) return createdAtMs;
268
+ return asOptionalPositiveFiniteNumber(Number(data?.meta?.createdAt)) ?? 0;
269
+ };
270
+ var partitionReadServers = ({
271
+ allServers,
272
+ preferredServerOrigin
273
+ }) => {
274
+ const preferredServer = typeof preferredServerOrigin === "string" && preferredServerOrigin.trim().length > 0 ? normalizeServerOrigin(preferredServerOrigin) : null;
275
+ const fallbackServers = preferredServer ? allServers.filter(
276
+ (server) => normalizeServerOrigin(server) !== preferredServer
277
+ ) : allServers;
278
+ return {
279
+ preferredServer,
280
+ fallbackServers,
281
+ orderedServersForLocalHit: preferredServer ? [preferredServer, ...fallbackServers] : fallbackServers
282
+ };
283
+ };
284
+ var compareRemoteRecordsByComparableTime = (left, right) => toComparableTimestamp(left) - toComparableTimestamp(right);
285
+ var pickBestSettledRemoteRecord = ({
286
+ settledResults,
287
+ isBetterCandidate
288
+ }) => {
289
+ const validResults = settledResults.map((result, index) => ({
290
+ data: result.status === "fulfilled" ? result.value : null,
291
+ index
292
+ })).filter((item) => item.data !== null && typeof item.data === "object");
293
+ if (validResults.length === 0) return null;
294
+ const latest = validResults.reduce(
295
+ (best, current) => isBetterCandidate(current.data, best.data) ? current : best
296
+ );
297
+ return { index: latest.index, data: latest.data };
298
+ };
299
+ var shouldReplaceLocalWithRemoteRecord = ({
300
+ localData,
301
+ remoteData,
302
+ isRemoteNewer
303
+ }) => {
304
+ if (!remoteData || typeof remoteData !== "object") return false;
305
+ if (!localData || typeof localData !== "object") return true;
306
+ return isRemoteNewer(remoteData, localData);
307
+ };
308
+ var shouldReplicateLocalRecord = ({
309
+ localData,
310
+ remoteData,
311
+ remoteTargetCount
312
+ }) => !!localData && !remoteData && remoteTargetCount > 0;
313
+ var compactUniqueServers = (servers) => {
314
+ const out = [];
315
+ for (const server of servers) {
316
+ if (typeof server !== "string" || server.trim().length === 0) continue;
317
+ const normalized = normalizeServerOrigin(server);
318
+ if (!out.includes(normalized)) out.push(normalized);
319
+ }
320
+ return out;
321
+ };
322
+ var planAuthorityReadServers = ({
323
+ allServers,
324
+ authorityServer,
325
+ serverOrigin
326
+ }) => compactUniqueServers([authorityServer, serverOrigin, ...allServers]);
327
+
328
+ // packages/core/fnv1a32.ts
329
+ var fnv1a32 = (str) => {
330
+ let hash = 2166136261;
331
+ for (let i = 0; i < str.length; i++) {
332
+ hash ^= str.charCodeAt(i);
333
+ hash = hash * 16777619 >>> 0;
334
+ }
335
+ return hash >>> 0;
336
+ };
337
+ var fnv1a32Hex = (str) => fnv1a32(str).toString(16).padStart(8, "0");
338
+
339
+ // packages/database/fileRing.ts
340
+ var chooseServersByKey = (allServers, key, replicaCount) => {
341
+ if (!allServers.length || replicaCount <= 0) return [];
342
+ const uniqueServers = Array.from(new Set(allServers)).filter((s) => !!s);
343
+ if (uniqueServers.length === 0) return [];
344
+ const scored = uniqueServers.map((server) => ({
345
+ server,
346
+ score: fnv1a32(`${server}::${key}`)
347
+ }));
348
+ scored.sort((a, b) => a.score - b.score);
349
+ const limit = Math.min(replicaCount, scored.length);
350
+ return scored.slice(0, limit).map((item) => item.server);
351
+ };
352
+
353
+ // packages/database/tenantPlacement.ts
354
+ var TENANT_REPLICA_COUNT = 2;
355
+ var planServersForTenant = (allServers, currentServer, tenantId) => {
356
+ const uniqueServers = Array.from(new Set(allServers)).filter(Boolean);
357
+ if (!uniqueServers.length) return [];
358
+ const key = asOptionalTrimmedString(tenantId) ?? "default-tenant";
359
+ const fromRing = chooseServersByKey(
360
+ uniqueServers,
361
+ key,
362
+ TENANT_REPLICA_COUNT
363
+ );
364
+ const set = new Set(fromRing);
365
+ if (currentServer && uniqueServers.includes(currentServer)) {
366
+ set.add(currentServer);
367
+ }
368
+ return Array.from(set);
369
+ };
370
+
371
+ // packages/database/authority/deviceLocal.ts
372
+ var DEVICE_LOCAL_OWNER_ID = "local";
373
+ var DEVICE_LOCAL_DB_KEY_PREFIXES = [
374
+ "dialog-local-",
375
+ "agent-local-"
376
+ ];
377
+ var clean = (value) => asOptionalTrimmedString(value) ?? null;
378
+ var isDeviceLocalOwnerId = (userId) => clean(userId) === DEVICE_LOCAL_OWNER_ID;
379
+ var resolveEffectiveSpaceActorId = (accountUserId) => {
380
+ const cleaned = clean(accountUserId);
381
+ if (!cleaned || isDeviceLocalOwnerId(cleaned)) {
382
+ return DEVICE_LOCAL_OWNER_ID;
383
+ }
384
+ return cleaned;
385
+ };
386
+ var isDeviceLocalSpaceMembership = (membership) => isDeviceLocalOwnerId(membership?.userId);
387
+ var isDeviceLocalSpaceBody = (space) => isDeviceLocalOwnerId(space?.userId) || isDeviceLocalOwnerId(space?.ownerId);
388
+ var isDeviceLocalDbKey = (dbKey) => {
389
+ const key = clean(dbKey);
390
+ if (!key) return false;
391
+ for (const prefix of DEVICE_LOCAL_DB_KEY_PREFIXES) {
392
+ if (key.startsWith(prefix)) return true;
393
+ }
394
+ return parseOwnerUserIdFromDbKey(key, {
395
+ candidateOwnerUserIds: [DEVICE_LOCAL_OWNER_ID]
396
+ }) === DEVICE_LOCAL_OWNER_ID;
397
+ };
398
+ var resolveRecordOwnerUserId = (record) => {
399
+ if (!record) return null;
400
+ const explicit = clean(record.userId);
401
+ if (explicit) return explicit;
402
+ if (isDeviceLocalDbKey(record.dbKey) || isDeviceLocalDbKey(record.id)) {
403
+ return DEVICE_LOCAL_OWNER_ID;
404
+ }
405
+ const fromKey = parseOwnerUserIdFromDbKey(clean(record.dbKey) ?? "", {
406
+ candidateOwnerUserIds: [DEVICE_LOCAL_OWNER_ID]
407
+ }) ?? parseOwnerUserIdFromDbKey(clean(record.id) ?? "", {
408
+ candidateOwnerUserIds: [DEVICE_LOCAL_OWNER_ID]
409
+ });
410
+ return fromKey;
411
+ };
412
+
413
+ // packages/database/actions/replication.ts
414
+ var isReadonlyPublicRecordKey = (dbKey) => dbKey.startsWith("agent-pub-");
415
+ var normalizeCurrentUserId = (state) => {
416
+ const userId = selectIdentityUserId(state);
417
+ return asOptionalTrimmedString(userId) ?? null;
418
+ };
419
+ var resolveReplicationServers = (currentServer, syncServers, preferredServerOrigin) => getAllServers(currentServer, syncServers, preferredServerOrigin);
420
+ var resolveAuthorityReplicationServers = ({
421
+ currentServer,
422
+ syncServers,
423
+ preferredServerOrigin,
424
+ dbKey,
425
+ record,
426
+ state
427
+ }) => {
428
+ const allServers = resolveReplicationServers(
429
+ currentServer,
430
+ syncServers,
431
+ preferredServerOrigin
432
+ );
433
+ const authority = resolveRecordAuthority({
434
+ dbKey,
435
+ record,
436
+ currentUserId: selectIdentityUserId(state),
437
+ currentServer,
438
+ userAuthorityRegistry: state?.settings?.userAuthorityRegistry ?? selectIdentityUser(state)?.authorityRegistry
439
+ });
440
+ if (isDeviceLocalOwnerId(authority.ownerUserId) || isDeviceLocalOwnerId(record?.userId) || isDeviceLocalDbKey(dbKey)) {
441
+ return [];
442
+ }
443
+ return planAuthorityReadServers({
444
+ allServers,
445
+ authorityServer: preferredServerOrigin ?? authority.authorityServer,
446
+ serverOrigin: authority.serverOrigin
447
+ });
448
+ };
449
+ var scheduleWriteReplication = (servers, request, state) => {
450
+ if (servers.length === 0) return;
451
+ Promise.resolve().then(async () => {
452
+ const [primaryServer, ...backupServers] = servers;
453
+ const primarySucceeded = await noloWriteRequest(primaryServer, request, state);
454
+ if (!primarySucceeded) {
455
+ console.warn(`Primary write sync failed for ${request.customKey} on ${primaryServer}`);
456
+ }
457
+ if (backupServers.length === 0) {
458
+ return;
459
+ }
460
+ syncWithServers(
461
+ backupServers,
462
+ (server, requestConfig, requestState, signal) => noloWriteRequest(server, requestConfig, requestState, signal, {
463
+ failureLogLevel: "info"
464
+ }),
465
+ `Backup write sync failed for ${request.customKey} on`,
466
+ request,
467
+ state
468
+ );
469
+ });
470
+ };
471
+ var resolveTenantReplicationServers = ({
472
+ currentServer,
473
+ syncServers,
474
+ tenantId
475
+ }) => {
476
+ const allServers = resolveReplicationServers(currentServer, syncServers);
477
+ if (allServers.length === 0) {
478
+ return [];
479
+ }
480
+ return planServersForTenant(allServers, currentServer, tenantId);
481
+ };
482
+ var resolveUploadReplicationServers = ({
483
+ currentServer,
484
+ syncServers,
485
+ tenantId,
486
+ uploadConfig,
487
+ state
488
+ }) => {
489
+ const allServers = resolveReplicationServers(currentServer, syncServers);
490
+ const authority = resolveRecordAuthority({
491
+ dbKey: uploadConfig.customKey,
492
+ record: uploadConfig.metadata,
493
+ currentUserId: selectIdentityUserId(state),
494
+ currentServer,
495
+ userAuthorityRegistry: state?.settings?.userAuthorityRegistry ?? selectIdentityUser(state)?.authorityRegistry
496
+ });
497
+ if (authority.ownerUserId || authority.authorityServer) {
498
+ return planAuthorityReadServers({
499
+ allServers,
500
+ authorityServer: authority.authorityServer,
501
+ serverOrigin: authority.serverOrigin
502
+ });
503
+ }
504
+ return resolveTenantReplicationServers({
505
+ currentServer,
506
+ syncServers,
507
+ tenantId
508
+ });
509
+ };
510
+ var scheduleExistingRecordReplication = ({
511
+ currentServer,
512
+ syncServers,
513
+ preferredServerOrigin,
514
+ dbKey,
515
+ localData,
516
+ state
517
+ }) => {
518
+ if (isReadonlyPublicRecordKey(dbKey)) {
519
+ return [];
520
+ }
521
+ const currentUserId = normalizeCurrentUserId(state);
522
+ const authority = resolveRecordAuthority({
523
+ dbKey,
524
+ record: localData,
525
+ currentUserId,
526
+ currentServer,
527
+ userAuthorityRegistry: state?.settings?.userAuthorityRegistry ?? selectIdentityUser(state)?.authorityRegistry
528
+ });
529
+ if (authority.ownerUserId && currentUserId && authority.ownerUserId !== currentUserId) {
530
+ return [];
531
+ }
532
+ const servers = resolveAuthorityReplicationServers({
533
+ currentServer,
534
+ syncServers,
535
+ preferredServerOrigin,
536
+ dbKey,
537
+ record: localData,
538
+ state
539
+ });
540
+ if (servers.length === 0) {
541
+ return [];
542
+ }
543
+ scheduleWriteReplication(
544
+ servers,
545
+ {
546
+ data: localData,
547
+ customKey: dbKey,
548
+ userId: typeof localData?.userId === "string" ? localData.userId : selectIdentityUserId(state)
549
+ },
550
+ state
551
+ );
552
+ return servers;
553
+ };
554
+ var schedulePatchReplication = ({
555
+ servers,
556
+ dbKey,
557
+ changes,
558
+ state,
559
+ preferredServerOrigin
560
+ }) => {
561
+ if (servers.length === 0) return;
562
+ Promise.resolve().then(async () => {
563
+ const primaryServer = typeof preferredServerOrigin === "string" && preferredServerOrigin.trim().length > 0 ? normalizeServerOrigin(preferredServerOrigin) : servers[0];
564
+ const backupServers = servers.filter(
565
+ (server) => normalizeServerOrigin(server) !== primaryServer
566
+ );
567
+ const primarySucceeded = await noloPatchRequest(primaryServer, dbKey, changes, state, void 0, {
568
+ failureLogLevel: "warn"
569
+ });
570
+ if (!primarySucceeded) {
571
+ console.warn(`Primary patch sync failed for ${dbKey} on ${primaryServer}`);
572
+ }
573
+ if (backupServers.length > 0) {
574
+ syncWithServers(
575
+ backupServers,
576
+ (server, targetDbKey, nextChanges, requestState, signal) => noloPatchRequest(server, targetDbKey, nextChanges, requestState, signal, {
577
+ failureLogLevel: "info"
578
+ }),
579
+ `Backup patch sync failed for ${dbKey} on`,
580
+ dbKey,
581
+ changes,
582
+ state
583
+ );
584
+ }
585
+ });
586
+ };
587
+ var scheduleConfiguredPatchReplication = ({
588
+ currentServer,
589
+ syncServers,
590
+ preferredServerOrigin,
591
+ dbKey,
592
+ changes,
593
+ state
594
+ }) => {
595
+ const servers = resolveAuthorityReplicationServers({
596
+ currentServer,
597
+ syncServers,
598
+ preferredServerOrigin,
599
+ dbKey,
600
+ record: changes,
601
+ state
602
+ });
603
+ if (servers.length === 0) {
604
+ return [];
605
+ }
606
+ schedulePatchReplication({
607
+ servers,
608
+ dbKey,
609
+ changes,
610
+ state,
611
+ preferredServerOrigin
612
+ });
613
+ return servers;
614
+ };
615
+ var scheduleUploadReplication = ({
616
+ currentServer,
617
+ syncServers,
618
+ tenantId,
619
+ uploadConfig,
620
+ state,
621
+ excludeServers = []
622
+ }) => {
623
+ const servers = resolveUploadReplicationServers({
624
+ currentServer,
625
+ syncServers,
626
+ tenantId,
627
+ uploadConfig,
628
+ state
629
+ });
630
+ const excluded = new Set(
631
+ excludeServers.filter((server) => typeof server === "string").map((server) => normalizeServerOrigin(server))
632
+ );
633
+ const remainingServers = servers.filter(
634
+ (server) => !excluded.has(normalizeServerOrigin(server))
635
+ );
636
+ if (remainingServers.length === 0) {
637
+ return [];
638
+ }
639
+ Promise.resolve().then(() => {
640
+ syncWithServers(
641
+ remainingServers,
642
+ noloUploadRequest,
643
+ `Upload sync failed for ${uploadConfig.customKey} on`,
644
+ uploadConfig,
645
+ state
646
+ );
647
+ });
648
+ return remainingServers;
649
+ };
650
+ var uploadToCurrentServer = async ({
651
+ currentServer,
652
+ uploadConfig,
653
+ state
654
+ }) => {
655
+ if (!currentServer) {
656
+ return false;
657
+ }
658
+ return noloUploadRequest(currentServer, uploadConfig, state);
659
+ };
660
+ var deleteFromReplicationServers = async ({
661
+ servers,
662
+ dbKey,
663
+ deleteOptions = { type: "single" },
664
+ state,
665
+ preferredServerOrigin
666
+ }) => {
667
+ if (!servers.length) {
668
+ return { succeeded: [], failed: [] };
669
+ }
670
+ const preferredServer = typeof preferredServerOrigin === "string" && preferredServerOrigin.trim().length > 0 ? normalizeServerOrigin(preferredServerOrigin) : null;
671
+ const remainingServers = preferredServer ? servers.filter((server) => normalizeServerOrigin(server) !== preferredServer) : servers;
672
+ const succeeded = [];
673
+ const failed = [];
674
+ if (preferredServer) {
675
+ const ok = await noloDeleteRequest(preferredServer, dbKey, deleteOptions, state);
676
+ if (ok) {
677
+ succeeded.push(preferredServer);
678
+ } else {
679
+ failed.push(preferredServer);
680
+ }
681
+ }
682
+ if (remainingServers.length > 0) {
683
+ const results = await Promise.all(
684
+ remainingServers.map(async (server) => ({
685
+ server,
686
+ ok: await noloDeleteRequest(server, dbKey, deleteOptions, state)
687
+ }))
688
+ );
689
+ results.forEach(({ server, ok }) => {
690
+ if (ok) succeeded.push(server);
691
+ else failed.push(server);
692
+ });
693
+ }
694
+ return { succeeded, failed };
695
+ };
696
+ var scheduleDeleteReplication = ({
697
+ currentServer,
698
+ syncServers,
699
+ preferredServerOrigin,
700
+ dbKey,
701
+ deleteOptions,
702
+ state,
703
+ onResult,
704
+ onError
705
+ }) => {
706
+ const servers = resolveAuthorityReplicationServers({
707
+ currentServer,
708
+ syncServers,
709
+ preferredServerOrigin,
710
+ dbKey,
711
+ state
712
+ });
713
+ if (servers.length === 0) {
714
+ return [];
715
+ }
716
+ void Promise.resolve().then(
717
+ () => deleteFromReplicationServers({
718
+ servers,
719
+ dbKey,
720
+ deleteOptions,
721
+ state,
722
+ preferredServerOrigin
723
+ })
724
+ ).then((result) => {
725
+ onResult?.(result);
726
+ }).catch((error) => {
727
+ onError?.(error);
728
+ });
729
+ return servers;
730
+ };
731
+
732
+ export {
733
+ selectRuntimeSnapshot,
734
+ selectRuntimeCurrentServer,
735
+ getRuntimeServerContext,
736
+ fnv1a32Hex,
737
+ parseOwnerUserIdFromDbKey,
738
+ DEVICE_LOCAL_OWNER_ID,
739
+ isDeviceLocalOwnerId,
740
+ resolveEffectiveSpaceActorId,
741
+ isDeviceLocalSpaceMembership,
742
+ isDeviceLocalSpaceBody,
743
+ resolveRecordOwnerUserId,
744
+ resolveRecordAuthority,
745
+ partitionReadServers,
746
+ compareRemoteRecordsByComparableTime,
747
+ pickBestSettledRemoteRecord,
748
+ shouldReplaceLocalWithRemoteRecord,
749
+ shouldReplicateLocalRecord,
750
+ planAuthorityReadServers,
751
+ resolveReplicationServers,
752
+ resolveAuthorityReplicationServers,
753
+ scheduleWriteReplication,
754
+ resolveUploadReplicationServers,
755
+ scheduleExistingRecordReplication,
756
+ scheduleConfiguredPatchReplication,
757
+ scheduleUploadReplication,
758
+ uploadToCurrentServer,
759
+ scheduleDeleteReplication
760
+ };