nolo-cli 0.228.0-alpha.1 → 0.228.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-WZKT6XEU.js → _executeModel-GIFVXKDT.js} +89 -82
- package/{accountResolver-QETKNC7T.js → accountResolver-NGICIMEE.js} +1 -1
- package/{action-GDZDXPMB.js → action-WZTKEF5H.js} +9 -6
- package/{addContentAction-7RO4AMRI.js → addContentAction-MLI6GOBV.js} +14 -13
- package/{addDialogAgentAction-EVYBGTXB.js → addDialogAgentAction-ARGQM22H.js} +17 -16
- package/{agentDeleteCommand-PZWRHNXY.js → agentDeleteCommand-UF7XVELS.js} +120 -111
- package/{agentEmailCommands-QTKMEICX.js → agentEmailCommands-SFHRPQYC.js} +120 -107
- package/agentListCommands-IXKBP3W5.js +644 -0
- package/{agentMachineCommands-7QGICJLM.js → agentMachineCommands-7NX6PWQ6.js} +56 -48
- package/{agentProviderCommands-STI3DQ6A.js → agentProviderCommands-C5T7C5KZ.js} +2 -2
- package/{agentPullCommand-KHV4EELF.js → agentPullCommand-4EQZYHU4.js} +1 -1
- package/agentRecordCommands-IUNX6XD6.js +188 -0
- package/{agentRunCommand-OFQLOF5Y.js → agentRunCommand-LCR4XADM.js} +127 -111
- package/{agentRunControl-MBG4U6SL.js → agentRunControl-RN2P6AOD.js} +11 -9
- package/{agentRuntimeLocal-TU4LA353.js → agentRuntimeLocal-LVXPQ7QA.js} +57 -43
- package/{agentSlice-L4SBGWTB.js → agentSlice-ZGMOH6TE.js} +15 -14
- package/{appDeleteCommands-JWP3XPUA.js → appDeleteCommands-BESCJOQM.js} +56 -48
- package/{appDeployCommands-6E4TQCWI.js → appDeployCommands-LPTR6IOX.js} +56 -48
- package/{appDeployStatusCommands-ALU4SADG.js → appDeployStatusCommands-BZ7KZ5RD.js} +56 -48
- package/{appGetCommands-JEY4L6L4.js → appGetCommands-EDWGJV4S.js} +56 -48
- package/{appListCommands-PCAVHU7M.js → appListCommands-OPRWYPM6.js} +56 -48
- package/{authCommand-CGRIIOOV.js → authCommand-3C3RN4OU.js} +25 -19
- package/{authCommands-55OGQGCR.js → authCommands-ZMVEDCQD.js} +12 -6
- package/{builtinSkillRegistry-BAE2LDXF.js → builtinSkillRegistry-VRCMQ77Q.js} +7 -7
- package/{chromeCommands-G5UDKVSV.js → chromeCommands-O4IIKTBD.js} +384 -7
- package/{chromeOpsCommands-WAA45NCS.js → chromeOpsCommands-NZITLHWO.js} +3 -3
- package/{chunk-AUAJTAFM.js → chunk-2BKNICGK.js} +4 -4
- package/{chunk-QYB23WUH.js → chunk-2FK2KZSL.js} +1 -1
- package/chunk-2SXN7LAY.js +15 -0
- package/{chunk-H6L2NFHY.js → chunk-3DJJ4CFG.js} +11 -11
- package/{chunk-TSPMLCWI.js → chunk-4IQN6FWY.js} +5 -5
- package/{chunk-GUXZK7SE.js → chunk-4OXPN3WC.js} +17 -6
- package/chunk-4ZCTKB27.js +31 -0
- package/chunk-53W5BXLN.js +340 -0
- package/{chunk-3P54D2E4.js → chunk-5HUO7SEX.js} +9 -107
- package/chunk-6ASGEP5D.js +21 -0
- package/{chunk-DDC6P6EH.js → chunk-6CXQ3YNJ.js} +68 -40
- package/{chunk-G7IUT2V3.js → chunk-6MTVACLN.js} +365 -64
- package/{chunk-ZOHO6MOF.js → chunk-6RSNVJGO.js} +2 -99
- package/{chunk-XSW4EXQV.js → chunk-6TVYUQRM.js} +55 -18
- package/{chunk-PDCV7P5W.js → chunk-6XIE5ZGI.js} +1 -1
- package/{chunk-7Z6EW7AH.js → chunk-6XVPMGXK.js} +97 -11
- package/{chunk-ALAES342.js → chunk-73PZD7JZ.js} +9 -5
- package/{chunk-2MCB7CD7.js → chunk-7UVVLYKC.js} +9 -9
- package/{chunk-S6FDXXZV.js → chunk-ADOOL3PG.js} +2 -2
- package/{chunk-OWKNSIXL.js → chunk-AEZBAFC6.js} +334 -77
- package/{chunk-PWTNI4N7.js → chunk-ANUP75N2.js} +22 -0
- package/{chunk-RG2DGNL6.js → chunk-ARFCL53U.js} +5 -5
- package/{chunk-SRCCSTIM.js → chunk-AS6L5KSD.js} +4 -4
- package/{chunk-GPOV42YM.js → chunk-BAH3BAUZ.js} +8 -8
- package/{chunk-N5Z2V73W.js → chunk-BFKJ2RS3.js} +1 -1
- package/{chunk-F6Z6ZCUV.js → chunk-BVEDT6DM.js} +3 -3
- package/chunk-C5A54QS7.js +108 -0
- package/{chunk-CD3RU7XL.js → chunk-CD2DK5JA.js} +120 -14
- package/{chunk-BP5ZJ6B4.js → chunk-CD64YXRB.js} +1 -1
- package/{chunk-VP3BINY7.js → chunk-CIGCTSBF.js} +31 -1
- package/{chunk-D6YNCNM6.js → chunk-CIUZXD5D.js} +12 -12
- package/{chunk-EVGU5P4U.js → chunk-CO6E7YK6.js} +1 -1
- package/{chunk-VMJVAJ6W.js → chunk-CTIEJRTP.js} +28 -4
- package/{chunk-7JGMNKKG.js → chunk-CTWCZKNS.js} +29 -8
- package/{chunk-YFLVRVYK.js → chunk-D25ONVOH.js} +1 -1
- package/{chunk-LKA64WH4.js → chunk-DMPZMYH4.js} +37 -1
- package/{chunk-262R3XNN.js → chunk-E5RYFR7E.js} +334 -103
- package/{chunk-OQHIVPG4.js → chunk-E6A5NHDH.js} +4 -1
- package/{chunk-HSSBDZLD.js → chunk-EDT65EUE.js} +6 -6
- package/{chunk-IAAIUH64.js → chunk-EQZQUQ33.js} +7 -7
- package/{chunk-HBRDSQ3M.js → chunk-ESN4WNWU.js} +3 -2
- package/{chunk-2YGBI2XB.js → chunk-FE7G6DSP.js} +11 -1
- package/{chunk-547ENH5T.js → chunk-FFFKAOJN.js} +4 -4
- package/{chunk-5ZUOVCKT.js → chunk-FGHEF6WI.js} +3 -1
- package/{chunk-IXG6YXQM.js → chunk-FTWAOKFU.js} +795 -361
- package/chunk-GAHJLSDO.js +107 -0
- package/{chunk-2X7WFDT6.js → chunk-GX6DITLQ.js} +1 -1
- package/{chunk-GYS5FUYR.js → chunk-HCCQEMTK.js} +28 -28
- package/{chunk-CMMI3DAT.js → chunk-HZDK56EK.js} +33 -26
- package/{chunk-UE2EVEYS.js → chunk-IIOSZAJX.js} +4 -4
- package/chunk-IIRJ4P4I.js +24 -0
- package/{chunk-QCB42576.js → chunk-IJZC2KIJ.js} +1 -1
- package/{chunk-RYOLWYBK.js → chunk-ITBX27W6.js} +97 -21
- package/{chunk-VSYTM22R.js → chunk-J2VIGDJN.js} +6 -6
- package/{chunk-QBZCGP34.js → chunk-JEWMQR6J.js} +1 -1
- package/{chunk-6QHKRARD.js → chunk-JFRJEPFI.js} +29 -5
- package/{chunk-S6K5F3KP.js → chunk-JP2BH4NC.js} +1 -1
- package/{chunk-MDZWUD3R.js → chunk-JU7VN4LF.js} +38 -29
- package/{chunk-RTHFJZ6M.js → chunk-K26XPZRB.js} +2 -2
- package/{chunk-ZYKJBRZ3.js → chunk-K7VIXYTZ.js} +1 -3
- package/chunk-KK3FCYZM.js +647 -0
- package/chunk-KLAMJNKQ.js +33394 -0
- package/{chunk-4JVNURX4.js → chunk-KQHEGELM.js} +68 -16
- package/chunk-KXOPLLFP.js +190 -0
- package/{chunk-GOCSSER3.js → chunk-KZ5OD2MO.js} +4 -4
- package/{chunk-ILHQ2AXT.js → chunk-KZAT2M2V.js} +14 -8
- package/chunk-LHCGKAFO.js +739 -0
- package/{chunk-XJPLSAPJ.js → chunk-LMGFVH65.js} +107 -104
- package/{chunk-QRGDJA4B.js → chunk-LTVEOOZL.js} +19 -6
- package/{chunk-L32W3PRP.js → chunk-MAA42MMV.js} +233 -17
- package/{chunk-ATEKLSLR.js → chunk-MTM4LRVG.js} +14 -9
- package/chunk-MVOZ22RZ.js +26 -0
- package/{chunk-2NPD3FTX.js → chunk-MYYNZG2M.js} +139 -39
- package/{chunk-DBUR22G5.js → chunk-MZVCFV3T.js} +19 -15
- package/{chunk-K67C2JUC.js → chunk-N74XL3NI.js} +9 -9
- package/{chunk-VS276URX.js → chunk-NEG5LYK5.js} +1 -1
- package/{chunk-RBPUNSG5.js → chunk-OAZP4TSA.js} +18 -108
- package/{chunk-SMJEXX2S.js → chunk-ODBYGVO2.js} +232 -10
- package/{chunk-M4SFKP5L.js → chunk-OHUYN3YU.js} +3 -3
- package/{chunk-HYLRQDEE.js → chunk-OLGFIQN2.js} +6 -6
- package/{chunk-M3JEW6N6.js → chunk-OYUMJMC5.js} +15 -0
- package/chunk-P27E22MA.js +203 -0
- package/{chunk-BIWI5M4E.js → chunk-PBPXXMWZ.js} +1 -1
- package/{chunk-OBSEKCVK.js → chunk-PQ63BDV3.js} +210 -51
- package/{chunk-4I2MXV5Q.js → chunk-PVFYPUIM.js} +2 -0
- package/{chunk-OG6MQOQG.js → chunk-QMNVV3YM.js} +10 -37
- package/{chunk-GACR7H6T.js → chunk-R5NRFXGD.js} +5 -5
- package/{chunk-5FUN7EG4.js → chunk-RD3QLZQV.js} +83 -47
- package/{chunk-4WVJLODK.js → chunk-RHBD22LV.js} +9 -4
- package/{chunk-EXJK7TQO.js → chunk-RMWDKLBE.js} +1520 -562
- package/{chunk-TGNIKIHR.js → chunk-RR3MB26M.js} +2 -2
- package/{chunk-OOJNQK6V.js → chunk-S25VJYXV.js} +8 -2
- package/{chunk-STJ6LSQE.js → chunk-SCMYAGQE.js} +1135 -712
- package/{chunk-YKY4OVOX.js → chunk-SPU3L3OR.js} +17 -170
- package/chunk-SR4FE5VD.js +9 -0
- package/{chunk-DUUDXSLX.js → chunk-SX6AWTNK.js} +28 -4
- package/{chunk-ZH3KXFHS.js → chunk-TMRJGSK2.js} +1 -1
- package/{chunk-S2NTVGA2.js → chunk-U35UUM5K.js} +2 -1
- package/{chunk-PPJYZRSQ.js → chunk-U5LOKQ2R.js} +30 -14
- package/{chunk-UAIHKQIA.js → chunk-U6RD332P.js} +18 -2
- package/{chunk-3U44JB3O.js → chunk-UF6J7NXV.js} +1 -1
- package/{chunk-Q3IVPFVO.js → chunk-UHW6SCVK.js} +1 -1
- package/chunk-UOUMPHS5.js +103 -0
- package/{chunk-HHFGE2WF.js → chunk-UPOW5HTG.js} +5 -5
- package/{chunk-DEA37IUY.js → chunk-V4IYI3SB.js} +2 -2
- package/{chunk-UWAIJOF2.js → chunk-VKCPKCSS.js} +66 -92
- package/{chunk-HGDKT2D6.js → chunk-VTHWBTRE.js} +177 -1
- package/{chunk-OBIC6EG7.js → chunk-VUHKG4KS.js} +3 -3
- package/{chunk-EEOOBRA7.js → chunk-W3HSD32M.js} +13 -6
- package/{chunk-P2ZLUIW2.js → chunk-W6T4FNZP.js} +351 -26
- package/chunk-WDWZPASX.js +29 -0
- package/chunk-WFGNWWJI.js +326 -0
- package/{chunk-R6Z5S5GA.js → chunk-WQDTSK5U.js} +51 -14
- package/{chunk-OYU2MA5S.js → chunk-X22AUZKL.js} +152 -167
- package/{chunk-4ZGPHFLE.js → chunk-X3OZ655T.js} +2 -2
- package/{chunk-NHY322ZU.js → chunk-XCA4WHX5.js} +588 -64
- package/{chunk-TI2EPRHE.js → chunk-XJSEST7D.js} +3 -3
- package/{chunk-JUSHVFNF.js → chunk-XNTZD4AE.js} +1230 -1356
- package/chunk-XSRSAU3O.js +133 -0
- package/{chunk-CYWNWA77.js → chunk-Y4NPF2UN.js} +6 -3
- package/{chunk-FJSNBZXR.js → chunk-YDRRGVT5.js} +1 -1
- package/{chunk-R3NEQZ53.js → chunk-YFW4H6DL.js} +405 -338
- package/{chunk-BNMPUQW6.js → chunk-YGDYYFRX.js} +20 -24
- package/{chunk-4N6G2CKP.js → chunk-YHNUDTU4.js} +49 -3
- package/chunk-YJPK35HB.js +175 -0
- package/{chunk-6OVNSQHN.js → chunk-YLAHYLDQ.js} +5 -0
- package/{chunk-AGYPUBFW.js → chunk-Z7KE4K3H.js} +195 -123
- package/{chunk-DGYCDA6W.js → chunk-ZM5AZTQG.js} +20 -13
- package/{chunk-CBUZ6DKA.js → chunk-ZQ6K57FJ.js} +1 -1
- package/{cliAgentConfigHelpers-BTRHMPW2.js → cliAgentConfigHelpers-37ZNEY5Y.js} +9 -9
- package/{cliAuthorityBrokerClient-XHH7MH2P.js → cliAuthorityBrokerClient-SFPC3WVK.js} +1 -1
- package/{cliLocalAgentRecordReader-M3F76NIP.js → cliLocalAgentRecordReader-MCQVRWBR.js} +59 -47
- package/{commandRegistry-ZLWHQVAI.js → commandRegistry-NTH5IAN5.js} +104 -92
- package/{contentThunks-4ZX2TO7C.js → contentThunks-SPXTX5U2.js} +38 -36
- package/{cooldownCommands-YB5H5BBK.js → cooldownCommands-TIFCHCUN.js} +1 -1
- package/{createAgentAutomationAction-L4CYUZJG.js → createAgentAutomationAction-KUQKCOXB.js} +38 -36
- package/{createDialogAction-QTU2R2Q3.js → createDialogAction-HJN5U3XS.js} +39 -37
- package/{createPageAction-F3GJTHW2.js → createPageAction-ZAHRDOAU.js} +43 -41
- package/{db-M7FU2GNK.js → db-CMUTP3W5.js} +2 -2
- package/{dbSlice-XRUZOGSU.js → dbSlice-656PMWR2.js} +13 -12
- package/{deleteFile-6URDHYRB.js → deleteFile-ZCQESEEQ.js} +10 -7
- package/{dialogCommands-NRLCOPJR.js → dialogCommands-KZTZLWPZ.js} +61 -54
- package/dialogMessageRecord-OAV77LT7.js +7 -0
- package/{dialogNotifyCommand-SHGPCU22.js → dialogNotifyCommand-PST75COP.js} +11 -11
- package/{dialogSlice-P2S4LXQD.js → dialogSlice-BXIERQHO.js} +39 -37
- package/{dialogUsageCommand-W2WCSGKF.js → dialogUsageCommand-6RW2FY6K.js} +5 -5
- package/{docCreateCommands-YJRDA3RX.js → docCreateCommands-26HJ5NAY.js} +55 -47
- package/{docDeleteCommands-A5QIHZNF.js → docDeleteCommands-UAOHH5XK.js} +57 -49
- package/{docReadCommands-CF2LTMYH.js → docReadCommands-4ADG7YE6.js} +55 -47
- package/{docStore-6O7NYL6A.js → docStore-FZ75HWP2.js} +15 -14
- package/{docUpdateCommands-QRKV4ZXE.js → docUpdateCommands-OGFJZENF.js} +55 -47
- package/fetchMessages-TQEUZD7H.js +1 -1
- package/{getPricing-LF5C4XSI.js → getPricing-FCHYVRJU.js} +4 -4
- package/{handleSendMessageAction-7IHLR37A.js → handleSendMessageAction-KP6GGBFY.js} +84 -79
- package/{hostCredentialCreate-VNCQUAFT.js → hostCredentialCreate-23TX56G7.js} +119 -105
- package/index.js +8 -8
- package/{lib-OT5OTXRU.js → lib-62SWPXNF.js} +3 -7
- package/{localDialogRead-CCOCVGAP.js → localDialogRead-CIOTQM5T.js} +1 -1
- package/{localRuntimeAdapter-FOWVNMIK.js → localRuntimeAdapter-MTUWOYPN.js} +126 -111
- package/{localRuntimeAuthority-IBJAT62G.js → localRuntimeAuthority-TYHQCTZN.js} +5 -3
- package/{localRuntimeDb-N7KHDXS2.js → localRuntimeDb-BO7IVWAZ.js} +1 -1
- package/{machineCommands-ZGC3J4JB.js → machineCommands-4WJUJQHW.js} +260 -323
- package/{machineWsRunDispatch-KK5U4M3G.js → machineWsRunDispatch-V3U4JM67.js} +115 -102
- package/markdownToSlate-KIYM7B3P.js +8 -0
- package/mcpLocalAuthorizeCommand-TI656UWC.js +106 -0
- package/{memberThunks-7Y3OYSJQ.js → memberThunks-JFYC4Z5L.js} +20 -15
- package/{models-H5NNZRLH.js → models-EP7VG6N2.js} +2 -2
- package/{overlay-BBQZXGYI.js → overlay-JA3SPVUS.js} +5 -3
- package/package.json +1 -1
- package/{projectArchive-7ZDYBXAX.js → projectArchive-NU2Z5HOR.js} +45 -43
- package/{providerPresetApply-WHAMP2D5.js → providerPresetApply-4H7YP5D7.js} +6 -6
- package/{providerRegistry-ZI2KORJ7.js → providerRegistry-F3UPOTIY.js} +6 -6
- package/{read-TYMBGEXO.js → read-BRZHXUJ6.js} +9 -8
- package/{readDocTool-SKQVHBLO.js → readDocTool-N7RVFQEE.js} +1 -1
- package/{readlineWorkspace-YHT4SX2C.js → readlineWorkspace-T56MRMS5.js} +6426 -3669
- package/rememberExplicit-CPAPONSI.js +15 -0
- package/{removeDialogAgentAction-F5QE2O2B.js → removeDialogAgentAction-J7XU7OUX.js} +19 -18
- package/{runAgentClientLoop-H4ED5V3K.js → runAgentClientLoop-O2GRCGRZ.js} +97 -75
- package/{runtimeDoctorCommands-RRKPBGVO.js → runtimeDoctorCommands-RDRJXMXC.js} +8 -8
- package/{secretCommands-KZWBZIYS.js → secretCommands-2FEMRUFM.js} +3 -3
- package/{setDialogExtraReferencesAction-72L27ERM.js → setDialogExtraReferencesAction-Q4V2ZZW2.js} +16 -15
- package/{setPrimaryDialogAgentAction-GJJDUSGJ.js → setPrimaryDialogAgentAction-742H5S6T.js} +19 -18
- package/{settingThunks-ZRGWVGZD.js → settingThunks-T4FXSV6M.js} +185 -66
- package/{skillDiscovery-I37M5KJC.js → skillDiscovery-MDDKPTW3.js} +4 -3
- package/{spaceCommands-MEH3HJBC.js → spaceCommands-W5TAVFDT.js} +59 -51
- package/{streamAgentChatTurn-ZXPOXU33.js → streamAgentChatTurn-OWDJMU5E.js} +238 -178
- package/{switchDialogAgentAction-IIJBPND3.js → switchDialogAgentAction-HLDLHRRA.js} +17 -16
- package/{tableCommands-FTAOCBTX.js → tableCommands-44GC4N6J.js} +8 -5
- package/{toolApiClient-OGQEBQVX.js → toolApiClient-N5PYW2R3.js} +8 -6
- package/{tools-2MRWA2PP.js → tools-O7SGGVA3.js} +67 -62
- package/{tuiRestart-2IL37YIB.js → tuiRestart-EOGC2BYY.js} +10 -10
- package/{tuiSummaryLlmCaller-W2QN4VAC.js → tuiSummaryLlmCaller-TM5BU73J.js} +16 -15
- package/{updateCommands-CPATDG6J.js → updateCommands-FBYA5WVG.js} +3 -3
- package/{updateDialogTitleAction-RZ3KZSGQ.js → updateDialogTitleAction-EXSZGTLL.js} +40 -38
- package/{usageCommand-2BF74MKF.js → usageCommand-L4OFWXEU.js} +2 -2
- package/{usageRebuildCommand-UHB55BQM.js → usageRebuildCommand-7JR33UHS.js} +3 -3
- package/webapi-QVV65DQF.js +2487 -0
- package/{windowsSelfUpdate-ZFD6J5HF.js → windowsSelfUpdate-M4V77OUB.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-ZCSQCHG3.js} +2 -2
- package/agentListCommands-GUGMORTK.js +0 -1005
- package/agentRecordCommands-SLLADS5C.js +0 -175
- package/chunk-2WZXXAQD.js +0 -57
- package/chunk-5ZMIIR23.js +0 -265
- package/chunk-62HXNQVV.js +0 -134
- package/chunk-TUSTONB3.js +0 -81
- package/chunk-ZXF6D3I6.js +0 -359
- package/{chunk-W6RFEDN4.js → chunk-AETZ7AD6.js} +3 -3
- /package/{chunk-FJ23FZXF.js → chunk-VIYVRPMJ.js} +0 -0
|
@@ -1,18 +1,18 @@
|
|
|
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-CTIEJRTP.js";
|
|
13
9
|
import {
|
|
14
10
|
AUTH_ERROR_PATTERNS
|
|
15
11
|
} from "./chunk-EWQ3HGNZ.js";
|
|
12
|
+
import {
|
|
13
|
+
resolveRuntimeAuthToken,
|
|
14
|
+
resolveRuntimeServerUrl
|
|
15
|
+
} from "./chunk-GX6DITLQ.js";
|
|
16
16
|
import {
|
|
17
17
|
AGENT_RUN_PROTOCOL,
|
|
18
18
|
HOST_RUNTIME_CONTENT_IDENTITY,
|
|
@@ -26,9 +26,200 @@ import {
|
|
|
26
26
|
isRecord
|
|
27
27
|
} from "./chunk-KUG52IAP.js";
|
|
28
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
|
+
}
|
|
219
|
+
|
|
29
220
|
// packages/cli/client/originShellApprovalTransport.ts
|
|
30
221
|
import { realpathSync } from "node:fs";
|
|
31
|
-
import { randomUUID } from "node:crypto";
|
|
222
|
+
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
32
223
|
|
|
33
224
|
// packages/cli/client/originShellApprovalBridge.ts
|
|
34
225
|
import { isAbsolute } from "node:path";
|
|
@@ -45,7 +236,7 @@ function createOriginShellApprovalBridge(deps) {
|
|
|
45
236
|
}
|
|
46
237
|
const requests = /* @__PURE__ */ new Map();
|
|
47
238
|
const fail = (reason) => ({ ok: false, reason });
|
|
48
|
-
const
|
|
239
|
+
const snapshot2 = (request) => ({ ok: true, request: { ...request } });
|
|
49
240
|
const validIdentity = (call) => {
|
|
50
241
|
try {
|
|
51
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;
|
|
@@ -71,7 +262,7 @@ function createOriginShellApprovalBridge(deps) {
|
|
|
71
262
|
const request = requests.get(id);
|
|
72
263
|
if (!request) return fail("unknown_request");
|
|
73
264
|
if (!CALL_KEYS.every((key) => request[key] === call[key])) return fail("call_mismatch");
|
|
74
|
-
return
|
|
265
|
+
return snapshot2(request);
|
|
75
266
|
};
|
|
76
267
|
return {
|
|
77
268
|
request(call) {
|
|
@@ -99,7 +290,7 @@ function createOriginShellApprovalBridge(deps) {
|
|
|
99
290
|
state: "pending"
|
|
100
291
|
};
|
|
101
292
|
requests.set(requestId, request);
|
|
102
|
-
return
|
|
293
|
+
return snapshot2(request);
|
|
103
294
|
},
|
|
104
295
|
decide(id, call, decision) {
|
|
105
296
|
const result = lookup(id, call);
|
|
@@ -113,7 +304,7 @@ function createOriginShellApprovalBridge(deps) {
|
|
|
113
304
|
state: decision === "approve" ? "approved" : "denied"
|
|
114
305
|
};
|
|
115
306
|
requests.set(id, request);
|
|
116
|
-
return
|
|
307
|
+
return snapshot2(request);
|
|
117
308
|
},
|
|
118
309
|
revoke() {
|
|
119
310
|
for (const [id, request] of requests) {
|
|
@@ -129,15 +320,15 @@ function createOriginShellApprovalBridge(deps) {
|
|
|
129
320
|
if (result.request.state !== "approved") return fail(result.request.state);
|
|
130
321
|
const request = { ...result.request, state: "consumed" };
|
|
131
322
|
requests.set(id, request);
|
|
132
|
-
return
|
|
323
|
+
return snapshot2(request);
|
|
133
324
|
}
|
|
134
325
|
};
|
|
135
326
|
}
|
|
136
327
|
|
|
137
328
|
// packages/cli/client/originShellApprovalTransport.ts
|
|
138
|
-
var
|
|
139
|
-
var
|
|
140
|
-
var
|
|
329
|
+
var KIND2 = "nolo.shell-approval.v1";
|
|
330
|
+
var MAX2 = 256;
|
|
331
|
+
var TTL2 = 6e4;
|
|
141
332
|
var NOTICE = "Executes with this local user's reachable permissions; workspace is NOT a directory sandbox.";
|
|
142
333
|
function payloadCall(payload, binding) {
|
|
143
334
|
if (typeof payload !== "string" || payload.length > 262144) throw new Error("Invalid approval payload");
|
|
@@ -149,17 +340,25 @@ function payloadCall(payload, binding) {
|
|
|
149
340
|
}
|
|
150
341
|
function send(channel, message) {
|
|
151
342
|
if (channel.connected === false || !channel.send) throw new Error("Approval channel disconnected");
|
|
152
|
-
channel.send({ kind:
|
|
343
|
+
channel.send({ kind: KIND2, ...message });
|
|
344
|
+
}
|
|
345
|
+
var liveApprovalHosts = /* @__PURE__ */ new Set();
|
|
346
|
+
function hasLiveShellApprovalHosts() {
|
|
347
|
+
return liveApprovalHosts.size > 0;
|
|
153
348
|
}
|
|
154
349
|
function attachShellApprovalHost(channel, host) {
|
|
155
350
|
const binding = Object.freeze({ ...host.binding });
|
|
156
351
|
const bridge = createOriginShellApprovalBridge({ binding, resolveWorkspace: realpathSync });
|
|
352
|
+
const connection = {};
|
|
157
353
|
let closed = false;
|
|
158
354
|
let count = 0;
|
|
159
355
|
const active = /* @__PURE__ */ new Set();
|
|
356
|
+
let unbindLifetime = () => {
|
|
357
|
+
};
|
|
160
358
|
const close = () => {
|
|
161
359
|
if (closed) return;
|
|
162
360
|
closed = true;
|
|
361
|
+
liveApprovalHosts.delete(connection);
|
|
163
362
|
bridge.revoke();
|
|
164
363
|
for (const controller of active) controller.abort();
|
|
165
364
|
active.clear();
|
|
@@ -168,13 +367,10 @@ function attachShellApprovalHost(channel, host) {
|
|
|
168
367
|
} catch {
|
|
169
368
|
}
|
|
170
369
|
channel.removeListener("message", receive);
|
|
171
|
-
|
|
172
|
-
channel.removeListener("exit", close);
|
|
173
|
-
channel.removeListener("error", close);
|
|
174
|
-
host.signal.removeEventListener("abort", close);
|
|
370
|
+
unbindLifetime();
|
|
175
371
|
};
|
|
176
372
|
const receive = (message) => {
|
|
177
|
-
if (closed || message?.kind !==
|
|
373
|
+
if (closed || message?.kind !== KIND2) return;
|
|
178
374
|
if (message.type === "hello") {
|
|
179
375
|
try {
|
|
180
376
|
send(channel, { type: "binding", binding });
|
|
@@ -184,7 +380,7 @@ function attachShellApprovalHost(channel, host) {
|
|
|
184
380
|
return;
|
|
185
381
|
}
|
|
186
382
|
if (message.type !== "request") return;
|
|
187
|
-
if (++count >
|
|
383
|
+
if (++count > MAX2 || typeof message.id !== "string" || message.id.length > 100) {
|
|
188
384
|
close();
|
|
189
385
|
return;
|
|
190
386
|
}
|
|
@@ -241,14 +437,12 @@ function attachShellApprovalHost(channel, host) {
|
|
|
241
437
|
})();
|
|
242
438
|
};
|
|
243
439
|
channel.on("message", receive);
|
|
244
|
-
channel
|
|
245
|
-
|
|
246
|
-
channel.
|
|
247
|
-
host.signal.addEventListener("abort", close, { once: true });
|
|
248
|
-
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();
|
|
249
443
|
return close;
|
|
250
444
|
}
|
|
251
|
-
function createShellApprovalChild(channel, timeoutMs =
|
|
445
|
+
function createShellApprovalChild(channel, timeoutMs = TTL2) {
|
|
252
446
|
let closed = false;
|
|
253
447
|
let binding;
|
|
254
448
|
let count = 0;
|
|
@@ -267,7 +461,7 @@ function createShellApprovalChild(channel, timeoutMs = TTL) {
|
|
|
267
461
|
channel.removeListener("disconnect", close);
|
|
268
462
|
};
|
|
269
463
|
const receive = (message) => {
|
|
270
|
-
if (closed || message?.kind !==
|
|
464
|
+
if (closed || message?.kind !== KIND2) return;
|
|
271
465
|
if (message.type === "revoke") {
|
|
272
466
|
close();
|
|
273
467
|
return;
|
|
@@ -285,7 +479,7 @@ function createShellApprovalChild(channel, timeoutMs = TTL) {
|
|
|
285
479
|
if (!entry) return;
|
|
286
480
|
pending.delete(message.id);
|
|
287
481
|
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() +
|
|
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)) {
|
|
289
483
|
entry.reject(new Error("Shell approval denied"));
|
|
290
484
|
return;
|
|
291
485
|
}
|
|
@@ -303,17 +497,17 @@ function createShellApprovalChild(channel, timeoutMs = TTL) {
|
|
|
303
497
|
close,
|
|
304
498
|
authority: {
|
|
305
499
|
async request(payload) {
|
|
306
|
-
if (++count >
|
|
307
|
-
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);
|
|
308
502
|
while (!binding && !closed && Date.now() < deadline) await new Promise((resolve2) => setTimeout(resolve2, 5));
|
|
309
503
|
if (closed || !binding) throw new Error("Shell approval unavailable");
|
|
310
504
|
payloadCall(payload, binding);
|
|
311
|
-
const id =
|
|
505
|
+
const id = randomUUID2();
|
|
312
506
|
return new Promise((resolve2, reject) => {
|
|
313
507
|
const timer = setTimeout(() => {
|
|
314
508
|
pending.delete(id);
|
|
315
509
|
reject(new Error("Shell approval timeout"));
|
|
316
|
-
}, Math.min(timeoutMs,
|
|
510
|
+
}, Math.min(timeoutMs, TTL2));
|
|
317
511
|
pending.set(id, { payload, resolve: resolve2, reject, timer });
|
|
318
512
|
try {
|
|
319
513
|
send(channel, { type: "request", id, runId: binding.runId, payload });
|
|
@@ -456,7 +650,7 @@ function redactLogLines(lines, options = {}) {
|
|
|
456
650
|
import { hostname as nodeHostname, homedir as nodeHomedir } from "node:os";
|
|
457
651
|
import { dirname, isAbsolute as isAbsolute2, join as join2, resolve } from "node:path";
|
|
458
652
|
import * as nodeFs2 from "node:fs";
|
|
459
|
-
import { randomUUID as
|
|
653
|
+
import { randomUUID as randomUUID3, createHash as createHash2 } from "node:crypto";
|
|
460
654
|
import { execFileSync as nodeExecFileSync, spawn as nodeSpawn } from "node:child_process";
|
|
461
655
|
|
|
462
656
|
// packages/cli/client/hostMemory.ts
|
|
@@ -705,7 +899,7 @@ var HostMemoryAdmissionError = class extends Error {
|
|
|
705
899
|
};
|
|
706
900
|
function assertHostMemoryAdmission(deps = {}) {
|
|
707
901
|
const readMem = deps.readHostMemory ?? readHostMemory;
|
|
708
|
-
const
|
|
902
|
+
const snapshot2 = readMem(deps.hostMemoryDeps);
|
|
709
903
|
const minAvailableMb = deps.minAvailableMb ?? LOCAL_AGENT_RUN_MIN_AVAILABLE_MB;
|
|
710
904
|
const startupWindowMs = deps.startupWindowMs ?? STARTUP_WINDOW_MS;
|
|
711
905
|
const reservedMbPerRun = deps.reservedMbPerRun ?? STARTUP_WINDOW_RESERVED_MB_PER_RUN;
|
|
@@ -713,7 +907,7 @@ function assertHostMemoryAdmission(deps = {}) {
|
|
|
713
907
|
for (const [name, value] of Object.entries({ minAvailableMb, startupWindowMs, reservedMbPerRun, now })) {
|
|
714
908
|
if (typeof value !== "number" || !Number.isFinite(value) || value < 0) throw new Error(`Invalid ${name}`);
|
|
715
909
|
}
|
|
716
|
-
if (!
|
|
910
|
+
if (!snapshot2) {
|
|
717
911
|
throw new HostMemoryAdmissionError(
|
|
718
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`,
|
|
719
913
|
{
|
|
@@ -727,19 +921,19 @@ function assertHostMemoryAdmission(deps = {}) {
|
|
|
727
921
|
}
|
|
728
922
|
);
|
|
729
923
|
}
|
|
730
|
-
if (!["cgroup", "proc-meminfo", "os"].includes(
|
|
924
|
+
if (!["cgroup", "proc-meminfo", "os"].includes(snapshot2.source)) throw new Error("Unknown host memory source");
|
|
731
925
|
let effectiveAvailableMb = null;
|
|
732
926
|
let limitingSource = "host";
|
|
733
|
-
if (
|
|
734
|
-
const cgroupAvail =
|
|
735
|
-
const hostAvail =
|
|
927
|
+
if (snapshot2.source === "cgroup") {
|
|
928
|
+
const cgroupAvail = snapshot2.availableMb;
|
|
929
|
+
const hostAvail = snapshot2.hostAvailableMb;
|
|
736
930
|
if (cgroupAvail === null || typeof cgroupAvail !== "number" || Number.isNaN(cgroupAvail) || !Number.isFinite(cgroupAvail) || cgroupAvail < 0) {
|
|
737
931
|
throw new HostMemoryAdmissionError(
|
|
738
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`,
|
|
739
933
|
{
|
|
740
934
|
effectiveAvailableMb: null,
|
|
741
935
|
requiredMinMb: minAvailableMb,
|
|
742
|
-
source:
|
|
936
|
+
source: snapshot2.source,
|
|
743
937
|
limitingSource: "cgroup",
|
|
744
938
|
activeStartupRuns: 0,
|
|
745
939
|
reservedStartupMb: 0,
|
|
@@ -751,7 +945,7 @@ function assertHostMemoryAdmission(deps = {}) {
|
|
|
751
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", {
|
|
752
946
|
effectiveAvailableMb: null,
|
|
753
947
|
requiredMinMb: minAvailableMb,
|
|
754
|
-
source:
|
|
948
|
+
source: snapshot2.source,
|
|
755
949
|
limitingSource: "host",
|
|
756
950
|
activeStartupRuns: 0,
|
|
757
951
|
reservedStartupMb: 0,
|
|
@@ -771,13 +965,13 @@ function assertHostMemoryAdmission(deps = {}) {
|
|
|
771
965
|
limitingSource = "cgroup";
|
|
772
966
|
}
|
|
773
967
|
} else {
|
|
774
|
-
if (
|
|
968
|
+
if (snapshot2.availableMb === null || typeof snapshot2.availableMb !== "number" || Number.isNaN(snapshot2.availableMb) || !Number.isFinite(snapshot2.availableMb) || snapshot2.availableMb < 0) {
|
|
775
969
|
throw new HostMemoryAdmissionError(
|
|
776
970
|
`[host-memory-admission] \u5BBF\u4E3B\u53EF\u7528\u5185\u5B58\u672A\u77E5\u6216\u65E0\u6548\uFF0C\u62D2\u7EDD\u65E0\u58F0\u5F53\u5145\u8DB3\u3002`,
|
|
777
971
|
{
|
|
778
972
|
effectiveAvailableMb: null,
|
|
779
973
|
requiredMinMb: minAvailableMb,
|
|
780
|
-
source:
|
|
974
|
+
source: snapshot2.source,
|
|
781
975
|
limitingSource: "host",
|
|
782
976
|
activeStartupRuns: 0,
|
|
783
977
|
reservedStartupMb: 0,
|
|
@@ -785,7 +979,7 @@ function assertHostMemoryAdmission(deps = {}) {
|
|
|
785
979
|
}
|
|
786
980
|
);
|
|
787
981
|
}
|
|
788
|
-
effectiveAvailableMb =
|
|
982
|
+
effectiveAvailableMb = snapshot2.availableMb;
|
|
789
983
|
limitingSource = "host";
|
|
790
984
|
}
|
|
791
985
|
let activeStartupRuns = 0;
|
|
@@ -797,7 +991,7 @@ function assertHostMemoryAdmission(deps = {}) {
|
|
|
797
991
|
{
|
|
798
992
|
effectiveAvailableMb,
|
|
799
993
|
requiredMinMb: minAvailableMb,
|
|
800
|
-
source:
|
|
994
|
+
source: snapshot2.source,
|
|
801
995
|
limitingSource,
|
|
802
996
|
activeStartupRuns: 0,
|
|
803
997
|
reservedStartupMb: 0,
|
|
@@ -812,7 +1006,7 @@ function assertHostMemoryAdmission(deps = {}) {
|
|
|
812
1006
|
{
|
|
813
1007
|
effectiveAvailableMb,
|
|
814
1008
|
requiredMinMb: minAvailableMb,
|
|
815
|
-
source:
|
|
1009
|
+
source: snapshot2.source,
|
|
816
1010
|
limitingSource,
|
|
817
1011
|
activeStartupRuns: 0,
|
|
818
1012
|
reservedStartupMb: 0,
|
|
@@ -828,7 +1022,7 @@ function assertHostMemoryAdmission(deps = {}) {
|
|
|
828
1022
|
{
|
|
829
1023
|
effectiveAvailableMb,
|
|
830
1024
|
requiredMinMb: minAvailableMb,
|
|
831
|
-
source:
|
|
1025
|
+
source: snapshot2.source,
|
|
832
1026
|
limitingSource,
|
|
833
1027
|
activeStartupRuns: 0,
|
|
834
1028
|
reservedStartupMb: 0,
|
|
@@ -850,7 +1044,7 @@ function assertHostMemoryAdmission(deps = {}) {
|
|
|
850
1044
|
{
|
|
851
1045
|
effectiveAvailableMb: netAvailableMb,
|
|
852
1046
|
requiredMinMb: minAvailableMb,
|
|
853
|
-
source:
|
|
1047
|
+
source: snapshot2.source,
|
|
854
1048
|
limitingSource,
|
|
855
1049
|
activeStartupRuns,
|
|
856
1050
|
reservedStartupMb,
|
|
@@ -863,7 +1057,7 @@ function assertHostMemoryAdmission(deps = {}) {
|
|
|
863
1057
|
effectiveAvailableMb: netAvailableMb,
|
|
864
1058
|
requiredMinMb: minAvailableMb,
|
|
865
1059
|
activeStartupRuns,
|
|
866
|
-
snapshot
|
|
1060
|
+
snapshot: snapshot2
|
|
867
1061
|
};
|
|
868
1062
|
}
|
|
869
1063
|
|
|
@@ -2027,6 +2221,42 @@ 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
|
+
}
|
|
2030
2260
|
async function listRunRecordsAsync(deps = {}) {
|
|
2031
2261
|
const dir = resolveRunsDir(deps.env, deps.homedir);
|
|
2032
2262
|
let entries;
|
|
@@ -2159,7 +2389,7 @@ async function gcRunRecords(deps = {}, options = {}) {
|
|
|
2159
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");
|
|
2160
2390
|
if (!fs.existsSync(artifact.path)) continue;
|
|
2161
2391
|
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 ||
|
|
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) {
|
|
2163
2393
|
throw new Error("artifact identity changed");
|
|
2164
2394
|
}
|
|
2165
2395
|
if (!tryUnlinkFile(fs, artifact.path)) artifactsOk = false;
|
|
@@ -2341,11 +2571,11 @@ function localWriterRecovery(record) {
|
|
|
2341
2571
|
function revokePreparedWriterLaunch(runId, attemptId, deps = {}) {
|
|
2342
2572
|
if (!/^[A-Za-z0-9_-]+$/.test(runId) || !attemptId) return "blocked";
|
|
2343
2573
|
return withRunRecordLock("local-writer-admission", deps, () => {
|
|
2344
|
-
const
|
|
2345
|
-
if (!
|
|
2574
|
+
const snapshot2 = readRunRecord(runId, deps);
|
|
2575
|
+
if (!snapshot2) return "blocked";
|
|
2346
2576
|
return withRunRecordLock(runId, deps, () => {
|
|
2347
2577
|
const latest = readRunRecord(runId, deps);
|
|
2348
|
-
if (!latest || JSON.stringify(latest) !== JSON.stringify(
|
|
2578
|
+
if (!latest || JSON.stringify(latest) !== JSON.stringify(snapshot2)) return "blocked";
|
|
2349
2579
|
const launch = latest.writerLaunch;
|
|
2350
2580
|
if (launch?.protocol !== "fenced-launch-v1" || launch.attemptId !== attemptId) return "blocked";
|
|
2351
2581
|
if (launch.phase === "revoked") return latest.localWriterClaim?.state === "released" ? "already-revoked" : "blocked";
|
|
@@ -2364,10 +2594,10 @@ function localWriterStillOwns(record, deps) {
|
|
|
2364
2594
|
const observed = e?.state === "known" && e.owner.state === "verified" ? nativeOwner(record.pid, deps) : void 0;
|
|
2365
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));
|
|
2366
2596
|
if (!isPidGone(record.pid, deps) && !reused) return true;
|
|
2367
|
-
const
|
|
2597
|
+
const snapshot2 = JSON.stringify(record);
|
|
2368
2598
|
const released = withRunRecordLock(record.runId, deps, () => {
|
|
2369
2599
|
const latest = readRunRecord(record.runId, deps);
|
|
2370
|
-
if (!latest || JSON.stringify(latest) !==
|
|
2600
|
+
if (!latest || JSON.stringify(latest) !== snapshot2) return false;
|
|
2371
2601
|
latest.localWriterClaim.state = "released";
|
|
2372
2602
|
writeRunRecord(latest, deps);
|
|
2373
2603
|
return true;
|
|
@@ -2376,14 +2606,14 @@ function localWriterStillOwns(record, deps) {
|
|
|
2376
2606
|
}
|
|
2377
2607
|
function acquireLocalWriterClaim(runId, cwd, deps) {
|
|
2378
2608
|
const fs = deps.fs ?? nodeFs2;
|
|
2379
|
-
const
|
|
2380
|
-
const worktree = trustedLocalWorktree(
|
|
2609
|
+
const canonical2 = String((fs.realpathSync ?? nodeFs2.realpathSync)(cwd));
|
|
2610
|
+
const worktree = trustedLocalWorktree(canonical2, deps);
|
|
2381
2611
|
const acquired = withRunRecordLock("local-writer-admission", deps, () => {
|
|
2382
2612
|
const updated = withRunRecordLock(runId, deps, () => {
|
|
2383
2613
|
const record = readRunRecord(runId, deps);
|
|
2384
2614
|
if (!record) throw new Error(`[local-writer-resource] missing run ${runId}`);
|
|
2385
2615
|
if (record.writerLaunch?.phase === "revoked") throw new Error("[local-writer-resource] claim attempt revoked");
|
|
2386
|
-
record.localWriterClaim = { cwd:
|
|
2616
|
+
record.localWriterClaim = { cwd: canonical2, ...worktree ? { worktree } : {}, state: "held" };
|
|
2387
2617
|
if (record.writerLaunch && record.execution?.state === "known" && record.execution.owner.state === "verified" && record.pid === process.pid) {
|
|
2388
2618
|
record.writerLaunch.phase = "granted";
|
|
2389
2619
|
}
|
|
@@ -2394,7 +2624,7 @@ function acquireLocalWriterClaim(runId, cwd, deps) {
|
|
|
2394
2624
|
return true;
|
|
2395
2625
|
}, { strict: true, requireDeadOwner: true });
|
|
2396
2626
|
if (!acquired) throw new Error("[local-writer-resource] admission lock busy; no child spawned");
|
|
2397
|
-
return
|
|
2627
|
+
return canonical2;
|
|
2398
2628
|
}
|
|
2399
2629
|
function nativeOwner(pid, deps) {
|
|
2400
2630
|
const first = probeProcessStartTime(pid, deps);
|
|
@@ -2494,19 +2724,19 @@ function resolveLocalContinuation(record, deps = {}) {
|
|
|
2494
2724
|
}
|
|
2495
2725
|
function registerLocalForegroundWriter(cwd, policy, agentKey, deps = {}) {
|
|
2496
2726
|
const fs = deps.fs ?? nodeFs2;
|
|
2497
|
-
const
|
|
2727
|
+
const canonical2 = String((fs.realpathSync ?? nodeFs2.realpathSync)(cwd));
|
|
2498
2728
|
const owner = nativeOwner(process.pid, deps);
|
|
2499
2729
|
if (owner.state !== "verified" || policy.readOnly || !policy.hostWritesAuthorized) {
|
|
2500
2730
|
throw new Error("[local-writer-resource] foreground native identity/authorization unknown");
|
|
2501
2731
|
}
|
|
2502
2732
|
const runId = defaultGenerateRunId();
|
|
2503
2733
|
fs.mkdirSync(resolveRunsDir(deps.env, deps.homedir), { recursive: true });
|
|
2504
|
-
const worktree = trustedLocalWorktree(
|
|
2734
|
+
const worktree = trustedLocalWorktree(canonical2, deps);
|
|
2505
2735
|
const record = {
|
|
2506
2736
|
runId,
|
|
2507
2737
|
agentKey,
|
|
2508
|
-
writerLaunch: { protocol: "fenced-launch-v1", attemptId:
|
|
2509
|
-
cwd:
|
|
2738
|
+
writerLaunch: { protocol: "fenced-launch-v1", attemptId: randomUUID3(), phase: "prepared" },
|
|
2739
|
+
cwd: canonical2,
|
|
2510
2740
|
startedAt: (deps.now?.() ?? /* @__PURE__ */ new Date()).toISOString(),
|
|
2511
2741
|
status: "running",
|
|
2512
2742
|
logPath: resolveRunLogPath(runId, deps.env, deps.homedir),
|
|
@@ -2517,7 +2747,7 @@ function registerLocalForegroundWriter(cwd, policy, agentKey, deps = {}) {
|
|
|
2517
2747
|
state: "known",
|
|
2518
2748
|
kind: "host-local",
|
|
2519
2749
|
runtimeKey: "local",
|
|
2520
|
-
canonicalCwd:
|
|
2750
|
+
canonicalCwd: canonical2,
|
|
2521
2751
|
device: { kind: "localhost", hostname: nodeHostname(), platform: process.platform },
|
|
2522
2752
|
...worktree ? { worktree } : {},
|
|
2523
2753
|
permissions: {
|
|
@@ -2532,7 +2762,7 @@ function registerLocalForegroundWriter(cwd, policy, agentKey, deps = {}) {
|
|
|
2532
2762
|
};
|
|
2533
2763
|
writeRunRecord(record, deps);
|
|
2534
2764
|
try {
|
|
2535
|
-
acquireLocalWriterClaim(runId,
|
|
2765
|
+
acquireLocalWriterClaim(runId, canonical2, deps);
|
|
2536
2766
|
} catch (error) {
|
|
2537
2767
|
finalizeRunRecord(runId, { status: "failed", exitCode: 1, note: String(error) }, deps);
|
|
2538
2768
|
throw error;
|
|
@@ -2551,10 +2781,13 @@ function releaseUnspawnedLocalWriterClaim(runId, deps) {
|
|
|
2551
2781
|
}, { strict: true });
|
|
2552
2782
|
if (!released) throw new Error(`[local-writer-resource] release lock busy: ${runId}`);
|
|
2553
2783
|
}
|
|
2784
|
+
var startupPhaseOrder = { spawn: 0, initializing: 1, protocol_validated: 2, model: 3 };
|
|
2554
2785
|
async function recordRunStartup(runId, phase, deps = {}) {
|
|
2555
2786
|
const attempt = () => withRunRecordLock(runId, deps, () => {
|
|
2556
2787
|
const record = readRunRecord(runId, deps);
|
|
2557
2788
|
if (!record || isRunTerminalStatus(record.status)) return true;
|
|
2789
|
+
if (record.pid != null && record.pid !== process.pid) return true;
|
|
2790
|
+
if (record.startup && startupPhaseOrder[record.startup.phase] >= startupPhaseOrder[phase]) return true;
|
|
2558
2791
|
record.startup = { protocol: AGENT_RUN_PROTOCOL, phase };
|
|
2559
2792
|
writeRunRecord(record, deps);
|
|
2560
2793
|
return true;
|
|
@@ -2671,7 +2904,7 @@ async function spawnLocalBackgroundRun(input, deps = {}) {
|
|
|
2671
2904
|
...title ? { title } : {},
|
|
2672
2905
|
cwd: canonicalCwd ?? input.cwd,
|
|
2673
2906
|
execution,
|
|
2674
|
-
...executionRequest ? { writerLaunch: { protocol: "fenced-launch-v1", attemptId:
|
|
2907
|
+
...executionRequest ? { writerLaunch: { protocol: "fenced-launch-v1", attemptId: randomUUID3(), phase: "prepared" } } : {},
|
|
2675
2908
|
...executionRequest ? (() => {
|
|
2676
2909
|
const parent = nativeOwner(process.pid, resolvedDeps);
|
|
2677
2910
|
return parent.state === "verified" ? { ownerPublication: { state: "pending", parent } } : {};
|
|
@@ -2767,7 +3000,7 @@ async function spawnLocalBackgroundRun(input, deps = {}) {
|
|
|
2767
3000
|
detached: true,
|
|
2768
3001
|
// Detached on Windows means no console; hide the one its children would create.
|
|
2769
3002
|
windowsHide: true,
|
|
2770
|
-
stdio: deps.shellApprovalHost ? ["ignore", logFd, logFd, "ipc"] : ["ignore", logFd, logFd]
|
|
3003
|
+
stdio: deps.shellApprovalHost || deps.mcpApprovalHost ? ["ignore", logFd, logFd, "ipc"] : ["ignore", logFd, logFd]
|
|
2771
3004
|
});
|
|
2772
3005
|
} catch (error) {
|
|
2773
3006
|
try {
|
|
@@ -2871,6 +3104,15 @@ async function spawnLocalBackgroundRun(input, deps = {}) {
|
|
|
2871
3104
|
throw new Error(`[host-memory-reservation] child ${proc.pid}, run ${runId}: association failed: ${error}`);
|
|
2872
3105
|
}
|
|
2873
3106
|
}
|
|
3107
|
+
if (deps.mcpApprovalHost) {
|
|
3108
|
+
attachMcpApprovalHost(proc, { ...deps.mcpApprovalHost, binding: {
|
|
3109
|
+
...deps.mcpApprovalHost.binding,
|
|
3110
|
+
runId,
|
|
3111
|
+
agentKey: input.agentKey,
|
|
3112
|
+
workspaceRoot: nodeFs2.realpathSync(input.cwd ?? process.cwd())
|
|
3113
|
+
} });
|
|
3114
|
+
proc.channel?.unref?.();
|
|
3115
|
+
}
|
|
2874
3116
|
if (deps.shellApprovalHost) {
|
|
2875
3117
|
attachShellApprovalHost(proc, { ...deps.shellApprovalHost, binding: {
|
|
2876
3118
|
...deps.shellApprovalHost.binding,
|
|
@@ -2962,6 +3204,9 @@ function transitionRunToTerminal(runId, update, deps = {}, options = {}) {
|
|
|
2962
3204
|
const settled = withRunRecordLock(runId, deps, () => {
|
|
2963
3205
|
const record2 = readRunRecord(runId, deps);
|
|
2964
3206
|
if (!record2) return { kind: "not_found" };
|
|
3207
|
+
if (options.expectedPid != null && record2.pid != null && record2.pid !== options.expectedPid) {
|
|
3208
|
+
return { kind: "kept", record: record2 };
|
|
3209
|
+
}
|
|
2965
3210
|
const orphanCorrection = options.allowOverOrphaned === true && record2.status === "orphaned" && (update.status === "done" || update.status === "failed");
|
|
2966
3211
|
if (isAgentRunTerminalStatus(record2.status) && !orphanCorrection) {
|
|
2967
3212
|
if (update.processExit) {
|
|
@@ -3022,7 +3267,7 @@ function transitionRunToTerminal(runId, update, deps = {}, options = {}) {
|
|
|
3022
3267
|
kind,
|
|
3023
3268
|
dev: String(stat.dev),
|
|
3024
3269
|
ino: String(stat.ino),
|
|
3025
|
-
sha256:
|
|
3270
|
+
sha256: createHash2("sha256").update(fs.readFileSync(path)).digest("hex")
|
|
3026
3271
|
};
|
|
3027
3272
|
record2.resultArtifacts = [...(record2.resultArtifacts ?? []).filter((a) => a.path !== path), artifact];
|
|
3028
3273
|
};
|
|
@@ -3053,7 +3298,7 @@ function transitionRunToTerminal(runId, update, deps = {}, options = {}) {
|
|
|
3053
3298
|
update.lastAssistantText ?? ""
|
|
3054
3299
|
);
|
|
3055
3300
|
if (typeof fs.renameSync !== "function") throw new Error("atomic result publication requires renameSync");
|
|
3056
|
-
pendingResultFile = `${resultFile}.${
|
|
3301
|
+
pendingResultFile = `${resultFile}.${randomUUID3()}.pending`;
|
|
3057
3302
|
try {
|
|
3058
3303
|
fs.writeFileSync(pendingResultFile, content, { encoding: "utf8", flag: "wx" });
|
|
3059
3304
|
stagingComplete = true;
|
|
@@ -3062,7 +3307,7 @@ function transitionRunToTerminal(runId, update, deps = {}, options = {}) {
|
|
|
3062
3307
|
}
|
|
3063
3308
|
if (fs.existsSync(resultFile)) {
|
|
3064
3309
|
const previous = fs.readFileSync(resultFile);
|
|
3065
|
-
const backup = `${resultFile}.${
|
|
3310
|
+
const backup = `${resultFile}.${randomUUID3()}.bak`;
|
|
3066
3311
|
backupFile = backup;
|
|
3067
3312
|
try {
|
|
3068
3313
|
fs.writeFileSync(backup, previous, { flag: "wx" });
|
|
@@ -3110,8 +3355,11 @@ function transitionRunToTerminal(runId, update, deps = {}, options = {}) {
|
|
|
3110
3355
|
}
|
|
3111
3356
|
var AUTHORITATIVE_SETTLE_MAX_ATTEMPTS = 4;
|
|
3112
3357
|
var AUTHORITATIVE_SETTLE_RETRY_DELAY_MS = 15;
|
|
3113
|
-
async function settleRunTerminalAuthoritatively(runId, update, deps = {}, transition = transitionRunToTerminal) {
|
|
3114
|
-
const attempt = () => transition(runId, update, deps, {
|
|
3358
|
+
async function settleRunTerminalAuthoritatively(runId, update, deps = {}, transition = transitionRunToTerminal, options = {}) {
|
|
3359
|
+
const attempt = () => transition(runId, update, deps, {
|
|
3360
|
+
allowOverOrphaned: true,
|
|
3361
|
+
...options.expectedPid != null ? { expectedPid: options.expectedPid } : {}
|
|
3362
|
+
});
|
|
3115
3363
|
let result = attempt();
|
|
3116
3364
|
for (let attemptNo = 1; result?.kind === "contended" && attemptNo < AUTHORITATIVE_SETTLE_MAX_ATTEMPTS; attemptNo += 1) {
|
|
3117
3365
|
await (deps.sleep ?? defaultSleep)(AUTHORITATIVE_SETTLE_RETRY_DELAY_MS);
|
|
@@ -3122,9 +3370,15 @@ async function settleRunTerminalAuthoritatively(runId, update, deps = {}, transi
|
|
|
3122
3370
|
`[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
3371
|
);
|
|
3124
3372
|
} else if (result?.kind === "kept" && result.record.status !== update.status) {
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3373
|
+
if (options.expectedPid != null && result.record.pid != null && result.record.pid !== options.expectedPid) {
|
|
3374
|
+
console.warn(
|
|
3375
|
+
`[nolo] run ${runId} belongs to PID ${result.record.pid}, not ${options.expectedPid}; keeping the durable record (${result.record.status}) over intended ${update.status}`
|
|
3376
|
+
);
|
|
3377
|
+
} else {
|
|
3378
|
+
console.warn(
|
|
3379
|
+
`[nolo] run ${runId} already terminal (${result.record.status}); keeping the durable outcome over intended ${update.status}`
|
|
3380
|
+
);
|
|
3381
|
+
}
|
|
3128
3382
|
}
|
|
3129
3383
|
return result ?? { kind: "not_found" };
|
|
3130
3384
|
}
|
|
@@ -3731,6 +3985,8 @@ async function runAgentRecoverPreparedWriterCommand(args, deps) {
|
|
|
3731
3985
|
}
|
|
3732
3986
|
|
|
3733
3987
|
export {
|
|
3988
|
+
createMcpApprovalChild,
|
|
3989
|
+
hasLiveShellApprovalHosts,
|
|
3734
3990
|
createShellApprovalChild,
|
|
3735
3991
|
TAIL_LINES_MAX,
|
|
3736
3992
|
readHostMemory,
|
|
@@ -3776,6 +4032,7 @@ export {
|
|
|
3776
4032
|
readRunRecord,
|
|
3777
4033
|
backfillRunRecordParentDialog,
|
|
3778
4034
|
listRunRecords,
|
|
4035
|
+
listRecentRunRecords,
|
|
3779
4036
|
listRunRecordsAsync,
|
|
3780
4037
|
findRunRecordByPid,
|
|
3781
4038
|
findRunRecord,
|