nolo-cli 0.228.0-alpha.2 → 0.228.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-VYCHHZVT.js → _executeModel-AKCTHGMP.js} +89 -83
- package/{accountResolver-QETKNC7T.js → accountResolver-NGICIMEE.js} +1 -1
- package/{action-GDZDXPMB.js → action-C6IQAKN4.js} +8 -5
- package/{addContentAction-7RO4AMRI.js → addContentAction-53364YDW.js} +13 -12
- package/{addDialogAgentAction-EVYBGTXB.js → addDialogAgentAction-U5DD5EN5.js} +16 -15
- package/{agentDeleteCommand-QWQKT54A.js → agentDeleteCommand-2E5FAGUO.js} +128 -115
- package/{agentEmailCommands-EISMBIRE.js → agentEmailCommands-UGZZAH7E.js} +128 -111
- package/{agentListCommands-4WLG32IW.js → agentListCommands-JCTW3J2K.js} +398 -179
- package/{agentMachineCommands-DC6NKWTU.js → agentMachineCommands-QPG5ZXF4.js} +58 -47
- package/{agentProviderCommands-STI3DQ6A.js → agentProviderCommands-QLTABYR7.js} +2 -2
- package/{agentPullCommand-KHV4EELF.js → agentPullCommand-2EYJ5ENC.js} +1 -1
- package/agentRecordCommands-4NTVR6MZ.js +194 -0
- package/agentRunCommand-VHF34PYC.js +232 -0
- package/{agentRunControl-MBG4U6SL.js → agentRunControl-QYTXUQGY.js} +14 -9
- package/{agentRuntimeLocal-HOXKWCYO.js → agentRuntimeLocal-U54AKHXH.js} +58 -43
- package/{agentSlice-UG76KEBH.js → agentSlice-4JGDEXWK.js} +14 -13
- package/{appDeleteCommands-WWCC6WA5.js → appDeleteCommands-XBE5QJ6P.js} +58 -47
- package/{appDeployCommands-AU4IUN33.js → appDeployCommands-QIYLXXGA.js} +58 -47
- package/{appDeployStatusCommands-STUW7WXL.js → appDeployStatusCommands-JXS6ZQZZ.js} +58 -47
- package/{appGetCommands-BGTLIQ4K.js → appGetCommands-SZS7SJPK.js} +58 -47
- package/{appListCommands-CUCPRUXW.js → appListCommands-B3GBJSNV.js} +58 -47
- package/{authCommand-OZ2KTP4Z.js → authCommand-V6EOMZX6.js} +25 -19
- package/{authCommands-55OGQGCR.js → authCommands-T5FODCEG.js} +12 -6
- package/{builtinSkillRegistry-BAE2LDXF.js → builtinSkillRegistry-ZQC3IIO2.js} +8 -7
- package/{chromeCommands-G5UDKVSV.js → chromeCommands-O4IIKTBD.js} +384 -7
- package/{chromeOpsCommands-WAA45NCS.js → chromeOpsCommands-OFX7ZGKP.js} +3 -3
- package/{chunk-DBUR22G5.js → chunk-223KZUJ6.js} +19 -15
- package/{chunk-3U44JB3O.js → chunk-2C5VN7NH.js} +1 -1
- package/{chunk-PWTNI4N7.js → chunk-2E4BYAUE.js} +22 -0
- package/{chunk-L32W3PRP.js → chunk-2FZVXOFX.js} +234 -18
- package/{chunk-HBRDSQ3M.js → chunk-2JHGUL5K.js} +3 -2
- package/chunk-2SXN7LAY.js +15 -0
- package/chunk-3A5NNQCN.js +64 -0
- package/chunk-3F2FRLIO.js +372 -0
- package/{chunk-DEA37IUY.js → chunk-46FETNLF.js} +2 -2
- package/{chunk-ZEVQHCLM.js → chunk-4GYVS4PM.js} +8 -6
- package/{chunk-CBUZ6DKA.js → chunk-4YPH5KRA.js} +1 -1
- package/chunk-4ZCTKB27.js +31 -0
- package/chunk-53W5BXLN.js +340 -0
- package/{chunk-7FEP5USX.js → chunk-5AYP5QBB.js} +5 -5
- package/{chunk-XAG3FWBE.js → chunk-5ISNPTQH.js} +5 -5
- package/{chunk-EVGU5P4U.js → chunk-5P3PPQVP.js} +1 -1
- package/{chunk-XSW4EXQV.js → chunk-6BMTKYAO.js} +55 -18
- package/chunk-6PAHSSD2.js +33401 -0
- package/{chunk-ZOHO6MOF.js → chunk-6RSNVJGO.js} +2 -99
- package/{chunk-7JGMNKKG.js → chunk-6SOWMEAY.js} +30 -9
- package/{chunk-RG2DGNL6.js → chunk-6VEO7Z3Y.js} +3 -3
- package/{chunk-PDCV7P5W.js → chunk-6XIE5ZGI.js} +1 -1
- package/{chunk-DGYCDA6W.js → chunk-7BIJFGKS.js} +36 -17
- package/{chunk-WFDNADFX.js → chunk-7OVOZRZF.js} +8 -8
- package/{chunk-WCFFRBL5.js → chunk-7PON4LBY.js} +45 -27
- package/{chunk-QRGDJA4B.js → chunk-7WHCIA5V.js} +33 -7
- package/{chunk-CMMI3DAT.js → chunk-ADYWV732.js} +59 -30
- package/{chunk-QYB23WUH.js → chunk-AIFQKNPP.js} +1 -1
- package/{chunk-HGDKT2D6.js → chunk-BPB3T5EU.js} +174 -1
- package/{chunk-DUUDXSLX.js → chunk-BZLGPM5B.js} +28 -4
- package/{chunk-ATEKLSLR.js → chunk-BZMDWGQQ.js} +14 -9
- package/chunk-C5A54QS7.js +108 -0
- package/{chunk-S6K5F3KP.js → chunk-CEKRIR22.js} +1 -1
- package/{chunk-42OKN2LI.js → chunk-D634SL2Y.js} +9 -107
- package/{chunk-DLXMMTGM.js → chunk-DHRPLRIR.js} +1283 -786
- package/{chunk-LKA64WH4.js → chunk-DMPZMYH4.js} +37 -1
- package/{chunk-OBIC6EG7.js → chunk-DNNPARJK.js} +9 -5
- package/{chunk-X3E6EHJW.js → chunk-E3LSO6EI.js} +292 -207
- package/{chunk-OQHIVPG4.js → chunk-E6A5NHDH.js} +4 -1
- package/chunk-EHFBP6IK.js +791 -0
- package/chunk-EJQE5HB7.js +21 -0
- package/{chunk-VQ5N5GSV.js → chunk-EL5NRJHI.js} +4 -4
- package/chunk-EUGTFFO6.js +42 -0
- package/{chunk-7BCG67EI.js → chunk-EVHTYVD2.js} +1199 -442
- package/{chunk-6XRPBZRS.js → chunk-EYLGAEB4.js} +0 -134
- package/{chunk-262R3XNN.js → chunk-FEIVARWR.js} +377 -112
- package/{chunk-3VZLEKV2.js → chunk-FLBJ7IJI.js} +14 -14
- package/{chunk-EEOOBRA7.js → chunk-FXEPZKNJ.js} +13 -6
- package/{chunk-XTJKU3Z4.js → chunk-FYAMUU55.js} +677 -140
- package/{chunk-M3OZRQNH.js → chunk-FZANZZ63.js} +1 -1
- package/chunk-GAHJLSDO.js +107 -0
- package/{chunk-WWTSEBDF.js → chunk-GIXWVN2W.js} +1 -1
- package/{chunk-4N6G2CKP.js → chunk-HDKMVYNJ.js} +47 -1
- package/chunk-HEVRQGGH.js +106 -0
- package/{chunk-BIWI5M4E.js → chunk-HFHJPHFK.js} +1 -1
- package/{chunk-R6Z5S5GA.js → chunk-HPDLPEUG.js} +60 -17
- package/{chunk-YKY4OVOX.js → chunk-HQUGB2HM.js} +17 -170
- package/chunk-IIRJ4P4I.js +24 -0
- package/chunk-IVK2KT3H.js +209 -0
- package/{chunk-ALAES342.js → chunk-IYLUK67R.js} +9 -5
- package/{chunk-N5Z2V73W.js → chunk-J55F3IEZ.js} +1 -1
- package/{chunk-S6FDXXZV.js → chunk-J7JRCOIW.js} +2 -2
- package/{chunk-OWKNSIXL.js → chunk-JAKRY74O.js} +470 -83
- package/{chunk-VS276URX.js → chunk-JCQ3WCQ3.js} +4 -2
- package/chunk-JLZJL3WC.js +988 -0
- package/{chunk-OBSEKCVK.js → chunk-JPXACKSW.js} +219 -52
- package/{chunk-OTKSESZR.js → chunk-KDBDOXOM.js} +138 -54
- package/{chunk-VP3BINY7.js → chunk-KDDHQMSH.js} +31 -1
- package/{chunk-RBPUNSG5.js → chunk-KG27JIG4.js} +18 -108
- package/{chunk-4WVJLODK.js → chunk-KHYSFS3W.js} +88 -7
- package/{chunk-TCZ2VJZQ.js → chunk-KKIQAVDR.js} +9 -9
- package/{chunk-4JVNURX4.js → chunk-KQHEGELM.js} +68 -16
- package/chunk-KXOPLLFP.js +190 -0
- package/{chunk-HS7MLR74.js → chunk-KZ4A7EIV.js} +3 -5
- package/{chunk-HYLRQDEE.js → chunk-LLUBUHNT.js} +6 -6
- package/{chunk-QJTZ76CP.js → chunk-LS5KAVFQ.js} +1 -0
- package/{chunk-RTHFJZ6M.js → chunk-LVZVSLKO.js} +29 -9
- package/{chunk-TI2EPRHE.js → chunk-MNFUKRRU.js} +3 -3
- package/chunk-MVOZ22RZ.js +26 -0
- package/{chunk-CNMY2XM6.js → chunk-O3A2CHAL.js} +6 -6
- package/{chunk-TSPMLCWI.js → chunk-OB4FBZXJ.js} +5 -5
- package/{chunk-LYD6C7OU.js → chunk-OJSJJKHF.js} +6 -6
- package/{chunk-M4SFKP5L.js → chunk-OKAXQFON.js} +3 -3
- package/{chunk-CD3RU7XL.js → chunk-OKH74FML.js} +121 -14
- package/{chunk-U2HBB7RS.js → chunk-OOV5JN25.js} +130 -30
- package/{chunk-ZH3KXFHS.js → chunk-OOVOAG4Q.js} +1 -1
- package/chunk-OQFOE4SJ.js +405 -0
- package/{chunk-M3JEW6N6.js → chunk-OYUMJMC5.js} +15 -0
- package/chunk-P27E22MA.js +203 -0
- package/{chunk-SRCCSTIM.js → chunk-P4R5KXU7.js} +4 -4
- package/{chunk-FJ23FZXF.js → chunk-PHREU2KZ.js} +5 -3
- package/{chunk-HSSBDZLD.js → chunk-PIVTQRX6.js} +43 -13
- package/{chunk-XFXFPUO7.js → chunk-PJL7OJRC.js} +13 -39
- package/{chunk-RRDRQOEC.js → chunk-PNLDLUMO.js} +276 -303
- package/{chunk-4I2MXV5Q.js → chunk-PVFYPUIM.js} +2 -0
- package/{chunk-HHFGE2WF.js → chunk-QGFLVQ6E.js} +5 -5
- package/{chunk-EGHP7KOY.js → chunk-QONAOHVW.js} +38 -29
- package/chunk-R3FZHW4Q.js +103 -0
- package/{chunk-ZYKJBRZ3.js → chunk-R3MV2GII.js} +1 -47
- package/chunk-R72QWIFO.js +50 -0
- package/{chunk-5FUN7EG4.js → chunk-RD3QLZQV.js} +83 -47
- package/{chunk-ILHQ2AXT.js → chunk-RIWKZT7E.js} +36 -8
- package/{chunk-OOJNQK6V.js → chunk-S25VJYXV.js} +8 -2
- package/{chunk-45CAVC35.js → chunk-S7H4KTMB.js} +2568 -337
- package/{chunk-OJ45MEEI.js → chunk-SA356NGW.js} +1 -1
- package/{chunk-F6Z6ZCUV.js → chunk-SCAC3NM5.js} +3 -3
- package/{chunk-YVFH2MFB.js → chunk-SLUN7W6S.js} +7 -7
- package/chunk-SQL7YNED.js +650 -0
- package/chunk-SR4FE5VD.js +9 -0
- package/{chunk-HF7BLF3F.js → chunk-SSOR2EDT.js} +107 -104
- package/chunk-TRRXYFTR.js +46 -0
- package/{chunk-3QIYD3VM.js → chunk-TUOHSUK5.js} +20068 -18402
- package/chunk-TYJCIA2O.js +835 -0
- package/{chunk-S2NTVGA2.js → chunk-U35UUM5K.js} +2 -1
- package/{chunk-GAYNXB6T.js → chunk-U3BUWDUP.js} +1031 -2155
- package/{chunk-BP5ZJ6B4.js → chunk-U6QNVOR5.js} +1 -1
- package/{chunk-UAIHKQIA.js → chunk-U6RD332P.js} +18 -2
- package/chunk-UAF5VQCE.js +77 -0
- package/{chunk-TQEKUOTI.js → chunk-UFGUJ2IH.js} +12 -12
- package/{chunk-VMJVAJ6W.js → chunk-UP7KBWLE.js} +109 -33
- package/{chunk-2X7WFDT6.js → chunk-UUCYUN6Y.js} +1 -1
- package/{chunk-5YMA6DDZ.js → chunk-UZKBVQUX.js} +1 -1
- package/chunk-V5TI7HJH.js +133 -0
- package/{chunk-WFGNWWJI.js → chunk-VH7UO6E5.js} +252 -114
- package/{chunk-MNEZUL5S.js → chunk-VJFDG3ZG.js} +63 -94
- package/{chunk-G7IUT2V3.js → chunk-WC3J5SL2.js} +635 -350
- package/{chunk-HXB4VDGK.js → chunk-WD5547ZF.js} +33 -30
- package/chunk-WDWZPASX.js +29 -0
- package/{chunk-4ZGPHFLE.js → chunk-WS36XPJD.js} +2 -2
- package/{chunk-6QHKRARD.js → chunk-WSLL7VV4.js} +29 -5
- package/chunk-XRGBJHZX.js +136 -0
- package/{chunk-MZG5CETE.js → chunk-Y2KWJTOZ.js} +4 -4
- package/{dialogUsageCommand-W2WCSGKF.js → chunk-Y2TCTNUD.js} +27 -20
- package/chunk-YJPK35HB.js +175 -0
- package/{chunk-6OVNSQHN.js → chunk-YLAHYLDQ.js} +5 -0
- package/{chunk-547ENH5T.js → chunk-YN23INFZ.js} +4 -4
- package/{chunk-4QYJPWHH.js → chunk-YXK3GJF5.js} +232 -10
- package/{chunk-MJI3UAXN.js → chunk-Z2OWAYMI.js} +77 -51
- package/{chunk-7Z6EW7AH.js → chunk-ZTHAJU3O.js} +106 -14
- package/{chunk-YFLVRVYK.js → chunk-ZYPXOQS2.js} +1 -1
- package/{cliAgentConfigHelpers-BTRHMPW2.js → cliAgentConfigHelpers-BXHQ3PXP.js} +9 -9
- package/{cliAuthorityBrokerClient-XHH7MH2P.js → cliAuthorityBrokerClient-TFNXJLXL.js} +1 -1
- package/cliAuthorityBrokerProcess-5ZFBTHLB.js +22 -0
- package/cliLocalAgentRecordReader-47PXMHPH.js +104 -0
- package/{commandRegistry-FVYPE2IN.js → commandRegistry-CTMPAQH2.js} +111 -162
- package/{contentThunks-GNFPG32S.js → contentThunks-CAHIIZO5.js} +38 -36
- package/{cooldownCommands-YB5H5BBK.js → cooldownCommands-WDOI5VD7.js} +3 -3
- package/{createAgentAutomationAction-PB4QIFQ4.js → createAgentAutomationAction-M25XZSPD.js} +38 -36
- package/{createDialogAction-EVTOPY7A.js → createDialogAction-4SN7FKI7.js} +39 -37
- package/{createPageAction-2UYF2IDZ.js → createPageAction-N7QPDN3M.js} +43 -41
- package/{db-M7FU2GNK.js → db-VR74ADGC.js} +7 -2
- package/{dbSlice-XRUZOGSU.js → dbSlice-RWPSVHBC.js} +12 -11
- package/{deleteFile-6URDHYRB.js → deleteFile-ECU6FU5C.js} +15 -7
- package/{dialogCommands-6SZD4TYP.js → dialogCommands-BBHWCKDP.js} +69 -53
- package/dialogMessageRecord-OAV77LT7.js +7 -0
- package/{dialogNotifyCommand-SHGPCU22.js → dialogNotifyCommand-IASQGEMW.js} +11 -11
- package/{dialogSlice-5EQ2A6LY.js → dialogSlice-JI3J22RV.js} +39 -37
- package/dialogTraceCommand-EW2KK6A4.js +961 -0
- package/dialogUsageCommand-WJ3U6KZU.js +27 -0
- package/{docCreateCommands-25E6PGN3.js → docCreateCommands-QSX3X5U4.js} +57 -46
- package/{docDeleteCommands-F7ZVGEHW.js → docDeleteCommands-63JBG2HQ.js} +59 -48
- package/{docReadCommands-JY2E5XEN.js → docReadCommands-CQFKRQUI.js} +57 -46
- package/{docStore-OKKIKLT3.js → docStore-XLBKGGNM.js} +14 -13
- package/{docUpdateCommands-OZ4CUSIQ.js → docUpdateCommands-534LUK25.js} +57 -46
- package/ebookDownloaderAgentCommand-DYSKF5ZY.js +677 -0
- package/fetchMessages-TQEUZD7H.js +1 -1
- package/{getPricing-LF5C4XSI.js → getPricing-5BLZRPTM.js} +4 -4
- package/{handleSendMessageAction-LNT7SZND.js → handleSendMessageAction-Q2VMEVOR.js} +127 -81
- package/{hostCredentialCreate-XUU2CSHI.js → hostCredentialCreate-C57T7YPE.js} +127 -109
- package/index.js +23 -11
- package/{localDialogRead-CCOCVGAP.js → localDialogRead-BJJT3TF5.js} +1 -1
- package/{localRuntimeAdapter-IBSTMSX7.js → localRuntimeAdapter-OALZPFZU.js} +134 -115
- package/localRuntimeAuthority-UF2DAQ3F.js +28 -0
- package/{localRuntimeDb-N7KHDXS2.js → localRuntimeDb-ZJFGNHML.js} +1 -1
- package/{machineCommands-HSQHDHOT.js → machineCommands-N6IVWRZT.js} +262 -325
- package/machineWsRunDispatch-PDWYB33B.js +209 -0
- package/markdownToSlate-PXYAIBVL.js +8 -0
- package/mcpLocalAuthorizeCommand-KYI4EGF5.js +110 -0
- package/{memberThunks-7Y3OYSJQ.js → memberThunks-43B7UYC5.js} +21 -16
- package/{models-H5NNZRLH.js → models-ZX2BYIMB.js} +2 -2
- package/{overlay-BBQZXGYI.js → overlay-JA3SPVUS.js} +5 -3
- package/package.json +2 -1
- package/{projectArchive-FQO654Z3.js → projectArchive-TJNW5DLM.js} +46 -44
- package/{providerPresetApply-WHAMP2D5.js → providerPresetApply-NTJUINI6.js} +36 -17
- package/{providerRegistry-ZI2KORJ7.js → providerRegistry-W45SLUV6.js} +6 -6
- package/{read-TYMBGEXO.js → read-KG6INYUT.js} +13 -7
- package/{readDocTool-SKQVHBLO.js → readDocTool-N3GA52JR.js} +1 -1
- package/{readlineWorkspace-7U272DSA.js → readlineWorkspace-PJZJVGA5.js} +7486 -4492
- package/rememberExplicit-CPAPONSI.js +15 -0
- package/{removeDialogAgentAction-F5QE2O2B.js → removeDialogAgentAction-EEVSOQOJ.js} +18 -17
- package/{runAgentClientLoop-AF4JQIJ7.js → runAgentClientLoop-3VC5TCDW.js} +107 -76
- package/{runtimeDoctorCommands-RRKPBGVO.js → runtimeDoctorCommands-V3M3JTUV.js} +14 -11
- package/{secretCommands-KZWBZIYS.js → secretCommands-KVVZS7A6.js} +3 -3
- package/{setDialogExtraReferencesAction-72L27ERM.js → setDialogExtraReferencesAction-DNO5POHA.js} +15 -14
- package/{setPrimaryDialogAgentAction-GJJDUSGJ.js → setPrimaryDialogAgentAction-QABBEO4C.js} +18 -17
- package/{settingThunks-ZRGWVGZD.js → settingThunks-DVKG4X4S.js} +181 -66
- package/{skillDiscovery-BHHPCUHZ.js → skillDiscovery-ZMJH36AK.js} +4 -3
- package/{spaceCommands-5VNWMDBE.js → spaceCommands-AGGZXPY3.js} +235 -87
- package/{streamAgentChatTurn-YSPEFY4K.js → streamAgentChatTurn-4GTLL2OF.js} +242 -169
- package/{switchDialogAgentAction-IIJBPND3.js → switchDialogAgentAction-KYWJSGOO.js} +16 -15
- package/{tableCommands-FTAOCBTX.js → tableCommands-EFA754RE.js} +7 -4
- package/{toolApiClient-OGQEBQVX.js → toolApiClient-N5PYW2R3.js} +8 -6
- package/{tools-M35PTIFB.js → tools-5AGPOPLW.js} +69 -65
- package/{tuiRestart-2IL37YIB.js → tuiRestart-77E7PL4R.js} +11 -10
- package/{tuiSummaryLlmCaller-W2QN4VAC.js → tuiSummaryLlmCaller-HROLGN4F.js} +16 -15
- package/{updateCommands-CPATDG6J.js → updateCommands-GJGRS6JK.js} +3 -3
- package/{updateDialogTitleAction-IMIRJRQQ.js → updateDialogTitleAction-5OSEDGRK.js} +40 -38
- package/{usageCommand-2BF74MKF.js → usageCommand-WI6SQOPB.js} +2 -2
- package/{usageRebuildCommand-UHB55BQM.js → usageRebuildCommand-WQRLLZAT.js} +3 -3
- package/webapi-QVV65DQF.js +2487 -0
- package/{windowsSelfUpdate-ZFD6J5HF.js → windowsSelfUpdate-C7LGVWYX.js} +2 -2
- package/workContext-Y3ADAPZU.js +14 -0
- package/workContextAccess-VU5I4LKZ.js +11 -0
- package/workContextWriteNotice-YCSSMHN4.js +7 -0
- package/{workloadLifecycle-HFJIN5IZ.js → workloadLifecycle-P2SJVV3S.js} +2 -2
- package/agentRecordCommands-IZYUVHME.js +0 -177
- package/agentRunCommand-QM7ETUTX.js +0 -209
- package/chunk-2YGBI2XB.js +0 -30
- package/chunk-5ZMIIR23.js +0 -265
- package/chunk-5ZUOVCKT.js +0 -32
- package/chunk-62HXNQVV.js +0 -134
- package/chunk-FJSNBZXR.js +0 -142
- package/chunk-FPBJM2BW.js +0 -689
- package/chunk-JQZRSXS5.js +0 -90
- package/chunk-P2ZLUIW2.js +0 -795
- package/chunk-PPJYZRSQ.js +0 -160
- package/chunk-TUSTONB3.js +0 -81
- package/chunk-ZXF6D3I6.js +0 -359
- package/cliLocalAgentRecordReader-H3HYQRRR.js +0 -91
- package/lib-OT5OTXRU.js +0 -21046
- package/localRuntimeAuthority-IBJAT62G.js +0 -16
- package/machineWsRunDispatch-L6H7J66T.js +0 -192
- package/{chunk-W6RFEDN4.js → chunk-AETZ7AD6.js} +3 -3
|
@@ -1,18 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
resolveRuntimeAuthToken,
|
|
3
|
-
resolveRuntimeServerUrl
|
|
4
|
-
} from "./chunk-2X7WFDT6.js";
|
|
5
1
|
import {
|
|
6
2
|
isAgentRunTerminalStatus,
|
|
7
3
|
normalizeRunTitle,
|
|
8
4
|
shortAgentKey
|
|
9
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-S25VJYXV.js";
|
|
10
6
|
import {
|
|
11
7
|
findPowerShellExecutable
|
|
12
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-UP7KBWLE.js";
|
|
9
|
+
import {
|
|
10
|
+
resolveModelTier
|
|
11
|
+
} from "./chunk-HEVRQGGH.js";
|
|
13
12
|
import {
|
|
14
13
|
AUTH_ERROR_PATTERNS
|
|
15
14
|
} from "./chunk-EWQ3HGNZ.js";
|
|
15
|
+
import {
|
|
16
|
+
resolveRuntimeAuthToken,
|
|
17
|
+
resolveRuntimeServerUrl
|
|
18
|
+
} from "./chunk-UUCYUN6Y.js";
|
|
16
19
|
import {
|
|
17
20
|
AGENT_RUN_PROTOCOL,
|
|
18
21
|
HOST_RUNTIME_CONTENT_IDENTITY,
|
|
@@ -26,9 +29,200 @@ import {
|
|
|
26
29
|
isRecord
|
|
27
30
|
} from "./chunk-KUG52IAP.js";
|
|
28
31
|
|
|
32
|
+
// packages/cli/mcp/mcpApprovalTransport.ts
|
|
33
|
+
import { randomUUID, createHash } from "node:crypto";
|
|
34
|
+
|
|
35
|
+
// packages/cli/client/inheritedApprovalChannel.ts
|
|
36
|
+
function sendInheritedApproval(channel, kind, message, failed) {
|
|
37
|
+
if (channel.connected === false || !channel.send) {
|
|
38
|
+
failed();
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
try {
|
|
42
|
+
channel.send({ kind, ...message }, (error) => {
|
|
43
|
+
if (error) failed();
|
|
44
|
+
});
|
|
45
|
+
} catch {
|
|
46
|
+
failed();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function bindInheritedApprovalLifetime(channel, close, signal) {
|
|
50
|
+
for (const event of ["disconnect", "exit", "error"]) channel.on(event, close);
|
|
51
|
+
signal?.addEventListener("abort", close, { once: true });
|
|
52
|
+
return () => {
|
|
53
|
+
for (const event of ["disconnect", "exit", "error"]) channel.removeListener(event, close);
|
|
54
|
+
signal?.removeEventListener("abort", close);
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// packages/cli/mcp/mcpApprovalTransport.ts
|
|
59
|
+
var KIND = "nolo.mcp-approval.v1";
|
|
60
|
+
var TTL = 6e4;
|
|
61
|
+
var MAX = 256;
|
|
62
|
+
function canonical(value) {
|
|
63
|
+
if (Array.isArray(value)) return `[${value.map(canonical).join(",")}]`;
|
|
64
|
+
if (value && typeof value === "object") return `{${Object.keys(value).sort().map((key) => `${JSON.stringify(key)}:${canonical(value[key])}`).join(",")}}`;
|
|
65
|
+
return JSON.stringify(value);
|
|
66
|
+
}
|
|
67
|
+
function snapshot(preview) {
|
|
68
|
+
return createHash("sha256").update(JSON.stringify(preview)).digest("hex");
|
|
69
|
+
}
|
|
70
|
+
function valid(preview, binding) {
|
|
71
|
+
const b = preview?.binding;
|
|
72
|
+
return b && b.authenticatedUserId === binding.ownerUserId && b.agentKey === binding.agentKey && typeof b.dialogId === "string" && b.dialogId.length > 0 && b.placement?.kind === "local" && typeof b.connectionId === "string" && Number.isInteger(b.connectionRevision) && b.connectionRevision > 0 && typeof b.catalogRevision === "string" && typeof b.toolName === "string" && /^[a-f0-9]{64}$/.test(b.argumentsDigest) && preview.arguments && typeof preview.arguments === "object" && !Array.isArray(preview.arguments) && createHash("sha256").update(canonical(preview.arguments)).digest("hex") === b.argumentsDigest && Number.isFinite(preview.expiresAt) && preview.expiresAt > Date.now() && preview.expiresAt <= Date.now() + TTL;
|
|
73
|
+
}
|
|
74
|
+
function attachMcpApprovalHost(channel, host) {
|
|
75
|
+
const binding = Object.freeze({ ...host.binding });
|
|
76
|
+
let closed = false;
|
|
77
|
+
let count = 0;
|
|
78
|
+
const seen = /* @__PURE__ */ new Set();
|
|
79
|
+
const active = /* @__PURE__ */ new Map();
|
|
80
|
+
const send2 = (message) => sendInheritedApproval(channel, KIND, message, close);
|
|
81
|
+
let unbind = () => {
|
|
82
|
+
};
|
|
83
|
+
const close = () => {
|
|
84
|
+
if (closed) return;
|
|
85
|
+
closed = true;
|
|
86
|
+
for (const controller of active.values()) controller.abort();
|
|
87
|
+
active.clear();
|
|
88
|
+
sendInheritedApproval(channel, KIND, { type: "revoke" }, () => {
|
|
89
|
+
});
|
|
90
|
+
channel.removeListener("message", receive);
|
|
91
|
+
unbind();
|
|
92
|
+
};
|
|
93
|
+
const receive = (m) => {
|
|
94
|
+
if (closed || m?.kind !== KIND) return;
|
|
95
|
+
if (m.type === "hello") {
|
|
96
|
+
send2({ type: "binding", binding });
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
if (m.type === "cancel") {
|
|
100
|
+
active.get(m.id)?.abort();
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
if (m.type !== "request") return;
|
|
104
|
+
if (++count > MAX || typeof m.id !== "string" || seen.has(m.id)) {
|
|
105
|
+
close();
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
seen.add(m.id);
|
|
109
|
+
let preview;
|
|
110
|
+
try {
|
|
111
|
+
if (typeof m.snapshot !== "string" || JSON.stringify(m.preview).length > 262144) throw new Error("invalid preview");
|
|
112
|
+
preview = structuredClone(m.preview);
|
|
113
|
+
if (m.runId !== binding.runId || !valid(preview, binding) || snapshot(preview) !== m.snapshot) throw new Error("binding mismatch");
|
|
114
|
+
} catch {
|
|
115
|
+
send2({ type: "decision", id: m.id, runId: binding.runId, snapshot: m.snapshot, decision: "deny" });
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
const controller = new AbortController();
|
|
119
|
+
active.set(m.id, controller);
|
|
120
|
+
const timer = setTimeout(() => controller.abort(), Math.max(0, preview.expiresAt - Date.now()));
|
|
121
|
+
void new Promise((resolve2) => {
|
|
122
|
+
controller.signal.addEventListener("abort", () => resolve2("deny"), { once: true });
|
|
123
|
+
Promise.resolve().then(() => closed || controller.signal.aborted ? "deny" : host.confirm(preview, controller.signal, { runId: binding.runId, requestId: m.id })).then(resolve2, () => resolve2("unavailable"));
|
|
124
|
+
}).then((decision) => {
|
|
125
|
+
clearTimeout(timer);
|
|
126
|
+
active.delete(m.id);
|
|
127
|
+
if (!closed) send2({
|
|
128
|
+
type: "decision",
|
|
129
|
+
id: m.id,
|
|
130
|
+
runId: binding.runId,
|
|
131
|
+
snapshot: m.snapshot,
|
|
132
|
+
decision: !controller.signal.aborted && Date.now() < preview.expiresAt ? decision : "deny"
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
};
|
|
136
|
+
channel.on("message", receive);
|
|
137
|
+
unbind = bindInheritedApprovalLifetime(channel, close, host.signal);
|
|
138
|
+
if (host.signal.aborted || channel.connected === false) close();
|
|
139
|
+
return close;
|
|
140
|
+
}
|
|
141
|
+
function createMcpApprovalChild(channel) {
|
|
142
|
+
const lifetime = new AbortController();
|
|
143
|
+
let binding;
|
|
144
|
+
let count = 0;
|
|
145
|
+
let closed = false;
|
|
146
|
+
const pending = /* @__PURE__ */ new Map();
|
|
147
|
+
const readyResolvers = /* @__PURE__ */ new Set();
|
|
148
|
+
let unbind = () => {
|
|
149
|
+
};
|
|
150
|
+
const close = () => {
|
|
151
|
+
if (closed) return;
|
|
152
|
+
closed = true;
|
|
153
|
+
lifetime.abort();
|
|
154
|
+
for (const entry of pending.values()) entry.finish("unavailable");
|
|
155
|
+
for (const resolve2 of readyResolvers) resolve2();
|
|
156
|
+
readyResolvers.clear();
|
|
157
|
+
channel.removeListener("message", receive);
|
|
158
|
+
unbind();
|
|
159
|
+
};
|
|
160
|
+
const send2 = (message) => sendInheritedApproval(channel, KIND, message, close);
|
|
161
|
+
const receive = (m) => {
|
|
162
|
+
if (closed || m?.kind !== KIND) return;
|
|
163
|
+
if (m.type === "revoke") {
|
|
164
|
+
close();
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
if (m.type === "binding") {
|
|
168
|
+
if (binding || !m.binding || typeof m.binding.runId !== "string" || typeof m.binding.ownerUserId !== "string" || typeof m.binding.agentKey !== "string") {
|
|
169
|
+
close();
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
binding = Object.freeze({ ...m.binding });
|
|
173
|
+
for (const resolve2 of readyResolvers) resolve2();
|
|
174
|
+
readyResolvers.clear();
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
if (m.type !== "decision") return;
|
|
178
|
+
const entry = pending.get(m.id);
|
|
179
|
+
if (!entry) return;
|
|
180
|
+
const matches = binding && m.runId === binding.runId && m.snapshot === entry.snapshot && Date.now() < entry.expiresAt;
|
|
181
|
+
entry.finish(!matches ? "deny" : m.decision === "approve" ? "approve" : m.decision === "unavailable" ? "unavailable" : "deny");
|
|
182
|
+
};
|
|
183
|
+
channel.on("message", receive);
|
|
184
|
+
unbind = bindInheritedApprovalLifetime(channel, close);
|
|
185
|
+
send2({ type: "hello" });
|
|
186
|
+
const confirm = async (input, signal) => {
|
|
187
|
+
if (closed || signal.aborted || ++count > MAX) return "unavailable";
|
|
188
|
+
if (!binding) await new Promise((resolve2) => {
|
|
189
|
+
const done = () => {
|
|
190
|
+
clearTimeout(timer);
|
|
191
|
+
readyResolvers.delete(done);
|
|
192
|
+
signal.removeEventListener("abort", done);
|
|
193
|
+
resolve2();
|
|
194
|
+
};
|
|
195
|
+
const timer = setTimeout(done, Math.max(0, Math.min(TTL, input.expiresAt - Date.now())));
|
|
196
|
+
readyResolvers.add(done);
|
|
197
|
+
signal.addEventListener("abort", done, { once: true });
|
|
198
|
+
});
|
|
199
|
+
if (closed || !binding) return "unavailable";
|
|
200
|
+
if (signal.aborted || !valid(input, binding)) return "deny";
|
|
201
|
+
const preview = structuredClone(input), id = randomUUID(), digest = snapshot(preview);
|
|
202
|
+
return new Promise((resolve2) => {
|
|
203
|
+
const abort = () => {
|
|
204
|
+
send2({ type: "cancel", id });
|
|
205
|
+
finish("deny");
|
|
206
|
+
};
|
|
207
|
+
const timer = setTimeout(abort, Math.max(0, preview.expiresAt - Date.now()));
|
|
208
|
+
const finish = (value) => {
|
|
209
|
+
if (!pending.delete(id)) return;
|
|
210
|
+
clearTimeout(timer);
|
|
211
|
+
signal.removeEventListener("abort", abort);
|
|
212
|
+
resolve2(value);
|
|
213
|
+
};
|
|
214
|
+
pending.set(id, { finish, snapshot: digest, expiresAt: preview.expiresAt });
|
|
215
|
+
signal.addEventListener("abort", abort, { once: true });
|
|
216
|
+
if (signal.aborted) abort();
|
|
217
|
+
else send2({ type: "request", id, runId: binding.runId, snapshot: digest, preview });
|
|
218
|
+
});
|
|
219
|
+
};
|
|
220
|
+
return { confirm, signal: lifetime.signal, close };
|
|
221
|
+
}
|
|
222
|
+
|
|
29
223
|
// packages/cli/client/originShellApprovalTransport.ts
|
|
30
224
|
import { realpathSync } from "node:fs";
|
|
31
|
-
import { randomUUID } from "node:crypto";
|
|
225
|
+
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
32
226
|
|
|
33
227
|
// packages/cli/client/originShellApprovalBridge.ts
|
|
34
228
|
import { isAbsolute } from "node:path";
|
|
@@ -45,7 +239,7 @@ function createOriginShellApprovalBridge(deps) {
|
|
|
45
239
|
}
|
|
46
240
|
const requests = /* @__PURE__ */ new Map();
|
|
47
241
|
const fail = (reason) => ({ ok: false, reason });
|
|
48
|
-
const
|
|
242
|
+
const snapshot2 = (request) => ({ ok: true, request: { ...request } });
|
|
49
243
|
const validIdentity = (call) => {
|
|
50
244
|
try {
|
|
51
245
|
return IDENTITY_KEYS.every((key) => typeof call[key] === "string" && call[key].trim().length > 0 && call[key] === binding[key]) && isAbsolute(call.workspaceRoot) && deps.resolveWorkspace(call.workspaceRoot) === binding.workspaceRoot;
|
|
@@ -71,7 +265,7 @@ function createOriginShellApprovalBridge(deps) {
|
|
|
71
265
|
const request = requests.get(id);
|
|
72
266
|
if (!request) return fail("unknown_request");
|
|
73
267
|
if (!CALL_KEYS.every((key) => request[key] === call[key])) return fail("call_mismatch");
|
|
74
|
-
return
|
|
268
|
+
return snapshot2(request);
|
|
75
269
|
};
|
|
76
270
|
return {
|
|
77
271
|
request(call) {
|
|
@@ -99,7 +293,7 @@ function createOriginShellApprovalBridge(deps) {
|
|
|
99
293
|
state: "pending"
|
|
100
294
|
};
|
|
101
295
|
requests.set(requestId, request);
|
|
102
|
-
return
|
|
296
|
+
return snapshot2(request);
|
|
103
297
|
},
|
|
104
298
|
decide(id, call, decision) {
|
|
105
299
|
const result = lookup(id, call);
|
|
@@ -113,7 +307,7 @@ function createOriginShellApprovalBridge(deps) {
|
|
|
113
307
|
state: decision === "approve" ? "approved" : "denied"
|
|
114
308
|
};
|
|
115
309
|
requests.set(id, request);
|
|
116
|
-
return
|
|
310
|
+
return snapshot2(request);
|
|
117
311
|
},
|
|
118
312
|
revoke() {
|
|
119
313
|
for (const [id, request] of requests) {
|
|
@@ -129,15 +323,15 @@ function createOriginShellApprovalBridge(deps) {
|
|
|
129
323
|
if (result.request.state !== "approved") return fail(result.request.state);
|
|
130
324
|
const request = { ...result.request, state: "consumed" };
|
|
131
325
|
requests.set(id, request);
|
|
132
|
-
return
|
|
326
|
+
return snapshot2(request);
|
|
133
327
|
}
|
|
134
328
|
};
|
|
135
329
|
}
|
|
136
330
|
|
|
137
331
|
// packages/cli/client/originShellApprovalTransport.ts
|
|
138
|
-
var
|
|
139
|
-
var
|
|
140
|
-
var
|
|
332
|
+
var KIND2 = "nolo.shell-approval.v1";
|
|
333
|
+
var MAX2 = 256;
|
|
334
|
+
var TTL2 = 6e4;
|
|
141
335
|
var NOTICE = "Executes with this local user's reachable permissions; workspace is NOT a directory sandbox.";
|
|
142
336
|
function payloadCall(payload, binding) {
|
|
143
337
|
if (typeof payload !== "string" || payload.length > 262144) throw new Error("Invalid approval payload");
|
|
@@ -149,17 +343,25 @@ function payloadCall(payload, binding) {
|
|
|
149
343
|
}
|
|
150
344
|
function send(channel, message) {
|
|
151
345
|
if (channel.connected === false || !channel.send) throw new Error("Approval channel disconnected");
|
|
152
|
-
channel.send({ kind:
|
|
346
|
+
channel.send({ kind: KIND2, ...message });
|
|
347
|
+
}
|
|
348
|
+
var liveApprovalHosts = /* @__PURE__ */ new Set();
|
|
349
|
+
function hasLiveShellApprovalHosts() {
|
|
350
|
+
return liveApprovalHosts.size > 0;
|
|
153
351
|
}
|
|
154
352
|
function attachShellApprovalHost(channel, host) {
|
|
155
353
|
const binding = Object.freeze({ ...host.binding });
|
|
156
354
|
const bridge = createOriginShellApprovalBridge({ binding, resolveWorkspace: realpathSync });
|
|
355
|
+
const connection = {};
|
|
157
356
|
let closed = false;
|
|
158
357
|
let count = 0;
|
|
159
358
|
const active = /* @__PURE__ */ new Set();
|
|
359
|
+
let unbindLifetime = () => {
|
|
360
|
+
};
|
|
160
361
|
const close = () => {
|
|
161
362
|
if (closed) return;
|
|
162
363
|
closed = true;
|
|
364
|
+
liveApprovalHosts.delete(connection);
|
|
163
365
|
bridge.revoke();
|
|
164
366
|
for (const controller of active) controller.abort();
|
|
165
367
|
active.clear();
|
|
@@ -168,13 +370,10 @@ function attachShellApprovalHost(channel, host) {
|
|
|
168
370
|
} catch {
|
|
169
371
|
}
|
|
170
372
|
channel.removeListener("message", receive);
|
|
171
|
-
|
|
172
|
-
channel.removeListener("exit", close);
|
|
173
|
-
channel.removeListener("error", close);
|
|
174
|
-
host.signal.removeEventListener("abort", close);
|
|
373
|
+
unbindLifetime();
|
|
175
374
|
};
|
|
176
375
|
const receive = (message) => {
|
|
177
|
-
if (closed || message?.kind !==
|
|
376
|
+
if (closed || message?.kind !== KIND2) return;
|
|
178
377
|
if (message.type === "hello") {
|
|
179
378
|
try {
|
|
180
379
|
send(channel, { type: "binding", binding });
|
|
@@ -184,7 +383,7 @@ function attachShellApprovalHost(channel, host) {
|
|
|
184
383
|
return;
|
|
185
384
|
}
|
|
186
385
|
if (message.type !== "request") return;
|
|
187
|
-
if (++count >
|
|
386
|
+
if (++count > MAX2 || typeof message.id !== "string" || message.id.length > 100) {
|
|
188
387
|
close();
|
|
189
388
|
return;
|
|
190
389
|
}
|
|
@@ -241,14 +440,12 @@ function attachShellApprovalHost(channel, host) {
|
|
|
241
440
|
})();
|
|
242
441
|
};
|
|
243
442
|
channel.on("message", receive);
|
|
244
|
-
channel
|
|
245
|
-
|
|
246
|
-
channel.
|
|
247
|
-
host.signal.addEventListener("abort", close, { once: true });
|
|
248
|
-
if (host.signal.aborted) close();
|
|
443
|
+
unbindLifetime = bindInheritedApprovalLifetime(channel, close, host.signal);
|
|
444
|
+
liveApprovalHosts.add(connection);
|
|
445
|
+
if (host.signal.aborted || channel.connected === false) close();
|
|
249
446
|
return close;
|
|
250
447
|
}
|
|
251
|
-
function createShellApprovalChild(channel, timeoutMs =
|
|
448
|
+
function createShellApprovalChild(channel, timeoutMs = TTL2) {
|
|
252
449
|
let closed = false;
|
|
253
450
|
let binding;
|
|
254
451
|
let count = 0;
|
|
@@ -267,7 +464,7 @@ function createShellApprovalChild(channel, timeoutMs = TTL) {
|
|
|
267
464
|
channel.removeListener("disconnect", close);
|
|
268
465
|
};
|
|
269
466
|
const receive = (message) => {
|
|
270
|
-
if (closed || message?.kind !==
|
|
467
|
+
if (closed || message?.kind !== KIND2) return;
|
|
271
468
|
if (message.type === "revoke") {
|
|
272
469
|
close();
|
|
273
470
|
return;
|
|
@@ -285,7 +482,7 @@ function createShellApprovalChild(channel, timeoutMs = TTL) {
|
|
|
285
482
|
if (!entry) return;
|
|
286
483
|
pending.delete(message.id);
|
|
287
484
|
clearTimeout(entry.timer);
|
|
288
|
-
if (!binding || message.runId !== binding.runId || message.approved !== true || typeof message.ticket !== "string" || !Number.isFinite(message.expiresAt) || message.expiresAt <= Date.now() || message.expiresAt > Date.now() +
|
|
485
|
+
if (!binding || message.runId !== binding.runId || message.approved !== true || typeof message.ticket !== "string" || !Number.isFinite(message.expiresAt) || message.expiresAt <= Date.now() || message.expiresAt > Date.now() + TTL2 || tickets.has(message.ticket)) {
|
|
289
486
|
entry.reject(new Error("Shell approval denied"));
|
|
290
487
|
return;
|
|
291
488
|
}
|
|
@@ -303,17 +500,17 @@ function createShellApprovalChild(channel, timeoutMs = TTL) {
|
|
|
303
500
|
close,
|
|
304
501
|
authority: {
|
|
305
502
|
async request(payload) {
|
|
306
|
-
if (++count >
|
|
307
|
-
const deadline = Date.now() + Math.min(timeoutMs,
|
|
503
|
+
if (++count > MAX2) throw new Error("Shell approval capacity exceeded");
|
|
504
|
+
const deadline = Date.now() + Math.min(timeoutMs, TTL2);
|
|
308
505
|
while (!binding && !closed && Date.now() < deadline) await new Promise((resolve2) => setTimeout(resolve2, 5));
|
|
309
506
|
if (closed || !binding) throw new Error("Shell approval unavailable");
|
|
310
507
|
payloadCall(payload, binding);
|
|
311
|
-
const id =
|
|
508
|
+
const id = randomUUID2();
|
|
312
509
|
return new Promise((resolve2, reject) => {
|
|
313
510
|
const timer = setTimeout(() => {
|
|
314
511
|
pending.delete(id);
|
|
315
512
|
reject(new Error("Shell approval timeout"));
|
|
316
|
-
}, Math.min(timeoutMs,
|
|
513
|
+
}, Math.min(timeoutMs, TTL2));
|
|
317
514
|
pending.set(id, { payload, resolve: resolve2, reject, timer });
|
|
318
515
|
try {
|
|
319
516
|
send(channel, { type: "request", id, runId: binding.runId, payload });
|
|
@@ -334,6 +531,37 @@ function createShellApprovalChild(channel, timeoutMs = TTL) {
|
|
|
334
531
|
};
|
|
335
532
|
}
|
|
336
533
|
|
|
534
|
+
// packages/cli/client/reviewVerdict.ts
|
|
535
|
+
var SEVERITIES = ["CRITICAL", "HIGH", "MEDIUM", "LOW"];
|
|
536
|
+
var BLOCKERS = ["CRITICAL", "HIGH"];
|
|
537
|
+
function stripFrontmatter(markdown) {
|
|
538
|
+
return markdown.replace(/^---[\r\n]+[\s\S]*?[\r\n]+---(?:\r?\n|$)/, "");
|
|
539
|
+
}
|
|
540
|
+
function parseStructuredReview(text) {
|
|
541
|
+
const body = stripFrontmatter(text).trim();
|
|
542
|
+
if (!body.startsWith("{")) return { kind: "legacy" };
|
|
543
|
+
const nonempty = (v) => typeof v === "string" && v.trim().length > 0;
|
|
544
|
+
try {
|
|
545
|
+
const value = JSON.parse(body);
|
|
546
|
+
const keys = ["schemaVersion", "revision", "status", "reason", "findings"];
|
|
547
|
+
if (!value || value.schemaVersion !== 1 || Object.keys(value).some((k) => !keys.includes(k)) || !["completed", "incomplete"].includes(value.status) || !nonempty(value.revision) || !Array.isArray(value.findings) || value.reason !== void 0 && (value.status !== "incomplete" || !nonempty(value.reason)) || value.status === "incomplete" && !nonempty(value.reason))
|
|
548
|
+
return { kind: "invalid", reason: "\u7ED3\u6784\u5316\u5BA1\u67E5\u5B57\u6BB5\u65E0\u6548\u6216\u672A\u5B8C\u6210\u539F\u56E0\u7F3A\u5931" };
|
|
549
|
+
const ids = /* @__PURE__ */ new Set();
|
|
550
|
+
const findingKeys = ["id", "severity", "file", "line", "evidence", "impact"];
|
|
551
|
+
for (const f of value.findings) {
|
|
552
|
+
if (!f || Object.keys(f).some((k) => !findingKeys.includes(k)) || !nonempty(f.id) || ids.has(f.id.trim()) || !SEVERITIES.includes(f.severity) || !nonempty(f.file) || !Number.isSafeInteger(f.line) || f.line < 1 || !nonempty(f.evidence) || !nonempty(f.impact))
|
|
553
|
+
return { kind: "invalid", reason: "\u7ED3\u6784\u5316 finding \u65E0\u6548\u6216 id \u91CD\u590D" };
|
|
554
|
+
ids.add(f.id.trim());
|
|
555
|
+
}
|
|
556
|
+
return { kind: "structured", review: value };
|
|
557
|
+
} catch {
|
|
558
|
+
return { kind: "invalid", reason: "\u7ED3\u6784\u5316\u5BA1\u67E5 JSON \u65E0\u6548" };
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
function structuredReviewVerdict(review) {
|
|
562
|
+
return review.status === "completed" && !review.findings.some((f) => BLOCKERS.includes(f.severity)) ? "APPROVE" : "BLOCK";
|
|
563
|
+
}
|
|
564
|
+
|
|
337
565
|
// packages/core/redactLogLines.ts
|
|
338
566
|
var TAIL_LINES_MAX = 500;
|
|
339
567
|
var REDACTED_TOKEN = "[REDACTED_TOKEN]";
|
|
@@ -456,7 +684,7 @@ function redactLogLines(lines, options = {}) {
|
|
|
456
684
|
import { hostname as nodeHostname, homedir as nodeHomedir } from "node:os";
|
|
457
685
|
import { dirname, isAbsolute as isAbsolute2, join as join2, resolve } from "node:path";
|
|
458
686
|
import * as nodeFs2 from "node:fs";
|
|
459
|
-
import { randomUUID as
|
|
687
|
+
import { randomUUID as randomUUID3, createHash as createHash2 } from "node:crypto";
|
|
460
688
|
import { execFileSync as nodeExecFileSync, spawn as nodeSpawn } from "node:child_process";
|
|
461
689
|
|
|
462
690
|
// packages/cli/client/hostMemory.ts
|
|
@@ -705,7 +933,7 @@ var HostMemoryAdmissionError = class extends Error {
|
|
|
705
933
|
};
|
|
706
934
|
function assertHostMemoryAdmission(deps = {}) {
|
|
707
935
|
const readMem = deps.readHostMemory ?? readHostMemory;
|
|
708
|
-
const
|
|
936
|
+
const snapshot2 = readMem(deps.hostMemoryDeps);
|
|
709
937
|
const minAvailableMb = deps.minAvailableMb ?? LOCAL_AGENT_RUN_MIN_AVAILABLE_MB;
|
|
710
938
|
const startupWindowMs = deps.startupWindowMs ?? STARTUP_WINDOW_MS;
|
|
711
939
|
const reservedMbPerRun = deps.reservedMbPerRun ?? STARTUP_WINDOW_RESERVED_MB_PER_RUN;
|
|
@@ -713,7 +941,7 @@ function assertHostMemoryAdmission(deps = {}) {
|
|
|
713
941
|
for (const [name, value] of Object.entries({ minAvailableMb, startupWindowMs, reservedMbPerRun, now })) {
|
|
714
942
|
if (typeof value !== "number" || !Number.isFinite(value) || value < 0) throw new Error(`Invalid ${name}`);
|
|
715
943
|
}
|
|
716
|
-
if (!
|
|
944
|
+
if (!snapshot2) {
|
|
717
945
|
throw new HostMemoryAdmissionError(
|
|
718
946
|
`[host-memory-admission] \u65E0\u6CD5\u6D4B\u5B9A\u672C\u673A\u53EF\u7528\u5185\u5B58\uFF08\u5FEB\u7167\u4E3A null\uFF09\uFF0C\u62D2\u7EDD\u672C\u5730 fork\u3002\u9700\u786E\u4FDD /proc/meminfo \u6216 OS \u5185\u5B58\u6307\u6807\u53EF\u8BFB\u3002`,
|
|
719
947
|
{
|
|
@@ -727,19 +955,19 @@ function assertHostMemoryAdmission(deps = {}) {
|
|
|
727
955
|
}
|
|
728
956
|
);
|
|
729
957
|
}
|
|
730
|
-
if (!["cgroup", "proc-meminfo", "os"].includes(
|
|
958
|
+
if (!["cgroup", "proc-meminfo", "os"].includes(snapshot2.source)) throw new Error("Unknown host memory source");
|
|
731
959
|
let effectiveAvailableMb = null;
|
|
732
960
|
let limitingSource = "host";
|
|
733
|
-
if (
|
|
734
|
-
const cgroupAvail =
|
|
735
|
-
const hostAvail =
|
|
961
|
+
if (snapshot2.source === "cgroup") {
|
|
962
|
+
const cgroupAvail = snapshot2.availableMb;
|
|
963
|
+
const hostAvail = snapshot2.hostAvailableMb;
|
|
736
964
|
if (cgroupAvail === null || typeof cgroupAvail !== "number" || Number.isNaN(cgroupAvail) || !Number.isFinite(cgroupAvail) || cgroupAvail < 0) {
|
|
737
965
|
throw new HostMemoryAdmissionError(
|
|
738
966
|
`[host-memory-admission] cgroup \u914D\u989D\u5185\u5B58\u5360\u7528\u672A\u77E5\u6216\u65E0\u6548\uFF0C\u62D2\u7EDD\u65E0\u58F0\u5F53\u5145\u8DB3\u3002`,
|
|
739
967
|
{
|
|
740
968
|
effectiveAvailableMb: null,
|
|
741
969
|
requiredMinMb: minAvailableMb,
|
|
742
|
-
source:
|
|
970
|
+
source: snapshot2.source,
|
|
743
971
|
limitingSource: "cgroup",
|
|
744
972
|
activeStartupRuns: 0,
|
|
745
973
|
reservedStartupMb: 0,
|
|
@@ -751,7 +979,7 @@ function assertHostMemoryAdmission(deps = {}) {
|
|
|
751
979
|
throw new HostMemoryAdmissionError("[host-memory-admission] \u5BBF\u4E3B\u53EF\u7528\u5185\u5B58\u672A\u77E5\u6216\u65E0\u6548\uFF0C\u62D2\u7EDD\u672C\u5730 fork\u3002", {
|
|
752
980
|
effectiveAvailableMb: null,
|
|
753
981
|
requiredMinMb: minAvailableMb,
|
|
754
|
-
source:
|
|
982
|
+
source: snapshot2.source,
|
|
755
983
|
limitingSource: "host",
|
|
756
984
|
activeStartupRuns: 0,
|
|
757
985
|
reservedStartupMb: 0,
|
|
@@ -771,13 +999,13 @@ function assertHostMemoryAdmission(deps = {}) {
|
|
|
771
999
|
limitingSource = "cgroup";
|
|
772
1000
|
}
|
|
773
1001
|
} else {
|
|
774
|
-
if (
|
|
1002
|
+
if (snapshot2.availableMb === null || typeof snapshot2.availableMb !== "number" || Number.isNaN(snapshot2.availableMb) || !Number.isFinite(snapshot2.availableMb) || snapshot2.availableMb < 0) {
|
|
775
1003
|
throw new HostMemoryAdmissionError(
|
|
776
1004
|
`[host-memory-admission] \u5BBF\u4E3B\u53EF\u7528\u5185\u5B58\u672A\u77E5\u6216\u65E0\u6548\uFF0C\u62D2\u7EDD\u65E0\u58F0\u5F53\u5145\u8DB3\u3002`,
|
|
777
1005
|
{
|
|
778
1006
|
effectiveAvailableMb: null,
|
|
779
1007
|
requiredMinMb: minAvailableMb,
|
|
780
|
-
source:
|
|
1008
|
+
source: snapshot2.source,
|
|
781
1009
|
limitingSource: "host",
|
|
782
1010
|
activeStartupRuns: 0,
|
|
783
1011
|
reservedStartupMb: 0,
|
|
@@ -785,7 +1013,7 @@ function assertHostMemoryAdmission(deps = {}) {
|
|
|
785
1013
|
}
|
|
786
1014
|
);
|
|
787
1015
|
}
|
|
788
|
-
effectiveAvailableMb =
|
|
1016
|
+
effectiveAvailableMb = snapshot2.availableMb;
|
|
789
1017
|
limitingSource = "host";
|
|
790
1018
|
}
|
|
791
1019
|
let activeStartupRuns = 0;
|
|
@@ -797,7 +1025,7 @@ function assertHostMemoryAdmission(deps = {}) {
|
|
|
797
1025
|
{
|
|
798
1026
|
effectiveAvailableMb,
|
|
799
1027
|
requiredMinMb: minAvailableMb,
|
|
800
|
-
source:
|
|
1028
|
+
source: snapshot2.source,
|
|
801
1029
|
limitingSource,
|
|
802
1030
|
activeStartupRuns: 0,
|
|
803
1031
|
reservedStartupMb: 0,
|
|
@@ -812,7 +1040,7 @@ function assertHostMemoryAdmission(deps = {}) {
|
|
|
812
1040
|
{
|
|
813
1041
|
effectiveAvailableMb,
|
|
814
1042
|
requiredMinMb: minAvailableMb,
|
|
815
|
-
source:
|
|
1043
|
+
source: snapshot2.source,
|
|
816
1044
|
limitingSource,
|
|
817
1045
|
activeStartupRuns: 0,
|
|
818
1046
|
reservedStartupMb: 0,
|
|
@@ -828,7 +1056,7 @@ function assertHostMemoryAdmission(deps = {}) {
|
|
|
828
1056
|
{
|
|
829
1057
|
effectiveAvailableMb,
|
|
830
1058
|
requiredMinMb: minAvailableMb,
|
|
831
|
-
source:
|
|
1059
|
+
source: snapshot2.source,
|
|
832
1060
|
limitingSource,
|
|
833
1061
|
activeStartupRuns: 0,
|
|
834
1062
|
reservedStartupMb: 0,
|
|
@@ -850,7 +1078,7 @@ function assertHostMemoryAdmission(deps = {}) {
|
|
|
850
1078
|
{
|
|
851
1079
|
effectiveAvailableMb: netAvailableMb,
|
|
852
1080
|
requiredMinMb: minAvailableMb,
|
|
853
|
-
source:
|
|
1081
|
+
source: snapshot2.source,
|
|
854
1082
|
limitingSource,
|
|
855
1083
|
activeStartupRuns,
|
|
856
1084
|
reservedStartupMb,
|
|
@@ -863,7 +1091,7 @@ function assertHostMemoryAdmission(deps = {}) {
|
|
|
863
1091
|
effectiveAvailableMb: netAvailableMb,
|
|
864
1092
|
requiredMinMb: minAvailableMb,
|
|
865
1093
|
activeStartupRuns,
|
|
866
|
-
snapshot
|
|
1094
|
+
snapshot: snapshot2
|
|
867
1095
|
};
|
|
868
1096
|
}
|
|
869
1097
|
|
|
@@ -1141,6 +1369,10 @@ function buildResultFrontMatter(input) {
|
|
|
1141
1369
|
["cacheInputTokens", input.cacheUsage?.input_tokens],
|
|
1142
1370
|
["cacheCachedTokens", input.cacheUsage?.cached_tokens],
|
|
1143
1371
|
["cacheHitRatio", input.cacheUsage?.cache_hit_ratio],
|
|
1372
|
+
// run 级 token 总量与生效档位(结构化回溯用;缺省省略,绝不写 0/unknown)
|
|
1373
|
+
["inputTokens", input.inputTokens],
|
|
1374
|
+
["outputTokens", input.outputTokens],
|
|
1375
|
+
["modelTier", input.modelTier],
|
|
1144
1376
|
["dialogId", input.dialogId],
|
|
1145
1377
|
["server", input.server],
|
|
1146
1378
|
["serverSync", input.serverSync],
|
|
@@ -1229,6 +1461,77 @@ function classifyRunFailure(input) {
|
|
|
1229
1461
|
}
|
|
1230
1462
|
|
|
1231
1463
|
// packages/cli/agentRunControl.ts
|
|
1464
|
+
var STANDALONE_VERDICT_RE = /^(APPROVE|WARNING|BLOCK)$/i;
|
|
1465
|
+
var LABELED_VERDICT_RE = /^(?:结论|判定|VERDICT)\s*[::]\s*(APPROVE|WARNING|BLOCK)$/i;
|
|
1466
|
+
var STANDALONE_ESCALATION_RE = /^need_escalation$/i;
|
|
1467
|
+
var ESCALATION_WITH_DETAIL_RE = /^need_escalation\s*[::]\s*\S/i;
|
|
1468
|
+
var LABELED_ESCALATION_RE = /^(?:状态|结论|判定|status|escalation|escalated)\s*[::]\s*need_escalation\b/i;
|
|
1469
|
+
function stripVerdictDecoration(line) {
|
|
1470
|
+
return line.replace(/^\s*(?:[-*+>]|\d+[.)])\s*/, "").replace(/[*`"']/g, "").replace(/^_+|_+$/g, "").trim();
|
|
1471
|
+
}
|
|
1472
|
+
function leadingColumns(line) {
|
|
1473
|
+
let col = 0;
|
|
1474
|
+
for (const ch of line) {
|
|
1475
|
+
if (ch === " ") col += 1;
|
|
1476
|
+
else if (ch === " ") col += 4 - col % 4;
|
|
1477
|
+
else break;
|
|
1478
|
+
}
|
|
1479
|
+
return col;
|
|
1480
|
+
}
|
|
1481
|
+
function assertionLines(text) {
|
|
1482
|
+
const kept = [];
|
|
1483
|
+
let fence = null;
|
|
1484
|
+
for (const rawLine of text.split(/\r?\n/)) {
|
|
1485
|
+
const indent = leadingColumns(rawLine);
|
|
1486
|
+
const content = rawLine.replace(/^[ \t]*/, "");
|
|
1487
|
+
if (fence) {
|
|
1488
|
+
if (indent >= 4) continue;
|
|
1489
|
+
if (new RegExp(`^\\${fence.char}{${fence.length},}\\s*$`).test(content)) fence = null;
|
|
1490
|
+
continue;
|
|
1491
|
+
}
|
|
1492
|
+
if (indent >= 4) continue;
|
|
1493
|
+
const open = /^(`{3,}|~{3,})/.exec(content);
|
|
1494
|
+
if (open) {
|
|
1495
|
+
fence = { char: open[1][0], length: open[1].length };
|
|
1496
|
+
continue;
|
|
1497
|
+
}
|
|
1498
|
+
if (/^>/.test(content)) continue;
|
|
1499
|
+
kept.push(rawLine);
|
|
1500
|
+
}
|
|
1501
|
+
return kept;
|
|
1502
|
+
}
|
|
1503
|
+
function parseWholeTextJson(text) {
|
|
1504
|
+
const trimmed = text.trim();
|
|
1505
|
+
if (!trimmed) return void 0;
|
|
1506
|
+
try {
|
|
1507
|
+
return { value: JSON.parse(trimmed) };
|
|
1508
|
+
} catch {
|
|
1509
|
+
return void 0;
|
|
1510
|
+
}
|
|
1511
|
+
}
|
|
1512
|
+
function deriveRunFinalObservation(text) {
|
|
1513
|
+
if (typeof text !== "string" || !text.trim()) return { escalated: false };
|
|
1514
|
+
const lines = assertionLines(text);
|
|
1515
|
+
const wholeJson = parseWholeTextJson(text);
|
|
1516
|
+
const escalated = wholeJson ? typeof wholeJson.value === "object" && wholeJson.value !== null && !Array.isArray(wholeJson.value) && wholeJson.value.status === "need_escalation" : lines.some((line) => {
|
|
1517
|
+
const bare = stripVerdictDecoration(line);
|
|
1518
|
+
return STANDALONE_ESCALATION_RE.test(bare) || ESCALATION_WITH_DETAIL_RE.test(bare) || LABELED_ESCALATION_RE.test(bare);
|
|
1519
|
+
});
|
|
1520
|
+
const structured = parseStructuredReview(text);
|
|
1521
|
+
if (structured.kind === "structured") {
|
|
1522
|
+
return { escalated, reviewVerdict: structuredReviewVerdict(structured.review) };
|
|
1523
|
+
}
|
|
1524
|
+
if (structured.kind === "invalid" || wholeJson) return { escalated };
|
|
1525
|
+
const found = /* @__PURE__ */ new Set();
|
|
1526
|
+
for (const line of lines) {
|
|
1527
|
+
const bare = stripVerdictDecoration(line);
|
|
1528
|
+
const hit = LABELED_VERDICT_RE.exec(bare) ?? STANDALONE_VERDICT_RE.exec(bare);
|
|
1529
|
+
if (!hit) continue;
|
|
1530
|
+
found.add(hit[1].toUpperCase());
|
|
1531
|
+
}
|
|
1532
|
+
if (found.size !== 1) return { escalated };
|
|
1533
|
+
return { escalated, reviewVerdict: [...found][0] };
|
|
1534
|
+
}
|
|
1232
1535
|
var RUN_TERMINAL_STATUSES = /* @__PURE__ */ new Set([
|
|
1233
1536
|
"done",
|
|
1234
1537
|
"failed",
|
|
@@ -2027,6 +2330,42 @@ function listRunRecords(deps = {}) {
|
|
|
2027
2330
|
(a, b) => new Date(b.startedAt).getTime() - new Date(a.startedAt).getTime()
|
|
2028
2331
|
);
|
|
2029
2332
|
}
|
|
2333
|
+
function listRecentRunRecords(deps = {}) {
|
|
2334
|
+
const limit = deps.limit ?? 400;
|
|
2335
|
+
if (!Number.isFinite(limit) || limit <= 0) return [];
|
|
2336
|
+
const fs = deps.fs ?? nodeFs2;
|
|
2337
|
+
const dir = resolveRunsDir(deps.env, deps.homedir);
|
|
2338
|
+
let entries = [];
|
|
2339
|
+
try {
|
|
2340
|
+
entries = fs.readdirSync(dir);
|
|
2341
|
+
} catch {
|
|
2342
|
+
return [];
|
|
2343
|
+
}
|
|
2344
|
+
const timestampedRuns = [];
|
|
2345
|
+
const customRuns = [];
|
|
2346
|
+
for (const entry of entries) {
|
|
2347
|
+
if (!entry.endsWith(".json") || entry.startsWith("acked-") || entry.startsWith("busy-ack-") || entry.endsWith(".isolation.json") || entry.includes(".result.")) {
|
|
2348
|
+
continue;
|
|
2349
|
+
}
|
|
2350
|
+
if (entry.startsWith("run-")) {
|
|
2351
|
+
timestampedRuns.push(entry);
|
|
2352
|
+
} else {
|
|
2353
|
+
customRuns.push(entry);
|
|
2354
|
+
}
|
|
2355
|
+
}
|
|
2356
|
+
timestampedRuns.sort((a, b) => a < b ? 1 : a > b ? -1 : 0);
|
|
2357
|
+
const candidates = timestampedRuns.length >= limit ? timestampedRuns : [...timestampedRuns, ...customRuns.sort((a, b) => a < b ? 1 : a > b ? -1 : 0)];
|
|
2358
|
+
const records = [];
|
|
2359
|
+
for (const entry of candidates) {
|
|
2360
|
+
if (records.length >= limit) break;
|
|
2361
|
+
const runId = entry.slice(0, -".json".length);
|
|
2362
|
+
const record = readRunRecord(runId, deps);
|
|
2363
|
+
if (record) records.push(record);
|
|
2364
|
+
}
|
|
2365
|
+
return records.sort(
|
|
2366
|
+
(a, b) => new Date(b.startedAt).getTime() - new Date(a.startedAt).getTime()
|
|
2367
|
+
);
|
|
2368
|
+
}
|
|
2030
2369
|
async function listRunRecordsAsync(deps = {}) {
|
|
2031
2370
|
const dir = resolveRunsDir(deps.env, deps.homedir);
|
|
2032
2371
|
let entries;
|
|
@@ -2159,7 +2498,7 @@ async function gcRunRecords(deps = {}, options = {}) {
|
|
|
2159
2498
|
if (artifact.publisher !== "run-result-v1" || !/^[A-Za-z0-9._-]+$/.test(record.runId) || !["pending", "bak"].includes(artifact.kind) || !new RegExp(`^${uuid}\\.${artifact.kind}$`).test(name) || artifact.path !== join2(runsDirForLegacy, prefix + name)) throw new Error("unsafe artifact ownership");
|
|
2160
2499
|
if (!fs.existsSync(artifact.path)) continue;
|
|
2161
2500
|
const stat = fs.lstatSync?.(artifact.path);
|
|
2162
|
-
if (!stat || !stat.isFile() || stat.isSymbolicLink() || fs.realpathSync?.(artifact.path) !== resolve(artifact.path) || String(stat.dev) !== artifact.dev || String(stat.ino) !== artifact.ino ||
|
|
2501
|
+
if (!stat || !stat.isFile() || stat.isSymbolicLink() || fs.realpathSync?.(artifact.path) !== resolve(artifact.path) || String(stat.dev) !== artifact.dev || String(stat.ino) !== artifact.ino || createHash2("sha256").update(fs.readFileSync(artifact.path)).digest("hex") !== artifact.sha256) {
|
|
2163
2502
|
throw new Error("artifact identity changed");
|
|
2164
2503
|
}
|
|
2165
2504
|
if (!tryUnlinkFile(fs, artifact.path)) artifactsOk = false;
|
|
@@ -2341,11 +2680,11 @@ function localWriterRecovery(record) {
|
|
|
2341
2680
|
function revokePreparedWriterLaunch(runId, attemptId, deps = {}) {
|
|
2342
2681
|
if (!/^[A-Za-z0-9_-]+$/.test(runId) || !attemptId) return "blocked";
|
|
2343
2682
|
return withRunRecordLock("local-writer-admission", deps, () => {
|
|
2344
|
-
const
|
|
2345
|
-
if (!
|
|
2683
|
+
const snapshot2 = readRunRecord(runId, deps);
|
|
2684
|
+
if (!snapshot2) return "blocked";
|
|
2346
2685
|
return withRunRecordLock(runId, deps, () => {
|
|
2347
2686
|
const latest = readRunRecord(runId, deps);
|
|
2348
|
-
if (!latest || JSON.stringify(latest) !== JSON.stringify(
|
|
2687
|
+
if (!latest || JSON.stringify(latest) !== JSON.stringify(snapshot2)) return "blocked";
|
|
2349
2688
|
const launch = latest.writerLaunch;
|
|
2350
2689
|
if (launch?.protocol !== "fenced-launch-v1" || launch.attemptId !== attemptId) return "blocked";
|
|
2351
2690
|
if (launch.phase === "revoked") return latest.localWriterClaim?.state === "released" ? "already-revoked" : "blocked";
|
|
@@ -2364,10 +2703,10 @@ function localWriterStillOwns(record, deps) {
|
|
|
2364
2703
|
const observed = e?.state === "known" && e.owner.state === "verified" ? nativeOwner(record.pid, deps) : void 0;
|
|
2365
2704
|
const reused = observed?.state === "verified" && e?.state === "known" && e.owner.state === "verified" && (observed.startedAt !== e.owner.startedAt || (observed.linux?.bootId !== e.owner.linux?.bootId || observed.linux?.startTicks !== e.owner.linux?.startTicks));
|
|
2366
2705
|
if (!isPidGone(record.pid, deps) && !reused) return true;
|
|
2367
|
-
const
|
|
2706
|
+
const snapshot2 = JSON.stringify(record);
|
|
2368
2707
|
const released = withRunRecordLock(record.runId, deps, () => {
|
|
2369
2708
|
const latest = readRunRecord(record.runId, deps);
|
|
2370
|
-
if (!latest || JSON.stringify(latest) !==
|
|
2709
|
+
if (!latest || JSON.stringify(latest) !== snapshot2) return false;
|
|
2371
2710
|
latest.localWriterClaim.state = "released";
|
|
2372
2711
|
writeRunRecord(latest, deps);
|
|
2373
2712
|
return true;
|
|
@@ -2376,14 +2715,14 @@ function localWriterStillOwns(record, deps) {
|
|
|
2376
2715
|
}
|
|
2377
2716
|
function acquireLocalWriterClaim(runId, cwd, deps) {
|
|
2378
2717
|
const fs = deps.fs ?? nodeFs2;
|
|
2379
|
-
const
|
|
2380
|
-
const worktree = trustedLocalWorktree(
|
|
2718
|
+
const canonical2 = String((fs.realpathSync ?? nodeFs2.realpathSync)(cwd));
|
|
2719
|
+
const worktree = trustedLocalWorktree(canonical2, deps);
|
|
2381
2720
|
const acquired = withRunRecordLock("local-writer-admission", deps, () => {
|
|
2382
2721
|
const updated = withRunRecordLock(runId, deps, () => {
|
|
2383
2722
|
const record = readRunRecord(runId, deps);
|
|
2384
2723
|
if (!record) throw new Error(`[local-writer-resource] missing run ${runId}`);
|
|
2385
2724
|
if (record.writerLaunch?.phase === "revoked") throw new Error("[local-writer-resource] claim attempt revoked");
|
|
2386
|
-
record.localWriterClaim = { cwd:
|
|
2725
|
+
record.localWriterClaim = { cwd: canonical2, ...worktree ? { worktree } : {}, state: "held" };
|
|
2387
2726
|
if (record.writerLaunch && record.execution?.state === "known" && record.execution.owner.state === "verified" && record.pid === process.pid) {
|
|
2388
2727
|
record.writerLaunch.phase = "granted";
|
|
2389
2728
|
}
|
|
@@ -2394,7 +2733,7 @@ function acquireLocalWriterClaim(runId, cwd, deps) {
|
|
|
2394
2733
|
return true;
|
|
2395
2734
|
}, { strict: true, requireDeadOwner: true });
|
|
2396
2735
|
if (!acquired) throw new Error("[local-writer-resource] admission lock busy; no child spawned");
|
|
2397
|
-
return
|
|
2736
|
+
return canonical2;
|
|
2398
2737
|
}
|
|
2399
2738
|
function nativeOwner(pid, deps) {
|
|
2400
2739
|
const first = probeProcessStartTime(pid, deps);
|
|
@@ -2427,11 +2766,12 @@ function validateLocalWriterChild(runId, cwd, policy, deps = {}) {
|
|
|
2427
2766
|
if (!r || r.runId !== runId || r.pid !== process.pid || r.status !== "running" || e?.state !== "known" || e.kind !== "host-local" || e.runtimeKey !== "local" || e.device.kind !== "localhost" || e.device.hostname !== nodeHostname() || e.device.platform !== process.platform || !["cli-command-authorized", "cli-tool-dispatch-authorized"].includes(e.provenance) || e.owner.state !== "verified" || native.state !== "verified" || e.owner.pid !== process.pid || e.owner.startedAt !== native.startedAt || (e.owner.linux?.bootId !== native.linux?.bootId || e.owner.linux?.startTicks !== native.linux?.startTicks) || r.processIdentity !== "verified" || r.processStartedAt !== e.owner.startedAt || e.canonicalCwd !== real || r.cwd !== real || e.permissions.hostWritesAuthorized !== policy.hostWritesAuthorized || e.permissions.readOnly !== policy.readOnly) fail("native identity/authorization");
|
|
2428
2767
|
if (e?.state !== "known") return fail();
|
|
2429
2768
|
const set = (v) => JSON.stringify(v === void 0 ? null : [...new Set(v)].sort());
|
|
2430
|
-
if (set(e.permissions.allowedToolNames) !== set(policy.allowedToolNames) || set(e.permissions.blockedToolNames) !== set(policy.blockedToolNames) || JSON.stringify(e.worktree) !== JSON.stringify(trustedLocalWorktree(real, deps))) fail("scope/worktree");
|
|
2769
|
+
if (set(e.permissions.allowedToolNames) !== set(policy.allowedToolNames) || !policy.readOnly && set(e.permissions.blockedToolNames) !== set(policy.blockedToolNames) || JSON.stringify(e.worktree) !== JSON.stringify(trustedLocalWorktree(real, deps))) fail("scope/worktree");
|
|
2431
2770
|
if (!policy.readOnly && (!policy.hostWritesAuthorized || r?.localWriterClaim?.state !== "held" || r.localWriterClaim.cwd !== real || e.worktree && (r.localWriterClaim.worktree?.root !== e.worktree.root || r.localWriterClaim.worktree.gitDir !== e.worktree.gitDir))) fail();
|
|
2432
|
-
|
|
2771
|
+
const blockedToolNames = policy.readOnly ? [.../* @__PURE__ */ new Set([...e.permissions.blockedToolNames ?? [], ...policy.blockedToolNames ?? []])] : policy.blockedToolNames;
|
|
2772
|
+
return { blockedToolNames };
|
|
2433
2773
|
}, { strict: true, requireDeadOwner: true });
|
|
2434
|
-
|
|
2774
|
+
return validated ?? fail("registry lock busy");
|
|
2435
2775
|
}
|
|
2436
2776
|
async function awaitLocalWriterChild(runId, cwd, policy, deps = {}) {
|
|
2437
2777
|
if (!/^[A-Za-z0-9_-]+$/.test(runId)) throw new Error("[local-writer-resource] child binding invalid id");
|
|
@@ -2445,8 +2785,7 @@ async function awaitLocalWriterChild(runId, cwd, policy, deps = {}) {
|
|
|
2445
2785
|
const native = publication ? nativeOwner(publication.parent.pid, deps) : { state: "unknown" };
|
|
2446
2786
|
const parentLive = publication && native.state === "verified" && publication.parent.startedAt === native.startedAt && publication.parent.linux?.bootId === native.linux?.bootId && publication.parent.linux?.startTicks === native.linux?.startTicks;
|
|
2447
2787
|
try {
|
|
2448
|
-
validateLocalWriterChild(runId, cwd, policy, deps);
|
|
2449
|
-
return;
|
|
2788
|
+
return validateLocalWriterChild(runId, cwd, policy, deps);
|
|
2450
2789
|
} catch (error) {
|
|
2451
2790
|
const lockBusy = String(error).includes("registry lock busy");
|
|
2452
2791
|
const pending = publication?.state === "pending" && r?.execution?.state === "known" && r.execution.owner.state === "unknown";
|
|
@@ -2494,19 +2833,19 @@ function resolveLocalContinuation(record, deps = {}) {
|
|
|
2494
2833
|
}
|
|
2495
2834
|
function registerLocalForegroundWriter(cwd, policy, agentKey, deps = {}) {
|
|
2496
2835
|
const fs = deps.fs ?? nodeFs2;
|
|
2497
|
-
const
|
|
2836
|
+
const canonical2 = String((fs.realpathSync ?? nodeFs2.realpathSync)(cwd));
|
|
2498
2837
|
const owner = nativeOwner(process.pid, deps);
|
|
2499
2838
|
if (owner.state !== "verified" || policy.readOnly || !policy.hostWritesAuthorized) {
|
|
2500
2839
|
throw new Error("[local-writer-resource] foreground native identity/authorization unknown");
|
|
2501
2840
|
}
|
|
2502
2841
|
const runId = defaultGenerateRunId();
|
|
2503
2842
|
fs.mkdirSync(resolveRunsDir(deps.env, deps.homedir), { recursive: true });
|
|
2504
|
-
const worktree = trustedLocalWorktree(
|
|
2843
|
+
const worktree = trustedLocalWorktree(canonical2, deps);
|
|
2505
2844
|
const record = {
|
|
2506
2845
|
runId,
|
|
2507
2846
|
agentKey,
|
|
2508
|
-
writerLaunch: { protocol: "fenced-launch-v1", attemptId:
|
|
2509
|
-
cwd:
|
|
2847
|
+
writerLaunch: { protocol: "fenced-launch-v1", attemptId: randomUUID3(), phase: "prepared" },
|
|
2848
|
+
cwd: canonical2,
|
|
2510
2849
|
startedAt: (deps.now?.() ?? /* @__PURE__ */ new Date()).toISOString(),
|
|
2511
2850
|
status: "running",
|
|
2512
2851
|
logPath: resolveRunLogPath(runId, deps.env, deps.homedir),
|
|
@@ -2517,7 +2856,7 @@ function registerLocalForegroundWriter(cwd, policy, agentKey, deps = {}) {
|
|
|
2517
2856
|
state: "known",
|
|
2518
2857
|
kind: "host-local",
|
|
2519
2858
|
runtimeKey: "local",
|
|
2520
|
-
canonicalCwd:
|
|
2859
|
+
canonicalCwd: canonical2,
|
|
2521
2860
|
device: { kind: "localhost", hostname: nodeHostname(), platform: process.platform },
|
|
2522
2861
|
...worktree ? { worktree } : {},
|
|
2523
2862
|
permissions: {
|
|
@@ -2532,7 +2871,7 @@ function registerLocalForegroundWriter(cwd, policy, agentKey, deps = {}) {
|
|
|
2532
2871
|
};
|
|
2533
2872
|
writeRunRecord(record, deps);
|
|
2534
2873
|
try {
|
|
2535
|
-
acquireLocalWriterClaim(runId,
|
|
2874
|
+
acquireLocalWriterClaim(runId, canonical2, deps);
|
|
2536
2875
|
} catch (error) {
|
|
2537
2876
|
finalizeRunRecord(runId, { status: "failed", exitCode: 1, note: String(error) }, deps);
|
|
2538
2877
|
throw error;
|
|
@@ -2551,10 +2890,13 @@ function releaseUnspawnedLocalWriterClaim(runId, deps) {
|
|
|
2551
2890
|
}, { strict: true });
|
|
2552
2891
|
if (!released) throw new Error(`[local-writer-resource] release lock busy: ${runId}`);
|
|
2553
2892
|
}
|
|
2893
|
+
var startupPhaseOrder = { spawn: 0, initializing: 1, protocol_validated: 2, model: 3 };
|
|
2554
2894
|
async function recordRunStartup(runId, phase, deps = {}) {
|
|
2555
2895
|
const attempt = () => withRunRecordLock(runId, deps, () => {
|
|
2556
2896
|
const record = readRunRecord(runId, deps);
|
|
2557
2897
|
if (!record || isRunTerminalStatus(record.status)) return true;
|
|
2898
|
+
if (record.pid != null && record.pid !== process.pid) return true;
|
|
2899
|
+
if (record.startup && startupPhaseOrder[record.startup.phase] >= startupPhaseOrder[phase]) return true;
|
|
2558
2900
|
record.startup = { protocol: AGENT_RUN_PROTOCOL, phase };
|
|
2559
2901
|
writeRunRecord(record, deps);
|
|
2560
2902
|
return true;
|
|
@@ -2668,10 +3010,11 @@ async function spawnLocalBackgroundRun(input, deps = {}) {
|
|
|
2668
3010
|
startup: { protocol: AGENT_RUN_PROTOCOL, phase: "spawn" },
|
|
2669
3011
|
agentKey: input.agentKey,
|
|
2670
3012
|
agentName: input.agentName?.trim() || shortAgentKey(input.agentKey),
|
|
3013
|
+
...typeof input.callerAgentKey === "string" && input.callerAgentKey.trim() ? { callerAgentKey: input.callerAgentKey.trim() } : {},
|
|
2671
3014
|
...title ? { title } : {},
|
|
2672
3015
|
cwd: canonicalCwd ?? input.cwd,
|
|
2673
3016
|
execution,
|
|
2674
|
-
...executionRequest ? { writerLaunch: { protocol: "fenced-launch-v1", attemptId:
|
|
3017
|
+
...executionRequest ? { writerLaunch: { protocol: "fenced-launch-v1", attemptId: randomUUID3(), phase: "prepared" } } : {},
|
|
2675
3018
|
...executionRequest ? (() => {
|
|
2676
3019
|
const parent = nativeOwner(process.pid, resolvedDeps);
|
|
2677
3020
|
return parent.state === "verified" ? { ownerPublication: { state: "pending", parent } } : {};
|
|
@@ -2767,7 +3110,7 @@ async function spawnLocalBackgroundRun(input, deps = {}) {
|
|
|
2767
3110
|
detached: true,
|
|
2768
3111
|
// Detached on Windows means no console; hide the one its children would create.
|
|
2769
3112
|
windowsHide: true,
|
|
2770
|
-
stdio: deps.shellApprovalHost ? ["ignore", logFd, logFd, "ipc"] : ["ignore", logFd, logFd]
|
|
3113
|
+
stdio: deps.shellApprovalHost || deps.mcpApprovalHost ? ["ignore", logFd, logFd, "ipc"] : ["ignore", logFd, logFd]
|
|
2771
3114
|
});
|
|
2772
3115
|
} catch (error) {
|
|
2773
3116
|
try {
|
|
@@ -2871,6 +3214,15 @@ async function spawnLocalBackgroundRun(input, deps = {}) {
|
|
|
2871
3214
|
throw new Error(`[host-memory-reservation] child ${proc.pid}, run ${runId}: association failed: ${error}`);
|
|
2872
3215
|
}
|
|
2873
3216
|
}
|
|
3217
|
+
if (deps.mcpApprovalHost) {
|
|
3218
|
+
attachMcpApprovalHost(proc, { ...deps.mcpApprovalHost, binding: {
|
|
3219
|
+
...deps.mcpApprovalHost.binding,
|
|
3220
|
+
runId,
|
|
3221
|
+
agentKey: input.agentKey,
|
|
3222
|
+
workspaceRoot: nodeFs2.realpathSync(input.cwd ?? process.cwd())
|
|
3223
|
+
} });
|
|
3224
|
+
proc.channel?.unref?.();
|
|
3225
|
+
}
|
|
2874
3226
|
if (deps.shellApprovalHost) {
|
|
2875
3227
|
attachShellApprovalHost(proc, { ...deps.shellApprovalHost, binding: {
|
|
2876
3228
|
...deps.shellApprovalHost.binding,
|
|
@@ -2962,6 +3314,9 @@ function transitionRunToTerminal(runId, update, deps = {}, options = {}) {
|
|
|
2962
3314
|
const settled = withRunRecordLock(runId, deps, () => {
|
|
2963
3315
|
const record2 = readRunRecord(runId, deps);
|
|
2964
3316
|
if (!record2) return { kind: "not_found" };
|
|
3317
|
+
if (options.expectedPid != null && record2.pid != null && record2.pid !== options.expectedPid) {
|
|
3318
|
+
return { kind: "kept", record: record2 };
|
|
3319
|
+
}
|
|
2965
3320
|
const orphanCorrection = options.allowOverOrphaned === true && record2.status === "orphaned" && (update.status === "done" || update.status === "failed");
|
|
2966
3321
|
if (isAgentRunTerminalStatus(record2.status) && !orphanCorrection) {
|
|
2967
3322
|
if (update.processExit) {
|
|
@@ -3002,9 +3357,25 @@ function transitionRunToTerminal(runId, update, deps = {}, options = {}) {
|
|
|
3002
3357
|
if (typeof update.lastAssistantText === "string" && update.lastAssistantText) {
|
|
3003
3358
|
record2.lastAssistantText = update.lastAssistantText.slice(0, 2e3);
|
|
3004
3359
|
}
|
|
3360
|
+
if (typeof update.model === "string" && update.model.trim()) {
|
|
3361
|
+
record2.model = update.model.trim();
|
|
3362
|
+
}
|
|
3363
|
+
const finalObservation = deriveRunFinalObservation(update.lastAssistantText);
|
|
3364
|
+
if (finalObservation.escalated) record2.escalated = true;
|
|
3365
|
+
if (finalObservation.reviewVerdict) record2.reviewVerdict = finalObservation.reviewVerdict;
|
|
3005
3366
|
if (update.cacheUsage) {
|
|
3006
3367
|
record2.cacheHitRatio = update.cacheUsage.cache_hit_ratio;
|
|
3007
3368
|
record2.cacheCachedTokens = update.cacheUsage.cached_tokens;
|
|
3369
|
+
if (typeof update.cacheUsage.input_tokens === "number") {
|
|
3370
|
+
record2.inputTokens = update.cacheUsage.input_tokens;
|
|
3371
|
+
}
|
|
3372
|
+
if (typeof update.cacheUsage.output_tokens === "number") {
|
|
3373
|
+
record2.outputTokens = update.cacheUsage.output_tokens;
|
|
3374
|
+
}
|
|
3375
|
+
}
|
|
3376
|
+
const resolvedTier = record2.selectionCheck?.modelTier ?? resolveModelTier(record2.model);
|
|
3377
|
+
if (resolvedTier !== "unknown" || record2.selectionCheck?.modelTier) {
|
|
3378
|
+
record2.modelTier = resolvedTier;
|
|
3008
3379
|
}
|
|
3009
3380
|
record2.endedAt = now().toISOString();
|
|
3010
3381
|
let resultWriteFailed = false;
|
|
@@ -3022,7 +3393,7 @@ function transitionRunToTerminal(runId, update, deps = {}, options = {}) {
|
|
|
3022
3393
|
kind,
|
|
3023
3394
|
dev: String(stat.dev),
|
|
3024
3395
|
ino: String(stat.ino),
|
|
3025
|
-
sha256:
|
|
3396
|
+
sha256: createHash2("sha256").update(fs.readFileSync(path)).digest("hex")
|
|
3026
3397
|
};
|
|
3027
3398
|
record2.resultArtifacts = [...(record2.resultArtifacts ?? []).filter((a) => a.path !== path), artifact];
|
|
3028
3399
|
};
|
|
@@ -3048,12 +3419,15 @@ function transitionRunToTerminal(runId, update, deps = {}, options = {}) {
|
|
|
3048
3419
|
serverSync: update.serverSync,
|
|
3049
3420
|
cwd: record2.cwd,
|
|
3050
3421
|
continuedFrom: record2.continuedFrom,
|
|
3051
|
-
...update.cacheUsage ? { cacheUsage: update.cacheUsage } : {}
|
|
3422
|
+
...update.cacheUsage ? { cacheUsage: update.cacheUsage } : {},
|
|
3423
|
+
...typeof record2.inputTokens === "number" ? { inputTokens: record2.inputTokens } : {},
|
|
3424
|
+
...typeof record2.outputTokens === "number" ? { outputTokens: record2.outputTokens } : {},
|
|
3425
|
+
...record2.modelTier ? { modelTier: record2.modelTier } : {}
|
|
3052
3426
|
},
|
|
3053
3427
|
update.lastAssistantText ?? ""
|
|
3054
3428
|
);
|
|
3055
3429
|
if (typeof fs.renameSync !== "function") throw new Error("atomic result publication requires renameSync");
|
|
3056
|
-
pendingResultFile = `${resultFile}.${
|
|
3430
|
+
pendingResultFile = `${resultFile}.${randomUUID3()}.pending`;
|
|
3057
3431
|
try {
|
|
3058
3432
|
fs.writeFileSync(pendingResultFile, content, { encoding: "utf8", flag: "wx" });
|
|
3059
3433
|
stagingComplete = true;
|
|
@@ -3062,7 +3436,7 @@ function transitionRunToTerminal(runId, update, deps = {}, options = {}) {
|
|
|
3062
3436
|
}
|
|
3063
3437
|
if (fs.existsSync(resultFile)) {
|
|
3064
3438
|
const previous = fs.readFileSync(resultFile);
|
|
3065
|
-
const backup = `${resultFile}.${
|
|
3439
|
+
const backup = `${resultFile}.${randomUUID3()}.bak`;
|
|
3066
3440
|
backupFile = backup;
|
|
3067
3441
|
try {
|
|
3068
3442
|
fs.writeFileSync(backup, previous, { flag: "wx" });
|
|
@@ -3110,8 +3484,11 @@ function transitionRunToTerminal(runId, update, deps = {}, options = {}) {
|
|
|
3110
3484
|
}
|
|
3111
3485
|
var AUTHORITATIVE_SETTLE_MAX_ATTEMPTS = 4;
|
|
3112
3486
|
var AUTHORITATIVE_SETTLE_RETRY_DELAY_MS = 15;
|
|
3113
|
-
async function settleRunTerminalAuthoritatively(runId, update, deps = {}, transition = transitionRunToTerminal) {
|
|
3114
|
-
const attempt = () => transition(runId, update, deps, {
|
|
3487
|
+
async function settleRunTerminalAuthoritatively(runId, update, deps = {}, transition = transitionRunToTerminal, options = {}) {
|
|
3488
|
+
const attempt = () => transition(runId, update, deps, {
|
|
3489
|
+
allowOverOrphaned: true,
|
|
3490
|
+
...options.expectedPid != null ? { expectedPid: options.expectedPid } : {}
|
|
3491
|
+
});
|
|
3115
3492
|
let result = attempt();
|
|
3116
3493
|
for (let attemptNo = 1; result?.kind === "contended" && attemptNo < AUTHORITATIVE_SETTLE_MAX_ATTEMPTS; attemptNo += 1) {
|
|
3117
3494
|
await (deps.sleep ?? defaultSleep)(AUTHORITATIVE_SETTLE_RETRY_DELAY_MS);
|
|
@@ -3122,9 +3499,15 @@ async function settleRunTerminalAuthoritatively(runId, update, deps = {}, transi
|
|
|
3122
3499
|
`[nolo] authoritative settlement for run ${runId} lost the record lock ${AUTHORITATIVE_SETTLE_MAX_ATTEMPTS} times; durable record still ${result.record.status} \u2014 terminal status pending reconcile, child outcome (exitCode/dialogId/credits/DoD) may be lost`
|
|
3123
3500
|
);
|
|
3124
3501
|
} else if (result?.kind === "kept" && result.record.status !== update.status) {
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3502
|
+
if (options.expectedPid != null && result.record.pid != null && result.record.pid !== options.expectedPid) {
|
|
3503
|
+
console.warn(
|
|
3504
|
+
`[nolo] run ${runId} belongs to PID ${result.record.pid}, not ${options.expectedPid}; keeping the durable record (${result.record.status}) over intended ${update.status}`
|
|
3505
|
+
);
|
|
3506
|
+
} else {
|
|
3507
|
+
console.warn(
|
|
3508
|
+
`[nolo] run ${runId} already terminal (${result.record.status}); keeping the durable outcome over intended ${update.status}`
|
|
3509
|
+
);
|
|
3510
|
+
}
|
|
3128
3511
|
}
|
|
3129
3512
|
return result ?? { kind: "not_found" };
|
|
3130
3513
|
}
|
|
@@ -3731,6 +4114,8 @@ async function runAgentRecoverPreparedWriterCommand(args, deps) {
|
|
|
3731
4114
|
}
|
|
3732
4115
|
|
|
3733
4116
|
export {
|
|
4117
|
+
createMcpApprovalChild,
|
|
4118
|
+
hasLiveShellApprovalHosts,
|
|
3734
4119
|
createShellApprovalChild,
|
|
3735
4120
|
TAIL_LINES_MAX,
|
|
3736
4121
|
readHostMemory,
|
|
@@ -3740,6 +4125,7 @@ export {
|
|
|
3740
4125
|
getRunResultHeaderMeta,
|
|
3741
4126
|
serverOriginForDialog,
|
|
3742
4127
|
isHistoryIntegrityFailure,
|
|
4128
|
+
deriveRunFinalObservation,
|
|
3743
4129
|
RUN_TERMINAL_STATUSES,
|
|
3744
4130
|
isRunTerminalStatus,
|
|
3745
4131
|
resolveNoloHome,
|
|
@@ -3776,6 +4162,7 @@ export {
|
|
|
3776
4162
|
readRunRecord,
|
|
3777
4163
|
backfillRunRecordParentDialog,
|
|
3778
4164
|
listRunRecords,
|
|
4165
|
+
listRecentRunRecords,
|
|
3779
4166
|
listRunRecordsAsync,
|
|
3780
4167
|
findRunRecordByPid,
|
|
3781
4168
|
findRunRecord,
|