nolo-cli 0.54.0-alpha.2 → 0.54.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-ANY4SIAS.js → _executeModel-OPTKYHJA.js} +48 -42
- package/{action-Q4W5JPI5.js → action-ORXWW2ZG.js} +8 -8
- package/{addContentAction-O25HFR37.js → addContentAction-53BZ34AE.js} +8 -7
- package/{addDialogAgentAction-GH7AUPPB.js → addDialogAgentAction-JRYUS54Y.js} +10 -9
- package/{agentDeleteCommand-JWIKNWWI.js → agentDeleteCommand-FJIWU2BS.js} +30 -28
- package/{agentEmailCommands-PL22BEU5.js → agentEmailCommands-CE32L43B.js} +57 -52
- package/{agentListCommands-6NR7AQEK.js → agentListCommands-VJNKULIK.js} +42 -33
- package/{agentMachineCommands-TASPU6OA.js → agentMachineCommands-HCJ3WQXL.js} +30 -28
- package/{agentRecordCommands-Z64TA63M.js → agentRecordCommands-QFWERED4.js} +55 -50
- package/{agentRunCommand-4QJQLPRW.js → agentRunCommand-G3GQMUNN.js} +65 -53
- package/{agentRunControl-4GHHSXFZ.js → agentRunControl-INKFDXDA.js} +3 -1
- package/{agentRuntimeLocal-PCJJ56J2.js → agentRuntimeLocal-K327ELSL.js} +30 -26
- package/{agentSlice-KYLDUSNN.js → agentSlice-ODKF4J6M.js} +8 -8
- package/{agentSuperviseCommands-VB6BUS5H.js → agentSuperviseCommands-5AR3DKNN.js} +2 -2
- package/{appDeleteCommands-WLHMJAVT.js → appDeleteCommands-XUXMFDI4.js} +31 -29
- package/{appDeployCommands-CKON7N2E.js → appDeployCommands-37F4GPCU.js} +31 -29
- package/{appDeployStatusCommands-PXRLDASH.js → appDeployStatusCommands-WSPU7TUK.js} +31 -29
- package/{appGetCommands-RAB5RM4M.js → appGetCommands-YLOBA3EM.js} +31 -29
- package/{appListCommands-GU57FB62.js → appListCommands-UD62R5ME.js} +31 -29
- package/{authCommand-QOPOEYEK.js → authCommand-OK6HLHGS.js} +13 -13
- package/{authCommands-SBQVTD6V.js → authCommands-2DUIUEMT.js} +2 -2
- package/{chatQueueReduxAdapter-5O2WLITN.js → chatQueueReduxAdapter-TV2TUOQS.js} +26 -23
- package/{chunk-7CH6U3FL.js → chunk-2GRGFCF6.js} +2 -4
- package/{chunk-T27IEBNQ.js → chunk-2QDDKFG5.js} +74 -1
- package/{chunk-VULELK4T.js → chunk-2WBFJHQA.js} +4 -26
- package/{chunk-IKTHA3JH.js → chunk-3LKZRP7E.js} +2 -2
- package/{chunk-INXBNYCG.js → chunk-3Y2K5O2R.js} +64 -6
- package/{chunk-VRZIH5JO.js → chunk-3ZTR7ZO4.js} +1 -1
- package/{chunk-GV35EHNA.js → chunk-5FCIPEKT.js} +262 -96
- package/{chunk-RTLJUGQH.js → chunk-5UAYZEXO.js} +2 -2
- package/{chunk-TI5BCZCH.js → chunk-6COJEAYH.js} +32 -101
- package/{chunk-Y7LNKP32.js → chunk-6HDYSFLO.js} +4 -6
- package/chunk-6IGD47IC.js +19 -0
- package/chunk-6YTOJY35.js +352 -0
- package/{chunk-6FGXGFAH.js → chunk-75MSWWUE.js} +1 -1
- package/{chunk-3Z3DXZBD.js → chunk-7FAS3NEF.js} +16 -16
- package/{chunk-AV6KQCM5.js → chunk-7NYDJAQ7.js} +19 -14
- package/{chunk-CVT7L2WZ.js → chunk-A65UV3M5.js} +4 -4
- package/{chunk-7APQB6R6.js → chunk-AUVFJGPC.js} +3 -3
- package/{chunk-H4RYESI6.js → chunk-BBTN4NQD.js} +4 -4
- package/{chunk-757BGY6Y.js → chunk-BG7J6Y5X.js} +1 -1
- package/chunk-BY2FF2C4.js +526 -0
- package/{chunk-FA4SY4F5.js → chunk-BYEJ7K2Z.js} +1 -1
- package/chunk-BYXBJQAS.js +0 -0
- package/{chunk-3AOLVADY.js → chunk-DVINR3PL.js} +1 -1
- package/{chunk-UITMHBVK.js → chunk-EA5OYZVD.js} +1 -1
- package/{chunk-4NN3EK7H.js → chunk-EICIFHVS.js} +1 -1
- package/chunk-EJE33XNR.js +19059 -0
- package/{chunk-6SZ52ORL.js → chunk-FJHMLRDQ.js} +9 -9
- package/{chunk-RU5D3B22.js → chunk-GRFK2XP4.js} +2 -2
- package/{chunk-J3UALFHL.js → chunk-HJTAGT3W.js} +1 -1
- package/{chunk-WL3UOGYO.js → chunk-HPW5MNDQ.js} +38 -98
- package/{chunk-H2G6JXTR.js → chunk-HQUORJTM.js} +1 -1
- package/{chunk-OYNDYVSE.js → chunk-JON2PHYT.js} +1 -1
- package/{chunk-7K5VMB4Q.js → chunk-JXIP6ZWH.js} +7 -7
- package/{chunk-KUUTWU4I.js → chunk-K4NISKOR.js} +46 -8
- package/{chunk-SP3DPVBH.js → chunk-KLIBF3BY.js} +2 -2
- package/chunk-LRGKOI5Y.js +297 -0
- package/{chunk-LN3OQJGG.js → chunk-MLEZPE3U.js} +2 -2
- package/{chunk-FGEYVPPR.js → chunk-MYMBBB6Q.js} +5 -64
- package/{chunk-VRJUIUIY.js → chunk-N4JKMCY3.js} +2 -2
- package/{chunk-U5Z7LFZF.js → chunk-NFLA6GSU.js} +4 -4
- package/{chunk-SVEUG45B.js → chunk-NHRQCXIQ.js} +0 -24
- package/{chunk-56W233KG.js → chunk-NJUQBYFJ.js} +3 -1
- package/{chunk-Q24S4NDF.js → chunk-Q4XZVZPN.js} +1 -1
- package/{chunk-UW4INMD2.js → chunk-RHMDMTDK.js} +2 -2
- package/{chunk-MFI4FGHX.js → chunk-SAJSBPI2.js} +1 -1
- package/{chunk-WHVQA7PJ.js → chunk-SSXTSPSG.js} +27 -6
- package/{chunk-2BWU4ORW.js → chunk-SUEIAK5N.js} +1 -1
- package/{chunk-3QJTD6DO.js → chunk-SVC3GGUA.js} +5 -5
- package/{chunk-QDHZCAH3.js → chunk-SVDMVX4G.js} +118 -2
- package/{chunk-GBADO3SM.js → chunk-SWJGJMTW.js} +1 -1
- package/{chunk-DQLYEGP7.js → chunk-SYYUU7EV.js} +2 -2
- package/{chunk-U2A47SVI.js → chunk-TC6P4NDR.js} +7 -7
- package/{chunk-V4KZGLOI.js → chunk-TR4DXUYX.js} +1983 -447
- package/{chunk-BANYWEYY.js → chunk-TY3ADTX5.js} +1 -1
- package/chunk-UAD2WT54.js +64 -0
- package/{chunk-PAHILFNT.js → chunk-UGBHDMHI.js} +4 -4
- package/{chunk-6FQ2552G.js → chunk-UOWXD4VN.js} +799 -956
- package/{chunk-5WADL4O7.js → chunk-UR66XPVF.js} +3 -3
- package/{chunk-6BYAXNH5.js → chunk-VZMUOPYG.js} +12 -2
- package/{chunk-LA4IDAK7.js → chunk-WQHGJHAL.js} +440 -2981
- package/{chunk-GLGD2JGY.js → chunk-XIJZOCSP.js} +7 -7
- package/{chunk-BJLYCOZK.js → chunk-YBFJQC2M.js} +93 -776
- package/{chunk-MRWGHF56.js → chunk-YDH3FDFQ.js} +12 -356
- package/{chunk-32I5RVMY.js → chunk-YLCUU3WM.js} +3 -3
- package/{chunk-D3JQPONH.js → chunk-YQBXOHE6.js} +1 -1
- package/chunk-ZJ7UHBJS.js +89 -0
- package/{chunk-TNPCQNGQ.js → chunk-ZVOHVJI3.js} +4 -9
- package/contentThunks-KNI6VXLT.js +71 -0
- package/{createAgentAutomationAction-UJLNFFFC.js → createAgentAutomationAction-OK4L33KF.js} +27 -23
- package/{createDialogAction-TJCX6GUE.js → createDialogAction-JDSMY4AY.js} +28 -24
- package/{createPageAction-N3IYABHV.js → createPageAction-T7RA3HCG.js} +29 -24
- package/{dbSlice-D5CNGWPD.js → dbSlice-TVX6SN2T.js} +6 -6
- package/{deleteFile-44TUM34Y.js → deleteFile-JYKRT7C3.js} +3 -3
- package/{dialogCommands-35M6RBAC.js → dialogCommands-UQZYWOOV.js} +32 -30
- package/{dialogSlice-KO7ADD7H.js → dialogSlice-TYW2G7IL.js} +26 -23
- package/{docCreateCommands-VXHZWQ3P.js → docCreateCommands-OA6HZBWO.js} +34 -32
- package/{docDeleteCommands-4WFAJR6A.js → docDeleteCommands-KBB3YQI2.js} +31 -29
- package/{docReadCommands-OYREEFAR.js → docReadCommands-ZLMFVC67.js} +30 -28
- package/{docStore-5BU76DFK.js → docStore-2URPBVCS.js} +8 -33
- package/{docUpdateCommands-A7QERSME.js → docUpdateCommands-HMH5KUON.js} +34 -32
- package/{fetchMessages-KZQVBXKY.js → fetchMessages-DRABNDPZ.js} +3 -3
- package/{getPricing-HAU62AFM.js → getPricing-RFOPUWHY.js} +4 -4
- package/{handleSendMessageAction-OSGQJQ45.js → handleSendMessageAction-GO53TY7U.js} +28 -25
- package/index.js +56 -56
- package/{localDialogRead-NQ33HBSI.js → localDialogRead-PUQKFI73.js} +1 -1
- package/{machineCommands-J43U3TX5.js → machineCommands-RK6L7ZWL.js} +59 -54
- package/{machineWsRunDispatch-Z2Z6STXZ.js → machineWsRunDispatch-3X64DW2Z.js} +54 -49
- package/memberThunks-THZYZFSN.js +638 -0
- package/{models-4QF4BJVY.js → models-JVKUEER5.js} +2 -2
- package/package.json +1 -1
- package/{read-RGNPI5H2.js → read-K4JU4MQC.js} +3 -3
- package/{readDocTool-6ESWKTXD.js → readDocTool-LQGR6FUN.js} +1 -1
- package/{readlineWorkspace-YRPV6JPN.js → readlineWorkspace-XUFJV3RS.js} +604 -263
- package/{removeDialogAgentAction-JYT73FU2.js → removeDialogAgentAction-ECHCFB7N.js} +12 -11
- package/{runAgentClientLoop-5YM5WMAY.js → runAgentClientLoop-24GQ2AW6.js} +46 -40
- package/{setDialogExtraReferencesAction-D564LMYQ.js → setDialogExtraReferencesAction-KCVJNGMB.js} +9 -8
- package/{setPrimaryDialogAgentAction-ACY3BLYA.js → setPrimaryDialogAgentAction-VDOBOMKC.js} +12 -11
- package/{settingSlice-MKI3MNZJ.js → settingSlice-VR2IJSXC.js} +7 -7
- package/{skillDiscovery-GPUDHDTZ.js → skillDiscovery-2QTZINON.js} +3 -3
- package/{spaceCommands-MY26V52L.js → spaceCommands-S5YJJXL7.js} +30 -28
- package/{streamAgentChatTurn-XV5X5TNQ.js → streamAgentChatTurn-QHKP3ABO.js} +77 -64
- package/{switchDialogAgentAction-CJ5H6SAR.js → switchDialogAgentAction-5L4UP7VI.js} +10 -9
- package/{toolApiClient-B2MFXMEG.js → toolApiClient-53U4UDFF.js} +3 -2
- package/{tools-MIMELA2Y.js → tools-SSXSTC3O.js} +37 -32
- package/{tuiSummaryLlmCaller-XJ5BKNNS.js → tuiSummaryLlmCaller-URFJHFC5.js} +17 -15
- package/{updateDialogTitleAction-EIZUSWHR.js → updateDialogTitleAction-YFYAEW3T.js} +28 -24
- package/chunk-6BGAQ3KR.js +0 -7081
- package/chunk-YBV6QJKM.js +0 -441
- package/spaceSlice-JUIXC365.js +0 -127
- package/{chunk-NQ4N4IGO.js → chunk-CS6TCJ7E.js} +3 -3
- package/{chunk-PYKV6FSC.js → chunk-XOJRZUPF.js} +3 -3
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
toCompactAgentSummary,
|
|
18
18
|
toSafeAgentSummary,
|
|
19
19
|
toUnavailableAgentSummary
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-GRFK2XP4.js";
|
|
21
21
|
import {
|
|
22
22
|
getUserDataItemTimestamp,
|
|
23
23
|
mergeAndDedupUserData
|
|
@@ -28,22 +28,29 @@ import {
|
|
|
28
28
|
readPageFunc,
|
|
29
29
|
readPageFunctionSchema,
|
|
30
30
|
slateToSimplifiedMarkdown
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-3ZTR7ZO4.js";
|
|
32
32
|
import {
|
|
33
33
|
TASK_PREVIEW_MAX,
|
|
34
34
|
buildDelegatedTaskContent,
|
|
35
35
|
formatListRunsCard,
|
|
36
|
+
formatNotFoundRunCard,
|
|
36
37
|
formatStartRunCard,
|
|
37
38
|
formatStatusRunCard,
|
|
38
39
|
formatStopRunCard,
|
|
39
40
|
resolveRunLabel
|
|
40
41
|
} from "./chunk-KXKQO4Q6.js";
|
|
41
42
|
import {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
addMemberSpace,
|
|
44
|
+
fetchAuthoritativeRemoteSpace,
|
|
45
|
+
getAllMemberSpaces,
|
|
46
|
+
removeMemberSpace,
|
|
47
|
+
selectSpaceRemoteAuth,
|
|
48
|
+
setMembershipLoaded,
|
|
49
|
+
setMembershipLoading,
|
|
50
|
+
setMembershipRejected,
|
|
51
|
+
setSpaceInitialized,
|
|
52
|
+
updateMemberSpaceName
|
|
53
|
+
} from "./chunk-LRGKOI5Y.js";
|
|
47
54
|
import {
|
|
48
55
|
ToolApiError,
|
|
49
56
|
buildToolRequestHeaders,
|
|
@@ -51,10 +58,13 @@ import {
|
|
|
51
58
|
getRequestConfig,
|
|
52
59
|
getToolBaseUrl,
|
|
53
60
|
getToolRequestContext
|
|
54
|
-
} from "./chunk-
|
|
61
|
+
} from "./chunk-TY3ADTX5.js";
|
|
55
62
|
import {
|
|
56
63
|
setDialogExtraReferencesAction
|
|
57
|
-
} from "./chunk-
|
|
64
|
+
} from "./chunk-UGBHDMHI.js";
|
|
65
|
+
import {
|
|
66
|
+
markdownToSlate
|
|
67
|
+
} from "./chunk-INZZJSQF.js";
|
|
58
68
|
import {
|
|
59
69
|
extractMentionsFromSlate
|
|
60
70
|
} from "./chunk-MEYIRKDN.js";
|
|
@@ -64,34 +74,49 @@ import {
|
|
|
64
74
|
import {
|
|
65
75
|
isSkillSummaryMarker
|
|
66
76
|
} from "./chunk-VF4K2QE6.js";
|
|
77
|
+
import {
|
|
78
|
+
createDocState
|
|
79
|
+
} from "./chunk-6HDYSFLO.js";
|
|
67
80
|
import {
|
|
68
81
|
BUILTIN_OBJECT_SKILL_IDS,
|
|
69
82
|
buildBuiltinObjectSkillConfig,
|
|
70
83
|
buildBuiltinObjectSkillDbKey,
|
|
71
84
|
buildBuiltinObjectSkillPageContent,
|
|
72
85
|
createDialogAction
|
|
73
|
-
} from "./chunk-
|
|
86
|
+
} from "./chunk-FJHMLRDQ.js";
|
|
74
87
|
import {
|
|
75
|
-
|
|
88
|
+
DEFAULT_COLLAPSED_CATEGORIES,
|
|
76
89
|
addContentToSpace,
|
|
77
90
|
addRow,
|
|
78
91
|
createTable,
|
|
79
|
-
|
|
80
|
-
|
|
92
|
+
deleteContentFromSpace,
|
|
93
|
+
deleteTable,
|
|
94
|
+
expandCategoryInCollapsed,
|
|
81
95
|
fetchAndCacheTableRows,
|
|
82
|
-
|
|
83
|
-
getAllMemberSpaces,
|
|
84
|
-
getCurrentSpaceId,
|
|
85
|
-
getCurrentSpaceIdRaw,
|
|
86
|
-
getViewMode,
|
|
96
|
+
getCollapsedCategories,
|
|
87
97
|
i18nBaseConfig,
|
|
88
98
|
initReactI18next,
|
|
89
99
|
instance,
|
|
90
100
|
loadTableRows,
|
|
101
|
+
readStoredCollapsedCategories,
|
|
102
|
+
setCollapsedCategories,
|
|
103
|
+
toggleCategoryCollapse,
|
|
91
104
|
updateContentCategory,
|
|
92
|
-
updateContentTitle
|
|
93
|
-
|
|
105
|
+
updateContentTitle,
|
|
106
|
+
writeStoredCollapsedCategories
|
|
107
|
+
} from "./chunk-WQHGJHAL.js";
|
|
108
|
+
import {
|
|
109
|
+
getCurrentSpaceId,
|
|
110
|
+
getCurrentSpaceIdRaw,
|
|
111
|
+
getCurrentSpaceRaw,
|
|
112
|
+
getViewMode,
|
|
113
|
+
setCurrentSpace,
|
|
114
|
+
setCurrentSpaceBoth,
|
|
115
|
+
setViewMode,
|
|
116
|
+
updateCurrentSpaceIfMatch
|
|
117
|
+
} from "./chunk-ZJ7UHBJS.js";
|
|
94
118
|
import {
|
|
119
|
+
deleteDialog,
|
|
95
120
|
normalizeAppRouteId,
|
|
96
121
|
resolveDialogRuntimeAgentKey,
|
|
97
122
|
selectAllMsgs,
|
|
@@ -100,19 +125,22 @@ import {
|
|
|
100
125
|
selectMsgById,
|
|
101
126
|
uiAskChoiceFunc,
|
|
102
127
|
uiAskChoiceFunctionSchema
|
|
103
|
-
} from "./chunk-
|
|
128
|
+
} from "./chunk-YBFJQC2M.js";
|
|
104
129
|
import {
|
|
105
130
|
createAgent,
|
|
131
|
+
deleteServerSyncedCredential,
|
|
106
132
|
runLlm,
|
|
107
133
|
streamAgentChatTurn,
|
|
108
134
|
updateAgent
|
|
109
|
-
} from "./chunk-
|
|
135
|
+
} from "./chunk-TC6P4NDR.js";
|
|
110
136
|
import {
|
|
111
137
|
getActiveDialogKey,
|
|
112
|
-
require_react,
|
|
113
138
|
selectCurrentDialogKey,
|
|
114
139
|
selectPendingRawDataByPageKey
|
|
115
|
-
} from "./chunk-
|
|
140
|
+
} from "./chunk-6YTOJY35.js";
|
|
141
|
+
import {
|
|
142
|
+
require_react
|
|
143
|
+
} from "./chunk-YDH3FDFQ.js";
|
|
116
144
|
import {
|
|
117
145
|
CODING_SKILL_SLUGS,
|
|
118
146
|
buildCodingSkillConfig,
|
|
@@ -145,19 +173,22 @@ import {
|
|
|
145
173
|
redactAgentRecordForWorkspaceTool,
|
|
146
174
|
resolveNoloDialogInput,
|
|
147
175
|
verifyNoloDialogSubjectRefQuery
|
|
148
|
-
} from "./chunk-
|
|
176
|
+
} from "./chunk-ZVOHVJI3.js";
|
|
149
177
|
import {
|
|
150
178
|
isAgentUnavailableNow
|
|
151
179
|
} from "./chunk-IWUMSAQF.js";
|
|
152
180
|
import {
|
|
153
181
|
buildDatabaseFileContentUrl
|
|
154
|
-
} from "./chunk-
|
|
182
|
+
} from "./chunk-BBTN4NQD.js";
|
|
155
183
|
import {
|
|
156
184
|
DEFAULT_MODEL
|
|
157
|
-
} from "./chunk-
|
|
185
|
+
} from "./chunk-SVDMVX4G.js";
|
|
158
186
|
import {
|
|
159
187
|
compactWhitespace
|
|
160
188
|
} from "./chunk-DWLEOOGR.js";
|
|
189
|
+
import {
|
|
190
|
+
createFileCredentialBroker
|
|
191
|
+
} from "./chunk-CS6TCJ7E.js";
|
|
161
192
|
import {
|
|
162
193
|
toErrorMessage
|
|
163
194
|
} from "./chunk-HNMXYYJR.js";
|
|
@@ -167,7 +198,7 @@ import {
|
|
|
167
198
|
} from "./chunk-O6OSWFZQ.js";
|
|
168
199
|
import {
|
|
169
200
|
shareResourceAction
|
|
170
|
-
} from "./chunk-
|
|
201
|
+
} from "./chunk-AUVFJGPC.js";
|
|
171
202
|
import {
|
|
172
203
|
AGENT_UPDATE_FIELD_NAMES,
|
|
173
204
|
nolotusId,
|
|
@@ -175,36 +206,49 @@ import {
|
|
|
175
206
|
selectAutoApproveSelfUpdateFields,
|
|
176
207
|
selectCurrentServer,
|
|
177
208
|
selectSyncServers
|
|
178
|
-
} from "./chunk-
|
|
209
|
+
} from "./chunk-SVC3GGUA.js";
|
|
179
210
|
import {
|
|
180
211
|
asRecordOrEmpty
|
|
181
212
|
} from "./chunk-KX6YBIHG.js";
|
|
182
213
|
import {
|
|
214
|
+
UNCATEGORIZED_ID,
|
|
183
215
|
addContentAction,
|
|
216
|
+
checkSpaceMembership
|
|
217
|
+
} from "./chunk-MYMBBB6Q.js";
|
|
218
|
+
import {
|
|
184
219
|
createSpaceKey,
|
|
185
220
|
normalizeSpaceId
|
|
186
|
-
} from "./chunk-
|
|
221
|
+
} from "./chunk-UAD2WT54.js";
|
|
187
222
|
import {
|
|
188
223
|
patch,
|
|
189
224
|
read,
|
|
190
225
|
readAndWait,
|
|
191
226
|
readAndWaitAction,
|
|
227
|
+
remove,
|
|
192
228
|
selectById,
|
|
229
|
+
selectEntities,
|
|
193
230
|
toTimestampMs,
|
|
194
231
|
write
|
|
195
|
-
} from "./chunk-
|
|
232
|
+
} from "./chunk-7NYDJAQ7.js";
|
|
196
233
|
import {
|
|
197
234
|
SEPARATOR,
|
|
235
|
+
TYPE_STORAGE_PREFIXES,
|
|
198
236
|
createAgentKey,
|
|
199
237
|
dialogMessageRange,
|
|
200
238
|
fileKey,
|
|
201
239
|
isAgentKey,
|
|
240
|
+
isAppKey,
|
|
241
|
+
isDialogKey,
|
|
242
|
+
isFileKey,
|
|
243
|
+
isPageKey,
|
|
202
244
|
isTableMetaKey,
|
|
245
|
+
isTaskKey,
|
|
203
246
|
metaKey,
|
|
204
247
|
rowKey,
|
|
248
|
+
splitKey,
|
|
205
249
|
toTrimmedString,
|
|
206
250
|
ulid
|
|
207
|
-
} from "./chunk-
|
|
251
|
+
} from "./chunk-NHRQCXIQ.js";
|
|
208
252
|
import {
|
|
209
253
|
asOptionalFiniteNumber
|
|
210
254
|
} from "./chunk-WWC7I6TA.js";
|
|
@@ -218,28 +262,38 @@ import {
|
|
|
218
262
|
import {
|
|
219
263
|
DEFAULT_CODE_PLANNER_EXECUTOR_CANDIDATE_KEYS,
|
|
220
264
|
readAction
|
|
221
|
-
} from "./chunk-
|
|
265
|
+
} from "./chunk-2WBFJHQA.js";
|
|
222
266
|
import {
|
|
223
267
|
extractCustomId
|
|
224
268
|
} from "./chunk-BJIRLHJR.js";
|
|
225
269
|
import {
|
|
270
|
+
DEVICE_LOCAL_OWNER_ID,
|
|
226
271
|
createAsyncThunk,
|
|
227
272
|
getRuntimeServerContext,
|
|
273
|
+
isDeviceLocalOwnerId,
|
|
274
|
+
isDeviceLocalSpaceBody,
|
|
275
|
+
isDeviceLocalSpaceMembership,
|
|
228
276
|
noloWriteRequest,
|
|
277
|
+
resolveEffectiveSpaceActorId,
|
|
278
|
+
resolveRecordOwnerUserId,
|
|
229
279
|
selectIdentityToken,
|
|
230
280
|
selectIdentityUserBalance,
|
|
231
281
|
selectIdentityUserId,
|
|
232
282
|
selectRuntimeSnapshot
|
|
233
|
-
} from "./chunk-
|
|
283
|
+
} from "./chunk-XOJRZUPF.js";
|
|
234
284
|
import {
|
|
235
285
|
isAbortError
|
|
236
286
|
} from "./chunk-QOKAKDPE.js";
|
|
237
287
|
import {
|
|
238
|
-
|
|
239
|
-
|
|
288
|
+
buildTombstoneRecord,
|
|
289
|
+
isTombstoneRecord
|
|
290
|
+
} from "./chunk-GBRG75BQ.js";
|
|
240
291
|
import {
|
|
241
292
|
asTrimmedString
|
|
242
293
|
} from "./chunk-3EUW3WEO.js";
|
|
294
|
+
import {
|
|
295
|
+
isRecord
|
|
296
|
+
} from "./chunk-KUG52IAP.js";
|
|
243
297
|
import {
|
|
244
298
|
API_ENDPOINTS
|
|
245
299
|
} from "./chunk-LCBAMY2M.js";
|
|
@@ -2053,6 +2107,8 @@ var chat_locale_default = {
|
|
|
2053
2107
|
privateDialogGuestTitle: "This is a private dialog link",
|
|
2054
2108
|
privateDialogGuestHint: "The /dialog-\u2026 route is only available to signed-in users who have permission to this dialog. If you want to share it with someone else, use a /share/<token> link instead.",
|
|
2055
2109
|
thinkingProcess: "Thinking Process",
|
|
2110
|
+
thinkingActive: "Thinking\u2026",
|
|
2111
|
+
thinkingDone: "Thought for {{seconds}}s",
|
|
2056
2112
|
thinkingContent: "Thinking Content",
|
|
2057
2113
|
answerContent: "Answer",
|
|
2058
2114
|
// Mobile Upload
|
|
@@ -2425,6 +2481,8 @@ var chat_locale_default = {
|
|
|
2425
2481
|
privateDialogGuestTitle: "\u8FD9\u662F\u79C1\u6709\u5BF9\u8BDD\u94FE\u63A5",
|
|
2426
2482
|
privateDialogGuestHint: "\u5F53\u524D /dialog-\u2026 \u8DEF\u7531\u53EA\u5BF9\u767B\u5F55\u4E14\u6709\u6743\u9650\u7684\u8D26\u53F7\u53EF\u89C1\u3002\u82E5\u8981\u628A\u8FD9\u6BB5\u5BF9\u8BDD\u53D1\u7ED9\u522B\u4EBA\uFF0C\u8BF7\u6539\u7528 /share/<token> \u94FE\u63A5\u3002",
|
|
2427
2483
|
thinkingProcess: "\u601D\u8003\u8FC7\u7A0B",
|
|
2484
|
+
thinkingActive: "\u601D\u8003\u4E2D\u2026",
|
|
2485
|
+
thinkingDone: "\u601D\u8003\u4E86 {{seconds}}s",
|
|
2428
2486
|
thinkingContent: "\u601D\u8003\u5185\u5BB9",
|
|
2429
2487
|
answerContent: "\u56DE\u7B54",
|
|
2430
2488
|
deleteMessageTitle: "\u5220\u9664\u6D88\u606F",
|
|
@@ -2782,6 +2840,8 @@ var chat_locale_default = {
|
|
|
2782
2840
|
privateDialogGuestTitle: "\u9019\u662F\u79C1\u6709\u5C0D\u8A71\u9023\u7D50",
|
|
2783
2841
|
privateDialogGuestHint: "\u76EE\u524D /dialog-\u2026 \u8DEF\u7531\u53EA\u5C0D\u5DF2\u767B\u5165\u4E14\u6709\u6B0A\u9650\u7684\u5E33\u865F\u53EF\u898B\u3002\u82E5\u8981\u628A\u9019\u6BB5\u5C0D\u8A71\u5206\u4EAB\u7D66\u5225\u4EBA\uFF0C\u8ACB\u6539\u7528 /share/<token> \u9023\u7D50\u3002",
|
|
2784
2842
|
thinkingProcess: "\u601D\u8003\u904E\u7A0B",
|
|
2843
|
+
thinkingActive: "\u601D\u8003\u4E2D\u2026",
|
|
2844
|
+
thinkingDone: "\u601D\u8003\u4E86 {{seconds}}s",
|
|
2785
2845
|
thinkingContent: "\u601D\u8003\u5167\u5BB9",
|
|
2786
2846
|
answerContent: "\u56DE\u7B54",
|
|
2787
2847
|
deleteMessageTitle: "\u522A\u9664\u8A0A\u606F",
|
|
@@ -3077,6 +3137,8 @@ var chat_locale_default = {
|
|
|
3077
3137
|
privateDialogGuestTitle: "\u3053\u308C\u306F\u975E\u516C\u958B\u30C0\u30A4\u30A2\u30ED\u30B0\u30EA\u30F3\u30AF\u3067\u3059",
|
|
3078
3138
|
privateDialogGuestHint: "/dialog-\u2026 \u30EB\u30FC\u30C8\u306F\u3001\u3053\u306E\u30C0\u30A4\u30A2\u30ED\u30B0\u306B\u6A29\u9650\u306E\u3042\u308B\u30ED\u30B0\u30A4\u30F3\u6E08\u307F\u30E6\u30FC\u30B6\u30FC\u3060\u3051\u304C\u958B\u3051\u307E\u3059\u3002\u4ED6\u306E\u4EBA\u306B\u5171\u6709\u3057\u305F\u3044\u5834\u5408\u306F\u3001/share/<token> \u30EA\u30F3\u30AF\u3092\u4F7F\u3063\u3066\u304F\u3060\u3055\u3044\u3002",
|
|
3079
3139
|
thinkingProcess: "\u601D\u8003\u30D7\u30ED\u30BB\u30B9",
|
|
3140
|
+
thinkingActive: "\u8003\u3048\u3066\u3044\u307E\u3059\u2026",
|
|
3141
|
+
thinkingDone: "{{seconds}}\u79D2\u8003\u3048\u305F",
|
|
3080
3142
|
thinkingContent: "\u601D\u8003\u5185\u5BB9",
|
|
3081
3143
|
answerContent: "\u56DE\u7B54",
|
|
3082
3144
|
// Mobile Upload
|
|
@@ -10293,8 +10355,10 @@ Pro unlocks at ${ADVANCED_FEATURE_MIN_BALANCE} points. No subscription lock-in.`
|
|
|
10293
10355
|
name: "Model Name",
|
|
10294
10356
|
input: "Input / 1M Points",
|
|
10295
10357
|
output: "Output / 1M Points",
|
|
10358
|
+
cache: "Cache Hit / 1M Points",
|
|
10296
10359
|
vision: "Vision"
|
|
10297
10360
|
},
|
|
10361
|
+
cacheNote: 'Cache hit: repeated identical input prefixes are billed at a lower cached rate. "\u2014" means the model has no cached pricing.',
|
|
10298
10362
|
faqTitle: "Frequently Asked Questions",
|
|
10299
10363
|
faqSubtitle: "Have questions? Check here first",
|
|
10300
10364
|
faq: [
|
|
@@ -10385,8 +10449,10 @@ Pro unlocks at ${ADVANCED_FEATURE_MIN_BALANCE} points. No subscription lock-in.`
|
|
|
10385
10449
|
name: "\u6A21\u578B\u540D\u79F0",
|
|
10386
10450
|
input: "\u8F93\u5165 / 1M \u79EF\u5206",
|
|
10387
10451
|
output: "\u8F93\u51FA / 1M \u79EF\u5206",
|
|
10452
|
+
cache: "\u7F13\u5B58\u547D\u4E2D / 1M \u79EF\u5206",
|
|
10388
10453
|
vision: "\u89C6\u89C9\u8BC6\u522B"
|
|
10389
10454
|
},
|
|
10455
|
+
cacheNote: "\u7F13\u5B58\u547D\u4E2D\uFF1A\u76F8\u540C\u524D\u7F00\u7684\u91CD\u590D\u8F93\u5165\u6309\u66F4\u4F4E\u7684\u7F13\u5B58\u4EF7\u8BA1\u8D39\uFF1B\u300C\u2014\u300D\u8868\u793A\u8BE5\u6A21\u578B\u6682\u65E0\u7F13\u5B58\u4EF7\u3002",
|
|
10390
10456
|
searchBoxPlaceholder: "\u6309\u6A21\u578B\u540D\u641C\u7D22...",
|
|
10391
10457
|
faqTitle: "\u5E38\u89C1\u95EE\u9898",
|
|
10392
10458
|
faqSubtitle: "\u6709\u7591\u95EE\uFF1F\u5148\u770B\u8FD9\u91CC",
|
|
@@ -10478,8 +10544,10 @@ Pro unlocks at ${ADVANCED_FEATURE_MIN_BALANCE} points. No subscription lock-in.`
|
|
|
10478
10544
|
name: "\u6A21\u578B\u540D\u7A31",
|
|
10479
10545
|
input: "\u8F38\u5165 / 1M \u7A4D\u5206",
|
|
10480
10546
|
output: "\u8F38\u51FA / 1M \u7A4D\u5206",
|
|
10547
|
+
cache: "\u5FEB\u53D6\u547D\u4E2D / 1M \u7A4D\u5206",
|
|
10481
10548
|
vision: "\u8996\u89BA\u8B58\u5225"
|
|
10482
10549
|
},
|
|
10550
|
+
cacheNote: "\u5FEB\u53D6\u547D\u4E2D\uFF1A\u76F8\u540C\u524D\u7DB4\u7684\u91CD\u8907\u8F38\u5165\u6309\u66F4\u4F4E\u7684\u5FEB\u53D6\u50F9\u8A08\u8CBB\uFF1B\u300C\u2014\u300D\u8868\u793A\u8A72\u6A21\u578B\u66AB\u7121\u5FEB\u53D6\u50F9\u3002",
|
|
10483
10551
|
faqTitle: "\u5E38\u898B\u554F\u984C",
|
|
10484
10552
|
faqSubtitle: "\u6709\u7591\u554F\uFF1F\u5148\u770B\u9019\u88E1",
|
|
10485
10553
|
faq: [
|
|
@@ -10570,8 +10638,10 @@ Pro unlocks at ${ADVANCED_FEATURE_MIN_BALANCE} points. No subscription lock-in.`
|
|
|
10570
10638
|
name: "\u30E2\u30C7\u30EB\u540D",
|
|
10571
10639
|
input: "\u5165\u529B / 1M \u30DD\u30A4\u30F3\u30C8",
|
|
10572
10640
|
output: "\u51FA\u529B / 1M \u30DD\u30A4\u30F3\u30C8",
|
|
10641
|
+
cache: "\u30AD\u30E3\u30C3\u30B7\u30E5\u30D2\u30C3\u30C8 / 1M \u30DD\u30A4\u30F3\u30C8",
|
|
10573
10642
|
vision: "\u30D3\u30B8\u30E7\u30F3\u8A8D\u8B58"
|
|
10574
10643
|
},
|
|
10644
|
+
cacheNote: "\u30AD\u30E3\u30C3\u30B7\u30E5\u30D2\u30C3\u30C8\uFF1A\u540C\u3058\u63A5\u982D\u8F9E\u306E\u7E70\u308A\u8FD4\u3057\u5165\u529B\u306F\u3001\u3088\u308A\u4F4E\u3044\u30AD\u30E3\u30C3\u30B7\u30E5\u4FA1\u683C\u3067\u8AB2\u91D1\u3055\u308C\u307E\u3059\u3002\u300C\u2014\u300D\u306F\u30AD\u30E3\u30C3\u30B7\u30E5\u4FA1\u683C\u304C\u8A2D\u5B9A\u3055\u308C\u3066\u3044\u306A\u3044\u30E2\u30C7\u30EB\u3067\u3059\u3002",
|
|
10575
10645
|
faqTitle: "\u3088\u304F\u3042\u308B\u8CEA\u554F",
|
|
10576
10646
|
faqSubtitle: "\u3054\u8CEA\u554F\u304C\u3042\u308A\u307E\u3059\u304B\uFF1F \u307E\u305A\u306F\u3053\u3061\u3089\u3092\u3054\u78BA\u8A8D\u304F\u3060\u3055\u3044",
|
|
10577
10647
|
faq: [
|
|
@@ -10601,7 +10671,7 @@ Pro unlocks at ${ADVANCED_FEATURE_MIN_BALANCE} points. No subscription lock-in.`
|
|
|
10601
10671
|
var recharge_locale_default = {
|
|
10602
10672
|
["en" /* EN */]: {
|
|
10603
10673
|
translation: {
|
|
10604
|
-
|
|
10674
|
+
recharge_page: {
|
|
10605
10675
|
title: "Recharge",
|
|
10606
10676
|
viewPricing: "View pricing",
|
|
10607
10677
|
channel: { online: "Online payment", transfer: "QR transfer" },
|
|
@@ -10668,7 +10738,7 @@ var recharge_locale_default = {
|
|
|
10668
10738
|
},
|
|
10669
10739
|
["zh-CN" /* ZH_CN */]: {
|
|
10670
10740
|
translation: {
|
|
10671
|
-
|
|
10741
|
+
recharge_page: {
|
|
10672
10742
|
title: "\u5145\u503C",
|
|
10673
10743
|
viewPricing: "\u67E5\u770B\u4EF7\u683C",
|
|
10674
10744
|
channel: { online: "\u5728\u7EBF\u652F\u4ED8", transfer: "\u626B\u7801\u8F6C\u8D26" },
|
|
@@ -10735,7 +10805,7 @@ var recharge_locale_default = {
|
|
|
10735
10805
|
},
|
|
10736
10806
|
["zh-Hant" /* ZH_HANT */]: {
|
|
10737
10807
|
translation: {
|
|
10738
|
-
|
|
10808
|
+
recharge_page: {
|
|
10739
10809
|
title: "\u5132\u503C",
|
|
10740
10810
|
viewPricing: "\u67E5\u770B\u50F9\u683C",
|
|
10741
10811
|
channel: { online: "\u7DDA\u4E0A\u652F\u4ED8", transfer: "\u6383\u78BC\u8F49\u5E33" },
|
|
@@ -10802,7 +10872,7 @@ var recharge_locale_default = {
|
|
|
10802
10872
|
},
|
|
10803
10873
|
["ja" /* JA */]: {
|
|
10804
10874
|
translation: {
|
|
10805
|
-
|
|
10875
|
+
recharge_page: {
|
|
10806
10876
|
title: "\u30C1\u30E3\u30FC\u30B8",
|
|
10807
10877
|
viewPricing: "\u6599\u91D1\u3092\u898B\u308B",
|
|
10808
10878
|
channel: { online: "\u30AA\u30F3\u30E9\u30A4\u30F3\u6C7A\u6E08", transfer: "QR\u9001\u91D1" },
|
|
@@ -11830,7 +11900,7 @@ var HOSTED_EXEC_RUNTIME_TOOL_POLICY = {
|
|
|
11830
11900
|
workspace: { mode: "lease" }
|
|
11831
11901
|
};
|
|
11832
11902
|
var findModelConfig = async (modelName, provider) => {
|
|
11833
|
-
const { ALL_MODELS } = await import("./models-
|
|
11903
|
+
const { ALL_MODELS } = await import("./models-JVKUEER5.js");
|
|
11834
11904
|
const name = toTrimmedString(modelName);
|
|
11835
11905
|
const prov = toTrimmedString(provider ?? "");
|
|
11836
11906
|
if (!name) return null;
|
|
@@ -12071,7 +12141,7 @@ var buildFormDataFromArgs = async (args) => {
|
|
|
12071
12141
|
const trimmedModel = toTrimmedString(model);
|
|
12072
12142
|
const trimmedProvider = toTrimmedString(provider);
|
|
12073
12143
|
const modelConfig = await findModelConfig(trimmedModel, trimmedProvider);
|
|
12074
|
-
const { getModelPricing } = await import("./getPricing-
|
|
12144
|
+
const { getModelPricing } = await import("./getPricing-RFOPUWHY.js");
|
|
12075
12145
|
const normalizedTools = tools ?? [];
|
|
12076
12146
|
const resolvedRuntimeToolPolicy = runtimeToolPolicy ?? (normalizedTools.includes("execShell") ? HOSTED_EXEC_RUNTIME_TOOL_POLICY : void 0);
|
|
12077
12147
|
const formData = {
|
|
@@ -12130,9 +12200,9 @@ var findSpaceConfig = (nameOrId, allSpaces) => {
|
|
|
12130
12200
|
return null;
|
|
12131
12201
|
};
|
|
12132
12202
|
async function createAgentToolFunc(args, thunkApi) {
|
|
12133
|
-
const
|
|
12134
|
-
const currentUserId = selectIdentityUserId(
|
|
12135
|
-
const currentBalance = selectIdentityUserBalance(
|
|
12203
|
+
const state2 = thunkApi.getState();
|
|
12204
|
+
const currentUserId = selectIdentityUserId(state2);
|
|
12205
|
+
const currentBalance = selectIdentityUserBalance(state2);
|
|
12136
12206
|
const allSpaces = getAllMemberSpaces();
|
|
12137
12207
|
if (!currentUserId) {
|
|
12138
12208
|
throw new Error("\u521B\u5EFA Agent \u5931\u8D25\uFF1A\u5F53\u524D\u672A\u767B\u5F55\u6216\u7F3A\u5C11 userId\u3002");
|
|
@@ -12175,10 +12245,10 @@ ${availableList}`
|
|
|
12175
12245
|
createAgent({
|
|
12176
12246
|
userId: currentUserId,
|
|
12177
12247
|
formData,
|
|
12178
|
-
spaceId:
|
|
12248
|
+
spaceId: getCurrentSpaceId() || void 0
|
|
12179
12249
|
})
|
|
12180
12250
|
).unwrap();
|
|
12181
|
-
const currentSpaceId =
|
|
12251
|
+
const currentSpaceId = getCurrentSpaceId();
|
|
12182
12252
|
if (currentSpaceId) {
|
|
12183
12253
|
const agentDbKey = agent.isPublic ? createAgentKey.public(agent.id) : createAgentKey.private(currentUserId, agent.id);
|
|
12184
12254
|
try {
|
|
@@ -12485,8 +12555,8 @@ var updateAgentToolFunctionSchema = {
|
|
|
12485
12555
|
}
|
|
12486
12556
|
};
|
|
12487
12557
|
async function updateAgentToolFunc(args, thunkApi) {
|
|
12488
|
-
const
|
|
12489
|
-
const userId = selectIdentityUserId(
|
|
12558
|
+
const state2 = thunkApi.getState();
|
|
12559
|
+
const userId = selectIdentityUserId(state2);
|
|
12490
12560
|
const db = thunkApi.extra?.db;
|
|
12491
12561
|
validateUpdateArgs(userId, { requireAgentId: true, agentId: args.agentId });
|
|
12492
12562
|
const dbKey = args.agentId.trim();
|
|
@@ -12575,7 +12645,7 @@ var createDocFunctionSchema = {
|
|
|
12575
12645
|
async function createDocFunc(args, thunkApi) {
|
|
12576
12646
|
const { getState } = thunkApi;
|
|
12577
12647
|
const dispatch = thunkApi.dispatch.bind(thunkApi);
|
|
12578
|
-
const
|
|
12648
|
+
const state2 = getState();
|
|
12579
12649
|
console.log("[createDocTool] Received args:", args);
|
|
12580
12650
|
const rawTitle = (args.title ?? "").trim();
|
|
12581
12651
|
const title = rawTitle || "\u65B0\u9875\u9762";
|
|
@@ -12808,7 +12878,7 @@ var createSkillDocFunctionSchema = {
|
|
|
12808
12878
|
};
|
|
12809
12879
|
async function createSkillDocFunc(args, thunkApi) {
|
|
12810
12880
|
const { dispatch, getState } = thunkApi;
|
|
12811
|
-
const
|
|
12881
|
+
const state2 = getState();
|
|
12812
12882
|
const { title, content, skillConfig, evalConfig } = buildSkillDocFromArgs(args);
|
|
12813
12883
|
const explicitSpaceId = (args.spaceId ?? "").trim() || void 0;
|
|
12814
12884
|
const currentSpaceId = getCurrentSpaceId() || void 0;
|
|
@@ -13155,7 +13225,7 @@ var importSkillFunctionSchema = {
|
|
|
13155
13225
|
};
|
|
13156
13226
|
async function importSkillFunc(args, thunkApi) {
|
|
13157
13227
|
const { dispatch, getState } = thunkApi;
|
|
13158
|
-
const
|
|
13228
|
+
const state2 = getState();
|
|
13159
13229
|
const explicitContent = asTrimmedString(args.content);
|
|
13160
13230
|
const url = typeof args.url === "string" ? normalizeUrl(args.url) : "";
|
|
13161
13231
|
if (!explicitContent && !url) {
|
|
@@ -14024,8 +14094,8 @@ var loadSkillFunctionSchema = {
|
|
|
14024
14094
|
}
|
|
14025
14095
|
};
|
|
14026
14096
|
var getRuntime = (thunkApi) => {
|
|
14027
|
-
const
|
|
14028
|
-
return
|
|
14097
|
+
const state2 = thunkApi?.getState?.();
|
|
14098
|
+
return state2 ? selectRuntimeSnapshot(state2) : null;
|
|
14029
14099
|
};
|
|
14030
14100
|
var authHeaders = (token) => token ? { Authorization: `Bearer ${token}` } : {};
|
|
14031
14101
|
async function readRemoteRecord(args) {
|
|
@@ -14114,12 +14184,12 @@ async function listSkillCandidates(thunkApi) {
|
|
|
14114
14184
|
}
|
|
14115
14185
|
var resolveCurrentAgentKeyForSkillGate = (thunkApi) => {
|
|
14116
14186
|
try {
|
|
14117
|
-
const
|
|
14118
|
-
if (!
|
|
14187
|
+
const state2 = thunkApi?.getState?.();
|
|
14188
|
+
if (!state2) return null;
|
|
14119
14189
|
const currentDialogKey = getActiveDialogKey();
|
|
14120
14190
|
if (!currentDialogKey) return null;
|
|
14121
14191
|
const dialogConfig = selectById(
|
|
14122
|
-
|
|
14192
|
+
state2,
|
|
14123
14193
|
currentDialogKey
|
|
14124
14194
|
);
|
|
14125
14195
|
return asTrimmedNonEmptyStringArray(dialogConfig?.cybots)[0] ?? null;
|
|
@@ -14212,11 +14282,11 @@ ${body}`
|
|
|
14212
14282
|
}
|
|
14213
14283
|
async function persistLoadedSkillReference(thunkApi, dbKey, name) {
|
|
14214
14284
|
try {
|
|
14215
|
-
const
|
|
14285
|
+
const state2 = thunkApi?.getState?.();
|
|
14216
14286
|
const currentDialogKey = getActiveDialogKey();
|
|
14217
|
-
if (!
|
|
14287
|
+
if (!state2 || !currentDialogKey) return;
|
|
14218
14288
|
const dialogConfig = selectById(
|
|
14219
|
-
|
|
14289
|
+
state2,
|
|
14220
14290
|
currentDialogKey
|
|
14221
14291
|
);
|
|
14222
14292
|
const existing = dialogConfig?.extraReferences ?? [];
|
|
@@ -14232,6 +14302,279 @@ async function persistLoadedSkillReference(thunkApi, dbKey, name) {
|
|
|
14232
14302
|
}
|
|
14233
14303
|
}
|
|
14234
14304
|
|
|
14305
|
+
// packages/create/space/category/categoryActions.ts
|
|
14306
|
+
import { ulid as ulid2 } from "ulid";
|
|
14307
|
+
var syncCurrentSpace = (spaceId, updatedSpaceData) => {
|
|
14308
|
+
if (getCurrentSpaceIdRaw() === spaceId) {
|
|
14309
|
+
updateCurrentSpaceIfMatch(spaceId, updatedSpaceData);
|
|
14310
|
+
}
|
|
14311
|
+
};
|
|
14312
|
+
var setAllCategoriesCollapsed = createAsyncThunk(
|
|
14313
|
+
"space/setAllCategoriesCollapsed",
|
|
14314
|
+
async (input, thunkAPI) => {
|
|
14315
|
+
try {
|
|
14316
|
+
const { getState } = thunkAPI;
|
|
14317
|
+
const rootState = getState();
|
|
14318
|
+
const spaceId = input.spaceId || getCurrentSpaceId();
|
|
14319
|
+
if (!spaceId) throw new Error("\u65E0\u6CD5\u5207\u6362\u6298\u53E0\u72B6\u6001\uFF1A\u6CA1\u6709\u6D3B\u52A8\u7684\u7A7A\u95F4\u3002");
|
|
14320
|
+
const currentSpace = getCurrentSpaceRaw();
|
|
14321
|
+
const categoryIds = currentSpace?.categories ? Object.keys(currentSpace.categories) : [];
|
|
14322
|
+
categoryIds.push(UNCATEGORIZED_ID);
|
|
14323
|
+
const collapsedCategories = {};
|
|
14324
|
+
categoryIds.forEach((id) => {
|
|
14325
|
+
collapsedCategories[id] = input.collapsed;
|
|
14326
|
+
});
|
|
14327
|
+
if (typeof window !== "undefined") {
|
|
14328
|
+
writeStoredCollapsedCategories(
|
|
14329
|
+
spaceId,
|
|
14330
|
+
collapsedCategories,
|
|
14331
|
+
window.localStorage
|
|
14332
|
+
);
|
|
14333
|
+
}
|
|
14334
|
+
setCollapsedCategories(collapsedCategories, spaceId);
|
|
14335
|
+
return collapsedCategories;
|
|
14336
|
+
} catch (error) {
|
|
14337
|
+
console.error("\u6279\u91CF\u5207\u6362\u5206\u7C7B\u6298\u53E0\u72B6\u6001\u5931\u8D25:", error?.message);
|
|
14338
|
+
throw error;
|
|
14339
|
+
}
|
|
14340
|
+
}
|
|
14341
|
+
);
|
|
14342
|
+
var toggleCategoryCollapse2 = createAsyncThunk(
|
|
14343
|
+
"space/toggleCategoryCollapse",
|
|
14344
|
+
async (input, thunkAPI) => {
|
|
14345
|
+
try {
|
|
14346
|
+
const { getState } = thunkAPI;
|
|
14347
|
+
const { categoryId } = input;
|
|
14348
|
+
const rootState = getState();
|
|
14349
|
+
const spaceId = getCurrentSpaceId();
|
|
14350
|
+
if (!spaceId) throw new Error("\u65E0\u6CD5\u5207\u6362\u6298\u53E0\u72B6\u6001\uFF1A\u6CA1\u6709\u6D3B\u52A8\u7684\u7A7A\u95F4\u3002");
|
|
14351
|
+
if (!categoryId) throw new Error("\u65E0\u6548\u7684\u5206\u7C7BID\u3002");
|
|
14352
|
+
const defaultCollapsed = DEFAULT_COLLAPSED_CATEGORIES[categoryId] ?? true;
|
|
14353
|
+
const currentCollapsedCategories = getCollapsedCategories();
|
|
14354
|
+
const isCurrentlyCollapsed = currentCollapsedCategories[categoryId] ?? defaultCollapsed;
|
|
14355
|
+
const newCollapsedState = !isCurrentlyCollapsed;
|
|
14356
|
+
const collapsedCategories = {
|
|
14357
|
+
...currentCollapsedCategories,
|
|
14358
|
+
[categoryId]: newCollapsedState
|
|
14359
|
+
};
|
|
14360
|
+
if (typeof window !== "undefined") {
|
|
14361
|
+
writeStoredCollapsedCategories(
|
|
14362
|
+
spaceId,
|
|
14363
|
+
collapsedCategories,
|
|
14364
|
+
window.localStorage
|
|
14365
|
+
);
|
|
14366
|
+
}
|
|
14367
|
+
toggleCategoryCollapse(categoryId);
|
|
14368
|
+
return collapsedCategories;
|
|
14369
|
+
} catch (error) {
|
|
14370
|
+
console.error("\u5207\u6362\u5206\u7C7B\u6298\u53E0\u72B6\u6001\u5931\u8D25:", error?.message);
|
|
14371
|
+
throw error;
|
|
14372
|
+
}
|
|
14373
|
+
}
|
|
14374
|
+
);
|
|
14375
|
+
var addCategory = createAsyncThunk(
|
|
14376
|
+
"space/addCategory",
|
|
14377
|
+
async (input, thunkAPI) => {
|
|
14378
|
+
const { spaceId: inputSpaceId, name, categoryId, order } = input;
|
|
14379
|
+
const { dispatch, getState } = thunkAPI;
|
|
14380
|
+
const rootState = getState();
|
|
14381
|
+
const spaceId = inputSpaceId || getCurrentSpaceId();
|
|
14382
|
+
if (!spaceId) {
|
|
14383
|
+
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");
|
|
14384
|
+
}
|
|
14385
|
+
const currentUserId = selectIdentityUserId(rootState);
|
|
14386
|
+
if (!currentUserId) throw new Error("User is not logged in.");
|
|
14387
|
+
if (!name.trim()) {
|
|
14388
|
+
throw new Error("\u65E0\u6548\u7684\u5206\u7C7B\u540D\u79F0\u3002");
|
|
14389
|
+
}
|
|
14390
|
+
const spaceKey = createSpaceKey.space(spaceId);
|
|
14391
|
+
const spaceData = await dispatch(read({
|
|
14392
|
+
dbKey: spaceKey
|
|
14393
|
+
})).unwrap();
|
|
14394
|
+
checkSpaceMembership(spaceData, currentUserId);
|
|
14395
|
+
const newCategoryId = categoryId || ulid2();
|
|
14396
|
+
if (spaceData.categories?.[newCategoryId]) {
|
|
14397
|
+
throw new Error(`\u5206\u7C7B ID "${newCategoryId}" \u5DF2\u5B58\u5728\u3002`);
|
|
14398
|
+
}
|
|
14399
|
+
const existingValidCategories = spaceData.categories ? Object.values(spaceData.categories).filter(Boolean) : [];
|
|
14400
|
+
const finalOrder = typeof order === "number" ? order : existingValidCategories.length;
|
|
14401
|
+
const nowISO = (/* @__PURE__ */ new Date()).toISOString();
|
|
14402
|
+
const newCategory = {
|
|
14403
|
+
name: name.trim(),
|
|
14404
|
+
order: finalOrder,
|
|
14405
|
+
updatedAt: nowISO
|
|
14406
|
+
};
|
|
14407
|
+
const updatedSpaceData = await dispatch(
|
|
14408
|
+
patch({
|
|
14409
|
+
dbKey: spaceKey,
|
|
14410
|
+
changes: {
|
|
14411
|
+
categories: { [newCategoryId]: newCategory },
|
|
14412
|
+
updatedAt: nowISO
|
|
14413
|
+
}
|
|
14414
|
+
})
|
|
14415
|
+
).unwrap();
|
|
14416
|
+
const currentCollapsedCategories = getCollapsedCategories();
|
|
14417
|
+
const collapsedCategories = {
|
|
14418
|
+
...currentCollapsedCategories,
|
|
14419
|
+
[newCategoryId]: false
|
|
14420
|
+
};
|
|
14421
|
+
if (typeof window !== "undefined") {
|
|
14422
|
+
writeStoredCollapsedCategories(
|
|
14423
|
+
spaceId,
|
|
14424
|
+
collapsedCategories,
|
|
14425
|
+
window.localStorage
|
|
14426
|
+
);
|
|
14427
|
+
}
|
|
14428
|
+
expandCategoryInCollapsed(newCategoryId, spaceId);
|
|
14429
|
+
syncCurrentSpace(spaceId, updatedSpaceData);
|
|
14430
|
+
return { spaceId, updatedSpaceData, newCategoryId, collapsedCategories };
|
|
14431
|
+
}
|
|
14432
|
+
);
|
|
14433
|
+
var deleteCategory = createAsyncThunk(
|
|
14434
|
+
"space/deleteCategory",
|
|
14435
|
+
async (input, thunkAPI) => {
|
|
14436
|
+
const { categoryId, spaceId } = input;
|
|
14437
|
+
const { dispatch, getState } = thunkAPI;
|
|
14438
|
+
const rootState = getState();
|
|
14439
|
+
const currentUserId = selectIdentityUserId(rootState);
|
|
14440
|
+
if (!currentUserId) throw new Error("User is not logged in.");
|
|
14441
|
+
if (!categoryId.trim()) throw new Error("\u65E0\u6548\u7684 categoryId\u3002");
|
|
14442
|
+
const spaceKey = createSpaceKey.space(spaceId);
|
|
14443
|
+
const spaceData = await dispatch(read({
|
|
14444
|
+
dbKey: spaceKey
|
|
14445
|
+
})).unwrap();
|
|
14446
|
+
checkSpaceMembership(spaceData, currentUserId);
|
|
14447
|
+
if (!spaceData?.categories?.[categoryId]) {
|
|
14448
|
+
throw new Error("\u6307\u5B9A\u7684\u5206\u7C7B\u4E0D\u5B58\u5728\u6216\u5DF2\u88AB\u5220\u9664\u3002");
|
|
14449
|
+
}
|
|
14450
|
+
const nowISO = (/* @__PURE__ */ new Date()).toISOString();
|
|
14451
|
+
const changes = {
|
|
14452
|
+
categories: { [categoryId]: null },
|
|
14453
|
+
updatedAt: nowISO
|
|
14454
|
+
};
|
|
14455
|
+
if (spaceData.contents) {
|
|
14456
|
+
const contentsPatch = {};
|
|
14457
|
+
let contentsChanged = false;
|
|
14458
|
+
for (const key in spaceData.contents) {
|
|
14459
|
+
if (spaceData.contents[key]?.categoryId === categoryId) {
|
|
14460
|
+
contentsPatch[key] = {
|
|
14461
|
+
categoryId: null,
|
|
14462
|
+
updatedAt: nowISO
|
|
14463
|
+
};
|
|
14464
|
+
contentsChanged = true;
|
|
14465
|
+
}
|
|
14466
|
+
}
|
|
14467
|
+
if (contentsChanged) changes.contents = contentsPatch;
|
|
14468
|
+
}
|
|
14469
|
+
const updatedSpaceData = await dispatch(
|
|
14470
|
+
patch({ dbKey: spaceKey, changes })
|
|
14471
|
+
).unwrap();
|
|
14472
|
+
const collapsedCategories = { ...getCollapsedCategories() };
|
|
14473
|
+
delete collapsedCategories[categoryId];
|
|
14474
|
+
setCollapsedCategories(collapsedCategories, spaceId);
|
|
14475
|
+
if (typeof window !== "undefined") {
|
|
14476
|
+
writeStoredCollapsedCategories(
|
|
14477
|
+
spaceId,
|
|
14478
|
+
collapsedCategories,
|
|
14479
|
+
window.localStorage
|
|
14480
|
+
);
|
|
14481
|
+
}
|
|
14482
|
+
syncCurrentSpace(spaceId, updatedSpaceData);
|
|
14483
|
+
return { spaceId, updatedSpaceData, collapsedCategories };
|
|
14484
|
+
}
|
|
14485
|
+
);
|
|
14486
|
+
var updateCategoryName = createAsyncThunk(
|
|
14487
|
+
"space/updateCategoryName",
|
|
14488
|
+
async (input, thunkAPI) => {
|
|
14489
|
+
const { spaceId, categoryId, name } = input;
|
|
14490
|
+
const { dispatch, getState } = thunkAPI;
|
|
14491
|
+
const currentUserId = selectIdentityUserId(getState());
|
|
14492
|
+
if (!currentUserId) throw new Error("User is not logged in.");
|
|
14493
|
+
if (!categoryId.trim()) throw new Error("\u65E0\u6548\u7684 categoryId\u3002");
|
|
14494
|
+
const trimmedName = name.trim();
|
|
14495
|
+
if (!trimmedName) throw new Error("\u5206\u7C7B\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A\u6216\u4EC5\u5305\u542B\u7A7A\u683C\u3002");
|
|
14496
|
+
const spaceKey = createSpaceKey.space(spaceId);
|
|
14497
|
+
const spaceData = await dispatch(read({
|
|
14498
|
+
dbKey: spaceKey
|
|
14499
|
+
})).unwrap();
|
|
14500
|
+
checkSpaceMembership(spaceData, currentUserId);
|
|
14501
|
+
const existingCategory = spaceData.categories?.[categoryId];
|
|
14502
|
+
if (!existingCategory) {
|
|
14503
|
+
throw new Error("\u6307\u5B9A\u7684\u5206\u7C7B\u4E0D\u5B58\u5728\u3002");
|
|
14504
|
+
}
|
|
14505
|
+
const nowISO = (/* @__PURE__ */ new Date()).toISOString();
|
|
14506
|
+
const changes = {
|
|
14507
|
+
categories: {
|
|
14508
|
+
[categoryId]: {
|
|
14509
|
+
...existingCategory,
|
|
14510
|
+
name: trimmedName,
|
|
14511
|
+
updatedAt: nowISO
|
|
14512
|
+
}
|
|
14513
|
+
},
|
|
14514
|
+
updatedAt: nowISO
|
|
14515
|
+
};
|
|
14516
|
+
const updatedSpaceData = await dispatch(
|
|
14517
|
+
patch({ dbKey: spaceKey, changes })
|
|
14518
|
+
).unwrap();
|
|
14519
|
+
syncCurrentSpace(spaceId, updatedSpaceData);
|
|
14520
|
+
return { spaceId, updatedSpaceData };
|
|
14521
|
+
}
|
|
14522
|
+
);
|
|
14523
|
+
var reorderCategories = createAsyncThunk(
|
|
14524
|
+
"space/reorderCategories",
|
|
14525
|
+
async (input, thunkAPI) => {
|
|
14526
|
+
const { spaceId, sortedCategoryIds } = input;
|
|
14527
|
+
const { dispatch, getState } = thunkAPI;
|
|
14528
|
+
const stateRoot = getState();
|
|
14529
|
+
const currentUserId = selectIdentityUserId(stateRoot);
|
|
14530
|
+
if (!currentUserId) {
|
|
14531
|
+
throw new Error("User is not logged in.");
|
|
14532
|
+
}
|
|
14533
|
+
if (!Array.isArray(sortedCategoryIds)) {
|
|
14534
|
+
throw new Error(
|
|
14535
|
+
"Invalid sortedCategoryIds provided: must be an array."
|
|
14536
|
+
);
|
|
14537
|
+
}
|
|
14538
|
+
const spaceKey = createSpaceKey.space(spaceId);
|
|
14539
|
+
const spaceData = await dispatch(read({
|
|
14540
|
+
dbKey: spaceKey
|
|
14541
|
+
})).unwrap();
|
|
14542
|
+
checkSpaceMembership(spaceData, currentUserId);
|
|
14543
|
+
if (!spaceData.categories || Object.keys(spaceData.categories).length === 0) {
|
|
14544
|
+
return { spaceId, updatedSpaceData: spaceData };
|
|
14545
|
+
}
|
|
14546
|
+
const nowISO = (/* @__PURE__ */ new Date()).toISOString();
|
|
14547
|
+
const currentCategories = spaceData.categories;
|
|
14548
|
+
const updatedCategoriesChanges = {};
|
|
14549
|
+
let hasValidChanges = false;
|
|
14550
|
+
sortedCategoryIds.forEach((catId, index) => {
|
|
14551
|
+
const existingCategory = currentCategories[catId];
|
|
14552
|
+
if (existingCategory) {
|
|
14553
|
+
updatedCategoriesChanges[catId] = {
|
|
14554
|
+
...existingCategory,
|
|
14555
|
+
order: index,
|
|
14556
|
+
updatedAt: nowISO
|
|
14557
|
+
};
|
|
14558
|
+
if (existingCategory.order !== index) {
|
|
14559
|
+
hasValidChanges = true;
|
|
14560
|
+
}
|
|
14561
|
+
}
|
|
14562
|
+
});
|
|
14563
|
+
if (!hasValidChanges) {
|
|
14564
|
+
return { spaceId, updatedSpaceData: spaceData };
|
|
14565
|
+
}
|
|
14566
|
+
const changes = {
|
|
14567
|
+
categories: updatedCategoriesChanges,
|
|
14568
|
+
updatedAt: nowISO
|
|
14569
|
+
};
|
|
14570
|
+
const updatedSpaceData = await dispatch(
|
|
14571
|
+
patch({ dbKey: spaceKey, changes })
|
|
14572
|
+
).unwrap();
|
|
14573
|
+
syncCurrentSpace(spaceId, updatedSpaceData);
|
|
14574
|
+
return { spaceId, updatedSpaceData };
|
|
14575
|
+
}
|
|
14576
|
+
);
|
|
14577
|
+
|
|
14235
14578
|
// packages/ai/tools/category/createCategoryTool.ts
|
|
14236
14579
|
var createCategoryFunctionSchema = {
|
|
14237
14580
|
// 已从 'create_category' 更新为 'createCategory'
|
|
@@ -14251,7 +14594,7 @@ var createCategoryFunctionSchema = {
|
|
|
14251
14594
|
async function createCategoryFunc(args, thunkApi) {
|
|
14252
14595
|
const { getState } = thunkApi;
|
|
14253
14596
|
const dispatch = thunkApi.dispatch.bind(thunkApi);
|
|
14254
|
-
const
|
|
14597
|
+
const state2 = getState();
|
|
14255
14598
|
const spaceId = getCurrentSpaceId();
|
|
14256
14599
|
if (!spaceId) {
|
|
14257
14600
|
throw new Error("\u65E0\u6CD5\u521B\u5EFA\u5206\u7C7B\uFF0C\u56E0\u4E3A\u5F53\u524D\u7A7A\u95F4\u672A\u8BBE\u5B9A\u3002");
|
|
@@ -14295,7 +14638,7 @@ var updateContentCategoryFunctionSchema = {
|
|
|
14295
14638
|
async function updateContentCategoryFunc(args, thunkApi) {
|
|
14296
14639
|
const { getState } = thunkApi;
|
|
14297
14640
|
const dispatch = thunkApi.dispatch.bind(thunkApi);
|
|
14298
|
-
const
|
|
14641
|
+
const state2 = getState();
|
|
14299
14642
|
const spaceId = getCurrentSpaceId();
|
|
14300
14643
|
if (!spaceId) {
|
|
14301
14644
|
throw new Error("\u65E0\u6CD5\u66F4\u65B0\u5206\u7C7B\uFF0C\u56E0\u4E3A\u5F53\u524D\u7A7A\u95F4\u672A\u8BBE\u5B9A\u3002");
|
|
@@ -14320,6 +14663,19 @@ async function updateContentCategoryFunc(args, thunkApi) {
|
|
|
14320
14663
|
}
|
|
14321
14664
|
}
|
|
14322
14665
|
|
|
14666
|
+
// packages/create/space/spaceCurrentSelectors.ts
|
|
14667
|
+
var getSpaceUpdatedAt = (space) => space ? Number(space.updatedAt) || 0 : 0;
|
|
14668
|
+
function getCurrentSpace(entities) {
|
|
14669
|
+
const spaceId = getCurrentSpaceId();
|
|
14670
|
+
if (!spaceId) return null;
|
|
14671
|
+
const stored = getCurrentSpaceRaw();
|
|
14672
|
+
const entity = entities[createSpaceKey.space(spaceId)];
|
|
14673
|
+
if (!stored) return entity ?? null;
|
|
14674
|
+
if (!entity) return stored;
|
|
14675
|
+
return getSpaceUpdatedAt(entity) > getSpaceUpdatedAt(stored) ? entity : stored;
|
|
14676
|
+
}
|
|
14677
|
+
var selectCurrentSpace = (state2) => getCurrentSpace(selectEntities(state2));
|
|
14678
|
+
|
|
14323
14679
|
// packages/ai/tools/category/queryContentsByCategoryTool.ts
|
|
14324
14680
|
var queryContentsByCategoryFunctionSchema = {
|
|
14325
14681
|
name: "queryContentsByCategory",
|
|
@@ -14341,12 +14697,12 @@ var queryContentsByCategoryFunctionSchema = {
|
|
|
14341
14697
|
};
|
|
14342
14698
|
async function queryContentsByCategoryFunc(args, thunkApi) {
|
|
14343
14699
|
const { getState } = thunkApi;
|
|
14344
|
-
const
|
|
14700
|
+
const state2 = getState();
|
|
14345
14701
|
const spaceId = getCurrentSpaceId();
|
|
14346
14702
|
if (!spaceId) {
|
|
14347
14703
|
throw new Error("\u65E0\u6CD5\u67E5\u8BE2\u5185\u5BB9\uFF0C\u56E0\u4E3A\u5F53\u524D\u7A7A\u95F4\u672A\u8BBE\u5B9A\u3002");
|
|
14348
14704
|
}
|
|
14349
|
-
const currentSpace =
|
|
14705
|
+
const currentSpace = selectCurrentSpace(state2);
|
|
14350
14706
|
if (!currentSpace) {
|
|
14351
14707
|
throw new Error("\u5F53\u524D\u7A7A\u95F4\u6570\u636E\u672A\u627E\u5230\u3002");
|
|
14352
14708
|
}
|
|
@@ -14388,15 +14744,15 @@ var buildRequestHeaders = (token) => {
|
|
|
14388
14744
|
};
|
|
14389
14745
|
var handleApiResponse = async (response) => {
|
|
14390
14746
|
if (!response.ok) {
|
|
14391
|
-
let
|
|
14747
|
+
let errorMessage2 = `API \u9519\u8BEF\uFF01\u72B6\u6001\u7801: ${response.status}`;
|
|
14392
14748
|
try {
|
|
14393
14749
|
const errorData = await response.json();
|
|
14394
14750
|
if (errorData?.error) {
|
|
14395
|
-
|
|
14751
|
+
errorMessage2 += `: ${errorData.error.message || JSON.stringify(errorData.error)}`;
|
|
14396
14752
|
}
|
|
14397
14753
|
} catch (e) {
|
|
14398
14754
|
}
|
|
14399
|
-
throw new Error(
|
|
14755
|
+
throw new Error(errorMessage2);
|
|
14400
14756
|
}
|
|
14401
14757
|
return response.json();
|
|
14402
14758
|
};
|
|
@@ -14530,8 +14886,8 @@ async function importDataFunc(args, thunkApi) {
|
|
|
14530
14886
|
throw new Error("`tableName` \u548C `fileReferenceId` \u90FD\u662F\u5FC5\u9700\u7684\u53C2\u6570\u3002");
|
|
14531
14887
|
}
|
|
14532
14888
|
try {
|
|
14533
|
-
const
|
|
14534
|
-
const pendingData = selectPendingRawDataByPageKey(
|
|
14889
|
+
const state2 = thunkApi.getState();
|
|
14890
|
+
const pendingData = selectPendingRawDataByPageKey(state2, pageKey);
|
|
14535
14891
|
if (!pendingData || !pendingData.jsonData) {
|
|
14536
14892
|
throw new Error(`\u5728\u5185\u5B58\u4E2D\u627E\u4E0D\u5230\u6587\u4EF6 (ID: ${pageKey}) \u7684\u6570\u636E\u3002`);
|
|
14537
14893
|
}
|
|
@@ -14834,8 +15190,8 @@ ${markdownContent}`
|
|
|
14834
15190
|
const title = tableMeta.displayName || `Table (${tableMeta.tableId})`;
|
|
14835
15191
|
const { rows, markdown: tableMd } = await thunkApi.dispatch(
|
|
14836
15192
|
async (_dispatch, getState, { db }) => {
|
|
14837
|
-
const
|
|
14838
|
-
const { currentToken: token, remoteServers } = getRuntimeServerContext(
|
|
15193
|
+
const state2 = getState();
|
|
15194
|
+
const { currentToken: token, remoteServers } = getRuntimeServerContext(state2);
|
|
14839
15195
|
return await fetchAndSerializeTable(tableMeta, db, {
|
|
14840
15196
|
token,
|
|
14841
15197
|
remoteServers
|
|
@@ -14915,11 +15271,9 @@ async function listUserSpacesFunc(args, thunkApi, context) {
|
|
|
14915
15271
|
const { ownedOnly = false } = args || {};
|
|
14916
15272
|
try {
|
|
14917
15273
|
const { getState } = thunkApi;
|
|
14918
|
-
const
|
|
14919
|
-
|
|
14920
|
-
|
|
14921
|
-
memberSpaces = memberSpaces.filter((ms) => ms.role === "owner");
|
|
14922
|
-
}
|
|
15274
|
+
const state2 = getState();
|
|
15275
|
+
const allMembers = getAllMemberSpaces();
|
|
15276
|
+
let memberSpaces = ownedOnly ? allMembers.filter((ms) => ms.role === "owner") : [...allMembers];
|
|
14923
15277
|
if (memberSpaces.length === 0) {
|
|
14924
15278
|
return {
|
|
14925
15279
|
rawData: { spaces: [] },
|
|
@@ -15040,8 +15394,8 @@ var jsonPreview = (value, maxLength = 1800) => {
|
|
|
15040
15394
|
...(truncated)`;
|
|
15041
15395
|
};
|
|
15042
15396
|
var getRuntime2 = (thunkApi) => {
|
|
15043
|
-
const
|
|
15044
|
-
return
|
|
15397
|
+
const state2 = thunkApi?.getState?.();
|
|
15398
|
+
return state2 ? selectRuntimeSnapshot(state2) : null;
|
|
15045
15399
|
};
|
|
15046
15400
|
var authHeaders2 = (token) => token ? { Authorization: `Bearer ${token}` } : {};
|
|
15047
15401
|
var DrainExhaustedError = class extends Error {
|
|
@@ -15385,10 +15739,10 @@ async function deleteDialogsFunc(args, thunkApi) {
|
|
|
15385
15739
|
const deletedDialogIds = [];
|
|
15386
15740
|
const deletedDialogKeys = [];
|
|
15387
15741
|
const failures = [];
|
|
15388
|
-
const { deleteDialog } = await import("./dialogSlice-
|
|
15742
|
+
const { deleteDialog: deleteDialog2 } = await import("./dialogSlice-TYW2G7IL.js");
|
|
15389
15743
|
for (const target of targets) {
|
|
15390
15744
|
try {
|
|
15391
|
-
await thunkApi.dispatch(
|
|
15745
|
+
await thunkApi.dispatch(deleteDialog2(target.dbKey)).unwrap();
|
|
15392
15746
|
} catch (error) {
|
|
15393
15747
|
failures.push({
|
|
15394
15748
|
dbKey: target.dbKey,
|
|
@@ -15469,7 +15823,7 @@ function formatAgentListCard(agents, maxDisplay = 8) {
|
|
|
15469
15823
|
}
|
|
15470
15824
|
var listAgentsFunctionSchema = {
|
|
15471
15825
|
name: "listAgents",
|
|
15472
|
-
description: "List the current user's Nolo agents as safe summaries.
|
|
15826
|
+
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
15827
|
parameters: {
|
|
15474
15828
|
type: "object",
|
|
15475
15829
|
properties: {
|
|
@@ -15680,7 +16034,7 @@ var readSkillDocFunctionSchema = {
|
|
|
15680
16034
|
}
|
|
15681
16035
|
};
|
|
15682
16036
|
async function readSkillDocFunc(args, thunkApi) {
|
|
15683
|
-
const { buildReadDocResult } = await import("./readDocTool-
|
|
16037
|
+
const { buildReadDocResult } = await import("./readDocTool-LQGR6FUN.js");
|
|
15684
16038
|
const id = args?.id ?? args?.doc ?? args?.docKey ?? args?.pageKey;
|
|
15685
16039
|
if (typeof id !== "string" || !id.trim()) {
|
|
15686
16040
|
throw new Error("readSkillDoc requires id or doc.");
|
|
@@ -15728,121 +16082,1193 @@ async function cliDoctorFunc(_args, thunkApi) {
|
|
|
15728
16082
|
return { rawData: result, displayData: jsonPreview(result) };
|
|
15729
16083
|
}
|
|
15730
16084
|
|
|
15731
|
-
// packages/
|
|
15732
|
-
|
|
15733
|
-
|
|
15734
|
-
|
|
15735
|
-
|
|
15736
|
-
|
|
15737
|
-
|
|
15738
|
-
|
|
15739
|
-
|
|
15740
|
-
|
|
15741
|
-
|
|
15742
|
-
|
|
15743
|
-
|
|
15744
|
-
|
|
15745
|
-
|
|
15746
|
-
|
|
15747
|
-
|
|
15748
|
-
const name = getSpaceName(membership).toLowerCase();
|
|
15749
|
-
if (matchMode === "spaceId") return spaceId === normalizedQuery;
|
|
15750
|
-
if (matchMode === "exact") return name === textQuery;
|
|
15751
|
-
if (matchMode === "contains") return name.includes(textQuery);
|
|
15752
|
-
return name.startsWith(textQuery);
|
|
15753
|
-
});
|
|
16085
|
+
// packages/database/queryPrefixes.ts
|
|
16086
|
+
function getUserDataPrefixes(type, userId) {
|
|
16087
|
+
const normalizedType = toTrimmedString(type);
|
|
16088
|
+
const normalizedUserId = toTrimmedString(userId);
|
|
16089
|
+
if (!normalizedType || !normalizedUserId) return [];
|
|
16090
|
+
const aliases = TYPE_STORAGE_PREFIXES[normalizedType] ?? [normalizedType];
|
|
16091
|
+
const seen = /* @__PURE__ */ new Set();
|
|
16092
|
+
const prefixes = [];
|
|
16093
|
+
for (const raw of aliases) {
|
|
16094
|
+
const alias = toTrimmedString(raw);
|
|
16095
|
+
if (!alias) continue;
|
|
16096
|
+
const prefix = `${alias}-${normalizedUserId}-`;
|
|
16097
|
+
if (seen.has(prefix)) continue;
|
|
16098
|
+
seen.add(prefix);
|
|
16099
|
+
prefixes.push(prefix);
|
|
16100
|
+
}
|
|
16101
|
+
return prefixes;
|
|
15754
16102
|
}
|
|
15755
|
-
|
|
15756
|
-
|
|
15757
|
-
|
|
15758
|
-
|
|
15759
|
-
|
|
15760
|
-
|
|
15761
|
-
|
|
15762
|
-
|
|
15763
|
-
|
|
15764
|
-
|
|
15765
|
-
|
|
15766
|
-
|
|
15767
|
-
|
|
15768
|
-
|
|
15769
|
-
|
|
15770
|
-
|
|
15771
|
-
|
|
15772
|
-
|
|
15773
|
-
|
|
15774
|
-
|
|
15775
|
-
|
|
15776
|
-
|
|
15777
|
-
|
|
16103
|
+
|
|
16104
|
+
// packages/database/client/fetchUserData.ts
|
|
16105
|
+
var attachQueriedKey = (key, value) => {
|
|
16106
|
+
if (!value || typeof value !== "object") return value;
|
|
16107
|
+
if (typeof value.dbKey === "string" && value.dbKey.trim().length > 0) {
|
|
16108
|
+
return value;
|
|
16109
|
+
}
|
|
16110
|
+
return {
|
|
16111
|
+
...value,
|
|
16112
|
+
dbKey: key
|
|
16113
|
+
};
|
|
16114
|
+
};
|
|
16115
|
+
var normalizeTypeList = (types) => {
|
|
16116
|
+
const raw = Array.isArray(types) ? types : [types];
|
|
16117
|
+
const seen = /* @__PURE__ */ new Set();
|
|
16118
|
+
const out = [];
|
|
16119
|
+
for (const t of raw) {
|
|
16120
|
+
const n = toTrimmedString(t);
|
|
16121
|
+
if (!n || seen.has(n)) continue;
|
|
16122
|
+
seen.add(n);
|
|
16123
|
+
out.push(n);
|
|
16124
|
+
}
|
|
16125
|
+
return out;
|
|
16126
|
+
};
|
|
16127
|
+
async function fetchUserData(db, types, userId, options = {}) {
|
|
16128
|
+
const results = {};
|
|
16129
|
+
const typeArray = normalizeTypeList(types);
|
|
16130
|
+
const includeDeleted = options.includeDeleted === true;
|
|
16131
|
+
try {
|
|
16132
|
+
for (const type of typeArray) {
|
|
16133
|
+
const byKey = /* @__PURE__ */ new Map();
|
|
16134
|
+
const prefixes = getUserDataPrefixes(type, userId);
|
|
16135
|
+
for (const prefix of prefixes) {
|
|
16136
|
+
if (!prefix) continue;
|
|
16137
|
+
let iterator = db.iterator({
|
|
16138
|
+
gte: prefix,
|
|
16139
|
+
lte: `${prefix}\uFFFF`
|
|
16140
|
+
});
|
|
16141
|
+
if (iterator && typeof iterator.then === "function") {
|
|
16142
|
+
iterator = await iterator;
|
|
16143
|
+
}
|
|
16144
|
+
for await (const [key, value] of iterator) {
|
|
16145
|
+
const keyStr = String(key);
|
|
16146
|
+
if (byKey.has(keyStr)) continue;
|
|
16147
|
+
const hydrated = attachQueriedKey(keyStr, value);
|
|
16148
|
+
if (!hydrated) continue;
|
|
16149
|
+
if (!includeDeleted && hydrated.deletedAt) continue;
|
|
16150
|
+
byKey.set(keyStr, hydrated);
|
|
16151
|
+
}
|
|
16152
|
+
}
|
|
16153
|
+
results[type] = [...byKey.values()];
|
|
15778
16154
|
}
|
|
15779
|
-
|
|
15780
|
-
|
|
15781
|
-
skipped.push({
|
|
15782
|
-
spaceId,
|
|
15783
|
-
name,
|
|
15784
|
-
reason: "not_owner",
|
|
15785
|
-
ownerId
|
|
15786
|
-
});
|
|
15787
|
-
continue;
|
|
16155
|
+
if (Array.isArray(types)) {
|
|
16156
|
+
return results;
|
|
15788
16157
|
}
|
|
15789
|
-
|
|
15790
|
-
|
|
15791
|
-
|
|
15792
|
-
|
|
15793
|
-
|
|
15794
|
-
contentCount: record.contents && typeof record.contents === "object" ? Object.keys(record.contents).length : 0
|
|
15795
|
-
});
|
|
16158
|
+
const single = toTrimmedString(types);
|
|
16159
|
+
return results[single] ?? [];
|
|
16160
|
+
} catch (error) {
|
|
16161
|
+
console.error("Query error:", error);
|
|
16162
|
+
throw error;
|
|
15796
16163
|
}
|
|
15797
|
-
return { deletable, skipped };
|
|
15798
|
-
}
|
|
15799
|
-
function resolveConfirmedSpaceDeletionTargets(preview, confirmedSpaceIds) {
|
|
15800
|
-
const wanted = new Set(
|
|
15801
|
-
confirmedSpaceIds.map((spaceId) => normalizeSpaceId(spaceId)).filter(Boolean)
|
|
15802
|
-
);
|
|
15803
|
-
const targets = preview.deletable.filter((item) => wanted.has(item.spaceId));
|
|
15804
|
-
const found = new Set(targets.map((item) => item.spaceId));
|
|
15805
|
-
const missingConfirmedSpaceIds = Array.from(wanted).filter((spaceId) => !found.has(spaceId));
|
|
15806
|
-
return { targets, missingConfirmedSpaceIds };
|
|
15807
16164
|
}
|
|
15808
16165
|
|
|
15809
|
-
// packages/
|
|
15810
|
-
|
|
15811
|
-
|
|
15812
|
-
|
|
15813
|
-
|
|
15814
|
-
|
|
15815
|
-
|
|
15816
|
-
|
|
15817
|
-
|
|
15818
|
-
|
|
15819
|
-
|
|
15820
|
-
|
|
15821
|
-
|
|
15822
|
-
|
|
15823
|
-
|
|
15824
|
-
|
|
15825
|
-
|
|
15826
|
-
|
|
15827
|
-
|
|
15828
|
-
|
|
15829
|
-
|
|
15830
|
-
|
|
15831
|
-
|
|
15832
|
-
|
|
15833
|
-
|
|
15834
|
-
|
|
16166
|
+
// packages/create/space/addSpaceAction.ts
|
|
16167
|
+
import { ulid as ulid3 } from "ulid";
|
|
16168
|
+
async function getUserDataOnce({
|
|
16169
|
+
types,
|
|
16170
|
+
userId,
|
|
16171
|
+
limit,
|
|
16172
|
+
isLoggedIn = false,
|
|
16173
|
+
currentUserId,
|
|
16174
|
+
db
|
|
16175
|
+
}) {
|
|
16176
|
+
try {
|
|
16177
|
+
const typeArray = Array.isArray(types) ? types : [types];
|
|
16178
|
+
const effectiveUserId = userId === "local" && isLoggedIn && currentUserId ? currentUserId : userId;
|
|
16179
|
+
const localResults = await fetchUserData(db, typeArray, effectiveUserId);
|
|
16180
|
+
const localData = Object.values(localResults).flat();
|
|
16181
|
+
return { data: localData };
|
|
16182
|
+
} catch (err) {
|
|
16183
|
+
const error = err instanceof Error ? err : new Error("Unknown error occurred");
|
|
16184
|
+
return { data: [], error };
|
|
16185
|
+
}
|
|
16186
|
+
}
|
|
16187
|
+
var targetTypes = ["dialog" /* DIALOG */, "page" /* DOC */];
|
|
16188
|
+
var getCurrentPathForLog = () => typeof window !== "undefined" && typeof window.location?.pathname === "string" ? window.location.pathname : void 0;
|
|
16189
|
+
var addSpaceAction = async (input, thunkAPI) => {
|
|
16190
|
+
const {
|
|
16191
|
+
name,
|
|
16192
|
+
description = "",
|
|
16193
|
+
boundFolder
|
|
16194
|
+
} = input;
|
|
16195
|
+
const visibility = input.visibility ?? "private" /* PRIVATE */;
|
|
16196
|
+
const { dispatch, getState, extra } = thunkAPI;
|
|
16197
|
+
const state2 = getState();
|
|
16198
|
+
const accountUserId = selectIdentityUserId(state2);
|
|
16199
|
+
const userId = resolveEffectiveSpaceActorId(accountUserId);
|
|
16200
|
+
const spaceId = ulid3();
|
|
16201
|
+
const now = Date.now();
|
|
16202
|
+
const nowISO = new Date(now).toISOString();
|
|
16203
|
+
const spaceData = {
|
|
16204
|
+
id: spaceId,
|
|
16205
|
+
name,
|
|
16206
|
+
description,
|
|
16207
|
+
boundFolder,
|
|
16208
|
+
ownerId: userId,
|
|
16209
|
+
userId,
|
|
16210
|
+
visibility,
|
|
16211
|
+
members: [userId],
|
|
16212
|
+
categories: {},
|
|
16213
|
+
contents: {},
|
|
16214
|
+
createdAt: now,
|
|
16215
|
+
updatedAt: now,
|
|
16216
|
+
type: "space" /* SPACE */
|
|
16217
|
+
};
|
|
16218
|
+
const spaces = getAllMemberSpaces();
|
|
16219
|
+
const hasSpaceForActor = spaces.some(
|
|
16220
|
+
(membership) => {
|
|
16221
|
+
if (isDeviceLocalOwnerId(userId)) {
|
|
16222
|
+
return isDeviceLocalSpaceMembership(membership);
|
|
15835
16223
|
}
|
|
15836
|
-
|
|
15837
|
-
|
|
16224
|
+
if (isDeviceLocalSpaceMembership(membership)) return false;
|
|
16225
|
+
return membership.userId === userId || membership.ownerId === userId;
|
|
16226
|
+
}
|
|
16227
|
+
);
|
|
16228
|
+
console.info("[space/create] addSpaceAction", {
|
|
16229
|
+
userId,
|
|
16230
|
+
name,
|
|
16231
|
+
visibility,
|
|
16232
|
+
boundFolder,
|
|
16233
|
+
memberSpaceCount: spaces.length,
|
|
16234
|
+
hasSpaceForActor,
|
|
16235
|
+
currentPath: getCurrentPathForLog()
|
|
16236
|
+
});
|
|
16237
|
+
if (!hasSpaceForActor) {
|
|
16238
|
+
const { data: oldItems = [] } = await getUserDataOnce({
|
|
16239
|
+
types: targetTypes,
|
|
16240
|
+
userId,
|
|
16241
|
+
limit: 100,
|
|
16242
|
+
db: extra.db
|
|
16243
|
+
});
|
|
16244
|
+
const hasOldSideData = oldItems.length > 0;
|
|
16245
|
+
if (hasOldSideData) {
|
|
16246
|
+
const contents = {};
|
|
16247
|
+
const updatePromises = [];
|
|
16248
|
+
for (const item of oldItems) {
|
|
16249
|
+
if (!item.id || !item.type) continue;
|
|
16250
|
+
const recordOwner = resolveRecordOwnerUserId(item);
|
|
16251
|
+
if (recordOwner !== userId) continue;
|
|
16252
|
+
const stableContentKey = typeof item.dbKey === "string" && item.dbKey.trim() ? item.dbKey : item.id;
|
|
16253
|
+
contents[stableContentKey] = {
|
|
16254
|
+
title: item.title || "",
|
|
16255
|
+
type: item.type,
|
|
16256
|
+
contentKey: stableContentKey,
|
|
16257
|
+
categoryId: "",
|
|
16258
|
+
pinned: false,
|
|
16259
|
+
createdAt: item.createdAt ?? now,
|
|
16260
|
+
updatedAt: item.updatedAt ?? now,
|
|
16261
|
+
order: item.order
|
|
16262
|
+
};
|
|
16263
|
+
if (item.dbKey) {
|
|
16264
|
+
updatePromises.push(
|
|
16265
|
+
dispatch(
|
|
16266
|
+
patch({
|
|
16267
|
+
dbKey: item.dbKey,
|
|
16268
|
+
changes: { spaceId, updatedAt: now }
|
|
16269
|
+
})
|
|
16270
|
+
)
|
|
16271
|
+
);
|
|
16272
|
+
}
|
|
16273
|
+
}
|
|
16274
|
+
spaceData.contents = contents;
|
|
16275
|
+
await Promise.all(updatePromises);
|
|
16276
|
+
}
|
|
15838
16277
|
}
|
|
16278
|
+
const spaceKey = createSpaceKey.space(spaceId);
|
|
16279
|
+
await dispatch(
|
|
16280
|
+
write({ data: spaceData, customKey: spaceKey, userId })
|
|
16281
|
+
).unwrap();
|
|
16282
|
+
const spaceMemberKey = createSpaceKey.member(userId, spaceId);
|
|
16283
|
+
const spaceMemberData = {
|
|
16284
|
+
dbKey: spaceMemberKey,
|
|
16285
|
+
type: "space" /* SPACE */,
|
|
16286
|
+
userId,
|
|
16287
|
+
role: "owner" /* OWNER */,
|
|
16288
|
+
joinedAt: now,
|
|
16289
|
+
spaceId,
|
|
16290
|
+
spaceName: name,
|
|
16291
|
+
ownerId: userId,
|
|
16292
|
+
visibility,
|
|
16293
|
+
createdAt: nowISO,
|
|
16294
|
+
updatedAt: nowISO
|
|
16295
|
+
};
|
|
16296
|
+
await dispatch(
|
|
16297
|
+
write({ data: spaceMemberData, customKey: spaceMemberKey, userId })
|
|
16298
|
+
).unwrap();
|
|
16299
|
+
return spaceMemberData;
|
|
15839
16300
|
};
|
|
15840
|
-
|
|
15841
|
-
|
|
15842
|
-
|
|
15843
|
-
|
|
16301
|
+
|
|
16302
|
+
// packages/app/favorite/favoriteStore.ts
|
|
16303
|
+
var import_react3 = __toESM(require_react());
|
|
16304
|
+
|
|
16305
|
+
// packages/app/sessionSnapshot.ts
|
|
16306
|
+
var import_react = __toESM(require_react());
|
|
16307
|
+
|
|
16308
|
+
// packages/app/hooks/useHasMounted.ts
|
|
16309
|
+
var import_react2 = __toESM(require_react());
|
|
16310
|
+
|
|
16311
|
+
// packages/app/favorite/favoriteStore.ts
|
|
16312
|
+
var createInitialState = () => ({
|
|
16313
|
+
agentIds: [],
|
|
16314
|
+
contentIds: [],
|
|
16315
|
+
favoritedAtById: {},
|
|
16316
|
+
initialized: false,
|
|
16317
|
+
loading: false,
|
|
16318
|
+
error: null
|
|
16319
|
+
});
|
|
16320
|
+
var state = createInitialState();
|
|
16321
|
+
var listeners = /* @__PURE__ */ new Set();
|
|
16322
|
+
var version = 0;
|
|
16323
|
+
var notify = () => {
|
|
16324
|
+
version += 1;
|
|
16325
|
+
for (const listener of listeners) {
|
|
15844
16326
|
try {
|
|
15845
|
-
|
|
16327
|
+
listener();
|
|
16328
|
+
} catch {
|
|
16329
|
+
}
|
|
16330
|
+
}
|
|
16331
|
+
};
|
|
16332
|
+
function removeFavoriteLocally(payload) {
|
|
16333
|
+
const { targetType, id } = payload;
|
|
16334
|
+
if (targetType === "agent") {
|
|
16335
|
+
state = {
|
|
16336
|
+
...state,
|
|
16337
|
+
agentIds: state.agentIds.filter((item) => item !== id),
|
|
16338
|
+
favoritedAtById: { ...state.favoritedAtById }
|
|
16339
|
+
};
|
|
16340
|
+
delete state.favoritedAtById[id];
|
|
16341
|
+
notify();
|
|
16342
|
+
return;
|
|
16343
|
+
}
|
|
16344
|
+
if (targetType === "doc" || targetType === "page" || targetType === "content") {
|
|
16345
|
+
state = {
|
|
16346
|
+
...state,
|
|
16347
|
+
contentIds: state.contentIds.filter((item) => item !== id),
|
|
16348
|
+
favoritedAtById: { ...state.favoritedAtById }
|
|
16349
|
+
};
|
|
16350
|
+
delete state.favoritedAtById[id];
|
|
16351
|
+
notify();
|
|
16352
|
+
}
|
|
16353
|
+
}
|
|
16354
|
+
|
|
16355
|
+
// packages/app/favorite/deletedFavoriteProjection.ts
|
|
16356
|
+
var resolveDeletedFavoriteProjectionRemoval = (contentKey) => {
|
|
16357
|
+
if (!contentKey) return null;
|
|
16358
|
+
if (isAgentKey(contentKey)) {
|
|
16359
|
+
return { targetType: "agent", id: contentKey };
|
|
16360
|
+
}
|
|
16361
|
+
if (isPageKey(contentKey) || isTableMetaKey(contentKey) || isFileKey(contentKey)) {
|
|
16362
|
+
return { targetType: "content", id: contentKey };
|
|
16363
|
+
}
|
|
16364
|
+
return null;
|
|
16365
|
+
};
|
|
16366
|
+
|
|
16367
|
+
// packages/agent-runtime/deleteAgentLocalCredential.ts
|
|
16368
|
+
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.";
|
|
16369
|
+
var createAgentLocalCredentialBroker = createFileCredentialBroker;
|
|
16370
|
+
function isPublicAgentProjectionKey(dbKey) {
|
|
16371
|
+
const key = asTrimmedString(dbKey);
|
|
16372
|
+
return key.startsWith("agent-pub-");
|
|
16373
|
+
}
|
|
16374
|
+
function extractAgentLocalCredentialRef(record) {
|
|
16375
|
+
if (!record || typeof record !== "object") return null;
|
|
16376
|
+
const value = record.credentialRef;
|
|
16377
|
+
return asOptionalTrimmedString(value) ?? null;
|
|
16378
|
+
}
|
|
16379
|
+
async function deleteAgentLocalCredentialRef(credentialRef, options) {
|
|
16380
|
+
const ref = asTrimmedString(credentialRef);
|
|
16381
|
+
if (!ref) {
|
|
16382
|
+
return { deleted: false, skipped: true };
|
|
16383
|
+
}
|
|
16384
|
+
try {
|
|
16385
|
+
const factory = options?.brokerFactory ?? createAgentLocalCredentialBroker;
|
|
16386
|
+
const broker = factory();
|
|
16387
|
+
await broker.delete(ref);
|
|
16388
|
+
return { deleted: true };
|
|
16389
|
+
} catch {
|
|
16390
|
+
return {
|
|
16391
|
+
deleted: false,
|
|
16392
|
+
warning: AGENT_LOCAL_CREDENTIAL_DELETE_FAILED_MESSAGE
|
|
16393
|
+
};
|
|
16394
|
+
}
|
|
16395
|
+
}
|
|
16396
|
+
|
|
16397
|
+
// packages/app/hooks/deleteDbKey.ts
|
|
16398
|
+
var performDirectDelete = async (dispatch, getState, contentKey, preferredServerOrigin, includeAttachments) => {
|
|
16399
|
+
if (isDialogKey(contentKey)) {
|
|
16400
|
+
await dispatch(
|
|
16401
|
+
deleteDialog({ dialogKey: contentKey, includeAttachments })
|
|
16402
|
+
).unwrap();
|
|
16403
|
+
return;
|
|
16404
|
+
}
|
|
16405
|
+
if (isTableMetaKey(contentKey)) {
|
|
16406
|
+
await dispatch(deleteTable({ dbKey: contentKey })).unwrap();
|
|
16407
|
+
return;
|
|
16408
|
+
}
|
|
16409
|
+
if (isAgentKey(contentKey)) {
|
|
16410
|
+
let credentialRef = null;
|
|
16411
|
+
let credentialSynced = false;
|
|
16412
|
+
if (!isPublicAgentProjectionKey(contentKey)) {
|
|
16413
|
+
try {
|
|
16414
|
+
let record = selectById(getState(), contentKey);
|
|
16415
|
+
if (!record) {
|
|
16416
|
+
try {
|
|
16417
|
+
record = await dispatch(
|
|
16418
|
+
read({
|
|
16419
|
+
dbKey: contentKey,
|
|
16420
|
+
preferredServerOrigin
|
|
16421
|
+
})
|
|
16422
|
+
).unwrap();
|
|
16423
|
+
} catch {
|
|
16424
|
+
record = null;
|
|
16425
|
+
}
|
|
16426
|
+
}
|
|
16427
|
+
credentialRef = extractAgentLocalCredentialRef(record);
|
|
16428
|
+
if (record && typeof record === "object" && "credentialSynced" in record) {
|
|
16429
|
+
credentialSynced = record.credentialSynced === true;
|
|
16430
|
+
}
|
|
16431
|
+
} catch {
|
|
16432
|
+
credentialRef = null;
|
|
16433
|
+
}
|
|
16434
|
+
}
|
|
16435
|
+
await dispatch(
|
|
16436
|
+
remove({
|
|
16437
|
+
dbKey: contentKey,
|
|
16438
|
+
preferredServerOrigin
|
|
16439
|
+
})
|
|
16440
|
+
).unwrap();
|
|
16441
|
+
if (credentialRef) {
|
|
16442
|
+
const cleanup = await deleteAgentLocalCredentialRef(credentialRef);
|
|
16443
|
+
if (!cleanup.deleted && "warning" in cleanup) {
|
|
16444
|
+
console.warn(
|
|
16445
|
+
"[deleteDbKey] local API credential cleanup failed after agent delete:",
|
|
16446
|
+
cleanup.warning
|
|
16447
|
+
);
|
|
16448
|
+
}
|
|
16449
|
+
}
|
|
16450
|
+
if (credentialRef && credentialSynced) {
|
|
16451
|
+
try {
|
|
16452
|
+
const { currentServer, currentToken } = selectRuntimeSnapshot(
|
|
16453
|
+
getState()
|
|
16454
|
+
);
|
|
16455
|
+
if (currentServer && currentToken) {
|
|
16456
|
+
await deleteServerSyncedCredential(
|
|
16457
|
+
{ currentServer, authToken: currentToken },
|
|
16458
|
+
credentialRef
|
|
16459
|
+
);
|
|
16460
|
+
}
|
|
16461
|
+
} catch {
|
|
16462
|
+
}
|
|
16463
|
+
}
|
|
16464
|
+
return;
|
|
16465
|
+
}
|
|
16466
|
+
if (isAppKey(contentKey) || isPageKey(contentKey) || isFileKey(contentKey) || isTaskKey(contentKey)) {
|
|
16467
|
+
await dispatch(
|
|
16468
|
+
remove({
|
|
16469
|
+
dbKey: contentKey,
|
|
16470
|
+
preferredServerOrigin
|
|
16471
|
+
})
|
|
16472
|
+
).unwrap();
|
|
16473
|
+
}
|
|
16474
|
+
};
|
|
16475
|
+
var resolveDeleteInput = (input) => {
|
|
16476
|
+
if (typeof input === "string" && input.trim()) {
|
|
16477
|
+
return { contentKey: input };
|
|
16478
|
+
}
|
|
16479
|
+
if (input && typeof input === "object") {
|
|
16480
|
+
const candidates = [input.contentKey, input.dbKey, input.key];
|
|
16481
|
+
const preferredServerOrigin = asNonEmptyStringArray([
|
|
16482
|
+
input.preferredServerOrigin,
|
|
16483
|
+
input.serverOrigin
|
|
16484
|
+
])[0];
|
|
16485
|
+
const inputSpaceId = typeof input.spaceId === "string" && input.spaceId.trim().length > 0 ? input.spaceId : null;
|
|
16486
|
+
const includeAttachments = input.includeAttachments === true;
|
|
16487
|
+
for (const candidate of candidates) {
|
|
16488
|
+
if (typeof candidate === "string" && candidate.trim()) {
|
|
16489
|
+
return {
|
|
16490
|
+
contentKey: candidate,
|
|
16491
|
+
preferredServerOrigin,
|
|
16492
|
+
inputSpaceId,
|
|
16493
|
+
includeAttachments
|
|
16494
|
+
};
|
|
16495
|
+
}
|
|
16496
|
+
}
|
|
16497
|
+
}
|
|
16498
|
+
throw new Error("Invalid delete key");
|
|
16499
|
+
};
|
|
16500
|
+
var extractDeleteErrorMessage = (error, seen = /* @__PURE__ */ new Set(), depth = 0) => {
|
|
16501
|
+
if (depth > 8) {
|
|
16502
|
+
return null;
|
|
16503
|
+
}
|
|
16504
|
+
if (error instanceof Error && error.message.trim()) {
|
|
16505
|
+
return error.message;
|
|
16506
|
+
}
|
|
16507
|
+
if (typeof error === "string" && error.trim()) {
|
|
16508
|
+
return error;
|
|
16509
|
+
}
|
|
16510
|
+
if (!error || typeof error !== "object") {
|
|
16511
|
+
return null;
|
|
16512
|
+
}
|
|
16513
|
+
if (seen.has(error)) {
|
|
16514
|
+
return null;
|
|
16515
|
+
}
|
|
16516
|
+
seen.add(error);
|
|
16517
|
+
const record = error;
|
|
16518
|
+
const directKeys = ["message", "error", "detail", "title"];
|
|
16519
|
+
for (const key of directKeys) {
|
|
16520
|
+
const value = record[key];
|
|
16521
|
+
if (typeof value === "string" && value.trim()) {
|
|
16522
|
+
return value;
|
|
16523
|
+
}
|
|
16524
|
+
}
|
|
16525
|
+
const nestedKeys = ["payload", "data", "cause"];
|
|
16526
|
+
for (const key of nestedKeys) {
|
|
16527
|
+
const message = extractDeleteErrorMessage(record[key], seen, depth + 1);
|
|
16528
|
+
if (message) {
|
|
16529
|
+
return message;
|
|
16530
|
+
}
|
|
16531
|
+
}
|
|
16532
|
+
if (Array.isArray(record.errors)) {
|
|
16533
|
+
const messages = record.errors.map((item) => extractDeleteErrorMessage(item, seen, depth + 1)).filter((item) => Boolean(item));
|
|
16534
|
+
if (messages.length > 0) {
|
|
16535
|
+
return messages.join("\n");
|
|
16536
|
+
}
|
|
16537
|
+
}
|
|
16538
|
+
try {
|
|
16539
|
+
const serialized = JSON.stringify(error);
|
|
16540
|
+
if (serialized && serialized !== "{}") {
|
|
16541
|
+
return serialized;
|
|
16542
|
+
}
|
|
16543
|
+
} catch {
|
|
16544
|
+
return null;
|
|
16545
|
+
}
|
|
16546
|
+
return null;
|
|
16547
|
+
};
|
|
16548
|
+
var getDeleteErrorMessage = (error, fallback = "Delete failed") => {
|
|
16549
|
+
return extractDeleteErrorMessage(error) ?? fallback;
|
|
16550
|
+
};
|
|
16551
|
+
var normalizeDeleteError = (error) => {
|
|
16552
|
+
if (error instanceof Error && error.message.trim()) {
|
|
16553
|
+
return error;
|
|
16554
|
+
}
|
|
16555
|
+
return new Error(getDeleteErrorMessage(error));
|
|
16556
|
+
};
|
|
16557
|
+
var deleteDbKey = (input, spaceId) => async (dispatch, getState) => {
|
|
16558
|
+
try {
|
|
16559
|
+
const {
|
|
16560
|
+
contentKey,
|
|
16561
|
+
preferredServerOrigin,
|
|
16562
|
+
inputSpaceId,
|
|
16563
|
+
includeAttachments
|
|
16564
|
+
} = resolveDeleteInput(input);
|
|
16565
|
+
const effectiveSpaceId = typeof spaceId === "string" && spaceId.trim().length > 0 ? spaceId : inputSpaceId ?? null;
|
|
16566
|
+
await performDirectDelete(
|
|
16567
|
+
dispatch,
|
|
16568
|
+
getState,
|
|
16569
|
+
contentKey,
|
|
16570
|
+
preferredServerOrigin,
|
|
16571
|
+
includeAttachments
|
|
16572
|
+
);
|
|
16573
|
+
const spaceIds = isAppKey(contentKey) ? /* @__PURE__ */ new Set([
|
|
16574
|
+
effectiveSpaceId,
|
|
16575
|
+
...getAllMemberSpaces().map((space) => space.spaceId)
|
|
16576
|
+
]) : /* @__PURE__ */ new Set([effectiveSpaceId]);
|
|
16577
|
+
await Promise.all(
|
|
16578
|
+
[...spaceIds].filter((spaceId2) => Boolean(spaceId2)).map(
|
|
16579
|
+
(spaceId2) => dispatch(
|
|
16580
|
+
deleteContentFromSpace({
|
|
16581
|
+
contentKey,
|
|
16582
|
+
spaceId: spaceId2,
|
|
16583
|
+
...preferredServerOrigin ? { sourceServerOrigin: preferredServerOrigin } : {}
|
|
16584
|
+
})
|
|
16585
|
+
).unwrap().catch((err) => {
|
|
16586
|
+
console.warn("[deleteDbKey] space cleanup failed (entity already tombstoned):", err);
|
|
16587
|
+
})
|
|
16588
|
+
)
|
|
16589
|
+
);
|
|
16590
|
+
const favoriteProjectionRemoval = resolveDeletedFavoriteProjectionRemoval(contentKey);
|
|
16591
|
+
if (favoriteProjectionRemoval) {
|
|
16592
|
+
removeFavoriteLocally(favoriteProjectionRemoval);
|
|
16593
|
+
}
|
|
16594
|
+
if (typeof window !== "undefined") {
|
|
16595
|
+
window.dispatchEvent(
|
|
16596
|
+
new CustomEvent("nolo-user-data-updated", {
|
|
16597
|
+
detail: { deletedDbKey: contentKey }
|
|
16598
|
+
})
|
|
16599
|
+
);
|
|
16600
|
+
}
|
|
16601
|
+
return true;
|
|
16602
|
+
} catch (error) {
|
|
16603
|
+
throw normalizeDeleteError(error);
|
|
16604
|
+
}
|
|
16605
|
+
};
|
|
16606
|
+
|
|
16607
|
+
// packages/create/space/deleteSpaceAction.ts
|
|
16608
|
+
var getCurrentUserId = (state2) => asOptionalTrimmedString(selectIdentityUserId(state2)) ?? null;
|
|
16609
|
+
var fetchSpaceData = async (spaceId, dispatch) => {
|
|
16610
|
+
const spaceKey = createSpaceKey.space(spaceId);
|
|
16611
|
+
try {
|
|
16612
|
+
return await dispatch(read({
|
|
16613
|
+
dbKey: spaceKey
|
|
16614
|
+
})).unwrap();
|
|
16615
|
+
} catch (error) {
|
|
16616
|
+
console.warn(`Failed to read space ${spaceId}:`, error);
|
|
16617
|
+
return void 0;
|
|
16618
|
+
}
|
|
16619
|
+
};
|
|
16620
|
+
var checkOwnerPermission = (spaceData, accountUserId) => {
|
|
16621
|
+
if (!spaceData) return;
|
|
16622
|
+
if (isDeviceLocalSpaceBody(spaceData)) return;
|
|
16623
|
+
if (!accountUserId) {
|
|
16624
|
+
throw new Error("User is not logged in.");
|
|
16625
|
+
}
|
|
16626
|
+
if (spaceData.ownerId !== accountUserId) {
|
|
16627
|
+
throw new Error("Only owner can delete space");
|
|
16628
|
+
}
|
|
16629
|
+
};
|
|
16630
|
+
var deleteSpaceData = async (spaceId, dispatch) => {
|
|
16631
|
+
const spaceKey = createSpaceKey.space(spaceId);
|
|
16632
|
+
try {
|
|
16633
|
+
await dispatch(remove(spaceKey)).unwrap();
|
|
16634
|
+
} catch (error) {
|
|
16635
|
+
console.warn(`Failed to delete space ${spaceId}:`, error);
|
|
16636
|
+
}
|
|
16637
|
+
};
|
|
16638
|
+
var tombstoneLocalAuthorityRecord = async (dbKey, existing, dispatch) => {
|
|
16639
|
+
const nowIso = (/* @__PURE__ */ new Date()).toISOString();
|
|
16640
|
+
const base = existing && typeof existing === "object" ? { ...existing } : { dbKey };
|
|
16641
|
+
const tombstone = buildTombstoneRecord(
|
|
16642
|
+
{
|
|
16643
|
+
...base,
|
|
16644
|
+
dbKey,
|
|
16645
|
+
userId: DEVICE_LOCAL_OWNER_ID
|
|
16646
|
+
},
|
|
16647
|
+
nowIso
|
|
16648
|
+
);
|
|
16649
|
+
await dispatch(
|
|
16650
|
+
write({
|
|
16651
|
+
data: tombstone,
|
|
16652
|
+
customKey: dbKey,
|
|
16653
|
+
userId: DEVICE_LOCAL_OWNER_ID
|
|
16654
|
+
})
|
|
16655
|
+
).unwrap();
|
|
16656
|
+
};
|
|
16657
|
+
var deleteLocalSpaceAuthority = async (spaceId, spaceData, dispatch) => {
|
|
16658
|
+
const spaceKey = createSpaceKey.space(spaceId);
|
|
16659
|
+
try {
|
|
16660
|
+
await tombstoneLocalAuthorityRecord(
|
|
16661
|
+
spaceKey,
|
|
16662
|
+
spaceData && typeof spaceData === "object" ? spaceData : { dbKey: spaceKey },
|
|
16663
|
+
dispatch
|
|
16664
|
+
);
|
|
16665
|
+
} catch (error) {
|
|
16666
|
+
console.warn(`Failed to tombstone local space ${spaceId}:`, error);
|
|
16667
|
+
throw error;
|
|
16668
|
+
}
|
|
16669
|
+
const memberIds = /* @__PURE__ */ new Set([
|
|
16670
|
+
DEVICE_LOCAL_OWNER_ID,
|
|
16671
|
+
...asTrimmedNonEmptyStringArray(spaceData?.members)
|
|
16672
|
+
]);
|
|
16673
|
+
for (const memberId of memberIds) {
|
|
16674
|
+
const memberKey = createSpaceKey.member(memberId, spaceId);
|
|
16675
|
+
let existingMember = null;
|
|
16676
|
+
try {
|
|
16677
|
+
existingMember = await dispatch(read({ dbKey: memberKey })).unwrap();
|
|
16678
|
+
} catch {
|
|
16679
|
+
existingMember = null;
|
|
16680
|
+
}
|
|
16681
|
+
try {
|
|
16682
|
+
await tombstoneLocalAuthorityRecord(
|
|
16683
|
+
memberKey,
|
|
16684
|
+
existingMember ?? {
|
|
16685
|
+
dbKey: memberKey,
|
|
16686
|
+
type: "space" /* SPACE */,
|
|
16687
|
+
userId: memberId,
|
|
16688
|
+
spaceId: normalizeSpaceId(spaceId)
|
|
16689
|
+
},
|
|
16690
|
+
dispatch
|
|
16691
|
+
);
|
|
16692
|
+
} catch (err) {
|
|
16693
|
+
console.warn(
|
|
16694
|
+
`Failed to tombstone local membership ${memberId} for space ${spaceId}:`,
|
|
16695
|
+
err
|
|
16696
|
+
);
|
|
16697
|
+
}
|
|
16698
|
+
}
|
|
16699
|
+
};
|
|
16700
|
+
var deleteAllMembers = async (spaceData, spaceId, dispatch) => {
|
|
16701
|
+
if (spaceData?.members) {
|
|
16702
|
+
for (const memberId of spaceData.members) {
|
|
16703
|
+
const memberKey = createSpaceKey.member(memberId, spaceId);
|
|
16704
|
+
await dispatch(remove(memberKey)).unwrap().catch(
|
|
16705
|
+
(err) => console.warn(
|
|
16706
|
+
`Failed to delete member ${memberId} for space ${spaceId}:`,
|
|
16707
|
+
err
|
|
16708
|
+
)
|
|
16709
|
+
);
|
|
16710
|
+
}
|
|
16711
|
+
}
|
|
16712
|
+
};
|
|
16713
|
+
var deleteCurrentUserMember = async (userId, spaceId, dispatch) => {
|
|
16714
|
+
const currentUserMemberKey = createSpaceKey.member(userId, spaceId);
|
|
16715
|
+
await dispatch(remove(currentUserMemberKey)).unwrap().catch(
|
|
16716
|
+
(err) => console.warn(
|
|
16717
|
+
`Failed to delete member key for user ${userId} in space ${spaceId}:`,
|
|
16718
|
+
err
|
|
16719
|
+
)
|
|
16720
|
+
);
|
|
16721
|
+
};
|
|
16722
|
+
var resolveDeleteArgs = (input) => {
|
|
16723
|
+
if (typeof input === "string") {
|
|
16724
|
+
return { spaceId: input, strategy: "delete-space-only" };
|
|
16725
|
+
}
|
|
16726
|
+
return {
|
|
16727
|
+
spaceId: input.spaceId,
|
|
16728
|
+
strategy: input.strategy ?? "delete-space-only"
|
|
16729
|
+
};
|
|
16730
|
+
};
|
|
16731
|
+
var isOwnedByUser = (entityKey, entity, userId) => {
|
|
16732
|
+
if (!entityKey || !userId) return false;
|
|
16733
|
+
const keyParts = splitKey(entityKey);
|
|
16734
|
+
const keyedOwner = keyParts[1];
|
|
16735
|
+
if ((isDialogKey(entityKey) || isPageKey(entityKey) || isFileKey(entityKey) || isTableMetaKey(entityKey)) && keyedOwner === userId) {
|
|
16736
|
+
return true;
|
|
16737
|
+
}
|
|
16738
|
+
if ((isAgentKey(entityKey) || isAppKey(entityKey)) && entity?.userId === userId) {
|
|
16739
|
+
return true;
|
|
16740
|
+
}
|
|
16741
|
+
if (entity?.tenantId === userId || entity?.userId === userId || entity?.ownerId === userId) {
|
|
16742
|
+
return true;
|
|
16743
|
+
}
|
|
16744
|
+
return false;
|
|
16745
|
+
};
|
|
16746
|
+
var nextUpdatedAt = (entity) => {
|
|
16747
|
+
const source = entity?.updatedAt ?? entity?.updated_at ?? entity?.createdAt ?? entity?.created ?? Date.now();
|
|
16748
|
+
const timestamp = typeof source === "number" ? source : Date.parse(String(source)) || Date.now();
|
|
16749
|
+
return new Date(Math.max(Date.now(), timestamp + 1)).toISOString();
|
|
16750
|
+
};
|
|
16751
|
+
var listSpaceEntities = async (spaceData, dispatch) => {
|
|
16752
|
+
const results = [];
|
|
16753
|
+
const contents = Object.values(spaceData?.contents ?? {}).filter(Boolean);
|
|
16754
|
+
for (const item of contents) {
|
|
16755
|
+
const entityKey = typeof item.contentKey === "string" ? item.contentKey : "";
|
|
16756
|
+
if (!entityKey) continue;
|
|
16757
|
+
let entity = null;
|
|
16758
|
+
try {
|
|
16759
|
+
entity = await dispatch(read({ dbKey: entityKey })).unwrap();
|
|
16760
|
+
} catch {
|
|
16761
|
+
entity = null;
|
|
16762
|
+
}
|
|
16763
|
+
results.push({ entityKey, entity });
|
|
16764
|
+
}
|
|
16765
|
+
return results;
|
|
16766
|
+
};
|
|
16767
|
+
var clearEntitySpaceIds = async (entities, dispatch) => {
|
|
16768
|
+
await Promise.all(
|
|
16769
|
+
entities.filter(({ entity }) => entity && typeof entity === "object").map(
|
|
16770
|
+
({ entityKey, entity }) => dispatch(
|
|
16771
|
+
patch({
|
|
16772
|
+
dbKey: entityKey,
|
|
16773
|
+
changes: {
|
|
16774
|
+
spaceId: null,
|
|
16775
|
+
updatedAt: nextUpdatedAt(entity)
|
|
16776
|
+
}
|
|
16777
|
+
})
|
|
16778
|
+
).unwrap()
|
|
16779
|
+
)
|
|
16780
|
+
);
|
|
16781
|
+
};
|
|
16782
|
+
var deleteOwnedEntities = async (ownedEntities, dispatch) => {
|
|
16783
|
+
for (const { entityKey } of ownedEntities) {
|
|
16784
|
+
await dispatch(deleteDbKey(entityKey));
|
|
16785
|
+
}
|
|
16786
|
+
};
|
|
16787
|
+
var deleteSpaceAction = async (input, thunkAPI) => {
|
|
16788
|
+
const { dispatch, getState } = thunkAPI;
|
|
16789
|
+
const { spaceId, strategy } = resolveDeleteArgs(input);
|
|
16790
|
+
const accountUserId = getCurrentUserId(getState());
|
|
16791
|
+
const spaceData = await fetchSpaceData(spaceId, dispatch);
|
|
16792
|
+
const isLocalSpace = isDeviceLocalSpaceBody(spaceData);
|
|
16793
|
+
if (!isLocalSpace) {
|
|
16794
|
+
if (!accountUserId) {
|
|
16795
|
+
throw new Error("User is not logged in.");
|
|
16796
|
+
}
|
|
16797
|
+
checkOwnerPermission(spaceData, accountUserId);
|
|
16798
|
+
}
|
|
16799
|
+
const ownershipUserId = isLocalSpace ? DEVICE_LOCAL_OWNER_ID : accountUserId;
|
|
16800
|
+
if (spaceData && strategy !== "delete-space-only") {
|
|
16801
|
+
const allEntities = await listSpaceEntities(spaceData, dispatch);
|
|
16802
|
+
const ownedEntities = allEntities.filter(
|
|
16803
|
+
({ entityKey, entity }) => isOwnedByUser(entityKey, entity, ownershipUserId)
|
|
16804
|
+
);
|
|
16805
|
+
const unownedEntities = allEntities.filter(
|
|
16806
|
+
({ entityKey, entity }) => !isOwnedByUser(entityKey, entity, ownershipUserId)
|
|
16807
|
+
);
|
|
16808
|
+
if (strategy === "move-owned-to-all") {
|
|
16809
|
+
await clearEntitySpaceIds(allEntities, dispatch);
|
|
16810
|
+
} else if (strategy === "delete-owned-content") {
|
|
16811
|
+
await deleteOwnedEntities(ownedEntities, dispatch);
|
|
16812
|
+
await clearEntitySpaceIds(unownedEntities, dispatch);
|
|
16813
|
+
}
|
|
16814
|
+
}
|
|
16815
|
+
if (isLocalSpace) {
|
|
16816
|
+
await deleteLocalSpaceAuthority(spaceId, spaceData, dispatch);
|
|
16817
|
+
} else {
|
|
16818
|
+
await deleteSpaceData(spaceId, dispatch);
|
|
16819
|
+
await deleteAllMembers(spaceData, spaceId, dispatch);
|
|
16820
|
+
await deleteCurrentUserMember(accountUserId, spaceId, dispatch);
|
|
16821
|
+
}
|
|
16822
|
+
return { spaceId, strategy };
|
|
16823
|
+
};
|
|
16824
|
+
|
|
16825
|
+
// packages/create/space/fetchSpaceAction.ts
|
|
16826
|
+
var fetchSpaceAction = async (input, thunkAPI) => {
|
|
16827
|
+
const rawSpaceId = typeof input === "string" ? input : input?.spaceId;
|
|
16828
|
+
const fresh = typeof input === "object" && input !== null ? !!input.fresh : false;
|
|
16829
|
+
const { dispatch } = thunkAPI;
|
|
16830
|
+
if (!rawSpaceId) {
|
|
16831
|
+
throw new Error("spaceId is required");
|
|
16832
|
+
}
|
|
16833
|
+
const spaceId = normalizeSpaceId(rawSpaceId);
|
|
16834
|
+
const spaceKey = createSpaceKey.space(spaceId);
|
|
16835
|
+
const readSpace = async (dbKey) => {
|
|
16836
|
+
try {
|
|
16837
|
+
const { read: read2, readAndWait: readAndWait2 } = await import("./dbSlice-TVX6SN2T.js");
|
|
16838
|
+
if (fresh) {
|
|
16839
|
+
return await dispatch(readAndWait2(dbKey)).unwrap();
|
|
16840
|
+
}
|
|
16841
|
+
return await dispatch(
|
|
16842
|
+
read2({
|
|
16843
|
+
dbKey
|
|
16844
|
+
})
|
|
16845
|
+
).unwrap();
|
|
16846
|
+
} catch {
|
|
16847
|
+
return null;
|
|
16848
|
+
}
|
|
16849
|
+
};
|
|
16850
|
+
const readLocalSpaceBody = async () => {
|
|
16851
|
+
let spaceData2 = await readSpace(spaceKey);
|
|
16852
|
+
if (!spaceData2 && rawSpaceId !== spaceKey) {
|
|
16853
|
+
spaceData2 = await readSpace(rawSpaceId);
|
|
16854
|
+
}
|
|
16855
|
+
if (!spaceData2 || isTombstoneRecord(spaceData2)) {
|
|
16856
|
+
return null;
|
|
16857
|
+
}
|
|
16858
|
+
return spaceData2;
|
|
16859
|
+
};
|
|
16860
|
+
if (fresh) {
|
|
16861
|
+
const localBody = await readLocalSpaceBody();
|
|
16862
|
+
if (localBody && isDeviceLocalSpaceBody(localBody)) {
|
|
16863
|
+
return { spaceId, spaceData: localBody };
|
|
16864
|
+
}
|
|
16865
|
+
const { token, userId, servers } = selectSpaceRemoteAuth(thunkAPI.getState());
|
|
16866
|
+
if (token && userId && servers.length > 0) {
|
|
16867
|
+
const remoteSpace = await fetchAuthoritativeRemoteSpace({
|
|
16868
|
+
servers,
|
|
16869
|
+
token,
|
|
16870
|
+
userId,
|
|
16871
|
+
spaceId
|
|
16872
|
+
});
|
|
16873
|
+
if (remoteSpace) return { spaceId, spaceData: remoteSpace };
|
|
16874
|
+
throw new Error(`Space not found: ${spaceId}`);
|
|
16875
|
+
}
|
|
16876
|
+
if (localBody) {
|
|
16877
|
+
return { spaceId, spaceData: localBody };
|
|
16878
|
+
}
|
|
16879
|
+
throw new Error(`Space not found: ${spaceId}`);
|
|
16880
|
+
}
|
|
16881
|
+
const spaceData = await readLocalSpaceBody();
|
|
16882
|
+
if (!spaceData) {
|
|
16883
|
+
throw new Error(`Space not found: ${spaceId}`);
|
|
16884
|
+
}
|
|
16885
|
+
return { spaceId, spaceData };
|
|
16886
|
+
};
|
|
16887
|
+
|
|
16888
|
+
// packages/create/space/updateSpaceAction.ts
|
|
16889
|
+
var updateSpaceAction = async (input, thunkAPI) => {
|
|
16890
|
+
const { spaceId, name, description, visibility, boundFolder } = input;
|
|
16891
|
+
const { dispatch, getState } = thunkAPI;
|
|
16892
|
+
const state2 = getState();
|
|
16893
|
+
const userId = selectIdentityUserId(state2);
|
|
16894
|
+
const spaceKey = createSpaceKey.space(spaceId);
|
|
16895
|
+
let spaceData = null;
|
|
16896
|
+
try {
|
|
16897
|
+
spaceData = await dispatch(read({
|
|
16898
|
+
dbKey: spaceKey
|
|
16899
|
+
})).unwrap();
|
|
16900
|
+
} catch (readError) {
|
|
16901
|
+
throw new Error(
|
|
16902
|
+
`\u65E0\u6CD5\u52A0\u8F7D\u7A7A\u95F4\u6570\u636E: ${spaceId}, \u539F\u56E0: ${toErrorMessage(readError)}`
|
|
16903
|
+
);
|
|
16904
|
+
}
|
|
16905
|
+
if (!spaceData) {
|
|
16906
|
+
throw new Error(`\u7A7A\u95F4\u4E0D\u5B58\u5728: ${spaceId}`);
|
|
16907
|
+
}
|
|
16908
|
+
if (!userId) {
|
|
16909
|
+
throw new Error("\u7528\u6237\u672A\u767B\u5F55\uFF0C\u65E0\u6CD5\u66F4\u65B0\u7A7A\u95F4\u8BBE\u7F6E\u3002");
|
|
16910
|
+
}
|
|
16911
|
+
if (!spaceData.members || !spaceData.members.includes(userId)) {
|
|
16912
|
+
throw new Error("\u5F53\u524D\u7528\u6237\u4E0D\u662F\u7A7A\u95F4\u6210\u5458\uFF0C\u65E0\u6CD5\u66F4\u65B0\u7A7A\u95F4\u8BBE\u7F6E\u3002");
|
|
16913
|
+
}
|
|
16914
|
+
const changes = {};
|
|
16915
|
+
let hasChanges = false;
|
|
16916
|
+
if (name !== void 0 && name !== spaceData.name) {
|
|
16917
|
+
changes.name = name.trim();
|
|
16918
|
+
hasChanges = true;
|
|
16919
|
+
}
|
|
16920
|
+
if (description !== void 0 && description !== spaceData.description) {
|
|
16921
|
+
changes.description = description;
|
|
16922
|
+
hasChanges = true;
|
|
16923
|
+
}
|
|
16924
|
+
if (visibility !== void 0 && visibility !== spaceData.visibility) {
|
|
16925
|
+
changes.visibility = visibility;
|
|
16926
|
+
hasChanges = true;
|
|
16927
|
+
}
|
|
16928
|
+
if (boundFolder !== void 0 && (boundFolder || void 0) !== (spaceData.boundFolder || void 0)) {
|
|
16929
|
+
changes.boundFolder = boundFolder || void 0;
|
|
16930
|
+
hasChanges = true;
|
|
16931
|
+
}
|
|
16932
|
+
if (!hasChanges) {
|
|
16933
|
+
return { updatedSpace: spaceData, spaceId };
|
|
16934
|
+
}
|
|
16935
|
+
const now = Date.now();
|
|
16936
|
+
changes.updatedAt = now;
|
|
16937
|
+
let updatedSpaceData;
|
|
16938
|
+
try {
|
|
16939
|
+
updatedSpaceData = await dispatch(
|
|
16940
|
+
patch({
|
|
16941
|
+
dbKey: spaceKey,
|
|
16942
|
+
changes
|
|
16943
|
+
})
|
|
16944
|
+
).unwrap();
|
|
16945
|
+
} catch (patchError) {
|
|
16946
|
+
throw new Error(`\u66F4\u65B0\u7A7A\u95F4\u8BBE\u7F6E\u5931\u8D25: ${toErrorMessage(patchError)}`);
|
|
16947
|
+
}
|
|
16948
|
+
if (changes.name !== void 0) {
|
|
16949
|
+
const memberKey = createSpaceKey.member(userId, spaceId);
|
|
16950
|
+
try {
|
|
16951
|
+
const memberData = await dispatch(
|
|
16952
|
+
read({
|
|
16953
|
+
dbKey: memberKey
|
|
16954
|
+
})
|
|
16955
|
+
).unwrap();
|
|
16956
|
+
if (memberData) {
|
|
16957
|
+
const memberChanges = {
|
|
16958
|
+
spaceName: changes.name,
|
|
16959
|
+
updatedAt: now
|
|
16960
|
+
// 为 member 数据也设置 updatedAt
|
|
16961
|
+
};
|
|
16962
|
+
await dispatch(
|
|
16963
|
+
patch({
|
|
16964
|
+
dbKey: memberKey,
|
|
16965
|
+
changes: memberChanges
|
|
16966
|
+
})
|
|
16967
|
+
).unwrap();
|
|
16968
|
+
}
|
|
16969
|
+
} catch (memberError) {
|
|
16970
|
+
console.error(
|
|
16971
|
+
`Failed to update member data ${memberKey} for space name change:`,
|
|
16972
|
+
memberError
|
|
16973
|
+
);
|
|
16974
|
+
}
|
|
16975
|
+
}
|
|
16976
|
+
return {
|
|
16977
|
+
updatedSpace: updatedSpaceData,
|
|
16978
|
+
spaceId
|
|
16979
|
+
};
|
|
16980
|
+
};
|
|
16981
|
+
|
|
16982
|
+
// packages/create/space/fetchSpaceSidebarStateAction.ts
|
|
16983
|
+
var fetchSpaceSidebarStateAction = async (spaceId, thunkAPI) => {
|
|
16984
|
+
const { dispatch, getState } = thunkAPI;
|
|
16985
|
+
const normalizedSpaceId = normalizeSpaceId(spaceId);
|
|
16986
|
+
return {
|
|
16987
|
+
collapsedCategories: typeof window === "undefined" ? {} : readStoredCollapsedCategories(
|
|
16988
|
+
normalizedSpaceId,
|
|
16989
|
+
window.localStorage
|
|
16990
|
+
)
|
|
16991
|
+
};
|
|
16992
|
+
};
|
|
16993
|
+
|
|
16994
|
+
// packages/create/space/applyFetchSpaceFulfilled.ts
|
|
16995
|
+
function applyFetchSpaceFulfilled(payload) {
|
|
16996
|
+
const { spaceId, spaceData } = payload;
|
|
16997
|
+
const currentSpaceId = getCurrentSpaceIdRaw();
|
|
16998
|
+
if (!currentSpaceId || currentSpaceId === spaceId) {
|
|
16999
|
+
setCurrentSpaceBoth(spaceId, spaceData);
|
|
17000
|
+
setSpaceInitialized();
|
|
17001
|
+
}
|
|
17002
|
+
}
|
|
17003
|
+
|
|
17004
|
+
// packages/create/space/changeSpaceAction.ts
|
|
17005
|
+
var getSpaceUpdatedAt2 = (space) => {
|
|
17006
|
+
if (!space) return 0;
|
|
17007
|
+
return toTimestampMs(space.updatedAt);
|
|
17008
|
+
};
|
|
17009
|
+
var changeSpaceAction = async (spaceId, thunkAPI) => {
|
|
17010
|
+
const normalizedSpaceId = normalizeSpaceId(spaceId);
|
|
17011
|
+
const sidebarPromise = fetchSpaceSidebarStateAction(
|
|
17012
|
+
normalizedSpaceId,
|
|
17013
|
+
thunkAPI
|
|
17014
|
+
).catch(() => ({ collapsedCategories: {} }));
|
|
17015
|
+
let spaceData = null;
|
|
17016
|
+
let usedLocal = false;
|
|
17017
|
+
try {
|
|
17018
|
+
const local = await fetchSpaceAction(
|
|
17019
|
+
{ spaceId: normalizedSpaceId, fresh: false },
|
|
17020
|
+
thunkAPI
|
|
17021
|
+
);
|
|
17022
|
+
if (local?.spaceData) {
|
|
17023
|
+
spaceData = local.spaceData;
|
|
17024
|
+
usedLocal = true;
|
|
17025
|
+
}
|
|
17026
|
+
} catch {
|
|
17027
|
+
}
|
|
17028
|
+
if (!spaceData) {
|
|
17029
|
+
const fresh = await fetchSpaceAction(
|
|
17030
|
+
{ spaceId: normalizedSpaceId, fresh: true },
|
|
17031
|
+
thunkAPI
|
|
17032
|
+
);
|
|
17033
|
+
if (!fresh?.spaceData) {
|
|
17034
|
+
throw new Error("\u7A7A\u95F4\u4E0D\u5B58\u5728\u6216\u52A0\u8F7D\u5931\u8D25");
|
|
17035
|
+
}
|
|
17036
|
+
spaceData = fresh.spaceData;
|
|
17037
|
+
} else if (usedLocal) {
|
|
17038
|
+
void fetchSpaceAction({ spaceId: normalizedSpaceId, fresh: true }, thunkAPI).then((result) => {
|
|
17039
|
+
if (!result?.spaceData) return;
|
|
17040
|
+
if (normalizeSpaceId(getCurrentSpaceIdRaw() || "") !== normalizedSpaceId) {
|
|
17041
|
+
return;
|
|
17042
|
+
}
|
|
17043
|
+
if (getSpaceUpdatedAt2(result.spaceData) < getSpaceUpdatedAt2(getCurrentSpaceRaw())) {
|
|
17044
|
+
return;
|
|
17045
|
+
}
|
|
17046
|
+
applyFetchSpaceFulfilled({
|
|
17047
|
+
spaceId: normalizedSpaceId,
|
|
17048
|
+
spaceData: result.spaceData
|
|
17049
|
+
});
|
|
17050
|
+
}).catch(() => {
|
|
17051
|
+
});
|
|
17052
|
+
}
|
|
17053
|
+
const sidebarState = await sidebarPromise;
|
|
17054
|
+
return {
|
|
17055
|
+
spaceId: normalizedSpaceId,
|
|
17056
|
+
spaceData,
|
|
17057
|
+
sidebarState
|
|
17058
|
+
};
|
|
17059
|
+
};
|
|
17060
|
+
|
|
17061
|
+
// packages/create/space/spaceThunks.ts
|
|
17062
|
+
var errorMessage = (error) => error?.message;
|
|
17063
|
+
var fetchSpaceSidebarState = createAsyncThunk(
|
|
17064
|
+
"space/fetchSpaceSidebarState",
|
|
17065
|
+
async (arg, thunkAPI) => {
|
|
17066
|
+
try {
|
|
17067
|
+
const payload = await fetchSpaceSidebarStateAction(arg, thunkAPI);
|
|
17068
|
+
setCollapsedCategories(
|
|
17069
|
+
payload.collapsedCategories,
|
|
17070
|
+
getCurrentSpaceIdRaw()
|
|
17071
|
+
);
|
|
17072
|
+
return payload;
|
|
17073
|
+
} catch (error) {
|
|
17074
|
+
console.error("\u83B7\u53D6\u7A7A\u95F4\u4FA7\u8FB9\u680F\u72B6\u6001\u5931\u8D25:", errorMessage(error));
|
|
17075
|
+
setCollapsedCategories({}, getCurrentSpaceIdRaw());
|
|
17076
|
+
throw error;
|
|
17077
|
+
}
|
|
17078
|
+
}
|
|
17079
|
+
);
|
|
17080
|
+
var changeSpace = createAsyncThunk(
|
|
17081
|
+
"space/changeSpace",
|
|
17082
|
+
async (arg, thunkAPI) => {
|
|
17083
|
+
const newSpaceId = normalizeSpaceId(arg);
|
|
17084
|
+
if (getCurrentSpaceIdRaw() !== newSpaceId) {
|
|
17085
|
+
setMembershipLoading();
|
|
17086
|
+
setCurrentSpace(null);
|
|
17087
|
+
}
|
|
17088
|
+
try {
|
|
17089
|
+
const payload = await changeSpaceAction(arg, thunkAPI);
|
|
17090
|
+
setCurrentSpaceBoth(payload.spaceId, payload.spaceData);
|
|
17091
|
+
setMembershipLoaded();
|
|
17092
|
+
setCollapsedCategories(
|
|
17093
|
+
payload.sidebarState?.collapsedCategories || {},
|
|
17094
|
+
payload.spaceId
|
|
17095
|
+
);
|
|
17096
|
+
return payload;
|
|
17097
|
+
} catch (error) {
|
|
17098
|
+
setMembershipRejected(errorMessage(error) || "\u5207\u6362\u7A7A\u95F4\u5931\u8D25", false);
|
|
17099
|
+
setCurrentSpaceBoth(null, null);
|
|
17100
|
+
setCollapsedCategories({}, null);
|
|
17101
|
+
throw error;
|
|
17102
|
+
}
|
|
17103
|
+
}
|
|
17104
|
+
);
|
|
17105
|
+
var addSpace = createAsyncThunk(
|
|
17106
|
+
"space/addSpace",
|
|
17107
|
+
async (arg, thunkAPI) => {
|
|
17108
|
+
setMembershipLoading();
|
|
17109
|
+
try {
|
|
17110
|
+
const payload = await addSpaceAction(arg, thunkAPI);
|
|
17111
|
+
addMemberSpace(payload);
|
|
17112
|
+
return payload;
|
|
17113
|
+
} catch (error) {
|
|
17114
|
+
setMembershipRejected(errorMessage(error) || "\u6DFB\u52A0\u7A7A\u95F4\u5931\u8D25", false);
|
|
17115
|
+
throw error;
|
|
17116
|
+
}
|
|
17117
|
+
}
|
|
17118
|
+
);
|
|
17119
|
+
var deleteSpace = createAsyncThunk(
|
|
17120
|
+
"space/deleteSpace",
|
|
17121
|
+
async (arg, thunkAPI) => {
|
|
17122
|
+
const payload = await deleteSpaceAction(arg, thunkAPI);
|
|
17123
|
+
const spaceId = typeof payload?.spaceId === "string" ? payload.spaceId : "";
|
|
17124
|
+
const normalizedSpaceId = normalizeSpaceId(spaceId);
|
|
17125
|
+
const currentSpaceId = getCurrentSpaceIdRaw();
|
|
17126
|
+
const normalizedCurrentSpaceId = currentSpaceId ? normalizeSpaceId(currentSpaceId) : null;
|
|
17127
|
+
removeMemberSpace(normalizedSpaceId);
|
|
17128
|
+
if (normalizedCurrentSpaceId === normalizedSpaceId) {
|
|
17129
|
+
setCurrentSpaceBoth(null, null);
|
|
17130
|
+
setCollapsedCategories({}, null);
|
|
17131
|
+
setViewMode("all");
|
|
17132
|
+
}
|
|
17133
|
+
return payload;
|
|
17134
|
+
}
|
|
17135
|
+
);
|
|
17136
|
+
var updateSpace = createAsyncThunk(
|
|
17137
|
+
"space/updateSpace",
|
|
17138
|
+
async (arg, thunkAPI) => {
|
|
17139
|
+
const payload = await updateSpaceAction(arg, thunkAPI);
|
|
17140
|
+
const { updatedSpace, spaceId } = payload;
|
|
17141
|
+
updateCurrentSpaceIfMatch(spaceId, updatedSpace);
|
|
17142
|
+
if (updatedSpace.name) {
|
|
17143
|
+
updateMemberSpaceName(updatedSpace.id, updatedSpace.name);
|
|
17144
|
+
}
|
|
17145
|
+
return payload;
|
|
17146
|
+
}
|
|
17147
|
+
);
|
|
17148
|
+
var fetchSpace = createAsyncThunk(
|
|
17149
|
+
"space/fetchSpace",
|
|
17150
|
+
async (arg, thunkAPI) => {
|
|
17151
|
+
const payload = await fetchSpaceAction(arg, thunkAPI);
|
|
17152
|
+
applyFetchSpaceFulfilled(payload);
|
|
17153
|
+
return payload;
|
|
17154
|
+
}
|
|
17155
|
+
);
|
|
17156
|
+
|
|
17157
|
+
// packages/ai/tools/deleteSpacesToolModel.ts
|
|
17158
|
+
var getSpaceName = (membership, record) => String(
|
|
17159
|
+
membership.spaceName ?? membership.name ?? membership.title ?? record?.name ?? record?.title ?? membership.spaceId ?? ""
|
|
17160
|
+
).trim();
|
|
17161
|
+
var countMembers = (members) => {
|
|
17162
|
+
if (Array.isArray(members)) return members.length;
|
|
17163
|
+
if (members && typeof members === "object") return Object.keys(members).length;
|
|
17164
|
+
return 0;
|
|
17165
|
+
};
|
|
17166
|
+
function filterSpaceDeletionCandidates(memberships, query) {
|
|
17167
|
+
const rawQuery = String(query.query ?? "").trim();
|
|
17168
|
+
if (!rawQuery) return [];
|
|
17169
|
+
const matchMode = query.matchMode ?? "prefix";
|
|
17170
|
+
const normalizedQuery = normalizeSpaceId(rawQuery).toLowerCase();
|
|
17171
|
+
const textQuery = rawQuery.toLowerCase();
|
|
17172
|
+
return memberships.filter((membership) => {
|
|
17173
|
+
const spaceId = normalizeSpaceId(String(membership.spaceId ?? "")).toLowerCase();
|
|
17174
|
+
const name = getSpaceName(membership).toLowerCase();
|
|
17175
|
+
if (matchMode === "spaceId") return spaceId === normalizedQuery;
|
|
17176
|
+
if (matchMode === "exact") return name === textQuery;
|
|
17177
|
+
if (matchMode === "contains") return name.includes(textQuery);
|
|
17178
|
+
return name.startsWith(textQuery);
|
|
17179
|
+
});
|
|
17180
|
+
}
|
|
17181
|
+
function buildDeleteSpacesPreview(args) {
|
|
17182
|
+
const deletable = [];
|
|
17183
|
+
const skipped = [];
|
|
17184
|
+
for (const membership of args.candidates) {
|
|
17185
|
+
const spaceId = normalizeSpaceId(String(membership.spaceId ?? ""));
|
|
17186
|
+
const fallbackName = getSpaceName(membership);
|
|
17187
|
+
if (!spaceId) {
|
|
17188
|
+
skipped.push({
|
|
17189
|
+
spaceId: "",
|
|
17190
|
+
name: fallbackName,
|
|
17191
|
+
reason: "missing_space_id"
|
|
17192
|
+
});
|
|
17193
|
+
continue;
|
|
17194
|
+
}
|
|
17195
|
+
const record = args.spaceRecordsById[spaceId];
|
|
17196
|
+
const name = getSpaceName(membership, record ?? void 0) || spaceId;
|
|
17197
|
+
if (!record) {
|
|
17198
|
+
skipped.push({
|
|
17199
|
+
spaceId,
|
|
17200
|
+
name,
|
|
17201
|
+
reason: "missing_space_record"
|
|
17202
|
+
});
|
|
17203
|
+
continue;
|
|
17204
|
+
}
|
|
17205
|
+
const ownerId = typeof record.ownerId === "string" ? record.ownerId : typeof membership.ownerId === "string" ? membership.ownerId : null;
|
|
17206
|
+
if (ownerId && ownerId !== args.currentUserId) {
|
|
17207
|
+
skipped.push({
|
|
17208
|
+
spaceId,
|
|
17209
|
+
name,
|
|
17210
|
+
reason: "not_owner",
|
|
17211
|
+
ownerId
|
|
17212
|
+
});
|
|
17213
|
+
continue;
|
|
17214
|
+
}
|
|
17215
|
+
deletable.push({
|
|
17216
|
+
spaceId,
|
|
17217
|
+
name,
|
|
17218
|
+
ownerId,
|
|
17219
|
+
memberCount: countMembers(record.members),
|
|
17220
|
+
contentCount: record.contents && typeof record.contents === "object" ? Object.keys(record.contents).length : 0
|
|
17221
|
+
});
|
|
17222
|
+
}
|
|
17223
|
+
return { deletable, skipped };
|
|
17224
|
+
}
|
|
17225
|
+
function resolveConfirmedSpaceDeletionTargets(preview, confirmedSpaceIds) {
|
|
17226
|
+
const wanted = new Set(
|
|
17227
|
+
confirmedSpaceIds.map((spaceId) => normalizeSpaceId(spaceId)).filter(Boolean)
|
|
17228
|
+
);
|
|
17229
|
+
const targets = preview.deletable.filter((item) => wanted.has(item.spaceId));
|
|
17230
|
+
const found = new Set(targets.map((item) => item.spaceId));
|
|
17231
|
+
const missingConfirmedSpaceIds = Array.from(wanted).filter((spaceId) => !found.has(spaceId));
|
|
17232
|
+
return { targets, missingConfirmedSpaceIds };
|
|
17233
|
+
}
|
|
17234
|
+
|
|
17235
|
+
// packages/ai/tools/deleteSpacesTool.ts
|
|
17236
|
+
var deleteSpacesFunctionSchema = {
|
|
17237
|
+
name: "deleteSpaces",
|
|
17238
|
+
description: [
|
|
17239
|
+
"\u6309\u540D\u79F0\u6216 ID \u67E5\u627E\u5E76\u5220\u9664\u5F53\u524D\u7528\u6237\u62E5\u6709\u7684 Space\u3002",
|
|
17240
|
+
"\u8FD9\u662F\u5371\u9669\u64CD\u4F5C\uFF1A\u7B2C\u4E00\u6B21\u8C03\u7528\u4F1A\u8FD4\u56DE\u5F85\u5220\u9664\u5217\u8868\u5E76\u7B49\u5F85\u7528\u6237\u786E\u8BA4\uFF1B\u786E\u8BA4\u540E\u624D\u6267\u884C\u5220\u9664\u3002",
|
|
17241
|
+
"\u9ED8\u8BA4\u53EA\u5220\u9664 Space \u58F3\u548C\u6210\u5458\u5173\u7CFB\uFF0C\u4E0D\u5220\u9664\u5176\u4E2D\u6302\u8F7D\u7684 doc/dialog/file \u5185\u5BB9\u3002",
|
|
17242
|
+
"\u975E owner \u7684 Space \u4F1A\u88AB\u8DF3\u8FC7\uFF0C\u4E0D\u4F1A\u5220\u9664\u3002"
|
|
17243
|
+
].join("\n"),
|
|
17244
|
+
parameters: {
|
|
17245
|
+
type: "object",
|
|
17246
|
+
properties: {
|
|
17247
|
+
query: {
|
|
17248
|
+
type: "string",
|
|
17249
|
+
description: "\u8981\u5220\u9664\u7684 Space \u7B5B\u9009\u8BCD\uFF0C\u4F8B\u5982 rn_owner_verify_0504\uFF0C\u6216\u914D\u5408 matchMode=spaceId \u4F20\u5165 space id\u3002"
|
|
17250
|
+
},
|
|
17251
|
+
matchMode: {
|
|
17252
|
+
type: "string",
|
|
17253
|
+
enum: ["prefix", "exact", "contains", "spaceId"],
|
|
17254
|
+
description: "\u5339\u914D\u65B9\u5F0F\u3002prefix=\u540D\u79F0\u524D\u7F00\uFF0Cexact=\u540D\u79F0\u5B8C\u5168\u5339\u914D\uFF0Ccontains=\u540D\u79F0\u5305\u542B\uFF0CspaceId=\u6309 Space ID \u5339\u914D\u3002\u9ED8\u8BA4 prefix\u3002",
|
|
17255
|
+
default: "prefix"
|
|
17256
|
+
},
|
|
17257
|
+
confirmedSpaceIds: {
|
|
17258
|
+
type: "array",
|
|
17259
|
+
items: { type: "string" },
|
|
17260
|
+
description: "\u53EF\u9009\uFF1A\u786E\u8BA4\u9636\u6BB5\u8981\u5220\u9664\u7684 Space ID \u5217\u8868\u3002\u4E0D\u4F20\u65F6\uFF0C\u7528\u6237\u70B9\u51FB\u786E\u8BA4\u4F1A\u5220\u9664\u9884\u89C8\u5217\u8868\u4E2D\u7684\u5168\u90E8\u53EF\u5220\u9664\u9879\u3002"
|
|
17261
|
+
}
|
|
17262
|
+
},
|
|
17263
|
+
required: ["query"]
|
|
17264
|
+
}
|
|
17265
|
+
};
|
|
17266
|
+
var defaultDeps = {
|
|
17267
|
+
selectCurrentUserId: selectIdentityUserId,
|
|
17268
|
+
selectMemberSpaces: (state2) => getAllMemberSpaces(),
|
|
17269
|
+
readSpaceRecord: async (thunkApi, spaceId) => {
|
|
17270
|
+
try {
|
|
17271
|
+
const record = await thunkApi.dispatch(
|
|
15846
17272
|
read({ dbKey: createSpaceKey.space(spaceId), waitRemote: true })
|
|
15847
17273
|
).unwrap();
|
|
15848
17274
|
return record ?? null;
|
|
@@ -15850,13 +17276,13 @@ var defaultDeps = {
|
|
|
15850
17276
|
return null;
|
|
15851
17277
|
}
|
|
15852
17278
|
},
|
|
15853
|
-
selectDeleteServers: (
|
|
15854
|
-
const { currentServer, remoteServers } = getRuntimeServerContext(
|
|
17279
|
+
selectDeleteServers: (state2) => {
|
|
17280
|
+
const { currentServer, remoteServers } = getRuntimeServerContext(state2);
|
|
15855
17281
|
return remoteServers.length > 0 ? remoteServers : currentServer ? [currentServer] : [];
|
|
15856
17282
|
},
|
|
15857
17283
|
deleteServerKey: async (thunkApi, server, dbKey) => {
|
|
15858
|
-
const
|
|
15859
|
-
const token =
|
|
17284
|
+
const state2 = thunkApi.getState();
|
|
17285
|
+
const token = state2?.auth?.currentToken;
|
|
15860
17286
|
if (!server) {
|
|
15861
17287
|
return { ok: false, status: 0, detail: "missing server" };
|
|
15862
17288
|
}
|
|
@@ -15890,13 +17316,13 @@ var readSpaceRecordsById = async (thunkApi, memberships, deps) => {
|
|
|
15890
17316
|
return recordsById;
|
|
15891
17317
|
};
|
|
15892
17318
|
var loadDeletionContext = async (args, thunkApi, deps) => {
|
|
15893
|
-
const
|
|
15894
|
-
const currentUserId = deps.selectCurrentUserId(
|
|
17319
|
+
const state2 = thunkApi.getState();
|
|
17320
|
+
const currentUserId = deps.selectCurrentUserId(state2);
|
|
15895
17321
|
if (!currentUserId) {
|
|
15896
17322
|
throw new Error("deleteSpaces \u9700\u8981\u5F53\u524D\u767B\u5F55\u7528\u6237\u3002");
|
|
15897
17323
|
}
|
|
15898
|
-
const memberships = deps.selectMemberSpaces(
|
|
15899
|
-
const deleteServers = deps.selectDeleteServers(
|
|
17324
|
+
const memberships = deps.selectMemberSpaces(state2);
|
|
17325
|
+
const deleteServers = deps.selectDeleteServers(state2);
|
|
15900
17326
|
const candidates = filterSpaceDeletionCandidates(memberships, {
|
|
15901
17327
|
query: args.query,
|
|
15902
17328
|
matchMode: args.matchMode
|
|
@@ -16513,8 +17939,8 @@ var extractLegacyValues = (args) => {
|
|
|
16513
17939
|
);
|
|
16514
17940
|
};
|
|
16515
17941
|
async function addTableRowFunc(args, thunkApi) {
|
|
16516
|
-
const
|
|
16517
|
-
const tableState =
|
|
17942
|
+
const state2 = thunkApi.getState();
|
|
17943
|
+
const tableState = state2.table;
|
|
16518
17944
|
const currentTable = tableState.currentTable;
|
|
16519
17945
|
const tenantId = args?.tenantId ?? currentTable?.tenantId;
|
|
16520
17946
|
const tableId = args?.tableId ?? currentTable?.tableId;
|
|
@@ -16926,9 +18352,9 @@ var readSharedTableMeta = async (thunkApi, tableDbKey) => {
|
|
|
16926
18352
|
return result.payload;
|
|
16927
18353
|
};
|
|
16928
18354
|
async function shareTableFunc(args, thunkApi) {
|
|
16929
|
-
const
|
|
16930
|
-
const dialogId =
|
|
16931
|
-
const latestUserInput =
|
|
18355
|
+
const state2 = thunkApi?.getState?.();
|
|
18356
|
+
const dialogId = state2 ? selectCurrentDialogId(state2) : void 0;
|
|
18357
|
+
const latestUserInput = state2 ? selectAllMsgs(state2, dialogId).slice().reverse().find((message) => message?.role === "user" && typeof message?.content === "string")?.content : void 0;
|
|
16932
18358
|
if (!hasExplicitPublicShareRequest(latestUserInput)) {
|
|
16933
18359
|
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
18360
|
}
|
|
@@ -17235,8 +18661,8 @@ var pickRowColumns = (row, columns, options = {}) => {
|
|
|
17235
18661
|
var formatKnownColumns = (tableMeta) => tableMeta.columns.map((column) => column.name).join(", ") || "(\u65E0\u5217\u5B9A\u4E49)";
|
|
17236
18662
|
|
|
17237
18663
|
// packages/ai/tools/table/toolShared.ts
|
|
17238
|
-
var resolveTableIdentity = (args,
|
|
17239
|
-
const currentTable =
|
|
18664
|
+
var resolveTableIdentity = (args, state2) => {
|
|
18665
|
+
const currentTable = state2.table.currentTable;
|
|
17240
18666
|
const tenantId = args.tenantId ?? currentTable?.tenantId;
|
|
17241
18667
|
const tableId = args.tableId ?? currentTable?.tableId;
|
|
17242
18668
|
return { tenantId, tableId, currentTable };
|
|
@@ -17255,8 +18681,8 @@ async function ensureRowsLoaded(thunkApi, tenantId, tableId) {
|
|
|
17255
18681
|
const message = result.payload || result.error?.message || "\u52A0\u8F7D\u8868\u884C\u5931\u8D25";
|
|
17256
18682
|
throw new Error(message);
|
|
17257
18683
|
}
|
|
17258
|
-
const
|
|
17259
|
-
return
|
|
18684
|
+
const state2 = thunkApi.getState();
|
|
18685
|
+
return state2.table.rows.filter(
|
|
17260
18686
|
(row) => row?.tenantId === tenantId && row?.tableId === tableId && !row?.deletedAt
|
|
17261
18687
|
);
|
|
17262
18688
|
}
|
|
@@ -17329,14 +18755,14 @@ var toPreviewJson3 = (value, maxLength = 600) => {
|
|
|
17329
18755
|
return "[\u65E0\u6CD5\u5E8F\u5217\u5316\u4E3A JSON]";
|
|
17330
18756
|
}
|
|
17331
18757
|
};
|
|
17332
|
-
var selectCurrentUserId = (
|
|
18758
|
+
var selectCurrentUserId = (state2) => typeof state2.auth?.currentUser?.userId === "string" ? state2.auth.currentUser.userId : void 0;
|
|
17333
18759
|
var normalizeTableQueryArgs = (args, thunkApi) => {
|
|
17334
|
-
const
|
|
17335
|
-
return buildNoloTableQueryRequest(args ?? {}, selectCurrentUserId(
|
|
18760
|
+
const state2 = thunkApi.getState();
|
|
18761
|
+
return buildNoloTableQueryRequest(args ?? {}, selectCurrentUserId(state2)) ?? args;
|
|
17336
18762
|
};
|
|
17337
18763
|
var requireTableIdentity = (args, thunkApi) => {
|
|
17338
|
-
const
|
|
17339
|
-
const { tenantId, tableId } = resolveTableIdentity(args,
|
|
18764
|
+
const state2 = thunkApi.getState();
|
|
18765
|
+
const { tenantId, tableId } = resolveTableIdentity(args, state2);
|
|
17340
18766
|
if (!tenantId || !tableId) {
|
|
17341
18767
|
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
18768
|
}
|
|
@@ -17664,8 +19090,8 @@ async function deleteTableRowsFunc(args, thunkApi) {
|
|
|
17664
19090
|
|
|
17665
19091
|
// packages/ai/tools/table/schemaTools.ts
|
|
17666
19092
|
var requireTableIdentity2 = (args, thunkApi) => {
|
|
17667
|
-
const
|
|
17668
|
-
const { tenantId, tableId } = resolveTableIdentity(args,
|
|
19093
|
+
const state2 = thunkApi.getState();
|
|
19094
|
+
const { tenantId, tableId } = resolveTableIdentity(args, state2);
|
|
17669
19095
|
if (!tenantId || !tableId) {
|
|
17670
19096
|
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
19097
|
}
|
|
@@ -20360,7 +21786,7 @@ var cloudflareCrawlStatusFunctionSchema = {
|
|
|
20360
21786
|
async function cloudflareCrawlStatusFunc(args, thunkApi) {
|
|
20361
21787
|
const { jobId, limit, status, cursor } = args;
|
|
20362
21788
|
if (!jobId) throw new Error("\u5FC5\u987B\u63D0\u4F9B jobId");
|
|
20363
|
-
const { getToolRequestContext: getToolRequestContext2 } = await import("./toolApiClient-
|
|
21789
|
+
const { getToolRequestContext: getToolRequestContext2 } = await import("./toolApiClient-53U4UDFF.js");
|
|
20364
21790
|
const { baseUrl, token } = getToolRequestContext2(thunkApi);
|
|
20365
21791
|
const params = new URLSearchParams();
|
|
20366
21792
|
if (limit !== void 0) params.set("limit", String(limit));
|
|
@@ -21130,12 +22556,12 @@ function stringifyIfPresent(value) {
|
|
|
21130
22556
|
|
|
21131
22557
|
// packages/ai/tools/geminiImagePreviewTool.ts
|
|
21132
22558
|
var selectCurrentDialogKeyFromState = (_state) => getActiveDialogKey();
|
|
21133
|
-
var selectCurrentSpaceIdFromState = (
|
|
21134
|
-
var selectUserIdFromState = (
|
|
21135
|
-
var selectCurrentServerFromState = (
|
|
22559
|
+
var selectCurrentSpaceIdFromState = (_state) => getCurrentSpaceId();
|
|
22560
|
+
var selectUserIdFromState = (state2) => typeof state2?.auth?.currentUser?.userId === "string" ? state2.auth.currentUser.userId : null;
|
|
22561
|
+
var selectCurrentServerFromState = (state2) => typeof state2?.settings?.currentServer === "string" ? state2.settings.currentServer : null;
|
|
21136
22562
|
async function addImageContentToSpace(input) {
|
|
21137
22563
|
const injectedAddContentAction = input.thunkApi?.extra?.addContentAction;
|
|
21138
|
-
const addContentAction2 = typeof injectedAddContentAction === "function" ? injectedAddContentAction : (await import("./addContentAction-
|
|
22564
|
+
const addContentAction2 = typeof injectedAddContentAction === "function" ? injectedAddContentAction : (await import("./addContentAction-53BZ34AE.js")).addContentAction;
|
|
21139
22565
|
await addContentAction2(
|
|
21140
22566
|
{
|
|
21141
22567
|
spaceId: input.spaceId,
|
|
@@ -21414,8 +22840,8 @@ var createGeminiImageExecutor = (model) => async (args, thunkApi) => {
|
|
|
21414
22840
|
if (!trimmedPrompt) {
|
|
21415
22841
|
throw new Error("prompt \u4E0D\u80FD\u4E3A\u7A7A");
|
|
21416
22842
|
}
|
|
21417
|
-
const
|
|
21418
|
-
const currentDialogKey = selectCurrentDialogKeyFromState(
|
|
22843
|
+
const state2 = thunkApi.getState();
|
|
22844
|
+
const currentDialogKey = selectCurrentDialogKeyFromState(state2);
|
|
21419
22845
|
const dialogId = currentDialogKey ? extractCustomId(currentDialogKey) : void 0;
|
|
21420
22846
|
const result = await callToolApi(
|
|
21421
22847
|
thunkApi,
|
|
@@ -21423,9 +22849,9 @@ var createGeminiImageExecutor = (model) => async (args, thunkApi) => {
|
|
|
21423
22849
|
{ prompt: trimmedPrompt, images, aspectRatio, imageSize, model, dialogId },
|
|
21424
22850
|
{ withAuth: true }
|
|
21425
22851
|
);
|
|
21426
|
-
const spaceId = selectCurrentSpaceIdFromState(
|
|
21427
|
-
const userId = selectUserIdFromState(
|
|
21428
|
-
const currentServer = selectCurrentServerFromState(
|
|
22852
|
+
const spaceId = selectCurrentSpaceIdFromState(state2);
|
|
22853
|
+
const userId = selectUserIdFromState(state2);
|
|
22854
|
+
const currentServer = selectCurrentServerFromState(state2);
|
|
21429
22855
|
if (spaceId && userId && result?.files?.length) {
|
|
21430
22856
|
for (let i = 0; i < result.files.length; i++) {
|
|
21431
22857
|
const f = result.files[i];
|
|
@@ -21579,8 +23005,8 @@ var runOpenAIImageTool = async (args, thunkApi, model) => {
|
|
|
21579
23005
|
if (!trimmedPrompt) {
|
|
21580
23006
|
throw new Error("prompt \u4E0D\u80FD\u4E3A\u7A7A");
|
|
21581
23007
|
}
|
|
21582
|
-
const
|
|
21583
|
-
const currentDialogKey = selectCurrentDialogKey(
|
|
23008
|
+
const state2 = thunkApi.getState();
|
|
23009
|
+
const currentDialogKey = selectCurrentDialogKey(state2);
|
|
21584
23010
|
const dialogId = currentDialogKey ? extractCustomId(currentDialogKey) : void 0;
|
|
21585
23011
|
const result = await callToolApi(
|
|
21586
23012
|
thunkApi,
|
|
@@ -21603,8 +23029,8 @@ var runOpenAIImageTool = async (args, thunkApi, model) => {
|
|
|
21603
23029
|
{ withAuth: true }
|
|
21604
23030
|
);
|
|
21605
23031
|
const spaceId = getCurrentSpaceId();
|
|
21606
|
-
const userId = selectIdentityUserId(
|
|
21607
|
-
const currentServer = selectCurrentServer(
|
|
23032
|
+
const userId = selectIdentityUserId(state2);
|
|
23033
|
+
const currentServer = selectCurrentServer(state2);
|
|
21608
23034
|
if (spaceId && userId && result?.files?.length) {
|
|
21609
23035
|
for (let i = 0; i < result.files.length; i += 1) {
|
|
21610
23036
|
const file = result.files[i];
|
|
@@ -21706,10 +23132,10 @@ var chatgptWebImageGenerateFunc = async (args, thunkApi) => {
|
|
|
21706
23132
|
if (!trimmedPrompt) {
|
|
21707
23133
|
throw new Error("prompt \u4E0D\u80FD\u4E3A\u7A7A");
|
|
21708
23134
|
}
|
|
21709
|
-
const
|
|
21710
|
-
const currentDialogKey = selectCurrentDialogKey(
|
|
23135
|
+
const state2 = thunkApi.getState();
|
|
23136
|
+
const currentDialogKey = selectCurrentDialogKey(state2);
|
|
21711
23137
|
const dialogId = currentDialogKey ? extractCustomId(currentDialogKey) : void 0;
|
|
21712
|
-
const dialogConfig = selectCurrentDialogConfig(
|
|
23138
|
+
const dialogConfig = selectCurrentDialogConfig(state2);
|
|
21713
23139
|
const agentKey = asNonEmptyStringArray(dialogConfig?.cybots)[0];
|
|
21714
23140
|
const result = await callToolApi(
|
|
21715
23141
|
thunkApi,
|
|
@@ -21722,8 +23148,8 @@ var chatgptWebImageGenerateFunc = async (args, thunkApi) => {
|
|
|
21722
23148
|
{ withAuth: true, agentKey }
|
|
21723
23149
|
);
|
|
21724
23150
|
const spaceId = getCurrentSpaceId();
|
|
21725
|
-
const userId = selectIdentityUserId(
|
|
21726
|
-
const currentServer = selectCurrentServer(
|
|
23151
|
+
const userId = selectIdentityUserId(state2);
|
|
23152
|
+
const currentServer = selectCurrentServer(state2);
|
|
21727
23153
|
if (spaceId && userId && result?.files?.length) {
|
|
21728
23154
|
for (let i = 0; i < result.files.length; i += 1) {
|
|
21729
23155
|
const file = result.files[i];
|
|
@@ -21825,10 +23251,10 @@ var remotionRenderVideoFunc = async (args, thunkApi) => {
|
|
|
21825
23251
|
},
|
|
21826
23252
|
{ withAuth: true }
|
|
21827
23253
|
);
|
|
21828
|
-
const
|
|
21829
|
-
const userId = selectIdentityUserId(
|
|
23254
|
+
const state2 = thunkApi.getState();
|
|
23255
|
+
const userId = selectIdentityUserId(state2);
|
|
21830
23256
|
const spaceId = getCurrentSpaceId();
|
|
21831
|
-
const currentServer = selectCurrentServer(
|
|
23257
|
+
const currentServer = selectCurrentServer(state2);
|
|
21832
23258
|
const fileId = result?.fileId;
|
|
21833
23259
|
const metadata = result?.metadata || {};
|
|
21834
23260
|
const fileDbKey = userId && fileId ? fileKey.single(userId, fileId) : "";
|
|
@@ -21884,7 +23310,12 @@ var rememberMemoryFunctionSchema = {
|
|
|
21884
23310
|
"\u628A\u503C\u5F97\u957F\u671F\u8BB0\u4F4F\u7684\u7528\u6237\u504F\u597D\u3001\u7EA0\u6B63\u3001\u51B3\u7B56\u4E60\u60EF\u6216\u5F53\u524D Space \u5171\u8BC6\u5199\u6210\u4E00\u6761 memory\u3002",
|
|
21885
23311
|
"\u9ED8\u8BA4\u503E\u5411\u4E8E\u8BB0\uFF1A\u7528\u6237\u8BF4\u51FA\u300C\u8BB0\u4F4F/\u8BB0\u5F97/\u522B\u5FD8\u4E86/\u4EE5\u540E\u90FD/\u522B\u518D/\u6211\u559C\u6B22/\u6211\u4E0D\u559C\u6B22/\u4E0B\u6B21\u300D\u8FD9\u7C7B\u8BDD\u65F6\uFF0C\u9ED8\u8BA4\u5C31\u8C03\u7528\u672C\u5DE5\u5177\uFF0C\u4E0D\u8981\u53CD\u590D\u81EA\u95EE\u662F\u5426\u591F\u683C\u3002",
|
|
21886
23312
|
"\u4ECD\u7136\u4E0D\u8981\u8BB0\uFF1A\u4E00\u6B21\u6027\u4EFB\u52A1\u7EC6\u8282\u3001\u5F53\u524D\u4EFB\u52A1\u8FDB\u5EA6\u3001\u5F88\u5FEB\u8FC7\u671F\u7684\u4E8B\u5B9E\u3002",
|
|
21887
|
-
"\
|
|
23313
|
+
"\u3010\u6F14\u8FDB\u66F4\u65B0\u3011\u540C\u4E00\u4E8B\u5B9E\u7684\u72B6\u6001/\u7ED3\u8BBA\u53D8\u5316\uFF08\u5982\u300C\u672A push\u2192\u5DF2 push\u300D\u300C\u914D\u989D\u8017\u5C3D\u2192\u5DF2\u6062\u590D\u300D\uFF09\u662F\u66F4\u65B0\u800C\u975E\u65B0\u4E8B\u5B9E\uFF1A\u5199\u5165\u65F6\u7528\u53D6\u4EE3\u540E\u7684\u8868\u8FF0\u4E00\u6B21\u6027\u8BF4\u6E05\uFF1B\u82E5\u672C\u6761\u5DF2\u53D6\u4EE3\u67D0\u6761\u65E7\u8BB0\u5FC6\uFF0C\u8C03\u7528 deleteMemory \u5F52\u6863\u65E7\u6761\uFF0C\u907F\u514D\u540C\u4E3B\u9898\u591A\u7248\u672C\u5E76\u5B58\u3002",
|
|
23314
|
+
"\u3010\u65F6\u6548\u72B6\u6001\u7981\u5165\u3011\u914D\u989D\u4F59\u91CF\u3001\u9650\u6D41\u51B7\u5374\u671F\u9650\u3001\u90E8\u7F72\u5F53\u524D\u72B6\u6001\u7B49\u5F88\u5FEB\u8FC7\u671F\u7684\u5FEB\u7167\u4E0D\u8FDB\u957F\u671F\u8BB0\u5FC6\uFF1B\u8FD9\u7C7B\u4FE1\u606F\u7528\u5B9E\u65F6\u67E5\u8BE2\uFF08\u5982 listAgents\u3001\u90E8\u7F72\u65E5\u5FD7\uFF09\u83B7\u53D6\u5F53\u4E0B\u771F\u503C\uFF0C\u4E0D\u8981\u843D\u8FDB\u8BB0\u5FC6\u3002",
|
|
23315
|
+
"\u3010procedural \u786C\u95E8\u3011kind=procedural \u5FC5\u987B\u540C\u65F6\u4F20 recurrenceEvidence\uFF08\u8BF4\u660E\u540C\u4E00\u95EE\u9898\u6B64\u524D\u5728\u4EC0\u4E48\u65F6\u5019\u9047\u5230\u8FC7\uFF09\uFF1B",
|
|
23316
|
+
"\u7ED9\u4E0D\u51FA\u590D\u73B0\u8BC1\u636E\u7684\u4E00\u5F8B\u6309 episodic \u5B58\u50A8\uFF08\u4E0D\u62A5\u9519\uFF0C\u4F46\u4F60\u4F1A\u5728\u8FD4\u56DE\u503C\u91CC\u770B\u5230\u964D\u7EA7\u63D0\u793A\uFF09\u3002",
|
|
23317
|
+
"\u5224\u636E\uFF1A\u8FD9\u4E2A\u6D41\u7A0B\u4F60**\u81F3\u5C11\u5DF2\u7ECF\u9047\u5230\u8FC7\u4E24\u6B21**\u624D\u7B97 procedural\u3002\u5355\u6B21\u6392\u969C\u5B9E\u5F55\u3001\u67D0\u6B21\u4E8B\u6545\u7684\u5904\u7406\u8FC7\u7A0B\u3001",
|
|
23318
|
+
"\u4E00\u6B21\u6027\u8C03\u7814\u7ED3\u8BBA\u90FD\u4E0D\u662F procedural\u2014\u2014\u54EA\u6015\u5B83\u5199\u5F97\u5F88\u50CF\u64CD\u4F5C\u624B\u518C\uFF0C\u4E5F\u5E94\u8BE5\u7528\u9ED8\u8BA4\u7684 episodic\u3002",
|
|
21888
23319
|
"scope \u6309\u5185\u5BB9\u6027\u8D28\u9009\uFF0C\u4E0D\u56FA\u5B9A\u4F18\u5148\u67D0\u4E00\u5C42\uFF1A",
|
|
21889
23320
|
" - Space \u534F\u4F5C\u7EA6\u5B9A/\u56E2\u961F\u89C4\u5219 \u2192 scope=space\uFF08\u5F53\u524D dialog \u7ED1\u5B9A space \u65F6\uFF09",
|
|
21890
23321
|
" - \u7528\u6237\u4E2A\u4EBA\u8EAB\u4EFD\u6216\u7EAF\u4E2A\u4EBA\u504F\u597D \u2192 scope=user\uFF08\u4E25\u683C\u4FDD\u5B58\u4E3A\u7528\u6237\u4E3B\u4F53\uFF09",
|
|
@@ -21916,7 +23347,11 @@ var rememberMemoryFunctionSchema = {
|
|
|
21916
23347
|
kind: {
|
|
21917
23348
|
type: "string",
|
|
21918
23349
|
enum: ["episodic", "semantic", "procedural"],
|
|
21919
|
-
description: "\u8BB0\u5FC6\u7C7B\u578B\u3002\u9ED8\u8BA4 episodic\u3002\u53EA\u6709\
|
|
23350
|
+
description: "\u8BB0\u5FC6\u7C7B\u578B\u3002\u9ED8\u8BA4 episodic\u3002\u53EA\u6709\u4F60\u81F3\u5C11\u9047\u5230\u8FC7\u4E24\u6B21\u7684\u53EF\u6267\u884C\u6D41\u7A0B/\u7A33\u5B9A runbook \u624D\u7528 procedural\uFF0C\u4E14\u5FC5\u987B\u540C\u65F6\u63D0\u4F9B recurrenceEvidence\uFF0C\u5426\u5219\u4F1A\u88AB\u964D\u7EA7\u4E3A episodic\u3002\u5355\u6B21\u6392\u969C\u5B9E\u5F55\u7528 episodic\u3002"
|
|
23351
|
+
},
|
|
23352
|
+
recurrenceEvidence: {
|
|
23353
|
+
type: "string",
|
|
23354
|
+
description: "kind=procedural \u65F6\u5FC5\u586B\uFF1A\u540C\u4E00\u95EE\u9898\u6B64\u524D\u5728\u4EC0\u4E48\u65F6\u5019\u9047\u5230\u8FC7\uFF08\u65F6\u95F4/\u573A\u666F/\u5BF9\u8BDD\uFF09\uFF0C\u7528\u4E8E\u8BC1\u660E\u5B83\u786E\u5B9E\u91CD\u590D\u51FA\u73B0\u3002\u4F8B\u5982\u201C2026-08-27 \u548C 2026-09-01 \u4E24\u6B21\u90E8\u7F72\u90FD\u5361\u5728\u540C\u4E00\u5904 PM2 \u6B8B\u7559\u5B9E\u4F8B\u201D\u3002\u7F3A\u5931\u5219\u672C\u6761\u964D\u7EA7\u4E3A episodic\u3002"
|
|
21920
23355
|
}
|
|
21921
23356
|
},
|
|
21922
23357
|
required: ["content"]
|
|
@@ -21925,11 +23360,12 @@ var rememberMemoryFunctionSchema = {
|
|
|
21925
23360
|
|
|
21926
23361
|
// packages/ai/tools/rememberMemoryTool.ts
|
|
21927
23362
|
async function rememberMemoryFunc(args, thunkApi) {
|
|
21928
|
-
const
|
|
23363
|
+
const state2 = thunkApi.getState();
|
|
21929
23364
|
const spaceId = getCurrentSpaceId() || void 0;
|
|
21930
23365
|
const content = String(args.content ?? "").trim();
|
|
21931
23366
|
const scope = args.scope ?? "auto";
|
|
21932
23367
|
const kind = args.kind ?? "episodic";
|
|
23368
|
+
const recurrenceEvidence = String(args.recurrenceEvidence ?? "").trim();
|
|
21933
23369
|
if (!content) {
|
|
21934
23370
|
throw new Error("rememberMemory \u9700\u8981\u975E\u7A7A content\u3002");
|
|
21935
23371
|
}
|
|
@@ -21940,14 +23376,20 @@ async function rememberMemoryFunc(args, thunkApi) {
|
|
|
21940
23376
|
content,
|
|
21941
23377
|
scope,
|
|
21942
23378
|
kind,
|
|
21943
|
-
spaceId
|
|
23379
|
+
spaceId,
|
|
23380
|
+
...recurrenceEvidence ? { recurrenceEvidence } : {}
|
|
21944
23381
|
},
|
|
21945
23382
|
{ withAuth: true }
|
|
21946
23383
|
);
|
|
21947
23384
|
const scopeLabel = result.resolvedScopes?.[0]?.ownerType === "space" ? "\u5F53\u524D\u7A7A\u95F4" : "\u5F53\u524D\u7528\u6237";
|
|
23385
|
+
const similar = result.similarMemories ?? [];
|
|
23386
|
+
const similarHint = similar.length ? `
|
|
23387
|
+
\u63D0\u793A\uFF1A\u5DF2\u6709 ${similar.length} \u6761\u8BED\u4E49\u76F8\u8FD1\u7684\u65E2\u6709\u8BB0\u5FC6\uFF08\u5982 ${similar[0].id}\uFF1A"${similar[0].content.slice(0, 48)}\u2026"\uFF09\u3002\u82E5\u672C\u6761\u5DF2\u53D6\u4EE3\u5B83\uFF0C\u8BF7\u8C03\u7528 deleteMemory \u5F52\u6863\u65E7\u6761\uFF0C\u907F\u514D\u540C\u4E3B\u9898\u7248\u672C\u5806\u79EF\u3002` : "";
|
|
23388
|
+
const downgradeHint = result.kindDowngradeReason ? `
|
|
23389
|
+
\u6CE8\u610F\uFF1A${result.kindDowngradeReason}` : "";
|
|
21948
23390
|
return {
|
|
21949
23391
|
rawData: result,
|
|
21950
|
-
displayData: `\u5DF2\u8BB0\u4F4F\u8FD9\u6761${scopeLabel}\u8BB0\u5FC6\u3002`
|
|
23392
|
+
displayData: `\u5DF2\u8BB0\u4F4F\u8FD9\u6761${scopeLabel}\u8BB0\u5FC6\u3002${downgradeHint}${similarHint}`
|
|
21951
23393
|
};
|
|
21952
23394
|
}
|
|
21953
23395
|
|
|
@@ -22089,9 +23531,9 @@ var queryMemoryFunctionSchema = {
|
|
|
22089
23531
|
async function queryMemoryFunc(args, thunkApi) {
|
|
22090
23532
|
const query = String(args.query ?? "").trim();
|
|
22091
23533
|
if (!query) throw new Error("queryMemory \u9700\u8981\u975E\u7A7A query\u3002");
|
|
22092
|
-
const
|
|
23534
|
+
const state2 = thunkApi.getState();
|
|
22093
23535
|
const dialogKey = getActiveDialogKey();
|
|
22094
|
-
const dialog = dialogKey ? selectById(
|
|
23536
|
+
const dialog = dialogKey ? selectById(state2, dialogKey) : null;
|
|
22095
23537
|
const result = await callToolApi(
|
|
22096
23538
|
thunkApi,
|
|
22097
23539
|
"/api/memory/query",
|
|
@@ -22742,21 +24184,21 @@ var updateSelfToolFunctionSchema = {
|
|
|
22742
24184
|
properties: agentUpdateFieldSchemaProperties
|
|
22743
24185
|
}
|
|
22744
24186
|
};
|
|
22745
|
-
var resolveCurrentAgentKey = (
|
|
22746
|
-
const parentMessage = parentMessageId ? selectMsgById(
|
|
24187
|
+
var resolveCurrentAgentKey = (state2, parentMessageId) => {
|
|
24188
|
+
const parentMessage = parentMessageId ? selectMsgById(state2, parentMessageId) : void 0;
|
|
22747
24189
|
const parentAgentKey = resolveMessageAgentKey(parentMessage);
|
|
22748
24190
|
if (parentAgentKey) {
|
|
22749
24191
|
return parentAgentKey;
|
|
22750
24192
|
}
|
|
22751
|
-
const currentDialog = selectCurrentDialogConfig(
|
|
24193
|
+
const currentDialog = selectCurrentDialogConfig(state2);
|
|
22752
24194
|
return asTrimmedNonEmptyStringArray(currentDialog?.cybots)[0];
|
|
22753
24195
|
};
|
|
22754
24196
|
async function updateSelfToolFunc(args, thunkApi, runtime) {
|
|
22755
|
-
const
|
|
22756
|
-
const userId = selectIdentityUserId(
|
|
24197
|
+
const state2 = thunkApi.getState();
|
|
24198
|
+
const userId = selectIdentityUserId(state2);
|
|
22757
24199
|
const db = thunkApi.extra?.db;
|
|
22758
24200
|
validateUpdateArgs(userId);
|
|
22759
|
-
const currentAgentKey = resolveCurrentAgentKey(
|
|
24201
|
+
const currentAgentKey = resolveCurrentAgentKey(state2, runtime?.parentMessageId);
|
|
22760
24202
|
if (!currentAgentKey) {
|
|
22761
24203
|
throw new Error("updateSelf \u5931\u8D25\uFF1A\u65E0\u6CD5\u8BC6\u522B\u5F53\u524D\u6B63\u5728\u8FD0\u884C\u7684 Agent\u3002");
|
|
22762
24204
|
}
|
|
@@ -22765,7 +24207,7 @@ async function updateSelfToolFunc(args, thunkApi, runtime) {
|
|
|
22765
24207
|
throw new Error(`updateSelf \u5931\u8D25\uFF1A\u672A\u627E\u5230\u5F53\u524D Agent\uFF08${currentAgentKey}\uFF09\u3002`);
|
|
22766
24208
|
}
|
|
22767
24209
|
const requestedFields = listRequestedFields(args);
|
|
22768
|
-
const autoApprovedFields = selectAutoApproveSelfUpdateFields(
|
|
24210
|
+
const autoApprovedFields = selectAutoApproveSelfUpdateFields(state2);
|
|
22769
24211
|
assertAgentUpdateConfirmation({
|
|
22770
24212
|
scope: "self",
|
|
22771
24213
|
requestedFields,
|
|
@@ -23130,7 +24572,9 @@ async function listenToDialogEvents(dialogId, currentServer, authHeader, signal,
|
|
|
23130
24572
|
onFailed?.(errMsg);
|
|
23131
24573
|
reader.cancel().catch(() => {
|
|
23132
24574
|
});
|
|
23133
|
-
|
|
24575
|
+
const err2 = new Error(errMsg);
|
|
24576
|
+
err2.name = "AgentRunFailedError";
|
|
24577
|
+
reject(err2);
|
|
23134
24578
|
return;
|
|
23135
24579
|
}
|
|
23136
24580
|
}
|
|
@@ -23146,9 +24590,9 @@ async function listenToDialogEvents(dialogId, currentServer, authHeader, signal,
|
|
|
23146
24590
|
}
|
|
23147
24591
|
var runAgentBackground = createAsyncThunk("agent/runBackground", async (args, { getState, signal: thunkSignal }) => {
|
|
23148
24592
|
const { agentKey, userInput, serverBase, spaceId, parentDialogId, ephemeral, runKind, onStatusChange, onDone, onFailed } = args;
|
|
23149
|
-
const
|
|
23150
|
-
const currentServer = normalizeServerOrigin(serverBase) || selectCurrentServer(
|
|
23151
|
-
const token = selectIdentityToken(
|
|
24593
|
+
const state2 = getState();
|
|
24594
|
+
const currentServer = normalizeServerOrigin(serverBase) || selectCurrentServer(state2);
|
|
24595
|
+
const token = selectIdentityToken(state2);
|
|
23152
24596
|
if (!currentServer) throw new Error("\u672A\u914D\u7F6E\u670D\u52A1\u5668\u5730\u5740");
|
|
23153
24597
|
const authHeader = token ? `Bearer ${token}` : "";
|
|
23154
24598
|
const effectiveSignal = args.signal ?? thunkSignal;
|
|
@@ -23265,58 +24709,64 @@ var runAgentBackground = createAsyncThunk("agent/runBackground", async (args, {
|
|
|
23265
24709
|
});
|
|
23266
24710
|
|
|
23267
24711
|
// packages/ai/tools/agent/startAgentRunTool.ts
|
|
23268
|
-
|
|
23269
|
-
|
|
23270
|
-
|
|
23271
|
-
|
|
23272
|
-
|
|
23273
|
-
|
|
23274
|
-
|
|
23275
|
-
|
|
23276
|
-
|
|
23277
|
-
|
|
23278
|
-
|
|
23279
|
-
|
|
23280
|
-
|
|
23281
|
-
|
|
23282
|
-
|
|
23283
|
-
|
|
23284
|
-
|
|
23285
|
-
|
|
23286
|
-
|
|
23287
|
-
|
|
23288
|
-
|
|
23289
|
-
|
|
23290
|
-
|
|
23291
|
-
|
|
23292
|
-
|
|
23293
|
-
|
|
23294
|
-
|
|
23295
|
-
|
|
23296
|
-
|
|
23297
|
-
|
|
23298
|
-
|
|
23299
|
-
|
|
23300
|
-
|
|
23301
|
-
|
|
23302
|
-
|
|
23303
|
-
|
|
23304
|
-
|
|
23305
|
-
|
|
23306
|
-
|
|
23307
|
-
|
|
23308
|
-
|
|
23309
|
-
|
|
23310
|
-
|
|
24712
|
+
function buildStartAgentRunFunctionSchema(opts) {
|
|
24713
|
+
const supportsWait = opts?.supportsWait !== false;
|
|
24714
|
+
return {
|
|
24715
|
+
name: "startAgentRun",
|
|
24716
|
+
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" + (supportsWait ? "\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" : "\u672C\u5BBF\u4E3B\u53EA\u6709\u5F02\u6B65\u6D3E\u53D1\uFF0C\u6CA1\u6709\u540C\u6B65\u7B49\u5F85\uFF1Arun \u5230\u7EC8\u6001\u4F1A\u81EA\u52A8\u5524\u9192\u5BF9\u8BDD\u628A\u7ED3\u679C\u9001\u56DE\u6765\u3002"),
|
|
24717
|
+
parameters: {
|
|
24718
|
+
type: "object",
|
|
24719
|
+
properties: {
|
|
24720
|
+
agentKey: {
|
|
24721
|
+
type: "string",
|
|
24722
|
+
description: "\u8981\u542F\u52A8\u7684 Agent \u7684\u53EF\u8FD0\u884C dbKey\uFF0C\u5FC5\u987B\u662F listAgents \u8FD4\u56DE\u7684 agentKey \u5B57\u6BB5\uFF08owned: agent-<userId>-<id>\uFF1Bpublic: agent-pub-<id>\uFF09\u6216 readAgent \u8FD4\u56DE\u7684 agentKey\u3002\u53EA\u63A5\u53D7\u7CBE\u786E dbKey\uFF0C\u4E0D\u63A5\u53D7 name/handle/bare id\u3002"
|
|
24723
|
+
},
|
|
24724
|
+
task: {
|
|
24725
|
+
type: "string",
|
|
24726
|
+
description: "\u59D4\u6258\u7ED9\u8BE5 Agent \u7684\u5B50\u4EFB\u52A1\u63CF\u8FF0\uFF08\u81EA\u7136\u8BED\u8A00\uFF09\u3002\u5EFA\u8BAE\u5305\u542B\u5FC5\u8981\u7684\u4E0A\u4E0B\u6587\u8BF4\u660E\u3002"
|
|
24727
|
+
},
|
|
24728
|
+
input: {
|
|
24729
|
+
description: "\u53EF\u9009\u3002JSON \u6216\u5B57\u7B26\u4E32\uFF0C\u4F5C\u4E3A\u672C\u6B21\u5B50\u4EFB\u52A1\u7684\u9644\u52A0\u8F93\u5165\uFF08\u5982\u6293\u53D6\u5230\u7684\u539F\u59CB\u6570\u636E\u3001\u4E0A\u4E0B\u6587\u7247\u6BB5\u7B49\uFF09\u3002"
|
|
24730
|
+
},
|
|
24731
|
+
agentName: {
|
|
24732
|
+
type: "string",
|
|
24733
|
+
description: "\u53EF\u9009\u3002\u7531 listAgents/readAgent \u5F97\u5230\u7684\u53EF\u8BFB Agent \u540D\u79F0\uFF0C\u7528\u4E8E TUI \u8FD0\u884C\u5361\u7247\u5C55\u793A\u3002"
|
|
24734
|
+
},
|
|
24735
|
+
ephemeral: {
|
|
24736
|
+
type: "boolean",
|
|
24737
|
+
description: "\u53EF\u9009\u3002\u4E3A true \u65F6\u672C\u6B21 run \u4E0D\u6301\u4E45\u5316 dialog\uFF08\u4E0D\u7559\u8BB0\u5F55\uFF09\u3002\u7528\u4E8E\u4E00\u6B21\u6027\u5BA1\u67E5\uFF08review\uFF09\u7B49\u4E0D\u9700\u7559\u75D5\u7684\u573A\u666F\u3002\u9ED8\u8BA4 false\u3002"
|
|
24738
|
+
},
|
|
24739
|
+
batchId: {
|
|
24740
|
+
type: "string",
|
|
24741
|
+
description: "\u53EF\u9009\u3002\u6279\u6B21 id\uFF0C\u7528\u4E8E\u628A\u591A\u4E2A\u5E76\u884C run \u5F52\u4E3A\u4E00\u7EC4\uFF0C\u4FBF\u4E8E\u540E\u7EED controlAgentRun(list, batchId=...) \u6309\u6279\u67E5\u8BE2\u3002\u672A\u4F20\u65F6\u81EA\u52A8\u751F\u6210\u4E00\u4E2A\u5E76\u5728\u8FD4\u56DE\u503C\u4E2D\u5E26\u56DE\uFF0C\u8C03\u7528\u65B9\u65E0\u9700\u5148\u521B\u5EFA\u3002"
|
|
24742
|
+
},
|
|
24743
|
+
trackTodo: {
|
|
24744
|
+
type: "boolean",
|
|
24745
|
+
description: '\u53EF\u9009\u3002\u4E3A true \u65F6\u672C\u6B21 run \u4F1A\u88AB\u8BB0\u5F55\u8FDB runtime todo\uFF08~/.nolo/todos.json\uFF09\u3002\u4F20\u4E86 batchId \u65F6\u9ED8\u8BA4\u5373\u8BB0\u5F55\uFF08\u6BCF\u6279\u5BF9\u5E94\u4E00\u9879 todo\uFF09\u3002todo \u72B6\u6001\u7531\u5173\u8054 run \u72B6\u6001 + review \u7ED3\u8BBA\u63A8\u5BFC\uFF0C\u7528 controlAgentRun(action:"todo") \u67E5\u8BE2\u3002'
|
|
24746
|
+
},
|
|
24747
|
+
...supportsWait ? {
|
|
24748
|
+
wait: {
|
|
24749
|
+
type: "boolean",
|
|
24750
|
+
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",
|
|
24751
|
+
default: false
|
|
24752
|
+
},
|
|
24753
|
+
resultMode: {
|
|
24754
|
+
type: "string",
|
|
24755
|
+
enum: ["full", "summary"],
|
|
24756
|
+
default: "full",
|
|
24757
|
+
description: "\u53EF\u9009\u3002full=\u8FD4\u56DE\u5B8C\u6574\u8F93\u51FA\uFF1Bsummary=\u53EA\u8FD4\u56DE\u5B50\u4EFB\u52A1\u603B\u7ED3\uFF08\u622A\u65AD\u4E2D\u95F4\u90E8\u5206\uFF09\u3002\u9ED8\u8BA4 full\u3002"
|
|
24758
|
+
}
|
|
24759
|
+
} : {},
|
|
24760
|
+
parentDialogId: {
|
|
24761
|
+
type: "string",
|
|
24762
|
+
description: "\u53EF\u9009\u3002\u7236\u5BF9\u8BDD id\uFF0C\u7528\u4E8E\u5EFA\u7ACB\u7236\u5B50\u5BF9\u8BDD\u5F52\u5C5E\u5173\u7CFB\u3002\u9ED8\u8BA4\u4ECE\u8FD0\u884C\u65F6\u5F53\u524D\u6FC0\u6D3B\u5BF9\u8BDD\u83B7\u53D6\u3002"
|
|
24763
|
+
}
|
|
23311
24764
|
},
|
|
23312
|
-
|
|
23313
|
-
|
|
23314
|
-
|
|
23315
|
-
|
|
23316
|
-
|
|
23317
|
-
required: ["agentKey", "task"]
|
|
23318
|
-
}
|
|
23319
|
-
};
|
|
24765
|
+
required: ["agentKey", "task"]
|
|
24766
|
+
}
|
|
24767
|
+
};
|
|
24768
|
+
}
|
|
24769
|
+
var startAgentRunFunctionSchema = buildStartAgentRunFunctionSchema();
|
|
23320
24770
|
async function startAgentRunFunc(args, thunkApi, _context) {
|
|
23321
24771
|
const { agentKey, task, input, agentName, ephemeral, batchId, wait } = args;
|
|
23322
24772
|
const resultMode = args.resultMode ?? "full";
|
|
@@ -23393,69 +24843,93 @@ ${text.slice(-SUMMARY_TAIL_CHARS)}`;
|
|
|
23393
24843
|
}
|
|
23394
24844
|
|
|
23395
24845
|
// packages/ai/tools/agent/controlAgentRunTool.ts
|
|
23396
|
-
var
|
|
23397
|
-
|
|
23398
|
-
|
|
23399
|
-
|
|
23400
|
-
|
|
23401
|
-
|
|
23402
|
-
|
|
23403
|
-
|
|
23404
|
-
|
|
23405
|
-
|
|
23406
|
-
|
|
23407
|
-
|
|
23408
|
-
|
|
23409
|
-
|
|
23410
|
-
|
|
23411
|
-
|
|
23412
|
-
|
|
23413
|
-
|
|
23414
|
-
|
|
23415
|
-
|
|
23416
|
-
|
|
23417
|
-
|
|
23418
|
-
|
|
23419
|
-
|
|
23420
|
-
|
|
23421
|
-
|
|
23422
|
-
|
|
23423
|
-
|
|
23424
|
-
|
|
23425
|
-
|
|
23426
|
-
|
|
23427
|
-
|
|
23428
|
-
|
|
23429
|
-
|
|
23430
|
-
|
|
23431
|
-
|
|
23432
|
-
|
|
23433
|
-
|
|
23434
|
-
|
|
23435
|
-
|
|
23436
|
-
|
|
23437
|
-
|
|
23438
|
-
|
|
23439
|
-
|
|
23440
|
-
|
|
23441
|
-
|
|
23442
|
-
|
|
23443
|
-
|
|
23444
|
-
|
|
23445
|
-
|
|
23446
|
-
|
|
23447
|
-
|
|
23448
|
-
|
|
23449
|
-
|
|
24846
|
+
var CONTROL_AGENT_RUN_ACTIONS = [
|
|
24847
|
+
"list",
|
|
24848
|
+
"status",
|
|
24849
|
+
"stop",
|
|
24850
|
+
"todo",
|
|
24851
|
+
"wait",
|
|
24852
|
+
"append"
|
|
24853
|
+
];
|
|
24854
|
+
var ACTION_DESCRIPTIONS = {
|
|
24855
|
+
list: "list=\u5217\u51FA run\uFF08\u7701\u7565 runId\uFF09",
|
|
24856
|
+
status: "status=\u67E5\u5355\u6761 run \u72B6\u6001 + \u53EF\u9009\u65E5\u5FD7",
|
|
24857
|
+
stop: "stop=\u53D6\u6D88 run",
|
|
24858
|
+
append: "append=\u5411\u4EFB\u52A1\u8FFD\u52A0\u6307\u4EE4\uFF08\u8FD0\u884C\u4E2D\u5165\u961F\uFF0C\u7EC8\u6001 continuation\uFF09",
|
|
24859
|
+
wait: "wait=\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",
|
|
24860
|
+
todo: "todo=\u5217\u51FA runtime todo\uFF08\u7531 startAgentRun \u7684 batchId/trackTodo \u4EA7\u751F\uFF09"
|
|
24861
|
+
};
|
|
24862
|
+
function buildControlAgentRunFunctionSchema(opts) {
|
|
24863
|
+
const actions = opts?.actions ?? CONTROL_AGENT_RUN_ACTIONS;
|
|
24864
|
+
const hasWait = actions.includes("wait");
|
|
24865
|
+
const actionList = actions.filter((a) => a !== "todo").join("/");
|
|
24866
|
+
return {
|
|
24867
|
+
name: "controlAgentRun",
|
|
24868
|
+
description: `\u89C2\u5BDF\u548C\u63A7\u5236\u540E\u53F0 agent run\uFF08action\uFF1A${actionList}\uFF0C\u53E6\u6709 todo \u67E5\u8BE2\uFF09\u3002` + (hasWait ? "\u7528 startAgentRun \u62FF\u5230 runId \u540E\u8DDF\u8FDB\u5EA6\u3001\u7B49\u7ED3\u679C\u3001\u8FFD\u52A0\u6307\u4EE4\u6216\u53EB\u505C\u3002" : "\u7528 startAgentRun \u62FF\u5230 runId \u540E\u8DDF\u8FDB\u5EA6\u3001\u8FFD\u52A0\u6307\u4EE4\u6216\u53EB\u505C\u3002") + "\u76EF\u68A2/\u8F6E\u8BE2\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" + (hasWait ? "\u963B\u585E\u7B49\u5F85\uFF08wait action\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 \u65E0\u5E76\u884C\u5DE5\u4F5C\u53EF\u505A\u3002" : "\u672C\u73AF\u5883\u6709\u7EC8\u6001\u5524\u9192\uFF1Arun \u5230\u7EC8\u6001\u4F1A\u81EA\u52A8\u628A\u5BF9\u8BDD\u63A5\u56DE\u6765\uFF0C\u6240\u4EE5\u6CA1\u6709\u963B\u585E\u7B49\u5F85\u52A8\u4F5C\u2014\u2014\u6D3E\u53D1\u540E\u76F4\u63A5\u6536\u5C3E\uFF0C\u4E0D\u8981\u7528\u8FDE\u7EED\u67E5\u72B6\u6001\u4EE3\u66FF\u7B49\u5F85\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",
|
|
24869
|
+
parameters: {
|
|
24870
|
+
type: "object",
|
|
24871
|
+
properties: {
|
|
24872
|
+
action: {
|
|
24873
|
+
type: "string",
|
|
24874
|
+
enum: [...actions],
|
|
24875
|
+
description: actions.map((a) => ACTION_DESCRIPTIONS[a]).join("\uFF1B")
|
|
24876
|
+
},
|
|
24877
|
+
runId: {
|
|
24878
|
+
type: "string",
|
|
24879
|
+
description: "\u76EE\u6807 run \u7684 ID\uFF08startAgentRun \u8FD4\u56DE\u7684 runId\uFF09\u3002action=list \u65F6\u7701\u7565\u3002"
|
|
24880
|
+
},
|
|
24881
|
+
dialogKey: {
|
|
24882
|
+
type: "string",
|
|
24883
|
+
description: "\u53EF\u9009\u3002action=append \u65F6\u76EE\u6807 dialog \u7684 dbKey\uFF08\u5982 dialog-user-xxx\uFF09\u3002\u7F3A\u7701\u65F6\u7531 runId \u63A8\u5BFC\u3002"
|
|
24884
|
+
},
|
|
24885
|
+
userInput: {
|
|
24886
|
+
type: "string",
|
|
24887
|
+
description: "action=append \u65F6\u8FFD\u52A0\u7ED9\u8BE5\u4EFB\u52A1\u7684\u65B0\u6307\u4EE4\u6216\u7EA0\u504F\u6587\u672C\u3002"
|
|
24888
|
+
},
|
|
24889
|
+
mode: {
|
|
24890
|
+
type: "string",
|
|
24891
|
+
enum: ["enqueue", "continue"],
|
|
24892
|
+
description: "\u53EF\u9009\u3002action=append \u65F6\u7684\u8FFD\u52A0\u6A21\u5F0F\uFF1Aenqueue=\u52A0\u5165\u961F\u5217\u4F9B\u4E0B\u4E00\u8F6E\u6D88\u8D39\uFF1Bcontinue=\u7EC8\u6001\u7EED\u8DD1\u3002\u7F3A\u7701\u65F6\u81EA\u52A8\u6839\u636E run \u72B6\u6001\u9002\u914D\u3002"
|
|
24893
|
+
},
|
|
24894
|
+
...hasWait ? {
|
|
24895
|
+
timeoutMs: {
|
|
24896
|
+
type: "number",
|
|
24897
|
+
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',
|
|
24898
|
+
default: 1e5
|
|
24899
|
+
}
|
|
24900
|
+
} : {},
|
|
24901
|
+
tailLines: {
|
|
24902
|
+
type: "number",
|
|
24903
|
+
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",
|
|
24904
|
+
default: 0
|
|
24905
|
+
},
|
|
24906
|
+
batchId: {
|
|
24907
|
+
type: "string",
|
|
24908
|
+
description: "\u53EF\u9009\u3002action=list \u65F6\u53EA\u8FD4\u56DE\u8BE5\u6279\u6B21\u7684 run\uFF08startAgentRun \u8FD4\u56DE\u503C\u6216\u5165\u53C2\u4E2D\u7684 batchId\uFF09\u3002"
|
|
24909
|
+
},
|
|
24910
|
+
status: {
|
|
24911
|
+
type: "string",
|
|
24912
|
+
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"
|
|
24913
|
+
},
|
|
24914
|
+
statusFilter: {
|
|
24915
|
+
type: "string",
|
|
24916
|
+
enum: ["running", "done", "failed", "cancelled", "orphaned", "all"],
|
|
24917
|
+
description: "\u53EF\u9009\u3002action=list \u65F6\u6309\u72B6\u6001\u8FC7\u6EE4\uFF0C\u9ED8\u8BA4 all\u3002\u4E0E status \u540C\u4E49\uFF08status \u4F18\u5148\uFF0C\u4E14 status \u652F\u6301\u591A\u503C\uFF09\u3002"
|
|
24918
|
+
},
|
|
24919
|
+
limit: {
|
|
24920
|
+
type: "number",
|
|
24921
|
+
description: "\u53EF\u9009\u3002action=list \u65F6\u9650\u5236\u8FD4\u56DE\u6570\u91CF\uFF0C\u9ED8\u8BA4 20\uFF0C\u4E0A\u9650 200\u3002\u4E0D\u5E26\u4EFB\u4F55\u53C2\u6570\u4E0D\u4F1A\u8FD4\u56DE\u5168\u91CF\u3002"
|
|
24922
|
+
},
|
|
24923
|
+
offset: {
|
|
24924
|
+
type: "number",
|
|
24925
|
+
description: "\u53EF\u9009\u3002action=list \u65F6\u8DF3\u8FC7\u524D N \u6761\uFF0C\u914D\u5408 limit \u7FFB\u9875\u3002\u9ED8\u8BA4 0\u3002"
|
|
24926
|
+
}
|
|
23450
24927
|
},
|
|
23451
|
-
|
|
23452
|
-
|
|
23453
|
-
|
|
23454
|
-
|
|
23455
|
-
|
|
23456
|
-
required: ["action"]
|
|
23457
|
-
}
|
|
23458
|
-
};
|
|
24928
|
+
required: ["action"]
|
|
24929
|
+
}
|
|
24930
|
+
};
|
|
24931
|
+
}
|
|
24932
|
+
var controlAgentRunFunctionSchema = buildControlAgentRunFunctionSchema();
|
|
23459
24933
|
async function controlAgentRunFunc(args, thunkApi, _context) {
|
|
23460
24934
|
const { action, runId, dialogKey, userInput, mode, tailLines, timeoutMs, batchId, status, statusFilter, limit, offset } = args;
|
|
23461
24935
|
if (action === "list") {
|
|
@@ -23486,9 +24960,9 @@ async function controlAgentRunFunc(args, thunkApi, _context) {
|
|
|
23486
24960
|
if (!runId) {
|
|
23487
24961
|
throw new Error("controlAgentRun(wait): runId is required");
|
|
23488
24962
|
}
|
|
23489
|
-
return handleWait(thunkApi, { runId, timeoutMs });
|
|
24963
|
+
return handleWait(thunkApi, { runId, timeoutMs }, _context);
|
|
23490
24964
|
}
|
|
23491
|
-
throw new Error(`controlAgentRun:
|
|
24965
|
+
throw new Error(`controlAgentRun: \u672A\u77E5 action "${action}"`);
|
|
23492
24966
|
}
|
|
23493
24967
|
async function handleList(thunkApi, opts) {
|
|
23494
24968
|
try {
|
|
@@ -23518,7 +24992,7 @@ async function handleList(thunkApi, opts) {
|
|
|
23518
24992
|
hasMore,
|
|
23519
24993
|
...batchSummary ? { batchSummary } : {}
|
|
23520
24994
|
},
|
|
23521
|
-
displayData: formatListRunsCard(runs
|
|
24995
|
+
displayData: formatListRunsCard(runs)
|
|
23522
24996
|
};
|
|
23523
24997
|
} catch (e) {
|
|
23524
24998
|
throw new Error(`controlAgentRun(list) \u5931\u8D25: ${toErrorMessage(e)}`);
|
|
@@ -23554,7 +25028,7 @@ async function handleStatus(thunkApi, opts) {
|
|
|
23554
25028
|
if (!resData || resData.found === false) {
|
|
23555
25029
|
return {
|
|
23556
25030
|
rawData: { found: false, runId: opts.runId },
|
|
23557
|
-
displayData:
|
|
25031
|
+
displayData: formatNotFoundRunCard()
|
|
23558
25032
|
};
|
|
23559
25033
|
}
|
|
23560
25034
|
const run = resData.run;
|
|
@@ -23596,8 +25070,9 @@ async function handleStop(thunkApi, opts) {
|
|
|
23596
25070
|
}
|
|
23597
25071
|
async function handleAppend(thunkApi, opts) {
|
|
23598
25072
|
try {
|
|
23599
|
-
const
|
|
23600
|
-
const
|
|
25073
|
+
const state2 = thunkApi.getState?.() ?? {};
|
|
25074
|
+
const userId = state2?.identity?.currentUser?.userId ?? state2?.auth?.currentUser?.userId;
|
|
25075
|
+
const resolvedKey = opts.dialogKey || (opts.runId?.startsWith("dialog-") ? opts.runId : opts.runId && userId ? `dialog-${userId}-${opts.runId}` : opts.runId);
|
|
23601
25076
|
if (!resolvedKey) {
|
|
23602
25077
|
throw new Error("dialogKey or runId is required to append an instruction");
|
|
23603
25078
|
}
|
|
@@ -23621,29 +25096,29 @@ async function handleAppend(thunkApi, opts) {
|
|
|
23621
25096
|
throw new Error(`controlAgentRun(append) \u5931\u8D25: ${toErrorMessage(e)}`);
|
|
23622
25097
|
}
|
|
23623
25098
|
}
|
|
23624
|
-
async function handleWait(thunkApi, opts) {
|
|
25099
|
+
async function handleWait(thunkApi, opts, contextOpts) {
|
|
23625
25100
|
const timeoutMs = opts.timeoutMs ?? 1e5;
|
|
23626
25101
|
const requestContext = getToolRequestContext(thunkApi);
|
|
23627
|
-
const serverBase = requestContext
|
|
25102
|
+
const serverBase = requestContext.baseUrl || requestContext.currentServer;
|
|
25103
|
+
const authHeader = requestContext.token ? `Bearer ${requestContext.token}` : "";
|
|
25104
|
+
let cleanupSignal = null;
|
|
23628
25105
|
try {
|
|
23629
25106
|
const initial = await callToolApi(
|
|
23630
25107
|
thunkApi,
|
|
23631
25108
|
"/api/agent/runs/control",
|
|
23632
|
-
{ action: "status", runId: opts.runId
|
|
25109
|
+
{ action: "status", runId: opts.runId },
|
|
23633
25110
|
{ withAuth: true }
|
|
23634
25111
|
);
|
|
23635
|
-
const
|
|
23636
|
-
|
|
23637
|
-
|
|
23638
|
-
|
|
23639
|
-
displayData: `\u672A\u627E\u5230 runId \u4E3A ${opts.runId} \u7684\u8FD0\u884C\u8BB0\u5F55\uFF0C\u65E0\u6CD5\u7B49\u5F85\u3002`
|
|
23640
|
-
};
|
|
25112
|
+
const resData = initial?.data ?? initial;
|
|
25113
|
+
const initialRun = resData?.run;
|
|
25114
|
+
if (!resData || resData.found === false || !initialRun) {
|
|
25115
|
+
throw new Error(`\u7B49\u5F85\u5931\u8D25\uFF1ArunId ${opts.runId} \u4E0D\u5B58\u5728`);
|
|
23641
25116
|
}
|
|
23642
25117
|
const terminalStatuses = ["done", "failed", "cancelled", "orphaned"];
|
|
23643
25118
|
if (terminalStatuses.includes(initialRun.status)) {
|
|
23644
25119
|
const name2 = resolveRunLabel(initialRun);
|
|
23645
25120
|
return {
|
|
23646
|
-
rawData: { found: true, ...initialRun },
|
|
25121
|
+
rawData: { runId: opts.runId, status: initialRun.status, content: initialRun.lastAssistantText, found: true, ...initialRun },
|
|
23647
25122
|
displayData: formatStatusRunCard(name2, initialRun.status, {
|
|
23648
25123
|
runId: opts.runId,
|
|
23649
25124
|
lastToolNames: initialRun.lastToolNames,
|
|
@@ -23654,42 +25129,99 @@ async function handleWait(thunkApi, opts) {
|
|
|
23654
25129
|
})
|
|
23655
25130
|
};
|
|
23656
25131
|
}
|
|
23657
|
-
const
|
|
23658
|
-
|
|
23659
|
-
|
|
23660
|
-
|
|
25132
|
+
const abortController = new AbortController();
|
|
25133
|
+
if (contextOpts?.signal) {
|
|
25134
|
+
if (contextOpts.signal.aborted) {
|
|
25135
|
+
const err = new Error("SSE \u8BA2\u9605\u88AB\u5916\u90E8\u4E2D\u6B62");
|
|
25136
|
+
err.name = "AgentWaitInterruptedError";
|
|
25137
|
+
throw err;
|
|
25138
|
+
}
|
|
25139
|
+
const onAbort = () => abortController.abort();
|
|
25140
|
+
contextOpts.signal.addEventListener("abort", onAbort, { once: true });
|
|
25141
|
+
cleanupSignal = () => {
|
|
25142
|
+
contextOpts.signal?.removeEventListener("abort", onAbort);
|
|
25143
|
+
};
|
|
25144
|
+
}
|
|
25145
|
+
let timer = null;
|
|
25146
|
+
const timeoutPromise = new Promise((resolve) => {
|
|
25147
|
+
timer = setTimeout(() => {
|
|
25148
|
+
abortController.abort();
|
|
25149
|
+
resolve({ isTimeout: true });
|
|
25150
|
+
}, timeoutMs);
|
|
23661
25151
|
});
|
|
23662
|
-
const
|
|
25152
|
+
const listenPromise = listenToDialogEvents(
|
|
25153
|
+
opts.runId,
|
|
25154
|
+
serverBase,
|
|
25155
|
+
authHeader,
|
|
25156
|
+
abortController.signal
|
|
25157
|
+
);
|
|
25158
|
+
let raceResult;
|
|
25159
|
+
try {
|
|
25160
|
+
raceResult = await Promise.race([listenPromise, timeoutPromise]);
|
|
25161
|
+
} catch (e) {
|
|
25162
|
+
if (e?.name === "AgentRunFailedError") {
|
|
25163
|
+
const errMsg = e.message || "\u672A\u77E5\u9519\u8BEF";
|
|
25164
|
+
const name2 = resolveRunLabel(initialRun);
|
|
25165
|
+
return {
|
|
25166
|
+
rawData: {
|
|
25167
|
+
runId: opts.runId,
|
|
25168
|
+
found: true,
|
|
25169
|
+
status: "failed",
|
|
25170
|
+
errorMessage: errMsg
|
|
25171
|
+
},
|
|
25172
|
+
displayData: formatStatusRunCard(name2, "failed", {
|
|
25173
|
+
runId: opts.runId,
|
|
25174
|
+
errorMessage: errMsg
|
|
25175
|
+
})
|
|
25176
|
+
};
|
|
25177
|
+
}
|
|
25178
|
+
throw e;
|
|
25179
|
+
} finally {
|
|
25180
|
+
if (timer) clearTimeout(timer);
|
|
25181
|
+
}
|
|
25182
|
+
if (raceResult && typeof raceResult === "object" && "isTimeout" in raceResult && raceResult.isTimeout) {
|
|
25183
|
+
const rawData2 = {
|
|
25184
|
+
runId: opts.runId,
|
|
25185
|
+
found: true,
|
|
25186
|
+
status: "timeout",
|
|
25187
|
+
waitedMs: timeoutMs
|
|
25188
|
+
};
|
|
25189
|
+
return {
|
|
25190
|
+
rawData: rawData2,
|
|
25191
|
+
displayData: `\u5DF2\u7B49\u5F85 ${timeoutMs}ms\uFF0CrunId: ${opts.runId} \u4ECD\u5728\u8FD0\u884C\u4E2D\uFF08\u672A\u8FBE\u7EC8\u6001\uFF09\u3002\u53EF\u7A0D\u540E\u518D\u6B21 wait \u6216\u6539\u7528 status/stop\u3002`
|
|
25192
|
+
};
|
|
25193
|
+
}
|
|
25194
|
+
if (contextOpts?.signal?.aborted || abortController.signal.aborted && !("isTimeout" in (raceResult ?? {}))) {
|
|
25195
|
+
const err = new Error("SSE \u8BA2\u9605\u88AB\u5916\u90E8\u4E2D\u6B62");
|
|
25196
|
+
err.name = "AgentWaitInterruptedError";
|
|
25197
|
+
throw err;
|
|
25198
|
+
}
|
|
25199
|
+
const res = raceResult;
|
|
25200
|
+
const status = res?.status ?? "done";
|
|
23663
25201
|
const rawData = {
|
|
23664
25202
|
runId: opts.runId,
|
|
23665
25203
|
found: true,
|
|
23666
25204
|
status,
|
|
23667
|
-
|
|
23668
|
-
|
|
25205
|
+
content: res?.content,
|
|
25206
|
+
usage: res?.usage,
|
|
25207
|
+
...res?.errorMessage && { errorMessage: res.errorMessage }
|
|
23669
25208
|
};
|
|
23670
|
-
if (status === "timeout") {
|
|
23671
|
-
return {
|
|
23672
|
-
rawData,
|
|
23673
|
-
displayData: `\u7B49\u5F85\u8D85\u65F6\uFF08\u4E0A\u9650 ${timeoutMs}ms\uFF09\uFF0CrunId: ${opts.runId} \u4ECD\u5728\u8FD0\u884C\u4E2D\u3002\u53EF\u7A0D\u540E\u518D wait \u6216\u6539\u7528 status/stop\u3002`
|
|
23674
|
-
};
|
|
23675
|
-
}
|
|
23676
25209
|
const name = resolveRunLabel(initialRun);
|
|
23677
25210
|
return {
|
|
23678
25211
|
rawData,
|
|
23679
25212
|
displayData: formatStatusRunCard(name, status, {
|
|
23680
25213
|
runId: opts.runId,
|
|
23681
|
-
lastAssistantText:
|
|
23682
|
-
errorMessage:
|
|
25214
|
+
lastAssistantText: res?.content,
|
|
25215
|
+
errorMessage: res?.errorMessage
|
|
23683
25216
|
})
|
|
23684
25217
|
};
|
|
23685
25218
|
} catch (e) {
|
|
23686
|
-
if (isAbortError(e)) {
|
|
23687
|
-
|
|
23688
|
-
rawData: { runId: opts.runId, status: "aborted" },
|
|
23689
|
-
displayData: `\u7B49\u5F85\u5DF2\u4E2D\u65AD\uFF08runId: ${opts.runId}\uFF09\u3002`
|
|
23690
|
-
};
|
|
25219
|
+
if (isAbortError(e) || e?.name === "AgentWaitInterruptedError") {
|
|
25220
|
+
throw e;
|
|
23691
25221
|
}
|
|
23692
25222
|
throw new Error(`controlAgentRun(wait) \u5931\u8D25: ${toErrorMessage(e)}`);
|
|
25223
|
+
} finally {
|
|
25224
|
+
cleanupSignal?.();
|
|
23693
25225
|
}
|
|
23694
25226
|
}
|
|
23695
25227
|
|
|
@@ -24848,14 +26380,14 @@ ${resultStr}
|
|
|
24848
26380
|
}
|
|
24849
26381
|
|
|
24850
26382
|
// packages/ai/tools/toolRunStore.ts
|
|
24851
|
-
var
|
|
26383
|
+
var import_react4 = __toESM(require_react());
|
|
24852
26384
|
var createToolRunId = () => `toolrun_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 8)}`;
|
|
24853
26385
|
var runsById = /* @__PURE__ */ new Map();
|
|
24854
|
-
var
|
|
24855
|
-
var
|
|
24856
|
-
var
|
|
24857
|
-
|
|
24858
|
-
for (const listener of
|
|
26386
|
+
var listeners2 = /* @__PURE__ */ new Set();
|
|
26387
|
+
var version2 = 0;
|
|
26388
|
+
var notify2 = () => {
|
|
26389
|
+
version2 += 1;
|
|
26390
|
+
for (const listener of listeners2) {
|
|
24859
26391
|
try {
|
|
24860
26392
|
listener();
|
|
24861
26393
|
} catch {
|
|
@@ -24888,14 +26420,14 @@ function toolRunStarted(payload) {
|
|
|
24888
26420
|
outputSummary: void 0,
|
|
24889
26421
|
steps: void 0
|
|
24890
26422
|
});
|
|
24891
|
-
|
|
26423
|
+
notify2();
|
|
24892
26424
|
}
|
|
24893
26425
|
function toolRunSetPending(payload) {
|
|
24894
26426
|
const { id } = payload;
|
|
24895
26427
|
const run = runsById.get(id);
|
|
24896
26428
|
if (run) {
|
|
24897
26429
|
run.status = "pending";
|
|
24898
|
-
|
|
26430
|
+
notify2();
|
|
24899
26431
|
}
|
|
24900
26432
|
}
|
|
24901
26433
|
function toolRunSucceeded(payload) {
|
|
@@ -24908,7 +26440,7 @@ function toolRunSucceeded(payload) {
|
|
|
24908
26440
|
run.steps = steps;
|
|
24909
26441
|
}
|
|
24910
26442
|
run.finishedAt = finishedAt ?? Date.now();
|
|
24911
|
-
|
|
26443
|
+
notify2();
|
|
24912
26444
|
}
|
|
24913
26445
|
}
|
|
24914
26446
|
function toolRunUpdated(payload) {
|
|
@@ -24921,7 +26453,7 @@ function toolRunUpdated(payload) {
|
|
|
24921
26453
|
if (steps !== void 0) {
|
|
24922
26454
|
run.steps = steps;
|
|
24923
26455
|
}
|
|
24924
|
-
|
|
26456
|
+
notify2();
|
|
24925
26457
|
}
|
|
24926
26458
|
}
|
|
24927
26459
|
function toolRunFailed(payload) {
|
|
@@ -24937,7 +26469,7 @@ function toolRunFailed(payload) {
|
|
|
24937
26469
|
run.steps = steps;
|
|
24938
26470
|
}
|
|
24939
26471
|
run.finishedAt = finishedAt ?? Date.now();
|
|
24940
|
-
|
|
26472
|
+
notify2();
|
|
24941
26473
|
}
|
|
24942
26474
|
}
|
|
24943
26475
|
function getAllToolRuns() {
|
|
@@ -24957,7 +26489,7 @@ var executeToolRun = createAsyncThunk(
|
|
|
24957
26489
|
if (!executionInput) {
|
|
24958
26490
|
throw new Error(`ToolRun ${id} has no input to execute with.`);
|
|
24959
26491
|
}
|
|
24960
|
-
const { findToolExecutor: findToolExecutor2 } = await import("./tools-
|
|
26492
|
+
const { findToolExecutor: findToolExecutor2 } = await import("./tools-SSXSTC3O.js");
|
|
24961
26493
|
const { executor } = findToolExecutor2(run.toolName);
|
|
24962
26494
|
toolRunStarted({
|
|
24963
26495
|
id: run.id,
|
|
@@ -24981,7 +26513,7 @@ var executeToolRun = createAsyncThunk(
|
|
|
24981
26513
|
const latestState = thunkApi.getState();
|
|
24982
26514
|
const userId = latestState.auth?.currentUser?.userId;
|
|
24983
26515
|
if (userId) {
|
|
24984
|
-
const { fetchUserSpaceMemberships } = await import("./
|
|
26516
|
+
const { fetchUserSpaceMemberships } = await import("./memberThunks-THZYZFSN.js");
|
|
24985
26517
|
await thunkApi.dispatch(fetchUserSpaceMemberships(userId));
|
|
24986
26518
|
}
|
|
24987
26519
|
}
|
|
@@ -25006,9 +26538,9 @@ var executeToolRun = createAsyncThunk(
|
|
|
25006
26538
|
// packages/app/actions/syncAppRecord.ts
|
|
25007
26539
|
var syncAppRecord = (appKey, appRecord, options = {}) => async (_dispatch, getState, extra) => {
|
|
25008
26540
|
if (!appKey || !appRecord) return;
|
|
25009
|
-
const
|
|
25010
|
-
const currentServer = selectCurrentServer(
|
|
25011
|
-
const syncServers = selectSyncServers(
|
|
26541
|
+
const state2 = getState();
|
|
26542
|
+
const currentServer = selectCurrentServer(state2);
|
|
26543
|
+
const syncServers = selectSyncServers(state2) ?? [];
|
|
25012
26544
|
const { db: clientDb } = extra ?? {};
|
|
25013
26545
|
const normalizedRecord = {
|
|
25014
26546
|
...appRecord,
|
|
@@ -25028,7 +26560,7 @@ var syncAppRecord = (appKey, appRecord, options = {}) => async (_dispatch, getSt
|
|
|
25028
26560
|
(server) => noloWriteRequest(
|
|
25029
26561
|
server,
|
|
25030
26562
|
{ data: normalizedRecord, customKey: appKey, userId: normalizedRecord.userId },
|
|
25031
|
-
|
|
26563
|
+
state2
|
|
25032
26564
|
)
|
|
25033
26565
|
)
|
|
25034
26566
|
);
|
|
@@ -25411,7 +26943,7 @@ function decideAppDeploySpaceId(params) {
|
|
|
25411
26943
|
return asOptionalTrimmedString(params.explicitSpaceId) ?? asOptionalTrimmedString(params.currentSpaceId);
|
|
25412
26944
|
}
|
|
25413
26945
|
async function resolveAppDeploySpaceId(args, thunkApi) {
|
|
25414
|
-
const
|
|
26946
|
+
const state2 = thunkApi?.getState?.();
|
|
25415
26947
|
const rawSpaceId = getViewMode() === "all" ? null : getCurrentSpaceIdRaw();
|
|
25416
26948
|
const currentSpaceId = asOptionalTrimmedString(rawSpaceId);
|
|
25417
26949
|
if (!args.appId) {
|
|
@@ -25492,17 +27024,17 @@ function isLikelyReactWorkerMisuse(code) {
|
|
|
25492
27024
|
code
|
|
25493
27025
|
);
|
|
25494
27026
|
}
|
|
25495
|
-
function rewriteAppDeployError(
|
|
25496
|
-
if (
|
|
27027
|
+
function rewriteAppDeployError(errorMessage2, args) {
|
|
27028
|
+
if (errorMessage2.includes("React SPA \u6A21\u5F0F\u5FC5\u987B\u63D0\u4F9B files \u53C2\u6570")) {
|
|
25497
27029
|
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
27030
|
}
|
|
25499
|
-
if (
|
|
27031
|
+
if (errorMessage2.includes("\u9700\u8981\u63D0\u4F9B code \u6216 files \u53C2\u6570")) {
|
|
25500
27032
|
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
27033
|
}
|
|
25502
|
-
if (
|
|
27034
|
+
if (errorMessage2.includes("Bundle failed") && args.framework !== "react-spa" && isLikelyReactWorkerMisuse(args.code)) {
|
|
25503
27035
|
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
27036
|
}
|
|
25505
|
-
return
|
|
27037
|
+
return errorMessage2;
|
|
25506
27038
|
}
|
|
25507
27039
|
function messageContentToText(content) {
|
|
25508
27040
|
if (typeof content === "string") return content;
|
|
@@ -25515,10 +27047,10 @@ function messageContentToText(content) {
|
|
|
25515
27047
|
}
|
|
25516
27048
|
function getLatestUserInputFromThunk(thunkApi) {
|
|
25517
27049
|
try {
|
|
25518
|
-
const
|
|
25519
|
-
if (!
|
|
25520
|
-
const dialogId = selectCurrentDialogId(
|
|
25521
|
-
const messages = selectAllMsgs(
|
|
27050
|
+
const state2 = thunkApi?.getState?.();
|
|
27051
|
+
if (!state2) return void 0;
|
|
27052
|
+
const dialogId = selectCurrentDialogId(state2);
|
|
27053
|
+
const messages = selectAllMsgs(state2, dialogId);
|
|
25522
27054
|
for (let i = messages.length - 1; i >= 0; i -= 1) {
|
|
25523
27055
|
const message = messages[i];
|
|
25524
27056
|
if (message?.role !== "user") continue;
|
|
@@ -26743,7 +28275,7 @@ async function appVersionRestoreFunc(args, thunkApi) {
|
|
|
26743
28275
|
thunkApi,
|
|
26744
28276
|
"/api/version/restore",
|
|
26745
28277
|
{ type: "app", entityId: appId, versionId, restoreMode: restoreMode ?? "source_only" },
|
|
26746
|
-
{ withAuth: true
|
|
28278
|
+
{ withAuth: true }
|
|
26747
28279
|
);
|
|
26748
28280
|
return {
|
|
26749
28281
|
rawData: data,
|
|
@@ -26812,7 +28344,7 @@ var updateContentTitleTool = {
|
|
|
26812
28344
|
};
|
|
26813
28345
|
var updateContentTitleFunc = async (args, thunkApi) => {
|
|
26814
28346
|
const { dispatch, getState } = thunkApi;
|
|
26815
|
-
const
|
|
28347
|
+
const state2 = getState();
|
|
26816
28348
|
const spaceId = getCurrentSpaceId();
|
|
26817
28349
|
const { contentId, title } = args;
|
|
26818
28350
|
console.log(
|
|
@@ -26850,8 +28382,8 @@ var updateContentTitleFunc = async (args, thunkApi) => {
|
|
|
26850
28382
|
};
|
|
26851
28383
|
} catch (error) {
|
|
26852
28384
|
console.error("[updateContentTitleFunc] \u66F4\u65B0\u6807\u9898\u5931\u8D25:", error);
|
|
26853
|
-
const
|
|
26854
|
-
throw new Error(`\u66F4\u65B0\u6807\u9898\u65F6\u51FA\u9519: ${
|
|
28385
|
+
const errorMessage2 = error?.message || JSON.stringify(error) || "\u672A\u77E5\u9519\u8BEF";
|
|
28386
|
+
throw new Error(`\u66F4\u65B0\u6807\u9898\u65F6\u51FA\u9519: ${errorMessage2}`);
|
|
26855
28387
|
}
|
|
26856
28388
|
};
|
|
26857
28389
|
|
|
@@ -27015,9 +28547,9 @@ function buildMyContentItemsFromUserData(records, currentServer, spaceNameById,
|
|
|
27015
28547
|
}
|
|
27016
28548
|
|
|
27017
28549
|
// packages/ai/tools/searchWorkspaceTool.ts
|
|
27018
|
-
var selectCurrentSpaceIdFromState2 = (
|
|
27019
|
-
var selectCurrentSpaceFromState = (
|
|
27020
|
-
var selectAllMemberSpacesFromState = (
|
|
28550
|
+
var selectCurrentSpaceIdFromState2 = (_state) => getCurrentSpaceId();
|
|
28551
|
+
var selectCurrentSpaceFromState = (state2) => selectCurrentSpace(state2);
|
|
28552
|
+
var selectAllMemberSpacesFromState = (state2) => {
|
|
27021
28553
|
const memberSpaces = getAllMemberSpaces();
|
|
27022
28554
|
return [...memberSpaces].sort((a, b) => {
|
|
27023
28555
|
const aUpdatedAt = a.spaceUpdatedAt ?? a.memberUpdatedAt ?? a.updatedAt ?? a.createdAt ?? a.joinedAt ?? 0;
|
|
@@ -27089,8 +28621,8 @@ var buildScopedDisplayData = (query, results, scopeLabel) => {
|
|
|
27089
28621
|
return `\u5728${scopeLabel}\u4E2D\u627E\u5230 ${results.length} \u4E2A\u5339\u914D\u9879\uFF1A
|
|
27090
28622
|
${summary}`;
|
|
27091
28623
|
};
|
|
27092
|
-
var loadLocalMyContentResults = async (thunkApi,
|
|
27093
|
-
const userId =
|
|
28624
|
+
var loadLocalMyContentResults = async (thunkApi, state2) => {
|
|
28625
|
+
const userId = state2.auth?.currentUser?.userId?.trim();
|
|
27094
28626
|
if (!userId) {
|
|
27095
28627
|
throw new Error("\u65E0\u6CD5\u641C\u7D22\u5168\u90E8\u5185\u5BB9\uFF0C\u56E0\u4E3A\u5F53\u524D\u7528\u6237\u672A\u767B\u5F55\u3002");
|
|
27096
28628
|
}
|
|
@@ -27105,13 +28637,13 @@ var loadLocalMyContentResults = async (thunkApi, state) => {
|
|
|
27105
28637
|
const sortedRecords = [...dedupedRecords].sort(
|
|
27106
28638
|
(a, b) => getUserDataItemTimestamp(b) - getUserDataItemTimestamp(a)
|
|
27107
28639
|
);
|
|
27108
|
-
const memberSpaces = selectAllMemberSpacesFromState(
|
|
28640
|
+
const memberSpaces = selectAllMemberSpacesFromState(state2);
|
|
27109
28641
|
const spaceNameById = new Map(
|
|
27110
28642
|
memberSpaces.map((space) => [space.spaceId, space.spaceName || space.spaceId])
|
|
27111
28643
|
);
|
|
27112
28644
|
return buildMyContentItemsFromUserData(
|
|
27113
28645
|
sortedRecords,
|
|
27114
|
-
|
|
28646
|
+
state2.settings?.currentServer || "",
|
|
27115
28647
|
spaceNameById,
|
|
27116
28648
|
"\u6211\u7684\u5E94\u7528",
|
|
27117
28649
|
"\u6211\u7684\u5185\u5BB9"
|
|
@@ -27119,12 +28651,12 @@ var loadLocalMyContentResults = async (thunkApi, state) => {
|
|
|
27119
28651
|
};
|
|
27120
28652
|
async function searchWorkspaceFunc(args, thunkApi) {
|
|
27121
28653
|
const { getState } = thunkApi;
|
|
27122
|
-
const
|
|
27123
|
-
const spaceId = selectCurrentSpaceIdFromState2(
|
|
28654
|
+
const state2 = getState();
|
|
28655
|
+
const spaceId = selectCurrentSpaceIdFromState2(state2);
|
|
27124
28656
|
if (!spaceId) {
|
|
27125
28657
|
throw new Error("\u65E0\u6CD5\u67E5\u8BE2\u5185\u5BB9\uFF0C\u56E0\u4E3A\u5F53\u524D\u7A7A\u95F4\u672A\u8BBE\u5B9A\u3002");
|
|
27126
28658
|
}
|
|
27127
|
-
const currentSpace = selectCurrentSpaceFromState(
|
|
28659
|
+
const currentSpace = selectCurrentSpaceFromState(state2);
|
|
27128
28660
|
if (!currentSpace) {
|
|
27129
28661
|
throw new Error("\u5F53\u524D\u7A7A\u95F4\u6570\u636E\u672A\u627E\u5230\u3002");
|
|
27130
28662
|
}
|
|
@@ -27136,8 +28668,8 @@ async function searchWorkspaceFunc(args, thunkApi) {
|
|
|
27136
28668
|
return { rawData, displayData };
|
|
27137
28669
|
}
|
|
27138
28670
|
async function searchAllSpacesFunc(args, thunkApi) {
|
|
27139
|
-
const
|
|
27140
|
-
const items = await loadLocalMyContentResults(thunkApi,
|
|
28671
|
+
const state2 = thunkApi.getState();
|
|
28672
|
+
const items = await loadLocalMyContentResults(thunkApi, state2);
|
|
27141
28673
|
const results = items.filter((item) => matchesMyContentSearch(args.query, item)).map((item) => toSearchResultItem(item));
|
|
27142
28674
|
return {
|
|
27143
28675
|
rawData: { success: true, contents: results },
|
|
@@ -27293,8 +28825,8 @@ async function fetchDialogMessagesFromServer(args) {
|
|
|
27293
28825
|
}
|
|
27294
28826
|
async function collectBestAvailableDialogMessages(db, dialogId, thunkApi, scanLimit) {
|
|
27295
28827
|
const localMessages = await collectDialogMessages(db, dialogId);
|
|
27296
|
-
const
|
|
27297
|
-
const runtime =
|
|
28828
|
+
const state2 = thunkApi?.getState?.();
|
|
28829
|
+
const runtime = state2 ? selectRuntimeSnapshot(state2) : null;
|
|
27298
28830
|
const serverBases = Array.from(new Set([
|
|
27299
28831
|
runtime?.localRuntimeOrigin,
|
|
27300
28832
|
runtime?.currentServer,
|
|
@@ -27464,7 +28996,7 @@ async function updateDocFunc(args, thunkApi) {
|
|
|
27464
28996
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
27465
28997
|
};
|
|
27466
28998
|
await dispatch(write({ data: updatedPageData, customKey: id })).unwrap();
|
|
27467
|
-
const { getDocState, applyExternalDocUpdate } = await import("./docStore-
|
|
28999
|
+
const { getDocState, applyExternalDocUpdate } = await import("./docStore-2URPBVCS.js");
|
|
27468
29000
|
if (getDocState().pageKey === id) {
|
|
27469
29001
|
applyExternalDocUpdate({
|
|
27470
29002
|
slateData: finalSlateData,
|
|
@@ -27489,7 +29021,7 @@ async function updateDocFunc(args, thunkApi) {
|
|
|
27489
29021
|
// packages/ai/tools/updateUserPreferenceProfileTool.ts
|
|
27490
29022
|
async function dispatchSetSettings(thunkApi, changes) {
|
|
27491
29023
|
const injectedSetSettings = thunkApi?.extra?.setSettings;
|
|
27492
|
-
const setSettings = typeof injectedSetSettings === "function" ? injectedSetSettings : (await import("./settingSlice-
|
|
29024
|
+
const setSettings = typeof injectedSetSettings === "function" ? injectedSetSettings : (await import("./settingSlice-VR2IJSXC.js")).setSettings;
|
|
27493
29025
|
await thunkApi.dispatch(setSettings(changes)).unwrap();
|
|
27494
29026
|
}
|
|
27495
29027
|
var updateUserPreferenceProfileFunctionSchema = {
|
|
@@ -29760,6 +31292,10 @@ export {
|
|
|
29760
31292
|
readXhsProfileFunc,
|
|
29761
31293
|
rememberMemoryFunctionSchema,
|
|
29762
31294
|
deleteMemoryFunctionSchema,
|
|
31295
|
+
queryMemoryFunctionSchema,
|
|
31296
|
+
buildStartAgentRunFunctionSchema,
|
|
31297
|
+
CONTROL_AGENT_RUN_ACTIONS,
|
|
31298
|
+
buildControlAgentRunFunctionSchema,
|
|
29763
31299
|
setTodoListFunc,
|
|
29764
31300
|
TOOL_GROUP_META,
|
|
29765
31301
|
toolQueryFunctionSchema,
|