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
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  i18n_default,
3
3
  toolRegistry
4
- } from "./chunk-WKOEOQCI.js";
4
+ } from "./chunk-OSUZKICS.js";
5
5
  import {
6
6
  canonicalizeToolNames
7
7
  } from "./chunk-O6OSWFZQ.js";
8
8
  import {
9
9
  isNoloHostedProvider
10
- } from "./chunk-WL3UOGYO.js";
10
+ } from "./chunk-G4WSLTQF.js";
11
11
  import {
12
12
  asTrimmedLowercaseString
13
13
  } from "./chunk-QSJ3HFEF.js";
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  getRuntimeServerContext,
3
3
  scheduleDeleteReplication
4
- } from "./chunk-HHBXCRJS.js";
4
+ } from "./chunk-XOJRZUPF.js";
5
5
  import {
6
6
  fetchFromClientDb
7
- } from "./chunk-L3JWI7WX.js";
7
+ } from "./chunk-QOKAKDPE.js";
8
8
  import {
9
9
  buildTombstoneRecord
10
10
  } from "./chunk-GBRG75BQ.js";
@@ -432,11 +432,18 @@ function createRunActivityTracker(runId, deps = {}, options = {}) {
432
432
  }
433
433
  function doWrite() {
434
434
  writeTimer = void 0;
435
- const record = readRunRecord(runId, deps);
436
- if (!record) return;
437
- const activity = serializeActivity();
438
- writeRunRecord({ ...record, activity }, deps);
439
- lastWriteAt = now().getTime();
435
+ withRunRecordLock(
436
+ runId,
437
+ deps,
438
+ () => {
439
+ const record = readRunRecord(runId, deps);
440
+ if (!record) return;
441
+ const activity = serializeActivity();
442
+ writeRunRecord({ ...record, activity }, deps);
443
+ lastWriteAt = now().getTime();
444
+ },
445
+ { strict: true }
446
+ );
440
447
  }
441
448
  function scheduleWrite() {
442
449
  if (writeTimer !== void 0) return;
@@ -498,6 +505,16 @@ function readRunRecord(runId, deps = {}) {
498
505
  }
499
506
  return null;
500
507
  }
