nolo-cli 0.49.1 → 0.50.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 (131) hide show
  1. package/{_executeModel-KE4PQSZ3.js → _executeModel-JKEH7ACW.js} +48 -42
  2. package/{action-IU6ON7ZB.js → action-VSG2IYP3.js} +8 -8
  3. package/{addContentAction-5V5CCI3I.js → addContentAction-2HJJITDI.js} +8 -7
  4. package/{addDialogAgentAction-KF3KZZNZ.js → addDialogAgentAction-7BSQVVL5.js} +10 -9
  5. package/{agentDeleteCommand-Z67TJG3W.js → agentDeleteCommand-SVXKS5SC.js} +30 -28
  6. package/{agentEmailCommands-7LPIK7JE.js → agentEmailCommands-WN7QBTP3.js} +57 -52
  7. package/{agentListCommands-5J2IM3IT.js → agentListCommands-2BEBOQIG.js} +42 -33
  8. package/{agentMachineCommands-YXH6FXUQ.js → agentMachineCommands-WALP3ONU.js} +30 -28
  9. package/{agentRecordCommands-GZLCDVUS.js → agentRecordCommands-E652SW57.js} +55 -50
  10. package/{agentRunCommand-WYH5Q54Q.js → agentRunCommand-6VXWXKCS.js} +60 -53
  11. package/{agentRunControl-4GHHSXFZ.js → agentRunControl-LJVFDJGU.js} +3 -1
  12. package/{agentRuntimeLocal-A6EF3RUY.js → agentRuntimeLocal-SBG7BDFQ.js} +30 -26
  13. package/{agentSlice-ARTDF6VD.js → agentSlice-3WYXIGEO.js} +8 -8
  14. package/{agentSuperviseCommands-VB6BUS5H.js → agentSuperviseCommands-F3RFAL7K.js} +2 -2
  15. package/{appDeleteCommands-V2B7ZCLC.js → appDeleteCommands-NTUNMEXY.js} +31 -29
  16. package/{appDeployCommands-AXQU44RD.js → appDeployCommands-DISWXRTL.js} +31 -29
  17. package/{appDeployStatusCommands-FWGSC2UM.js → appDeployStatusCommands-IKRA6B6F.js} +31 -29
  18. package/{appGetCommands-67R3RFZK.js → appGetCommands-UMOP2DFV.js} +31 -29
  19. package/{appListCommands-TTASJPGV.js → appListCommands-ZKFD2AKS.js} +31 -29
  20. package/{authCommand-QOPOEYEK.js → authCommand-BS3CQC6I.js} +11 -11
  21. package/{chatQueueReduxAdapter-6CAHUQ4O.js → chatQueueReduxAdapter-A3YH4MT4.js} +24 -21
  22. package/{chunk-76UA7376.js → chunk-273FJUYI.js} +6 -6
  23. package/{chunk-7CH6U3FL.js → chunk-2GRGFCF6.js} +2 -4
  24. package/{chunk-T27IEBNQ.js → chunk-2QDDKFG5.js} +74 -1
  25. package/{chunk-IRJVFYOH.js → chunk-2TLYVDTN.js} +321 -1100
  26. package/{chunk-6BYAXNH5.js → chunk-3QOCS5IF.js} +11 -2
  27. package/chunk-6IGD47IC.js +19 -0
  28. package/{chunk-GFD7TIZU.js → chunk-6TUT5ZJD.js} +4 -6
  29. package/chunk-6YTOJY35.js +352 -0
  30. package/{chunk-B54WOZ77.js → chunk-7H7GQL6V.js} +2 -2
  31. package/{chunk-OYNDYVSE.js → chunk-B45YNDAE.js} +1 -1
  32. package/{chunk-UQWFIWHX.js → chunk-BKIDF5LV.js} +1 -1
  33. package/{chunk-5XCW6RQG.js → chunk-BUBPRCIU.js} +1 -1
  34. package/chunk-BYXBJQAS.js +0 -0
  35. package/{chunk-X7S7OFUX.js → chunk-CEVCRRHU.js} +4 -4
  36. package/{chunk-SP3DPVBH.js → chunk-DEIGUGP6.js} +2 -2
  37. package/{chunk-V2IPBG5U.js → chunk-DGEPT6FH.js} +1 -1
  38. package/{chunk-3AOLVADY.js → chunk-DVINR3PL.js} +1 -1
  39. package/{chunk-NN3AMBY3.js → chunk-DXOELY7S.js} +64 -69
  40. package/{chunk-OFZPJ3NT.js → chunk-E4MARS3Q.js} +1 -1
  41. package/{chunk-QUCSAM43.js → chunk-EAYBPWHX.js} +87 -66
  42. package/{chunk-DQLYEGP7.js → chunk-EGVY3GMT.js} +1 -1
  43. package/{chunk-2JYSSXLY.js → chunk-EJFW7TRP.js} +5 -26
  44. package/{chunk-HPZL4IBN.js → chunk-FGRCSLPV.js} +34 -45
  45. package/{chunk-WL3UOGYO.js → chunk-G4WSLTQF.js} +31 -97
  46. package/{chunk-HR5XDXYM.js → chunk-G5SQVIFZ.js} +3 -3
  47. package/{chunk-J3UALFHL.js → chunk-GHE5XMVR.js} +1 -1
  48. package/{chunk-6SMMK7MD.js → chunk-GKB4AZKV.js} +440 -2981
  49. package/{chunk-IKSFDJXB.js → chunk-GKNGRBE6.js} +150 -27
  50. package/{chunk-Q24S4NDF.js → chunk-HQTK2SFT.js} +1 -1
  51. package/{chunk-GDGIEGHV.js → chunk-IPTZ5TVU.js} +7 -6
  52. package/{chunk-4RXXP6WD.js → chunk-J7KDNHUO.js} +5 -64
  53. package/{chunk-QDHZCAH3.js → chunk-KNQ5LYVZ.js} +57 -2
  54. package/{chunk-VRJUIUIY.js → chunk-KVVNC5V3.js} +2 -2
  55. package/{chunk-CVT7L2WZ.js → chunk-LVCAWHI5.js} +4 -4
  56. package/{chunk-WX5E6HZS.js → chunk-N6SLQMSA.js} +6 -6
  57. package/{chunk-SQTVMYMU.js → chunk-NTZO3KX2.js} +3 -3
  58. package/{chunk-LGUQHYAL.js → chunk-O5FLGN2L.js} +3 -2
  59. package/{chunk-WKOEOQCI.js → chunk-OSUZKICS.js} +1600 -190
  60. package/{chunk-EXDR5D6X.js → chunk-Q2QN2RHG.js} +7 -7
  61. package/{chunk-L3JWI7WX.js → chunk-QOKAKDPE.js} +15 -11
  62. package/{chunk-757BGY6Y.js → chunk-RFYXK6KI.js} +1 -1
  63. package/chunk-RQSN75DW.js +1766 -0
  64. package/{chunk-HCMFFI2G.js → chunk-S3JNURSO.js} +2 -2
  65. package/{chunk-YZ2WE6CW.js → chunk-SAJSBPI2.js} +2 -2
  66. package/{chunk-WHVQA7PJ.js → chunk-SCBBGS2N.js} +23 -5
  67. package/chunk-SGSJBBKP.js +297 -0
  68. package/{chunk-GFUOVFQA.js → chunk-TUBNQ3OF.js} +2 -2
  69. package/{chunk-BANYWEYY.js → chunk-TY3ADTX5.js} +1 -1
  70. package/chunk-UAD2WT54.js +64 -0
  71. package/{chunk-SW7RCUGA.js → chunk-UEV5WVQV.js} +3 -3
  72. package/{chunk-EURF2SV6.js → chunk-UMCMW5R3.js} +51 -34
  73. package/{chunk-K524MUQC.js → chunk-VFDRZHPM.js} +16 -16
  74. package/{chunk-5WADL4O7.js → chunk-W22UTILW.js} +3 -3
  75. package/{chunk-IKTHA3JH.js → chunk-WERPP2S7.js} +2 -2
  76. package/{chunk-GBADO3SM.js → chunk-WSUHBABG.js} +1 -1
  77. package/{chunk-U5Z7LFZF.js → chunk-X3OGKR5Q.js} +4 -4
  78. package/{chunk-AVKUDHJO.js → chunk-X5LRMXTS.js} +10 -10
  79. package/{chunk-DIQCV4FR.js → chunk-X665UCNM.js} +1 -1
  80. package/{chunk-HCBQVVFZ.js → chunk-X7P6EJUY.js} +4 -4
  81. package/{chunk-HHBXCRJS.js → chunk-XOJRZUPF.js} +4 -4
  82. package/{chunk-MRWGHF56.js → chunk-YDH3FDFQ.js} +12 -356
  83. package/{chunk-TNPCQNGQ.js → chunk-YEFRCO5N.js} +4 -9
  84. package/{chunk-RO2IUWZE.js → chunk-YUKTCDVN.js} +1 -1
  85. package/{chunk-56W233KG.js → chunk-YWY25N4V.js} +1 -1
  86. package/{chunk-RU5D3B22.js → chunk-ZDS63Y4O.js} +2 -2
  87. package/chunk-ZJ7UHBJS.js +89 -0
  88. package/{chunk-SG65C33A.js → chunk-ZLMG6NRV.js} +4 -4
  89. package/{codingSkills-BYQI6EPT.js → codingSkills-FQPCEIWL.js} +2 -2
  90. package/contentThunks-J33BZB3E.js +71 -0
  91. package/{createAgentAutomationAction-7BBF5YXN.js → createAgentAutomationAction-HTMTGX6Q.js} +25 -21
  92. package/{createDialogAction-B5URPHP4.js → createDialogAction-WYQBSN6A.js} +27 -23
  93. package/{createPageAction-ISJKM5Q3.js → createPageAction-ICRRK3SA.js} +27 -22
  94. package/{dbSlice-FWF5F4L7.js → dbSlice-YORO4VL4.js} +6 -6
  95. package/{deleteFile-NPZ64DFN.js → deleteFile-JYKRT7C3.js} +4 -4
  96. package/{dialogCommands-XHH4MVA4.js → dialogCommands-FRSIAPKY.js} +31 -29
  97. package/{dialogSlice-NRAN5X7F.js → dialogSlice-5KPVIAWH.js} +24 -21
  98. package/{docCreateCommands-FUN2Z7HQ.js → docCreateCommands-DBRJMPDX.js} +30 -28
  99. package/{docDeleteCommands-OZDPFXPF.js → docDeleteCommands-BCYPLWXN.js} +31 -29
  100. package/{docReadCommands-FIPK7LE3.js → docReadCommands-L5JX4Q7G.js} +30 -28
  101. package/{docStore-LUS7SWC3.js → docStore-34NXLCEO.js} +8 -33
  102. package/{docUpdateCommands-BZ5GKAN4.js → docUpdateCommands-RELG7XJD.js} +30 -28
  103. package/fetchMessages-KZQVBXKY.js +1 -1
  104. package/{getPricing-HAU62AFM.js → getPricing-FM7TJZFV.js} +4 -4
  105. package/{handleSendMessageAction-RA4OD2ZH.js → handleSendMessageAction-MEYK7RPD.js} +25 -22
  106. package/index.js +64 -64
  107. package/{machineCommands-WDAYEFBE.js → machineCommands-YSXTOWHQ.js} +59 -54
  108. package/{machineWsRunDispatch-TPQ2FQVS.js → machineWsRunDispatch-DNAYOPQT.js} +54 -49
  109. package/memberThunks-KVPBG4V7.js +638 -0
  110. package/{models-4QF4BJVY.js → models-CW5EL6Z7.js} +2 -2
  111. package/package.json +2 -3
  112. package/{read-J7RVVCHH.js → read-NIOV5F7W.js} +4 -4
  113. package/{readDocTool-G2WBM4IH.js → readDocTool-ULKJ5BEM.js} +1 -1
  114. package/{readlineWorkspace-HN44KGIF.js → readlineWorkspace-KZ3LPQG2.js} +829 -393
  115. package/{removeDialogAgentAction-RMPISD42.js → removeDialogAgentAction-JGSCPML3.js} +12 -11
  116. package/{runAgentClientLoop-ZYUI22EA.js → runAgentClientLoop-O2AUHIJT.js} +46 -40
  117. package/{setDialogExtraReferencesAction-7BUTHDAL.js → setDialogExtraReferencesAction-CORU64NM.js} +9 -8
  118. package/{setPrimaryDialogAgentAction-WCYIBGZ4.js → setPrimaryDialogAgentAction-5VS2VKLZ.js} +12 -11
  119. package/{settingSlice-7NN2MI6Y.js → settingSlice-3GNGTC2T.js} +7 -7
  120. package/{skillDiscovery-COX56OBO.js → skillDiscovery-CYUCJMAG.js} +3 -3
  121. package/{spaceCommands-OJ2567D4.js → spaceCommands-OI7RIB2T.js} +30 -28
  122. package/{streamAgentChatTurn-FNFMMGNN.js → streamAgentChatTurn-TA3PGS6C.js} +61 -54
  123. package/{switchDialogAgentAction-WGMMQHDI.js → switchDialogAgentAction-LP433X4D.js} +10 -9
  124. package/{tableCommands-P2TXJ3CF.js → tableCommands-R6WFRDYF.js} +1 -1
  125. package/{toolApiClient-B2MFXMEG.js → toolApiClient-53U4UDFF.js} +3 -2
  126. package/{tools-QCDR3UMD.js → tools-6ZPQ75XA.js} +37 -32
  127. package/{tuiSummaryLlmCaller-LCGT62QC.js → tuiSummaryLlmCaller-YKYQB4ZL.js} +17 -15
  128. package/{updateDialogTitleAction-Y3OGJWDB.js → updateDialogTitleAction-LRJ7NSOS.js} +26 -22
  129. package/chunk-EUG45QJR.js +0 -6104
  130. package/spaceSlice-F7JCOZEF.js +0 -127
  131. package/{chunk-NQ4N4IGO.js → chunk-CS6TCJ7E.js} +3 -3
