nolo-cli 0.54.0-alpha.2 → 0.61.0-alpha.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 (172) hide show
  1. package/README.md +3 -3
  2. package/{_executeModel-ANY4SIAS.js → _executeModel-CKT6RGTL.js} +58 -49
  3. package/{action-Q4W5JPI5.js → action-76JX3JX3.js} +9 -8
  4. package/{addContentAction-O25HFR37.js → addContentAction-V3NAZRTJ.js} +9 -7
  5. package/{addDialogAgentAction-GH7AUPPB.js → addDialogAgentAction-RZOAF46K.js} +11 -9
  6. package/{agentDeleteCommand-JWIKNWWI.js → agentDeleteCommand-VN7NPXQ4.js} +37 -32
  7. package/{agentEmailCommands-PL22BEU5.js → agentEmailCommands-F2TNAV4A.js} +73 -65
  8. package/{agentGrantCommands-2LEZDADN.js → agentGrantCommands-R3VQEZJR.js} +1 -1
  9. package/{agentListCommands-6NR7AQEK.js → agentListCommands-OSM2ANI3.js} +78 -39
  10. package/{agentMachineCommands-TASPU6OA.js → agentMachineCommands-MTPWYVRV.js} +38 -33
  11. package/{agentPullCommand-M552CYSI.js → agentPullCommand-N7L2CT7L.js} +2 -2
  12. package/agentRecordCommands-VWAWTVVC.js +122 -0
  13. package/agentRunCommand-PLZOBNVK.js +149 -0
  14. package/{agentRunControl-4GHHSXFZ.js → agentRunControl-WECMOO6O.js} +13 -6
  15. package/{agentRuntimeLocal-PCJJ56J2.js → agentRuntimeLocal-XCJLRWQE.js} +35 -28
  16. package/{agentSlice-KYLDUSNN.js → agentSlice-F6DOP4IW.js} +10 -9
  17. package/{appDeleteCommands-WLHMJAVT.js → appDeleteCommands-3BCFTRFJ.js} +37 -32
  18. package/{appDeployCommands-CKON7N2E.js → appDeployCommands-B4GMHCYA.js} +37 -32
  19. package/{appDeployStatusCommands-PXRLDASH.js → appDeployStatusCommands-4MN36WIG.js} +37 -32
  20. package/{appGetCommands-RAB5RM4M.js → appGetCommands-4GJIEUAX.js} +37 -32
  21. package/{appListCommands-GU57FB62.js → appListCommands-CHU53GSX.js} +37 -32
  22. package/{authCommand-QOPOEYEK.js → authCommand-WOTWLJNF.js} +38 -32
  23. package/{authCommands-SBQVTD6V.js → authCommands-ILTBI6JV.js} +8 -6
  24. package/{chatQueueReduxAdapter-5O2WLITN.js → chatQueueReduxAdapter-HNSQXNIR.js} +29 -24
  25. package/{chunk-WL3UOGYO.js → chunk-22BTGNSP.js} +151 -155
  26. package/{chunk-7CH6U3FL.js → chunk-2GRGFCF6.js} +2 -4
  27. package/{chunk-V4KZGLOI.js → chunk-2HPRMEEZ.js} +3059 -1079
  28. package/{chunk-UNZDCI3O.js → chunk-2KDR4CWE.js} +35 -4
  29. package/{chunk-VRZIH5JO.js → chunk-2PGGC63K.js} +1 -1
  30. package/{chunk-T27IEBNQ.js → chunk-2QDDKFG5.js} +74 -1
  31. package/{chunk-7K5VMB4Q.js → chunk-37QVS7BU.js} +21 -8
  32. package/{chunk-UITMHBVK.js → chunk-37XDGCY7.js} +1 -1
  33. package/chunk-3BLB7QKO.js +433 -0
  34. package/{chunk-NQ4N4IGO.js → chunk-3JQ2NRYU.js} +33 -10
  35. package/{chunk-UW4INMD2.js → chunk-3JWKQDA4.js} +2 -2
  36. package/{chunk-IKTHA3JH.js → chunk-3QGUVVX5.js} +2 -2
  37. package/{chunk-WHVQA7PJ.js → chunk-45YO6H7P.js} +97 -35
  38. package/chunk-4C4ST2YE.js +20015 -0
  39. package/{chunk-32I5RVMY.js → chunk-4NJEIGBQ.js} +5 -5
  40. package/{chunk-KUUTWU4I.js → chunk-5ZYA4JJ3.js} +90 -22
  41. package/chunk-6YTOJY35.js +352 -0
  42. package/{chunk-INXBNYCG.js → chunk-7A3RRUCQ.js} +155 -12
  43. package/{chunk-GV35EHNA.js → chunk-7O7KH4X5.js} +1262 -971
  44. package/{chunk-Y7LNKP32.js → chunk-7UF7CQ6B.js} +4 -6
  45. package/{chunk-2BWU4ORW.js → chunk-AQMVUA7N.js} +2 -1
  46. package/{chunk-LA4IDAK7.js → chunk-AVE2YR4F.js} +1056 -3591
  47. package/{chunk-TI5BCZCH.js → chunk-B7DXRX7F.js} +59 -121
  48. package/chunk-BFU6C242.js +66 -0
  49. package/{chunk-FA4SY4F5.js → chunk-BYEJ7K2Z.js} +1 -1
  50. package/chunk-BYXBJQAS.js +0 -0
  51. package/{chunk-IA3A5373.js → chunk-C3FZR5EC.js} +1 -1
  52. package/{chunk-IWUMSAQF.js → chunk-CJCJF5XB.js} +26 -3
  53. package/{chunk-PAHILFNT.js → chunk-CP7VIDZ7.js} +4 -4
  54. package/{chunk-OYNDYVSE.js → chunk-CTCW7U7N.js} +1 -1
  55. package/{chunk-BJLYCOZK.js → chunk-D5XKNNUV.js} +135 -795
  56. package/{chunk-AV6KQCM5.js → chunk-DNNSCSA2.js} +19 -14
  57. package/{chunk-3AOLVADY.js → chunk-DVINR3PL.js} +1 -1
  58. package/{chunk-NI2BS6UD.js → chunk-DWUCB2A3.js} +1 -1
  59. package/{chunk-AA564GBL.js → chunk-DZZL7UBV.js} +1 -1
  60. package/{chunk-6FGXGFAH.js → chunk-E6RGHPDR.js} +6 -4
  61. package/chunk-EDKF7RX4.js +30 -0
  62. package/{chunk-6SZ52ORL.js → chunk-ES6CVKVD.js} +24 -30
  63. package/{chunk-DQLYEGP7.js → chunk-FHAGENAS.js} +3 -4
  64. package/{chunk-56W233KG.js → chunk-FKFMIBTT.js} +5 -1
  65. package/{chunk-INZZJSQF.js → chunk-FZGV4FGK.js} +24 -12
  66. package/{chunk-D3JQPONH.js → chunk-GAL47RNP.js} +1 -1
  67. package/{chunk-6FQ2552G.js → chunk-HBPV76EK.js} +1085 -1150
  68. package/{chunk-LN3OQJGG.js → chunk-HLU5Q2GV.js} +4 -4
  69. package/{chunk-U2A47SVI.js → chunk-HQP7HJDL.js} +7 -7
  70. package/{chunk-H2G6JXTR.js → chunk-HQUORJTM.js} +1 -1
  71. package/{chunk-3Z3DXZBD.js → chunk-IYCUMIYS.js} +24 -20
  72. package/{chunk-7APQB6R6.js → chunk-JX5PJCWS.js} +8 -6
  73. package/{chunk-LYGNQHUW.js → chunk-JYYZCK2Z.js} +2 -4
  74. package/{chunk-PYKV6FSC.js → chunk-KWSQR2KK.js} +16 -31
  75. package/{chunk-VULELK4T.js → chunk-L7B47JXR.js} +37 -64
  76. package/{chunk-4NN3EK7H.js → chunk-LAFC3B2I.js} +1 -1
  77. package/{chunk-VRJUIUIY.js → chunk-LJKICKVC.js} +2 -2
  78. package/chunk-M3JEW6N6.js +193 -0
  79. package/chunk-MBOEV4L2.js +301 -0
  80. package/{chunk-QDHZCAH3.js → chunk-MMZ6ZTVO.js} +229 -74
  81. package/{chunk-JDSUTNYY.js → chunk-MP64VFGD.js} +2 -2
  82. package/{chunk-U5Z7LFZF.js → chunk-MXUDQZXQ.js} +47 -8
  83. package/chunk-N4G4PKQ6.js +23 -0
  84. package/{chunk-SVEUG45B.js → chunk-NHRQCXIQ.js} +0 -24
  85. package/{chunk-KXKQO4Q6.js → chunk-NTW5GWDM.js} +58 -1
  86. package/chunk-ONXOABJR.js +215 -0
  87. package/{chunk-BANYWEYY.js → chunk-OZX2IPKM.js} +8 -3
  88. package/{chunk-Q24S4NDF.js → chunk-P7OOB7QP.js} +1 -1
  89. package/{chunk-GLGD2JGY.js → chunk-PEZJEQAO.js} +7 -7
  90. package/{chunk-GBADO3SM.js → chunk-PQDIDWGX.js} +1 -1
  91. package/chunk-PSCNXBYA.js +11 -0
  92. package/chunk-QEFJJS2I.js +508 -0
  93. package/{chunk-757BGY6Y.js → chunk-QEW2MFDQ.js} +1 -1
  94. package/{chunk-SP3DPVBH.js → chunk-RDBARW6T.js} +8 -3
  95. package/{chunk-TNPCQNGQ.js → chunk-RJ2SAFB5.js} +83 -41
  96. package/{chunk-FGEYVPPR.js → chunk-RVWRKFUB.js} +8 -65
  97. package/{chunk-43CXXVJD.js → chunk-RXX4GDIH.js} +1 -1
  98. package/chunk-SEJ5OS6F.js +49 -0
  99. package/{chunk-MFI4FGHX.js → chunk-SOJM57FX.js} +5 -2
  100. package/{chunk-EKLRRZIN.js → chunk-SPAQ4PVV.js} +0 -5
  101. package/{chunk-L7NG2M6H.js → chunk-TRV2MIDW.js} +89 -74
  102. package/chunk-UAD2WT54.js +64 -0
  103. package/{chunk-RTLJUGQH.js → chunk-UZPQSVM6.js} +2 -2
  104. package/{chunk-3QJTD6DO.js → chunk-VMWYBIXG.js} +9 -7
  105. package/{chunk-ZHXJ6M7T.js → chunk-W7XHHYWM.js} +4 -0
  106. package/{chunk-5WADL4O7.js → chunk-XAVSS3KE.js} +21 -3
  107. package/{chunk-CVT7L2WZ.js → chunk-XOKOSO35.js} +13 -22
  108. package/{chunk-6BYAXNH5.js → chunk-XTJTN3RW.js} +57 -4
  109. package/{chunk-T5HJEUQN.js → chunk-YCDWJX45.js} +1 -1
  110. package/{chunk-MRWGHF56.js → chunk-YDH3FDFQ.js} +12 -356
  111. package/{chunk-H4RYESI6.js → chunk-Z4QSJILV.js} +85 -13
  112. package/chunk-ZJ7UHBJS.js +89 -0
  113. package/{chunk-O5FLGN2L.js → chunk-ZRSJ3JEH.js} +6 -2
  114. package/{cliExecutor-BBUVQU4L.js → cliExecutor-HG3S345O.js} +1 -1
  115. package/{codingSkills-BCQXRZOI.js → codingSkills-VDXQYWX4.js} +2 -2
  116. package/contentThunks-7YG2ZYQC.js +73 -0
  117. package/{cooldownCommands-GI5NNWGL.js → cooldownCommands-BSCH2W7P.js} +2 -2
  118. package/{createAgentAutomationAction-UJLNFFFC.js → createAgentAutomationAction-PJQSCAIO.js} +32 -26
  119. package/createDialogAction-SFEJX6SP.js +64 -0
  120. package/{createPageAction-N3IYABHV.js → createPageAction-B7WRHOQO.js} +35 -28
  121. package/{dbSlice-D5CNGWPD.js → dbSlice-IBVOBVMS.js} +7 -6
  122. package/{deleteFile-44TUM34Y.js → deleteFile-FWP2PSBG.js} +4 -3
  123. package/{dialogCommands-35M6RBAC.js → dialogCommands-VL2X22QC.js} +38 -33
  124. package/{dialogSlice-KO7ADD7H.js → dialogSlice-ANMACABO.js} +29 -24
  125. package/{docCreateCommands-VXHZWQ3P.js → docCreateCommands-ITLGZ5YI.js} +40 -35
  126. package/{docDeleteCommands-4WFAJR6A.js → docDeleteCommands-LH3YNL4C.js} +37 -32
  127. package/{docReadCommands-OYREEFAR.js → docReadCommands-YAJ77F36.js} +36 -31
  128. package/{docStore-5BU76DFK.js → docStore-D4HGHPWI.js} +9 -33
  129. package/{docUpdateCommands-A7QERSME.js → docUpdateCommands-DQBOMH2G.js} +40 -35
  130. package/{fetchMessages-KZQVBXKY.js → fetchMessages-DRABNDPZ.js} +3 -3
  131. package/{getPricing-HAU62AFM.js → getPricing-NM3NUTAS.js} +5 -5
  132. package/handleSendMessageAction-DF2OABGW.js +675 -0
  133. package/index.js +79 -88
  134. package/{lib-2ZTNRXR4.js → lib-FRRS27KN.js} +63 -28
  135. package/{localDialogRead-NQ33HBSI.js → localDialogRead-PUQKFI73.js} +1 -1
  136. package/{localRuntimeAuthority-KQDAE64E.js → localRuntimeAuthority-R5UBODT3.js} +6 -4
  137. package/{localRuntimeDb-PF7CFKDL.js → localRuntimeDb-P37ZTX55.js} +1 -1
  138. package/{machineCommands-J43U3TX5.js → machineCommands-JXDYQ5LB.js} +309 -87
  139. package/{machineWsRunDispatch-Z2Z6STXZ.js → machineWsRunDispatch-3QHI7JX5.js} +67 -59
  140. package/memberThunks-VZI6G7YZ.js +640 -0
  141. package/{models-4QF4BJVY.js → models-FAMINFZ7.js} +2 -2
  142. package/package.json +3 -2
  143. package/{read-RGNPI5H2.js → read-2BYWW7AA.js} +4 -3
  144. package/{readDocTool-6ESWKTXD.js → readDocTool-LC3A7QTB.js} +1 -1
  145. package/{readlineWorkspace-YRPV6JPN.js → readlineWorkspace-KVZTEAHB.js} +4609 -2698
  146. package/{removeDialogAgentAction-JYT73FU2.js → removeDialogAgentAction-SFYZXHNK.js} +14 -12
  147. package/{runAgentClientLoop-5YM5WMAY.js → runAgentClientLoop-KGTEL7ZP.js} +60 -50
  148. package/{runtimeDoctorCommands-JKTTN723.js → runtimeDoctorCommands-CROTMULY.js} +7 -5
  149. package/{setDialogExtraReferencesAction-D564LMYQ.js → setDialogExtraReferencesAction-Q32RGFTA.js} +10 -8
  150. package/{setPrimaryDialogAgentAction-ACY3BLYA.js → setPrimaryDialogAgentAction-BFYJHUJS.js} +14 -12
  151. package/{settingSlice-MKI3MNZJ.js → settingSlice-IRUU4VFB.js} +8 -7
  152. package/{skillDiscovery-GPUDHDTZ.js → skillDiscovery-NTRLM6KP.js} +3 -3
  153. package/{spaceCommands-MY26V52L.js → spaceCommands-KNAYWMCZ.js} +40 -220
  154. package/{streamAgentChatTurn-XV5X5TNQ.js → streamAgentChatTurn-FLYPTXKZ.js} +140 -95
  155. package/{switchDialogAgentAction-CJ5H6SAR.js → switchDialogAgentAction-L2KOKCGG.js} +11 -9
  156. package/{tableCommands-R6WFRDYF.js → tableCommands-SUNTHAYX.js} +1 -1
  157. package/{toolApiClient-B2MFXMEG.js → toolApiClient-VGYUB4P5.js} +4 -2
  158. package/{tools-MIMELA2Y.js → tools-CVLUXK6P.js} +46 -38
  159. package/{tuiSummaryLlmCaller-XJ5BKNNS.js → tuiSummaryLlmCaller-F3DPFFZM.js} +20 -16
  160. package/{updateCommands-IYKLF3JX.js → updateCommands-AJYSD73Y.js} +2 -2
  161. package/{updateDialogTitleAction-EIZUSWHR.js → updateDialogTitleAction-HWJIZEIV.js} +33 -27
  162. package/agentRecordCommands-Z64TA63M.js +0 -114
  163. package/agentRunCommand-4QJQLPRW.js +0 -134
  164. package/agentSuperviseCommands-VB6BUS5H.js +0 -640
  165. package/chunk-6BGAQ3KR.js +0 -7081
  166. package/chunk-FD36SCCD.js +0 -105
  167. package/chunk-J3UALFHL.js +0 -370
  168. package/chunk-RU5D3B22.js +0 -230
  169. package/chunk-YBV6QJKM.js +0 -441
  170. package/createDialogAction-TJCX6GUE.js +0 -58
  171. package/handleSendMessageAction-OSGQJQ45.js +0 -406
  172. package/spaceSlice-JUIXC365.js +0 -127
