nolo-cli 0.224.0-alpha.2 → 0.224.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{_executeModel-4WBUORCW.js → _executeModel-5NA4USGG.js} +77 -71
- package/{action-CK64LS6S.js → action-X75O3XPH.js} +11 -8
- package/{addContentAction-EQXMFNPR.js → addContentAction-GVC77QSN.js} +14 -13
- package/{addDialogAgentAction-RSDZDASD.js → addDialogAgentAction-KKDVAMW3.js} +15 -14
- package/{agentDeleteCommand-BB6KU5AO.js → agentDeleteCommand-2RFGKFAB.js} +127 -119
- package/{agentEmailCommands-KMHPL6OH.js → agentEmailCommands-GQCQKKOR.js} +126 -114
- package/{agentFavoriteCommands-2LKGKSUD.js → agentFavoriteCommands-7LOP3HUD.js} +5 -5
- package/{agentGrantCommands-QQV4N4JW.js → agentGrantCommands-L6O2HVJI.js} +5 -5
- package/{agentListCommands-5UNM7CGG.js → agentListCommands-HSGLDPDQ.js} +110 -495
- package/{agentMachineCommands-OC5D4YZW.js → agentMachineCommands-BISF6PVV.js} +63 -57
- package/{agentProviderCommands-ZCH37KAL.js → agentProviderCommands-O3Q25PKU.js} +6 -6
- package/{agentPullCommand-XN6ZPBUW.js → agentPullCommand-G6U2LHMW.js} +6 -6
- package/agentRecordCommands-AOXPGYAJ.js +189 -0
- package/{agentRunCommand-M22Y3D5U.js → agentRunCommand-AFAIP7U7.js} +129 -115
- package/{agentRunControl-QDFW5P2T.js → agentRunControl-VBL7UFSG.js} +20 -14
- package/{agentRuntimeLocal-SD7U2EGY.js → agentRuntimeLocal-T7BX2WGL.js} +47 -41
- package/{agentSlice-AJPMMBOP.js → agentSlice-XJNKE3PG.js} +18 -17
- package/{appDeleteCommands-NE3NQQJL.js → appDeleteCommands-LURUSPY7.js} +56 -50
- package/{appDeployCommands-2BAHY522.js → appDeployCommands-SMEW4AK2.js} +56 -50
- package/{appDeployStatusCommands-JTW6LZNC.js → appDeployStatusCommands-VYPJTBJK.js} +56 -50
- package/{appGetCommands-WKFEJO6A.js → appGetCommands-N4NI5GGJ.js} +56 -50
- package/{appListCommands-HNAZZLFX.js → appListCommands-5C6ONN3Z.js} +56 -50
- package/{authCommand-VQP625QS.js → authCommand-4CVBDADE.js} +29 -28
- package/{authCommands-PAKU3CJZ.js → authCommands-EHU2BHOX.js} +12 -11
- package/{builtinSkillRegistry-PXH7EGQB.js → builtinSkillRegistry-AYWYQVA4.js} +4 -4
- package/{chromeOpsCommands-YKX2QX3A.js → chromeOpsCommands-CSDG2HYN.js} +6 -6
- package/{chunk-OOF7XDZF.js → chunk-2574ANSV.js} +6 -6
- package/chunk-2SXN7LAY.js +15 -0
- package/{chunk-OGHP3CTL.js → chunk-2X7WFDT6.js} +1 -1
- package/{chunk-XI2BWJM5.js → chunk-324FWHUA.js} +20 -3
- package/{chunk-D726I5AZ.js → chunk-3EMIEC27.js} +2 -2
- package/{chunk-XUJZYUIM.js → chunk-3FBAVU2Y.js} +24 -22
- package/{chunk-YL3EFYL3.js → chunk-4D4QD7FT.js} +3 -1
- package/{chunk-5RKUPJYL.js → chunk-4FIO2S7Z.js} +11 -3
- package/{chunk-EK7PGVPY.js → chunk-4IQVE43Z.js} +63 -32
- package/{chunk-6NKA6RKF.js → chunk-4Q6HQORG.js} +8 -8
- package/{chunk-P2ZLUIW2.js → chunk-4X5AVCM7.js} +94 -4
- package/chunk-4ZCTKB27.js +31 -0
- package/{chunk-JWXITTQB.js → chunk-5HUO7SEX.js} +9 -107
- package/{chunk-4A2JIXR2.js → chunk-5QZSEQSK.js} +1 -1
- package/chunk-5ZUOVCKT.js +32 -0
- package/{chunk-TRWT3EE3.js → chunk-62HXNQVV.js} +1 -1
- package/{chunk-JC5XLWZK.js → chunk-6CKUO32A.js} +27 -15
- package/chunk-6D25V6CB.js +133 -0
- package/chunk-6WOLPIPY.js +379 -0
- package/{chunk-KOXKKHFE.js → chunk-6WZVM33D.js} +9 -4
- package/{chunk-YGMBIXCF.js → chunk-6XRPBZRS.js} +4 -2
- package/{chunk-ULK35M44.js → chunk-7AJRJGSQ.js} +1049 -2860
- package/chunk-7NIBQ4HY.js +138 -0
- package/{chunk-7Z6EW7AH.js → chunk-7TTMMOKH.js} +13 -6
- package/{chunk-ZLOSGVCQ.js → chunk-A3LUWRQK.js} +15 -15
- package/{chunk-C4WTX5TU.js → chunk-A5EVA6HU.js} +2 -2
- package/{chunk-ZLNHUFOF.js → chunk-A74QP4FI.js} +2613 -1297
- package/{chunk-ME4XUFTD.js → chunk-AEQMKYZN.js} +15 -15
- package/{chunk-6E2NWYT4.js → chunk-AH5R7BYW.js} +22 -176
- package/{chunk-H7R3365N.js → chunk-ANJRDS6U.js} +8 -5
- package/{chunk-YFLVRVYK.js → chunk-AVJDELEA.js} +1 -1
- package/{chunk-GIABSSWQ.js → chunk-B5SV4H3J.js} +4 -4
- package/{chunk-S7RA7A4X.js → chunk-B7DE5XJW.js} +387 -347
- package/chunk-BEM6LPD2.js +734 -0
- package/{chunk-SRL56PI2.js → chunk-BGGAY6OK.js} +46 -8
- package/{chunk-BKJSRO66.js → chunk-BGGV6B5O.js} +555 -328
- package/{chunk-BGGHA5DV.js → chunk-BIABIPGW.js} +1 -1
- package/chunk-BIDSIRTS.js +307 -0
- package/{chunk-6D7NVU66.js → chunk-BXSMFPTG.js} +17 -14
- package/{chunk-Q6HOUF4O.js → chunk-CBUZ6DKA.js} +3 -3
- package/{chunk-LE6LGAJE.js → chunk-CD3RU7XL.js} +17 -2
- package/{chunk-GVGOEMNV.js → chunk-CKZPMJNU.js} +3 -3
- package/{chunk-HJAGA3GR.js → chunk-CVJRVBJL.js} +3 -3
- package/chunk-D374I563.js +62 -0
- package/{chunk-XWGDCWXY.js → chunk-DNZ4JJ7C.js} +9 -9
- package/chunk-DVYAFH2Q.js +103 -0
- package/{chunk-PYIMOZSX.js → chunk-DXW5WDHZ.js} +4 -4
- package/{chunk-KFHREHUQ.js → chunk-DXWGFL2Z.js} +89 -1
- package/{chunk-KPAFQHRT.js → chunk-E5KJOZWY.js} +4 -4
- package/{chunk-GNHMRBYZ.js → chunk-EBKHA63G.js} +106 -14
- package/{chunk-PFJNLBRU.js → chunk-EEOOBRA7.js} +6 -6
- package/{chunk-M3JEW6N6.js → chunk-F26GAEH3.js} +10 -0
- package/{chunk-QLFCTYRH.js → chunk-F3XI6WQP.js} +17 -10
- package/{chunk-AFHOCBSP.js → chunk-F6YWDVIB.js} +1 -1
- package/{chunk-SJYK3LLP.js → chunk-FFYE5ATM.js} +6 -6
- package/{chunk-QG3USDTD.js → chunk-FZKA3XFA.js} +21 -21
- package/{chunk-C4VAR65S.js → chunk-G22P367E.js} +153 -117
- package/{chunk-WOIURUUV.js → chunk-GDUC4VS2.js} +12 -12
- package/{chunk-2VUZSVAS.js → chunk-GXXY2NL3.js} +22 -20
- package/{chunk-IWH5SOU4.js → chunk-H7ZYKHAZ.js} +38 -18
- package/{chunk-G2EJ7NL4.js → chunk-HBRDSQ3M.js} +2 -2
- package/{chunk-EGXPAWLG.js → chunk-HCNOO374.js} +1 -1
- package/{chunk-DJSTBAOU.js → chunk-HOM6LTEW.js} +4 -4
- package/{chunk-S2NTVGA2.js → chunk-I2OYPD3Y.js} +1 -1
- package/{chunk-RXJ26SQW.js → chunk-IJTXNLQE.js} +13 -13
- package/{chunk-UYOICCYG.js → chunk-IUMS6F53.js} +59 -88
- package/{chunk-MOMR7NMG.js → chunk-IUTUWIKE.js} +2 -2
- package/{chunk-JVRQ6YVK.js → chunk-JBWXPACD.js} +1 -1
- package/{chunk-SASHAZ67.js → chunk-KZPEGO6D.js} +13 -2
- package/{chunk-HCJFGH6Y.js → chunk-L32W3PRP.js} +46 -16
- package/{chunk-GGKNJ42M.js → chunk-LYDEFPQP.js} +18 -108
- package/{chunk-K5FNYHZC.js → chunk-MECDGHLK.js} +420 -120
- package/{chunk-EOWLBDY6.js → chunk-MM73SP4K.js} +1 -1
- package/{chunk-J6T25AJ6.js → chunk-MYOSN6BT.js} +82 -18
- package/{chunk-Q7WP5RPC.js → chunk-MYPKBJJO.js} +5 -5
- package/{chunk-6RQFZCKH.js → chunk-N2JROHD3.js} +4 -4
- package/{chunk-VREDDN25.js → chunk-O6IPRAVV.js} +14 -9
- package/{chunk-VALBGPM6.js → chunk-OBSEKCVK.js} +17 -20
- package/{chunk-AMEOV5VZ.js → chunk-OOJNQK6V.js} +33 -33
- package/{chunk-PPJYZRSQ.js → chunk-OX6GNNVT.js} +6 -1
- package/{chunk-5R63B62U.js → chunk-P3IZUMIC.js} +8 -8
- package/{chunk-FRSBYNWI.js → chunk-PGKA77TZ.js} +52 -217
- package/{chunk-H5LWB3D3.js → chunk-PRMEU7BT.js} +347 -14
- package/{chunk-2ZKFCIJJ.js → chunk-PROOOQZ3.js} +1 -1
- package/{chunk-EUCFKKDM.js → chunk-PVFYPUIM.js} +40 -10
- package/{chunk-HOCHUZQ7.js → chunk-QJTZ76CP.js} +24 -6
- package/{chunk-MK2Q7ZJD.js → chunk-R7XWZDOH.js} +58 -24
- package/{chunk-5FUN7EG4.js → chunk-RD3QLZQV.js} +83 -47
- package/chunk-RETQOQ4D.js +33394 -0
- package/{chunk-AVHRSJUH.js → chunk-RM4UMFY4.js} +32 -25
- package/{chunk-2OLYKYNY.js → chunk-RTHFJZ6M.js} +8 -8
- package/{chunk-OB6DVWPF.js → chunk-S2MHR4PU.js} +164 -4
- package/{chunk-IWQAOW2X.js → chunk-SRCCSTIM.js} +8 -8
- package/{chunk-PVZY6P3S.js → chunk-T6VROBY7.js} +2 -2
- package/{chunk-2KTUDBG7.js → chunk-TEMLHVGX.js} +1 -1
- package/{chunk-TVFRV3UQ.js → chunk-TRHJ4NJB.js} +673 -1279
- package/{chunk-QVBXJNZ2.js → chunk-TUSTONB3.js} +1 -1
- package/{chunk-UMRI2IRY.js → chunk-TWTJV35S.js} +6 -6
- package/{chunk-5OZC7R7Y.js → chunk-U3G7RRXJ.js} +13 -12
- package/{chunk-CXDPIPZ4.js → chunk-UFC4J7OY.js} +3 -3
- package/{chunk-CKT6QUE2.js → chunk-UHW6SCVK.js} +1 -1
- package/{chunk-AGP3YSEC.js → chunk-ULLHVDTZ.js} +48 -3
- package/{chunk-SYQR7FQS.js → chunk-VM72HKW2.js} +97 -29
- package/{chunk-KEN3N2TN.js → chunk-VMJVAJ6W.js} +13 -10
- package/{chunk-53X6PS42.js → chunk-VREG6ANQ.js} +103 -100
- package/{chunk-SOF4OWDM.js → chunk-VS276URX.js} +0 -2
- package/{chunk-SH3IKNCG.js → chunk-VSRISJXZ.js} +15 -8
- package/chunk-WDWZPASX.js +29 -0
- package/chunk-WFGNWWJI.js +326 -0
- package/{chunk-UJKTI5PG.js → chunk-WRKMXMU7.js} +2 -1
- package/{chunk-FIYSMXHY.js → chunk-WWTSEBDF.js} +1 -1
- package/{chunk-E2BESSAW.js → chunk-X4O7FJF5.js} +2 -0
- package/chunk-X7IA2B7R.js +166 -0
- package/{chunk-5ZMIIR23.js → chunk-XBAEM4RI.js} +7 -0
- package/{chunk-4JVNURX4.js → chunk-XS5A3EKX.js} +1 -23
- package/{chunk-N5Z2V73W.js → chunk-Y2MF4DCJ.js} +1 -1
- package/{chunk-EVYGYDPG.js → chunk-Y5OWZQMJ.js} +39 -30
- package/{chunk-AK5O76CC.js → chunk-YGCOJNFZ.js} +3 -3
- package/{chunk-L5I543VB.js → chunk-YGDYYFRX.js} +20 -24
- package/{chunk-OK4MZRJ6.js → chunk-Z2WZAE4P.js} +128 -149
- package/chunk-Z6YTCDU4.js +24 -0
- package/chunk-ZEKUFJLW.js +1438 -0
- package/{chunk-KN3HEZIQ.js → chunk-ZVOL2MAJ.js} +1 -1
- package/{cliAgentConfigHelpers-PO3MVDME.js → cliAgentConfigHelpers-U5OAVAKQ.js} +12 -12
- package/{cliAuthorityBrokerClient-XHH7MH2P.js → cliAuthorityBrokerClient-S42VMGB6.js} +1 -1
- package/{cliEnvHelpers-VPSJ4XWC.js → cliEnvHelpers-CNMP3RDX.js} +1 -1
- package/{cliExecutor-4MAX3PZL.js → cliExecutor-K6FDZTQ2.js} +3 -1
- package/{cliLocalAgentRecordReader-Z7CH4K4R.js → cliLocalAgentRecordReader-HVZAQCUD.js} +49 -44
- package/{commandRegistry-3JVE76K2.js → commandRegistry-TME7INFU.js} +98 -94
- package/{contentThunks-SRKUHSBR.js → contentThunks-U6OC4R2N.js} +37 -35
- package/{cooldownCommands-X7P5M2V5.js → cooldownCommands-U7XSRVJP.js} +4 -4
- package/{createAgentAutomationAction-B4BQV46J.js → createAgentAutomationAction-IP4LFN3W.js} +37 -35
- package/{createDialogAction-IONSKZIX.js → createDialogAction-IAGQJ3LH.js} +38 -37
- package/{createPageAction-K75KBQOO.js → createPageAction-AZ3UIFKA.js} +38 -36
- package/{db-CS4ZJQKV.js → db-M7FU2GNK.js} +9 -6
- package/{dbSlice-ZJPDIFER.js → dbSlice-DKKMJJYY.js} +13 -12
- package/{deleteFile-Q3YDB4ML.js → deleteFile-TQSONMVU.js} +11 -8
- package/{dialogCommands-6KQEBHSG.js → dialogCommands-PCDRMBWG.js} +60 -55
- package/dialogMessageRecord-OAV77LT7.js +7 -0
- package/{dialogNotifyCommand-WIZFFEY3.js → dialogNotifyCommand-O35MWMOS.js} +13 -13
- package/{dialogSlice-GPALSBQM.js → dialogSlice-QAKYN4DE.js} +35 -33
- package/{dialogUsageCommand-HTVPR2CX.js → dialogUsageCommand-2SSLTXKO.js} +3 -3
- package/{docCreateCommands-XZOLWBRC.js → docCreateCommands-CFQFZOAD.js} +54 -48
- package/{docDeleteCommands-ZSO4LGWE.js → docDeleteCommands-5CPNTIIS.js} +56 -50
- package/{docReadCommands-TTMXCDER.js → docReadCommands-XQILYSAJ.js} +54 -48
- package/{docStore-O43KOHIX.js → docStore-GIVRT7TQ.js} +15 -14
- package/{docUpdateCommands-PRG6WOXL.js → docUpdateCommands-VETKSUDD.js} +54 -48
- package/fetchMessages-TQEUZD7H.js +1 -1
- package/{getPricing-YH3VMSVU.js → getPricing-LF5C4XSI.js} +5 -5
- package/{handleSendMessageAction-I2GHUSHZ.js → handleSendMessageAction-HKIW4ZNO.js} +70 -66
- package/{hostCredentialCreate-V775SKCE.js → hostCredentialCreate-6VDJFNDO.js} +118 -105
- 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-AV2VKKPG.js} +1 -1
- package/{localRecall-2J6QPOK2.js → localRecall-BDYKXB46.js} +3 -1
- package/{localRuntimeAdapter-SAMUDW5S.js → localRuntimeAdapter-BQ4F5PZV.js} +120 -108
- package/{localRuntimeAuthority-IBJAT62G.js → localRuntimeAuthority-WCNA4A3G.js} +4 -2
- package/{localRuntimeDb-N7KHDXS2.js → localRuntimeDb-CRNIBOOM.js} +1 -1
- package/{machineCommands-ZXZWGMFE.js → machineCommands-K6XIGOAD.js} +142 -115
- package/{machineWsRunDispatch-3ZEI4BEC.js → machineWsRunDispatch-4OO7Z6UM.js} +114 -102
- package/mcpLocalAuthorizeCommand-ZP6ESAGE.js +106 -0
- package/{memberThunks-JRYNONYV.js → memberThunks-PBJPZ2JU.js} +22 -17
- package/{memoryCommands-5WC3T66U.js → memoryCommands-BC6REPQB.js} +4 -4
- package/{models-CXINDUJA.js → models-H5NNZRLH.js} +2 -2
- package/{overlay-THLKYIWY.js → overlay-JA3SPVUS.js} +7 -3
- package/package.json +1 -1
- package/{projectArchive-V7EYBAX6.js → projectArchive-G7AOQPRW.js} +43 -41
- package/{providerPresetApply-SHT2SUVB.js → providerPresetApply-OPBCAONX.js} +6 -6
- package/{providerRegistry-TA7EGCVZ.js → providerRegistry-J2HCVTHE.js} +6 -6
- package/{read-Q7GOHGNP.js → read-JEGPITEW.js} +10 -9
- package/{readDocTool-Z5OQ6422.js → readDocTool-TE3XIU4Y.js} +1 -1
- package/{readlineWorkspace-S4VRNWYG.js → readlineWorkspace-SOW5QUGZ.js} +4412 -4279
- package/{removeDialogAgentAction-U3F2MNAY.js → removeDialogAgentAction-CX3OAH4Y.js} +17 -16
- package/{runAgentClientLoop-MQLOUDF5.js → runAgentClientLoop-HQJPDFGQ.js} +95 -70
- package/{runtimeDoctorCommands-I47JN4HS.js → runtimeDoctorCommands-GUH2YGMH.js} +17 -17
- package/{secretCommands-LJXOOYA7.js → secretCommands-NJXFVHZU.js} +4 -4
- package/{setDialogExtraReferencesAction-G3WSJ7EM.js → setDialogExtraReferencesAction-CGM67EEQ.js} +16 -15
- package/{setPrimaryDialogAgentAction-6FHAHZBB.js → setPrimaryDialogAgentAction-3ABWPPXR.js} +17 -16
- package/{settingThunks-AXTBX3Q5.js → settingThunks-AY76OHYX.js} +181 -62
- package/{skillDiscovery-B5V23AXP.js → skillDiscovery-MDDKPTW3.js} +4 -3
- package/{spaceCommands-IB6FKWIC.js → spaceCommands-G63QGYQO.js} +59 -53
- package/{store-JRVN62NM.js → store-Z53ICFL3.js} +3 -1
- package/{streamAgentChatTurn-GMNIKJVL.js → streamAgentChatTurn-E3XH2KFD.js} +160 -155
- package/{switchDialogAgentAction-UOFIAGPL.js → switchDialogAgentAction-G6EZRKCQ.js} +15 -14
- package/{tableCommands-HITDSLHS.js → tableCommands-JI75ZHDI.js} +14 -11
- package/{toolApiClient-OGQEBQVX.js → toolApiClient-62UUPDUA.js} +3 -5
- package/{tools-MWIF3S4T.js → tools-7RSX22FT.js} +64 -59
- package/tuiRestart-KAAA7TND.js +41 -0
- package/{tuiSummaryLlmCaller-7LWYTHLM.js → tuiSummaryLlmCaller-BVNHMWLR.js} +19 -19
- package/{updateCommands-RJVCRSBP.js → updateCommands-ASK5XYPH.js} +8 -6
- package/{updateDialogTitleAction-ZXHMZFSX.js → updateDialogTitleAction-SEWV252V.js} +37 -35
- package/{usageCommand-RVKHEPLU.js → usageCommand-JVT5J3DC.js} +3 -3
- package/{usageRebuildCommand-GRAFOZF2.js → usageRebuildCommand-IZYYUTEW.js} +4 -4
- package/webapi-24RZDIIQ.js +2488 -0
- package/{windowsSelfUpdate-KERHIAB4.js → windowsSelfUpdate-BSDIS2J5.js} +2 -2
- package/workContext-MM3P5GP5.js +13 -0
- package/workContextAccess-UZHDLBUR.js +11 -0
- package/workContextWriteNotice-YCSSMHN4.js +7 -0
- package/agentRecordCommands-S2IVVEES.js +0 -177
- package/chunk-2THCNKE4.js +0 -147
- package/chunk-2WZXXAQD.js +0 -57
- package/chunk-652XYZGP.js +0 -352
- package/chunk-BJF2MHJ3.js +0 -118
- package/chunk-KEPOVMF4.js +0 -91
- package/chunk-OXKUPBAQ.js +0 -776
- 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/{offlineMarxistsAgentCommand-4IC3Y4C6.js → offlineMarxistsAgentCommand-XVXUE6G5.js} +3 -3
- package/{workloadLifecycle-O2I3NZ2Q.js → workloadLifecycle-YIZ7KLUP.js} +3 -3
|
@@ -1,29 +1,225 @@
|
|
|
1
1
|
import {
|
|
2
2
|
resolveRuntimeAuthToken,
|
|
3
3
|
resolveRuntimeServerUrl
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-2X7WFDT6.js";
|
|
5
5
|
import {
|
|
6
6
|
isAgentRunTerminalStatus,
|
|
7
7
|
normalizeRunTitle,
|
|
8
8
|
shortAgentKey
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-OOJNQK6V.js";
|
|
10
10
|
import {
|
|
11
11
|
findPowerShellExecutable
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-VMJVAJ6W.js";
|
|
13
13
|
import {
|
|
14
14
|
AUTH_ERROR_PATTERNS
|
|
15
15
|
} from "./chunk-EWQ3HGNZ.js";
|
|
16
|
+
import {
|
|
17
|
+
AGENT_RUN_PROTOCOL,
|
|
18
|
+
HOST_RUNTIME_CONTENT_IDENTITY,
|
|
19
|
+
RuntimeVersionMismatchError,
|
|
20
|
+
getHostRuntimeExecutable,
|
|
21
|
+
isCompiledBinary,
|
|
22
|
+
resolveCliEntrypointPath,
|
|
23
|
+
resolveExactRuntimeEntrypoint
|
|
24
|
+
} from "./chunk-BIDSIRTS.js";
|
|
16
25
|
import {
|
|
17
26
|
isRecord
|
|
18
27
|
} from "./chunk-KUG52IAP.js";
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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,34 @@ function listRunRecords(deps = {}) {
|
|
|
2027
2221
|
(a, b) => new Date(b.startedAt).getTime() - new Date(a.startedAt).getTime()
|
|
2028
2222
|
);
|
|
2029
2223
|
}
|
|
2224
|
+
async function listRunRecordsAsync(deps = {}) {
|
|
2225
|
+
const dir = resolveRunsDir(deps.env, deps.homedir);
|
|
2226
|
+
let entries;
|
|
2227
|
+
try {
|
|
2228
|
+
entries = await nodeFs2.promises.readdir(dir);
|
|
2229
|
+
} catch {
|
|
2230
|
+
return [];
|
|
2231
|
+
}
|
|
2232
|
+
const records = new Array(entries.length);
|
|
2233
|
+
let next = 0;
|
|
2234
|
+
const readNext = async () => {
|
|
2235
|
+
while (next < entries.length) {
|
|
2236
|
+
const index = next++;
|
|
2237
|
+
const entry = entries[index];
|
|
2238
|
+
if (!entry.endsWith(".json")) continue;
|
|
2239
|
+
const path = resolveRunRecordPath(entry.slice(0, -5), deps.env, deps.homedir);
|
|
2240
|
+
for (let attempt = 0; attempt < 2; attempt++) {
|
|
2241
|
+
try {
|
|
2242
|
+
records[index] = JSON.parse(await nodeFs2.promises.readFile(path, "utf8"));
|
|
2243
|
+
break;
|
|
2244
|
+
} catch {
|
|
2245
|
+
}
|
|
2246
|
+
}
|
|
2247
|
+
}
|
|
2248
|
+
};
|
|
2249
|
+
await Promise.all(Array.from({ length: Math.min(16, entries.length) }, readNext));
|
|
2250
|
+
return records.filter((record) => Boolean(record)).sort((a, b) => new Date(b.startedAt).getTime() - new Date(a.startedAt).getTime());
|
|
2251
|
+
}
|
|
2030
2252
|
function findRunRecordByPid(pid, deps = {}) {
|
|
2031
2253
|
return listRunRecords(deps).find((record) => record.pid === pid);
|
|
2032
2254
|
}
|
|
@@ -2131,7 +2353,7 @@ async function gcRunRecords(deps = {}, options = {}) {
|
|
|
2131
2353
|
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
2354
|
if (!fs.existsSync(artifact.path)) continue;
|
|
2133
2355
|
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 ||
|
|
2356
|
+
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
2357
|
throw new Error("artifact identity changed");
|
|
2136
2358
|
}
|
|
2137
2359
|
if (!tryUnlinkFile(fs, artifact.path)) artifactsOk = false;
|
|
@@ -2220,38 +2442,22 @@ function rewriteMsgFileArg(args, messagePath) {
|
|
|
2220
2442
|
return result;
|
|
2221
2443
|
}
|
|
2222
2444
|
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;
|
|
2445
|
+
const entrypoint = cliEntrypointPath ?? resolveCliEntrypointPath();
|
|
2446
|
+
if (!fs.existsSync(entrypoint)) throw new RuntimeVersionMismatchError("runtime entrypoint missing");
|
|
2447
|
+
return fs === nodeFs2 ? resolveExactRuntimeEntrypoint(entrypoint) : String(fs.realpathSync?.(entrypoint) ?? entrypoint);
|
|
2243
2448
|
}
|
|
2244
2449
|
function buildAgentRunChildCommand(options, deps = {}) {
|
|
2245
2450
|
const fs = deps.fs ?? nodeFs2;
|
|
2246
|
-
const execPath =
|
|
2451
|
+
const execPath = getHostRuntimeExecutable();
|
|
2247
2452
|
const commandParts = options.commandPath ?? [];
|
|
2248
2453
|
let strippedArgs = stripBackgroundFlag(options.rawArgs);
|
|
2249
2454
|
if (options.messagePath) {
|
|
2250
2455
|
strippedArgs = rewriteMsgFileArg(strippedArgs, options.messagePath);
|
|
2251
2456
|
}
|
|
2252
2457
|
strippedArgs = absolutizeSkillArgs(strippedArgs);
|
|
2253
|
-
if (isCompiledBinary() || options.cliEntrypointPath === execPath) {
|
|
2254
|
-
|
|
2458
|
+
if (isCompiledBinary() || options.cliEntrypointPath === process.execPath || options.cliEntrypointPath === execPath) {
|
|
2459
|
+
const fixed = resolveValidCliEntrypoint(isCompiledBinary() ? execPath : options.cliEntrypointPath ?? execPath, fs);
|
|
2460
|
+
return { execPath: fixed, childArgs: [...commandParts, ...strippedArgs] };
|
|
2255
2461
|
}
|
|
2256
2462
|
const entrypoint = resolveValidCliEntrypoint(options.cliEntrypointPath, fs);
|
|
2257
2463
|
if (entrypoint === execPath) {
|
|
@@ -2329,11 +2535,11 @@ function localWriterRecovery(record) {
|
|
|
2329
2535
|
function revokePreparedWriterLaunch(runId, attemptId, deps = {}) {
|
|
2330
2536
|
if (!/^[A-Za-z0-9_-]+$/.test(runId) || !attemptId) return "blocked";
|
|
2331
2537
|
return withRunRecordLock("local-writer-admission", deps, () => {
|
|
2332
|
-
const
|
|
2333
|
-
if (!
|
|
2538
|
+
const snapshot2 = readRunRecord(runId, deps);
|
|
2539
|
+
if (!snapshot2) return "blocked";
|
|
2334
2540
|
return withRunRecordLock(runId, deps, () => {
|
|
2335
2541
|
const latest = readRunRecord(runId, deps);
|
|
2336
|
-
if (!latest || JSON.stringify(latest) !== JSON.stringify(
|
|
2542
|
+
if (!latest || JSON.stringify(latest) !== JSON.stringify(snapshot2)) return "blocked";
|
|
2337
2543
|
const launch = latest.writerLaunch;
|
|
2338
2544
|
if (launch?.protocol !== "fenced-launch-v1" || launch.attemptId !== attemptId) return "blocked";
|
|
2339
2545
|
if (launch.phase === "revoked") return latest.localWriterClaim?.state === "released" ? "already-revoked" : "blocked";
|
|
@@ -2352,10 +2558,10 @@ function localWriterStillOwns(record, deps) {
|
|
|
2352
2558
|
const observed = e?.state === "known" && e.owner.state === "verified" ? nativeOwner(record.pid, deps) : void 0;
|
|
2353
2559
|
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
2560
|
if (!isPidGone(record.pid, deps) && !reused) return true;
|
|
2355
|
-
const
|
|
2561
|
+
const snapshot2 = JSON.stringify(record);
|
|
2356
2562
|
const released = withRunRecordLock(record.runId, deps, () => {
|
|
2357
2563
|
const latest = readRunRecord(record.runId, deps);
|
|
2358
|
-
if (!latest || JSON.stringify(latest) !==
|
|
2564
|
+
if (!latest || JSON.stringify(latest) !== snapshot2) return false;
|
|
2359
2565
|
latest.localWriterClaim.state = "released";
|
|
2360
2566
|
writeRunRecord(latest, deps);
|
|
2361
2567
|
return true;
|
|
@@ -2364,14 +2570,14 @@ function localWriterStillOwns(record, deps) {
|
|
|
2364
2570
|
}
|
|
2365
2571
|
function acquireLocalWriterClaim(runId, cwd, deps) {
|
|
2366
2572
|
const fs = deps.fs ?? nodeFs2;
|
|
2367
|
-
const
|
|
2368
|
-
const worktree = trustedLocalWorktree(
|
|
2573
|
+
const canonical2 = String((fs.realpathSync ?? nodeFs2.realpathSync)(cwd));
|
|
2574
|
+
const worktree = trustedLocalWorktree(canonical2, deps);
|
|
2369
2575
|
const acquired = withRunRecordLock("local-writer-admission", deps, () => {
|
|
2370
2576
|
const updated = withRunRecordLock(runId, deps, () => {
|
|
2371
2577
|
const record = readRunRecord(runId, deps);
|
|
2372
2578
|
if (!record) throw new Error(`[local-writer-resource] missing run ${runId}`);
|
|
2373
2579
|
if (record.writerLaunch?.phase === "revoked") throw new Error("[local-writer-resource] claim attempt revoked");
|
|
2374
|
-
record.localWriterClaim = { cwd:
|
|
2580
|
+
record.localWriterClaim = { cwd: canonical2, ...worktree ? { worktree } : {}, state: "held" };
|
|
2375
2581
|
if (record.writerLaunch && record.execution?.state === "known" && record.execution.owner.state === "verified" && record.pid === process.pid) {
|
|
2376
2582
|
record.writerLaunch.phase = "granted";
|
|
2377
2583
|
}
|
|
@@ -2382,7 +2588,7 @@ function acquireLocalWriterClaim(runId, cwd, deps) {
|
|
|
2382
2588
|
return true;
|
|
2383
2589
|
}, { strict: true, requireDeadOwner: true });
|
|
2384
2590
|
if (!acquired) throw new Error("[local-writer-resource] admission lock busy; no child spawned");
|
|
2385
|
-
return
|
|
2591
|
+
return canonical2;
|
|
2386
2592
|
}
|
|
2387
2593
|
function nativeOwner(pid, deps) {
|
|
2388
2594
|
const first = probeProcessStartTime(pid, deps);
|
|
@@ -2482,19 +2688,19 @@ function resolveLocalContinuation(record, deps = {}) {
|
|
|
2482
2688
|
}
|
|
2483
2689
|
function registerLocalForegroundWriter(cwd, policy, agentKey, deps = {}) {
|
|
2484
2690
|
const fs = deps.fs ?? nodeFs2;
|
|
2485
|
-
const
|
|
2691
|
+
const canonical2 = String((fs.realpathSync ?? nodeFs2.realpathSync)(cwd));
|
|
2486
2692
|
const owner = nativeOwner(process.pid, deps);
|
|
2487
2693
|
if (owner.state !== "verified" || policy.readOnly || !policy.hostWritesAuthorized) {
|
|
2488
2694
|
throw new Error("[local-writer-resource] foreground native identity/authorization unknown");
|
|
2489
2695
|
}
|
|
2490
2696
|
const runId = defaultGenerateRunId();
|
|
2491
2697
|
fs.mkdirSync(resolveRunsDir(deps.env, deps.homedir), { recursive: true });
|
|
2492
|
-
const worktree = trustedLocalWorktree(
|
|
2698
|
+
const worktree = trustedLocalWorktree(canonical2, deps);
|
|
2493
2699
|
const record = {
|
|
2494
2700
|
runId,
|
|
2495
2701
|
agentKey,
|
|
2496
|
-
writerLaunch: { protocol: "fenced-launch-v1", attemptId:
|
|
2497
|
-
cwd:
|
|
2702
|
+
writerLaunch: { protocol: "fenced-launch-v1", attemptId: randomUUID3(), phase: "prepared" },
|
|
2703
|
+
cwd: canonical2,
|
|
2498
2704
|
startedAt: (deps.now?.() ?? /* @__PURE__ */ new Date()).toISOString(),
|
|
2499
2705
|
status: "running",
|
|
2500
2706
|
logPath: resolveRunLogPath(runId, deps.env, deps.homedir),
|
|
@@ -2505,7 +2711,7 @@ function registerLocalForegroundWriter(cwd, policy, agentKey, deps = {}) {
|
|
|
2505
2711
|
state: "known",
|
|
2506
2712
|
kind: "host-local",
|
|
2507
2713
|
runtimeKey: "local",
|
|
2508
|
-
canonicalCwd:
|
|
2714
|
+
canonicalCwd: canonical2,
|
|
2509
2715
|
device: { kind: "localhost", hostname: nodeHostname(), platform: process.platform },
|
|
2510
2716
|
...worktree ? { worktree } : {},
|
|
2511
2717
|
permissions: {
|
|
@@ -2520,7 +2726,7 @@ function registerLocalForegroundWriter(cwd, policy, agentKey, deps = {}) {
|
|
|
2520
2726
|
};
|
|
2521
2727
|
writeRunRecord(record, deps);
|
|
2522
2728
|
try {
|
|
2523
|
-
acquireLocalWriterClaim(runId,
|
|
2729
|
+
acquireLocalWriterClaim(runId, canonical2, deps);
|
|
2524
2730
|
} catch (error) {
|
|
2525
2731
|
finalizeRunRecord(runId, { status: "failed", exitCode: 1, note: String(error) }, deps);
|
|
2526
2732
|
throw error;
|
|
@@ -2539,6 +2745,48 @@ function releaseUnspawnedLocalWriterClaim(runId, deps) {
|
|
|
2539
2745
|
}, { strict: true });
|
|
2540
2746
|
if (!released) throw new Error(`[local-writer-resource] release lock busy: ${runId}`);
|
|
2541
2747
|
}
|
|
2748
|
+
async function recordRunStartup(runId, phase, deps = {}) {
|
|
2749
|
+
const attempt = () => withRunRecordLock(runId, deps, () => {
|
|
2750
|
+
const record = readRunRecord(runId, deps);
|
|
2751
|
+
if (!record || isRunTerminalStatus(record.status)) return true;
|
|
2752
|
+
record.startup = { protocol: AGENT_RUN_PROTOCOL, phase };
|
|
2753
|
+
writeRunRecord(record, deps);
|
|
2754
|
+
return true;
|
|
2755
|
+
}, { strict: true });
|
|
2756
|
+
const deadline = Date.now() + 2e3;
|
|
2757
|
+
while (!attempt()) {
|
|
2758
|
+
if (Date.now() >= deadline) throw new Error(`Startup evidence lock busy: ${runId}`);
|
|
2759
|
+
await new Promise((resolve2) => setTimeout(resolve2, 20));
|
|
2760
|
+
}
|
|
2761
|
+
}
|
|
2762
|
+
async function settleBackgroundProcessExit(runId, code, signal, deps = {}) {
|
|
2763
|
+
const deadline = Date.now() + 2e3;
|
|
2764
|
+
while (true) {
|
|
2765
|
+
const settled = withRunRecordLock(runId, deps, () => {
|
|
2766
|
+
const record = readRunRecord(runId, deps);
|
|
2767
|
+
if (!record) return true;
|
|
2768
|
+
if (isRunTerminalStatus(record.status)) {
|
|
2769
|
+
record.processExit = { code, signal };
|
|
2770
|
+
writeRunRecord(record, deps);
|
|
2771
|
+
return true;
|
|
2772
|
+
}
|
|
2773
|
+
return false;
|
|
2774
|
+
}, { strict: true });
|
|
2775
|
+
if (settled === true) return;
|
|
2776
|
+
if (settled === false) {
|
|
2777
|
+
const result = transitionRunToTerminal(runId, {
|
|
2778
|
+
status: signal === "SIGTERM" || signal === "SIGKILL" ? "killed" : "failed",
|
|
2779
|
+
exitCode: code ?? 1,
|
|
2780
|
+
processExit: { code, signal },
|
|
2781
|
+
failureReason: signal === "SIGTERM" || signal === "SIGKILL" ? "cancelled" : "startup_failed",
|
|
2782
|
+
note: `Child exited without terminal result (code=${code}, signal=${signal})`
|
|
2783
|
+
}, deps);
|
|
2784
|
+
if (result.kind !== "contended") return;
|
|
2785
|
+
}
|
|
2786
|
+
if (Date.now() >= deadline) throw new Error(`Process exit settlement lock busy: ${runId}`);
|
|
2787
|
+
await (deps.sleep ?? defaultSleep)(20);
|
|
2788
|
+
}
|
|
2789
|
+
}
|
|
2542
2790
|
async function spawnLocalBackgroundRun(input, deps = {}) {
|
|
2543
2791
|
const homedir = deps.homedir ?? nodeHomedir;
|
|
2544
2792
|
const env = deps.env ?? (deps.homedir ? { ...process.env, NOLO_HOME: join2(homedir(), ".nolo") } : process.env);
|
|
@@ -2611,12 +2859,13 @@ async function spawnLocalBackgroundRun(input, deps = {}) {
|
|
|
2611
2859
|
...input.evidenceScope ? { evidenceScope: input.evidenceScope } : {},
|
|
2612
2860
|
...input.dispatchSpeedProvenance ? { dispatchSpeedProvenance: input.dispatchSpeedProvenance } : {},
|
|
2613
2861
|
runId,
|
|
2862
|
+
startup: { protocol: AGENT_RUN_PROTOCOL, phase: "spawn" },
|
|
2614
2863
|
agentKey: input.agentKey,
|
|
2615
2864
|
agentName: input.agentName?.trim() || shortAgentKey(input.agentKey),
|
|
2616
2865
|
...title ? { title } : {},
|
|
2617
2866
|
cwd: canonicalCwd ?? input.cwd,
|
|
2618
2867
|
execution,
|
|
2619
|
-
...executionRequest ? { writerLaunch: { protocol: "fenced-launch-v1", attemptId:
|
|
2868
|
+
...executionRequest ? { writerLaunch: { protocol: "fenced-launch-v1", attemptId: randomUUID3(), phase: "prepared" } } : {},
|
|
2620
2869
|
...executionRequest ? (() => {
|
|
2621
2870
|
const parent = nativeOwner(process.pid, resolvedDeps);
|
|
2622
2871
|
return parent.state === "verified" ? { ownerPublication: { state: "pending", parent } } : {};
|
|
@@ -2641,17 +2890,32 @@ async function spawnLocalBackgroundRun(input, deps = {}) {
|
|
|
2641
2890
|
const rawArgsWithQueue = (input.rawArgs ?? []).some(
|
|
2642
2891
|
(arg) => arg === "--queue-file" || arg.startsWith("--queue-file=")
|
|
2643
2892
|
) ? input.rawArgs : [...input.rawArgs ?? [], "--queue-file", queuePath];
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2893
|
+
let childCommand;
|
|
2894
|
+
try {
|
|
2895
|
+
childCommand = buildAgentRunChildCommand(
|
|
2896
|
+
{
|
|
2897
|
+
rawArgs: rawArgsWithQueue,
|
|
2898
|
+
commandPath: input.commandPath,
|
|
2899
|
+
cliEntrypointPath: input.cliEntrypointPath,
|
|
2900
|
+
messagePath
|
|
2901
|
+
},
|
|
2902
|
+
deps
|
|
2903
|
+
);
|
|
2904
|
+
} catch (error) {
|
|
2905
|
+
const result = await settleRunTerminalAuthoritatively(runId, {
|
|
2906
|
+
status: "failed",
|
|
2907
|
+
exitCode: 1,
|
|
2908
|
+
failureReason: error instanceof RuntimeVersionMismatchError ? "runtime_version_mismatch" : "startup_failed",
|
|
2909
|
+
note: String(error)
|
|
2910
|
+
}, resolvedDeps, (id, update, d) => transitionRunToTerminal(id, update, d));
|
|
2911
|
+
if (result.kind === "contended") throw new Error(`Startup settlement lock busy: ${runId}; ${error}`);
|
|
2912
|
+
throw error;
|
|
2913
|
+
}
|
|
2914
|
+
const { execPath, childArgs } = childCommand;
|
|
2653
2915
|
const childEnv = {
|
|
2654
2916
|
...env,
|
|
2917
|
+
NOLO_AGENT_RUN_PROTOCOL: AGENT_RUN_PROTOCOL,
|
|
2918
|
+
NOLO_AGENT_RUN_CONTENT_IDENTITY: HOST_RUNTIME_CONTENT_IDENTITY,
|
|
2655
2919
|
NOLO_AGENT_RUN_CHILD: "1",
|
|
2656
2920
|
NOLO_AGENT_RUN_ID: runId,
|
|
2657
2921
|
...record.writerLaunch ? { NOLO_WRITER_LAUNCH_ATTEMPT: record.writerLaunch.attemptId } : {}
|
|
@@ -2697,31 +2961,49 @@ async function spawnLocalBackgroundRun(input, deps = {}) {
|
|
|
2697
2961
|
detached: true,
|
|
2698
2962
|
// Detached on Windows means no console; hide the one its children would create.
|
|
2699
2963
|
windowsHide: true,
|
|
2700
|
-
stdio: deps.shellApprovalHost ? ["ignore", logFd, logFd, "ipc"] : ["ignore", logFd, logFd]
|
|
2964
|
+
stdio: deps.shellApprovalHost || deps.mcpApprovalHost ? ["ignore", logFd, logFd, "ipc"] : ["ignore", logFd, logFd]
|
|
2701
2965
|
});
|
|
2702
2966
|
} catch (error) {
|
|
2703
2967
|
try {
|
|
2704
2968
|
reservation?.release("spawn_sync_failed");
|
|
2705
2969
|
if (input.claimLocalWrites) releaseUnspawnedLocalWriterClaim(runId, resolvedDeps);
|
|
2706
2970
|
} finally {
|
|
2707
|
-
finalizeRunRecord(runId, { status: "failed", exitCode: 1, note: String(error) }, resolvedDeps);
|
|
2971
|
+
finalizeRunRecord(runId, { status: "failed", exitCode: 1, failureReason: error instanceof RuntimeVersionMismatchError ? "runtime_version_mismatch" : "startup_failed", note: String(error) }, resolvedDeps);
|
|
2708
2972
|
}
|
|
2709
2973
|
throw error;
|
|
2710
2974
|
} finally {
|
|
2711
2975
|
fs.closeSync?.(logFd);
|
|
2712
2976
|
}
|
|
2713
2977
|
proc.once?.("error", (error) => {
|
|
2978
|
+
let note = String(error);
|
|
2714
2979
|
try {
|
|
2715
2980
|
reservation.release("child_error");
|
|
2716
2981
|
} catch (releaseError) {
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2982
|
+
note += `; reservation release failed: ${releaseError}`;
|
|
2983
|
+
}
|
|
2984
|
+
void settleRunTerminalAuthoritatively(runId, {
|
|
2985
|
+
status: "failed",
|
|
2986
|
+
exitCode: 1,
|
|
2987
|
+
failureReason: "startup_failed",
|
|
2988
|
+
note
|
|
2989
|
+
}, resolvedDeps, (id, update, d) => transitionRunToTerminal(id, update, d)).then((result) => {
|
|
2990
|
+
if (result.kind === "contended") throw new Error(`Startup settlement lock busy: ${runId}`);
|
|
2991
|
+
}).catch((error2) => {
|
|
2992
|
+
input.output?.write(`[nolo] background error settlement failed: ${error2}
|
|
2993
|
+
`);
|
|
2994
|
+
});
|
|
2995
|
+
});
|
|
2996
|
+
proc.once?.("exit", (code, signal) => {
|
|
2997
|
+
void settleBackgroundProcessExit(runId, code, signal, resolvedDeps).catch((error) => {
|
|
2998
|
+
input.output?.write(`[nolo] background exit settlement failed: ${error}
|
|
2999
|
+
`);
|
|
3000
|
+
});
|
|
3001
|
+
try {
|
|
3002
|
+
reservation.release("child_exit");
|
|
3003
|
+
} catch (error) {
|
|
3004
|
+
input.output?.write(`[nolo] reservation release failed: ${error}
|
|
3005
|
+
`);
|
|
2723
3006
|
}
|
|
2724
|
-
finalizeRunRecord(runId, { status: "failed", exitCode: 1, note: String(error) }, resolvedDeps);
|
|
2725
3007
|
});
|
|
2726
3008
|
const hostMemoryNotice = emitHostMemoryNotice(hostMemory, input.output);
|
|
2727
3009
|
if (typeof proc.pid === "number") {
|
|
@@ -2783,6 +3065,15 @@ async function spawnLocalBackgroundRun(input, deps = {}) {
|
|
|
2783
3065
|
throw new Error(`[host-memory-reservation] child ${proc.pid}, run ${runId}: association failed: ${error}`);
|
|
2784
3066
|
}
|
|
2785
3067
|
}
|
|
3068
|
+
if (deps.mcpApprovalHost) {
|
|
3069
|
+
attachMcpApprovalHost(proc, { ...deps.mcpApprovalHost, binding: {
|
|
3070
|
+
...deps.mcpApprovalHost.binding,
|
|
3071
|
+
runId,
|
|
3072
|
+
agentKey: input.agentKey,
|
|
3073
|
+
workspaceRoot: nodeFs2.realpathSync(input.cwd ?? process.cwd())
|
|
3074
|
+
} });
|
|
3075
|
+
proc.channel?.unref?.();
|
|
3076
|
+
}
|
|
2786
3077
|
if (deps.shellApprovalHost) {
|
|
2787
3078
|
attachShellApprovalHost(proc, { ...deps.shellApprovalHost, binding: {
|
|
2788
3079
|
...deps.shellApprovalHost.binding,
|
|
@@ -2876,10 +3167,15 @@ function transitionRunToTerminal(runId, update, deps = {}, options = {}) {
|
|
|
2876
3167
|
if (!record2) return { kind: "not_found" };
|
|
2877
3168
|
const orphanCorrection = options.allowOverOrphaned === true && record2.status === "orphaned" && (update.status === "done" || update.status === "failed");
|
|
2878
3169
|
if (isAgentRunTerminalStatus(record2.status) && !orphanCorrection) {
|
|
3170
|
+
if (update.processExit) {
|
|
3171
|
+
record2.processExit = update.processExit;
|
|
3172
|
+
writeRunRecord(record2, deps);
|
|
3173
|
+
}
|
|
2879
3174
|
return { kind: "kept", record: record2 };
|
|
2880
3175
|
}
|
|
2881
3176
|
const now = deps.now ?? (() => /* @__PURE__ */ new Date());
|
|
2882
3177
|
record2.status = update.status;
|
|
3178
|
+
if (update.processExit) record2.processExit = update.processExit;
|
|
2883
3179
|
if (typeof update.exitCode === "number") record2.exitCode = update.exitCode;
|
|
2884
3180
|
if (update.dialogId) record2.dialogId = update.dialogId;
|
|
2885
3181
|
if (typeof update.credits === "number" && Number.isFinite(update.credits)) {
|
|
@@ -2929,11 +3225,11 @@ function transitionRunToTerminal(runId, update, deps = {}, options = {}) {
|
|
|
2929
3225
|
kind,
|
|
2930
3226
|
dev: String(stat.dev),
|
|
2931
3227
|
ino: String(stat.ino),
|
|
2932
|
-
sha256:
|
|
3228
|
+
sha256: createHash2("sha256").update(fs.readFileSync(path)).digest("hex")
|
|
2933
3229
|
};
|
|
2934
3230
|
record2.resultArtifacts = [...(record2.resultArtifacts ?? []).filter((a) => a.path !== path), artifact];
|
|
2935
3231
|
};
|
|
2936
|
-
if (typeof update.lastAssistantText === "string" && update.lastAssistantText || update.acceptance?.checks.observations?.length) {
|
|
3232
|
+
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
3233
|
try {
|
|
2938
3234
|
const fs = deps.fs ?? nodeFs2;
|
|
2939
3235
|
const resultFile = join2(resolveRunsDir(deps.env, deps.homedir), `${runId}.result.md`);
|
|
@@ -2960,7 +3256,7 @@ function transitionRunToTerminal(runId, update, deps = {}, options = {}) {
|
|
|
2960
3256
|
update.lastAssistantText ?? ""
|
|
2961
3257
|
);
|
|
2962
3258
|
if (typeof fs.renameSync !== "function") throw new Error("atomic result publication requires renameSync");
|
|
2963
|
-
pendingResultFile = `${resultFile}.${
|
|
3259
|
+
pendingResultFile = `${resultFile}.${randomUUID3()}.pending`;
|
|
2964
3260
|
try {
|
|
2965
3261
|
fs.writeFileSync(pendingResultFile, content, { encoding: "utf8", flag: "wx" });
|
|
2966
3262
|
stagingComplete = true;
|
|
@@ -2969,7 +3265,7 @@ function transitionRunToTerminal(runId, update, deps = {}, options = {}) {
|
|
|
2969
3265
|
}
|
|
2970
3266
|
if (fs.existsSync(resultFile)) {
|
|
2971
3267
|
const previous = fs.readFileSync(resultFile);
|
|
2972
|
-
const backup = `${resultFile}.${
|
|
3268
|
+
const backup = `${resultFile}.${randomUUID3()}.bak`;
|
|
2973
3269
|
backupFile = backup;
|
|
2974
3270
|
try {
|
|
2975
3271
|
fs.writeFileSync(backup, previous, { flag: "wx" });
|
|
@@ -3638,6 +3934,8 @@ async function runAgentRecoverPreparedWriterCommand(args, deps) {
|
|
|
3638
3934
|
}
|
|
3639
3935
|
|
|
3640
3936
|
export {
|
|
3937
|
+
createMcpApprovalChild,
|
|
3938
|
+
hasLiveShellApprovalHosts,
|
|
3641
3939
|
createShellApprovalChild,
|
|
3642
3940
|
TAIL_LINES_MAX,
|
|
3643
3941
|
readHostMemory,
|
|
@@ -3646,7 +3944,6 @@ export {
|
|
|
3646
3944
|
recordRunResultHeaderMeta,
|
|
3647
3945
|
getRunResultHeaderMeta,
|
|
3648
3946
|
serverOriginForDialog,
|
|
3649
|
-
stripResultFrontMatter,
|
|
3650
3947
|
isHistoryIntegrityFailure,
|
|
3651
3948
|
RUN_TERMINAL_STATUSES,
|
|
3652
3949
|
isRunTerminalStatus,
|
|
@@ -3684,6 +3981,7 @@ export {
|
|
|
3684
3981
|
readRunRecord,
|
|
3685
3982
|
backfillRunRecordParentDialog,
|
|
3686
3983
|
listRunRecords,
|
|
3984
|
+
listRunRecordsAsync,
|
|
3687
3985
|
findRunRecordByPid,
|
|
3688
3986
|
findRunRecord,
|
|
3689
3987
|
DEFAULT_LIST_LIMIT,
|
|
@@ -3701,6 +3999,8 @@ export {
|
|
|
3701
3999
|
awaitLocalWriterChild,
|
|
3702
4000
|
resolveLocalContinuation,
|
|
3703
4001
|
registerLocalForegroundWriter,
|
|
4002
|
+
recordRunStartup,
|
|
4003
|
+
settleBackgroundProcessExit,
|
|
3704
4004
|
spawnLocalBackgroundRun,
|
|
3705
4005
|
ackRunRecord,
|
|
3706
4006
|
DEFAULT_ACK_LEASE_TTL_MS,
|