508
+ function backfillRunRecordParentDialog(runId, parentDialogId, deps = {}) {
509
+ if (!parentDialogId) return false;
510
+ const updated = withRunRecordLock(runId, deps, () => {
511
+ const record = readRunRecord(runId, deps);
512
+ if (!record || record.parentDialogId) return false;
513
+ writeRunRecord({ ...record, parentDialogId }, deps);
514
+ return true;
515
+ });
516
+ return updated === true;
517
+ }
501
518
  function listRunRecords(deps = {}) {
502
519
  const fs = deps.fs ?? nodeFs;
503
520
  const dir = resolveRunsDir(deps.env, deps.homedir);
@@ -1391,6 +1408,7 @@ export {
1391
1408
  writeRunRecord,
1392
1409
  createRunActivityTracker,
1393
1410
  readRunRecord,
1411
+ backfillRunRecordParentDialog,
1394
1412
  listRunRecords,
1395
1413
  findRunRecordByPid,
1396
1414
  findRunRecord,
@@ -0,0 +1,297 @@
1
+ import {
2
+ require_react
3
+ } from "./chunk-YDH3FDFQ.js";
4
+ import {
5
+ createSpaceKey,
6
+ normalizeSpaceId
7
+ } from "./chunk-UAD2WT54.js";
8
+ import {
9
+ toTimestampMs
10
+ } from "./chunk-273FJUYI.js";
11
+ import {
12
+ fetchFromServer,
13
+ getAllServers
14
+ } from "./chunk-QOKAKDPE.js";
15
+ import {
16
+ isTombstoneRecord
17
+ } from "./chunk-GBRG75BQ.js";
18
+ import {
19
+ __toESM
20
+ } from "./chunk-4VNS5WPM.js";
21
+
22
+ // packages/create/space/spaceMembershipStore.ts
23
+ var import_react = __toESM(require_react(), 1);
24
+ var createInitialState = () => ({
25
+ memberSpaces: null,
26
+ loading: false,
27
+ membershipStatus: "idle",
28
+ initialized: false
29
+ });
30
+ var state = createInitialState();
31
+ var listeners = /* @__PURE__ */ new Set();
32
+ var version = 0;
33
+ var notify = () => {
34
+ version += 1;
35
+ for (const listener of listeners) {
36
+ try {
37
+ listener();
38
+ } catch {
39
+ }
40
+ }
41
+ };
42
+ var getMembershipUpdatedAt = (space) => {
43
+ if (!space) return 0;
44
+ return toTimestampMs(
45
+ space.spaceUpdatedAt ?? space.memberUpdatedAt ?? space.updatedAt ?? space.createdAt ?? space.joinedAt
46
+ );
47
+ };
48
+ function dedupeMemberSpacesById(memberSpaces) {
49
+ const membershipMap = /* @__PURE__ */ new Map();
50
+ memberSpaces.forEach((space) => {
51
+ const prev = membershipMap.get(space.spaceId);
52
+ if (!prev || getMembershipUpdatedAt(space) >= getMembershipUpdatedAt(prev)) {
53
+ membershipMap.set(space.spaceId, space);
54
+ }
55
+ });
56
+ return Array.from(membershipMap.values());
57
+ }
58
+ function getMemberSpaces() {
59
+ return state.memberSpaces;
60
+ }
61
+ function getAllMemberSpaces() {
62
+ const memberSpaces = dedupeMemberSpacesById(state.memberSpaces || []);
63
+ return [...memberSpaces].sort((a, b) => {
64
+ return getMembershipUpdatedAt(b) - getMembershipUpdatedAt(a);
65
+ });
66
+ }
67
+ function setMemberSpaces(spaces) {
68
+ state = {
69
+ ...state,
70
+ memberSpaces: spaces,
71
+ loading: false,
72
+ error: void 0,
73
+ membershipStatus: "fresh",
74
+ initialized: true
75
+ };
76
+ notify();
77
+ }
78
+ function setMembershipLoading() {
79
+ state = { ...state, loading: true, membershipStatus: "loading" };
80
+ notify();
81
+ }
82
+ function setMembershipRejected(errorMessage, isRemoteUnavailable) {
83
+ const membershipStatus = isRemoteUnavailable ? "offline" : state.membershipStatus === "loading" ? "idle" : state.membershipStatus;
84
+ state = {
85
+ ...state,
86
+ loading: false,
87
+ error: errorMessage,
88
+ membershipStatus
89
+ };
90
+ notify();
91
+ }
92
+ function hydrateMemberSpacesFromLocal(spaces) {
93
+ if (state.memberSpaces !== null || spaces.length === 0) return;
94
+ state = {
95
+ ...state,
96
+ memberSpaces: dedupeMemberSpacesById(spaces),
97
+ loading: false
98
+ };
99
+ notify();
100
+ }
101
+ function appendRecoveredMemberships(recovered) {
102
+ if (!recovered || recovered.length === 0) return;
103
+ if (state.memberSpaces === null) {
104
+ state = {
105
+ ...state,
106
+ memberSpaces: dedupeMemberSpacesById(recovered)
107
+ };
108
+ notify();
109
+ return;
110
+ }
111
+ state = {
112
+ ...state,
113
+ memberSpaces: dedupeMemberSpacesById([
114
+ ...state.memberSpaces,
115
+ ...recovered
116
+ ]).sort((a, b) => toTimestampMs(b.joinedAt) - toTimestampMs(a.joinedAt))
117
+ };
118
+ notify();
119
+ }
120
+ function setSpaceInitialized() {
121
+ state = { ...state, initialized: true };
122
+ notify();
123
+ }
124
+ function setMembershipLoaded() {
125
+ state = { ...state, loading: false, error: void 0 };
126
+ notify();
127
+ }
128
+ function addMemberSpace(space) {
129
+ const existing = state.memberSpaces || [];
130
+ state = {
131
+ ...state,
132
+ memberSpaces: dedupeMemberSpacesById([...existing, space])
133
+ };
134
+ notify();
135
+ }
136
+ function removeMemberSpace(spaceId) {
137
+ if (!state.memberSpaces) return;
138
+ const normalized = normalizeSpaceId(spaceId);
139
+ state = {
140
+ ...state,
141
+ memberSpaces: state.memberSpaces.filter(
142
+ (s) => normalizeSpaceId(s.spaceId) !== normalized
143
+ )
144
+ };
145
+ notify();
146
+ }
147
+ function updateMemberSpaceName(spaceId, name) {
148
+ if (!state.memberSpaces || !name) return;
149
+ state = {
150
+ ...state,
151
+ memberSpaces: state.memberSpaces.map(
152
+ (space) => space.spaceId === spaceId ? { ...space, spaceName: name } : space
153
+ )
154
+ };
155
+ notify();
156
+ }
157
+
158
+ // packages/create/space/spaceAccess.ts
159
+ var resolveSpaceRemoteServers = (state2) => {
160
+ const currentServer = typeof state2?.settings?.currentServer === "string" ? state2.settings.currentServer : void 0;
161
+ const syncServers = Array.isArray(state2?.settings?.syncServers) ? state2.settings.syncServers : void 0;
162
+ return getAllServers(currentServer, syncServers);
163
+ };
164
+ var selectSpaceRemoteAuth = (state2) => ({
165
+ token: state2?.auth?.currentToken ?? null,
166
+ userId: state2?.auth?.currentUser?.userId ?? null,
167
+ servers: resolveSpaceRemoteServers(state2)
168
+ });
169
+ var spaceListsUser = (spaceData, userId) => {
170
+ if (!spaceData || isTombstoneRecord(spaceData)) return false;
171
+ if (spaceData.ownerId === userId) return true;
172
+ return Array.isArray(spaceData.members) && spaceData.members.includes(userId);
173
+ };
174
+ var membershipBelongsToUser = (membership, userId) => !membership.userId || membership.userId === userId;
175
+ var membershipFetchCache = /* @__PURE__ */ new Map();
176
+ var MEMBERSHIP_FETCH_CACHE_TTL_MS = 3e4;
177
+ async function fetchMembershipsFromServer(server, token, userId, timeoutMs) {
178
+ if (!token) return { ok: false, memberships: [] };
179
+ const controller = new AbortController();
180
+ const timeoutId = setTimeout(() => controller.abort(), timeoutMs);
181
+ try {
182
+ const response = await fetch(`${server}/rpc/getUserSpaceMemberships`, {
183
+ method: "POST",
184
+ headers: {
185
+ Authorization: `Bearer ${token}`,
186
+ "Content-Type": "application/json"
187
+ },
188
+ body: JSON.stringify({ userId }),
189
+ signal: controller.signal
190
+ });
191
+ clearTimeout(timeoutId);
192
+ if (!response.ok) {
193
+ console.error(
194
+ `Failed to fetch memberships from ${server}: ${response.statusText}`
195
+ );
196
+ return { ok: false, memberships: [] };
197
+ }
198
+ const data = await response.json();
199
+ return {
200
+ ok: true,
201
+ server,
202
+ memberships: Array.isArray(data) ? data : []
203
+ };
204
+ } catch (error) {
205
+ clearTimeout(timeoutId);
206
+ console.error(`Error fetching memberships from ${server}:`, error);
207
+ return { ok: false, memberships: [] };
208
+ }
209
+ }
210
+ var fetchRemoteUserSpaceMemberships = (server, token, userId, timeoutMs = 5e3) => {
211
+ const cacheKey = `${server}|${userId}`;
212
+ const cached = membershipFetchCache.get(cacheKey);
213
+ if (cached) return cached;
214
+ const promise = fetchMembershipsFromServer(server, token, userId, timeoutMs);
215
+ membershipFetchCache.set(cacheKey, promise);
216
+ promise.catch(() => {
217
+ }).finally(() => {
218
+ setTimeout(() => {
219
+ if (membershipFetchCache.get(cacheKey) === promise) {
220
+ membershipFetchCache.delete(cacheKey);
221
+ }
222
+ }, MEMBERSHIP_FETCH_CACHE_TTL_MS);
223
+ });
224
+ return promise;
225
+ };
226
+ var fetchRemoteSpace = async (server, token, spaceId) => {
227
+ try {
228
+ const space = await fetchFromServer(
229
+ server,
230
+ createSpaceKey.space(normalizeSpaceId(spaceId)),
231
+ token ?? void 0
232
+ );
233
+ return space && typeof space === "object" ? space : null;
234
+ } catch {
235
+ return null;
236
+ }
237
+ };
238
+ var hasActiveRemoteMembership = async (server, token, userId, spaceId) => {
239
+ const result = await fetchRemoteUserSpaceMemberships(server, token, userId);
240
+ if (!result.ok) return false;
241
+ const normalizedSpaceId = normalizeSpaceId(spaceId);
242
+ return result.memberships.some((membership) => {
243
+ const membershipSpaceId = typeof membership?.spaceId === "string" ? normalizeSpaceId(membership.spaceId) : "";
244
+ return membershipSpaceId === normalizedSpaceId && membershipBelongsToUser(membership, userId) && !isTombstoneRecord(membership);
245
+ });
246
+ };
247
+ var fetchAuthoritativeRemoteSpace = async ({
248
+ servers,
249
+ token,
250
+ userId,
251
+ spaceId
252
+ }) => {
253
+ const normalizedSpaceId = normalizeSpaceId(spaceId);
254
+ for (const server of servers) {
255
+ const space = await fetchRemoteSpace(server, token, normalizedSpaceId);
256
+ if (!space) continue;
257
+ if (!spaceListsUser(space, userId)) {
258
+ throw new Error(`Current user is not a member of space: ${normalizedSpaceId}`);
259
+ }
260
+ if (space.ownerId !== userId) {
261
+ const hasMembership = await hasActiveRemoteMembership(
262
+ server,
263
+ token,
264
+ userId,
265
+ normalizedSpaceId
266
+ );
267
+ if (!hasMembership) {
268
+ throw new Error(
269
+ `Current user has no active membership for space: ${normalizedSpaceId}`
270
+ );
271
+ }
272
+ }
273
+ return space;
274
+ }
275
+ return null;
276
+ };
277
+
278
+ export {
279
+ selectSpaceRemoteAuth,
280
+ spaceListsUser,
281
+ membershipBelongsToUser,
282
+ fetchRemoteUserSpaceMemberships,
283
+ fetchRemoteSpace,
284
+ fetchAuthoritativeRemoteSpace,
285
+ getMemberSpaces,
286
+ getAllMemberSpaces,
287
+ setMemberSpaces,
288
+ setMembershipLoading,
289
+ setMembershipRejected,
290
+ hydrateMemberSpacesFromLocal,
291
+ appendRecoveredMemberships,
292
+ setSpaceInitialized,
293
+ setMembershipLoaded,
294
+ addMemberSpace,
295
+ removeMemberSpace,
296
+ updateMemberSpaceName
297
+ };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  clearCliLocalRuntimePreparedAgentCache
3
- } from "./chunk-QUCSAM43.js";
3
+ } from "./chunk-EAYBPWHX.js";
4
4
  import {
5
5
  getReadableCliDb
6
6
  } from "./chunk-43CXXVJD.js";