@@ -0,0 +1,640 @@
1
+ import {
2
+ appendRecoveredMemberships,
3
+ fetchRemoteSpace,
4
+ fetchRemoteUserSpaceMemberships,
5
+ getMemberSpaces,
6
+ hydrateMemberSpacesFromLocal,
7
+ membershipBelongsToUser,
8
+ selectSpaceRemoteAuth,
9
+ setMemberSpaces,
10
+ setMembershipLoading,
11
+ setMembershipRejected,
12
+ spaceListsUser
13
+ } from "./chunk-MBOEV4L2.js";
14
+ import {
15
+ getCurrentSpaceIdRaw,
16
+ updateCurrentSpaceIfMatch
17
+ } from "./chunk-ZJ7UHBJS.js";
18
+ import "./chunk-YDH3FDFQ.js";
19
+ import "./chunk-BYXBJQAS.js";
20
+ import {
21
+ createSpaceKey,
22
+ normalizeSpaceId
23
+ } from "./chunk-UAD2WT54.js";
24
+ import {
25
+ read,
26
+ remove,
27
+ write
28
+ } from "./chunk-DNNSCSA2.js";
29
+ import {
30
+ DB_PREFIX
31
+ } from "./chunk-NHRQCXIQ.js";
32
+ import "./chunk-WWC7I6TA.js";
33
+ import "./chunk-I42VC5KR.js";
34
+ import "./chunk-SOJM57FX.js";
35
+ import "./chunk-QSJ3HFEF.js";
36
+ import {
37
+ readAction
38
+ } from "./chunk-L7B47JXR.js";
39
+ import "./chunk-BJIRLHJR.js";
40
+ import {
41
+ DEVICE_LOCAL_OWNER_ID,
42
+ createAsyncThunk,
43
+ isDeviceLocalOwnerId,
44
+ isDeviceLocalSpaceMembership
45
+ } from "./chunk-KWSQR2KK.js";
46
+ import {
47
+ logger
48
+ } from "./chunk-QOKAKDPE.js";
49
+ import "./chunk-OW765XBU.js";
50
+ import {
51
+ selectIdentityUserId
52
+ } from "./chunk-SEJ5OS6F.js";
53
+ import {
54
+ isTombstoneRecord
55
+ } from "./chunk-GBRG75BQ.js";
56
+ import {
57
+ asTrimmedString
58
+ } from "./chunk-3EUW3WEO.js";
59
+ import "./chunk-U6VC4MU4.js";
60
+ import "./chunk-KUG52IAP.js";
61
+ import {
62
+ API_ENDPOINTS
63
+ } from "./chunk-LCBAMY2M.js";
64
+ import "./chunk-4SN6J65J.js";
65
+ import "./chunk-CF7PE763.js";
66
+ import "./chunk-G3SUCT4W.js";
67
+ import "./chunk-4VNS5WPM.js";
68
+
69
+ // packages/create/space/member/isSpaceMembershipRemoteUnavailableError.ts
70
+ var SPACE_MEMBERSHIP_REMOTE_UNAVAILABLE = "space_membership_remote_unavailable";
71
+ var isSpaceMembershipRemoteUnavailableError = (error) => {
72
+ if (typeof error === "string") {
73
+ return error.includes(SPACE_MEMBERSHIP_REMOTE_UNAVAILABLE);
74
+ }
75
+ if (error instanceof Error) {
76
+ return error.message.includes(SPACE_MEMBERSHIP_REMOTE_UNAVAILABLE);
77
+ }
78
+ if (error && typeof error === "object" && "message" in error && typeof error.message === "string") {
79
+ return error.message.includes(
80
+ SPACE_MEMBERSHIP_REMOTE_UNAVAILABLE
81
+ );
82
+ }
83
+ return false;
84
+ };
85
+
86
+ // packages/create/space/member/fetchUserSpaceMembershipsAction.ts
87
+ var CONTENT_SPACE_RECOVERY_TYPES = [
88
+ "app" /* APP */,
89
+ "page" /* DOC */,
90
+ "dialog" /* DIALOG */,
91
+ "image" /* IMAGE */,
92
+ "file" /* FILE */,
93
+ "table" /* TABLE */,
94
+ "agent" /* AGENT */
95
+ ];
96
+ var readLocalSpaceData = async (db, spaceId) => {
97
+ const normalizedSpaceId = normalizeSpaceId(spaceId);
98
+ const spaceKey = createSpaceKey.space(normalizedSpaceId);
99
+ try {
100
+ return await db.get(spaceKey) ?? null;
101
+ } catch {
102
+ return null;
103
+ }
104
+ };
105
+ var membershipCheckUserId = (membership, activeUserId) => isDeviceLocalSpaceMembership(membership) ? DEVICE_LOCAL_OWNER_ID : activeUserId;
106
+ var buildLocalMembershipPreview = async (userId, db, memberships) => {
107
+ const preview = await Promise.all(
108
+ memberships.map(async (membership) => {
109
+ if (isTombstoneRecord(membership)) return null;
110
+ const checkUserId = membershipCheckUserId(membership, userId);
111
+ if (!membershipBelongsToUser(membership, checkUserId)) return null;
112
+ const normalizedSpaceId = normalizeSpaceId(membership.spaceId);
113
+ const localSpaceData = await readLocalSpaceData(db, normalizedSpaceId);
114
+ if (!localSpaceData || isTombstoneRecord(localSpaceData)) return null;
115
+ if (!spaceListsUser(localSpaceData, checkUserId)) return null;
116
+ return {
117
+ ...membership,
118
+ spaceId: normalizedSpaceId
119
+ };
120
+ })
121
+ );
122
+ return preview.filter(
123
+ (membership) => !!membership
124
+ );
125
+ };
126
+ var fetchLocalForUser = async (userId, db) => {
127
+ try {
128
+ const memberships = [];
129
+ const prefix = `space-member-${userId}`;
130
+ let iterator = db.iterator({
131
+ gte: prefix,
132
+ lte: prefix + "\xFF"
133
+ });
134
+ if (iterator && typeof iterator.then === "function") {
135
+ iterator = await iterator;
136
+ }
137
+ for await (const [_, memberData] of iterator) {
138
+ if (memberData && typeof memberData === "object" && memberData.spaceId && !isTombstoneRecord(memberData)) {
139
+ memberships.push(memberData);
140
+ }
141
+ }
142
+ return memberships;
143
+ } catch (error) {
144
+ console.error("Error fetching local memberships:", error);
145
+ return [];
146
+ }
147
+ };
148
+ var fetchLocalUnion = async (userId, db) => {
149
+ const deviceLocalRows = await fetchLocalForUser(DEVICE_LOCAL_OWNER_ID, db);
150
+ const taggedLocal = deviceLocalRows.map(
151
+ (membership) => ({
152
+ ...membership,
153
+ spaceId: normalizeSpaceId(membership.spaceId),
154
+ deviceLocal: true,
155
+ userId: membership.userId || DEVICE_LOCAL_OWNER_ID
156
+ })
157
+ );
158
+ if (isDeviceLocalOwnerId(userId)) {
159
+ return taggedLocal;
160
+ }
161
+ const accountRows = await fetchLocalForUser(userId, db);
162
+ const taggedAccount = accountRows.map(
163
+ (membership) => ({
164
+ ...membership,
165
+ spaceId: normalizeSpaceId(membership.spaceId),
166
+ deviceLocal: false
167
+ })
168
+ );
169
+ return [...taggedLocal, ...taggedAccount];
170
+ };
171
+ var fetchRemoteContentSpaceIds = async (server, userId, token) => {
172
+ try {
173
+ const queryParams = new URLSearchParams({ limit: "200" });
174
+ const headers = {
175
+ "Content-Type": "application/json"
176
+ };
177
+ const authToken = asTrimmedString(token);
178
+ if (authToken) {
179
+ headers.Authorization = `Bearer ${authToken}`;
180
+ }
181
+ const response = await fetch(
182
+ `${server}${API_ENDPOINTS.DATABASE}/query/${encodeURIComponent(userId)}?${queryParams}`,
183
+ {
184
+ method: "POST",
185
+ headers,
186
+ body: JSON.stringify({
187
+ type: [...CONTENT_SPACE_RECOVERY_TYPES],
188
+ includeDeleted: true,
189
+ summary: true
190
+ })
191
+ }
192
+ );
193
+ if (!response.ok) return [];
194
+ const data = await response.json();
195
+ const records = Array.isArray(data?.data?.data) ? data.data.data : [];
196
+ return records.filter((record) => !isTombstoneRecord(record)).map(
197
+ (record) => typeof record?.spaceId === "string" ? normalizeSpaceId(record.spaceId) : ""
198
+ ).filter((spaceId) => spaceId.length > 0);
199
+ } catch {
200
+ return [];
201
+ }
202
+ };
203
+ var recoverMembershipsFromContentSpaces = async ({
204
+ servers,
205
+ token,
206
+ userId,
207
+ knownSpaceIds
208
+ }) => {
209
+ const candidateSpaceIds = /* @__PURE__ */ new Set();
210
+ await Promise.all(
211
+ servers.map(async (server) => {
212
+ const spaceIds = await fetchRemoteContentSpaceIds(server, userId, token);
213
+ spaceIds.forEach((spaceId) => {
214
+ if (!knownSpaceIds.has(spaceId)) {
215
+ candidateSpaceIds.add(spaceId);
216
+ }
217
+ });
218
+ })
219
+ );
220
+ const results = await Promise.all(
221
+ [...candidateSpaceIds].map(async (spaceId) => {
222
+ try {
223
+ for (const server of servers) {
224
+ const remoteSpace = await fetchRemoteSpace(server, token, spaceId);
225
+ if (!spaceListsUser(remoteSpace, userId)) continue;
226
+ return {
227
+ userId,
228
+ spaceId,
229
+ spaceName: typeof remoteSpace?.name === "string" && remoteSpace.name.trim() ? remoteSpace.name : spaceId,
230
+ role: remoteSpace?.ownerId === userId ? "owner" /* OWNER */ : "member" /* MEMBER */,
231
+ joinedAt: remoteSpace?.updatedAt ?? remoteSpace?.createdAt ?? Date.now(),
232
+ sourceServer: server
233
+ };
234
+ }
235
+ } catch {
236
+ }
237
+ return null;
238
+ })
239
+ );
240
+ const recovered = results.filter(
241
+ (m) => m !== null
242
+ );
243
+ return recovered;
244
+ };
245
+ var fetchUserSpaceMembershipsAction = async (userId, thunkAPI) => {
246
+ const state = thunkAPI.getState();
247
+ const db = thunkAPI.extra.db;
248
+ const { token, servers } = selectSpaceRemoteAuth(state);
249
+ const isLocalActor = isDeviceLocalOwnerId(userId);
250
+ const localMembershipsPromise = fetchLocalUnion(userId, db);
251
+ const remoteResultsPromise = isLocalActor ? Promise.resolve([]) : Promise.all(
252
+ servers.map(
253
+ (server) => fetchRemoteUserSpaceMemberships(server, token, userId)
254
+ )
255
+ );
256
+ const localMemberships = await localMembershipsPromise;
257
+ if (getMemberSpaces() === null && localMemberships.length > 0) {
258
+ const localPreview = await buildLocalMembershipPreview(
259
+ userId,
260
+ db,
261
+ localMemberships
262
+ );
263
+ if (localPreview.length > 0) {
264
+ hydrateMemberSpacesFromLocal(localPreview);
265
+ }
266
+ }
267
+ const remoteResults = await remoteResultsPromise;
268
+ const successfulRemoteResults = remoteResults.filter((result) => result.ok);
269
+ const successfulRemoteMemberships = successfulRemoteResults.flatMap(
270
+ (result) => result.memberships.map((membership) => ({
271
+ ...membership,
272
+ sourceServer: result.server
273
+ }))
274
+ );
275
+ const hasSuccessfulRemoteFetch = successfulRemoteResults.length > 0;
276
+ const hasRemoteAuthority = !isLocalActor && !!token && servers.length > 0;
277
+ if (hasRemoteAuthority && !hasSuccessfulRemoteFetch) {
278
+ throw new Error(
279
+ `${SPACE_MEMBERSHIP_REMOTE_UNAVAILABLE}: unable to refresh memberships from ${servers.join(", ")}`
280
+ );
281
+ }
282
+ const remoteSpaceIds = new Set(
283
+ successfulRemoteMemberships.map(
284
+ (membership) => normalizeSpaceId(membership.spaceId)
285
+ )
286
+ );
287
+ const filteredLocalMemberships = hasSuccessfulRemoteFetch ? (await Promise.all(
288
+ localMemberships.map(async (membership) => {
289
+ const normalizedSpaceId = normalizeSpaceId(membership.spaceId);
290
+ if (membership.deviceLocal || isDeviceLocalSpaceMembership(membership)) {
291
+ return {
292
+ ...membership,
293
+ spaceId: normalizedSpaceId,
294
+ deviceLocal: true
295
+ };
296
+ }
297
+ if (remoteSpaceIds.has(normalizedSpaceId)) {
298
+ return {
299
+ ...membership,
300
+ spaceId: normalizedSpaceId
301
+ };
302
+ }
303
+ console.warn(
304
+ `[SpaceMembership] Membership missing from remote index, verifying space record: user=${userId}, spaceId=${normalizedSpaceId}`
305
+ );
306
+ return {
307
+ ...membership,
308
+ spaceId: normalizedSpaceId,
309
+ requiresRemoteSpaceVerification: true
310
+ };
311
+ })
312
+ )).filter((membership) => !!membership) : localMemberships.map((membership) => ({
313
+ ...membership,
314
+ spaceId: normalizeSpaceId(membership.spaceId)
315
+ }));
316
+ const verifyActiveSpaceMembership = async (membership) => {
317
+ if (isTombstoneRecord(membership)) return null;
318
+ const checkUserId = membershipCheckUserId(membership, userId);
319
+ if (!membershipBelongsToUser(membership, checkUserId)) return null;
320
+ const normalizedSpaceId = normalizeSpaceId(membership.spaceId);
321
+ const localSpaceData = await readLocalSpaceData(db, normalizedSpaceId);
322
+ const isDeviceLocal = membership.deviceLocal || isDeviceLocalSpaceMembership(membership);
323
+ if (isDeviceLocal) {
324
+ if (!localSpaceData || isTombstoneRecord(localSpaceData)) return null;
325
+ if (!spaceListsUser(localSpaceData, checkUserId)) {
326
+ return null;
327
+ }
328
+ const {
329
+ sourceServer: _s,
330
+ requiresRemoteSpaceVerification: _r,
331
+ deviceLocal: _d,
332
+ ...visible
333
+ } = membership;
334
+ return {
335
+ ...visible,
336
+ spaceId: normalizedSpaceId,
337
+ userId: DEVICE_LOCAL_OWNER_ID
338
+ };
339
+ }
340
+ if (membership.sourceServer || membership.requiresRemoteSpaceVerification) {
341
+ if (localSpaceData && isTombstoneRecord(localSpaceData)) return null;
342
+ if (membership.sourceServer && !membership.requiresRemoteSpaceVerification) {
343
+ const { sourceServer: _ss, ...verifiedMembership } = membership;
344
+ return {
345
+ ...verifiedMembership,
346
+ spaceId: normalizedSpaceId
347
+ };
348
+ }
349
+ try {
350
+ const remoteSpaceServers = Array.from(
351
+ new Set(
352
+ [membership.sourceServer, ...servers].filter(
353
+ (server) => typeof server === "string" && server.length > 0
354
+ )
355
+ )
356
+ );
357
+ let remoteSpace = null;
358
+ for (const server of remoteSpaceServers) {
359
+ remoteSpace = await fetchRemoteSpace(
360
+ server,
361
+ token,
362
+ normalizedSpaceId
363
+ );
364
+ if (remoteSpace) break;
365
+ }
366
+ if (!spaceListsUser(remoteSpace, userId)) return null;
367
+ const {
368
+ requiresRemoteSpaceVerification,
369
+ deviceLocal: _dl,
370
+ ...verifiedMembership
371
+ } = membership;
372
+ return {
373
+ ...verifiedMembership,
374
+ spaceId: normalizedSpaceId
375
+ };
376
+ } catch {
377
+ return null;
378
+ }
379
+ }
380
+ if (localSpaceData) {
381
+ return !spaceListsUser(localSpaceData, userId) ? null : {
382
+ ...membership,
383
+ spaceId: normalizedSpaceId
384
+ };
385
+ }
386
+ if (!membership.sourceServer && servers.length === 0) {
387
+ return {
388
+ ...membership,
389
+ spaceId: normalizedSpaceId
390
+ };
391
+ }
392
+ try {
393
+ const remoteSpace = await readAction(
394
+ {
395
+ dbKey: createSpaceKey.space(normalizedSpaceId),
396
+ preferredServerOrigin: membership.sourceServer
397
+ },
398
+ thunkAPI
399
+ );
400
+ if (!spaceListsUser(remoteSpace, userId)) return null;
401
+ return {
402
+ ...membership,
403
+ spaceId: normalizedSpaceId
404
+ };
405
+ } catch {
406
+ return null;
407
+ }
408
+ };
409
+ const activeMemberships = (await Promise.all(
410
+ [...filteredLocalMemberships, ...successfulRemoteMemberships].map(
411
+ verifyActiveSpaceMembership
412
+ )
413
+ )).filter((membership) => !!membership);
414
+ const knownSpaceIds = new Set(
415
+ [
416
+ ...filteredLocalMemberships,
417
+ ...successfulRemoteMemberships,
418
+ ...activeMemberships
419
+ ].map((membership) => normalizeSpaceId(membership.spaceId))
420
+ );
421
+ if (hasRemoteAuthority && hasSuccessfulRemoteFetch && !isLocalActor) {
422
+ void recoverMembershipsFromContentSpaces({
423
+ servers,
424
+ token,
425
+ userId,
426
+ knownSpaceIds
427
+ }).then((rawRecovered) => {
428
+ const activeUserId = selectIdentityUserId(thunkAPI.getState()) ?? null;
429
+ if (activeUserId !== userId) return;
430
+ if (rawRecovered.length === 0) return;
431
+ const cleaned = rawRecovered.map((membership) => {
432
+ const {
433
+ sourceServer: _ss,
434
+ requiresRemoteSpaceVerification: _rv,
435
+ deviceLocal: _dl,
436
+ ...visible
437
+ } = membership;
438
+ return { ...visible, spaceId: normalizeSpaceId(membership.spaceId) };
439
+ });
440
+ appendRecoveredMemberships(cleaned);
441
+ }).catch(() => {
442
+ });
443
+ }
444
+ const membershipMap = /* @__PURE__ */ new Map();
445
+ const preferAccountOnCollision = (existing, next) => {
446
+ if (!existing) return next;
447
+ const existingLocal = isDeviceLocalSpaceMembership(existing);
448
+ const nextLocal = isDeviceLocalSpaceMembership(next);
449
+ if (existingLocal && !nextLocal) return next;
450
+ if (!existingLocal && nextLocal) return existing;
451
+ return next;
452
+ };
453
+ [...activeMemberships].forEach((membership) => {
454
+ const normalizedSpaceId = normalizeSpaceId(membership.spaceId);
455
+ const {
456
+ sourceServer: _sourceServer,
457
+ requiresRemoteSpaceVerification: _req,
458
+ deviceLocal: _deviceLocal,
459
+ ...visibleMembership
460
+ } = membership;
461
+ const cleaned = {
462
+ ...visibleMembership,
463
+ spaceId: normalizedSpaceId
464
+ };
465
+ const existing = membershipMap.get(normalizedSpaceId);
466
+ membershipMap.set(
467
+ normalizedSpaceId,
468
+ preferAccountOnCollision(existing, cleaned)
469
+ );
470
+ });
471
+ const finalMemberships = Array.from(membershipMap.values()).sort(
472
+ (a, b) => (b.joinedAt || 0) - (a.joinedAt || 0)
473
+ );
474
+ return finalMemberships;
475
+ };
476
+
477
+ // packages/database/thunkApiTypes.ts
478
+ var dbThunkState = (thunkApi) => thunkApi.getState();
479
+ var dbThunkExtra = (thunkApi) => thunkApi.extra;
480
+
481
+ // packages/create/space/member/addMemberAction.ts
482
+ var addMemberAction = async (input, thunkAPI) => {
483
+ const { spaceId, memberId, role = "member" /* MEMBER */ } = input;
484
+ const { dispatch } = thunkAPI;
485
+ const state = dbThunkState(thunkAPI);
486
+ const currentUserId = selectIdentityUserId(state);
487
+ const { db } = dbThunkExtra(thunkAPI);
488
+ const resolvedMemberId = db ? await resolveMemberId(db, memberId) : memberId.trim();
489
+ const spaceKey = createSpaceKey.space(spaceId);
490
+ const spaceData = await dispatch(read({
491
+ dbKey: spaceKey
492
+ })).unwrap();
493
+ if (!spaceData) {
494
+ throw new Error("Space not found");
495
+ }
496
+ if (!currentUserId) {
497
+ throw new Error("User is not logged in.");
498
+ }
499
+ if (!spaceData.members.includes(currentUserId)) {
500
+ throw new Error("\u5F53\u524D\u7528\u6237\u4E0D\u662F\u7A7A\u95F4\u6210\u5458\uFF0C\u65E0\u6CD5\u6DFB\u52A0\u6210\u5458");
501
+ }
502
+ if (spaceData.members.includes(resolvedMemberId)) {
503
+ throw new Error("\u6210\u5458\u5DF2\u5B58\u5728");
504
+ }
505
+ const updatedSpaceData = {
506
+ ...spaceData,
507
+ members: [...spaceData.members, resolvedMemberId],
508
+ updatedAt: Date.now()
509
+ };
510
+ await dispatch(
511
+ write({ data: updatedSpaceData, customKey: spaceKey })
512
+ ).unwrap();
513
+ const now = Date.now();
514
+ const spaceMemberData = {
515
+ userId: resolvedMemberId,
516
+ role,
517
+ // 使用传入的 role,默认为 MEMBER
518
+ joinedAt: now,
519
+ updatedAt: now,
520
+ // 可选字段,初始化时设置为当前时间
521
+ spaceId,
522
+ spaceName: spaceData.name,
523
+ ownerId: spaceData.ownerId,
524
+ visibility: spaceData.visibility,
525
+ type: "space" /* SPACE */
526
+ // 添加 type 字段
527
+ };
528
+ const spaceMemberKey = createSpaceKey.member(resolvedMemberId, spaceId);
529
+ await dispatch(
530
+ write({
531
+ data: spaceMemberData,
532
+ customKey: spaceMemberKey
533
+ })
534
+ ).unwrap();
535
+ return { spaceId, updatedSpaceData };
536
+ };
537
+ async function resolveMemberId(db, identifier) {
538
+ const trimmed = identifier.trim();
539
+ let foundUserId = null;
540
+ let matchCount = 0;
541
+ try {
542
+ for await (const [key, value] of db.iterator({
543
+ gte: `${DB_PREFIX.USER}`,
544
+ lte: `${DB_PREFIX.USER}\uFFFF`
545
+ })) {
546
+ if (value.username === trimmed) {
547
+ foundUserId = key.slice(DB_PREFIX.USER.length);
548
+ matchCount++;
549
+ }
550
+ }
551
+ } catch (err) {
552
+ logger.warn({ err, identifier: trimmed }, "Failed to scan users by username");
553
+ }
554
+ if (matchCount > 1) {
555
+ throw new Error(
556
+ `\u627E\u5230\u591A\u4E2A\u7528\u6237\u540D\u4E3A ${trimmed} \u7684\u7528\u6237\uFF0C\u8BF7\u4F7F\u7528\u7528\u6237 ID \u9080\u8BF7`
557
+ );
558
+ }
559
+ if (matchCount === 1 && foundUserId) {
560
+ return foundUserId;
561
+ }
562
+ return trimmed;
563
+ }
564
+
565
+ // packages/create/space/member/removeMemberAction.ts
566
+ var removeMemberAction = async (input, thunkAPI) => {
567
+ const { spaceId, memberId } = input;
568
+ const { dispatch, getState } = thunkAPI;
569
+ const state = getState();
570
+ const currentUserId = selectIdentityUserId(state);
571
+ const spaceKey = createSpaceKey.space(spaceId);
572
+ const spaceData = await dispatch(read({
573
+ dbKey: spaceKey
574
+ })).unwrap();
575
+ if (!spaceData) {
576
+ throw new Error("Space not found");
577
+ }
578
+ if (spaceData.ownerId !== currentUserId) {
579
+ throw new Error("\u53EA\u6709\u7A7A\u95F4\u6240\u6709\u8005\u624D\u80FD\u5220\u9664\u6210\u5458");
580
+ }
581
+ if (!spaceData.members.includes(memberId)) {
582
+ throw new Error("\u5F85\u5220\u9664\u7684\u6210\u5458\u4E0D\u5B58\u5728");
583
+ }
584
+ const updatedSpaceData = {
585
+ ...spaceData,
586
+ members: spaceData.members.filter((id) => id !== memberId),
587
+ updatedAt: Date.now()
588
+ };
589
+ const memberKey = createSpaceKey.member(memberId, spaceId);
590
+ await Promise.all([
591
+ dispatch(write({ data: updatedSpaceData, customKey: spaceKey })).unwrap(),
592
+ dispatch(remove(memberKey)).unwrap()
593
+ // 使用 remove 替代 del
594
+ ]);
595
+ return { spaceId, updatedSpaceData };
596
+ };
597
+
598
+ // packages/create/space/member/memberThunks.ts
599
+ var fetchUserSpaceMemberships = createAsyncThunk(
600
+ "space/fetchUserSpaceMemberships",
601
+ async (arg, thunkAPI) => {
602
+ setMembershipLoading();
603
+ try {
604
+ const payload = await fetchUserSpaceMembershipsAction(arg, thunkAPI);
605
+ setMemberSpaces(payload);
606
+ return payload;
607
+ } catch (error) {
608
+ setMembershipRejected(
609
+ error?.message || "Failed to fetch space memberships",
610
+ isSpaceMembershipRemoteUnavailableError(error)
611
+ );
612
+ throw error;
613
+ }
614
+ }
615
+ );
616
+ var addMember = createAsyncThunk(
617
+ "space/addMember",
618
+ async (arg, thunkAPI) => {
619
+ const payload = await addMemberAction(arg, thunkAPI);
620
+ if (getCurrentSpaceIdRaw() === payload.spaceId) {
621
+ updateCurrentSpaceIfMatch(payload.spaceId, payload.updatedSpaceData);
622
+ }
623
+ return payload;
624
+ }
625
+ );
626
+ var removeMember = createAsyncThunk(
627
+ "space/removeMember",
628
+ async (arg, thunkAPI) => {
629
+ const payload = await removeMemberAction(arg, thunkAPI);
630
+ if (getCurrentSpaceIdRaw() === payload.spaceId) {
631
+ updateCurrentSpaceIfMatch(payload.spaceId, payload.updatedSpaceData);
632
+ }
633
+ return payload;
634
+ }
635
+ );
636
+ export {
637
+ addMember,
638
+ fetchUserSpaceMemberships,
639
+ removeMember
640
+ };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  ALL_MODELS
3
- } from "./chunk-56W233KG.js";
4
- import "./chunk-WL3UOGYO.js";
3
+ } from "./chunk-FKFMIBTT.js";
4
+ import "./chunk-22BTGNSP.js";
5
5
  import "./chunk-QSJ3HFEF.js";