@@ -0,0 +1,638 @@
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-SGSJBBKP.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-273FJUYI.js";
29
+ import {
30
+ DB_PREFIX
31
+ } from "./chunk-SVEUG45B.js";
32
+ import "./chunk-WWC7I6TA.js";
33
+ import "./chunk-I42VC5KR.js";
34
+ import "./chunk-SAJSBPI2.js";
35
+ import "./chunk-QSJ3HFEF.js";
36
+ import {
37
+ readAction
38
+ } from "./chunk-EJFW7TRP.js";
39
+ import "./chunk-BJIRLHJR.js";
40
+ import {
41
+ DEVICE_LOCAL_OWNER_ID,
42
+ createAsyncThunk,
43
+ isDeviceLocalOwnerId,
44
+ isDeviceLocalSpaceMembership,
45
+ selectIdentityUserId
46
+ } from "./chunk-XOJRZUPF.js";
47
+ import {
48
+ logger
49
+ } from "./chunk-QOKAKDPE.js";
50
+ import "./chunk-OW765XBU.js";
51
+ import {
52
+ isTombstoneRecord
53
+ } from "./chunk-GBRG75BQ.js";
54
+ import {
55
+ asTrimmedString
56
+ } from "./chunk-3EUW3WEO.js";
57
+ import "./chunk-U6VC4MU4.js";
58
+ import "./chunk-KUG52IAP.js";
59
+ import {
60
+ API_ENDPOINTS
61
+ } from "./chunk-LCBAMY2M.js";
62
+ import "./chunk-4SN6J65J.js";
63
+ import "./chunk-CF7PE763.js";
64
+ import "./chunk-G3SUCT4W.js";
65
+ import "./chunk-4VNS5WPM.js";
66
+
67
+ // packages/create/space/member/isSpaceMembershipRemoteUnavailableError.ts
68
+ var SPACE_MEMBERSHIP_REMOTE_UNAVAILABLE = "space_membership_remote_unavailable";
69
+ var isSpaceMembershipRemoteUnavailableError = (error) => {
70
+ if (typeof error === "string") {
71
+ return error.includes(SPACE_MEMBERSHIP_REMOTE_UNAVAILABLE);
72
+ }
73
+ if (error instanceof Error) {
74
+ return error.message.includes(SPACE_MEMBERSHIP_REMOTE_UNAVAILABLE);
75
+ }
76
+ if (error && typeof error === "object" && "message" in error && typeof error.message === "string") {
77
+ return error.message.includes(
78
+ SPACE_MEMBERSHIP_REMOTE_UNAVAILABLE
79
+ );
80
+ }
81
+ return false;
82
+ };
83
+
84
+ // packages/create/space/member/fetchUserSpaceMembershipsAction.ts
85
+ var CONTENT_SPACE_RECOVERY_TYPES = [
86
+ "app" /* APP */,
87
+ "page" /* DOC */,
88
+ "dialog" /* DIALOG */,
89
+ "image" /* IMAGE */,
90
+ "file" /* FILE */,
91
+ "table" /* TABLE */,
92
+ "agent" /* AGENT */
93
+ ];
94
+ var readLocalSpaceData = async (db, spaceId) => {
95
+ const normalizedSpaceId = normalizeSpaceId(spaceId);
96
+ const spaceKey = createSpaceKey.space(normalizedSpaceId);
97
+ try {
98
+ return await db.get(spaceKey) ?? null;
99
+ } catch {
100
+ return null;
101
+ }
102
+ };
103
+ var membershipCheckUserId = (membership, activeUserId) => isDeviceLocalSpaceMembership(membership) ? DEVICE_LOCAL_OWNER_ID : activeUserId;
104
+ var buildLocalMembershipPreview = async (userId, db, memberships) => {
105
+ const preview = await Promise.all(
106
+ memberships.map(async (membership) => {
107
+ if (isTombstoneRecord(membership)) return null;
108
+ const checkUserId = membershipCheckUserId(membership, userId);
109
+ if (!membershipBelongsToUser(membership, checkUserId)) return null;
110
+ const normalizedSpaceId = normalizeSpaceId(membership.spaceId);
111
+ const localSpaceData = await readLocalSpaceData(db, normalizedSpaceId);
112
+ if (!localSpaceData || isTombstoneRecord(localSpaceData)) return null;
113
+ if (!spaceListsUser(localSpaceData, checkUserId)) return null;
114
+ return {
115
+ ...membership,
116
+ spaceId: normalizedSpaceId
117
+ };
118
+ })
119
+ );
120
+ return preview.filter(
121
+ (membership) => !!membership
122
+ );
123
+ };
124
+ var fetchLocalForUser = async (userId, db) => {
125
+ try {
126
+ const memberships = [];
127
+ const prefix = `space-member-${userId}`;
128
+ let iterator = db.iterator({
129
+ gte: prefix,
130
+ lte: prefix + "\xFF"
131
+ });
132
+ if (iterator && typeof iterator.then === "function") {
133
+ iterator = await iterator;
134
+ }
135
+ for await (const [_, memberData] of iterator) {
136
+ if (memberData && typeof memberData === "object" && memberData.spaceId && !isTombstoneRecord(memberData)) {
137
+ memberships.push(memberData);
138
+ }
139
+ }
140
+ return memberships;
141
+ } catch (error) {
142
+ console.error("Error fetching local memberships:", error);
143
+ return [];
144
+ }
145
+ };
146
+ var fetchLocalUnion = async (userId, db) => {
147
+ const deviceLocalRows = await fetchLocalForUser(DEVICE_LOCAL_OWNER_ID, db);
148
+ const taggedLocal = deviceLocalRows.map(
149
+ (membership) => ({
150
+ ...membership,
151
+ spaceId: normalizeSpaceId(membership.spaceId),
152
+ deviceLocal: true,
153
+ userId: membership.userId || DEVICE_LOCAL_OWNER_ID
154
+ })
155
+ );
156
+ if (isDeviceLocalOwnerId(userId)) {
157
+ return taggedLocal;
158
+ }
159
+ const accountRows = await fetchLocalForUser(userId, db);
160
+ const taggedAccount = accountRows.map(
161
+ (membership) => ({
162
+ ...membership,
163
+ spaceId: normalizeSpaceId(membership.spaceId),
164
+ deviceLocal: false
165
+ })
166
+ );
167
+ return [...taggedLocal, ...taggedAccount];
168
+ };
169
+ var fetchRemoteContentSpaceIds = async (server, userId, token) => {
170
+ try {
171
+ const queryParams = new URLSearchParams({ limit: "200" });
172
+ const headers = {
173
+ "Content-Type": "application/json"
174
+ };
175
+ const authToken = asTrimmedString(token);
176
+ if (authToken) {
177
+ headers.Authorization = `Bearer ${authToken}`;
178
+ }
179
+ const response = await fetch(
180
+ `${server}${API_ENDPOINTS.DATABASE}/query/${encodeURIComponent(userId)}?${queryParams}`,
181
+ {
182
+ method: "POST",
183
+ headers,
184
+ body: JSON.stringify({
185
+ type: [...CONTENT_SPACE_RECOVERY_TYPES],
186
+ includeDeleted: true,
187
+ summary: true
188
+ })
189
+ }
190
+ );
191
+ if (!response.ok) return [];
192
+ const data = await response.json();
193
+ const records = Array.isArray(data?.data?.data) ? data.data.data : [];
194
+ return records.filter((record) => !isTombstoneRecord(record)).map(
195
+ (record) => typeof record?.spaceId === "string" ? normalizeSpaceId(record.spaceId) : ""
196
+ ).filter((spaceId) => spaceId.length > 0);
197
+ } catch {
198
+ return [];
199
+ }
200
+ };
201
+ var recoverMembershipsFromContentSpaces = async ({
202
+ servers,
203
+ token,
204
+ userId,
205
+ knownSpaceIds
206
+ }) => {
207
+ const candidateSpaceIds = /* @__PURE__ */ new Set();
208
+ await Promise.all(
209
+ servers.map(async (server) => {
210
+ const spaceIds = await fetchRemoteContentSpaceIds(server, userId, token);
211
+ spaceIds.forEach((spaceId) => {
212
+ if (!knownSpaceIds.has(spaceId)) {
213
+ candidateSpaceIds.add(spaceId);
214
+ }
215
+ });
216
+ })
217
+ );
218
+ const results = await Promise.all(
219
+ [...candidateSpaceIds].map(async (spaceId) => {
220
+ try {
221
+ for (const server of servers) {
222
+ const remoteSpace = await fetchRemoteSpace(server, token, spaceId);
223
+ if (!spaceListsUser(remoteSpace, userId)) continue;
224
+ return {
225
+ userId,
226
+ spaceId,
227
+ spaceName: typeof remoteSpace?.name === "string" && remoteSpace.name.trim() ? remoteSpace.name : spaceId,
228
+ role: remoteSpace?.ownerId === userId ? "owner" /* OWNER */ : "member" /* MEMBER */,
229
+ joinedAt: remoteSpace?.updatedAt ?? remoteSpace?.createdAt ?? Date.now(),
230
+ sourceServer: server
231
+ };
232
+ }
233
+ } catch {
234
+ }
235
+ return null;
236
+ })
237
+ );
238
+ const recovered = results.filter(
239
+ (m) => m !== null
240
+ );
241
+ return recovered;
242
+ };
243
+ var fetchUserSpaceMembershipsAction = async (userId, thunkAPI) => {
244
+ const state = thunkAPI.getState();
245
+ const db = thunkAPI.extra.db;
246
+ const { token, servers } = selectSpaceRemoteAuth(state);
247
+ const isLocalActor = isDeviceLocalOwnerId(userId);
248
+ const localMembershipsPromise = fetchLocalUnion(userId, db);
249
+ const remoteResultsPromise = isLocalActor ? Promise.resolve([]) : Promise.all(
250
+ servers.map(
251
+ (server) => fetchRemoteUserSpaceMemberships(server, token, userId)
252
+ )
253
+ );
254
+ const localMemberships = await localMembershipsPromise;
255
+ if (getMemberSpaces() === null && localMemberships.length > 0) {
256
+ const localPreview = await buildLocalMembershipPreview(
257
+ userId,
258
+ db,
259
+ localMemberships
260
+ );
261
+ if (localPreview.length > 0) {
262
+ hydrateMemberSpacesFromLocal(localPreview);
263
+ }
264
+ }
265
+ const remoteResults = await remoteResultsPromise;
266
+ const successfulRemoteResults = remoteResults.filter((result) => result.ok);
267
+ const successfulRemoteMemberships = successfulRemoteResults.flatMap(
268
+ (result) => result.memberships.map((membership) => ({
269
+ ...membership,
270
+ sourceServer: result.server
271
+ }))
272
+ );
273
+ const hasSuccessfulRemoteFetch = successfulRemoteResults.length > 0;
274
+ const hasRemoteAuthority = !isLocalActor && !!token && servers.length > 0;
275
+ if (hasRemoteAuthority && !hasSuccessfulRemoteFetch) {
276
+ throw new Error(
277
+ `${SPACE_MEMBERSHIP_REMOTE_UNAVAILABLE}: unable to refresh memberships from ${servers.join(", ")}`
278
+ );
279
+ }
280
+ const remoteSpaceIds = new Set(
281
+ successfulRemoteMemberships.map(
282
+ (membership) => normalizeSpaceId(membership.spaceId)
283
+ )
284
+ );
285
+ const filteredLocalMemberships = hasSuccessfulRemoteFetch ? (await Promise.all(
286
+ localMemberships.map(async (membership) => {
287
+ const normalizedSpaceId = normalizeSpaceId(membership.spaceId);
288
+ if (membership.deviceLocal || isDeviceLocalSpaceMembership(membership)) {
289
+ return {
290
+ ...membership,
291
+ spaceId: normalizedSpaceId,
292
+ deviceLocal: true
293
+ };
294
+ }
295
+ if (remoteSpaceIds.has(normalizedSpaceId)) {
296
+ return {
297
+ ...membership,
298
+ spaceId: normalizedSpaceId
299
+ };
300
+ }
301
+ console.warn(
302
+ `[SpaceMembership] Membership missing from remote index, verifying space record: user=${userId}, spaceId=${normalizedSpaceId}`
303
+ );
304
+ return {
305
+ ...membership,
306
+ spaceId: normalizedSpaceId,
307
+ requiresRemoteSpaceVerification: true
308
+ };
309
+ })
310
+ )).filter((membership) => !!membership) : localMemberships.map((membership) => ({
311
+ ...membership,
312
+ spaceId: normalizeSpaceId(membership.spaceId)
313
+ }));
314
+ const verifyActiveSpaceMembership = async (membership) => {
315
+ if (isTombstoneRecord(membership)) return null;
316
+ const checkUserId = membershipCheckUserId(membership, userId);
317
+ if (!membershipBelongsToUser(membership, checkUserId)) return null;
318
+ const normalizedSpaceId = normalizeSpaceId(membership.spaceId);
319
+ const localSpaceData = await readLocalSpaceData(db, normalizedSpaceId);
320
+ const isDeviceLocal = membership.deviceLocal || isDeviceLocalSpaceMembership(membership);
321
+ if (isDeviceLocal) {
322
+ if (!localSpaceData || isTombstoneRecord(localSpaceData)) return null;
323
+ if (!spaceListsUser(localSpaceData, checkUserId)) {
324
+ return null;
325
+ }
326
+ const {
327
+ sourceServer: _s,
328
+ requiresRemoteSpaceVerification: _r,
329
+ deviceLocal: _d,
330
+ ...visible
331
+ } = membership;
332
+ return {
333
+ ...visible,
334
+ spaceId: normalizedSpaceId,
335
+ userId: DEVICE_LOCAL_OWNER_ID
336
+ };
337
+ }
338
+ if (membership.sourceServer || membership.requiresRemoteSpaceVerification) {
339
+ if (localSpaceData && isTombstoneRecord(localSpaceData)) return null;
340
+ if (membership.sourceServer && !membership.requiresRemoteSpaceVerification) {
341
+ const { sourceServer: _ss, ...verifiedMembership } = membership;
342
+ return {
343
+ ...verifiedMembership,
344
+ spaceId: normalizedSpaceId
345
+ };
346
+ }
347
+ try {
348
+ const remoteSpaceServers = Array.from(
349
+ new Set(
350
+ [membership.sourceServer, ...servers].filter(
351
+ (server) => typeof server === "string" && server.length > 0
352
+ )
353
+ )
354
+ );
355
+ let remoteSpace = null;
356
+ for (const server of remoteSpaceServers) {
357
+ remoteSpace = await fetchRemoteSpace(
358
+ server,
359
+ token,
360
+ normalizedSpaceId
361
+ );
362
+ if (remoteSpace) break;
363
+ }
364
+ if (!spaceListsUser(remoteSpace, userId)) return null;
365
+ const {
366
+ requiresRemoteSpaceVerification,
367
+ deviceLocal: _dl,
368
+ ...verifiedMembership
369
+ } = membership;
370
+ return {
371
+ ...verifiedMembership,
372
+ spaceId: normalizedSpaceId
373
+ };
374
+ } catch {
375
+ return null;
376
+ }
377
+ }
378
+ if (localSpaceData) {
379
+ return !spaceListsUser(localSpaceData, userId) ? null : {
380
+ ...membership,
381
+ spaceId: normalizedSpaceId
382
+ };
383
+ }
384
+ if (!membership.sourceServer && servers.length === 0) {
385
+ return {
386
+ ...membership,
387
+ spaceId: normalizedSpaceId
388
+ };
389
+ }
390
+ try {
391
+ const remoteSpace = await readAction(
392
+ {
393
+ dbKey: createSpaceKey.space(normalizedSpaceId),
394
+ preferredServerOrigin: membership.sourceServer
395
+ },
396
+ thunkAPI
397
+ );
398
+ if (!spaceListsUser(remoteSpace, userId)) return null;
399
+ return {
400
+ ...membership,
401
+ spaceId: normalizedSpaceId
402
+ };
403
+ } catch {
404
+ return null;
405
+ }
406
+ };
407
+ const activeMemberships = (await Promise.all(
408
+ [...filteredLocalMemberships, ...successfulRemoteMemberships].map(
409
+ verifyActiveSpaceMembership
410
+ )
411
+ )).filter((membership) => !!membership);
412
+ const knownSpaceIds = new Set(
413
+ [
414
+ ...filteredLocalMemberships,
415
+ ...successfulRemoteMemberships,
416
+ ...activeMemberships
417
+ ].map((membership) => normalizeSpaceId(membership.spaceId))
418
+ );
419
+ if (hasRemoteAuthority && hasSuccessfulRemoteFetch && !isLocalActor) {
420
+ void recoverMembershipsFromContentSpaces({
421
+ servers,
422
+ token,
423
+ userId,
424
+ knownSpaceIds
425
+ }).then((rawRecovered) => {
426
+ const activeUserId = thunkAPI.getState()?.auth?.currentUser?.userId ?? null;
427
+ if (activeUserId !== userId) return;
428
+ if (rawRecovered.length === 0) return;
429
+ const cleaned = rawRecovered.map((membership) => {
430
+ const {
431
+ sourceServer: _ss,
432
+ requiresRemoteSpaceVerification: _rv,
433
+ deviceLocal: _dl,
434
+ ...visible
435
+ } = membership;
436
+ return { ...visible, spaceId: normalizeSpaceId(membership.spaceId) };
437
+ });
438
+ appendRecoveredMemberships(cleaned);
439
+ }).catch(() => {
440
+ });
441
+ }
442
+ const membershipMap = /* @__PURE__ */ new Map();
443
+ const preferAccountOnCollision = (existing, next) => {
444
+ if (!existing) return next;
445
+ const existingLocal = isDeviceLocalSpaceMembership(existing);
446
+ const nextLocal = isDeviceLocalSpaceMembership(next);
447
+ if (existingLocal && !nextLocal) return next;
448
+ if (!existingLocal && nextLocal) return existing;
449
+ return next;
450
+ };
451
+ [...activeMemberships].forEach((membership) => {
452
+ const normalizedSpaceId = normalizeSpaceId(membership.spaceId);
453
+ const {
454
+ sourceServer: _sourceServer,
455
+ requiresRemoteSpaceVerification: _req,
456
+ deviceLocal: _deviceLocal,
457
+ ...visibleMembership
458
+ } = membership;
459
+ const cleaned = {
460
+ ...visibleMembership,
461
+ spaceId: normalizedSpaceId
462
+ };
463
+ const existing = membershipMap.get(normalizedSpaceId);
464
+ membershipMap.set(
465
+ normalizedSpaceId,
466
+ preferAccountOnCollision(existing, cleaned)
467
+ );
468
+ });
469
+ const finalMemberships = Array.from(membershipMap.values()).sort(
470
+ (a, b) => (b.joinedAt || 0) - (a.joinedAt || 0)
471
+ );
472
+ return finalMemberships;
473
+ };
474
+
475
+ // packages/database/thunkApiTypes.ts
476
+ var dbThunkState = (thunkApi) => thunkApi.getState();
477
+ var dbThunkExtra = (thunkApi) => thunkApi.extra;
478
+
479
+ // packages/create/space/member/addMemberAction.ts
480
+ var addMemberAction = async (input, thunkAPI) => {
481
+ const { spaceId, memberId, role = "member" /* MEMBER */ } = input;
482
+ const { dispatch } = thunkAPI;
483
+ const state = dbThunkState(thunkAPI);
484
+ const currentUserId = selectIdentityUserId(state);
485
+ const { db } = dbThunkExtra(thunkAPI);
486
+ const resolvedMemberId = db ? await resolveMemberId(db, memberId) : memberId.trim();
487
+ const spaceKey = createSpaceKey.space(spaceId);
488
+ const spaceData = await dispatch(read({
489
+ dbKey: spaceKey
490
+ })).unwrap();
491
+ if (!spaceData) {
492
+ throw new Error("Space not found");
493
+ }
494
+ if (!currentUserId) {
495
+ throw new Error("User is not logged in.");
496
+ }
497
+ if (!spaceData.members.includes(currentUserId)) {
498
+ throw new Error("\u5F53\u524D\u7528\u6237\u4E0D\u662F\u7A7A\u95F4\u6210\u5458\uFF0C\u65E0\u6CD5\u6DFB\u52A0\u6210\u5458");
499
+ }
500
+ if (spaceData.members.includes(resolvedMemberId)) {
501
+ throw new Error("\u6210\u5458\u5DF2\u5B58\u5728");
502
+ }
503
+ const updatedSpaceData = {
504
+ ...spaceData,
505
+ members: [...spaceData.members, resolvedMemberId],
506
+ updatedAt: Date.now()
507
+ };
508
+ await dispatch(
509
+ write({ data: updatedSpaceData, customKey: spaceKey })
510
+ ).unwrap();
511
+ const now = Date.now();
512
+ const spaceMemberData = {
513
+ userId: resolvedMemberId,
514
+ role,
515
+ // 使用传入的 role,默认为 MEMBER
516
+ joinedAt: now,
517
+ updatedAt: now,
518
+ // 可选字段,初始化时设置为当前时间
519
+ spaceId,
520
+ spaceName: spaceData.name,
521
+ ownerId: spaceData.ownerId,
522
+ visibility: spaceData.visibility,
523
+ type: "space" /* SPACE */
524
+ // 添加 type 字段
525
+ };
526
+ const spaceMemberKey = createSpaceKey.member(resolvedMemberId, spaceId);
527
+ await dispatch(
528
+ write({
529
+ data: spaceMemberData,
530
+ customKey: spaceMemberKey
531
+ })
532
+ ).unwrap();
533
+ return { spaceId, updatedSpaceData };
534
+ };
535
+ async function resolveMemberId(db, identifier) {
536
+ const trimmed = identifier.trim();
537
+ let foundUserId = null;
538
+ let matchCount = 0;
539
+ try {
540
+ for await (const [key, value] of db.iterator({
541
+ gte: `${DB_PREFIX.USER}`,
542
+ lte: `${DB_PREFIX.USER}\uFFFF`
543
+ })) {
544
+ if (value.username === trimmed) {
545
+ foundUserId = key.slice(DB_PREFIX.USER.length);
546
+ matchCount++;
547
+ }
548
+ }
549
+ } catch (err) {
550
+ logger.warn({ err, identifier: trimmed }, "Failed to scan users by username");
551
+ }
552
+ if (matchCount > 1) {
553
+ throw new Error(
554
+ `\u627E\u5230\u591A\u4E2A\u7528\u6237\u540D\u4E3A ${trimmed} \u7684\u7528\u6237\uFF0C\u8BF7\u4F7F\u7528\u7528\u6237 ID \u9080\u8BF7`
555
+ );
556
+ }
557
+ if (matchCount === 1 && foundUserId) {
558
+ return foundUserId;
559
+ }
560
+ return trimmed;
561
+ }
562
+
563
+ // packages/create/space/member/removeMemberAction.ts
564
+ var removeMemberAction = async (input, thunkAPI) => {
565
+ const { spaceId, memberId } = input;
566
+ const { dispatch, getState } = thunkAPI;
567
+ const state = getState();
568
+ const currentUserId = selectIdentityUserId(state);
569
+ const spaceKey = createSpaceKey.space(spaceId);
570
+ const spaceData = await dispatch(read({
571
+ dbKey: spaceKey
572
+ })).unwrap();
573
+ if (!spaceData) {
574
+ throw new Error("Space not found");
575
+ }
576
+ if (spaceData.ownerId !== currentUserId) {
577
+ throw new Error("\u53EA\u6709\u7A7A\u95F4\u6240\u6709\u8005\u624D\u80FD\u5220\u9664\u6210\u5458");
578
+ }
579
+ if (!spaceData.members.includes(memberId)) {
580
+ throw new Error("\u5F85\u5220\u9664\u7684\u6210\u5458\u4E0D\u5B58\u5728");
581
+ }
582
+ const updatedSpaceData = {
583
+ ...spaceData,
584
+ members: spaceData.members.filter((id) => id !== memberId),
585
+ updatedAt: Date.now()
586
+ };
587
+ const memberKey = createSpaceKey.member(memberId, spaceId);
588
+ await Promise.all([
589
+ dispatch(write({ data: updatedSpaceData, customKey: spaceKey })).unwrap(),
590
+ dispatch(remove(memberKey)).unwrap()
591
+ // 使用 remove 替代 del
592
+ ]);
593
+ return { spaceId, updatedSpaceData };
594
+ };
595
+
596
+ // packages/create/space/member/memberThunks.ts
597
+ var fetchUserSpaceMemberships = createAsyncThunk(
598
+ "space/fetchUserSpaceMemberships",
599
+ async (arg, thunkAPI) => {
600
+ setMembershipLoading();
601
+ try {
602
+ const payload = await fetchUserSpaceMembershipsAction(arg, thunkAPI);
603
+ setMemberSpaces(payload);
604
+ return payload;
605
+ } catch (error) {
606
+ setMembershipRejected(
607
+ error?.message,
608
+ isSpaceMembershipRemoteUnavailableError(error)
609
+ );
610
+ throw error;
611
+ }
612
+ }
613
+ );
614
+ var addMember = createAsyncThunk(
615
+ "space/addMember",
616
+ async (arg, thunkAPI) => {
617
+ const payload = await addMemberAction(arg, thunkAPI);
618
+ if (getCurrentSpaceIdRaw() === payload.spaceId) {
619
+ updateCurrentSpaceIfMatch(payload.spaceId, payload.updatedSpaceData);
620
+ }
621
+ return payload;
622
+ }
623
+ );
624
+ var removeMember = createAsyncThunk(
625
+ "space/removeMember",
626
+ async (arg, thunkAPI) => {
627
+ const payload = await removeMemberAction(arg, thunkAPI);
628
+ if (getCurrentSpaceIdRaw() === payload.spaceId) {
629
+ updateCurrentSpaceIfMatch(payload.spaceId, payload.updatedSpaceData);
630
+ }
631
+ return payload;
632
+ }
633
+ );
634
+ export {
635
+ addMember,
636
+ fetchUserSpaceMemberships,
637
+ removeMember
638
+ };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  ALL_MODELS
3
- } from "./chunk-56W233KG.js";
4
- import "./chunk-WL3UOGYO.js";
3
+ } from "./chunk-YWY25N4V.js";
4
+ import "./chunk-G4WSLTQF.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.49.1",
3
+ "version": "0.50.0",
4
4
  "type": "module",
