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.
- package/{_executeModel-KE4PQSZ3.js → _executeModel-JKEH7ACW.js} +48 -42
- package/{action-IU6ON7ZB.js → action-VSG2IYP3.js} +8 -8
- package/{addContentAction-5V5CCI3I.js → addContentAction-2HJJITDI.js} +8 -7
- package/{addDialogAgentAction-KF3KZZNZ.js → addDialogAgentAction-7BSQVVL5.js} +10 -9
- package/{agentDeleteCommand-Z67TJG3W.js → agentDeleteCommand-SVXKS5SC.js} +30 -28
- package/{agentEmailCommands-7LPIK7JE.js → agentEmailCommands-WN7QBTP3.js} +57 -52
- package/{agentListCommands-5J2IM3IT.js → agentListCommands-2BEBOQIG.js} +42 -33
- package/{agentMachineCommands-YXH6FXUQ.js → agentMachineCommands-WALP3ONU.js} +30 -28
- package/{agentRecordCommands-GZLCDVUS.js → agentRecordCommands-E652SW57.js} +55 -50
- package/{agentRunCommand-WYH5Q54Q.js → agentRunCommand-6VXWXKCS.js} +60 -53
- package/{agentRunControl-4GHHSXFZ.js → agentRunControl-LJVFDJGU.js} +3 -1
- package/{agentRuntimeLocal-A6EF3RUY.js → agentRuntimeLocal-SBG7BDFQ.js} +30 -26
- package/{agentSlice-ARTDF6VD.js → agentSlice-3WYXIGEO.js} +8 -8
- package/{agentSuperviseCommands-VB6BUS5H.js → agentSuperviseCommands-F3RFAL7K.js} +2 -2
- package/{appDeleteCommands-V2B7ZCLC.js → appDeleteCommands-NTUNMEXY.js} +31 -29
- package/{appDeployCommands-AXQU44RD.js → appDeployCommands-DISWXRTL.js} +31 -29
- package/{appDeployStatusCommands-FWGSC2UM.js → appDeployStatusCommands-IKRA6B6F.js} +31 -29
- package/{appGetCommands-67R3RFZK.js → appGetCommands-UMOP2DFV.js} +31 -29
- package/{appListCommands-TTASJPGV.js → appListCommands-ZKFD2AKS.js} +31 -29
- package/{authCommand-QOPOEYEK.js → authCommand-BS3CQC6I.js} +11 -11
- package/{chatQueueReduxAdapter-6CAHUQ4O.js → chatQueueReduxAdapter-A3YH4MT4.js} +24 -21
- package/{chunk-76UA7376.js → chunk-273FJUYI.js} +6 -6
- package/{chunk-7CH6U3FL.js → chunk-2GRGFCF6.js} +2 -4
- package/{chunk-T27IEBNQ.js → chunk-2QDDKFG5.js} +74 -1
- package/{chunk-IRJVFYOH.js → chunk-2TLYVDTN.js} +321 -1100
- package/{chunk-6BYAXNH5.js → chunk-3QOCS5IF.js} +11 -2
- package/chunk-6IGD47IC.js +19 -0
- package/{chunk-GFD7TIZU.js → chunk-6TUT5ZJD.js} +4 -6
- package/chunk-6YTOJY35.js +352 -0
- package/{chunk-B54WOZ77.js → chunk-7H7GQL6V.js} +2 -2
- package/{chunk-OYNDYVSE.js → chunk-B45YNDAE.js} +1 -1
- package/{chunk-UQWFIWHX.js → chunk-BKIDF5LV.js} +1 -1
- package/{chunk-5XCW6RQG.js → chunk-BUBPRCIU.js} +1 -1
- package/chunk-BYXBJQAS.js +0 -0
- package/{chunk-X7S7OFUX.js → chunk-CEVCRRHU.js} +4 -4
- package/{chunk-SP3DPVBH.js → chunk-DEIGUGP6.js} +2 -2
- package/{chunk-V2IPBG5U.js → chunk-DGEPT6FH.js} +1 -1
- package/{chunk-3AOLVADY.js → chunk-DVINR3PL.js} +1 -1
- package/{chunk-NN3AMBY3.js → chunk-DXOELY7S.js} +64 -69
- package/{chunk-OFZPJ3NT.js → chunk-E4MARS3Q.js} +1 -1
- package/{chunk-QUCSAM43.js → chunk-EAYBPWHX.js} +87 -66
- package/{chunk-DQLYEGP7.js → chunk-EGVY3GMT.js} +1 -1
- package/{chunk-2JYSSXLY.js → chunk-EJFW7TRP.js} +5 -26
- package/{chunk-HPZL4IBN.js → chunk-FGRCSLPV.js} +34 -45
- package/{chunk-WL3UOGYO.js → chunk-G4WSLTQF.js} +31 -97
- package/{chunk-HR5XDXYM.js → chunk-G5SQVIFZ.js} +3 -3
- package/{chunk-J3UALFHL.js → chunk-GHE5XMVR.js} +1 -1
- package/{chunk-6SMMK7MD.js → chunk-GKB4AZKV.js} +440 -2981
- package/{chunk-IKSFDJXB.js → chunk-GKNGRBE6.js} +150 -27
- package/{chunk-Q24S4NDF.js → chunk-HQTK2SFT.js} +1 -1
- package/{chunk-GDGIEGHV.js → chunk-IPTZ5TVU.js} +7 -6
- package/{chunk-4RXXP6WD.js → chunk-J7KDNHUO.js} +5 -64
- package/{chunk-QDHZCAH3.js → chunk-KNQ5LYVZ.js} +57 -2
- package/{chunk-VRJUIUIY.js → chunk-KVVNC5V3.js} +2 -2
- package/{chunk-CVT7L2WZ.js → chunk-LVCAWHI5.js} +4 -4
- package/{chunk-WX5E6HZS.js → chunk-N6SLQMSA.js} +6 -6
- package/{chunk-SQTVMYMU.js → chunk-NTZO3KX2.js} +3 -3
- package/{chunk-LGUQHYAL.js → chunk-O5FLGN2L.js} +3 -2
- package/{chunk-WKOEOQCI.js → chunk-OSUZKICS.js} +1600 -190
- package/{chunk-EXDR5D6X.js → chunk-Q2QN2RHG.js} +7 -7
- package/{chunk-L3JWI7WX.js → chunk-QOKAKDPE.js} +15 -11
- package/{chunk-757BGY6Y.js → chunk-RFYXK6KI.js} +1 -1
- package/chunk-RQSN75DW.js +1766 -0
- package/{chunk-HCMFFI2G.js → chunk-S3JNURSO.js} +2 -2
- package/{chunk-YZ2WE6CW.js → chunk-SAJSBPI2.js} +2 -2
- package/{chunk-WHVQA7PJ.js → chunk-SCBBGS2N.js} +23 -5
- package/chunk-SGSJBBKP.js +297 -0
- package/{chunk-GFUOVFQA.js → chunk-TUBNQ3OF.js} +2 -2
- package/{chunk-BANYWEYY.js → chunk-TY3ADTX5.js} +1 -1
- package/chunk-UAD2WT54.js +64 -0
- package/{chunk-SW7RCUGA.js → chunk-UEV5WVQV.js} +3 -3
- package/{chunk-EURF2SV6.js → chunk-UMCMW5R3.js} +51 -34
- package/{chunk-K524MUQC.js → chunk-VFDRZHPM.js} +16 -16
- package/{chunk-5WADL4O7.js → chunk-W22UTILW.js} +3 -3
- package/{chunk-IKTHA3JH.js → chunk-WERPP2S7.js} +2 -2
- package/{chunk-GBADO3SM.js → chunk-WSUHBABG.js} +1 -1
- package/{chunk-U5Z7LFZF.js → chunk-X3OGKR5Q.js} +4 -4
- package/{chunk-AVKUDHJO.js → chunk-X5LRMXTS.js} +10 -10
- package/{chunk-DIQCV4FR.js → chunk-X665UCNM.js} +1 -1
- package/{chunk-HCBQVVFZ.js → chunk-X7P6EJUY.js} +4 -4
- package/{chunk-HHBXCRJS.js → chunk-XOJRZUPF.js} +4 -4
- package/{chunk-MRWGHF56.js → chunk-YDH3FDFQ.js} +12 -356
- package/{chunk-TNPCQNGQ.js → chunk-YEFRCO5N.js} +4 -9
- package/{chunk-RO2IUWZE.js → chunk-YUKTCDVN.js} +1 -1
- package/{chunk-56W233KG.js → chunk-YWY25N4V.js} +1 -1
- package/{chunk-RU5D3B22.js → chunk-ZDS63Y4O.js} +2 -2
- package/chunk-ZJ7UHBJS.js +89 -0
- package/{chunk-SG65C33A.js → chunk-ZLMG6NRV.js} +4 -4
- package/{codingSkills-BYQI6EPT.js → codingSkills-FQPCEIWL.js} +2 -2
- package/contentThunks-J33BZB3E.js +71 -0
- package/{createAgentAutomationAction-7BBF5YXN.js → createAgentAutomationAction-HTMTGX6Q.js} +25 -21
- package/{createDialogAction-B5URPHP4.js → createDialogAction-WYQBSN6A.js} +27 -23
- package/{createPageAction-ISJKM5Q3.js → createPageAction-ICRRK3SA.js} +27 -22
- package/{dbSlice-FWF5F4L7.js → dbSlice-YORO4VL4.js} +6 -6
- package/{deleteFile-NPZ64DFN.js → deleteFile-JYKRT7C3.js} +4 -4
- package/{dialogCommands-XHH4MVA4.js → dialogCommands-FRSIAPKY.js} +31 -29
- package/{dialogSlice-NRAN5X7F.js → dialogSlice-5KPVIAWH.js} +24 -21
- package/{docCreateCommands-FUN2Z7HQ.js → docCreateCommands-DBRJMPDX.js} +30 -28
- package/{docDeleteCommands-OZDPFXPF.js → docDeleteCommands-BCYPLWXN.js} +31 -29
- package/{docReadCommands-FIPK7LE3.js → docReadCommands-L5JX4Q7G.js} +30 -28
- package/{docStore-LUS7SWC3.js → docStore-34NXLCEO.js} +8 -33
- package/{docUpdateCommands-BZ5GKAN4.js → docUpdateCommands-RELG7XJD.js} +30 -28
- package/fetchMessages-KZQVBXKY.js +1 -1
- package/{getPricing-HAU62AFM.js → getPricing-FM7TJZFV.js} +4 -4
- package/{handleSendMessageAction-RA4OD2ZH.js → handleSendMessageAction-MEYK7RPD.js} +25 -22
- package/index.js +64 -64
- package/{machineCommands-WDAYEFBE.js → machineCommands-YSXTOWHQ.js} +59 -54
- package/{machineWsRunDispatch-TPQ2FQVS.js → machineWsRunDispatch-DNAYOPQT.js} +54 -49
- package/memberThunks-KVPBG4V7.js +638 -0
- package/{models-4QF4BJVY.js → models-CW5EL6Z7.js} +2 -2
- package/package.json +2 -3
- package/{read-J7RVVCHH.js → read-NIOV5F7W.js} +4 -4
- package/{readDocTool-G2WBM4IH.js → readDocTool-ULKJ5BEM.js} +1 -1
- package/{readlineWorkspace-HN44KGIF.js → readlineWorkspace-KZ3LPQG2.js} +829 -393
- package/{removeDialogAgentAction-RMPISD42.js → removeDialogAgentAction-JGSCPML3.js} +12 -11
- package/{runAgentClientLoop-ZYUI22EA.js → runAgentClientLoop-O2AUHIJT.js} +46 -40
- package/{setDialogExtraReferencesAction-7BUTHDAL.js → setDialogExtraReferencesAction-CORU64NM.js} +9 -8
- package/{setPrimaryDialogAgentAction-WCYIBGZ4.js → setPrimaryDialogAgentAction-5VS2VKLZ.js} +12 -11
- package/{settingSlice-7NN2MI6Y.js → settingSlice-3GNGTC2T.js} +7 -7
- package/{skillDiscovery-COX56OBO.js → skillDiscovery-CYUCJMAG.js} +3 -3
- package/{spaceCommands-OJ2567D4.js → spaceCommands-OI7RIB2T.js} +30 -28
- package/{streamAgentChatTurn-FNFMMGNN.js → streamAgentChatTurn-TA3PGS6C.js} +61 -54
- package/{switchDialogAgentAction-WGMMQHDI.js → switchDialogAgentAction-LP433X4D.js} +10 -9
- package/{tableCommands-P2TXJ3CF.js → tableCommands-R6WFRDYF.js} +1 -1
- package/{toolApiClient-B2MFXMEG.js → toolApiClient-53U4UDFF.js} +3 -2
- package/{tools-QCDR3UMD.js → tools-6ZPQ75XA.js} +37 -32
- package/{tuiSummaryLlmCaller-LCGT62QC.js → tuiSummaryLlmCaller-YKYQB4ZL.js} +17 -15
- package/{updateDialogTitleAction-Y3OGJWDB.js → updateDialogTitleAction-LRJ7NSOS.js} +26 -22
- package/chunk-EUG45QJR.js +0 -6104
- package/spaceSlice-F7JCOZEF.js +0 -127
- package/{chunk-NQ4N4IGO.js → chunk-CS6TCJ7E.js} +3 -3
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
toCompactAgentSummary,
|
|
18
18
|
toSafeAgentSummary,
|
|
19
19
|
toUnavailableAgentSummary
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-ZDS63Y4O.js";
|
|
21
21
|
import {
|
|
22
22
|
getUserDataItemTimestamp,
|
|
23
23
|
mergeAndDedupUserData
|
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
readPageFunc,
|
|
29
29
|
readPageFunctionSchema,
|
|
30
30
|
slateToSimplifiedMarkdown
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-BUBPRCIU.js";
|
|
32
32
|
import {
|
|
33
33
|
TASK_PREVIEW_MAX,
|
|
34
34
|
buildDelegatedTaskContent,
|
|
@@ -39,11 +39,17 @@ import {
|
|
|
39
39
|
resolveRunLabel
|
|
40
40
|
} from "./chunk-KXKQO4Q6.js";
|
|
41
41
|
import {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
addMemberSpace,
|
|
43
|
+
fetchAuthoritativeRemoteSpace,
|
|
44
|
+
getAllMemberSpaces,
|
|
45
|
+
removeMemberSpace,
|
|
46
|
+
selectSpaceRemoteAuth,
|
|
47
|
+
setMembershipLoaded,
|
|
48
|
+
setMembershipLoading,
|
|
49
|
+
setMembershipRejected,
|
|
50
|
+
setSpaceInitialized,
|
|
51
|
+
updateMemberSpaceName
|
|
52
|
+
} from "./chunk-SGSJBBKP.js";
|
|
47
53
|
import {
|
|
48
54
|
ToolApiError,
|
|
49
55
|
buildToolRequestHeaders,
|
|
@@ -51,10 +57,13 @@ import {
|
|
|
51
57
|
getRequestConfig,
|
|
52
58
|
getToolBaseUrl,
|
|
53
59
|
getToolRequestContext
|
|
54
|
-
} from "./chunk-
|
|
60
|
+
} from "./chunk-TY3ADTX5.js";
|
|
55
61
|
import {
|
|
56
62
|
setDialogExtraReferencesAction
|
|
57
|
-
} from "./chunk-
|
|
63
|
+
} from "./chunk-X7P6EJUY.js";
|
|
64
|
+
import {
|
|
65
|
+
markdownToSlate
|
|
66
|
+
} from "./chunk-INZZJSQF.js";
|
|
58
67
|
import {
|
|
59
68
|
extractMentionsFromSlate
|
|
60
69
|
} from "./chunk-MEYIRKDN.js";
|
|
@@ -64,34 +73,49 @@ import {
|
|
|
64
73
|
import {
|
|
65
74
|
isSkillSummaryMarker
|
|
66
75
|
} from "./chunk-VF4K2QE6.js";
|
|
76
|
+
import {
|
|
77
|
+
createDocState
|
|
78
|
+
} from "./chunk-6TUT5ZJD.js";
|
|
67
79
|
import {
|
|
68
80
|
BUILTIN_OBJECT_SKILL_IDS,
|
|
69
81
|
buildBuiltinObjectSkillConfig,
|
|
70
82
|
buildBuiltinObjectSkillDbKey,
|
|
71
83
|
buildBuiltinObjectSkillPageContent,
|
|
72
84
|
createDialogAction
|
|
73
|
-
} from "./chunk-
|
|
85
|
+
} from "./chunk-X5LRMXTS.js";
|
|
74
86
|
import {
|
|
75
|
-
|
|
87
|
+
DEFAULT_COLLAPSED_CATEGORIES,
|
|
76
88
|
addContentToSpace,
|
|
77
89
|
addRow,
|
|
78
90
|
createTable,
|
|
79
|
-
|
|
80
|
-
|
|
91
|
+
deleteContentFromSpace,
|
|
92
|
+
deleteTable,
|
|
93
|
+
expandCategoryInCollapsed,
|
|
81
94
|
fetchAndCacheTableRows,
|
|
82
|
-
|
|
83
|
-
getAllMemberSpaces,
|
|
84
|
-
getCurrentSpaceId,
|
|
85
|
-
getCurrentSpaceIdRaw,
|
|
86
|
-
getViewMode,
|
|
95
|
+
getCollapsedCategories,
|
|
87
96
|
i18nBaseConfig,
|
|
88
97
|
initReactI18next,
|
|
89
98
|
instance,
|
|
90
99
|
loadTableRows,
|
|
100
|
+
readStoredCollapsedCategories,
|
|
101
|
+
setCollapsedCategories,
|
|
102
|
+
toggleCategoryCollapse,
|
|
91
103
|
updateContentCategory,
|
|
92
|
-
updateContentTitle
|
|
93
|
-
|
|
104
|
+
updateContentTitle,
|
|
105
|
+
writeStoredCollapsedCategories
|
|
106
|
+
} from "./chunk-GKB4AZKV.js";
|
|
94
107
|
import {
|
|
108
|
+
getCurrentSpaceId,
|
|
109
|
+
getCurrentSpaceIdRaw,
|
|
110
|
+
getCurrentSpaceRaw,
|
|
111
|
+
getViewMode,
|
|
112
|
+
setCurrentSpace,
|
|
113
|
+
setCurrentSpaceBoth,
|
|
114
|
+
setViewMode,
|
|
115
|
+
updateCurrentSpaceIfMatch
|
|
116
|
+
} from "./chunk-ZJ7UHBJS.js";
|
|
117
|
+
import {
|
|
118
|
+
deleteDialog,
|
|
95
119
|
normalizeAppRouteId,
|
|
96
120
|
resolveDialogRuntimeAgentKey,
|
|
97
121
|
selectAllMsgs,
|
|
@@ -100,29 +124,32 @@ import {
|
|
|
100
124
|
selectMsgById,
|
|
101
125
|
uiAskChoiceFunc,
|
|
102
126
|
uiAskChoiceFunctionSchema
|
|
103
|
-
} from "./chunk-
|
|
127
|
+
} from "./chunk-UMCMW5R3.js";
|
|
104
128
|
import {
|
|
105
129
|
createAgent,
|
|
130
|
+
deleteServerSyncedCredential,
|
|
106
131
|
runLlm,
|
|
107
132
|
streamAgentChatTurn,
|
|
108
133
|
updateAgent
|
|
109
|
-
} from "./chunk-
|
|
134
|
+
} from "./chunk-N6SLQMSA.js";
|
|
110
135
|
import {
|
|
111
136
|
getActiveDialogKey,
|
|
112
|
-
require_react,
|
|
113
137
|
selectCurrentDialogKey,
|
|
114
138
|
selectPendingRawDataByPageKey
|
|
115
|
-
} from "./chunk-
|
|
139
|
+
} from "./chunk-6YTOJY35.js";
|
|
140
|
+
import {
|
|
141
|
+
require_react
|
|
142
|
+
} from "./chunk-YDH3FDFQ.js";
|
|
116
143
|
import {
|
|
117
144
|
CODING_SKILL_SLUGS,
|
|
118
145
|
buildCodingSkillConfig,
|
|
119
146
|
buildCodingSkillContentBySlug,
|
|
120
147
|
buildCodingSkillId,
|
|
121
148
|
buildCodingSkillPageKey
|
|
122
|
-
} from "./chunk-
|
|
149
|
+
} from "./chunk-DGEPT6FH.js";
|
|
123
150
|
import {
|
|
124
151
|
CAPABILITY_PACKS
|
|
125
|
-
} from "./chunk-
|
|
152
|
+
} from "./chunk-O5FLGN2L.js";
|
|
126
153
|
import {
|
|
127
154
|
buildSkillDocMarkdown,
|
|
128
155
|
normalizeSkillModalities,
|
|
@@ -145,19 +172,22 @@ import {
|
|
|
145
172
|
redactAgentRecordForWorkspaceTool,
|
|
146
173
|
resolveNoloDialogInput,
|
|
147
174
|
verifyNoloDialogSubjectRefQuery
|
|
148
|
-
} from "./chunk-
|
|
175
|
+
} from "./chunk-YEFRCO5N.js";
|
|
149
176
|
import {
|
|
150
177
|
isAgentUnavailableNow
|
|
151
178
|
} from "./chunk-IWUMSAQF.js";
|
|
152
179
|
import {
|
|
153
180
|
buildDatabaseFileContentUrl
|
|
154
|
-
} from "./chunk-
|
|
181
|
+
} from "./chunk-G5SQVIFZ.js";
|
|
155
182
|
import {
|
|
156
183
|
DEFAULT_MODEL
|
|
157
|
-
} from "./chunk-
|
|
184
|
+
} from "./chunk-KNQ5LYVZ.js";
|
|
158
185
|
import {
|
|
159
186
|
compactWhitespace
|
|
160
187
|
} from "./chunk-DWLEOOGR.js";
|
|
188
|
+
import {
|
|
189
|
+
createFileCredentialBroker
|
|
190
|
+
} from "./chunk-CS6TCJ7E.js";
|
|
161
191
|
import {
|
|
162
192
|
toErrorMessage
|
|
163
193
|
} from "./chunk-HNMXYYJR.js";
|
|
@@ -167,7 +197,7 @@ import {
|
|
|
167
197
|
} from "./chunk-O6OSWFZQ.js";
|
|
168
198
|
import {
|
|
169
199
|
shareResourceAction
|
|
170
|
-
} from "./chunk-
|
|
200
|
+
} from "./chunk-NTZO3KX2.js";
|
|
171
201
|
import {
|
|
172
202
|
AGENT_UPDATE_FIELD_NAMES,
|
|
173
203
|
nolotusId,
|
|
@@ -175,33 +205,46 @@ import {
|
|
|
175
205
|
selectAutoApproveSelfUpdateFields,
|
|
176
206
|
selectCurrentServer,
|
|
177
207
|
selectSyncServers
|
|
178
|
-
} from "./chunk-
|
|
208
|
+
} from "./chunk-CEVCRRHU.js";
|
|
179
209
|
import {
|
|
180
210
|
asRecordOrEmpty
|
|
181
211
|
} from "./chunk-KX6YBIHG.js";
|
|
182
212
|
import {
|
|
213
|
+
UNCATEGORIZED_ID,
|
|
183
214
|
addContentAction,
|
|
215
|
+
checkSpaceMembership
|
|
216
|
+
} from "./chunk-J7KDNHUO.js";
|
|
217
|
+
import {
|
|
184
218
|
createSpaceKey,
|
|
185
219
|
normalizeSpaceId
|
|
186
|
-
} from "./chunk-
|
|
220
|
+
} from "./chunk-UAD2WT54.js";
|
|
187
221
|
import {
|
|
188
222
|
patch,
|
|
189
223
|
read,
|
|
190
224
|
readAndWait,
|
|
191
225
|
readAndWaitAction,
|
|
226
|
+
remove,
|
|
192
227
|
selectById,
|
|
228
|
+
selectEntities,
|
|
193
229
|
toTimestampMs,
|
|
194
230
|
write
|
|
195
|
-
} from "./chunk-
|
|
231
|
+
} from "./chunk-273FJUYI.js";
|
|
196
232
|
import {
|
|
197
233
|
SEPARATOR,
|
|
234
|
+
TYPE_STORAGE_PREFIXES,
|
|
198
235
|
createAgentKey,
|
|
199
236
|
dialogMessageRange,
|
|
200
237
|
fileKey,
|
|
201
238
|
isAgentKey,
|
|
239
|
+
isAppKey,
|
|
240
|
+
isDialogKey,
|
|
241
|
+
isFileKey,
|
|
242
|
+
isPageKey,
|
|
202
243
|
isTableMetaKey,
|
|
244
|
+
isTaskKey,
|
|
203
245
|
metaKey,
|
|
204
246
|
rowKey,
|
|
247
|
+
splitKey,
|
|
205
248
|
toTrimmedString,
|
|
206
249
|
ulid
|
|
207
250
|
} from "./chunk-SVEUG45B.js";
|
|
@@ -218,28 +261,38 @@ import {
|
|
|
218
261
|
import {
|
|
219
262
|
DEFAULT_CODE_PLANNER_EXECUTOR_CANDIDATE_KEYS,
|
|
220
263
|
readAction
|
|
221
|
-
} from "./chunk-
|
|
264
|
+
} from "./chunk-EJFW7TRP.js";
|
|
222
265
|
import {
|
|
223
266
|
extractCustomId
|
|
224
267
|
} from "./chunk-BJIRLHJR.js";
|
|
225
268
|
import {
|
|
269
|
+
DEVICE_LOCAL_OWNER_ID,
|
|
226
270
|
createAsyncThunk,
|
|
227
271
|
getRuntimeServerContext,
|
|
272
|
+
isDeviceLocalOwnerId,
|
|
273
|
+
isDeviceLocalSpaceBody,
|
|
274
|
+
isDeviceLocalSpaceMembership,
|
|
228
275
|
noloWriteRequest,
|
|
276
|
+
resolveEffectiveSpaceActorId,
|
|
277
|
+
resolveRecordOwnerUserId,
|
|
229
278
|
selectIdentityToken,
|
|
230
279
|
selectIdentityUserBalance,
|
|
231
280
|
selectIdentityUserId,
|
|
232
281
|
selectRuntimeSnapshot
|
|
233
|
-
} from "./chunk-
|
|
282
|
+
} from "./chunk-XOJRZUPF.js";
|
|
234
283
|
import {
|
|
235
284
|
isAbortError
|
|
236
|
-
} from "./chunk-
|
|
285
|
+
} from "./chunk-QOKAKDPE.js";
|
|
237
286
|
import {
|
|
238
|
-
|
|
239
|
-
|
|
287
|
+
buildTombstoneRecord,
|
|
288
|
+
isTombstoneRecord
|
|
289
|
+
} from "./chunk-GBRG75BQ.js";
|
|
240
290
|
import {
|
|
241
291
|
asTrimmedString
|
|
242
292
|
} from "./chunk-3EUW3WEO.js";
|
|
293
|
+
import {
|
|
294
|
+
isRecord
|
|
295
|
+
} from "./chunk-KUG52IAP.js";
|
|
243
296
|
import {
|
|
244
297
|
API_ENDPOINTS
|
|
245
298
|
} from "./chunk-LCBAMY2M.js";
|
|
@@ -11830,7 +11883,7 @@ var HOSTED_EXEC_RUNTIME_TOOL_POLICY = {
|
|
|
11830
11883
|
workspace: { mode: "lease" }
|
|
11831
11884
|
};
|
|
11832
11885
|
var findModelConfig = async (modelName, provider) => {
|
|
11833
|
-
const { ALL_MODELS } = await import("./models-
|
|
11886
|
+
const { ALL_MODELS } = await import("./models-CW5EL6Z7.js");
|
|
11834
11887
|
const name = toTrimmedString(modelName);
|
|
11835
11888
|
const prov = toTrimmedString(provider ?? "");
|
|
11836
11889
|
if (!name) return null;
|
|
@@ -12071,7 +12124,7 @@ var buildFormDataFromArgs = async (args) => {
|
|
|
12071
12124
|
const trimmedModel = toTrimmedString(model);
|
|
12072
12125
|
const trimmedProvider = toTrimmedString(provider);
|
|
12073
12126
|
const modelConfig = await findModelConfig(trimmedModel, trimmedProvider);
|
|
12074
|
-
const { getModelPricing } = await import("./getPricing-
|
|
12127
|
+
const { getModelPricing } = await import("./getPricing-FM7TJZFV.js");
|
|
12075
12128
|
const normalizedTools = tools ?? [];
|
|
12076
12129
|
const resolvedRuntimeToolPolicy = runtimeToolPolicy ?? (normalizedTools.includes("execShell") ? HOSTED_EXEC_RUNTIME_TOOL_POLICY : void 0);
|
|
12077
12130
|
const formData = {
|
|
@@ -12130,9 +12183,9 @@ var findSpaceConfig = (nameOrId, allSpaces) => {
|
|
|
12130
12183
|
return null;
|
|
12131
12184
|
};
|
|
12132
12185
|
async function createAgentToolFunc(args, thunkApi) {
|
|
12133
|
-
const
|
|
12134
|
-
const currentUserId = selectIdentityUserId(
|
|
12135
|
-
const currentBalance = selectIdentityUserBalance(
|
|
12186
|
+
const state2 = thunkApi.getState();
|
|
12187
|
+
const currentUserId = selectIdentityUserId(state2);
|
|
12188
|
+
const currentBalance = selectIdentityUserBalance(state2);
|
|
12136
12189
|
const allSpaces = getAllMemberSpaces();
|
|
12137
12190
|
if (!currentUserId) {
|
|
12138
12191
|
throw new Error("\u521B\u5EFA Agent \u5931\u8D25\uFF1A\u5F53\u524D\u672A\u767B\u5F55\u6216\u7F3A\u5C11 userId\u3002");
|
|
@@ -12175,10 +12228,10 @@ ${availableList}`
|
|
|
12175
12228
|
createAgent({
|
|
12176
12229
|
userId: currentUserId,
|
|
12177
12230
|
formData,
|
|
12178
|
-
spaceId:
|
|
12231
|
+
spaceId: getCurrentSpaceId() || void 0
|
|
12179
12232
|
})
|
|
12180
12233
|
).unwrap();
|
|
12181
|
-
const currentSpaceId =
|
|
12234
|
+
const currentSpaceId = getCurrentSpaceId();
|
|
12182
12235
|
if (currentSpaceId) {
|
|
12183
12236
|
const agentDbKey = agent.isPublic ? createAgentKey.public(agent.id) : createAgentKey.private(currentUserId, agent.id);
|
|
12184
12237
|
try {
|
|
@@ -12485,8 +12538,8 @@ var updateAgentToolFunctionSchema = {
|
|
|
12485
12538
|
}
|
|
12486
12539
|
};
|
|
12487
12540
|
async function updateAgentToolFunc(args, thunkApi) {
|
|
12488
|
-
const
|
|
12489
|
-
const userId = selectIdentityUserId(
|
|
12541
|
+
const state2 = thunkApi.getState();
|
|
12542
|
+
const userId = selectIdentityUserId(state2);
|
|
12490
12543
|
const db = thunkApi.extra?.db;
|
|
12491
12544
|
validateUpdateArgs(userId, { requireAgentId: true, agentId: args.agentId });
|
|
12492
12545
|
const dbKey = args.agentId.trim();
|
|
@@ -12575,7 +12628,7 @@ var createDocFunctionSchema = {
|
|
|
12575
12628
|
async function createDocFunc(args, thunkApi) {
|
|
12576
12629
|
const { getState } = thunkApi;
|
|
12577
12630
|
const dispatch = thunkApi.dispatch.bind(thunkApi);
|
|
12578
|
-
const
|
|
12631
|
+
const state2 = getState();
|
|
12579
12632
|
console.log("[createDocTool] Received args:", args);
|
|
12580
12633
|
const rawTitle = (args.title ?? "").trim();
|
|
12581
12634
|
const title = rawTitle || "\u65B0\u9875\u9762";
|
|
@@ -12808,7 +12861,7 @@ var createSkillDocFunctionSchema = {
|
|
|
12808
12861
|
};
|
|
12809
12862
|
async function createSkillDocFunc(args, thunkApi) {
|
|
12810
12863
|
const { dispatch, getState } = thunkApi;
|
|
12811
|
-
const
|
|
12864
|
+
const state2 = getState();
|
|
12812
12865
|
const { title, content, skillConfig, evalConfig } = buildSkillDocFromArgs(args);
|
|
12813
12866
|
const explicitSpaceId = (args.spaceId ?? "").trim() || void 0;
|
|
12814
12867
|
const currentSpaceId = getCurrentSpaceId() || void 0;
|
|
@@ -13155,7 +13208,7 @@ var importSkillFunctionSchema = {
|
|
|
13155
13208
|
};
|
|
13156
13209
|
async function importSkillFunc(args, thunkApi) {
|
|
13157
13210
|
const { dispatch, getState } = thunkApi;
|
|
13158
|
-
const
|
|
13211
|
+
const state2 = getState();
|
|
13159
13212
|
const explicitContent = asTrimmedString(args.content);
|
|
13160
13213
|
const url = typeof args.url === "string" ? normalizeUrl(args.url) : "";
|
|
13161
13214
|
if (!explicitContent && !url) {
|
|
@@ -14024,8 +14077,8 @@ var loadSkillFunctionSchema = {
|
|
|
14024
14077
|
}
|
|
14025
14078
|
};
|
|
14026
14079
|
var getRuntime = (thunkApi) => {
|
|
14027
|
-
const
|
|
14028
|
-
return
|
|
14080
|
+
const state2 = thunkApi?.getState?.();
|
|
14081
|
+
return state2 ? selectRuntimeSnapshot(state2) : null;
|
|
14029
14082
|
};
|
|
14030
14083
|
var authHeaders = (token) => token ? { Authorization: `Bearer ${token}` } : {};
|
|
14031
14084
|
async function readRemoteRecord(args) {
|
|
@@ -14114,12 +14167,12 @@ async function listSkillCandidates(thunkApi) {
|
|
|
14114
14167
|
}
|
|
14115
14168
|
var resolveCurrentAgentKeyForSkillGate = (thunkApi) => {
|
|
14116
14169
|
try {
|
|
14117
|
-
const
|
|
14118
|
-
if (!
|
|
14170
|
+
const state2 = thunkApi?.getState?.();
|
|
14171
|
+
if (!state2) return null;
|
|
14119
14172
|
const currentDialogKey = getActiveDialogKey();
|
|
14120
14173
|
if (!currentDialogKey) return null;
|
|
14121
14174
|
const dialogConfig = selectById(
|
|
14122
|
-
|
|
14175
|
+
state2,
|
|
14123
14176
|
currentDialogKey
|
|
14124
14177
|
);
|
|
14125
14178
|
return asTrimmedNonEmptyStringArray(dialogConfig?.cybots)[0] ?? null;
|
|
@@ -14212,11 +14265,11 @@ ${body}`
|
|
|
14212
14265
|
}
|
|
14213
14266
|
async function persistLoadedSkillReference(thunkApi, dbKey, name) {
|
|
14214
14267
|
try {
|
|
14215
|
-
const
|
|
14268
|
+
const state2 = thunkApi?.getState?.();
|
|
14216
14269
|
const currentDialogKey = getActiveDialogKey();
|
|
14217
|
-
if (!
|
|
14270
|
+
if (!state2 || !currentDialogKey) return;
|
|
14218
14271
|
const dialogConfig = selectById(
|
|
14219
|
-
|
|
14272
|
+
state2,
|
|
14220
14273
|
currentDialogKey
|
|
14221
14274
|
);
|
|
14222
14275
|
const existing = dialogConfig?.extraReferences ?? [];
|
|
@@ -14232,6 +14285,279 @@ async function persistLoadedSkillReference(thunkApi, dbKey, name) {
|
|
|
14232
14285
|
}
|
|
14233
14286
|
}
|
|
14234
14287
|
|
|
14288
|
+
// packages/create/space/category/categoryActions.ts
|
|
14289
|
+
import { ulid as ulid2 } from "ulid";
|
|
14290
|
+
var syncCurrentSpace = (spaceId, updatedSpaceData) => {
|
|
14291
|
+
if (getCurrentSpaceIdRaw() === spaceId) {
|
|
14292
|
+
updateCurrentSpaceIfMatch(spaceId, updatedSpaceData);
|
|
14293
|
+
}
|
|
14294
|
+
};
|
|
14295
|
+
var setAllCategoriesCollapsed = createAsyncThunk(
|
|
14296
|
+
"space/setAllCategoriesCollapsed",
|
|
14297
|
+
async (input, thunkAPI) => {
|
|
14298
|
+
try {
|
|
14299
|
+
const { getState } = thunkAPI;
|
|
14300
|
+
const rootState = getState();
|
|
14301
|
+
const spaceId = input.spaceId || getCurrentSpaceId();
|
|
14302
|
+
if (!spaceId) throw new Error("\u65E0\u6CD5\u5207\u6362\u6298\u53E0\u72B6\u6001\uFF1A\u6CA1\u6709\u6D3B\u52A8\u7684\u7A7A\u95F4\u3002");
|
|
14303
|
+
const currentSpace = getCurrentSpaceRaw();
|
|
14304
|
+
const categoryIds = currentSpace?.categories ? Object.keys(currentSpace.categories) : [];
|
|
14305
|
+
categoryIds.push(UNCATEGORIZED_ID);
|
|
14306
|
+
const collapsedCategories = {};
|
|
14307
|
+
categoryIds.forEach((id) => {
|
|
14308
|
+
collapsedCategories[id] = input.collapsed;
|
|
14309
|
+
});
|
|
14310
|
+
if (typeof window !== "undefined") {
|
|
14311
|
+
writeStoredCollapsedCategories(
|
|
14312
|
+
spaceId,
|
|
14313
|
+
collapsedCategories,
|
|
14314
|
+
window.localStorage
|
|
14315
|
+
);
|
|
14316
|
+
}
|
|
14317
|
+
setCollapsedCategories(collapsedCategories, spaceId);
|
|
14318
|
+
return collapsedCategories;
|
|
14319
|
+
} catch (error) {
|
|
14320
|
+
console.error("\u6279\u91CF\u5207\u6362\u5206\u7C7B\u6298\u53E0\u72B6\u6001\u5931\u8D25:", error?.message);
|
|
14321
|
+
throw error;
|
|
14322
|
+
}
|
|
14323
|
+
}
|
|
14324
|
+
);
|
|
14325
|
+
var toggleCategoryCollapse2 = createAsyncThunk(
|
|
14326
|
+
"space/toggleCategoryCollapse",
|
|
14327
|
+
async (input, thunkAPI) => {
|
|
14328
|
+
try {
|
|
14329
|
+
const { getState } = thunkAPI;
|
|
14330
|
+
const { categoryId } = input;
|
|
14331
|
+
const rootState = getState();
|
|
14332
|
+
const spaceId = getCurrentSpaceId();
|
|
14333
|
+
if (!spaceId) throw new Error("\u65E0\u6CD5\u5207\u6362\u6298\u53E0\u72B6\u6001\uFF1A\u6CA1\u6709\u6D3B\u52A8\u7684\u7A7A\u95F4\u3002");
|
|
14334
|
+
if (!categoryId) throw new Error("\u65E0\u6548\u7684\u5206\u7C7BID\u3002");
|
|
14335
|
+
const defaultCollapsed = DEFAULT_COLLAPSED_CATEGORIES[categoryId] ?? true;
|
|
14336
|
+
const currentCollapsedCategories = getCollapsedCategories();
|
|
14337
|
+
const isCurrentlyCollapsed = currentCollapsedCategories[categoryId] ?? defaultCollapsed;
|
|
14338
|
+
const newCollapsedState = !isCurrentlyCollapsed;
|
|
14339
|
+
const collapsedCategories = {
|
|
14340
|
+
...currentCollapsedCategories,
|
|
14341
|
+
[categoryId]: newCollapsedState
|
|
14342
|
+
};
|
|
14343
|
+
if (typeof window !== "undefined") {
|
|
14344
|
+
writeStoredCollapsedCategories(
|
|
14345
|
+
spaceId,
|
|
14346
|
+
collapsedCategories,
|
|
14347
|
+
window.localStorage
|
|
14348
|
+
);
|
|
14349
|
+
}
|
|
14350
|
+
toggleCategoryCollapse(categoryId);
|
|
14351
|
+
return collapsedCategories;
|
|
14352
|
+
} catch (error) {
|
|
14353
|
+
console.error("\u5207\u6362\u5206\u7C7B\u6298\u53E0\u72B6\u6001\u5931\u8D25:", error?.message);
|
|
14354
|
+
throw error;
|
|
14355
|
+
}
|
|
14356
|
+
}
|
|
14357
|
+
);
|
|
14358
|
+
var addCategory = createAsyncThunk(
|
|
14359
|
+
"space/addCategory",
|
|
14360
|
+
async (input, thunkAPI) => {
|
|
14361
|
+
const { spaceId: inputSpaceId, name, categoryId, order } = input;
|
|
14362
|
+
const { dispatch, getState } = thunkAPI;
|
|
14363
|
+
const rootState = getState();
|
|
14364
|
+
const spaceId = inputSpaceId || getCurrentSpaceId();
|
|
14365
|
+
if (!spaceId) {
|
|
14366
|
+
throw new Error("\u65E0\u6CD5\u6DFB\u52A0\u5206\u7C7B\uFF1A\u672A\u9009\u62E9\u5F53\u524D\u7A7A\u95F4\u4E14\u672A\u63D0\u4F9B\u7A7A\u95F4 ID\u3002");
|
|
14367
|
+
}
|
|
14368
|
+
const currentUserId = selectIdentityUserId(rootState);
|
|
14369
|
+
if (!currentUserId) throw new Error("User is not logged in.");
|
|
14370
|
+
if (!name.trim()) {
|
|
14371
|
+
throw new Error("\u65E0\u6548\u7684\u5206\u7C7B\u540D\u79F0\u3002");
|
|
14372
|
+
}
|
|
14373
|
+
const spaceKey = createSpaceKey.space(spaceId);
|
|
14374
|
+
const spaceData = await dispatch(read({
|
|
14375
|
+
dbKey: spaceKey
|
|
14376
|
+
})).unwrap();
|
|
14377
|
+
checkSpaceMembership(spaceData, currentUserId);
|
|
14378
|
+
const newCategoryId = categoryId || ulid2();
|
|
14379
|
+
if (spaceData.categories?.[newCategoryId]) {
|
|
14380
|
+
throw new Error(`\u5206\u7C7B ID "${newCategoryId}" \u5DF2\u5B58\u5728\u3002`);
|
|
14381
|
+
}
|
|
14382
|
+
const existingValidCategories = spaceData.categories ? Object.values(spaceData.categories).filter(Boolean) : [];
|
|
14383
|
+
const finalOrder = typeof order === "number" ? order : existingValidCategories.length;
|
|
14384
|
+
const nowISO = (/* @__PURE__ */ new Date()).toISOString();
|
|
14385
|
+
const newCategory = {
|
|
14386
|
+
name: name.trim(),
|
|
14387
|
+
order: finalOrder,
|
|
14388
|
+
updatedAt: nowISO
|
|
14389
|
+
};
|
|
14390
|
+
const updatedSpaceData = await dispatch(
|
|
14391
|
+
patch({
|
|
14392
|
+
dbKey: spaceKey,
|
|
14393
|
+
changes: {
|
|
14394
|
+
categories: { [newCategoryId]: newCategory },
|
|
14395
|
+
updatedAt: nowISO
|
|
14396
|
+
}
|
|
14397
|
+
})
|
|
14398
|
+
).unwrap();
|
|
14399
|
+
const currentCollapsedCategories = getCollapsedCategories();
|
|
14400
|
+
const collapsedCategories = {
|
|
14401
|
+
...currentCollapsedCategories,
|
|
14402
|
+
[newCategoryId]: false
|
|
14403
|
+
};
|
|
14404
|
+
if (typeof window !== "undefined") {
|
|
14405
|
+
writeStoredCollapsedCategories(
|
|
14406
|
+
spaceId,
|
|
14407
|
+
collapsedCategories,
|
|
14408
|
+
window.localStorage
|
|
14409
|
+
);
|
|
14410
|
+
}
|
|
14411
|
+
expandCategoryInCollapsed(newCategoryId, spaceId);
|
|
14412
|
+
syncCurrentSpace(spaceId, updatedSpaceData);
|
|
14413
|
+
return { spaceId, updatedSpaceData, newCategoryId, collapsedCategories };
|
|
14414
|
+
}
|
|
14415
|
+
);
|
|
14416
|
+
var deleteCategory = createAsyncThunk(
|
|
14417
|
+
"space/deleteCategory",
|
|
14418
|
+
async (input, thunkAPI) => {
|
|
14419
|
+
const { categoryId, spaceId } = input;
|
|
14420
|
+
const { dispatch, getState } = thunkAPI;
|
|
14421
|
+
const rootState = getState();
|
|
14422
|
+
const currentUserId = selectIdentityUserId(rootState);
|
|
14423
|
+
if (!currentUserId) throw new Error("User is not logged in.");
|
|
14424
|
+
if (!categoryId.trim()) throw new Error("\u65E0\u6548\u7684 categoryId\u3002");
|
|
14425
|
+
const spaceKey = createSpaceKey.space(spaceId);
|
|
14426
|
+
const spaceData = await dispatch(read({
|
|
14427
|
+
dbKey: spaceKey
|
|
14428
|
+
})).unwrap();
|
|
14429
|
+
checkSpaceMembership(spaceData, currentUserId);
|
|
14430
|
+
if (!spaceData?.categories?.[categoryId]) {
|
|
14431
|
+
throw new Error("\u6307\u5B9A\u7684\u5206\u7C7B\u4E0D\u5B58\u5728\u6216\u5DF2\u88AB\u5220\u9664\u3002");
|
|
14432
|
+
}
|
|
14433
|
+
const nowISO = (/* @__PURE__ */ new Date()).toISOString();
|
|
14434
|
+
const changes = {
|
|
14435
|
+
categories: { [categoryId]: null },
|
|
14436
|
+
updatedAt: nowISO
|
|
14437
|
+
};
|
|
14438
|
+
if (spaceData.contents) {
|
|
14439
|
+
const contentsPatch = {};
|
|
14440
|
+
let contentsChanged = false;
|
|
14441
|
+
for (const key in spaceData.contents) {
|
|
14442
|
+
if (spaceData.contents[key]?.categoryId === categoryId) {
|
|
14443
|
+
contentsPatch[key] = {
|
|
14444
|
+
categoryId: null,
|
|
14445
|
+
updatedAt: nowISO
|
|
14446
|
+
};
|
|
14447
|
+
contentsChanged = true;
|
|
14448
|
+
}
|
|
14449
|
+
}
|
|
14450
|
+
if (contentsChanged) changes.contents = contentsPatch;
|
|
14451
|
+
}
|
|
14452
|
+
const updatedSpaceData = await dispatch(
|
|
14453
|
+
patch({ dbKey: spaceKey, changes })
|
|
14454
|
+
).unwrap();
|
|
14455
|
+
const collapsedCategories = { ...getCollapsedCategories() };
|
|
14456
|
+
delete collapsedCategories[categoryId];
|
|
14457
|
+
setCollapsedCategories(collapsedCategories, spaceId);
|
|
14458
|
+
if (typeof window !== "undefined") {
|
|
14459
|
+
writeStoredCollapsedCategories(
|
|
14460
|
+
spaceId,
|
|
14461
|
+
collapsedCategories,
|
|
14462
|
+
window.localStorage
|
|
14463
|
+
);
|
|
14464
|
+
}
|
|
14465
|
+
syncCurrentSpace(spaceId, updatedSpaceData);
|
|
14466
|
+
return { spaceId, updatedSpaceData, collapsedCategories };
|
|
14467
|
+
}
|
|
14468
|
+
);
|
|
14469
|
+
var updateCategoryName = createAsyncThunk(
|
|
14470
|
+
"space/updateCategoryName",
|
|
14471
|
+
async (input, thunkAPI) => {
|
|
14472
|
+
const { spaceId, categoryId, name } = input;
|
|
14473
|
+
const { dispatch, getState } = thunkAPI;
|
|
14474
|
+
const currentUserId = selectIdentityUserId(getState());
|
|
14475
|
+
if (!currentUserId) throw new Error("User is not logged in.");
|
|
14476
|
+
if (!categoryId.trim()) throw new Error("\u65E0\u6548\u7684 categoryId\u3002");
|
|
14477
|
+
const trimmedName = name.trim();
|
|
14478
|
+
if (!trimmedName) throw new Error("\u5206\u7C7B\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A\u6216\u4EC5\u5305\u542B\u7A7A\u683C\u3002");
|
|
14479
|
+
const spaceKey = createSpaceKey.space(spaceId);
|
|
14480
|
+
const spaceData = await dispatch(read({
|
|
14481
|
+
dbKey: spaceKey
|
|
14482
|
+
})).unwrap();
|
|
14483
|
+
checkSpaceMembership(spaceData, currentUserId);
|
|
14484
|
+
const existingCategory = spaceData.categories?.[categoryId];
|
|
14485
|
+
if (!existingCategory) {
|
|
14486
|
+
throw new Error("\u6307\u5B9A\u7684\u5206\u7C7B\u4E0D\u5B58\u5728\u3002");
|
|
14487
|
+
}
|
|
14488
|
+
const nowISO = (/* @__PURE__ */ new Date()).toISOString();
|
|
14489
|
+
const changes = {
|
|
14490
|
+
categories: {
|
|
14491
|
+
[categoryId]: {
|
|
14492
|
+
...existingCategory,
|
|
14493
|
+
name: trimmedName,
|
|
14494
|
+
updatedAt: nowISO
|
|
14495
|
+
}
|
|
14496
|
+
},
|
|
14497
|
+
updatedAt: nowISO
|
|
14498
|
+
};
|
|
14499
|
+
const updatedSpaceData = await dispatch(
|
|
14500
|
+
patch({ dbKey: spaceKey, changes })
|
|
14501
|
+
).unwrap();
|
|
14502
|
+
syncCurrentSpace(spaceId, updatedSpaceData);
|
|
14503
|
+
return { spaceId, updatedSpaceData };
|
|
14504
|
+
}
|
|
14505
|
+
);
|
|
14506
|
+
var reorderCategories = createAsyncThunk(
|
|
14507
|
+
"space/reorderCategories",
|
|
14508
|
+
async (input, thunkAPI) => {
|
|
14509
|
+
const { spaceId, sortedCategoryIds } = input;
|
|
14510
|
+
const { dispatch, getState } = thunkAPI;
|
|
14511
|
+
const stateRoot = getState();
|
|
14512
|
+
const currentUserId = selectIdentityUserId(stateRoot);
|
|
14513
|
+
if (!currentUserId) {
|
|
14514
|
+
throw new Error("User is not logged in.");
|
|
14515
|
+
}
|
|
14516
|
+
if (!Array.isArray(sortedCategoryIds)) {
|
|
14517
|
+
throw new Error(
|
|
14518
|
+
"Invalid sortedCategoryIds provided: must be an array."
|
|
14519
|
+
);
|
|
14520
|
+
}
|
|
14521
|
+
const spaceKey = createSpaceKey.space(spaceId);
|
|
14522
|
+
const spaceData = await dispatch(read({
|
|
14523
|
+
dbKey: spaceKey
|
|
14524
|
+
})).unwrap();
|
|
14525
|
+
checkSpaceMembership(spaceData, currentUserId);
|
|
14526
|
+
if (!spaceData.categories || Object.keys(spaceData.categories).length === 0) {
|
|
14527
|
+
return { spaceId, updatedSpaceData: spaceData };
|
|
14528
|
+
}
|
|
14529
|
+
const nowISO = (/* @__PURE__ */ new Date()).toISOString();
|
|
14530
|
+
const currentCategories = spaceData.categories;
|
|
14531
|
+
const updatedCategoriesChanges = {};
|
|
14532
|
+
let hasValidChanges = false;
|
|
14533
|
+
sortedCategoryIds.forEach((catId, index) => {
|
|
14534
|
+
const existingCategory = currentCategories[catId];
|
|
14535
|
+
if (existingCategory) {
|
|
14536
|
+
updatedCategoriesChanges[catId] = {
|
|
14537
|
+
...existingCategory,
|
|
14538
|
+
order: index,
|
|
14539
|
+
updatedAt: nowISO
|
|
14540
|
+
};
|
|
14541
|
+
if (existingCategory.order !== index) {
|
|
14542
|
+
hasValidChanges = true;
|
|
14543
|
+
}
|
|
14544
|
+
}
|
|
14545
|
+
});
|
|
14546
|
+
if (!hasValidChanges) {
|
|
14547
|
+
return { spaceId, updatedSpaceData: spaceData };
|
|
14548
|
+
}
|
|
14549
|
+
const changes = {
|
|
14550
|
+
categories: updatedCategoriesChanges,
|
|
14551
|
+
updatedAt: nowISO
|
|
14552
|
+
};
|
|
14553
|
+
const updatedSpaceData = await dispatch(
|
|
14554
|
+
patch({ dbKey: spaceKey, changes })
|
|
14555
|
+
).unwrap();
|
|
14556
|
+
syncCurrentSpace(spaceId, updatedSpaceData);
|
|
14557
|
+
return { spaceId, updatedSpaceData };
|
|
14558
|
+
}
|
|
14559
|
+
);
|
|
14560
|
+
|
|
14235
14561
|
// packages/ai/tools/category/createCategoryTool.ts
|
|
14236
14562
|
var createCategoryFunctionSchema = {
|
|
14237
14563
|
// 已从 'create_category' 更新为 'createCategory'
|
|
@@ -14251,7 +14577,7 @@ var createCategoryFunctionSchema = {
|
|
|
14251
14577
|
async function createCategoryFunc(args, thunkApi) {
|
|
14252
14578
|
const { getState } = thunkApi;
|
|
14253
14579
|
const dispatch = thunkApi.dispatch.bind(thunkApi);
|
|
14254
|
-
const
|
|
14580
|
+
const state2 = getState();
|
|
14255
14581
|
const spaceId = getCurrentSpaceId();
|
|
14256
14582
|
if (!spaceId) {
|
|
14257
14583
|
throw new Error("\u65E0\u6CD5\u521B\u5EFA\u5206\u7C7B\uFF0C\u56E0\u4E3A\u5F53\u524D\u7A7A\u95F4\u672A\u8BBE\u5B9A\u3002");
|
|
@@ -14295,7 +14621,7 @@ var updateContentCategoryFunctionSchema = {
|
|
|
14295
14621
|
async function updateContentCategoryFunc(args, thunkApi) {
|
|
14296
14622
|
const { getState } = thunkApi;
|
|
14297
14623
|
const dispatch = thunkApi.dispatch.bind(thunkApi);
|
|
14298
|
-
const
|
|
14624
|
+
const state2 = getState();
|
|
14299
14625
|
const spaceId = getCurrentSpaceId();
|
|
14300
14626
|
if (!spaceId) {
|
|
14301
14627
|
throw new Error("\u65E0\u6CD5\u66F4\u65B0\u5206\u7C7B\uFF0C\u56E0\u4E3A\u5F53\u524D\u7A7A\u95F4\u672A\u8BBE\u5B9A\u3002");
|
|
@@ -14320,6 +14646,19 @@ async function updateContentCategoryFunc(args, thunkApi) {
|
|
|
14320
14646
|
}
|
|
14321
14647
|
}
|
|
14322
14648
|
|
|
14649
|
+
// packages/create/space/spaceCurrentSelectors.ts
|
|
14650
|
+
var getSpaceUpdatedAt = (space) => space ? Number(space.updatedAt) || 0 : 0;
|
|
14651
|
+
function getCurrentSpace(entities) {
|
|
14652
|
+
const spaceId = getCurrentSpaceId();
|
|
14653
|
+
if (!spaceId) return null;
|
|
14654
|
+
const stored = getCurrentSpaceRaw();
|
|
14655
|
+
const entity = entities[createSpaceKey.space(spaceId)];
|
|
14656
|
+
if (!stored) return entity ?? null;
|
|
14657
|
+
if (!entity) return stored;
|
|
14658
|
+
return getSpaceUpdatedAt(entity) > getSpaceUpdatedAt(stored) ? entity : stored;
|
|
14659
|
+
}
|
|
14660
|
+
var selectCurrentSpace = (state2) => getCurrentSpace(selectEntities(state2));
|
|
14661
|
+
|
|
14323
14662
|
// packages/ai/tools/category/queryContentsByCategoryTool.ts
|
|
14324
14663
|
var queryContentsByCategoryFunctionSchema = {
|
|
14325
14664
|
name: "queryContentsByCategory",
|
|
@@ -14341,12 +14680,12 @@ var queryContentsByCategoryFunctionSchema = {
|
|
|
14341
14680
|
};
|
|
14342
14681
|
async function queryContentsByCategoryFunc(args, thunkApi) {
|
|
14343
14682
|
const { getState } = thunkApi;
|
|
14344
|
-
const
|
|
14683
|
+
const state2 = getState();
|
|
14345
14684
|
const spaceId = getCurrentSpaceId();
|
|
14346
14685
|
if (!spaceId) {
|
|
14347
14686
|
throw new Error("\u65E0\u6CD5\u67E5\u8BE2\u5185\u5BB9\uFF0C\u56E0\u4E3A\u5F53\u524D\u7A7A\u95F4\u672A\u8BBE\u5B9A\u3002");
|
|
14348
14687
|
}
|
|
14349
|
-
const currentSpace =
|
|
14688
|
+
const currentSpace = selectCurrentSpace(state2);
|
|
14350
14689
|
if (!currentSpace) {
|
|
14351
14690
|
throw new Error("\u5F53\u524D\u7A7A\u95F4\u6570\u636E\u672A\u627E\u5230\u3002");
|
|
14352
14691
|
}
|
|
@@ -14388,15 +14727,15 @@ var buildRequestHeaders = (token) => {
|
|
|
14388
14727
|
};
|
|
14389
14728
|
var handleApiResponse = async (response) => {
|
|
14390
14729
|
if (!response.ok) {
|
|
14391
|
-
let
|
|
14730
|
+
let errorMessage2 = `API \u9519\u8BEF\uFF01\u72B6\u6001\u7801: ${response.status}`;
|
|
14392
14731
|
try {
|
|
14393
14732
|
const errorData = await response.json();
|
|
14394
14733
|
if (errorData?.error) {
|
|
14395
|
-
|
|
14734
|
+
errorMessage2 += `: ${errorData.error.message || JSON.stringify(errorData.error)}`;
|
|
14396
14735
|
}
|
|
14397
14736
|
} catch (e) {
|
|
14398
14737
|
}
|
|
14399
|
-
throw new Error(
|
|
14738
|
+
throw new Error(errorMessage2);
|
|
14400
14739
|
}
|
|
14401
14740
|
return response.json();
|
|
14402
14741
|
};
|
|
@@ -14530,8 +14869,8 @@ async function importDataFunc(args, thunkApi) {
|
|
|
14530
14869
|
throw new Error("`tableName` \u548C `fileReferenceId` \u90FD\u662F\u5FC5\u9700\u7684\u53C2\u6570\u3002");
|
|
14531
14870
|
}
|
|
14532
14871
|
try {
|
|
14533
|
-
const
|
|
14534
|
-
const pendingData = selectPendingRawDataByPageKey(
|
|
14872
|
+
const state2 = thunkApi.getState();
|
|
14873
|
+
const pendingData = selectPendingRawDataByPageKey(state2, pageKey);
|
|
14535
14874
|
if (!pendingData || !pendingData.jsonData) {
|
|
14536
14875
|
throw new Error(`\u5728\u5185\u5B58\u4E2D\u627E\u4E0D\u5230\u6587\u4EF6 (ID: ${pageKey}) \u7684\u6570\u636E\u3002`);
|
|
14537
14876
|
}
|
|
@@ -14834,8 +15173,8 @@ ${markdownContent}`
|
|
|
14834
15173
|
const title = tableMeta.displayName || `Table (${tableMeta.tableId})`;
|
|
14835
15174
|
const { rows, markdown: tableMd } = await thunkApi.dispatch(
|
|
14836
15175
|
async (_dispatch, getState, { db }) => {
|
|
14837
|
-
const
|
|
14838
|
-
const { currentToken: token, remoteServers } = getRuntimeServerContext(
|
|
15176
|
+
const state2 = getState();
|
|
15177
|
+
const { currentToken: token, remoteServers } = getRuntimeServerContext(state2);
|
|
14839
15178
|
return await fetchAndSerializeTable(tableMeta, db, {
|
|
14840
15179
|
token,
|
|
14841
15180
|
remoteServers
|
|
@@ -14915,7 +15254,7 @@ async function listUserSpacesFunc(args, thunkApi, context) {
|
|
|
14915
15254
|
const { ownedOnly = false } = args || {};
|
|
14916
15255
|
try {
|
|
14917
15256
|
const { getState } = thunkApi;
|
|
14918
|
-
const
|
|
15257
|
+
const state2 = getState();
|
|
14919
15258
|
let memberSpaces = getAllMemberSpaces();
|
|
14920
15259
|
if (ownedOnly) {
|
|
14921
15260
|
memberSpaces = memberSpaces.filter((ms) => ms.role === "owner");
|
|
@@ -15040,8 +15379,8 @@ var jsonPreview = (value, maxLength = 1800) => {
|
|
|
15040
15379
|
...(truncated)`;
|
|
15041
15380
|
};
|
|
15042
15381
|
var getRuntime2 = (thunkApi) => {
|
|
15043
|
-
const
|
|
15044
|
-
return
|
|
15382
|
+
const state2 = thunkApi?.getState?.();
|
|
15383
|
+
return state2 ? selectRuntimeSnapshot(state2) : null;
|
|
15045
15384
|
};
|
|
15046
15385
|
var authHeaders2 = (token) => token ? { Authorization: `Bearer ${token}` } : {};
|
|
15047
15386
|
var DrainExhaustedError = class extends Error {
|
|
@@ -15385,10 +15724,10 @@ async function deleteDialogsFunc(args, thunkApi) {
|
|
|
15385
15724
|
const deletedDialogIds = [];
|
|
15386
15725
|
const deletedDialogKeys = [];
|
|
15387
15726
|
const failures = [];
|
|
15388
|
-
const { deleteDialog } = await import("./dialogSlice-
|
|
15727
|
+
const { deleteDialog: deleteDialog2 } = await import("./dialogSlice-5KPVIAWH.js");
|
|
15389
15728
|
for (const target of targets) {
|
|
15390
15729
|
try {
|
|
15391
|
-
await thunkApi.dispatch(
|
|
15730
|
+
await thunkApi.dispatch(deleteDialog2(target.dbKey)).unwrap();
|
|
15392
15731
|
} catch (error) {
|
|
15393
15732
|
failures.push({
|
|
15394
15733
|
dbKey: target.dbKey,
|
|
@@ -15469,7 +15808,7 @@ function formatAgentListCard(agents, maxDisplay = 8) {
|
|
|
15469
15808
|
}
|
|
15470
15809
|
var listAgentsFunctionSchema = {
|
|
15471
15810
|
name: "listAgents",
|
|
15472
|
-
description: "List the current user's Nolo agents as safe summaries.
|
|
15811
|
+
description: "List the current user's Nolo agents as safe summaries. The `agents` array carries a compact agent-selection projection per agent: runnable `agentKey` (agent-<userId>-<id> owned, agent-pub-<id> public) plus name, model, provider, apiSource, tools, isFavorite, isOAuth, isOwned, isPublic. Copy `agentKey` verbatim into startAgentRun. Set `verbose: true` for troubleshooting to also get prices, introduction, modelAbility and timestamps. Results prioritize favorites, then OAuth/custom, then owned, then public. Rate-limited agents (429, nextAvailableAt in the future) are hidden by default; set `showUnavailable: true` to include them; `unavailableCount` and `unavailableAgents` carry their nextAvailableAt recovery timestamps.",
|
|
15473
15812
|
parameters: {
|
|
15474
15813
|
type: "object",
|
|
15475
15814
|
properties: {
|
|
@@ -15680,7 +16019,7 @@ var readSkillDocFunctionSchema = {
|
|
|
15680
16019
|
}
|
|
15681
16020
|
};
|
|
15682
16021
|
async function readSkillDocFunc(args, thunkApi) {
|
|
15683
|
-
const { buildReadDocResult } = await import("./readDocTool-
|
|
16022
|
+
const { buildReadDocResult } = await import("./readDocTool-ULKJ5BEM.js");
|
|
15684
16023
|
const id = args?.id ?? args?.doc ?? args?.docKey ?? args?.pageKey;
|
|
15685
16024
|
if (typeof id !== "string" || !id.trim()) {
|
|
15686
16025
|
throw new Error("readSkillDoc requires id or doc.");
|
|
@@ -15728,6 +16067,1077 @@ async function cliDoctorFunc(_args, thunkApi) {
|
|
|
15728
16067
|
return { rawData: result, displayData: jsonPreview(result) };
|
|
15729
16068
|
}
|
|
15730
16069
|
|
|
16070
|
+
// packages/database/queryPrefixes.ts
|
|
16071
|
+
function getUserDataPrefixes(type, userId) {
|
|
16072
|
+
const normalizedType = toTrimmedString(type);
|
|
16073
|
+
const normalizedUserId = toTrimmedString(userId);
|
|
16074
|
+
if (!normalizedType || !normalizedUserId) return [];
|
|
16075
|
+
const aliases = TYPE_STORAGE_PREFIXES[normalizedType] ?? [normalizedType];
|
|
16076
|
+
const seen = /* @__PURE__ */ new Set();
|
|
16077
|
+
const prefixes = [];
|
|
16078
|
+
for (const raw of aliases) {
|
|
16079
|
+
const alias = toTrimmedString(raw);
|
|
16080
|
+
if (!alias) continue;
|
|
16081
|
+
const prefix = `${alias}-${normalizedUserId}-`;
|
|
16082
|
+
if (seen.has(prefix)) continue;
|
|
16083
|
+
seen.add(prefix);
|
|
16084
|
+
prefixes.push(prefix);
|
|
16085
|
+
}
|
|
16086
|
+
return prefixes;
|
|
16087
|
+
}
|
|
16088
|
+
|
|
16089
|
+
// packages/database/client/fetchUserData.ts
|
|
16090
|
+
var attachQueriedKey = (key, value) => {
|
|
16091
|
+
if (!value || typeof value !== "object") return value;
|
|
16092
|
+
if (typeof value.dbKey === "string" && value.dbKey.trim().length > 0) {
|
|
16093
|
+
return value;
|
|
16094
|
+
}
|
|
16095
|
+
return {
|
|
16096
|
+
...value,
|
|
16097
|
+
dbKey: key
|
|
16098
|
+
};
|
|
16099
|
+
};
|
|
16100
|
+
var normalizeTypeList = (types) => {
|
|
16101
|
+
const raw = Array.isArray(types) ? types : [types];
|
|
16102
|
+
const seen = /* @__PURE__ */ new Set();
|
|
16103
|
+
const out = [];
|
|
16104
|
+
for (const t of raw) {
|
|
16105
|
+
const n = toTrimmedString(t);
|
|
16106
|
+
if (!n || seen.has(n)) continue;
|
|
16107
|
+
seen.add(n);
|
|
16108
|
+
out.push(n);
|
|
16109
|
+
}
|
|
16110
|
+
return out;
|
|
16111
|
+
};
|
|
16112
|
+
async function fetchUserData(db, types, userId, options = {}) {
|
|
16113
|
+
const results = {};
|
|
16114
|
+
const typeArray = normalizeTypeList(types);
|
|
16115
|
+
const includeDeleted = options.includeDeleted === true;
|
|
16116
|
+
try {
|
|
16117
|
+
for (const type of typeArray) {
|
|
16118
|
+
const byKey = /* @__PURE__ */ new Map();
|
|
16119
|
+
const prefixes = getUserDataPrefixes(type, userId);
|
|
16120
|
+
for (const prefix of prefixes) {
|
|
16121
|
+
if (!prefix) continue;
|
|
16122
|
+
let iterator = db.iterator({
|
|
16123
|
+
gte: prefix,
|
|
16124
|
+
lte: `${prefix}\uFFFF`
|
|
16125
|
+
});
|
|
16126
|
+
if (iterator && typeof iterator.then === "function") {
|
|
16127
|
+
iterator = await iterator;
|
|
16128
|
+
}
|
|
16129
|
+
for await (const [key, value] of iterator) {
|
|
16130
|
+
const keyStr = String(key);
|
|
16131
|
+
if (byKey.has(keyStr)) continue;
|
|
16132
|
+
const hydrated = attachQueriedKey(keyStr, value);
|
|
16133
|
+
if (!hydrated) continue;
|
|
16134
|
+
if (!includeDeleted && hydrated.deletedAt) continue;
|
|
16135
|
+
byKey.set(keyStr, hydrated);
|
|
16136
|
+
}
|
|
16137
|
+
}
|
|
16138
|
+
results[type] = [...byKey.values()];
|
|
16139
|
+
}
|
|
16140
|
+
if (Array.isArray(types)) {
|
|
16141
|
+
return results;
|
|
16142
|
+
}
|
|
16143
|
+
const single = toTrimmedString(types);
|
|
16144
|
+
return results[single] ?? [];
|
|
16145
|
+
} catch (error) {
|
|
16146
|
+
console.error("Query error:", error);
|
|
16147
|
+
throw error;
|
|
16148
|
+
}
|
|
16149
|
+
}
|
|
16150
|
+
|
|
16151
|
+
// packages/create/space/addSpaceAction.ts
|
|
16152
|
+
import { ulid as ulid3 } from "ulid";
|
|
16153
|
+
async function getUserDataOnce({
|
|
16154
|
+
types,
|
|
16155
|
+
userId,
|
|
16156
|
+
limit,
|
|
16157
|
+
isLoggedIn = false,
|
|
16158
|
+
currentUserId,
|
|
16159
|
+
db
|
|
16160
|
+
}) {
|
|
16161
|
+
try {
|
|
16162
|
+
const typeArray = Array.isArray(types) ? types : [types];
|
|
16163
|
+
const effectiveUserId = userId === "local" && isLoggedIn && currentUserId ? currentUserId : userId;
|
|
16164
|
+
const localResults = await fetchUserData(db, typeArray, effectiveUserId);
|
|
16165
|
+
const localData = Object.values(localResults).flat();
|
|
16166
|
+
return { data: localData };
|
|
16167
|
+
} catch (err) {
|
|
16168
|
+
const error = err instanceof Error ? err : new Error("Unknown error occurred");
|
|
16169
|
+
return { data: [], error };
|
|
16170
|
+
}
|
|
16171
|
+
}
|
|
16172
|
+
var targetTypes = ["dialog" /* DIALOG */, "page" /* DOC */];
|
|
16173
|
+
var getCurrentPathForLog = () => typeof window !== "undefined" && typeof window.location?.pathname === "string" ? window.location.pathname : void 0;
|
|
16174
|
+
var addSpaceAction = async (input, thunkAPI) => {
|
|
16175
|
+
const {
|
|
16176
|
+
name,
|
|
16177
|
+
description = "",
|
|
16178
|
+
boundFolder
|
|
16179
|
+
} = input;
|
|
16180
|
+
const visibility = input.visibility ?? "private" /* PRIVATE */;
|
|
16181
|
+
const { dispatch, getState, extra } = thunkAPI;
|
|
16182
|
+
const state2 = getState();
|
|
16183
|
+
const accountUserId = selectIdentityUserId(state2);
|
|
16184
|
+
const userId = resolveEffectiveSpaceActorId(accountUserId);
|
|
16185
|
+
const spaceId = ulid3();
|
|
16186
|
+
const now = Date.now();
|
|
16187
|
+
const nowISO = new Date(now).toISOString();
|
|
16188
|
+
const spaceData = {
|
|
16189
|
+
id: spaceId,
|
|
16190
|
+
name,
|
|
16191
|
+
description,
|
|
16192
|
+
boundFolder,
|
|
16193
|
+
ownerId: userId,
|
|
16194
|
+
userId,
|
|
16195
|
+
visibility,
|
|
16196
|
+
members: [userId],
|
|
16197
|
+
categories: {},
|
|
16198
|
+
contents: {},
|
|
16199
|
+
createdAt: now,
|
|
16200
|
+
updatedAt: now,
|
|
16201
|
+
type: "space" /* SPACE */
|
|
16202
|
+
};
|
|
16203
|
+
const spaces = getAllMemberSpaces();
|
|
16204
|
+
const hasSpaceForActor = spaces.some(
|
|
16205
|
+
(membership) => {
|
|
16206
|
+
if (isDeviceLocalOwnerId(userId)) {
|
|
16207
|
+
return isDeviceLocalSpaceMembership(membership);
|
|
16208
|
+
}
|
|
16209
|
+
if (isDeviceLocalSpaceMembership(membership)) return false;
|
|
16210
|
+
return membership.userId === userId || membership.ownerId === userId;
|
|
16211
|
+
}
|
|
16212
|
+
);
|
|
16213
|
+
console.info("[space/create] addSpaceAction", {
|
|
16214
|
+
userId,
|
|
16215
|
+
name,
|
|
16216
|
+
visibility,
|
|
16217
|
+
boundFolder,
|
|
16218
|
+
memberSpaceCount: spaces.length,
|
|
16219
|
+
hasSpaceForActor,
|
|
16220
|
+
currentPath: getCurrentPathForLog()
|
|
16221
|
+
});
|
|
16222
|
+
if (!hasSpaceForActor) {
|
|
16223
|
+
const { data: oldItems = [] } = await getUserDataOnce({
|
|
16224
|
+
types: targetTypes,
|
|
16225
|
+
userId,
|
|
16226
|
+
limit: 100,
|
|
16227
|
+
db: extra.db
|
|
16228
|
+
});
|
|
16229
|
+
const hasOldSideData = oldItems.length > 0;
|
|
16230
|
+
if (hasOldSideData) {
|
|
16231
|
+
const contents = {};
|
|
16232
|
+
const updatePromises = [];
|
|
16233
|
+
for (const item of oldItems) {
|
|
16234
|
+
if (!item.id || !item.type) continue;
|
|
16235
|
+
const recordOwner = resolveRecordOwnerUserId(item);
|
|
16236
|
+
if (recordOwner !== userId) continue;
|
|
16237
|
+
const stableContentKey = typeof item.dbKey === "string" && item.dbKey.trim() ? item.dbKey : item.id;
|
|
16238
|
+
contents[stableContentKey] = {
|
|
16239
|
+
title: item.title || "",
|
|
16240
|
+
type: item.type,
|
|
16241
|
+
contentKey: stableContentKey,
|
|
16242
|
+
categoryId: "",
|
|
16243
|
+
pinned: false,
|
|
16244
|
+
createdAt: item.createdAt ?? now,
|
|
16245
|
+
updatedAt: item.updatedAt ?? now,
|
|
16246
|
+
order: item.order
|
|
16247
|
+
};
|
|
16248
|
+
if (item.dbKey) {
|
|
16249
|
+
updatePromises.push(
|
|
16250
|
+
dispatch(
|
|
16251
|
+
patch({
|
|
16252
|
+
dbKey: item.dbKey,
|
|
16253
|
+
changes: { spaceId, updatedAt: now }
|
|
16254
|
+
})
|
|
16255
|
+
)
|
|
16256
|
+
);
|
|
16257
|
+
}
|
|
16258
|
+
}
|
|
16259
|
+
spaceData.contents = contents;
|
|
16260
|
+
await Promise.all(updatePromises);
|
|
16261
|
+
}
|
|
16262
|
+
}
|
|
16263
|
+
const spaceKey = createSpaceKey.space(spaceId);
|
|
16264
|
+
await dispatch(
|
|
16265
|
+
write({ data: spaceData, customKey: spaceKey, userId })
|
|
16266
|
+
).unwrap();
|
|
16267
|
+
const spaceMemberKey = createSpaceKey.member(userId, spaceId);
|
|
16268
|
+
const spaceMemberData = {
|
|
16269
|
+
dbKey: spaceMemberKey,
|
|
16270
|
+
type: "space" /* SPACE */,
|
|
16271
|
+
userId,
|
|
16272
|
+
role: "owner" /* OWNER */,
|
|
16273
|
+
joinedAt: now,
|
|
16274
|
+
spaceId,
|
|
16275
|
+
spaceName: name,
|
|
16276
|
+
ownerId: userId,
|
|
16277
|
+
visibility,
|
|
16278
|
+
createdAt: nowISO,
|
|
16279
|
+
updatedAt: nowISO
|
|
16280
|
+
};
|
|
16281
|
+
await dispatch(
|
|
16282
|
+
write({ data: spaceMemberData, customKey: spaceMemberKey, userId })
|
|
16283
|
+
).unwrap();
|
|
16284
|
+
return spaceMemberData;
|
|
16285
|
+
};
|
|
16286
|
+
|
|
16287
|
+
// packages/app/favorite/favoriteStore.ts
|
|
16288
|
+
var import_react3 = __toESM(require_react());
|
|
16289
|
+
|
|
16290
|
+
// packages/app/sessionSnapshot.ts
|
|
16291
|
+
var import_react = __toESM(require_react());
|
|
16292
|
+
|
|
16293
|
+
// packages/app/hooks/useHasMounted.ts
|
|
16294
|
+
var import_react2 = __toESM(require_react());
|
|
16295
|
+
|
|
16296
|
+
// packages/app/favorite/favoriteStore.ts
|
|
16297
|
+
var createInitialState = () => ({
|
|
16298
|
+
agentIds: [],
|
|
16299
|
+
contentIds: [],
|
|
16300
|
+
favoritedAtById: {},
|
|
16301
|
+
initialized: false,
|
|
16302
|
+
loading: false,
|
|
16303
|
+
error: null
|
|
16304
|
+
});
|
|
16305
|
+
var state = createInitialState();
|
|
16306
|
+
var listeners = /* @__PURE__ */ new Set();
|
|
16307
|
+
var version = 0;
|
|
16308
|
+
var notify = () => {
|
|
16309
|
+
version += 1;
|
|
16310
|
+
for (const listener of listeners) {
|
|
16311
|
+
try {
|
|
16312
|
+
listener();
|
|
16313
|
+
} catch {
|
|
16314
|
+
}
|
|
16315
|
+
}
|
|
16316
|
+
};
|
|
16317
|
+
function removeFavoriteLocally(payload) {
|
|
16318
|
+
const { targetType, id } = payload;
|
|
16319
|
+
if (targetType === "agent") {
|
|
16320
|
+
state = {
|
|
16321
|
+
...state,
|
|
16322
|
+
agentIds: state.agentIds.filter((item) => item !== id),
|
|
16323
|
+
favoritedAtById: { ...state.favoritedAtById }
|
|
16324
|
+
};
|
|
16325
|
+
delete state.favoritedAtById[id];
|
|
16326
|
+
notify();
|
|
16327
|
+
return;
|
|
16328
|
+
}
|
|
16329
|
+
if (targetType === "doc" || targetType === "page" || targetType === "content") {
|
|
16330
|
+
state = {
|
|
16331
|
+
...state,
|
|
16332
|
+
contentIds: state.contentIds.filter((item) => item !== id),
|
|
16333
|
+
favoritedAtById: { ...state.favoritedAtById }
|
|
16334
|
+
};
|
|
16335
|
+
delete state.favoritedAtById[id];
|
|
16336
|
+
notify();
|
|
16337
|
+
}
|
|
16338
|
+
}
|
|
16339
|
+
|
|
16340
|
+
// packages/app/favorite/deletedFavoriteProjection.ts
|
|
16341
|
+
var resolveDeletedFavoriteProjectionRemoval = (contentKey) => {
|
|
16342
|
+
if (!contentKey) return null;
|
|
16343
|
+
if (isAgentKey(contentKey)) {
|
|
16344
|
+
return { targetType: "agent", id: contentKey };
|
|
16345
|
+
}
|
|
16346
|
+
if (isPageKey(contentKey) || isTableMetaKey(contentKey) || isFileKey(contentKey)) {
|
|
16347
|
+
return { targetType: "content", id: contentKey };
|
|
16348
|
+
}
|
|
16349
|
+
return null;
|
|
16350
|
+
};
|
|
16351
|
+
|
|
16352
|
+
// packages/agent-runtime/deleteAgentLocalCredential.ts
|
|
16353
|
+
var AGENT_LOCAL_CREDENTIAL_DELETE_FAILED_MESSAGE = "Agent was deleted, but local API key cleanup failed. You may remove the leftover credential manually if needed.";
|
|
16354
|
+
var createAgentLocalCredentialBroker = createFileCredentialBroker;
|
|
16355
|
+
function isPublicAgentProjectionKey(dbKey) {
|
|
16356
|
+
const key = asTrimmedString(dbKey);
|
|
16357
|
+
return key.startsWith("agent-pub-");
|
|
16358
|
+
}
|
|
16359
|
+
function extractAgentLocalCredentialRef(record) {
|
|
16360
|
+
if (!record || typeof record !== "object") return null;
|
|
16361
|
+
const value = record.credentialRef;
|
|
16362
|
+
return asOptionalTrimmedString(value) ?? null;
|
|
16363
|
+
}
|
|
16364
|
+
async function deleteAgentLocalCredentialRef(credentialRef, options) {
|
|
16365
|
+
const ref = asTrimmedString(credentialRef);
|
|
16366
|
+
if (!ref) {
|
|
16367
|
+
return { deleted: false, skipped: true };
|
|
16368
|
+
}
|
|
16369
|
+
try {
|
|
16370
|
+
const factory = options?.brokerFactory ?? createAgentLocalCredentialBroker;
|
|
16371
|
+
const broker = factory();
|
|
16372
|
+
await broker.delete(ref);
|
|
16373
|
+
return { deleted: true };
|
|
16374
|
+
} catch {
|
|
16375
|
+
return {
|
|
16376
|
+
deleted: false,
|
|
16377
|
+
warning: AGENT_LOCAL_CREDENTIAL_DELETE_FAILED_MESSAGE
|
|
16378
|
+
};
|
|
16379
|
+
}
|
|
16380
|
+
}
|
|
16381
|
+
|
|
16382
|
+
// packages/app/hooks/deleteDbKey.ts
|
|
16383
|
+
var performDirectDelete = async (dispatch, getState, contentKey, preferredServerOrigin, includeAttachments) => {
|
|
16384
|
+
if (isDialogKey(contentKey)) {
|
|
16385
|
+
await dispatch(
|
|
16386
|
+
deleteDialog({ dialogKey: contentKey, includeAttachments })
|
|
16387
|
+
).unwrap();
|
|
16388
|
+
return;
|
|
16389
|
+
}
|
|
16390
|
+
if (isTableMetaKey(contentKey)) {
|
|
16391
|
+
await dispatch(deleteTable({ dbKey: contentKey })).unwrap();
|
|
16392
|
+
return;
|
|
16393
|
+
}
|
|
16394
|
+
if (isAgentKey(contentKey)) {
|
|
16395
|
+
let credentialRef = null;
|
|
16396
|
+
let credentialSynced = false;
|
|
16397
|
+
if (!isPublicAgentProjectionKey(contentKey)) {
|
|
16398
|
+
try {
|
|
16399
|
+
let record = selectById(getState(), contentKey);
|
|
16400
|
+
if (!record) {
|
|
16401
|
+
try {
|
|
16402
|
+
record = await dispatch(
|
|
16403
|
+
read({
|
|
16404
|
+
dbKey: contentKey,
|
|
16405
|
+
preferredServerOrigin
|
|
16406
|
+
})
|
|
16407
|
+
).unwrap();
|
|
16408
|
+
} catch {
|
|
16409
|
+
record = null;
|
|
16410
|
+
}
|
|
16411
|
+
}
|
|
16412
|
+
credentialRef = extractAgentLocalCredentialRef(record);
|
|
16413
|
+
if (record && typeof record === "object" && "credentialSynced" in record) {
|
|
16414
|
+
credentialSynced = record.credentialSynced === true;
|
|
16415
|
+
}
|
|
16416
|
+
} catch {
|
|
16417
|
+
credentialRef = null;
|
|
16418
|
+
}
|
|
16419
|
+
}
|
|
16420
|
+
await dispatch(
|
|
16421
|
+
remove({
|
|
16422
|
+
dbKey: contentKey,
|
|
16423
|
+
preferredServerOrigin
|
|
16424
|
+
})
|
|
16425
|
+
).unwrap();
|
|
16426
|
+
if (credentialRef) {
|
|
16427
|
+
const cleanup = await deleteAgentLocalCredentialRef(credentialRef);
|
|
16428
|
+
if (!cleanup.deleted && "warning" in cleanup) {
|
|
16429
|
+
console.warn(
|
|
16430
|
+
"[deleteDbKey] local API credential cleanup failed after agent delete:",
|
|
16431
|
+
cleanup.warning
|
|
16432
|
+
);
|
|
16433
|
+
}
|
|
16434
|
+
}
|
|
16435
|
+
if (credentialRef && credentialSynced) {
|
|
16436
|
+
try {
|
|
16437
|
+
const { currentServer, currentToken } = selectRuntimeSnapshot(
|
|
16438
|
+
getState()
|
|
16439
|
+
);
|
|
16440
|
+
if (currentServer && currentToken) {
|
|
16441
|
+
await deleteServerSyncedCredential(
|
|
16442
|
+
{ currentServer, authToken: currentToken },
|
|
16443
|
+
credentialRef
|
|
16444
|
+
);
|
|
16445
|
+
}
|
|
16446
|
+
} catch {
|
|
16447
|
+
}
|
|
16448
|
+
}
|
|
16449
|
+
return;
|
|
16450
|
+
}
|
|
16451
|
+
if (isAppKey(contentKey) || isPageKey(contentKey) || isFileKey(contentKey) || isTaskKey(contentKey)) {
|
|
16452
|
+
await dispatch(
|
|
16453
|
+
remove({
|
|
16454
|
+
dbKey: contentKey,
|
|
16455
|
+
preferredServerOrigin
|
|
16456
|
+
})
|
|
16457
|
+
).unwrap();
|
|
16458
|
+
}
|
|
16459
|
+
};
|
|
16460
|
+
var resolveDeleteInput = (input) => {
|
|
16461
|
+
if (typeof input === "string" && input.trim()) {
|
|
16462
|
+
return { contentKey: input };
|
|
16463
|
+
}
|
|
16464
|
+
if (input && typeof input === "object") {
|
|
16465
|
+
const candidates = [input.contentKey, input.dbKey, input.key];
|
|
16466
|
+
const preferredServerOrigin = asNonEmptyStringArray([
|
|
16467
|
+
input.preferredServerOrigin,
|
|
16468
|
+
input.serverOrigin
|
|
16469
|
+
])[0];
|
|
16470
|
+
const inputSpaceId = typeof input.spaceId === "string" && input.spaceId.trim().length > 0 ? input.spaceId : null;
|
|
16471
|
+
const includeAttachments = input.includeAttachments === true;
|
|
16472
|
+
for (const candidate of candidates) {
|
|
16473
|
+
if (typeof candidate === "string" && candidate.trim()) {
|
|
16474
|
+
return {
|
|
16475
|
+
contentKey: candidate,
|
|
16476
|
+
preferredServerOrigin,
|
|
16477
|
+
inputSpaceId,
|
|
16478
|
+
includeAttachments
|
|
16479
|
+
};
|
|
16480
|
+
}
|
|
16481
|
+
}
|
|
16482
|
+
}
|
|
16483
|
+
throw new Error("Invalid delete key");
|
|
16484
|
+
};
|
|
16485
|
+
var extractDeleteErrorMessage = (error, seen = /* @__PURE__ */ new Set(), depth = 0) => {
|
|
16486
|
+
if (depth > 8) {
|
|
16487
|
+
return null;
|
|
16488
|
+
}
|
|
16489
|
+
if (error instanceof Error && error.message.trim()) {
|
|
16490
|
+
return error.message;
|
|
16491
|
+
}
|
|
16492
|
+
if (typeof error === "string" && error.trim()) {
|
|
16493
|
+
return error;
|
|
16494
|
+
}
|
|
16495
|
+
if (!error || typeof error !== "object") {
|
|
16496
|
+
return null;
|
|
16497
|
+
}
|
|
16498
|
+
if (seen.has(error)) {
|
|
16499
|
+
return null;
|
|
16500
|
+
}
|
|
16501
|
+
seen.add(error);
|
|
16502
|
+
const record = error;
|
|
16503
|
+
const directKeys = ["message", "error", "detail", "title"];
|
|
16504
|
+
for (const key of directKeys) {
|
|
16505
|
+
const value = record[key];
|
|
16506
|
+
if (typeof value === "string" && value.trim()) {
|
|
16507
|
+
return value;
|
|
16508
|
+
}
|
|
16509
|
+
}
|
|
16510
|
+
const nestedKeys = ["payload", "data", "cause"];
|
|
16511
|
+
for (const key of nestedKeys) {
|
|
16512
|
+
const message = extractDeleteErrorMessage(record[key], seen, depth + 1);
|
|
16513
|
+
if (message) {
|
|
16514
|
+
return message;
|
|
16515
|
+
}
|
|
16516
|
+
}
|
|
16517
|
+
if (Array.isArray(record.errors)) {
|
|
16518
|
+
const messages = record.errors.map((item) => extractDeleteErrorMessage(item, seen, depth + 1)).filter((item) => Boolean(item));
|
|
16519
|
+
if (messages.length > 0) {
|
|
16520
|
+
return messages.join("\n");
|
|
16521
|
+
}
|
|
16522
|
+
}
|
|
16523
|
+
try {
|
|
16524
|
+
const serialized = JSON.stringify(error);
|
|
16525
|
+
if (serialized && serialized !== "{}") {
|
|
16526
|
+
return serialized;
|
|
16527
|
+
}
|
|
16528
|
+
} catch {
|
|
16529
|
+
return null;
|
|
16530
|
+
}
|
|
16531
|
+
return null;
|
|
16532
|
+
};
|
|
16533
|
+
var getDeleteErrorMessage = (error, fallback = "Delete failed") => {
|
|
16534
|
+
return extractDeleteErrorMessage(error) ?? fallback;
|
|
16535
|
+
};
|
|
16536
|
+
var normalizeDeleteError = (error) => {
|
|
16537
|
+
if (error instanceof Error && error.message.trim()) {
|
|
16538
|
+
return error;
|
|
16539
|
+
}
|
|
16540
|
+
return new Error(getDeleteErrorMessage(error));
|
|
16541
|
+
};
|
|
16542
|
+
var deleteDbKey = (input, spaceId) => async (dispatch, getState) => {
|
|
16543
|
+
try {
|
|
16544
|
+
const {
|
|
16545
|
+
contentKey,
|
|
16546
|
+
preferredServerOrigin,
|
|
16547
|
+
inputSpaceId,
|
|
16548
|
+
includeAttachments
|
|
16549
|
+
} = resolveDeleteInput(input);
|
|
16550
|
+
const effectiveSpaceId = typeof spaceId === "string" && spaceId.trim().length > 0 ? spaceId : inputSpaceId ?? null;
|
|
16551
|
+
await performDirectDelete(
|
|
16552
|
+
dispatch,
|
|
16553
|
+
getState,
|
|
16554
|
+
contentKey,
|
|
16555
|
+
preferredServerOrigin,
|
|
16556
|
+
includeAttachments
|
|
16557
|
+
);
|
|
16558
|
+
const spaceIds = isAppKey(contentKey) ? /* @__PURE__ */ new Set([
|
|
16559
|
+
effectiveSpaceId,
|
|
16560
|
+
...getAllMemberSpaces().map((space) => space.spaceId)
|
|
16561
|
+
]) : /* @__PURE__ */ new Set([effectiveSpaceId]);
|
|
16562
|
+
await Promise.all(
|
|
16563
|
+
[...spaceIds].filter((spaceId2) => Boolean(spaceId2)).map(
|
|
16564
|
+
(spaceId2) => dispatch(
|
|
16565
|
+
deleteContentFromSpace({
|
|
16566
|
+
contentKey,
|
|
16567
|
+
spaceId: spaceId2,
|
|
16568
|
+
...preferredServerOrigin ? { sourceServerOrigin: preferredServerOrigin } : {}
|
|
16569
|
+
})
|
|
16570
|
+
).unwrap().catch((err) => {
|
|
16571
|
+
console.warn("[deleteDbKey] space cleanup failed (entity already tombstoned):", err);
|
|
16572
|
+
})
|
|
16573
|
+
)
|
|
16574
|
+
);
|
|
16575
|
+
const favoriteProjectionRemoval = resolveDeletedFavoriteProjectionRemoval(contentKey);
|
|
16576
|
+
if (favoriteProjectionRemoval) {
|
|
16577
|
+
removeFavoriteLocally(favoriteProjectionRemoval);
|
|
16578
|
+
}
|
|
16579
|
+
if (typeof window !== "undefined") {
|
|
16580
|
+
window.dispatchEvent(
|
|
16581
|
+
new CustomEvent("nolo-user-data-updated", {
|
|
16582
|
+
detail: { deletedDbKey: contentKey }
|
|
16583
|
+
})
|
|
16584
|
+
);
|
|
16585
|
+
}
|
|
16586
|
+
return true;
|
|
16587
|
+
} catch (error) {
|
|
16588
|
+
throw normalizeDeleteError(error);
|
|
16589
|
+
}
|
|
16590
|
+
};
|
|
16591
|
+
|
|
16592
|
+
// packages/create/space/deleteSpaceAction.ts
|
|
16593
|
+
var getCurrentUserId = (state2) => asOptionalTrimmedString(selectIdentityUserId(state2)) ?? null;
|
|
16594
|
+
var fetchSpaceData = async (spaceId, dispatch) => {
|
|
16595
|
+
const spaceKey = createSpaceKey.space(spaceId);
|
|
16596
|
+
try {
|
|
16597
|
+
return await dispatch(read({
|
|
16598
|
+
dbKey: spaceKey
|
|
16599
|
+
})).unwrap();
|
|
16600
|
+
} catch (error) {
|
|
16601
|
+
console.warn(`Failed to read space ${spaceId}:`, error);
|
|
16602
|
+
return void 0;
|
|
16603
|
+
}
|
|
16604
|
+
};
|
|
16605
|
+
var checkOwnerPermission = (spaceData, accountUserId) => {
|
|
16606
|
+
if (!spaceData) return;
|
|
16607
|
+
if (isDeviceLocalSpaceBody(spaceData)) return;
|
|
16608
|
+
if (!accountUserId) {
|
|
16609
|
+
throw new Error("User is not logged in.");
|
|
16610
|
+
}
|
|
16611
|
+
if (spaceData.ownerId !== accountUserId) {
|
|
16612
|
+
throw new Error("Only owner can delete space");
|
|
16613
|
+
}
|
|
16614
|
+
};
|
|
16615
|
+
var deleteSpaceData = async (spaceId, dispatch) => {
|
|
16616
|
+
const spaceKey = createSpaceKey.space(spaceId);
|
|
16617
|
+
try {
|
|
16618
|
+
await dispatch(remove(spaceKey)).unwrap();
|
|
16619
|
+
} catch (error) {
|
|
16620
|
+
console.warn(`Failed to delete space ${spaceId}:`, error);
|
|
16621
|
+
}
|
|
16622
|
+
};
|
|
16623
|
+
var tombstoneLocalAuthorityRecord = async (dbKey, existing, dispatch) => {
|
|
16624
|
+
const nowIso = (/* @__PURE__ */ new Date()).toISOString();
|
|
16625
|
+
const base = existing && typeof existing === "object" ? { ...existing } : { dbKey };
|
|
16626
|
+
const tombstone = buildTombstoneRecord(
|
|
16627
|
+
{
|
|
16628
|
+
...base,
|
|
16629
|
+
dbKey,
|
|
16630
|
+
userId: DEVICE_LOCAL_OWNER_ID
|
|
16631
|
+
},
|
|
16632
|
+
nowIso
|
|
16633
|
+
);
|
|
16634
|
+
await dispatch(
|
|
16635
|
+
write({
|
|
16636
|
+
data: tombstone,
|
|
16637
|
+
customKey: dbKey,
|
|
16638
|
+
userId: DEVICE_LOCAL_OWNER_ID
|
|
16639
|
+
})
|
|
16640
|
+
).unwrap();
|
|
16641
|
+
};
|
|
16642
|
+
var deleteLocalSpaceAuthority = async (spaceId, spaceData, dispatch) => {
|
|
16643
|
+
const spaceKey = createSpaceKey.space(spaceId);
|
|
16644
|
+
try {
|
|
16645
|
+
await tombstoneLocalAuthorityRecord(
|
|
16646
|
+
spaceKey,
|
|
16647
|
+
spaceData && typeof spaceData === "object" ? spaceData : { dbKey: spaceKey },
|
|
16648
|
+
dispatch
|
|
16649
|
+
);
|
|
16650
|
+
} catch (error) {
|
|
16651
|
+
console.warn(`Failed to tombstone local space ${spaceId}:`, error);
|
|
16652
|
+
throw error;
|
|
16653
|
+
}
|
|
16654
|
+
const memberIds = /* @__PURE__ */ new Set([
|
|
16655
|
+
DEVICE_LOCAL_OWNER_ID,
|
|
16656
|
+
...asTrimmedNonEmptyStringArray(spaceData?.members)
|
|
16657
|
+
]);
|
|
16658
|
+
for (const memberId of memberIds) {
|
|
16659
|
+
const memberKey = createSpaceKey.member(memberId, spaceId);
|
|
16660
|
+
let existingMember = null;
|
|
16661
|
+
try {
|
|
16662
|
+
existingMember = await dispatch(read({ dbKey: memberKey })).unwrap();
|
|
16663
|
+
} catch {
|
|
16664
|
+
existingMember = null;
|
|
16665
|
+
}
|
|
16666
|
+
try {
|
|
16667
|
+
await tombstoneLocalAuthorityRecord(
|
|
16668
|
+
memberKey,
|
|
16669
|
+
existingMember ?? {
|
|
16670
|
+
dbKey: memberKey,
|
|
16671
|
+
type: "space" /* SPACE */,
|
|
16672
|
+
userId: memberId,
|
|
16673
|
+
spaceId: normalizeSpaceId(spaceId)
|
|
16674
|
+
},
|
|
16675
|
+
dispatch
|
|
16676
|
+
);
|
|
16677
|
+
} catch (err) {
|
|
16678
|
+
console.warn(
|
|
16679
|
+
`Failed to tombstone local membership ${memberId} for space ${spaceId}:`,
|
|
16680
|
+
err
|
|
16681
|
+
);
|
|
16682
|
+
}
|
|
16683
|
+
}
|
|
16684
|
+
};
|
|
16685
|
+
var deleteAllMembers = async (spaceData, spaceId, dispatch) => {
|
|
16686
|
+
if (spaceData?.members) {
|
|
16687
|
+
for (const memberId of spaceData.members) {
|
|
16688
|
+
const memberKey = createSpaceKey.member(memberId, spaceId);
|
|
16689
|
+
await dispatch(remove(memberKey)).unwrap().catch(
|
|
16690
|
+
(err) => console.warn(
|
|
16691
|
+
`Failed to delete member ${memberId} for space ${spaceId}:`,
|
|
16692
|
+
err
|
|
16693
|
+
)
|
|
16694
|
+
);
|
|
16695
|
+
}
|
|
16696
|
+
}
|
|
16697
|
+
};
|
|
16698
|
+
var deleteCurrentUserMember = async (userId, spaceId, dispatch) => {
|
|
16699
|
+
const currentUserMemberKey = createSpaceKey.member(userId, spaceId);
|
|
16700
|
+
await dispatch(remove(currentUserMemberKey)).unwrap().catch(
|
|
16701
|
+
(err) => console.warn(
|
|
16702
|
+
`Failed to delete member key for user ${userId} in space ${spaceId}:`,
|
|
16703
|
+
err
|
|
16704
|
+
)
|
|
16705
|
+
);
|
|
16706
|
+
};
|
|
16707
|
+
var resolveDeleteArgs = (input) => {
|
|
16708
|
+
if (typeof input === "string") {
|
|
16709
|
+
return { spaceId: input, strategy: "delete-space-only" };
|
|
16710
|
+
}
|
|
16711
|
+
return {
|
|
16712
|
+
spaceId: input.spaceId,
|
|
16713
|
+
strategy: input.strategy ?? "delete-space-only"
|
|
16714
|
+
};
|
|
16715
|
+
};
|
|
16716
|
+
var isOwnedByUser = (entityKey, entity, userId) => {
|
|
16717
|
+
if (!entityKey || !userId) return false;
|
|
16718
|
+
const keyParts = splitKey(entityKey);
|
|
16719
|
+
const keyedOwner = keyParts[1];
|
|
16720
|
+
if ((isDialogKey(entityKey) || isPageKey(entityKey) || isFileKey(entityKey) || isTableMetaKey(entityKey)) && keyedOwner === userId) {
|
|
16721
|
+
return true;
|
|
16722
|
+
}
|
|
16723
|
+
if ((isAgentKey(entityKey) || isAppKey(entityKey)) && entity?.userId === userId) {
|
|
16724
|
+
return true;
|
|
16725
|
+
}
|
|
16726
|
+
if (entity?.tenantId === userId || entity?.userId === userId || entity?.ownerId === userId) {
|
|
16727
|
+
return true;
|
|
16728
|
+
}
|
|
16729
|
+
return false;
|
|
16730
|
+
};
|
|
16731
|
+
var nextUpdatedAt = (entity) => {
|
|
16732
|
+
const source = entity?.updatedAt ?? entity?.updated_at ?? entity?.createdAt ?? entity?.created ?? Date.now();
|
|
16733
|
+
const timestamp = typeof source === "number" ? source : Date.parse(String(source)) || Date.now();
|
|
16734
|
+
return new Date(Math.max(Date.now(), timestamp + 1)).toISOString();
|
|
16735
|
+
};
|
|
16736
|
+
var listSpaceEntities = async (spaceData, dispatch) => {
|
|
16737
|
+
const results = [];
|
|
16738
|
+
const contents = Object.values(spaceData?.contents ?? {}).filter(Boolean);
|
|
16739
|
+
for (const item of contents) {
|
|
16740
|
+
const entityKey = typeof item.contentKey === "string" ? item.contentKey : "";
|
|
16741
|
+
if (!entityKey) continue;
|
|
16742
|
+
let entity = null;
|
|
16743
|
+
try {
|
|
16744
|
+
entity = await dispatch(read({ dbKey: entityKey })).unwrap();
|
|
16745
|
+
} catch {
|
|
16746
|
+
entity = null;
|
|
16747
|
+
}
|
|
16748
|
+
results.push({ entityKey, entity });
|
|
16749
|
+
}
|
|
16750
|
+
return results;
|
|
16751
|
+
};
|
|
16752
|
+
var clearEntitySpaceIds = async (entities, dispatch) => {
|
|
16753
|
+
await Promise.all(
|
|
16754
|
+
entities.filter(({ entity }) => entity && typeof entity === "object").map(
|
|
16755
|
+
({ entityKey, entity }) => dispatch(
|
|
16756
|
+
patch({
|
|
16757
|
+
dbKey: entityKey,
|
|
16758
|
+
changes: {
|
|
16759
|
+
spaceId: null,
|
|
16760
|
+
updatedAt: nextUpdatedAt(entity)
|
|
16761
|
+
}
|
|
16762
|
+
})
|
|
16763
|
+
).unwrap()
|
|
16764
|
+
)
|
|
16765
|
+
);
|
|
16766
|
+
};
|
|
16767
|
+
var deleteOwnedEntities = async (ownedEntities, dispatch) => {
|
|
16768
|
+
for (const { entityKey } of ownedEntities) {
|
|
16769
|
+
await dispatch(deleteDbKey(entityKey));
|
|
16770
|
+
}
|
|
16771
|
+
};
|
|
16772
|
+
var deleteSpaceAction = async (input, thunkAPI) => {
|
|
16773
|
+
const { dispatch, getState } = thunkAPI;
|
|
16774
|
+
const { spaceId, strategy } = resolveDeleteArgs(input);
|
|
16775
|
+
const accountUserId = getCurrentUserId(getState());
|
|
16776
|
+
const spaceData = await fetchSpaceData(spaceId, dispatch);
|
|
16777
|
+
const isLocalSpace = isDeviceLocalSpaceBody(spaceData);
|
|
16778
|
+
if (!isLocalSpace) {
|
|
16779
|
+
if (!accountUserId) {
|
|
16780
|
+
throw new Error("User is not logged in.");
|
|
16781
|
+
}
|
|
16782
|
+
checkOwnerPermission(spaceData, accountUserId);
|
|
16783
|
+
}
|
|
16784
|
+
const ownershipUserId = isLocalSpace ? DEVICE_LOCAL_OWNER_ID : accountUserId;
|
|
16785
|
+
if (spaceData && strategy !== "delete-space-only") {
|
|
16786
|
+
const allEntities = await listSpaceEntities(spaceData, dispatch);
|
|
16787
|
+
const ownedEntities = allEntities.filter(
|
|
16788
|
+
({ entityKey, entity }) => isOwnedByUser(entityKey, entity, ownershipUserId)
|
|
16789
|
+
);
|
|
16790
|
+
const unownedEntities = allEntities.filter(
|
|
16791
|
+
({ entityKey, entity }) => !isOwnedByUser(entityKey, entity, ownershipUserId)
|
|
16792
|
+
);
|
|
16793
|
+
if (strategy === "move-owned-to-all") {
|
|
16794
|
+
await clearEntitySpaceIds(allEntities, dispatch);
|
|
16795
|
+
} else if (strategy === "delete-owned-content") {
|
|
16796
|
+
await deleteOwnedEntities(ownedEntities, dispatch);
|
|
16797
|
+
await clearEntitySpaceIds(unownedEntities, dispatch);
|
|
16798
|
+
}
|
|
16799
|
+
}
|
|
16800
|
+
if (isLocalSpace) {
|
|
16801
|
+
await deleteLocalSpaceAuthority(spaceId, spaceData, dispatch);
|
|
16802
|
+
} else {
|
|
16803
|
+
await deleteSpaceData(spaceId, dispatch);
|
|
16804
|
+
await deleteAllMembers(spaceData, spaceId, dispatch);
|
|
16805
|
+
await deleteCurrentUserMember(accountUserId, spaceId, dispatch);
|
|
16806
|
+
}
|
|
16807
|
+
return { spaceId, strategy };
|
|
16808
|
+
};
|
|
16809
|
+
|
|
16810
|
+
// packages/create/space/fetchSpaceAction.ts
|
|
16811
|
+
var fetchSpaceAction = async (input, thunkAPI) => {
|
|
16812
|
+
const rawSpaceId = typeof input === "string" ? input : input?.spaceId;
|
|
16813
|
+
const fresh = typeof input === "object" && input !== null ? !!input.fresh : false;
|
|
16814
|
+
const { dispatch } = thunkAPI;
|
|
16815
|
+
if (!rawSpaceId) {
|
|
16816
|
+
throw new Error("spaceId is required");
|
|
16817
|
+
}
|
|
16818
|
+
const spaceId = normalizeSpaceId(rawSpaceId);
|
|
16819
|
+
const spaceKey = createSpaceKey.space(spaceId);
|
|
16820
|
+
const readSpace = async (dbKey) => {
|
|
16821
|
+
try {
|
|
16822
|
+
const { read: read2, readAndWait: readAndWait2 } = await import("./dbSlice-YORO4VL4.js");
|
|
16823
|
+
if (fresh) {
|
|
16824
|
+
return await dispatch(readAndWait2(dbKey)).unwrap();
|
|
16825
|
+
}
|
|
16826
|
+
return await dispatch(
|
|
16827
|
+
read2({
|
|
16828
|
+
dbKey
|
|
16829
|
+
})
|
|
16830
|
+
).unwrap();
|
|
16831
|
+
} catch {
|
|
16832
|
+
return null;
|
|
16833
|
+
}
|
|
16834
|
+
};
|
|
16835
|
+
const readLocalSpaceBody = async () => {
|
|
16836
|
+
let spaceData2 = await readSpace(spaceKey);
|
|
16837
|
+
if (!spaceData2 && rawSpaceId !== spaceKey) {
|
|
16838
|
+
spaceData2 = await readSpace(rawSpaceId);
|
|
16839
|
+
}
|
|
16840
|
+
if (!spaceData2 || isTombstoneRecord(spaceData2)) {
|
|
16841
|
+
return null;
|
|
16842
|
+
}
|
|
16843
|
+
return spaceData2;
|
|
16844
|
+
};
|
|
16845
|
+
if (fresh) {
|
|
16846
|
+
const localBody = await readLocalSpaceBody();
|
|
16847
|
+
if (localBody && isDeviceLocalSpaceBody(localBody)) {
|
|
16848
|
+
return { spaceId, spaceData: localBody };
|
|
16849
|
+
}
|
|
16850
|
+
const { token, userId, servers } = selectSpaceRemoteAuth(thunkAPI.getState());
|
|
16851
|
+
if (token && userId && servers.length > 0) {
|
|
16852
|
+
const remoteSpace = await fetchAuthoritativeRemoteSpace({
|
|
16853
|
+
servers,
|
|
16854
|
+
token,
|
|
16855
|
+
userId,
|
|
16856
|
+
spaceId
|
|
16857
|
+
});
|
|
16858
|
+
if (remoteSpace) return { spaceId, spaceData: remoteSpace };
|
|
16859
|
+
throw new Error(`Space not found: ${spaceId}`);
|
|
16860
|
+
}
|
|
16861
|
+
if (localBody) {
|
|
16862
|
+
return { spaceId, spaceData: localBody };
|
|
16863
|
+
}
|
|
16864
|
+
throw new Error(`Space not found: ${spaceId}`);
|
|
16865
|
+
}
|
|
16866
|
+
const spaceData = await readLocalSpaceBody();
|
|
16867
|
+
if (!spaceData) {
|
|
16868
|
+
throw new Error(`Space not found: ${spaceId}`);
|
|
16869
|
+
}
|
|
16870
|
+
return { spaceId, spaceData };
|
|
16871
|
+
};
|
|
16872
|
+
|
|
16873
|
+
// packages/create/space/updateSpaceAction.ts
|
|
16874
|
+
var updateSpaceAction = async (input, thunkAPI) => {
|
|
16875
|
+
const { spaceId, name, description, visibility, boundFolder } = input;
|
|
16876
|
+
const { dispatch, getState } = thunkAPI;
|
|
16877
|
+
const state2 = getState();
|
|
16878
|
+
const userId = selectIdentityUserId(state2);
|
|
16879
|
+
const spaceKey = createSpaceKey.space(spaceId);
|
|
16880
|
+
let spaceData = null;
|
|
16881
|
+
try {
|
|
16882
|
+
spaceData = await dispatch(read({
|
|
16883
|
+
dbKey: spaceKey
|
|
16884
|
+
})).unwrap();
|
|
16885
|
+
} catch (readError) {
|
|
16886
|
+
throw new Error(
|
|
16887
|
+
`\u65E0\u6CD5\u52A0\u8F7D\u7A7A\u95F4\u6570\u636E: ${spaceId}, \u539F\u56E0: ${toErrorMessage(readError)}`
|
|
16888
|
+
);
|
|
16889
|
+
}
|
|
16890
|
+
if (!spaceData) {
|
|
16891
|
+
throw new Error(`\u7A7A\u95F4\u4E0D\u5B58\u5728: ${spaceId}`);
|
|
16892
|
+
}
|
|
16893
|
+
if (!userId) {
|
|
16894
|
+
throw new Error("\u7528\u6237\u672A\u767B\u5F55\uFF0C\u65E0\u6CD5\u66F4\u65B0\u7A7A\u95F4\u8BBE\u7F6E\u3002");
|
|
16895
|
+
}
|
|
16896
|
+
if (!spaceData.members || !spaceData.members.includes(userId)) {
|
|
16897
|
+
throw new Error("\u5F53\u524D\u7528\u6237\u4E0D\u662F\u7A7A\u95F4\u6210\u5458\uFF0C\u65E0\u6CD5\u66F4\u65B0\u7A7A\u95F4\u8BBE\u7F6E\u3002");
|
|
16898
|
+
}
|
|
16899
|
+
const changes = {};
|
|
16900
|
+
let hasChanges = false;
|
|
16901
|
+
if (name !== void 0 && name !== spaceData.name) {
|
|
16902
|
+
changes.name = name.trim();
|
|
16903
|
+
hasChanges = true;
|
|
16904
|
+
}
|
|
16905
|
+
if (description !== void 0 && description !== spaceData.description) {
|
|
16906
|
+
changes.description = description;
|
|
16907
|
+
hasChanges = true;
|
|
16908
|
+
}
|
|
16909
|
+
if (visibility !== void 0 && visibility !== spaceData.visibility) {
|
|
16910
|
+
changes.visibility = visibility;
|
|
16911
|
+
hasChanges = true;
|
|
16912
|
+
}
|
|
16913
|
+
if (boundFolder !== void 0 && (boundFolder || void 0) !== (spaceData.boundFolder || void 0)) {
|
|
16914
|
+
changes.boundFolder = boundFolder || void 0;
|
|
16915
|
+
hasChanges = true;
|
|
16916
|
+
}
|
|
16917
|
+
if (!hasChanges) {
|
|
16918
|
+
return { updatedSpace: spaceData, spaceId };
|
|
16919
|
+
}
|
|
16920
|
+
const now = Date.now();
|
|
16921
|
+
changes.updatedAt = now;
|
|
16922
|
+
let updatedSpaceData;
|
|
16923
|
+
try {
|
|
16924
|
+
updatedSpaceData = await dispatch(
|
|
16925
|
+
patch({
|
|
16926
|
+
dbKey: spaceKey,
|
|
16927
|
+
changes
|
|
16928
|
+
})
|
|
16929
|
+
).unwrap();
|
|
16930
|
+
} catch (patchError) {
|
|
16931
|
+
throw new Error(`\u66F4\u65B0\u7A7A\u95F4\u8BBE\u7F6E\u5931\u8D25: ${toErrorMessage(patchError)}`);
|
|
16932
|
+
}
|
|
16933
|
+
if (changes.name !== void 0) {
|
|
16934
|
+
const memberKey = createSpaceKey.member(userId, spaceId);
|
|
16935
|
+
try {
|
|
16936
|
+
const memberData = await dispatch(
|
|
16937
|
+
read({
|
|
16938
|
+
dbKey: memberKey
|
|
16939
|
+
})
|
|
16940
|
+
).unwrap();
|
|
16941
|
+
if (memberData) {
|
|
16942
|
+
const memberChanges = {
|
|
16943
|
+
spaceName: changes.name,
|
|
16944
|
+
updatedAt: now
|
|
16945
|
+
// 为 member 数据也设置 updatedAt
|
|
16946
|
+
};
|
|
16947
|
+
await dispatch(
|
|
16948
|
+
patch({
|
|
16949
|
+
dbKey: memberKey,
|
|
16950
|
+
changes: memberChanges
|
|
16951
|
+
})
|
|
16952
|
+
).unwrap();
|
|
16953
|
+
}
|
|
16954
|
+
} catch (memberError) {
|
|
16955
|
+
console.error(
|
|
16956
|
+
`Failed to update member data ${memberKey} for space name change:`,
|
|
16957
|
+
memberError
|
|
16958
|
+
);
|
|
16959
|
+
}
|
|
16960
|
+
}
|
|
16961
|
+
return {
|
|
16962
|
+
updatedSpace: updatedSpaceData,
|
|
16963
|
+
spaceId
|
|
16964
|
+
};
|
|
16965
|
+
};
|
|
16966
|
+
|
|
16967
|
+
// packages/create/space/fetchSpaceSidebarStateAction.ts
|
|
16968
|
+
var fetchSpaceSidebarStateAction = async (spaceId, thunkAPI) => {
|
|
16969
|
+
const { dispatch, getState } = thunkAPI;
|
|
16970
|
+
const normalizedSpaceId = normalizeSpaceId(spaceId);
|
|
16971
|
+
return {
|
|
16972
|
+
collapsedCategories: typeof window === "undefined" ? {} : readStoredCollapsedCategories(
|
|
16973
|
+
normalizedSpaceId,
|
|
16974
|
+
window.localStorage
|
|
16975
|
+
)
|
|
16976
|
+
};
|
|
16977
|
+
};
|
|
16978
|
+
|
|
16979
|
+
// packages/create/space/applyFetchSpaceFulfilled.ts
|
|
16980
|
+
function applyFetchSpaceFulfilled(payload) {
|
|
16981
|
+
const { spaceId, spaceData } = payload;
|
|
16982
|
+
const currentSpaceId = getCurrentSpaceIdRaw();
|
|
16983
|
+
if (!currentSpaceId || currentSpaceId === spaceId) {
|
|
16984
|
+
setCurrentSpaceBoth(spaceId, spaceData);
|
|
16985
|
+
setSpaceInitialized();
|
|
16986
|
+
}
|
|
16987
|
+
}
|
|
16988
|
+
|
|
16989
|
+
// packages/create/space/changeSpaceAction.ts
|
|
16990
|
+
var getSpaceUpdatedAt2 = (space) => {
|
|
16991
|
+
if (!space) return 0;
|
|
16992
|
+
return toTimestampMs(space.updatedAt);
|
|
16993
|
+
};
|
|
16994
|
+
var changeSpaceAction = async (spaceId, thunkAPI) => {
|
|
16995
|
+
const normalizedSpaceId = normalizeSpaceId(spaceId);
|
|
16996
|
+
const sidebarPromise = fetchSpaceSidebarStateAction(
|
|
16997
|
+
normalizedSpaceId,
|
|
16998
|
+
thunkAPI
|
|
16999
|
+
).catch(() => ({ collapsedCategories: {} }));
|
|
17000
|
+
let spaceData = null;
|
|
17001
|
+
let usedLocal = false;
|
|
17002
|
+
try {
|
|
17003
|
+
const local = await fetchSpaceAction(
|
|
17004
|
+
{ spaceId: normalizedSpaceId, fresh: false },
|
|
17005
|
+
thunkAPI
|
|
17006
|
+
);
|
|
17007
|
+
if (local?.spaceData) {
|
|
17008
|
+
spaceData = local.spaceData;
|
|
17009
|
+
usedLocal = true;
|
|
17010
|
+
}
|
|
17011
|
+
} catch {
|
|
17012
|
+
}
|
|
17013
|
+
if (!spaceData) {
|
|
17014
|
+
const fresh = await fetchSpaceAction(
|
|
17015
|
+
{ spaceId: normalizedSpaceId, fresh: true },
|
|
17016
|
+
thunkAPI
|
|
17017
|
+
);
|
|
17018
|
+
if (!fresh?.spaceData) {
|
|
17019
|
+
throw new Error("\u7A7A\u95F4\u4E0D\u5B58\u5728\u6216\u52A0\u8F7D\u5931\u8D25");
|
|
17020
|
+
}
|
|
17021
|
+
spaceData = fresh.spaceData;
|
|
17022
|
+
} else if (usedLocal) {
|
|
17023
|
+
void fetchSpaceAction({ spaceId: normalizedSpaceId, fresh: true }, thunkAPI).then((result) => {
|
|
17024
|
+
if (!result?.spaceData) return;
|
|
17025
|
+
if (normalizeSpaceId(getCurrentSpaceIdRaw() || "") !== normalizedSpaceId) {
|
|
17026
|
+
return;
|
|
17027
|
+
}
|
|
17028
|
+
if (getSpaceUpdatedAt2(result.spaceData) < getSpaceUpdatedAt2(getCurrentSpaceRaw())) {
|
|
17029
|
+
return;
|
|
17030
|
+
}
|
|
17031
|
+
applyFetchSpaceFulfilled({
|
|
17032
|
+
spaceId: normalizedSpaceId,
|
|
17033
|
+
spaceData: result.spaceData
|
|
17034
|
+
});
|
|
17035
|
+
}).catch(() => {
|
|
17036
|
+
});
|
|
17037
|
+
}
|
|
17038
|
+
const sidebarState = await sidebarPromise;
|
|
17039
|
+
return {
|
|
17040
|
+
spaceId: normalizedSpaceId,
|
|
17041
|
+
spaceData,
|
|
17042
|
+
sidebarState
|
|
17043
|
+
};
|
|
17044
|
+
};
|
|
17045
|
+
|
|
17046
|
+
// packages/create/space/spaceThunks.ts
|
|
17047
|
+
var errorMessage = (error) => error?.message;
|
|
17048
|
+
var fetchSpaceSidebarState = createAsyncThunk(
|
|
17049
|
+
"space/fetchSpaceSidebarState",
|
|
17050
|
+
async (arg, thunkAPI) => {
|
|
17051
|
+
try {
|
|
17052
|
+
const payload = await fetchSpaceSidebarStateAction(arg, thunkAPI);
|
|
17053
|
+
setCollapsedCategories(
|
|
17054
|
+
payload.collapsedCategories,
|
|
17055
|
+
getCurrentSpaceIdRaw()
|
|
17056
|
+
);
|
|
17057
|
+
return payload;
|
|
17058
|
+
} catch (error) {
|
|
17059
|
+
console.error("\u83B7\u53D6\u7A7A\u95F4\u4FA7\u8FB9\u680F\u72B6\u6001\u5931\u8D25:", errorMessage(error));
|
|
17060
|
+
setCollapsedCategories({}, getCurrentSpaceIdRaw());
|
|
17061
|
+
throw error;
|
|
17062
|
+
}
|
|
17063
|
+
}
|
|
17064
|
+
);
|
|
17065
|
+
var changeSpace = createAsyncThunk(
|
|
17066
|
+
"space/changeSpace",
|
|
17067
|
+
async (arg, thunkAPI) => {
|
|
17068
|
+
const newSpaceId = normalizeSpaceId(arg);
|
|
17069
|
+
if (getCurrentSpaceIdRaw() !== newSpaceId) {
|
|
17070
|
+
setMembershipLoading();
|
|
17071
|
+
setCurrentSpace(null);
|
|
17072
|
+
}
|
|
17073
|
+
try {
|
|
17074
|
+
const payload = await changeSpaceAction(arg, thunkAPI);
|
|
17075
|
+
setCurrentSpaceBoth(payload.spaceId, payload.spaceData);
|
|
17076
|
+
setMembershipLoaded();
|
|
17077
|
+
setCollapsedCategories(
|
|
17078
|
+
payload.sidebarState?.collapsedCategories || {},
|
|
17079
|
+
payload.spaceId
|
|
17080
|
+
);
|
|
17081
|
+
return payload;
|
|
17082
|
+
} catch (error) {
|
|
17083
|
+
setMembershipRejected(errorMessage(error) || "\u5207\u6362\u7A7A\u95F4\u5931\u8D25", false);
|
|
17084
|
+
setCurrentSpaceBoth(null, null);
|
|
17085
|
+
setCollapsedCategories({}, null);
|
|
17086
|
+
throw error;
|
|
17087
|
+
}
|
|
17088
|
+
}
|
|
17089
|
+
);
|
|
17090
|
+
var addSpace = createAsyncThunk(
|
|
17091
|
+
"space/addSpace",
|
|
17092
|
+
async (arg, thunkAPI) => {
|
|
17093
|
+
setMembershipLoading();
|
|
17094
|
+
try {
|
|
17095
|
+
const payload = await addSpaceAction(arg, thunkAPI);
|
|
17096
|
+
addMemberSpace(payload);
|
|
17097
|
+
return payload;
|
|
17098
|
+
} catch (error) {
|
|
17099
|
+
setMembershipRejected(errorMessage(error), false);
|
|
17100
|
+
throw error;
|
|
17101
|
+
}
|
|
17102
|
+
}
|
|
17103
|
+
);
|
|
17104
|
+
var deleteSpace = createAsyncThunk(
|
|
17105
|
+
"space/deleteSpace",
|
|
17106
|
+
async (arg, thunkAPI) => {
|
|
17107
|
+
const payload = await deleteSpaceAction(arg, thunkAPI);
|
|
17108
|
+
const normalizedSpaceId = normalizeSpaceId(payload.spaceId);
|
|
17109
|
+
const currentSpaceId = getCurrentSpaceIdRaw();
|
|
17110
|
+
const normalizedCurrentSpaceId = currentSpaceId ? normalizeSpaceId(currentSpaceId) : null;
|
|
17111
|
+
removeMemberSpace(normalizedSpaceId);
|
|
17112
|
+
if (normalizedCurrentSpaceId === normalizedSpaceId) {
|
|
17113
|
+
setCurrentSpaceBoth(null, null);
|
|
17114
|
+
setCollapsedCategories({}, null);
|
|
17115
|
+
setViewMode("all");
|
|
17116
|
+
}
|
|
17117
|
+
return payload;
|
|
17118
|
+
}
|
|
17119
|
+
);
|
|
17120
|
+
var updateSpace = createAsyncThunk(
|
|
17121
|
+
"space/updateSpace",
|
|
17122
|
+
async (arg, thunkAPI) => {
|
|
17123
|
+
const payload = await updateSpaceAction(arg, thunkAPI);
|
|
17124
|
+
const { updatedSpace, spaceId } = payload;
|
|
17125
|
+
updateCurrentSpaceIfMatch(spaceId, updatedSpace);
|
|
17126
|
+
if (updatedSpace.name) {
|
|
17127
|
+
updateMemberSpaceName(updatedSpace.id, updatedSpace.name);
|
|
17128
|
+
}
|
|
17129
|
+
return payload;
|
|
17130
|
+
}
|
|
17131
|
+
);
|
|
17132
|
+
var fetchSpace = createAsyncThunk(
|
|
17133
|
+
"space/fetchSpace",
|
|
17134
|
+
async (arg, thunkAPI) => {
|
|
17135
|
+
const payload = await fetchSpaceAction(arg, thunkAPI);
|
|
17136
|
+
applyFetchSpaceFulfilled(payload);
|
|
17137
|
+
return payload;
|
|
17138
|
+
}
|
|
17139
|
+
);
|
|
17140
|
+
|
|
15731
17141
|
// packages/ai/tools/deleteSpacesToolModel.ts
|
|
15732
17142
|
var getSpaceName = (membership, record) => String(
|
|
15733
17143
|
membership.spaceName ?? membership.name ?? membership.title ?? record?.name ?? record?.title ?? membership.spaceId ?? ""
|
|
@@ -15839,7 +17249,7 @@ var deleteSpacesFunctionSchema = {
|
|
|
15839
17249
|
};
|
|
15840
17250
|
var defaultDeps = {
|
|
15841
17251
|
selectCurrentUserId: selectIdentityUserId,
|
|
15842
|
-
selectMemberSpaces: (
|
|
17252
|
+
selectMemberSpaces: (state2) => getAllMemberSpaces(),
|
|
15843
17253
|
readSpaceRecord: async (thunkApi, spaceId) => {
|
|
15844
17254
|
try {
|
|
15845
17255
|
const record = await thunkApi.dispatch(
|
|
@@ -15850,13 +17260,13 @@ var defaultDeps = {
|
|
|
15850
17260
|
return null;
|
|
15851
17261
|
}
|
|
15852
17262
|
},
|
|
15853
|
-
selectDeleteServers: (
|
|
15854
|
-
const { currentServer, remoteServers } = getRuntimeServerContext(
|
|
17263
|
+
selectDeleteServers: (state2) => {
|
|
17264
|
+
const { currentServer, remoteServers } = getRuntimeServerContext(state2);
|
|
15855
17265
|
return remoteServers.length > 0 ? remoteServers : currentServer ? [currentServer] : [];
|
|
15856
17266
|
},
|
|
15857
17267
|
deleteServerKey: async (thunkApi, server, dbKey) => {
|
|
15858
|
-
const
|
|
15859
|
-
const token =
|
|
17268
|
+
const state2 = thunkApi.getState();
|
|
17269
|
+
const token = state2?.auth?.currentToken;
|
|
15860
17270
|
if (!server) {
|
|
15861
17271
|
return { ok: false, status: 0, detail: "missing server" };
|
|
15862
17272
|
}
|
|
@@ -15890,13 +17300,13 @@ var readSpaceRecordsById = async (thunkApi, memberships, deps) => {
|
|
|
15890
17300
|
return recordsById;
|
|
15891
17301
|
};
|
|
15892
17302
|
var loadDeletionContext = async (args, thunkApi, deps) => {
|
|
15893
|
-
const
|
|
15894
|
-
const currentUserId = deps.selectCurrentUserId(
|
|
17303
|
+
const state2 = thunkApi.getState();
|
|
17304
|
+
const currentUserId = deps.selectCurrentUserId(state2);
|
|
15895
17305
|
if (!currentUserId) {
|
|
15896
17306
|
throw new Error("deleteSpaces \u9700\u8981\u5F53\u524D\u767B\u5F55\u7528\u6237\u3002");
|
|
15897
17307
|
}
|
|
15898
|
-
const memberships = deps.selectMemberSpaces(
|
|
15899
|
-
const deleteServers = deps.selectDeleteServers(
|
|
17308
|
+
const memberships = deps.selectMemberSpaces(state2);
|
|
17309
|
+
const deleteServers = deps.selectDeleteServers(state2);
|
|
15900
17310
|
const candidates = filterSpaceDeletionCandidates(memberships, {
|
|
15901
17311
|
query: args.query,
|
|
15902
17312
|
matchMode: args.matchMode
|
|
@@ -16513,8 +17923,8 @@ var extractLegacyValues = (args) => {
|
|
|
16513
17923
|
);
|
|
16514
17924
|
};
|
|
16515
17925
|
async function addTableRowFunc(args, thunkApi) {
|
|
16516
|
-
const
|
|
16517
|
-
const tableState =
|
|
17926
|
+
const state2 = thunkApi.getState();
|
|
17927
|
+
const tableState = state2.table;
|
|
16518
17928
|
const currentTable = tableState.currentTable;
|
|
16519
17929
|
const tenantId = args?.tenantId ?? currentTable?.tenantId;
|
|
16520
17930
|
const tableId = args?.tableId ?? currentTable?.tableId;
|
|
@@ -16926,9 +18336,9 @@ var readSharedTableMeta = async (thunkApi, tableDbKey) => {
|
|
|
16926
18336
|
return result.payload;
|
|
16927
18337
|
};
|
|
16928
18338
|
async function shareTableFunc(args, thunkApi) {
|
|
16929
|
-
const
|
|
16930
|
-
const dialogId =
|
|
16931
|
-
const latestUserInput =
|
|
18339
|
+
const state2 = thunkApi?.getState?.();
|
|
18340
|
+
const dialogId = state2 ? selectCurrentDialogId(state2) : void 0;
|
|
18341
|
+
const latestUserInput = state2 ? selectAllMsgs(state2, dialogId).slice().reverse().find((message) => message?.role === "user" && typeof message?.content === "string")?.content : void 0;
|
|
16932
18342
|
if (!hasExplicitPublicShareRequest(latestUserInput)) {
|
|
16933
18343
|
throw new Error("\u5F53\u524D\u7B56\u7565\u4E0D\u5141\u8BB8\u5728\u7528\u6237\u672A\u660E\u786E\u8981\u6C42\u516C\u5F00/\u793E\u533A\u5206\u4EAB\u65F6\u81EA\u52A8\u53D1\u5E03\u8868\u3002");
|
|
16934
18344
|
}
|
|
@@ -17235,8 +18645,8 @@ var pickRowColumns = (row, columns, options = {}) => {
|
|
|
17235
18645
|
var formatKnownColumns = (tableMeta) => tableMeta.columns.map((column) => column.name).join(", ") || "(\u65E0\u5217\u5B9A\u4E49)";
|
|
17236
18646
|
|
|
17237
18647
|
// packages/ai/tools/table/toolShared.ts
|
|
17238
|
-
var resolveTableIdentity = (args,
|
|
17239
|
-
const currentTable =
|
|
18648
|
+
var resolveTableIdentity = (args, state2) => {
|
|
18649
|
+
const currentTable = state2.table.currentTable;
|
|
17240
18650
|
const tenantId = args.tenantId ?? currentTable?.tenantId;
|
|
17241
18651
|
const tableId = args.tableId ?? currentTable?.tableId;
|
|
17242
18652
|
return { tenantId, tableId, currentTable };
|
|
@@ -17255,8 +18665,8 @@ async function ensureRowsLoaded(thunkApi, tenantId, tableId) {
|
|
|
17255
18665
|
const message = result.payload || result.error?.message || "\u52A0\u8F7D\u8868\u884C\u5931\u8D25";
|
|
17256
18666
|
throw new Error(message);
|
|
17257
18667
|
}
|
|
17258
|
-
const
|
|
17259
|
-
return
|
|
18668
|
+
const state2 = thunkApi.getState();
|
|
18669
|
+
return state2.table.rows.filter(
|
|
17260
18670
|
(row) => row?.tenantId === tenantId && row?.tableId === tableId && !row?.deletedAt
|
|
17261
18671
|
);
|
|
17262
18672
|
}
|
|
@@ -17329,14 +18739,14 @@ var toPreviewJson3 = (value, maxLength = 600) => {
|
|
|
17329
18739
|
return "[\u65E0\u6CD5\u5E8F\u5217\u5316\u4E3A JSON]";
|
|
17330
18740
|
}
|
|
17331
18741
|
};
|
|
17332
|
-
var selectCurrentUserId = (
|
|
18742
|
+
var selectCurrentUserId = (state2) => typeof state2.auth?.currentUser?.userId === "string" ? state2.auth.currentUser.userId : void 0;
|
|
17333
18743
|
var normalizeTableQueryArgs = (args, thunkApi) => {
|
|
17334
|
-
const
|
|
17335
|
-
return buildNoloTableQueryRequest(args ?? {}, selectCurrentUserId(
|
|
18744
|
+
const state2 = thunkApi.getState();
|
|
18745
|
+
return buildNoloTableQueryRequest(args ?? {}, selectCurrentUserId(state2)) ?? args;
|
|
17336
18746
|
};
|
|
17337
18747
|
var requireTableIdentity = (args, thunkApi) => {
|
|
17338
|
-
const
|
|
17339
|
-
const { tenantId, tableId } = resolveTableIdentity(args,
|
|
18748
|
+
const state2 = thunkApi.getState();
|
|
18749
|
+
const { tenantId, tableId } = resolveTableIdentity(args, state2);
|
|
17340
18750
|
if (!tenantId || !tableId) {
|
|
17341
18751
|
throw new Error("\u9700\u8981\u663E\u5F0F\u63D0\u4F9B tenantId \u548C tableId\uFF0C\u6216\u5728\u5DF2\u6253\u5F00\u7684\u8868\u9875\u9762\u4E2D\u8C03\u7528\u3002");
|
|
17342
18752
|
}
|
|
@@ -17664,8 +19074,8 @@ async function deleteTableRowsFunc(args, thunkApi) {
|
|
|
17664
19074
|
|
|
17665
19075
|
// packages/ai/tools/table/schemaTools.ts
|
|
17666
19076
|
var requireTableIdentity2 = (args, thunkApi) => {
|
|
17667
|
-
const
|
|
17668
|
-
const { tenantId, tableId } = resolveTableIdentity(args,
|
|
19077
|
+
const state2 = thunkApi.getState();
|
|
19078
|
+
const { tenantId, tableId } = resolveTableIdentity(args, state2);
|
|
17669
19079
|
if (!tenantId || !tableId) {
|
|
17670
19080
|
throw new Error("\u9700\u8981\u663E\u5F0F\u63D0\u4F9B tenantId \u548C tableId\uFF0C\u6216\u5728\u5DF2\u6253\u5F00\u7684\u8868\u9875\u9762\u4E2D\u8C03\u7528\u3002");
|
|
17671
19081
|
}
|
|
@@ -20360,7 +21770,7 @@ var cloudflareCrawlStatusFunctionSchema = {
|
|
|
20360
21770
|
async function cloudflareCrawlStatusFunc(args, thunkApi) {
|
|
20361
21771
|
const { jobId, limit, status, cursor } = args;
|
|
20362
21772
|
if (!jobId) throw new Error("\u5FC5\u987B\u63D0\u4F9B jobId");
|
|
20363
|
-
const { getToolRequestContext: getToolRequestContext2 } = await import("./toolApiClient-
|
|
21773
|
+
const { getToolRequestContext: getToolRequestContext2 } = await import("./toolApiClient-53U4UDFF.js");
|
|
20364
21774
|
const { baseUrl, token } = getToolRequestContext2(thunkApi);
|
|
20365
21775
|
const params = new URLSearchParams();
|
|
20366
21776
|
if (limit !== void 0) params.set("limit", String(limit));
|
|
@@ -21130,12 +22540,12 @@ function stringifyIfPresent(value) {
|
|
|
21130
22540
|
|
|
21131
22541
|
// packages/ai/tools/geminiImagePreviewTool.ts
|
|
21132
22542
|
var selectCurrentDialogKeyFromState = (_state) => getActiveDialogKey();
|
|
21133
|
-
var selectCurrentSpaceIdFromState = (
|
|
21134
|
-
var selectUserIdFromState = (
|
|
21135
|
-
var selectCurrentServerFromState = (
|
|
22543
|
+
var selectCurrentSpaceIdFromState = (_state) => getCurrentSpaceId();
|
|
22544
|
+
var selectUserIdFromState = (state2) => typeof state2?.auth?.currentUser?.userId === "string" ? state2.auth.currentUser.userId : null;
|
|
22545
|
+
var selectCurrentServerFromState = (state2) => typeof state2?.settings?.currentServer === "string" ? state2.settings.currentServer : null;
|
|
21136
22546
|
async function addImageContentToSpace(input) {
|
|
21137
22547
|
const injectedAddContentAction = input.thunkApi?.extra?.addContentAction;
|
|
21138
|
-
const addContentAction2 = typeof injectedAddContentAction === "function" ? injectedAddContentAction : (await import("./addContentAction-
|
|
22548
|
+
const addContentAction2 = typeof injectedAddContentAction === "function" ? injectedAddContentAction : (await import("./addContentAction-2HJJITDI.js")).addContentAction;
|
|
21139
22549
|
await addContentAction2(
|
|
21140
22550
|
{
|
|
21141
22551
|
spaceId: input.spaceId,
|
|
@@ -21414,8 +22824,8 @@ var createGeminiImageExecutor = (model) => async (args, thunkApi) => {
|
|
|
21414
22824
|
if (!trimmedPrompt) {
|
|
21415
22825
|
throw new Error("prompt \u4E0D\u80FD\u4E3A\u7A7A");
|
|
21416
22826
|
}
|
|
21417
|
-
const
|
|
21418
|
-
const currentDialogKey = selectCurrentDialogKeyFromState(
|
|
22827
|
+
const state2 = thunkApi.getState();
|
|
22828
|
+
const currentDialogKey = selectCurrentDialogKeyFromState(state2);
|
|
21419
22829
|
const dialogId = currentDialogKey ? extractCustomId(currentDialogKey) : void 0;
|
|
21420
22830
|
const result = await callToolApi(
|
|
21421
22831
|
thunkApi,
|
|
@@ -21423,9 +22833,9 @@ var createGeminiImageExecutor = (model) => async (args, thunkApi) => {
|
|
|
21423
22833
|
{ prompt: trimmedPrompt, images, aspectRatio, imageSize, model, dialogId },
|
|
21424
22834
|
{ withAuth: true }
|
|
21425
22835
|
);
|
|
21426
|
-
const spaceId = selectCurrentSpaceIdFromState(
|
|
21427
|
-
const userId = selectUserIdFromState(
|
|
21428
|
-
const currentServer = selectCurrentServerFromState(
|
|
22836
|
+
const spaceId = selectCurrentSpaceIdFromState(state2);
|
|
22837
|
+
const userId = selectUserIdFromState(state2);
|
|
22838
|
+
const currentServer = selectCurrentServerFromState(state2);
|
|
21429
22839
|
if (spaceId && userId && result?.files?.length) {
|
|
21430
22840
|
for (let i = 0; i < result.files.length; i++) {
|
|
21431
22841
|
const f = result.files[i];
|
|
@@ -21579,8 +22989,8 @@ var runOpenAIImageTool = async (args, thunkApi, model) => {
|
|
|
21579
22989
|
if (!trimmedPrompt) {
|
|
21580
22990
|
throw new Error("prompt \u4E0D\u80FD\u4E3A\u7A7A");
|
|
21581
22991
|
}
|
|
21582
|
-
const
|
|
21583
|
-
const currentDialogKey = selectCurrentDialogKey(
|
|
22992
|
+
const state2 = thunkApi.getState();
|
|
22993
|
+
const currentDialogKey = selectCurrentDialogKey(state2);
|
|
21584
22994
|
const dialogId = currentDialogKey ? extractCustomId(currentDialogKey) : void 0;
|
|
21585
22995
|
const result = await callToolApi(
|
|
21586
22996
|
thunkApi,
|
|
@@ -21603,8 +23013,8 @@ var runOpenAIImageTool = async (args, thunkApi, model) => {
|
|
|
21603
23013
|
{ withAuth: true }
|
|
21604
23014
|
);
|
|
21605
23015
|
const spaceId = getCurrentSpaceId();
|
|
21606
|
-
const userId = selectIdentityUserId(
|
|
21607
|
-
const currentServer = selectCurrentServer(
|
|
23016
|
+
const userId = selectIdentityUserId(state2);
|
|
23017
|
+
const currentServer = selectCurrentServer(state2);
|
|
21608
23018
|
if (spaceId && userId && result?.files?.length) {
|
|
21609
23019
|
for (let i = 0; i < result.files.length; i += 1) {
|
|
21610
23020
|
const file = result.files[i];
|
|
@@ -21706,10 +23116,10 @@ var chatgptWebImageGenerateFunc = async (args, thunkApi) => {
|
|
|
21706
23116
|
if (!trimmedPrompt) {
|
|
21707
23117
|
throw new Error("prompt \u4E0D\u80FD\u4E3A\u7A7A");
|
|
21708
23118
|
}
|
|
21709
|
-
const
|
|
21710
|
-
const currentDialogKey = selectCurrentDialogKey(
|
|
23119
|
+
const state2 = thunkApi.getState();
|
|
23120
|
+
const currentDialogKey = selectCurrentDialogKey(state2);
|
|
21711
23121
|
const dialogId = currentDialogKey ? extractCustomId(currentDialogKey) : void 0;
|
|
21712
|
-
const dialogConfig = selectCurrentDialogConfig(
|
|
23122
|
+
const dialogConfig = selectCurrentDialogConfig(state2);
|
|
21713
23123
|
const agentKey = asNonEmptyStringArray(dialogConfig?.cybots)[0];
|
|
21714
23124
|
const result = await callToolApi(
|
|
21715
23125
|
thunkApi,
|
|
@@ -21722,8 +23132,8 @@ var chatgptWebImageGenerateFunc = async (args, thunkApi) => {
|
|
|
21722
23132
|
{ withAuth: true, agentKey }
|
|
21723
23133
|
);
|
|
21724
23134
|
const spaceId = getCurrentSpaceId();
|
|
21725
|
-
const userId = selectIdentityUserId(
|
|
21726
|
-
const currentServer = selectCurrentServer(
|
|
23135
|
+
const userId = selectIdentityUserId(state2);
|
|
23136
|
+
const currentServer = selectCurrentServer(state2);
|
|
21727
23137
|
if (spaceId && userId && result?.files?.length) {
|
|
21728
23138
|
for (let i = 0; i < result.files.length; i += 1) {
|
|
21729
23139
|
const file = result.files[i];
|
|
@@ -21825,10 +23235,10 @@ var remotionRenderVideoFunc = async (args, thunkApi) => {
|
|
|
21825
23235
|
},
|
|
21826
23236
|
{ withAuth: true }
|
|
21827
23237
|
);
|
|
21828
|
-
const
|
|
21829
|
-
const userId = selectIdentityUserId(
|
|
23238
|
+
const state2 = thunkApi.getState();
|
|
23239
|
+
const userId = selectIdentityUserId(state2);
|
|
21830
23240
|
const spaceId = getCurrentSpaceId();
|
|
21831
|
-
const currentServer = selectCurrentServer(
|
|
23241
|
+
const currentServer = selectCurrentServer(state2);
|
|
21832
23242
|
const fileId = result?.fileId;
|
|
21833
23243
|
const metadata = result?.metadata || {};
|
|
21834
23244
|
const fileDbKey = userId && fileId ? fileKey.single(userId, fileId) : "";
|
|
@@ -21925,7 +23335,7 @@ var rememberMemoryFunctionSchema = {
|
|
|
21925
23335
|
|
|
21926
23336
|
// packages/ai/tools/rememberMemoryTool.ts
|
|
21927
23337
|
async function rememberMemoryFunc(args, thunkApi) {
|
|
21928
|
-
const
|
|
23338
|
+
const state2 = thunkApi.getState();
|
|
21929
23339
|
const spaceId = getCurrentSpaceId() || void 0;
|
|
21930
23340
|
const content = String(args.content ?? "").trim();
|
|
21931
23341
|
const scope = args.scope ?? "auto";
|
|
@@ -22089,9 +23499,9 @@ var queryMemoryFunctionSchema = {
|
|
|
22089
23499
|
async function queryMemoryFunc(args, thunkApi) {
|
|
22090
23500
|
const query = String(args.query ?? "").trim();
|
|
22091
23501
|
if (!query) throw new Error("queryMemory \u9700\u8981\u975E\u7A7A query\u3002");
|
|
22092
|
-
const
|
|
23502
|
+
const state2 = thunkApi.getState();
|
|
22093
23503
|
const dialogKey = getActiveDialogKey();
|
|
22094
|
-
const dialog = dialogKey ? selectById(
|
|
23504
|
+
const dialog = dialogKey ? selectById(state2, dialogKey) : null;
|
|
22095
23505
|
const result = await callToolApi(
|
|
22096
23506
|
thunkApi,
|
|
22097
23507
|
"/api/memory/query",
|
|
@@ -22742,21 +24152,21 @@ var updateSelfToolFunctionSchema = {
|
|
|
22742
24152
|
properties: agentUpdateFieldSchemaProperties
|
|
22743
24153
|
}
|
|
22744
24154
|
};
|
|
22745
|
-
var resolveCurrentAgentKey = (
|
|
22746
|
-
const parentMessage = parentMessageId ? selectMsgById(
|
|
24155
|
+
var resolveCurrentAgentKey = (state2, parentMessageId) => {
|
|
24156
|
+
const parentMessage = parentMessageId ? selectMsgById(state2, parentMessageId) : void 0;
|
|
22747
24157
|
const parentAgentKey = resolveMessageAgentKey(parentMessage);
|
|
22748
24158
|
if (parentAgentKey) {
|
|
22749
24159
|
return parentAgentKey;
|
|
22750
24160
|
}
|
|
22751
|
-
const currentDialog = selectCurrentDialogConfig(
|
|
24161
|
+
const currentDialog = selectCurrentDialogConfig(state2);
|
|
22752
24162
|
return asTrimmedNonEmptyStringArray(currentDialog?.cybots)[0];
|
|
22753
24163
|
};
|
|
22754
24164
|
async function updateSelfToolFunc(args, thunkApi, runtime) {
|
|
22755
|
-
const
|
|
22756
|
-
const userId = selectIdentityUserId(
|
|
24165
|
+
const state2 = thunkApi.getState();
|
|
24166
|
+
const userId = selectIdentityUserId(state2);
|
|
22757
24167
|
const db = thunkApi.extra?.db;
|
|
22758
24168
|
validateUpdateArgs(userId);
|
|
22759
|
-
const currentAgentKey = resolveCurrentAgentKey(
|
|
24169
|
+
const currentAgentKey = resolveCurrentAgentKey(state2, runtime?.parentMessageId);
|
|
22760
24170
|
if (!currentAgentKey) {
|
|
22761
24171
|
throw new Error("updateSelf \u5931\u8D25\uFF1A\u65E0\u6CD5\u8BC6\u522B\u5F53\u524D\u6B63\u5728\u8FD0\u884C\u7684 Agent\u3002");
|
|
22762
24172
|
}
|
|
@@ -22765,7 +24175,7 @@ async function updateSelfToolFunc(args, thunkApi, runtime) {
|
|
|
22765
24175
|
throw new Error(`updateSelf \u5931\u8D25\uFF1A\u672A\u627E\u5230\u5F53\u524D Agent\uFF08${currentAgentKey}\uFF09\u3002`);
|
|
22766
24176
|
}
|
|
22767
24177
|
const requestedFields = listRequestedFields(args);
|
|
22768
|
-
const autoApprovedFields = selectAutoApproveSelfUpdateFields(
|
|
24178
|
+
const autoApprovedFields = selectAutoApproveSelfUpdateFields(state2);
|
|
22769
24179
|
assertAgentUpdateConfirmation({
|
|
22770
24180
|
scope: "self",
|
|
22771
24181
|
requestedFields,
|
|
@@ -23146,9 +24556,9 @@ async function listenToDialogEvents(dialogId, currentServer, authHeader, signal,
|
|
|
23146
24556
|
}
|
|
23147
24557
|
var runAgentBackground = createAsyncThunk("agent/runBackground", async (args, { getState, signal: thunkSignal }) => {
|
|
23148
24558
|
const { agentKey, userInput, serverBase, spaceId, parentDialogId, ephemeral, runKind, onStatusChange, onDone, onFailed } = args;
|
|
23149
|
-
const
|
|
23150
|
-
const currentServer = normalizeServerOrigin(serverBase) || selectCurrentServer(
|
|
23151
|
-
const token = selectIdentityToken(
|
|
24559
|
+
const state2 = getState();
|
|
24560
|
+
const currentServer = normalizeServerOrigin(serverBase) || selectCurrentServer(state2);
|
|
24561
|
+
const token = selectIdentityToken(state2);
|
|
23152
24562
|
if (!currentServer) throw new Error("\u672A\u914D\u7F6E\u670D\u52A1\u5668\u5730\u5740");
|
|
23153
24563
|
const authHeader = token ? `Bearer ${token}` : "";
|
|
23154
24564
|
const effectiveSignal = args.signal ?? thunkSignal;
|
|
@@ -23267,7 +24677,7 @@ var runAgentBackground = createAsyncThunk("agent/runBackground", async (args, {
|
|
|
23267
24677
|
// packages/ai/tools/agent/startAgentRunTool.ts
|
|
23268
24678
|
var startAgentRunFunctionSchema = {
|
|
23269
24679
|
name: "startAgentRun",
|
|
23270
|
-
description: "\u542F\u52A8\u4E00\u4E2A Agent \u6267\u884C\u5B50\u4EFB\u52A1\u3002\u9ED8\u8BA4\u5F02\u6B65\
|
|
24680
|
+
description: "\u542F\u52A8\u4E00\u4E2A Agent \u6267\u884C\u5B50\u4EFB\u52A1\u3002\u9ED8\u8BA4\u5F02\u6B65\uFF08fork+exec\uFF09\uFF1A\u7ACB\u5373\u8FD4\u56DE runId \u4E0D\u963B\u585E\u5BF9\u8BDD\uFF0C\u4E4B\u540E\u7528 controlAgentRun \u89C2\u5BDF/\u505C\u6B62\uFF0C\u7B49\u7EC8\u6001\u901A\u77E5\uFF0C\u7981\u6B62\u8F6E\u8BE2\u3002\u8981\u540C\u6B65\u7ED3\u679C\u4F20 wait:true\uFF08\u4F1A\u51BB\u7ED3\u5BF9\u8BDD\uFF0C\u4EC5\u9650 \u2460 \u9884\u8BA1 <100s \u4E14\u9A6C\u4E0A\u8981\u7528\u7ED3\u679C \u2461 \u7528\u6237\u660E\u786E\u8981\u6C42\u540C\u6B65\u7B49\u5F85\u6216\u6B63\u5728\u4E0E\u8BE5\u5B50\u4EFB\u52A1\u5BF9\u8BDD \u2462 \u73AF\u5883\u4E0D\u652F\u6301\u7EC8\u6001\u5524\u9192\u4E14\u65E0\u5E76\u884C\u5DE5\u4F5C\uFF1B\u8BE6\u89C1 wait \u53C2\u6570\uFF09\u3002wait:true \u65F6\u53EF\u7528 resultMode \u63A7\u5236\u8FD4\u56DE\u5185\u5BB9\uFF1Afull=\u5B8C\u6574\u8F93\u51FA\uFF1Bsummary=\u53EA\u56DE\u5934\u5C3E\u603B\u7ED3\uFF08\u9632\u957F\u8F93\u51FA\u6491\u7206\u4E0A\u4E0B\u6587\uFF09\u3002",
|
|
23271
24681
|
parameters: {
|
|
23272
24682
|
type: "object",
|
|
23273
24683
|
properties: {
|
|
@@ -23300,7 +24710,7 @@ var startAgentRunFunctionSchema = {
|
|
|
23300
24710
|
},
|
|
23301
24711
|
wait: {
|
|
23302
24712
|
type: "boolean",
|
|
23303
|
-
description: "\u53EF\u9009\u3002\u4E3A true \u65F6\u540C\u6B65\u7B49\u5F85\u5B50\u4EFB\u52A1\u5B8C\u6210\u5E76\u76F4\u63A5\u8FD4\u56DE\u7ED3\u679C\uFF08\u8BA2\u9605 SSE \u7B49 done/failed\uFF09\uFF0C\u4E0D\u8FD4\u56DE runId
|
|
24713
|
+
description: "\u53EF\u9009\u3002\u4E3A true \u65F6\u540C\u6B65\u7B49\u5F85\u5B50\u4EFB\u52A1\u5B8C\u6210\u5E76\u76F4\u63A5\u8FD4\u56DE\u7ED3\u679C\uFF08\u8BA2\u9605 SSE \u7B49 done/failed\uFF09\uFF0C\u4E0D\u8FD4\u56DE runId\u3002\u963B\u585E\u7B49\u5F85\u4F1A\u51BB\u7ED3\u5F53\u524D\u5BF9\u8BDD\uFF0C\u4EC5\u9650\u4E09\u79CD\u60C5\u51B5\uFF08\u89C1\u9876\u5C42\u63CF\u8FF0\uFF09\uFF1B\u9ED8\u8BA4 false\uFF08\u5F02\u6B65\uFF0C\u8FD4\u56DE runId \u540E\u7528 controlAgentRun \u89C2\u5BDF\uFF09\u3002",
|
|
23304
24714
|
default: false
|
|
23305
24715
|
},
|
|
23306
24716
|
resultMode: {
|
|
@@ -23395,14 +24805,14 @@ ${text.slice(-SUMMARY_TAIL_CHARS)}`;
|
|
|
23395
24805
|
// packages/ai/tools/agent/controlAgentRunTool.ts
|
|
23396
24806
|
var controlAgentRunFunctionSchema = {
|
|
23397
24807
|
name: "controlAgentRun",
|
|
23398
|
-
description: "\u89C2\u5BDF\u548C\u63A7\u5236\u540E\u53F0 agent run\
|
|
24808
|
+
description: "\u89C2\u5BDF\u548C\u63A7\u5236\u540E\u53F0 agent run\uFF08\u4E94 action\uFF1Alist/status/stop/append/wait\uFF0C\u53E6\u6709 todo \u67E5\u8BE2\uFF09\u3002\u7528 startAgentRun \u62FF\u5230 runId \u540E\u8DDF\u8FDB\u5EA6\u3001\u7B49\u7ED3\u679C\u3001\u8FFD\u52A0\u6307\u4EE4\u6216\u53EB\u505C\u3002\u76EF\u68A2/\u8F6E\u8BE2/\u963B\u585E\u7EAA\u5F8B\u89C1 system prompt\u300C\u591A Agent \u7F16\u6392\u300D\u6BB5\uFF1A\u5F02\u6B65\u6D3E\u53D1\u540E\u7B49\u7EC8\u6001\u901A\u77E5\u3001\u4E0D\u8981\u8F6E\u8BE2\uFF1B\u963B\u585E\u7B49\u5F85\uFF08wait action \u6216 startAgentRun wait:true\uFF09\u4F1A\u51BB\u7ED3\u5BF9\u8BDD\uFF0C\u4EC5\u9650 \u2460 \u9884\u8BA1 <100s \u4E14\u9A6C\u4E0A\u8981\u7528\u7ED3\u679C \u2461 \u7528\u6237\u660E\u786E\u8981\u6C42\u540C\u6B65\u7B49\u5F85\u6216\u6B63\u5728\u4E0E\u8BE5\u5B50\u4EFB\u52A1\u5BF9\u8BDD \u2462 \u73AF\u5883\u4E0D\u652F\u6301\u7EC8\u6001\u5524\u9192\u4E14\u65E0\u5E76\u884C\u5DE5\u4F5C\u3002\u672C\u5DE5\u5177\u4F9B\u4F60\u81EA\u5DF1\u505A\u51B3\u7B56\u7528\uFF1A\u7528\u6237\u754C\u9762\u5DF2\u5B9E\u65F6\u663E\u793A\u6BCF\u6761 run \u7684\u72B6\u6001\uFF0C\u4E0D\u5FC5\u4E3A\u300C\u8BA9\u7528\u6237\u770B\u5230\u72B6\u6001\u300D\u800C\u8C03\u7528\uFF0C\u8FD4\u56DE\u503C\u4E5F\u4E0D\u8981\u590D\u8FF0\u7ED9\u7528\u6237\u3002",
|
|
23399
24809
|
parameters: {
|
|
23400
24810
|
type: "object",
|
|
23401
24811
|
properties: {
|
|
23402
24812
|
action: {
|
|
23403
24813
|
type: "string",
|
|
23404
24814
|
enum: ["list", "status", "stop", "todo", "wait", "append"],
|
|
23405
|
-
description: "
|
|
24815
|
+
description: "list=\u5217\u51FA run\uFF08\u7701\u7565 runId\uFF09\uFF1Bstatus=\u67E5\u5355\u6761 run \u72B6\u6001 + \u53EF\u9009\u65E5\u5FD7\uFF1Bstop=\u53D6\u6D88 run\uFF1Bappend=\u5411\u4EFB\u52A1\u8FFD\u52A0\u6307\u4EE4\uFF08\u8FD0\u884C\u4E2D\u5165\u961F\uFF0C\u7EC8\u6001 continuation\uFF09\uFF1Bwait=\u7EC8\u6001\u963B\u585E\u7B49\u5F85\uFF1A\u8BA2\u9605\u8BE5 dialog \u7684 SSE \u4E8B\u4EF6\u6D41\u7B49 done/failed\uFF0C\u5DF2\u7EC8\u6001\u7ACB\u5373\u8FD4\u56DE\uFF0C\u4E0D\u662F\u8F6E\u8BE2\uFF1Btodo=\u5217\u51FA runtime todo\uFF08\u7531 startAgentRun \u7684 batchId/trackTodo \u4EA7\u751F\uFF09\u3002"
|
|
23406
24816
|
},
|
|
23407
24817
|
runId: {
|
|
23408
24818
|
type: "string",
|
|
@@ -23423,12 +24833,12 @@ var controlAgentRunFunctionSchema = {
|
|
|
23423
24833
|
},
|
|
23424
24834
|
timeoutMs: {
|
|
23425
24835
|
type: "number",
|
|
23426
|
-
description: '\u53EF\u9009\u3002action=wait \u7684\u7B49\u5F85\u4E0A\u9650\uFF08\u6BEB\u79D2\uFF09\uFF0C\u9ED8\u8BA4 100000\
|
|
24836
|
+
description: '\u53EF\u9009\u3002action=wait \u7684\u7B49\u5F85\u4E0A\u9650\uFF08\u6BEB\u79D2\uFF09\uFF0C\u9ED8\u8BA4 100000\u3002\u8D85\u65F6\u8FD4\u56DE status="timeout"\uFF08\u4E0D\u662F\u5931\u8D25\uFF09\uFF0C\u53EF\u7A0D\u540E\u518D wait \u6216\u6539\u7528 status/stop\u3002',
|
|
23427
24837
|
default: 1e5
|
|
23428
24838
|
},
|
|
23429
24839
|
tailLines: {
|
|
23430
24840
|
type: "number",
|
|
23431
|
-
description: "\u53EF\u9009\u3002action=status \u65F6\uFF1A0=\u53EA\u8FD4\u56DE\u72B6\u6001\u6458\u8981\uFF0C>0=\u540C\u65F6\u8FD4\u56DE\u6700\u8FD1 N \u884C\u65E5\u5FD7\uFF08\u9ED8\u8BA4 0\uFF09\u3002\
|
|
24841
|
+
description: "\u53EF\u9009\u3002action=status \u65F6\uFF1A0=\u53EA\u8FD4\u56DE\u72B6\u6001\u6458\u8981\uFF0C>0=\u540C\u65F6\u8FD4\u56DE\u6700\u8FD1 N \u884C\u65E5\u5FD7\uFF08\u9ED8\u8BA4 0\uFF09\u3002\u72B6\u6001\u6458\u8981\u5DF2\u542B progress\uFF08\u5DE5\u5177\u8C03\u7528/LLM \u8C03\u7528/inFlight=\u6B64\u523B\u5728\u6267\u884C\u4EC0\u4E48\u3001idleMs\uFF09\uFF0C\u5148\u770B\u5B83\u5224\u65AD\u300C\u5728\u5E72\u6D3B\u300D\u8FD8\u662F\u300C\u5361\u4F4F\u300D\uFF0C\u786E\u5B9E\u53EF\u7591\u6216\u5DF2\u5931\u8D25\u624D\u62C9\u65E5\u5FD7\u3002",
|
|
23432
24842
|
default: 0
|
|
23433
24843
|
},
|
|
23434
24844
|
batchId: {
|
|
@@ -23437,7 +24847,7 @@ var controlAgentRunFunctionSchema = {
|
|
|
23437
24847
|
},
|
|
23438
24848
|
status: {
|
|
23439
24849
|
type: "string",
|
|
23440
|
-
description: "\u53EF\u9009\u3002action=list \u65F6\u6309\u72B6\u6001\u8FC7\u6EE4\uFF0C\
|
|
24850
|
+
description: "\u53EF\u9009\u3002action=list \u65F6\u6309\u72B6\u6001\u8FC7\u6EE4\uFF0C\u5355\u503C\u6216\u9017\u53F7\u5206\u9694\u591A\u503C\uFF08\u5982 'running,orphaned'\uFF09\u3002\u4E0E statusFilter \u540C\u4E49\uFF0Cstatus \u4F18\u5148\uFF1Borphaned=pid \u5DF2\u6B7B\u4F46\u8BB0\u5F55\u4ECD running \u7684\u5B64\u513F run\u3002\u9ED8\u8BA4 all\u3002"
|
|
23441
24851
|
},
|
|
23442
24852
|
statusFilter: {
|
|
23443
24853
|
type: "string",
|
|
@@ -24848,14 +26258,14 @@ ${resultStr}
|
|
|
24848
26258
|
}
|
|
24849
26259
|
|
|
24850
26260
|
// packages/ai/tools/toolRunStore.ts
|
|
24851
|
-
var
|
|
26261
|
+
var import_react4 = __toESM(require_react());
|
|
24852
26262
|
var createToolRunId = () => `toolrun_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 8)}`;
|
|
24853
26263
|
var runsById = /* @__PURE__ */ new Map();
|
|
24854
|
-
var
|
|
24855
|
-
var
|
|
24856
|
-
var
|
|
24857
|
-
|
|
24858
|
-
for (const listener of
|
|
26264
|
+
var listeners2 = /* @__PURE__ */ new Set();
|
|
26265
|
+
var version2 = 0;
|
|
26266
|
+
var notify2 = () => {
|
|
26267
|
+
version2 += 1;
|
|
26268
|
+
for (const listener of listeners2) {
|
|
24859
26269
|
try {
|
|
24860
26270
|
listener();
|
|
24861
26271
|
} catch {
|
|
@@ -24888,14 +26298,14 @@ function toolRunStarted(payload) {
|
|
|
24888
26298
|
outputSummary: void 0,
|
|
24889
26299
|
steps: void 0
|
|
24890
26300
|
});
|
|
24891
|
-
|
|
26301
|
+
notify2();
|
|
24892
26302
|
}
|
|
24893
26303
|
function toolRunSetPending(payload) {
|
|
24894
26304
|
const { id } = payload;
|
|
24895
26305
|
const run = runsById.get(id);
|
|
24896
26306
|
if (run) {
|
|
24897
26307
|
run.status = "pending";
|
|
24898
|
-
|
|
26308
|
+
notify2();
|
|
24899
26309
|
}
|
|
24900
26310
|
}
|
|
24901
26311
|
function toolRunSucceeded(payload) {
|
|
@@ -24908,7 +26318,7 @@ function toolRunSucceeded(payload) {
|
|
|
24908
26318
|
run.steps = steps;
|
|
24909
26319
|
}
|
|
24910
26320
|
run.finishedAt = finishedAt ?? Date.now();
|
|
24911
|
-
|
|
26321
|
+
notify2();
|
|
24912
26322
|
}
|
|
24913
26323
|
}
|
|
24914
26324
|
function toolRunUpdated(payload) {
|
|
@@ -24921,7 +26331,7 @@ function toolRunUpdated(payload) {
|
|
|
24921
26331
|
if (steps !== void 0) {
|
|
24922
26332
|
run.steps = steps;
|
|
24923
26333
|
}
|
|
24924
|
-
|
|
26334
|
+
notify2();
|
|
24925
26335
|
}
|
|
24926
26336
|
}
|
|
24927
26337
|
function toolRunFailed(payload) {
|
|
@@ -24937,7 +26347,7 @@ function toolRunFailed(payload) {
|
|
|
24937
26347
|
run.steps = steps;
|
|
24938
26348
|
}
|
|
24939
26349
|
run.finishedAt = finishedAt ?? Date.now();
|
|
24940
|
-
|
|
26350
|
+
notify2();
|
|
24941
26351
|
}
|
|
24942
26352
|
}
|
|
24943
26353
|
function getAllToolRuns() {
|
|
@@ -24957,7 +26367,7 @@ var executeToolRun = createAsyncThunk(
|
|
|
24957
26367
|
if (!executionInput) {
|
|
24958
26368
|
throw new Error(`ToolRun ${id} has no input to execute with.`);
|
|
24959
26369
|
}
|
|
24960
|
-
const { findToolExecutor: findToolExecutor2 } = await import("./tools-
|
|
26370
|
+
const { findToolExecutor: findToolExecutor2 } = await import("./tools-6ZPQ75XA.js");
|
|
24961
26371
|
const { executor } = findToolExecutor2(run.toolName);
|
|
24962
26372
|
toolRunStarted({
|
|
24963
26373
|
id: run.id,
|
|
@@ -24981,7 +26391,7 @@ var executeToolRun = createAsyncThunk(
|
|
|
24981
26391
|
const latestState = thunkApi.getState();
|
|
24982
26392
|
const userId = latestState.auth?.currentUser?.userId;
|
|
24983
26393
|
if (userId) {
|
|
24984
|
-
const { fetchUserSpaceMemberships } = await import("./
|
|
26394
|
+
const { fetchUserSpaceMemberships } = await import("./memberThunks-KVPBG4V7.js");
|
|
24985
26395
|
await thunkApi.dispatch(fetchUserSpaceMemberships(userId));
|
|
24986
26396
|
}
|
|
24987
26397
|
}
|
|
@@ -25006,9 +26416,9 @@ var executeToolRun = createAsyncThunk(
|
|
|
25006
26416
|
// packages/app/actions/syncAppRecord.ts
|
|
25007
26417
|
var syncAppRecord = (appKey, appRecord, options = {}) => async (_dispatch, getState, extra) => {
|
|
25008
26418
|
if (!appKey || !appRecord) return;
|
|
25009
|
-
const
|
|
25010
|
-
const currentServer = selectCurrentServer(
|
|
25011
|
-
const syncServers = selectSyncServers(
|
|
26419
|
+
const state2 = getState();
|
|
26420
|
+
const currentServer = selectCurrentServer(state2);
|
|
26421
|
+
const syncServers = selectSyncServers(state2) ?? [];
|
|
25012
26422
|
const { db: clientDb } = extra ?? {};
|
|
25013
26423
|
const normalizedRecord = {
|
|
25014
26424
|
...appRecord,
|
|
@@ -25028,7 +26438,7 @@ var syncAppRecord = (appKey, appRecord, options = {}) => async (_dispatch, getSt
|
|
|
25028
26438
|
(server) => noloWriteRequest(
|
|
25029
26439
|
server,
|
|
25030
26440
|
{ data: normalizedRecord, customKey: appKey, userId: normalizedRecord.userId },
|
|
25031
|
-
|
|
26441
|
+
state2
|
|
25032
26442
|
)
|
|
25033
26443
|
)
|
|
25034
26444
|
);
|
|
@@ -25411,7 +26821,7 @@ function decideAppDeploySpaceId(params) {
|
|
|
25411
26821
|
return asOptionalTrimmedString(params.explicitSpaceId) ?? asOptionalTrimmedString(params.currentSpaceId);
|
|
25412
26822
|
}
|
|
25413
26823
|
async function resolveAppDeploySpaceId(args, thunkApi) {
|
|
25414
|
-
const
|
|
26824
|
+
const state2 = thunkApi?.getState?.();
|
|
25415
26825
|
const rawSpaceId = getViewMode() === "all" ? null : getCurrentSpaceIdRaw();
|
|
25416
26826
|
const currentSpaceId = asOptionalTrimmedString(rawSpaceId);
|
|
25417
26827
|
if (!args.appId) {
|
|
@@ -25492,17 +26902,17 @@ function isLikelyReactWorkerMisuse(code) {
|
|
|
25492
26902
|
code
|
|
25493
26903
|
);
|
|
25494
26904
|
}
|
|
25495
|
-
function rewriteAppDeployError(
|
|
25496
|
-
if (
|
|
26905
|
+
function rewriteAppDeployError(errorMessage2, args) {
|
|
26906
|
+
if (errorMessage2.includes("React SPA \u6A21\u5F0F\u5FC5\u987B\u63D0\u4F9B files \u53C2\u6570")) {
|
|
25497
26907
|
return "React SPA \u9700\u8981\u4F20 `files`\uFF08\u81F3\u5C11 `main.tsx` + `App.tsx`\uFF09\uFF0C\u4E0D\u80FD\u53EA\u4F20 `code`\u3002\u5982\u679C\u4F60\u73B0\u5728\u62FF\u5230\u7684\u662F\u591A\u6587\u4EF6\u6E90\u7801\uFF0C\u4E5F\u53EF\u4EE5\u76F4\u63A5\u4F20 `pages`\uFF0C\u7CFB\u7EDF\u4F1A\u81EA\u52A8\u517C\u5BB9\u4E3A `files`\u3002";
|
|
25498
26908
|
}
|
|
25499
|
-
if (
|
|
26909
|
+
if (errorMessage2.includes("\u9700\u8981\u63D0\u4F9B code \u6216 files \u53C2\u6570")) {
|
|
25500
26910
|
return "\u7F3A\u5C11\u53EF\u90E8\u7F72\u6E90\u7801\u3002\u8BF7\u4F20 `code`\uFF08\u5355\u6587\u4EF6 Worker\uFF09\u6216 `files`\uFF08\u591A\u6587\u4EF6\u9879\u76EE\uFF09\uFF1B\u5982\u679C\u4F60\u624B\u4E0A\u5B57\u6BB5\u540D\u662F `pages`\uFF0C\u73B0\u5728\u4E5F\u53EF\u4EE5\u76F4\u63A5\u4F20\u3002";
|
|
25501
26911
|
}
|
|
25502
|
-
if (
|
|
26912
|
+
if (errorMessage2.includes("Bundle failed") && args.framework !== "react-spa" && isLikelyReactWorkerMisuse(args.code)) {
|
|
25503
26913
|
return '\u68C0\u6D4B\u5230\u4F60\u628A React \u7EC4\u4EF6\u4EE3\u7801\u5F53\u6210\u5355\u6587\u4EF6 Worker \u53BB\u90E8\u7F72\u4E86\u3002\u8981\u505A\u4EA4\u4E92\u7F51\u9875\uFF0C\u8BF7\u6539\u7528 `framework: "react-spa"` \u5E76\u4F20 `files`\uFF08\u901A\u5E38\u662F `main.tsx` + `App.tsx`\uFF09\uFF1B\u5982\u679C\u4F60\u53EA\u60F3\u8FD4\u56DE\u9759\u6001 HTML\uFF0C\u8BF7\u53BB\u6389 `react` / `react-dom` / `react-icons` import\u3002';
|
|
25504
26914
|
}
|
|
25505
|
-
return
|
|
26915
|
+
return errorMessage2;
|
|
25506
26916
|
}
|
|
25507
26917
|
function messageContentToText(content) {
|
|
25508
26918
|
if (typeof content === "string") return content;
|
|
@@ -25515,10 +26925,10 @@ function messageContentToText(content) {
|
|
|
25515
26925
|
}
|
|
25516
26926
|
function getLatestUserInputFromThunk(thunkApi) {
|
|
25517
26927
|
try {
|
|
25518
|
-
const
|
|
25519
|
-
if (!
|
|
25520
|
-
const dialogId = selectCurrentDialogId(
|
|
25521
|
-
const messages = selectAllMsgs(
|
|
26928
|
+
const state2 = thunkApi?.getState?.();
|
|
26929
|
+
if (!state2) return void 0;
|
|
26930
|
+
const dialogId = selectCurrentDialogId(state2);
|
|
26931
|
+
const messages = selectAllMsgs(state2, dialogId);
|
|
25522
26932
|
for (let i = messages.length - 1; i >= 0; i -= 1) {
|
|
25523
26933
|
const message = messages[i];
|
|
25524
26934
|
if (message?.role !== "user") continue;
|
|
@@ -26812,7 +28222,7 @@ var updateContentTitleTool = {
|
|
|
26812
28222
|
};
|
|
26813
28223
|
var updateContentTitleFunc = async (args, thunkApi) => {
|
|
26814
28224
|
const { dispatch, getState } = thunkApi;
|
|
26815
|
-
const
|
|
28225
|
+
const state2 = getState();
|
|
26816
28226
|
const spaceId = getCurrentSpaceId();
|
|
26817
28227
|
const { contentId, title } = args;
|
|
26818
28228
|
console.log(
|
|
@@ -26850,8 +28260,8 @@ var updateContentTitleFunc = async (args, thunkApi) => {
|
|
|
26850
28260
|
};
|
|
26851
28261
|
} catch (error) {
|
|
26852
28262
|
console.error("[updateContentTitleFunc] \u66F4\u65B0\u6807\u9898\u5931\u8D25:", error);
|
|
26853
|
-
const
|
|
26854
|
-
throw new Error(`\u66F4\u65B0\u6807\u9898\u65F6\u51FA\u9519: ${
|
|
28263
|
+
const errorMessage2 = error?.message || JSON.stringify(error) || "\u672A\u77E5\u9519\u8BEF";
|
|
28264
|
+
throw new Error(`\u66F4\u65B0\u6807\u9898\u65F6\u51FA\u9519: ${errorMessage2}`);
|
|
26855
28265
|
}
|
|
26856
28266
|
};
|
|
26857
28267
|
|
|
@@ -27015,9 +28425,9 @@ function buildMyContentItemsFromUserData(records, currentServer, spaceNameById,
|
|
|
27015
28425
|
}
|
|
27016
28426
|
|
|
27017
28427
|
// packages/ai/tools/searchWorkspaceTool.ts
|
|
27018
|
-
var selectCurrentSpaceIdFromState2 = (
|
|
27019
|
-
var selectCurrentSpaceFromState = (
|
|
27020
|
-
var selectAllMemberSpacesFromState = (
|
|
28428
|
+
var selectCurrentSpaceIdFromState2 = (_state) => getCurrentSpaceId();
|
|
28429
|
+
var selectCurrentSpaceFromState = (state2) => selectCurrentSpace(state2);
|
|
28430
|
+
var selectAllMemberSpacesFromState = (state2) => {
|
|
27021
28431
|
const memberSpaces = getAllMemberSpaces();
|
|
27022
28432
|
return [...memberSpaces].sort((a, b) => {
|
|
27023
28433
|
const aUpdatedAt = a.spaceUpdatedAt ?? a.memberUpdatedAt ?? a.updatedAt ?? a.createdAt ?? a.joinedAt ?? 0;
|
|
@@ -27089,8 +28499,8 @@ var buildScopedDisplayData = (query, results, scopeLabel) => {
|
|
|
27089
28499
|
return `\u5728${scopeLabel}\u4E2D\u627E\u5230 ${results.length} \u4E2A\u5339\u914D\u9879\uFF1A
|
|
27090
28500
|
${summary}`;
|
|
27091
28501
|
};
|
|
27092
|
-
var loadLocalMyContentResults = async (thunkApi,
|
|
27093
|
-
const userId =
|
|
28502
|
+
var loadLocalMyContentResults = async (thunkApi, state2) => {
|
|
28503
|
+
const userId = state2.auth?.currentUser?.userId?.trim();
|
|
27094
28504
|
if (!userId) {
|
|
27095
28505
|
throw new Error("\u65E0\u6CD5\u641C\u7D22\u5168\u90E8\u5185\u5BB9\uFF0C\u56E0\u4E3A\u5F53\u524D\u7528\u6237\u672A\u767B\u5F55\u3002");
|
|
27096
28506
|
}
|
|
@@ -27105,13 +28515,13 @@ var loadLocalMyContentResults = async (thunkApi, state) => {
|
|
|
27105
28515
|
const sortedRecords = [...dedupedRecords].sort(
|
|
27106
28516
|
(a, b) => getUserDataItemTimestamp(b) - getUserDataItemTimestamp(a)
|
|
27107
28517
|
);
|
|
27108
|
-
const memberSpaces = selectAllMemberSpacesFromState(
|
|
28518
|
+
const memberSpaces = selectAllMemberSpacesFromState(state2);
|
|
27109
28519
|
const spaceNameById = new Map(
|
|
27110
28520
|
memberSpaces.map((space) => [space.spaceId, space.spaceName || space.spaceId])
|
|
27111
28521
|
);
|
|
27112
28522
|
return buildMyContentItemsFromUserData(
|
|
27113
28523
|
sortedRecords,
|
|
27114
|
-
|
|
28524
|
+
state2.settings?.currentServer || "",
|
|
27115
28525
|
spaceNameById,
|
|
27116
28526
|
"\u6211\u7684\u5E94\u7528",
|
|
27117
28527
|
"\u6211\u7684\u5185\u5BB9"
|
|
@@ -27119,12 +28529,12 @@ var loadLocalMyContentResults = async (thunkApi, state) => {
|
|
|
27119
28529
|
};
|
|
27120
28530
|
async function searchWorkspaceFunc(args, thunkApi) {
|
|
27121
28531
|
const { getState } = thunkApi;
|
|
27122
|
-
const
|
|
27123
|
-
const spaceId = selectCurrentSpaceIdFromState2(
|
|
28532
|
+
const state2 = getState();
|
|
28533
|
+
const spaceId = selectCurrentSpaceIdFromState2(state2);
|
|
27124
28534
|
if (!spaceId) {
|
|
27125
28535
|
throw new Error("\u65E0\u6CD5\u67E5\u8BE2\u5185\u5BB9\uFF0C\u56E0\u4E3A\u5F53\u524D\u7A7A\u95F4\u672A\u8BBE\u5B9A\u3002");
|
|
27126
28536
|
}
|
|
27127
|
-
const currentSpace = selectCurrentSpaceFromState(
|
|
28537
|
+
const currentSpace = selectCurrentSpaceFromState(state2);
|
|
27128
28538
|
if (!currentSpace) {
|
|
27129
28539
|
throw new Error("\u5F53\u524D\u7A7A\u95F4\u6570\u636E\u672A\u627E\u5230\u3002");
|
|
27130
28540
|
}
|
|
@@ -27136,8 +28546,8 @@ async function searchWorkspaceFunc(args, thunkApi) {
|
|
|
27136
28546
|
return { rawData, displayData };
|
|
27137
28547
|
}
|
|
27138
28548
|
async function searchAllSpacesFunc(args, thunkApi) {
|
|
27139
|
-
const
|
|
27140
|
-
const items = await loadLocalMyContentResults(thunkApi,
|
|
28549
|
+
const state2 = thunkApi.getState();
|
|
28550
|
+
const items = await loadLocalMyContentResults(thunkApi, state2);
|
|
27141
28551
|
const results = items.filter((item) => matchesMyContentSearch(args.query, item)).map((item) => toSearchResultItem(item));
|
|
27142
28552
|
return {
|
|
27143
28553
|
rawData: { success: true, contents: results },
|
|
@@ -27293,8 +28703,8 @@ async function fetchDialogMessagesFromServer(args) {
|
|
|
27293
28703
|
}
|
|
27294
28704
|
async function collectBestAvailableDialogMessages(db, dialogId, thunkApi, scanLimit) {
|
|
27295
28705
|
const localMessages = await collectDialogMessages(db, dialogId);
|
|
27296
|
-
const
|
|
27297
|
-
const runtime =
|
|
28706
|
+
const state2 = thunkApi?.getState?.();
|
|
28707
|
+
const runtime = state2 ? selectRuntimeSnapshot(state2) : null;
|
|
27298
28708
|
const serverBases = Array.from(new Set([
|
|
27299
28709
|
runtime?.localRuntimeOrigin,
|
|
27300
28710
|
runtime?.currentServer,
|
|
@@ -27464,7 +28874,7 @@ async function updateDocFunc(args, thunkApi) {
|
|
|
27464
28874
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
27465
28875
|
};
|
|
27466
28876
|
await dispatch(write({ data: updatedPageData, customKey: id })).unwrap();
|
|
27467
|
-
const { getDocState, applyExternalDocUpdate } = await import("./docStore-
|
|
28877
|
+
const { getDocState, applyExternalDocUpdate } = await import("./docStore-34NXLCEO.js");
|
|
27468
28878
|
if (getDocState().pageKey === id) {
|
|
27469
28879
|
applyExternalDocUpdate({
|
|
27470
28880
|
slateData: finalSlateData,
|
|
@@ -27489,7 +28899,7 @@ async function updateDocFunc(args, thunkApi) {
|
|
|
27489
28899
|
// packages/ai/tools/updateUserPreferenceProfileTool.ts
|
|
27490
28900
|
async function dispatchSetSettings(thunkApi, changes) {
|
|
27491
28901
|
const injectedSetSettings = thunkApi?.extra?.setSettings;
|
|
27492
|
-
const setSettings = typeof injectedSetSettings === "function" ? injectedSetSettings : (await import("./settingSlice-
|
|
28902
|
+
const setSettings = typeof injectedSetSettings === "function" ? injectedSetSettings : (await import("./settingSlice-3GNGTC2T.js")).setSettings;
|
|
27493
28903
|
await thunkApi.dispatch(setSettings(changes)).unwrap();
|
|
27494
28904
|
}
|
|
27495
28905
|
var updateUserPreferenceProfileFunctionSchema = {
|
|
@@ -28087,7 +29497,7 @@ var baseToolDefinitions = [
|
|
|
28087
29497
|
executor: uiAskChoiceFunc,
|
|
28088
29498
|
description: {
|
|
28089
29499
|
name: "ask_user",
|
|
28090
|
-
description: "\u5411\u7528\u6237\u63D0\u51FA\
|
|
29500
|
+
description: "\u5411\u7528\u6237\u63D0\u51FA\u5E26\u9009\u9879\u7684\u95EE\u9898\uFF0C\u8BA9\u754C\u9762\u5C55\u793A\u6309\u94AE\u4F9B\u9009\u62E9\u3002\u4EC5\u5728\u9009\u9879\u771F\u6B63\u4E92\u65A5\u4E14\u65E0\u6CD5\u4ECE\u4E0A\u4E0B\u6587\u63A8\u65AD\u7528\u6237\u504F\u597D\u65F6\u4F7F\u7528\uFF1B\u5DF2\u6709\u660E\u786E\u65B9\u5411\u6216\u7528\u6237\u5DF2\u6388\u6743\u4F60\u51B3\u5B9A\u65F6\uFF0C\u76F4\u63A5\u6267\u884C\u5E76\u5728\u6587\u672C\u4E2D\u8BF4\u660E\uFF0C\u4E0D\u8981\u4E3A\u6B64\u8C03\u7528\u672C\u5DE5\u5177\u3002",
|
|
28091
29501
|
category: "\u4EA4\u4E92 / UI"
|
|
28092
29502
|
},
|
|
28093
29503
|
behavior: "answer"
|