@@ -12,7 +12,7 @@ import {
12
12
  resolveAgentRecordFromHybridStore,
13
13
  sanitizeAgentRecordForCliOutput,
14
14
  writeAgentRecord
15
- } from "./chunk-DQLYEGP7.js";
15
+ } from "./chunk-EGVY3GMT.js";
16
16
  import {
17
17
  resolveCliAgentKeyInput
18
18
  } from "./chunk-EKLRRZIN.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getActiveDialogKey
3
- } from "./chunk-MRWGHF56.js";
3
+ } from "./chunk-6YTOJY35.js";
4
4
  import {
5
5
  compactWhitespace
6
6
  } from "./chunk-DWLEOOGR.js";
@@ -0,0 +1,64 @@
1
+ // packages/create/space/spaceKeys.ts
2
+ var SEPARATOR = "-";
3
+ var SPACE_PREFIX = "space";
4
+ var SPACE_PREFIX_WITH_SEPARATOR = `${SPACE_PREFIX}${SEPARATOR}`;
5
+ var normalizeSpaceId = (spaceId) => {
6
+ if (!spaceId) return spaceId;
7
+ return spaceId.startsWith(SPACE_PREFIX_WITH_SEPARATOR) ? spaceId.slice(SPACE_PREFIX_WITH_SEPARATOR.length) : spaceId;
8
+ };
9
+ var createSpaceKey = {
10
+ // 空间基础信息的key
11
+ space: (spaceId) => {
12
+ return [SPACE_PREFIX, normalizeSpaceId(spaceId)].join(SEPARATOR);
13
+ },
14
+ // 空间成员的key
15
+ member: (userId, spaceId) => {
16
+ return [SPACE_PREFIX, "member", userId, normalizeSpaceId(spaceId)].join(
17
+ SEPARATOR
18
+ );
19
+ },
20
+ // 查询用户所在的所有空间的范围
21
+ memberRange: (userId) => {
22
+ return {
23
+ start: [SPACE_PREFIX, "member", userId, ""].join(SEPARATOR),
24
+ end: [SPACE_PREFIX, "member", userId, "\uFFFF"].join(SEPARATOR)
25
+ };
26
+ },
27
+ /**
28
+ * 预留:未来若出现“按用户、按空间、且必须跨设备同步”的空间级偏好,
29
+ * 统一使用这个 key family。当前产品主链不要依赖它。
30
+ */
31
+ setting: (userId, spaceId) => {
32
+ return [SPACE_PREFIX, "setting", userId, normalizeSpaceId(spaceId)].join(
33
+ SEPARATOR
34
+ );
35
+ },
36
+ /**
37
+ * 预留:未来如确实需要批量读取空间级远端偏好,再使用这个范围。
38
+ */
39
+ settingRange: (userId) => {
40
+ return {
41
+ start: [SPACE_PREFIX, "setting", userId, ""].join(SEPARATOR),
42
+ end: [SPACE_PREFIX, "setting", userId, "\uFFFF"].join(SEPARATOR)
43
+ };
44
+ },
45
+ // 从成员key中提取空间key
46
+ // 成员 key 格式: space-member-{userId}-{spaceId}
47
+ // userId 是单段(无连字符),spaceId 是 ULID(无连字符)
48
+ spaceFromMember: (memberKey) => {
49
+ const parts = memberKey.split(SEPARATOR);
50
+ if (parts.length < 4) return "";
51
+ const spaceId = parts[parts.length - 1];
52
+ return [SPACE_PREFIX, spaceId].join(SEPARATOR);
53
+ },
54
+ // 从成员key中提取空间ID
55
+ spaceIdFromMember: (memberKey) => {
56
+ const parts = memberKey.split(SEPARATOR);
57
+ return parts.length >= 4 ? parts[parts.length - 1] : "";
58
+ }
59
+ };
60
+
61
+ export {
62
+ normalizeSpaceId,
63
+ createSpaceKey
64
+ };
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  MODEL_LOOKUP_MAP
3
- } from "./chunk-QDHZCAH3.js";
3
+ } from "./chunk-KNQ5LYVZ.js";
4
4
  import {
5
5
  ALL_MODELS
6
- } from "./chunk-56W233KG.js";
6
+ } from "./chunk-YWY25N4V.js";
7
7
  import {
8
8
  PUBLIC_DEEPSEEK_V4_FLASH_AGENT_KEY
9
- } from "./chunk-2JYSSXLY.js";
9
+ } from "./chunk-EJFW7TRP.js";
10
10
 
11
11
  // packages/ai/llm/getModelContextWindow.ts
12
12
  var DEFAULT_CONTEXT_WINDOW = 256e3;