6
6
  import "./chunk-4VNS5WPM.js";
7
7
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nolo-cli",
3
- "version": "0.54.0-alpha.2",
3
+ "version": "0.61.0-alpha.2",
4
4
  "type": "module",
5
5
  "description": "Agent-first terminal workspace for Nolo",
6
6
  "bin": {
@@ -16,6 +16,7 @@
16
16
  },
17
17
  "dependencies": {
18
18
  "level": "^10.0.0",
19
- "ulid": "^2.3.0"
19
+ "ulid": "^2.3.0",
20
+ "tweetnacl": "^1.0.3"
20
21
  }
21
22
  }
@@ -1,14 +1,15 @@
1
1
  import {
2
2
  readAction
3
- } from "./chunk-VULELK4T.js";
3
+ } from "./chunk-L7B47JXR.js";
4
4
  import "./chunk-BJIRLHJR.js";
5
- import "./chunk-PYKV6FSC.js";
5
+ import "./chunk-KWSQR2KK.js";
6
6
  import "./chunk-QOKAKDPE.js";
7
7
  import "./chunk-OW765XBU.js";
8
+ import "./chunk-SEJ5OS6F.js";
8
9
  import "./chunk-GBRG75BQ.js";
9
- import "./chunk-KUG52IAP.js";
10
10
  import "./chunk-3EUW3WEO.js";
11
11
  import "./chunk-U6VC4MU4.js";
12
+ import "./chunk-KUG52IAP.js";
12
13
  import "./chunk-LCBAMY2M.js";
13
14
  import "./chunk-4SN6J65J.js";
14
15
  import "./chunk-CF7PE763.js";
@@ -4,7 +4,7 @@ import {
4
4
  readDocFunctionSchema,
5
5
  readPageFunc,
6
6
  readPageFunctionSchema
7
- } from "./chunk-VRZIH5JO.js";
7
+ } from "./chunk-2PGGC63K.js";
8
8
  import "./chunk-HNMXYYJR.js";
9
9
  import "./chunk-4VNS5WPM.js";
10
10
  export {