nolo-cli 0.258.0-alpha.1 → 0.260.0-alpha.1
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 +1 -1
- package/{_executeModel-E2LL7FPO.js → _executeModel-EO6JFCOF.js} +97 -83
- package/accountResolver-NGICIMEE.js +1 -1
- package/{action-C6IQAKN4.js → action-WIA56QT4.js} +12 -10
- package/{addContentAction-53364YDW.js → addContentAction-OCMWZLYG.js} +14 -13
- package/{addDialogAgentAction-U5DD5EN5.js → addDialogAgentAction-ER2NZ7BC.js} +20 -24
- package/{agentDeleteCommand-ORNRRKJO.js → agentDeleteCommand-KSXSNPAU.js} +184 -146
- package/{agentEmailCommands-2ALVFOD5.js → agentEmailCommands-NXRWS7NS.js} +142 -126
- package/{agentGrantCommands-L6O2HVJI.js → agentGrantCommands-D2S7LCTU.js} +8 -5
- package/{agentListCommands-6I4NQPR4.js → agentListCommands-PFXGZZ3Y.js} +87 -68
- package/{agentMachineCommands-PNHTIJ6A.js → agentMachineCommands-2Q55CSL4.js} +68 -59
- package/{agentProviderCommands-QLTABYR7.js → agentProviderCommands-EUNS7Y2Z.js} +10 -7
- package/{agentPullCommand-2EYJ5ENC.js → agentPullCommand-S2VMPSWL.js} +9 -6
- package/agentRecordCommands-FUFI526H.js +210 -0
- package/agentRun-ZNMUPDHF.js +250 -0
- package/agentRunCommand-ISVQ2UYC.js +248 -0
- package/{agentRunControl-3TIVJ3SR.js → agentRunControl-NEK44LDM.js} +19 -12
- package/{agentRuntimeLocal-3MAEFYSB.js → agentRuntimeLocal-SST4EPLT.js} +62 -49
- package/{agentSlice-KOQXUPKT.js → agentSlice-4ZJJJN4M.js} +15 -18
- package/appConfigCommands-MPHS6FHD.js +417 -0
- package/{appDeleteCommands-FEPN62UR.js → appDeleteCommands-W26WGENW.js} +68 -58
- package/{appDeployCommands-DPFEWFYZ.js → appDeployCommands-ER7IOF5E.js} +74 -59
- package/{appDeployStatusCommands-LQ5X5KVX.js → appDeployStatusCommands-VKLL3A77.js} +68 -58
- package/{appGetCommands-W3JBBIF7.js → appGetCommands-P6GXJNUD.js} +74 -58
- package/{appListCommands-LUHZS7JU.js → appListCommands-ACA2IZZM.js} +74 -58
- package/appMigrateCommands-OGF4E2W6.js +230 -0
- package/appSourceCommands-GAHVBRUM.js +279 -0
- package/{authCommand-HKSXJT3J.js → authCommand-PXE7NZTQ.js} +26 -40
- package/{authCommands-T5FODCEG.js → authCommands-AZPYXTUB.js} +20 -17
- package/{builtinSkillRegistry-FVEEO4U2.js → builtinSkillRegistry-6XUWMAV5.js} +8 -6
- package/{chromeOpsCommands-4UIKH26F.js → chromeOpsCommands-7UKKUOBU.js} +68 -18
- package/{chunk-KO5PFS74.js → chunk-2CKFROQS.js} +2454 -1115
- package/{chunk-6N4IKMTH.js → chunk-2I4R6ZRV.js} +40 -26
- package/{chunk-FXEPZKNJ.js → chunk-2MIZHEND.js} +506 -64
- package/{chunk-TLE77UJ5.js → chunk-2OROOEOQ.js} +0 -1
- package/{chunk-6RSNVJGO.js → chunk-2ZBPWX7N.js} +4 -4
- package/chunk-35JIFLIG.js +30 -0
- package/{chunk-ZYPXOQS2.js → chunk-3EPED3UO.js} +1 -1
- package/{chunk-DNNPARJK.js → chunk-3QMN3T6L.js} +50 -37
- package/{chunk-DMPZMYH4.js → chunk-3R4AYHJR.js} +13 -1
- package/{chunk-HPDLPEUG.js → chunk-42JZNSAY.js} +267 -234
- package/{chunk-223KZUJ6.js → chunk-4HZCBA4Q.js} +18 -15
- package/{chunk-C5A54QS7.js → chunk-4INJGWE3.js} +18 -5
- package/chunk-4IVMDQBA.js +261 -0
- package/chunk-4Y6CZ2N4.js +82 -0
- package/{chunk-OKAXQFON.js → chunk-52BNL6GP.js} +4 -4
- package/{chunk-KZ4A7EIV.js → chunk-56OAS5RZ.js} +1 -1
- package/{chunk-QGFLVQ6E.js → chunk-6KUTNAPU.js} +4 -14
- package/{chunk-MNFUKRRU.js → chunk-6XAAKRJB.js} +7 -7
- package/{chunk-P27E22MA.js → chunk-6Z6DGDPI.js} +1 -1
- package/chunk-72VWN4VK.js +51 -0
- package/{chunk-2RZBFJEG.js → chunk-75FZ2Z7C.js} +16027 -17392
- package/{chunk-ADYWV732.js → chunk-76B6YUQS.js} +264 -177
- package/{chunk-AKBNCTPY.js → chunk-76K4GTY5.js} +1 -1
- package/{chunk-ZMJMHXYX.js → chunk-7HUCUD2I.js} +3 -3
- package/chunk-7LR2IFUH.js +100 -0
- package/{chunk-S73EPYNC.js → chunk-7LS5ATRP.js} +20 -6
- package/{chunk-Y2TCTNUD.js → chunk-7QO6YSA4.js} +4 -4
- package/{chunk-TF427WGH.js → chunk-7RYH7YIY.js} +19 -27
- package/{chunk-KHYSFS3W.js → chunk-A454UXB6.js} +148 -73
- package/chunk-AMNZPQCY.js +635 -0
- package/chunk-AMTF6FJD.js +356 -0
- package/{chunk-MUDMYJCM.js → chunk-AQNWWJLH.js} +2 -56
- package/{chunk-WSLL7VV4.js → chunk-B4NA5UJR.js} +9 -9
- package/{chunk-LHCGKAFO.js → chunk-BKP325XS.js} +184 -112
- package/{chunk-PENRYZ4D.js → chunk-BPB3T5EU.js} +4 -7
- package/{chunk-46FETNLF.js → chunk-BTIFQBYW.js} +7 -6
- package/{chunk-2JHGUL5K.js → chunk-BVYHE6QD.js} +2 -2
- package/{chunk-KXOPLLFP.js → chunk-CA7LGAHV.js} +69 -9
- package/{chunk-2FZVXOFX.js → chunk-CEIWXKHP.js} +112 -200
- package/{chunk-AIFQKNPP.js → chunk-CL33RFD7.js} +1 -1
- package/{chunk-JAGD4PSH.js → chunk-CRGPRAJ4.js} +46 -42
- package/{chunk-P4R5KXU7.js → chunk-CW6LRDSF.js} +5 -5
- package/{chunk-BD22OFDQ.js → chunk-CZHIOBBK.js} +8 -3
- package/chunk-D3ONA3FP.js +762 -0
- package/chunk-D3SAQ6T7.js +1697 -0
- package/{chunk-PIVTQRX6.js → chunk-DDKA6V6X.js} +111 -12
- package/{chunk-KQHEGELM.js → chunk-DEAII55O.js} +16 -6
- package/{chunk-J55F3IEZ.js → chunk-DKJQEFNG.js} +1 -1
- package/chunk-DLXL4NSL.js +1179 -0
- package/{chunk-EJQE5HB7.js → chunk-DSBRIUX5.js} +4 -2
- package/{chunk-XRGBJHZX.js → chunk-E36V7MPY.js} +9 -5
- package/{chunk-4YPH5KRA.js → chunk-EDKMRDET.js} +1 -1
- package/chunk-EJHLDJWZ.js +58 -0
- package/{chunk-E4HBZDV6.js → chunk-EMFZXJTN.js} +15 -47
- package/chunk-ER6NTALN.js +34 -0
- package/chunk-EUHMI5KG.js +101 -0
- package/{chunk-YQLAFJRQ.js → chunk-FBNVJ2TO.js} +1 -1
- package/{chunk-EXD7S7QW.js → chunk-FF5ZRKW7.js} +12 -7
- package/{chunk-7PTWFSZZ.js → chunk-FGD4NMTP.js} +4 -4
- package/{chunk-6XIE5ZGI.js → chunk-FGFJUFPS.js} +5 -6
- package/chunk-FI4DPLR7.js +902 -0
- package/chunk-FKVLQNGJ.js +25 -0
- package/{chunk-JCQ3WCQ3.js → chunk-FOC4TORM.js} +69 -3
- package/{chunk-JPXACKSW.js → chunk-G22P2J7O.js} +30 -81
- package/{chunk-7WHCIA5V.js → chunk-G5IAIGGD.js} +3 -8
- package/{chunk-IZHENZQ5.js → chunk-G5JGA5YM.js} +180 -31
- package/{chunk-7EUJ65PF.js → chunk-GMBWWBSJ.js} +782 -449
- package/{chunk-WS36XPJD.js → chunk-GYFKKTDI.js} +82 -6
- package/{chunk-APXC3SQO.js → chunk-GZ4I5EMM.js} +9 -9
- package/{chunk-324FWHUA.js → chunk-HHXF57CL.js} +12 -3
- package/chunk-HJTI7RZV.js +94 -0
- package/{chunk-JGVWHUYK.js → chunk-HPIY372N.js} +7 -7
- package/{chunk-Q2MPKE4B.js → chunk-HVRG27HI.js} +76 -26
- package/{chunk-HDKMVYNJ.js → chunk-I3NWAILT.js} +6 -4
- package/{chunk-MD7O2NN2.js → chunk-IM7HCFB4.js} +313 -275
- package/{chunk-DWES4SXY.js → chunk-INN2PBW7.js} +1 -1
- package/chunk-IV6VUVLJ.js +88 -0
- package/chunk-J42X32PV.js +472 -0
- package/{chunk-V6S5OZSP.js → chunk-JHQNWV2C.js} +4441 -2569
- package/{chunk-R7XWZDOH.js → chunk-JUMQJSQF.js} +1423 -282
- package/{chunk-BIDSIRTS.js → chunk-JUNYPVL6.js} +10 -16
- package/chunk-JVEKCQAP.js +222 -0
- package/{chunk-JW6OURKM.js → chunk-KAHYBAEN.js} +215 -473
- package/chunk-KDDXC2IH.js +148 -0
- package/chunk-KGKTN2NX.js +25 -0
- package/chunk-KGWE224L.js +246 -0
- package/chunk-L3UFGEDU.js +17157 -0
- package/{chunk-CBIGMWMI.js → chunk-LHJB4BXJ.js} +1 -1
- package/{chunk-DCTQJDDQ.js → chunk-LIH7WSX5.js} +23 -379
- package/chunk-LJOPY4TL.js +443 -0
- package/{chunk-TRRXYFTR.js → chunk-LOFRSJX2.js} +1 -0
- package/{chunk-SQL7YNED.js → chunk-LPXBBC32.js} +71 -5
- package/chunk-LXP53WGF.js +168 -0
- package/chunk-MDAYRIP7.js +1889 -0
- package/chunk-MRACVEPZ.js +7 -0
- package/chunk-NHLLXINQ.js +8 -0
- package/{chunk-VQR2ACSC.js → chunk-NTBTVKKB.js} +17 -25
- package/{chunk-LVZVSLKO.js → chunk-O7ZY6SUK.js} +5 -22
- package/{chunk-APQBEIOQ.js → chunk-P4XAHM4B.js} +1 -1
- package/chunk-PL5RKESU.js +40 -0
- package/{chunk-U2H426FE.js → chunk-PQ3QZMJK.js} +20 -4
- package/chunk-Q5FJJ6XI.js +103 -0
- package/{createAgentAutomationAction-HEZ3G5L4.js → chunk-QKM55LP2.js} +3 -160
- package/{chunk-SIHOY5YI.js → chunk-QZCLCAYC.js} +170 -164
- package/{chunk-FE7G6DSP.js → chunk-R72QWIFO.js} +14 -4
- package/{chunk-JLZJL3WC.js → chunk-RDZ5OIAT.js} +370 -39
- package/{chunk-5RGU3J7P.js → chunk-REAE2SZK.js} +0 -1
- package/chunk-RF576RYE.js +117 -0
- package/chunk-RI7SXDJW.js +1317 -0
- package/{chunk-JOJH3KWV.js → chunk-RIOAPUGV.js} +242 -25
- package/{chunk-7B55IVLF.js → chunk-RL6H2A2Z.js} +2561 -4059
- package/{chunk-BZLGPM5B.js → chunk-RNLKWUVY.js} +7 -12
- package/{chunk-BB76X6O4.js → chunk-RWXHGPWJ.js} +1 -1
- package/chunk-S7BF2OGX.js +432 -0
- package/{chunk-6VEO7Z3Y.js → chunk-SD4MBKZ7.js} +6 -6
- package/{chunk-PNBQ5JTA.js → chunk-SGEBRBF3.js} +7 -4
- package/{chunk-6SOWMEAY.js → chunk-SR57FDTX.js} +2 -258
- package/{chunk-CEKRIR22.js → chunk-SU4NCTW4.js} +1 -1
- package/{chunk-LJ6WIQZO.js → chunk-SX6PDLBZ.js} +279 -149
- package/{chunk-6VNBJ7GI.js → chunk-T4WU747C.js} +5 -5
- package/{chunk-53W5BXLN.js → chunk-TCOHWKDM.js} +54 -55
- package/{chunk-KO5GO2BC.js → chunk-TXMFSGRY.js} +1 -1
- package/{chunk-UUCYUN6Y.js → chunk-UB7NV7NN.js} +1 -1
- package/{chunk-CVDJUPBN.js → chunk-UOLGGEEC.js} +774 -119
- package/{chunk-ADUCBH4M.js → chunk-USFG4EWQ.js} +51 -42
- package/{chunk-LLUBUHNT.js → chunk-UYZOBSSO.js} +5 -9
- package/{chunk-ONTHDYFU.js → chunk-VDC3BW24.js} +24 -10
- package/chunk-VH356OQ3.js +425 -0
- package/{chunk-U6QNVOR5.js → chunk-VKM7DOYB.js} +130 -6
- package/{chunk-3GGVFHWI.js → chunk-VPAO5WQX.js} +17 -14
- package/{chunk-OYUMJMC5.js → chunk-W2RQYNPI.js} +5 -0
- package/{chunk-C63KMRJE.js → chunk-W2Z5E2R7.js} +126 -698
- package/{chunk-4ZCTKB27.js → chunk-W5GKF5ZW.js} +1 -0
- package/{chunk-NUHQO3RB.js → chunk-WIVVNJUS.js} +1 -1
- package/chunk-WLJNHFEB.js +1710 -0
- package/chunk-WMBJDXMY.js +408 -0
- package/chunk-WSQLCWLQ.js +201 -0
- package/{chunk-YN23INFZ.js → chunk-WXD6Y7DW.js} +23 -2
- package/{chunk-RQKTCHQM.js → chunk-WY6DMHMG.js} +1 -1
- package/{chunk-MLK3FEXG.js → chunk-XJW6SLBZ.js} +3 -3
- package/{chunk-7BIJFGKS.js → chunk-XQFDCRG3.js} +105 -51
- package/chunk-XT6C2QZW.js +46 -0
- package/{chunk-NRUYSNSZ.js → chunk-Y7THFNVJ.js} +9 -9
- package/{chunk-ZEZC7IIM.js → chunk-YFSM2366.js} +35 -35
- package/{chunk-RD3QLZQV.js → chunk-YM5XULB2.js} +324 -2
- package/{chunk-BD5YJJLJ.js → chunk-YNP3ITPU.js} +19 -12
- package/{chunk-U35UUM5K.js → chunk-YOUSQIIK.js} +1 -1
- package/{chunk-RIWKZT7E.js → chunk-YRPIUIEQ.js} +11 -9
- package/{chunk-Z3JZ2R5F.js → chunk-YU235GGN.js} +25 -8
- package/chunk-YWEZSBLL.js +790 -0
- package/chunk-Z3KTXWWB.js +76 -0
- package/{chunk-YLAHYLDQ.js → chunk-ZC3CMUKU.js} +2 -89
- package/chunk-ZD7OULYZ.js +368 -0
- package/{chunk-5P3PPQVP.js → chunk-ZQAADXSF.js} +1 -1
- package/{chunk-HQUGB2HM.js → chunk-ZTCMXPIS.js} +62 -50
- package/{cliAgentConfigHelpers-BXHQ3PXP.js → cliAgentConfigHelpers-KMXS7JP5.js} +20 -14
- package/{cliAuthorityBrokerClient-TFNXJLXL.js → cliAuthorityBrokerClient-3SKOA7OZ.js} +3 -1
- package/cliAuthorityBrokerProcess-DCCUT4YQ.js +34 -0
- package/{cliEnvHelpers-CNMP3RDX.js → cliEnvHelpers-YDGDHIEE.js} +5 -2
- package/{cliExecutor-K6FDZTQ2.js → cliExecutor-Z62UBJ5S.js} +12 -6
- package/cliLocalAgentRecordReader-X2YHEBWI.js +113 -0
- package/cloudAutomationCommands-C6Q3BFRB.js +310 -0
- package/{commandRegistry-QKOJ5FIC.js → commandRegistry-TYYYTW5E.js} +263 -120
- package/{contentThunks-ZDBDDZP3.js → contentThunks-E6BJ5YSX.js} +45 -43
- package/{cooldownCommands-Y4ZQQ35D.js → cooldownCommands-FPAFS7XG.js} +1 -1
- package/createAgentAutomationAction-L3NLCIIW.js +172 -0
- package/{createDialogAction-DK62W5VA.js → createDialogAction-QSWKRPWQ.js} +46 -42
- package/{createPageAction-W6NXHVKO.js → createPageAction-ZVVUT4CZ.js} +49 -45
- package/{db-VR74ADGC.js → db-KTQ3LL2Q.js} +3 -3
- package/{dbSlice-RWPSVHBC.js → dbSlice-SEVKNA7A.js} +21 -16
- package/deleteDbKey-43MTK2DI.js +86 -0
- package/{dialogCommands-Z24IDINY.js → dialogCommands-UVMTIFSA.js} +80 -66
- package/{dialogMessageRecord-OAV77LT7.js → dialogMessageRecord-2HJTEXQX.js} +1 -1
- package/{dialogNotifyCommand-IASQGEMW.js → dialogNotifyCommand-LMWF7EQI.js} +22 -14
- package/dialogPortabilityCommands-PAMLEBST.js +3036 -0
- package/{dialogSlice-62GISS77.js → dialogSlice-VHPXENDZ.js} +43 -42
- package/{dialogTraceCommand-FDINAIZ6.js → dialogTraceCommand-SO2WKAXW.js} +83 -69
- package/{dialogUsageCommand-WJ3U6KZU.js → dialogUsageCommand-EUO6JXTD.js} +6 -3
- package/{docCreateCommands-SXA4TMGJ.js → docCreateCommands-H4RLIUNX.js} +68 -59
- package/{docDeleteCommands-ELXSZK3F.js → docDeleteCommands-OVAKCBMT.js} +68 -59
- package/{docReadCommands-DFLAQPI4.js → docReadCommands-KFISIUVA.js} +67 -58
- package/{docStore-UWF2PMCB.js → docStore-X7BEA735.js} +16 -17
- package/{docUpdateCommands-KB6M5HUH.js → docUpdateCommands-VOEER36L.js} +68 -59
- package/ebookDownloaderAgentCommand-2DHPGEOQ.js +674 -0
- package/{fetchMessages-TQEUZD7H.js → fetchMessages-RGPIYEPZ.js} +2 -2
- package/{getPricing-5BLZRPTM.js → getPricing-BK6CUBAE.js} +8 -4
- package/{handleSendMessageAction-ZV6OQPQG.js → handleSendMessageAction-GQ2KKOET.js} +265 -119
- package/{hostCredentialCreate-3IA5IJFG.js → hostCredentialCreate-PJAIKZQP.js} +138 -122
- package/index.js +35 -21
- package/{keys-RWF7UCB4.js → keys-FXEGMKSG.js} +2 -2
- package/localAutomationCommands-UU66LOWB.js +198 -0
- package/localAutomationRuntime-SW4R42SZ.js +60 -0
- package/{localDialogRead-BJJT3TF5.js → localDialogRead-W2EVXISA.js} +2 -2
- package/{localRuntimeAdapter-SSG5ORLZ.js → localRuntimeAdapter-WRBLXFUZ.js} +136 -119
- package/localRuntimeAuthority-3YDFZD3L.js +44 -0
- package/{localRuntimeDb-ZJFGNHML.js → localRuntimeDb-CJWJK47G.js} +1 -1
- package/{machineCommands-4WKJ3TLO.js → machineCommands-JFYED66N.js} +251 -357
- package/{machineInfo-LWHTEBHJ.js → machineInfo-BJIU3WQ5.js} +4 -2
- package/machineWsRunDispatch-CZUV2FXE.js +227 -0
- package/{mcpLocalAuthorizeCommand-RBXJDE6J.js → mcpLocalAuthorizeCommand-HLU72QME.js} +40 -22
- package/mcpLocalManageCommands-OHHU6F5C.js +212 -0
- package/{memberThunks-43B7UYC5.js → memberThunks-FJW4GPM5.js} +102 -22
- package/{memoryCommands-BC6REPQB.js → memoryCommands-2RLHDMU2.js} +25 -34
- package/{models-ZX2BYIMB.js → models-TOXYINNM.js} +3 -2
- package/{offlineMarxistsAgentCommand-XVXUE6G5.js → offlineMarxistsAgentCommand-WZBJBCPZ.js} +16 -22
- package/package.json +3 -3
- package/parityCommands-7EWR34P3.js +613 -0
- package/{projectArchive-JN43WW4E.js → projectArchive-JIVRMXVV.js} +49 -45
- package/{providerPresetApply-NTJUINI6.js → providerPresetApply-IRJ56XIZ.js} +12 -16
- package/{providerRegistry-W45SLUV6.js → providerRegistry-26PAUYH2.js} +3 -13
- package/{read-KG6INYUT.js → read-6YR57D6V.js} +11 -10
- package/{readDocTool-N3GA52JR.js → readDocTool-NKOGL2MW.js} +5 -1
- package/{readlineWorkspace-D6EUSB2Q.js → readlineWorkspace-V26AN2FL.js} +926 -572
- package/{rememberExplicit-CPAPONSI.js → rememberExplicit-7KX4HXQC.js} +4 -4
- package/remove-BF33RCTH.js +32 -0
- package/{removeDialogAgentAction-EEVSOQOJ.js → removeDialogAgentAction-GWHBWF4W.js} +22 -26
- package/{runAgentClientLoop-FEZTSUSJ.js → runAgentClientLoop-EKD2EEEA.js} +117 -82
- package/{runtimeDoctorCommands-V3M3JTUV.js → runtimeDoctorCommands-IALUR5BZ.js} +23 -16
- package/{secretCommands-53NZFD4T.js → secretCommands-CSTQYB6T.js} +2 -2
- package/{setDialogExtraReferencesAction-DNO5POHA.js → setDialogExtraReferencesAction-RL6FGO7T.js} +16 -17
- package/{setPrimaryDialogAgentAction-QABBEO4C.js → setPrimaryDialogAgentAction-XJASBB3K.js} +23 -27
- package/{settingThunks-DVKG4X4S.js → settingThunks-ZT7ZYXXL.js} +170 -497
- package/{skillDiscovery-5GEGWJ6N.js → skillDiscovery-IUEZZG2B.js} +3 -3
- package/{spaceCommands-4ACQQNZL.js → spaceCommands-65WQHVOI.js} +194 -90
- package/spacePruneCommand-PTMRUWYJ.js +233 -0
- package/{store-Z53ICFL3.js → store-WSAVTR32.js} +3 -1
- package/{streamAgentChatTurn-I425SVYJ.js → streamAgentChatTurn-B5NICHZW.js} +225 -137
- package/{switchDialogAgentAction-KYWJSGOO.js → switchDialogAgentAction-X6DFOIAX.js} +19 -23
- package/{tableCommands-EFA754RE.js → tableCommands-6E77VD73.js} +28 -49
- package/{toolApiClient-N5PYW2R3.js → toolApiClient-GTTWEV6P.js} +15 -4
- package/{tools-WBPFTSMK.js → tools-UMCPIQX6.js} +73 -63
- package/{tuiRestart-VN5F4GYU.js → tuiRestart-O7UDLNQU.js} +20 -13
- package/tuiSummaryLlmCaller-7APIUIIV.js +52 -0
- package/{updateCommands-VQEBBIGO.js → updateCommands-DXDIAQFS.js} +12 -7
- package/{updateDialogTitleAction-VB5DTVXV.js → updateDialogTitleAction-HZLKWVKM.js} +57 -58
- package/{usageCommand-WI6SQOPB.js → usageCommand-WYLNBDHB.js} +6 -8
- package/{usageRebuildCommand-WQRLLZAT.js → usageRebuildCommand-AEUPY2PE.js} +11 -15
- package/{windowsSelfUpdate-ZEZKGX4M.js → windowsSelfUpdate-SXSVXK4X.js} +2 -2
- package/workContext-ZAW6VXT7.js +18 -0
- package/workContextQueryProjection-CACY5VFE.js +23 -0
- package/{workloadLifecycle-DYX5ZMAT.js → workloadLifecycle-P2SJVV3S.js} +1 -1
- package/agentFavoriteCommands-7LOP3HUD.js +0 -186
- package/agentRecordCommands-BEZPBYBM.js +0 -194
- package/agentRunCommand-2T72V5KY.js +0 -232
- package/chunk-2MBTWINN.js +0 -89
- package/chunk-523DITKR.js +0 -32
- package/chunk-BUDVRYES.js +0 -2213
- package/chunk-BXGU6274.js +0 -862
- package/chunk-BZMDWGQQ.js +0 -47
- package/chunk-GAHJLSDO.js +0 -107
- package/chunk-GYX6XTAI.js +0 -84
- package/chunk-HNUWUO75.js +0 -93
- package/chunk-HSBHS6KT.js +0 -33401
- package/chunk-KG27JIG4.js +0 -136
- package/chunk-OB4FBZXJ.js +0 -364
- package/chunk-OKH74FML.js +0 -3746
- package/chunk-OLZBQWZU.js +0 -6
- package/chunk-OOV5JN25.js +0 -1317
- package/chunk-OQFOE4SJ.js +0 -405
- package/chunk-PXYBUFDB.js +0 -53
- package/chunk-R3FZHW4Q.js +0 -103
- package/chunk-R3MV2GII.js +0 -106
- package/chunk-SCAC3NM5.js +0 -11751
- package/chunk-SR4FE5VD.js +0 -9
- package/chunk-SYTHYBMI.js +0 -3558
- package/chunk-UKZX3NHN.js +0 -48
- package/chunk-UVLYNWIE.js +0 -74
- package/chunk-WFEWP352.js +0 -861
- package/chunk-X4O7FJF5.js +0 -160
- package/chunk-YJPK35HB.js +0 -175
- package/chunk-YNIYE47Z.js +0 -105
- package/chunk-Z4PCXPUE.js +0 -127
- package/chunk-ZTHAJU3O.js +0 -2537
- package/cliAuthorityBrokerProcess-5ZFBTHLB.js +0 -22
- package/cliLocalAgentRecordReader-Q6677YID.js +0 -104
- package/deleteFile-ECU6FU5C.js +0 -55
- package/localRuntimeAuthority-UF2DAQ3F.js +0 -28
- package/machineWsRunDispatch-7PROH7E7.js +0 -209
- package/markdownToSlate-PXYAIBVL.js +0 -8
- package/tuiSummaryLlmCaller-HROLGN4F.js +0 -45
- package/webapi-QVV65DQF.js +0 -2487
- package/workContext-Y3ADAPZU.js +0 -14
- package/{chunk-USGHJSGO.js → chunk-GX2MFKF3.js} +3 -3
- package/{chunk-PHREU2KZ.js → chunk-WX266G2C.js} +0 -0
- package/{chunk-DXWGFL2Z.js → chunk-YY7IGJMN.js} +3 -3
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
parseSseDataLineJson,
|
|
5
|
-
parseSseDataLineObject
|
|
6
|
-
} from "./chunk-OOV5JN25.js";
|
|
2
|
+
DEVIN_CONNECT_URL
|
|
3
|
+
} from "./chunk-Q5FJJ6XI.js";
|
|
7
4
|
import {
|
|
8
5
|
ALWAYS_EXCLUDED_GLOBS,
|
|
9
6
|
EXECUTION_BACKEND_KINDS
|
|
@@ -19,27 +16,28 @@ import {
|
|
|
19
16
|
finalizeResponsesToolCalls,
|
|
20
17
|
flushChatCompletionStream,
|
|
21
18
|
providerHttpFailure,
|
|
19
|
+
readSseFrames,
|
|
22
20
|
throwIfChatCompletionStreamFailed
|
|
23
|
-
} from "./chunk-
|
|
24
|
-
import {
|
|
25
|
-
readSseFrames
|
|
26
|
-
} from "./chunk-HNUWUO75.js";
|
|
21
|
+
} from "./chunk-DDKA6V6X.js";
|
|
27
22
|
import {
|
|
28
23
|
evaluateFileWritePolicy,
|
|
29
24
|
summarizeToolArguments
|
|
30
25
|
} from "./chunk-CHOZJMJS.js";
|
|
31
26
|
import {
|
|
32
27
|
resolveToolExecutionContract
|
|
33
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-3R4AYHJR.js";
|
|
29
|
+
import {
|
|
30
|
+
projectChatUsage
|
|
31
|
+
} from "./chunk-AQNWWJLH.js";
|
|
34
32
|
import {
|
|
35
33
|
evaluateRequestBudget,
|
|
36
34
|
hasImageInRuntimeMessages,
|
|
37
35
|
stripImagePartsFromMessages
|
|
38
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-XJW6SLBZ.js";
|
|
39
37
|
import {
|
|
40
38
|
resolveAgentImageInputSupport,
|
|
41
39
|
resolveToolImagePolicy
|
|
42
|
-
} from "./chunk-
|
|
40
|
+
} from "./chunk-RNLKWUVY.js";
|
|
43
41
|
import {
|
|
44
42
|
applyShapingCounts,
|
|
45
43
|
attachProjectionFacts,
|
|
@@ -50,7 +48,7 @@ import {
|
|
|
50
48
|
projectUserPartForModel,
|
|
51
49
|
resolveOutboundDiagnosticSink,
|
|
52
50
|
writeThinkingFacts
|
|
53
|
-
} from "./chunk-
|
|
51
|
+
} from "./chunk-CL33RFD7.js";
|
|
54
52
|
import {
|
|
55
53
|
createThinkParserState,
|
|
56
54
|
createToolCallAccumulator,
|
|
@@ -59,20 +57,15 @@ import {
|
|
|
59
57
|
finalizeAccumulatedToolCalls
|
|
60
58
|
} from "./chunk-56GBUMO5.js";
|
|
61
59
|
import {
|
|
62
|
-
OFFLOAD_NUDGE_PREFIX,
|
|
63
|
-
ROUND_BUDGET_WARNING_PREFIX,
|
|
64
|
-
SUBTASK_SOFT_BUDGET_NOTICE_PREFIXES,
|
|
65
60
|
TOOL_GUIDED_SECTION_ORDER,
|
|
66
61
|
buildIdentityBlock,
|
|
67
62
|
buildPlatformStaticScopedBlocks,
|
|
68
63
|
buildRuntimeGuidanceBlocks,
|
|
69
|
-
detectDispatchIntent,
|
|
70
|
-
detectDispatchIntentFromMessages,
|
|
71
64
|
estimateContextTokens,
|
|
72
65
|
hashStablePrefixContent,
|
|
73
66
|
resolveResponseGuidelines,
|
|
74
67
|
resolveToolGuidedSections
|
|
75
|
-
} from "./chunk-
|
|
68
|
+
} from "./chunk-D3ONA3FP.js";
|
|
76
69
|
import {
|
|
77
70
|
BRIDGE_STREAM_MAX_CHARS,
|
|
78
71
|
CLI_NOLO_WORKSPACE_TOOL_NAMES,
|
|
@@ -87,48 +80,58 @@ import {
|
|
|
87
80
|
parseNoloWorkspaceToolArguments,
|
|
88
81
|
readTextStreamUpToChars,
|
|
89
82
|
resolveNoloDialogInput
|
|
90
|
-
} from "./chunk-
|
|
83
|
+
} from "./chunk-HVRG27HI.js";
|
|
91
84
|
import {
|
|
85
|
+
TOOL_HAD_IMAGES,
|
|
86
|
+
TOOL_IMAGES,
|
|
87
|
+
TOOL_IMAGE_NOTICES,
|
|
92
88
|
classifyUnparsableToolArgs,
|
|
93
|
-
collectStablePromptPrefix,
|
|
94
89
|
convertMessagesToResponsesInput,
|
|
90
|
+
createToolImageLedger,
|
|
91
|
+
createToolImageNotices,
|
|
95
92
|
downgradeUnparsableToolCalls,
|
|
96
93
|
extractReasoningFromResponseOutput,
|
|
97
94
|
extractTextFromResponseOutput,
|
|
98
95
|
extractToolCallsFromResponseOutput,
|
|
96
|
+
finishResponsesToolDiscovery,
|
|
99
97
|
getUsageRequestOptions,
|
|
98
|
+
hadToolImages,
|
|
99
|
+
hasDeferrableResponsesTools,
|
|
100
100
|
hasParsableObjectArguments,
|
|
101
101
|
markDowngradedToolTurnOrigin,
|
|
102
102
|
normalizeChatCompletionsBodyForProvider,
|
|
103
|
+
prepareResponsesToolDiscovery,
|
|
103
104
|
repairTruncatedToolArguments,
|
|
104
105
|
requiresBareImageUrl,
|
|
106
|
+
resetToolImageDelivery,
|
|
105
107
|
resolveReasoningReplayOptions,
|
|
106
108
|
sanitizeForOutbound,
|
|
107
109
|
scanTruncation,
|
|
108
110
|
shouldStripReasoningContentForOutbound,
|
|
109
|
-
|
|
111
|
+
stripToolImages,
|
|
110
112
|
toBareImageUrlMessages,
|
|
111
113
|
toOpenAiCompatibleMessages,
|
|
112
114
|
toResponsesTools,
|
|
113
|
-
transferDowngradedToolTurnOrigin
|
|
114
|
-
} from "./chunk-FXEPZKNJ.js";
|
|
115
|
-
import {
|
|
116
|
-
TOOL_HAD_IMAGES,
|
|
117
|
-
TOOL_IMAGES,
|
|
118
|
-
TOOL_IMAGE_NOTICES,
|
|
119
|
-
createToolImageLedger,
|
|
120
|
-
createToolImageNotices,
|
|
121
|
-
hadToolImages,
|
|
122
|
-
resetToolImageDelivery,
|
|
123
|
-
stripToolImages,
|
|
124
115
|
toolImageDelivery,
|
|
125
116
|
toolImages,
|
|
117
|
+
transferDowngradedToolTurnOrigin,
|
|
126
118
|
withoutToolImages
|
|
127
|
-
} from "./chunk-
|
|
119
|
+
} from "./chunk-2MIZHEND.js";
|
|
128
120
|
import {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
121
|
+
TOOL_DISCOVERY_CALL_NAME,
|
|
122
|
+
TOOL_DISCOVERY_ID_PREFIX,
|
|
123
|
+
collectStablePromptPrefix,
|
|
124
|
+
collectToolLoadingReferences,
|
|
125
|
+
filterToolDiscoveryHistory,
|
|
126
|
+
isToolDiscoveryCall,
|
|
127
|
+
projectStaticToolDiscoveryBody,
|
|
128
|
+
resolveNativeToolDiscoveryProtocol,
|
|
129
|
+
splitHostedToolDiscovery,
|
|
130
|
+
stablePromptCacheKey
|
|
131
|
+
} from "./chunk-4IVMDQBA.js";
|
|
132
|
+
import {
|
|
133
|
+
isContextOverflowText
|
|
134
|
+
} from "./chunk-2OROOEOQ.js";
|
|
132
135
|
import {
|
|
133
136
|
MAX_CONTROL_SEQUENCE_CHARS,
|
|
134
137
|
PROJECT_INSTRUCTION_MAX_BYTES,
|
|
@@ -145,10 +148,18 @@ import {
|
|
|
145
148
|
sanitizeToolOutputText,
|
|
146
149
|
scrubObjectSecrets,
|
|
147
150
|
scrubSecrets
|
|
148
|
-
} from "./chunk-
|
|
151
|
+
} from "./chunk-TXMFSGRY.js";
|
|
149
152
|
import {
|
|
150
153
|
buildDialogFallbackTitleFromUserInput
|
|
151
|
-
} from "./chunk-
|
|
154
|
+
} from "./chunk-LXP53WGF.js";
|
|
155
|
+
import {
|
|
156
|
+
OFFLOAD_NUDGE_PREFIX,
|
|
157
|
+
ROUND_BUDGET_WARNING_PREFIX,
|
|
158
|
+
SUBTASK_SOFT_BUDGET_NOTICE_PREFIXES,
|
|
159
|
+
detectDispatchIntent,
|
|
160
|
+
detectDispatchIntentFromMessages,
|
|
161
|
+
isInternalNoticeMessage
|
|
162
|
+
} from "./chunk-4Y6CZ2N4.js";
|
|
152
163
|
import {
|
|
153
164
|
EMPTY_ASSISTANT_REPAIR_PROMPT,
|
|
154
165
|
extractReferenceKeysFromMessage,
|
|
@@ -157,18 +168,16 @@ import {
|
|
|
157
168
|
resolveEmptyAssistantFallbackMessage,
|
|
158
169
|
resolveEmptyAssistantOutcome,
|
|
159
170
|
resolveTruncatedReasoningTailLog
|
|
160
|
-
} from "./chunk-
|
|
171
|
+
} from "./chunk-G5IAIGGD.js";
|
|
161
172
|
import {
|
|
162
173
|
COMPACTION_SUMMARY_SCHEMA_VERSION,
|
|
163
174
|
COMPACTION_SUMMARY_SYSTEM_PROMPT,
|
|
164
175
|
buildCompactionMetricsFromPlan,
|
|
165
176
|
buildHistoricalCompactionRequest,
|
|
166
|
-
buildSummarySourceDiagnostics,
|
|
167
|
-
buildSummarySourceSegments,
|
|
168
177
|
classifySummaryError,
|
|
169
178
|
computeSummarySourceMetadata,
|
|
170
179
|
createSummaryBudget,
|
|
171
|
-
|
|
180
|
+
extractFileOperationsFromCalls,
|
|
172
181
|
formatCompactionMetricsLog,
|
|
173
182
|
getMessageTokenCount,
|
|
174
183
|
getModelContextWindow,
|
|
@@ -182,7 +191,7 @@ import {
|
|
|
182
191
|
runSummaryWithContract,
|
|
183
192
|
summaryCompletionTokens,
|
|
184
193
|
truncateToolOutputForContext
|
|
185
|
-
} from "./chunk-
|
|
194
|
+
} from "./chunk-CEIWXKHP.js";
|
|
186
195
|
import {
|
|
187
196
|
createProviderCallTimingTracker,
|
|
188
197
|
finalizeProviderCallTiming,
|
|
@@ -192,7 +201,7 @@ import {
|
|
|
192
201
|
} from "./chunk-H57T64RA.js";
|
|
193
202
|
import {
|
|
194
203
|
sha256Hex
|
|
195
|
-
} from "./chunk-
|
|
204
|
+
} from "./chunk-WMBJDXMY.js";
|
|
196
205
|
import {
|
|
197
206
|
clipCompactText
|
|
198
207
|
} from "./chunk-5MMAK75Q.js";
|
|
@@ -227,7 +236,7 @@ import {
|
|
|
227
236
|
toProcessTaskView,
|
|
228
237
|
truncateToolOutput,
|
|
229
238
|
workspaceChildEnv
|
|
230
|
-
} from "./chunk-
|
|
239
|
+
} from "./chunk-2I4R6ZRV.js";
|
|
231
240
|
import {
|
|
232
241
|
resolveModelTier
|
|
233
242
|
} from "./chunk-HEVRQGGH.js";
|
|
@@ -240,19 +249,22 @@ import {
|
|
|
240
249
|
import {
|
|
241
250
|
isAbortError
|
|
242
251
|
} from "./chunk-7DPNBQSV.js";
|
|
243
|
-
import {
|
|
244
|
-
isLevelNotFoundError
|
|
245
|
-
} from "./chunk-OW765XBU.js";
|
|
246
252
|
import {
|
|
247
253
|
buildAgentsMdLayer,
|
|
248
254
|
buildAgentsMdLayerHeader,
|
|
249
255
|
buildDialogSummaryLayer,
|
|
250
256
|
hasMemoryTools
|
|
251
|
-
} from "./chunk-
|
|
257
|
+
} from "./chunk-FBNVJ2TO.js";
|
|
252
258
|
import {
|
|
253
259
|
MEMORY_USE_GUIDANCE,
|
|
254
260
|
buildUserResponseLanguageContext
|
|
255
|
-
} from "./chunk-
|
|
261
|
+
} from "./chunk-Z3KTXWWB.js";
|
|
262
|
+
import {
|
|
263
|
+
toErrorMessage
|
|
264
|
+
} from "./chunk-HNMXYYJR.js";
|
|
265
|
+
import {
|
|
266
|
+
isLevelNotFoundError
|
|
267
|
+
} from "./chunk-OW765XBU.js";
|
|
256
268
|
import {
|
|
257
269
|
resolveNoloStateDir
|
|
258
270
|
} from "./chunk-6UBGXX2W.js";
|
|
@@ -261,37 +273,35 @@ import {
|
|
|
261
273
|
} from "./chunk-BV3FLP2L.js";
|
|
262
274
|
import {
|
|
263
275
|
dialogMessageRecordToAgentRuntimeMessage
|
|
264
|
-
} from "./chunk-
|
|
276
|
+
} from "./chunk-W5GKF5ZW.js";
|
|
265
277
|
import {
|
|
266
278
|
dialogMessageKey,
|
|
267
279
|
dialogMessageRange
|
|
268
280
|
} from "./chunk-OJKUU3LP.js";
|
|
269
281
|
import {
|
|
270
282
|
resolveLocalUserId
|
|
271
|
-
} from "./chunk-
|
|
283
|
+
} from "./chunk-6KUTNAPU.js";
|
|
284
|
+
import {
|
|
285
|
+
applyToolSurfaceConstraints,
|
|
286
|
+
isSubtaskRun
|
|
287
|
+
} from "./chunk-FOC4TORM.js";
|
|
272
288
|
import {
|
|
273
|
-
|
|
274
|
-
|
|
289
|
+
buildProviderAuthHeaders,
|
|
290
|
+
buildProviderExecutionPlan
|
|
291
|
+
} from "./chunk-O7ZY6SUK.js";
|
|
275
292
|
import {
|
|
276
293
|
canonicalizeToolName,
|
|
277
294
|
canonicalizeToolNames
|
|
278
|
-
} from "./chunk-
|
|
295
|
+
} from "./chunk-HJTI7RZV.js";
|
|
279
296
|
import {
|
|
280
297
|
asTrimmedNonEmptyStringArray
|
|
281
298
|
} from "./chunk-I42VC5KR.js";
|
|
282
|
-
import {
|
|
283
|
-
asOptionalPositiveFiniteNumber
|
|
284
|
-
} from "./chunk-U6VC4MU4.js";
|
|
285
|
-
import {
|
|
286
|
-
toErrorMessage
|
|
287
|
-
} from "./chunk-HNMXYYJR.js";
|
|
288
|
-
import {
|
|
289
|
-
buildProviderAuthHeaders,
|
|
290
|
-
buildProviderExecutionPlan
|
|
291
|
-
} from "./chunk-LVZVSLKO.js";
|
|
292
299
|
import {
|
|
293
300
|
asTrimmedString
|
|
294
301
|
} from "./chunk-3EUW3WEO.js";
|
|
302
|
+
import {
|
|
303
|
+
asOptionalPositiveFiniteNumber
|
|
304
|
+
} from "./chunk-U6VC4MU4.js";
|
|
295
305
|
import {
|
|
296
306
|
isRecord
|
|
297
307
|
} from "./chunk-KUG52IAP.js";
|
|
@@ -303,7 +313,7 @@ import {
|
|
|
303
313
|
} from "./chunk-CF7PE763.js";
|
|
304
314
|
import {
|
|
305
315
|
PLATFORM_HOSTED_DEEPSEEK_FLASH_MODEL
|
|
306
|
-
} from "./chunk-
|
|
316
|
+
} from "./chunk-G22P2J7O.js";
|
|
307
317
|
import {
|
|
308
318
|
asTrimmedLowercaseString
|
|
309
319
|
} from "./chunk-QSJ3HFEF.js";
|
|
@@ -917,7 +927,7 @@ function buildExecShellToolDefinition(toolName = "execShell") {
|
|
|
917
927
|
type: "function",
|
|
918
928
|
function: {
|
|
919
929
|
name: toolName,
|
|
920
|
-
description: `Execute a shell command from the workspace root. Prefer one compound command (e.g. 'git status && git diff --stat') to finish verification in one step; do not cd into guessed paths. Commands block until exit; long-running ones (sleep over ${IMMEDIATE_DETACH_SLEEP_THRESHOLD_SECONDS}s, dev servers, watchers) auto-detach returning {detached: true, pid, label}; for persistent services prefer launchProcess.${WINDOWS_SHELL_NOTE} LIFECYCLE: (1) A normal command waits synchronously
|
|
930
|
+
description: `Execute a shell command from the workspace root. Prefer one compound command (e.g. 'git status && git diff --stat') to finish verification in one step; do not cd into guessed paths. Commands block until exit; long-running ones (sleep over ${IMMEDIATE_DETACH_SLEEP_THRESHOLD_SECONDS}s, dev servers, watchers) auto-detach returning {detached: true, pid, label}; for persistent services prefer launchProcess.${WINDOWS_SHELL_NOTE} LIFECYCLE: (1) A normal command waits synchronously up to 120s; a result carrying exitCode already finished \u2014 parse it now, never read it as "still running". (2) Only metadata.detached === true AND a taskId yields an automatic completion turn; that taskId is NOT a path or result file \u2014 never rerun the command just for its output; that turn delivers the result inline (if truncated it carries a full-output path in its overflow marker, read it with readFile only when present). (3) Text the command prints (STARTED, ...) has zero lifecycle meaning. (4) Shell-level backgrounding (&, nohup, disown, setsid, Start-Process) is NOT tracked: no completion notice. Use background: true to track a finite job; no standalone sleeps. When a sync result's core output went to a file, read it in the same turn.`,
|
|
921
931
|
parameters: {
|
|
922
932
|
type: "object",
|
|
923
933
|
properties: {
|
|
@@ -931,11 +941,11 @@ function buildExecShellToolDefinition(toolName = "execShell") {
|
|
|
931
941
|
},
|
|
932
942
|
background: {
|
|
933
943
|
type: "boolean",
|
|
934
|
-
description: "
|
|
944
|
+
description: "Detach this command into a tracked background task (no 120s wait): returns {detached: true, taskId}; on completion the platform resumes this conversation with a bounded result capsule (exitCode, duration, tails). Default false. Use for finite jobs (tests, builds, batch) whose result you need later; NOT for dev servers/watchers \u2014 use launchProcess."
|
|
935
945
|
},
|
|
936
946
|
label: {
|
|
937
947
|
type: "string",
|
|
938
|
-
description: "Optional
|
|
948
|
+
description: "Optional label for the background task, shown in task lists and completion notices. Defaults to the last token."
|
|
939
949
|
}
|
|
940
950
|
}
|
|
941
951
|
}
|
|
@@ -1400,6 +1410,16 @@ function readAgentsMdLayerFromDisk(cwd) {
|
|
|
1400
1410
|
return null;
|
|
1401
1411
|
}
|
|
1402
1412
|
|
|
1413
|
+
// packages/agent-runtime/types.ts
|
|
1414
|
+
var AGENT_PROMPT_IN_MESSAGES = Symbol("agent-prompt-in-messages");
|
|
1415
|
+
function hasAssembledAgentPrompt(messages) {
|
|
1416
|
+
return messages.some((raw) => {
|
|
1417
|
+
if (!raw || typeof raw !== "object") return false;
|
|
1418
|
+
const message = raw;
|
|
1419
|
+
return message.role === "system" && message[AGENT_PROMPT_IN_MESSAGES] === true;
|
|
1420
|
+
});
|
|
1421
|
+
}
|
|
1422
|
+
|
|
1403
1423
|
// packages/agent-runtime/toolCallPairing.ts
|
|
1404
1424
|
function readToolCallId(message) {
|
|
1405
1425
|
if (typeof message.tool_call_id === "string" && message.tool_call_id) {
|
|
@@ -1728,7 +1748,11 @@ function prepareMessagesForProviderCall(messages) {
|
|
|
1728
1748
|
let projectedToolContentChars = 0;
|
|
1729
1749
|
let truncatedToolResults = 0;
|
|
1730
1750
|
const projected = paired.map((message) => {
|
|
1731
|
-
const {
|
|
1751
|
+
const {
|
|
1752
|
+
context_reference: _contextReference,
|
|
1753
|
+
internalNotice: _internalNotice,
|
|
1754
|
+
...providerMessage
|
|
1755
|
+
} = message;
|
|
1732
1756
|
const sanitizedContent = providerMessage.content == null ? "" : typeof providerMessage.content === "string" ? providerMessage.content : providerMessage.content;
|
|
1733
1757
|
if (providerMessage.role !== "tool") {
|
|
1734
1758
|
return transferDowngradedToolTurnOrigin(message, {
|
|
@@ -2308,7 +2332,13 @@ function projectRunResultRead(path, content, raw = false) {
|
|
|
2308
2332
|
else if (typeof code === "number" && Number.isInteger(code)) exitNonzero++;
|
|
2309
2333
|
else exitUnknown++;
|
|
2310
2334
|
}
|
|
2311
|
-
const
|
|
2335
|
+
const workspace = isRecord(acceptance.workspace) ? acceptance.workspace : void 0;
|
|
2336
|
+
const paths = workspace?.changedPaths;
|
|
2337
|
+
const foldChangedPaths = Array.isArray(paths) && paths.length > 8;
|
|
2338
|
+
const workspaceProjection = foldChangedPaths ? {
|
|
2339
|
+
workspace: { ...workspace, changedPaths: paths.slice(0, 5), changedPathsCount: paths.length, changedPathsTruncated: true }
|
|
2340
|
+
} : {};
|
|
2341
|
+
const projected = { ...acceptance, ...workspaceProjection, checks: { ...checks, observationSummary: {
|
|
2312
2342
|
count: observations.length,
|
|
2313
2343
|
exitZero,
|
|
2314
2344
|
exitNonzero,
|
|
@@ -2318,7 +2348,7 @@ function projectRunResultRead(path, content, raw = false) {
|
|
|
2318
2348
|
limitation: "Exit counts are observations, not version-bound test or review approval."
|
|
2319
2349
|
} } };
|
|
2320
2350
|
const line = `acceptance: ${JSON.stringify(JSON.stringify(projected))}`;
|
|
2321
|
-
if (line.length >= header[index].length) return unchanged;
|
|
2351
|
+
if (!foldChangedPaths && line.length >= header[index].length) return unchanged;
|
|
2322
2352
|
header[index] = line;
|
|
2323
2353
|
return { content: header.join("\n") + content.slice(end3), projected: true };
|
|
2324
2354
|
} catch {
|
|
@@ -4639,17 +4669,17 @@ function buildWorkspacePathProperty() {
|
|
|
4639
4669
|
};
|
|
4640
4670
|
}
|
|
4641
4671
|
function buildReadWorkspaceDescription() {
|
|
4642
|
-
return "Read
|
|
4672
|
+
return "Read UTF-8 text (including runtime spills). Read known targets concurrently in one turn; search/glob first if paths or ranges are unknown, then use lines.";
|
|
4643
4673
|
}
|
|
4644
4674
|
function buildReadWorkspaceParameters() {
|
|
4645
4675
|
const path = buildWorkspacePathProperty();
|
|
4646
4676
|
const lines = {
|
|
4647
4677
|
type: "string",
|
|
4648
|
-
description: '
|
|
4678
|
+
description: '1-based inclusive slice: "40-120", "120-" (to EOF), "-50" (tail), "50" (head). Omit to start at top; large reads are bounded. Continue at metadata endLine+1.'
|
|
4649
4679
|
};
|
|
4650
4680
|
const force = {
|
|
4651
4681
|
type: "boolean",
|
|
4652
|
-
description: "
|
|
4682
|
+
description: "An unchanged, already delivered range returns only a notice; true refetches (e.g. after compaction)."
|
|
4653
4683
|
};
|
|
4654
4684
|
return {
|
|
4655
4685
|
type: "object",
|
|
@@ -4659,7 +4689,7 @@ function buildReadWorkspaceParameters() {
|
|
|
4659
4689
|
force,
|
|
4660
4690
|
raw: {
|
|
4661
4691
|
type: "boolean",
|
|
4662
|
-
description: "
|
|
4692
|
+
description: "Original *.result.md bytes incl. acceptance observations. Default compacts only machine observations, preserving report text and physical line numbers."
|
|
4663
4693
|
}
|
|
4664
4694
|
},
|
|
4665
4695
|
required: ["path"]
|
|
@@ -4680,7 +4710,7 @@ function buildWriteWorkspaceFileTool() {
|
|
|
4680
4710
|
type: "function",
|
|
4681
4711
|
function: {
|
|
4682
4712
|
name: "writeFile",
|
|
4683
|
-
description: "Write full UTF-8 file content
|
|
4713
|
+
description: "Write full UTF-8 file content in the workspace (new files or whole-file rewrites). Prefer editFile for targeted edits.",
|
|
4684
4714
|
parameters: {
|
|
4685
4715
|
type: "object",
|
|
4686
4716
|
properties: {
|
|
@@ -4700,23 +4730,23 @@ function buildReplaceWorkspaceTextTool() {
|
|
|
4700
4730
|
type: "function",
|
|
4701
4731
|
function: {
|
|
4702
4732
|
name: "editFile",
|
|
4703
|
-
description: "Replace exact text
|
|
4733
|
+
description: "Replace exact text. Count mismatch errors; never fall back to whole-file rewrite.",
|
|
4704
4734
|
parameters: {
|
|
4705
4735
|
type: "object",
|
|
4706
4736
|
properties: {
|
|
4707
4737
|
path: buildWorkspacePathProperty(),
|
|
4708
4738
|
oldText: {
|
|
4709
4739
|
type: "string",
|
|
4710
|
-
description: "Exact text
|
|
4740
|
+
description: "Exact existing text."
|
|
4711
4741
|
},
|
|
4712
4742
|
newText: {
|
|
4713
4743
|
type: "string",
|
|
4714
|
-
description: "Replacement
|
|
4744
|
+
description: "Replacement for oldText."
|
|
4715
4745
|
},
|
|
4716
4746
|
expectedReplacements: {
|
|
4717
4747
|
type: "integer",
|
|
4718
4748
|
minimum: 1,
|
|
4719
|
-
description: "Expected
|
|
4749
|
+
description: "Expected count; default 1."
|
|
4720
4750
|
}
|
|
4721
4751
|
// 刻意保持单一声明(integer),不引入 anyOf/oneOf 组合 schema:
|
|
4722
4752
|
// provider 对组合 schema 的处理不一致——Gemini 会把无顶层 type 的联合
|
|
@@ -4729,26 +4759,26 @@ function buildReplaceWorkspaceTextTool() {
|
|
|
4729
4759
|
};
|
|
4730
4760
|
}
|
|
4731
4761
|
function buildGlobWorkspaceDescription() {
|
|
4732
|
-
return "
|
|
4762
|
+
return "Glob paths without reading contents; brace groups combine patterns.";
|
|
4733
4763
|
}
|
|
4734
4764
|
function buildGlobWorkspaceParameters() {
|
|
4735
4765
|
const pattern = {
|
|
4736
4766
|
type: "string",
|
|
4737
|
-
description: "
|
|
4767
|
+
description: "File glob, e.g. **/*.{ts,tsx}."
|
|
4738
4768
|
};
|
|
4739
4769
|
const path = buildWorkspacePathProperty();
|
|
4740
4770
|
const includeIgnored = {
|
|
4741
4771
|
type: "boolean",
|
|
4742
|
-
description: "
|
|
4772
|
+
description: "Include gitignored files, never .git or node_modules."
|
|
4743
4773
|
};
|
|
4744
4774
|
const maxResults = {
|
|
4745
4775
|
type: "integer",
|
|
4746
|
-
description: "
|
|
4776
|
+
description: "Maximum paths."
|
|
4747
4777
|
};
|
|
4748
4778
|
const exclude = {
|
|
4749
4779
|
type: "array",
|
|
4750
4780
|
items: { type: "string" },
|
|
4751
|
-
description: "
|
|
4781
|
+
description: "Exclude globs."
|
|
4752
4782
|
};
|
|
4753
4783
|
return {
|
|
4754
4784
|
type: "object",
|
|
@@ -4827,32 +4857,32 @@ function buildLaunchProcessTool() {
|
|
|
4827
4857
|
type: "function",
|
|
4828
4858
|
function: {
|
|
4829
4859
|
name: "launchProcess",
|
|
4830
|
-
description:
|
|
4860
|
+
description: 'Track a dev server, watcher or REPL; returns pid/label/taskId/status immediately unless readyPattern waits (ready/readyOutcome/matchedLine/waitedMs/tails). Exit is notice-only on the next real turn, never wakes one. Inspect/read/wait/stop via listProcesses/readProcessOutput/taskWait/taskStop. Finite jobs needing wakeup: execShell background:true. Temporary preview servers: one you start for your own objective verification belongs to the turn that started it \u2014 stop it with taskStop before you return, or run the whole check as one finite job (execShell background:true / a foreground command) so it ends by itself. A preview the user is watching stays up: a new turn is NOT proof that verification finished (the next message may be "it does not open", "keep going", or a background wake). Close a user-facing preview only after you have confirmed all four yourself: it is the task/PID you started (listProcesses, then taskStop with that exact taskId), it holds no state you need (stateless \u2014 restarting loses nothing), verification is actually finished, and the user no longer needs it. The stop path only refuses a foreground grace-window command or an already-terminal task; tasks from other turns and other conversations share the same registry, so nothing else identifies your ownership \u2014 when you cannot match the task/PID, ask the user instead of guessing.',
|
|
4831
4861
|
parameters: {
|
|
4832
4862
|
type: "object",
|
|
4833
4863
|
properties: {
|
|
4834
4864
|
command: {
|
|
4835
4865
|
type: "string",
|
|
4836
|
-
description: "
|
|
4866
|
+
description: "Background shell command."
|
|
4837
4867
|
},
|
|
4838
4868
|
label: {
|
|
4839
4869
|
type: "string",
|
|
4840
|
-
description: "
|
|
4870
|
+
description: "Display label."
|
|
4841
4871
|
},
|
|
4842
4872
|
persist: {
|
|
4843
4873
|
type: "boolean",
|
|
4844
|
-
description: "
|
|
4874
|
+
description: "Survive session/conversation close; default false."
|
|
4845
4875
|
},
|
|
4846
4876
|
readyPattern: {
|
|
4847
4877
|
type: "string",
|
|
4848
4878
|
minLength: 1,
|
|
4849
|
-
description: "
|
|
4879
|
+
description: "Wait for stdout/stderr regex; omit for immediate return. Linear-time, per line, ANSI stripped; while running, newline-terminated only. Backreferences and lookarounds fail with `invalid-arguments`."
|
|
4850
4880
|
},
|
|
4851
4881
|
readyTimeoutMs: {
|
|
4852
4882
|
type: "integer",
|
|
4853
4883
|
minimum: 100,
|
|
4854
4884
|
maximum: 12e4,
|
|
4855
|
-
description: "
|
|
4885
|
+
description: "Ready wait in ms; default 30000, clamp 100..120000. Timeout returns tails without stopping task."
|
|
4856
4886
|
}
|
|
4857
4887
|
},
|
|
4858
4888
|
required: ["command"]
|
|
@@ -4884,10 +4914,12 @@ function buildListProcessesTool() {
|
|
|
4884
4914
|
type: "function",
|
|
4885
4915
|
function: {
|
|
4886
4916
|
name: "listProcesses",
|
|
4887
|
-
description: "List
|
|
4917
|
+
description: "List running process tasks by default, or include finished tasks. Returns {taskId, pid, pgid, label, command (preview up to 240 characters), status, startedAt, persist, promoted, transient, ownerDialogId?, exitCode?, durationMs?, outputRef?}[].",
|
|
4888
4918
|
parameters: {
|
|
4889
4919
|
type: "object",
|
|
4890
|
-
properties: {
|
|
4920
|
+
properties: {
|
|
4921
|
+
includeFinished: { type: "boolean", default: false, description: "Include finished tasks. Defaults to false (running only)." }
|
|
4922
|
+
}
|
|
4891
4923
|
}
|
|
4892
4924
|
}
|
|
4893
4925
|
};
|
|
@@ -4897,40 +4929,40 @@ function buildReadProcessOutputTool() {
|
|
|
4897
4929
|
type: "function",
|
|
4898
4930
|
function: {
|
|
4899
4931
|
name: "readProcessOutput",
|
|
4900
|
-
description:
|
|
4932
|
+
description: "Read live/final stdout/stderr for tracked launchProcess or promoted execShell tasks. Returns {outcome, taskId, status, exitCode?, cursor, stdout, stderr, truncated, cursorEvicted, matchedStream?, matchedLine?, waitedMs?, outputRef?}. cursorEvicted means earlier bytes dropped from 64KB ring. Do not poll finite execShell jobs; completion wakes the conversation.",
|
|
4901
4933
|
parameters: {
|
|
4902
4934
|
type: "object",
|
|
4903
4935
|
properties: {
|
|
4904
4936
|
taskId: {
|
|
4905
4937
|
type: "string",
|
|
4906
4938
|
minLength: 1,
|
|
4907
|
-
description:
|
|
4939
|
+
description: "Task ID from launchProcess or listProcesses."
|
|
4908
4940
|
},
|
|
4909
4941
|
cursor: {
|
|
4910
4942
|
type: "string",
|
|
4911
|
-
description:
|
|
4943
|
+
description: "Reuse returned <stdoutLines>:<stderrLines> cursor for new output; omit for current tail."
|
|
4912
4944
|
},
|
|
4913
4945
|
stream: {
|
|
4914
4946
|
type: "string",
|
|
4915
4947
|
enum: ["both", "stdout", "stderr"],
|
|
4916
|
-
description:
|
|
4948
|
+
description: "Read/match streams; default both."
|
|
4917
4949
|
},
|
|
4918
4950
|
maxChars: {
|
|
4919
4951
|
type: "integer",
|
|
4920
4952
|
minimum: 256,
|
|
4921
4953
|
maximum: 32e3,
|
|
4922
|
-
description: "
|
|
4954
|
+
description: "Chars per stream; default 8000, clamp 256..32000."
|
|
4923
4955
|
},
|
|
4924
4956
|
waitForPattern: {
|
|
4925
4957
|
type: "string",
|
|
4926
4958
|
minLength: 1,
|
|
4927
|
-
description: "
|
|
4959
|
+
description: "Wait for regex match, exit or timeoutMs. Linear-time, per line, ANSI stripped; while running, newline-terminated only. Backreferences and lookarounds fail with `invalid-arguments`."
|
|
4928
4960
|
},
|
|
4929
4961
|
timeoutMs: {
|
|
4930
4962
|
type: "integer",
|
|
4931
4963
|
minimum: 0,
|
|
4932
4964
|
maximum: 12e4,
|
|
4933
|
-
description: "
|
|
4965
|
+
description: "waitForPattern budget (ms); default 30000, clamp 0..120000."
|
|
4934
4966
|
}
|
|
4935
4967
|
},
|
|
4936
4968
|
required: ["taskId"]
|
|
@@ -4967,14 +4999,14 @@ function buildTaskStopTool() {
|
|
|
4967
4999
|
type: "function",
|
|
4968
5000
|
function: {
|
|
4969
5001
|
name: "taskStop",
|
|
4970
|
-
description:
|
|
5002
|
+
description: `Signal background process group: SIGTERM, then SIGKILL after a short grace period if alive. Returns {outcome,status,signal,escalated}: stopped only if signalled; else not-stoppable (finished/foreground) or not-found. Never pass runId/empty IDs; stop agent runs with controlAgentRun(action: "stop"). This is the close path for cleanup you decided on (e.g. a preview server you started, once the user is done with it): only the named taskId is signalled, and a foreground grace-window command or an already-terminal task is refused. Nothing else is checked \u2014 every task in this process shares one registry, other turns' and other conversations' tasks and any running deploy included \u2014 so match the taskId/PID against the task you started before calling, and never use it as blanket cleanup.`,
|
|
4971
5003
|
parameters: {
|
|
4972
5004
|
type: "object",
|
|
4973
5005
|
properties: {
|
|
4974
5006
|
taskId: {
|
|
4975
5007
|
type: "string",
|
|
4976
5008
|
minLength: 1,
|
|
4977
|
-
description: "Task
|
|
5009
|
+
description: "Task ID from launchProcess or detached execShell."
|
|
4978
5010
|
}
|
|
4979
5011
|
},
|
|
4980
5012
|
required: ["taskId"]
|
|
@@ -4998,7 +5030,7 @@ function buildWorkspaceToolDefinition(toolName) {
|
|
|
4998
5030
|
type: "function",
|
|
4999
5031
|
function: {
|
|
5000
5032
|
name: "read_image",
|
|
5001
|
-
description: "
|
|
5033
|
+
description: "Local PNG/JPEG/WebP/GIF: path or paths (1\u20134), not both; any failure rejects batch. Long edge >1568px \u2192 resize to JPEG q80; base64 limits: 2MiB/image, 8MiB/request. Never reread chat [\u9644\u4EF6] (already visible).",
|
|
5002
5034
|
parameters: {
|
|
5003
5035
|
type: "object",
|
|
5004
5036
|
properties: {
|
|
@@ -5026,19 +5058,19 @@ function buildWorkspaceToolDefinition(toolName) {
|
|
|
5026
5058
|
type: "function",
|
|
5027
5059
|
function: {
|
|
5028
5060
|
name: "searchFiles",
|
|
5029
|
-
description: "Search UTF-8 text
|
|
5061
|
+
description: "Search workspace UTF-8 text, literal or regex, on Windows/macOS/Linux. Prefer over shell grep/rg/Select-String.",
|
|
5030
5062
|
parameters: {
|
|
5031
5063
|
type: "object",
|
|
5032
5064
|
properties: {
|
|
5033
|
-
query: { type: "string", minLength: 1, description: "Search text
|
|
5065
|
+
query: { type: "string", minLength: 1, description: "Search text; pattern is a grep/rg alias if query is omitted." },
|
|
5034
5066
|
path: buildWorkspacePathProperty(),
|
|
5035
|
-
regex: { type: "boolean", description: "
|
|
5067
|
+
regex: { type: "boolean", description: "Regex if true; literal by default." },
|
|
5036
5068
|
caseSensitive: { type: "boolean", description: "Default true." },
|
|
5037
|
-
include: { type: "string", description: "
|
|
5069
|
+
include: { type: "string", description: "Include glob, e.g. *.{ts,md}." },
|
|
5038
5070
|
exclude: { type: "array", items: { type: "string" } },
|
|
5039
|
-
contextLines: { type: "integer", minimum: 0, maximum: 5 },
|
|
5040
|
-
maxResults: { type: "integer", minimum: 1, maximum: 1e3, description: "
|
|
5041
|
-
includeIgnored: { type: "boolean", description: "
|
|
5071
|
+
contextLines: { type: "integer", minimum: 0, maximum: 5, description: "Context lines around each match (0..5)." },
|
|
5072
|
+
maxResults: { type: "integer", minimum: 1, maximum: 1e3, description: "Stop at this many matches; default 100." },
|
|
5073
|
+
includeIgnored: { type: "boolean", description: "Include gitignored files; default false." }
|
|
5042
5074
|
},
|
|
5043
5075
|
required: ["query"],
|
|
5044
5076
|
additionalProperties: false
|
|
@@ -5899,7 +5931,7 @@ async function readFileTool(args2) {
|
|
|
5899
5931
|
const approval = await resolveLocalWorkspaceToolApproval({
|
|
5900
5932
|
workspaceRoot: args2.workspaceRoot,
|
|
5901
5933
|
requestedPath,
|
|
5902
|
-
allowRuntimeOwnedSpill:
|
|
5934
|
+
allowRuntimeOwnedSpill: !args2.denyExternalReadSpills,
|
|
5903
5935
|
...args2.confirmExternalFileAccess ? { confirmExternalFileAccess: args2.confirmExternalFileAccess } : {}
|
|
5904
5936
|
});
|
|
5905
5937
|
const absolutePath = approval.path;
|
|
@@ -6770,7 +6802,8 @@ async function launchProcessTool(args2) {
|
|
|
6770
6802
|
};
|
|
6771
6803
|
}
|
|
6772
6804
|
async function listProcessesTool(args2) {
|
|
6773
|
-
const
|
|
6805
|
+
const { includeFinished } = parseWorkspaceToolArguments(args2.call.arguments);
|
|
6806
|
+
const list = getProcessRegistry().list().filter((task) => includeFinished === true || task.status === "running").map(toProcessTaskView);
|
|
6774
6807
|
return {
|
|
6775
6808
|
content: JSON.stringify(list),
|
|
6776
6809
|
metadata: {
|
|
@@ -6923,7 +6956,10 @@ async function openDesktopPreviewTool(args2) {
|
|
|
6923
6956
|
try {
|
|
6924
6957
|
const response = await fetch(`http://127.0.0.1:${port}/api/desktop/preview/open`, {
|
|
6925
6958
|
method: "POST",
|
|
6926
|
-
headers: {
|
|
6959
|
+
headers: {
|
|
6960
|
+
"Content-Type": "application/json",
|
|
6961
|
+
"x-nolo-desktop-tool": "1"
|
|
6962
|
+
},
|
|
6927
6963
|
body: JSON.stringify({ url })
|
|
6928
6964
|
});
|
|
6929
6965
|
const bodyText = await response.text();
|
|
@@ -7064,6 +7100,7 @@ function createLocalWorkspaceToolExecutors(args2) {
|
|
|
7064
7100
|
call,
|
|
7065
7101
|
workspaceRoot: args2.workspaceRoot,
|
|
7066
7102
|
...readFileLedger ? { readLedger: readFileLedger } : {},
|
|
7103
|
+
denyExternalReadSpills: args2.denyExternalReadSpills,
|
|
7067
7104
|
...fileAccess
|
|
7068
7105
|
}), { resetReadLedger: () => readFileLedger?.clear() }),
|
|
7069
7106
|
writeFile: (call) => writeFileTool({
|
|
@@ -7493,7 +7530,7 @@ async function executeLocalToolWithPolicy(args2) {
|
|
|
7493
7530
|
}
|
|
7494
7531
|
|
|
7495
7532
|
// packages/agent-runtime/localLoop.ts
|
|
7496
|
-
import { resolve as resolvePath } from "node:path";
|
|
7533
|
+
import { relative as relative6, resolve as resolvePath, sep as sep4 } from "node:path";
|
|
7497
7534
|
|
|
7498
7535
|
// node_modules/effect/dist/Pipeable.js
|
|
7499
7536
|
var pipeArguments = (self, args2) => {
|
|
@@ -20391,6 +20428,9 @@ function buildToolArgsDiagnosticLine(args2) {
|
|
|
20391
20428
|
}
|
|
20392
20429
|
|
|
20393
20430
|
// packages/agent-runtime/progressGuard.ts
|
|
20431
|
+
function workGoalFailureKey(toolName, code) {
|
|
20432
|
+
if (toolName === "rememberMemory" && (code === "WORK_MEMORY_INVALID_GOAL" || code === "WORK_MEMORY_GOAL_REQUIRED")) return code;
|
|
20433
|
+
}
|
|
20394
20434
|
var DEFAULT_MAX_CONSECUTIVE_IDENTICAL_ROUNDS = 5;
|
|
20395
20435
|
var DEFAULT_MAX_CONSECUTIVE_STAGNANT_TOOL_ROUNDS = 8;
|
|
20396
20436
|
function sortJsonKeys(obj) {
|
|
@@ -20502,6 +20542,15 @@ var LocalLoopProgressGuard = class {
|
|
|
20502
20542
|
lastToolCallsSignature = null;
|
|
20503
20543
|
lastToolResultsSignature = null;
|
|
20504
20544
|
consecutiveStagnantToolCount = 0;
|
|
20545
|
+
reportedDeterministicFailures = /* @__PURE__ */ new Set();
|
|
20546
|
+
/** Same input error stays visible to the model, but is reported once per turn. */
|
|
20547
|
+
shouldReportToolError(toolName, code) {
|
|
20548
|
+
const key = workGoalFailureKey(toolName, code);
|
|
20549
|
+
if (this.config.disabled || !key) return true;
|
|
20550
|
+
if (this.reportedDeterministicFailures.has(key)) return false;
|
|
20551
|
+
this.reportedDeterministicFailures.add(key);
|
|
20552
|
+
return true;
|
|
20553
|
+
}
|
|
20505
20554
|
constructor(config, env) {
|
|
20506
20555
|
this.config = resolveProgressGuardConfig(config, env);
|
|
20507
20556
|
}
|
|
@@ -20538,8 +20587,12 @@ var LocalLoopProgressGuard = class {
|
|
|
20538
20587
|
observeToolExecution(toolCalls, toolResults) {
|
|
20539
20588
|
if (this.config.disabled) return { action: "continue" };
|
|
20540
20589
|
if (!toolCalls || toolCalls.length === 0) return { action: "continue" };
|
|
20541
|
-
const
|
|
20542
|
-
|
|
20590
|
+
const goalFailures = toolResults.map(
|
|
20591
|
+
({ toolName, metadata }) => metadata?.error === true ? workGoalFailureKey(toolName, metadata.code) : void 0
|
|
20592
|
+
);
|
|
20593
|
+
const rejectedGoals = goalFailures.length === toolCalls.length && goalFailures.every(Boolean) ? "work-goal-errors" : void 0;
|
|
20594
|
+
const toolCallsSig = rejectedGoals ?? buildToolCallsSignature(toolCalls);
|
|
20595
|
+
const toolResultsSig = rejectedGoals ?? buildToolResultsSignature(toolResults);
|
|
20543
20596
|
const toolCallsUnchanged = this.lastToolCallsSignature !== null && this.lastToolCallsSignature === toolCallsSig;
|
|
20544
20597
|
const toolResultsUnchanged = this.lastToolResultsSignature !== null && this.lastToolResultsSignature === toolResultsSig;
|
|
20545
20598
|
if (toolCallsUnchanged && toolResultsUnchanged) {
|
|
@@ -21181,6 +21234,8 @@ ${toolResult.content}` : toolResult.content,
|
|
|
21181
21234
|
);
|
|
21182
21235
|
} catch (error) {
|
|
21183
21236
|
const finishedAt = Date.now();
|
|
21237
|
+
const code = error?.code;
|
|
21238
|
+
const report = args2.shouldReportToolError?.(toolName, code) !== false;
|
|
21184
21239
|
emitLoopEvent(
|
|
21185
21240
|
boundary,
|
|
21186
21241
|
{
|
|
@@ -21199,7 +21254,8 @@ ${toolResult.content}` : toolResult.content,
|
|
|
21199
21254
|
toolCallId: toolCall.id,
|
|
21200
21255
|
toolName,
|
|
21201
21256
|
elapsedMs: Math.max(0, finishedAt - startedAt),
|
|
21202
|
-
message: toErrorMessage(error)
|
|
21257
|
+
message: toErrorMessage(error),
|
|
21258
|
+
...!report ? { repeatedDeterministicFailure: true } : {}
|
|
21203
21259
|
}
|
|
21204
21260
|
);
|
|
21205
21261
|
if (error && typeof error === "object" && error.code === LOCAL_TURN_ABORTED_CODE) {
|
|
@@ -21355,44 +21411,6 @@ function createTurnUsageLedger(args2) {
|
|
|
21355
21411
|
};
|
|
21356
21412
|
}
|
|
21357
21413
|
|
|
21358
|
-
// packages/agent-runtime/agentRunIsolation.ts
|
|
21359
|
-
var ORCHESTRATION_TOOL_NAMES = /* @__PURE__ */ new Set([
|
|
21360
|
-
"startAgentRun",
|
|
21361
|
-
"controlAgentRun",
|
|
21362
|
-
"listAgents",
|
|
21363
|
-
"readAgent",
|
|
21364
|
-
"runStreamingAgent"
|
|
21365
|
-
]);
|
|
21366
|
-
var INTERACTION_REQUIRED_TOOL_NAMES = /* @__PURE__ */ new Set([
|
|
21367
|
-
"ask_user",
|
|
21368
|
-
// 凭据请求:需要宿主交互面板(Block 1a);desktop 无通道时同 ask_user 剥离。
|
|
21369
|
-
"secret-request"
|
|
21370
|
-
]);
|
|
21371
|
-
var SELF_MUTATION_TOOL_NAMES = /* @__PURE__ */ new Set([
|
|
21372
|
-
"updateSelf",
|
|
21373
|
-
"updateAgent"
|
|
21374
|
-
]);
|
|
21375
|
-
var SUBTASK_REMOVED_TOOL_NAMES = /* @__PURE__ */ new Set([
|
|
21376
|
-
...ORCHESTRATION_TOOL_NAMES,
|
|
21377
|
-
...INTERACTION_REQUIRED_TOOL_NAMES,
|
|
21378
|
-
...SELF_MUTATION_TOOL_NAMES
|
|
21379
|
-
]);
|
|
21380
|
-
function isSubtaskRun(env) {
|
|
21381
|
-
if (!env) return false;
|
|
21382
|
-
const value = env.NOLO_AGENT_RUN_CHILD;
|
|
21383
|
-
return typeof value === "string" && value.length > 0 && value !== "0";
|
|
21384
|
-
}
|
|
21385
|
-
var RUN_WAKE_CHANNEL_ENV = "NOLO_RUN_WAKE";
|
|
21386
|
-
function hasRunWakeChannel(env) {
|
|
21387
|
-
if (!env) return false;
|
|
21388
|
-
const value = env[RUN_WAKE_CHANNEL_ENV];
|
|
21389
|
-
return typeof value === "string" && value.length > 0 && value !== "0";
|
|
21390
|
-
}
|
|
21391
|
-
function filterToolNamesForRunKind(toolNames, isSubtask) {
|
|
21392
|
-
if (!isSubtask) return [...toolNames];
|
|
21393
|
-
return toolNames.filter((name) => !SUBTASK_REMOVED_TOOL_NAMES.has(name));
|
|
21394
|
-
}
|
|
21395
|
-
|
|
21396
21414
|
// packages/agent-runtime/subtaskBudget.ts
|
|
21397
21415
|
var DEFAULT_SUBTASK_SOFT_BUDGET_MILESTONE_1_TOOL_CALLS = 40;
|
|
21398
21416
|
var DEFAULT_SUBTASK_SOFT_BUDGET_MILESTONE_2_TOOL_CALLS = 80;
|
|
@@ -21503,6 +21521,105 @@ var normalizeContextBlockScopes = (legacyBlocks = void 0, scopes = void 0) => {
|
|
|
21503
21521
|
return (Array.isArray(legacyBlocks) ? legacyBlocks : []).filter((block) => typeof block === "string").map((block) => block.trim()).filter((block) => block.length > 0).map((block) => ({ content: block, cacheScope: "turn" }));
|
|
21504
21522
|
};
|
|
21505
21523
|
|
|
21524
|
+
// packages/ai/context/summaryQuality.ts
|
|
21525
|
+
var COMPACTION_REQUIRED_SECTIONS = [
|
|
21526
|
+
"\u5173\u952E\u4E8B\u5B9E\u6863\u6848",
|
|
21527
|
+
"\u5BF9\u8BDD\u8FDB\u5C55\u4E0E\u5F85\u529E",
|
|
21528
|
+
"\u6587\u4EF6\u64CD\u4F5C\u6E05\u5355"
|
|
21529
|
+
];
|
|
21530
|
+
var COMPACTION_REQUIRED_SLOTS = [
|
|
21531
|
+
"\u539F\u59CB\u76EE\u6807",
|
|
21532
|
+
"\u76EE\u6807\u6F14\u5316",
|
|
21533
|
+
"\u5DF2\u8BC1\u4F2A\u7684\u5047\u8BBE",
|
|
21534
|
+
"\u5361\u70B9\u4E0E\u9700\u7528\u6237\u51B3\u5B9A",
|
|
21535
|
+
"\u8F93\u5165\u672A\u8986\u76D6"
|
|
21536
|
+
];
|
|
21537
|
+
function hasSectionHeading(text2, heading) {
|
|
21538
|
+
const re = new RegExp(`^\\s*(?:#{1,6}\\s*)?${heading}\\s*[:\uFF1A]?\\s*$`, "m");
|
|
21539
|
+
return re.test(text2);
|
|
21540
|
+
}
|
|
21541
|
+
function hasSlotMarker(text2, slot) {
|
|
21542
|
+
const re = new RegExp(`(?:^|\\n)\\s*(?:[-*\u2022]\\s*)?(?:\\*\\*)?[\u300C\u3010\\[]?${slot}[\u300D\u3011\\]]?(?:\\*\\*)?\\s*[:\uFF1A]`, "m");
|
|
21543
|
+
return re.test(text2);
|
|
21544
|
+
}
|
|
21545
|
+
function extractOriginalGoalText(text2) {
|
|
21546
|
+
const match7 = text2.match(
|
|
21547
|
+
/(?:^|\n)\s*(?:[-*•]\s*)?(?:\*\*)?[「【\[]?原始目标[」】\]]?(?:\*\*)?\s*[::]\s*([^\n]+)/
|
|
21548
|
+
);
|
|
21549
|
+
if (!match7?.[1]) return null;
|
|
21550
|
+
const normalized = normalizeForComparison(match7[1]);
|
|
21551
|
+
return normalized.length > 0 ? normalized : null;
|
|
21552
|
+
}
|
|
21553
|
+
function normalizeForComparison(raw) {
|
|
21554
|
+
return raw.replace(/[`*_~「」『』【】\[\]()"'“”‘’]/g, "").replace(/\s+/g, " ").trim().toLowerCase();
|
|
21555
|
+
}
|
|
21556
|
+
function isGoalPreserved(prevGoal, nextGoal) {
|
|
21557
|
+
if (!nextGoal) return false;
|
|
21558
|
+
if (nextGoal === prevGoal || nextGoal.includes(prevGoal) || prevGoal.includes(nextGoal)) {
|
|
21559
|
+
return true;
|
|
21560
|
+
}
|
|
21561
|
+
const toBigrams = (s) => {
|
|
21562
|
+
const compact = s.replace(/\s+/g, "");
|
|
21563
|
+
const grams = /* @__PURE__ */ new Set();
|
|
21564
|
+
if (compact.length < 2) {
|
|
21565
|
+
if (compact.length === 1) grams.add(compact);
|
|
21566
|
+
return grams;
|
|
21567
|
+
}
|
|
21568
|
+
for (let i = 0; i < compact.length - 1; i++) {
|
|
21569
|
+
grams.add(compact.slice(i, i + 2));
|
|
21570
|
+
}
|
|
21571
|
+
return grams;
|
|
21572
|
+
};
|
|
21573
|
+
const prevGrams = toBigrams(prevGoal);
|
|
21574
|
+
const nextGrams = toBigrams(nextGoal);
|
|
21575
|
+
if (prevGrams.size === 0) return true;
|
|
21576
|
+
let hits = 0;
|
|
21577
|
+
for (const g of prevGrams) {
|
|
21578
|
+
if (nextGrams.has(g)) hits++;
|
|
21579
|
+
}
|
|
21580
|
+
return hits / prevGrams.size >= 0.6;
|
|
21581
|
+
}
|
|
21582
|
+
function inspectCompactionSummaryQuality(args2) {
|
|
21583
|
+
const text2 = typeof args2.newSummary === "string" ? args2.newSummary : "";
|
|
21584
|
+
let sectionsPresent = 0;
|
|
21585
|
+
for (const heading of COMPACTION_REQUIRED_SECTIONS) {
|
|
21586
|
+
if (hasSectionHeading(text2, heading)) sectionsPresent++;
|
|
21587
|
+
}
|
|
21588
|
+
let requiredSlotsPresent = 0;
|
|
21589
|
+
for (const slot of COMPACTION_REQUIRED_SLOTS) {
|
|
21590
|
+
if (hasSlotMarker(text2, slot)) requiredSlotsPresent++;
|
|
21591
|
+
}
|
|
21592
|
+
const hasOriginalGoal = hasSlotMarker(text2, "\u539F\u59CB\u76EE\u6807");
|
|
21593
|
+
const prevGoal = typeof args2.previousSummary === "string" && args2.previousSummary.trim().length > 0 ? extractOriginalGoalText(args2.previousSummary) : null;
|
|
21594
|
+
const nextGoal = extractOriginalGoalText(text2);
|
|
21595
|
+
const originalGoalPreserved = prevGoal === null ? null : isGoalPreserved(prevGoal, nextGoal);
|
|
21596
|
+
let writtenPathsTotal = null;
|
|
21597
|
+
let writtenPathsCovered = null;
|
|
21598
|
+
if (Array.isArray(args2.fileOps)) {
|
|
21599
|
+
const writtenPaths = /* @__PURE__ */ new Set();
|
|
21600
|
+
for (const op of args2.fileOps) {
|
|
21601
|
+
if ((op.type === "write" || op.type === "edit") && typeof op.path === "string" && op.path.trim()) {
|
|
21602
|
+
writtenPaths.add(op.path.trim());
|
|
21603
|
+
}
|
|
21604
|
+
}
|
|
21605
|
+
writtenPathsTotal = writtenPaths.size;
|
|
21606
|
+
let covered = 0;
|
|
21607
|
+
for (const path of writtenPaths) {
|
|
21608
|
+
if (text2.includes(path)) covered++;
|
|
21609
|
+
}
|
|
21610
|
+
writtenPathsCovered = covered;
|
|
21611
|
+
}
|
|
21612
|
+
return {
|
|
21613
|
+
sectionsPresent,
|
|
21614
|
+
sectionsComplete: sectionsPresent === COMPACTION_REQUIRED_SECTIONS.length,
|
|
21615
|
+
requiredSlotsPresent,
|
|
21616
|
+
hasOriginalGoal,
|
|
21617
|
+
originalGoalPreserved,
|
|
21618
|
+
writtenPathsTotal,
|
|
21619
|
+
writtenPathsCovered
|
|
21620
|
+
};
|
|
21621
|
+
}
|
|
21622
|
+
|
|
21506
21623
|
// packages/agent-runtime/providerInputItemLimits.ts
|
|
21507
21624
|
var PROVIDER_INPUT_ITEM_LIMITS = [
|
|
21508
21625
|
{
|
|
@@ -21564,18 +21681,22 @@ function appendCompactionTelemetryRecord(record2, opts) {
|
|
|
21564
21681
|
return false;
|
|
21565
21682
|
}
|
|
21566
21683
|
}
|
|
21684
|
+
function appendPostCompactionTurnRecord(record2, opts) {
|
|
21685
|
+
const file = resolveCompactionTelemetryLogPath(opts);
|
|
21686
|
+
if (!file) return false;
|
|
21687
|
+
try {
|
|
21688
|
+
mkdirSync(dirname3(file), { recursive: true });
|
|
21689
|
+
appendFileSync(file, JSON.stringify(record2) + "\n", "utf8");
|
|
21690
|
+
return true;
|
|
21691
|
+
} catch {
|
|
21692
|
+
return false;
|
|
21693
|
+
}
|
|
21694
|
+
}
|
|
21567
21695
|
|
|
21568
21696
|
// packages/agent-runtime/localAutoCompaction.ts
|
|
21569
21697
|
import { randomUUID } from "node:crypto";
|
|
21570
|
-
|
|
21571
|
-
|
|
21572
|
-
id: typeof message.id === "string" && message.id.length > 0 ? message.id : `local-${index}`,
|
|
21573
|
-
role: message.role,
|
|
21574
|
-
content: message.content ?? "",
|
|
21575
|
-
...typeof message.tool_call_id === "string" ? { tool_call_id: message.tool_call_id } : {},
|
|
21576
|
-
...Array.isArray(message.tool_calls) ? { tool_calls: message.tool_calls } : {}
|
|
21577
|
-
}));
|
|
21578
|
-
}
|
|
21698
|
+
|
|
21699
|
+
// packages/ai/context/compactHistoryCore.ts
|
|
21579
21700
|
function findSummaryAnchorIndex(bridged, anchorId) {
|
|
21580
21701
|
const actual = bridged.findIndex((message) => message.id === anchorId);
|
|
21581
21702
|
if (actual >= 0) return actual;
|
|
@@ -21584,55 +21705,76 @@ function findSummaryAnchorIndex(bridged, anchorId) {
|
|
|
21584
21705
|
const index = Number(legacy[1]);
|
|
21585
21706
|
return Number.isSafeInteger(index) && index < bridged.length ? index : -1;
|
|
21586
21707
|
}
|
|
21587
|
-
function
|
|
21588
|
-
const
|
|
21589
|
-
|
|
21590
|
-
|
|
21591
|
-
|
|
21592
|
-
|
|
21593
|
-
|
|
21594
|
-
|
|
21595
|
-
|
|
21596
|
-
|
|
21708
|
+
function resolveCompactHistory(rows, stored) {
|
|
21709
|
+
const anchor = typeof stored.summarizedBeforeId === "string" && stored.summarizedBeforeId || void 0;
|
|
21710
|
+
const index = anchor ? findSummaryAnchorIndex(rows, anchor) : -1;
|
|
21711
|
+
const validation = stored.schemaVersion !== void 0 && stored.schemaVersion !== COMPACTION_SUMMARY_SCHEMA_VERSION ? false : !stored.sourceHash ? void 0 : index >= 0 && (stored.sourceCount === void 0 || stored.sourceCount === index + 1) && computeSummarySourceMetadata(rows, rows[index]?.id)?.sourceHash === stored.sourceHash;
|
|
21712
|
+
const invalid3 = validation === false || !!anchor && index < 0;
|
|
21713
|
+
return {
|
|
21714
|
+
validation,
|
|
21715
|
+
invalid: invalid3,
|
|
21716
|
+
summary: !invalid3 && typeof stored.summary === "string" ? stored.summary : "",
|
|
21717
|
+
anchor: invalid3 ? void 0 : rows[index]?.id,
|
|
21718
|
+
pending: invalid3 || index < 0 ? rows : rows.slice(index + 1)
|
|
21719
|
+
};
|
|
21720
|
+
}
|
|
21721
|
+
function prepareCompactHistory(input, source, project, window = input.contextWindow, canonicalizeToolName2) {
|
|
21722
|
+
const plan = planCompression(input);
|
|
21723
|
+
const request3 = plan.shouldCompress && plan.msgsToCompress.length ? buildHistoricalCompactionRequest({
|
|
21724
|
+
msgsToCompress: plan.msgsToCompress.map(project),
|
|
21725
|
+
previousSummary: input.summary,
|
|
21726
|
+
contextWindow: window,
|
|
21727
|
+
canonicalizeToolName: canonicalizeToolName2
|
|
21728
|
+
}) : void 0;
|
|
21729
|
+
function ready() {
|
|
21730
|
+
if (request3?.status !== "ready") throw new Error("Compaction request not ready");
|
|
21731
|
+
return request3;
|
|
21597
21732
|
}
|
|
21598
|
-
|
|
21599
|
-
|
|
21600
|
-
|
|
21601
|
-
|
|
21602
|
-
|
|
21603
|
-
|
|
21604
|
-
|
|
21733
|
+
return {
|
|
21734
|
+
plan,
|
|
21735
|
+
request: request3,
|
|
21736
|
+
summarize: (callback4) => callback4(ready().promptContent, ready().outputTokenBudget),
|
|
21737
|
+
metadata: () => computeSummarySourceMetadata(source, ready().summarizedBeforeId),
|
|
21738
|
+
metrics(reason, newSummary, summaryUsage) {
|
|
21739
|
+
const bounded3 = ready();
|
|
21740
|
+
return buildCompactionMetricsFromPlan({
|
|
21741
|
+
reason,
|
|
21742
|
+
previousSummary: input.summary,
|
|
21743
|
+
newSummary,
|
|
21744
|
+
summaryUsage,
|
|
21745
|
+
plan: { msgsToCompress: bounded3.coveredMessages, msgsToKeep: [...plan.msgsToCompress.slice(bounded3.coveredMessages.length), ...plan.msgsToKeep] },
|
|
21746
|
+
summaryInput: bounded3,
|
|
21747
|
+
planCounts: { pendingMessageCount: plan.diagnostics?.pendingMsgCount, plannedCompressCount: plan.diagnostics?.compressCount }
|
|
21748
|
+
});
|
|
21749
|
+
}
|
|
21750
|
+
};
|
|
21605
21751
|
}
|
|
21606
|
-
|
|
21607
|
-
|
|
21608
|
-
|
|
21609
|
-
|
|
21610
|
-
|
|
21611
|
-
|
|
21612
|
-
|
|
21613
|
-
|
|
21614
|
-
|
|
21615
|
-
|
|
21616
|
-
|
|
21617
|
-
|
|
21752
|
+
|
|
21753
|
+
// packages/agent-runtime/localAutoCompaction.ts
|
|
21754
|
+
function toPlanCompressionMessages(history) {
|
|
21755
|
+
let discoveries = /* @__PURE__ */ new Set();
|
|
21756
|
+
return history.map((message, index) => {
|
|
21757
|
+
const calls = message.role === "assistant" && Array.isArray(message.tool_calls) ? message.tool_calls : void 0;
|
|
21758
|
+
if (message.role !== "tool") {
|
|
21759
|
+
discoveries = new Set(calls?.filter(isToolDiscoveryCall).map((call) => call.id));
|
|
21760
|
+
}
|
|
21761
|
+
const discoveryResult = message.role === "tool" && typeof message.tool_call_id === "string" && message.tool_call_id.startsWith(TOOL_DISCOVERY_ID_PREFIX) && (discoveries.delete(message.tool_call_id) || message.toolName === TOOL_DISCOVERY_CALL_NAME);
|
|
21762
|
+
return {
|
|
21763
|
+
id: typeof message.id === "string" && message.id.length > 0 ? message.id : `local-${index}`,
|
|
21764
|
+
role: message.role,
|
|
21765
|
+
content: discoveryResult ? "" : message.content ?? "",
|
|
21766
|
+
// Keep the empty discovery pair together so the compressor can group mixed batches.
|
|
21767
|
+
...typeof message.tool_call_id === "string" ? { tool_call_id: message.tool_call_id } : {},
|
|
21768
|
+
...calls ? { tool_calls: discoveries.size ? calls.map(
|
|
21769
|
+
(call) => isToolDiscoveryCall(call) ? { ...call, function: { name: "", arguments: "{}" } } : call
|
|
21770
|
+
) : calls } : {}
|
|
21771
|
+
};
|
|
21772
|
+
});
|
|
21618
21773
|
}
|
|
21619
|
-
function
|
|
21620
|
-
const
|
|
21621
|
-
|
|
21622
|
-
|
|
21623
|
-
}
|
|
21624
|
-
const sourceHash = stored.sourceHash;
|
|
21625
|
-
if (typeof sourceHash !== "string" || !sourceHash) return void 0;
|
|
21626
|
-
if (typeof stored.sourceCount === "number" && history.length < stored.sourceCount) {
|
|
21627
|
-
return false;
|
|
21628
|
-
}
|
|
21629
|
-
const bridged = toPlanCompressionMessages(history);
|
|
21630
|
-
const found = findSummaryAnchorIndex(bridged, stored.summarizedBeforeId ?? "");
|
|
21631
|
-
if (found === -1) return false;
|
|
21632
|
-
const recomputed = hashSummarySourceSlice(history, stored.summarizedBeforeId);
|
|
21633
|
-
if (recomputed === void 0) return false;
|
|
21634
|
-
if (recomputed !== sourceHash) return false;
|
|
21635
|
-
return true;
|
|
21774
|
+
function hashSummarySourceSlice(history, summarizedBeforeId) {
|
|
21775
|
+
const rows = toPlanCompressionMessages(history);
|
|
21776
|
+
const index = findSummaryAnchorIndex(rows, summarizedBeforeId ?? "");
|
|
21777
|
+
return computeSummarySourceMetadata(rows, rows[index]?.id)?.sourceHash;
|
|
21636
21778
|
}
|
|
21637
21779
|
function buildLocalSummaryHistoryMessage(summary) {
|
|
21638
21780
|
const layer = buildDialogSummaryLayer({ summary });
|
|
@@ -21659,9 +21801,10 @@ function projectHistoryWithSummary(args2) {
|
|
|
21659
21801
|
}
|
|
21660
21802
|
const preservedUser = latestUser >= 0 && latestUser < startIndex ? [args2.history[latestUser]] : [];
|
|
21661
21803
|
const summaryMsg = args2.summary.trim().length > 0 ? [buildLocalSummaryHistoryMessage(args2.summary)] : [];
|
|
21804
|
+
const loaded = summaryMsg[0] && startIndex > 0 ? collectToolLoadingReferences(args2.history.slice(0, startIndex)) : void 0;
|
|
21805
|
+
if (loaded?.loaded.length) summaryMsg[0].compactedToolLoading = loaded;
|
|
21662
21806
|
return [...summaryMsg, ...preservedUser, ...projected];
|
|
21663
21807
|
}
|
|
21664
|
-
var COLD_RESUME_IDLE_MS = 60 * 60 * 1e3;
|
|
21665
21808
|
async function completeRoutedCompactionSummary(args2) {
|
|
21666
21809
|
const budget = createSummaryBudget({ mode: "automatic", signal: args2.options.signal, deadlineMs: args2.options.deadlineMs });
|
|
21667
21810
|
try {
|
|
@@ -21682,7 +21825,7 @@ async function completeRoutedCompactionSummary(args2) {
|
|
|
21682
21825
|
model: PLATFORM_HOSTED_DEEPSEEK_FLASH_MODEL,
|
|
21683
21826
|
provider: "nolo",
|
|
21684
21827
|
attemptId: options.attemptId,
|
|
21685
|
-
run: async () => args2.fallback.complete ? args2.fallback.complete(args2.content, options) : { text: await args2.fallback(args2.content, options) ?? "" }
|
|
21828
|
+
run: async (context3) => args2.fallback.complete ? args2.fallback.complete(args2.content, { ...options, ...context3 }) : { text: await args2.fallback(args2.content, { ...options, ...context3 }) ?? "" }
|
|
21686
21829
|
},
|
|
21687
21830
|
current: { attemptId: options.attemptId, run: async () => {
|
|
21688
21831
|
currentResult = await args2.current();
|
|
@@ -21722,31 +21865,6 @@ async function completeRoutedCompactionSummary(args2) {
|
|
|
21722
21865
|
budget.dispose();
|
|
21723
21866
|
}
|
|
21724
21867
|
}
|
|
21725
|
-
var COMPACTION_RETRY_BACKOFF_MS = 6e4;
|
|
21726
|
-
var COMPACTION_RETRY_BACKOFF_MAX_ENTRIES = 256;
|
|
21727
|
-
var compactionRetryBackoff = /* @__PURE__ */ new Map();
|
|
21728
|
-
var COMPACTION_RETRY_DELAYS_MS = [3e3, 8e3];
|
|
21729
|
-
var compactionRetryDelaysOverride;
|
|
21730
|
-
function compactionRetryDelayMs(retryCount) {
|
|
21731
|
-
const table = compactionRetryDelaysOverride ?? COMPACTION_RETRY_DELAYS_MS;
|
|
21732
|
-
return table[Math.min(retryCount, table.length - 1)];
|
|
21733
|
-
}
|
|
21734
|
-
function isCompactionBackedOff(dialogId, now) {
|
|
21735
|
-
for (const [key, until2] of compactionRetryBackoff) {
|
|
21736
|
-
if (until2 <= now) compactionRetryBackoff.delete(key);
|
|
21737
|
-
}
|
|
21738
|
-
const until = compactionRetryBackoff.get(dialogId);
|
|
21739
|
-
return until !== void 0 && until > now;
|
|
21740
|
-
}
|
|
21741
|
-
function recordCompactionFailure(dialogId, now) {
|
|
21742
|
-
compactionRetryBackoff.delete(dialogId);
|
|
21743
|
-
while (compactionRetryBackoff.size >= COMPACTION_RETRY_BACKOFF_MAX_ENTRIES) {
|
|
21744
|
-
const oldest = compactionRetryBackoff.keys().next().value;
|
|
21745
|
-
if (oldest === void 0) break;
|
|
21746
|
-
compactionRetryBackoff.delete(oldest);
|
|
21747
|
-
}
|
|
21748
|
-
compactionRetryBackoff.set(dialogId, now + COMPACTION_RETRY_BACKOFF_MS);
|
|
21749
|
-
}
|
|
21750
21868
|
async function maybeAutoCompactLocalHistory(args2) {
|
|
21751
21869
|
const { adapter, dialogId, history } = args2;
|
|
21752
21870
|
const emitPhase = (phase) => {
|
|
@@ -21785,10 +21903,11 @@ async function maybeAutoCompactLocalHistory(args2) {
|
|
|
21785
21903
|
});
|
|
21786
21904
|
}
|
|
21787
21905
|
const bridged = toPlanCompressionMessages(history);
|
|
21788
|
-
const
|
|
21789
|
-
const invalidSummary =
|
|
21906
|
+
const active = resolveCompactHistory(bridged, stored ?? {});
|
|
21907
|
+
const invalidSummary = active.invalid;
|
|
21790
21908
|
const invalidStored = stored;
|
|
21791
|
-
|
|
21909
|
+
let invalidationReason = null;
|
|
21910
|
+
if (invalidSummary) {
|
|
21792
21911
|
let reason;
|
|
21793
21912
|
if (invalidStored?.schemaVersion !== void 0 && invalidStored.schemaVersion !== COMPACTION_SUMMARY_SCHEMA_VERSION) {
|
|
21794
21913
|
reason = "schema-version-mismatch";
|
|
@@ -21799,8 +21918,7 @@ async function maybeAutoCompactLocalHistory(args2) {
|
|
|
21799
21918
|
} else {
|
|
21800
21919
|
reason = "hash-mismatch";
|
|
21801
21920
|
}
|
|
21802
|
-
|
|
21803
|
-
const segmentDiff = reason === "hash-mismatch" ? diffSummarySourceSegments(invalidStored?.sourceSegments, currentSegments) : void 0;
|
|
21921
|
+
invalidationReason = reason;
|
|
21804
21922
|
console.warn(
|
|
21805
21923
|
`[localLoop] invalidated dialog summary for ${dialogId} (${reason}); discarding and re-compressing`,
|
|
21806
21924
|
// 诊断分项(**仅加日志,不改任何哈希/校验/重锚语义**):区分「历史真被改写」
|
|
@@ -21813,32 +21931,21 @@ async function maybeAutoCompactLocalHistory(args2) {
|
|
|
21813
21931
|
storedSourceCount: typeof invalidStored?.sourceCount === "number" ? invalidStored.sourceCount : null,
|
|
21814
21932
|
summarizedBeforeId: typeof invalidStored?.summarizedBeforeId === "string" ? invalidStored.summarizedBeforeId : null,
|
|
21815
21933
|
recomputedHashPrefix: hashSummarySourceSlice(history, invalidStored?.summarizedBeforeId)?.slice(0, 8) ?? null,
|
|
21816
|
-
storedHashPrefix: typeof invalidStored?.sourceHash === "string" && invalidStored.sourceHash ? invalidStored.sourceHash.slice(0, 8) : null
|
|
21817
|
-
...segmentDiff ? { segmentDiff } : {}
|
|
21934
|
+
storedHashPrefix: typeof invalidStored?.sourceHash === "string" && invalidStored.sourceHash ? invalidStored.sourceHash.slice(0, 8) : null
|
|
21818
21935
|
}
|
|
21819
21936
|
);
|
|
21820
|
-
logSummarySourceDiagnostics(
|
|
21821
|
-
"invalidated",
|
|
21822
|
-
dialogId,
|
|
21823
|
-
history,
|
|
21824
|
-
invalidStored?.summarizedBeforeId,
|
|
21825
|
-
segmentDiff
|
|
21826
|
-
);
|
|
21827
21937
|
stored = null;
|
|
21828
21938
|
}
|
|
21829
|
-
const
|
|
21830
|
-
const summarizedBeforeId = typeof stored?.summarizedBeforeId === "string" ? stored.summarizedBeforeId : void 0;
|
|
21831
|
-
const legacyAnchorIndex = summarizedBeforeId ? findSummaryAnchorIndex(bridged, summarizedBeforeId) : -1;
|
|
21832
|
-
const planAnchorId = summarizedBeforeId && /^local-(0|[1-9]\d*)$/.test(summarizedBeforeId) && legacyAnchorIndex >= 0 ? bridged[legacyAnchorIndex].id : summarizedBeforeId;
|
|
21939
|
+
const { summary: existingSummary, anchor: summarizedBeforeId } = active;
|
|
21833
21940
|
const contextWindow = typeof args2.contextWindow === "number" && Number.isFinite(args2.contextWindow) && args2.contextWindow > 0 ? args2.contextWindow : getModelContextWindow(args2.model ?? "");
|
|
21834
21941
|
const allMsgs = toPlanCompressionMessages(prepareHistoryForNextTurn(history, args2.contextReferenceResolver));
|
|
21835
21942
|
const maxInputItems = resolveProviderInputItemLimit({ provider: args2.provider, endpoint: args2.providerEndpoint });
|
|
21836
21943
|
const force = args2.force === true || invalidSummary || args2.requestOverBudget?.(
|
|
21837
21944
|
existingSummary ? projectHistoryWithSummary({ history, summary: existingSummary, summarizedBeforeId }) : history
|
|
21838
21945
|
) === true;
|
|
21839
|
-
const
|
|
21946
|
+
const core = prepareCompactHistory({
|
|
21840
21947
|
allMsgs,
|
|
21841
|
-
summarizedBeforeId
|
|
21948
|
+
summarizedBeforeId,
|
|
21842
21949
|
summary: existingSummary,
|
|
21843
21950
|
contextWindow,
|
|
21844
21951
|
// 失败路径补救:预算裁剪即将丢消息时由 localLoop 传入 force,交由 planCompression
|
|
@@ -21849,7 +21956,8 @@ async function maybeAutoCompactLocalHistory(args2) {
|
|
|
21849
21956
|
preserveLatestUserByProjection: true,
|
|
21850
21957
|
maxInputItems,
|
|
21851
21958
|
...args2.realContextUsagePercent !== void 0 ? { realContextUsagePercent: args2.realContextUsagePercent } : {}
|
|
21852
|
-
});
|
|
21959
|
+
}, bridged, (m) => m, contextWindow, canonicalizeToolName);
|
|
21960
|
+
const { plan, request: bounded3 } = core;
|
|
21853
21961
|
const itemDiagnostics = maxInputItems !== void 0 ? {
|
|
21854
21962
|
itemCount: plan.diagnostics?.itemCount,
|
|
21855
21963
|
maxInputItems,
|
|
@@ -21894,35 +22002,7 @@ async function maybeAutoCompactLocalHistory(args2) {
|
|
|
21894
22002
|
}
|
|
21895
22003
|
};
|
|
21896
22004
|
};
|
|
21897
|
-
if (!
|
|
21898
|
-
return projectExisting();
|
|
21899
|
-
}
|
|
21900
|
-
const retryNow = args2.now?.() ?? Date.now();
|
|
21901
|
-
if (isCompactionBackedOff(dialogId, retryNow)) {
|
|
21902
|
-
const projected = projectExisting();
|
|
21903
|
-
const diag = plan.diagnostics;
|
|
21904
|
-
return {
|
|
21905
|
-
...projected,
|
|
21906
|
-
decision: {
|
|
21907
|
-
outcome: "skipped",
|
|
21908
|
-
skipReason: "retry-backoff",
|
|
21909
|
-
...diag ? {
|
|
21910
|
-
...itemDiagnostics,
|
|
21911
|
-
estimatedTokens: diag.totalUsed,
|
|
21912
|
-
historyBudget: diag.historyBudget,
|
|
21913
|
-
triggerRatio: diag.triggerRatio,
|
|
21914
|
-
...diag.realUsageRatio !== void 0 ? { realUsageRatio: diag.realUsageRatio } : {}
|
|
21915
|
-
} : {}
|
|
21916
|
-
}
|
|
21917
|
-
};
|
|
21918
|
-
}
|
|
21919
|
-
const msgsToCompress = plan.msgsToCompress;
|
|
21920
|
-
const bounded3 = buildHistoricalCompactionRequest({
|
|
21921
|
-
msgsToCompress,
|
|
21922
|
-
previousSummary: existingSummary,
|
|
21923
|
-
contextWindow,
|
|
21924
|
-
canonicalizeToolName
|
|
21925
|
-
});
|
|
22005
|
+
if (!bounded3) return projectExisting();
|
|
21926
22006
|
const telemetryTrigger = invalidSummary ? "invalid-summary" : args2.force ? "budget-rescue" : plan.diagnostics?.triggeredByItemLimit ? "item-limit" : plan.diagnostics?.triggeredByRealUsage ? "real-usage" : plan.diagnostics?.triggeredByEstimate ? "estimate" : "unknown";
|
|
21927
22007
|
const telemetryPromptTokens = typeof args2.triggerPromptTokens === "number" && Number.isFinite(args2.triggerPromptTokens) && args2.triggerPromptTokens > 0 ? Math.round(args2.triggerPromptTokens) : null;
|
|
21928
22008
|
const telemetryLogOpts = args2.telemetryLogFile ? { logFile: args2.telemetryLogFile } : void 0;
|
|
@@ -21961,7 +22041,20 @@ async function maybeAutoCompactLocalHistory(args2) {
|
|
|
21961
22041
|
residentReductionTokens: null,
|
|
21962
22042
|
beforeProjectedTokens: null,
|
|
21963
22043
|
afterProjectedTokens: null,
|
|
21964
|
-
finishReason: null
|
|
22044
|
+
finishReason: null,
|
|
22045
|
+
mode: "local-auto",
|
|
22046
|
+
route: null,
|
|
22047
|
+
blockedReason: bounded3.reason,
|
|
22048
|
+
previousSummaryTokens: bounded3.diagnostics?.previousSummaryTokens ?? null,
|
|
22049
|
+
fileOpsCount: bounded3.diagnostics?.fileOpsCount ?? null,
|
|
22050
|
+
invalidationReason,
|
|
22051
|
+
summaryLlmInputTokens: null,
|
|
22052
|
+
summaryLlmOutputTokens: null,
|
|
22053
|
+
qualitySectionsPresent: null,
|
|
22054
|
+
qualitySlotsPresent: null,
|
|
22055
|
+
qualityOriginalGoalPreserved: null,
|
|
22056
|
+
qualityWrittenPathsTotal: null,
|
|
22057
|
+
qualityWrittenPathsCovered: null
|
|
21965
22058
|
},
|
|
21966
22059
|
telemetryLogOpts
|
|
21967
22060
|
);
|
|
@@ -21972,9 +22065,8 @@ async function maybeAutoCompactLocalHistory(args2) {
|
|
|
21972
22065
|
}
|
|
21973
22066
|
emitPhase({ kind: "compaction-start" });
|
|
21974
22067
|
let compactionAttemptId = randomUUID();
|
|
21975
|
-
const maxAttempts =
|
|
22068
|
+
const maxAttempts = 2;
|
|
21976
22069
|
let attempt = 0;
|
|
21977
|
-
let retryCount = 0;
|
|
21978
22070
|
let attemptRoute = "current";
|
|
21979
22071
|
let attemptTimingLogged = false;
|
|
21980
22072
|
let telemetryWritten = false;
|
|
@@ -21993,11 +22085,18 @@ async function maybeAutoCompactLocalHistory(args2) {
|
|
|
21993
22085
|
let summaryDiagnostics = {
|
|
21994
22086
|
maxOutputTokens: bounded3.outputTokenBudget
|
|
21995
22087
|
};
|
|
22088
|
+
const readUsageTokenField = (usage, primary, alias) => {
|
|
22089
|
+
if (!usage) return null;
|
|
22090
|
+
const raw = usage[primary] ?? usage[alias];
|
|
22091
|
+
return typeof raw === "number" && Number.isFinite(raw) && raw >= 0 ? Math.floor(raw) : null;
|
|
22092
|
+
};
|
|
21996
22093
|
const writeCompactionTelemetryOnce = (outcome, fields = {}) => {
|
|
21997
22094
|
if (telemetryWritten) return;
|
|
21998
22095
|
telemetryWritten = true;
|
|
21999
22096
|
const m = fields.metrics;
|
|
22000
22097
|
const isSuccess6 = outcome === "success";
|
|
22098
|
+
const usage = fields.summaryUsage ?? m?.summaryUsage;
|
|
22099
|
+
const q = isSuccess6 ? fields.quality ?? null : null;
|
|
22001
22100
|
appendCompactionTelemetryRecord(
|
|
22002
22101
|
{
|
|
22003
22102
|
schemaVersion: COMPACTION_TELEMETRY_SCHEMA_VERSION,
|
|
@@ -22027,7 +22126,20 @@ async function maybeAutoCompactLocalHistory(args2) {
|
|
|
22027
22126
|
residentReductionTokens: m?.residentReductionTokens ?? null,
|
|
22028
22127
|
beforeProjectedTokens: fields.beforeProjectedTokens ?? null,
|
|
22029
22128
|
afterProjectedTokens: fields.afterProjectedTokens ?? null,
|
|
22030
|
-
finishReason: summaryDiagnostics.finishReason ?? null
|
|
22129
|
+
finishReason: summaryDiagnostics.finishReason ?? null,
|
|
22130
|
+
mode: "local-auto",
|
|
22131
|
+
route: attempt > 0 ? attemptRoute : null,
|
|
22132
|
+
blockedReason: null,
|
|
22133
|
+
previousSummaryTokens: m?.previousSummaryTokens ?? compactionPrevSummaryTokens ?? null,
|
|
22134
|
+
fileOpsCount: fields.fileOpsCount ?? null,
|
|
22135
|
+
invalidationReason,
|
|
22136
|
+
summaryLlmInputTokens: readUsageTokenField(usage, "input_tokens", "prompt_tokens"),
|
|
22137
|
+
summaryLlmOutputTokens: readUsageTokenField(usage, "output_tokens", "completion_tokens") ?? (typeof summaryDiagnostics.completionTokens === "number" ? summaryDiagnostics.completionTokens : null),
|
|
22138
|
+
qualitySectionsPresent: q?.sectionsPresent ?? null,
|
|
22139
|
+
qualitySlotsPresent: q?.requiredSlotsPresent ?? null,
|
|
22140
|
+
qualityOriginalGoalPreserved: q?.originalGoalPreserved ?? null,
|
|
22141
|
+
qualityWrittenPathsTotal: q?.writtenPathsTotal ?? null,
|
|
22142
|
+
qualityWrittenPathsCovered: q?.writtenPathsCovered ?? null
|
|
22031
22143
|
},
|
|
22032
22144
|
telemetryLogOpts
|
|
22033
22145
|
);
|
|
@@ -22089,11 +22201,10 @@ async function maybeAutoCompactLocalHistory(args2) {
|
|
|
22089
22201
|
let timeoutHandle;
|
|
22090
22202
|
let abortListener;
|
|
22091
22203
|
if (args2.abortSignal?.aborted) requestController.abort(args2.abortSignal.reason);
|
|
22092
|
-
let currentOnly = false;
|
|
22093
22204
|
const physicalRequest = async (route, operation) => {
|
|
22094
22205
|
if (attempt >= maxAttempts) throw { code: "SUMMARY_ATTEMPT_LIMIT" };
|
|
22095
22206
|
if (requestController.signal.aborted) throw requestController.signal.reason;
|
|
22096
|
-
attempt
|
|
22207
|
+
const ordinal = ++attempt;
|
|
22097
22208
|
attemptRoute = route;
|
|
22098
22209
|
attemptTimingLogged = false;
|
|
22099
22210
|
compactionAttemptId = randomUUID();
|
|
@@ -22106,6 +22217,7 @@ async function maybeAutoCompactLocalHistory(args2) {
|
|
|
22106
22217
|
return value;
|
|
22107
22218
|
} catch (error) {
|
|
22108
22219
|
reportAttemptUsage2(error);
|
|
22220
|
+
if (ordinal !== attempt) throw error;
|
|
22109
22221
|
const safe = classifySummaryError(error);
|
|
22110
22222
|
summaryDiagnostics = {
|
|
22111
22223
|
...summaryDiagnostics,
|
|
@@ -22121,15 +22233,14 @@ async function maybeAutoCompactLocalHistory(args2) {
|
|
|
22121
22233
|
throw error;
|
|
22122
22234
|
}
|
|
22123
22235
|
};
|
|
22124
|
-
const currentRequest = async () => {
|
|
22125
|
-
currentOnly = true;
|
|
22236
|
+
const currentRequest = async (content, maxOutputTokens) => {
|
|
22126
22237
|
const provider = await args2.resolveProvider();
|
|
22127
22238
|
summaryModel = provider.model ?? args2.model;
|
|
22128
22239
|
summaryProvider = args2.provider;
|
|
22129
22240
|
if (requestController.signal.aborted) throw requestController.signal.reason ?? new DOMException("Summary cancelled", "AbortError");
|
|
22130
22241
|
try {
|
|
22131
22242
|
return await physicalRequest("current", () => provider.complete(
|
|
22132
|
-
[{ role: "system", content: COMPACTION_SUMMARY_SYSTEM_PROMPT }, { role: "user", content
|
|
22243
|
+
[{ role: "system", content: COMPACTION_SUMMARY_SYSTEM_PROMPT }, { role: "user", content }],
|
|
22133
22244
|
{
|
|
22134
22245
|
signal: requestController.signal,
|
|
22135
22246
|
timeoutMs: Math.max(1, requestDeadlineMs - Date.now()),
|
|
@@ -22137,7 +22248,7 @@ async function maybeAutoCompactLocalHistory(args2) {
|
|
|
22137
22248
|
// 服务端 x-request-id 可对上,用于关联请求级证据。不进 prompt/摘要/持久化。
|
|
22138
22249
|
requestId: compactionAttemptId,
|
|
22139
22250
|
// Room for factual handoff, exact commands and file operations.
|
|
22140
|
-
max_tokens:
|
|
22251
|
+
max_tokens: maxOutputTokens,
|
|
22141
22252
|
reasoning_effort: "low"
|
|
22142
22253
|
}
|
|
22143
22254
|
));
|
|
@@ -22150,7 +22261,6 @@ async function maybeAutoCompactLocalHistory(args2) {
|
|
|
22150
22261
|
}
|
|
22151
22262
|
};
|
|
22152
22263
|
const fallback2 = args2.summaryFallback?.preferPlatform ? args2.summaryFallback : void 0;
|
|
22153
|
-
let eligibility;
|
|
22154
22264
|
const routedFallback = fallback2 ? Object.assign(
|
|
22155
22265
|
async (content, options) => {
|
|
22156
22266
|
summaryModel = PLATFORM_HOSTED_DEEPSEEK_FLASH_MODEL;
|
|
@@ -22158,7 +22268,7 @@ async function maybeAutoCompactLocalHistory(args2) {
|
|
|
22158
22268
|
return physicalRequest("platform", () => fallback2(content, { ...options, attemptId: compactionAttemptId }));
|
|
22159
22269
|
},
|
|
22160
22270
|
{
|
|
22161
|
-
preferPlatform: (options) =>
|
|
22271
|
+
preferPlatform: (options) => fallback2.preferPlatform(options),
|
|
22162
22272
|
...fallback2.complete ? { complete: async (content, options) => {
|
|
22163
22273
|
summaryModel = PLATFORM_HOSTED_DEEPSEEK_FLASH_MODEL;
|
|
22164
22274
|
summaryProvider = "nolo";
|
|
@@ -22166,49 +22276,18 @@ async function maybeAutoCompactLocalHistory(args2) {
|
|
|
22166
22276
|
} } : {}
|
|
22167
22277
|
}
|
|
22168
22278
|
) : void 0;
|
|
22169
|
-
const requestOnce = () => routedFallback
|
|
22279
|
+
const requestOnce = (content, maxOutputTokens) => routedFallback ? completeRoutedCompactionSummary({
|
|
22170
22280
|
fallback: routedFallback,
|
|
22171
|
-
content
|
|
22281
|
+
content,
|
|
22172
22282
|
options: {
|
|
22173
22283
|
signal: requestController.signal,
|
|
22174
22284
|
deadlineMs: requestDeadlineMs,
|
|
22175
22285
|
attemptId: compactionAttemptId,
|
|
22176
|
-
maxOutputTokens
|
|
22286
|
+
maxOutputTokens
|
|
22177
22287
|
},
|
|
22178
|
-
current: currentRequest
|
|
22179
|
-
}) : currentRequest();
|
|
22180
|
-
const request3 = (
|
|
22181
|
-
for (; ; ) {
|
|
22182
|
-
try {
|
|
22183
|
-
return await requestOnce();
|
|
22184
|
-
} catch (error) {
|
|
22185
|
-
const safe = classifySummaryError(error);
|
|
22186
|
-
const terminal = isQuotaExhaustedError(safe.status ?? 0, safe.code, safe.errorType) || safe.category === "cancelled" || safe.category === "timeout" || ["PROVIDER_UNAVAILABLE", "SUMMARY_TRUNCATED", "INSUFFICIENT_BALANCE"].includes(safe.code ?? "") || safe.errorType === "insufficient_balance_error";
|
|
22187
|
-
const busy = !terminal && (safe.category === "http" && (safe.status === 503 || safe.status === 429) || /^(capacity|overload(?:ed)?|rate[_-]?limit(?:ed)?)(?:[_-](?:error|exceeded))?$/i.test(safe.errorType ?? "") || ["PLATFORM_LLM_BUSY", "RATE_LIMIT", "CAPACITY", "OVERLOAD", "RESOURCE_EXHAUSTED"].includes(safe.code ?? ""));
|
|
22188
|
-
const delayMs = compactionRetryDelayMs(retryCount);
|
|
22189
|
-
if (!busy || attempt >= maxAttempts || requestController.signal.aborted || requestDeadlineMs - Date.now() < delayMs + 5e3) throw error;
|
|
22190
|
-
primaryElapsedMs = Date.now() - compactionT0;
|
|
22191
|
-
logCompactionTiming("provider-error", {});
|
|
22192
|
-
emitPhase({ kind: "compaction-retry", attempt: attempt + 1, maxAttempts });
|
|
22193
|
-
await new Promise((resolve7, reject) => {
|
|
22194
|
-
const signal = requestController.signal;
|
|
22195
|
-
const cancel = () => {
|
|
22196
|
-
clearTimeout(timer);
|
|
22197
|
-
signal.removeEventListener("abort", cancel);
|
|
22198
|
-
reject(signal.reason);
|
|
22199
|
-
};
|
|
22200
|
-
const timer = setTimeout(() => {
|
|
22201
|
-
signal.removeEventListener("abort", cancel);
|
|
22202
|
-
resolve7();
|
|
22203
|
-
}, delayMs);
|
|
22204
|
-
signal.addEventListener("abort", cancel, { once: true });
|
|
22205
|
-
if (signal.aborted) cancel();
|
|
22206
|
-
});
|
|
22207
|
-
if (requestController.signal.aborted || requestDeadlineMs - Date.now() < 5e3) throw error;
|
|
22208
|
-
retryCount++;
|
|
22209
|
-
}
|
|
22210
|
-
}
|
|
22211
|
-
})().then(
|
|
22288
|
+
current: () => currentRequest(content, maxOutputTokens)
|
|
22289
|
+
}) : currentRequest(content, maxOutputTokens);
|
|
22290
|
+
const request3 = core.summarize(requestOnce).then(
|
|
22212
22291
|
(value) => ({ kind: "done", value }),
|
|
22213
22292
|
(error) => ({ kind: "provider-error", error })
|
|
22214
22293
|
);
|
|
@@ -22259,33 +22338,13 @@ async function maybeAutoCompactLocalHistory(args2) {
|
|
|
22259
22338
|
}
|
|
22260
22339
|
const newSummary = result4?.content?.trim() ?? "";
|
|
22261
22340
|
if (!newSummary) {
|
|
22262
|
-
recordCompactionFailure(dialogId, args2.now?.() ?? Date.now());
|
|
22263
22341
|
logCompactionTiming("empty", { model: result4?.model });
|
|
22264
22342
|
writeCompactionTelemetryOnce("empty", { model: result4?.model });
|
|
22265
22343
|
emitPhase({ kind: "compaction-end" });
|
|
22266
22344
|
return { ...projectExisting(), failureMessage: "Summary empty", failureReason: "provider-error", decision: { outcome: "failed", reason: "provider-error", detail: "Summary empty", ...itemDiagnostics } };
|
|
22267
22345
|
}
|
|
22268
22346
|
const metricsReason = invalidSummary ? "invalid_summary" : "context_budget";
|
|
22269
|
-
const metrics =
|
|
22270
|
-
reason: metricsReason,
|
|
22271
|
-
previousSummary: existingSummary,
|
|
22272
|
-
plan: {
|
|
22273
|
-
msgsToCompress: bounded3.coveredMessages,
|
|
22274
|
-
msgsToKeep: [...msgsToCompress.slice(bounded3.coveredMessages.length), ...plan.msgsToKeep]
|
|
22275
|
-
},
|
|
22276
|
-
newSummary,
|
|
22277
|
-
summaryUsage: result4?.usage,
|
|
22278
|
-
summaryInput: {
|
|
22279
|
-
inputTokens: bounded3.inputTokens,
|
|
22280
|
-
capTokens: bounded3.capTokens,
|
|
22281
|
-
expandedMessages: bounded3.expandedMessages,
|
|
22282
|
-
omittedMessages: bounded3.omittedMessages
|
|
22283
|
-
},
|
|
22284
|
-
planCounts: {
|
|
22285
|
-
pendingMessageCount: plan.diagnostics?.pendingMsgCount,
|
|
22286
|
-
plannedCompressCount: plan.diagnostics?.compressCount
|
|
22287
|
-
}
|
|
22288
|
-
});
|
|
22347
|
+
const metrics = core.metrics(metricsReason, newSummary, result4?.usage);
|
|
22289
22348
|
const projectedHistory = projectHistoryWithSummary({
|
|
22290
22349
|
history,
|
|
22291
22350
|
summary: newSummary,
|
|
@@ -22321,7 +22380,6 @@ async function maybeAutoCompactLocalHistory(args2) {
|
|
|
22321
22380
|
if (projectedTokens >= beforeProjectedTokens || candidateOverBudget) {
|
|
22322
22381
|
const failureMessage = `compaction candidate rejected: ${projectedTokens >= beforeProjectedTokens ? "no token reduction" : "above history budget"} (before=${beforeProjectedTokens}, after=${projectedTokens}, budget=${historyBudget})`;
|
|
22323
22382
|
console.warn(`[localLoop] ${failureMessage}`);
|
|
22324
|
-
recordCompactionFailure(dialogId, args2.now?.() ?? Date.now());
|
|
22325
22383
|
logCompactionTiming("empty", {});
|
|
22326
22384
|
writeCompactionTelemetryOnce("unsafe-projection", {
|
|
22327
22385
|
model: result4?.model ?? args2.model ?? null,
|
|
@@ -22342,15 +22400,7 @@ async function maybeAutoCompactLocalHistory(args2) {
|
|
|
22342
22400
|
}
|
|
22343
22401
|
};
|
|
22344
22402
|
}
|
|
22345
|
-
const
|
|
22346
|
-
const sourceMeta = await computeSummarySourceMetadata(
|
|
22347
|
-
bridgedHistory,
|
|
22348
|
-
bounded3.summarizedBeforeId
|
|
22349
|
-
);
|
|
22350
|
-
const sourceSegments = buildSummarySourceSegments(
|
|
22351
|
-
bridgedHistory,
|
|
22352
|
-
bounded3.summarizedBeforeId
|
|
22353
|
-
);
|
|
22403
|
+
const sourceMeta = core.metadata();
|
|
22354
22404
|
if (Date.now() >= summaryDeadlineMs) throw Object.assign(new Error("Summary deadline exceeded"), { compactionReason: "timeout" });
|
|
22355
22405
|
if (args2.abortSignal?.aborted) {
|
|
22356
22406
|
throw Object.assign(new Error("auto-compaction aborted"), { compactionReason: "aborted" });
|
|
@@ -22364,7 +22414,6 @@ async function maybeAutoCompactLocalHistory(args2) {
|
|
|
22364
22414
|
sourceHash: sourceMeta?.sourceHash,
|
|
22365
22415
|
sourceCount: sourceMeta?.sourceCount ?? 0,
|
|
22366
22416
|
schemaVersion: COMPACTION_SUMMARY_SCHEMA_VERSION,
|
|
22367
|
-
...sourceSegments.length > 0 ? { sourceSegments } : {},
|
|
22368
22417
|
referenceKeys: Array.from(
|
|
22369
22418
|
new Set(
|
|
22370
22419
|
history.slice(0, sourceMeta?.sourceCount ?? 0).flatMap((message) => extractReferenceKeysFromMessage(message))
|
|
@@ -22373,17 +22422,35 @@ async function maybeAutoCompactLocalHistory(args2) {
|
|
|
22373
22422
|
};
|
|
22374
22423
|
await adapter.saveDialogSummary(summarySavePayload);
|
|
22375
22424
|
saveElapsedMs = Date.now() - saveT0;
|
|
22376
|
-
logSummarySourceDiagnostics("saved", dialogId, history, bounded3.summarizedBeforeId);
|
|
22377
22425
|
console.log(formatCompactionMetricsLog(metrics));
|
|
22378
22426
|
logCompactionTiming("success", {
|
|
22379
22427
|
model: result4?.model ?? args2.model ?? null,
|
|
22380
22428
|
outputChars: newSummary.length
|
|
22381
22429
|
});
|
|
22430
|
+
let summaryQuality = null;
|
|
22431
|
+
let coveredFileOpsCount = null;
|
|
22432
|
+
try {
|
|
22433
|
+
const coveredFileOps = [];
|
|
22434
|
+
for (const msg of bounded3.coveredMessages) {
|
|
22435
|
+
if (!Array.isArray(msg.tool_calls)) continue;
|
|
22436
|
+
coveredFileOps.push(...extractFileOperationsFromCalls(msg.tool_calls, canonicalizeToolName));
|
|
22437
|
+
}
|
|
22438
|
+
coveredFileOpsCount = coveredFileOps.length;
|
|
22439
|
+
summaryQuality = inspectCompactionSummaryQuality({
|
|
22440
|
+
newSummary,
|
|
22441
|
+
previousSummary: existingSummary,
|
|
22442
|
+
fileOps: coveredFileOps
|
|
22443
|
+
});
|
|
22444
|
+
} catch {
|
|
22445
|
+
}
|
|
22382
22446
|
writeCompactionTelemetryOnce("success", {
|
|
22383
22447
|
model: result4?.model ?? args2.model ?? null,
|
|
22384
22448
|
metrics,
|
|
22385
22449
|
beforeProjectedTokens,
|
|
22386
|
-
afterProjectedTokens: projectedTokens
|
|
22450
|
+
afterProjectedTokens: projectedTokens,
|
|
22451
|
+
summaryUsage: result4?.usage,
|
|
22452
|
+
fileOpsCount: coveredFileOpsCount,
|
|
22453
|
+
quality: summaryQuality
|
|
22387
22454
|
});
|
|
22388
22455
|
emitPhase({ kind: "compaction-end" });
|
|
22389
22456
|
return {
|
|
@@ -22433,9 +22500,8 @@ async function maybeAutoCompactLocalHistory(args2) {
|
|
|
22433
22500
|
...safe.outputChars === void 0 ? {} : { outputChars: safe.outputChars }
|
|
22434
22501
|
};
|
|
22435
22502
|
logCompactionTiming(failureReason, {});
|
|
22436
|
-
|
|
22437
|
-
|
|
22438
|
-
if (failureReason !== "aborted") recordCompactionFailure(dialogId, failureNow);
|
|
22503
|
+
const telemetryFailureOutcome = safe.code === "SUMMARY_TRUNCATED" ? "truncated" : failureReason;
|
|
22504
|
+
writeCompactionTelemetryOnce(telemetryFailureOutcome, {});
|
|
22439
22505
|
if (failureReason === "aborted") emitPhase({ kind: "compaction-end" });
|
|
22440
22506
|
else emitPhase({ kind: "compaction-failed", reason: failureReason });
|
|
22441
22507
|
return {
|
|
@@ -22461,7 +22527,6 @@ function emitCompactionPhaseEvent(boundary, phase, scope3) {
|
|
|
22461
22527
|
emitLoopEvent(boundary, { kind: "turn-phase", phase: "compacting", atMs, compactionScope: scope3 });
|
|
22462
22528
|
emitLoopEvent(boundary, { kind: "compaction-start", atMs, scope: scope3 });
|
|
22463
22529
|
} else if (phase.kind === "waiting-provider") emitLoopEvent(boundary, { kind: "turn-phase", phase: "waiting-provider", atMs, compactionScope: scope3 });
|
|
22464
|
-
else if (phase.kind === "compaction-retry") emitLoopEvent(boundary, { kind: "compaction-retry", atMs, scope: scope3, attempt: phase.attempt, maxAttempts: phase.maxAttempts });
|
|
22465
22530
|
else if (phase.kind === "compaction-end") emitLoopEvent(boundary, { kind: "compaction-end", atMs, scope: scope3 });
|
|
22466
22531
|
else emitLoopEvent(boundary, { kind: "compaction-failed", atMs, scope: scope3, reason: phase.reason });
|
|
22467
22532
|
}
|
|
@@ -22550,6 +22615,14 @@ function createTurnCompactionController(args2) {
|
|
|
22550
22615
|
onAttemptUsage: args2.onUsage,
|
|
22551
22616
|
onPhase: (phase) => emitPhase(phase, "initial")
|
|
22552
22617
|
});
|
|
22618
|
+
if (compacted.summaryGenerated) {
|
|
22619
|
+
pendingPostCompaction = {
|
|
22620
|
+
dialogId: args2.continueDialogId ?? compactionDialogId,
|
|
22621
|
+
triggerPromptTokens: triggerPromptTokens ?? null,
|
|
22622
|
+
estimatedReductionTokens: compacted.metrics?.residentReductionTokens ?? null,
|
|
22623
|
+
model: args2.model ?? null
|
|
22624
|
+
};
|
|
22625
|
+
}
|
|
22553
22626
|
args2.onSelectedSummary?.(compacted.selectedSummary ?? { outcome: "absent" });
|
|
22554
22627
|
emitObservation(compacted);
|
|
22555
22628
|
return { history: compacted.history, usage: compacted.usage };
|
|
@@ -22564,6 +22637,37 @@ function createTurnCompactionController(args2) {
|
|
|
22564
22637
|
return { history: result4.history, applied: result4.history !== history, usage: result4.usage };
|
|
22565
22638
|
};
|
|
22566
22639
|
let lastCompactionOutcome;
|
|
22640
|
+
let pendingPostCompaction = null;
|
|
22641
|
+
const recordPostCompactionUsage = (usage, model) => {
|
|
22642
|
+
if (!pendingPostCompaction || !usage || typeof usage !== "object") return;
|
|
22643
|
+
const pending = pendingPostCompaction;
|
|
22644
|
+
pendingPostCompaction = null;
|
|
22645
|
+
const rawInput = usage.input_tokens ?? usage.prompt_tokens;
|
|
22646
|
+
const nextPromptTokens = typeof rawInput === "number" && Number.isFinite(rawInput) && rawInput > 0 ? Math.floor(rawInput) : null;
|
|
22647
|
+
if (nextPromptTokens === null) return;
|
|
22648
|
+
const rawCacheRead = readCacheReadInputTokens(usage);
|
|
22649
|
+
const nextCacheReadTokens = typeof rawCacheRead === "number" && Number.isFinite(rawCacheRead) && rawCacheRead >= 0 ? Math.floor(rawCacheRead) : null;
|
|
22650
|
+
const nextCacheReadRatio = nextCacheReadTokens !== null ? Number((nextCacheReadTokens / nextPromptTokens).toFixed(4)) : null;
|
|
22651
|
+
const actualTokenDrop = pending.triggerPromptTokens !== null ? pending.triggerPromptTokens - nextPromptTokens : null;
|
|
22652
|
+
const dropErrorRatio = actualTokenDrop !== null && pending.estimatedReductionTokens !== null && pending.triggerPromptTokens !== null && pending.triggerPromptTokens > 0 ? Number((Math.abs(actualTokenDrop - pending.estimatedReductionTokens) / pending.triggerPromptTokens).toFixed(4)) : null;
|
|
22653
|
+
appendPostCompactionTurnRecord(
|
|
22654
|
+
{
|
|
22655
|
+
schemaVersion: COMPACTION_TELEMETRY_SCHEMA_VERSION,
|
|
22656
|
+
kind: "post-compaction",
|
|
22657
|
+
ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
22658
|
+
dialogId: pending.dialogId,
|
|
22659
|
+
model: model ?? pending.model ?? null,
|
|
22660
|
+
triggerPromptTokens: pending.triggerPromptTokens,
|
|
22661
|
+
nextPromptTokens,
|
|
22662
|
+
nextCacheReadTokens,
|
|
22663
|
+
nextCacheReadRatio,
|
|
22664
|
+
actualTokenDrop,
|
|
22665
|
+
estimatedReductionTokens: pending.estimatedReductionTokens,
|
|
22666
|
+
dropErrorRatio
|
|
22667
|
+
},
|
|
22668
|
+
args2.telemetryLogFile ? { logFile: args2.telemetryLogFile } : void 0
|
|
22669
|
+
);
|
|
22670
|
+
};
|
|
22567
22671
|
const prepareRequest = async (requestOverBudget, initial = false, availableHistoryTokens, force = false) => {
|
|
22568
22672
|
lastCompactionOutcome = void 0;
|
|
22569
22673
|
const contextUsage = args2.getContextUsage();
|
|
@@ -22607,6 +22711,14 @@ function createTurnCompactionController(args2) {
|
|
|
22607
22711
|
onPhase: (phase) => emitPhase(phase, initial ? "initial" : "in-loop")
|
|
22608
22712
|
});
|
|
22609
22713
|
lastCompactionOutcome = { result: compacted };
|
|
22714
|
+
if (compacted.summaryGenerated) {
|
|
22715
|
+
pendingPostCompaction = {
|
|
22716
|
+
dialogId: compactionDialogId,
|
|
22717
|
+
triggerPromptTokens: inputTokens > 0 ? inputTokens : null,
|
|
22718
|
+
estimatedReductionTokens: compacted.metrics?.residentReductionTokens ?? null,
|
|
22719
|
+
model: args2.model ?? null
|
|
22720
|
+
};
|
|
22721
|
+
}
|
|
22610
22722
|
if (compacted.compressed) {
|
|
22611
22723
|
const rebuilt = composeProviderMessages({
|
|
22612
22724
|
prefix: args2.getWorkingPrefix(),
|
|
@@ -22634,7 +22746,7 @@ function createTurnCompactionController(args2) {
|
|
|
22634
22746
|
};
|
|
22635
22747
|
return { getLastCompactionOutcome: () => lastCompactionOutcome, runInitial, maybeCompactInLoop: async () => {
|
|
22636
22748
|
await prepareRequest();
|
|
22637
|
-
}, forceCompact, prepareRequest };
|
|
22749
|
+
}, forceCompact, prepareRequest, recordPostCompactionUsage };
|
|
22638
22750
|
}
|
|
22639
22751
|
|
|
22640
22752
|
// packages/agent-runtime/providerCallTelemetry.ts
|
|
@@ -22750,13 +22862,6 @@ function buildRequestTelemetry(args2) {
|
|
|
22750
22862
|
return void 0;
|
|
22751
22863
|
}
|
|
22752
22864
|
}
|
|
22753
|
-
function hashToolDefinitions(tools) {
|
|
22754
|
-
try {
|
|
22755
|
-
return shortHash(JSON.stringify(tools));
|
|
22756
|
-
} catch {
|
|
22757
|
-
return void 0;
|
|
22758
|
-
}
|
|
22759
|
-
}
|
|
22760
22865
|
|
|
22761
22866
|
// packages/agent-runtime/localLoop.ts
|
|
22762
22867
|
var LocalContextCoverageError = class extends Error {
|
|
@@ -22816,6 +22921,31 @@ var CONCURRENT_READONLY_TOOLS = /* @__PURE__ */ new Set([
|
|
|
22816
22921
|
"fetchWebpage",
|
|
22817
22922
|
"exa_search"
|
|
22818
22923
|
]);
|
|
22924
|
+
function classifyOffloadExploration(name, raw, workspaceRoot) {
|
|
22925
|
+
if (name === "searchFiles" || name === "globFiles") return "explore";
|
|
22926
|
+
if (name === "readPastedText") return "neutral";
|
|
22927
|
+
if (name === "readFile" || name === "read_file" || name === "readWorkspaceFile" || name === "controlAgentRun") {
|
|
22928
|
+
let args2;
|
|
22929
|
+
try {
|
|
22930
|
+
args2 = asRecordOrEmpty(JSON.parse(raw || "{}"));
|
|
22931
|
+
} catch {
|
|
22932
|
+
args2 = {};
|
|
22933
|
+
}
|
|
22934
|
+
if (name === "controlAgentRun") {
|
|
22935
|
+
return args2.action === "status" || args2.action === "list" ? "neutral" : "reset";
|
|
22936
|
+
}
|
|
22937
|
+
const singlePath = PATH_FIELD_ALIASES.map((key) => args2[key]).find((value) => typeof value === "string" && value.length > 0);
|
|
22938
|
+
const paths = Array.isArray(args2.files) && singlePath === void 0 ? args2.files.map((file) => asRecordOrEmpty(file).path) : [singlePath];
|
|
22939
|
+
const base = workspaceRoot?.trim() || process.cwd();
|
|
22940
|
+
const allReferenceMaterial = paths.length > 0 && paths.every((path) => {
|
|
22941
|
+
if (typeof path !== "string" || !path.trim()) return false;
|
|
22942
|
+
const target = relative6(base, resolvePath(base, path.trim())).split(sep4).join("/");
|
|
22943
|
+
return target.endsWith(".result.md") || target.endsWith("/AGENTS.md") || target === "AGENTS.md" || target.endsWith(".md") && (target.startsWith(".agents/skills/") || target.startsWith("docs/"));
|
|
22944
|
+
});
|
|
22945
|
+
return allReferenceMaterial ? "neutral" : "explore";
|
|
22946
|
+
}
|
|
22947
|
+
return CONCURRENT_READONLY_TOOLS.has(name) ? "neutral" : "reset";
|
|
22948
|
+
}
|
|
22819
22949
|
function partitionToolCallsIntoBatches(toolCalls) {
|
|
22820
22950
|
const batches = [];
|
|
22821
22951
|
let currentBatch = [];
|
|
@@ -23182,6 +23312,21 @@ async function runLocalAgentTurn(input) {
|
|
|
23182
23312
|
input.contextBlocks,
|
|
23183
23313
|
input.contextBlockScopes
|
|
23184
23314
|
);
|
|
23315
|
+
if (input.recallFreshWorkContext && input.adapter.host === "cli" && input.freshDialog && !input.userMessages?.length) {
|
|
23316
|
+
const id = dialogTurnUserMessageId(input.runtimeContext?.turnId, 0);
|
|
23317
|
+
const [message] = applyPersistedTurnInput(
|
|
23318
|
+
[{ role: "user", id, content: sanitizedInput }],
|
|
23319
|
+
sanitizedPersistedInput,
|
|
23320
|
+
input.persistedInputReference
|
|
23321
|
+
);
|
|
23322
|
+
throwIfAborted(input);
|
|
23323
|
+
const recalled = await input.recallFreshWorkContext(message);
|
|
23324
|
+
throwIfAborted(input);
|
|
23325
|
+
if (recalled) {
|
|
23326
|
+
sanitizedPersistedInput ??= sanitizedInput;
|
|
23327
|
+
if (recalled.block) callerScopes.push({ content: recalled.block, cacheScope: "turn" });
|
|
23328
|
+
}
|
|
23329
|
+
}
|
|
23185
23330
|
const callerHasMemoryGuidance = callerScopes.some(
|
|
23186
23331
|
(scope3) => scope3.content.includes(MEMORY_USE_GUIDANCE)
|
|
23187
23332
|
);
|
|
@@ -23365,6 +23510,7 @@ async function runLocalAgentTurn(input) {
|
|
|
23365
23510
|
};
|
|
23366
23511
|
const userInputText = extractUserInputText(input.input);
|
|
23367
23512
|
let toolCallCount = 0;
|
|
23513
|
+
let toolDiscoveryCallCount = 0;
|
|
23368
23514
|
let requestCalibrationRatio = 1;
|
|
23369
23515
|
let result4 = { content: "" };
|
|
23370
23516
|
let stopReason;
|
|
@@ -23496,17 +23642,18 @@ async function runLocalAgentTurn(input) {
|
|
|
23496
23642
|
};
|
|
23497
23643
|
const trackRoundOffloadSignals = (roundToolCalls, roundResults) => {
|
|
23498
23644
|
if (!offloadNudgeEnabled || roundToolCalls.length === 0) return;
|
|
23499
|
-
let
|
|
23645
|
+
let explorationRound = false;
|
|
23646
|
+
let resetExploration = false;
|
|
23500
23647
|
roundToolCalls.forEach((call, index) => {
|
|
23501
23648
|
const name = normalizeLocalToolName(call.function.name);
|
|
23502
23649
|
if (name === "startAgentRun") {
|
|
23503
23650
|
hasDispatchedSubagent = true;
|
|
23504
|
-
|
|
23651
|
+
resetExploration = true;
|
|
23505
23652
|
return;
|
|
23506
23653
|
}
|
|
23507
|
-
|
|
23508
|
-
|
|
23509
|
-
|
|
23654
|
+
const exploration = classifyOffloadExploration(name, call.function.arguments, input.adapter.workspaceRoot);
|
|
23655
|
+
if (exploration === "explore") explorationRound = true;
|
|
23656
|
+
if (exploration === "reset") resetExploration = true;
|
|
23510
23657
|
if (OFFLOAD_WRITE_TOOLS.has(name)) {
|
|
23511
23658
|
const toolResult = roundResults[index];
|
|
23512
23659
|
const failed = !toolResult || toolResult.metadata?.blocked === true || Boolean(toolResult.metadata?.error) || isToolExecutionFailure(toolResult);
|
|
@@ -23516,7 +23663,8 @@ async function runLocalAgentTurn(input) {
|
|
|
23516
23663
|
}
|
|
23517
23664
|
}
|
|
23518
23665
|
});
|
|
23519
|
-
|
|
23666
|
+
if (resetExploration) consecutiveReadOnlyRounds = 0;
|
|
23667
|
+
else if (explorationRound) consecutiveReadOnlyRounds++;
|
|
23520
23668
|
};
|
|
23521
23669
|
while (true) {
|
|
23522
23670
|
partialContent = "";
|
|
@@ -23525,22 +23673,26 @@ async function runLocalAgentTurn(input) {
|
|
|
23525
23673
|
await applyPendingInjections();
|
|
23526
23674
|
if (roundWarningThreshold > 0 && round >= roundWarningThreshold && !roundBudgetWarningInjected) {
|
|
23527
23675
|
const prompt = buildRoundBudgetWarningPrompt(roundWarningThreshold);
|
|
23528
|
-
transcript.push({ role: "user", content: prompt });
|
|
23676
|
+
transcript.push({ role: "user", content: prompt, internalNotice: true });
|
|
23529
23677
|
roundBudgetWarningInjected = true;
|
|
23530
23678
|
}
|
|
23531
23679
|
if (offloadNudgeEnabled && !offloadNudgeInjected && !hasDispatchedSubagent) {
|
|
23532
23680
|
const reason = consecutiveReadOnlyRounds >= DEFAULT_OFFLOAD_EXPLORE_ROUNDS ? "explore" : writtenPaths.size >= DEFAULT_OFFLOAD_WRITE_FILES ? "write" : null;
|
|
23533
23681
|
if (reason) {
|
|
23534
|
-
transcript.push({ role: "user", content: buildOffloadNudgePrompt(reason) });
|
|
23682
|
+
transcript.push({ role: "user", content: buildOffloadNudgePrompt(reason), internalNotice: true });
|
|
23535
23683
|
offloadNudgeInjected = true;
|
|
23536
23684
|
}
|
|
23537
23685
|
}
|
|
23686
|
+
const admissionProvider = await resolveProviderOnce();
|
|
23538
23687
|
const projectRequest = (source) => {
|
|
23688
|
+
source = filterToolDiscoveryHistory(source, admissionProvider.retainToolDiscoveryHistory);
|
|
23689
|
+
if (!admissionProvider.retainToolDiscoveryHistory && source.some((message) => message.compactedToolLoading)) {
|
|
23690
|
+
source = source.map(({ compactedToolLoading: _internal, ...message }) => message);
|
|
23691
|
+
}
|
|
23539
23692
|
const prepared = prepareMessagesForProviderCall(source);
|
|
23540
23693
|
const base = filterImagePartsFromMessages(prepared.messages, supportsImages);
|
|
23541
23694
|
return emptyAssistantRepairPending ? [...base, { role: "user", content: EMPTY_ASSISTANT_REPAIR_PROMPT }] : base;
|
|
23542
23695
|
};
|
|
23543
|
-
const admissionProvider = await resolveProviderOnce();
|
|
23544
23696
|
throwIfAborted(input);
|
|
23545
23697
|
const requestOverBudget = (messages2) => !evaluateLocalRequestBudget({
|
|
23546
23698
|
messages: messages2,
|
|
@@ -23776,6 +23928,7 @@ async function runLocalAgentTurn(input) {
|
|
|
23776
23928
|
}
|
|
23777
23929
|
}
|
|
23778
23930
|
if (providerInvoked) usageLedger.recordProviderCall({
|
|
23931
|
+
...error && typeof error === "object" && "usage" in error && error.usage && typeof error.usage === "object" ? { usage: error.usage } : {},
|
|
23779
23932
|
model: agentConfig.model,
|
|
23780
23933
|
telemetry: {
|
|
23781
23934
|
...requestTelemetry,
|
|
@@ -23828,6 +23981,7 @@ async function runLocalAgentTurn(input) {
|
|
|
23828
23981
|
provider: result4.provider,
|
|
23829
23982
|
telemetry: { ...finalizeCallTelemetry(requestTelemetry, result4, round, callStartedAt), requestState: "completed" }
|
|
23830
23983
|
});
|
|
23984
|
+
compaction.recordPostCompactionUsage(result4.usage, result4.model ?? agentConfig.model);
|
|
23831
23985
|
if (!result4.content && result4.output?.some((block) => block.type === "text") && !result4.output.some((block) => block.type === "toolCall")) {
|
|
23832
23986
|
result4 = {
|
|
23833
23987
|
...result4,
|
|
@@ -23860,6 +24014,23 @@ async function runLocalAgentTurn(input) {
|
|
|
23860
24014
|
break;
|
|
23861
24015
|
}
|
|
23862
24016
|
const toolCalls = result4.tool_calls ?? [];
|
|
24017
|
+
const discoveryResults = new Map(result4.toolDiscoveryResults?.map(({ callId, content }) => [callId, content]));
|
|
24018
|
+
if (toolCalls.some((call) => isToolDiscoveryCall(call) && !discoveryResults.has(call.id))) {
|
|
24019
|
+
throw new Error("The provider returned an unresolved tool discovery request.");
|
|
24020
|
+
}
|
|
24021
|
+
const completedDiscovery = result4.completedToolDiscovery ?? [];
|
|
24022
|
+
toolDiscoveryCallCount += discoveryResults.size + completedDiscovery.length;
|
|
24023
|
+
if (toolDiscoveryCallCount > 8) throw new Error("The turn exceeded the tool discovery limit (8).");
|
|
24024
|
+
if (completedDiscovery.length) {
|
|
24025
|
+
transcript.push({
|
|
24026
|
+
role: "assistant",
|
|
24027
|
+
content: null,
|
|
24028
|
+
tool_calls: completedDiscovery.map(({ call }) => call)
|
|
24029
|
+
});
|
|
24030
|
+
for (const { call, content } of completedDiscovery) {
|
|
24031
|
+
transcript.pushTool({ role: "tool", tool_call_id: call.id, toolName: call.function.name, content });
|
|
24032
|
+
}
|
|
24033
|
+
}
|
|
23863
24034
|
const rawToolCallsCount = (result4.tool_calls?.length ?? 0) || (Array.isArray(result4.raw_tool_calls) ? result4.raw_tool_calls.length : 0);
|
|
23864
24035
|
loopTiming.mark("postLlmProcessing", round);
|
|
23865
24036
|
if (toolCalls.length === 0 && rawToolCallsCount === 0) {
|
|
@@ -23967,12 +24138,18 @@ ${reasoningTailLog}
|
|
|
23967
24138
|
const slotResults = new Array(toolCalls.length);
|
|
23968
24139
|
const runSingleTool = async ({ index, toolCall }, executionInput = input, isClosed = () => false) => {
|
|
23969
24140
|
throwIfAborted(executionInput);
|
|
24141
|
+
const discoveryResult = isToolDiscoveryCall(toolCall) ? discoveryResults.get(toolCall.id) : void 0;
|
|
24142
|
+
if (discoveryResult !== void 0) {
|
|
24143
|
+
slotResults[index] = { toolName: toolCall.function.name, toolResult: { content: discoveryResult } };
|
|
24144
|
+
return;
|
|
24145
|
+
}
|
|
23970
24146
|
const { toolResult, toolExecMs } = await executeToolCall({
|
|
23971
24147
|
input: executionInput,
|
|
23972
24148
|
toolCall,
|
|
23973
24149
|
...prepareDirectWorkMemorySource ? { getDirectWorkSource } : {},
|
|
23974
24150
|
round,
|
|
23975
24151
|
boundary: observationBoundary,
|
|
24152
|
+
shouldReportToolError: (name, code) => progressGuard.shouldReportToolError(name, code),
|
|
23976
24153
|
loopTiming,
|
|
23977
24154
|
userInputText,
|
|
23978
24155
|
runToolNames: agentConfig.runScopedToolSurface?.finalToolNames,
|
|
@@ -24003,7 +24180,7 @@ ${reasoningTailLog}
|
|
|
24003
24180
|
loopTiming.mark("toolResultFormat", round);
|
|
24004
24181
|
transcript.pushTool({
|
|
24005
24182
|
role: "tool",
|
|
24006
|
-
content: formatToolMessageContent({
|
|
24183
|
+
content: isToolDiscoveryCall(toolCall) ? toolResult.content ?? "" : formatToolMessageContent({
|
|
24007
24184
|
toolName,
|
|
24008
24185
|
content: toolResult.content,
|
|
24009
24186
|
metadata: observedMetadata,
|
|
@@ -24108,7 +24285,8 @@ ${reasoningTailLog}
|
|
|
24108
24285
|
if (softBudgetAdvisory) {
|
|
24109
24286
|
transcript.push({
|
|
24110
24287
|
role: "user",
|
|
24111
|
-
content: softBudgetAdvisory.message
|
|
24288
|
+
content: softBudgetAdvisory.message,
|
|
24289
|
+
internalNotice: true
|
|
24112
24290
|
});
|
|
24113
24291
|
}
|
|
24114
24292
|
}
|
|
@@ -24224,8 +24402,26 @@ ${reasoningTailLog}
|
|
|
24224
24402
|
}
|
|
24225
24403
|
}
|
|
24226
24404
|
|
|
24405
|
+
// packages/agent-runtime/sseDataLine.ts
|
|
24406
|
+
function parseSseDataLineJson(line) {
|
|
24407
|
+
const trimmed = line.trim();
|
|
24408
|
+
if (!trimmed.startsWith("data:")) return null;
|
|
24409
|
+
const payload = trimmed.slice(5).trim();
|
|
24410
|
+
if (!payload || payload === "[DONE]") return null;
|
|
24411
|
+
try {
|
|
24412
|
+
return JSON.parse(payload);
|
|
24413
|
+
} catch {
|
|
24414
|
+
return null;
|
|
24415
|
+
}
|
|
24416
|
+
}
|
|
24417
|
+
function parseSseDataLineObject(line) {
|
|
24418
|
+
const parsed = parseSseDataLineJson(line);
|
|
24419
|
+
return parsed && typeof parsed === "object" ? parsed : null;
|
|
24420
|
+
}
|
|
24421
|
+
|
|
24227
24422
|
// packages/integrations/openai/responsesRequestBody.ts
|
|
24228
24423
|
function buildResponsesRequestBody(body, model, options) {
|
|
24424
|
+
if (!options?.retainToolDiscovery) body = projectStaticToolDiscoveryBody(body);
|
|
24229
24425
|
const tools = Array.isArray(body.tools) ? toResponsesTools(body.tools) : void 0;
|
|
24230
24426
|
const reasoningEffort = body.reasoning && typeof body.reasoning === "object" ? void 0 : typeof body.reasoning_effort === "string" && body.reasoning_effort.trim() ? body.reasoning_effort : void 0;
|
|
24231
24427
|
return {
|
|
@@ -24513,6 +24709,8 @@ function createResponsesStreamCollector(callbacks) {
|
|
|
24513
24709
|
const textSanitizer = createResponsesProtocolLeakSanitizer(callbacks?.onTextDelta);
|
|
24514
24710
|
let sawNonEmptyOutputTextDelta = false;
|
|
24515
24711
|
const toolCallsAcc = createResponsesToolAccumulator();
|
|
24712
|
+
const searchItems = /* @__PURE__ */ new Set();
|
|
24713
|
+
let sawDiscoveryItem = false;
|
|
24516
24714
|
let usage;
|
|
24517
24715
|
let failure;
|
|
24518
24716
|
let completedResponse;
|
|
@@ -24574,6 +24772,12 @@ function createResponsesStreamCollector(callbacks) {
|
|
|
24574
24772
|
}
|
|
24575
24773
|
if (type === "response.output_item.added" || type === "response.output_item.done") {
|
|
24576
24774
|
const item = ev.item;
|
|
24775
|
+
if (item?.type === "tool_search_call" && item.execution === "client") {
|
|
24776
|
+
sawDiscoveryItem = true;
|
|
24777
|
+
if (typeof item.call_id === "string" && item.call_id) searchItems.add(item.call_id);
|
|
24778
|
+
if (type === "response.output_item.done") observeMeaningfulOnce();
|
|
24779
|
+
return;
|
|
24780
|
+
}
|
|
24577
24781
|
if (item?.type === "message" && !sawNonEmptyOutputTextDelta) {
|
|
24578
24782
|
const itemText = extractOutputTextFromItem(item);
|
|
24579
24783
|
if (itemText) {
|
|
@@ -24623,8 +24827,17 @@ function createResponsesStreamCollector(callbacks) {
|
|
|
24623
24827
|
const finalize2 = () => {
|
|
24624
24828
|
let finalToolCalls = finalizeResponsesToolCalls(toolCallsAcc);
|
|
24625
24829
|
if (completedResponse) {
|
|
24626
|
-
|
|
24627
|
-
|
|
24830
|
+
let completedToolCalls = [];
|
|
24831
|
+
try {
|
|
24832
|
+
completedToolCalls = extractToolCallsFromResponseOutput(completedResponse, { strictSnapshot: authoritativeCompletedTools });
|
|
24833
|
+
} catch {
|
|
24834
|
+
failure ??= {
|
|
24835
|
+
code: "tool_discovery_history_incomplete",
|
|
24836
|
+
message: "Responses returned an invalid tool call in its completed snapshot."
|
|
24837
|
+
};
|
|
24838
|
+
finalToolCalls = [];
|
|
24839
|
+
}
|
|
24840
|
+
if (authoritativeCompletedTools || completedToolCalls.some(isToolDiscoveryCall)) {
|
|
24628
24841
|
for (const call of completedToolCalls) {
|
|
24629
24842
|
const name = call.function?.name;
|
|
24630
24843
|
if (typeof name !== "string" || !name.trim()) {
|
|
@@ -24674,6 +24887,17 @@ function createResponsesStreamCollector(callbacks) {
|
|
|
24674
24887
|
if (finalToolCalls.length === 0) finalToolCalls = completedToolCalls;
|
|
24675
24888
|
}
|
|
24676
24889
|
}
|
|
24890
|
+
const completedSearches = finalToolCalls.filter(isToolDiscoveryCall);
|
|
24891
|
+
if (completedSearches.length || sawDiscoveryItem) {
|
|
24892
|
+
const completedIds = new Set(completedSearches.map((call) => call.id));
|
|
24893
|
+
if (completedIds.size !== completedSearches.length || sawDiscoveryItem && (completedIds.size === 0 || [...searchItems].some((id) => !completedIds.has(TOOL_DISCOVERY_ID_PREFIX + id)))) {
|
|
24894
|
+
failure ??= {
|
|
24895
|
+
code: "tool_discovery_history_incomplete",
|
|
24896
|
+
message: "Responses ended without a completed snapshot for tool discovery."
|
|
24897
|
+
};
|
|
24898
|
+
}
|
|
24899
|
+
if (failure) finalToolCalls = [];
|
|
24900
|
+
}
|
|
24677
24901
|
if (authoritativeCompletedTools && failure) {
|
|
24678
24902
|
finalToolCalls = [];
|
|
24679
24903
|
}
|
|
@@ -24691,7 +24915,7 @@ function createResponsesStreamCollector(callbacks) {
|
|
|
24691
24915
|
if (!reasoning && completedResponse) {
|
|
24692
24916
|
reasoning = extractReasoningFromResponseOutput(completedResponse);
|
|
24693
24917
|
}
|
|
24694
|
-
const streamComplete = sawTerminalSuccess;
|
|
24918
|
+
const streamComplete = sawTerminalSuccess && !failure;
|
|
24695
24919
|
const streamTruncated = !sawTerminalEvent;
|
|
24696
24920
|
return {
|
|
24697
24921
|
content,
|
|
@@ -24740,7 +24964,7 @@ async function readResponsesSseCompletion(args2) {
|
|
|
24740
24964
|
...args2.requireResponseCompleted === true ? { requireResponseCompleted: true } : {},
|
|
24741
24965
|
...args2.authoritativeCompletedTools === true ? { authoritativeCompletedTools: true } : {}
|
|
24742
24966
|
});
|
|
24743
|
-
for await (const frame of readSseFrames(args2.response)) {
|
|
24967
|
+
for await (const frame of readSseFrames(args2.response, args2.signal)) {
|
|
24744
24968
|
for (const line of frame.split("\n")) {
|
|
24745
24969
|
const trimmedLine = line.trim();
|
|
24746
24970
|
if (trimmedLine === "[DONE]" || trimmedLine === "data: [DONE]") {
|
|
@@ -24774,6 +24998,17 @@ function resolveOpenAiCompatibleWire(config) {
|
|
|
24774
24998
|
if (config.wire) return config.wire;
|
|
24775
24999
|
return isOpenAiResponsesEndpoint(config.endpoint) ? "responses" : "chat.completions";
|
|
24776
25000
|
}
|
|
25001
|
+
function resolveResponsesDiscoveryProtocol(config) {
|
|
25002
|
+
const protocol = resolveNativeToolDiscoveryProtocol({
|
|
25003
|
+
...config,
|
|
25004
|
+
optInFlag: config.enableToolDiscovery,
|
|
25005
|
+
apiFormat: resolveOpenAiCompatibleWire(config)
|
|
25006
|
+
});
|
|
25007
|
+
return protocol === "anthropic-hosted" ? void 0 : protocol;
|
|
25008
|
+
}
|
|
25009
|
+
function usesNativeToolDiscovery(config) {
|
|
25010
|
+
return !!resolveResponsesDiscoveryProtocol(config);
|
|
25011
|
+
}
|
|
24777
25012
|
var PROMPT_CACHE_KEY_PROVIDERS = /* @__PURE__ */ new Set([
|
|
24778
25013
|
"opendesign",
|
|
24779
25014
|
"opencode",
|
|
@@ -24795,11 +25030,13 @@ function shouldInjectDirectPromptCacheKey(provider, endpoint) {
|
|
|
24795
25030
|
}
|
|
24796
25031
|
function buildOpenAiCompatibleChatCompletionRequest(args2) {
|
|
24797
25032
|
const isResponses = resolveOpenAiCompatibleWire(args2.providerConfig) === "responses";
|
|
24798
|
-
const
|
|
25033
|
+
const discoveryProtocol = resolveResponsesDiscoveryProtocol(args2.providerConfig);
|
|
25034
|
+
const retainToolDiscovery = !!discoveryProtocol && hasDeferrableResponsesTools(args2.tools);
|
|
25035
|
+
const shouldStripReasoning = !retainToolDiscovery && shouldStripReasoningContentForOutbound(
|
|
24799
25036
|
args2.providerConfig.provider,
|
|
24800
25037
|
args2.providerConfig.model
|
|
24801
25038
|
);
|
|
24802
|
-
const sanitizedMessages = sanitizeForOutbound(args2.messages, args2.tools);
|
|
25039
|
+
const sanitizedMessages = sanitizeForOutbound(args2.messages, args2.tools, { retainToolDiscovery });
|
|
24803
25040
|
const toolImagePolicy = resolveToolImagePolicy({
|
|
24804
25041
|
routeKind: isResponses ? "responses" : "openai-compatible",
|
|
24805
25042
|
legacySupportsToolImages: isResponses ? false : void 0,
|
|
@@ -24848,13 +25085,26 @@ function buildOpenAiCompatibleChatCompletionRequest(args2) {
|
|
|
24848
25085
|
} : {}
|
|
24849
25086
|
};
|
|
24850
25087
|
const body = isResponses ? buildResponsesRequestBody(rawBody, args2.providerConfig.model, {
|
|
24851
|
-
...toolImagePolicy
|
|
25088
|
+
...toolImagePolicy,
|
|
25089
|
+
retainToolDiscovery
|
|
24852
25090
|
}) : normalizeChatCompletionsBodyForProvider({
|
|
24853
25091
|
body: rawBody,
|
|
24854
25092
|
provider: args2.providerConfig.provider,
|
|
24855
25093
|
model: args2.providerConfig.model,
|
|
24856
25094
|
endpoint: args2.providerConfig.endpoint
|
|
24857
25095
|
});
|
|
25096
|
+
const toolDiscovery = retainToolDiscovery ? prepareResponsesToolDiscovery(
|
|
25097
|
+
body,
|
|
25098
|
+
args2.messages.find((message) => message.compactedToolLoading)?.compactedToolLoading,
|
|
25099
|
+
args2.mcpDiscoveryTools,
|
|
25100
|
+
discoveryProtocol
|
|
25101
|
+
) : void 0;
|
|
25102
|
+
if (retainToolDiscovery && !toolDiscovery) {
|
|
25103
|
+
return buildOpenAiCompatibleChatCompletionRequest({
|
|
25104
|
+
...args2,
|
|
25105
|
+
providerConfig: { ...args2.providerConfig, enableToolDiscovery: false }
|
|
25106
|
+
});
|
|
25107
|
+
}
|
|
24858
25108
|
if (args2.requestFacts) {
|
|
24859
25109
|
applyShapingCounts(args2.requestFacts, args2.shapingCounts);
|
|
24860
25110
|
writeThinkingFacts(args2.requestFacts, body);
|
|
@@ -24871,6 +25121,7 @@ function buildOpenAiCompatibleChatCompletionRequest(args2) {
|
|
|
24871
25121
|
};
|
|
24872
25122
|
return {
|
|
24873
25123
|
url: endpoint,
|
|
25124
|
+
...toolDiscovery ? { toolDiscovery } : {},
|
|
24874
25125
|
init: {
|
|
24875
25126
|
method: "POST",
|
|
24876
25127
|
headers,
|
|
@@ -24881,7 +25132,7 @@ function buildOpenAiCompatibleChatCompletionRequest(args2) {
|
|
|
24881
25132
|
function parseOpenAiCompatibleResponsesResponse(args2) {
|
|
24882
25133
|
const content = extractTextFromResponseOutput(args2.data);
|
|
24883
25134
|
const reasoning = extractReasoningFromResponseOutput(args2.data);
|
|
24884
|
-
const tool_calls = extractToolCallsFromResponseOutput(args2.data);
|
|
25135
|
+
const tool_calls = extractToolCallsFromResponseOutput(args2.data, { strictSnapshot: args2.strictToolSnapshot });
|
|
24885
25136
|
const u = args2.data?.usage;
|
|
24886
25137
|
const usage = u && typeof u === "object" ? {
|
|
24887
25138
|
prompt_tokens: typeof u.input_tokens === "number" ? u.input_tokens : typeof u.prompt_tokens === "number" ? u.prompt_tokens : 0,
|
|
@@ -24966,6 +25217,7 @@ async function readOpenAiCompatibleSseCompletion(args2) {
|
|
|
24966
25217
|
}
|
|
24967
25218
|
async function executeOpenAiCompatibleChatCompletion(args2) {
|
|
24968
25219
|
const isResponses = resolveOpenAiCompatibleWire(args2.providerConfig) === "responses";
|
|
25220
|
+
const strictResponses = usesNativeToolDiscovery(args2.providerConfig);
|
|
24969
25221
|
const timingTracker = createProviderCallTimingTracker();
|
|
24970
25222
|
const observeMeaningful = () => observeMeaningfulProviderResponse(timingTracker);
|
|
24971
25223
|
const diagnosticSink = resolveOutboundDiagnosticSink(args2.outboundDiagnostics);
|
|
@@ -24979,6 +25231,7 @@ async function executeOpenAiCompatibleChatCompletion(args2) {
|
|
|
24979
25231
|
callId: args2.outboundDiagnostics?.callId
|
|
24980
25232
|
}) : void 0;
|
|
24981
25233
|
let diagnosticAttempt = 0;
|
|
25234
|
+
let toolDiscovery;
|
|
24982
25235
|
const terminalIfEnabled = (outcome) => diagnosticCall?.terminal(diagnosticAttempt, outcome);
|
|
24983
25236
|
const send = async (apiKey2) => {
|
|
24984
25237
|
diagnosticAttempt += 1;
|
|
@@ -24988,11 +25241,13 @@ async function executeOpenAiCompatibleChatCompletion(args2) {
|
|
|
24988
25241
|
providerConfig: apiKey2 === args2.providerConfig.apiKey ? args2.providerConfig : { ...args2.providerConfig, apiKey: apiKey2 },
|
|
24989
25242
|
messages: args2.messages,
|
|
24990
25243
|
tools: args2.tools,
|
|
25244
|
+
mcpDiscoveryTools: args2.mcpDiscoveryTools,
|
|
24991
25245
|
stream: args2.stream,
|
|
24992
25246
|
sessionId: args2.sessionId,
|
|
24993
25247
|
...requestFacts ? { requestFacts } : {},
|
|
24994
25248
|
...requestFacts ? { shapingCounts: createRequestShapingCounts() } : {}
|
|
24995
25249
|
});
|
|
25250
|
+
toolDiscovery = request3.toolDiscovery;
|
|
24996
25251
|
if (requestFacts) diagnosticCall?.dispatch(diagnosticAttempt, requestFacts);
|
|
24997
25252
|
return args2.fetchImpl(request3.url, {
|
|
24998
25253
|
...request3.init,
|
|
@@ -25065,24 +25320,44 @@ async function executeOpenAiCompatibleChatCompletion(args2) {
|
|
|
25065
25320
|
terminalIfEnabled("completed");
|
|
25066
25321
|
return { ...result4, ...usage ? { usage } : {} };
|
|
25067
25322
|
};
|
|
25323
|
+
const finishDiscovery = (calls, usage, output) => {
|
|
25324
|
+
try {
|
|
25325
|
+
const discovery = finishResponsesToolDiscovery(calls, toolDiscovery, output);
|
|
25326
|
+
return toolDiscovery?.protocol === "openai-hosted" ? splitHostedToolDiscovery(discovery.calls, discovery.results) : discovery;
|
|
25327
|
+
} catch (error) {
|
|
25328
|
+
if (error instanceof Error && usage) Object.assign(error, { usage });
|
|
25329
|
+
throw error;
|
|
25330
|
+
}
|
|
25331
|
+
};
|
|
25068
25332
|
try {
|
|
25069
25333
|
if (isEventStream) {
|
|
25070
25334
|
if (isResponses) {
|
|
25071
25335
|
const streamed2 = await readResponsesSseCompletion({
|
|
25072
25336
|
response: res,
|
|
25337
|
+
signal: args2.signal,
|
|
25073
25338
|
...args2.onTextDelta ? { onTextDelta: args2.onTextDelta } : {},
|
|
25074
25339
|
...args2.onReasoningDelta ? { onReasoningDelta: args2.onReasoningDelta } : {},
|
|
25075
|
-
onMeaningfulDelta: observeMeaningful
|
|
25340
|
+
onMeaningfulDelta: observeMeaningful,
|
|
25341
|
+
...strictResponses ? { requireResponseCompleted: true, authoritativeCompletedTools: true } : {}
|
|
25076
25342
|
});
|
|
25343
|
+
args2.signal?.throwIfAborted();
|
|
25344
|
+
if (strictResponses && (!streamed2.stream_complete || streamed2.completed_response?.status !== "completed" || !Array.isArray(streamed2.completed_response.output))) {
|
|
25345
|
+
throw Object.assign(new Error("Responses tool discovery stream ended without response.completed."), {
|
|
25346
|
+
usage: streamed2.usage
|
|
25347
|
+
});
|
|
25348
|
+
}
|
|
25349
|
+
const discovery = finishDiscovery(streamed2.tool_calls ?? [], streamed2.usage, streamed2.completed_response?.output);
|
|
25077
25350
|
return withTiming({
|
|
25078
25351
|
content: streamed2.content,
|
|
25079
25352
|
model: args2.providerConfig.model,
|
|
25080
25353
|
provider: args2.providerConfig.provider,
|
|
25081
|
-
...
|
|
25354
|
+
...discovery.calls.length ? { tool_calls: discovery.calls, finish_reason: "tool_calls" } : {},
|
|
25355
|
+
...discovery.results.length ? { toolDiscoveryResults: discovery.results } : {},
|
|
25356
|
+
...discovery.completed?.length ? { completedToolDiscovery: discovery.completed } : {},
|
|
25082
25357
|
...streamed2.reasoning_content ? { reasoning_content: streamed2.reasoning_content } : {},
|
|
25083
25358
|
...streamed2.usage ? { usage: streamed2.usage } : {},
|
|
25084
25359
|
...streamed2.stream_complete ? { stream_complete: true } : {},
|
|
25085
|
-
|
|
25360
|
+
...!discovery.calls.length && streamed2.finish_reason ? { finish_reason: streamed2.finish_reason } : {},
|
|
25086
25361
|
...streamed2.leaked_protocol_intercepted ? { leaked_protocol_intercepted: true } : {},
|
|
25087
25362
|
trace: args2.messages
|
|
25088
25363
|
});
|
|
@@ -25113,11 +25388,30 @@ async function executeOpenAiCompatibleChatCompletion(args2) {
|
|
|
25113
25388
|
data = {};
|
|
25114
25389
|
}
|
|
25115
25390
|
if (isResponses) {
|
|
25116
|
-
|
|
25117
|
-
|
|
25118
|
-
|
|
25119
|
-
|
|
25120
|
-
|
|
25391
|
+
const usage = strictResponses ? projectChatUsage(data?.usage) : void 0;
|
|
25392
|
+
if (strictResponses && (data?.status !== "completed" || data.error || !Array.isArray(data.output))) {
|
|
25393
|
+
throw Object.assign(new Error("Responses did not complete the tool discovery round."), { usage });
|
|
25394
|
+
}
|
|
25395
|
+
let result4;
|
|
25396
|
+
try {
|
|
25397
|
+
result4 = parseOpenAiCompatibleResponsesResponse({
|
|
25398
|
+
providerConfig: args2.providerConfig,
|
|
25399
|
+
data,
|
|
25400
|
+
trace: args2.messages,
|
|
25401
|
+
strictToolSnapshot: strictResponses
|
|
25402
|
+
});
|
|
25403
|
+
} catch (error) {
|
|
25404
|
+
if (error instanceof Error && usage) Object.assign(error, { usage });
|
|
25405
|
+
throw error;
|
|
25406
|
+
}
|
|
25407
|
+
const discovery = finishDiscovery(result4.tool_calls ?? [], usage, data.output);
|
|
25408
|
+
return withTiming({
|
|
25409
|
+
...result4,
|
|
25410
|
+
...usage ? { usage } : {},
|
|
25411
|
+
...discovery.calls.length ? { tool_calls: discovery.calls, finish_reason: "tool_calls" } : {},
|
|
25412
|
+
...discovery.results.length ? { toolDiscoveryResults: discovery.results } : {},
|
|
25413
|
+
...discovery.completed?.length ? { completedToolDiscovery: discovery.completed } : {}
|
|
25414
|
+
});
|
|
25121
25415
|
}
|
|
25122
25416
|
return withTiming(parseOpenAiCompatibleChatCompletionResponse({
|
|
25123
25417
|
providerConfig: args2.providerConfig,
|
|
@@ -25132,7 +25426,11 @@ async function executeOpenAiCompatibleChatCompletion(args2) {
|
|
|
25132
25426
|
}
|
|
25133
25427
|
}
|
|
25134
25428
|
function describeOpenAiCompatibleRequestBudget(args2) {
|
|
25135
|
-
const request3 = buildOpenAiCompatibleChatCompletionRequest({
|
|
25429
|
+
const request3 = buildOpenAiCompatibleChatCompletionRequest({
|
|
25430
|
+
...args2,
|
|
25431
|
+
providerConfig: { ...args2.providerConfig, enableToolDiscovery: false },
|
|
25432
|
+
messages: []
|
|
25433
|
+
});
|
|
25136
25434
|
const body = JSON.parse(request3.init.body);
|
|
25137
25435
|
const cap = body.max_completion_tokens ?? body.max_output_tokens ?? body.max_tokens;
|
|
25138
25436
|
return {
|
|
@@ -25163,25 +25461,51 @@ async function resolveOpenAiCompatibleProviderConfig(args2) {
|
|
|
25163
25461
|
...plan.apiKeyHeader ? { apiKeyHeader: plan.apiKeyHeader } : {},
|
|
25164
25462
|
provider: plan.provider,
|
|
25165
25463
|
requestOptions: plan.requestOptions,
|
|
25464
|
+
...args2.env.NOLO_NATIVE_TOOL_DISCOVERY === "1" ? { enableToolDiscovery: true } : {},
|
|
25465
|
+
...args2.env.NOLO_OPENAI_TOOL_SEARCH_MODE === "hosted" ? { openAiSearchMode: "hosted" } : {},
|
|
25166
25466
|
...plan.usageProvider ? { usageProvider: plan.usageProvider } : {}
|
|
25167
25467
|
};
|
|
25168
25468
|
}
|
|
25169
25469
|
|
|
25170
25470
|
// packages/agent-runtime/dialogWritePlan.ts
|
|
25471
|
+
var DIALOG_ORIGIN_KEYS = /* @__PURE__ */ new Set(["host", "machineId", "worktreePath", "observedAt"]);
|
|
25472
|
+
function buildDialogLocalRuntimeMetadata(args2) {
|
|
25473
|
+
const raw = asRecordOrEmpty(args2.metadata);
|
|
25474
|
+
const rest = Object.fromEntries(
|
|
25475
|
+
Object.entries(raw).filter(([key]) => !DIALOG_ORIGIN_KEYS.has(key))
|
|
25476
|
+
);
|
|
25477
|
+
const machineId = asOptionalTrimmedString(raw.machineId);
|
|
25478
|
+
const worktreePath = asOptionalTrimmedString(raw.worktreePath);
|
|
25479
|
+
const observedAt = typeof raw.observedAt === "number" && Number.isFinite(raw.observedAt) ? raw.observedAt : args2.observedAt;
|
|
25480
|
+
return {
|
|
25481
|
+
host: args2.host,
|
|
25482
|
+
...machineId ? { machineId } : {},
|
|
25483
|
+
...worktreePath ? { worktreePath } : {},
|
|
25484
|
+
...typeof observedAt === "number" && Number.isFinite(observedAt) ? { observedAt } : {},
|
|
25485
|
+
...rest
|
|
25486
|
+
};
|
|
25487
|
+
}
|
|
25171
25488
|
function extractLastUserText(messages) {
|
|
25172
|
-
|
|
25173
|
-
|
|
25174
|
-
|
|
25175
|
-
|
|
25489
|
+
for (let i = messages.length - 1; i >= 0; i -= 1) {
|
|
25490
|
+
const message = messages[i];
|
|
25491
|
+
if (message?.role !== "user" || isInternalNoticeMessage(message)) continue;
|
|
25492
|
+
if (typeof message.content === "string") return message.content;
|
|
25493
|
+
if (Array.isArray(message.content)) {
|
|
25494
|
+
let text2 = "";
|
|
25495
|
+
for (let j = 0; j < message.content.length; j += 1) {
|
|
25496
|
+
const part = message.content[j];
|
|
25497
|
+
if (part?.type === "text" && typeof part.text === "string" && part.text) {
|
|
25498
|
+
text2 = text2 ? `${text2} ${part.text}` : part.text;
|
|
25499
|
+
}
|
|
25500
|
+
}
|
|
25501
|
+
return text2;
|
|
25502
|
+
}
|
|
25503
|
+
return "";
|
|
25176
25504
|
}
|
|
25177
25505
|
return "";
|
|
25178
25506
|
}
|
|
25179
|
-
function
|
|
25180
|
-
const
|
|
25181
|
-
if (typeof existing === "string" && existing.trim()) {
|
|
25182
|
-
return existing.trim();
|
|
25183
|
-
}
|
|
25184
|
-
const lastUserText = extractLastUserText(args2.messages).trim();
|
|
25507
|
+
function resolveFallbackDialogTitle(messages) {
|
|
25508
|
+
const lastUserText = extractLastUserText(messages).trim();
|
|
25185
25509
|
return buildDialogFallbackTitleFromUserInput(lastUserText) || "Local agent run";
|
|
25186
25510
|
}
|
|
25187
25511
|
function pickDialogTitle(args2) {
|
|
@@ -25202,10 +25526,7 @@ function pickDialogTitle(args2) {
|
|
|
25202
25526
|
return { title: override, titleSource: "generated" };
|
|
25203
25527
|
}
|
|
25204
25528
|
return {
|
|
25205
|
-
title:
|
|
25206
|
-
existingDialog: args2.existingDialog,
|
|
25207
|
-
messages: args2.messages
|
|
25208
|
-
}),
|
|
25529
|
+
title: resolveFallbackDialogTitle(args2.messages),
|
|
25209
25530
|
titleSource: "generated"
|
|
25210
25531
|
};
|
|
25211
25532
|
}
|
|
@@ -25288,6 +25609,7 @@ function buildDialogMessageWriteOps(args2) {
|
|
|
25288
25609
|
dialogId: args2.dialogId,
|
|
25289
25610
|
role: message.role,
|
|
25290
25611
|
content: message.content ?? "",
|
|
25612
|
+
...message.internalNotice === true ? { internalNotice: true } : {},
|
|
25291
25613
|
...message.context_reference !== void 0 ? { contextReference: message.context_reference } : {},
|
|
25292
25614
|
// 持久化思维链(reasoning):空轮/异常排查的关键证据,
|
|
25293
25615
|
// 回读由 dialogMessageRecordToAgentRuntimeMessage 还原。
|
|
@@ -25396,10 +25718,11 @@ function buildAgentRuntimeDialogWritePlan(args2) {
|
|
|
25396
25718
|
dialogId
|
|
25397
25719
|
}),
|
|
25398
25720
|
...typeof args2.input.result.toolCallCount === "number" ? { toolCallCount: args2.input.result.toolCallCount } : {},
|
|
25399
|
-
localRuntime: {
|
|
25721
|
+
localRuntime: buildDialogLocalRuntimeMetadata({
|
|
25400
25722
|
host: args2.runtimeHost,
|
|
25401
|
-
|
|
25402
|
-
|
|
25723
|
+
observedAt: args2.now,
|
|
25724
|
+
metadata: args2.runtimeMetadata
|
|
25725
|
+
}),
|
|
25403
25726
|
...buildRuntimeCheckpointField({
|
|
25404
25727
|
hasExistingCheckpoint: args2.existingDialog?.runtimeCheckpoint != null,
|
|
25405
25728
|
cleanExistingCheckpoint,
|
|
@@ -25588,7 +25911,8 @@ var DEFAULT_HOSTED_SANDBOX_RESOURCE_LIMITS = {
|
|
|
25588
25911
|
cpuSeconds: 30,
|
|
25589
25912
|
maxFileSizeBytes: 64 * 1024 * 1024,
|
|
25590
25913
|
maxOpenFiles: 256,
|
|
25591
|
-
maxProcesses: 256
|
|
25914
|
+
maxProcesses: 256,
|
|
25915
|
+
maxAddressSpaceBytes: 1024 * 1024 * 1024
|
|
25592
25916
|
};
|
|
25593
25917
|
var BWRAP_PROBE_TTL_MS = 5 * 6e4;
|
|
25594
25918
|
|
|
@@ -25657,8 +25981,11 @@ function buildLocalDialogWritePlan(args2) {
|
|
|
25657
25981
|
createId: args2.createId,
|
|
25658
25982
|
existingDialog: args2.existingDialog,
|
|
25659
25983
|
runtimeHost: "cli",
|
|
25984
|
+
// Origin evidence only (where the turn ran). `dialog.runtimeBinding.target`
|
|
25985
|
+
// is spread from existingDialog by the plan and stays authoritative.
|
|
25660
25986
|
runtimeMetadata: {
|
|
25661
|
-
...args2.cwd ? { worktreePath: args2.cwd } : {}
|
|
25987
|
+
...args2.cwd ? { worktreePath: args2.cwd } : {},
|
|
25988
|
+
...args2.originMachineId ? { machineId: args2.originMachineId } : {}
|
|
25662
25989
|
},
|
|
25663
25990
|
...args2.titleOverride ? { titleOverride: args2.titleOverride } : {}
|
|
25664
25991
|
});
|
|
@@ -25723,7 +26050,7 @@ async function saveCliPendingUserMessages(args2) {
|
|
|
25723
26050
|
if (ops.length) await args2.store.batch(ops);
|
|
25724
26051
|
}
|
|
25725
26052
|
async function readCliPendingUserMessages(store, dialogId) {
|
|
25726
|
-
const { readDialogMessageRecords } = await import("./cliLocalAgentRecordReader-
|
|
26053
|
+
const { readDialogMessageRecords } = await import("./cliLocalAgentRecordReader-X2YHEBWI.js");
|
|
25727
26054
|
const rows = await readDialogMessageRecords({ store, dialogId });
|
|
25728
26055
|
const uncertain = rows.filter(({ record: record2 }) => record2.metadata?.cliBatchPhase === "requested" && !record2.metadata?.cliBatchResolution);
|
|
25729
26056
|
const recovery = uncertain.length ? {
|
|
@@ -26022,10 +26349,10 @@ function buildLoadSkillExecutor(args2) {
|
|
|
26022
26349
|
metadata: { loadSkill: true, resolved: false }
|
|
26023
26350
|
};
|
|
26024
26351
|
}
|
|
26025
|
-
const { resolveSkillByName } = await import("./skillDiscovery-
|
|
26352
|
+
const { resolveSkillByName } = await import("./skillDiscovery-IUEZZG2B.js");
|
|
26026
26353
|
const resolved = resolveSkillByName(args2.cwd, name);
|
|
26027
26354
|
if (!resolved) {
|
|
26028
|
-
const { resolveBuiltinSkillByName } = await import("./builtinSkillRegistry-
|
|
26355
|
+
const { resolveBuiltinSkillByName } = await import("./builtinSkillRegistry-6XUWMAV5.js");
|
|
26029
26356
|
const builtin = resolveBuiltinSkillByName(name);
|
|
26030
26357
|
if (builtin) {
|
|
26031
26358
|
const denied = await rejectDisabledBuiltin(args2.agentSkillSource, builtin.slug, name, args2.resolveAgentSkillSource);
|
|
@@ -26104,7 +26431,7 @@ async function loadPreciseSkill(cwd, parsed, agentSkillSource, resolveAgentSkill
|
|
|
26104
26431
|
if (!nonEmpty(parsed.slug) || has2("projectBinding") || has2("relativePath")) {
|
|
26105
26432
|
return reject("builtin requires only an exact slug.");
|
|
26106
26433
|
}
|
|
26107
|
-
const { listBuiltinSkills } = await import("./builtinSkillRegistry-
|
|
26434
|
+
const { listBuiltinSkills } = await import("./builtinSkillRegistry-6XUWMAV5.js");
|
|
26108
26435
|
const builtin = listBuiltinSkills().find((entry) => entry.slug === parsed.slug);
|
|
26109
26436
|
if (!builtin) return reject("builtin slug not found.");
|
|
26110
26437
|
const denied = await rejectDisabledBuiltin(agentSkillSource, builtin.slug, builtin.slug, resolveAgentSkillSource);
|
|
@@ -26130,10 +26457,10 @@ ${builtin.content}`,
|
|
|
26130
26457
|
}
|
|
26131
26458
|
try {
|
|
26132
26459
|
const { realpathSync: realpathSync2, statSync: statSync2, readFileSync: readFileSync2 } = await import("node:fs");
|
|
26133
|
-
const { resolve: resolve7, relative:
|
|
26460
|
+
const { resolve: resolve7, relative: relative8, isAbsolute: isAbsolute6, basename: basename4, sep: sep5 } = await import("node:path");
|
|
26134
26461
|
const inside = (root, target) => {
|
|
26135
|
-
const rel =
|
|
26136
|
-
return rel !== "" && rel !== ".." && !rel.startsWith(`..${
|
|
26462
|
+
const rel = relative8(root, target);
|
|
26463
|
+
return rel !== "" && rel !== ".." && !rel.startsWith(`..${sep5}`) && !isAbsolute6(rel);
|
|
26137
26464
|
};
|
|
26138
26465
|
const realCwd = realpathSync2(cwd);
|
|
26139
26466
|
if (!isAbsolute6(parsed.projectBinding) || realpathSync2(parsed.projectBinding) !== realCwd) {
|
|
@@ -26170,7 +26497,7 @@ ${body}`,
|
|
|
26170
26497
|
}
|
|
26171
26498
|
}
|
|
26172
26499
|
async function formatUnknownSkillMessage(cwd, requestedName) {
|
|
26173
|
-
const { discoverSkills } = await import("./skillDiscovery-
|
|
26500
|
+
const { discoverSkills } = await import("./skillDiscovery-IUEZZG2B.js");
|
|
26174
26501
|
let available = [];
|
|
26175
26502
|
try {
|
|
26176
26503
|
available = discoverSkills(cwd).map((s) => s.name);
|
|
@@ -26742,12 +27069,12 @@ function createDevinProvider(options) {
|
|
|
26742
27069
|
}
|
|
26743
27070
|
|
|
26744
27071
|
// packages/agent-runtime/executionLeaseValidation.ts
|
|
26745
|
-
import { isAbsolute as isAbsolute5, relative as
|
|
27072
|
+
import { isAbsolute as isAbsolute5, relative as relative7, resolve as resolve6 } from "node:path";
|
|
26746
27073
|
function withinRoot(root, child) {
|
|
26747
27074
|
if (!isAbsolute5(root) || !isAbsolute5(child)) return false;
|
|
26748
27075
|
const canonicalRoot = resolve6(root);
|
|
26749
27076
|
const canonicalChild = resolve6(child);
|
|
26750
|
-
const suffix =
|
|
27077
|
+
const suffix = relative7(canonicalRoot, canonicalChild);
|
|
26751
27078
|
return suffix === "" || suffix !== ".." && !suffix.startsWith("../") && !suffix.startsWith("..\\") && !isAbsolute5(suffix);
|
|
26752
27079
|
}
|
|
26753
27080
|
function subsetOf(allowed, actual) {
|
|
@@ -26816,10 +27143,13 @@ export {
|
|
|
26816
27143
|
isDestructiveShellCommand,
|
|
26817
27144
|
evaluateShellCommandPolicy,
|
|
26818
27145
|
readAgentsMdLayerFromDisk,
|
|
27146
|
+
AGENT_PROMPT_IN_MESSAGES,
|
|
27147
|
+
hasAssembledAgentPrompt,
|
|
26819
27148
|
filterRetainedLedgerRecords,
|
|
26820
27149
|
isLineRangeCovered,
|
|
26821
27150
|
runTaskStop,
|
|
26822
27151
|
WORKSPACE_TOOL_NAMES,
|
|
27152
|
+
isPathInsideRoot,
|
|
26823
27153
|
buildLocalWorkspaceToolset,
|
|
26824
27154
|
buildLocalWorkspacePolicyToolNames,
|
|
26825
27155
|
buildLocalWorkspaceOpenAiTools,
|
|
@@ -26840,29 +27170,32 @@ export {
|
|
|
26840
27170
|
executeLocalToolWithPolicy,
|
|
26841
27171
|
Option_exports,
|
|
26842
27172
|
Duration_exports,
|
|
26843
|
-
Exit_exports,
|
|
26844
27173
|
Effect_exports,
|
|
26845
27174
|
LOCAL_TURN_ABORTED_CODE,
|
|
26846
|
-
|
|
26847
|
-
|
|
26848
|
-
|
|
26849
|
-
|
|
26850
|
-
|
|
26851
|
-
|
|
27175
|
+
inspectCompactionSummaryQuality,
|
|
27176
|
+
COMPACTION_TELEMETRY_SCHEMA_VERSION,
|
|
27177
|
+
appendCompactionTelemetryRecord,
|
|
27178
|
+
resolveCompactHistory,
|
|
27179
|
+
prepareCompactHistory,
|
|
27180
|
+
toPlanCompressionMessages,
|
|
26852
27181
|
projectContextProvenance,
|
|
26853
|
-
hashToolDefinitions,
|
|
26854
27182
|
LOCAL_AGENT_CONFIG_MISSING_CODE,
|
|
26855
27183
|
runLocalAgentTurn,
|
|
27184
|
+
parseSseDataLineJson,
|
|
27185
|
+
parseSseDataLineObject,
|
|
26856
27186
|
responsesStreamFailureStatus,
|
|
26857
27187
|
codexStreamFailureStatus,
|
|
26858
27188
|
createResponsesStreamCollector,
|
|
26859
27189
|
readResponsesSseCompletion,
|
|
27190
|
+
usesNativeToolDiscovery,
|
|
26860
27191
|
buildOpenAiCompatibleChatCompletionRequest,
|
|
26861
27192
|
parseOpenAiCompatibleChatCompletionResponse,
|
|
26862
27193
|
readOpenAiCompatibleSseCompletion,
|
|
26863
27194
|
executeOpenAiCompatibleChatCompletion,
|
|
26864
27195
|
describeOpenAiCompatibleRequestBudget,
|
|
26865
27196
|
resolveOpenAiCompatibleProviderConfig,
|
|
27197
|
+
extractLastUserText,
|
|
27198
|
+
resolveFallbackDialogTitle,
|
|
26866
27199
|
buildAgentRuntimeDialogWritePlan,
|
|
26867
27200
|
shouldCacheHybridRemoteRecord,
|
|
26868
27201
|
parseSyncServersEnv,
|