nolo-cli 0.227.0-alpha.1 → 0.227.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 +3 -5
- package/{_executeModel-JKQGZ3HU.js → _executeModel-CXOFYVHC.js} +93 -87
- package/{action-CK64LS6S.js → action-R2EIXR7I.js} +11 -8
- package/{addContentAction-CARFID6E.js → addContentAction-W6JVLQ6H.js} +17 -16
- package/{addDialogAgentAction-APLZLFW5.js → addDialogAgentAction-LVNKMXKZ.js} +20 -19
- package/{agentDeleteCommand-NVR2V2HH.js → agentDeleteCommand-VFSZPEQ5.js} +145 -137
- package/{agentEmailCommands-UCVOWD3S.js → agentEmailCommands-KRUIF4EH.js} +149 -137
- package/{agentFavoriteCommands-4PDOP3GW.js → agentFavoriteCommands-7LOP3HUD.js} +6 -6
- package/{agentGrantCommands-FLCEXLUH.js → agentGrantCommands-L6O2HVJI.js} +7 -7
- package/agentListCommands-TDFOLWN3.js +644 -0
- package/{agentMachineCommands-V3DGEJU4.js → agentMachineCommands-PSH7Q5PF.js} +76 -67
- package/{agentProviderCommands-7QBFRFRK.js → agentProviderCommands-C5T7C5KZ.js} +7 -7
- package/{agentPullCommand-E6JBGBVG.js → agentPullCommand-QQQZSC6S.js} +7 -7
- package/agentRecordCommands-KCKCW2QU.js +188 -0
- package/agentRunCommand-EF2T2QWD.js +223 -0
- package/{agentRunControl-SNZZ5XP4.js → agentRunControl-CSMSJFFB.js} +25 -17
- package/{agentRuntimeLocal-GOX2DIY7.js → agentRuntimeLocal-6QXQS3TS.js} +64 -50
- package/{agentSlice-N7H2FRJA.js → agentSlice-IZ5ANAF7.js} +19 -18
- package/{appDeleteCommands-LZDN26FU.js → appDeleteCommands-4M7ETEEG.js} +68 -59
- package/{appDeployCommands-6IO6TTZH.js → appDeployCommands-2VJ2NDW5.js} +68 -59
- package/{appDeployStatusCommands-FG3LX24J.js → appDeployStatusCommands-LDFSWOPQ.js} +68 -59
- package/{appGetCommands-NAKVDVD4.js → appGetCommands-RHVNOPT4.js} +68 -59
- package/{appListCommands-KL56RN73.js → appListCommands-U3XEVTL4.js} +68 -59
- package/{authCommand-AUN5MXV2.js → authCommand-PVZ45QRO.js} +36 -31
- package/{authCommands-D2IPS6ES.js → authCommands-6AUYO65N.js} +18 -13
- package/{builtinSkillRegistry-UQGLKRYP.js → builtinSkillRegistry-LRVAQCPW.js} +6 -6
- package/{chromeCommands-G5UDKVSV.js → chromeCommands-S7AW3AOD.js} +383 -6
- package/{chromeOpsCommands-UJWN5HWH.js → chromeOpsCommands-TBPM6MR4.js} +8 -8
- package/{chunk-ABGULE7H.js → chunk-22YUCKMK.js} +16 -16
- package/{chunk-P2ZLUIW2.js → chunk-2BSLGODA.js} +350 -25
- package/{chunk-GOLPOTG5.js → chunk-2COM7SAH.js} +4 -4
- package/{chunk-ULAQPRHX.js → chunk-2FK2KZSL.js} +1 -1
- package/{chunk-PLPLH2XZ.js → chunk-2IPR4PBB.js} +2 -2
- package/chunk-2SXN7LAY.js +15 -0
- package/{chunk-XI2BWJM5.js → chunk-324FWHUA.js} +20 -3
- package/{chunk-7Z3WUZ4Q.js → chunk-3YYFU6H7.js} +74 -46
- package/{chunk-C2B7M567.js → chunk-4OXPN3WC.js} +17 -6
- package/chunk-4TVOZGOS.js +62 -0
- package/chunk-4ZCTKB27.js +31 -0
- package/chunk-53AEDFBL.js +33394 -0
- package/chunk-53W5BXLN.js +340 -0
- package/{chunk-OXA5GWHU.js → chunk-56O2J2Y4.js} +3 -3
- package/{chunk-IAJJYHIB.js → chunk-56PB7FEN.js} +8 -8
- package/{chunk-JWXITTQB.js → chunk-5HUO7SEX.js} +9 -107
- package/{chunk-AGP3YSEC.js → chunk-5PASH2MB.js} +46 -1
- package/{chunk-PHOSZT3E.js → chunk-5UAKGCQG.js} +1 -1
- package/{chunk-5RKRXQ2H.js → chunk-5VVP7DW3.js} +20 -13
- package/chunk-6ASGEP5D.js +21 -0
- package/chunk-6PXFEPHL.js +103 -0
- package/chunk-6RSNVJGO.js +279 -0
- package/{chunk-YGMBIXCF.js → chunk-6XRPBZRS.js} +4 -2
- package/{chunk-KMRKZNGT.js → chunk-6YYTTLJV.js} +14 -13
- package/{chunk-VREDDN25.js → chunk-76HAJUOJ.js} +14 -9
- package/{chunk-FKEZOMIF.js → chunk-7DXFOL5B.js} +1410 -768
- package/{chunk-LA7JYAKF.js → chunk-AKPKOI5Z.js} +6 -6
- package/{chunk-PWTNI4N7.js → chunk-ANUP75N2.js} +22 -0
- package/{chunk-F5AY2UZL.js → chunk-AO6T7U62.js} +592 -68
- package/{chunk-LJSNEV7M.js → chunk-AS6L5KSD.js} +8 -8
- package/{chunk-GOQ6ZVTN.js → chunk-AVSZ6PBM.js} +5 -5
- package/chunk-BIDSIRTS.js +307 -0
- package/chunk-C5A54QS7.js +108 -0
- package/{chunk-KYH7XW3K.js → chunk-CD2DK5JA.js} +135 -14
- package/{chunk-G6HJUMST.js → chunk-CJQBWHNM.js} +2 -2
- package/{chunk-EVGU5P4U.js → chunk-CO6E7YK6.js} +1 -1
- package/{chunk-ZYA2YDB6.js → chunk-CT5JXREL.js} +17 -17
- package/{chunk-VPAZ6BEN.js → chunk-CTWCZKNS.js} +42 -17
- package/{chunk-4OKTPFNX.js → chunk-CX2LYFZQ.js} +107 -66
- package/{chunk-YFLVRVYK.js → chunk-DLT2DN4M.js} +1 -1
- package/{chunk-LKA64WH4.js → chunk-DMPZMYH4.js} +37 -1
- package/{chunk-KFHREHUQ.js → chunk-DXWGFL2Z.js} +89 -1
- package/{chunk-OQHIVPG4.js → chunk-E6A5NHDH.js} +4 -1
- package/{chunk-IX2BXN2K.js → chunk-EDT65EUE.js} +6 -6
- package/{chunk-VP3BINY7.js → chunk-EQZZASCD.js} +31 -1
- package/{chunk-45LZIYXB.js → chunk-ESN4WNWU.js} +3 -2
- package/{chunk-M3JEW6N6.js → chunk-F26GAEH3.js} +10 -0
- package/{chunk-CVERLOJM.js → chunk-F4XIS5DL.js} +1215 -1431
- package/chunk-FDZ2GBWO.js +166 -0
- package/chunk-FGHEF6WI.js +34 -0
- package/{chunk-CSW7IPVD.js → chunk-FMYNIAI6.js} +61 -24
- package/{chunk-VIHDJ3FK.js → chunk-FNT5VENS.js} +15 -15
- package/{chunk-PMDVQBGA.js → chunk-GAHJLSDO.js} +14 -7
- package/{chunk-GRXSJR2Z.js → chunk-GVTFSLNI.js} +112 -109
- package/{chunk-UN7HIYMH.js → chunk-GX6DITLQ.js} +1 -1
- package/{chunk-3VFYQH3I.js → chunk-HIDVLMZC.js} +203 -156
- package/{chunk-5LQDHFBN.js → chunk-IDFGIROZ.js} +20 -17
- package/{chunk-UCFPVYP7.js → chunk-IFWXH7LH.js} +1 -1
- package/{chunk-LXTC53TN.js → chunk-J45ACAOQ.js} +815 -361
- package/{chunk-S6K5F3KP.js → chunk-JP2BH4NC.js} +1 -1
- package/{chunk-X2KRQP7V.js → chunk-JV5FHHF7.js} +1 -1
- package/{chunk-6EDAMVG6.js → chunk-K26XPZRB.js} +11 -11
- package/{chunk-RU6DULV4.js → chunk-KB5RQRSJ.js} +1 -1
- package/{chunk-T43K75CK.js → chunk-KC2QVCI7.js} +24 -178
- package/chunk-KK3FCYZM.js +647 -0
- package/{chunk-XZODOEKU.js → chunk-KMDHRVS7.js} +29 -5
- package/{chunk-4JVNURX4.js → chunk-KQHEGELM.js} +68 -16
- package/{chunk-UAPNPNSG.js → chunk-KW72WVHO.js} +2085 -1046
- package/{chunk-ILHQ2AXT.js → chunk-KZAT2M2V.js} +14 -8
- package/{chunk-L42CBKBZ.js → chunk-KZKMH374.js} +3 -3
- package/{chunk-ZI5SZ3MV.js → chunk-L6BLA6BT.js} +40 -31
- package/{chunk-AK5O76CC.js → chunk-LC5CVWP2.js} +3 -3
- package/{chunk-N5Z2V73W.js → chunk-LELADM5Q.js} +1 -1
- package/chunk-LHCGKAFO.js +739 -0
- package/{chunk-YOT437BH.js → chunk-LOF2EFUE.js} +203 -123
- package/{chunk-YQETUZ5V.js → chunk-LTVEOOZL.js} +29 -16
- package/{chunk-T2BEPTAG.js → chunk-MAA42MMV.js} +272 -26
- package/{chunk-NAOO4PVX.js → chunk-MECW2HJG.js} +16 -16
- package/{chunk-5HL4KC4A.js → chunk-MEDPR36J.js} +62 -87
- package/chunk-MVOZ22RZ.js +26 -0
- package/{chunk-YPPKC6FL.js → chunk-MYYNZG2M.js} +140 -40
- package/{chunk-UVUVQVZ6.js → chunk-MZVCFV3T.js} +19 -15
- package/{chunk-CQVGR3MX.js → chunk-N7MXFYLU.js} +7 -7
- package/{chunk-IC2I373Q.js → chunk-NEG5LYK5.js} +4 -4
- package/chunk-NJJK3PDA.js +133 -0
- package/{chunk-OB6DVWPF.js → chunk-OGZE6BZG.js} +331 -99
- package/{chunk-M3Y4IBIR.js → chunk-OHUYN3YU.js} +6 -6
- package/chunk-P27E22MA.js +203 -0
- package/{chunk-SFTTXGPM.js → chunk-PDAXMBLW.js} +35 -28
- package/{chunk-OBSEKCVK.js → chunk-PQ63BDV3.js} +210 -51
- package/{chunk-EUCFKKDM.js → chunk-PVFYPUIM.js} +40 -10
- package/{chunk-SRG5CNLC.js → chunk-QIVE5WJE.js} +8 -8
- package/{chunk-HOCHUZQ7.js → chunk-QJTZ76CP.js} +24 -6
- package/{chunk-5RKUPJYL.js → chunk-QLUYDJST.js} +11 -3
- package/{chunk-7Z6EW7AH.js → chunk-QOURTDZL.js} +97 -11
- package/{chunk-VZW34YUL.js → chunk-QWSH3UAQ.js} +8 -5
- package/{chunk-MK2Q7ZJD.js → chunk-R7XWZDOH.js} +58 -24
- package/{chunk-5FUN7EG4.js → chunk-RD3QLZQV.js} +83 -47
- package/{chunk-SW6OD4KE.js → chunk-RDPAIR67.js} +351 -18
- package/{chunk-NO3VBWTL.js → chunk-RXTZB2DH.js} +4 -4
- package/{chunk-AXYH4734.js → chunk-S25VJYXV.js} +21 -15
- package/{chunk-MWHOH4RJ.js → chunk-SESKIWB4.js} +6 -6
- package/{chunk-GUVXQSFZ.js → chunk-SF4GMDZO.js} +18 -108
- package/{chunk-TINJKQSO.js → chunk-SQRKAYQW.js} +25 -25
- package/chunk-SR4FE5VD.js +9 -0
- package/{chunk-3HTP4WZQ.js → chunk-SX6AWTNK.js} +46 -8
- package/{chunk-4WVJLODK.js → chunk-T23G6PXQ.js} +8 -3
- package/{chunk-CLCXHIBS.js → chunk-T4QY3HZ5.js} +1 -1
- package/{chunk-HVUDBOQG.js → chunk-TB5KTLNB.js} +9 -6
- package/{chunk-KRRE4A7D.js → chunk-TKE4OJ4B.js} +280 -56
- package/{chunk-S2NTVGA2.js → chunk-U35UUM5K.js} +2 -1
- package/{chunk-PPJYZRSQ.js → chunk-U5LOKQ2R.js} +30 -14
- package/{chunk-CKT6QUE2.js → chunk-UHW6SCVK.js} +1 -1
- package/{chunk-T5N6NHAT.js → chunk-UPOW5HTG.js} +6 -6
- package/{chunk-WJP4TH6U.js → chunk-VEVLLBFK.js} +2 -2
- package/{chunk-HGDKT2D6.js → chunk-VTHWBTRE.js} +177 -1
- package/{chunk-KJAAPGBE.js → chunk-VUHKG4KS.js} +6 -6
- package/{chunk-TOKPHZ55.js → chunk-W3HSD32M.js} +17 -10
- package/{chunk-2SKTCNWO.js → chunk-W5OJBZLZ.js} +4 -4
- package/chunk-WBSJAIZP.js +170 -0
- package/chunk-WDWZPASX.js +29 -0
- package/chunk-WFGNWWJI.js +326 -0
- package/{chunk-FIYSMXHY.js → chunk-WWTSEBDF.js} +1 -1
- package/{chunk-E2BESSAW.js → chunk-X4O7FJF5.js} +2 -0
- package/{chunk-HYKGIXNO.js → chunk-XGWRH3OF.js} +114 -29
- package/{chunk-XIEYGCN6.js → chunk-XKV53E4E.js} +460 -117
- package/{chunk-JHF6VLVL.js → chunk-XYRTC2Y3.js} +155 -170
- package/{chunk-L5I543VB.js → chunk-YGDYYFRX.js} +20 -24
- package/{chunk-ZADGPNTV.js → chunk-YHWMKGOX.js} +77 -103
- package/{chunk-6OVNSQHN.js → chunk-YLAHYLDQ.js} +5 -0
- package/chunk-Z6YTCDU4.js +24 -0
- package/{chunk-PVAWNHP5.js → chunk-ZP26NIZE.js} +647 -387
- package/{chunk-2G3YSVO6.js → chunk-ZQ6K57FJ.js} +3 -3
- package/{cliAgentConfigHelpers-QVSQYTKC.js → cliAgentConfigHelpers-37ZNEY5Y.js} +16 -16
- package/{cliAuthorityBrokerClient-XHH7MH2P.js → cliAuthorityBrokerClient-SFPC3WVK.js} +1 -1
- package/{cliEnvHelpers-D6HMC46Z.js → cliEnvHelpers-CNMP3RDX.js} +2 -2
- package/{cliExecutor-4MAX3PZL.js → cliExecutor-K6FDZTQ2.js} +3 -1
- package/cliLocalAgentRecordReader-53773JID.js +102 -0
- package/{commandRegistry-TKR6OWXP.js → commandRegistry-RJUO2VOD.js} +113 -101
- package/{contentThunks-BQWRPCTM.js → contentThunks-4EFHLUTB.js} +44 -41
- package/{cooldownCommands-FZYQOWI5.js → cooldownCommands-QL6DWGVU.js} +3 -3
- package/{createAgentAutomationAction-GFI6SJZV.js → createAgentAutomationAction-ZFFGJ7CZ.js} +44 -41
- package/{createDialogAction-MMBIHFFU.js → createDialogAction-SDUGVTPS.js} +45 -43
- package/{createPageAction-EEYUE5FB.js → createPageAction-NNM3OFLY.js} +49 -46
- package/{db-CS4ZJQKV.js → db-6NRZLEW2.js} +10 -7
- package/{dbSlice-X4Z4E4QU.js → dbSlice-5MQ3ELID.js} +16 -15
- package/{deleteFile-QOOP2UK7.js → deleteFile-VCCHS72Y.js} +12 -9
- package/{dialogCommands-OXBQ73DD.js → dialogCommands-SJK5KWXU.js} +73 -66
- package/dialogMessageRecord-OAV77LT7.js +7 -0
- package/{dialogNotifyCommand-VWS5G4OO.js → dialogNotifyCommand-PST75COP.js} +19 -19
- package/{dialogSlice-KGYIABDY.js → dialogSlice-2KLMHECR.js} +44 -41
- package/{dialogUsageCommand-FEWCN7IA.js → dialogUsageCommand-BZPKR3DW.js} +8 -8
- package/{docCreateCommands-LS32VKY3.js → docCreateCommands-K7CDL2HY.js} +66 -57
- package/{docDeleteCommands-JTYR5RPH.js → docDeleteCommands-ZEY5YCSP.js} +69 -60
- package/{docReadCommands-E5LTVKWN.js → docReadCommands-A4ROLIQG.js} +66 -57
- package/{docStore-TVS2FNER.js → docStore-A4O6YJAM.js} +19 -18
- package/{docUpdateCommands-I3J3JDZ2.js → docUpdateCommands-6HTFQY4O.js} +66 -57
- package/{fetchMessages-Q3INLN5F.js → fetchMessages-TQEUZD7H.js} +3 -3
- package/{getPricing-VNGFM4PN.js → getPricing-FCHYVRJU.js} +6 -6
- package/{handleSendMessageAction-SSON36TJ.js → handleSendMessageAction-6WEFYBUC.js} +87 -82
- package/{hostCredentialCreate-WTW4THJF.js → hostCredentialCreate-WOWCNOYM.js} +136 -123
- package/index.js +54 -16
- package/keys-RWF7UCB4.js +1 -1
- package/{lib-OT5OTXRU.js → lib-62SWPXNF.js} +3 -7
- package/{localDialogRead-V36DX2Q2.js → localDialogRead-3T2KMCRC.js} +2 -2
- package/{localRuntimeAdapter-MI2JGXSF.js → localRuntimeAdapter-7EDBDRYW.js} +147 -133
- package/{localRuntimeAuthority-IBJAT62G.js → localRuntimeAuthority-7DKIT7UH.js} +4 -2
- package/{localRuntimeDb-N7KHDXS2.js → localRuntimeDb-5WZ4RJJO.js} +1 -1
- package/{machineCommands-3LROJZDK.js → machineCommands-XRPC67LL.js} +290 -354
- package/machineWsRunDispatch-SOGFW472.js +203 -0
- package/markdownToSlate-KIYM7B3P.js +8 -0
- package/mcpLocalAuthorizeCommand-VOJARP3M.js +106 -0
- package/{memberThunks-CFEPHAND.js → memberThunks-KC3WJGL3.js} +26 -21
- package/{memoryCommands-JQMEJO7J.js → memoryCommands-BC6REPQB.js} +6 -6
- package/{models-H5NNZRLH.js → models-EP7VG6N2.js} +2 -2
- package/{overlay-THLKYIWY.js → overlay-JA3SPVUS.js} +7 -3
- package/package.json +1 -1
- package/{projectArchive-3X54XFVN.js → projectArchive-GDVPIZX2.js} +50 -47
- package/{providerPresetApply-FO36N5TX.js → providerPresetApply-4H7YP5D7.js} +9 -9
- package/{providerRegistry-U2BSFE6K.js → providerRegistry-F3UPOTIY.js} +9 -9
- package/{read-KA3L2V7O.js → read-T7VU2IMO.js} +11 -10
- package/{readDocTool-AMAZAPAW.js → readDocTool-BPQ3QJSD.js} +1 -1
- package/{readlineWorkspace-Z3YUH4SX.js → readlineWorkspace-OWQIIUGH.js} +9406 -6791
- package/rememberExplicit-CPAPONSI.js +15 -0
- package/{removeDialogAgentAction-JQOJSUM7.js → removeDialogAgentAction-FEUUVMYC.js} +23 -22
- package/{runAgentClientLoop-4FCFLMDJ.js → runAgentClientLoop-SJREK2B7.js} +107 -86
- package/{runtimeDoctorCommands-CXOCVDPU.js → runtimeDoctorCommands-XQD4MN4I.js} +19 -19
- package/{secretCommands-GGUAWAE7.js → secretCommands-LH7QTJO2.js} +3 -3
- package/{setDialogExtraReferencesAction-YXQTGXIN.js → setDialogExtraReferencesAction-JSTQJPXL.js} +19 -18
- package/{setPrimaryDialogAgentAction-YNLB66WE.js → setPrimaryDialogAgentAction-Z2BQE3IY.js} +23 -22
- package/{settingThunks-E6N7RSSS.js → settingThunks-C2YWCNYI.js} +186 -67
- package/{skillDiscovery-B5V23AXP.js → skillDiscovery-MDDKPTW3.js} +4 -3
- package/{spaceCommands-DB5DKC2J.js → spaceCommands-YRBQ52PG.js} +71 -62
- package/{store-JRVN62NM.js → store-Z53ICFL3.js} +3 -1
- package/{streamAgentChatTurn-FCBGMD4D.js → streamAgentChatTurn-NCA4BKDZ.js} +244 -185
- package/{switchDialogAgentAction-LAHLUECU.js → switchDialogAgentAction-G7XVAOGH.js} +20 -19
- package/{tableCommands-VNSXHAMG.js → tableCommands-UHEA5QNL.js} +14 -11
- package/{toolApiClient-OGQEBQVX.js → toolApiClient-N5PYW2R3.js} +8 -6
- package/{tools-6JD36D6K.js → tools-6WQVUGKV.js} +74 -70
- package/tuiRestart-3J7LRMPR.js +41 -0
- package/{tuiSummaryLlmCaller-UHZIPGAX.js → tuiSummaryLlmCaller-2J6NG53N.js} +24 -23
- package/{updateCommands-KZ54HCU5.js → updateCommands-5OYND6EF.js} +8 -6
- package/{updateDialogTitleAction-RV3EUEN3.js → updateDialogTitleAction-QCSN3RYO.js} +46 -43
- package/{usageCommand-KFVV6UL3.js → usageCommand-SK7JTEPC.js} +3 -3
- package/{usageRebuildCommand-HHFSNK46.js → usageRebuildCommand-DF3HUP6F.js} +4 -4
- package/webapi-QVV65DQF.js +2487 -0
- package/{windowsSelfUpdate-KERHIAB4.js → windowsSelfUpdate-HIYNL3VR.js} +2 -2
- package/workContext-Y3ADAPZU.js +14 -0
- package/workContextAccess-UZHDLBUR.js +11 -0
- package/workContextWriteNotice-YCSSMHN4.js +7 -0
- package/{workloadLifecycle-O2I3NZ2Q.js → workloadLifecycle-ZCSQCHG3.js} +9 -9
- package/agentListCommands-C65UESYM.js +0 -1004
- package/agentRecordCommands-6RCJS2EY.js +0 -176
- package/agentRunCommand-P3GRKXKS.js +0 -208
- package/chunk-2WZXXAQD.js +0 -57
- package/chunk-5ZMIIR23.js +0 -265
- package/chunk-62HXNQVV.js +0 -134
- package/chunk-BJF2MHJ3.js +0 -118
- package/chunk-KEPOVMF4.js +0 -91
- package/chunk-PXKF5CV4.js +0 -357
- package/chunk-WACI5I6V.js +0 -147
- package/chunk-YGILMZ7N.js +0 -81
- package/cliLocalAgentRecordReader-SPKAJYME.js +0 -90
- package/machineWsRunDispatch-BUUJRUUB.js +0 -191
- package/{accountResolver-EK2S4PWF.js → accountResolver-QETKNC7T.js} +4 -4
- package/{chunk-VXL2FZTP.js → chunk-HXER7YJF.js} +3 -3
- package/{chunk-BLVSFYQ3.js → chunk-LISC7BD4.js} +3 -3
- package/{chunk-SSGTV4FC.js → chunk-USGHJSGO.js} +5 -5
- package/{chunk-FJ23FZXF.js → chunk-VIYVRPMJ.js} +0 -0
- package/{offlineMarxistsAgentCommand-AGA2X5E4.js → offlineMarxistsAgentCommand-XVXUE6G5.js} +5 -5
|
@@ -1,45 +1,33 @@
|
|
|
1
|
+
import {
|
|
2
|
+
confirmMcpOnHost,
|
|
3
|
+
createConnectorApprovalPort,
|
|
4
|
+
createMcpLocalRuntimeAdapter,
|
|
5
|
+
getHostApprovalRenderer,
|
|
6
|
+
openMcpLocalRuntimeManagement,
|
|
7
|
+
parsePendingApprovalResult,
|
|
8
|
+
runConnectorToolWithHostApproval,
|
|
9
|
+
withHostApprovalRequest
|
|
10
|
+
} from "./chunk-53AEDFBL.js";
|
|
1
11
|
import {
|
|
2
12
|
BROWSER_SHELL_BRIDGE_ENV
|
|
3
13
|
} from "./chunk-2YGBI2XB.js";
|
|
4
|
-
import {
|
|
5
|
-
defaultLoopbackRequest
|
|
6
|
-
} from "./chunk-VP3BINY7.js";
|
|
7
|
-
import {
|
|
8
|
-
clearCredentialAvailability,
|
|
9
|
-
markCredentialUnavailable,
|
|
10
|
-
readCredentialEntry
|
|
11
|
-
} from "./chunk-FIYSMXHY.js";
|
|
12
|
-
import {
|
|
13
|
-
CREDENTIAL_STORE_SESSION_FALLBACK_WARNING,
|
|
14
|
-
OAUTH_PROVIDER_REFS,
|
|
15
|
-
getSharedSessionCredentialBroker
|
|
16
|
-
} from "./chunk-5LQDHFBN.js";
|
|
17
|
-
import {
|
|
18
|
-
customNativeAuthHeaders,
|
|
19
|
-
detectDeclaredCustomNativeWire,
|
|
20
|
-
isCallerCancellation,
|
|
21
|
-
resolveCustomNativeApiKeyHeader,
|
|
22
|
-
resolveCustomNativeEndpoint
|
|
23
|
-
} from "./chunk-WOAZVUSN.js";
|
|
24
14
|
import {
|
|
25
15
|
adoptRequiredClaudeCodeVersion,
|
|
26
16
|
anthropicRefresh,
|
|
27
17
|
cursorRefresh,
|
|
18
|
+
fetchAntigravityAvailableModels,
|
|
28
19
|
getClaudeCodeUserAgent,
|
|
29
20
|
refreshAntigravityOAuthToken,
|
|
30
21
|
refreshOpenAiCodexToken,
|
|
31
22
|
resolveClaudeCodeVersion,
|
|
32
23
|
resolveServerSyncConfig,
|
|
33
24
|
xaiRefresh
|
|
34
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-XGWRH3OF.js";
|
|
35
26
|
import {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
deliverDialogNotification,
|
|
41
|
-
sha256Hex
|
|
42
|
-
} from "./chunk-M3Y4IBIR.js";
|
|
27
|
+
clearCredentialAvailability,
|
|
28
|
+
markCredentialUnavailable,
|
|
29
|
+
readCredentialEntry
|
|
30
|
+
} from "./chunk-WWTSEBDF.js";
|
|
43
31
|
import {
|
|
44
32
|
SANDBOX_HELPER_PATH,
|
|
45
33
|
SANDBOX_OUTPUT_LIMITS,
|
|
@@ -48,7 +36,7 @@ import {
|
|
|
48
36
|
buildWorkspaceHelperSource,
|
|
49
37
|
dockerExecutionToolNames,
|
|
50
38
|
parseToolOutput
|
|
51
|
-
} from "./chunk-
|
|
39
|
+
} from "./chunk-VTHWBTRE.js";
|
|
52
40
|
import {
|
|
53
41
|
createChromeConnectorClientResolver,
|
|
54
42
|
createVerifiedChromeConnectorClient,
|
|
@@ -56,30 +44,35 @@ import {
|
|
|
56
44
|
validateChromeConnectorPayload
|
|
57
45
|
} from "./chunk-UAIHKQIA.js";
|
|
58
46
|
import {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
47
|
+
customNativeAuthHeaders,
|
|
48
|
+
detectDeclaredCustomNativeWire,
|
|
49
|
+
isCallerCancellation,
|
|
50
|
+
resolveCustomNativeApiKeyHeader,
|
|
51
|
+
resolveCustomNativeEndpoint
|
|
52
|
+
} from "./chunk-WOAZVUSN.js";
|
|
53
|
+
import {
|
|
54
|
+
DialogNotifyError,
|
|
55
|
+
deliverDialogNotification,
|
|
56
|
+
sha256Hex
|
|
57
|
+
} from "./chunk-OHUYN3YU.js";
|
|
64
58
|
import {
|
|
65
59
|
createTuiSummaryLlmCaller
|
|
66
|
-
} from "./chunk-
|
|
60
|
+
} from "./chunk-QIVE5WJE.js";
|
|
67
61
|
import {
|
|
68
62
|
CliProviderQuotaError,
|
|
69
63
|
executeCli,
|
|
70
64
|
executeCliStreaming
|
|
71
|
-
} from "./chunk-
|
|
65
|
+
} from "./chunk-R7XWZDOH.js";
|
|
66
|
+
import {
|
|
67
|
+
isCursorOAuthAgent
|
|
68
|
+
} from "./chunk-VIWDGTDA.js";
|
|
72
69
|
import {
|
|
73
70
|
buildCliPrompt
|
|
74
71
|
} from "./chunk-ATNTHIZI.js";
|
|
75
|
-
import {
|
|
76
|
-
inferCaptureIntent,
|
|
77
|
-
resolveUserSkillRuntime
|
|
78
|
-
} from "./chunk-PXKF5CV4.js";
|
|
79
72
|
import {
|
|
80
73
|
inlineImageUrlsForCustomProvider,
|
|
81
74
|
prepareTools
|
|
82
|
-
} from "./chunk-
|
|
75
|
+
} from "./chunk-W5OJBZLZ.js";
|
|
83
76
|
import {
|
|
84
77
|
getServerProviderSecret
|
|
85
78
|
} from "./chunk-HS7MLR74.js";
|
|
@@ -102,24 +95,25 @@ import {
|
|
|
102
95
|
resolveCliLocalSpawnDispatch,
|
|
103
96
|
resolveRunContextFacts,
|
|
104
97
|
resolveStartAgentRunCwd
|
|
105
|
-
} from "./chunk-
|
|
106
|
-
import {
|
|
107
|
-
fetchWithTransientRetry,
|
|
108
|
-
isTransientFetchError
|
|
109
|
-
} from "./chunk-KFHREHUQ.js";
|
|
98
|
+
} from "./chunk-J45ACAOQ.js";
|
|
110
99
|
import {
|
|
111
100
|
deriveCredentialGroup,
|
|
112
101
|
deriveCustomProviderCredentialGroup
|
|
113
|
-
} from "./chunk-
|
|
102
|
+
} from "./chunk-AO6T7U62.js";
|
|
103
|
+
import {
|
|
104
|
+
resolveUserSkillRuntime
|
|
105
|
+
} from "./chunk-NJJK3PDA.js";
|
|
114
106
|
import {
|
|
115
107
|
normalizeEnabledPromptSkills,
|
|
116
108
|
resolveUserEnabledSkills
|
|
117
|
-
} from "./chunk-
|
|
109
|
+
} from "./chunk-6PXFEPHL.js";
|
|
118
110
|
import {
|
|
119
|
-
prepareTokenUsageData,
|
|
120
|
-
runKeyed,
|
|
121
111
|
validateAskChoiceInput
|
|
122
|
-
} from "./chunk-
|
|
112
|
+
} from "./chunk-RDPAIR67.js";
|
|
113
|
+
import {
|
|
114
|
+
prepareTokenUsageData,
|
|
115
|
+
runKeyed
|
|
116
|
+
} from "./chunk-ZP26NIZE.js";
|
|
123
117
|
import {
|
|
124
118
|
applyTokenUsageToDayStats,
|
|
125
119
|
require_format
|
|
@@ -130,7 +124,20 @@ import {
|
|
|
130
124
|
} from "./chunk-523DITKR.js";
|
|
131
125
|
import {
|
|
132
126
|
fetchServerSyncedCredential
|
|
133
|
-
} from "./chunk-
|
|
127
|
+
} from "./chunk-22YUCKMK.js";
|
|
128
|
+
import {
|
|
129
|
+
defaultLoopbackRequest,
|
|
130
|
+
loadLocalRunChildDialogIds
|
|
131
|
+
} from "./chunk-EQZZASCD.js";
|
|
132
|
+
import {
|
|
133
|
+
CREDENTIAL_STORE_SESSION_FALLBACK_WARNING,
|
|
134
|
+
OAUTH_PROVIDER_REFS,
|
|
135
|
+
getSharedSessionCredentialBroker
|
|
136
|
+
} from "./chunk-IDFGIROZ.js";
|
|
137
|
+
import {
|
|
138
|
+
fetchWithTransientRetry,
|
|
139
|
+
isTransientFetchError
|
|
140
|
+
} from "./chunk-DXWGFL2Z.js";
|
|
134
141
|
import {
|
|
135
142
|
_readQueueEntriesLocked,
|
|
136
143
|
ackRunRecord,
|
|
@@ -139,6 +146,7 @@ import {
|
|
|
139
146
|
checkStaleRun,
|
|
140
147
|
claimRunRecord,
|
|
141
148
|
commitRunRecordClaim,
|
|
149
|
+
defaultGenerateRunId,
|
|
142
150
|
findRunRecord,
|
|
143
151
|
gcRunRecords,
|
|
144
152
|
isRunTerminalStatus,
|
|
@@ -155,12 +163,7 @@ import {
|
|
|
155
163
|
terminateRunProcess,
|
|
156
164
|
transitionRunToTerminal,
|
|
157
165
|
withQueueLock
|
|
158
|
-
} from "./chunk-
|
|
159
|
-
import {
|
|
160
|
-
remoteDialogSyncTimeout,
|
|
161
|
-
resolveRuntimeAuthToken,
|
|
162
|
-
resolveRuntimeServerUrl
|
|
163
|
-
} from "./chunk-UN7HIYMH.js";
|
|
166
|
+
} from "./chunk-XKV53E4E.js";
|
|
164
167
|
import {
|
|
165
168
|
TASK_PREVIEW_MAX,
|
|
166
169
|
formatControlRunMessageCard,
|
|
@@ -177,24 +180,22 @@ import {
|
|
|
177
180
|
resolveAgentRunName,
|
|
178
181
|
resolveRunLabel,
|
|
179
182
|
shortRunId
|
|
180
|
-
} from "./chunk-
|
|
183
|
+
} from "./chunk-S25VJYXV.js";
|
|
181
184
|
import {
|
|
182
185
|
getDefaultCliLocalRuntimeDb
|
|
183
|
-
} from "./chunk-
|
|
184
|
-
import {
|
|
185
|
-
isTombstoneRecord
|
|
186
|
-
} from "./chunk-BV3FLP2L.js";
|
|
186
|
+
} from "./chunk-LELADM5Q.js";
|
|
187
187
|
import {
|
|
188
188
|
readAgentFromStore,
|
|
189
189
|
readDialogMessageRecords,
|
|
190
190
|
readDialogMessages,
|
|
191
191
|
resolveBuiltinLocalCliAgentConfig
|
|
192
|
-
} from "./chunk-
|
|
192
|
+
} from "./chunk-6YYTTLJV.js";
|
|
193
193
|
import {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
194
|
+
applyPublicAgentCatalogOverride
|
|
195
|
+
} from "./chunk-MZVCFV3T.js";
|
|
196
|
+
import {
|
|
197
|
+
applyBuiltinAgentRuntimeOverride
|
|
198
|
+
} from "./chunk-JP2BH4NC.js";
|
|
198
199
|
import {
|
|
199
200
|
DEFAULT_HYBRID_READ_TIMEOUT_MS,
|
|
200
201
|
Duration_exports,
|
|
@@ -211,26 +212,27 @@ import {
|
|
|
211
212
|
buildNoloWorkspaceCliToolExecutors,
|
|
212
213
|
codexStreamFailureStatus,
|
|
213
214
|
createDevinProvider,
|
|
214
|
-
createHostCredentialBrokerChain,
|
|
215
215
|
createHybridRecordStore,
|
|
216
216
|
createLocalWorkspaceToolExecutors,
|
|
217
217
|
createResponsesStreamCollector,
|
|
218
|
-
createStrictHostCredentialBroker,
|
|
219
218
|
deriveStableUuid,
|
|
220
219
|
describeOpenAiCompatibleRequestBudget,
|
|
221
|
-
dialogMessageRecordToAgentRuntimeMessage,
|
|
222
220
|
executeLocalToolWithPolicy,
|
|
223
221
|
executeOpenAiCompatibleChatCompletion,
|
|
224
222
|
filterRetainedLedgerRecords,
|
|
223
|
+
filterToolNamesForRunKind,
|
|
225
224
|
getAgentRuntimeToolParametersIndex,
|
|
226
225
|
getLocalShellLifecycle,
|
|
226
|
+
hasRunWakeChannel,
|
|
227
227
|
hashToolDefinitions,
|
|
228
228
|
internalListWorkspaceEntries,
|
|
229
229
|
internalSearchWorkspace,
|
|
230
230
|
isCommandExecutingTool,
|
|
231
231
|
isLineRangeCovered,
|
|
232
232
|
isStableSessionIdentityEnabled,
|
|
233
|
+
isSubtaskRun,
|
|
233
234
|
normalizeLocalToolName,
|
|
235
|
+
orderDialogHistory,
|
|
234
236
|
parseSyncServersEnv,
|
|
235
237
|
projectToolExecutionLocation,
|
|
236
238
|
readDevinUpstreamFailure,
|
|
@@ -244,11 +246,16 @@ import {
|
|
|
244
246
|
runExecShellGates,
|
|
245
247
|
validateConfiguredRootExecutionLease,
|
|
246
248
|
verifyOwnerRouteAck
|
|
247
|
-
} from "./chunk-
|
|
249
|
+
} from "./chunk-F4XIS5DL.js";
|
|
250
|
+
import {
|
|
251
|
+
createHostCredentialBrokerChain,
|
|
252
|
+
createStrictHostCredentialBroker
|
|
253
|
+
} from "./chunk-LHCGKAFO.js";
|
|
248
254
|
import {
|
|
249
255
|
accumulateGeminiChunks,
|
|
250
256
|
buildGeminiGenerateContentRequest,
|
|
251
257
|
fetchAntigravityCloudCodeCompletion,
|
|
258
|
+
hasAssembledAgentPrompt,
|
|
252
259
|
isGemini3Model,
|
|
253
260
|
parseSseDataLineJson,
|
|
254
261
|
parseSseDataLineObject,
|
|
@@ -256,7 +263,10 @@ import {
|
|
|
256
263
|
resolveAntigravityFinishReason,
|
|
257
264
|
resolveGeminiModelQuirks,
|
|
258
265
|
shouldUseGeminiNativeToolRoute
|
|
259
|
-
} from "./chunk-
|
|
266
|
+
} from "./chunk-MYYNZG2M.js";
|
|
267
|
+
import {
|
|
268
|
+
readLocalImage
|
|
269
|
+
} from "./chunk-AL3TYDIF.js";
|
|
260
270
|
import {
|
|
261
271
|
PlatformStreamInterruptedError,
|
|
262
272
|
buildPlatformChatCompletionRequest,
|
|
@@ -268,54 +278,64 @@ import {
|
|
|
268
278
|
readPlatformChatSseCompletion,
|
|
269
279
|
resolvePlatformChatProviderConfig,
|
|
270
280
|
shouldUsePlatformChatProvider
|
|
271
|
-
} from "./chunk-
|
|
281
|
+
} from "./chunk-EDT65EUE.js";
|
|
272
282
|
import {
|
|
273
283
|
readSseDataValues,
|
|
274
284
|
readSseFrames
|
|
275
285
|
} from "./chunk-HNUWUO75.js";
|
|
276
286
|
import {
|
|
277
|
-
|
|
278
|
-
} from "./chunk-
|
|
279
|
-
import {
|
|
280
|
-
resolveToolImagePolicy
|
|
281
|
-
} from "./chunk-3HTP4WZQ.js";
|
|
287
|
+
resolveAgentRuntimeConfigFromRecord
|
|
288
|
+
} from "./chunk-4OXPN3WC.js";
|
|
282
289
|
import {
|
|
283
290
|
assertDispatchSelectionAdmission,
|
|
284
291
|
buildNoloWorkspaceOpenAiTools,
|
|
285
292
|
filterClientNoloWorkspaceToolNames,
|
|
286
293
|
parseNoloWorkspaceToolArguments
|
|
287
|
-
} from "./chunk-
|
|
294
|
+
} from "./chunk-LOF2EFUE.js";
|
|
295
|
+
import {
|
|
296
|
+
MCP_TOOL_NAMES
|
|
297
|
+
} from "./chunk-FDZ2GBWO.js";
|
|
288
298
|
import {
|
|
289
299
|
extractQuotaSnapshot,
|
|
290
300
|
isCapacitySaturatedRateLimit,
|
|
291
301
|
mergeAvailabilityDeadline,
|
|
292
302
|
resolveAvailabilityAction,
|
|
293
303
|
resolveCredentialKeyWithFallback
|
|
294
|
-
} from "./chunk-
|
|
295
|
-
import {
|
|
296
|
-
HIGH_RISK_MUTATION_TOOL_NAMES,
|
|
297
|
-
resolveRequestToolSurface
|
|
298
|
-
} from "./chunk-IC2I373Q.js";
|
|
304
|
+
} from "./chunk-QJTZ76CP.js";
|
|
299
305
|
import {
|
|
300
306
|
collectStablePromptPrefix,
|
|
301
307
|
convertMessagesToResponsesInput,
|
|
302
308
|
findAgentStatePairingIssues,
|
|
303
309
|
stablePromptCacheKey,
|
|
304
310
|
toResponsesTools
|
|
305
|
-
} from "./chunk-
|
|
311
|
+
} from "./chunk-W3HSD32M.js";
|
|
306
312
|
import {
|
|
307
313
|
EMPTY_TOOL_RESULT_TEXT,
|
|
314
|
+
MAX_TOOL_IMAGES_PER_REQUEST,
|
|
315
|
+
MAX_TOOL_IMAGE_BASE64_BYTES_PER_REQUEST,
|
|
308
316
|
createToolImageBudget,
|
|
309
317
|
hadToolImages,
|
|
310
318
|
toolImageNotices,
|
|
311
319
|
toolImageOmission,
|
|
312
320
|
toolImageSource,
|
|
313
321
|
toolImages
|
|
314
|
-
} from "./chunk-
|
|
322
|
+
} from "./chunk-X4O7FJF5.js";
|
|
323
|
+
import {
|
|
324
|
+
resolveAgentImageInputSupport,
|
|
325
|
+
resolveCatalogImageSupport,
|
|
326
|
+
resolveToolImagePolicy,
|
|
327
|
+
withLiveImageSupport
|
|
328
|
+
} from "./chunk-SX6AWTNK.js";
|
|
329
|
+
import {
|
|
330
|
+
resolveHistoricalToolContentCap
|
|
331
|
+
} from "./chunk-WFGNWWJI.js";
|
|
332
|
+
import {
|
|
333
|
+
resolveAgentCallPlan
|
|
334
|
+
} from "./chunk-VUHKG4KS.js";
|
|
315
335
|
import {
|
|
316
336
|
resolveAgentRequiredPackIds,
|
|
317
337
|
resolveAgentSkillConfig
|
|
318
|
-
} from "./chunk-
|
|
338
|
+
} from "./chunk-JV5FHHF7.js";
|
|
319
339
|
import {
|
|
320
340
|
buildDialogFallbackTitleFromUserInput,
|
|
321
341
|
normalizeDialogTitle
|
|
@@ -329,13 +349,14 @@ import {
|
|
|
329
349
|
isCodexOAuthAgent,
|
|
330
350
|
markCodexOAuthCatalogFailure,
|
|
331
351
|
resolveCodexOAuthEffectiveModel
|
|
332
|
-
} from "./chunk-
|
|
352
|
+
} from "./chunk-LTVEOOZL.js";
|
|
333
353
|
import {
|
|
334
354
|
isDevinOAuthAgent
|
|
335
355
|
} from "./chunk-5ZUL4CUO.js";
|
|
336
356
|
import {
|
|
337
|
-
normalizeUsage
|
|
338
|
-
|
|
357
|
+
normalizeUsage,
|
|
358
|
+
sanitizeSummarySourceSegments
|
|
359
|
+
} from "./chunk-MAA42MMV.js";
|
|
339
360
|
import {
|
|
340
361
|
createProviderCallTimingTracker,
|
|
341
362
|
finalizeProviderCallTiming,
|
|
@@ -353,32 +374,34 @@ import {
|
|
|
353
374
|
resolveCurrentRunRuntimeToolPolicy,
|
|
354
375
|
resolveLocalWorkspaceExecutorOptionsFromPolicy,
|
|
355
376
|
resolveRequestedRuntimeToolNames
|
|
356
|
-
} from "./chunk-
|
|
357
|
-
import {
|
|
358
|
-
asRecordOrEmpty
|
|
359
|
-
} from "./chunk-KX6YBIHG.js";
|
|
377
|
+
} from "./chunk-USGHJSGO.js";
|
|
360
378
|
import {
|
|
361
379
|
createFileCredentialBroker
|
|
362
|
-
} from "./chunk-
|
|
380
|
+
} from "./chunk-E6A5NHDH.js";
|
|
363
381
|
import {
|
|
364
|
-
|
|
365
|
-
} from "./chunk-
|
|
382
|
+
asRecordOrEmpty
|
|
383
|
+
} from "./chunk-KX6YBIHG.js";
|
|
366
384
|
import {
|
|
367
385
|
withShellChildEnvironment
|
|
368
|
-
} from "./chunk-
|
|
386
|
+
} from "./chunk-TB5KTLNB.js";
|
|
369
387
|
import {
|
|
370
388
|
estimateTokenCount
|
|
371
389
|
} from "./chunk-PSCNXBYA.js";
|
|
372
390
|
import {
|
|
373
|
-
|
|
374
|
-
} from "./chunk-
|
|
391
|
+
compactWhitespace
|
|
392
|
+
} from "./chunk-DWLEOOGR.js";
|
|
375
393
|
import {
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
394
|
+
createOAuthTokenStore,
|
|
395
|
+
isTokenExpired,
|
|
396
|
+
readOAuthCredential,
|
|
397
|
+
resolveFreshAccessToken
|
|
398
|
+
} from "./chunk-G7Y4GXTY.js";
|
|
379
399
|
import {
|
|
380
|
-
|
|
381
|
-
} from "./chunk-
|
|
400
|
+
isTombstoneRecord
|
|
401
|
+
} from "./chunk-BV3FLP2L.js";
|
|
402
|
+
import {
|
|
403
|
+
dialogMessageRecordToAgentRuntimeMessage
|
|
404
|
+
} from "./chunk-4ZCTKB27.js";
|
|
382
405
|
import {
|
|
383
406
|
FORCED_TOOLS,
|
|
384
407
|
addDefaultLightWebToolsForConfiguredAgents,
|
|
@@ -390,85 +413,134 @@ import {
|
|
|
390
413
|
expandEnabledPacks,
|
|
391
414
|
resolveBuiltinSkillEntry,
|
|
392
415
|
resolveEffectiveEnabledPacks
|
|
393
|
-
} from "./chunk-
|
|
416
|
+
} from "./chunk-TKE4OJ4B.js";
|
|
394
417
|
import {
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
418
|
+
DIALOG_AGENT_LIST_INDEX_PREFIX,
|
|
419
|
+
TOKEN_DIALOG_INDEX_PREFIX,
|
|
420
|
+
createTokenDialogIndexKey,
|
|
421
|
+
createTokenKey,
|
|
422
|
+
createTokenStatsKey,
|
|
423
|
+
createUserKey,
|
|
424
|
+
isTokenStatsKey
|
|
425
|
+
} from "./chunk-SYTHYBMI.js";
|
|
399
426
|
import {
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
isAdaptiveThinkingModelId
|
|
403
|
-
} from "./chunk-KYH7XW3K.js";
|
|
427
|
+
dialogMessageKey
|
|
428
|
+
} from "./chunk-OJKUU3LP.js";
|
|
404
429
|
import {
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
} from "./chunk-JRTNUU5Z.js";
|
|
430
|
+
dialogIdFromKey
|
|
431
|
+
} from "./chunk-YZMNK53S.js";
|
|
408
432
|
import {
|
|
409
|
-
|
|
410
|
-
|
|
433
|
+
extractLastUserText,
|
|
434
|
+
localTurnHasSubjectRefs,
|
|
435
|
+
resolveLocalUserId,
|
|
436
|
+
withResolvedRuntimeToolSurface
|
|
437
|
+
} from "./chunk-UPOW5HTG.js";
|
|
411
438
|
import {
|
|
412
|
-
|
|
413
|
-
|
|
439
|
+
LOCAL_CODEX_AGENT_KEY,
|
|
440
|
+
isLocalCliAgentKey,
|
|
441
|
+
resolveCliAgentKeyInput
|
|
442
|
+
} from "./chunk-BR3GT6MR.js";
|
|
443
|
+
import {
|
|
444
|
+
HIGH_RISK_MUTATION_TOOL_NAMES,
|
|
445
|
+
resolveRequestToolSurface
|
|
446
|
+
} from "./chunk-NEG5LYK5.js";
|
|
447
|
+
import {
|
|
448
|
+
remoteDialogSyncTimeout,
|
|
449
|
+
resolveRuntimeAuthToken,
|
|
450
|
+
resolveRuntimeServerUrl
|
|
451
|
+
} from "./chunk-GX6DITLQ.js";
|
|
452
|
+
import {
|
|
453
|
+
CHROME_CONNECTOR_ACCEPTED_TOOL_NAMES,
|
|
454
|
+
canonicalizeChromeConnectorToolNames,
|
|
455
|
+
canonicalizeToolNames
|
|
456
|
+
} from "./chunk-YLAHYLDQ.js";
|
|
457
|
+
import {
|
|
458
|
+
asOptionalPositiveFiniteNumber
|
|
459
|
+
} from "./chunk-U6VC4MU4.js";
|
|
414
460
|
import {
|
|
415
461
|
classifyDialogSyncFailure,
|
|
416
462
|
getLogger,
|
|
417
463
|
startOwnedDialogSync
|
|
418
|
-
} from "./chunk-
|
|
464
|
+
} from "./chunk-6XRPBZRS.js";
|
|
419
465
|
import {
|
|
466
|
+
getHostRuntimeExecutable,
|
|
420
467
|
isCompiledBinary,
|
|
421
468
|
parseUserIdFromAuthToken,
|
|
422
469
|
resolveAuthToken,
|
|
423
470
|
resolveServerUrl
|
|
424
|
-
} from "./chunk-
|
|
471
|
+
} from "./chunk-BIDSIRTS.js";
|
|
425
472
|
import {
|
|
426
473
|
DEFAULT_NOLO_SERVER_URL
|
|
427
474
|
} from "./chunk-OLZBQWZU.js";
|
|
428
475
|
import {
|
|
429
476
|
NOLO_CLUSTER_SERVERS
|
|
430
477
|
} from "./chunk-LCBAMY2M.js";
|
|
431
|
-
import {
|
|
432
|
-
isLoopbackUrl
|
|
433
|
-
} from "./chunk-4SN6J65J.js";
|
|
434
|
-
import {
|
|
435
|
-
normalizeServerOrigin
|
|
436
|
-
} from "./chunk-CF7PE763.js";
|
|
437
478
|
import {
|
|
438
479
|
agentRunCardLabels,
|
|
439
480
|
t
|
|
440
|
-
} from "./chunk-
|
|
481
|
+
} from "./chunk-OGZE6BZG.js";
|
|
441
482
|
import {
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
readOAuthCredential,
|
|
445
|
-
resolveFreshAccessToken
|
|
446
|
-
} from "./chunk-G7Y4GXTY.js";
|
|
447
|
-
import {
|
|
448
|
-
createTokenDialogIndexKey,
|
|
449
|
-
createTokenKey,
|
|
450
|
-
createTokenStatsKey,
|
|
451
|
-
createUserKey
|
|
452
|
-
} from "./chunk-SYTHYBMI.js";
|
|
483
|
+
isAntigravityOAuthAgent
|
|
484
|
+
} from "./chunk-CTWCZKNS.js";
|
|
453
485
|
import {
|
|
454
|
-
|
|
455
|
-
} from "./chunk-
|
|
486
|
+
toErrorMessage
|
|
487
|
+
} from "./chunk-HNMXYYJR.js";
|
|
456
488
|
import {
|
|
457
|
-
|
|
458
|
-
|
|
489
|
+
buildProviderSessionHeaders,
|
|
490
|
+
resolvePlatformAuthToken
|
|
491
|
+
} from "./chunk-K26XPZRB.js";
|
|
459
492
|
import {
|
|
460
493
|
asTrimmedString
|
|
461
494
|
} from "./chunk-3EUW3WEO.js";
|
|
462
495
|
import {
|
|
463
|
-
|
|
464
|
-
|
|
496
|
+
anthropicOAuthModelMaxOutputTokens,
|
|
497
|
+
findModelConfig,
|
|
498
|
+
isAdaptiveThinkingModelId
|
|
499
|
+
} from "./chunk-CD2DK5JA.js";
|
|
500
|
+
import {
|
|
501
|
+
CLI_PROVIDER_VALUES,
|
|
502
|
+
isCliProvider
|
|
503
|
+
} from "./chunk-JRTNUU5Z.js";
|
|
504
|
+
import {
|
|
505
|
+
isRecord
|
|
506
|
+
} from "./chunk-KUG52IAP.js";
|
|
465
507
|
import {
|
|
466
508
|
asOptionalTrimmedString
|
|
467
509
|
} from "./chunk-G3SUCT4W.js";
|
|
510
|
+
import {
|
|
511
|
+
isLoopbackUrl
|
|
512
|
+
} from "./chunk-4SN6J65J.js";
|
|
513
|
+
import {
|
|
514
|
+
normalizeServerOrigin
|
|
515
|
+
} from "./chunk-CF7PE763.js";
|
|
516
|
+
import {
|
|
517
|
+
asTrimmedLowercaseString
|
|
518
|
+
} from "./chunk-QSJ3HFEF.js";
|
|
468
519
|
import {
|
|
469
520
|
__toESM
|
|
470
521
|
} from "./chunk-U67V476Y.js";
|
|
471
522
|
|
|
523
|
+
// packages/cli/client/liveImageSupport.ts
|
|
524
|
+
function createLiveImageSupportResolver(userId, discover, timeoutMs = 5e3) {
|
|
525
|
+
let discovery;
|
|
526
|
+
return async (config) => {
|
|
527
|
+
if (resolveCatalogImageSupport(config) !== void 0) return config;
|
|
528
|
+
const plan = resolveAgentCallPlan({ ...config, key: config.key ?? "" });
|
|
529
|
+
if (plan.authMethod.kind !== "oauth" || plan.authMethod.ref !== "antigravity") return config;
|
|
530
|
+
const raw = config.rawRecord ?? config;
|
|
531
|
+
const owner = typeof raw.userId === "string" && raw.userId.trim() ? raw.userId.trim() : typeof raw.ownerUserId === "string" ? raw.ownerUserId.trim() : void 0;
|
|
532
|
+
if (!userId || owner !== userId) return withLiveImageSupport(config, false);
|
|
533
|
+
discovery ??= new Promise((resolve8) => {
|
|
534
|
+
const timer = setTimeout(() => resolve8({}), timeoutMs);
|
|
535
|
+
Promise.resolve().then(discover).then(resolve8, () => resolve8({})).finally(() => clearTimeout(timer));
|
|
536
|
+
});
|
|
537
|
+
const models = await discovery;
|
|
538
|
+
const model = config.model?.trim() ?? "";
|
|
539
|
+
const entry = Object.hasOwn(models, model) ? models[model] : void 0;
|
|
540
|
+
return withLiveImageSupport(config, entry?.supportsImages === true && entry.disabled !== true);
|
|
541
|
+
};
|
|
542
|
+
}
|
|
543
|
+
|
|
472
544
|
// packages/agent-runtime/anthropicMessagesProvider.ts
|
|
473
545
|
import { randomUUID } from "node:crypto";
|
|
474
546
|
|
|
@@ -856,7 +928,7 @@ function buildAnthropicMessagesBody(args) {
|
|
|
856
928
|
const mode = resolveCacheMode();
|
|
857
929
|
const rawMessages = Array.isArray(args.openAiBody.messages) ? args.openAiBody.messages : [];
|
|
858
930
|
const system = [];
|
|
859
|
-
if (args.agentConfig.prompt?.trim()) {
|
|
931
|
+
if (!hasAssembledAgentPrompt(rawMessages) && args.agentConfig.prompt?.trim()) {
|
|
860
932
|
system.push({ type: "text", text: args.agentConfig.prompt.trim() });
|
|
861
933
|
}
|
|
862
934
|
const messages = [];
|
|
@@ -1201,6 +1273,57 @@ function clearCliLocalRuntimePreparedAgentCache() {
|
|
|
1201
1273
|
preparedAgentRuntimeCache.clear();
|
|
1202
1274
|
hybridStoreCache.clear();
|
|
1203
1275
|
}
|
|
1276
|
+
var SCALAR_AGENT_CONFIG_FINGERPRINT_FIELDS = [
|
|
1277
|
+
"apiSource",
|
|
1278
|
+
"customProviderUrl",
|
|
1279
|
+
"model",
|
|
1280
|
+
"name",
|
|
1281
|
+
"prompt",
|
|
1282
|
+
"provider",
|
|
1283
|
+
"revision",
|
|
1284
|
+
"updatedAt",
|
|
1285
|
+
"version"
|
|
1286
|
+
];
|
|
1287
|
+
var TOOL_LIST_FINGERPRINT_FIELDS = ["toolNames", "tools"];
|
|
1288
|
+
function extractFingerprintToolNames(raw) {
|
|
1289
|
+
if (!Array.isArray(raw)) return void 0;
|
|
1290
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1291
|
+
for (const value of raw) {
|
|
1292
|
+
const rawName = typeof value === "string" ? value : value && typeof value === "object" && !Array.isArray(value) ? typeof value.name === "string" ? value.name : value.function && typeof value.function === "object" && !Array.isArray(value.function) && typeof value.function.name === "string" ? value.function.name : "" : "";
|
|
1293
|
+
const trimmed = rawName.trim();
|
|
1294
|
+
if (trimmed) seen.add(trimmed);
|
|
1295
|
+
}
|
|
1296
|
+
return [...seen].sort((a, b) => a.localeCompare(b));
|
|
1297
|
+
}
|
|
1298
|
+
function buildLocalAgentConfigFingerprint(source) {
|
|
1299
|
+
const record = source && typeof source === "object" ? source : null;
|
|
1300
|
+
const payload = {
|
|
1301
|
+
skillPolicy: Object.entries(resolveAgentSkillConfig(record)).sort(
|
|
1302
|
+
([a], [b]) => a.localeCompare(b)
|
|
1303
|
+
)
|
|
1304
|
+
};
|
|
1305
|
+
if (record) {
|
|
1306
|
+
for (const field of SCALAR_AGENT_CONFIG_FINGERPRINT_FIELDS) {
|
|
1307
|
+
if (!Object.prototype.hasOwnProperty.call(record, field)) continue;
|
|
1308
|
+
const value = record[field];
|
|
1309
|
+
if (typeof value === "string" || typeof value === "number" && Number.isFinite(value) || typeof value === "boolean") {
|
|
1310
|
+
payload[field] = value;
|
|
1311
|
+
}
|
|
1312
|
+
}
|
|
1313
|
+
for (const field of TOOL_LIST_FINGERPRINT_FIELDS) {
|
|
1314
|
+
if (!Object.prototype.hasOwnProperty.call(record, field)) continue;
|
|
1315
|
+
const names = extractFingerprintToolNames(record[field]);
|
|
1316
|
+
if (names !== void 0) {
|
|
1317
|
+
payload[field] = names;
|
|
1318
|
+
}
|
|
1319
|
+
}
|
|
1320
|
+
}
|
|
1321
|
+
const ordered = {};
|
|
1322
|
+
for (const key of Object.keys(payload).sort((a, b) => a.localeCompare(b))) {
|
|
1323
|
+
ordered[key] = payload[key];
|
|
1324
|
+
}
|
|
1325
|
+
return JSON.stringify(ordered);
|
|
1326
|
+
}
|
|
1204
1327
|
async function defaultLocalRuntimeDb() {
|
|
1205
1328
|
return getDefaultCliLocalRuntimeDb();
|
|
1206
1329
|
}
|
|
@@ -1257,44 +1380,6 @@ var REGISTRY_INJECTED_TOOL_NAMES = /* @__PURE__ */ new Set([
|
|
|
1257
1380
|
"read_xhs_profile"
|
|
1258
1381
|
]);
|
|
1259
1382
|
|
|
1260
|
-
// packages/agent-runtime/agentRunIsolation.ts
|
|
1261
|
-
var ORCHESTRATION_TOOL_NAMES = /* @__PURE__ */ new Set([
|
|
1262
|
-
"startAgentRun",
|
|
1263
|
-
"controlAgentRun",
|
|
1264
|
-
"listAgents",
|
|
1265
|
-
"readAgent",
|
|
1266
|
-
"runStreamingAgent"
|
|
1267
|
-
]);
|
|
1268
|
-
var INTERACTION_REQUIRED_TOOL_NAMES = /* @__PURE__ */ new Set([
|
|
1269
|
-
"ask_user",
|
|
1270
|
-
// 凭据请求:需要宿主交互面板(Block 1a);desktop 无通道时同 ask_user 剥离。
|
|
1271
|
-
"secret-request"
|
|
1272
|
-
]);
|
|
1273
|
-
var SELF_MUTATION_TOOL_NAMES = /* @__PURE__ */ new Set([
|
|
1274
|
-
"updateSelf",
|
|
1275
|
-
"updateAgent"
|
|
1276
|
-
]);
|
|
1277
|
-
var SUBTASK_REMOVED_TOOL_NAMES = /* @__PURE__ */ new Set([
|
|
1278
|
-
...ORCHESTRATION_TOOL_NAMES,
|
|
1279
|
-
...INTERACTION_REQUIRED_TOOL_NAMES,
|
|
1280
|
-
...SELF_MUTATION_TOOL_NAMES
|
|
1281
|
-
]);
|
|
1282
|
-
function isSubtaskRun(env) {
|
|
1283
|
-
if (!env) return false;
|
|
1284
|
-
const value = env.NOLO_AGENT_RUN_CHILD;
|
|
1285
|
-
return typeof value === "string" && value.length > 0 && value !== "0";
|
|
1286
|
-
}
|
|
1287
|
-
var RUN_WAKE_CHANNEL_ENV = "NOLO_RUN_WAKE";
|
|
1288
|
-
function hasRunWakeChannel(env) {
|
|
1289
|
-
if (!env) return false;
|
|
1290
|
-
const value = env[RUN_WAKE_CHANNEL_ENV];
|
|
1291
|
-
return typeof value === "string" && value.length > 0 && value !== "0";
|
|
1292
|
-
}
|
|
1293
|
-
function filterToolNamesForRunKind(toolNames, isSubtask) {
|
|
1294
|
-
if (!isSubtask) return [...toolNames];
|
|
1295
|
-
return toolNames.filter((name) => !SUBTASK_REMOVED_TOOL_NAMES.has(name));
|
|
1296
|
-
}
|
|
1297
|
-
|
|
1298
1383
|
// packages/cli/client/localRuntimeTools.ts
|
|
1299
1384
|
var CLI_CHROME_CONNECTOR_TOOL_NAME_SET = new Set(
|
|
1300
1385
|
CHROME_CONNECTOR_ACCEPTED_TOOL_NAMES
|
|
@@ -1467,7 +1552,7 @@ function resolveCliRequestedToolNames(agentConfig, env, systemBuiltinSkills) {
|
|
|
1467
1552
|
filtered,
|
|
1468
1553
|
agentConfig?.disabledTools
|
|
1469
1554
|
);
|
|
1470
|
-
return filterToolNamesForRunKind(afterDisabled, isSubtask);
|
|
1555
|
+
return filterToolNamesForRunKind(afterDisabled.filter((name) => !MCP_TOOL_NAMES.includes(name) || agentConfig.key === "agent-0e95801d90-gpt-6-1-sol" && Array.isArray(agentConfig.toolNames) && agentConfig.toolNames.includes(name)), isSubtask);
|
|
1471
1556
|
}
|
|
1472
1557
|
function resolveProviderOpenAiToolBundle(agentConfig, env, buildTools = buildOpenAiTools, additionalToolNames = []) {
|
|
1473
1558
|
const requestedToolNames = [
|
|
@@ -1495,6 +1580,7 @@ function buildLocalWorkspaceToolsetForEnv(args) {
|
|
|
1495
1580
|
return toolset;
|
|
1496
1581
|
}
|
|
1497
1582
|
function buildLocalPolicyToolNames(args) {
|
|
1583
|
+
if (args.toolNames?.length === 0) return [];
|
|
1498
1584
|
const schemaBuilder = args.buildProviderOpenAiTools ?? buildOpenAiTools;
|
|
1499
1585
|
const tools = schemaBuilder({
|
|
1500
1586
|
agentKey: args.agentKey,
|
|
@@ -2409,7 +2495,7 @@ var resolveCliProviderTransport = async (ctx) => {
|
|
|
2409
2495
|
import { createHash } from "node:crypto";
|
|
2410
2496
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
2411
2497
|
var CODEX_RESPONSES_URL = "https://chatgpt.com/backend-api/codex/responses";
|
|
2412
|
-
var CODEX_CLIENT_VERSION = "0.
|
|
2498
|
+
var CODEX_CLIENT_VERSION = "0.169.0";
|
|
2413
2499
|
var CODEX_ORIGINATOR = "codex_cli_rs";
|
|
2414
2500
|
var CODEX_OPENAI_BETA = "responses=experimental";
|
|
2415
2501
|
var OPENAI_AUTH_CLAIM = "https://api.openai.com/auth";
|
|
@@ -2540,8 +2626,9 @@ function buildCodexRequestBody(args, identity = createCodexRequestIdentity(), se
|
|
|
2540
2626
|
routeKind: "codex/responses",
|
|
2541
2627
|
legacySupportsToolImages: false
|
|
2542
2628
|
}));
|
|
2543
|
-
const
|
|
2544
|
-
const
|
|
2629
|
+
const fallbackPrompt = hasAssembledAgentPrompt(rawMessages) ? void 0 : args.agentConfig.prompt;
|
|
2630
|
+
const instructions = collectInstructions(rawMessages, fallbackPrompt);
|
|
2631
|
+
const stableInstructions = collectStablePromptPrefix(rawMessages, fallbackPrompt);
|
|
2545
2632
|
const tools = toResponsesTools(
|
|
2546
2633
|
Array.isArray(args.openAiBody.tools) ? args.openAiBody.tools : void 0
|
|
2547
2634
|
);
|
|
@@ -2593,7 +2680,7 @@ function throwIfAborted(signal) {
|
|
|
2593
2680
|
}
|
|
2594
2681
|
function waitBackoff(ms, signal, injectedSleep) {
|
|
2595
2682
|
throwIfAborted(signal);
|
|
2596
|
-
return new Promise((
|
|
2683
|
+
return new Promise((resolve8, reject) => {
|
|
2597
2684
|
let timer;
|
|
2598
2685
|
const cleanup = () => {
|
|
2599
2686
|
signal?.removeEventListener("abort", onAbort);
|
|
@@ -2608,7 +2695,7 @@ function waitBackoff(ms, signal, injectedSleep) {
|
|
|
2608
2695
|
injectedSleep(ms).then(
|
|
2609
2696
|
() => {
|
|
2610
2697
|
cleanup();
|
|
2611
|
-
|
|
2698
|
+
resolve8();
|
|
2612
2699
|
},
|
|
2613
2700
|
(error) => {
|
|
2614
2701
|
cleanup();
|
|
@@ -2618,7 +2705,7 @@ function waitBackoff(ms, signal, injectedSleep) {
|
|
|
2618
2705
|
} else {
|
|
2619
2706
|
timer = setTimeout(() => {
|
|
2620
2707
|
cleanup();
|
|
2621
|
-
|
|
2708
|
+
resolve8();
|
|
2622
2709
|
}, ms);
|
|
2623
2710
|
}
|
|
2624
2711
|
});
|
|
@@ -2871,14 +2958,14 @@ function countCodexInputChars(messages) {
|
|
|
2871
2958
|
}
|
|
2872
2959
|
function abortableSleep(sleepFn, ms, signal) {
|
|
2873
2960
|
let timer;
|
|
2874
|
-
const waitOnce = () => sleepFn ? Promise.resolve(sleepFn(ms)) : new Promise((
|
|
2875
|
-
timer = setTimeout(
|
|
2961
|
+
const waitOnce = () => sleepFn ? Promise.resolve(sleepFn(ms)) : new Promise((resolve8) => {
|
|
2962
|
+
timer = setTimeout(resolve8, ms);
|
|
2876
2963
|
});
|
|
2877
2964
|
if (!signal) return waitOnce().then(() => void 0);
|
|
2878
2965
|
if (signal.aborted) {
|
|
2879
2966
|
return Promise.reject(signal.reason ?? new DOMException("aborted", "AbortError"));
|
|
2880
2967
|
}
|
|
2881
|
-
return new Promise((
|
|
2968
|
+
return new Promise((resolve8, reject) => {
|
|
2882
2969
|
let settled = false;
|
|
2883
2970
|
const finish = (settle) => {
|
|
2884
2971
|
if (settled) return;
|
|
@@ -2892,7 +2979,7 @@ function abortableSleep(sleepFn, ms, signal) {
|
|
|
2892
2979
|
);
|
|
2893
2980
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
2894
2981
|
waitOnce().then(
|
|
2895
|
-
() => finish(
|
|
2982
|
+
() => finish(resolve8),
|
|
2896
2983
|
(error) => finish(() => reject(error))
|
|
2897
2984
|
);
|
|
2898
2985
|
});
|
|
@@ -3795,7 +3882,7 @@ function waitWithAbort(ms, signal) {
|
|
|
3795
3882
|
if (signal?.aborted) {
|
|
3796
3883
|
return Promise.reject(signal.reason ?? new Error("owner-required proxy aborted"));
|
|
3797
3884
|
}
|
|
3798
|
-
return new Promise((
|
|
3885
|
+
return new Promise((resolve8, reject) => {
|
|
3799
3886
|
let timer;
|
|
3800
3887
|
const cleanup = () => {
|
|
3801
3888
|
if (timer !== void 0) clearTimeout(timer);
|
|
@@ -3807,7 +3894,7 @@ function waitWithAbort(ms, signal) {
|
|
|
3807
3894
|
};
|
|
3808
3895
|
timer = setTimeout(() => {
|
|
3809
3896
|
cleanup();
|
|
3810
|
-
|
|
3897
|
+
resolve8();
|
|
3811
3898
|
}, ms);
|
|
3812
3899
|
signal?.addEventListener("abort", onAbort, { once: true });
|
|
3813
3900
|
});
|
|
@@ -4326,9 +4413,14 @@ function resolveProviderResolveOverrides(agentConfig, options) {
|
|
|
4326
4413
|
// packages/cli/client/localRuntimePaths.ts
|
|
4327
4414
|
import { dirname, extname, join } from "node:path";
|
|
4328
4415
|
import { fileURLToPath } from "node:url";
|
|
4416
|
+
import { existsSync, realpathSync } from "node:fs";
|
|
4329
4417
|
function resolveLocalRuntimePaths(moduleUrl, compiled, execPath) {
|
|
4330
|
-
if (compiled)
|
|
4331
|
-
|
|
4418
|
+
if (compiled) {
|
|
4419
|
+
const entry = execPath === process.execPath ? getHostRuntimeExecutable() : realpathSync(execPath);
|
|
4420
|
+
return { cliDir: dirname(entry), cliEntrypoint: entry };
|
|
4421
|
+
}
|
|
4422
|
+
const path = fileURLToPath(moduleUrl);
|
|
4423
|
+
const modulePath = existsSync(path) ? realpathSync(path) : path;
|
|
4332
4424
|
const extension = extname(modulePath) === ".js" ? ".js" : ".ts";
|
|
4333
4425
|
const cliDir = extension === ".js" ? dirname(modulePath) : dirname(dirname(modulePath));
|
|
4334
4426
|
return { cliDir, cliEntrypoint: join(cliDir, `index${extension}`) };
|
|
@@ -4423,7 +4515,7 @@ function resolveLocalRunExecutionIsolationFact(args) {
|
|
|
4423
4515
|
isolation: "none",
|
|
4424
4516
|
sandbox: "host",
|
|
4425
4517
|
reason: "host-no-sandbox",
|
|
4426
|
-
note: "\u672C run \u5728\u5BBF\u4E3B\u6267\u884C\u4E14**\u65E0\u9694\u79BB**\uFF08\u672A\u8D70 docker \u901A\u9053\uFF0C\u4E5F\u6CA1\u6709\u53EF\u7528\u7684 bwrap workload\uFF09\u3002\u5199\u64CD\u4F5C\u76F4\u63A5\u4F5C\u7528\u4E8E\u5BBF\u4E3B\u5DE5\u4F5C\u533A\
|
|
4518
|
+
note: "\u672C run \u5728\u5BBF\u4E3B\u6267\u884C\u4E14**\u65E0\u9694\u79BB**\uFF08\u672A\u8D70 docker \u901A\u9053\uFF0C\u4E5F\u6CA1\u6709\u53EF\u7528\u7684 bwrap workload\uFF09\u3002\u5199\u64CD\u4F5C\u76F4\u63A5\u4F5C\u7528\u4E8E\u5BBF\u4E3B\u5DE5\u4F5C\u533A\uFF1BCLI \u672A\u70B9\u540D\u5199\u578B\u6D3E\u53D1\u9ED8\u8BA4\u5BBF\u4E3B\u4E14\u987B allowHostWrites: true\uFF0C\u4EA4\u4E92\u5F0F run \u53EF\u7528 --runtime-key docker\uFF08\u6216 --local \u663E\u5F0F\u58F0\u660E\u672C\u673A\u6267\u884C\uFF09\u3002",
|
|
4427
4519
|
recordedAt
|
|
4428
4520
|
});
|
|
4429
4521
|
}
|
|
@@ -4494,8 +4586,8 @@ function recordLocalRunExecutionIsolation(args) {
|
|
|
4494
4586
|
}
|
|
4495
4587
|
function joinPath(dir, name) {
|
|
4496
4588
|
if (!dir) return name;
|
|
4497
|
-
const
|
|
4498
|
-
return dir.endsWith(
|
|
4589
|
+
const sep3 = dir.includes("\\") && !dir.includes("/") ? "\\" : "/";
|
|
4590
|
+
return dir.endsWith(sep3) ? `${dir}${name}` : `${dir}${sep3}${name}`;
|
|
4499
4591
|
}
|
|
4500
4592
|
|
|
4501
4593
|
// packages/core/settingsSyncFreshness.ts
|
|
@@ -4562,7 +4654,7 @@ function isBusyProviderStreamError(error) {
|
|
|
4562
4654
|
return BUSY_STREAM_ERROR_RE.test(toErrorMessage(error));
|
|
4563
4655
|
}
|
|
4564
4656
|
async function defaultSleep(ms) {
|
|
4565
|
-
await new Promise((
|
|
4657
|
+
await new Promise((resolve8) => setTimeout(resolve8, ms));
|
|
4566
4658
|
}
|
|
4567
4659
|
function isRetryableProviderStreamError(error) {
|
|
4568
4660
|
const message = toErrorMessage(error);
|
|
@@ -4754,6 +4846,8 @@ function parseBackgroundRuns(text) {
|
|
|
4754
4846
|
tasks.push({
|
|
4755
4847
|
title: title || agent || runId || SUBJECT_RUN.label,
|
|
4756
4848
|
...runId ? { identifier: runId } : {},
|
|
4849
|
+
...status ? { runStatus: status } : {},
|
|
4850
|
+
...attrValue(attrs, "childDialogId") && attrValue(attrs, "childDialogId") !== "missing" ? { childDialogId: decodeXmlAttribute(attrValue(attrs, "childDialogId")) } : {},
|
|
4757
4851
|
outcome,
|
|
4758
4852
|
outcomeLabel: OUTCOME_LABEL[outcome],
|
|
4759
4853
|
...duration ? { duration } : {},
|
|
@@ -5024,13 +5118,177 @@ function mergeNoticeGroup(turns, noticeTasks, styleContent) {
|
|
|
5024
5118
|
}
|
|
5025
5119
|
|
|
5026
5120
|
// packages/cli/client/cliRemoteDialogSync.ts
|
|
5027
|
-
|
|
5121
|
+
var RESERVED_AUTHORITY_FIELDS = [
|
|
5122
|
+
"userBatchOwner",
|
|
5123
|
+
"userBatchPhase",
|
|
5124
|
+
"userBatchReceipt",
|
|
5125
|
+
"acceptedUserBatchId"
|
|
5126
|
+
];
|
|
5127
|
+
function hasReservedBatchAuthority(metadata) {
|
|
5128
|
+
if (!isRecord(metadata)) return false;
|
|
5129
|
+
return Object.keys(metadata).some((key) => RESERVED_AUTHORITY_FIELDS.some(
|
|
5130
|
+
(field) => key === field || key.startsWith(`${field}.`) || key === `metadata.${field}` || key.startsWith(`metadata.${field}.`)
|
|
5131
|
+
));
|
|
5132
|
+
}
|
|
5133
|
+
var LOCAL_ONLY_EVIDENCE_KEY_PREFIXES = [
|
|
5134
|
+
`${TOKEN_DIALOG_INDEX_PREFIX}-`,
|
|
5135
|
+
`${DIALOG_AGENT_LIST_INDEX_PREFIX}-`,
|
|
5136
|
+
"idx-tokendlg-backfill-",
|
|
5137
|
+
"token-charge-stats-",
|
|
5138
|
+
"usage-backup-"
|
|
5139
|
+
];
|
|
5140
|
+
function isRemoteDialogEvidenceExcludedKey(key) {
|
|
5141
|
+
if (!key) return true;
|
|
5142
|
+
if (isTokenStatsKey(key)) return true;
|
|
5143
|
+
return LOCAL_ONLY_EVIDENCE_KEY_PREFIXES.some(
|
|
5144
|
+
(prefix) => key.startsWith(prefix)
|
|
5145
|
+
);
|
|
5146
|
+
}
|
|
5147
|
+
var MAX_REMOTE_ERROR_DETAIL_CHARS = 120;
|
|
5148
|
+
var SAFE_SHORT_ERROR_CODE_RE = /^[A-Za-z0-9_.:-]{1,48}$/;
|
|
5149
|
+
function sanitizeRemoteDiagnosticText(raw) {
|
|
5150
|
+
const singleLine = raw.replace(/\u001b\[[0-9;?]*[ -/]*[@-~]/g, " ").replace(/[\u0000-\u001f\u007f]+/g, " ").replace(/\s+/g, " ").trim();
|
|
5151
|
+
if (!singleLine) return "";
|
|
5152
|
+
return singleLine.replace(/\bBearer\s+[A-Za-z0-9._~+/=-]{6,}/gi, "Bearer [REDACTED]").replace(/\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}(?:\.[A-Za-z0-9_-]+)?/g, "[REDACTED]").replace(/\b(?:sk|rk|pk|nolo|tok)_[A-Za-z0-9_-]{8,}/gi, "[REDACTED]").replace(/\bvault-cred-[A-Za-z0-9_-]+/gi, "[REDACTED]");
|
|
5153
|
+
}
|
|
5154
|
+
function clampSingleLine(text, maxLen) {
|
|
5155
|
+
if (text.length <= maxLen) return text;
|
|
5156
|
+
if (maxLen <= 3) return text.slice(0, maxLen);
|
|
5157
|
+
return `${text.slice(0, maxLen - 3)}...`;
|
|
5158
|
+
}
|
|
5159
|
+
function extractSafeRemoteErrorDetail(status, bodyText) {
|
|
5160
|
+
if (status < 400 || status >= 500 || !bodyText) return "";
|
|
5161
|
+
let parsed;
|
|
5162
|
+
try {
|
|
5163
|
+
parsed = JSON.parse(bodyText);
|
|
5164
|
+
} catch {
|
|
5165
|
+
return "";
|
|
5166
|
+
}
|
|
5167
|
+
if (!isRecord(parsed)) return "";
|
|
5168
|
+
const rawCodeCandidates = [
|
|
5169
|
+
parsed.code,
|
|
5170
|
+
isRecord(parsed.error) ? parsed.error.code : void 0,
|
|
5171
|
+
typeof parsed.error === "string" ? parsed.error : void 0,
|
|
5172
|
+
parsed.reason
|
|
5173
|
+
];
|
|
5174
|
+
let code = "";
|
|
5175
|
+
let fallbackMessageFromError = "";
|
|
5176
|
+
for (const candidate of rawCodeCandidates) {
|
|
5177
|
+
if (typeof candidate !== "string") continue;
|
|
5178
|
+
const cleaned = sanitizeRemoteDiagnosticText(candidate);
|
|
5179
|
+
if (!cleaned) continue;
|
|
5180
|
+
if (SAFE_SHORT_ERROR_CODE_RE.test(cleaned)) {
|
|
5181
|
+
code = cleaned;
|
|
5182
|
+
break;
|
|
5183
|
+
}
|
|
5184
|
+
if (!fallbackMessageFromError) {
|
|
5185
|
+
fallbackMessageFromError = cleaned;
|
|
5186
|
+
}
|
|
5187
|
+
}
|
|
5188
|
+
const rawMessageCandidates = [
|
|
5189
|
+
parsed.message,
|
|
5190
|
+
isRecord(parsed.error) ? parsed.error.message : void 0,
|
|
5191
|
+
fallbackMessageFromError
|
|
5192
|
+
];
|
|
5193
|
+
let message = "";
|
|
5194
|
+
for (const candidate of rawMessageCandidates) {
|
|
5195
|
+
if (typeof candidate !== "string") continue;
|
|
5196
|
+
const cleaned = sanitizeRemoteDiagnosticText(candidate);
|
|
5197
|
+
if (cleaned && cleaned !== code) {
|
|
5198
|
+
message = cleaned;
|
|
5199
|
+
break;
|
|
5200
|
+
}
|
|
5201
|
+
}
|
|
5202
|
+
if (!code && !message) return "";
|
|
5203
|
+
const payload = {};
|
|
5204
|
+
if (code) payload.code = code;
|
|
5205
|
+
if (message) payload.message = message;
|
|
5206
|
+
let serialized = JSON.stringify(payload);
|
|
5207
|
+
if (serialized.length <= MAX_REMOTE_ERROR_DETAIL_CHARS) {
|
|
5208
|
+
return serialized;
|
|
5209
|
+
}
|
|
5210
|
+
if (code && message) {
|
|
5211
|
+
const baseLen = JSON.stringify({ code, message: "" }).length;
|
|
5212
|
+
const budget = MAX_REMOTE_ERROR_DETAIL_CHARS - baseLen;
|
|
5213
|
+
if (budget >= 8) {
|
|
5214
|
+
serialized = JSON.stringify({
|
|
5215
|
+
code,
|
|
5216
|
+
message: clampSingleLine(message, budget)
|
|
5217
|
+
});
|
|
5218
|
+
if (serialized.length <= MAX_REMOTE_ERROR_DETAIL_CHARS) return serialized;
|
|
5219
|
+
}
|
|
5220
|
+
serialized = JSON.stringify({ code });
|
|
5221
|
+
return serialized.length <= MAX_REMOTE_ERROR_DETAIL_CHARS ? serialized : clampSingleLine(serialized, MAX_REMOTE_ERROR_DETAIL_CHARS);
|
|
5222
|
+
}
|
|
5223
|
+
if (message) {
|
|
5224
|
+
const baseLen = JSON.stringify({ message: "" }).length;
|
|
5225
|
+
const budget = MAX_REMOTE_ERROR_DETAIL_CHARS - baseLen;
|
|
5226
|
+
return budget > 0 ? JSON.stringify({ message: clampSingleLine(message, budget) }) : "";
|
|
5227
|
+
}
|
|
5228
|
+
return clampSingleLine(serialized, MAX_REMOTE_ERROR_DETAIL_CHARS);
|
|
5229
|
+
}
|
|
5230
|
+
function prepareRemoteDialogEvidenceRecord(key, value, options) {
|
|
5028
5231
|
const record = isRecord(value) ? { ...value } : {};
|
|
5029
|
-
if (key.includes("-msg-") && typeof record.type !== "string") {
|
|
5232
|
+
if (key.includes("-msg-") && (typeof record.type !== "string" || !record.type.trim() || record.type === "message")) {
|
|
5030
5233
|
record.type = "msg";
|
|
5031
5234
|
}
|
|
5235
|
+
if (key.startsWith("token-") && !isTokenStatsKey(key)) {
|
|
5236
|
+
if (typeof record.type !== "string" || !record.type.trim()) {
|
|
5237
|
+
record.type = "token";
|
|
5238
|
+
}
|
|
5239
|
+
const hasAgentId = typeof record.agentId === "string" && record.agentId.trim().length > 0;
|
|
5240
|
+
const hasCybotId = typeof record.cybotId === "string" && record.cybotId.trim().length > 0;
|
|
5241
|
+
const fallbackAgent = asOptionalTrimmedString(options?.fallbackAgentKey);
|
|
5242
|
+
if (!hasAgentId && !hasCybotId && fallbackAgent) {
|
|
5243
|
+
record.agentId = fallbackAgent;
|
|
5244
|
+
record.cybotId = fallbackAgent;
|
|
5245
|
+
}
|
|
5246
|
+
}
|
|
5247
|
+
const metadata = record.metadata;
|
|
5248
|
+
if (key.includes("-msg-") && record.role === "user" && isRecord(metadata) && metadata.queueState === "accepted" && (metadata.cliBatchPhase === "requested" || metadata.cliBatchPhase === "completed" || typeof metadata.cliBatchId === "string" && metadata.cliBatchId.length > 0 || options?.isAcceptedBatchMember === true) && !hasReservedBatchAuthority(metadata)) {
|
|
5249
|
+
const { queueState: _localQueueState, ...evidenceMetadata } = metadata;
|
|
5250
|
+
record.metadata = evidenceMetadata;
|
|
5251
|
+
}
|
|
5032
5252
|
return record;
|
|
5033
5253
|
}
|
|
5254
|
+
async function collectAcceptedUserBatchMessageKeys(ops, localStore) {
|
|
5255
|
+
const memberKeys = /* @__PURE__ */ new Set();
|
|
5256
|
+
const collectReceipt = (op) => {
|
|
5257
|
+
if (op.type !== "put" || !op.key.includes("-msg-")) return;
|
|
5258
|
+
const record = op.value;
|
|
5259
|
+
if (!isRecord(record) || record.role !== "user" || !isRecord(record.metadata)) return;
|
|
5260
|
+
const metadata = record.metadata;
|
|
5261
|
+
if (metadata.cliBatchPhase !== "requested" && metadata.cliBatchPhase !== "completed") {
|
|
5262
|
+
return;
|
|
5263
|
+
}
|
|
5264
|
+
if (hasReservedBatchAuthority(record) || hasReservedBatchAuthority(metadata)) return;
|
|
5265
|
+
if (!Array.isArray(metadata.acceptedUserMessageIds)) return;
|
|
5266
|
+
const match = /^((?:dialog-[^]+?)-msg-)[^]+$/.exec(op.key);
|
|
5267
|
+
if (!match) return;
|
|
5268
|
+
const prefix = match[1];
|
|
5269
|
+
for (const memberId of metadata.acceptedUserMessageIds) {
|
|
5270
|
+
if (typeof memberId === "string" && memberId.length > 0) {
|
|
5271
|
+
memberKeys.add(`${prefix}${memberId}`);
|
|
5272
|
+
}
|
|
5273
|
+
}
|
|
5274
|
+
};
|
|
5275
|
+
for (const op of ops) collectReceipt(op);
|
|
5276
|
+
const prefixes = /* @__PURE__ */ new Set();
|
|
5277
|
+
for (const op of ops) {
|
|
5278
|
+
const record = op.value;
|
|
5279
|
+
if (op.type !== "put" || memberKeys.has(op.key) || record?.role !== "user" || record?.metadata?.queueState !== "accepted" || hasReservedBatchAuthority(record.metadata) || record.metadata.cliBatchPhase === "requested" || record.metadata.cliBatchPhase === "completed" || typeof record.metadata.cliBatchId === "string" && record.metadata.cliBatchId.length > 0) continue;
|
|
5280
|
+
const prefix = typeof record.dialogId === "string" ? `dialog-${record.dialogId}-msg-` : /^((?:dialog-[^]+?)-msg-)[^]+$/.exec(op.key)?.[1];
|
|
5281
|
+
if (prefix && op.key.startsWith(prefix)) prefixes.add(prefix);
|
|
5282
|
+
}
|
|
5283
|
+
if (localStore) {
|
|
5284
|
+
for (const prefix of prefixes) {
|
|
5285
|
+
for await (const [key, value] of localStore.iterator({ gte: prefix, lt: `${prefix}\uFFFF` })) {
|
|
5286
|
+
if (key.startsWith(prefix)) collectReceipt({ type: "put", key, value });
|
|
5287
|
+
}
|
|
5288
|
+
}
|
|
5289
|
+
}
|
|
5290
|
+
return memberKeys;
|
|
5291
|
+
}
|
|
5034
5292
|
function normalizeRemoteSubjectRef(value) {
|
|
5035
5293
|
if (!isRecord(value)) return null;
|
|
5036
5294
|
const kind = asOptionalTrimmedString(value.kind);
|
|
@@ -5096,7 +5354,7 @@ function buildLocalParentWakeMessage(args) {
|
|
|
5096
5354
|
var EVIDENCE_WRITE_BATCH_SIZE = 4;
|
|
5097
5355
|
var EVIDENCE_WRITE_BATCH_GAP_MS = 300;
|
|
5098
5356
|
async function defaultEvidenceSleep(ms) {
|
|
5099
|
-
await new Promise((
|
|
5357
|
+
await new Promise((resolve8) => setTimeout(resolve8, ms));
|
|
5100
5358
|
}
|
|
5101
5359
|
async function runThrottledBatches(items, run, options = {}) {
|
|
5102
5360
|
const batchSize = options.batchSize ?? EVIDENCE_WRITE_BATCH_SIZE;
|
|
@@ -5123,7 +5381,10 @@ async function postRemoteRecord(args) {
|
|
|
5123
5381
|
body: JSON.stringify({
|
|
5124
5382
|
customKey: args.key,
|
|
5125
5383
|
userId: args.userId,
|
|
5126
|
-
data: prepareRemoteDialogEvidenceRecord(args.key, args.data
|
|
5384
|
+
data: prepareRemoteDialogEvidenceRecord(args.key, args.data, {
|
|
5385
|
+
fallbackAgentKey: args.fallbackAgentKey,
|
|
5386
|
+
isAcceptedBatchMember: args.isAcceptedBatchMember
|
|
5387
|
+
})
|
|
5127
5388
|
}),
|
|
5128
5389
|
signal: AbortSignal.timeout(remoteDialogSyncTimeout())
|
|
5129
5390
|
},
|
|
@@ -5140,8 +5401,9 @@ async function postRemoteRecord(args) {
|
|
|
5140
5401
|
);
|
|
5141
5402
|
if (!response.ok) {
|
|
5142
5403
|
const text = await response.text().catch(() => "");
|
|
5404
|
+
const detail = extractSafeRemoteErrorDetail(response.status, text);
|
|
5143
5405
|
throw new Error(
|
|
5144
|
-
`remote dialog evidence write failed: HTTP ${response.status} ${
|
|
5406
|
+
detail ? `remote dialog evidence write failed: HTTP ${response.status} ${detail}` : `remote dialog evidence write failed: HTTP ${response.status}`
|
|
5145
5407
|
);
|
|
5146
5408
|
}
|
|
5147
5409
|
}
|
|
@@ -5216,8 +5478,9 @@ async function maybeWakeParentDialogAfterLocalSync(args) {
|
|
|
5216
5478
|
});
|
|
5217
5479
|
if (!wakeResponse.ok) {
|
|
5218
5480
|
const text = await wakeResponse.text().catch(() => "");
|
|
5481
|
+
const detail = extractSafeRemoteErrorDetail(wakeResponse.status, text);
|
|
5219
5482
|
throw new Error(
|
|
5220
|
-
`parent dialog wake failed: HTTP ${wakeResponse.status} ${
|
|
5483
|
+
detail ? `parent dialog wake failed: HTTP ${wakeResponse.status} ${detail}` : `parent dialog wake failed: HTTP ${wakeResponse.status}`
|
|
5221
5484
|
);
|
|
5222
5485
|
}
|
|
5223
5486
|
const notifiedAt = Date.now();
|
|
@@ -5242,13 +5505,14 @@ async function maybeWakeParentDialogAfterLocalSync(args) {
|
|
|
5242
5505
|
async function syncLocalDialogEvidenceToRemote(args) {
|
|
5243
5506
|
const serverUrl = resolveRuntimeServerUrl(args.env);
|
|
5244
5507
|
const authToken = resolveRuntimeAuthToken(args.env);
|
|
5245
|
-
if (!serverUrl || !authToken) {
|
|
5508
|
+
if (!serverUrl || !authToken || args.userId === "local") {
|
|
5246
5509
|
return { attempted: false };
|
|
5247
5510
|
}
|
|
5248
5511
|
const orderedOps = [];
|
|
5249
5512
|
const nonMsgOps = [];
|
|
5250
5513
|
for (const op of args.ops) {
|
|
5251
5514
|
if (op.type !== "put") continue;
|
|
5515
|
+
if (isRemoteDialogEvidenceExcludedKey(op.key)) continue;
|
|
5252
5516
|
if (op.key.includes("-msg-")) {
|
|
5253
5517
|
orderedOps.push(op);
|
|
5254
5518
|
} else {
|
|
@@ -5256,21 +5520,23 @@ async function syncLocalDialogEvidenceToRemote(args) {
|
|
|
5256
5520
|
}
|
|
5257
5521
|
}
|
|
5258
5522
|
orderedOps.push(...nonMsgOps);
|
|
5523
|
+
const acceptedBatchKeys = await collectAcceptedUserBatchMessageKeys(orderedOps, args.localStore);
|
|
5524
|
+
const fallbackAgentKey = asOptionalTrimmedString(args.input?.agentKey);
|
|
5259
5525
|
await runThrottledBatches(
|
|
5260
5526
|
orderedOps.filter((op) => op.type === "put"),
|
|
5261
5527
|
(op) => postRemoteRecord({
|
|
5262
5528
|
authToken,
|
|
5263
5529
|
data: op.value,
|
|
5530
|
+
fallbackAgentKey,
|
|
5264
5531
|
fetchImpl: args.fetchImpl,
|
|
5532
|
+
isAcceptedBatchMember: acceptedBatchKeys.has(op.key),
|
|
5265
5533
|
key: op.key,
|
|
5266
5534
|
serverUrl,
|
|
5267
5535
|
userId: args.userId
|
|
5268
5536
|
}),
|
|
5269
5537
|
args.sleep ? { sleep: args.sleep } : {}
|
|
5270
5538
|
);
|
|
5271
|
-
const childDialogOp =
|
|
5272
|
-
(op) => op.type === "put" && !op.key.includes("-msg-")
|
|
5273
|
-
);
|
|
5539
|
+
const childDialogOp = nonMsgOps.find((op) => op.key.startsWith("dialog-")) ?? nonMsgOps[0];
|
|
5274
5540
|
const childDialogRecord = childDialogOp?.value && typeof childDialogOp.value === "object" ? childDialogOp.value : null;
|
|
5275
5541
|
if (childDialogOp && childDialogRecord) {
|
|
5276
5542
|
try {
|
|
@@ -5298,25 +5564,24 @@ async function syncLocalDialogEvidenceToRemote(args) {
|
|
|
5298
5564
|
// packages/cli/client/childShellApprovalHostResolver.ts
|
|
5299
5565
|
function createChildShellApprovalHostResolver(args) {
|
|
5300
5566
|
return async (agentKey) => {
|
|
5301
|
-
const
|
|
5302
|
-
|
|
5303
|
-
const ownerUserId = asOptionalTrimmedString(record?.userId) ?? asOptionalTrimmedString(record?.ownerUserId);
|
|
5304
|
-
if (!ownerUserId) return void 0;
|
|
5305
|
-
const deviceId = asOptionalTrimmedString(await args.resolveDeviceId());
|
|
5306
|
-
if (!deviceId) return void 0;
|
|
5567
|
+
const binding = await resolveChildApprovalBinding({ ...args, agentKey });
|
|
5568
|
+
if (!binding) return void 0;
|
|
5307
5569
|
return {
|
|
5308
|
-
binding
|
|
5309
|
-
runId: "pending-spawn",
|
|
5310
|
-
agentKey,
|
|
5311
|
-
ownerUserId,
|
|
5312
|
-
deviceId,
|
|
5313
|
-
workspaceRoot: args.workspaceRoot
|
|
5314
|
-
},
|
|
5570
|
+
binding,
|
|
5315
5571
|
confirm: args.session.confirm,
|
|
5316
5572
|
signal: args.session.signal
|
|
5317
5573
|
};
|
|
5318
5574
|
};
|
|
5319
5575
|
}
|
|
5576
|
+
async function resolveChildApprovalBinding(args) {
|
|
5577
|
+
const config = await args.readAgentConfig(args.agentKey);
|
|
5578
|
+
const record = config?.rawRecord;
|
|
5579
|
+
const ownerUserId = asOptionalTrimmedString(record?.userId) ?? asOptionalTrimmedString(record?.ownerUserId);
|
|
5580
|
+
if (!ownerUserId) return void 0;
|
|
5581
|
+
const deviceId = asOptionalTrimmedString(await args.resolveDeviceId());
|
|
5582
|
+
if (!deviceId) return void 0;
|
|
5583
|
+
return { runId: "pending-spawn", agentKey: args.agentKey, ownerUserId, deviceId, workspaceRoot: args.workspaceRoot };
|
|
5584
|
+
}
|
|
5320
5585
|
|
|
5321
5586
|
// packages/cli/client/cliDialogHistoryState.ts
|
|
5322
5587
|
var STATE_KEY_PREFIX = "cli-dialog-history-state";
|
|
@@ -5567,7 +5832,7 @@ function entriesToMessages(entries) {
|
|
|
5567
5832
|
const message = dialogMessageRecordToAgentRuntimeMessage(entry.record);
|
|
5568
5833
|
if (message) messages.push(message);
|
|
5569
5834
|
}
|
|
5570
|
-
return messages;
|
|
5835
|
+
return orderDialogHistory(messages);
|
|
5571
5836
|
}
|
|
5572
5837
|
async function persistIncompleteState(args) {
|
|
5573
5838
|
const persisted = await writeCliDialogHistoryState({
|
|
@@ -5668,7 +5933,7 @@ function analyzeRemoteDialogRecords(args) {
|
|
|
5668
5933
|
}
|
|
5669
5934
|
entries.push({ key, messageId, record, message });
|
|
5670
5935
|
}
|
|
5671
|
-
const messages = entries.map((entry) => entry.message);
|
|
5936
|
+
const messages = orderDialogHistory(entries.map((entry) => entry.message));
|
|
5672
5937
|
for (const detail of findAgentStatePairingIssues(messages)) {
|
|
5673
5938
|
issues.push({ code: "tool-pairing", detail });
|
|
5674
5939
|
}
|
|
@@ -5722,271 +5987,24 @@ async function fetchRemoteDialogMessageRecordsViaBridge(args) {
|
|
|
5722
5987
|
signal: args.signal
|
|
5723
5988
|
}
|
|
5724
5989
|
);
|
|
5725
|
-
if (!res.ok) {
|
|
5726
|
-
throw Object.assign(new Error(`dialog-read failed: HTTP ${res.status}`), {
|
|
5727
|
-
status: res.status
|
|
5728
|
-
});
|
|
5729
|
-
}
|
|
5730
|
-
const payload = await res.json();
|
|
5731
|
-
if (!isRecord(payload) || payload.ok !== true) {
|
|
5732
|
-
throw new Error(
|
|
5733
|
-
`dialog-read failed: ${String(payload?.error ?? "unknown error")}`
|
|
5734
|
-
);
|
|
5735
|
-
}
|
|
5736
|
-
if (!Array.isArray(payload.msgs)) throw new Error("dialog-read returned invalid history payload");
|
|
5737
|
-
return payload.msgs;
|
|
5738
|
-
}
|
|
5739
|
-
|
|
5740
|
-
// packages/cli/client/browserShellApprovalBridge.ts
|
|
5741
|
-
import { createServer } from "node:http";
|
|
5742
|
-
import { randomBytes, timingSafeEqual } from "node:crypto";
|
|
5743
|
-
|
|
5744
|
-
// packages/cli/client/hostApprovalFlow.ts
|
|
5745
|
-
var HOST_APPROVAL_SUMMARY_LIMIT = 2500;
|
|
5746
|
-
function clipApprovalSummary(text, limit = HOST_APPROVAL_SUMMARY_LIMIT) {
|
|
5747
|
-
const value = String(text ?? "").replace(/\r\n?/g, "\n").trim();
|
|
5748
|
-
if (value.length <= limit) return value;
|
|
5749
|
-
const tailChars = Math.max(1, Math.round(limit * 0.3));
|
|
5750
|
-
const headChars = Math.max(1, limit - tailChars);
|
|
5751
|
-
const head = value.slice(0, headChars);
|
|
5752
|
-
const tail = value.slice(value.length - tailChars);
|
|
5753
|
-
const omitted = value.length - head.length - tail.length;
|
|
5754
|
-
return `${head}
|
|
5755
|
-
\u2026\uFF08\u4E2D\u95F4 ${omitted} \u5B57\u7B26\u672A\u663E\u793A\uFF0C\u4EE5\u4E0B\u662F\u7ED3\u5C3E\uFF1B\u5168\u6587 ${value.length} \u5B57\u7B26\uFF09\u2026
|
|
5756
|
-
${tail}`;
|
|
5757
|
-
}
|
|
5758
|
-
function toEpochMs(value) {
|
|
5759
|
-
if (typeof value === "number" && Number.isFinite(value)) {
|
|
5760
|
-
return value < 1e11 ? Math.round(value * 1e3) : Math.round(value);
|
|
5761
|
-
}
|
|
5762
|
-
if (typeof value === "string" && value.trim()) {
|
|
5763
|
-
const asNumber = Number(value);
|
|
5764
|
-
if (Number.isFinite(asNumber)) return toEpochMs(asNumber);
|
|
5765
|
-
const parsed = Date.parse(value);
|
|
5766
|
-
if (Number.isFinite(parsed)) return parsed;
|
|
5767
|
-
}
|
|
5768
|
-
return void 0;
|
|
5769
|
-
}
|
|
5770
|
-
function remainingApprovalMs(expiresAt, now) {
|
|
5771
|
-
return Math.max(0, expiresAt - now);
|
|
5772
|
-
}
|
|
5773
|
-
function formatApprovalRemaining(expiresAt, now) {
|
|
5774
|
-
const totalSeconds = Math.ceil(remainingApprovalMs(expiresAt, now) / 1e3);
|
|
5775
|
-
if (totalSeconds <= 0) return "0s";
|
|
5776
|
-
const minutes = Math.floor(totalSeconds / 60);
|
|
5777
|
-
const seconds = totalSeconds % 60;
|
|
5778
|
-
return minutes > 0 ? `${minutes}m${seconds}s` : `${seconds}s`;
|
|
5779
|
-
}
|
|
5780
|
-
function isRecordLike(value) {
|
|
5781
|
-
return typeof value === "object" && value !== null;
|
|
5782
|
-
}
|
|
5783
|
-
function asTrimmedString2(value) {
|
|
5784
|
-
return typeof value === "string" ? value.trim() : "";
|
|
5785
|
-
}
|
|
5786
|
-
function normalizePendingApproval(raw) {
|
|
5787
|
-
if (!isRecordLike(raw)) return null;
|
|
5788
|
-
const approvalId = asTrimmedString2(raw.approvalId);
|
|
5789
|
-
const expiresAt = toEpochMs(raw.expiresAt ?? raw.expiresAtMs);
|
|
5790
|
-
if (!approvalId || expiresAt === void 0) return null;
|
|
5791
|
-
const tabId = asTrimmedString2(raw.tabId);
|
|
5792
|
-
return {
|
|
5793
|
-
approvalId,
|
|
5794
|
-
actionLabel: asTrimmedString2(raw.action) || "unknown",
|
|
5795
|
-
...asTrimmedString2(raw.target) ? { target: asTrimmedString2(raw.target) } : {},
|
|
5796
|
-
origin: asTrimmedString2(raw.origin),
|
|
5797
|
-
// Passed through verbatim (the connector's preview already has the identity line, the head and
|
|
5798
|
-
// the stated tail); only an upper-bound guard may touch it, see clipApprovalSummary.
|
|
5799
|
-
summary: clipApprovalSummary(asTrimmedString2(raw.summary)),
|
|
5800
|
-
expiresAt,
|
|
5801
|
-
...tabId ? { tabId } : {}
|
|
5802
|
-
};
|
|
5803
|
-
}
|
|
5804
|
-
function parsePendingApprovalResult(result) {
|
|
5805
|
-
let parsed;
|
|
5806
|
-
try {
|
|
5807
|
-
parsed = JSON.parse(result.content);
|
|
5808
|
-
} catch {
|
|
5809
|
-
return null;
|
|
5810
|
-
}
|
|
5811
|
-
if (!isRecordLike(parsed)) return null;
|
|
5812
|
-
const errorBlock = isRecordLike(parsed.error) ? parsed.error : void 0;
|
|
5813
|
-
const details = isRecordLike(errorBlock?.details) ? errorBlock.details : void 0;
|
|
5814
|
-
const verdict = isRecordLike(parsed.result) ? parsed.result : void 0;
|
|
5815
|
-
const candidates = [verdict, errorBlock, details].filter(isRecordLike);
|
|
5816
|
-
const pending = candidates.find((entry) => entry.code === "USER_APPROVAL_PENDING");
|
|
5817
|
-
if (!pending) return null;
|
|
5818
|
-
const ordered = [pending, details, verdict].filter(isRecordLike);
|
|
5819
|
-
const readField = (key) => {
|
|
5820
|
-
for (const entry of ordered) {
|
|
5821
|
-
const value = asTrimmedString2(entry[key]);
|
|
5822
|
-
if (value) return value;
|
|
5823
|
-
}
|
|
5824
|
-
return "";
|
|
5825
|
-
};
|
|
5826
|
-
const approvalId = readField("approvalId");
|
|
5827
|
-
if (!approvalId) return null;
|
|
5828
|
-
let expiresAt;
|
|
5829
|
-
for (const entry of ordered) {
|
|
5830
|
-
const candidate = toEpochMs(entry.expiresAt ?? entry.expiresAtMs);
|
|
5831
|
-
if (candidate !== void 0) {
|
|
5832
|
-
expiresAt = candidate;
|
|
5833
|
-
break;
|
|
5834
|
-
}
|
|
5835
|
-
}
|
|
5836
|
-
const message = readField("message");
|
|
5837
|
-
return {
|
|
5838
|
-
approvalId,
|
|
5839
|
-
action: readField("action"),
|
|
5840
|
-
...expiresAt !== void 0 ? { expiresAt } : {},
|
|
5841
|
-
...message ? { message } : {}
|
|
5842
|
-
};
|
|
5843
|
-
}
|
|
5844
|
-
function withApprovalId(call, approvalId) {
|
|
5845
|
-
let payload;
|
|
5846
|
-
try {
|
|
5847
|
-
const parsed = JSON.parse(call.arguments || "{}");
|
|
5848
|
-
payload = isRecordLike(parsed) ? { ...parsed } : {};
|
|
5849
|
-
} catch {
|
|
5850
|
-
return call;
|
|
5851
|
-
}
|
|
5852
|
-
payload.approvalId = approvalId;
|
|
5853
|
-
return { ...call, arguments: JSON.stringify(payload) };
|
|
5854
|
-
}
|
|
5855
|
-
function withHostApprovalRequest(call) {
|
|
5856
|
-
let payload;
|
|
5857
|
-
try {
|
|
5858
|
-
const parsed = JSON.parse(call.arguments || "{}");
|
|
5859
|
-
payload = isRecordLike(parsed) ? { ...parsed } : {};
|
|
5860
|
-
} catch {
|
|
5861
|
-
return call;
|
|
5862
|
-
}
|
|
5863
|
-
payload.hostApproval = true;
|
|
5864
|
-
return { ...call, arguments: JSON.stringify(payload) };
|
|
5865
|
-
}
|
|
5866
|
-
function createConnectorApprovalPort(getClient) {
|
|
5867
|
-
return {
|
|
5868
|
-
async listPendingApprovals() {
|
|
5869
|
-
const raw = await getClient().request("list_pending_approvals", {});
|
|
5870
|
-
const list = isRecordLike(raw) && Array.isArray(raw.approvals) ? raw.approvals : [];
|
|
5871
|
-
return list.map(normalizePendingApproval).filter((entry) => entry !== null);
|
|
5872
|
-
},
|
|
5873
|
-
async submitApprovalDecision(approvalId, decision) {
|
|
5874
|
-
try {
|
|
5875
|
-
const raw = await getClient().request("submit_approval_decision", {
|
|
5876
|
-
approvalId,
|
|
5877
|
-
decision
|
|
5878
|
-
});
|
|
5879
|
-
if (isRecordLike(raw) && raw.ok === false) {
|
|
5880
|
-
return { failed: asTrimmedString2(raw.code) || "USER_APPROVAL_REJECTED" };
|
|
5881
|
-
}
|
|
5882
|
-
const status = isRecordLike(raw) && raw.status === "denied" ? "denied" : "allowed";
|
|
5883
|
-
return { status };
|
|
5884
|
-
} catch (error) {
|
|
5885
|
-
const code = asTrimmedString2(error?.code);
|
|
5886
|
-
return { failed: code || "CHROME_CONNECTOR_ERROR" };
|
|
5887
|
-
}
|
|
5888
|
-
}
|
|
5889
|
-
};
|
|
5890
|
-
}
|
|
5891
|
-
function approvalFailure(code, message, action, extra) {
|
|
5892
|
-
return {
|
|
5893
|
-
content: JSON.stringify({ ok: false, error: { code, message } }),
|
|
5894
|
-
metadata: { chromeConnector: true, error: true, code, action, ...extra ?? {} }
|
|
5895
|
-
};
|
|
5896
|
-
}
|
|
5897
|
-
async function runConnectorToolWithHostApproval(args) {
|
|
5898
|
-
const first = await args.execute(
|
|
5899
|
-
withHostApprovalRequest(args.call)
|
|
5900
|
-
);
|
|
5901
|
-
const pending = parsePendingApprovalResult(first);
|
|
5902
|
-
if (!pending || !args.awaitHostApproval) return first;
|
|
5903
|
-
const now = args.now ?? Date.now;
|
|
5904
|
-
let listed;
|
|
5905
|
-
try {
|
|
5906
|
-
listed = await args.connector.listPendingApprovals();
|
|
5907
|
-
} catch {
|
|
5908
|
-
return first;
|
|
5909
|
-
}
|
|
5910
|
-
const card = listed.find((entry) => entry.approvalId === pending.approvalId);
|
|
5911
|
-
if (!card) {
|
|
5912
|
-
return approvalFailure(
|
|
5913
|
-
"USER_APPROVAL_EXPIRED",
|
|
5914
|
-
"\u5BA1\u6279\u5DF2\u8FC7\u671F\u6216\u4E0D\u518D\u5F85\u6279\uFF0C\u52A8\u4F5C\u672A\u6267\u884C\u3002",
|
|
5915
|
-
args.call.name
|
|
5916
|
-
);
|
|
5917
|
-
}
|
|
5918
|
-
if (card.expiresAt <= now()) {
|
|
5919
|
-
return approvalFailure("USER_APPROVAL_EXPIRED", "\u5BA1\u6279\u5DF2\u8FC7\u671F\uFF0C\u52A8\u4F5C\u672A\u6267\u884C\u3002", args.call.name);
|
|
5920
|
-
}
|
|
5921
|
-
const decision = await args.awaitHostApproval(card);
|
|
5922
|
-
if (decision === "deny") {
|
|
5923
|
-
await args.connector.submitApprovalDecision(card.approvalId, "deny");
|
|
5924
|
-
return approvalFailure("USER_APPROVAL_DENIED", "\u7528\u6237\u5DF2\u62D2\u7EDD", args.call.name, {
|
|
5925
|
-
approvalId: card.approvalId
|
|
5990
|
+
if (!res.ok) {
|
|
5991
|
+
throw Object.assign(new Error(`dialog-read failed: HTTP ${res.status}`), {
|
|
5992
|
+
status: res.status
|
|
5926
5993
|
});
|
|
5927
5994
|
}
|
|
5928
|
-
const
|
|
5929
|
-
if (
|
|
5930
|
-
|
|
5931
|
-
|
|
5932
|
-
submitted.failed === "USER_APPROVAL_EXPIRED" ? "\u5BA1\u6279\u5DF2\u8FC7\u671F\uFF0C\u52A8\u4F5C\u672A\u6267\u884C\u3002" : "\u5BA1\u6279\u51B3\u5B9A\u672A\u88AB\u8FDE\u63A5\u5668\u63A5\u53D7\uFF0C\u52A8\u4F5C\u672A\u6267\u884C\u3002",
|
|
5933
|
-
args.call.name,
|
|
5934
|
-
{ approvalId: card.approvalId }
|
|
5995
|
+
const payload = await res.json();
|
|
5996
|
+
if (!isRecord(payload) || payload.ok !== true) {
|
|
5997
|
+
throw new Error(
|
|
5998
|
+
`dialog-read failed: ${String(payload?.error ?? "unknown error")}`
|
|
5935
5999
|
);
|
|
5936
6000
|
}
|
|
5937
|
-
if (
|
|
5938
|
-
|
|
5939
|
-
approvalId: card.approvalId
|
|
5940
|
-
});
|
|
5941
|
-
}
|
|
5942
|
-
return args.execute(withApprovalId(args.call, card.approvalId));
|
|
5943
|
-
}
|
|
5944
|
-
function createHostApprovalCardQueue() {
|
|
5945
|
-
const waiting = [];
|
|
5946
|
-
let active = false;
|
|
5947
|
-
const drain = async () => {
|
|
5948
|
-
if (active) return;
|
|
5949
|
-
active = true;
|
|
5950
|
-
try {
|
|
5951
|
-
while (waiting.length > 0) {
|
|
5952
|
-
waiting.sort((a, b) => a.card.expiresAt - b.card.expiresAt);
|
|
5953
|
-
const entry = waiting.shift();
|
|
5954
|
-
let decision = "deny";
|
|
5955
|
-
try {
|
|
5956
|
-
decision = await entry.present(entry.card);
|
|
5957
|
-
} catch {
|
|
5958
|
-
decision = "deny";
|
|
5959
|
-
}
|
|
5960
|
-
entry.resolve(decision);
|
|
5961
|
-
}
|
|
5962
|
-
} finally {
|
|
5963
|
-
active = false;
|
|
5964
|
-
}
|
|
5965
|
-
};
|
|
5966
|
-
return {
|
|
5967
|
-
/** Resolves with the user's answer once this card reaches the head of the queue. */
|
|
5968
|
-
present(card, present) {
|
|
5969
|
-
return new Promise((resolve7) => {
|
|
5970
|
-
waiting.push({ card, present, resolve: resolve7 });
|
|
5971
|
-
void Promise.resolve().then(drain);
|
|
5972
|
-
});
|
|
5973
|
-
},
|
|
5974
|
-
/** Cards currently queued or being shown (tests/telemetry). */
|
|
5975
|
-
size: () => waiting.length + (active ? 1 : 0)
|
|
5976
|
-
};
|
|
5977
|
-
}
|
|
5978
|
-
var registeredRenderer = null;
|
|
5979
|
-
function registerHostApprovalRenderer(renderer) {
|
|
5980
|
-
registeredRenderer = renderer;
|
|
5981
|
-
return () => {
|
|
5982
|
-
if (registeredRenderer === renderer) registeredRenderer = null;
|
|
5983
|
-
};
|
|
5984
|
-
}
|
|
5985
|
-
function getHostApprovalRenderer() {
|
|
5986
|
-
return registeredRenderer ?? void 0;
|
|
6001
|
+
if (!Array.isArray(payload.msgs)) throw new Error("dialog-read returned invalid history payload");
|
|
6002
|
+
return payload.msgs;
|
|
5987
6003
|
}
|
|
5988
6004
|
|
|
5989
6005
|
// packages/cli/client/browserShellApprovalBridge.ts
|
|
6006
|
+
import { createServer } from "node:http";
|
|
6007
|
+
import { randomBytes, timingSafeEqual } from "node:crypto";
|
|
5990
6008
|
async function createBrowserShellApprovalBridge(args) {
|
|
5991
6009
|
const timeoutMs = args.timeoutMs ?? 6e4;
|
|
5992
6010
|
if (!Number.isFinite(timeoutMs) || timeoutMs <= 0 || timeoutMs > 6e4) throw new Error("Invalid bridge timeout");
|
|
@@ -6037,6 +6055,7 @@ async function createBrowserShellApprovalBridge(args) {
|
|
|
6037
6055
|
let retry = false;
|
|
6038
6056
|
await runConnectorToolWithHostApproval({
|
|
6039
6057
|
call: current.call,
|
|
6058
|
+
signal: lifetime.signal,
|
|
6040
6059
|
execute: async () => {
|
|
6041
6060
|
requireActive();
|
|
6042
6061
|
if (calls++ === 0) return current.pending;
|
|
@@ -6061,13 +6080,13 @@ async function createBrowserShellApprovalBridge(args) {
|
|
|
6061
6080
|
},
|
|
6062
6081
|
...args.awaitHostApproval ? { awaitHostApproval: async (card) => {
|
|
6063
6082
|
requireActive();
|
|
6064
|
-
const decision = await new Promise((
|
|
6083
|
+
const decision = await new Promise((resolve8, reject) => {
|
|
6065
6084
|
const abort = () => reject(new Error("Browser approval bridge revoked"));
|
|
6066
6085
|
lifetime.signal.addEventListener("abort", abort, { once: true });
|
|
6067
6086
|
Promise.resolve().then(() => {
|
|
6068
6087
|
requireActive();
|
|
6069
6088
|
return args.awaitHostApproval(card, lifetime.signal);
|
|
6070
|
-
}).then(
|
|
6089
|
+
}).then(resolve8, reject).finally(() => lifetime.signal.removeEventListener("abort", abort));
|
|
6071
6090
|
});
|
|
6072
6091
|
requireActive();
|
|
6073
6092
|
if (decision !== "allow_once" && decision !== "deny") throw new Error("Invalid host decision");
|
|
@@ -6090,17 +6109,17 @@ async function createBrowserShellApprovalBridge(args) {
|
|
|
6090
6109
|
clearTimeout(timer);
|
|
6091
6110
|
args.signal?.removeEventListener("abort", onAbort);
|
|
6092
6111
|
bindings.clear();
|
|
6093
|
-
closing = new Promise((
|
|
6094
|
-
server.close(() =>
|
|
6112
|
+
closing = new Promise((resolve8) => {
|
|
6113
|
+
server.close(() => resolve8());
|
|
6095
6114
|
server.closeAllConnections();
|
|
6096
6115
|
});
|
|
6097
6116
|
return closing;
|
|
6098
6117
|
}
|
|
6099
|
-
await new Promise((
|
|
6118
|
+
await new Promise((resolve8, reject) => {
|
|
6100
6119
|
server.once("error", reject);
|
|
6101
6120
|
server.listen(0, "127.0.0.1", () => {
|
|
6102
6121
|
server.removeListener("error", reject);
|
|
6103
|
-
|
|
6122
|
+
resolve8();
|
|
6104
6123
|
});
|
|
6105
6124
|
});
|
|
6106
6125
|
const address = server.address();
|
|
@@ -6328,11 +6347,9 @@ function buildServerPlatformToolExecutors(args) {
|
|
|
6328
6347
|
return text;
|
|
6329
6348
|
};
|
|
6330
6349
|
const guardExplicitTableCapture = (call) => {
|
|
6331
|
-
if (inferCaptureIntent(String(call.userInput ?? "")) === "strong")
|
|
6332
|
-
return null;
|
|
6333
6350
|
return JSON.stringify({
|
|
6334
6351
|
error: "knowledge_capture_requires_confirmation",
|
|
6335
|
-
message: "\u5F53\u524D\
|
|
6352
|
+
message: "\u5F53\u524D\u6267\u884C\u9762\u6CA1\u6709\u53EF\u4FE1\u786E\u8BA4\u91CD\u653E\u80FD\u529B\uFF1B\u8BF7\u5728\u652F\u6301\u786E\u8BA4\u7684\u754C\u9762\u6838\u5BF9\u5177\u4F53\u5185\u5BB9\u548C\u76EE\u6807\u540E\u4FDD\u5B58\u3002",
|
|
6336
6353
|
policy: {
|
|
6337
6354
|
capability: "knowledge_capture",
|
|
6338
6355
|
target: "table",
|
|
@@ -6436,7 +6453,7 @@ function buildServerPlatformToolExecutors(args) {
|
|
|
6436
6453
|
const shortHash = (value, len) => createHash2("sha256").update(value).digest("hex").slice(0, len);
|
|
6437
6454
|
const localMemoryContext = async () => {
|
|
6438
6455
|
const openCliLocalRuntimeDb = async () => {
|
|
6439
|
-
const { getDefaultCliLocalRuntimeDb: getDefaultCliLocalRuntimeDb2 } = await import("./localRuntimeDb-
|
|
6456
|
+
const { getDefaultCliLocalRuntimeDb: getDefaultCliLocalRuntimeDb2 } = await import("./localRuntimeDb-5WZ4RJJO.js");
|
|
6440
6457
|
return getDefaultCliLocalRuntimeDb2({ env: args.env });
|
|
6441
6458
|
};
|
|
6442
6459
|
try {
|
|
@@ -6459,20 +6476,23 @@ function buildServerPlatformToolExecutors(args) {
|
|
|
6459
6476
|
return null;
|
|
6460
6477
|
}
|
|
6461
6478
|
const remoteItems = Array.isArray(remote?.selectedItems) ? remote.selectedItems : [];
|
|
6462
|
-
const [{ loadMemoryVNextCatalog }, { recallMemoryVNextLocal }] = await Promise.all([
|
|
6463
|
-
import("./store-
|
|
6479
|
+
const [{ loadMemoryVNextCatalog, getMemoryEvidenceVNextStrict }, { recallMemoryVNextLocal }] = await Promise.all([
|
|
6480
|
+
import("./store-Z53ICFL3.js"),
|
|
6464
6481
|
import("./localRecall-BDYKXB46.js")
|
|
6465
6482
|
]);
|
|
6466
6483
|
const catalog = await loadMemoryVNextCatalog(ctx.db, ctx.principal);
|
|
6467
6484
|
const hits = recallMemoryVNextLocal({
|
|
6468
6485
|
query,
|
|
6469
6486
|
entities: catalog.entities,
|
|
6470
|
-
states: catalog.states.filter((s) => !s.retiredAt && s.text.trim())
|
|
6487
|
+
states: catalog.states.filter((s) => !s.retiredAt && s.facet !== "work-context" && s.text.trim())
|
|
6471
6488
|
});
|
|
6472
6489
|
if (hits.length === 0) return null;
|
|
6473
6490
|
const { mergeAndDedupUserData } = await import("./userDataMerge-HT2ZVHBJ.js");
|
|
6474
|
-
const localItems = hits.map((hit) => {
|
|
6491
|
+
const localItems = await Promise.all(hits.map(async (hit) => {
|
|
6475
6492
|
const value = hit.state.value ?? {};
|
|
6493
|
+
const evidence = (await Promise.all((hit.state.evidenceIds ?? []).map(
|
|
6494
|
+
(id) => getMemoryEvidenceVNextStrict(ctx.db, ctx.principal, id)
|
|
6495
|
+
))).filter((item) => item != null && item.ownerId === ctx.principal);
|
|
6476
6496
|
return {
|
|
6477
6497
|
id: `vnext-state-${hit.state.id}`,
|
|
6478
6498
|
ownerType: "user",
|
|
@@ -6486,10 +6506,14 @@ function buildServerPlatformToolExecutors(args) {
|
|
|
6486
6506
|
lastActivatedAt: hit.state.createdAt,
|
|
6487
6507
|
activationCount: 1,
|
|
6488
6508
|
importance: typeof value.importance === "number" ? value.importance : 0.9,
|
|
6489
|
-
|
|
6509
|
+
...typeof value.confidence === "number" && Number.isFinite(value.confidence) ? { confidence: value.confidence } : {},
|
|
6510
|
+
...["verified", "stated", "inferred"].includes(value.provenance) ? { provenance: value.provenance } : {},
|
|
6511
|
+
...typeof value.sourceKind === "string" ? { sourceKind: value.sourceKind } : {},
|
|
6512
|
+
...typeof value.sourceDialogId === "string" ? { sourceDialogId: value.sourceDialogId } : {},
|
|
6513
|
+
evidence,
|
|
6490
6514
|
sourceOrigin: "local"
|
|
6491
6515
|
};
|
|
6492
|
-
});
|
|
6516
|
+
}));
|
|
6493
6517
|
const merged = mergeAndDedupUserData(localItems, [{ data: { data: remoteItems } }]);
|
|
6494
6518
|
const hasNewLocal = merged.some((item) => item.sourceOrigin === "local");
|
|
6495
6519
|
if (!hasNewLocal) return null;
|
|
@@ -6511,7 +6535,7 @@ function buildServerPlatformToolExecutors(args) {
|
|
|
6511
6535
|
for (let i = ordered.length - 1; i >= 0; i -= 1) {
|
|
6512
6536
|
if (isTombstoneRecord2(ordered[i])) ordered.splice(i, 1);
|
|
6513
6537
|
}
|
|
6514
|
-
const { buildMemoryOverlay, DEFAULT_MEMORY_OVERLAY_TOKEN_BUDGET } = await import("./overlay-
|
|
6538
|
+
const { buildMemoryOverlay, DEFAULT_MEMORY_OVERLAY_TOKEN_BUDGET } = await import("./overlay-JA3SPVUS.js");
|
|
6515
6539
|
const promptBlock = buildMemoryOverlay(ordered, {
|
|
6516
6540
|
maxTokens: DEFAULT_MEMORY_OVERLAY_TOKEN_BUDGET
|
|
6517
6541
|
});
|
|
@@ -6520,8 +6544,42 @@ function buildServerPlatformToolExecutors(args) {
|
|
|
6520
6544
|
const writeLocalMemory = async (input) => {
|
|
6521
6545
|
const ctx = await localMemoryContext();
|
|
6522
6546
|
if (!ctx) return false;
|
|
6547
|
+
if (input.topicKey) {
|
|
6548
|
+
const { normalizeTopicKey, rememberExplicitVNext } = await import("./rememberExplicit-CPAPONSI.js");
|
|
6549
|
+
const topicKey = normalizeTopicKey(input.topicKey);
|
|
6550
|
+
if (topicKey) {
|
|
6551
|
+
const now = input.createdAt || (/* @__PURE__ */ new Date()).toISOString();
|
|
6552
|
+
const kind = ["episodic", "semantic", "procedural"].includes(input.kind) ? input.kind : "episodic";
|
|
6553
|
+
const validSubjectTypes = ["user", "agent", "space", "project", "system"];
|
|
6554
|
+
const hasValidSubject = typeof input.subjectType === "string" && validSubjectTypes.includes(input.subjectType) && typeof input.subjectId === "string" && input.subjectId.trim().length > 0;
|
|
6555
|
+
const trimmedAgentKey = args.agentKey?.trim() || "";
|
|
6556
|
+
const useAgentSubject = (input.scope ?? "auto") === "auto" && Boolean(trimmedAgentKey);
|
|
6557
|
+
const subjectType = hasValidSubject ? input.subjectType : useAgentSubject ? "agent" : "user";
|
|
6558
|
+
const subjectId = hasValidSubject ? input.subjectId.trim() : useAgentSubject ? trimmedAgentKey : ctx.userId;
|
|
6559
|
+
await rememberExplicitVNext(ctx.db, {
|
|
6560
|
+
id: "",
|
|
6561
|
+
ownerType: "user",
|
|
6562
|
+
ownerId: ctx.userId,
|
|
6563
|
+
visibility: "private",
|
|
6564
|
+
subjectType,
|
|
6565
|
+
subjectId,
|
|
6566
|
+
kind,
|
|
6567
|
+
content: input.content,
|
|
6568
|
+
createdAt: now,
|
|
6569
|
+
lastActivatedAt: now,
|
|
6570
|
+
activationCount: 0,
|
|
6571
|
+
importance: kind === "procedural" ? 0.88 : 0.82,
|
|
6572
|
+
confidence: input.confidence,
|
|
6573
|
+
...input.tags?.length ? { tags: input.tags } : {},
|
|
6574
|
+
...input.provenance === "verified" || input.provenance === "stated" || input.provenance === "inferred" ? { provenance: input.provenance } : {},
|
|
6575
|
+
...input.sourceKind === "explicit-user-directive" || input.sourceKind === "agent-tool" || input.sourceKind === "inferred-understanding" || input.sourceKind === "dialog-learning" ? { sourceKind: input.sourceKind } : {},
|
|
6576
|
+
topicKey
|
|
6577
|
+
});
|
|
6578
|
+
return true;
|
|
6579
|
+
}
|
|
6580
|
+
}
|
|
6523
6581
|
const [{ putMemoryEntityVNext, putMemoryStateVNext, putMemoryEvidenceVNext }, { buildLegacyMemoryEvidence }] = await Promise.all([
|
|
6524
|
-
import("./store-
|
|
6582
|
+
import("./store-Z53ICFL3.js"),
|
|
6525
6583
|
import("./legacyMigration-TF4SYJCZ.js")
|
|
6526
6584
|
]);
|
|
6527
6585
|
const contentKey = `mem-${shortHash(
|
|
@@ -6562,6 +6620,8 @@ function buildServerPlatformToolExecutors(args) {
|
|
|
6562
6620
|
kind: input.kind,
|
|
6563
6621
|
contentKey,
|
|
6564
6622
|
origin: "cli-local",
|
|
6623
|
+
...input.provenance ? { provenance: input.provenance } : {},
|
|
6624
|
+
...input.sourceKind ? { sourceKind: input.sourceKind } : {},
|
|
6565
6625
|
...input.tags?.length ? { tags: input.tags } : {}
|
|
6566
6626
|
},
|
|
6567
6627
|
text: input.content,
|
|
@@ -6574,7 +6634,7 @@ function buildServerPlatformToolExecutors(args) {
|
|
|
6574
6634
|
const retireLocalMemory = async (filter) => {
|
|
6575
6635
|
const ctx = await localMemoryContext();
|
|
6576
6636
|
if (!ctx) return { retired: 0, localOnlyRetired: 0, skippedRemoteMiss: 0 };
|
|
6577
|
-
const { loadMemoryVNextCatalog, retireMemoryStateVNext } = await import("./store-
|
|
6637
|
+
const { loadMemoryVNextCatalog, retireMemoryStateVNext } = await import("./store-Z53ICFL3.js");
|
|
6578
6638
|
const catalog = await loadMemoryVNextCatalog(ctx.db, ctx.principal);
|
|
6579
6639
|
if (catalog.states.length === 0) {
|
|
6580
6640
|
return { retired: 0, localOnlyRetired: 0, skippedRemoteMiss: 0 };
|
|
@@ -6617,8 +6677,47 @@ function buildServerPlatformToolExecutors(args) {
|
|
|
6617
6677
|
}
|
|
6618
6678
|
return { retired, localOnlyRetired, skippedRemoteMiss };
|
|
6619
6679
|
};
|
|
6680
|
+
const workMemory = async (call, parsed, write) => {
|
|
6681
|
+
const context = call.runtimeContext;
|
|
6682
|
+
const dialogId = context?.dialogId;
|
|
6683
|
+
const userMessageId = context?.userMessageId;
|
|
6684
|
+
if (typeof dialogId !== "string" || write && typeof userMessageId !== "string") throw new Error("work memory requires host dialogId and persisted userMessageId");
|
|
6685
|
+
const fields = write ? ["itemKey", "activityId", "expectedRevision", "changeId", "patch"] : ["activityId", "status", "query", "limit", "discovery"];
|
|
6686
|
+
const payload = Object.fromEntries(fields.filter((k) => parsed[k] !== void 0 && parsed[k] !== "").map((k) => [k, parsed[k]]));
|
|
6687
|
+
if (parsed.storage !== void 0 && parsed.storage !== "server" && parsed.storage !== "local") throw new Error("invalid work storage");
|
|
6688
|
+
const { formatWorkContextWriteNotice } = await import("./workContextWriteNotice-YCSSMHN4.js");
|
|
6689
|
+
const writeResult = (result2, priorNotice, storage) => ({
|
|
6690
|
+
...result2,
|
|
6691
|
+
notice: [formatWorkContextWriteNotice(result2, storage ? { storage } : void 0), priorNotice].filter((v) => typeof v === "string" && v !== "").join("\n")
|
|
6692
|
+
});
|
|
6693
|
+
const workMetadata = { serverPlatformTool: true, memoryWrite: write, memoryRead: !write };
|
|
6694
|
+
if (parsed.storage === "server") {
|
|
6695
|
+
const content2 = await postServer(write ? "/api/memory/remember" : "/api/memory/query", { mode: "work", ...payload, dialogId, ...write ? { userMessageId } : {} });
|
|
6696
|
+
if (!write) return { content: content2, metadata: workMetadata };
|
|
6697
|
+
let served;
|
|
6698
|
+
try {
|
|
6699
|
+
served = JSON.parse(content2);
|
|
6700
|
+
} catch {
|
|
6701
|
+
return { content: content2, metadata: workMetadata };
|
|
6702
|
+
}
|
|
6703
|
+
return { content: JSON.stringify(writeResult(served, typeof served?.notice === "string" ? served.notice : void 0, "server")), metadata: workMetadata };
|
|
6704
|
+
}
|
|
6705
|
+
const ctx = await localMemoryContext();
|
|
6706
|
+
if (!ctx) throw new Error("local work memory unavailable");
|
|
6707
|
+
const { resolveLocalUserId: resolveLocalUserId2 } = await import("./cliAgentConfigHelpers-37ZNEY5Y.js");
|
|
6708
|
+
const localUserId = resolveLocalUserId2(args.env);
|
|
6709
|
+
const { resolveWorkContextAccess } = await import("./workContextAccess-UZHDLBUR.js");
|
|
6710
|
+
const { updateWorkContext, readWorkContexts } = await import("./workContext-Y3ADAPZU.js");
|
|
6711
|
+
const { scope, sourceRef } = await resolveWorkContextAccess(ctx.db, localUserId, dialogId, write ? userMessageId : void 0);
|
|
6712
|
+
if (scope.spaceId) throw new Error("local work memory cannot verify space membership");
|
|
6713
|
+
const result = write ? await updateWorkContext(ctx.db, scope, { ...payload.activityId !== void 0 ? { activityId: payload.activityId, expectedRevision: payload.expectedRevision } : { itemKey: payload.itemKey, originRef: sourceRef }, changeId: payload.changeId, sourceRefs: [sourceRef], patch: payload.patch }) : await readWorkContexts(ctx.db, scope, payload);
|
|
6714
|
+
const storageNotice = "Local and server stores are independent; changeId deduplication covers actual changes only.";
|
|
6715
|
+
const content = write ? { ...writeResult(result, storageNotice, "local"), storage: "local" } : { ...result, storage: "local", notice: storageNotice };
|
|
6716
|
+
return { content: JSON.stringify(content), metadata: workMetadata };
|
|
6717
|
+
};
|
|
6620
6718
|
const queryMemory = async (call) => {
|
|
6621
6719
|
const parsed = parseNoloWorkspaceToolArguments(call.arguments);
|
|
6720
|
+
if (parsed.mode === "work") return workMemory(call, parsed, false);
|
|
6622
6721
|
const query = typeof parsed.query === "string" ? parsed.query.trim() : "";
|
|
6623
6722
|
if (!query) {
|
|
6624
6723
|
return {
|
|
@@ -6626,14 +6725,25 @@ function buildServerPlatformToolExecutors(args) {
|
|
|
6626
6725
|
metadata: { serverPlatformTool: true, memoryRead: false }
|
|
6627
6726
|
};
|
|
6628
6727
|
}
|
|
6728
|
+
if (parsed.source !== void 0 && parsed.source !== "archive") {
|
|
6729
|
+
return { content: JSON.stringify({ error: "Invalid memory source" }), metadata: { serverPlatformTool: true, memoryRead: false } };
|
|
6730
|
+
}
|
|
6731
|
+
if (parsed.source === void 0 && (parsed.limit !== void 0 || parsed.cursor !== void 0)) {
|
|
6732
|
+
return { content: JSON.stringify({ error: "Pagination requires source archive" }), metadata: { serverPlatformTool: true, memoryRead: false } };
|
|
6733
|
+
}
|
|
6629
6734
|
const body = { userInput: query };
|
|
6735
|
+
if (parsed.source === "archive") {
|
|
6736
|
+
body.source = parsed.source;
|
|
6737
|
+
if (parsed.limit !== void 0) body.limit = parsed.limit;
|
|
6738
|
+
if (parsed.cursor !== void 0) body.cursor = parsed.cursor;
|
|
6739
|
+
}
|
|
6630
6740
|
if (args.agentKey) body.agentKey = args.agentKey;
|
|
6631
6741
|
const raw = await postServer("/api/memory/query", body, {
|
|
6632
6742
|
retryTransient: true
|
|
6633
6743
|
});
|
|
6634
6744
|
let content = raw;
|
|
6635
6745
|
try {
|
|
6636
|
-
const merged = await mergeLocalMemoryIntoQuery(query, raw);
|
|
6746
|
+
const merged = parsed.source === "archive" ? null : await mergeLocalMemoryIntoQuery(query, raw);
|
|
6637
6747
|
if (merged) content = merged;
|
|
6638
6748
|
} catch {
|
|
6639
6749
|
}
|
|
@@ -6644,6 +6754,7 @@ function buildServerPlatformToolExecutors(args) {
|
|
|
6644
6754
|
};
|
|
6645
6755
|
const rememberMemory = async (call) => {
|
|
6646
6756
|
const parsed = parseNoloWorkspaceToolArguments(call.arguments);
|
|
6757
|
+
if (parsed.mode === "work") return workMemory(call, parsed, true);
|
|
6647
6758
|
const content = typeof parsed.content === "string" ? parsed.content.trim() : "";
|
|
6648
6759
|
if (!content) {
|
|
6649
6760
|
return {
|
|
@@ -6659,9 +6770,28 @@ function buildServerPlatformToolExecutors(args) {
|
|
|
6659
6770
|
kind: parsed.kind ?? "episodic",
|
|
6660
6771
|
source: "agent-inferred"
|
|
6661
6772
|
};
|
|
6773
|
+
if (["verified", "stated", "inferred"].includes(parsed.provenance)) body.provenance = parsed.provenance;
|
|
6662
6774
|
if (typeof parsed.recurrenceEvidence === "string" && parsed.recurrenceEvidence.trim()) {
|
|
6663
6775
|
body.recurrenceEvidence = parsed.recurrenceEvidence.trim();
|
|
6664
6776
|
}
|
|
6777
|
+
if (parsed.topicKey !== void 0 && parsed.topicKey !== null) {
|
|
6778
|
+
if (typeof parsed.topicKey !== "string") {
|
|
6779
|
+
return {
|
|
6780
|
+
content: JSON.stringify({ error: "rememberMemory: topicKey must be a string" }),
|
|
6781
|
+
metadata: { serverPlatformTool: true, memoryWrite: false }
|
|
6782
|
+
};
|
|
6783
|
+
}
|
|
6784
|
+
const { normalizeTopicKey } = await import("./rememberExplicit-CPAPONSI.js");
|
|
6785
|
+
try {
|
|
6786
|
+
const normalizedTopicKey = normalizeTopicKey(parsed.topicKey);
|
|
6787
|
+
if (normalizedTopicKey) body.topicKey = normalizedTopicKey;
|
|
6788
|
+
} catch (err) {
|
|
6789
|
+
return {
|
|
6790
|
+
content: JSON.stringify({ error: err?.message ?? "invalid topicKey" }),
|
|
6791
|
+
metadata: { serverPlatformTool: true, memoryWrite: false }
|
|
6792
|
+
};
|
|
6793
|
+
}
|
|
6794
|
+
}
|
|
6665
6795
|
if (args.agentKey) body.agentKey = args.agentKey;
|
|
6666
6796
|
const raw = await postServer("/api/memory/remember", body, {
|
|
6667
6797
|
retryTransient: true
|
|
@@ -6674,12 +6804,21 @@ function buildServerPlatformToolExecutors(args) {
|
|
|
6674
6804
|
} catch {
|
|
6675
6805
|
}
|
|
6676
6806
|
const saved = Array.isArray(serverResult?.savedItems) ? serverResult.savedItems[0] : null;
|
|
6807
|
+
const resolvedTopicKey = typeof saved?.topicKey === "string" ? saved.topicKey : typeof body.topicKey === "string" ? body.topicKey : void 0;
|
|
6808
|
+
const validSubjectTypes = ["user", "agent", "space", "project", "system"];
|
|
6809
|
+
const savedSubjectType = typeof saved?.subjectType === "string" && validSubjectTypes.includes(saved.subjectType) ? saved.subjectType : void 0;
|
|
6810
|
+
const savedSubjectId = typeof saved?.subjectId === "string" && saved.subjectId.trim() ? saved.subjectId.trim() : void 0;
|
|
6677
6811
|
localSaved = await writeLocalMemory({
|
|
6678
6812
|
content: typeof saved?.content === "string" && saved.content.trim() ? saved.content : content,
|
|
6679
6813
|
kind: String(saved?.kind ?? serverResult?.savedKind ?? body.kind ?? "episodic"),
|
|
6680
6814
|
createdAt: typeof saved?.createdAt === "string" && saved.createdAt ? saved.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
6681
6815
|
confidence: typeof saved?.confidence === "number" ? saved.confidence : 0.8,
|
|
6682
|
-
|
|
6816
|
+
provenance: typeof saved?.provenance === "string" ? saved.provenance : void 0,
|
|
6817
|
+
sourceKind: typeof saved?.sourceKind === "string" ? saved.sourceKind : void 0,
|
|
6818
|
+
tags: Array.isArray(saved?.tags) ? saved.tags.map(String) : void 0,
|
|
6819
|
+
scope: typeof body.scope === "string" ? body.scope : "auto",
|
|
6820
|
+
...savedSubjectType && savedSubjectId ? { subjectType: savedSubjectType, subjectId: savedSubjectId } : {},
|
|
6821
|
+
...resolvedTopicKey ? { topicKey: resolvedTopicKey } : {}
|
|
6683
6822
|
});
|
|
6684
6823
|
} catch {
|
|
6685
6824
|
}
|
|
@@ -6813,9 +6952,194 @@ function buildServerPlatformToolExecutors(args) {
|
|
|
6813
6952
|
};
|
|
6814
6953
|
}
|
|
6815
6954
|
|
|
6955
|
+
// packages/cli/client/workspaceIsolation.ts
|
|
6956
|
+
import * as fs from "node:fs";
|
|
6957
|
+
import { execFileSync } from "node:child_process";
|
|
6958
|
+
import { createHash as createHash3 } from "node:crypto";
|
|
6959
|
+
import { homedir } from "node:os";
|
|
6960
|
+
import { basename, dirname as dirname2, isAbsolute, join as join2, relative, resolve, sep } from "node:path";
|
|
6961
|
+
var WorkspaceIsolationError = class extends Error {
|
|
6962
|
+
code = "workspace_isolation_refused";
|
|
6963
|
+
};
|
|
6964
|
+
var dependencies = /* @__PURE__ */ new Set(["node_modules", ".venv"]);
|
|
6965
|
+
var refuse = (reason) => {
|
|
6966
|
+
throw new WorkspaceIsolationError(`${reason}\uFF1B\u8BF7\u7F29\u5C0F\u5230\u5177\u4F53\u5B50\u6587\u4EF6\u5939\u540E\u91CD\u8BD5 workspaceIsolation:auto`);
|
|
6967
|
+
};
|
|
6968
|
+
function prepareWorkspaceIsolation(options) {
|
|
6969
|
+
const { baseCwd, runId, mode = "none", readOnly, platform = process.platform } = options;
|
|
6970
|
+
if (mode !== "auto" || readOnly === true) return { mode, kind: "none", effectiveCwd: baseCwd };
|
|
6971
|
+
if (!/^[a-zA-Z0-9_-]{1,128}$/.test(runId)) refuse("\u4E0D\u5B89\u5168\u7684 runId");
|
|
6972
|
+
const exec = options.execFile ?? execFileSync;
|
|
6973
|
+
const command = (file, args) => String(exec(file, args, { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"], timeout: 3e4, env: { ...process.env, LC_ALL: "C", LANG: "C" } }));
|
|
6974
|
+
const source = fs.realpathSync(baseCwd);
|
|
6975
|
+
let repoRoot;
|
|
6976
|
+
try {
|
|
6977
|
+
repoRoot = command("git", ["-C", source, "rev-parse", "--show-toplevel"]).trim();
|
|
6978
|
+
} catch (error) {
|
|
6979
|
+
if (error.code === "ENOENT") {
|
|
6980
|
+
for (let ancestor = source; ; ancestor = dirname2(ancestor)) {
|
|
6981
|
+
try {
|
|
6982
|
+
fs.lstatSync(join2(ancestor, ".git"));
|
|
6983
|
+
throw new WorkspaceIsolationError("\u68C0\u6D4B\u5230 Git \u4ED3\u5E93\uFF0C\u4F46 Git \u547D\u4EE4\u672A\u5B89\u88C5\uFF1B\u8BF7\u5B89\u88C5 Git \u540E\u91CD\u8BD5");
|
|
6984
|
+
} catch (markerError) {
|
|
6985
|
+
if (markerError.code !== "ENOENT") throw markerError;
|
|
6986
|
+
}
|
|
6987
|
+
if (ancestor === dirname2(ancestor)) break;
|
|
6988
|
+
}
|
|
6989
|
+
} else if (!String(error.stderr).includes("not a git repository")) {
|
|
6990
|
+
throw error;
|
|
6991
|
+
}
|
|
6992
|
+
}
|
|
6993
|
+
const linkDependencies = (from, to) => {
|
|
6994
|
+
for (const name of dependencies) {
|
|
6995
|
+
const target = join2(from, name), link = join2(to, name);
|
|
6996
|
+
try {
|
|
6997
|
+
if (fs.statSync(target).isDirectory() && !fs.existsSync(link)) fs.symlinkSync(target, link, platform === "win32" ? "junction" : "dir");
|
|
6998
|
+
} catch {
|
|
6999
|
+
}
|
|
7000
|
+
}
|
|
7001
|
+
};
|
|
7002
|
+
if (repoRoot) {
|
|
7003
|
+
repoRoot = fs.realpathSync(repoRoot);
|
|
7004
|
+
const subRel = relative(repoRoot, source);
|
|
7005
|
+
if (isAbsolute(subRel) || subRel.split(/[\\/]/).includes("..")) refuse("\u76EE\u5F55\u4E0D\u5728\u4ED3\u5E93\u5185");
|
|
7006
|
+
const shortId = createHash3("sha256").update(runId).digest("hex").slice(0, 12);
|
|
7007
|
+
const commonDirOutput = command("git", ["-C", source, "rev-parse", "--git-common-dir"]).trim();
|
|
7008
|
+
const commonDir = fs.realpathSync(resolve(source, commonDirOutput));
|
|
7009
|
+
const worktreeHostRoot = basename(commonDir) === ".git" ? dirname2(commonDir) : repoRoot;
|
|
7010
|
+
const root2 = join2(worktreeHostRoot, ".worktrees", `run-${shortId}`), branch = `nolo/run-${shortId}`;
|
|
7011
|
+
if (platform === "win32" && root2.length > 210) refuse("\u9694\u79BB\u76EE\u5F55\u8DEF\u5F84\u8FC7\u957F");
|
|
7012
|
+
command("git", ["-C", repoRoot, "-c", "checkout.workers=0", "-c", "core.longpaths=true", "worktree", "add", root2, "-b", branch, "HEAD"]);
|
|
7013
|
+
linkDependencies(repoRoot, root2);
|
|
7014
|
+
if (worktreeHostRoot !== repoRoot) linkDependencies(worktreeHostRoot, root2);
|
|
7015
|
+
return { mode, kind: "git-worktree", effectiveCwd: join2(root2, subRel), root: root2, sourceRoot: repoRoot, branch };
|
|
7016
|
+
}
|
|
7017
|
+
if (source === dirname2(source) || source === fs.realpathSync(homedir())) refuse("\u4E0D\u80FD\u9694\u79BB\u6587\u4EF6\u7CFB\u7EDF\u6839\u76EE\u5F55\u6216\u7528\u6237\u4E3B\u76EE\u5F55");
|
|
7018
|
+
let files = 0, bytes = 0, entries = 0;
|
|
7019
|
+
const scan = (dir, top, depth = 0) => {
|
|
7020
|
+
if (depth > 64) refuse("\u76EE\u5F55\u5D4C\u5957\u8D85\u8FC7 64 \u5C42\u4E0A\u9650");
|
|
7021
|
+
const handle = fs.opendirSync(dir);
|
|
7022
|
+
try {
|
|
7023
|
+
let entry;
|
|
7024
|
+
while (entry = handle.readSync()) {
|
|
7025
|
+
if (top && dependencies.has(entry.name)) continue;
|
|
7026
|
+
if (++entries > 4e3) refuse("\u76EE\u5F55\u6761\u76EE\u8D85\u8FC7 4000 \u4E0A\u9650");
|
|
7027
|
+
const path = join2(dir, entry.name), stat = fs.lstatSync(path);
|
|
7028
|
+
if (stat.isSymbolicLink() || !stat.isDirectory() && !stat.isFile()) refuse("\u666E\u901A\u4E1A\u52A1\u76EE\u5F55\u542B\u7B26\u53F7\u94FE\u63A5\u6216\u7279\u6B8A\u6587\u4EF6\uFF0C\u4E0D\u80FD\u5B89\u5168\u590D\u5236");
|
|
7029
|
+
if (stat.isDirectory()) scan(path, false, depth + 1);
|
|
7030
|
+
else if (++files > (options.maxFiles ?? 2e3) || (bytes += stat.size) > (options.maxBytes ?? 200 * 1024 * 1024)) refuse("\u76EE\u5F55\u8D85\u8FC7\u6587\u4EF6\u6570\u6216\u603B\u5927\u5C0F\u4E0A\u9650\uFF082000 \u6587\u4EF6 / 200 MiB\uFF09");
|
|
7031
|
+
}
|
|
7032
|
+
} finally {
|
|
7033
|
+
handle.closeSync();
|
|
7034
|
+
}
|
|
7035
|
+
};
|
|
7036
|
+
scan(source, true);
|
|
7037
|
+
const root = resolve(options.noloHome ?? join2(homedir(), ".nolo"), "workspaces", runId);
|
|
7038
|
+
const rel = relative(source, root);
|
|
7039
|
+
if (!rel || !rel.startsWith(`..${sep}`) && rel !== ".." && !isAbsolute(rel)) refuse("\u5FEB\u7167\u76EE\u6807\u4E0D\u80FD\u4F4D\u4E8E\u6E90\u76EE\u5F55\u5185");
|
|
7040
|
+
fs.mkdirSync(dirname2(root), { recursive: true });
|
|
7041
|
+
fs.mkdirSync(root);
|
|
7042
|
+
try {
|
|
7043
|
+
for (const entry of fs.readdirSync(source)) {
|
|
7044
|
+
if (dependencies.has(entry)) continue;
|
|
7045
|
+
const from = join2(source, entry), to = join2(root, entry);
|
|
7046
|
+
let copied = false;
|
|
7047
|
+
try {
|
|
7048
|
+
if (platform === "darwin") {
|
|
7049
|
+
command("cp", ["-cR", from, to]);
|
|
7050
|
+
copied = true;
|
|
7051
|
+
} else if (platform === "linux") {
|
|
7052
|
+
command("cp", ["-a", "--reflink=always", "--", from, to]);
|
|
7053
|
+
copied = true;
|
|
7054
|
+
}
|
|
7055
|
+
} catch {
|
|
7056
|
+
}
|
|
7057
|
+
if (!copied) fs.cpSync(from, to, { recursive: true, force: true, dereference: false });
|
|
7058
|
+
}
|
|
7059
|
+
linkDependencies(source, root);
|
|
7060
|
+
} catch (error) {
|
|
7061
|
+
try {
|
|
7062
|
+
rollbackWorkspaceIsolation({ mode, kind: "directory-snapshot", effectiveCwd: root, root, sourceRoot: source });
|
|
7063
|
+
} catch (cleanupError) {
|
|
7064
|
+
throw new AggregateError([error, cleanupError], `\u590D\u5236\u5931\u8D25\uFF1B\u9694\u79BB\u76EE\u5F55\u4FDD\u7559\u5F85\u5904\u7406: ${root}`);
|
|
7065
|
+
}
|
|
7066
|
+
throw error;
|
|
7067
|
+
}
|
|
7068
|
+
return { mode, kind: "directory-snapshot", effectiveCwd: root, root, sourceRoot: source };
|
|
7069
|
+
}
|
|
7070
|
+
function rollbackWorkspaceIsolation(workspace) {
|
|
7071
|
+
const { root, sourceRoot, branch, kind } = workspace;
|
|
7072
|
+
if (!root || !sourceRoot) return;
|
|
7073
|
+
if (kind === "git-worktree") {
|
|
7074
|
+
const git = (args) => String(execFileSync("git", ["-C", sourceRoot, ...args], { encoding: "utf8" }));
|
|
7075
|
+
for (const name of dependencies) {
|
|
7076
|
+
const link = join2(root, name), original = join2(sourceRoot, name);
|
|
7077
|
+
if (!git(["-C", root, "ls-files", "--", name]).trim()) {
|
|
7078
|
+
try {
|
|
7079
|
+
if (fs.lstatSync(link).isSymbolicLink() && fs.realpathSync(link) === fs.realpathSync(original)) fs.unlinkSync(link);
|
|
7080
|
+
} catch (error) {
|
|
7081
|
+
if (error.code !== "ENOENT") throw error;
|
|
7082
|
+
}
|
|
7083
|
+
}
|
|
7084
|
+
}
|
|
7085
|
+
if (git(["-C", root, "status", "--porcelain", "--ignored"]).trim()) throw new Error(`\u9694\u79BB\u76EE\u5F55\u542B\u672A\u9A8C\u8BC1\u5185\u5BB9\uFF0C\u4FDD\u7559 ${root}`);
|
|
7086
|
+
execFileSync("git", ["-C", sourceRoot, "merge-base", "--is-ancestor", branch, "HEAD"]);
|
|
7087
|
+
git(["worktree", "remove", root]);
|
|
7088
|
+
git(["branch", "-d", branch]);
|
|
7089
|
+
} else if (kind === "directory-snapshot") {
|
|
7090
|
+
const verify = (path) => {
|
|
7091
|
+
for (const entry of fs.readdirSync(path)) {
|
|
7092
|
+
const target = join2(path, entry), original = join2(sourceRoot, relative(root, target));
|
|
7093
|
+
const stat = fs.lstatSync(target);
|
|
7094
|
+
if (path === root && dependencies.has(entry) && stat.isSymbolicLink() && fs.realpathSync(target) === fs.realpathSync(original)) continue;
|
|
7095
|
+
if (stat.isDirectory() && fs.statSync(original).isDirectory()) verify(target);
|
|
7096
|
+
else if (!stat.isFile() || !fs.statSync(original).isFile() || !fs.readFileSync(target).equals(fs.readFileSync(original))) throw new Error(`\u9694\u79BB\u526F\u672C\u6709\u552F\u4E00\u5185\u5BB9\uFF0C\u4FDD\u7559 ${root}`);
|
|
7097
|
+
}
|
|
7098
|
+
};
|
|
7099
|
+
verify(root);
|
|
7100
|
+
fs.rmSync(root, { recursive: true });
|
|
7101
|
+
}
|
|
7102
|
+
}
|
|
7103
|
+
|
|
7104
|
+
// packages/cli/client/childRunImages.ts
|
|
7105
|
+
import { isAbsolute as isAbsolute2 } from "node:path";
|
|
7106
|
+
function validateChildImagePaths(value) {
|
|
7107
|
+
if (value === void 0) return [];
|
|
7108
|
+
if (!Array.isArray(value) || value.length < 1 || value.length > MAX_TOOL_IMAGES_PER_REQUEST || value.some((path) => typeof path !== "string" || !isAbsolute2(path) || path.includes("\0"))) {
|
|
7109
|
+
throw new Error("image_input_invalid: expected 1\u20134 absolute local image paths");
|
|
7110
|
+
}
|
|
7111
|
+
return value;
|
|
7112
|
+
}
|
|
7113
|
+
async function validateChildImages(paths) {
|
|
7114
|
+
let total = 0;
|
|
7115
|
+
const urls = [];
|
|
7116
|
+
for (let index = 0; index < paths.length; index++) {
|
|
7117
|
+
try {
|
|
7118
|
+
const result = await readLocalImage(paths[index]);
|
|
7119
|
+
const image = result.images?.[0];
|
|
7120
|
+
if (!image) throw new Error();
|
|
7121
|
+
total += image.dataBase64.length;
|
|
7122
|
+
if (total > MAX_TOOL_IMAGE_BASE64_BYTES_PER_REQUEST) throw new Error();
|
|
7123
|
+
urls.push(`data:${image.mimeType};base64,${image.dataBase64}`);
|
|
7124
|
+
} catch (error) {
|
|
7125
|
+
const code = error?.code;
|
|
7126
|
+
const reason = code === "ENOENT" ? "not found" : code === "EACCES" || code === "EPERM" ? "not accessible" : "invalid type/content or exceeds image budget";
|
|
7127
|
+
throw new Error(`image_input_invalid: image ${index + 1} unreadable (${reason})`);
|
|
7128
|
+
}
|
|
7129
|
+
}
|
|
7130
|
+
return urls;
|
|
7131
|
+
}
|
|
7132
|
+
async function normalizeCliRunImages(inputs, normalizeRemote) {
|
|
7133
|
+
const local = inputs.filter((input) => !/^(https?:|data:|file:)/i.test(input));
|
|
7134
|
+
if (local.length > MAX_TOOL_IMAGES_PER_REQUEST) throw new Error("image_input_invalid: expected at most 4 local images");
|
|
7135
|
+
const urls = await validateChildImages(local);
|
|
7136
|
+
let index = 0;
|
|
7137
|
+
return inputs.map((input) => /^(https?:|data:|file:)/i.test(input) ? normalizeRemote(input) : urls[index++]);
|
|
7138
|
+
}
|
|
7139
|
+
|
|
6816
7140
|
// packages/cli/agentRunArgs.ts
|
|
6817
|
-
import { readFileSync } from "node:fs";
|
|
6818
|
-
import { isAbsolute } from "node:path";
|
|
7141
|
+
import { readFileSync as readFileSync2 } from "node:fs";
|
|
7142
|
+
import { isAbsolute as isAbsolute3 } from "node:path";
|
|
6819
7143
|
function readFlagValue(args, flag) {
|
|
6820
7144
|
const index = args.indexOf(flag);
|
|
6821
7145
|
if (index < 0) return void 0;
|
|
@@ -6956,7 +7280,7 @@ function parseAgentRunArgs(args, options = {}) {
|
|
|
6956
7280
|
const agentKey = rawAgentKey ? resolveCliAgentKeyInput(rawAgentKey) : void 0;
|
|
6957
7281
|
const explicitMsg = readFlagValue(args, "--msg");
|
|
6958
7282
|
const msgFile = readFlagValue(args, "--msg-file");
|
|
6959
|
-
const fileMessage = msgFile ? (options.readTextFile ?? ((path) =>
|
|
7283
|
+
const fileMessage = msgFile ? (options.readTextFile ?? ((path) => readFileSync2(path, "utf8")))(msgFile) : void 0;
|
|
6960
7284
|
const rawMessage = explicitMsg ?? fileMessage ?? positional.slice(isNoLoginRunShorthand ? 0 : 1).join(" ");
|
|
6961
7285
|
if (!agentKey || !rawMessage.trim()) return null;
|
|
6962
7286
|
const message = rawMessage.trim();
|
|
@@ -7017,7 +7341,7 @@ function parseAgentRunArgs(args, options = {}) {
|
|
|
7017
7341
|
if (!rawInstaboxArtifactDir) {
|
|
7018
7342
|
throw new Error("--runtime-key instabox \u5FC5\u987B\u6307\u5B9A --instabox-artifact-dir <\u7EDD\u5BF9\u8DEF\u5F84>");
|
|
7019
7343
|
}
|
|
7020
|
-
if (!
|
|
7344
|
+
if (!isAbsolute3(rawInstaboxArtifactDir) || rawInstaboxArtifactDir.includes("\0") || rawInstaboxArtifactDir.split("/").includes("..")) {
|
|
7021
7345
|
throw new Error(`--instabox-artifact-dir \u5FC5\u987B\u4E3A\u5408\u6CD5\u7EDD\u5BF9\u8DEF\u5F84\uFF0C\u4E14\u4E0D\u80FD\u5305\u542B .. \u6216\u7A7A\u5B57\u7B26: "${rawInstaboxArtifactDir}"`);
|
|
7022
7346
|
}
|
|
7023
7347
|
if (rawInstaboxWorkspace === "snapshot" && !rawInstaboxManifest) {
|
|
@@ -7122,7 +7446,7 @@ function parseAgentRunArgs(args, options = {}) {
|
|
|
7122
7446
|
}
|
|
7123
7447
|
|
|
7124
7448
|
// packages/cli/client/cliAgentRunToolExecutors.ts
|
|
7125
|
-
import { join as
|
|
7449
|
+
import { dirname as dirname4, join as join4, resolve as resolve4 } from "node:path";
|
|
7126
7450
|
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
7127
7451
|
import * as nodeFs2 from "node:fs";
|
|
7128
7452
|
|
|
@@ -7186,7 +7510,7 @@ function waitForRunTerminal(args) {
|
|
|
7186
7510
|
}
|
|
7187
7511
|
|
|
7188
7512
|
// packages/cli/client/cliAgentRunToolExecutors.ts
|
|
7189
|
-
import { existsSync as
|
|
7513
|
+
import { existsSync as existsSync4, readFileSync as readFileSync5 } from "node:fs";
|
|
7190
7514
|
|
|
7191
7515
|
// packages/cli/client/agentRunSnapshot.ts
|
|
7192
7516
|
function readString(value) {
|
|
@@ -7306,13 +7630,13 @@ function isFailureStatus(status) {
|
|
|
7306
7630
|
function isOrphanedStatus(status) {
|
|
7307
7631
|
return status === "orphaned";
|
|
7308
7632
|
}
|
|
7309
|
-
function
|
|
7633
|
+
function toEpochMs(iso) {
|
|
7310
7634
|
if (!iso) return void 0;
|
|
7311
7635
|
const ms = Date.parse(iso);
|
|
7312
7636
|
return Number.isFinite(ms) ? ms : void 0;
|
|
7313
7637
|
}
|
|
7314
7638
|
function isOverTimeout(run, nowMs, timeoutMs) {
|
|
7315
|
-
const startedMs =
|
|
7639
|
+
const startedMs = toEpochMs(run.startedAt);
|
|
7316
7640
|
if (startedMs === void 0) return false;
|
|
7317
7641
|
return nowMs - startedMs >= timeoutMs;
|
|
7318
7642
|
}
|
|
@@ -7358,7 +7682,7 @@ function aggregateBatch(input) {
|
|
|
7358
7682
|
const { batchId, runs, now } = input;
|
|
7359
7683
|
const timeoutMs = input.timeoutMs ?? DEFAULT_BATCH_TIMEOUT_MS;
|
|
7360
7684
|
const notified = new Set(input.notifiedReasons ?? []);
|
|
7361
|
-
const nowMs =
|
|
7685
|
+
const nowMs = toEpochMs(now) ?? 0;
|
|
7362
7686
|
let success = 0;
|
|
7363
7687
|
let failed = 0;
|
|
7364
7688
|
let orphaned = 0;
|
|
@@ -7432,47 +7756,47 @@ function deriveAgentRunTodoStatus(input) {
|
|
|
7432
7756
|
}
|
|
7433
7757
|
|
|
7434
7758
|
// packages/cli/client/fileSystemStores.ts
|
|
7435
|
-
import { existsSync, mkdirSync, readFileSync as
|
|
7759
|
+
import { existsSync as existsSync3, mkdirSync as mkdirSync2, readFileSync as readFileSync3, writeFileSync } from "node:fs";
|
|
7436
7760
|
import { homedir as nodeHomedir } from "node:os";
|
|
7437
|
-
import { dirname as
|
|
7761
|
+
import { dirname as dirname3, join as join3 } from "node:path";
|
|
7438
7762
|
var nodeFs = {
|
|
7439
|
-
mkdirSync,
|
|
7763
|
+
mkdirSync: mkdirSync2,
|
|
7440
7764
|
writeFileSync,
|
|
7441
|
-
readFileSync:
|
|
7442
|
-
existsSync
|
|
7765
|
+
readFileSync: readFileSync3,
|
|
7766
|
+
existsSync: existsSync3
|
|
7443
7767
|
};
|
|
7444
|
-
function resolveNoloHome(env,
|
|
7768
|
+
function resolveNoloHome(env, homedir3) {
|
|
7445
7769
|
const custom = env?.NOLO_HOME;
|
|
7446
7770
|
if (custom && custom.trim()) return custom.trim();
|
|
7447
7771
|
const ambient = process.env.NOLO_HOME?.trim();
|
|
7448
7772
|
if (ambient) return ambient;
|
|
7449
|
-
return
|
|
7773
|
+
return join3(homedir3(), ".nolo");
|
|
7450
7774
|
}
|
|
7451
|
-
function ensureDir(dir,
|
|
7452
|
-
|
|
7775
|
+
function ensureDir(dir, fs2) {
|
|
7776
|
+
fs2.mkdirSync(dir, { recursive: true });
|
|
7453
7777
|
}
|
|
7454
|
-
function readJson(path,
|
|
7455
|
-
if (!
|
|
7778
|
+
function readJson(path, fs2) {
|
|
7779
|
+
if (!fs2.existsSync(path)) return void 0;
|
|
7456
7780
|
try {
|
|
7457
|
-
const raw =
|
|
7781
|
+
const raw = fs2.readFileSync(path, "utf8");
|
|
7458
7782
|
return JSON.parse(String(raw));
|
|
7459
7783
|
} catch {
|
|
7460
7784
|
return void 0;
|
|
7461
7785
|
}
|
|
7462
7786
|
}
|
|
7463
|
-
function writeJson(path, data,
|
|
7464
|
-
|
|
7787
|
+
function writeJson(path, data, fs2) {
|
|
7788
|
+
fs2.writeFileSync(path, JSON.stringify(data, null, 2));
|
|
7465
7789
|
}
|
|
7466
7790
|
function createFileSystemTodoStore(opts = {}) {
|
|
7467
7791
|
const env = opts.env ?? process.env;
|
|
7468
|
-
const
|
|
7469
|
-
const
|
|
7470
|
-
const noloHome = resolveNoloHome(env,
|
|
7471
|
-
const filePath = opts.filePath ??
|
|
7472
|
-
const oldFilePath =
|
|
7792
|
+
const homedir3 = opts.homedir ?? nodeHomedir;
|
|
7793
|
+
const fs2 = opts.fs ?? nodeFs;
|
|
7794
|
+
const noloHome = resolveNoloHome(env, homedir3);
|
|
7795
|
+
const filePath = opts.filePath ?? join3(noloHome, "agent_run_todos.json");
|
|
7796
|
+
const oldFilePath = join3(noloHome, "todos.json");
|
|
7473
7797
|
const loadMap = () => {
|
|
7474
|
-
if (!opts.filePath && !
|
|
7475
|
-
const oldData = readJson(oldFilePath,
|
|
7798
|
+
if (!opts.filePath && !fs2.existsSync(filePath) && fs2.existsSync(oldFilePath)) {
|
|
7799
|
+
const oldData = readJson(oldFilePath, fs2);
|
|
7476
7800
|
const map2 = /* @__PURE__ */ new Map();
|
|
7477
7801
|
if (oldData?.todos) {
|
|
7478
7802
|
for (const item of oldData.todos) {
|
|
@@ -7494,11 +7818,11 @@ function createFileSystemTodoStore(opts = {}) {
|
|
|
7494
7818
|
}
|
|
7495
7819
|
}
|
|
7496
7820
|
}
|
|
7497
|
-
ensureDir(
|
|
7498
|
-
writeJson(filePath, { todos: [...map2.values()] },
|
|
7821
|
+
ensureDir(dirname3(filePath), fs2);
|
|
7822
|
+
writeJson(filePath, { todos: [...map2.values()] }, fs2);
|
|
7499
7823
|
return map2;
|
|
7500
7824
|
}
|
|
7501
|
-
const data = readJson(filePath,
|
|
7825
|
+
const data = readJson(filePath, fs2);
|
|
7502
7826
|
const map = /* @__PURE__ */ new Map();
|
|
7503
7827
|
if (data?.todos) {
|
|
7504
7828
|
for (const todo of data.todos) {
|
|
@@ -7508,8 +7832,8 @@ function createFileSystemTodoStore(opts = {}) {
|
|
|
7508
7832
|
return map;
|
|
7509
7833
|
};
|
|
7510
7834
|
const persist = (map) => {
|
|
7511
|
-
ensureDir(
|
|
7512
|
-
writeJson(filePath, { todos: [...map.values()] },
|
|
7835
|
+
ensureDir(dirname3(filePath), fs2);
|
|
7836
|
+
writeJson(filePath, { todos: [...map.values()] }, fs2);
|
|
7513
7837
|
};
|
|
7514
7838
|
return {
|
|
7515
7839
|
async getTodo(id) {
|
|
@@ -7539,13 +7863,13 @@ function createFileSystemTodoStore(opts = {}) {
|
|
|
7539
7863
|
}
|
|
7540
7864
|
|
|
7541
7865
|
// packages/cli/client/instaboxRunConfig.ts
|
|
7542
|
-
import { lstatSync, readFileSync as
|
|
7543
|
-
import { isAbsolute as
|
|
7866
|
+
import { lstatSync as lstatSync2, readFileSync as readFileSync4, realpathSync as realpathSync3 } from "node:fs";
|
|
7867
|
+
import { isAbsolute as isAbsolute4, normalize, resolve as resolve3 } from "node:path";
|
|
7544
7868
|
|
|
7545
7869
|
// packages/cli/client/localInstaboxWorkspaceDelivery.ts
|
|
7546
7870
|
import { constants } from "node:fs";
|
|
7547
7871
|
import { open, realpath } from "node:fs/promises";
|
|
7548
|
-
import { createHash as
|
|
7872
|
+
import { createHash as createHash4 } from "node:crypto";
|
|
7549
7873
|
|
|
7550
7874
|
// packages/agent-runtime/instaboxBackend.ts
|
|
7551
7875
|
var INSTABOX_BACKEND_ID = "instabox";
|
|
@@ -7553,6 +7877,7 @@ var INSTABOX_DEFAULT_BASE_URL = "https://api.instabox.sh/v1";
|
|
|
7553
7877
|
var INSTABOX_MAX_EXEC_SECONDS = 600;
|
|
7554
7878
|
var INSTABOX_MAX_STDIN_BYTES = 1024 * 1024;
|
|
7555
7879
|
var SAFE_MESSAGE = {
|
|
7880
|
+
instabox_download_failed: "Instabox file download failed",
|
|
7556
7881
|
instabox_upload_failed: "Instabox file upload failed",
|
|
7557
7882
|
instabox_recovery_failed: "Instabox recovery persistence or authority validation failed",
|
|
7558
7883
|
instabox_recovery_unknown: "Instabox machine identity is unknown; manual reconciliation required",
|
|
@@ -7719,7 +8044,7 @@ var InstaboxBackend = class {
|
|
|
7719
8044
|
...rawBody === void 0 ? {} : { body: rawBody }
|
|
7720
8045
|
});
|
|
7721
8046
|
});
|
|
7722
|
-
this.#sleep = options.sleepImpl ?? ((ms) => new Promise((
|
|
8047
|
+
this.#sleep = options.sleepImpl ?? ((ms) => new Promise((resolve8) => setTimeout(resolve8, ms)));
|
|
7723
8048
|
this.#machineTimeoutSeconds = options.machineTimeoutSeconds ?? 1800;
|
|
7724
8049
|
this.#createTimeoutMs = options.createTimeoutMs ?? 18e4;
|
|
7725
8050
|
this.#deleteTimeoutMs = options.deleteTimeoutMs ?? 12e4;
|
|
@@ -7894,7 +8219,7 @@ var InstaboxBackend = class {
|
|
|
7894
8219
|
if (machine.name !== plan.name) mismatches.push("name mismatch");
|
|
7895
8220
|
if (template?.id !== plan.templateId) mismatches.push("template mismatch");
|
|
7896
8221
|
if (spec?.vcpus !== plan.vcpus || spec?.memMiB !== plan.memMiB || spec?.persistentDiskGiB !== expectedSpec.persistentDiskGiB) mismatches.push("spec mismatch");
|
|
7897
|
-
if (this.#billingPolicy === "free-only" && machine.maxRunMinutes
|
|
8222
|
+
if (this.#billingPolicy === "free-only" && (!Number.isSafeInteger(machine.maxRunMinutes) || machine.maxRunMinutes < 0 || machine.maxRunMinutes > plan.maxRunMinutes)) mismatches.push("maxRunMinutes mismatch");
|
|
7898
8223
|
if (mismatches.length > 0) {
|
|
7899
8224
|
const reason = mismatches.join("; ");
|
|
7900
8225
|
this.#assertDeletionAllowed(machineId, reason);
|
|
@@ -7943,6 +8268,7 @@ var InstaboxBackend = class {
|
|
|
7943
8268
|
const usageBaselineRunningMs = baseline === null ? null : Math.round(baseline.runningSeconds * 1e3);
|
|
7944
8269
|
const leaseId = `${machineId}:${ticket.ticketId}`;
|
|
7945
8270
|
this.#leases.set(leaseId, {
|
|
8271
|
+
ciWritableRoots: [...ticket.filesystem.writableRoots],
|
|
7946
8272
|
recovery: context.record,
|
|
7947
8273
|
machineId,
|
|
7948
8274
|
ticketId: ticket.ticketId,
|
|
@@ -7989,7 +8315,7 @@ var InstaboxBackend = class {
|
|
|
7989
8315
|
};
|
|
7990
8316
|
const fail5 = () => new InstaboxBackendError("instabox_upload_failed");
|
|
7991
8317
|
checkLease();
|
|
7992
|
-
if (!input || typeof input.path !== "string" || !input.path.startsWith("/workspace/") || input.path.endsWith("/") || input.path.split("/").some((p, i) => i > 0 && (!p || p === "." || p === "..")) || /[\\\x00-\x1f\x7f]/.test(input.path) || !(input.bytes instanceof Uint8Array) || input.bytes.byteLength > INSTABOX_MAX_UPLOAD_BYTES || !input.signal || !Number.isFinite(input.deadlineAt)) throw fail5();
|
|
8318
|
+
if (!input || typeof input.path !== "string" || !(input.path.startsWith("/workspace/") || (entry.ciWritableRoots ?? []).some((root) => root.startsWith("/data/home/nolo-ci/") && input.path.startsWith(root + "/"))) || input.path.endsWith("/") || input.path.split("/").some((p, i) => i > 0 && (!p || p === "." || p === "..")) || /[\\\x00-\x1f\x7f]/.test(input.path) || !(input.bytes instanceof Uint8Array) || input.bytes.byteLength > INSTABOX_MAX_UPLOAD_BYTES || !input.signal || !Number.isFinite(input.deadlineAt)) throw fail5();
|
|
7993
8319
|
let base;
|
|
7994
8320
|
try {
|
|
7995
8321
|
base = new URL(this.#baseUrl);
|
|
@@ -8054,6 +8380,44 @@ var InstaboxBackend = class {
|
|
|
8054
8380
|
controller.abort();
|
|
8055
8381
|
}
|
|
8056
8382
|
}
|
|
8383
|
+
/** Raw binary download, bounded and confined to a task-owned lease root. */
|
|
8384
|
+
async downloadFile(lease, input) {
|
|
8385
|
+
const entry = this.#requireEntry(lease);
|
|
8386
|
+
const fail5 = () => new InstaboxBackendError("instabox_download_failed");
|
|
8387
|
+
if (entry.releasedAt !== null || entry.stopState !== null || !Number.isSafeInteger(input.maxBytes) || input.maxBytes < 0 || input.maxBytes > INSTABOX_MAX_UPLOAD_BYTES || !(entry.ciWritableRoots ?? []).some((root) => root.startsWith("/data/home/nolo-ci/") && input.path.startsWith(root + "/")) || input.path.split("/").some((p, i) => i > 0 && (!p || p === "." || p === "..")) || /[\\\x00-\x1f\x7f]/.test(input.path)) throw fail5();
|
|
8388
|
+
const remaining = input.deadlineAt - this.#now();
|
|
8389
|
+
if (input.signal.aborted || remaining <= 0) throw fail5();
|
|
8390
|
+
const signal = AbortSignal.any([input.signal, AbortSignal.timeout(Math.min(remaining, 2147483647))]);
|
|
8391
|
+
const base = new URL(this.#baseUrl);
|
|
8392
|
+
if (base.protocol !== "https:" || base.username || base.password || base.search || base.hash) throw fail5();
|
|
8393
|
+
const response = await this.#fetch(`${this.#baseUrl}/machines/${encodeURIComponent(entry.machineId)}/files/content?path=${encodeURIComponent(input.path)}`, {
|
|
8394
|
+
method: "GET",
|
|
8395
|
+
headers: { "X-API-Key": this.#apiKey },
|
|
8396
|
+
signal,
|
|
8397
|
+
redirect: "error"
|
|
8398
|
+
});
|
|
8399
|
+
const length = response.headers?.get("Content-Length");
|
|
8400
|
+
if (response.status !== 200 || response.redirected || !length || !/^\d+$/.test(length) || Number(length) > input.maxBytes || decodeURIComponent(response.headers?.get("X-Instabox-File-Path") ?? "") !== input.path || !response.body) throw fail5();
|
|
8401
|
+
const reader = response.body.getReader();
|
|
8402
|
+
const chunks = [];
|
|
8403
|
+
let count2 = 0;
|
|
8404
|
+
try {
|
|
8405
|
+
for (; ; ) {
|
|
8406
|
+
signal.throwIfAborted();
|
|
8407
|
+
const part = await reader.read();
|
|
8408
|
+
if (part.done) break;
|
|
8409
|
+
count2 += part.value.byteLength;
|
|
8410
|
+
if (count2 > input.maxBytes || count2 > Number(length)) throw fail5();
|
|
8411
|
+
chunks.push(part.value);
|
|
8412
|
+
}
|
|
8413
|
+
if (count2 !== Number(length)) throw fail5();
|
|
8414
|
+
return Buffer.concat(chunks);
|
|
8415
|
+
} finally {
|
|
8416
|
+
await reader.cancel().catch(() => {
|
|
8417
|
+
});
|
|
8418
|
+
reader.releaseLock();
|
|
8419
|
+
}
|
|
8420
|
+
}
|
|
8057
8421
|
async execute(lease, request, onEvent) {
|
|
8058
8422
|
const entry = this.#requireEntry(lease);
|
|
8059
8423
|
if (entry.releasedAt !== null) {
|
|
@@ -8237,8 +8601,8 @@ var InstaboxBackend = class {
|
|
|
8237
8601
|
try {
|
|
8238
8602
|
await Promise.race([
|
|
8239
8603
|
this.#sleep(Math.min(this.#pollIntervalMs, remaining())),
|
|
8240
|
-
new Promise((
|
|
8241
|
-
timer = setTimeout(
|
|
8604
|
+
new Promise((resolve8) => {
|
|
8605
|
+
timer = setTimeout(resolve8, remaining());
|
|
8242
8606
|
})
|
|
8243
8607
|
]);
|
|
8244
8608
|
} finally {
|
|
@@ -8418,12 +8782,13 @@ var InstaboxBackend = class {
|
|
|
8418
8782
|
const response = await this.#call({ method: "GET", path: `/machines/${encodeURIComponent(machineId)}` });
|
|
8419
8783
|
const machine = asRecord(response.payload);
|
|
8420
8784
|
const spec = asRecord(machine?.spec);
|
|
8421
|
-
if (response.status !== 200 || machine?.id !== machineId || machine.orgId !== plan.orgId || machine.name !== plan.name || asRecord(machine.template)?.id !== plan.templateId || spec?.vcpus !== plan.vcpus || spec?.memMiB !== plan.memMiB || spec?.persistentDiskGiB !== record.persistentDiskGiB || typeof machine.free !== "boolean" || record.billingPolicy === "free-only" &&
|
|
8785
|
+
if (response.status !== 200 || machine?.id !== machineId || machine.orgId !== plan.orgId || machine.name !== plan.name || asRecord(machine.template)?.id !== plan.templateId || spec?.vcpus !== plan.vcpus || spec?.memMiB !== plan.memMiB || spec?.persistentDiskGiB !== record.persistentDiskGiB || typeof machine.free !== "boolean" || record.billingPolicy === "free-only" && machine.free !== true) {
|
|
8422
8786
|
throw this.#withRecovery(new InstaboxBackendError("instabox_recovery_failed"), record);
|
|
8423
8787
|
}
|
|
8424
8788
|
const leaseId = `${machineId}:${record.ticketId}`;
|
|
8425
8789
|
if (this.#leases.has(leaseId)) throw this.#withRecovery(new InstaboxBackendError("instabox_lease_mismatch"), record);
|
|
8426
8790
|
this.#leases.set(leaseId, {
|
|
8791
|
+
ciWritableRoots: [],
|
|
8427
8792
|
recovery: structuredClone(record),
|
|
8428
8793
|
machineId,
|
|
8429
8794
|
ticketId: record.ticketId,
|
|
@@ -8540,8 +8905,8 @@ var InstaboxBackend = class {
|
|
|
8540
8905
|
try {
|
|
8541
8906
|
return await Promise.race([
|
|
8542
8907
|
this.#call({ ...args, timeoutMs: void 0 }),
|
|
8543
|
-
new Promise((
|
|
8544
|
-
timer = setTimeout(() =>
|
|
8908
|
+
new Promise((resolve8) => {
|
|
8909
|
+
timer = setTimeout(() => resolve8({ status: 0, payload: null, transportError: "Timeout" }), args.timeoutMs);
|
|
8545
8910
|
})
|
|
8546
8911
|
]);
|
|
8547
8912
|
} finally {
|
|
@@ -8679,7 +9044,7 @@ function extractInstaboxErrorCode(payload) {
|
|
|
8679
9044
|
|
|
8680
9045
|
// packages/cli/client/localInstaboxWorkspaceDelivery.ts
|
|
8681
9046
|
var SNAPSHOT_LIMITS = { files: 256, fileBytes: 8 * 1024 * 1024, totalBytes: 32 * 1024 * 1024, chunkBytes: 384 * 1024 };
|
|
8682
|
-
var hash = (bytes) =>
|
|
9047
|
+
var hash = (bytes) => createHash4("sha256").update(bytes).digest("hex");
|
|
8683
9048
|
var fail = (code) => {
|
|
8684
9049
|
throw new Error(`instabox_workspace_delivery:${code}`);
|
|
8685
9050
|
};
|
|
@@ -8901,14 +9266,14 @@ function resolveInstaboxRunConfigPath(options) {
|
|
|
8901
9266
|
fail2("missing_path", `\u73AF\u5883\u53D8\u91CF ${INSTABOX_RUN_CONFIG_ENV} \u672A\u8BBE\u7F6E\u6216\u4E3A\u7A7A`);
|
|
8902
9267
|
}
|
|
8903
9268
|
const runsDir = options?.runsDir ?? resolveRunsDir(env);
|
|
8904
|
-
const normalizedRunsDir = normalize(
|
|
8905
|
-
const resolvedTarget =
|
|
9269
|
+
const normalizedRunsDir = normalize(resolve3(runsDir));
|
|
9270
|
+
const resolvedTarget = isAbsolute4(explicitPath) ? normalize(explicitPath) : normalize(resolve3(normalizedRunsDir, explicitPath));
|
|
8906
9271
|
if (resolvedTarget !== normalizedRunsDir && !resolvedTarget.startsWith(normalizedRunsDir.endsWith("/") ? normalizedRunsDir : `${normalizedRunsDir}/`)) {
|
|
8907
9272
|
fail2("path_traversal", `\u914D\u7F6E\u8DEF\u5F84 "${explicitPath}" \u8D8A\u51FA\u4E86\u9650\u5B9A\u7684 runs \u76EE\u5F55 "${normalizedRunsDir}"`);
|
|
8908
9273
|
}
|
|
8909
9274
|
let stats;
|
|
8910
9275
|
try {
|
|
8911
|
-
stats =
|
|
9276
|
+
stats = lstatSync2(resolvedTarget);
|
|
8912
9277
|
} catch (err) {
|
|
8913
9278
|
fail2("file_unreadable", `\u914D\u7F6E\u6587\u4EF6\u4E0D\u53EF\u8BFB\u6216\u4E0D\u5B58\u5728: ${resolvedTarget}`);
|
|
8914
9279
|
}
|
|
@@ -8922,8 +9287,8 @@ function resolveInstaboxRunConfigPath(options) {
|
|
|
8922
9287
|
fail2("file_too_large", `\u914D\u7F6E\u6587\u4EF6\u5927\u5C0F (${stats.size} \u5B57\u8282) \u8D85\u8FC7\u4E0A\u9650 (${INSTABOX_RUN_CONFIG_MAX_BYTES} \u5B57\u8282)`);
|
|
8923
9288
|
}
|
|
8924
9289
|
try {
|
|
8925
|
-
const realTarget =
|
|
8926
|
-
const realRuns =
|
|
9290
|
+
const realTarget = realpathSync3(resolvedTarget);
|
|
9291
|
+
const realRuns = realpathSync3(normalizedRunsDir);
|
|
8927
9292
|
if (realTarget !== realRuns && !realTarget.startsWith(realRuns.endsWith("/") ? realRuns : `${realRuns}/`)) {
|
|
8928
9293
|
fail2("symlink_traversal", `\u914D\u7F6E\u771F\u5B9E\u8DEF\u5F84 "${realTarget}" \u8D8A\u51FA runs \u771F\u5B9E\u76EE\u5F55 "${realRuns}"`);
|
|
8929
9294
|
}
|
|
@@ -8935,7 +9300,7 @@ function loadInstaboxRunConfig(options) {
|
|
|
8935
9300
|
const { resolvedPath } = resolveInstaboxRunConfigPath(options);
|
|
8936
9301
|
let rawText;
|
|
8937
9302
|
try {
|
|
8938
|
-
rawText =
|
|
9303
|
+
rawText = readFileSync4(resolvedPath, "utf8");
|
|
8939
9304
|
} catch (err) {
|
|
8940
9305
|
fail2("file_read_failed", `\u8BFB\u53D6\u914D\u7F6E\u6587\u4EF6\u5931\u8D25: ${err instanceof Error ? err.message : String(err)}`);
|
|
8941
9306
|
}
|
|
@@ -8984,7 +9349,7 @@ function loadInstaboxRunConfig(options) {
|
|
|
8984
9349
|
if (!artifactRootRaw) {
|
|
8985
9350
|
fail2("missing_artifact_root", "artifactRoot (artifact\u76EE\u7684\u76EE\u5F55) \u5FC5\u987B\u4E3A\u975E\u7A7A\u5B57\u7B26\u4E32\uFF0C\u672A\u914D\u7F6E\u6216\u9ED8\u8BA4\u5747\u88AB\u62D2\u7EDD");
|
|
8986
9351
|
}
|
|
8987
|
-
if (!
|
|
9352
|
+
if (!isAbsolute4(artifactRootRaw) || artifactRootRaw.includes("\0") || artifactRootRaw.split("/").includes("..")) {
|
|
8988
9353
|
fail2("invalid_artifact_root", `artifactRoot \u5FC5\u987B\u4E3A\u5408\u6CD5\u7EDD\u5BF9\u8DEF\u5F84: "${artifactRootRaw}"`);
|
|
8989
9354
|
}
|
|
8990
9355
|
const artifactRoot = normalize(artifactRootRaw);
|
|
@@ -9103,7 +9468,7 @@ async function evaluateAutoInstaboxPlacement(input) {
|
|
|
9103
9468
|
}
|
|
9104
9469
|
}
|
|
9105
9470
|
if (effectiveAvailableMb === null) {
|
|
9106
|
-
const note2 = `\u5BBF\u4E3B\u53EF\u7528\u5185\u5B58\u63A2\u6D4B\u5931\u8D25\u6216\u672A\u77E5\uFF08${memoryDiagnosis}\uFF09\uFF1B\u65E0\u6CD5\u5224\u65AD\u662F\u5426\u4F4E\u4E8E\u9884\u7B97\uFF08${LOCAL_TOOL_MEMORY_BUDGET_MB}MB\uFF09\uFF0C\u4FDD\u6301\u9ED8\u8BA4\
|
|
9471
|
+
const note2 = `\u5BBF\u4E3B\u53EF\u7528\u5185\u5B58\u63A2\u6D4B\u5931\u8D25\u6216\u672A\u77E5\uFF08${memoryDiagnosis}\uFF09\uFF1B\u65E0\u6CD5\u5224\u65AD\u662F\u5426\u4F4E\u4E8E\u9884\u7B97\uFF08${LOCAL_TOOL_MEMORY_BUDGET_MB}MB\uFF09\uFF0C\u4FDD\u6301\u9ED8\u8BA4\u5BBF\u4E3B\uFF08\u5199\u578B\u6D3E\u53D1\u4ECD\u987B allowHostWrites: true\uFF09\uFF0C\u4E0D\u81EA\u52A8\u8FC1\u79FB\u3002`;
|
|
9107
9472
|
return {
|
|
9108
9473
|
selectedRuntimeKey: void 0,
|
|
9109
9474
|
reason: "memory_unknown",
|
|
@@ -9120,7 +9485,7 @@ async function evaluateAutoInstaboxPlacement(input) {
|
|
|
9120
9485
|
}
|
|
9121
9486
|
const autoEnabled = input.autoEnabled === true || input.env?.NOLO_INSTABOX_AUTO === "1" || typeof process !== "undefined" && process.env?.NOLO_INSTABOX_AUTO === "1";
|
|
9122
9487
|
if (!autoEnabled) {
|
|
9123
|
-
const note2 = `\u5BBF\u4E3B\u53EF\u7528\u5185\u5B58\u7D27\u7F3A\uFF08${effectiveAvailableMb}MB < ${LOCAL_TOOL_MEMORY_BUDGET_MB}MB\uFF09\uFF0C\u4F46\u672A\u542F\u7528\u81EA\u52A8 Instabox\uFF08\u9700\u8BBE\u7F6E NOLO_INSTABOX_AUTO=1 \u6216\u914D\u7F6E\u5F00\u542F\uFF09\uFF1B\u4FDD\u6301\u9ED8\u8BA4
|
|
9488
|
+
const note2 = `\u5BBF\u4E3B\u53EF\u7528\u5185\u5B58\u7D27\u7F3A\uFF08${effectiveAvailableMb}MB < ${LOCAL_TOOL_MEMORY_BUDGET_MB}MB\uFF09\uFF0C\u4F46\u672A\u542F\u7528\u81EA\u52A8 Instabox\uFF08\u9700\u8BBE\u7F6E NOLO_INSTABOX_AUTO=1 \u6216\u914D\u7F6E\u5F00\u542F\uFF09\uFF1B\u4FDD\u6301\u9ED8\u8BA4\u5BBF\u4E3B\uFF08\u5199\u578B\u6D3E\u53D1\u4ECD\u987B allowHostWrites: true\uFF09\u3002`;
|
|
9124
9489
|
return {
|
|
9125
9490
|
selectedRuntimeKey: void 0,
|
|
9126
9491
|
reason: "auto_disabled",
|
|
@@ -9135,7 +9500,7 @@ async function evaluateAutoInstaboxPlacement(input) {
|
|
|
9135
9500
|
});
|
|
9136
9501
|
} catch (error) {
|
|
9137
9502
|
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
9138
|
-
const note2 = `\u5BBF\u4E3B\u53EF\u7528\u5185\u5B58\u7D27\u7F3A\uFF08${effectiveAvailableMb}MB < ${LOCAL_TOOL_MEMORY_BUDGET_MB}MB\uFF09\uFF0C\u5C1D\u8BD5\u81EA\u52A8\u6539\u7528 Instabox \u53D7\u963B\uFF1A${errorMsg}\uFF1B\u4FDD\u6301\u9ED8\u8BA4
|
|
9503
|
+
const note2 = `\u5BBF\u4E3B\u53EF\u7528\u5185\u5B58\u7D27\u7F3A\uFF08${effectiveAvailableMb}MB < ${LOCAL_TOOL_MEMORY_BUDGET_MB}MB\uFF09\uFF0C\u5C1D\u8BD5\u81EA\u52A8\u6539\u7528 Instabox \u53D7\u963B\uFF1A${errorMsg}\uFF1B\u4FDD\u6301\u9ED8\u8BA4\u5BBF\u4E3B\uFF08\u5199\u578B\u6D3E\u53D1\u4ECD\u987B allowHostWrites: true\uFF09\u3002`;
|
|
9139
9504
|
return {
|
|
9140
9505
|
selectedRuntimeKey: void 0,
|
|
9141
9506
|
reason: "config_unavailable",
|
|
@@ -9147,7 +9512,7 @@ async function evaluateAutoInstaboxPlacement(input) {
|
|
|
9147
9512
|
try {
|
|
9148
9513
|
const readiness = await input.checkReadiness();
|
|
9149
9514
|
if (readiness && readiness.ready === false) {
|
|
9150
|
-
const note2 = `\u5BBF\u4E3B\u53EF\u7528\u5185\u5B58\u7D27\u7F3A\uFF08${effectiveAvailableMb}MB < ${LOCAL_TOOL_MEMORY_BUDGET_MB}MB\uFF09\uFF0C\u5C1D\u8BD5\u81EA\u52A8\u6539\u7528 Instabox \u4F46\u88AB\u670D\u52A1\u7AEF\u51C6\u5165/\u5C31\u7EEA\u660E\u786E\u62D2\u7EDD\uFF1A${readiness.reason ?? "\u670D\u52A1\u7AEF\u672A\u5C31\u7EEA"}\uFF1B\u4FDD\u6301\u9ED8\u8BA4
|
|
9515
|
+
const note2 = `\u5BBF\u4E3B\u53EF\u7528\u5185\u5B58\u7D27\u7F3A\uFF08${effectiveAvailableMb}MB < ${LOCAL_TOOL_MEMORY_BUDGET_MB}MB\uFF09\uFF0C\u5C1D\u8BD5\u81EA\u52A8\u6539\u7528 Instabox \u4F46\u88AB\u670D\u52A1\u7AEF\u51C6\u5165/\u5C31\u7EEA\u660E\u786E\u62D2\u7EDD\uFF1A${readiness.reason ?? "\u670D\u52A1\u7AEF\u672A\u5C31\u7EEA"}\uFF1B\u4FDD\u6301\u9ED8\u8BA4\u5BBF\u4E3B\uFF08\u5199\u578B\u6D3E\u53D1\u4ECD\u987B allowHostWrites: true\uFF09\u3002`;
|
|
9151
9516
|
return {
|
|
9152
9517
|
selectedRuntimeKey: void 0,
|
|
9153
9518
|
reason: "readiness_rejected",
|
|
@@ -9157,7 +9522,7 @@ async function evaluateAutoInstaboxPlacement(input) {
|
|
|
9157
9522
|
}
|
|
9158
9523
|
} catch (error) {
|
|
9159
9524
|
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
9160
|
-
const note2 = `\u5BBF\u4E3B\u53EF\u7528\u5185\u5B58\u7D27\u7F3A\uFF08${effectiveAvailableMb}MB < ${LOCAL_TOOL_MEMORY_BUDGET_MB}MB\uFF09\uFF0C\u5C1D\u8BD5\u81EA\u52A8\u6539\u7528 Instabox \u4F46\u5C31\u7EEA\u68C0\u67E5\u629B\u9519\uFF1A${errorMsg}\uFF1B\u4FDD\u6301\u9ED8\u8BA4
|
|
9525
|
+
const note2 = `\u5BBF\u4E3B\u53EF\u7528\u5185\u5B58\u7D27\u7F3A\uFF08${effectiveAvailableMb}MB < ${LOCAL_TOOL_MEMORY_BUDGET_MB}MB\uFF09\uFF0C\u5C1D\u8BD5\u81EA\u52A8\u6539\u7528 Instabox \u4F46\u5C31\u7EEA\u68C0\u67E5\u629B\u9519\uFF1A${errorMsg}\uFF1B\u4FDD\u6301\u9ED8\u8BA4\u5BBF\u4E3B\uFF08\u5199\u578B\u6D3E\u53D1\u4ECD\u987B allowHostWrites: true\uFF09\u3002`;
|
|
9161
9526
|
return {
|
|
9162
9527
|
selectedRuntimeKey: void 0,
|
|
9163
9528
|
reason: "readiness_error",
|
|
@@ -9217,10 +9582,10 @@ var parseCallArgs = (call) => {
|
|
|
9217
9582
|
return {};
|
|
9218
9583
|
}
|
|
9219
9584
|
};
|
|
9220
|
-
var resolveFs = (deps) => deps.fs ?? { existsSync:
|
|
9585
|
+
var resolveFs = (deps) => deps.fs ?? { existsSync: existsSync4, readFileSync: readFileSync5 };
|
|
9221
9586
|
var probeRunCwd = (deps) => {
|
|
9222
|
-
const
|
|
9223
|
-
const stat =
|
|
9587
|
+
const fs2 = deps.fs;
|
|
9588
|
+
const stat = fs2?.statSync ?? nodeFs2.statSync;
|
|
9224
9589
|
return (absolutePath) => {
|
|
9225
9590
|
try {
|
|
9226
9591
|
return stat(absolutePath).isDirectory() ? "directory" : "not-a-directory";
|
|
@@ -9229,10 +9594,10 @@ var probeRunCwd = (deps) => {
|
|
|
9229
9594
|
}
|
|
9230
9595
|
};
|
|
9231
9596
|
};
|
|
9232
|
-
var tailFile = (logPath, tailLines,
|
|
9233
|
-
if (!
|
|
9597
|
+
var tailFile = (logPath, tailLines, fs2) => {
|
|
9598
|
+
if (!fs2.existsSync(logPath)) return void 0;
|
|
9234
9599
|
try {
|
|
9235
|
-
const content =
|
|
9600
|
+
const content = fs2.readFileSync(logPath, "utf8");
|
|
9236
9601
|
const lines = String(content).split(/\r?\n/);
|
|
9237
9602
|
if (lines.length > 0 && lines[lines.length - 1] === "") lines.pop();
|
|
9238
9603
|
return lines.slice(Math.max(0, lines.length - tailLines)).join("\n");
|
|
@@ -9302,6 +9667,8 @@ function buildRunStatusPayload(reconciled, deps, opts = {}) {
|
|
|
9302
9667
|
// 排在 2000 字 lastAssistantText 之后的键会被整段省略,模型连路径都看
|
|
9303
9668
|
// 不到。挂在头部才能保证「结论在哪」永远可见。
|
|
9304
9669
|
...reconciled.resultFile ? { resultFile: reconciled.resultFile } : {},
|
|
9670
|
+
...reconciled.continuedFrom ? { continuedFrom: reconciled.continuedFrom } : {},
|
|
9671
|
+
...isAgentRunTerminalStatus(reconciled.status) ? { resultNote: "Process terminal status is not delivery, test, review, user acceptance or integration/release approval. lastAssistantText is a preview, not a complete report; read resultFile for current scope, blockers and evidence. Runtime acceptance contains observations only; unknown stays unknown. continuedFrom is lineage, not inherited approval." } : {},
|
|
9305
9672
|
...typeof reconciled.toolCallCount === "number" ? { toolCallCount: reconciled.toolCallCount } : {},
|
|
9306
9673
|
...reconciled.lastAssistantText ? { lastAssistantText: reconciled.lastAssistantText } : {},
|
|
9307
9674
|
// Non-ephemeral runs expose dialogId so the caller can read the
|
|
@@ -9373,6 +9740,8 @@ async function assertCredentialFanoutAllowed(deps, args) {
|
|
|
9373
9740
|
function createCliStartAgentRunExecutor(deps = {}) {
|
|
9374
9741
|
return async (call) => {
|
|
9375
9742
|
const args = parseCallArgs(call);
|
|
9743
|
+
const imagePaths = validateChildImagePaths(args.imagePaths);
|
|
9744
|
+
if (imagePaths.length && args.runtimeKey !== "local") throw new Error("image_backend_unsupported: imagePaths requires explicit host-local runtimeKey=local");
|
|
9376
9745
|
const continueDialogId = normalizeContinueDialogId(args.continueDialogId);
|
|
9377
9746
|
const continuedRecord = continueDialogId ? await deps.dialogExistsForCurrentUser?.(continueDialogId) : void 0;
|
|
9378
9747
|
if (continueDialogId && !continuedRecord) {
|
|
@@ -9390,36 +9759,36 @@ function createCliStartAgentRunExecutor(deps = {}) {
|
|
|
9390
9759
|
let previousCacheHitRatio = previousRecord?.cacheHitRatio;
|
|
9391
9760
|
if (previousRecord && previousCacheHitRatio === void 0 && previousRecord.resultFile) {
|
|
9392
9761
|
try {
|
|
9393
|
-
const
|
|
9394
|
-
const runsDir =
|
|
9395
|
-
const expected =
|
|
9396
|
-
if (previousRecord.runId.includes("/") || previousRecord.runId.includes("\\") ||
|
|
9397
|
-
const stat =
|
|
9762
|
+
const fs2 = deps.fs ?? nodeFs2;
|
|
9763
|
+
const runsDir = resolve4(resolveRunsDir(deps.env, deps.homedir));
|
|
9764
|
+
const expected = resolve4(runsDir, `${previousRecord.runId}.result.md`);
|
|
9765
|
+
if (previousRecord.runId.includes("/") || previousRecord.runId.includes("\\") || resolve4(previousRecord.resultFile) !== expected || !fs2.realpathSync || !fs2.lstatSync) throw new Error("Unverified result path");
|
|
9766
|
+
const stat = fs2.lstatSync(expected);
|
|
9398
9767
|
if (!stat.isFile() || stat.isSymbolicLink()) throw new Error("Non-regular result file");
|
|
9399
|
-
const canonicalDir = String(
|
|
9400
|
-
if (String(
|
|
9401
|
-
if ((deps.platform ?? process.platform) !== "linux" || !
|
|
9768
|
+
const canonicalDir = String(fs2.realpathSync(runsDir));
|
|
9769
|
+
if (String(fs2.realpathSync(expected)) !== join4(canonicalDir, `${previousRecord.runId}.result.md`)) throw new Error("Result escapes runs directory");
|
|
9770
|
+
if ((deps.platform ?? process.platform) !== "linux" || !fs2.fstatSync || !fs2.readSync || !fs2.closeSync || !nodeFs2.constants.O_NOFOLLOW || !nodeFs2.constants.O_DIRECTORY) throw new Error("FD proof unavailable");
|
|
9402
9771
|
let dirFd;
|
|
9403
9772
|
let resultFd;
|
|
9404
9773
|
let text = "";
|
|
9405
9774
|
try {
|
|
9406
|
-
dirFd =
|
|
9407
|
-
if (!
|
|
9408
|
-
resultFd =
|
|
9409
|
-
if (!
|
|
9775
|
+
dirFd = fs2.openSync(runsDir, nodeFs2.constants.O_RDONLY | nodeFs2.constants.O_DIRECTORY | nodeFs2.constants.O_NOFOLLOW);
|
|
9776
|
+
if (!fs2.fstatSync(dirFd).isDirectory() || String(fs2.realpathSync(`/proc/self/fd/${dirFd}`)) !== canonicalDir) throw new Error("Unverified directory fd");
|
|
9777
|
+
resultFd = fs2.openSync(`/proc/self/fd/${dirFd}/${previousRecord.runId}.result.md`, nodeFs2.constants.O_RDONLY | nodeFs2.constants.O_NOFOLLOW | nodeFs2.constants.O_NONBLOCK);
|
|
9778
|
+
if (!fs2.fstatSync(resultFd).isFile() || String(fs2.realpathSync(`/proc/self/fd/${resultFd}`)) !== join4(canonicalDir, `${previousRecord.runId}.result.md`)) throw new Error("Unverified result fd");
|
|
9410
9779
|
const bytes = Buffer.alloc(16 * 1024);
|
|
9411
9780
|
let offset = 0;
|
|
9412
9781
|
while (offset < bytes.length) {
|
|
9413
|
-
const count2 =
|
|
9782
|
+
const count2 = fs2.readSync(resultFd, bytes, offset, bytes.length - offset, offset);
|
|
9414
9783
|
if (count2 === 0) break;
|
|
9415
9784
|
offset += count2;
|
|
9416
9785
|
}
|
|
9417
9786
|
text = bytes.subarray(0, offset).toString("utf8");
|
|
9418
9787
|
} finally {
|
|
9419
9788
|
try {
|
|
9420
|
-
if (resultFd !== void 0)
|
|
9789
|
+
if (resultFd !== void 0) fs2.closeSync(resultFd);
|
|
9421
9790
|
} finally {
|
|
9422
|
-
if (dirFd !== void 0)
|
|
9791
|
+
if (dirFd !== void 0) fs2.closeSync(dirFd);
|
|
9423
9792
|
}
|
|
9424
9793
|
}
|
|
9425
9794
|
const header = /^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/.exec(text)?.[1];
|
|
@@ -9444,9 +9813,9 @@ function createCliStartAgentRunExecutor(deps = {}) {
|
|
|
9444
9813
|
const bindingMachineId = agentKey && deps.resolveAgentRuntimeBindingMachineId ? await deps.resolveAgentRuntimeBindingMachineId(agentKey) : void 0;
|
|
9445
9814
|
const localMachineId = deps.resolveLocalMachineId ? await deps.resolveLocalMachineId() : void 0;
|
|
9446
9815
|
let memoryPlacementNote;
|
|
9447
|
-
let effectiveRuntimeKey = args.runtimeKey;
|
|
9816
|
+
let effectiveRuntimeKey = args.workspaceIsolation === "auto" && args.readOnly !== true && !args.runtimeKey?.trim() ? "local" : args.runtimeKey;
|
|
9448
9817
|
const autoPlacement = await evaluateAutoInstaboxPlacement({
|
|
9449
|
-
runtimeKey:
|
|
9818
|
+
runtimeKey: effectiveRuntimeKey,
|
|
9450
9819
|
cwd: args.cwd,
|
|
9451
9820
|
readOnly: args.readOnly === true,
|
|
9452
9821
|
env: deps.env,
|
|
@@ -9466,7 +9835,7 @@ function createCliStartAgentRunExecutor(deps = {}) {
|
|
|
9466
9835
|
const dispatch = resolveCliLocalSpawnDispatch({
|
|
9467
9836
|
runtimeKey: effectiveRuntimeKey,
|
|
9468
9837
|
readOnly: args.readOnly === true,
|
|
9469
|
-
// F1
|
|
9838
|
+
// F1:默认写型派发及 runtimeKey=local 是「在宿主文件系统上改代码」,需要调用方的显式确认
|
|
9470
9839
|
// (allowHostWrites: true);缺失即派发前拒绝(零 spawn、零 run 记录)。
|
|
9471
9840
|
allowHostWrites: args.allowHostWrites,
|
|
9472
9841
|
// 政策第 5 条:显式宿主 cwd × 沙盒落点必须在派发前失败(沙盒不兑现宿主
|
|
@@ -9478,6 +9847,8 @@ function createCliStartAgentRunExecutor(deps = {}) {
|
|
|
9478
9847
|
...bindingMachineId ? { bindingMachineId } : {},
|
|
9479
9848
|
...localMachineId ? { localMachineId } : {}
|
|
9480
9849
|
});
|
|
9850
|
+
if (args.workspaceIsolation !== void 0 && args.workspaceIsolation !== "none" && args.workspaceIsolation !== "auto") throw new Error("workspaceIsolation \u5FC5\u987B\u4E3A none \u6216 auto");
|
|
9851
|
+
if (args.workspaceIsolation === "auto" && args.readOnly !== true && dispatch.target !== "host") throw new Error("workspaceIsolation:auto \u53EA\u652F\u6301\u672C\u5730 CLI \u5BBF\u4E3B\u5199\u578B\u4EFB\u52A1\uFF0C\u6C99\u76D2\u4E0D\u80FD\u5151\u73B0\u5BBF\u4E3B\u76EE\u5F55\u9694\u79BB");
|
|
9481
9852
|
const task = typeof args.task === "string" ? args.task.trim() : "";
|
|
9482
9853
|
const runTitle = normalizeRunTitle(args.title);
|
|
9483
9854
|
if (!agentKey) throw new Error(t("agentRunTool.missingAgentKey"));
|
|
@@ -9490,6 +9861,15 @@ function createCliStartAgentRunExecutor(deps = {}) {
|
|
|
9490
9861
|
selectedModel = await deps.resolveAgentModel?.(agentKey);
|
|
9491
9862
|
} catch {
|
|
9492
9863
|
}
|
|
9864
|
+
if (imagePaths.length) {
|
|
9865
|
+
let imageSupport = false;
|
|
9866
|
+
try {
|
|
9867
|
+
imageSupport = await deps.resolveAgentImageSupport?.(agentKey) === true;
|
|
9868
|
+
} catch {
|
|
9869
|
+
}
|
|
9870
|
+
if (!imageSupport) throw new Error("image_model_unsupported: child model image capability is unsupported or unknown");
|
|
9871
|
+
await validateChildImages(imagePaths);
|
|
9872
|
+
}
|
|
9493
9873
|
const selectionCheck = assertDispatchSelectionAdmission({
|
|
9494
9874
|
dimension: args.dimension,
|
|
9495
9875
|
difficulty: args.difficulty,
|
|
@@ -9511,7 +9891,7 @@ function createCliStartAgentRunExecutor(deps = {}) {
|
|
|
9511
9891
|
const manifest = typeof args.instaboxManifest === "string" ? args.instaboxManifest.trim() : "";
|
|
9512
9892
|
if (workspace === "snapshot" && !manifest) throw new Error("instaboxWorkspace=snapshot \u5FC5\u987B\u63D0\u4F9B instaboxManifest");
|
|
9513
9893
|
if (workspace === "empty" && args.instaboxManifest !== void 0) throw new Error("instaboxWorkspace=empty \u4E0D\u5F97\u63D0\u4F9B instaboxManifest");
|
|
9514
|
-
const artifactDir = args.instaboxArtifactDir ??
|
|
9894
|
+
const artifactDir = args.instaboxArtifactDir ?? join4(
|
|
9515
9895
|
resolveRunsDir(deps.env, deps.homedir),
|
|
9516
9896
|
"instabox-artifacts",
|
|
9517
9897
|
randomUUID3()
|
|
@@ -9539,10 +9919,11 @@ function createCliStartAgentRunExecutor(deps = {}) {
|
|
|
9539
9919
|
...args.ephemeral === true ? ["--ephemeral"] : [],
|
|
9540
9920
|
// 只读角色安全收敛:审查类任务物理剥离写/改/删工具,遵循最小特权原则。
|
|
9541
9921
|
...isReadOnlyTask ? ["--read-only"] : [],
|
|
9542
|
-
//
|
|
9922
|
+
// 执行后端(默认宿主;写型须确认,沙盒须显式指定):唯一产出 `--runtime-key`
|
|
9543
9923
|
// 的地方,成对不变式在 buildCliLocalRuntimeForwardArgs 内机械断言。
|
|
9544
9924
|
...buildCliLocalRuntimeForwardArgs(dispatch),
|
|
9545
|
-
...instaboxArgs
|
|
9925
|
+
...instaboxArgs,
|
|
9926
|
+
...imagePaths.flatMap((path) => ["--image", path])
|
|
9546
9927
|
];
|
|
9547
9928
|
const agentName = await resolveAgentRunName(
|
|
9548
9929
|
agentKey,
|
|
@@ -9563,44 +9944,64 @@ function createCliStartAgentRunExecutor(deps = {}) {
|
|
|
9563
9944
|
});
|
|
9564
9945
|
const dodCommands = Array.isArray(args.dodCommands) ? args.dodCommands.filter((c) => typeof c === "string" && c.trim().length > 0).map((c) => c.trim()) : typeof args.dod === "string" && args.dod.trim().length > 0 ? [args.dod.trim()] : Array.isArray(args.dod) ? args.dod.filter((c) => typeof c === "string" && c.trim().length > 0).map((c) => c.trim()) : void 0;
|
|
9565
9946
|
const childPolicy = parseAgentRunArgs(rawArgs, { readTextFile: () => message });
|
|
9566
|
-
const
|
|
9567
|
-
|
|
9568
|
-
|
|
9569
|
-
|
|
9570
|
-
|
|
9571
|
-
|
|
9572
|
-
|
|
9573
|
-
|
|
9574
|
-
|
|
9575
|
-
|
|
9576
|
-
|
|
9577
|
-
|
|
9578
|
-
|
|
9579
|
-
|
|
9580
|
-
|
|
9581
|
-
|
|
9582
|
-
|
|
9583
|
-
|
|
9584
|
-
|
|
9585
|
-
|
|
9586
|
-
|
|
9587
|
-
|
|
9588
|
-
|
|
9589
|
-
|
|
9590
|
-
|
|
9591
|
-
|
|
9592
|
-
|
|
9593
|
-
|
|
9594
|
-
...
|
|
9595
|
-
|
|
9596
|
-
|
|
9597
|
-
|
|
9598
|
-
|
|
9599
|
-
|
|
9600
|
-
|
|
9601
|
-
|
|
9602
|
-
|
|
9603
|
-
|
|
9947
|
+
const isolationEnabled = args.workspaceIsolation === "auto" && !isReadOnlyTask;
|
|
9948
|
+
const isolationRunId = isolationEnabled ? (deps.generateRunId ?? defaultGenerateRunId)() : void 0;
|
|
9949
|
+
const baseCwd = requestedCwd ?? deps.cwd ?? process.cwd();
|
|
9950
|
+
const workspaceIsolation = isolationEnabled ? (deps.prepareIsolation ?? prepareWorkspaceIsolation)({
|
|
9951
|
+
baseCwd,
|
|
9952
|
+
runId: isolationRunId,
|
|
9953
|
+
mode: "auto",
|
|
9954
|
+
noloHome: dirname4(resolveRunsDir(deps.env, deps.homedir))
|
|
9955
|
+
}) : { mode: args.workspaceIsolation ?? "none", kind: "none", effectiveCwd: baseCwd };
|
|
9956
|
+
let spawned;
|
|
9957
|
+
try {
|
|
9958
|
+
spawned = await spawnLocalBackgroundRun(
|
|
9959
|
+
{
|
|
9960
|
+
selectionCheck,
|
|
9961
|
+
...evidenceScope ? { evidenceScope } : {},
|
|
9962
|
+
...dispatchUserId ? { dispatchSpeedProvenance: {
|
|
9963
|
+
version: 1,
|
|
9964
|
+
source: "cli-startAgentRun",
|
|
9965
|
+
userId: dispatchUserId
|
|
9966
|
+
} } : {},
|
|
9967
|
+
rawArgs,
|
|
9968
|
+
commandPath: ["agent", "run"],
|
|
9969
|
+
cliEntrypointPath: deps.cliEntrypoint,
|
|
9970
|
+
agentKey,
|
|
9971
|
+
...agentName ? { agentName } : {},
|
|
9972
|
+
...runTitle ? { title: runTitle } : {},
|
|
9973
|
+
...batchId ? { batchId } : {},
|
|
9974
|
+
...credentialGroup ? { credentialGroup } : {},
|
|
9975
|
+
...parentDialogId ? { parentDialogId } : {},
|
|
9976
|
+
// 续跑目标对话:spawn 时落盘,让"开着这条对话的 TUI"在 running 期间就能
|
|
9977
|
+
// 看到另一边在跑(dock 按 dialogId 也能匹配到这条 run)。
|
|
9978
|
+
...continueDialogId ? { dialogId: continueDialogId } : {},
|
|
9979
|
+
...dodCommands && dodCommands.length > 0 ? { dodCommands } : {},
|
|
9980
|
+
cwd: workspaceIsolation.effectiveCwd,
|
|
9981
|
+
...dispatch.runtimeKey === "local" && !isReadOnlyTask ? { claimLocalWrites: true } : {},
|
|
9982
|
+
...dispatch.target === "host" ? { localExecution: {
|
|
9983
|
+
runtimeKey: "local",
|
|
9984
|
+
hostWritesAuthorized: args.allowHostWrites === true,
|
|
9985
|
+
readOnly: isReadOnlyTask,
|
|
9986
|
+
...childPolicy?.allowedToolNames ? { allowedToolNames: childPolicy.allowedToolNames } : {},
|
|
9987
|
+
...childPolicy?.blockedToolNames ? { blockedToolNames: childPolicy.blockedToolNames } : {},
|
|
9988
|
+
provenance: "cli-tool-dispatch-authorized"
|
|
9989
|
+
} } : {},
|
|
9990
|
+
message,
|
|
9991
|
+
...args.ephemeral === true ? { ephemeral: true } : {},
|
|
9992
|
+
output: noopOutput
|
|
9993
|
+
},
|
|
9994
|
+
{ ...deps, ...isolationRunId !== void 0 ? { generateRunId: () => isolationRunId } : {}, mcpApprovalHost: deps.mcpApprovalHostForAgent ? await deps.mcpApprovalHostForAgent(agentKey) : deps.mcpApprovalHost, shellApprovalHost: deps.shellApprovalHostForAgent ? await deps.shellApprovalHostForAgent(agentKey) : deps.shellApprovalHost }
|
|
9995
|
+
);
|
|
9996
|
+
} catch (error) {
|
|
9997
|
+
try {
|
|
9998
|
+
if (isolationEnabled) (deps.rollbackIsolation ?? rollbackWorkspaceIsolation)(workspaceIsolation);
|
|
9999
|
+
} catch (cleanupError) {
|
|
10000
|
+
throw new AggregateError([error, cleanupError], `\u542F\u52A8\u5931\u8D25\uFF1B\u9694\u79BB\u76EE\u5F55\u4FDD\u7559\u5F85\u5904\u7406: ${workspaceIsolation.root}`);
|
|
10001
|
+
}
|
|
10002
|
+
throw error;
|
|
10003
|
+
}
|
|
10004
|
+
const { runId, batchId: resolvedBatchId } = spawned;
|
|
9604
10005
|
const displayName = resolveRunLabel({ agentName, agentKey, runId });
|
|
9605
10006
|
const labels = agentRunCardLabels();
|
|
9606
10007
|
const taskPreview = typeof args.task === "string" ? args.task.replace(/\s+/g, " ").trim().slice(0, TASK_PREVIEW_MAX) : "";
|
|
@@ -9635,6 +10036,7 @@ function createCliStartAgentRunExecutor(deps = {}) {
|
|
|
9635
10036
|
agentKey,
|
|
9636
10037
|
status: "running",
|
|
9637
10038
|
selectionCheck,
|
|
10039
|
+
...args.workspaceIsolation !== void 0 ? { workspaceIsolation } : {},
|
|
9638
10040
|
...contextFacts,
|
|
9639
10041
|
...continuationEvidence,
|
|
9640
10042
|
// batchId is always returned so the caller can later filter by it —
|
|
@@ -9707,7 +10109,7 @@ async function spawnContinuationRun(reconciled, message, userInput, deps) {
|
|
|
9707
10109
|
continuedFrom,
|
|
9708
10110
|
output: noopOutput
|
|
9709
10111
|
},
|
|
9710
|
-
{ ...deps, shellApprovalHost: deps.shellApprovalHostForAgent ? await deps.shellApprovalHostForAgent(agentKey) : deps.shellApprovalHost }
|
|
10112
|
+
{ ...deps, mcpApprovalHost: deps.mcpApprovalHostForAgent ? await deps.mcpApprovalHostForAgent(agentKey) : deps.mcpApprovalHost, shellApprovalHost: deps.shellApprovalHostForAgent ? await deps.shellApprovalHostForAgent(agentKey) : deps.shellApprovalHost }
|
|
9711
10113
|
);
|
|
9712
10114
|
const taskPreview = userInput.replace(/\s+/g, " ").trim().slice(0, TASK_PREVIEW_MAX);
|
|
9713
10115
|
return {
|
|
@@ -9915,7 +10317,7 @@ function createCliControlAgentRunExecutor(deps = {}) {
|
|
|
9915
10317
|
};
|
|
9916
10318
|
}
|
|
9917
10319
|
if (action === "append") {
|
|
9918
|
-
if (["runtimeKey", "allowHostWrites", "readOnly", "allowedToolNames", "blockedToolNames", "cwd"].some((key) => args[key] !== void 0)) {
|
|
10320
|
+
if (["runtimeKey", "allowHostWrites", "readOnly", "allowedToolNames", "blockedToolNames", "cwd", "workspaceIsolation"].some((key) => args[key] !== void 0)) {
|
|
9919
10321
|
throw new Error("[local-continuation] scope overrides are not supported; dispatch a fresh authorized run");
|
|
9920
10322
|
}
|
|
9921
10323
|
const dialogKeyArg = typeof args.dialogKey === "string" ? args.dialogKey.trim() : "";
|
|
@@ -9955,8 +10357,8 @@ ${userInput}` : userInput;
|
|
|
9955
10357
|
const afterCheck = checkStaleRun(reconciled2.runId, deps) ?? reconciled2;
|
|
9956
10358
|
if (isAgentRunTerminalStatus(afterCheck.status)) {
|
|
9957
10359
|
return await withQueueLock(queuePath, deps, async () => {
|
|
9958
|
-
const
|
|
9959
|
-
const remainingEntries = _readQueueEntriesLocked(queuePath,
|
|
10360
|
+
const fs2 = deps.fs ?? nodeFs2;
|
|
10361
|
+
const remainingEntries = _readQueueEntriesLocked(queuePath, fs2);
|
|
9960
10362
|
const ourEntryFound = remainingEntries.some((e) => e.id === entryId);
|
|
9961
10363
|
if (!ourEntryFound) {
|
|
9962
10364
|
return {
|
|
@@ -9986,11 +10388,11 @@ ${userInput}` : userInput;
|
|
|
9986
10388
|
${entry.text}`).join("\n\n");
|
|
9987
10389
|
const result = await spawnContinuationRun(afterCheck, mergedMessage, userInput, deps);
|
|
9988
10390
|
const transferred = new Set(remainingEntries.map((entry) => entry.id));
|
|
9989
|
-
const current = _readQueueEntriesLocked(queuePath,
|
|
9990
|
-
if (typeof
|
|
10391
|
+
const current = _readQueueEntriesLocked(queuePath, fs2);
|
|
10392
|
+
if (typeof fs2.renameSync !== "function") throw new Error("atomic queue replacement requires renameSync");
|
|
9991
10393
|
const pendingQueue = `${queuePath}.${randomUUID3()}.tmp`;
|
|
9992
|
-
|
|
9993
|
-
|
|
10394
|
+
fs2.writeFileSync(pendingQueue, serializeQueueEntries(current.filter((entry) => !transferred.has(entry.id))), { encoding: "utf8", flag: "wx" });
|
|
10395
|
+
fs2.renameSync(pendingQueue, queuePath);
|
|
9994
10396
|
return result;
|
|
9995
10397
|
});
|
|
9996
10398
|
}
|
|
@@ -10141,11 +10543,21 @@ function buildCliChromeConnectorToolExecutors(args) {
|
|
|
10141
10543
|
return Object.fromEntries(
|
|
10142
10544
|
CHROME_CONNECTOR_ACCEPTED_TOOL_NAMES.map((toolName) => [
|
|
10143
10545
|
toolName,
|
|
10144
|
-
(call) => {
|
|
10546
|
+
(call, options) => {
|
|
10145
10547
|
const target = approvalTargetForCall(call);
|
|
10146
10548
|
const connector = createConnectorApprovalPort(() => clientForTarget(target));
|
|
10147
10549
|
return runConnectorToolWithHostApproval({
|
|
10148
10550
|
call,
|
|
10551
|
+
signal: options?.abortSignal,
|
|
10552
|
+
// Foreground TUI turns have dialogId/turnId, not a persisted runId.
|
|
10553
|
+
// Preserve runId only when supplied by a real host owner; never mint
|
|
10554
|
+
// one from call.id or turnId (neither identifies a background run).
|
|
10555
|
+
context: {
|
|
10556
|
+
requestId: call.id,
|
|
10557
|
+
dialogId: call.runtimeContext?.dialogId,
|
|
10558
|
+
turnId: call.runtimeContext?.turnId,
|
|
10559
|
+
runId: call.runtimeContext?.runId
|
|
10560
|
+
},
|
|
10149
10561
|
execute: (nextCall) => executeChromeConnectorTool({ clientForTarget, call: nextCall }),
|
|
10150
10562
|
connector,
|
|
10151
10563
|
// Read the registry per call so a TUI that installs its renderer after the table is
|
|
@@ -10269,6 +10681,7 @@ function pickAgentRunResolverDeps(args) {
|
|
|
10269
10681
|
return {
|
|
10270
10682
|
...args.resolveAgentCredentialGroup ? { resolveAgentCredentialGroup: args.resolveAgentCredentialGroup } : {},
|
|
10271
10683
|
...args.dialogExistsForCurrentUser ? { dialogExistsForCurrentUser: args.dialogExistsForCurrentUser } : {},
|
|
10684
|
+
...args.resolveAgentImageSupport ? { resolveAgentImageSupport: args.resolveAgentImageSupport } : {},
|
|
10272
10685
|
...args.resolveAgentModel ? { resolveAgentModel: args.resolveAgentModel } : {},
|
|
10273
10686
|
...args.resolveAgentDisplayName ? { resolveAgentDisplayName: args.resolveAgentDisplayName } : {},
|
|
10274
10687
|
...args.resolveAgentRuntimeBindingMachineId ? { resolveAgentRuntimeBindingMachineId: args.resolveAgentRuntimeBindingMachineId } : {},
|
|
@@ -10276,11 +10689,19 @@ function pickAgentRunResolverDeps(args) {
|
|
|
10276
10689
|
};
|
|
10277
10690
|
}
|
|
10278
10691
|
function buildCliWorkspaceToolExecutors(args) {
|
|
10692
|
+
const resolveDialogStore = args.resolveDialogStore;
|
|
10279
10693
|
return buildNoloWorkspaceCliToolExecutors({
|
|
10280
10694
|
cliEntrypoint: args.cliEntrypoint ?? process.argv[1] ?? "",
|
|
10281
10695
|
env: args.env,
|
|
10282
10696
|
metadataKind: "cliWorkspaceTool",
|
|
10283
|
-
planningCaller: args.planningCaller
|
|
10697
|
+
planningCaller: args.planningCaller,
|
|
10698
|
+
// 只放开 readDialog(本机独占对话)的进程内直读;listDialogs 一律保持
|
|
10699
|
+
// 权威跨端合并路径——本地库只是缓存,抢答会静默漏掉 Web/手机端新对话。
|
|
10700
|
+
...resolveDialogStore ? {
|
|
10701
|
+
resolveDialogStore,
|
|
10702
|
+
resolveCurrentUserId: () => resolveLocalUserId(args.env),
|
|
10703
|
+
resolveLocalChildDialogIds: args.resolveLocalChildDialogIds ?? (() => loadLocalRunChildDialogIds({ env: args.env }))
|
|
10704
|
+
} : {}
|
|
10284
10705
|
});
|
|
10285
10706
|
}
|
|
10286
10707
|
function buildLocalToolExecutors(args) {
|
|
@@ -10306,7 +10727,9 @@ function buildLocalToolExecutors(args) {
|
|
|
10306
10727
|
...buildCliWorkspaceToolExecutors({
|
|
10307
10728
|
planningCaller: args.planningCaller,
|
|
10308
10729
|
env: args.env,
|
|
10309
|
-
cliEntrypoint: args.cliEntrypoint
|
|
10730
|
+
cliEntrypoint: args.cliEntrypoint,
|
|
10731
|
+
...args.resolveDialogStore ? { resolveDialogStore: args.resolveDialogStore } : {},
|
|
10732
|
+
...args.resolveLocalChildDialogIds ? { resolveLocalChildDialogIds: args.resolveLocalChildDialogIds } : {}
|
|
10310
10733
|
}),
|
|
10311
10734
|
// loadSkill resolves SKILL.md from the agent's workspace root (local-fs,
|
|
10312
10735
|
// no `nolo` CLI subcommand), so it is wired here instead of inside
|
|
@@ -10454,6 +10877,7 @@ function buildLocalToolExecutors(args) {
|
|
|
10454
10877
|
// (复用 ~/.nolo/runs/ 注册表,MED-1 修复)。
|
|
10455
10878
|
startAgentRun: createCliStartAgentRunExecutor({
|
|
10456
10879
|
shellApprovalHostForAgent: args.shellApprovalHostForAgent,
|
|
10880
|
+
mcpApprovalHostForAgent: args.mcpApprovalHostForAgent,
|
|
10457
10881
|
...pickAgentRunResolverDeps(args),
|
|
10458
10882
|
// α:展示名回读器——resolveAgentRunName 的读取来源(显式 agentName 优先,绝不覆盖)。
|
|
10459
10883
|
resolveAgentName: args.resolveAgentName,
|
|
@@ -10465,6 +10889,7 @@ function buildLocalToolExecutors(args) {
|
|
|
10465
10889
|
controlAgentRun: createCliControlAgentRunExecutor({
|
|
10466
10890
|
source: { parentDialogId: args.sourceParentDialogId, agentKey: args.agentKey },
|
|
10467
10891
|
shellApprovalHostForAgent: args.shellApprovalHostForAgent,
|
|
10892
|
+
mcpApprovalHostForAgent: args.mcpApprovalHostForAgent,
|
|
10468
10893
|
cwd: args.workspaceRoot,
|
|
10469
10894
|
cliEntrypoint: args.cliEntrypoint,
|
|
10470
10895
|
env: args.env
|
|
@@ -10645,8 +11070,8 @@ function createOAuthApiKeyRefResolver(options = {}) {
|
|
|
10645
11070
|
}
|
|
10646
11071
|
|
|
10647
11072
|
// packages/agent-runtime/localSandboxWorkload.ts
|
|
10648
|
-
import { existsSync as
|
|
10649
|
-
import { resolve as
|
|
11073
|
+
import { existsSync as existsSync5 } from "node:fs";
|
|
11074
|
+
import { resolve as resolve6 } from "node:path";
|
|
10650
11075
|
|
|
10651
11076
|
// packages/agent-runtime/executionChannel.ts
|
|
10652
11077
|
var EXECUTION_SHELL_TOOL = "execShell";
|
|
@@ -10732,12 +11157,12 @@ import {
|
|
|
10732
11157
|
openSync,
|
|
10733
11158
|
readlinkSync,
|
|
10734
11159
|
rmdirSync,
|
|
10735
|
-
unlinkSync,
|
|
11160
|
+
unlinkSync as unlinkSync2,
|
|
10736
11161
|
writeSync
|
|
10737
11162
|
} from "node:fs";
|
|
10738
11163
|
import { access } from "node:fs/promises";
|
|
10739
11164
|
import { tmpdir } from "node:os";
|
|
10740
|
-
import { isAbsolute as
|
|
11165
|
+
import { isAbsolute as isAbsolute5, join as join5, relative as relative2, resolve as resolve5 } from "node:path";
|
|
10741
11166
|
|
|
10742
11167
|
// packages/agent-runtime/linuxSandboxSeccomp.ts
|
|
10743
11168
|
var AUDIT_ARCH_X86_64 = 3221225534;
|
|
@@ -10830,14 +11255,14 @@ var MAX_OUTPUT_BYTES = 1024 * 1024;
|
|
|
10830
11255
|
var PSEUDO_FS = ["/proc", "/sys", "/dev", "/run"];
|
|
10831
11256
|
var SANDBOX_MOUNTS = ["/", "/usr", "/bin", "/lib", "/lib64", "/tmp"];
|
|
10832
11257
|
var inside = (parent, child) => {
|
|
10833
|
-
const rel =
|
|
10834
|
-
return rel === "" || rel !== ".." && !rel.startsWith("../") && !
|
|
11258
|
+
const rel = relative2(parent, child);
|
|
11259
|
+
return rel === "" || rel !== ".." && !rel.startsWith("../") && !isAbsolute5(rel);
|
|
10835
11260
|
};
|
|
10836
11261
|
function openRootHandle(path) {
|
|
10837
|
-
if (typeof path !== "string" || !
|
|
11262
|
+
if (typeof path !== "string" || !isAbsolute5(path) || path.includes("\0")) {
|
|
10838
11263
|
throw new Error("Sandbox root must be absolute");
|
|
10839
11264
|
}
|
|
10840
|
-
const expected =
|
|
11265
|
+
const expected = resolve5(path);
|
|
10841
11266
|
if (SANDBOX_MOUNTS.includes(expected) || PSEUDO_FS.some((reserved) => inside(reserved, expected))) {
|
|
10842
11267
|
throw new Error("Sandbox root overlaps a reserved sandbox/pseudo filesystem path");
|
|
10843
11268
|
}
|
|
@@ -10861,8 +11286,8 @@ function openRootHandle(path) {
|
|
|
10861
11286
|
}
|
|
10862
11287
|
var SECCOMP_TEMP_DIR_PREFIX = "nolo-bwrap-seccomp-";
|
|
10863
11288
|
function openSeccompFd(program) {
|
|
10864
|
-
const dir = mkdtempSync(
|
|
10865
|
-
const file =
|
|
11289
|
+
const dir = mkdtempSync(join5(tmpdir(), SECCOMP_TEMP_DIR_PREFIX));
|
|
11290
|
+
const file = join5(dir, "filter.bpf");
|
|
10866
11291
|
let writer = -1;
|
|
10867
11292
|
let reader = -1;
|
|
10868
11293
|
try {
|
|
@@ -10881,7 +11306,7 @@ function openSeccompFd(program) {
|
|
|
10881
11306
|
} finally {
|
|
10882
11307
|
if (writer >= 0) closeSync(writer);
|
|
10883
11308
|
try {
|
|
10884
|
-
|
|
11309
|
+
unlinkSync2(file);
|
|
10885
11310
|
} catch {
|
|
10886
11311
|
}
|
|
10887
11312
|
try {
|
|
@@ -11020,7 +11445,7 @@ var LinuxBubblewrapBackend = class {
|
|
|
11020
11445
|
if (request.timeoutMs !== void 0 && (!Number.isFinite(request.timeoutMs) || request.timeoutMs <= 0)) {
|
|
11021
11446
|
throw new Error("Sandbox timeout must be finite and positive");
|
|
11022
11447
|
}
|
|
11023
|
-
if (request.cwd && !active.writable.some(({ path: root }) =>
|
|
11448
|
+
if (request.cwd && !active.writable.some(({ path: root }) => isAbsolute5(request.cwd) && inside(root, resolve5(request.cwd)))) {
|
|
11024
11449
|
throw new Error("Command cwd outside writable sandbox roots");
|
|
11025
11450
|
}
|
|
11026
11451
|
if (!validateConfiguredRootExecutionLease(active.ticket, active.lease)) {
|
|
@@ -11177,7 +11602,7 @@ async function createLocalSandboxWorkload(args) {
|
|
|
11177
11602
|
const envRoots = typeof env.NOLO_LOCAL_SANDBOX_ROOTS === "string" ? env.NOLO_LOCAL_SANDBOX_ROOTS.split(":").map((entry) => entry.trim()) : [];
|
|
11178
11603
|
const readableRoots = normalizeRoots(
|
|
11179
11604
|
args.readableRoots && args.readableRoots.length > 0 ? args.readableRoots : [...DEFAULT_SANDBOX_READABLE_ROOTS, ...envRoots]
|
|
11180
|
-
).filter((root) => !FORBIDDEN_EXTRA_ROOTS.has(
|
|
11605
|
+
).filter((root) => !FORBIDDEN_EXTRA_ROOTS.has(resolve6(root)));
|
|
11181
11606
|
const backend = args.backend ?? new LinuxBubblewrapBackend();
|
|
11182
11607
|
const ticket = {
|
|
11183
11608
|
version: 1,
|
|
@@ -11225,7 +11650,7 @@ async function createLocalSandboxWorkload(args) {
|
|
|
11225
11650
|
if (canonicalToolName(toolName) !== EXECUTION_SHELL_TOOL) return null;
|
|
11226
11651
|
const callArgs = toolArgs ?? {};
|
|
11227
11652
|
const command = typeof callArgs.command === "string" ? callArgs.command : "";
|
|
11228
|
-
const mountedBins = readableRoots.map((root) => `${root}/bin`).filter((dir) =>
|
|
11653
|
+
const mountedBins = readableRoots.map((root) => `${root}/bin`).filter((dir) => existsSync5(dir));
|
|
11229
11654
|
const sandboxPath = [
|
|
11230
11655
|
...mountedBins,
|
|
11231
11656
|
process.env.PATH ?? "/usr/local/bin:/usr/bin:/bin"
|
|
@@ -11655,12 +12080,12 @@ async function executeWorkspaceDelivery(plan, runtime, deps = {}) {
|
|
|
11655
12080
|
}
|
|
11656
12081
|
const tmpDir = deps.tmpDir ?? (await import("node:os")).tmpdir();
|
|
11657
12082
|
const writeTempFile = deps.writeTempFile ?? (async (filePath, content) => {
|
|
11658
|
-
const
|
|
11659
|
-
await
|
|
12083
|
+
const fs2 = await import("node:fs/promises");
|
|
12084
|
+
await fs2.writeFile(filePath, content, "utf8");
|
|
11660
12085
|
});
|
|
11661
12086
|
const removeTempFile = deps.removeTempFile ?? (async (filePath) => {
|
|
11662
|
-
const
|
|
11663
|
-
await
|
|
12087
|
+
const fs2 = await import("node:fs/promises");
|
|
12088
|
+
await fs2.rm(filePath, { force: true });
|
|
11664
12089
|
});
|
|
11665
12090
|
let hostBaselineTemp = null;
|
|
11666
12091
|
if (plan.baselineUpload) {
|
|
@@ -11760,10 +12185,10 @@ async function applyDockerWorkspaceDelivery(runtime, selection) {
|
|
|
11760
12185
|
|
|
11761
12186
|
// packages/cli/client/localWorkspaceArchive.ts
|
|
11762
12187
|
import { spawnSync } from "node:child_process";
|
|
11763
|
-
import { mkdtempSync as mkdtempSync2, statSync as
|
|
12188
|
+
import { mkdtempSync as mkdtempSync2, statSync as statSync3, writeFileSync as writeFileSync2 } from "node:fs";
|
|
11764
12189
|
import { rm } from "node:fs/promises";
|
|
11765
12190
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
11766
|
-
import { join as
|
|
12191
|
+
import { join as join6 } from "node:path";
|
|
11767
12192
|
var runHostCommand = (argv, { cwd }) => {
|
|
11768
12193
|
const result = spawnSync(argv[0], argv.slice(1), {
|
|
11769
12194
|
cwd,
|
|
@@ -11823,11 +12248,11 @@ function prepareHostWorkspaceDelivery(args) {
|
|
|
11823
12248
|
`\u5DE5\u4F5C\u533A\u6587\u4EF6\u6570 ${tracked.length} \u8D85\u8FC7\u4E0A\u9650 ${MAX_DELIVERY_FILE_COUNT}\uFF1A\u7591\u4F3C\u628A node_modules / \u6784\u5EFA\u4EA7\u7269\u6253\u8FDB\u4E86\u5F52\u6863\uFF08\u5F52\u6863\u53EA\u53D6 git ls-files\uFF09\u3002`
|
|
11824
12249
|
);
|
|
11825
12250
|
}
|
|
11826
|
-
const stagingDir = mkdtempSync2(
|
|
12251
|
+
const stagingDir = mkdtempSync2(join6(args.tmpDir ?? tmpdir2(), "nolo-workspace-delivery-"));
|
|
11827
12252
|
const stamp = `${process.pid}-${Date.now()}`;
|
|
11828
|
-
const archivePath =
|
|
11829
|
-
const bundlePath =
|
|
11830
|
-
const listPath =
|
|
12253
|
+
const archivePath = join6(stagingDir, `workspace-${stamp}.tar.gz`);
|
|
12254
|
+
const bundlePath = join6(stagingDir, `workspace-${stamp}.bundle`);
|
|
12255
|
+
const listPath = join6(stagingDir, `filelist-${stamp}.z`);
|
|
11831
12256
|
const removeFile = args.removeFile ?? (async (filePath) => {
|
|
11832
12257
|
await rm(filePath, { force: true });
|
|
11833
12258
|
});
|
|
@@ -11908,7 +12333,7 @@ function prepareHostWorkspaceDelivery(args) {
|
|
|
11908
12333
|
}
|
|
11909
12334
|
let archiveSizeBytes = 0;
|
|
11910
12335
|
try {
|
|
11911
|
-
archiveSizeBytes =
|
|
12336
|
+
archiveSizeBytes = statSync3(archivePath).size;
|
|
11912
12337
|
} catch (error) {
|
|
11913
12338
|
return fail3(
|
|
11914
12339
|
"host_workspace_archive_failed",
|
|
@@ -11968,7 +12393,7 @@ function buildHostBundle(args) {
|
|
|
11968
12393
|
}
|
|
11969
12394
|
let sizeBytes = 0;
|
|
11970
12395
|
try {
|
|
11971
|
-
sizeBytes =
|
|
12396
|
+
sizeBytes = statSync3(args.bundlePath).size;
|
|
11972
12397
|
} catch (error) {
|
|
11973
12398
|
return {
|
|
11974
12399
|
ok: false,
|
|
@@ -12071,8 +12496,8 @@ async function createLocalDockerWorkload(args) {
|
|
|
12071
12496
|
}
|
|
12072
12497
|
const createLifecycle = args.createLifecycle ?? (async () => {
|
|
12073
12498
|
const [{ DockerWorkloadLifecycle, createDockerBindingAuthorizer }, accounts] = await Promise.all([
|
|
12074
|
-
import("./workloadLifecycle-
|
|
12075
|
-
import("./accountResolver-
|
|
12499
|
+
import("./workloadLifecycle-ZCSQCHG3.js"),
|
|
12500
|
+
import("./accountResolver-QETKNC7T.js")
|
|
12076
12501
|
]);
|
|
12077
12502
|
const resolveAccount = args.resolveAccount ?? accounts.createDockerAccountResolver({
|
|
12078
12503
|
env: args.env,
|
|
@@ -12167,28 +12592,28 @@ async function createLocalDockerWorkload(args) {
|
|
|
12167
12592
|
};
|
|
12168
12593
|
let rejectReady = () => {
|
|
12169
12594
|
};
|
|
12170
|
-
const ready = new Promise((
|
|
12171
|
-
resolveReady =
|
|
12595
|
+
const ready = new Promise((resolve8, reject) => {
|
|
12596
|
+
resolveReady = resolve8;
|
|
12172
12597
|
rejectReady = reject;
|
|
12173
12598
|
});
|
|
12174
12599
|
let releaseRun = () => {
|
|
12175
12600
|
};
|
|
12176
|
-
const releaseGate = new Promise((
|
|
12177
|
-
releaseRun =
|
|
12601
|
+
const releaseGate = new Promise((resolve8) => {
|
|
12602
|
+
releaseRun = resolve8;
|
|
12178
12603
|
});
|
|
12179
12604
|
const waitForReleaseOrAbort = () => {
|
|
12180
12605
|
const signal = args.signal;
|
|
12181
12606
|
if (!signal) return releaseGate;
|
|
12182
12607
|
if (signal.aborted) return Promise.resolve();
|
|
12183
|
-
return new Promise((
|
|
12608
|
+
return new Promise((resolve8) => {
|
|
12184
12609
|
const onAbort = () => {
|
|
12185
12610
|
signal.removeEventListener("abort", onAbort);
|
|
12186
|
-
|
|
12611
|
+
resolve8();
|
|
12187
12612
|
};
|
|
12188
12613
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
12189
12614
|
void releaseGate.then(() => {
|
|
12190
12615
|
signal.removeEventListener("abort", onAbort);
|
|
12191
|
-
|
|
12616
|
+
resolve8();
|
|
12192
12617
|
});
|
|
12193
12618
|
});
|
|
12194
12619
|
};
|
|
@@ -12682,12 +13107,12 @@ function describeInstaboxBridgeUnavailable(bridge) {
|
|
|
12682
13107
|
// packages/cli/client/localInstaboxWorkspaceRecovery.ts
|
|
12683
13108
|
import { constants as constants3 } from "node:fs";
|
|
12684
13109
|
import { open as open2 } from "node:fs/promises";
|
|
12685
|
-
import { createHash as
|
|
13110
|
+
import { createHash as createHash6, randomUUID as randomUUID4 } from "node:crypto";
|
|
12686
13111
|
|
|
12687
13112
|
// packages/agent-runtime/artifactStore.ts
|
|
12688
|
-
import { createHash as
|
|
13113
|
+
import { createHash as createHash5, createHmac } from "node:crypto";
|
|
12689
13114
|
import { mkdir, readFile, unlink, writeFile } from "node:fs/promises";
|
|
12690
|
-
import { dirname as
|
|
13115
|
+
import { dirname as dirname5, resolve as resolve7, sep as sep2 } from "node:path";
|
|
12691
13116
|
var ArtifactStoreError = class extends Error {
|
|
12692
13117
|
code;
|
|
12693
13118
|
key;
|
|
@@ -12737,12 +13162,12 @@ function isNotFoundError(error) {
|
|
|
12737
13162
|
return error?.code === "ENOENT";
|
|
12738
13163
|
}
|
|
12739
13164
|
function createLocalArtifactStore(options) {
|
|
12740
|
-
const root =
|
|
13165
|
+
const root = resolve7(options.rootDir);
|
|
12741
13166
|
const now = options.now ?? Date.now;
|
|
12742
13167
|
const pathFor = (key) => {
|
|
12743
13168
|
assertArtifactKey(key);
|
|
12744
|
-
const target =
|
|
12745
|
-
if (target !== root && !target.startsWith(`${root}${
|
|
13169
|
+
const target = resolve7(root, key);
|
|
13170
|
+
if (target !== root && !target.startsWith(`${root}${sep2}`)) {
|
|
12746
13171
|
throw new ArtifactStoreError(
|
|
12747
13172
|
"invalid_key",
|
|
12748
13173
|
`artifact key \u89E3\u6790\u540E\u8D8A\u51FA rootDir\uFF1A${describeKey(key)}`,
|
|
@@ -12756,7 +13181,7 @@ function createLocalArtifactStore(options) {
|
|
|
12756
13181
|
const bytes = toBytes(data);
|
|
12757
13182
|
const target = pathFor(key);
|
|
12758
13183
|
try {
|
|
12759
|
-
await mkdir(
|
|
13184
|
+
await mkdir(dirname5(target), { recursive: true });
|
|
12760
13185
|
await writeFile(target, bytes);
|
|
12761
13186
|
} catch (error) {
|
|
12762
13187
|
if (error instanceof ArtifactStoreError) throw error;
|
|
@@ -12812,12 +13237,12 @@ function createLocalArtifactStore(options) {
|
|
|
12812
13237
|
};
|
|
12813
13238
|
}
|
|
12814
13239
|
function sha256Hex2(data) {
|
|
12815
|
-
return
|
|
13240
|
+
return createHash5("sha256").update(data).digest("hex");
|
|
12816
13241
|
}
|
|
12817
13242
|
var EMPTY_SHA256 = sha256Hex2("");
|
|
12818
13243
|
|
|
12819
13244
|
// packages/cli/client/localInstaboxWorkspaceRecovery.ts
|
|
12820
|
-
var sha = (b) =>
|
|
13245
|
+
var sha = (b) => createHash6("sha256").update(b).digest("hex");
|
|
12821
13246
|
function fail4(code) {
|
|
12822
13247
|
throw Object.assign(new Error(`instabox_workspace_recovery:${code}; cleanup_pending`), { code: "instabox_cleanup_pending", cleanupPending: true });
|
|
12823
13248
|
}
|
|
@@ -13322,8 +13747,8 @@ async function createLocalInstaboxWorkload(args) {
|
|
|
13322
13747
|
}
|
|
13323
13748
|
|
|
13324
13749
|
// packages/cli/client/localRunArtifactExport.ts
|
|
13325
|
-
import { mkdirSync as
|
|
13326
|
-
import { dirname as
|
|
13750
|
+
import { mkdirSync as mkdirSync3, writeFileSync as writeFileSync3 } from "node:fs";
|
|
13751
|
+
import { dirname as dirname6, join as join7 } from "node:path";
|
|
13327
13752
|
|
|
13328
13753
|
// packages/agent-runtime/runArtifactExport.ts
|
|
13329
13754
|
var RUN_DIFF_COMMAND = "git add -A && git diff --cached --binary";
|
|
@@ -13531,13 +13956,13 @@ function serializeRunArtifactAudit(record) {
|
|
|
13531
13956
|
// packages/cli/client/localRunArtifactExport.ts
|
|
13532
13957
|
function resolveRunArtifactsRootDir(runsDir) {
|
|
13533
13958
|
const normalized = runsDir.replace(/[/\\]+$/, "");
|
|
13534
|
-
return
|
|
13959
|
+
return join7(dirname6(normalized || runsDir), "artifacts");
|
|
13535
13960
|
}
|
|
13536
13961
|
function writeRunArtifactAudit(args) {
|
|
13537
|
-
const
|
|
13538
|
-
const path =
|
|
13539
|
-
|
|
13540
|
-
|
|
13962
|
+
const fs2 = args.fs ?? { mkdirSync: mkdirSync3, writeFileSync: writeFileSync3 };
|
|
13963
|
+
const path = join7(args.runsDir, `${args.record.runId}.artifacts.json`);
|
|
13964
|
+
fs2.mkdirSync?.(args.runsDir, { recursive: true });
|
|
13965
|
+
fs2.writeFileSync(path, serializeRunArtifactAudit(args.record));
|
|
13541
13966
|
return path;
|
|
13542
13967
|
}
|
|
13543
13968
|
function createDockerRunTerminalExport(args) {
|
|
@@ -13887,9 +14312,78 @@ function buildTokenDialogIndexOps(args) {
|
|
|
13887
14312
|
|
|
13888
14313
|
// packages/cli/client/localRuntimeDialog.ts
|
|
13889
14314
|
var import_format = __toESM(require_format(), 1);
|
|
13890
|
-
import { appendFileSync, mkdirSync as
|
|
13891
|
-
import { homedir } from "os";
|
|
13892
|
-
import { join as
|
|
14315
|
+
import { appendFileSync, mkdirSync as mkdirSync4 } from "fs";
|
|
14316
|
+
import { homedir as homedir2 } from "os";
|
|
14317
|
+
import { join as join8 } from "path";
|
|
14318
|
+
|
|
14319
|
+
// packages/cli/client/cliCompletedTurnCapture.ts
|
|
14320
|
+
async function readCliCaptureSources(args) {
|
|
14321
|
+
if (args.input.result.stopReason !== "done" || args.input.result.error) return [];
|
|
14322
|
+
const explicitIds = args.input.cliCaptureUserMessageIds;
|
|
14323
|
+
const ids = [...new Set([
|
|
14324
|
+
...args.input.messages.filter((message) => message.role === "user").map((message) => message.cliMessageId),
|
|
14325
|
+
...Array.isArray(explicitIds) ? explicitIds : [],
|
|
14326
|
+
...args.persistedUserMessageIds ?? []
|
|
14327
|
+
].filter((id) => typeof id === "string" && /^[A-Za-z0-9_-]{1,128}$/.test(id)))];
|
|
14328
|
+
const sources = [];
|
|
14329
|
+
for (const id of ids) {
|
|
14330
|
+
const key = `dialog-${args.dialogId}-msg-${id}`;
|
|
14331
|
+
const record = await args.read(key);
|
|
14332
|
+
if (record?.id !== id || record?.dialogId !== args.dialogId || record?.userId !== args.userId || record?.role !== "user" || isTombstoneRecord(record) || typeof record?.content !== "string" || !record.content.trim() || typeof record?.createdAt !== "string" || !Number.isFinite(Date.parse(record.createdAt))) continue;
|
|
14333
|
+
sources.push({ type: "put", key, value: record });
|
|
14334
|
+
}
|
|
14335
|
+
return sources;
|
|
14336
|
+
}
|
|
14337
|
+
async function captureCliCompletedTurn(args) {
|
|
14338
|
+
if (args.input.result.stopReason !== "done" || args.input.result.error) {
|
|
14339
|
+
return [{ status: "skipped", reason: "turn_not_completed" }];
|
|
14340
|
+
}
|
|
14341
|
+
if (!args.sources.length) return [{ status: "deferred", reason: "missing_persisted_source" }];
|
|
14342
|
+
const serverUrl = resolveRuntimeServerUrl(args.env);
|
|
14343
|
+
if (!serverUrl) return [{ status: "deferred", reason: "server_not_configured" }];
|
|
14344
|
+
const authToken = resolveRuntimeAuthToken(args.env);
|
|
14345
|
+
if (!authToken) return [{ status: "deferred", reason: "not_authenticated" }];
|
|
14346
|
+
const results = [];
|
|
14347
|
+
for (const source of args.sources) {
|
|
14348
|
+
const userMessageId = source.value.id;
|
|
14349
|
+
try {
|
|
14350
|
+
const response = await fetchWithTransientRetry(
|
|
14351
|
+
args.fetchImpl,
|
|
14352
|
+
`${serverUrl}/api/memory/capture-turn`,
|
|
14353
|
+
{
|
|
14354
|
+
method: "POST",
|
|
14355
|
+
headers: { "Content-Type": "application/json", Authorization: `Bearer ${authToken}` },
|
|
14356
|
+
// The transitional validator requires nonempty userInput; native capture ignores it.
|
|
14357
|
+
// A short inert marker also avoids legacy text extraction on older servers.
|
|
14358
|
+
body: JSON.stringify({
|
|
14359
|
+
agentKey: args.input.agentKey,
|
|
14360
|
+
dialogId: args.dialogId,
|
|
14361
|
+
userMessageId,
|
|
14362
|
+
userInput: "native source"
|
|
14363
|
+
}),
|
|
14364
|
+
signal: AbortSignal.timeout(remoteDialogSyncTimeout())
|
|
14365
|
+
},
|
|
14366
|
+
{ retryableStatuses: /* @__PURE__ */ new Set([429, 502, 503]) }
|
|
14367
|
+
);
|
|
14368
|
+
if (!response.ok) {
|
|
14369
|
+
results.push({ status: "deferred", reason: `http_${response.status}`, userMessageId });
|
|
14370
|
+
continue;
|
|
14371
|
+
}
|
|
14372
|
+
const body = await response.json();
|
|
14373
|
+
const native = body?.protocol === "native" ? body.nativeCapture : null;
|
|
14374
|
+
if (!native || !["captured", "skipped"].includes(native.capture) || !["applied", "no_op", "deferred", "failed"].includes(native.formation)) {
|
|
14375
|
+
results.push({ status: "deferred", reason: "native_capture_unconfirmed", userMessageId });
|
|
14376
|
+
} else {
|
|
14377
|
+
results.push({ status: native.capture, reason: `formation_${native.formation}`, userMessageId });
|
|
14378
|
+
}
|
|
14379
|
+
} catch {
|
|
14380
|
+
results.push({ status: "deferred", reason: "transport_or_response_error", userMessageId });
|
|
14381
|
+
}
|
|
14382
|
+
}
|
|
14383
|
+
return results;
|
|
14384
|
+
}
|
|
14385
|
+
|
|
14386
|
+
// packages/cli/client/localRuntimeDialog.ts
|
|
13893
14387
|
var diagLog = {
|
|
13894
14388
|
warn: (msg) => getLogger("cli.localRuntimeDialog").warn(msg),
|
|
13895
14389
|
info: (msg) => getLogger("cli.localRuntimeDialog").info(msg)
|
|
@@ -13940,11 +14434,11 @@ function projectRawUsage(usage) {
|
|
|
13940
14434
|
function debugCaptureRawUsage(item) {
|
|
13941
14435
|
if (!process.env.NOLO_DEBUG_RAW_USAGE) return;
|
|
13942
14436
|
try {
|
|
13943
|
-
const noloHome = process.env.NOLO_HOME?.trim() ||
|
|
13944
|
-
const dir =
|
|
13945
|
-
|
|
14437
|
+
const noloHome = process.env.NOLO_HOME?.trim() || join8(homedir2(), ".nolo");
|
|
14438
|
+
const dir = join8(noloHome, "logs");
|
|
14439
|
+
mkdirSync4(dir, { recursive: true });
|
|
13946
14440
|
appendFileSync(
|
|
13947
|
-
|
|
14441
|
+
join8(dir, "raw-usage.jsonl"),
|
|
13948
14442
|
JSON.stringify({
|
|
13949
14443
|
ts: Date.now(),
|
|
13950
14444
|
model: item.model,
|
|
@@ -14187,6 +14681,28 @@ async function writeDialog(args) {
|
|
|
14187
14681
|
existingDialog,
|
|
14188
14682
|
cwd: args.cwd
|
|
14189
14683
|
});
|
|
14684
|
+
const prefetchedUserMessages = /* @__PURE__ */ new Map();
|
|
14685
|
+
if (plan.captureUserMessageIds.length > 0) {
|
|
14686
|
+
const captureEntries = plan.captureUserMessageIds.map((id) => ({
|
|
14687
|
+
id,
|
|
14688
|
+
op: plan.ops.find((op) => op.value.id === id && op.value.role === "user")
|
|
14689
|
+
}));
|
|
14690
|
+
const uniqueKeys = [...new Set(captureEntries.map((entry) => entry.op.key))];
|
|
14691
|
+
const readResults = await Promise.all(
|
|
14692
|
+
uniqueKeys.map(async (key) => [key, await args.store.read(key, { remote: false })])
|
|
14693
|
+
);
|
|
14694
|
+
const existingByKey = new Map(readResults);
|
|
14695
|
+
for (const { id, op } of captureEntries) {
|
|
14696
|
+
const existing = existingByKey.get(op.key);
|
|
14697
|
+
if (existing) {
|
|
14698
|
+
if (existing.id !== id || existing.dialogId !== plan.dialogId || existing.userId !== args.userId || existing.role !== "user" || JSON.stringify(existing.content) !== JSON.stringify(op.value.content)) {
|
|
14699
|
+
throw new Error("CLI persisted turn source conflict");
|
|
14700
|
+
}
|
|
14701
|
+
op.value = existing;
|
|
14702
|
+
}
|
|
14703
|
+
prefetchedUserMessages.set(op.key, op.value);
|
|
14704
|
+
}
|
|
14705
|
+
}
|
|
14190
14706
|
const lastInputTokens = extractLastProviderInputTokens(args.input) ?? (typeof existingDialog?.lastInputTokens === "number" && Number.isFinite(existingDialog.lastInputTokens) && existingDialog.lastInputTokens > 0 ? existingDialog.lastInputTokens : void 0);
|
|
14191
14707
|
if (typeof lastInputTokens === "number" && lastInputTokens > 0) {
|
|
14192
14708
|
const dialogOp = plan.ops.find(
|
|
@@ -14204,9 +14720,12 @@ async function writeDialog(args) {
|
|
|
14204
14720
|
source: "cli-local"
|
|
14205
14721
|
});
|
|
14206
14722
|
if (args.cliBatchCompletion) {
|
|
14207
|
-
|
|
14208
|
-
|
|
14209
|
-
|
|
14723
|
+
const completionOps = await Promise.all(
|
|
14724
|
+
args.cliBatchCompletion.batchIds.map(
|
|
14725
|
+
(batchId) => buildCliBatchCompletionOp(args.store, plan.dialogId, batchId)
|
|
14726
|
+
)
|
|
14727
|
+
);
|
|
14728
|
+
plan.ops.push(...completionOps);
|
|
14210
14729
|
}
|
|
14211
14730
|
await args.store.batch(plan.ops);
|
|
14212
14731
|
if (__perfEnabled) {
|
|
@@ -14235,40 +14754,56 @@ async function writeDialog(args) {
|
|
|
14235
14754
|
diagLog.info(`perf writeDialog D:token-record (cumulative): ${ms}ms`);
|
|
14236
14755
|
}
|
|
14237
14756
|
const hasSubjectRefs = localTurnHasSubjectRefs(args.input);
|
|
14238
|
-
|
|
14239
|
-
|
|
14240
|
-
|
|
14241
|
-
|
|
14242
|
-
|
|
14243
|
-
|
|
14244
|
-
|
|
14245
|
-
|
|
14246
|
-
|
|
14247
|
-
|
|
14248
|
-
|
|
14249
|
-
|
|
14250
|
-
|
|
14251
|
-
|
|
14252
|
-
|
|
14253
|
-
|
|
14254
|
-
|
|
14255
|
-
}
|
|
14256
|
-
})();
|
|
14257
|
-
await remoteSyncPromise;
|
|
14258
|
-
} else {
|
|
14259
|
-
remoteSyncPromise = startOwnedDialogSync(args.fetchImpl, (fetchImpl) => syncLocalDialogEvidenceToRemote({
|
|
14757
|
+
let memoryCaptureResults = [];
|
|
14758
|
+
const reportCapture = (results) => {
|
|
14759
|
+
memoryCaptureResults = results;
|
|
14760
|
+
for (const result of results) {
|
|
14761
|
+
diagLog.info(`memory_capture ${result.status}: ${result.reason}`);
|
|
14762
|
+
}
|
|
14763
|
+
};
|
|
14764
|
+
const captureSources = await readCliCaptureSources({
|
|
14765
|
+
input: args.input,
|
|
14766
|
+
dialogId: plan.dialogId,
|
|
14767
|
+
userId: args.userId,
|
|
14768
|
+
persistedUserMessageIds: plan.captureUserMessageIds,
|
|
14769
|
+
read: (key) => prefetchedUserMessages.has(key) ? Promise.resolve(prefetchedUserMessages.get(key)) : args.store.read(key, { remote: false })
|
|
14770
|
+
}).catch(() => []);
|
|
14771
|
+
const syncAndCapture = async (fetchImpl) => {
|
|
14772
|
+
try {
|
|
14773
|
+
const syncResult = args.userId === "local" ? { attempted: false } : await syncLocalDialogEvidenceToRemote({
|
|
14260
14774
|
env: args.env,
|
|
14261
14775
|
fetchImpl,
|
|
14262
14776
|
input: args.input,
|
|
14263
|
-
ops: [...plan.ops, ...tokenOps],
|
|
14777
|
+
ops: [...plan.ops, ...tokenOps, ...captureSources],
|
|
14778
|
+
localStore: args.store,
|
|
14264
14779
|
output: args.output,
|
|
14265
14780
|
userId: args.userId
|
|
14266
|
-
})).catch((error) => {
|
|
14267
|
-
args.output?.write(`[nolo] Remote dialog evidence sync failed; class=${classifyDialogSyncFailure(error)}; local history retained; remote sync incomplete.
|
|
14268
|
-
`);
|
|
14269
14781
|
});
|
|
14782
|
+
if (!syncResult.attempted) {
|
|
14783
|
+
if (hasSubjectRefs) args.output?.write(
|
|
14784
|
+
"[nolo] Local dialog evidence is local-only; set NOLO_SERVER and AUTH_TOKEN to make subjectRefs remotely queryable.\n"
|
|
14785
|
+
);
|
|
14786
|
+
const result = args.input.result.stopReason !== "done" || args.input.result.error ? { status: "skipped", reason: "turn_not_completed" } : { status: "deferred", reason: !resolveRuntimeServerUrl(args.env) ? "server_not_configured" : args.userId === "local" || !resolveRuntimeAuthToken(args.env) ? "not_authenticated" : "remote_sync_unavailable" };
|
|
14787
|
+
reportCapture([result]);
|
|
14788
|
+
return;
|
|
14789
|
+
}
|
|
14790
|
+
reportCapture(await captureCliCompletedTurn({
|
|
14791
|
+
input: args.input,
|
|
14792
|
+
dialogId: plan.dialogId,
|
|
14793
|
+
sources: captureSources,
|
|
14794
|
+
env: args.env,
|
|
14795
|
+
fetchImpl
|
|
14796
|
+
}));
|
|
14797
|
+
} catch (error) {
|
|
14798
|
+
reportCapture([{ status: "deferred", reason: "remote_sync_failed" }]);
|
|
14799
|
+
throw error;
|
|
14270
14800
|
}
|
|
14271
|
-
}
|
|
14801
|
+
};
|
|
14802
|
+
const remoteSyncPromise = hasSubjectRefs ? syncAndCapture(args.fetchImpl) : startOwnedDialogSync(args.fetchImpl, syncAndCapture).catch((error) => {
|
|
14803
|
+
args.output?.write(`[nolo] Remote dialog evidence sync failed; class=${classifyDialogSyncFailure(error)}; local history retained; remote sync incomplete.
|
|
14804
|
+
`);
|
|
14805
|
+
});
|
|
14806
|
+
if (hasSubjectRefs) await remoteSyncPromise;
|
|
14272
14807
|
let titlePatchPromise;
|
|
14273
14808
|
if (titlePromise) {
|
|
14274
14809
|
const dialogKey = `dialog-${args.userId}-${plan.dialogId}`;
|
|
@@ -14296,7 +14831,9 @@ async function writeDialog(args) {
|
|
|
14296
14831
|
const ms = (performance.now() - __perfT0).toFixed(1);
|
|
14297
14832
|
diagLog.info(`perf writeDialog total (blocking): ${ms}ms`);
|
|
14298
14833
|
}
|
|
14299
|
-
return { dialogId: plan.dialogId, title: plan.title, titlePatchPromise, remoteSyncPromise
|
|
14834
|
+
return { dialogId: plan.dialogId, title: plan.title, titlePatchPromise, remoteSyncPromise, get memoryCaptureResults() {
|
|
14835
|
+
return memoryCaptureResults;
|
|
14836
|
+
} };
|
|
14300
14837
|
}
|
|
14301
14838
|
function resolveCliDialogRecordKey(userId, dialogId) {
|
|
14302
14839
|
if (dialogId.startsWith("dialog-") && !dialogId.includes("-msg-")) {
|
|
@@ -14314,12 +14851,14 @@ async function loadCliDialogSummary(args) {
|
|
|
14314
14851
|
const sourceHash = record.sourceHash;
|
|
14315
14852
|
const sourceCount = record.sourceCount;
|
|
14316
14853
|
const schemaVersion = record.schemaVersion;
|
|
14854
|
+
const sourceSegments = sanitizeSummarySourceSegments(record.sourceSegments);
|
|
14317
14855
|
return {
|
|
14318
14856
|
summary,
|
|
14319
14857
|
...typeof summarizedBeforeId === "string" && summarizedBeforeId ? { summarizedBeforeId } : {},
|
|
14320
14858
|
...typeof sourceHash === "string" && sourceHash ? { sourceHash } : {},
|
|
14321
14859
|
...typeof sourceCount === "number" && sourceCount > 0 ? { sourceCount } : {},
|
|
14322
14860
|
..."schemaVersion" in record ? { schemaVersion } : {},
|
|
14861
|
+
...sourceSegments ? { sourceSegments } : {},
|
|
14323
14862
|
...Array.isArray(record.referenceKeys) ? { referenceKeys: record.referenceKeys.filter((key) => typeof key === "string") } : {}
|
|
14324
14863
|
};
|
|
14325
14864
|
}
|
|
@@ -14328,6 +14867,7 @@ async function saveCliDialogSummary(args) {
|
|
|
14328
14867
|
const existing = await args.store.read(dialogKey) ?? {};
|
|
14329
14868
|
const bareId = typeof existing.id === "string" && existing.id ? existing.id : args.dialogId.startsWith("dialog-") ? dialogIdFromKey(dialogKey) : args.dialogId;
|
|
14330
14869
|
const compressionCount = typeof existing.compressionCount === "number" ? existing.compressionCount + 1 : 1;
|
|
14870
|
+
const sanitizedSourceSegments = sanitizeSummarySourceSegments(args.sourceSegments);
|
|
14331
14871
|
await registerDialogOwner({
|
|
14332
14872
|
store: { get: (key) => args.store.read(key, { remote: false }), put: (key, value) => args.store.write(key, value) },
|
|
14333
14873
|
dialogId: bareId,
|
|
@@ -14345,6 +14885,7 @@ async function saveCliDialogSummary(args) {
|
|
|
14345
14885
|
...args.sourceHash !== void 0 ? { sourceHash: args.sourceHash } : {},
|
|
14346
14886
|
...args.sourceCount !== void 0 ? { sourceCount: args.sourceCount } : {},
|
|
14347
14887
|
...args.schemaVersion !== void 0 ? { schemaVersion: args.schemaVersion } : {},
|
|
14888
|
+
...sanitizedSourceSegments !== void 0 ? { sourceSegments: sanitizedSourceSegments } : {},
|
|
14348
14889
|
referenceKeys: Array.from(/* @__PURE__ */ new Set([
|
|
14349
14890
|
...Array.isArray(existing.referenceKeys) ? existing.referenceKeys.filter((key) => typeof key === "string") : [],
|
|
14350
14891
|
...args.referenceKeys ?? []
|
|
@@ -14616,6 +15157,25 @@ function createCliLocalRuntimeAdapter(deps) {
|
|
|
14616
15157
|
const defaultCompactionSummary = createTuiSummaryLlmCaller(deps.env, { fetchImpl, platformPrimary: true });
|
|
14617
15158
|
const loopbackRequest = deps.loopbackRequest ?? (deps.fetchImpl ? void 0 : defaultLoopbackRequest);
|
|
14618
15159
|
const userId = resolveLocalUserId(deps.env);
|
|
15160
|
+
const prependManualCompactHistory = async (dialogId, history) => {
|
|
15161
|
+
const record = await (await getOrCreateSharedStore(deps)).read(`dialog-${userId}-${dialogId}`);
|
|
15162
|
+
if (!Array.isArray(record?.manualCompactHistory)) return history;
|
|
15163
|
+
const { dialogMessageRecordToAgentRuntimeMessage: dialogMessageRecordToAgentRuntimeMessage2 } = await import("./dialogMessageRecord-OAV77LT7.js");
|
|
15164
|
+
const seed = record.manualCompactHistory.map((message) => {
|
|
15165
|
+
const parsed = dialogMessageRecordToAgentRuntimeMessage2(message);
|
|
15166
|
+
if (!parsed) throw new Error("Invalid manual compact history");
|
|
15167
|
+
return parsed;
|
|
15168
|
+
});
|
|
15169
|
+
return [...seed, ...history];
|
|
15170
|
+
};
|
|
15171
|
+
const resolveLiveImageSupport = createLiveImageSupportResolver(userId, async () => {
|
|
15172
|
+
const token = await createOAuthApiKeyRefResolver({
|
|
15173
|
+
migration: { enableLegacyMigration: true },
|
|
15174
|
+
localUserId: userId
|
|
15175
|
+
})("antigravity");
|
|
15176
|
+
if (!token) return {};
|
|
15177
|
+
return fetchAntigravityAvailableModels(fetchImpl, token);
|
|
15178
|
+
});
|
|
14619
15179
|
const localToolBudgets = parseLocalToolBudgets(deps.env);
|
|
14620
15180
|
const localToolUsage = /* @__PURE__ */ new Map();
|
|
14621
15181
|
const buildProviderOpenAiTools = deps.buildProviderOpenAiTools ?? buildOpenAiTools;
|
|
@@ -14783,15 +15343,15 @@ function createCliLocalRuntimeAdapter(deps) {
|
|
|
14783
15343
|
const runId = asOptionalTrimmedString(deps.env?.NOLO_AGENT_RUN_ID) ?? "interactive";
|
|
14784
15344
|
emitRunIsolationNotice(fact, { runId });
|
|
14785
15345
|
try {
|
|
14786
|
-
const { writeFileSync: writeFileSync4, mkdirSync:
|
|
14787
|
-
const { resolveRunsDir: resolveRunsDir2 } = await import("./agentRunControl-
|
|
15346
|
+
const { writeFileSync: writeFileSync4, mkdirSync: mkdirSync5 } = await import("node:fs");
|
|
15347
|
+
const { resolveRunsDir: resolveRunsDir2 } = await import("./agentRunControl-CSMSJFFB.js");
|
|
14788
15348
|
recordLocalRunExecutionIsolation({
|
|
14789
15349
|
runId,
|
|
14790
15350
|
runsDir: resolveRunsDir2(deps.env),
|
|
14791
15351
|
fact,
|
|
14792
15352
|
fs: {
|
|
14793
15353
|
writeFileSync: (path, data) => writeFileSync4(path, data),
|
|
14794
|
-
mkdirSync: (path, options) =>
|
|
15354
|
+
mkdirSync: (path, options) => mkdirSync5(path, options)
|
|
14795
15355
|
}
|
|
14796
15356
|
});
|
|
14797
15357
|
getLogger("cli.localRuntimeAdapter").info(
|
|
@@ -14809,7 +15369,7 @@ function createCliLocalRuntimeAdapter(deps) {
|
|
|
14809
15369
|
dockerWorkloadReleased = true;
|
|
14810
15370
|
dockerWorkloadLoad = null;
|
|
14811
15371
|
if (loaded) {
|
|
14812
|
-
const { resolveRunsDir: resolveRunsDir2 } = await import("./agentRunControl-
|
|
15372
|
+
const { resolveRunsDir: resolveRunsDir2 } = await import("./agentRunControl-CSMSJFFB.js");
|
|
14813
15373
|
const exportRunDiff = deps.exportDockerRunDiffArtifact ?? exportDockerRunDiffArtifact;
|
|
14814
15374
|
const warn = (message) => process.stderr.write(`[nolo] ${message}
|
|
14815
15375
|
`);
|
|
@@ -14890,7 +15450,6 @@ function createCliLocalRuntimeAdapter(deps) {
|
|
|
14890
15450
|
}
|
|
14891
15451
|
};
|
|
14892
15452
|
let runtimeToolExecutionLimits = {};
|
|
14893
|
-
const skillPolicyFingerprint = (source) => JSON.stringify(Object.entries(resolveAgentSkillConfig(source)).sort(([a], [b]) => a.localeCompare(b)));
|
|
14894
15453
|
let reviewAgentConfig;
|
|
14895
15454
|
let planningCaller = {};
|
|
14896
15455
|
const isCanonicalAutoReviewAdmitted = (visits) => {
|
|
@@ -14910,6 +15469,10 @@ function createCliLocalRuntimeAdapter(deps) {
|
|
|
14910
15469
|
readXPost: deps.readXPost,
|
|
14911
15470
|
readXhsProfile: deps.readXhsProfile,
|
|
14912
15471
|
cliEntrypoint: CLI_ENTRYPOINT,
|
|
15472
|
+
// 本地进程内直连:readDialog / listDialogs 走已在手的共享 store
|
|
15473
|
+
// (local-first,未命中才远端回退),不再 spawn `nolo` 子进程 + 试探
|
|
15474
|
+
// 多个 HTTP 端点;本地答不了时 executor 内部自行回退 CLI 桥。
|
|
15475
|
+
resolveDialogStore: () => getOrCreateSharedStore(deps),
|
|
14913
15476
|
resolveAgentCredentialGroup,
|
|
14914
15477
|
resolveAgentDisplayName,
|
|
14915
15478
|
// α:spawn 前从 agent 配置回读真实 name(resolveAgentRunName 的读取来源)。
|
|
@@ -14924,6 +15487,10 @@ function createCliLocalRuntimeAdapter(deps) {
|
|
|
14924
15487
|
const deleted = Boolean(rec?.deletedAt || rec?.deleted || rec?.isDeleted);
|
|
14925
15488
|
return !deleted && typeof rec?.name === "string" && rec.name.trim() ? rec.name.trim() : void 0;
|
|
14926
15489
|
},
|
|
15490
|
+
resolveAgentImageSupport: async (agentRef) => {
|
|
15491
|
+
const record = await readAgentFromStore({ agentRef, store: await getOrCreateSharedStore(deps), userId });
|
|
15492
|
+
return !!record && resolveAgentImageInputSupport(await resolveLiveImageSupport({ ...record, hasVision: record.hasVision ?? false }));
|
|
15493
|
+
},
|
|
14927
15494
|
resolveAgentModel,
|
|
14928
15495
|
dialogExistsForCurrentUser: async (dialogId) => {
|
|
14929
15496
|
const store = await getOrCreateSharedStore(deps);
|
|
@@ -14932,6 +15499,20 @@ function createCliLocalRuntimeAdapter(deps) {
|
|
|
14932
15499
|
},
|
|
14933
15500
|
resolveAgentRuntimeBindingMachineId,
|
|
14934
15501
|
resolveLocalMachineId,
|
|
15502
|
+
mcpApprovalHostForAgent: async (childAgentKey) => {
|
|
15503
|
+
const approvalSignal = deps.mcpApprovalSignal ?? deps.shellApprovalSession?.signal;
|
|
15504
|
+
if (!getHostApprovalRenderer() || !approvalSignal || approvalSignal.aborted) return void 0;
|
|
15505
|
+
const binding = await resolveChildApprovalBinding({
|
|
15506
|
+
readAgentConfig: async (key) => readAgentFromStore({ agentRef: key, store: await getOrCreateSharedStore(deps), userId }),
|
|
15507
|
+
resolveDeviceId: async () => {
|
|
15508
|
+
const { detectMachineInfo } = await import("./machineInfo-LWHTEBHJ.js");
|
|
15509
|
+
return (await detectMachineInfo({ probeLaunchable: false }))?.machineId;
|
|
15510
|
+
},
|
|
15511
|
+
workspaceRoot,
|
|
15512
|
+
agentKey: childAgentKey
|
|
15513
|
+
});
|
|
15514
|
+
return binding ? { binding, signal: approvalSignal, confirm: confirmMcpOnHost } : void 0;
|
|
15515
|
+
},
|
|
14935
15516
|
...deps.shellApprovalSession ? {
|
|
14936
15517
|
shellApprovalHostForAgent: createChildShellApprovalHostResolver({
|
|
14937
15518
|
readAgentConfig: async (childAgentKey) => readAgentFromStore({
|
|
@@ -14964,6 +15545,13 @@ function createCliLocalRuntimeAdapter(deps) {
|
|
|
14964
15545
|
} } : {},
|
|
14965
15546
|
...runtimeToolExecutionLimits
|
|
14966
15547
|
});
|
|
15548
|
+
let localMcpManagement;
|
|
15549
|
+
const getLocalMcpManagement = () => localMcpManagement ??= openMcpLocalRuntimeManagement({
|
|
15550
|
+
authenticatedUserId: userId,
|
|
15551
|
+
env: deps.env,
|
|
15552
|
+
createOAuthManager: deps.createMcpOAuthManager
|
|
15553
|
+
});
|
|
15554
|
+
const localMcpSessions = /* @__PURE__ */ new Map();
|
|
14967
15555
|
let localToolExecutors = buildCurrentToolExecutors();
|
|
14968
15556
|
const credentialBroker = createHostCredentialBrokerChain({
|
|
14969
15557
|
strict: createStrictHostCredentialBroker(),
|
|
@@ -15102,14 +15690,24 @@ function createCliLocalRuntimeAdapter(deps) {
|
|
|
15102
15690
|
const cached = deps.pastedTextStore ? void 0 : preparedAgentRuntimeCache.get(cacheKey);
|
|
15103
15691
|
if (cached) {
|
|
15104
15692
|
const localRecord = await sharedStore.read(cached.agentConfig.key, { remote: false }).catch(() => null);
|
|
15105
|
-
const
|
|
15693
|
+
const effectiveLocalRecord = localRecord && typeof localRecord === "object" ? applyBuiltinAgentRuntimeOverride(
|
|
15694
|
+
agentRef,
|
|
15695
|
+
resolveAgentRuntimeConfigFromRecord(
|
|
15696
|
+
cached.agentConfig.key,
|
|
15697
|
+
applyPublicAgentCatalogOverride(
|
|
15698
|
+
localRecord,
|
|
15699
|
+
cached.agentConfig.key
|
|
15700
|
+
)
|
|
15701
|
+
)
|
|
15702
|
+
).rawRecord : null;
|
|
15703
|
+
const unchanged = !localRecord || cached.localAgentConfigFingerprint !== void 0 && effectiveLocalRecord != null && cached.localAgentConfigFingerprint === buildLocalAgentConfigFingerprint(effectiveLocalRecord);
|
|
15106
15704
|
if (!unchanged) preparedAgentRuntimeCache.delete(cacheKey);
|
|
15107
15705
|
if (unchanged) {
|
|
15108
15706
|
activeAgentToolNames = cached.activeAgentToolNames;
|
|
15109
15707
|
runtimeToolExecutionLimits = cached.runtimeToolExecutionLimits;
|
|
15110
15708
|
reviewAgentConfig = cached.agentConfig;
|
|
15111
15709
|
localToolExecutors = buildCurrentToolExecutors(cached.agentConfig);
|
|
15112
|
-
return cached.agentConfig;
|
|
15710
|
+
return resolveLiveImageSupport(cached.agentConfig);
|
|
15113
15711
|
}
|
|
15114
15712
|
}
|
|
15115
15713
|
const storedAgentConfig = await readAgentFromStore({
|
|
@@ -15141,10 +15739,10 @@ function createCliLocalRuntimeAdapter(deps) {
|
|
|
15141
15739
|
const userPromptPatches = accountAutoReviewPrompt ? [...userSkills.skillPromptPatches, accountAutoReviewPrompt] : userSkills.skillPromptPatches;
|
|
15142
15740
|
const agentConfig = packAgentConfig && userPromptPatches.length ? {
|
|
15143
15741
|
...packAgentConfig,
|
|
15144
|
-
|
|
15145
|
-
|
|
15146
|
-
|
|
15147
|
-
].filter(Boolean).join("\n\n")
|
|
15742
|
+
// Patches are admitted by the account skill graph and arrive once per
|
|
15743
|
+
// canonical skill identity. Keep them separate from arbitrary prompt
|
|
15744
|
+
// text: substring matching cannot establish runtime contribution ownership.
|
|
15745
|
+
prompt: [packAgentConfig.prompt, ...userPromptPatches].filter(Boolean).join("\n\n")
|
|
15148
15746
|
} : packAgentConfig;
|
|
15149
15747
|
const requestedToolNames = agentConfig ? resolveCliRequestedToolNames(
|
|
15150
15748
|
agentConfig,
|
|
@@ -15190,12 +15788,14 @@ function createCliLocalRuntimeAdapter(deps) {
|
|
|
15190
15788
|
if (exposedAgentConfig && !deps.pastedTextStore) {
|
|
15191
15789
|
preparedAgentRuntimeCache.set(cacheKey, {
|
|
15192
15790
|
agentConfig: exposedAgentConfig,
|
|
15193
|
-
|
|
15791
|
+
localAgentConfigFingerprint: buildLocalAgentConfigFingerprint(
|
|
15792
|
+
exposedAgentConfig.rawRecord
|
|
15793
|
+
),
|
|
15194
15794
|
activeAgentToolNames,
|
|
15195
15795
|
runtimeToolExecutionLimits
|
|
15196
15796
|
});
|
|
15197
15797
|
}
|
|
15198
|
-
return exposedAgentConfig;
|
|
15798
|
+
return exposedAgentConfig ? resolveLiveImageSupport(exposedAgentConfig) : exposedAgentConfig;
|
|
15199
15799
|
},
|
|
15200
15800
|
loadDialogHistory: async (dialogId) => {
|
|
15201
15801
|
const loaded = await loadCliDialogHistoryWithSource({
|
|
@@ -15204,21 +15804,25 @@ function createCliLocalRuntimeAdapter(deps) {
|
|
|
15204
15804
|
env: deps.env,
|
|
15205
15805
|
fetchImpl
|
|
15206
15806
|
});
|
|
15207
|
-
return loaded.messages;
|
|
15807
|
+
return prependManualCompactHistory(dialogId, loaded.messages);
|
|
15208
15808
|
},
|
|
15209
15809
|
// Source-aware variant so a cross-machine resume that could not load the
|
|
15210
15810
|
// remote history reports `none` instead of looking like a new dialog.
|
|
15211
|
-
loadDialogHistoryWithSource: async (dialogId, options) =>
|
|
15212
|
-
|
|
15213
|
-
|
|
15214
|
-
|
|
15215
|
-
|
|
15216
|
-
|
|
15217
|
-
|
|
15218
|
-
|
|
15219
|
-
|
|
15220
|
-
|
|
15221
|
-
|
|
15811
|
+
loadDialogHistoryWithSource: async (dialogId, options) => {
|
|
15812
|
+
const loaded = await loadCliDialogHistoryWithSource({
|
|
15813
|
+
strictContinueHistory: options?.strictContinueHistory,
|
|
15814
|
+
freshDialog: options?.freshDialog,
|
|
15815
|
+
dialogId,
|
|
15816
|
+
store: await getOrCreateSharedStore(deps),
|
|
15817
|
+
env: deps.env,
|
|
15818
|
+
fetchImpl,
|
|
15819
|
+
log: (message) => {
|
|
15820
|
+
logLocalRuntimeDiagnostic("dialog-history", { dialogId, message });
|
|
15821
|
+
}
|
|
15822
|
+
});
|
|
15823
|
+
const messages = await prependManualCompactHistory(dialogId, loaded.messages);
|
|
15824
|
+
return { ...loaded, messages };
|
|
15825
|
+
},
|
|
15222
15826
|
loadDialogSummary: async (dialogId) => loadCliDialogSummary({
|
|
15223
15827
|
store: await getOrCreateSharedStore(deps),
|
|
15224
15828
|
userId,
|
|
@@ -15233,6 +15837,7 @@ function createCliLocalRuntimeAdapter(deps) {
|
|
|
15233
15837
|
sourceHash: input.sourceHash,
|
|
15234
15838
|
sourceCount: input.sourceCount,
|
|
15235
15839
|
schemaVersion: input.schemaVersion,
|
|
15840
|
+
...input.sourceSegments !== void 0 ? { sourceSegments: input.sourceSegments } : {},
|
|
15236
15841
|
referenceKeys: input.referenceKeys
|
|
15237
15842
|
}),
|
|
15238
15843
|
loadLastContextUsage: async (dialogId) => {
|
|
@@ -15411,6 +16016,9 @@ function createCliLocalRuntimeAdapter(deps) {
|
|
|
15411
16016
|
...ownerOriginExecution ? { ownerOriginExecution } : {}
|
|
15412
16017
|
});
|
|
15413
16018
|
},
|
|
16019
|
+
onWorkingHistoryReplaced: () => {
|
|
16020
|
+
localToolExecutors.readFile?.resetReadLedger?.();
|
|
16021
|
+
},
|
|
15414
16022
|
executeTool: async (call, opts) => {
|
|
15415
16023
|
const contextualCall = opts?.runtimeContext ? { ...call, runtimeContext: opts.runtimeContext } : call;
|
|
15416
16024
|
let injectedCall = contextualCall;
|
|
@@ -15585,7 +16193,43 @@ function createCliLocalRuntimeAdapter(deps) {
|
|
|
15585
16193
|
workspaceRoot,
|
|
15586
16194
|
execShellApproval: deps.execShellApproval,
|
|
15587
16195
|
...runtimeToolExecutionLimits,
|
|
15588
|
-
executors: localToolExecutors,
|
|
16196
|
+
executors: call.name === "listMcpConnections" || call.name === "listMcpTools" || call.name === "callMcpTool" ? { ...localToolExecutors, [call.name]: async (mcpCall) => {
|
|
16197
|
+
const dialogId = opts?.runtimeContext?.dialogId ?? deps.parentDialogId;
|
|
16198
|
+
const agentKey = planningCaller.agentKey;
|
|
16199
|
+
const signal = opts?.abortSignal;
|
|
16200
|
+
if (!userId || !agentKey || typeof dialogId !== "string" || !dialogId || !signal) {
|
|
16201
|
+
return { content: JSON.stringify({ ok: false, error: { code: "forbidden" } }) };
|
|
16202
|
+
}
|
|
16203
|
+
try {
|
|
16204
|
+
let entries = localMcpSessions.get(signal);
|
|
16205
|
+
if (!entries) {
|
|
16206
|
+
entries = /* @__PURE__ */ new Map();
|
|
16207
|
+
localMcpSessions.set(signal, entries);
|
|
16208
|
+
signal.addEventListener("abort", () => {
|
|
16209
|
+
localMcpSessions.delete(signal);
|
|
16210
|
+
for (const pending2 of entries.values()) void pending2.then((mcp2) => mcp2.close()).catch(() => {
|
|
16211
|
+
});
|
|
16212
|
+
}, { once: true });
|
|
16213
|
+
}
|
|
16214
|
+
const key = JSON.stringify([agentKey, dialogId]);
|
|
16215
|
+
let pending = entries.get(key);
|
|
16216
|
+
if (!pending) {
|
|
16217
|
+
pending = getLocalMcpManagement().then((repository) => createMcpLocalRuntimeAdapter({
|
|
16218
|
+
repository,
|
|
16219
|
+
identity: { authenticatedUserId: userId, agentKey, dialogId },
|
|
16220
|
+
signal: deps.mcpApprovalSignal ? AbortSignal.any([signal, deps.mcpApprovalSignal]) : signal,
|
|
16221
|
+
confirm: deps.mcpConfirmation
|
|
16222
|
+
}));
|
|
16223
|
+
entries.set(key, pending);
|
|
16224
|
+
}
|
|
16225
|
+
const mcp = await pending;
|
|
16226
|
+
const input = JSON.parse(mcpCall.arguments);
|
|
16227
|
+
const output = call.name === "listMcpConnections" ? await mcp.listMcpConnections() : call.name === "listMcpTools" ? await mcp.listMcpTools(input) : await mcp.callMcpTool(input);
|
|
16228
|
+
return { content: JSON.stringify(output) };
|
|
16229
|
+
} catch {
|
|
16230
|
+
return { content: JSON.stringify({ ok: false, error: { code: signal.aborted ? "cancelled" : "transport_error" } }) };
|
|
16231
|
+
}
|
|
16232
|
+
} } : localToolExecutors,
|
|
15589
16233
|
// 沙盒分支的 gate 已经跑过(channel 未接管才会落回这里):把
|
|
15590
16234
|
// confirmed 传下去,避免破坏性确认在同一调用里弹第二次。
|
|
15591
16235
|
...sandboxGatePassed ? { confirmed: true } : {},
|
|
@@ -15655,12 +16299,6 @@ function createCliLocalRuntimeAdapter(deps) {
|
|
|
15655
16299
|
}
|
|
15656
16300
|
|
|
15657
16301
|
export {
|
|
15658
|
-
readTimestamp,
|
|
15659
|
-
parseAgentRunEvent,
|
|
15660
|
-
isLiveAgentRunObservation,
|
|
15661
|
-
formatApprovalRemaining,
|
|
15662
|
-
createHostApprovalCardQueue,
|
|
15663
|
-
registerHostApprovalRenderer,
|
|
15664
16302
|
matchContextualFragment,
|
|
15665
16303
|
renderNoticeElements,
|
|
15666
16304
|
renderCliNotice,
|
|
@@ -15669,14 +16307,17 @@ export {
|
|
|
15669
16307
|
buildNoticeTasksFromRuns,
|
|
15670
16308
|
setTurnNoticeMeta,
|
|
15671
16309
|
mergeNoticeGroup,
|
|
15672
|
-
|
|
15673
|
-
|
|
16310
|
+
readTimestamp,
|
|
16311
|
+
parseAgentRunEvent,
|
|
16312
|
+
isLiveAgentRunObservation,
|
|
15674
16313
|
createOriginShellGrant,
|
|
16314
|
+
createCliHybridRecordStore,
|
|
15675
16315
|
preparedAgentRuntimeCache,
|
|
15676
16316
|
hybridStoreCache,
|
|
15677
16317
|
normalizeRuntimeCacheCwd,
|
|
15678
16318
|
buildPreparedAgentCacheKey,
|
|
15679
16319
|
clearCliLocalRuntimePreparedAgentCache,
|
|
16320
|
+
buildLocalAgentConfigFingerprint,
|
|
15680
16321
|
defaultLocalRuntimeDb,
|
|
15681
16322
|
createFallbackId,
|
|
15682
16323
|
logLocalRuntimeDiagnostic,
|
|
@@ -15713,6 +16354,7 @@ export {
|
|
|
15713
16354
|
resolveBoundMachineId,
|
|
15714
16355
|
isCliProviderAgentConfig,
|
|
15715
16356
|
detectCurrentMachineId,
|
|
16357
|
+
normalizeCliRunImages,
|
|
15716
16358
|
readFlagValue,
|
|
15717
16359
|
isFullstackCodingAgentRef,
|
|
15718
16360
|
positionalArgs,
|