5
5
  "description": "Agent-first terminal workspace for Nolo",
6
6
  "bin": {
@@ -16,7 +16,6 @@
16
16
  },
17
17
  "dependencies": {
18
18
  "level": "^10.0.0",
19
- "ulid": "^2.3.0",
20
- "tweetnacl": "^1.0.3"
19
+ "ulid": "^2.3.0"
21
20
  }
22
21
  }
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  readAction
3
- } from "./chunk-2JYSSXLY.js";
3
+ } from "./chunk-EJFW7TRP.js";
4
4
  import "./chunk-BJIRLHJR.js";
5
- import "./chunk-HHBXCRJS.js";
6
- import "./chunk-L3JWI7WX.js";
5
+ import "./chunk-XOJRZUPF.js";
6
+ import "./chunk-QOKAKDPE.js";
7
7
  import "./chunk-OW765XBU.js";
8
8
  import "./chunk-GBRG75BQ.js";
9
- import "./chunk-KUG52IAP.js";
10
9
  import "./chunk-3EUW3WEO.js";
11
10
  import "./chunk-U6VC4MU4.js";
11
+ import "./chunk-KUG52IAP.js";
12
12
  import "./chunk-LCBAMY2M.js";
13
13
  import "./chunk-4SN6J65J.js";
14
14
  import "./chunk-CF7PE763.js";
@@ -4,7 +4,7 @@ import {
4
4
  readDocFunctionSchema,
5
5
  readPageFunc,
6
6
  readPageFunctionSchema
7
- } from "./chunk-5XCW6RQG.js";
7
+ } from "./chunk-BUBPRCIU.js";
8
8
  import "./chunk-HNMXYYJR.js";
9
9
  import "./chunk-4VNS5WPM.js";
10
10
  export {