nolo-cli 0.226.0-alpha.2 → 0.226.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -5
- package/{_executeModel-IKZGZZXW.js → _executeModel-IZ2MCXHO.js} +89 -83
- package/{action-CK64LS6S.js → action-VDEW6WLI.js} +9 -6
- package/{addContentAction-EQXMFNPR.js → addContentAction-7YVXHIPQ.js} +15 -14
- package/{addDialogAgentAction-RSDZDASD.js → addDialogAgentAction-BX7B47HF.js} +18 -17
- package/{agentDeleteCommand-IZY3VF5F.js → agentDeleteCommand-N7ELXPLD.js} +145 -138
- package/{agentEmailCommands-YWL567CL.js → agentEmailCommands-OFS477PV.js} +144 -133
- package/{agentFavoriteCommands-2LKGKSUD.js → agentFavoriteCommands-7LOP3HUD.js} +5 -5
- package/{agentGrantCommands-QQV4N4JW.js → agentGrantCommands-L6O2HVJI.js} +5 -5
- package/agentListCommands-IQQHJSXP.js +644 -0
- package/{agentMachineCommands-AXJ4A772.js → agentMachineCommands-NS65BEW7.js} +75 -66
- package/{agentProviderCommands-7BSJH7TO.js → agentProviderCommands-SS6M6VGY.js} +6 -6
- package/{agentPullCommand-XN6ZPBUW.js → agentPullCommand-QQQZSC6S.js} +6 -6
- package/agentRecordCommands-4VE7CNLC.js +188 -0
- package/agentRunCommand-2MUXHKNW.js +223 -0
- package/{agentRunControl-DFEEOFC7.js → agentRunControl-55GL6Q3M.js} +23 -15
- package/{agentRuntimeLocal-GSTYFEX4.js → agentRuntimeLocal-5DB2P4MU.js} +63 -49
- package/{agentSlice-5F5U5X2U.js → agentSlice-5VTAFG43.js} +19 -18
- package/{appDeleteCommands-L7HL4AWF.js → appDeleteCommands-EDKUPHJM.js} +67 -58
- package/{appDeployCommands-SGSUNFZR.js → appDeployCommands-JO74GW4L.js} +67 -58
- package/{appDeployStatusCommands-AAA3XD54.js → appDeployStatusCommands-U77ZUHX7.js} +67 -58
- package/{appGetCommands-LN72GAOA.js → appGetCommands-QCMHBYPX.js} +67 -58
- package/{appListCommands-IJQQ3VND.js → appListCommands-ZQJYEXI6.js} +67 -58
- package/{authCommand-7JXW54U4.js → authCommand-W4KXRZLI.js} +33 -28
- package/{authCommands-YDNAIDEY.js → authCommands-6AUYO65N.js} +15 -10
- package/{builtinSkillRegistry-PXH7EGQB.js → builtinSkillRegistry-GHE3RD3V.js} +8 -8
- package/{chromeCommands-G5UDKVSV.js → chromeCommands-S7AW3AOD.js} +383 -6
- package/{chromeOpsCommands-YKX2QX3A.js → chromeOpsCommands-TBPM6MR4.js} +6 -6
- package/{chunk-7Z6EW7AH.js → chunk-247AAJRK.js} +13 -6
- package/{chunk-P2ZLUIW2.js → chunk-2BSLGODA.js} +350 -25
- package/{chunk-4HFTBHBF.js → chunk-2N4UBHUU.js} +8 -8
- package/chunk-2SXN7LAY.js +15 -0
- package/{chunk-GBUDWITV.js → chunk-2T5BHLID.js} +2871 -1565
- package/{chunk-XI2BWJM5.js → chunk-324FWHUA.js} +20 -3
- package/{chunk-VFBVA3U2.js → chunk-3OQFXODL.js} +131 -40
- package/{chunk-BGGHA5DV.js → chunk-3ORFJP2Z.js} +1 -1
- package/{chunk-E5EIYI34.js → chunk-3UNAGTBW.js} +32 -95
- package/{chunk-LM2PS3YS.js → chunk-4F7SWSWO.js} +26 -13
- package/{chunk-SBVTHMEG.js → chunk-4FE3IWRE.js} +1 -1
- package/{chunk-GOAPXKQU.js → chunk-4UK6UBXF.js} +4 -4
- package/{chunk-4JVNURX4.js → chunk-4YFC3DWW.js} +68 -16
- package/chunk-4ZCTKB27.js +31 -0
- package/chunk-53W5BXLN.js +340 -0
- package/{chunk-NEKH3XDV.js → chunk-5GRWWUB4.js} +4 -4
- package/{chunk-JWXITTQB.js → chunk-5HUO7SEX.js} +9 -107
- package/{chunk-ZH6MUQEO.js → chunk-6326DRQY.js} +1 -1
- package/{chunk-AVHRSJUH.js → chunk-6MQWGA5F.js} +31 -24
- package/{chunk-67BE44IS.js → chunk-6MX6S6TE.js} +3 -3
- package/chunk-6RSNVJGO.js +279 -0
- package/{chunk-L4NFXFFF.js → chunk-6S6CZUXK.js} +42 -33
- package/{chunk-PDCV7P5W.js → chunk-6XIE5ZGI.js} +1 -1
- package/{chunk-JHRQXQ4A.js → chunk-6XLWUNZB.js} +25 -25
- package/{chunk-YGMBIXCF.js → chunk-6XRPBZRS.js} +4 -2
- package/{chunk-62HXNQVV.js → chunk-776CXKMX.js} +1 -1
- package/{chunk-6J4TTPS2.js → chunk-7AWKDRXG.js} +5 -5
- package/{chunk-3KNEE64G.js → chunk-7GTXPS3D.js} +16 -16
- package/{chunk-RRVQ446B.js → chunk-7HUHOCIY.js} +147 -162
- package/{chunk-PWTNI4N7.js → chunk-ANUP75N2.js} +22 -0
- package/chunk-BEM6LPD2.js +734 -0
- package/{chunk-AGP3YSEC.js → chunk-BH7CEVOH.js} +46 -1
- package/chunk-BIDSIRTS.js +307 -0
- package/{chunk-4AMQZTE7.js → chunk-C4KX626C.js} +15 -15
- package/chunk-C5A54QS7.js +108 -0
- package/{chunk-BYH3HMUP.js → chunk-CHYYSFFM.js} +6 -6
- package/{chunk-VREDDN25.js → chunk-CJTB3OYB.js} +14 -9
- package/{chunk-YFLVRVYK.js → chunk-DLT2DN4M.js} +1 -1
- package/{chunk-LKA64WH4.js → chunk-DMPZMYH4.js} +37 -1
- package/{chunk-EOWLBDY6.js → chunk-DOK7GDRU.js} +1 -1
- package/{chunk-T3T57NVP.js → chunk-DPAIQLAL.js} +105 -102
- package/{chunk-KFHREHUQ.js → chunk-DXWGFL2Z.js} +89 -1
- package/{chunk-XN23AUVU.js → chunk-EKXPHL7M.js} +8 -5
- package/{chunk-DISQCYPE.js → chunk-ENYTIRIO.js} +6 -6
- package/{chunk-2TIQO6TC.js → chunk-ER3P6MBT.js} +206 -308
- package/{chunk-M3JEW6N6.js → chunk-F26GAEH3.js} +10 -0
- package/{chunk-JM5C4EUA.js → chunk-F4MCAOWN.js} +6 -6
- package/chunk-FDZ2GBWO.js +166 -0
- package/{chunk-PMDVQBGA.js → chunk-GAHJLSDO.js} +14 -7
- package/{chunk-N5PQJKCY.js → chunk-GES5GIAU.js} +14 -13
- package/{chunk-QTMIHVLE.js → chunk-HQVNO7FH.js} +66 -35
- package/chunk-HSWEFHFS.js +103 -0
- package/{chunk-S2NTVGA2.js → chunk-I2OYPD3Y.js} +1 -1
- package/{chunk-F7DU25CE.js → chunk-IIG3TT73.js} +460 -123
- package/{chunk-AK5O76CC.js → chunk-IZJFTY4R.js} +3 -3
- package/{chunk-2VA6TU4I.js → chunk-J25ESVUW.js} +22 -19
- package/{chunk-2COEG5ZV.js → chunk-J2XZZXIH.js} +4 -4
- package/{chunk-JVRQ6YVK.js → chunk-JBWXPACD.js} +1 -1
- package/{chunk-D726I5AZ.js → chunk-JVJ53XCH.js} +2 -2
- package/{chunk-TXGQ4O5S.js → chunk-KC2QVCI7.js} +20 -174
- package/{chunk-UKS7D2NL.js → chunk-KF2DWSAH.js} +113 -28
- package/chunk-KK3FCYZM.js +647 -0
- package/{chunk-HHL7WG65.js → chunk-KLD7K5FD.js} +349 -16
- package/{chunk-WSJMT3FA.js → chunk-KMW5CRRM.js} +1564 -2955
- package/{chunk-N5Z2V73W.js → chunk-LELADM5Q.js} +1 -1
- package/{chunk-4NA3YTBC.js → chunk-LMFMV5UC.js} +8 -8
- package/{chunk-KZU52OJ5.js → chunk-LZOOUQAZ.js} +6 -6
- package/{chunk-VV7TXWOC.js → chunk-M5EA44QU.js} +6 -6
- package/{chunk-UYOICCYG.js → chunk-MEDPR36J.js} +64 -89
- package/chunk-MFXJY44K.js +133 -0
- package/chunk-MVOZ22RZ.js +26 -0
- package/{chunk-3QFLXA24.js → chunk-N6EN3HK3.js} +3 -3
- package/{chunk-SOF4OWDM.js → chunk-NEG5LYK5.js} +1 -3
- package/{chunk-W772FYAQ.js → chunk-ODGSLWLO.js} +593 -370
- package/{chunk-OB6DVWPF.js → chunk-OGZE6BZG.js} +331 -99
- package/{chunk-KYH7XW3K.js → chunk-OJRTTERA.js} +77 -2
- package/{chunk-2VUZSVAS.js → chunk-OKPC4QNX.js} +57 -20
- package/{chunk-SOG7OEXX.js → chunk-ONFFUQYM.js} +1 -1
- package/{chunk-KNIIRXHF.js → chunk-P244EH4W.js} +46 -8
- package/chunk-P27E22MA.js +203 -0
- package/{chunk-YDBMZ7FV.js → chunk-PK7VT4ZU.js} +3 -3
- package/{chunk-EUCFKKDM.js → chunk-PVFYPUIM.js} +40 -10
- package/{chunk-HOCHUZQ7.js → chunk-QJTZ76CP.js} +24 -6
- package/{chunk-5RKUPJYL.js → chunk-QLUYDJST.js} +11 -3
- package/{chunk-EFX3Q5SM.js → chunk-QUJKDFZW.js} +17 -17
- package/{chunk-C4VAR65S.js → chunk-QXUVCIPB.js} +204 -124
- package/{chunk-BLSNUIZD.js → chunk-QYNABNNQ.js} +13 -13
- package/{chunk-MK2Q7ZJD.js → chunk-R7XWZDOH.js} +58 -24
- package/{chunk-5FUN7EG4.js → chunk-RD3QLZQV.js} +83 -47
- package/{chunk-KC4SCKXO.js → chunk-RGUWOMXU.js} +1234 -1451
- package/{chunk-IZIN2UNJ.js → chunk-RH44TIHX.js} +206 -27
- package/{chunk-GNHMRBYZ.js → chunk-RIMFTQMC.js} +282 -58
- package/{chunk-VQUWV3YR.js → chunk-S25VJYXV.js} +9 -3
- package/{chunk-EJU6WCDH.js → chunk-SBRJOYND.js} +723 -355
- package/{chunk-UEKXWO7A.js → chunk-SBRSXY67.js} +18 -7
- package/chunk-SR4FE5VD.js +9 -0
- package/{chunk-4WVJLODK.js → chunk-T23G6PXQ.js} +8 -3
- package/chunk-T3WSFTBS.js +62 -0
- package/{chunk-KEN3N2TN.js → chunk-TB5KTLNB.js} +15 -12
- package/{chunk-VP3BINY7.js → chunk-TOK555CQ.js} +31 -1
- package/{chunk-OBSEKCVK.js → chunk-U4VSBDO5.js} +88 -0
- package/{chunk-PPJYZRSQ.js → chunk-U5LOKQ2R.js} +30 -14
- package/{chunk-GGKNJ42M.js → chunk-UDT4SI37.js} +18 -108
- package/{chunk-CKT6QUE2.js → chunk-UHW6SCVK.js} +1 -1
- package/{chunk-GVGOEMNV.js → chunk-UQXOORR3.js} +5 -5
- package/{chunk-6O5YP6FX.js → chunk-UR7555FE.js} +9 -9
- package/{chunk-QLFCTYRH.js → chunk-UWOCASVL.js} +20 -13
- package/{chunk-C4WTX5TU.js → chunk-V2V5Q6DU.js} +2 -2
- package/{chunk-2ZKFCIJJ.js → chunk-VCU5GV42.js} +1 -1
- package/{chunk-FTQWYWUI.js → chunk-VMWY7TUA.js} +1 -1
- package/chunk-VNALJT32.js +33394 -0
- package/{chunk-HGDKT2D6.js → chunk-VTHWBTRE.js} +177 -1
- package/chunk-WBSJAIZP.js +170 -0
- package/chunk-WDWZPASX.js +29 -0
- package/chunk-WFGNWWJI.js +326 -0
- package/{chunk-UJKTI5PG.js → chunk-WRKMXMU7.js} +2 -1
- package/chunk-WVOZ35E4.js +1438 -0
- package/{chunk-FIYSMXHY.js → chunk-WWTSEBDF.js} +1 -1
- package/{chunk-E2BESSAW.js → chunk-X4O7FJF5.js} +2 -0
- package/{chunk-GIABSSWQ.js → chunk-XDNXKFWF.js} +6 -6
- package/{chunk-GBZ4YKEO.js → chunk-XLN2GD6Z.js} +7 -7
- package/{chunk-45LZIYXB.js → chunk-XNEDFWT4.js} +2 -2
- package/{chunk-EWPDMS4N.js → chunk-Y22P6ASC.js} +32 -17
- package/{chunk-LJSNEV7M.js → chunk-Y3DOUQQQ.js} +8 -8
- package/{chunk-KOXKKHFE.js → chunk-Y5EBOURK.js} +10 -5
- package/{chunk-L5I543VB.js → chunk-YGDYYFRX.js} +20 -24
- package/{chunk-6OVNSQHN.js → chunk-YLAHYLDQ.js} +5 -0
- package/{chunk-PVZY6P3S.js → chunk-YTEY27GN.js} +2 -2
- package/chunk-YUZ2DAIH.js +34 -0
- package/chunk-Z6YTCDU4.js +24 -0
- package/{chunk-MOMR7NMG.js → chunk-ZCVBIIUE.js} +4 -4
- package/{chunk-AZQZ5XPM.js → chunk-ZCZLTJEW.js} +98 -57
- package/{chunk-KN3HEZIQ.js → chunk-ZVOL2MAJ.js} +1 -1
- package/{cliAgentConfigHelpers-KICKKNYQ.js → cliAgentConfigHelpers-6OFDHJFT.js} +13 -13
- package/{cliAuthorityBrokerClient-XHH7MH2P.js → cliAuthorityBrokerClient-SFPC3WVK.js} +1 -1
- package/{cliEnvHelpers-VPSJ4XWC.js → cliEnvHelpers-CNMP3RDX.js} +1 -1
- package/{cliExecutor-4MAX3PZL.js → cliExecutor-K6FDZTQ2.js} +3 -1
- package/cliLocalAgentRecordReader-FHIMCBUK.js +102 -0
- package/{commandRegistry-6EQXVODF.js → commandRegistry-OKIWAJIS.js} +113 -101
- package/{contentThunks-ANUP57QV.js → contentThunks-VF2DCU46.js} +41 -38
- package/{cooldownCommands-X7P5M2V5.js → cooldownCommands-QL6DWGVU.js} +4 -4
- package/{createAgentAutomationAction-XMUWUDKQ.js → createAgentAutomationAction-BGET7Q6K.js} +41 -38
- package/{createDialogAction-43QJIQDH.js → createDialogAction-XYDQZETK.js} +42 -40
- package/{createPageAction-SJO7UC3J.js → createPageAction-74S5RO7U.js} +46 -43
- package/{db-CS4ZJQKV.js → db-6NRZLEW2.js} +10 -7
- package/{dbSlice-ZJPDIFER.js → dbSlice-FI7VNDR5.js} +14 -13
- package/{deleteFile-Q3YDB4ML.js → deleteFile-GD62MPZW.js} +10 -7
- package/{dialogCommands-V5IYEOQP.js → dialogCommands-Y6DHZUAM.js} +71 -64
- package/dialogMessageRecord-OAV77LT7.js +7 -0
- package/{dialogNotifyCommand-77B57PL6.js → dialogNotifyCommand-MKXL4NGL.js} +15 -15
- package/{dialogSlice-FQ6WOKWJ.js → dialogSlice-XAUKSWZ4.js} +41 -38
- package/{dialogUsageCommand-HTVPR2CX.js → dialogUsageCommand-BZPKR3DW.js} +6 -6
- package/{docCreateCommands-36WS33BK.js → docCreateCommands-PHDFOQBM.js} +66 -57
- package/{docDeleteCommands-C4CS4XLF.js → docDeleteCommands-OSHJM67Y.js} +69 -60
- package/{docReadCommands-QZMSFMPN.js → docReadCommands-E6QYCFMS.js} +66 -57
- package/{docStore-BZ2O7WLF.js → docStore-ZZT2BEBU.js} +16 -15
- package/{docUpdateCommands-BYI64HVV.js → docUpdateCommands-DHIOPK2C.js} +66 -57
- package/fetchMessages-TQEUZD7H.js +2 -2
- package/{getPricing-VNGFM4PN.js → getPricing-RNRITFOP.js} +6 -6
- package/{handleSendMessageAction-I5J7QR7K.js → handleSendMessageAction-ARUU6CNF.js} +83 -78
- package/{hostCredentialCreate-AVPMK7EQ.js → hostCredentialCreate-SNQT73H4.js} +131 -119
- package/index.js +56 -18
- package/keys-RWF7UCB4.js +1 -1
- package/{lib-OT5OTXRU.js → lib-62SWPXNF.js} +3 -7
- package/{localDialogRead-SVTPA5GY.js → localDialogRead-3T2KMCRC.js} +1 -1
- package/{localRuntimeAdapter-S56R76HN.js → localRuntimeAdapter-MHI6Y2IZ.js} +143 -130
- package/{localRuntimeAuthority-IBJAT62G.js → localRuntimeAuthority-7DKIT7UH.js} +4 -2
- package/{localRuntimeDb-N7KHDXS2.js → localRuntimeDb-5WZ4RJJO.js} +1 -1
- package/{machineCommands-77NFB2AE.js → machineCommands-3O6Y27R4.js} +283 -348
- package/machineWsRunDispatch-5PFLR5XC.js +203 -0
- package/markdownToSlate-KIYM7B3P.js +8 -0
- package/mcpLocalAuthorizeCommand-BQCQ2KRJ.js +106 -0
- package/{memberThunks-JRYNONYV.js → memberThunks-TU6A6OBV.js} +24 -19
- package/{memoryCommands-5WC3T66U.js → memoryCommands-BC6REPQB.js} +4 -4
- package/{models-H5NNZRLH.js → models-CINY5UZR.js} +2 -2
- package/{overlay-THLKYIWY.js → overlay-JA3SPVUS.js} +7 -3
- package/package.json +1 -1
- package/{projectArchive-GNOSYH6F.js → projectArchive-X2EVXU3N.js} +47 -44
- package/{providerPresetApply-J3WMRPD2.js → providerPresetApply-HUWNV2NI.js} +7 -7
- package/{providerRegistry-KJGB5XWS.js → providerRegistry-7FWKDKZJ.js} +7 -7
- package/{read-Q7GOHGNP.js → read-QAHEQID5.js} +9 -8
- package/{readDocTool-Z5OQ6422.js → readDocTool-KG5DP6EM.js} +1 -1
- package/{readlineWorkspace-2PONGBUP.js → readlineWorkspace-SO3APHVP.js} +8125 -6196
- package/rememberExplicit-CPAPONSI.js +15 -0
- package/{removeDialogAgentAction-U3F2MNAY.js → removeDialogAgentAction-QZCCVK2G.js} +20 -19
- package/{runAgentClientLoop-WEXFFHVS.js → runAgentClientLoop-FLHHCOVH.js} +106 -81
- package/{runtimeDoctorCommands-UXKXYBW6.js → runtimeDoctorCommands-DN3I52C6.js} +17 -17
- package/{secretCommands-LJXOOYA7.js → secretCommands-36BCE3UE.js} +4 -4
- package/{setDialogExtraReferencesAction-G3WSJ7EM.js → setDialogExtraReferencesAction-PDPTYSEW.js} +17 -16
- package/{setPrimaryDialogAgentAction-6FHAHZBB.js → setPrimaryDialogAgentAction-DOUIPR66.js} +20 -19
- package/{settingThunks-AXTBX3Q5.js → settingThunks-MHGGP6UE.js} +186 -67
- package/{skillDiscovery-B5V23AXP.js → skillDiscovery-MDDKPTW3.js} +4 -3
- package/{spaceCommands-GUKMDRWN.js → spaceCommands-JH7UYE3K.js} +70 -61
- package/{store-JRVN62NM.js → store-Z53ICFL3.js} +3 -1
- package/{streamAgentChatTurn-D2WFS5MF.js → streamAgentChatTurn-VDDA2TX6.js} +200 -195
- package/{switchDialogAgentAction-UOFIAGPL.js → switchDialogAgentAction-7USK3DAP.js} +18 -17
- package/{tableCommands-HITDSLHS.js → tableCommands-UONBFC7L.js} +15 -12
- package/{toolApiClient-OGQEBQVX.js → toolApiClient-53YMJ2G6.js} +8 -6
- package/{tools-YKE6PQHT.js → tools-MIOCXKMG.js} +72 -68
- package/tuiRestart-ET3QISZ5.js +41 -0
- package/{tuiSummaryLlmCaller-7WLUKNP2.js → tuiSummaryLlmCaller-MSINBP3M.js} +21 -20
- package/{updateCommands-RJVCRSBP.js → updateCommands-5OYND6EF.js} +8 -6
- package/{updateDialogTitleAction-D5NCA4FC.js → updateDialogTitleAction-2L4CC4YO.js} +43 -40
- package/{usageCommand-YPJ2ZI2F.js → usageCommand-JTKDAG6I.js} +3 -3
- package/{usageRebuildCommand-FERQO74C.js → usageRebuildCommand-4TFZCKXM.js} +4 -4
- package/webapi-24RZDIIQ.js +2488 -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-YBNOQ5T3.js +0 -991
- package/agentRecordCommands-WUUC2CX7.js +0 -177
- package/agentRunCommand-W6MDKVLJ.js +0 -208
- package/chunk-2THCNKE4.js +0 -147
- package/chunk-2WZXXAQD.js +0 -57
- package/chunk-5ZMIIR23.js +0 -265
- package/chunk-BJF2MHJ3.js +0 -118
- package/chunk-KEPOVMF4.js +0 -91
- package/chunk-OLMJR6UM.js +0 -357
- package/chunk-QVBXJNZ2.js +0 -81
- package/chunk-QZI44GWV.js +0 -776
- package/cliLocalAgentRecordReader-6FXGFBI3.js +0 -90
- package/machineWsRunDispatch-5XWFUJ53.js +0 -192
- package/{accountResolver-EK2S4PWF.js → accountResolver-QETKNC7T.js} +3 -3
- package/{chunk-W6RFEDN4.js → chunk-AETZ7AD6.js} +3 -3
- package/{chunk-BLVSFYQ3.js → chunk-LISC7BD4.js} +3 -3
- package/{chunk-SNBZZPYH.js → chunk-OQHIVPG4.js} +3 -3
- package/{chunk-47ITIXO7.js → chunk-USGHJSGO.js} +3 -3
- package/{chunk-FJ23FZXF.js → chunk-VIYVRPMJ.js} +0 -0
- package/{offlineMarxistsAgentCommand-4IC3Y4C6.js → offlineMarxistsAgentCommand-XVXUE6G5.js} +3 -3
|
@@ -1,29 +1,225 @@
|
|
|
1
|
-
import {
|
|
2
|
-
resolveRuntimeAuthToken,
|
|
3
|
-
resolveRuntimeServerUrl
|
|
4
|
-
} from "./chunk-SBVTHMEG.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-TB5KTLNB.js";
|
|
13
9
|
import {
|
|
14
10
|
AUTH_ERROR_PATTERNS
|
|
15
11
|
} from "./chunk-EWQ3HGNZ.js";
|
|
16
12
|
import {
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
resolveRuntimeAuthToken,
|
|
14
|
+
resolveRuntimeServerUrl
|
|
15
|
+
} from "./chunk-4FE3IWRE.js";
|
|
19
16
|
import {
|
|
17
|
+
AGENT_RUN_PROTOCOL,
|
|
18
|
+
HOST_RUNTIME_CONTENT_IDENTITY,
|
|
19
|
+
RuntimeVersionMismatchError,
|
|
20
|
+
getHostRuntimeExecutable,
|
|
20
21
|
isCompiledBinary,
|
|
21
|
-
resolveCliEntrypointPath
|
|
22
|
-
|
|
22
|
+
resolveCliEntrypointPath,
|
|
23
|
+
resolveExactRuntimeEntrypoint
|
|
24
|
+
} from "./chunk-BIDSIRTS.js";
|
|
25
|
+
import {
|
|
26
|
+
isRecord
|
|
27
|
+
} from "./chunk-KUG52IAP.js";
|
|
28
|
+
|
|
29
|
+
// packages/cli/mcp/mcpApprovalTransport.ts
|
|
30
|
+
import { randomUUID, createHash } from "node:crypto";
|
|
31
|
+
|
|
32
|
+
// packages/cli/client/inheritedApprovalChannel.ts
|
|
33
|
+
function sendInheritedApproval(channel, kind, message, failed) {
|
|
34
|
+
if (channel.connected === false || !channel.send) {
|
|
35
|
+
failed();
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
try {
|
|
39
|
+
channel.send({ kind, ...message }, (error) => {
|
|
40
|
+
if (error) failed();
|
|
41
|
+
});
|
|
42
|
+
} catch {
|
|
43
|
+
failed();
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function bindInheritedApprovalLifetime(channel, close, signal) {
|
|
47
|
+
for (const event of ["disconnect", "exit", "error"]) channel.on(event, close);
|
|
48
|
+
signal?.addEventListener("abort", close, { once: true });
|
|
49
|
+
return () => {
|
|
50
|
+
for (const event of ["disconnect", "exit", "error"]) channel.removeListener(event, close);
|
|
51
|
+
signal?.removeEventListener("abort", close);
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// packages/cli/mcp/mcpApprovalTransport.ts
|
|
56
|
+
var KIND = "nolo.mcp-approval.v1";
|
|
57
|
+
var TTL = 6e4;
|
|
58
|
+
var MAX = 256;
|
|
59
|
+
function canonical(value) {
|
|
60
|
+
if (Array.isArray(value)) return `[${value.map(canonical).join(",")}]`;
|
|
61
|
+
if (value && typeof value === "object") return `{${Object.keys(value).sort().map((key) => `${JSON.stringify(key)}:${canonical(value[key])}`).join(",")}}`;
|
|
62
|
+
return JSON.stringify(value);
|
|
63
|
+
}
|
|
64
|
+
function snapshot(preview) {
|
|
65
|
+
return createHash("sha256").update(JSON.stringify(preview)).digest("hex");
|
|
66
|
+
}
|
|
67
|
+
function valid(preview, binding) {
|
|
68
|
+
const b = preview?.binding;
|
|
69
|
+
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;
|
|
70
|
+
}
|
|
71
|
+
function attachMcpApprovalHost(channel, host) {
|
|
72
|
+
const binding = Object.freeze({ ...host.binding });
|
|
73
|
+
let closed = false;
|
|
74
|
+
let count = 0;
|
|
75
|
+
const seen = /* @__PURE__ */ new Set();
|
|
76
|
+
const active = /* @__PURE__ */ new Map();
|
|
77
|
+
const send2 = (message) => sendInheritedApproval(channel, KIND, message, close);
|
|
78
|
+
let unbind = () => {
|
|
79
|
+
};
|
|
80
|
+
const close = () => {
|
|
81
|
+
if (closed) return;
|
|
82
|
+
closed = true;
|
|
83
|
+
for (const controller of active.values()) controller.abort();
|
|
84
|
+
active.clear();
|
|
85
|
+
sendInheritedApproval(channel, KIND, { type: "revoke" }, () => {
|
|
86
|
+
});
|
|
87
|
+
channel.removeListener("message", receive);
|
|
88
|
+
unbind();
|
|
89
|
+
};
|
|
90
|
+
const receive = (m) => {
|
|
91
|
+
if (closed || m?.kind !== KIND) return;
|
|
92
|
+
if (m.type === "hello") {
|
|
93
|
+
send2({ type: "binding", binding });
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
if (m.type === "cancel") {
|
|
97
|
+
active.get(m.id)?.abort();
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
if (m.type !== "request") return;
|
|
101
|
+
if (++count > MAX || typeof m.id !== "string" || seen.has(m.id)) {
|
|
102
|
+
close();
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
seen.add(m.id);
|
|
106
|
+
let preview;
|
|
107
|
+
try {
|
|
108
|
+
if (typeof m.snapshot !== "string" || JSON.stringify(m.preview).length > 262144) throw new Error("invalid preview");
|
|
109
|
+
preview = structuredClone(m.preview);
|
|
110
|
+
if (m.runId !== binding.runId || !valid(preview, binding) || snapshot(preview) !== m.snapshot) throw new Error("binding mismatch");
|
|
111
|
+
} catch {
|
|
112
|
+
send2({ type: "decision", id: m.id, runId: binding.runId, snapshot: m.snapshot, decision: "deny" });
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
const controller = new AbortController();
|
|
116
|
+
active.set(m.id, controller);
|
|
117
|
+
const timer = setTimeout(() => controller.abort(), Math.max(0, preview.expiresAt - Date.now()));
|
|
118
|
+
void new Promise((resolve2) => {
|
|
119
|
+
controller.signal.addEventListener("abort", () => resolve2("deny"), { once: true });
|
|
120
|
+
Promise.resolve().then(() => closed || controller.signal.aborted ? "deny" : host.confirm(preview, controller.signal, { runId: binding.runId, requestId: m.id })).then(resolve2, () => resolve2("unavailable"));
|
|
121
|
+
}).then((decision) => {
|
|
122
|
+
clearTimeout(timer);
|
|
123
|
+
active.delete(m.id);
|
|
124
|
+
if (!closed) send2({
|
|
125
|
+
type: "decision",
|
|
126
|
+
id: m.id,
|
|
127
|
+
runId: binding.runId,
|
|
128
|
+
snapshot: m.snapshot,
|
|
129
|
+
decision: !controller.signal.aborted && Date.now() < preview.expiresAt ? decision : "deny"
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
};
|
|
133
|
+
channel.on("message", receive);
|
|
134
|
+
unbind = bindInheritedApprovalLifetime(channel, close, host.signal);
|
|
135
|
+
if (host.signal.aborted || channel.connected === false) close();
|
|
136
|
+
return close;
|
|
137
|
+
}
|
|
138
|
+
function createMcpApprovalChild(channel) {
|
|
139
|
+
const lifetime = new AbortController();
|
|
140
|
+
let binding;
|
|
141
|
+
let count = 0;
|
|
142
|
+
let closed = false;
|
|
143
|
+
const pending = /* @__PURE__ */ new Map();
|
|
144
|
+
const readyResolvers = /* @__PURE__ */ new Set();
|
|
145
|
+
let unbind = () => {
|
|
146
|
+
};
|
|
147
|
+
const close = () => {
|
|
148
|
+
if (closed) return;
|
|
149
|
+
closed = true;
|
|
150
|
+
lifetime.abort();
|
|
151
|
+
for (const entry of pending.values()) entry.finish("unavailable");
|
|
152
|
+
for (const resolve2 of readyResolvers) resolve2();
|
|
153
|
+
readyResolvers.clear();
|
|
154
|
+
channel.removeListener("message", receive);
|
|
155
|
+
unbind();
|
|
156
|
+
};
|
|
157
|
+
const send2 = (message) => sendInheritedApproval(channel, KIND, message, close);
|
|
158
|
+
const receive = (m) => {
|
|
159
|
+
if (closed || m?.kind !== KIND) return;
|
|
160
|
+
if (m.type === "revoke") {
|
|
161
|
+
close();
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
if (m.type === "binding") {
|
|
165
|
+
if (binding || !m.binding || typeof m.binding.runId !== "string" || typeof m.binding.ownerUserId !== "string" || typeof m.binding.agentKey !== "string") {
|
|
166
|
+
close();
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
binding = Object.freeze({ ...m.binding });
|
|
170
|
+
for (const resolve2 of readyResolvers) resolve2();
|
|
171
|
+
readyResolvers.clear();
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
if (m.type !== "decision") return;
|
|
175
|
+
const entry = pending.get(m.id);
|
|
176
|
+
if (!entry) return;
|
|
177
|
+
const matches = binding && m.runId === binding.runId && m.snapshot === entry.snapshot && Date.now() < entry.expiresAt;
|
|
178
|
+
entry.finish(!matches ? "deny" : m.decision === "approve" ? "approve" : m.decision === "unavailable" ? "unavailable" : "deny");
|
|
179
|
+
};
|
|
180
|
+
channel.on("message", receive);
|
|
181
|
+
unbind = bindInheritedApprovalLifetime(channel, close);
|
|
182
|
+
send2({ type: "hello" });
|
|
183
|
+
const confirm = async (input, signal) => {
|
|
184
|
+
if (closed || signal.aborted || ++count > MAX) return "unavailable";
|
|
185
|
+
if (!binding) await new Promise((resolve2) => {
|
|
186
|
+
const done = () => {
|
|
187
|
+
clearTimeout(timer);
|
|
188
|
+
readyResolvers.delete(done);
|
|
189
|
+
signal.removeEventListener("abort", done);
|
|
190
|
+
resolve2();
|
|
191
|
+
};
|
|
192
|
+
const timer = setTimeout(done, Math.max(0, Math.min(TTL, input.expiresAt - Date.now())));
|
|
193
|
+
readyResolvers.add(done);
|
|
194
|
+
signal.addEventListener("abort", done, { once: true });
|
|
195
|
+
});
|
|
196
|
+
if (closed || !binding) return "unavailable";
|
|
197
|
+
if (signal.aborted || !valid(input, binding)) return "deny";
|
|
198
|
+
const preview = structuredClone(input), id = randomUUID(), digest = snapshot(preview);
|
|
199
|
+
return new Promise((resolve2) => {
|
|
200
|
+
const abort = () => {
|
|
201
|
+
send2({ type: "cancel", id });
|
|
202
|
+
finish("deny");
|
|
203
|
+
};
|
|
204
|
+
const timer = setTimeout(abort, Math.max(0, preview.expiresAt - Date.now()));
|
|
205
|
+
const finish = (value) => {
|
|
206
|
+
if (!pending.delete(id)) return;
|
|
207
|
+
clearTimeout(timer);
|
|
208
|
+
signal.removeEventListener("abort", abort);
|
|
209
|
+
resolve2(value);
|
|
210
|
+
};
|
|
211
|
+
pending.set(id, { finish, snapshot: digest, expiresAt: preview.expiresAt });
|
|
212
|
+
signal.addEventListener("abort", abort, { once: true });
|
|
213
|
+
if (signal.aborted) abort();
|
|
214
|
+
else send2({ type: "request", id, runId: binding.runId, snapshot: digest, preview });
|
|
215
|
+
});
|
|
216
|
+
};
|
|
217
|
+
return { confirm, signal: lifetime.signal, close };
|
|
218
|
+
}
|
|
23
219
|
|
|
24
220
|
// packages/cli/client/originShellApprovalTransport.ts
|
|
25
221
|
import { realpathSync } from "node:fs";
|
|
26
|
-
import { randomUUID } from "node:crypto";
|
|
222
|
+
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
27
223
|
|
|
28
224
|
// packages/cli/client/originShellApprovalBridge.ts
|
|
29
225
|
import { isAbsolute } from "node:path";
|
|
@@ -40,7 +236,7 @@ function createOriginShellApprovalBridge(deps) {
|
|
|
40
236
|
}
|
|
41
237
|
const requests = /* @__PURE__ */ new Map();
|
|
42
238
|
const fail = (reason) => ({ ok: false, reason });
|
|
43
|
-
const
|
|
239
|
+
const snapshot2 = (request) => ({ ok: true, request: { ...request } });
|
|
44
240
|
const validIdentity = (call) => {
|
|
45
241
|
try {
|
|
46
242
|
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;
|
|
@@ -66,7 +262,7 @@ function createOriginShellApprovalBridge(deps) {
|
|
|
66
262
|
const request = requests.get(id);
|
|
67
263
|
if (!request) return fail("unknown_request");
|
|
68
264
|
if (!CALL_KEYS.every((key) => request[key] === call[key])) return fail("call_mismatch");
|
|
69
|
-
return
|
|
265
|
+
return snapshot2(request);
|
|
70
266
|
};
|
|
71
267
|
return {
|
|
72
268
|
request(call) {
|
|
@@ -94,7 +290,7 @@ function createOriginShellApprovalBridge(deps) {
|
|
|
94
290
|
state: "pending"
|
|
95
291
|
};
|
|
96
292
|
requests.set(requestId, request);
|
|
97
|
-
return
|
|
293
|
+
return snapshot2(request);
|
|
98
294
|
},
|
|
99
295
|
decide(id, call, decision) {
|
|
100
296
|
const result = lookup(id, call);
|
|
@@ -108,7 +304,7 @@ function createOriginShellApprovalBridge(deps) {
|
|
|
108
304
|
state: decision === "approve" ? "approved" : "denied"
|
|
109
305
|
};
|
|
110
306
|
requests.set(id, request);
|
|
111
|
-
return
|
|
307
|
+
return snapshot2(request);
|
|
112
308
|
},
|
|
113
309
|
revoke() {
|
|
114
310
|
for (const [id, request] of requests) {
|
|
@@ -124,15 +320,15 @@ function createOriginShellApprovalBridge(deps) {
|
|
|
124
320
|
if (result.request.state !== "approved") return fail(result.request.state);
|
|
125
321
|
const request = { ...result.request, state: "consumed" };
|
|
126
322
|
requests.set(id, request);
|
|
127
|
-
return
|
|
323
|
+
return snapshot2(request);
|
|
128
324
|
}
|
|
129
325
|
};
|
|
130
326
|
}
|
|
131
327
|
|
|
132
328
|
// packages/cli/client/originShellApprovalTransport.ts
|
|
133
|
-
var
|
|
134
|
-
var
|
|
135
|
-
var
|
|
329
|
+
var KIND2 = "nolo.shell-approval.v1";
|
|
330
|
+
var MAX2 = 256;
|
|
331
|
+
var TTL2 = 6e4;
|
|
136
332
|
var NOTICE = "Executes with this local user's reachable permissions; workspace is NOT a directory sandbox.";
|
|
137
333
|
function payloadCall(payload, binding) {
|
|
138
334
|
if (typeof payload !== "string" || payload.length > 262144) throw new Error("Invalid approval payload");
|
|
@@ -144,17 +340,25 @@ function payloadCall(payload, binding) {
|
|
|
144
340
|
}
|
|
145
341
|
function send(channel, message) {
|
|
146
342
|
if (channel.connected === false || !channel.send) throw new Error("Approval channel disconnected");
|
|
147
|
-
channel.send({ kind:
|
|
343
|
+
channel.send({ kind: KIND2, ...message });
|
|
344
|
+
}
|
|
345
|
+
var liveApprovalHosts = /* @__PURE__ */ new Set();
|
|
346
|
+
function hasLiveShellApprovalHosts() {
|
|
347
|
+
return liveApprovalHosts.size > 0;
|
|
148
348
|
}
|
|
149
349
|
function attachShellApprovalHost(channel, host) {
|
|
150
350
|
const binding = Object.freeze({ ...host.binding });
|
|
151
351
|
const bridge = createOriginShellApprovalBridge({ binding, resolveWorkspace: realpathSync });
|
|
352
|
+
const connection = {};
|
|
152
353
|
let closed = false;
|
|
153
354
|
let count = 0;
|
|
154
355
|
const active = /* @__PURE__ */ new Set();
|
|
356
|
+
let unbindLifetime = () => {
|
|
357
|
+
};
|
|
155
358
|
const close = () => {
|
|
156
359
|
if (closed) return;
|
|
157
360
|
closed = true;
|
|
361
|
+
liveApprovalHosts.delete(connection);
|
|
158
362
|
bridge.revoke();
|
|
159
363
|
for (const controller of active) controller.abort();
|
|
160
364
|
active.clear();
|
|
@@ -163,13 +367,10 @@ function attachShellApprovalHost(channel, host) {
|
|
|
163
367
|
} catch {
|
|
164
368
|
}
|
|
165
369
|
channel.removeListener("message", receive);
|
|
166
|
-
|
|
167
|
-
channel.removeListener("exit", close);
|
|
168
|
-
channel.removeListener("error", close);
|
|
169
|
-
host.signal.removeEventListener("abort", close);
|
|
370
|
+
unbindLifetime();
|
|
170
371
|
};
|
|
171
372
|
const receive = (message) => {
|
|
172
|
-
if (closed || message?.kind !==
|
|
373
|
+
if (closed || message?.kind !== KIND2) return;
|
|
173
374
|
if (message.type === "hello") {
|
|
174
375
|
try {
|
|
175
376
|
send(channel, { type: "binding", binding });
|
|
@@ -179,7 +380,7 @@ function attachShellApprovalHost(channel, host) {
|
|
|
179
380
|
return;
|
|
180
381
|
}
|
|
181
382
|
if (message.type !== "request") return;
|
|
182
|
-
if (++count >
|
|
383
|
+
if (++count > MAX2 || typeof message.id !== "string" || message.id.length > 100) {
|
|
183
384
|
close();
|
|
184
385
|
return;
|
|
185
386
|
}
|
|
@@ -236,14 +437,12 @@ function attachShellApprovalHost(channel, host) {
|
|
|
236
437
|
})();
|
|
237
438
|
};
|
|
238
439
|
channel.on("message", receive);
|
|
239
|
-
channel
|
|
240
|
-
|
|
241
|
-
channel.
|
|
242
|
-
host.signal.addEventListener("abort", close, { once: true });
|
|
243
|
-
if (host.signal.aborted) close();
|
|
440
|
+
unbindLifetime = bindInheritedApprovalLifetime(channel, close, host.signal);
|
|
441
|
+
liveApprovalHosts.add(connection);
|
|
442
|
+
if (host.signal.aborted || channel.connected === false) close();
|
|
244
443
|
return close;
|
|
245
444
|
}
|
|
246
|
-
function createShellApprovalChild(channel, timeoutMs =
|
|
445
|
+
function createShellApprovalChild(channel, timeoutMs = TTL2) {
|
|
247
446
|
let closed = false;
|
|
248
447
|
let binding;
|
|
249
448
|
let count = 0;
|
|
@@ -262,7 +461,7 @@ function createShellApprovalChild(channel, timeoutMs = TTL) {
|
|
|
262
461
|
channel.removeListener("disconnect", close);
|
|
263
462
|
};
|
|
264
463
|
const receive = (message) => {
|
|
265
|
-
if (closed || message?.kind !==
|
|
464
|
+
if (closed || message?.kind !== KIND2) return;
|
|
266
465
|
if (message.type === "revoke") {
|
|
267
466
|
close();
|
|
268
467
|
return;
|
|
@@ -280,7 +479,7 @@ function createShellApprovalChild(channel, timeoutMs = TTL) {
|
|
|
280
479
|
if (!entry) return;
|
|
281
480
|
pending.delete(message.id);
|
|
282
481
|
clearTimeout(entry.timer);
|
|
283
|
-
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() +
|
|
482
|
+
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)) {
|
|
284
483
|
entry.reject(new Error("Shell approval denied"));
|
|
285
484
|
return;
|
|
286
485
|
}
|
|
@@ -298,17 +497,17 @@ function createShellApprovalChild(channel, timeoutMs = TTL) {
|
|
|
298
497
|
close,
|
|
299
498
|
authority: {
|
|
300
499
|
async request(payload) {
|
|
301
|
-
if (++count >
|
|
302
|
-
const deadline = Date.now() + Math.min(timeoutMs,
|
|
500
|
+
if (++count > MAX2) throw new Error("Shell approval capacity exceeded");
|
|
501
|
+
const deadline = Date.now() + Math.min(timeoutMs, TTL2);
|
|
303
502
|
while (!binding && !closed && Date.now() < deadline) await new Promise((resolve2) => setTimeout(resolve2, 5));
|
|
304
503
|
if (closed || !binding) throw new Error("Shell approval unavailable");
|
|
305
504
|
payloadCall(payload, binding);
|
|
306
|
-
const id =
|
|
505
|
+
const id = randomUUID2();
|
|
307
506
|
return new Promise((resolve2, reject) => {
|
|
308
507
|
const timer = setTimeout(() => {
|
|
309
508
|
pending.delete(id);
|
|
310
509
|
reject(new Error("Shell approval timeout"));
|
|
311
|
-
}, Math.min(timeoutMs,
|
|
510
|
+
}, Math.min(timeoutMs, TTL2));
|
|
312
511
|
pending.set(id, { payload, resolve: resolve2, reject, timer });
|
|
313
512
|
try {
|
|
314
513
|
send(channel, { type: "request", id, runId: binding.runId, payload });
|
|
@@ -451,7 +650,7 @@ function redactLogLines(lines, options = {}) {
|
|
|
451
650
|
import { hostname as nodeHostname, homedir as nodeHomedir } from "node:os";
|
|
452
651
|
import { dirname, isAbsolute as isAbsolute2, join as join2, resolve } from "node:path";
|
|
453
652
|
import * as nodeFs2 from "node:fs";
|
|
454
|
-
import { randomUUID as
|
|
653
|
+
import { randomUUID as randomUUID3, createHash as createHash2 } from "node:crypto";
|
|
455
654
|
import { execFileSync as nodeExecFileSync, spawn as nodeSpawn } from "node:child_process";
|
|
456
655
|
|
|
457
656
|
// packages/cli/client/hostMemory.ts
|
|
@@ -700,7 +899,7 @@ var HostMemoryAdmissionError = class extends Error {
|
|
|
700
899
|
};
|
|
701
900
|
function assertHostMemoryAdmission(deps = {}) {
|
|
702
901
|
const readMem = deps.readHostMemory ?? readHostMemory;
|
|
703
|
-
const
|
|
902
|
+
const snapshot2 = readMem(deps.hostMemoryDeps);
|
|
704
903
|
const minAvailableMb = deps.minAvailableMb ?? LOCAL_AGENT_RUN_MIN_AVAILABLE_MB;
|
|
705
904
|
const startupWindowMs = deps.startupWindowMs ?? STARTUP_WINDOW_MS;
|
|
706
905
|
const reservedMbPerRun = deps.reservedMbPerRun ?? STARTUP_WINDOW_RESERVED_MB_PER_RUN;
|
|
@@ -708,7 +907,7 @@ function assertHostMemoryAdmission(deps = {}) {
|
|
|
708
907
|
for (const [name, value] of Object.entries({ minAvailableMb, startupWindowMs, reservedMbPerRun, now })) {
|
|
709
908
|
if (typeof value !== "number" || !Number.isFinite(value) || value < 0) throw new Error(`Invalid ${name}`);
|
|
710
909
|
}
|
|
711
|
-
if (!
|
|
910
|
+
if (!snapshot2) {
|
|
712
911
|
throw new HostMemoryAdmissionError(
|
|
713
912
|
`[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`,
|
|
714
913
|
{
|
|
@@ -722,19 +921,19 @@ function assertHostMemoryAdmission(deps = {}) {
|
|
|
722
921
|
}
|
|
723
922
|
);
|
|
724
923
|
}
|
|
725
|
-
if (!["cgroup", "proc-meminfo", "os"].includes(
|
|
924
|
+
if (!["cgroup", "proc-meminfo", "os"].includes(snapshot2.source)) throw new Error("Unknown host memory source");
|
|
726
925
|
let effectiveAvailableMb = null;
|
|
727
926
|
let limitingSource = "host";
|
|
728
|
-
if (
|
|
729
|
-
const cgroupAvail =
|
|
730
|
-
const hostAvail =
|
|
927
|
+
if (snapshot2.source === "cgroup") {
|
|
928
|
+
const cgroupAvail = snapshot2.availableMb;
|
|
929
|
+
const hostAvail = snapshot2.hostAvailableMb;
|
|
731
930
|
if (cgroupAvail === null || typeof cgroupAvail !== "number" || Number.isNaN(cgroupAvail) || !Number.isFinite(cgroupAvail) || cgroupAvail < 0) {
|
|
732
931
|
throw new HostMemoryAdmissionError(
|
|
733
932
|
`[host-memory-admission] cgroup \u914D\u989D\u5185\u5B58\u5360\u7528\u672A\u77E5\u6216\u65E0\u6548\uFF0C\u62D2\u7EDD\u65E0\u58F0\u5F53\u5145\u8DB3\u3002`,
|
|
734
933
|
{
|
|
735
934
|
effectiveAvailableMb: null,
|
|
736
935
|
requiredMinMb: minAvailableMb,
|
|
737
|
-
source:
|
|
936
|
+
source: snapshot2.source,
|
|
738
937
|
limitingSource: "cgroup",
|
|
739
938
|
activeStartupRuns: 0,
|
|
740
939
|
reservedStartupMb: 0,
|
|
@@ -746,7 +945,7 @@ function assertHostMemoryAdmission(deps = {}) {
|
|
|
746
945
|
throw new HostMemoryAdmissionError("[host-memory-admission] \u5BBF\u4E3B\u53EF\u7528\u5185\u5B58\u672A\u77E5\u6216\u65E0\u6548\uFF0C\u62D2\u7EDD\u672C\u5730 fork\u3002", {
|
|
747
946
|
effectiveAvailableMb: null,
|
|
748
947
|
requiredMinMb: minAvailableMb,
|
|
749
|
-
source:
|
|
948
|
+
source: snapshot2.source,
|
|
750
949
|
limitingSource: "host",
|
|
751
950
|
activeStartupRuns: 0,
|
|
752
951
|
reservedStartupMb: 0,
|
|
@@ -766,13 +965,13 @@ function assertHostMemoryAdmission(deps = {}) {
|
|
|
766
965
|
limitingSource = "cgroup";
|
|
767
966
|
}
|
|
768
967
|
} else {
|
|
769
|
-
if (
|
|
968
|
+
if (snapshot2.availableMb === null || typeof snapshot2.availableMb !== "number" || Number.isNaN(snapshot2.availableMb) || !Number.isFinite(snapshot2.availableMb) || snapshot2.availableMb < 0) {
|
|
770
969
|
throw new HostMemoryAdmissionError(
|
|
771
970
|
`[host-memory-admission] \u5BBF\u4E3B\u53EF\u7528\u5185\u5B58\u672A\u77E5\u6216\u65E0\u6548\uFF0C\u62D2\u7EDD\u65E0\u58F0\u5F53\u5145\u8DB3\u3002`,
|
|
772
971
|
{
|
|
773
972
|
effectiveAvailableMb: null,
|
|
774
973
|
requiredMinMb: minAvailableMb,
|
|
775
|
-
source:
|
|
974
|
+
source: snapshot2.source,
|
|
776
975
|
limitingSource: "host",
|
|
777
976
|
activeStartupRuns: 0,
|
|
778
977
|
reservedStartupMb: 0,
|
|
@@ -780,7 +979,7 @@ function assertHostMemoryAdmission(deps = {}) {
|
|
|
780
979
|
}
|
|
781
980
|
);
|
|
782
981
|
}
|
|
783
|
-
effectiveAvailableMb =
|
|
982
|
+
effectiveAvailableMb = snapshot2.availableMb;
|
|
784
983
|
limitingSource = "host";
|
|
785
984
|
}
|
|
786
985
|
let activeStartupRuns = 0;
|
|
@@ -792,7 +991,7 @@ function assertHostMemoryAdmission(deps = {}) {
|
|
|
792
991
|
{
|
|
793
992
|
effectiveAvailableMb,
|
|
794
993
|
requiredMinMb: minAvailableMb,
|
|
795
|
-
source:
|
|
994
|
+
source: snapshot2.source,
|
|
796
995
|
limitingSource,
|
|
797
996
|
activeStartupRuns: 0,
|
|
798
997
|
reservedStartupMb: 0,
|
|
@@ -807,7 +1006,7 @@ function assertHostMemoryAdmission(deps = {}) {
|
|
|
807
1006
|
{
|
|
808
1007
|
effectiveAvailableMb,
|
|
809
1008
|
requiredMinMb: minAvailableMb,
|
|
810
|
-
source:
|
|
1009
|
+
source: snapshot2.source,
|
|
811
1010
|
limitingSource,
|
|
812
1011
|
activeStartupRuns: 0,
|
|
813
1012
|
reservedStartupMb: 0,
|
|
@@ -823,7 +1022,7 @@ function assertHostMemoryAdmission(deps = {}) {
|
|
|
823
1022
|
{
|
|
824
1023
|
effectiveAvailableMb,
|
|
825
1024
|
requiredMinMb: minAvailableMb,
|
|
826
|
-
source:
|
|
1025
|
+
source: snapshot2.source,
|
|
827
1026
|
limitingSource,
|
|
828
1027
|
activeStartupRuns: 0,
|
|
829
1028
|
reservedStartupMb: 0,
|
|
@@ -845,7 +1044,7 @@ function assertHostMemoryAdmission(deps = {}) {
|
|
|
845
1044
|
{
|
|
846
1045
|
effectiveAvailableMb: netAvailableMb,
|
|
847
1046
|
requiredMinMb: minAvailableMb,
|
|
848
|
-
source:
|
|
1047
|
+
source: snapshot2.source,
|
|
849
1048
|
limitingSource,
|
|
850
1049
|
activeStartupRuns,
|
|
851
1050
|
reservedStartupMb,
|
|
@@ -858,7 +1057,7 @@ function assertHostMemoryAdmission(deps = {}) {
|
|
|
858
1057
|
effectiveAvailableMb: netAvailableMb,
|
|
859
1058
|
requiredMinMb: minAvailableMb,
|
|
860
1059
|
activeStartupRuns,
|
|
861
|
-
snapshot
|
|
1060
|
+
snapshot: snapshot2
|
|
862
1061
|
};
|
|
863
1062
|
}
|
|
864
1063
|
|
|
@@ -1152,11 +1351,6 @@ ${lines.join("\n")}
|
|
|
1152
1351
|
function buildResultFileContent(input, body) {
|
|
1153
1352
|
return `${buildResultFrontMatter(input)}${body}`;
|
|
1154
1353
|
}
|
|
1155
|
-
var RESULT_FRONT_MATTER_RE = /^---\nrunId: [^\n]*\n(?:[^\n]*\n)*?---\n/;
|
|
1156
|
-
function stripResultFrontMatter(text) {
|
|
1157
|
-
const match = RESULT_FRONT_MATTER_RE.exec(text);
|
|
1158
|
-
return match ? text.slice(match[0].length) : text;
|
|
1159
|
-
}
|
|
1160
1354
|
|
|
1161
1355
|
// packages/ai/tools/agent/runFailureClass.ts
|
|
1162
1356
|
function isHistoryIntegrityFailure(message) {
|
|
@@ -2027,6 +2221,70 @@ function listRunRecords(deps = {}) {
|
|
|
2027
2221
|
(a, b) => new Date(b.startedAt).getTime() - new Date(a.startedAt).getTime()
|
|
2028
2222
|
);
|
|
2029
2223
|
}
|
|
2224
|
+
function listRecentRunRecords(deps = {}) {
|
|
2225
|
+
const limit = deps.limit ?? 400;
|
|
2226
|
+
if (!Number.isFinite(limit) || limit <= 0) return [];
|
|
2227
|
+
const fs = deps.fs ?? nodeFs2;
|
|
2228
|
+
const dir = resolveRunsDir(deps.env, deps.homedir);
|
|
2229
|
+
let entries = [];
|
|
2230
|
+
try {
|
|
2231
|
+
entries = fs.readdirSync(dir);
|
|
2232
|
+
} catch {
|
|
2233
|
+
return [];
|
|
2234
|
+
}
|
|
2235
|
+
const timestampedRuns = [];
|
|
2236
|
+
const customRuns = [];
|
|
2237
|
+
for (const entry of entries) {
|
|
2238
|
+
if (!entry.endsWith(".json") || entry.startsWith("acked-") || entry.startsWith("busy-ack-") || entry.endsWith(".isolation.json") || entry.includes(".result.")) {
|
|
2239
|
+
continue;
|
|
2240
|
+
}
|
|
2241
|
+
if (entry.startsWith("run-")) {
|
|
2242
|
+
timestampedRuns.push(entry);
|
|
2243
|
+
} else {
|
|
2244
|
+
customRuns.push(entry);
|
|
2245
|
+
}
|
|
2246
|
+
}
|
|
2247
|
+
timestampedRuns.sort((a, b) => a < b ? 1 : a > b ? -1 : 0);
|
|
2248
|
+
const candidates = timestampedRuns.length >= limit ? timestampedRuns : [...timestampedRuns, ...customRuns.sort((a, b) => a < b ? 1 : a > b ? -1 : 0)];
|
|
2249
|
+
const records = [];
|
|
2250
|
+
for (const entry of candidates) {
|
|
2251
|
+
if (records.length >= limit) break;
|
|
2252
|
+
const runId = entry.slice(0, -".json".length);
|
|
2253
|
+
const record = readRunRecord(runId, deps);
|
|
2254
|
+
if (record) records.push(record);
|
|
2255
|
+
}
|
|
2256
|
+
return records.sort(
|
|
2257
|
+
(a, b) => new Date(b.startedAt).getTime() - new Date(a.startedAt).getTime()
|
|
2258
|
+
);
|
|
2259
|
+
}
|
|
2260
|
+
async function listRunRecordsAsync(deps = {}) {
|
|
2261
|
+
const dir = resolveRunsDir(deps.env, deps.homedir);
|
|
2262
|
+
let entries;
|
|
2263
|
+
try {
|
|
2264
|
+
entries = await nodeFs2.promises.readdir(dir);
|
|
2265
|
+
} catch {
|
|
2266
|
+
return [];
|
|
2267
|
+
}
|
|
2268
|
+
const records = new Array(entries.length);
|
|
2269
|
+
let next = 0;
|
|
2270
|
+
const readNext = async () => {
|
|
2271
|
+
while (next < entries.length) {
|
|
2272
|
+
const index = next++;
|
|
2273
|
+
const entry = entries[index];
|
|
2274
|
+
if (!entry.endsWith(".json")) continue;
|
|
2275
|
+
const path = resolveRunRecordPath(entry.slice(0, -5), deps.env, deps.homedir);
|
|
2276
|
+
for (let attempt = 0; attempt < 2; attempt++) {
|
|
2277
|
+
try {
|
|
2278
|
+
records[index] = JSON.parse(await nodeFs2.promises.readFile(path, "utf8"));
|
|
2279
|
+
break;
|
|
2280
|
+
} catch {
|
|
2281
|
+
}
|
|
2282
|
+
}
|
|
2283
|
+
}
|
|
2284
|
+
};
|
|
2285
|
+
await Promise.all(Array.from({ length: Math.min(16, entries.length) }, readNext));
|
|
2286
|
+
return records.filter((record) => Boolean(record)).sort((a, b) => new Date(b.startedAt).getTime() - new Date(a.startedAt).getTime());
|
|
2287
|
+
}
|
|
2030
2288
|
function findRunRecordByPid(pid, deps = {}) {
|
|
2031
2289
|
return listRunRecords(deps).find((record) => record.pid === pid);
|
|
2032
2290
|
}
|
|
@@ -2131,7 +2389,7 @@ async function gcRunRecords(deps = {}, options = {}) {
|
|
|
2131
2389
|
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");
|
|
2132
2390
|
if (!fs.existsSync(artifact.path)) continue;
|
|
2133
2391
|
const stat = fs.lstatSync?.(artifact.path);
|
|
2134
|
-
if (!stat || !stat.isFile() || stat.isSymbolicLink() || fs.realpathSync?.(artifact.path) !== resolve(artifact.path) || String(stat.dev) !== artifact.dev || String(stat.ino) !== artifact.ino ||
|
|
2392
|
+
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) {
|
|
2135
2393
|
throw new Error("artifact identity changed");
|
|
2136
2394
|
}
|
|
2137
2395
|
if (!tryUnlinkFile(fs, artifact.path)) artifactsOk = false;
|
|
@@ -2220,38 +2478,22 @@ function rewriteMsgFileArg(args, messagePath) {
|
|
|
2220
2478
|
return result;
|
|
2221
2479
|
}
|
|
2222
2480
|
function resolveValidCliEntrypoint(cliEntrypointPath, fs = nodeFs2) {
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
const fallback = resolveCliEntrypointPath();
|
|
2227
|
-
if (fs.existsSync(fallback)) {
|
|
2228
|
-
return fallback;
|
|
2229
|
-
}
|
|
2230
|
-
const candidates = [
|
|
2231
|
-
join2(dirname(fallback), "cli", "index.ts"),
|
|
2232
|
-
join2(dirname(fallback), "cli", "index.js"),
|
|
2233
|
-
join2(dirname(fallback), "..", "packages", "cli", "index.ts"),
|
|
2234
|
-
join2(dirname(fallback), "..", "packages", "cli", "index.js"),
|
|
2235
|
-
join2(dirname(fallback), "..", "index.js")
|
|
2236
|
-
];
|
|
2237
|
-
for (const cand of candidates) {
|
|
2238
|
-
if (fs.existsSync(cand)) {
|
|
2239
|
-
return cand;
|
|
2240
|
-
}
|
|
2241
|
-
}
|
|
2242
|
-
return fallback;
|
|
2481
|
+
const entrypoint = cliEntrypointPath ?? resolveCliEntrypointPath();
|
|
2482
|
+
if (!fs.existsSync(entrypoint)) throw new RuntimeVersionMismatchError("runtime entrypoint missing");
|
|
2483
|
+
return fs === nodeFs2 ? resolveExactRuntimeEntrypoint(entrypoint) : String(fs.realpathSync?.(entrypoint) ?? entrypoint);
|
|
2243
2484
|
}
|
|
2244
2485
|
function buildAgentRunChildCommand(options, deps = {}) {
|
|
2245
2486
|
const fs = deps.fs ?? nodeFs2;
|
|
2246
|
-
const execPath =
|
|
2487
|
+
const execPath = getHostRuntimeExecutable();
|
|
2247
2488
|
const commandParts = options.commandPath ?? [];
|
|
2248
2489
|
let strippedArgs = stripBackgroundFlag(options.rawArgs);
|
|
2249
2490
|
if (options.messagePath) {
|
|
2250
2491
|
strippedArgs = rewriteMsgFileArg(strippedArgs, options.messagePath);
|
|
2251
2492
|
}
|
|
2252
2493
|
strippedArgs = absolutizeSkillArgs(strippedArgs);
|
|
2253
|
-
if (isCompiledBinary() || options.cliEntrypointPath === execPath) {
|
|
2254
|
-
|
|
2494
|
+
if (isCompiledBinary() || options.cliEntrypointPath === process.execPath || options.cliEntrypointPath === execPath) {
|
|
2495
|
+
const fixed = resolveValidCliEntrypoint(isCompiledBinary() ? execPath : options.cliEntrypointPath ?? execPath, fs);
|
|
2496
|
+
return { execPath: fixed, childArgs: [...commandParts, ...strippedArgs] };
|
|
2255
2497
|
}
|
|
2256
2498
|
const entrypoint = resolveValidCliEntrypoint(options.cliEntrypointPath, fs);
|
|
2257
2499
|
if (entrypoint === execPath) {
|
|
@@ -2329,11 +2571,11 @@ function localWriterRecovery(record) {
|
|
|
2329
2571
|
function revokePreparedWriterLaunch(runId, attemptId, deps = {}) {
|
|
2330
2572
|
if (!/^[A-Za-z0-9_-]+$/.test(runId) || !attemptId) return "blocked";
|
|
2331
2573
|
return withRunRecordLock("local-writer-admission", deps, () => {
|
|
2332
|
-
const
|
|
2333
|
-
if (!
|
|
2574
|
+
const snapshot2 = readRunRecord(runId, deps);
|
|
2575
|
+
if (!snapshot2) return "blocked";
|
|
2334
2576
|
return withRunRecordLock(runId, deps, () => {
|
|
2335
2577
|
const latest = readRunRecord(runId, deps);
|
|
2336
|
-
if (!latest || JSON.stringify(latest) !== JSON.stringify(
|
|
2578
|
+
if (!latest || JSON.stringify(latest) !== JSON.stringify(snapshot2)) return "blocked";
|
|
2337
2579
|
const launch = latest.writerLaunch;
|
|
2338
2580
|
if (launch?.protocol !== "fenced-launch-v1" || launch.attemptId !== attemptId) return "blocked";
|
|
2339
2581
|
if (launch.phase === "revoked") return latest.localWriterClaim?.state === "released" ? "already-revoked" : "blocked";
|
|
@@ -2352,10 +2594,10 @@ function localWriterStillOwns(record, deps) {
|
|
|
2352
2594
|
const observed = e?.state === "known" && e.owner.state === "verified" ? nativeOwner(record.pid, deps) : void 0;
|
|
2353
2595
|
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));
|
|
2354
2596
|
if (!isPidGone(record.pid, deps) && !reused) return true;
|
|
2355
|
-
const
|
|
2597
|
+
const snapshot2 = JSON.stringify(record);
|
|
2356
2598
|
const released = withRunRecordLock(record.runId, deps, () => {
|
|
2357
2599
|
const latest = readRunRecord(record.runId, deps);
|
|
2358
|
-
if (!latest || JSON.stringify(latest) !==
|
|
2600
|
+
if (!latest || JSON.stringify(latest) !== snapshot2) return false;
|
|
2359
2601
|
latest.localWriterClaim.state = "released";
|
|
2360
2602
|
writeRunRecord(latest, deps);
|
|
2361
2603
|
return true;
|
|
@@ -2364,14 +2606,14 @@ function localWriterStillOwns(record, deps) {
|
|
|
2364
2606
|
}
|
|
2365
2607
|
function acquireLocalWriterClaim(runId, cwd, deps) {
|
|
2366
2608
|
const fs = deps.fs ?? nodeFs2;
|
|
2367
|
-
const
|
|
2368
|
-
const worktree = trustedLocalWorktree(
|
|
2609
|
+
const canonical2 = String((fs.realpathSync ?? nodeFs2.realpathSync)(cwd));
|
|
2610
|
+
const worktree = trustedLocalWorktree(canonical2, deps);
|
|
2369
2611
|
const acquired = withRunRecordLock("local-writer-admission", deps, () => {
|
|
2370
2612
|
const updated = withRunRecordLock(runId, deps, () => {
|
|
2371
2613
|
const record = readRunRecord(runId, deps);
|
|
2372
2614
|
if (!record) throw new Error(`[local-writer-resource] missing run ${runId}`);
|
|
2373
2615
|
if (record.writerLaunch?.phase === "revoked") throw new Error("[local-writer-resource] claim attempt revoked");
|
|
2374
|
-
record.localWriterClaim = { cwd:
|
|
2616
|
+
record.localWriterClaim = { cwd: canonical2, ...worktree ? { worktree } : {}, state: "held" };
|
|
2375
2617
|
if (record.writerLaunch && record.execution?.state === "known" && record.execution.owner.state === "verified" && record.pid === process.pid) {
|
|
2376
2618
|
record.writerLaunch.phase = "granted";
|
|
2377
2619
|
}
|
|
@@ -2382,7 +2624,7 @@ function acquireLocalWriterClaim(runId, cwd, deps) {
|
|
|
2382
2624
|
return true;
|
|
2383
2625
|
}, { strict: true, requireDeadOwner: true });
|
|
2384
2626
|
if (!acquired) throw new Error("[local-writer-resource] admission lock busy; no child spawned");
|
|
2385
|
-
return
|
|
2627
|
+
return canonical2;
|
|
2386
2628
|
}
|
|
2387
2629
|
function nativeOwner(pid, deps) {
|
|
2388
2630
|
const first = probeProcessStartTime(pid, deps);
|
|
@@ -2482,19 +2724,19 @@ function resolveLocalContinuation(record, deps = {}) {
|
|
|
2482
2724
|
}
|
|
2483
2725
|
function registerLocalForegroundWriter(cwd, policy, agentKey, deps = {}) {
|
|
2484
2726
|
const fs = deps.fs ?? nodeFs2;
|
|
2485
|
-
const
|
|
2727
|
+
const canonical2 = String((fs.realpathSync ?? nodeFs2.realpathSync)(cwd));
|
|
2486
2728
|
const owner = nativeOwner(process.pid, deps);
|
|
2487
2729
|
if (owner.state !== "verified" || policy.readOnly || !policy.hostWritesAuthorized) {
|
|
2488
2730
|
throw new Error("[local-writer-resource] foreground native identity/authorization unknown");
|
|
2489
2731
|
}
|
|
2490
2732
|
const runId = defaultGenerateRunId();
|
|
2491
2733
|
fs.mkdirSync(resolveRunsDir(deps.env, deps.homedir), { recursive: true });
|
|
2492
|
-
const worktree = trustedLocalWorktree(
|
|
2734
|
+
const worktree = trustedLocalWorktree(canonical2, deps);
|
|
2493
2735
|
const record = {
|
|
2494
2736
|
runId,
|
|
2495
2737
|
agentKey,
|
|
2496
|
-
writerLaunch: { protocol: "fenced-launch-v1", attemptId:
|
|
2497
|
-
cwd:
|
|
2738
|
+
writerLaunch: { protocol: "fenced-launch-v1", attemptId: randomUUID3(), phase: "prepared" },
|
|
2739
|
+
cwd: canonical2,
|
|
2498
2740
|
startedAt: (deps.now?.() ?? /* @__PURE__ */ new Date()).toISOString(),
|
|
2499
2741
|
status: "running",
|
|
2500
2742
|
logPath: resolveRunLogPath(runId, deps.env, deps.homedir),
|
|
@@ -2505,7 +2747,7 @@ function registerLocalForegroundWriter(cwd, policy, agentKey, deps = {}) {
|
|
|
2505
2747
|
state: "known",
|
|
2506
2748
|
kind: "host-local",
|
|
2507
2749
|
runtimeKey: "local",
|
|
2508
|
-
canonicalCwd:
|
|
2750
|
+
canonicalCwd: canonical2,
|
|
2509
2751
|
device: { kind: "localhost", hostname: nodeHostname(), platform: process.platform },
|
|
2510
2752
|
...worktree ? { worktree } : {},
|
|
2511
2753
|
permissions: {
|
|
@@ -2520,7 +2762,7 @@ function registerLocalForegroundWriter(cwd, policy, agentKey, deps = {}) {
|
|
|
2520
2762
|
};
|
|
2521
2763
|
writeRunRecord(record, deps);
|
|
2522
2764
|
try {
|
|
2523
|
-
acquireLocalWriterClaim(runId,
|
|
2765
|
+
acquireLocalWriterClaim(runId, canonical2, deps);
|
|
2524
2766
|
} catch (error) {
|
|
2525
2767
|
finalizeRunRecord(runId, { status: "failed", exitCode: 1, note: String(error) }, deps);
|
|
2526
2768
|
throw error;
|
|
@@ -2539,6 +2781,48 @@ function releaseUnspawnedLocalWriterClaim(runId, deps) {
|
|
|
2539
2781
|
}, { strict: true });
|
|
2540
2782
|
if (!released) throw new Error(`[local-writer-resource] release lock busy: ${runId}`);
|
|
2541
2783
|
}
|
|
2784
|
+
async function recordRunStartup(runId, phase, deps = {}) {
|
|
2785
|
+
const attempt = () => withRunRecordLock(runId, deps, () => {
|
|
2786
|
+
const record = readRunRecord(runId, deps);
|
|
2787
|
+
if (!record || isRunTerminalStatus(record.status)) return true;
|
|
2788
|
+
record.startup = { protocol: AGENT_RUN_PROTOCOL, phase };
|
|
2789
|
+
writeRunRecord(record, deps);
|
|
2790
|
+
return true;
|
|
2791
|
+
}, { strict: true });
|
|
2792
|
+
const deadline = Date.now() + 2e3;
|
|
2793
|
+
while (!attempt()) {
|
|
2794
|
+
if (Date.now() >= deadline) throw new Error(`Startup evidence lock busy: ${runId}`);
|
|
2795
|
+
await new Promise((resolve2) => setTimeout(resolve2, 20));
|
|
2796
|
+
}
|
|
2797
|
+
}
|
|
2798
|
+
async function settleBackgroundProcessExit(runId, code, signal, deps = {}) {
|
|
2799
|
+
const deadline = Date.now() + 2e3;
|
|
2800
|
+
while (true) {
|
|
2801
|
+
const settled = withRunRecordLock(runId, deps, () => {
|
|
2802
|
+
const record = readRunRecord(runId, deps);
|
|
2803
|
+
if (!record) return true;
|
|
2804
|
+
if (isRunTerminalStatus(record.status)) {
|
|
2805
|
+
record.processExit = { code, signal };
|
|
2806
|
+
writeRunRecord(record, deps);
|
|
2807
|
+
return true;
|
|
2808
|
+
}
|
|
2809
|
+
return false;
|
|
2810
|
+
}, { strict: true });
|
|
2811
|
+
if (settled === true) return;
|
|
2812
|
+
if (settled === false) {
|
|
2813
|
+
const result = transitionRunToTerminal(runId, {
|
|
2814
|
+
status: signal === "SIGTERM" || signal === "SIGKILL" ? "killed" : "failed",
|
|
2815
|
+
exitCode: code ?? 1,
|
|
2816
|
+
processExit: { code, signal },
|
|
2817
|
+
failureReason: signal === "SIGTERM" || signal === "SIGKILL" ? "cancelled" : "startup_failed",
|
|
2818
|
+
note: `Child exited without terminal result (code=${code}, signal=${signal})`
|
|
2819
|
+
}, deps);
|
|
2820
|
+
if (result.kind !== "contended") return;
|
|
2821
|
+
}
|
|
2822
|
+
if (Date.now() >= deadline) throw new Error(`Process exit settlement lock busy: ${runId}`);
|
|
2823
|
+
await (deps.sleep ?? defaultSleep)(20);
|
|
2824
|
+
}
|
|
2825
|
+
}
|
|
2542
2826
|
async function spawnLocalBackgroundRun(input, deps = {}) {
|
|
2543
2827
|
const homedir = deps.homedir ?? nodeHomedir;
|
|
2544
2828
|
const env = deps.env ?? (deps.homedir ? { ...process.env, NOLO_HOME: join2(homedir(), ".nolo") } : process.env);
|
|
@@ -2611,12 +2895,13 @@ async function spawnLocalBackgroundRun(input, deps = {}) {
|
|
|
2611
2895
|
...input.evidenceScope ? { evidenceScope: input.evidenceScope } : {},
|
|
2612
2896
|
...input.dispatchSpeedProvenance ? { dispatchSpeedProvenance: input.dispatchSpeedProvenance } : {},
|
|
2613
2897
|
runId,
|
|
2898
|
+
startup: { protocol: AGENT_RUN_PROTOCOL, phase: "spawn" },
|
|
2614
2899
|
agentKey: input.agentKey,
|
|
2615
2900
|
agentName: input.agentName?.trim() || shortAgentKey(input.agentKey),
|
|
2616
2901
|
...title ? { title } : {},
|
|
2617
2902
|
cwd: canonicalCwd ?? input.cwd,
|
|
2618
2903
|
execution,
|
|
2619
|
-
...executionRequest ? { writerLaunch: { protocol: "fenced-launch-v1", attemptId:
|
|
2904
|
+
...executionRequest ? { writerLaunch: { protocol: "fenced-launch-v1", attemptId: randomUUID3(), phase: "prepared" } } : {},
|
|
2620
2905
|
...executionRequest ? (() => {
|
|
2621
2906
|
const parent = nativeOwner(process.pid, resolvedDeps);
|
|
2622
2907
|
return parent.state === "verified" ? { ownerPublication: { state: "pending", parent } } : {};
|
|
@@ -2641,17 +2926,32 @@ async function spawnLocalBackgroundRun(input, deps = {}) {
|
|
|
2641
2926
|
const rawArgsWithQueue = (input.rawArgs ?? []).some(
|
|
2642
2927
|
(arg) => arg === "--queue-file" || arg.startsWith("--queue-file=")
|
|
2643
2928
|
) ? input.rawArgs : [...input.rawArgs ?? [], "--queue-file", queuePath];
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2929
|
+
let childCommand;
|
|
2930
|
+
try {
|
|
2931
|
+
childCommand = buildAgentRunChildCommand(
|
|
2932
|
+
{
|
|
2933
|
+
rawArgs: rawArgsWithQueue,
|
|
2934
|
+
commandPath: input.commandPath,
|
|
2935
|
+
cliEntrypointPath: input.cliEntrypointPath,
|
|
2936
|
+
messagePath
|
|
2937
|
+
},
|
|
2938
|
+
deps
|
|
2939
|
+
);
|
|
2940
|
+
} catch (error) {
|
|
2941
|
+
const result = await settleRunTerminalAuthoritatively(runId, {
|
|
2942
|
+
status: "failed",
|
|
2943
|
+
exitCode: 1,
|
|
2944
|
+
failureReason: error instanceof RuntimeVersionMismatchError ? "runtime_version_mismatch" : "startup_failed",
|
|
2945
|
+
note: String(error)
|
|
2946
|
+
}, resolvedDeps, (id, update, d) => transitionRunToTerminal(id, update, d));
|
|
2947
|
+
if (result.kind === "contended") throw new Error(`Startup settlement lock busy: ${runId}; ${error}`);
|
|
2948
|
+
throw error;
|
|
2949
|
+
}
|
|
2950
|
+
const { execPath, childArgs } = childCommand;
|
|
2653
2951
|
const childEnv = {
|
|
2654
2952
|
...env,
|
|
2953
|
+
NOLO_AGENT_RUN_PROTOCOL: AGENT_RUN_PROTOCOL,
|
|
2954
|
+
NOLO_AGENT_RUN_CONTENT_IDENTITY: HOST_RUNTIME_CONTENT_IDENTITY,
|
|
2655
2955
|
NOLO_AGENT_RUN_CHILD: "1",
|
|
2656
2956
|
NOLO_AGENT_RUN_ID: runId,
|
|
2657
2957
|
...record.writerLaunch ? { NOLO_WRITER_LAUNCH_ATTEMPT: record.writerLaunch.attemptId } : {}
|
|
@@ -2697,31 +2997,49 @@ async function spawnLocalBackgroundRun(input, deps = {}) {
|
|
|
2697
2997
|
detached: true,
|
|
2698
2998
|
// Detached on Windows means no console; hide the one its children would create.
|
|
2699
2999
|
windowsHide: true,
|
|
2700
|
-
stdio: deps.shellApprovalHost ? ["ignore", logFd, logFd, "ipc"] : ["ignore", logFd, logFd]
|
|
3000
|
+
stdio: deps.shellApprovalHost || deps.mcpApprovalHost ? ["ignore", logFd, logFd, "ipc"] : ["ignore", logFd, logFd]
|
|
2701
3001
|
});
|
|
2702
3002
|
} catch (error) {
|
|
2703
3003
|
try {
|
|
2704
3004
|
reservation?.release("spawn_sync_failed");
|
|
2705
3005
|
if (input.claimLocalWrites) releaseUnspawnedLocalWriterClaim(runId, resolvedDeps);
|
|
2706
3006
|
} finally {
|
|
2707
|
-
finalizeRunRecord(runId, { status: "failed", exitCode: 1, note: String(error) }, resolvedDeps);
|
|
3007
|
+
finalizeRunRecord(runId, { status: "failed", exitCode: 1, failureReason: error instanceof RuntimeVersionMismatchError ? "runtime_version_mismatch" : "startup_failed", note: String(error) }, resolvedDeps);
|
|
2708
3008
|
}
|
|
2709
3009
|
throw error;
|
|
2710
3010
|
} finally {
|
|
2711
3011
|
fs.closeSync?.(logFd);
|
|
2712
3012
|
}
|
|
2713
3013
|
proc.once?.("error", (error) => {
|
|
3014
|
+
let note = String(error);
|
|
2714
3015
|
try {
|
|
2715
3016
|
reservation.release("child_error");
|
|
2716
3017
|
} catch (releaseError) {
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
3018
|
+
note += `; reservation release failed: ${releaseError}`;
|
|
3019
|
+
}
|
|
3020
|
+
void settleRunTerminalAuthoritatively(runId, {
|
|
3021
|
+
status: "failed",
|
|
3022
|
+
exitCode: 1,
|
|
3023
|
+
failureReason: "startup_failed",
|
|
3024
|
+
note
|
|
3025
|
+
}, resolvedDeps, (id, update, d) => transitionRunToTerminal(id, update, d)).then((result) => {
|
|
3026
|
+
if (result.kind === "contended") throw new Error(`Startup settlement lock busy: ${runId}`);
|
|
3027
|
+
}).catch((error2) => {
|
|
3028
|
+
input.output?.write(`[nolo] background error settlement failed: ${error2}
|
|
3029
|
+
`);
|
|
3030
|
+
});
|
|
3031
|
+
});
|
|
3032
|
+
proc.once?.("exit", (code, signal) => {
|
|
3033
|
+
void settleBackgroundProcessExit(runId, code, signal, resolvedDeps).catch((error) => {
|
|
3034
|
+
input.output?.write(`[nolo] background exit settlement failed: ${error}
|
|
3035
|
+
`);
|
|
3036
|
+
});
|
|
3037
|
+
try {
|
|
3038
|
+
reservation.release("child_exit");
|
|
3039
|
+
} catch (error) {
|
|
3040
|
+
input.output?.write(`[nolo] reservation release failed: ${error}
|
|
3041
|
+
`);
|
|
2723
3042
|
}
|
|
2724
|
-
finalizeRunRecord(runId, { status: "failed", exitCode: 1, note: String(error) }, resolvedDeps);
|
|
2725
3043
|
});
|
|
2726
3044
|
const hostMemoryNotice = emitHostMemoryNotice(hostMemory, input.output);
|
|
2727
3045
|
if (typeof proc.pid === "number") {
|
|
@@ -2783,6 +3101,15 @@ async function spawnLocalBackgroundRun(input, deps = {}) {
|
|
|
2783
3101
|
throw new Error(`[host-memory-reservation] child ${proc.pid}, run ${runId}: association failed: ${error}`);
|
|
2784
3102
|
}
|
|
2785
3103
|
}
|
|
3104
|
+
if (deps.mcpApprovalHost) {
|
|
3105
|
+
attachMcpApprovalHost(proc, { ...deps.mcpApprovalHost, binding: {
|
|
3106
|
+
...deps.mcpApprovalHost.binding,
|
|
3107
|
+
runId,
|
|
3108
|
+
agentKey: input.agentKey,
|
|
3109
|
+
workspaceRoot: nodeFs2.realpathSync(input.cwd ?? process.cwd())
|
|
3110
|
+
} });
|
|
3111
|
+
proc.channel?.unref?.();
|
|
3112
|
+
}
|
|
2786
3113
|
if (deps.shellApprovalHost) {
|
|
2787
3114
|
attachShellApprovalHost(proc, { ...deps.shellApprovalHost, binding: {
|
|
2788
3115
|
...deps.shellApprovalHost.binding,
|
|
@@ -2876,10 +3203,15 @@ function transitionRunToTerminal(runId, update, deps = {}, options = {}) {
|
|
|
2876
3203
|
if (!record2) return { kind: "not_found" };
|
|
2877
3204
|
const orphanCorrection = options.allowOverOrphaned === true && record2.status === "orphaned" && (update.status === "done" || update.status === "failed");
|
|
2878
3205
|
if (isAgentRunTerminalStatus(record2.status) && !orphanCorrection) {
|
|
3206
|
+
if (update.processExit) {
|
|
3207
|
+
record2.processExit = update.processExit;
|
|
3208
|
+
writeRunRecord(record2, deps);
|
|
3209
|
+
}
|
|
2879
3210
|
return { kind: "kept", record: record2 };
|
|
2880
3211
|
}
|
|
2881
3212
|
const now = deps.now ?? (() => /* @__PURE__ */ new Date());
|
|
2882
3213
|
record2.status = update.status;
|
|
3214
|
+
if (update.processExit) record2.processExit = update.processExit;
|
|
2883
3215
|
if (typeof update.exitCode === "number") record2.exitCode = update.exitCode;
|
|
2884
3216
|
if (update.dialogId) record2.dialogId = update.dialogId;
|
|
2885
3217
|
if (typeof update.credits === "number" && Number.isFinite(update.credits)) {
|
|
@@ -2929,11 +3261,11 @@ function transitionRunToTerminal(runId, update, deps = {}, options = {}) {
|
|
|
2929
3261
|
kind,
|
|
2930
3262
|
dev: String(stat.dev),
|
|
2931
3263
|
ino: String(stat.ino),
|
|
2932
|
-
sha256:
|
|
3264
|
+
sha256: createHash2("sha256").update(fs.readFileSync(path)).digest("hex")
|
|
2933
3265
|
};
|
|
2934
3266
|
record2.resultArtifacts = [...(record2.resultArtifacts ?? []).filter((a) => a.path !== path), artifact];
|
|
2935
3267
|
};
|
|
2936
|
-
if (typeof update.lastAssistantText === "string" && update.lastAssistantText || update.acceptance?.checks.observations?.length) {
|
|
3268
|
+
if (typeof update.lastAssistantText === "string" && update.lastAssistantText || update.acceptance?.checks.observations?.length || update.failureReason === "startup_failed" || update.failureReason === "runtime_protocol_mismatch" || update.failureReason === "runtime_version_mismatch") {
|
|
2937
3269
|
try {
|
|
2938
3270
|
const fs = deps.fs ?? nodeFs2;
|
|
2939
3271
|
const resultFile = join2(resolveRunsDir(deps.env, deps.homedir), `${runId}.result.md`);
|
|
@@ -2960,7 +3292,7 @@ function transitionRunToTerminal(runId, update, deps = {}, options = {}) {
|
|
|
2960
3292
|
update.lastAssistantText ?? ""
|
|
2961
3293
|
);
|
|
2962
3294
|
if (typeof fs.renameSync !== "function") throw new Error("atomic result publication requires renameSync");
|
|
2963
|
-
pendingResultFile = `${resultFile}.${
|
|
3295
|
+
pendingResultFile = `${resultFile}.${randomUUID3()}.pending`;
|
|
2964
3296
|
try {
|
|
2965
3297
|
fs.writeFileSync(pendingResultFile, content, { encoding: "utf8", flag: "wx" });
|
|
2966
3298
|
stagingComplete = true;
|
|
@@ -2969,7 +3301,7 @@ function transitionRunToTerminal(runId, update, deps = {}, options = {}) {
|
|
|
2969
3301
|
}
|
|
2970
3302
|
if (fs.existsSync(resultFile)) {
|
|
2971
3303
|
const previous = fs.readFileSync(resultFile);
|
|
2972
|
-
const backup = `${resultFile}.${
|
|
3304
|
+
const backup = `${resultFile}.${randomUUID3()}.bak`;
|
|
2973
3305
|
backupFile = backup;
|
|
2974
3306
|
try {
|
|
2975
3307
|
fs.writeFileSync(backup, previous, { flag: "wx" });
|
|
@@ -3638,6 +3970,8 @@ async function runAgentRecoverPreparedWriterCommand(args, deps) {
|
|
|
3638
3970
|
}
|
|
3639
3971
|
|
|
3640
3972
|
export {
|
|
3973
|
+
createMcpApprovalChild,
|
|
3974
|
+
hasLiveShellApprovalHosts,
|
|
3641
3975
|
createShellApprovalChild,
|
|
3642
3976
|
TAIL_LINES_MAX,
|
|
3643
3977
|
readHostMemory,
|
|
@@ -3646,7 +3980,6 @@ export {
|
|
|
3646
3980
|
recordRunResultHeaderMeta,
|
|
3647
3981
|
getRunResultHeaderMeta,
|
|
3648
3982
|
serverOriginForDialog,
|
|
3649
|
-
stripResultFrontMatter,
|
|
3650
3983
|
isHistoryIntegrityFailure,
|
|
3651
3984
|
RUN_TERMINAL_STATUSES,
|
|
3652
3985
|
isRunTerminalStatus,
|
|
@@ -3684,6 +4017,8 @@ export {
|
|
|
3684
4017
|
readRunRecord,
|
|
3685
4018
|
backfillRunRecordParentDialog,
|
|
3686
4019
|
listRunRecords,
|
|
4020
|
+
listRecentRunRecords,
|
|
4021
|
+
listRunRecordsAsync,
|
|
3687
4022
|
findRunRecordByPid,
|
|
3688
4023
|
findRunRecord,
|
|
3689
4024
|
DEFAULT_LIST_LIMIT,
|
|
@@ -3701,6 +4036,8 @@ export {
|
|
|
3701
4036
|
awaitLocalWriterChild,
|
|
3702
4037
|
resolveLocalContinuation,
|
|
3703
4038
|
registerLocalForegroundWriter,
|
|
4039
|
+
recordRunStartup,
|
|
4040
|
+
settleBackgroundProcessExit,
|
|
3704
4041
|
spawnLocalBackgroundRun,
|
|
3705
4042
|
ackRunRecord,
|
|
3706
4043
|
DEFAULT_ACK_LEASE_TTL_MS,
|