nolo-cli 0.213.0 → 0.220.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/README.md +3 -2
- package/{_executeModel-CUJLCFWR.js → _executeModel-BNEMFCAO.js} +125 -96
- package/{accountResolver-4LKIHEKL.js → accountResolver-QETKNC7T.js} +4 -4
- package/{action-DF5UYSJF.js → action-GDZDXPMB.js} +14 -13
- package/{addContentAction-WERAONNY.js → addContentAction-7RO4AMRI.js} +21 -20
- package/{addDialogAgentAction-7VI7YRML.js → addDialogAgentAction-EVYBGTXB.js} +26 -25
- package/{agentDeleteCommand-XJORXPGU.js → agentDeleteCommand-7QTQNFCO.js} +145 -137
- package/{agentEmailCommands-XTYYFR6Z.js → agentEmailCommands-I7SHOSD6.js} +146 -139
- package/{agentFavoriteCommands-EDK743YA.js → agentFavoriteCommands-7LOP3HUD.js} +11 -12
- package/{agentGrantCommands-RQWK2TEV.js → agentGrantCommands-L6O2HVJI.js} +9 -9
- package/{agentListCommands-OBLRBLHS.js → agentListCommands-GUGMORTK.js} +180 -103
- package/{agentMachineCommands-5FMT3OT5.js → agentMachineCommands-UMDKILU3.js} +75 -66
- package/{agentProviderCommands-Q5O33MED.js → agentProviderCommands-STI3DQ6A.js} +8 -8
- package/{agentPullCommand-6EM3URVK.js → agentPullCommand-KHV4EELF.js} +11 -11
- package/agentRecordCommands-YTAMTHOY.js +175 -0
- package/agentRunCommand-DBM6YNO6.js +207 -0
- package/{agentRunControl-TAMHJQSR.js → agentRunControl-MBG4U6SL.js} +40 -19
- package/{agentRuntimeLocal-SOO2OPJG.js → agentRuntimeLocal-TU4LA353.js} +55 -48
- package/{agentSlice-CHR6KOZN.js → agentSlice-DPG7Q7IA.js} +24 -23
- package/{appDeleteCommands-GUP6P5YE.js → appDeleteCommands-JWP3XPUA.js} +67 -58
- package/{appDeployCommands-MH2FX4O5.js → appDeployCommands-6E4TQCWI.js} +67 -58
- package/{appDeployStatusCommands-SUHN3HPJ.js → appDeployStatusCommands-ALU4SADG.js} +67 -58
- package/{appGetCommands-YWDEX6Z4.js → appGetCommands-JEY4L6L4.js} +67 -58
- package/{appListCommands-ZQVMLPAY.js → appListCommands-PCAVHU7M.js} +67 -58
- package/{authCommand-PWX2ZNUP.js → authCommand-CGRIIOOV.js} +37 -33
- package/{authCommands-HV3EAU3V.js → authCommands-55OGQGCR.js} +16 -12
- package/{builtinSkillRegistry-2QETTQPM.js → builtinSkillRegistry-BAE2LDXF.js} +11 -13
- package/{chromeCommands-REEAH4SX.js → chromeCommands-G5UDKVSV.js} +3 -3
- package/{chromeOpsCommands-DIVM2K3T.js → chromeOpsCommands-WAA45NCS.js} +23 -13
- package/{chunk-VNYYOX3V.js → chunk-262R3XNN.js} +157 -50
- package/chunk-2MCB7CD7.js +98 -0
- package/{chunk-CTPXME7U.js → chunk-2NPD3FTX.js} +30 -7
- package/{chunk-YB3YZK56.js → chunk-2WZXXAQD.js} +1 -67
- package/{chunk-HRMJUN5J.js → chunk-2X7WFDT6.js} +1 -1
- package/chunk-2YGBI2XB.js +30 -0
- package/{chunk-TY3TIUJK.js → chunk-324FWHUA.js} +85 -3
- package/{chunk-KFLT5KAD.js → chunk-3NNXR7EH.js} +20 -20
- package/{chunk-ZRSNONOB.js → chunk-3P54D2E4.js} +8 -3
- package/{chunk-7OCO4TDT.js → chunk-3U44JB3O.js} +1 -1
- package/{chunk-TX5EYMGT.js → chunk-44J7Z5AQ.js} +34 -258
- package/chunk-4D4QD7FT.js +201 -0
- package/chunk-4I2MXV5Q.js +275 -0
- package/{chunk-MYOH447Z.js → chunk-4JVNURX4.js} +1 -1
- package/{chunk-COFEN36Z.js → chunk-4ZGPHFLE.js} +3 -3
- package/{chunk-ZXOUUDCG.js → chunk-53MFERZ3.js} +3869 -362
- package/chunk-547ENH5T.js +226 -0
- package/{chunk-YDH3FDFQ.js → chunk-5FUN7EG4.js} +1 -1
- package/{chunk-6DWMYIUY.js → chunk-5WKDR7HS.js} +14 -9
- package/chunk-5ZUOVCKT.js +32 -0
- package/{chunk-T43B7LB2.js → chunk-62HXNQVV.js} +1 -1
- package/{chunk-ZC3CMUKU.js → chunk-6OVNSQHN.js} +84 -2
- package/{chunk-IXNGOHV5.js → chunk-6QHKRARD.js} +12 -153
- package/{chunk-4T2WNOY7.js → chunk-6RDBLXVQ.js} +28 -17
- package/{chunk-EYLGAEB4.js → chunk-6XRPBZRS.js} +134 -0
- package/{chunk-KIM6CLW5.js → chunk-7JGMNKKG.js} +57 -26
- package/{chunk-P5L7CXOC.js → chunk-7Z6EW7AH.js} +3 -2
- package/chunk-AGYPUBFW.js +686 -0
- package/{chunk-Y63ZSOR6.js → chunk-AL3TYDIF.js} +1 -1
- package/{chunk-NOKUNJON.js → chunk-ALAES342.js} +75 -94
- package/{chunk-4I7ERB7F.js → chunk-ATEKLSLR.js} +2 -2
- package/{chunk-CRHOO2ZR.js → chunk-AUAJTAFM.js} +8 -8
- package/{chunk-LLRPJECG.js → chunk-AWIL6EHN.js} +15 -157
- package/chunk-BIDSIRTS.js +307 -0
- package/chunk-BIWI5M4E.js +62 -0
- package/{chunk-4VJAC32I.js → chunk-BNMPUQW6.js} +3 -2
- package/{chunk-RLBNLZVC.js → chunk-BP5ZJ6B4.js} +1 -1
- package/{chunk-NBTY7YJF.js → chunk-BR3GT6MR.js} +1 -0
- package/{chunk-7RFNTILS.js → chunk-BUDVRYES.js} +2 -2
- package/{chunk-SVYO6AO7.js → chunk-BV3FLP2L.js} +41 -1
- package/{chunk-ZL5RAEEB.js → chunk-CBUZ6DKA.js} +3 -3
- package/{chunk-SM3NSZJV.js → chunk-CD3RU7XL.js} +36 -2
- package/chunk-CMMI3DAT.js +1621 -0
- package/{chunk-J2NHJ7WX.js → chunk-CYWNWA77.js} +6 -6
- package/{chunk-MOIJOHA5.js → chunk-D6YNCNM6.js} +35 -21
- package/{chunk-H2TJUNCH.js → chunk-DBUR22G5.js} +16 -16
- package/chunk-DEA37IUY.js +271 -0
- package/{chunk-O2TZF4AI.js → chunk-DGYCDA6W.js} +4 -4
- package/{chunk-YWSEPJ7C.js → chunk-DUUDXSLX.js} +21 -7
- package/{chunk-KFHREHUQ.js → chunk-DXWGFL2Z.js} +89 -1
- package/{chunk-H5HF7TJA.js → chunk-EEOOBRA7.js} +6 -6
- package/{chunk-Y6ORVLSS.js → chunk-EVGU5P4U.js} +1 -1
- package/chunk-EWQ3HGNZ.js +90 -0
- package/{chunk-6VLJ6YA7.js → chunk-F6Z6ZCUV.js} +9 -9
- package/{chunk-75XIDFBW.js → chunk-FJ23FZXF.js} +72 -28
- package/chunk-FJSNBZXR.js +142 -0
- package/{chunk-WRYQ35LQ.js → chunk-G7IUT2V3.js} +860 -57
- package/{chunk-PCLE46CE.js → chunk-GBWGPTA7.js} +2 -1
- package/{chunk-H7PPIYWP.js → chunk-GPOV42YM.js} +19 -19
- package/{chunk-W4S457LU.js → chunk-GUXZK7SE.js} +42 -6
- package/{chunk-QHPRUL4O.js → chunk-GV6PRJBU.js} +4 -4
- package/{chunk-YUA6OAH5.js → chunk-HBRDSQ3M.js} +2 -2
- package/{chunk-G7MLNNEX.js → chunk-HHFGE2WF.js} +7 -7
- package/{chunk-OQPKUBPB.js → chunk-HSSBDZLD.js} +19 -7
- package/{chunk-EHSZD5OI.js → chunk-HXER7YJF.js} +4 -4
- package/{chunk-TAKB25RM.js → chunk-HYLRQDEE.js} +6 -6
- package/{chunk-LOEO7LRC.js → chunk-ILHQ2AXT.js} +10 -8
- package/{chunk-BBJ22CLB.js → chunk-JJMR2EA3.js} +64 -34
- package/{chunk-G2BQWAVT.js → chunk-JLAMNSBC.js} +4 -4
- package/{chunk-RSHTSUEG.js → chunk-JUSHVFNF.js} +2133 -622
- package/{chunk-YJAFKXMU.js → chunk-KHVFJSVE.js} +54 -49
- package/{chunk-X7SDOJUM.js → chunk-KRI6N5QZ.js} +16 -16
- package/{chunk-7BT37FK3.js → chunk-L32W3PRP.js} +675 -128
- package/chunk-LKA64WH4.js +227 -0
- package/{chunk-HUBHAQK2.js → chunk-LMRRCEDE.js} +31 -31
- package/chunk-M4SFKP5L.js +675 -0
- package/{chunk-MDB67IWP.js → chunk-MSMHU36U.js} +12 -12
- package/{chunk-7Y4YTDQF.js → chunk-MXKWTPUM.js} +288 -166
- package/{chunk-WYDI6TGM.js → chunk-MXRUXMZ3.js} +94 -135
- package/{chunk-AZMYUSVF.js → chunk-N5Z2V73W.js} +1 -1
- package/{chunk-QG4AOSON.js → chunk-NHY322ZU.js} +154 -32
- package/{chunk-UHJGXRJ4.js → chunk-OBIC6EG7.js} +6 -6
- package/{chunk-GOO6G4PY.js → chunk-OBSEKCVK.js} +123 -70
- package/{chunk-WMTBPBMP.js → chunk-OG6MQOQG.js} +130 -60
- package/{chunk-XJWWBO34.js → chunk-OJKUU3LP.js} +5 -7
- package/{chunk-ALQ3657A.js → chunk-OOJNQK6V.js} +21 -1
- package/{chunk-NSAPDIN2.js → chunk-OWKNSIXL.js} +679 -74
- package/{chunk-6XIE5ZGI.js → chunk-PDCV7P5W.js} +1 -1
- package/{chunk-A7TFUNZO.js → chunk-PPJYZRSQ.js} +6 -2
- package/{chunk-F6UUQOG6.js → chunk-Q3IVPFVO.js} +4 -4
- package/{chunk-VO4WSAVP.js → chunk-QBZCGP34.js} +3 -3
- package/chunk-QCB42576.js +13 -0
- package/chunk-QHEN7NZ7.js +46 -0
- package/{chunk-3UKL3HPD.js → chunk-QJTZ76CP.js} +32 -84
- package/{chunk-V5Y3R6BT.js → chunk-QRGDJA4B.js} +215 -212
- package/{chunk-4KB6WQUL.js → chunk-QYB23WUH.js} +1 -1
- package/{chunk-ZNWI6OVT.js → chunk-R44TU3MZ.js} +85 -11
- package/{chunk-PYRUW7XN.js → chunk-R6Z5S5GA.js} +139 -57
- package/{chunk-VL5KOY2C.js → chunk-R7XWZDOH.js} +125 -29
- package/{chunk-R5O4QAWG.js → chunk-RBPUNSG5.js} +11 -77
- package/{chunk-NJLL224W.js → chunk-RG2DGNL6.js} +3 -3
- package/{chunk-C6KNNXWU.js → chunk-RGQ4UUWZ.js} +25 -2
- package/{chunk-TCZHTTUU.js → chunk-RTHFJZ6M.js} +11 -11
- package/{chunk-RZOV7OMV.js → chunk-RYOLWYBK.js} +146 -200
- package/{chunk-OWYYDMGJ.js → chunk-S2NTVGA2.js} +4 -2
- package/{chunk-XHQC4PXX.js → chunk-S5NA3C52.js} +488 -226
- package/{secretCommands-LXDWOLZ6.js → chunk-S6FDXXZV.js} +190 -15
- package/chunk-S6K5F3KP.js +99 -0
- package/{chunk-INN4LTAJ.js → chunk-SRCCSTIM.js} +8 -8
- package/{chunk-JY5NGFFH.js → chunk-SYTHYBMI.js} +5 -5
- package/{chunk-UYD5HQ6T.js → chunk-SZVMASJ2.js} +3300 -1396
- package/{chunk-FUGMREBO.js → chunk-TGNIKIHR.js} +3 -3
- package/{chunk-HPFCI4SK.js → chunk-TI2EPRHE.js} +4 -4
- package/chunk-TLE77UJ5.js +230 -0
- package/chunk-TSPMLCWI.js +364 -0
- package/{chunk-YGILMZ7N.js → chunk-TUSTONB3.js} +1 -1
- package/{chunk-4VNS5WPM.js → chunk-U67V476Y.js} +1 -8
- package/{chunk-F7CI2ZC5.js → chunk-UAIHKQIA.js} +2 -1
- package/{chunk-WPORQFYN.js → chunk-UVLYNWIE.js} +2 -2
- package/{chunk-H4UOTUOX.js → chunk-VMJVAJ6W.js} +152 -19
- package/{chunk-KC4XDTT3.js → chunk-VS276URX.js} +4 -4
- package/{chunk-YTF4WH7J.js → chunk-WWTSEBDF.js} +1 -1
- package/{chunk-E2BESSAW.js → chunk-X4O7FJF5.js} +2 -0
- package/{chunk-RPQXPZZF.js → chunk-XSW4EXQV.js} +976 -17
- package/{chunk-7QTZCMKL.js → chunk-XTETTSKN.js} +3036 -2468
- package/{chunk-J5JTMQIA.js → chunk-YFLVRVYK.js} +1 -1
- package/chunk-YKY4OVOX.js +1141 -0
- package/{chunk-MMA3LZ3W.js → chunk-YNIYE47Z.js} +1 -1
- package/chunk-YZMNK53S.js +68 -0
- package/{chunk-FY7F4Q6X.js → chunk-Z4PCXPUE.js} +2 -2
- package/{chunk-INUFILG6.js → chunk-ZH3KXFHS.js} +11 -3
- package/chunk-ZOHO6MOF.js +376 -0
- package/{cliAgentConfigHelpers-WJBZQTLW.js → cliAgentConfigHelpers-BTRHMPW2.js} +18 -19
- package/{cliAuthorityBrokerClient-PM3U6Q6J.js → cliAuthorityBrokerClient-XHH7MH2P.js} +1 -1
- package/{cliAuthorityStoreDriver-TKLXNNTG.js → cliAuthorityStoreDriver-6FE3BJNB.js} +1 -1
- package/{cliEnvHelpers-BVYTMUPJ.js → cliEnvHelpers-CNMP3RDX.js} +3 -3
- package/{cliExecutor-BWBF2MTI.js → cliExecutor-K6FDZTQ2.js} +4 -2
- package/cliLocalAgentRecordReader-M3F76NIP.js +90 -0
- package/{commandRegistry-W63CYRZJ.js → commandRegistry-T3UBK6OA.js} +105 -97
- package/{contentThunks-U7PL5MQD.js → contentThunks-YEPZAHXU.js} +53 -48
- package/{cooldownCommands-TIGUHXTD.js → cooldownCommands-YB5H5BBK.js} +5 -4
- package/{createAgentAutomationAction-OLBQDD6R.js → createAgentAutomationAction-TBIIO5WT.js} +51 -48
- package/{createDialogAction-SVH6B3SB.js → createDialogAction-KBKMYFTQ.js} +52 -53
- package/{createPageAction-F4DIWZ2Z.js → createPageAction-3FGAPLJO.js} +56 -53
- package/{cursorProvider-YGGNMVWX.js → cursorProvider-2RACMEMF.js} +1 -1
- package/{db-HUCI5R4G.js → db-M7FU2GNK.js} +10 -7
- package/{dbSlice-BVH2YZPQ.js → dbSlice-XRUZOGSU.js} +20 -19
- package/{deleteFile-5YOEKV4U.js → deleteFile-6URDHYRB.js} +12 -12
- package/{desktopFolderProjects-SFY5EZS3.js → desktopFolderProjects-4POAMVJN.js} +2 -2
- package/{dialogCommands-KHIEPY3M.js → dialogCommands-NRLCOPJR.js} +71 -64
- package/dialogNotifyCommand-SHGPCU22.js +36 -0
- package/{dialogSlice-ZCTDV2PZ.js → dialogSlice-DP2WTMNO.js} +48 -45
- package/{dialogUsageCommand-7KCPYGHG.js → dialogUsageCommand-W2WCSGKF.js} +11 -10
- package/{docCreateCommands-DPMZI7G5.js → docCreateCommands-YJRDA3RX.js} +66 -59
- package/{docDeleteCommands-IRQQLUBT.js → docDeleteCommands-A5QIHZNF.js} +69 -62
- package/{docReadCommands-LK37XH6L.js → docReadCommands-CF2LTMYH.js} +66 -59
- package/{docStore-V2KECILA.js → docStore-NDY3K3PK.js} +25 -24
- package/{docUpdateCommands-O6T3HJHH.js → docUpdateCommands-QRKV4ZXE.js} +69 -62
- package/{fetchMessages-NR4KNQLO.js → fetchMessages-TQEUZD7H.js} +8 -7
- package/{getPricing-2MNMXEVG.js → getPricing-LF5C4XSI.js} +7 -7
- package/{handleSendMessageAction-2PE25WM3.js → handleSendMessageAction-IUGVVJ43.js} +206 -314
- package/{hostCredentialCreate-S233UMAP.js → hostCredentialCreate-X2ZFRXDR.js} +132 -124
- package/index.js +65 -27
- package/{keys-BEGDOTRL.js → keys-RWF7UCB4.js} +5 -4
- package/legacyMigration-TF4SYJCZ.js +19 -0
- package/{lib-5KKIBFIT.js → lib-OT5OTXRU.js} +7087 -6664
- package/{localDialogRead-7NNDVVF7.js → localDialogRead-CCOCVGAP.js} +3 -3
- package/{localFirstLog-DHNOY2NA.js → localFirstLog-OIETGK66.js} +1 -1
- package/localRecall-BDYKXB46.js +17 -0
- package/{localRuntimeAdapter-KY6WXNBR.js → localRuntimeAdapter-KAG3T4LF.js} +138 -130
- package/{localRuntimeAuthority-OYH4AE4G.js → localRuntimeAuthority-IBJAT62G.js} +1 -1
- package/{localRuntimeDb-VBIMCWUC.js → localRuntimeDb-N7KHDXS2.js} +2 -2
- package/{machineCommands-Q6HA3IXF.js → machineCommands-6NIQJE2A.js} +143 -135
- package/{machineInfo-UKPTZO5Y.js → machineInfo-LWHTEBHJ.js} +1 -1
- package/machineWsRunDispatch-RA5NOSGG.js +190 -0
- package/{memberThunks-7EDJADWU.js → memberThunks-7Y3OYSJQ.js} +30 -29
- package/{memoryCommands-ASCE5STX.js → memoryCommands-BC6REPQB.js} +7 -7
- package/models-H5NNZRLH.js +9 -0
- package/{oauthTokenStore-OEERZFUC.js → oauthTokenStore-RUYNYALS.js} +1 -1
- package/{offlineMarxistsAgentCommand-2QTHJCHV.js → offlineMarxistsAgentCommand-XVXUE6G5.js} +6 -6
- package/overlay-BBQZXGYI.js +13 -0
- package/package.json +2 -2
- package/{pdf-U6KSUEZZ.js → pdf-KE3QI2V7.js} +1 -1
- package/{processSpawn-ZU5QFM43.js → processSpawn-6GEO77KV.js} +1 -1
- package/{profileConfig-KN3N2BLF.js → profileConfig-KOWK4HOG.js} +1 -1
- package/{projectArchive-DRTDIMEV.js → projectArchive-OIUP63MV.js} +59 -56
- package/{providerPresetApply-YXGV6NXB.js → providerPresetApply-WHAMP2D5.js} +20 -13
- package/{providerRegistry-S6UL6UNA.js → providerRegistry-ZI2KORJ7.js} +11 -11
- package/{read-4V2RMG7N.js → read-TYMBGEXO.js} +13 -13
- package/{readDocTool-BH6ATGQO.js → readDocTool-SKQVHBLO.js} +2 -2
- package/{readlineWorkspace-2W4WRCOU.js → readlineWorkspace-ZGC4KSXG.js} +7760 -6499
- package/{removeDialogAgentAction-LYAZGNKW.js → removeDialogAgentAction-F5QE2O2B.js} +29 -28
- package/{runAgentClientLoop-J2VQBS2Z.js → runAgentClientLoop-NKUW2DSJ.js} +94 -88
- package/{runtimeDoctorCommands-QAI3MBKQ.js → runtimeDoctorCommands-RRKPBGVO.js} +19 -19
- package/{runtimeModeArgs-2Y7BALTO.js → runtimeModeArgs-X7DL7PUN.js} +1 -1
- package/secretCommands-KZWBZIYS.js +24 -0
- package/{setDialogExtraReferencesAction-OCRPGPYH.js → setDialogExtraReferencesAction-72L27ERM.js} +25 -24
- package/{setPrimaryDialogAgentAction-HFJDQIBU.js → setPrimaryDialogAgentAction-GJJDUSGJ.js} +29 -28
- package/{settingThunks-RAMHMTGM.js → settingThunks-ZRGWVGZD.js} +99 -90
- package/{skillDiscovery-XKHROSH2.js → skillDiscovery-I37M5KJC.js} +4 -4
- package/{skillSummaryMarker-42HKSXYY.js → skillSummaryMarker-62UW7HI7.js} +1 -1
- package/{slateToRenderMarkdown-Y5IYN73U.js → slateToRenderMarkdown-R3X74MCX.js} +1 -1
- package/{slateUtils-NGV2NMKM.js → slateUtils-ESQAJ6RN.js} +1 -1
- package/{spaceCommands-KVJZVKVO.js → spaceCommands-MEH3HJBC.js} +66 -57
- package/store-Z53ICFL3.js +48 -0
- package/{streamAgentChatTurn-GHBMJJ6S.js → streamAgentChatTurn-FJTUUXHJ.js} +886 -668
- package/{switchDialogAgentAction-EBRMW3RA.js → switchDialogAgentAction-IIJBPND3.js} +26 -25
- package/{tableCommands-MP6VFSVT.js → tableCommands-FTAOCBTX.js} +13 -13
- package/tombstones-FQQMEDOW.js +32 -0
- package/{toolApiClient-HGNO53TC.js → toolApiClient-OGQEBQVX.js} +4 -4
- package/{tools-EWKCPKMS.js → tools-ZXHIAOSP.js} +82 -81
- package/tuiRestart-2IL37YIB.js +41 -0
- package/tuiSummaryLlmCaller-W2QN4VAC.js +44 -0
- package/{updateCommands-ZQYU6SCI.js → updateCommands-CPATDG6J.js} +11 -7
- package/{updateDialogTitleAction-5GGMBTDF.js → updateDialogTitleAction-JMKLKL4P.js} +54 -51
- package/{usageCommand-F4IPVMIZ.js → usageCommand-2BF74MKF.js} +11 -10
- package/{usageRebuildCommand-HAW2AD5N.js → usageRebuildCommand-UHB55BQM.js} +12 -11
- package/userDataMerge-HT2ZVHBJ.js +13 -0
- package/{windowsSelfUpdate-257DV2T6.js → windowsSelfUpdate-ZFD6J5HF.js} +3 -3
- package/{workloadLifecycle-4C42SVBD.js → workloadLifecycle-HFJIN5IZ.js} +4 -4
- package/agentRecordCommands-ZQ7SVYGG.js +0 -167
- package/agentRunCommand-WS7IGO2W.js +0 -196
- package/chunk-3CGG2PAL.js +0 -594
- package/chunk-5MQRBSMW.js +0 -862
- package/chunk-5XBUWM6I.js +0 -89
- package/chunk-CJEIOP3E.js +0 -0
- package/chunk-EHGEOAHI.js +0 -636
- package/chunk-FW6YHHLI.js +0 -842
- package/chunk-GPVRUGGY.js +0 -115
- package/chunk-HSVBJRF4.js +0 -339
- package/chunk-LEC5ALIN.js +0 -91
- package/chunk-WACI5I6V.js +0 -147
- package/chunk-WJZOQR2J.js +0 -151
- package/chunk-ZCWRMUWT.js +0 -89
- package/dist-M676ULYG.js +0 -7314
- package/machineWsRunDispatch-WWJQ6WR3.js +0 -182
- package/models-PJBE6JDV.js +0 -9
- package/tuiSummaryLlmCaller-ALQYUUWB.js +0 -189
- package/{chunk-AGP3YSEC.js → chunk-4N6G2CKP.js} +3 -3
- package/{chunk-BLVSFYQ3.js → chunk-LISC7BD4.js} +3 -3
- package/{chunk-2QHFH3DR.js → chunk-USGHJSGO.js} +3 -3
- package/{chunk-AETZ7AD6.js → chunk-W6RFEDN4.js} +3 -3
|
@@ -1,10 +1,29 @@
|
|
|
1
|
-
import {
|
|
2
|
-
applyPublicAgentCatalogOverride
|
|
3
|
-
} from "./chunk-H2TJUNCH.js";
|
|
4
1
|
import {
|
|
5
2
|
buildCliPrompt
|
|
6
3
|
} from "./chunk-ATNTHIZI.js";
|
|
7
4
|
import {
|
|
5
|
+
applyImageConfigRuntimeOverride,
|
|
6
|
+
buildDynamicContexts,
|
|
7
|
+
buildForegroundTurnAdmissionFetchInit,
|
|
8
|
+
buildStaticContexts,
|
|
9
|
+
compressOldToolResults,
|
|
10
|
+
consumeAgentRunStream,
|
|
11
|
+
mergeAgentToolsWithRuntime,
|
|
12
|
+
mergeContexts,
|
|
13
|
+
projectDesktopToolUiContent,
|
|
14
|
+
pushGate,
|
|
15
|
+
resolveImageGenerationStreamingState,
|
|
16
|
+
resolveTurnToolContext,
|
|
17
|
+
targetForRunKind,
|
|
18
|
+
validateAccessAndBalance,
|
|
19
|
+
withRequestContextBlocks
|
|
20
|
+
} from "./chunk-MXRUXMZ3.js";
|
|
21
|
+
import {
|
|
22
|
+
resolveUserSkillRuntime
|
|
23
|
+
} from "./chunk-R44TU3MZ.js";
|
|
24
|
+
import {
|
|
25
|
+
buildEmptyCompletionRepairBody,
|
|
26
|
+
buildFinalCompletionsRequestBody,
|
|
8
27
|
deliverHtmlArtifactToolResult,
|
|
9
28
|
filterAndCleanMessages,
|
|
10
29
|
handleToolCalls,
|
|
@@ -12,12 +31,15 @@ import {
|
|
|
12
31
|
readStreamChunk,
|
|
13
32
|
sendOpenAICompletionsRequest,
|
|
14
33
|
updateTotalUsage
|
|
15
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-KHVFJSVE.js";
|
|
16
35
|
import "./chunk-JEXVIMYZ.js";
|
|
17
36
|
import {
|
|
18
|
-
|
|
19
|
-
|
|
37
|
+
inlineImageUrlsForCustomProvider,
|
|
38
|
+
prepareTools,
|
|
39
|
+
shouldInlineImageUrlsForAgent
|
|
40
|
+
} from "./chunk-JLAMNSBC.js";
|
|
20
41
|
import {
|
|
42
|
+
DirectApiKeyResolutionError,
|
|
21
43
|
INVALID_TOOL_ARGS_REPLACEMENT,
|
|
22
44
|
buildInvalidToolCallSelfHealResult,
|
|
23
45
|
generateRequestBody,
|
|
@@ -27,259 +49,249 @@ import {
|
|
|
27
49
|
sanitizeOutboundResponsesInput,
|
|
28
50
|
selectResponsesConversationState,
|
|
29
51
|
updateResponsesConversationState
|
|
30
|
-
} from "./chunk-
|
|
52
|
+
} from "./chunk-JJMR2EA3.js";
|
|
31
53
|
import "./chunk-HS7MLR74.js";
|
|
32
|
-
import "./chunk-
|
|
33
|
-
import "./chunk-KFHREHUQ.js";
|
|
34
|
-
import {
|
|
35
|
-
isOwnedAgentRecord,
|
|
36
|
-
resolveBillingSource
|
|
37
|
-
} from "./chunk-QG4AOSON.js";
|
|
38
|
-
import "./chunk-PCLE46CE.js";
|
|
39
|
-
import "./chunk-IXNGOHV5.js";
|
|
40
|
-
import "./chunk-75XIDFBW.js";
|
|
41
|
-
import {
|
|
42
|
-
applyImageConfigRuntimeOverride,
|
|
43
|
-
buildDynamicContexts,
|
|
44
|
-
buildForegroundTurnAdmissionFetchInit,
|
|
45
|
-
buildStaticContexts,
|
|
46
|
-
compressOldToolResults,
|
|
47
|
-
consumeAgentRunStream,
|
|
48
|
-
mergeAgentToolsWithRuntime,
|
|
49
|
-
mergeContexts,
|
|
50
|
-
projectDesktopToolUiContent,
|
|
51
|
-
resolveImageGenerationStreamingState,
|
|
52
|
-
resolveTurnToolContext,
|
|
53
|
-
trimMessagesWithSummary,
|
|
54
|
-
validateAccessAndBalance,
|
|
55
|
-
withRequestContextBlocks
|
|
56
|
-
} from "./chunk-WYDI6TGM.js";
|
|
54
|
+
import "./chunk-S5NA3C52.js";
|
|
57
55
|
import {
|
|
58
|
-
|
|
59
|
-
|
|
56
|
+
isGptProModel,
|
|
57
|
+
isPlatformPaidAgentCall,
|
|
58
|
+
shouldBlockForGptPro
|
|
59
|
+
} from "./chunk-NHY322ZU.js";
|
|
60
|
+
import "./chunk-6QHKRARD.js";
|
|
60
61
|
import {
|
|
61
|
-
isContextOverflowText,
|
|
62
|
-
parseApiError,
|
|
63
62
|
performServerProxyFetchWithRetry
|
|
64
|
-
} from "./chunk-
|
|
63
|
+
} from "./chunk-44J7Z5AQ.js";
|
|
65
64
|
import {
|
|
66
65
|
createSSEParser,
|
|
67
66
|
selectMaxExecutionTime,
|
|
68
67
|
waitForAbortableDelay
|
|
69
|
-
} from "./chunk-
|
|
68
|
+
} from "./chunk-LMRRCEDE.js";
|
|
70
69
|
import "./chunk-NF64D32W.js";
|
|
71
|
-
import "./chunk-
|
|
72
|
-
import "./chunk-
|
|
73
|
-
import "./chunk-
|
|
74
|
-
import "./chunk-
|
|
75
|
-
import "./chunk-
|
|
76
|
-
import "./chunk-TAKB25RM.js";
|
|
77
|
-
import "./chunk-RLBNLZVC.js";
|
|
70
|
+
import "./chunk-RBPUNSG5.js";
|
|
71
|
+
import "./chunk-4JVNURX4.js";
|
|
72
|
+
import "./chunk-HYLRQDEE.js";
|
|
73
|
+
import "./chunk-BP5ZJ6B4.js";
|
|
74
|
+
import "./chunk-FJ23FZXF.js";
|
|
78
75
|
import "./chunk-AGIM7IMJ.js";
|
|
79
|
-
import "./chunk-INN4LTAJ.js";
|
|
80
|
-
import {
|
|
81
|
-
getPublicImageAgentDefaultProfile,
|
|
82
|
-
getPublicImageAgentMode
|
|
83
|
-
} from "./chunk-VIDPVFP3.js";
|
|
84
76
|
import "./chunk-63W5N6P3.js";
|
|
85
|
-
import "./chunk-
|
|
86
|
-
import "./chunk-
|
|
77
|
+
import "./chunk-VF4K2QE6.js";
|
|
78
|
+
import "./chunk-5WKDR7HS.js";
|
|
79
|
+
import "./chunk-AWIL6EHN.js";
|
|
80
|
+
import "./chunk-MXKWTPUM.js";
|
|
81
|
+
import {
|
|
82
|
+
getCurrentSpaceId
|
|
83
|
+
} from "./chunk-547ENH5T.js";
|
|
87
84
|
import {
|
|
88
85
|
addToolMessage,
|
|
89
86
|
addUserMessage,
|
|
90
|
-
|
|
87
|
+
admitPendingUserMessages,
|
|
88
|
+
createUserBatchExecution,
|
|
91
89
|
estimateMissingUsage,
|
|
92
90
|
finalizeTransientMessageOnError,
|
|
93
91
|
messageStreamEnd,
|
|
94
92
|
messageStreaming,
|
|
95
93
|
prepareAndPersistUserMessage,
|
|
96
94
|
removeTransientMessage,
|
|
97
|
-
|
|
95
|
+
runPendingUserBatchRequest,
|
|
96
|
+
selectAdmittedMessages,
|
|
98
97
|
selectAllMsgs,
|
|
99
98
|
selectCurrentDialogConfig,
|
|
100
99
|
selectDialogConfigByKey,
|
|
100
|
+
snapshotUserBatchInput,
|
|
101
101
|
toast,
|
|
102
|
+
updateDialogSummaryAction,
|
|
102
103
|
updateTokens,
|
|
103
104
|
updateToolMessage
|
|
104
|
-
} from "./chunk-
|
|
105
|
+
} from "./chunk-53MFERZ3.js";
|
|
105
106
|
import "./chunk-TZXPT53C.js";
|
|
106
|
-
import "./chunk-
|
|
107
|
-
import "./chunk-LEC5ALIN.js";
|
|
107
|
+
import "./chunk-BUDVRYES.js";
|
|
108
108
|
import "./chunk-523DITKR.js";
|
|
109
|
-
import "./chunk-
|
|
110
|
-
import {
|
|
111
|
-
getCurrentSpaceId
|
|
112
|
-
} from "./chunk-5XBUWM6I.js";
|
|
109
|
+
import "./chunk-3NNXR7EH.js";
|
|
113
110
|
import "./chunk-BYXBJQAS.js";
|
|
114
111
|
import "./chunk-QYPE3TS3.js";
|
|
115
112
|
import {
|
|
116
113
|
createCliChatTurnStream,
|
|
117
114
|
getCliChatSession,
|
|
118
115
|
startCliChatSession
|
|
119
|
-
} from "./chunk-
|
|
120
|
-
import "./chunk-4JH2UMJR.js";
|
|
121
|
-
import "./chunk-GPVRUGGY.js";
|
|
122
|
-
import "./chunk-UAD2WT54.js";
|
|
116
|
+
} from "./chunk-RG2DGNL6.js";
|
|
123
117
|
import "./chunk-5RGU3J7P.js";
|
|
124
|
-
import "./chunk-WPORQFYN.js";
|
|
125
|
-
import "./chunk-MMA3LZ3W.js";
|
|
126
118
|
import {
|
|
127
119
|
addActiveController,
|
|
128
120
|
claimDialogTurnPhase,
|
|
129
121
|
clearDialogTurnPhase,
|
|
130
122
|
clearPendingUserInputQueue,
|
|
131
123
|
dequeueUserInput,
|
|
124
|
+
getDialogRuntimeState,
|
|
132
125
|
removeActiveController,
|
|
133
126
|
selectActiveControllers,
|
|
134
127
|
selectPendingUserInputQueue,
|
|
135
128
|
setDialogTurnPhase,
|
|
129
|
+
subscribe,
|
|
136
130
|
tokenUsageLiveUpdate
|
|
137
|
-
} from "./chunk-
|
|
138
|
-
import "./chunk-
|
|
139
|
-
import "./chunk-
|
|
131
|
+
} from "./chunk-S2NTVGA2.js";
|
|
132
|
+
import "./chunk-UVLYNWIE.js";
|
|
133
|
+
import "./chunk-YNIYE47Z.js";
|
|
134
|
+
import "./chunk-5FUN7EG4.js";
|
|
135
|
+
import "./chunk-5ZUOVCKT.js";
|
|
136
|
+
import "./chunk-DXWGFL2Z.js";
|
|
137
|
+
import "./chunk-3L2WKC3W.js";
|
|
138
|
+
import "./chunk-TI2EPRHE.js";
|
|
140
139
|
import {
|
|
141
140
|
selectCurrentServer
|
|
142
|
-
} from "./chunk-
|
|
141
|
+
} from "./chunk-ATEKLSLR.js";
|
|
142
|
+
import "./chunk-DEA37IUY.js";
|
|
143
|
+
import "./chunk-UAD2WT54.js";
|
|
143
144
|
import {
|
|
144
145
|
patch,
|
|
145
146
|
read,
|
|
146
147
|
selectById,
|
|
147
148
|
write
|
|
148
|
-
} from "./chunk-
|
|
149
|
+
} from "./chunk-CMMI3DAT.js";
|
|
149
150
|
import "./chunk-3PVYUPXK.js";
|
|
150
|
-
import "./chunk-
|
|
151
|
-
import "./chunk-
|
|
151
|
+
import "./chunk-DGYCDA6W.js";
|
|
152
|
+
import "./chunk-4ZGPHFLE.js";
|
|
152
153
|
import {
|
|
153
154
|
selectRuntimeCurrentServer
|
|
154
|
-
} from "./chunk-
|
|
155
|
+
} from "./chunk-R6Z5S5GA.js";
|
|
155
156
|
import "./chunk-UEILX4EV.js";
|
|
156
|
-
import "./chunk-
|
|
157
|
+
import "./chunk-7Z6EW7AH.js";
|
|
157
158
|
import {
|
|
158
159
|
getIsDesktopApp
|
|
159
|
-
} from "./chunk-
|
|
160
|
-
import "./chunk-QQ56R7KS.js";
|
|
161
|
-
import "./chunk-OW765XBU.js";
|
|
160
|
+
} from "./chunk-4N6G2CKP.js";
|
|
162
161
|
import {
|
|
163
162
|
selectIdentityToken,
|
|
164
163
|
selectIdentityUser,
|
|
165
164
|
selectIdentityUserId
|
|
166
165
|
} from "./chunk-PXYBUFDB.js";
|
|
167
|
-
import "./chunk-
|
|
168
|
-
import "./chunk-
|
|
169
|
-
import "./chunk-
|
|
170
|
-
import "./chunk-
|
|
171
|
-
import "./chunk-
|
|
172
|
-
import
|
|
173
|
-
|
|
166
|
+
import "./chunk-QQ56R7KS.js";
|
|
167
|
+
import "./chunk-GBWGPTA7.js";
|
|
168
|
+
import "./chunk-OOJNQK6V.js";
|
|
169
|
+
import "./chunk-HXER7YJF.js";
|
|
170
|
+
import "./chunk-BV3FLP2L.js";
|
|
171
|
+
import {
|
|
172
|
+
applyPublicAgentCatalogOverride
|
|
173
|
+
} from "./chunk-DBUR22G5.js";
|
|
174
|
+
import {
|
|
175
|
+
applyBuiltinAgentRuntimeOverride,
|
|
176
|
+
resolveBuiltinPlatformAgentRecord
|
|
177
|
+
} from "./chunk-S6K5F3KP.js";
|
|
178
|
+
import "./chunk-SRCCSTIM.js";
|
|
179
|
+
import {
|
|
180
|
+
getPublicImageAgentDefaultProfile,
|
|
181
|
+
getPublicImageAgentMode
|
|
182
|
+
} from "./chunk-VIDPVFP3.js";
|
|
183
|
+
import "./chunk-4JH2UMJR.js";
|
|
174
184
|
import {
|
|
175
185
|
assertDesktopAgentRuntimeTurnBodyHasNoRawSecrets,
|
|
176
186
|
buildDesktopAgentRuntimeAgentConfigSnapshot,
|
|
177
187
|
buildDesktopAgentRuntimeDialogHistorySnapshot,
|
|
188
|
+
evaluateRequestBudget,
|
|
178
189
|
extractImageUrlsFromMessages,
|
|
179
190
|
stripImagePartsForTextOnlyAgent
|
|
180
|
-
} from "./chunk-
|
|
191
|
+
} from "./chunk-GUXZK7SE.js";
|
|
192
|
+
import "./chunk-2WZXXAQD.js";
|
|
193
|
+
import "./chunk-DUUDXSLX.js";
|
|
181
194
|
import {
|
|
182
195
|
projectUserPartForModel
|
|
183
|
-
} from "./chunk-
|
|
196
|
+
} from "./chunk-QYB23WUH.js";
|
|
184
197
|
import "./chunk-56GBUMO5.js";
|
|
185
|
-
import
|
|
186
|
-
isGptProModel,
|
|
187
|
-
shouldBlockForGptPro
|
|
188
|
-
} from "./chunk-5MQRBSMW.js";
|
|
198
|
+
import "./chunk-AGYPUBFW.js";
|
|
189
199
|
import {
|
|
190
200
|
extractImagePartsFromResponseOutput,
|
|
191
201
|
extractTextFromResponseOutput,
|
|
192
202
|
toResponsesTools
|
|
193
|
-
} from "./chunk-
|
|
194
|
-
import "./chunk-
|
|
195
|
-
import "./chunk-
|
|
196
|
-
import "./chunk-
|
|
203
|
+
} from "./chunk-EEOOBRA7.js";
|
|
204
|
+
import "./chunk-X4O7FJF5.js";
|
|
205
|
+
import "./chunk-RYOLWYBK.js";
|
|
206
|
+
import "./chunk-QJTZ76CP.js";
|
|
197
207
|
import {
|
|
198
208
|
resolveRuntimeToolSurfaceForAgent
|
|
199
|
-
} from "./chunk-
|
|
200
|
-
import
|
|
201
|
-
|
|
202
|
-
|
|
209
|
+
} from "./chunk-VS276URX.js";
|
|
210
|
+
import {
|
|
211
|
+
isContextOverflowText,
|
|
212
|
+
parseApiError
|
|
213
|
+
} from "./chunk-TLE77UJ5.js";
|
|
203
214
|
import {
|
|
204
215
|
resolveAgentCallPlan,
|
|
205
216
|
resolveClientWire
|
|
206
|
-
} from "./chunk-
|
|
217
|
+
} from "./chunk-OBIC6EG7.js";
|
|
218
|
+
import "./chunk-FJSNBZXR.js";
|
|
207
219
|
import {
|
|
208
220
|
resolveAgentContextWindow
|
|
209
|
-
} from "./chunk-
|
|
221
|
+
} from "./chunk-QRGDJA4B.js";
|
|
222
|
+
import "./chunk-5ZUL4CUO.js";
|
|
210
223
|
import {
|
|
211
224
|
getModelInfo
|
|
212
|
-
} from "./chunk-
|
|
225
|
+
} from "./chunk-L32W3PRP.js";
|
|
213
226
|
import "./chunk-H57T64RA.js";
|
|
214
|
-
import "./chunk-
|
|
215
|
-
import {
|
|
216
|
-
isOAuthApiKeyRef
|
|
217
|
-
} from "./chunk-UKZX3NHN.js";
|
|
227
|
+
import "./chunk-UKZX3NHN.js";
|
|
218
228
|
import "./chunk-5MMAK75Q.js";
|
|
219
|
-
import "./chunk-
|
|
220
|
-
import "./chunk-OQHIVPG4.js";
|
|
229
|
+
import "./chunk-USGHJSGO.js";
|
|
221
230
|
import {
|
|
222
231
|
asRecordOrEmpty
|
|
223
232
|
} from "./chunk-KX6YBIHG.js";
|
|
233
|
+
import "./chunk-OQHIVPG4.js";
|
|
224
234
|
import "./chunk-DWLEOOGR.js";
|
|
225
235
|
import {
|
|
226
236
|
isAbortError
|
|
227
237
|
} from "./chunk-7DPNBQSV.js";
|
|
228
|
-
import "./chunk-
|
|
229
|
-
import "./chunk-
|
|
230
|
-
import
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
import "./chunk-
|
|
238
|
+
import "./chunk-OW765XBU.js";
|
|
239
|
+
import "./chunk-EWQ3HGNZ.js";
|
|
240
|
+
import {
|
|
241
|
+
estimateTokenCount
|
|
242
|
+
} from "./chunk-PSCNXBYA.js";
|
|
243
|
+
import "./chunk-G7Y4GXTY.js";
|
|
244
|
+
import "./chunk-6UBGXX2W.js";
|
|
245
|
+
import "./chunk-G7IUT2V3.js";
|
|
246
|
+
import "./chunk-6OVNSQHN.js";
|
|
247
|
+
import "./chunk-W6RFEDN4.js";
|
|
248
|
+
import "./chunk-EVGU5P4U.js";
|
|
234
249
|
import {
|
|
235
250
|
isSystemBuiltinTrustedAgentKey
|
|
236
|
-
} from "./chunk-
|
|
251
|
+
} from "./chunk-ILHQ2AXT.js";
|
|
237
252
|
import {
|
|
238
253
|
extractCustomId
|
|
239
254
|
} from "./chunk-M2EJHDJP.js";
|
|
255
|
+
import "./chunk-SYTHYBMI.js";
|
|
240
256
|
import {
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
import
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
import "./chunk-
|
|
257
|
+
createDialogMessageKeyAndId,
|
|
258
|
+
dialogMessageKey
|
|
259
|
+
} from "./chunk-OJKUU3LP.js";
|
|
260
|
+
import "./chunk-YZMNK53S.js";
|
|
261
|
+
import "./chunk-I42VC5KR.js";
|
|
262
|
+
import "./chunk-U6VC4MU4.js";
|
|
263
|
+
import "./chunk-3P54D2E4.js";
|
|
264
|
+
import "./chunk-BNMPUQW6.js";
|
|
265
|
+
import "./chunk-KHCLMKZZ.js";
|
|
266
|
+
import "./chunk-LCBAMY2M.js";
|
|
267
|
+
import "./chunk-62HXNQVV.js";
|
|
268
|
+
import "./chunk-7JGMNKKG.js";
|
|
269
|
+
import "./chunk-RTHFJZ6M.js";
|
|
248
270
|
import {
|
|
249
271
|
isOpenAiResponsesModel
|
|
250
|
-
} from "./chunk-
|
|
251
|
-
import {
|
|
252
|
-
getApiEndpoint
|
|
253
|
-
} from "./chunk-SM3NSZJV.js";
|
|
254
|
-
import "./chunk-JRTNUU5Z.js";
|
|
272
|
+
} from "./chunk-HBRDSQ3M.js";
|
|
255
273
|
import {
|
|
256
274
|
toErrorMessage
|
|
257
275
|
} from "./chunk-HNMXYYJR.js";
|
|
276
|
+
import {
|
|
277
|
+
asTrimmedString
|
|
278
|
+
} from "./chunk-3EUW3WEO.js";
|
|
279
|
+
import {
|
|
280
|
+
getApiEndpoint
|
|
281
|
+
} from "./chunk-CD3RU7XL.js";
|
|
282
|
+
import "./chunk-JRTNUU5Z.js";
|
|
258
283
|
import {
|
|
259
284
|
isRecord
|
|
260
285
|
} from "./chunk-KUG52IAP.js";
|
|
261
|
-
import "./chunk-GOO6G4PY.js";
|
|
262
|
-
import "./chunk-QSJ3HFEF.js";
|
|
263
|
-
import "./chunk-LCBAMY2M.js";
|
|
264
|
-
import "./chunk-4SN6J65J.js";
|
|
265
|
-
import "./chunk-CF7PE763.js";
|
|
266
|
-
import "./chunk-G7Y4GXTY.js";
|
|
267
|
-
import "./chunk-6UBGXX2W.js";
|
|
268
|
-
import "./chunk-JY5NGFFH.js";
|
|
269
|
-
import {
|
|
270
|
-
createDialogMessageKeyAndId,
|
|
271
|
-
dialogMessageKey
|
|
272
|
-
} from "./chunk-XJWWBO34.js";
|
|
273
|
-
import "./chunk-I42VC5KR.js";
|
|
274
|
-
import "./chunk-U6VC4MU4.js";
|
|
275
286
|
import "./chunk-WWC7I6TA.js";
|
|
276
|
-
import {
|
|
277
|
-
asTrimmedString
|
|
278
|
-
} from "./chunk-3EUW3WEO.js";
|
|
279
287
|
import {
|
|
280
288
|
asOptionalTrimmedString
|
|
281
289
|
} from "./chunk-G3SUCT4W.js";
|
|
282
|
-
import "./chunk-
|
|
290
|
+
import "./chunk-4SN6J65J.js";
|
|
291
|
+
import "./chunk-CF7PE763.js";
|
|
292
|
+
import "./chunk-OBSEKCVK.js";
|
|
293
|
+
import "./chunk-QSJ3HFEF.js";
|
|
294
|
+
import "./chunk-U67V476Y.js";
|
|
283
295
|
|
|
284
296
|
// packages/ai/agent/isVoiceModel.ts
|
|
285
297
|
function isVoiceModel(model, provider) {
|
|
@@ -476,6 +488,40 @@ var hasReportedTokenOrCostUsage = (usage) => {
|
|
|
476
488
|
var shouldSkipBillingForUserAbort = (error, usage) => {
|
|
477
489
|
return isAbortError(error) && !hasReportedTokenOrCostUsage(usage);
|
|
478
490
|
};
|
|
491
|
+
function buildResponsesRequestBodyWithTools(bodyData, agentConfig) {
|
|
492
|
+
const functionTools = getModelInfo(agentConfig.model)?.hasImageOutput ? [] : prepareTools(agentConfig.tools ?? [], { provider: agentConfig.provider });
|
|
493
|
+
const imageMode = getPublicImageAgentMode(agentConfig);
|
|
494
|
+
const imageProfile = imageMode === "continuous" ? getPublicImageAgentDefaultProfile("continuous") : null;
|
|
495
|
+
const imageGenerationModel = asOptionalTrimmedString(
|
|
496
|
+
agentConfig?.imageModel
|
|
497
|
+
);
|
|
498
|
+
const tools = [
|
|
499
|
+
...toResponsesTools(functionTools) ?? [],
|
|
500
|
+
...shouldEnableBuiltInImageGeneration(agentConfig) ? [
|
|
501
|
+
{
|
|
502
|
+
type: "image_generation",
|
|
503
|
+
...imageGenerationModel ? { model: imageGenerationModel } : {}
|
|
504
|
+
}
|
|
505
|
+
] : [],
|
|
506
|
+
...imageMode === "continuous" ? [
|
|
507
|
+
{
|
|
508
|
+
type: "image_generation",
|
|
509
|
+
action: "auto",
|
|
510
|
+
...imageGenerationModel ? { model: imageGenerationModel } : {},
|
|
511
|
+
quality: imageProfile?.quality,
|
|
512
|
+
output_format: imageProfile?.outputFormat
|
|
513
|
+
}
|
|
514
|
+
] : []
|
|
515
|
+
];
|
|
516
|
+
const sourceBodyData = bodyData;
|
|
517
|
+
const sanitizedInput = Array.isArray(sourceBodyData?.input) ? sanitizeOutboundResponsesInput(sourceBodyData.input) : sourceBodyData?.input;
|
|
518
|
+
const baseBodyData = sanitizedInput !== sourceBodyData?.input ? { ...sourceBodyData, input: sanitizedInput } : sourceBodyData;
|
|
519
|
+
return {
|
|
520
|
+
...baseBodyData,
|
|
521
|
+
...tools.length ? { tools, tool_choice: baseBodyData.tool_choice ?? "auto" } : {},
|
|
522
|
+
stream: true
|
|
523
|
+
};
|
|
524
|
+
}
|
|
479
525
|
var sendOpenAIResponseRequest = async ({
|
|
480
526
|
bodyData,
|
|
481
527
|
agentConfig,
|
|
@@ -744,39 +790,7 @@ var sendOpenAIResponseRequest = async ({
|
|
|
744
790
|
})
|
|
745
791
|
);
|
|
746
792
|
}
|
|
747
|
-
const
|
|
748
|
-
const imageMode = getPublicImageAgentMode(agentConfig);
|
|
749
|
-
const imageProfile = imageMode === "continuous" ? getPublicImageAgentDefaultProfile("continuous") : null;
|
|
750
|
-
const imageGenerationModel = asOptionalTrimmedString(
|
|
751
|
-
agentConfig?.imageModel
|
|
752
|
-
);
|
|
753
|
-
const tools = [
|
|
754
|
-
...toResponsesTools(functionTools) ?? [],
|
|
755
|
-
...shouldEnableBuiltInImageGeneration(agentConfig) ? [
|
|
756
|
-
{
|
|
757
|
-
type: "image_generation",
|
|
758
|
-
...imageGenerationModel ? { model: imageGenerationModel } : {}
|
|
759
|
-
}
|
|
760
|
-
] : [],
|
|
761
|
-
...imageMode === "continuous" ? [
|
|
762
|
-
{
|
|
763
|
-
type: "image_generation",
|
|
764
|
-
action: "auto",
|
|
765
|
-
...imageGenerationModel ? { model: imageGenerationModel } : {},
|
|
766
|
-
quality: imageProfile?.quality,
|
|
767
|
-
output_format: imageProfile?.outputFormat
|
|
768
|
-
}
|
|
769
|
-
] : []
|
|
770
|
-
];
|
|
771
|
-
const buildRequestBody = (sourceBodyData) => {
|
|
772
|
-
const sanitizedInput = Array.isArray(sourceBodyData?.input) ? sanitizeOutboundResponsesInput(sourceBodyData.input) : sourceBodyData?.input;
|
|
773
|
-
const baseBodyData = sanitizedInput !== sourceBodyData?.input ? { ...sourceBodyData, input: sanitizedInput } : sourceBodyData;
|
|
774
|
-
return {
|
|
775
|
-
...baseBodyData,
|
|
776
|
-
...tools.length ? { tools, tool_choice: baseBodyData.tool_choice ?? "auto" } : {},
|
|
777
|
-
stream: true
|
|
778
|
-
};
|
|
779
|
-
};
|
|
793
|
+
const buildRequestBody = (body) => buildResponsesRequestBodyWithTools(body, agentConfig);
|
|
780
794
|
let requestBody = buildRequestBody(bodyData);
|
|
781
795
|
const fallbackRequestBody = fallbackBodyData ? buildRequestBody(fallbackBodyData) : null;
|
|
782
796
|
const api = getApiEndpoint(agentConfig);
|
|
@@ -1146,37 +1160,79 @@ var buildAgentViewMessages = (allMessages, currentAgentKey) => {
|
|
|
1146
1160
|
return result;
|
|
1147
1161
|
};
|
|
1148
1162
|
|
|
1149
|
-
// packages/ai/agent/
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
)
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1163
|
+
// packages/ai/agent/requestAdmission.ts
|
|
1164
|
+
function projectSummaryHistory(messages, summary, anchor) {
|
|
1165
|
+
if (!summary || !anchor) return messages;
|
|
1166
|
+
const covered = messages.findIndex((message) => message.id === anchor);
|
|
1167
|
+
if (covered < 0) return messages;
|
|
1168
|
+
let start = covered + 1;
|
|
1169
|
+
while (start > 0 && messages[start]?.role === "tool") start--;
|
|
1170
|
+
const latestUser = messages.map((message) => message.role).lastIndexOf("user");
|
|
1171
|
+
const suffix = messages.slice(start);
|
|
1172
|
+
return latestUser >= 0 && latestUser < start ? [messages[latestUser], ...suffix] : suffix;
|
|
1173
|
+
}
|
|
1174
|
+
var UNKNOWN_IMAGE_RESERVE_TOKENS = 4096;
|
|
1175
|
+
function projectWireImageCosts(items) {
|
|
1176
|
+
let imageCount = 0;
|
|
1177
|
+
if (!Array.isArray(items)) return { projected: items, imageCount };
|
|
1178
|
+
const projected = items.map((message) => {
|
|
1179
|
+
if (!message || !Array.isArray(message.content)) return message;
|
|
1180
|
+
return { ...message, content: message.content.map((part) => {
|
|
1181
|
+
if (part?.type === "image_url" && typeof part.image_url?.url === "string") {
|
|
1182
|
+
imageCount++;
|
|
1183
|
+
return { type: "image_url", image_url: { detail: part.image_url.detail } };
|
|
1184
|
+
}
|
|
1185
|
+
if (part?.type === "input_image" && (typeof part.image_url === "string" || typeof part.file_id === "string")) {
|
|
1186
|
+
imageCount++;
|
|
1187
|
+
return { type: "input_image", detail: part.detail };
|
|
1188
|
+
}
|
|
1189
|
+
return part;
|
|
1190
|
+
}) };
|
|
1191
|
+
});
|
|
1192
|
+
return { projected, imageCount };
|
|
1193
|
+
}
|
|
1194
|
+
function estimateWebRequestBudget(body, contextWindow) {
|
|
1195
|
+
const { messages, input, instructions, tools, ...other } = body;
|
|
1196
|
+
const count = (value) => value == null ? 0 : estimateTokenCount(JSON.stringify(value));
|
|
1197
|
+
const projectedMessages = projectWireImageCosts(messages);
|
|
1198
|
+
const projectedInput = projectWireImageCosts(input);
|
|
1199
|
+
const unknownImageCount = projectedMessages.imageCount + projectedInput.imageCount;
|
|
1200
|
+
const heuristicImageReserveTokens = unknownImageCount * UNKNOWN_IMAGE_RESERVE_TOKENS;
|
|
1201
|
+
const cap = body.max_output_tokens ?? body.max_completion_tokens ?? body.max_tokens;
|
|
1202
|
+
const decision = evaluateRequestBudget({
|
|
1203
|
+
contextWindow,
|
|
1204
|
+
messageTokens: count(projectedMessages.projected) + count(projectedInput.projected) + count(instructions),
|
|
1205
|
+
toolSchemaTokens: count(tools),
|
|
1206
|
+
otherInputTokens: count(other) + heuristicImageReserveTokens,
|
|
1207
|
+
protocolReserveTokens: 1024,
|
|
1208
|
+
output: { semantics: "unknown", fallbackReserveTokens: cap === void 0 ? 8192 : Number(cap) }
|
|
1209
|
+
});
|
|
1210
|
+
return { ...decision, unknownImageCount, heuristicImageReserveTokens, imageCostBasis: "unknown-provider-heuristic" };
|
|
1211
|
+
}
|
|
1212
|
+
async function admitWebRequest(options) {
|
|
1213
|
+
for (let attempt = 0; attempt < 2; attempt++) {
|
|
1214
|
+
if (options.signal.aborted) {
|
|
1215
|
+
const error = new Error("Request admission aborted");
|
|
1216
|
+
error.name = "AbortError";
|
|
1217
|
+
throw options.signal.reason ?? error;
|
|
1218
|
+
}
|
|
1219
|
+
const request = await options.build();
|
|
1220
|
+
if (options.signal.aborted) {
|
|
1221
|
+
const error = new Error("Request admission aborted");
|
|
1222
|
+
error.name = "AbortError";
|
|
1223
|
+
throw options.signal.reason ?? error;
|
|
1224
|
+
}
|
|
1225
|
+
const decisions = request.wireBodies.map((body) => estimateWebRequestBudget(body, options.contextWindow));
|
|
1226
|
+
if (decisions.length && decisions.every((decision) => decision.fitsEstimate)) return request.value;
|
|
1227
|
+
if (attempt) throw new Error("Context budget exceeded after budget_rescue; request not sent (heuristic estimate)");
|
|
1228
|
+
const allowances = request.wireBodies.map((body) => {
|
|
1229
|
+
const systemOnly = (items) => Array.isArray(items) ? items.filter((item) => item.role === "system" || item.role === "developer") : items;
|
|
1230
|
+
const external = estimateWebRequestBudget({ ...body, messages: systemOnly(body.messages), input: systemOnly(body.input) }, options.contextWindow);
|
|
1231
|
+
return Math.max(0, external.availableInputTokens - external.estimatedInputTokens);
|
|
1232
|
+
});
|
|
1233
|
+
await options.rescue(Math.min(...allowances));
|
|
1234
|
+
}
|
|
1235
|
+
throw new Error("Context budget admission failed");
|
|
1180
1236
|
}
|
|
1181
1237
|
|
|
1182
1238
|
// packages/ai/agent/persistMessageWithFixedId.ts
|
|
@@ -1236,13 +1292,14 @@ function buildDesktopAgentRuntimeTurnBody(args) {
|
|
|
1236
1292
|
} else if (Array.isArray(args.dialogMessages) && continueDialogId) {
|
|
1237
1293
|
dialogHistorySnapshot = buildDesktopAgentRuntimeDialogHistorySnapshot({
|
|
1238
1294
|
dialogId: continueDialogId,
|
|
1239
|
-
messages: args.dialogMessages,
|
|
1240
|
-
currentInput: args.input
|
|
1295
|
+
messages: args.userMessages?.length ? args.dialogMessages.filter((message) => !args.userMessages.some((user) => user.cliMessageId === message.id)) : args.dialogMessages,
|
|
1296
|
+
currentInput: args.userMessages?.length ? void 0 : args.input
|
|
1241
1297
|
}) ?? void 0;
|
|
1242
1298
|
}
|
|
1243
1299
|
const body = {
|
|
1244
1300
|
agentRef: args.agentRef,
|
|
1245
1301
|
input: args.input,
|
|
1302
|
+
...args.userMessages?.length ? { userMessages: args.userMessages } : {},
|
|
1246
1303
|
...Array.isArray(args.contextBlocks) && args.contextBlocks.length > 0 ? { contextBlocks: args.contextBlocks } : {},
|
|
1247
1304
|
...args.runtimeContext ? { runtimeContext: args.runtimeContext } : {},
|
|
1248
1305
|
...continueDialogId ? { continueDialogId } : {},
|
|
@@ -1988,6 +2045,7 @@ var streamAgentChatTurnHandler = async (args, thunkApi) => {
|
|
|
1988
2045
|
let loopKey = null;
|
|
1989
2046
|
let runtimeDialogKey = explicitDialogKey ?? null;
|
|
1990
2047
|
let turnPhaseTurnId = null;
|
|
2048
|
+
const batchExecution = createUserBatchExecution(loopController.signal, () => !thunkApi.signal.aborted && (!turnPhaseTurnId || !runtimeDialogKey || getDialogRuntimeState(runtimeDialogKey).turnPhaseTurnId === turnPhaseTurnId));
|
|
1991
2049
|
let remoteTransientMessageId = null;
|
|
1992
2050
|
let remoteTransientMessageFinalized = false;
|
|
1993
2051
|
let modelRequestStarted = false;
|
|
@@ -2123,7 +2181,7 @@ var streamAgentChatTurnHandler = async (args, thunkApi) => {
|
|
|
2123
2181
|
if (boundMachineId) {
|
|
2124
2182
|
const token = selectIdentityToken(currentState);
|
|
2125
2183
|
const authHeader = token ? `Bearer ${token}` : "";
|
|
2126
|
-
const rawMessages = selectAllMsgs(currentState, dialogId2);
|
|
2184
|
+
const rawMessages = selectAdmittedMessages(selectAllMsgs(currentState, dialogId2));
|
|
2127
2185
|
const visibleMessages = buildAgentViewMessages(
|
|
2128
2186
|
rawMessages,
|
|
2129
2187
|
agentConfig.dbKey
|
|
@@ -2184,15 +2242,16 @@ var streamAgentChatTurnHandler = async (args, thunkApi) => {
|
|
|
2184
2242
|
...Array.isArray(contextBlocks) && contextBlocks.length > 0 ? { contextBlocks } : {},
|
|
2185
2243
|
messages: cleanedMessages,
|
|
2186
2244
|
stream: true,
|
|
2187
|
-
persistDialog:
|
|
2188
|
-
|
|
2245
|
+
persistDialog: true,
|
|
2246
|
+
continueDialogId: dialogId2,
|
|
2189
2247
|
...explicitTarget ? { runtimeTarget: explicitTarget } : {},
|
|
2190
2248
|
runtimeContext: {
|
|
2191
2249
|
surface: "web",
|
|
2192
2250
|
host: "browser",
|
|
2193
2251
|
runtime: "react",
|
|
2194
2252
|
entrypoint: "chat-dialog",
|
|
2195
|
-
capabilities: ["streaming", "dialog-ui", "machine-bound-cli"]
|
|
2253
|
+
capabilities: ["streaming", "dialog-ui", "machine-bound-cli", "durable-user-batch", "client-user-prepersisted"],
|
|
2254
|
+
userMessageId: selectAdmittedMessages(selectAllMsgs(getState(), dialogId2)).filter((message) => message.role === "user").at(-1)?.id
|
|
2196
2255
|
},
|
|
2197
2256
|
...dialogConfig?.spaceId ? { spaceId: dialogConfig.spaceId } : {}
|
|
2198
2257
|
}),
|
|
@@ -2239,6 +2298,15 @@ var streamAgentChatTurnHandler = async (args, thunkApi) => {
|
|
|
2239
2298
|
if (payload.type === "error") {
|
|
2240
2299
|
return { reject: payload.message || "\u7535\u8111\u7AEF Agent \u6267\u884C\u5931\u8D25" };
|
|
2241
2300
|
}
|
|
2301
|
+
if (payload.type === "action_gate" && payload.gate) {
|
|
2302
|
+
pushGate(
|
|
2303
|
+
payload.gate,
|
|
2304
|
+
targetForRunKind("server-run", {
|
|
2305
|
+
server: currentServer2,
|
|
2306
|
+
token
|
|
2307
|
+
})
|
|
2308
|
+
);
|
|
2309
|
+
}
|
|
2242
2310
|
remoteToolHandlers.handleToolPayload(payload);
|
|
2243
2311
|
if (payload.type === "text" && typeof payload.content === "string") {
|
|
2244
2312
|
accumulated2 += payload.content;
|
|
@@ -2547,6 +2615,8 @@ var streamAgentChatTurnHandler = async (args, thunkApi) => {
|
|
|
2547
2615
|
dialogKey,
|
|
2548
2616
|
dialogId
|
|
2549
2617
|
});
|
|
2618
|
+
turnPhaseTurnId = `turn-phase:${dialogId}:${crypto.randomUUID()}`;
|
|
2619
|
+
claimDialogTurnPhase({ dialogKey, turnId: turnPhaseTurnId });
|
|
2550
2620
|
if (shouldUseDesktopLocalRuntime(agentConfig, explicitTarget)) {
|
|
2551
2621
|
const desktopMessageMetadata = buildMessageMetadata(agentConfig);
|
|
2552
2622
|
const w2 = typeof globalThis !== "undefined" && globalThis.window ? globalThis.window : null;
|
|
@@ -2554,428 +2624,489 @@ var streamAgentChatTurnHandler = async (args, thunkApi) => {
|
|
|
2554
2624
|
dispatch(addActiveController({ messageId: loopKey, controller: loopController, dialogKey }));
|
|
2555
2625
|
turnPhaseTurnId = `turn-phase:${dialogId}:${Date.now().toString(36)}:${Math.random().toString(36).slice(2, 8)}`;
|
|
2556
2626
|
claimDialogTurnPhase({ dialogKey, turnId: turnPhaseTurnId });
|
|
2557
|
-
|
|
2558
|
-
const
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
toolCallIds: []
|
|
2574
|
-
});
|
|
2575
|
-
remoteTransientMessageId = assistantMessageKeys.messageId;
|
|
2627
|
+
const ownsDesktopTurn = () => !loopController.signal.aborted && !thunkApi.signal.aborted && getDialogRuntimeState(dialogKey).turnPhaseTurnId === turnPhaseTurnId;
|
|
2628
|
+
const admitDesktopBatch = async () => {
|
|
2629
|
+
const admission = new AbortController();
|
|
2630
|
+
const checkOwner = () => {
|
|
2631
|
+
if (!ownsDesktopTurn()) admission.abort();
|
|
2632
|
+
};
|
|
2633
|
+
const unsubscribe = subscribe(checkOwner);
|
|
2634
|
+
loopController.signal.addEventListener("abort", checkOwner);
|
|
2635
|
+
thunkApi.signal.addEventListener("abort", checkOwner);
|
|
2636
|
+
checkOwner();
|
|
2637
|
+
try {
|
|
2638
|
+
return await dispatch(admitPendingUserMessages({ dialogKey, signal: admission.signal })).unwrap();
|
|
2639
|
+
} finally {
|
|
2640
|
+
unsubscribe();
|
|
2641
|
+
loopController.signal.removeEventListener("abort", checkOwner);
|
|
2642
|
+
thunkApi.signal.removeEventListener("abort", checkOwner);
|
|
2576
2643
|
}
|
|
2577
|
-
return assistantMessageKeys;
|
|
2578
|
-
};
|
|
2579
|
-
const streamDesktopAssistantUpsert = () => {
|
|
2580
|
-
const { key: msgKey2, messageId: messageId2 } = ensureAssistantMessageKeys();
|
|
2581
|
-
const segment2 = assistantSegments[assistantSegments.length - 1];
|
|
2582
|
-
segment2.content = currentContent;
|
|
2583
|
-
dispatch(messageStreaming({
|
|
2584
|
-
id: messageId2,
|
|
2585
|
-
dialogId,
|
|
2586
|
-
dbKey: msgKey2,
|
|
2587
|
-
content: currentContent,
|
|
2588
|
-
role: "assistant",
|
|
2589
|
-
isStreaming: true,
|
|
2590
|
-
thinkContent: reasoningBuffer,
|
|
2591
|
-
...desktopMessageMetadata
|
|
2592
|
-
}));
|
|
2593
|
-
};
|
|
2594
|
-
const streamDesktopAssistantText = (text) => {
|
|
2595
|
-
currentContent += text;
|
|
2596
|
-
streamDesktopAssistantUpsert();
|
|
2597
2644
|
};
|
|
2598
|
-
const
|
|
2599
|
-
|
|
2600
|
-
|
|
2645
|
+
const sameInput = (content) => JSON.stringify(content) === JSON.stringify(userInput);
|
|
2646
|
+
const initialMessages = selectAllMsgs(getState(), dialogId);
|
|
2647
|
+
const initialUser = initialMessages.filter((message) => message.role === "user" && sameInput(message.content)).at(-1);
|
|
2648
|
+
const isUserTurn = !!initialUser && sameInput(initialUser.content);
|
|
2649
|
+
let desktopBatch = isUserTurn && initialUser.metadata?.queueState === "pending" ? await admitDesktopBatch() : isUserTurn ? [...initialMessages.filter((message) => message.role === "user" && message.id !== initialUser.id && message.metadata?.userBatchPhase === "admitted"), initialUser] : [];
|
|
2650
|
+
if (!ownsDesktopTurn()) return { aborted: true };
|
|
2651
|
+
while (ownsDesktopTurn()) {
|
|
2652
|
+
const desktopRequestUserInput = snapshotUserBatchInput(desktopBatch.length ? desktopBatch : selectAllMsgs(getState(), dialogId));
|
|
2653
|
+
const desktopInput = desktopBatch.length ? desktopBatch[desktopBatch.length - 1].content : userInput;
|
|
2654
|
+
let currentContent = "";
|
|
2655
|
+
const assistantSegments = [];
|
|
2656
|
+
let assistantMessageKeys = null;
|
|
2657
|
+
let streamResult = null;
|
|
2658
|
+
let streamError = null;
|
|
2659
|
+
let reasoningBuffer = "";
|
|
2660
|
+
const activeToolMessages = /* @__PURE__ */ new Map();
|
|
2661
|
+
let desktopToolExecutionLocation = void 0;
|
|
2662
|
+
const ensureAssistantMessageKeys = () => {
|
|
2663
|
+
if (!assistantMessageKeys) {
|
|
2664
|
+
assistantMessageKeys = createDialogMessageKeyAndId(dialogId);
|
|
2665
|
+
assistantSegments.push({
|
|
2666
|
+
key: assistantMessageKeys.key,
|
|
2667
|
+
messageId: assistantMessageKeys.messageId,
|
|
2668
|
+
content: "",
|
|
2669
|
+
finalized: false,
|
|
2670
|
+
toolCallIds: []
|
|
2671
|
+
});
|
|
2672
|
+
remoteTransientMessageId = assistantMessageKeys.messageId;
|
|
2673
|
+
}
|
|
2674
|
+
return assistantMessageKeys;
|
|
2675
|
+
};
|
|
2676
|
+
const streamDesktopAssistantUpsert = () => {
|
|
2677
|
+
const { key: msgKey2, messageId: messageId2 } = ensureAssistantMessageKeys();
|
|
2678
|
+
const segment2 = assistantSegments[assistantSegments.length - 1];
|
|
2601
2679
|
segment2.content = currentContent;
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
if (assistantMessageKeys && (currentContent.length > 0 || reasoningBuffer.length > 0)) {
|
|
2605
|
-
dispatch(updateToolMessage({
|
|
2606
|
-
id: assistantMessageKeys.messageId,
|
|
2680
|
+
dispatch(messageStreaming({
|
|
2681
|
+
id: messageId2,
|
|
2607
2682
|
dialogId,
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2683
|
+
dbKey: msgKey2,
|
|
2684
|
+
content: currentContent,
|
|
2685
|
+
role: "assistant",
|
|
2686
|
+
isStreaming: true,
|
|
2687
|
+
thinkContent: reasoningBuffer,
|
|
2688
|
+
...desktopMessageMetadata
|
|
2613
2689
|
}));
|
|
2614
|
-
}
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
const
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
// adapter 内部,runtime 没有任何 deadline)就会无限静默。
|
|
2636
|
-
// 量级必须大于 runtime 自己的 idle 窗(默认 10 分钟无新输出
|
|
2637
|
-
// 才放弃,见 localLoop.DEFAULT_LLM_REQUEST_TIMEOUT_MS),
|
|
2638
|
-
// 否则一个健康的慢思考轮次会被客户端提前判死,用户拿到的是
|
|
2639
|
-
// 未分类的 "stream stalled" 而不是 runtime 的
|
|
2640
|
-
// LLM_REQUEST_TIMEOUT 可操作文案。取 2× = 20 分钟:
|
|
2641
|
-
// 只兜「runtime 完全没 deadline」的真悬挂。
|
|
2642
|
-
noEventWatchdogMs: DESKTOP_SSE_NO_EVENT_WATCHDOG_MS
|
|
2643
|
-
});
|
|
2644
|
-
for await (const event of eventStream) {
|
|
2645
|
-
if (loopController.signal.aborted || thunkApi.signal.aborted) {
|
|
2646
|
-
if (w2) w2.__LOOP_STOP_REASON__ = "aborted";
|
|
2647
|
-
break;
|
|
2690
|
+
};
|
|
2691
|
+
const streamDesktopAssistantText = (text) => {
|
|
2692
|
+
currentContent += text;
|
|
2693
|
+
streamDesktopAssistantUpsert();
|
|
2694
|
+
};
|
|
2695
|
+
const finalizeCurrentAssistantSegmentForTool = () => {
|
|
2696
|
+
const segment2 = assistantSegments[assistantSegments.length - 1];
|
|
2697
|
+
if (segment2) {
|
|
2698
|
+
segment2.content = currentContent;
|
|
2699
|
+
segment2.finalized = true;
|
|
2700
|
+
}
|
|
2701
|
+
if (assistantMessageKeys && (currentContent.length > 0 || reasoningBuffer.length > 0)) {
|
|
2702
|
+
dispatch(updateToolMessage({
|
|
2703
|
+
id: assistantMessageKeys.messageId,
|
|
2704
|
+
dialogId,
|
|
2705
|
+
changes: {
|
|
2706
|
+
content: currentContent,
|
|
2707
|
+
thinkContent: reasoningBuffer,
|
|
2708
|
+
isStreaming: false
|
|
2709
|
+
}
|
|
2710
|
+
}));
|
|
2648
2711
|
}
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2712
|
+
assistantMessageKeys = null;
|
|
2713
|
+
currentContent = "";
|
|
2714
|
+
};
|
|
2715
|
+
try {
|
|
2716
|
+
const desktopAgentRef = agentConfig.dbKey || agentKey;
|
|
2717
|
+
const eventStream = await dispatch(runPendingUserBatchRequest({
|
|
2718
|
+
dialogKey,
|
|
2719
|
+
signal: loopController.signal,
|
|
2720
|
+
execution: batchExecution,
|
|
2721
|
+
requestUserInput: desktopRequestUserInput,
|
|
2722
|
+
owns: ownsDesktopTurn,
|
|
2723
|
+
start: () => {
|
|
2724
|
+
const iterator = runDesktopAgentRuntimeTurnStream({
|
|
2725
|
+
agentRef: desktopAgentRef,
|
|
2726
|
+
input: desktopInput,
|
|
2727
|
+
...desktopBatch.length ? {
|
|
2728
|
+
userMessages: desktopBatch.map((message) => ({
|
|
2729
|
+
role: "user",
|
|
2730
|
+
content: message.content,
|
|
2731
|
+
cliMessageId: message.id
|
|
2732
|
+
})),
|
|
2733
|
+
runtimeContext: { userMessageId: desktopBatch[desktopBatch.length - 1].id }
|
|
2734
|
+
} : {},
|
|
2735
|
+
...Array.isArray(contextBlocks) && contextBlocks.length > 0 ? { contextBlocks } : {},
|
|
2736
|
+
continueDialogId: dialogId,
|
|
2737
|
+
dialogKey,
|
|
2738
|
+
cwd: runtimeOptions?.cwd,
|
|
2739
|
+
restrictShellToWorkspace: runtimeOptions?.restrictShellToWorkspace === true,
|
|
2740
|
+
workspaceToolsHint: runtimeOptions?.workspaceToolsHint === true,
|
|
2741
|
+
agentConfigSnapshot: agentConfig,
|
|
2742
|
+
dialogMessages: selectAdmittedMessages(selectAllMsgs(getState(), dialogId)),
|
|
2743
|
+
signal: loopController.signal,
|
|
2744
|
+
// SSE 传输层兜底(review 修复 4):此前本调用方从不传
|
|
2745
|
+
// noEventWatchdogMs,watchdog 永远关闭——「已有安全网」只是
|
|
2746
|
+
// 错觉,挂起点若在 provider.complete 之外(resolveProvider /
|
|
2747
|
+
// adapter 内部,runtime 没有任何 deadline)就会无限静默。
|
|
2748
|
+
// 量级必须大于 runtime 自己的 idle 窗(默认 10 分钟无新输出
|
|
2749
|
+
// 才放弃,见 localLoop.DEFAULT_LLM_REQUEST_TIMEOUT_MS),
|
|
2750
|
+
// 否则一个健康的慢思考轮次会被客户端提前判死,用户拿到的是
|
|
2751
|
+
// 未分类的 "stream stalled" 而不是 runtime 的
|
|
2752
|
+
// LLM_REQUEST_TIMEOUT 可操作文案。取 2× = 20 分钟:
|
|
2753
|
+
// 只兜「runtime 完全没 deadline」的真悬挂。
|
|
2754
|
+
noEventWatchdogMs: DESKTOP_SSE_NO_EVENT_WATCHDOG_MS
|
|
2755
|
+
});
|
|
2756
|
+
const first = iterator.next();
|
|
2757
|
+
return async function* () {
|
|
2758
|
+
const event = await first;
|
|
2759
|
+
if (!event.done) yield event.value;
|
|
2760
|
+
yield* iterator;
|
|
2761
|
+
}();
|
|
2655
2762
|
}
|
|
2656
|
-
}
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
if (
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2763
|
+
})).unwrap();
|
|
2764
|
+
if (!eventStream || !ownsDesktopTurn()) break;
|
|
2765
|
+
for await (const event of eventStream) {
|
|
2766
|
+
if (loopController.signal.aborted || thunkApi.signal.aborted) {
|
|
2767
|
+
if (w2) w2.__LOOP_STOP_REASON__ = "aborted";
|
|
2768
|
+
break;
|
|
2769
|
+
}
|
|
2770
|
+
if (event.type === "delta") {
|
|
2771
|
+
streamDesktopAssistantText(event.text);
|
|
2772
|
+
} else if (event.type === "thinking") {
|
|
2773
|
+
if (typeof event.content === "string") {
|
|
2774
|
+
reasoningBuffer += event.content;
|
|
2775
|
+
streamDesktopAssistantUpsert();
|
|
2776
|
+
}
|
|
2777
|
+
} else if (event.type === "tool") {
|
|
2778
|
+
const toolEvent = event.event;
|
|
2779
|
+
const callId = toolEvent.toolCallId;
|
|
2780
|
+
if (!callId) continue;
|
|
2781
|
+
if (toolEvent.type === "tool-call") {
|
|
2782
|
+
attachToolCallIdToSegment(assistantSegments, callId);
|
|
2783
|
+
finalizeCurrentAssistantSegmentForTool();
|
|
2784
|
+
const { key: dbKey, messageId: toolMsgId } = createDialogMessageKeyAndId(dialogId);
|
|
2785
|
+
const toolMsg = {
|
|
2786
|
+
id: toolMsgId,
|
|
2787
|
+
dialogId,
|
|
2788
|
+
dbKey,
|
|
2789
|
+
role: "tool",
|
|
2790
|
+
content: "",
|
|
2791
|
+
isStreaming: true,
|
|
2792
|
+
toolName: toolEvent.toolName,
|
|
2793
|
+
toolCallId: callId,
|
|
2794
|
+
// F2: 实际执行位置(服务端/runtime 投影)挂到 tool
|
|
2795
|
+
// 卡片 metadata。优先事件自带 metadata(runtime
|
|
2796
|
+
// 投影层直接注入的同名字段),兜底用 turn 级
|
|
2797
|
+
// execution_location 帧。缺失/不合法时渲染层
|
|
2798
|
+
// projectToolExecutionLocation 收敛为 unknown。
|
|
2799
|
+
metadata: {
|
|
2800
|
+
...isRecord(toolEvent.metadata) ? toolEvent.metadata : {},
|
|
2801
|
+
...desktopToolExecutionLocation !== void 0 && !(isRecord(toolEvent.metadata) && toolEvent.metadata.executionLocation !== void 0) ? { executionLocation: desktopToolExecutionLocation } : {},
|
|
2802
|
+
...toolEvent.argumentsPreview ? { argumentsPreview: toolEvent.argumentsPreview } : {}
|
|
2803
|
+
},
|
|
2804
|
+
...toolEvent.argumentsPreview ? {
|
|
2805
|
+
toolPayload: {
|
|
2806
|
+
input: {
|
|
2807
|
+
command: toolEvent.argumentsPreview,
|
|
2808
|
+
cmd: toolEvent.argumentsPreview
|
|
2809
|
+
}
|
|
2688
2810
|
}
|
|
2689
|
-
}
|
|
2690
|
-
} : {}
|
|
2691
|
-
};
|
|
2692
|
-
activeToolMessages.set(callId, toolMsg);
|
|
2693
|
-
dispatch(messageStreaming(toolMsg));
|
|
2694
|
-
} else if (toolEvent.type === "tool-result" || toolEvent.type === "tool-error") {
|
|
2695
|
-
const existing = activeToolMessages.get(callId);
|
|
2696
|
-
if (existing) {
|
|
2697
|
-
const isError = toolEvent.type === "tool-error";
|
|
2698
|
-
const existingMeta = asRecordOrEmpty(existing.metadata);
|
|
2699
|
-
const existingInput = isRecord(existing.toolPayload?.input) ? existing.toolPayload.input : {};
|
|
2700
|
-
const mergedMeta = {
|
|
2701
|
-
...existingMeta,
|
|
2702
|
-
...toolEvent.metadata,
|
|
2703
|
-
...isError ? { error: true, message: toolEvent.message } : {},
|
|
2704
|
-
// 服务端/runtime 已在事件 metadata 带
|
|
2705
|
-
// executionLocation 时尊重之;tool-call 阶段
|
|
2706
|
-
// 已写入的值由 existingMeta 保留;仅当两边都
|
|
2707
|
-
// 没有且 turn 级 execution_location 帧存在时
|
|
2708
|
-
// 兜底补上,绝不覆盖已有值。
|
|
2709
|
-
...existingMeta.executionLocation === void 0 && (!isRecord(toolEvent.metadata) || toolEvent.metadata.executionLocation === void 0) && desktopToolExecutionLocation !== void 0 ? { executionLocation: desktopToolExecutionLocation } : {}
|
|
2710
|
-
};
|
|
2711
|
-
const toolResultMsg = {
|
|
2712
|
-
...existing,
|
|
2713
|
-
isStreaming: false,
|
|
2714
|
-
content: projectDesktopToolUiContent({
|
|
2715
|
-
toolName: toolEvent.toolName || existing.toolName,
|
|
2716
|
-
content: toolEvent.content,
|
|
2717
|
-
summary: toolEvent.summary,
|
|
2718
|
-
message: toolEvent.message,
|
|
2719
|
-
metadata: mergedMeta,
|
|
2720
|
-
argumentsPreview: asOptionalTrimmedString(mergedMeta.argumentsPreview) || asOptionalTrimmedString(existingInput.command) || asOptionalTrimmedString(existingInput.cmd) || void 0
|
|
2721
|
-
}),
|
|
2722
|
-
metadata: mergedMeta
|
|
2811
|
+
} : {}
|
|
2723
2812
|
};
|
|
2724
|
-
activeToolMessages.set(callId,
|
|
2725
|
-
dispatch(messageStreaming(
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2813
|
+
activeToolMessages.set(callId, toolMsg);
|
|
2814
|
+
dispatch(messageStreaming(toolMsg));
|
|
2815
|
+
} else if (toolEvent.type === "tool-result" || toolEvent.type === "tool-error") {
|
|
2816
|
+
const existing = activeToolMessages.get(callId);
|
|
2817
|
+
if (existing) {
|
|
2818
|
+
const isError = toolEvent.type === "tool-error";
|
|
2819
|
+
const existingMeta = asRecordOrEmpty(existing.metadata);
|
|
2820
|
+
const existingInput = isRecord(existing.toolPayload?.input) ? existing.toolPayload.input : {};
|
|
2821
|
+
const mergedMeta = {
|
|
2822
|
+
...existingMeta,
|
|
2823
|
+
...toolEvent.metadata,
|
|
2824
|
+
...isError ? { error: true, message: toolEvent.message } : {},
|
|
2825
|
+
// 服务端/runtime 已在事件 metadata 带
|
|
2826
|
+
// executionLocation 时尊重之;tool-call 阶段
|
|
2827
|
+
// 已写入的值由 existingMeta 保留;仅当两边都
|
|
2828
|
+
// 没有且 turn 级 execution_location 帧存在时
|
|
2829
|
+
// 兜底补上,绝不覆盖已有值。
|
|
2830
|
+
...existingMeta.executionLocation === void 0 && (!isRecord(toolEvent.metadata) || toolEvent.metadata.executionLocation === void 0) && desktopToolExecutionLocation !== void 0 ? { executionLocation: desktopToolExecutionLocation } : {}
|
|
2831
|
+
};
|
|
2832
|
+
const toolResultMsg = {
|
|
2833
|
+
...existing,
|
|
2834
|
+
isStreaming: false,
|
|
2835
|
+
content: projectDesktopToolUiContent({
|
|
2836
|
+
toolName: toolEvent.toolName || existing.toolName,
|
|
2837
|
+
content: toolEvent.content,
|
|
2838
|
+
summary: toolEvent.summary,
|
|
2839
|
+
message: toolEvent.message,
|
|
2840
|
+
metadata: mergedMeta,
|
|
2841
|
+
argumentsPreview: asOptionalTrimmedString(mergedMeta.argumentsPreview) || asOptionalTrimmedString(existingInput.command) || asOptionalTrimmedString(existingInput.cmd) || void 0
|
|
2842
|
+
}),
|
|
2843
|
+
metadata: mergedMeta
|
|
2844
|
+
};
|
|
2845
|
+
activeToolMessages.set(callId, toolResultMsg);
|
|
2846
|
+
dispatch(messageStreaming(toolResultMsg));
|
|
2847
|
+
const resultToolName = toolEvent.toolName || existing.toolName;
|
|
2848
|
+
if (!isError) {
|
|
2849
|
+
deliverHtmlArtifactToolResult(resultToolName, toolEvent.content, dialogKey);
|
|
2850
|
+
}
|
|
2729
2851
|
}
|
|
2730
2852
|
}
|
|
2853
|
+
} else if (event.type === "status") {
|
|
2854
|
+
const phase = event.phase === "validating-context" ? "validating" : event.phase;
|
|
2855
|
+
setDialogTurnPhase({ phase, dialogKey, turnId: turnPhaseTurnId ?? void 0 });
|
|
2856
|
+
} else if (event.type === "execution_location") {
|
|
2857
|
+
desktopToolExecutionLocation = event.location;
|
|
2858
|
+
} else if (event.type === "action_gate") {
|
|
2859
|
+
pushGate(
|
|
2860
|
+
event.gate,
|
|
2861
|
+
targetForRunKind("desktop-local")
|
|
2862
|
+
);
|
|
2863
|
+
} else if (event.type === "done") {
|
|
2864
|
+
streamResult = event.result;
|
|
2865
|
+
} else if (event.type === "error") {
|
|
2866
|
+
streamError = event.error;
|
|
2731
2867
|
}
|
|
2732
|
-
}
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
streamResult = event.result;
|
|
2739
|
-
} else if (event.type === "error") {
|
|
2740
|
-
streamError = event.error;
|
|
2868
|
+
}
|
|
2869
|
+
} catch (err) {
|
|
2870
|
+
if (isAbortError(err) || loopController.signal.aborted || thunkApi.signal.aborted) {
|
|
2871
|
+
if (w2) w2.__LOOP_STOP_REASON__ = "aborted";
|
|
2872
|
+
} else {
|
|
2873
|
+
streamError = err?.message || "Local turn read stream error";
|
|
2741
2874
|
}
|
|
2742
2875
|
}
|
|
2743
|
-
|
|
2744
|
-
if (isAbortError(err) || loopController.signal.aborted || thunkApi.signal.aborted) {
|
|
2876
|
+
if (loopController.signal.aborted || thunkApi.signal.aborted || typeof streamError === "string" && /operation was aborted/i.test(streamError)) {
|
|
2745
2877
|
if (w2) w2.__LOOP_STOP_REASON__ = "aborted";
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
const stopKeys = assistantMessageKeys;
|
|
2753
|
-
if (stopKeys) {
|
|
2754
|
-
const last = assistantSegments[assistantSegments.length - 1];
|
|
2755
|
-
if (last && last.messageId === stopKeys.messageId) {
|
|
2756
|
-
last.content = currentContent;
|
|
2878
|
+
const stopKeys = assistantMessageKeys;
|
|
2879
|
+
if (stopKeys) {
|
|
2880
|
+
const last = assistantSegments[assistantSegments.length - 1];
|
|
2881
|
+
if (last && last.messageId === stopKeys.messageId) {
|
|
2882
|
+
last.content = currentContent;
|
|
2883
|
+
}
|
|
2757
2884
|
}
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
typeof toolName === "string" && toolName ? toolName : "tool"
|
|
2766
|
-
);
|
|
2767
|
-
}
|
|
2768
|
-
for (const segment2 of assistantSegments) {
|
|
2769
|
-
const hasContent = segment2.content.trim().length > 0;
|
|
2770
|
-
const hasToolCalls = segment2.toolCallIds && segment2.toolCallIds.length > 0;
|
|
2771
|
-
if (hasContent || hasToolCalls) {
|
|
2772
|
-
const stopToolCalls = buildMinimalToolCallsFromIds(
|
|
2773
|
-
segment2.toolCallIds,
|
|
2774
|
-
stopToolNameById
|
|
2885
|
+
const stopToolNameById = /* @__PURE__ */ new Map();
|
|
2886
|
+
for (const [callId, toolMsg] of activeToolMessages) {
|
|
2887
|
+
if (!toolMessageWillPersist(toolMsg)) continue;
|
|
2888
|
+
const toolName = toolMsg?.toolName;
|
|
2889
|
+
stopToolNameById.set(
|
|
2890
|
+
callId,
|
|
2891
|
+
typeof toolName === "string" && toolName ? toolName : "tool"
|
|
2775
2892
|
);
|
|
2776
|
-
await persistMessageWithFixedId(dispatch, {
|
|
2777
|
-
dialogId,
|
|
2778
|
-
id: segment2.messageId,
|
|
2779
|
-
dbKey: segment2.key,
|
|
2780
|
-
role: "assistant",
|
|
2781
|
-
content: segment2.content,
|
|
2782
|
-
...stopToolCalls.length > 0 ? { tool_calls: stopToolCalls } : {},
|
|
2783
|
-
...desktopMessageMetadata,
|
|
2784
|
-
userId: selectIdentityUserId(getState())
|
|
2785
|
-
});
|
|
2786
|
-
} else {
|
|
2787
|
-
dispatch(removeTransientMessage(segment2.messageId));
|
|
2788
2893
|
}
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2894
|
+
for (const segment2 of assistantSegments) {
|
|
2895
|
+
const hasContent = segment2.content.trim().length > 0;
|
|
2896
|
+
const hasToolCalls = segment2.toolCallIds && segment2.toolCallIds.length > 0;
|
|
2897
|
+
if (hasContent || hasToolCalls) {
|
|
2898
|
+
const stopToolCalls = buildMinimalToolCallsFromIds(
|
|
2899
|
+
segment2.toolCallIds,
|
|
2900
|
+
stopToolNameById
|
|
2901
|
+
);
|
|
2902
|
+
await persistMessageWithFixedId(dispatch, {
|
|
2903
|
+
dialogId,
|
|
2904
|
+
id: segment2.messageId,
|
|
2905
|
+
dbKey: segment2.key,
|
|
2906
|
+
role: "assistant",
|
|
2907
|
+
content: segment2.content,
|
|
2908
|
+
...stopToolCalls.length > 0 ? { tool_calls: stopToolCalls } : {},
|
|
2909
|
+
...desktopMessageMetadata,
|
|
2910
|
+
userId: selectIdentityUserId(getState())
|
|
2911
|
+
});
|
|
2912
|
+
} else {
|
|
2913
|
+
dispatch(removeTransientMessage(segment2.messageId));
|
|
2914
|
+
}
|
|
2797
2915
|
}
|
|
2798
|
-
const
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
typeof toolName === "string" && toolName ? toolName : "tool"
|
|
2817
|
-
);
|
|
2916
|
+
const durableTools = [];
|
|
2917
|
+
for (const toolMsg of activeToolMessages.values()) {
|
|
2918
|
+
const content = toolMsg?.content;
|
|
2919
|
+
const hasContent = typeof content === "string" ? content.trim().length > 0 : Array.isArray(content) && content.length > 0;
|
|
2920
|
+
if (!hasContent) {
|
|
2921
|
+
dispatch(removeTransientMessage(toolMsg.id));
|
|
2922
|
+
continue;
|
|
2923
|
+
}
|
|
2924
|
+
const stopped = { ...toolMsg, isStreaming: false };
|
|
2925
|
+
dispatch(messageStreaming(stopped));
|
|
2926
|
+
durableTools.push(stopped);
|
|
2927
|
+
}
|
|
2928
|
+
await persistToolMessages(dispatch, durableTools, {
|
|
2929
|
+
isStreaming: false,
|
|
2930
|
+
soft: true
|
|
2931
|
+
});
|
|
2932
|
+
remoteTransientMessageFinalized = true;
|
|
2933
|
+
return { aborted: true };
|
|
2818
2934
|
}
|
|
2819
|
-
|
|
2820
|
-
const
|
|
2821
|
-
const
|
|
2822
|
-
|
|
2823
|
-
const
|
|
2824
|
-
|
|
2825
|
-
|
|
2935
|
+
const finalizeDesktopTurnOnError = async (errorText) => {
|
|
2936
|
+
const errorToolNameById = /* @__PURE__ */ new Map();
|
|
2937
|
+
for (const [callId, toolMsg] of activeToolMessages) {
|
|
2938
|
+
if (!toolMessageWillPersist(toolMsg)) continue;
|
|
2939
|
+
const toolName = toolMsg?.toolName;
|
|
2940
|
+
errorToolNameById.set(
|
|
2941
|
+
callId,
|
|
2942
|
+
typeof toolName === "string" && toolName ? toolName : "tool"
|
|
2826
2943
|
);
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2944
|
+
}
|
|
2945
|
+
for (const segment2 of assistantSegments) {
|
|
2946
|
+
const hasContent = segment2.content.trim().length > 0;
|
|
2947
|
+
const hasToolCalls = segment2.toolCallIds && segment2.toolCallIds.length > 0;
|
|
2948
|
+
if (hasContent || hasToolCalls) {
|
|
2949
|
+
const errorToolCalls = buildMinimalToolCallsFromIds(
|
|
2950
|
+
segment2.toolCallIds,
|
|
2951
|
+
errorToolNameById
|
|
2952
|
+
);
|
|
2953
|
+
await persistMessageWithFixedId(dispatch, {
|
|
2954
|
+
dialogId,
|
|
2955
|
+
id: segment2.messageId,
|
|
2956
|
+
dbKey: segment2.key,
|
|
2957
|
+
role: "assistant",
|
|
2958
|
+
content: segment2.content,
|
|
2959
|
+
...errorToolCalls.length > 0 ? { tool_calls: errorToolCalls } : {},
|
|
2960
|
+
...desktopMessageMetadata,
|
|
2961
|
+
userId: selectIdentityUserId(getState())
|
|
2962
|
+
});
|
|
2963
|
+
if (hasContent) {
|
|
2964
|
+
dispatch(finalizeTransientMessageOnError({
|
|
2965
|
+
id: segment2.messageId,
|
|
2966
|
+
error: errorText
|
|
2967
|
+
}));
|
|
2968
|
+
}
|
|
2969
|
+
} else {
|
|
2838
2970
|
dispatch(finalizeTransientMessageOnError({
|
|
2839
2971
|
id: segment2.messageId,
|
|
2840
2972
|
error: errorText
|
|
2841
2973
|
}));
|
|
2842
2974
|
}
|
|
2843
|
-
} else {
|
|
2844
|
-
dispatch(finalizeTransientMessageOnError({
|
|
2845
|
-
id: segment2.messageId,
|
|
2846
|
-
error: errorText
|
|
2847
|
-
}));
|
|
2848
2975
|
}
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
2976
|
+
const durableTools = [];
|
|
2977
|
+
for (const toolMsg of activeToolMessages.values()) {
|
|
2978
|
+
const content = toolMsg?.content;
|
|
2979
|
+
const hasContent = typeof content === "string" ? content.trim().length > 0 : Array.isArray(content) && content.length > 0;
|
|
2980
|
+
if (!hasContent) {
|
|
2981
|
+
dispatch(removeTransientMessage(toolMsg.id));
|
|
2982
|
+
continue;
|
|
2983
|
+
}
|
|
2984
|
+
const stopped = { ...toolMsg, isStreaming: false };
|
|
2985
|
+
dispatch(messageStreaming(stopped));
|
|
2986
|
+
durableTools.push(stopped);
|
|
2857
2987
|
}
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
};
|
|
2869
|
-
if (streamError) {
|
|
2870
|
-
const info = classifyLocalTurnStreamError(streamError);
|
|
2871
|
-
const finalError = info.actionHint ? `${streamError}
|
|
2988
|
+
await persistToolMessages(dispatch, durableTools, {
|
|
2989
|
+
isStreaming: false,
|
|
2990
|
+
soft: true
|
|
2991
|
+
});
|
|
2992
|
+
remoteTransientMessageFinalized = true;
|
|
2993
|
+
setLoopStopReason("error");
|
|
2994
|
+
};
|
|
2995
|
+
if (streamError) {
|
|
2996
|
+
const info = classifyLocalTurnStreamError(streamError);
|
|
2997
|
+
const finalError = info.actionHint ? `${streamError}
|
|
2872
2998
|
|
|
2873
2999
|
${info.actionHint}` : streamError;
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
|
|
3000
|
+
await finalizeDesktopTurnOnError(finalError);
|
|
3001
|
+
return rejectWithValue(finalError);
|
|
3002
|
+
}
|
|
3003
|
+
if (!streamResult) {
|
|
3004
|
+
const message = "Local turn stream closed unexpectedly without result";
|
|
3005
|
+
await finalizeDesktopTurnOnError(message);
|
|
3006
|
+
return rejectWithValue(message);
|
|
3007
|
+
}
|
|
3008
|
+
const desktopTurnMessages = streamResult.turnMessages || [];
|
|
3009
|
+
const hasSegmentWithCallIds = assistantSegments.some(
|
|
3010
|
+
(s) => s.toolCallIds.length > 0
|
|
3011
|
+
);
|
|
3012
|
+
if (!hasSegmentWithCallIds) {
|
|
3013
|
+
const doneOnlyAssistantCalls = desktopTurnMessages.filter(
|
|
3014
|
+
(m) => m?.role === "assistant" && Array.isArray(m.tool_calls) && m.tool_calls.length > 0
|
|
3015
|
+
).flatMap((m) => m.tool_calls.map((tc) => tc?.id)).filter((id) => typeof id === "string");
|
|
3016
|
+
if (doneOnlyAssistantCalls.length > 0) {
|
|
3017
|
+
ensureAssistantMessageKeys();
|
|
3018
|
+
for (const callId of doneOnlyAssistantCalls) {
|
|
3019
|
+
attachToolCallIdToSegment(assistantSegments, callId);
|
|
3020
|
+
}
|
|
3021
|
+
if (currentContent.length === 0) {
|
|
3022
|
+
finalizeCurrentAssistantSegmentForTool();
|
|
3023
|
+
}
|
|
2894
3024
|
}
|
|
2895
|
-
|
|
2896
|
-
|
|
3025
|
+
}
|
|
3026
|
+
if (activeToolMessages.size === 0) {
|
|
3027
|
+
for (const toolMessage of buildDesktopRuntimeToolMessagesForUi({
|
|
3028
|
+
dialogId,
|
|
3029
|
+
turnMessages: desktopTurnMessages
|
|
3030
|
+
})) {
|
|
3031
|
+
dispatch(messageStreaming(toolMessage));
|
|
3032
|
+
activeToolMessages.set(
|
|
3033
|
+
asTrimmedString(toolMessage.toolCallId) || toolMessage.id,
|
|
3034
|
+
toolMessage
|
|
3035
|
+
);
|
|
2897
3036
|
}
|
|
2898
3037
|
}
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
3038
|
+
await persistToolMessages(
|
|
3039
|
+
dispatch,
|
|
3040
|
+
activeToolMessages.values(),
|
|
3041
|
+
{ isStreaming: false, soft: true }
|
|
3042
|
+
);
|
|
3043
|
+
const earlierFinalizedSegments = selectPersistableFinalizedSegments(assistantSegments);
|
|
3044
|
+
for (const segment2 of earlierFinalizedSegments) {
|
|
3045
|
+
const segmentToolCalls = resolveSegmentToolCalls(
|
|
3046
|
+
segment2.toolCallIds,
|
|
3047
|
+
desktopTurnMessages
|
|
2909
3048
|
);
|
|
3049
|
+
dispatch(write({
|
|
3050
|
+
data: {
|
|
3051
|
+
id: segment2.messageId,
|
|
3052
|
+
dbKey: segment2.key,
|
|
3053
|
+
dialogId,
|
|
3054
|
+
content: segment2.content,
|
|
3055
|
+
role: "assistant",
|
|
3056
|
+
isStreaming: false,
|
|
3057
|
+
type: "msg" /* MSG */,
|
|
3058
|
+
...segmentToolCalls.length > 0 ? { tool_calls: segmentToolCalls } : {},
|
|
3059
|
+
...desktopMessageMetadata
|
|
3060
|
+
},
|
|
3061
|
+
customKey: segment2.key
|
|
3062
|
+
}));
|
|
2910
3063
|
}
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
{
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
dispatch(write({
|
|
2924
|
-
data: {
|
|
2925
|
-
id: segment2.messageId,
|
|
2926
|
-
dbKey: segment2.key,
|
|
2927
|
-
dialogId,
|
|
2928
|
-
content: segment2.content,
|
|
2929
|
-
role: "assistant",
|
|
2930
|
-
isStreaming: false,
|
|
2931
|
-
type: "msg" /* MSG */,
|
|
2932
|
-
...segmentToolCalls.length > 0 ? { tool_calls: segmentToolCalls } : {},
|
|
2933
|
-
...desktopMessageMetadata
|
|
2934
|
-
},
|
|
2935
|
-
customKey: segment2.key
|
|
3064
|
+
const { key: msgKey, messageId } = ensureAssistantMessageKeys();
|
|
3065
|
+
const lastSegmentContent = hasInlineExecutedToolCalls(streamResult) ? currentContent || "" : streamResult.content || currentContent || "";
|
|
3066
|
+
const segment = assistantSegments[assistantSegments.length - 1];
|
|
3067
|
+
segment.content = lastSegmentContent;
|
|
3068
|
+
dispatch(messageStreaming({
|
|
3069
|
+
id: messageId,
|
|
3070
|
+
dialogId,
|
|
3071
|
+
dbKey: msgKey,
|
|
3072
|
+
content: lastSegmentContent,
|
|
3073
|
+
role: "assistant",
|
|
3074
|
+
isStreaming: false,
|
|
3075
|
+
...desktopMessageMetadata
|
|
2936
3076
|
}));
|
|
3077
|
+
const lastSegmentToolCalls = segment ? resolveSegmentToolCalls(segment.toolCallIds, desktopTurnMessages) : [];
|
|
3078
|
+
await dispatch(messageStreamEnd({
|
|
3079
|
+
finalContentBuffer: [
|
|
3080
|
+
{
|
|
3081
|
+
type: "text",
|
|
3082
|
+
text: lastSegmentContent
|
|
3083
|
+
}
|
|
3084
|
+
],
|
|
3085
|
+
totalUsage: streamResult.usage ?? void 0,
|
|
3086
|
+
billingUsageRecords: streamResult.usageRecords,
|
|
3087
|
+
messageId,
|
|
3088
|
+
msgKey,
|
|
3089
|
+
agentConfig,
|
|
3090
|
+
dialogId,
|
|
3091
|
+
dialogKey,
|
|
3092
|
+
// 优先用本 turn 累计的 thinking SSE;为空时兜底 streamResult.reasoning_content
|
|
3093
|
+
// (provider 在 SSE 流内累计返回的 reasoning_content)。
|
|
3094
|
+
reasoningBuffer: reasoningBuffer || (typeof streamResult?.reasoning_content === "string" ? streamResult.reasoning_content : ""),
|
|
3095
|
+
toolCalls: lastSegmentToolCalls,
|
|
3096
|
+
// 把 provider 报告的 finish_reason 透传给 messageStreamEnd,
|
|
3097
|
+
// 由 assembleFinalAssistantMessage 决定是否写进最终 Message。
|
|
3098
|
+
finishReason: streamResult.finish_reason ?? void 0,
|
|
3099
|
+
messageMetadata: desktopMessageMetadata
|
|
3100
|
+
})).unwrap();
|
|
3101
|
+
remoteTransientMessageFinalized = true;
|
|
3102
|
+
if (!isUserTurn || !ownsDesktopTurn() || streamResult.finish_reason !== "stop" || streamResult.stopReason && streamResult.stopReason !== "done" || streamResult.pendingInteraction || streamResult.hasPendingInteraction || streamResult.error || streamResult.emptyAssistantFallbackReason) {
|
|
3103
|
+
return { usage: streamResult.usage ?? void 0 };
|
|
3104
|
+
}
|
|
3105
|
+
desktopBatch = await admitDesktopBatch();
|
|
3106
|
+
if (!ownsDesktopTurn()) return { aborted: true };
|
|
3107
|
+
if (!desktopBatch.length) return { usage: streamResult.usage ?? void 0 };
|
|
2937
3108
|
}
|
|
2938
|
-
|
|
2939
|
-
const lastSegmentContent = hasInlineExecutedToolCalls(streamResult) ? currentContent || "" : streamResult.content || currentContent || "";
|
|
2940
|
-
const segment = assistantSegments[assistantSegments.length - 1];
|
|
2941
|
-
segment.content = lastSegmentContent;
|
|
2942
|
-
dispatch(messageStreaming({
|
|
2943
|
-
id: messageId,
|
|
2944
|
-
dialogId,
|
|
2945
|
-
dbKey: msgKey,
|
|
2946
|
-
content: lastSegmentContent,
|
|
2947
|
-
role: "assistant",
|
|
2948
|
-
isStreaming: false,
|
|
2949
|
-
...desktopMessageMetadata
|
|
2950
|
-
}));
|
|
2951
|
-
const lastSegmentToolCalls = segment ? resolveSegmentToolCalls(segment.toolCallIds, desktopTurnMessages) : [];
|
|
2952
|
-
await dispatch(messageStreamEnd({
|
|
2953
|
-
finalContentBuffer: [
|
|
2954
|
-
{
|
|
2955
|
-
type: "text",
|
|
2956
|
-
text: lastSegmentContent
|
|
2957
|
-
}
|
|
2958
|
-
],
|
|
2959
|
-
totalUsage: streamResult.usage ?? void 0,
|
|
2960
|
-
billingUsageRecords: streamResult.usageRecords,
|
|
2961
|
-
messageId,
|
|
2962
|
-
msgKey,
|
|
2963
|
-
agentConfig,
|
|
2964
|
-
dialogId,
|
|
2965
|
-
dialogKey,
|
|
2966
|
-
// 优先用本 turn 累计的 thinking SSE;为空时兜底 streamResult.reasoning_content
|
|
2967
|
-
// (provider 在 SSE 流内累计返回的 reasoning_content)。
|
|
2968
|
-
reasoningBuffer: reasoningBuffer || (typeof streamResult?.reasoning_content === "string" ? streamResult.reasoning_content : ""),
|
|
2969
|
-
toolCalls: lastSegmentToolCalls,
|
|
2970
|
-
// 把 provider 报告的 finish_reason 透传给 messageStreamEnd,
|
|
2971
|
-
// 由 assembleFinalAssistantMessage 决定是否写进最终 Message。
|
|
2972
|
-
finishReason: streamResult.finish_reason ?? void 0,
|
|
2973
|
-
messageMetadata: desktopMessageMetadata
|
|
2974
|
-
})).unwrap();
|
|
2975
|
-
remoteTransientMessageFinalized = true;
|
|
2976
|
-
return {
|
|
2977
|
-
usage: streamResult.usage ?? void 0
|
|
2978
|
-
};
|
|
3109
|
+
return { aborted: true };
|
|
2979
3110
|
}
|
|
2980
3111
|
const userInputText = extractAgentRunUserText(userInput);
|
|
2981
3112
|
const explicitServerBase = asOptionalTrimmedString(args.serverBase) ?? null;
|
|
@@ -2990,7 +3121,7 @@ ${info.actionHint}` : streamError;
|
|
|
2990
3121
|
} else {
|
|
2991
3122
|
const token = selectIdentityToken(state);
|
|
2992
3123
|
const authHeader = token ? `Bearer ${token}` : "";
|
|
2993
|
-
const rawMessages = selectAllMsgs(state, dialogId);
|
|
3124
|
+
const rawMessages = selectAdmittedMessages(selectAllMsgs(state, dialogId));
|
|
2994
3125
|
const visibleMessages = buildAgentViewMessages(
|
|
2995
3126
|
rawMessages,
|
|
2996
3127
|
agentConfig.dbKey
|
|
@@ -3124,6 +3255,15 @@ ${info.actionHint}` : streamError;
|
|
|
3124
3255
|
if (payload.type === "error") {
|
|
3125
3256
|
return { reject: payload.message || "\u8FDC\u7AEF Agent \u6267\u884C\u5931\u8D25" };
|
|
3126
3257
|
}
|
|
3258
|
+
if (payload.type === "action_gate" && payload.gate) {
|
|
3259
|
+
pushGate(
|
|
3260
|
+
payload.gate,
|
|
3261
|
+
targetForRunKind("server-run", {
|
|
3262
|
+
server: explicitServerBase,
|
|
3263
|
+
token
|
|
3264
|
+
})
|
|
3265
|
+
);
|
|
3266
|
+
}
|
|
3127
3267
|
if (payload.type === "agent_handoff") {
|
|
3128
3268
|
await patchDialogThreadMetadata(
|
|
3129
3269
|
dispatch,
|
|
@@ -3229,7 +3369,7 @@ ${info.actionHint}` : streamError;
|
|
|
3229
3369
|
recommendedSkillHints: turnToolContext.recommendedSkillHints,
|
|
3230
3370
|
skillPromptPatches: turnToolContext.skillPromptPatches
|
|
3231
3371
|
};
|
|
3232
|
-
const initialRawMsgs = selectAllMsgs(state, dialogId);
|
|
3372
|
+
const initialRawMsgs = selectAdmittedMessages(selectAllMsgs(state, dialogId));
|
|
3233
3373
|
const initialHistoryIds = new Set(initialRawMsgs.map((m) => m.id));
|
|
3234
3374
|
const accountSkillRuntime = agentConfigWithReferences.runtimePromptAlreadyInMessages ? null : await resolveUserSkillRuntime(agentConfigWithReferences, state.settings);
|
|
3235
3375
|
const agentConfigWithTools = resolveWebAgentRuntimeToolSurface(
|
|
@@ -3391,7 +3531,7 @@ ${info.actionHint}` : streamError;
|
|
|
3391
3531
|
mergeContexts(staticContexts2, dynamicContexts),
|
|
3392
3532
|
contextBlocks
|
|
3393
3533
|
);
|
|
3394
|
-
const rawMessages = selectAllMsgs(loopState, dialogId);
|
|
3534
|
+
const rawMessages = selectAdmittedMessages(selectAllMsgs(loopState, dialogId));
|
|
3395
3535
|
let visibleMessages = buildAgentViewMessages(
|
|
3396
3536
|
rawMessages,
|
|
3397
3537
|
agentConfigForCall.dbKey
|
|
@@ -3419,9 +3559,9 @@ ${info.actionHint}` : streamError;
|
|
|
3419
3559
|
}
|
|
3420
3560
|
}
|
|
3421
3561
|
}
|
|
3562
|
+
const requestUserInput = snapshotUserBatchInput(selectAllMsgs(loopState, dialogId));
|
|
3422
3563
|
const cleanedMessages = filterAndCleanMessages(visibleMessages);
|
|
3423
3564
|
const ctxWindow = resolveAgentContextWindow(agentConfigForCall);
|
|
3424
|
-
const summaryTokenCount = contexts.dialogSummary ? estimateTokenCount(contexts.dialogSummary) : 0;
|
|
3425
3565
|
const messagesBeforeStrip = compressOldToolResults(cleanedMessages);
|
|
3426
3566
|
const preprocessedResult = await stripImagePartsForTextOnlyAgent(
|
|
3427
3567
|
messagesBeforeStrip,
|
|
@@ -3432,49 +3572,69 @@ ${info.actionHint}` : streamError;
|
|
|
3432
3572
|
messagesBeforeStrip,
|
|
3433
3573
|
targetUserMessageId: activeTurnUserMessageId2
|
|
3434
3574
|
});
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
|
|
3575
|
+
const { bodyData, fallbackBodyData, dynamicMessages, stableMessages } = await admitWebRequest({
|
|
3576
|
+
contextWindow: ctxWindow,
|
|
3577
|
+
signal: loopController.signal,
|
|
3578
|
+
rescue: (availableHistoryTokens) => updateDialogSummaryAction({
|
|
3579
|
+
dialogKey,
|
|
3580
|
+
force: true,
|
|
3581
|
+
reason: "budget_rescue",
|
|
3582
|
+
availableHistoryTokens,
|
|
3583
|
+
contextWindow: ctxWindow,
|
|
3584
|
+
preserveLatestUserByProjection: true
|
|
3585
|
+
}, { ...thunkApi, signal: loopController.signal }),
|
|
3586
|
+
build: async () => {
|
|
3587
|
+
const summaryConfig = selectById(getState(), dialogKey);
|
|
3588
|
+
const refreshedContexts = { ...contexts, dialogSummary: summaryConfig?.summary || null };
|
|
3589
|
+
const processedMessages = projectSummaryHistory(preprocessedResult.messages, summaryConfig?.summary, summaryConfig?.summarizedBeforeId);
|
|
3590
|
+
let firstDynamicIdx = processedMessages.findIndex(
|
|
3591
|
+
(m) => m.id && !initialHistoryIds.has(m.id)
|
|
3592
|
+
);
|
|
3593
|
+
if (firstDynamicIdx === -1) firstDynamicIdx = processedMessages.length;
|
|
3594
|
+
let stableMessages2 = processedMessages.slice(0, firstDynamicIdx);
|
|
3595
|
+
let dynamicMessages2 = processedMessages.slice(firstDynamicIdx);
|
|
3596
|
+
const bodyData2 = generateRequestBody({
|
|
3597
|
+
agentConfig: effectiveAgentConfig,
|
|
3598
|
+
messages: dynamicMessages2,
|
|
3599
|
+
stableMessages: stableMessages2,
|
|
3600
|
+
userInput: userInputText,
|
|
3601
|
+
contexts: refreshedContexts,
|
|
3602
|
+
responsesState
|
|
3603
|
+
});
|
|
3604
|
+
const fallbackBodyData2 = responsesState ? generateRequestBody({
|
|
3605
|
+
agentConfig: effectiveAgentConfig,
|
|
3606
|
+
messages: dynamicMessages2,
|
|
3607
|
+
stableMessages: stableMessages2,
|
|
3608
|
+
userInput: userInputText,
|
|
3609
|
+
contexts: refreshedContexts,
|
|
3610
|
+
responsesState: null
|
|
3611
|
+
}) : void 0;
|
|
3612
|
+
return { value: { bodyData: bodyData2, fallbackBodyData: fallbackBodyData2, dynamicMessages: dynamicMessages2, stableMessages: stableMessages2 }, wireBodies: [buildResponsesRequestBodyWithTools(bodyData2, agentConfigForCall), ...fallbackBodyData2 ? [buildResponsesRequestBodyWithTools(fallbackBodyData2, agentConfigForCall)] : []] };
|
|
3613
|
+
}
|
|
3453
3614
|
});
|
|
3454
|
-
const fallbackBodyData = responsesState ? generateRequestBody({
|
|
3455
|
-
agentConfig: effectiveAgentConfig,
|
|
3456
|
-
messages: dynamicMessages,
|
|
3457
|
-
stableMessages,
|
|
3458
|
-
userInput: userInputText,
|
|
3459
|
-
contexts,
|
|
3460
|
-
responsesState: null
|
|
3461
|
-
}) : void 0;
|
|
3462
3615
|
logQuickChatPerfStage2(quickChatPerfStartedAt, "stream-agent-model-request-starting", {
|
|
3463
3616
|
responseApi: true,
|
|
3464
3617
|
dynamicMessageCount: dynamicMessages.length,
|
|
3465
3618
|
stableMessageCount: stableMessages.length
|
|
3466
3619
|
});
|
|
3467
3620
|
modelRequestStarted = true;
|
|
3468
|
-
const meta = await
|
|
3469
|
-
bodyData,
|
|
3470
|
-
agentConfig: agentConfigForCall,
|
|
3471
|
-
thunkApi,
|
|
3621
|
+
const meta = await dispatch(runPendingUserBatchRequest({
|
|
3472
3622
|
dialogKey,
|
|
3473
|
-
|
|
3474
|
-
|
|
3475
|
-
|
|
3476
|
-
|
|
3477
|
-
|
|
3623
|
+
signal: loopController.signal,
|
|
3624
|
+
execution: batchExecution,
|
|
3625
|
+
requestUserInput,
|
|
3626
|
+
start: () => sendOpenAIResponseRequest({
|
|
3627
|
+
bodyData,
|
|
3628
|
+
agentConfig: agentConfigForCall,
|
|
3629
|
+
thunkApi,
|
|
3630
|
+
dialogKey,
|
|
3631
|
+
parentMessageId: currentParentMessageId2,
|
|
3632
|
+
messageMetadata: streamingMessageMetadata,
|
|
3633
|
+
quickChatPerfStartedAt,
|
|
3634
|
+
fallbackBodyData
|
|
3635
|
+
})
|
|
3636
|
+
})).unwrap();
|
|
3637
|
+
if (!meta || loopController.signal.aborted || thunkApi.signal.aborted) break;
|
|
3478
3638
|
logQuickChatPerfStage2(quickChatPerfStartedAt, "stream-agent-model-request-finished", {
|
|
3479
3639
|
responseApi: true,
|
|
3480
3640
|
hasToolCalls: meta.hasToolCalls,
|
|
@@ -3524,6 +3684,17 @@ ${info.actionHint}` : streamError;
|
|
|
3524
3684
|
if (w2) w2.__LOOP_STOP_REASON__ = "pending";
|
|
3525
3685
|
break;
|
|
3526
3686
|
}
|
|
3687
|
+
if (!loopController.signal.aborted && !thunkApi.signal.aborted) {
|
|
3688
|
+
const admitted = await dispatch(admitPendingUserMessages({
|
|
3689
|
+
dialogKey,
|
|
3690
|
+
signal: loopController.signal
|
|
3691
|
+
})).unwrap();
|
|
3692
|
+
if (loopController.signal.aborted || thunkApi.signal.aborted) break;
|
|
3693
|
+
if (admitted.length) {
|
|
3694
|
+
activeTurnUserMessageId2 = admitted[admitted.length - 1].id;
|
|
3695
|
+
continue;
|
|
3696
|
+
}
|
|
3697
|
+
}
|
|
3527
3698
|
const afterTurnState = getState();
|
|
3528
3699
|
const queuedMessages = selectPendingUserInputQueue(afterTurnState, dialogKey);
|
|
3529
3700
|
if (queuedMessages.length > 0) {
|
|
@@ -3673,7 +3844,7 @@ ${info.actionHint}` : streamError;
|
|
|
3673
3844
|
mergeContexts(staticContexts, dynamicContexts),
|
|
3674
3845
|
contextBlocks
|
|
3675
3846
|
);
|
|
3676
|
-
const rawMessages = selectAllMsgs(loopState, dialogId);
|
|
3847
|
+
const rawMessages = selectAdmittedMessages(selectAllMsgs(loopState, dialogId));
|
|
3677
3848
|
let visibleMessages = buildAgentViewMessages(
|
|
3678
3849
|
rawMessages,
|
|
3679
3850
|
agentConfigForCall.dbKey
|
|
@@ -3701,9 +3872,9 @@ ${info.actionHint}` : streamError;
|
|
|
3701
3872
|
}
|
|
3702
3873
|
}
|
|
3703
3874
|
}
|
|
3875
|
+
const requestUserInput = snapshotUserBatchInput(selectAllMsgs(loopState, dialogId));
|
|
3704
3876
|
const cleanedMessages = filterAndCleanMessages(visibleMessages);
|
|
3705
3877
|
const ctxWindow = resolveAgentContextWindow(agentConfigForCall);
|
|
3706
|
-
const summaryTokenCount = contexts.dialogSummary ? estimateTokenCount(contexts.dialogSummary) : 0;
|
|
3707
3878
|
const messagesBeforeStrip = compressOldToolResults(cleanedMessages);
|
|
3708
3879
|
const preprocessedResult = await stripImagePartsForTextOnlyAgent(
|
|
3709
3880
|
messagesBeforeStrip,
|
|
@@ -3714,23 +3885,44 @@ ${info.actionHint}` : streamError;
|
|
|
3714
3885
|
messagesBeforeStrip,
|
|
3715
3886
|
targetUserMessageId: activeTurnUserMessageId
|
|
3716
3887
|
});
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3888
|
+
const { bodyData, dynamicMessages, stableMessages } = await admitWebRequest({
|
|
3889
|
+
contextWindow: ctxWindow,
|
|
3890
|
+
signal: loopController.signal,
|
|
3891
|
+
rescue: (availableHistoryTokens) => updateDialogSummaryAction({
|
|
3892
|
+
dialogKey,
|
|
3893
|
+
force: true,
|
|
3894
|
+
reason: "budget_rescue",
|
|
3895
|
+
availableHistoryTokens,
|
|
3896
|
+
contextWindow: ctxWindow,
|
|
3897
|
+
preserveLatestUserByProjection: true
|
|
3898
|
+
}, { ...thunkApi, signal: loopController.signal }),
|
|
3899
|
+
build: async () => {
|
|
3900
|
+
const summaryConfig = selectById(getState(), dialogKey);
|
|
3901
|
+
const refreshedContexts = { ...contexts, dialogSummary: summaryConfig?.summary || null };
|
|
3902
|
+
const processedMessages = projectSummaryHistory(preprocessedResult.messages, summaryConfig?.summary, summaryConfig?.summarizedBeforeId);
|
|
3903
|
+
let firstDynamicIdx = processedMessages.findIndex(
|
|
3904
|
+
(m) => m.id && !initialHistoryIds.has(m.id)
|
|
3905
|
+
);
|
|
3906
|
+
if (firstDynamicIdx === -1) firstDynamicIdx = processedMessages.length;
|
|
3907
|
+
let stableMessages2 = processedMessages.slice(0, firstDynamicIdx);
|
|
3908
|
+
let dynamicMessages2 = processedMessages.slice(firstDynamicIdx);
|
|
3909
|
+
const bodyData2 = generateRequestBody({
|
|
3910
|
+
agentConfig: effectiveAgentConfig,
|
|
3911
|
+
messages: dynamicMessages2,
|
|
3912
|
+
stableMessages: stableMessages2,
|
|
3913
|
+
userInput: userInputText,
|
|
3914
|
+
contexts: refreshedContexts
|
|
3915
|
+
});
|
|
3916
|
+
const finalBody = await inlineImageUrlsForCustomProvider(
|
|
3917
|
+
buildFinalCompletionsRequestBody(
|
|
3918
|
+
bodyData2,
|
|
3919
|
+
agentConfigForCall,
|
|
3920
|
+
shouldDisableQuickChatToolsForDirectAnswer(quickChatPerfStartedAt, userInput, runtimeOptions, currentDialog)
|
|
3921
|
+
),
|
|
3922
|
+
{ shouldInline: shouldInlineImageUrlsForAgent(agentConfigForCall), signal: loopController.signal }
|
|
3923
|
+
);
|
|
3924
|
+
return { value: { bodyData: finalBody, dynamicMessages: dynamicMessages2, stableMessages: stableMessages2 }, wireBodies: [buildEmptyCompletionRepairBody(finalBody)] };
|
|
3925
|
+
}
|
|
3734
3926
|
});
|
|
3735
3927
|
logQuickChatPerfStage2(quickChatPerfStartedAt, "stream-agent-model-request-starting", {
|
|
3736
3928
|
responseApi: false,
|
|
@@ -3754,16 +3946,23 @@ ${info.actionHint}` : streamError;
|
|
|
3754
3946
|
}
|
|
3755
3947
|
);
|
|
3756
3948
|
}
|
|
3757
|
-
const meta = await
|
|
3758
|
-
bodyData,
|
|
3759
|
-
agentConfig: agentConfigForCall,
|
|
3760
|
-
thunkApi,
|
|
3949
|
+
const meta = await dispatch(runPendingUserBatchRequest({
|
|
3761
3950
|
dialogKey,
|
|
3762
|
-
|
|
3763
|
-
|
|
3764
|
-
|
|
3765
|
-
|
|
3766
|
-
|
|
3951
|
+
signal: loopController.signal,
|
|
3952
|
+
execution: batchExecution,
|
|
3953
|
+
requestUserInput,
|
|
3954
|
+
start: () => sendOpenAICompletionsRequest({
|
|
3955
|
+
bodyData,
|
|
3956
|
+
agentConfig: agentConfigForCall,
|
|
3957
|
+
thunkApi,
|
|
3958
|
+
dialogKey,
|
|
3959
|
+
parentMessageId: currentParentMessageId,
|
|
3960
|
+
messageMetadata: streamingMessageMetadata,
|
|
3961
|
+
disableToolsForThisRequest,
|
|
3962
|
+
quickChatPerfStartedAt
|
|
3963
|
+
})
|
|
3964
|
+
})).unwrap();
|
|
3965
|
+
if (!meta || loopController.signal.aborted || thunkApi.signal.aborted) break;
|
|
3767
3966
|
logQuickChatPerfStage2(quickChatPerfStartedAt, "stream-agent-model-request-finished", {
|
|
3768
3967
|
responseApi: false,
|
|
3769
3968
|
hasToolCalls: meta.hasToolCalls,
|
|
@@ -3784,6 +3983,17 @@ ${info.actionHint}` : streamError;
|
|
|
3784
3983
|
if (w) w.__LOOP_STOP_REASON__ = "pending";
|
|
3785
3984
|
break;
|
|
3786
3985
|
}
|
|
3986
|
+
if (!loopController.signal.aborted && !thunkApi.signal.aborted) {
|
|
3987
|
+
const admitted = await dispatch(admitPendingUserMessages({
|
|
3988
|
+
dialogKey,
|
|
3989
|
+
signal: loopController.signal
|
|
3990
|
+
})).unwrap();
|
|
3991
|
+
if (loopController.signal.aborted || thunkApi.signal.aborted) break;
|
|
3992
|
+
if (admitted.length) {
|
|
3993
|
+
activeTurnUserMessageId = admitted[admitted.length - 1].id;
|
|
3994
|
+
continue;
|
|
3995
|
+
}
|
|
3996
|
+
}
|
|
3787
3997
|
const afterTurnState = getState();
|
|
3788
3998
|
const queuedMessages = selectPendingUserInputQueue(afterTurnState, dialogKey);
|
|
3789
3999
|
if (queuedMessages.length > 0) {
|
|
@@ -3844,10 +4054,18 @@ ${info.actionHint}` : streamError;
|
|
|
3844
4054
|
} else if (!isTurnAborted(error)) {
|
|
3845
4055
|
setLoopStopReason("error");
|
|
3846
4056
|
}
|
|
4057
|
+
if (error instanceof DirectApiKeyResolutionError || error?.kind === "credential_missing") {
|
|
4058
|
+
return rejectWithValue({
|
|
4059
|
+
kind: "credential_missing",
|
|
4060
|
+
credentialRef: error.credentialRef,
|
|
4061
|
+
message: error.message
|
|
4062
|
+
});
|
|
4063
|
+
}
|
|
3847
4064
|
return rejectWithValue(
|
|
3848
4065
|
error?.message || "An unexpected error occurred in streamAgentChatTurn."
|
|
3849
4066
|
);
|
|
3850
4067
|
} finally {
|
|
4068
|
+
batchExecution.dispose();
|
|
3851
4069
|
clearDialogTurnPhase({ dialogKey: runtimeDialogKey ?? void 0, turnId: turnPhaseTurnId ?? void 0 });
|
|
3852
4070
|
if (loopKey && runtimeDialogKey) {
|
|
3853
4071
|
dispatch(removeActiveController({ messageId: loopKey, dialogKey: runtimeDialogKey }));
|