nolo-cli 0.224.0-alpha.1 → 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.
Files changed (236) hide show
  1. package/{_executeModel-WW57SJN4.js → _executeModel-5NA4USGG.js} +77 -70
  2. package/{action-CK64LS6S.js → action-X75O3XPH.js} +11 -8
  3. package/{addContentAction-EQXMFNPR.js → addContentAction-GVC77QSN.js} +14 -13
  4. package/{addDialogAgentAction-RSDZDASD.js → addDialogAgentAction-KKDVAMW3.js} +15 -14
  5. package/{agentDeleteCommand-X2VWEKUA.js → agentDeleteCommand-2RFGKFAB.js} +127 -118
  6. package/{agentEmailCommands-6IE773VW.js → agentEmailCommands-GQCQKKOR.js} +126 -113
  7. package/{agentFavoriteCommands-2LKGKSUD.js → agentFavoriteCommands-7LOP3HUD.js} +5 -5
  8. package/{agentGrantCommands-QQV4N4JW.js → agentGrantCommands-L6O2HVJI.js} +5 -5
  9. package/{agentListCommands-5UNM7CGG.js → agentListCommands-HSGLDPDQ.js} +110 -495
  10. package/{agentMachineCommands-EVWFKK6Q.js → agentMachineCommands-BISF6PVV.js} +63 -57
  11. package/{agentProviderCommands-ZCH37KAL.js → agentProviderCommands-O3Q25PKU.js} +6 -6
  12. package/{agentPullCommand-XN6ZPBUW.js → agentPullCommand-G6U2LHMW.js} +6 -6
  13. package/agentRecordCommands-AOXPGYAJ.js +189 -0
  14. package/{agentRunCommand-KGOT2AFB.js → agentRunCommand-AFAIP7U7.js} +129 -113
  15. package/{agentRunControl-QDFW5P2T.js → agentRunControl-VBL7UFSG.js} +20 -14
  16. package/{agentRuntimeLocal-SD7U2EGY.js → agentRuntimeLocal-T7BX2WGL.js} +47 -41
  17. package/{agentSlice-ACZGTZVW.js → agentSlice-XJNKE3PG.js} +18 -17
  18. package/{appDeleteCommands-NE3NQQJL.js → appDeleteCommands-LURUSPY7.js} +56 -50
  19. package/{appDeployCommands-2BAHY522.js → appDeployCommands-SMEW4AK2.js} +56 -50
  20. package/{appDeployStatusCommands-JTW6LZNC.js → appDeployStatusCommands-VYPJTBJK.js} +56 -50
  21. package/{appGetCommands-WKFEJO6A.js → appGetCommands-N4NI5GGJ.js} +56 -50
  22. package/{appListCommands-HNAZZLFX.js → appListCommands-5C6ONN3Z.js} +56 -50
  23. package/{authCommand-4FDPL7WG.js → authCommand-4CVBDADE.js} +29 -24
  24. package/{authCommands-GAJ3NIXO.js → authCommands-EHU2BHOX.js} +12 -7
  25. package/{builtinSkillRegistry-PXH7EGQB.js → builtinSkillRegistry-AYWYQVA4.js} +4 -4
  26. package/{chromeOpsCommands-YKX2QX3A.js → chromeOpsCommands-CSDG2HYN.js} +6 -6
  27. package/{chunk-OOF7XDZF.js → chunk-2574ANSV.js} +6 -6
  28. package/chunk-2SXN7LAY.js +15 -0
  29. package/{chunk-OGHP3CTL.js → chunk-2X7WFDT6.js} +1 -1
  30. package/{chunk-XI2BWJM5.js → chunk-324FWHUA.js} +20 -3
  31. package/{chunk-D726I5AZ.js → chunk-3EMIEC27.js} +2 -2
  32. package/{chunk-S7SB7L2I.js → chunk-3FBAVU2Y.js} +24 -22
  33. package/{chunk-YL3EFYL3.js → chunk-4D4QD7FT.js} +3 -1
  34. package/{chunk-5RKUPJYL.js → chunk-4FIO2S7Z.js} +11 -3
  35. package/{chunk-MKQ2UTTX.js → chunk-4IQVE43Z.js} +63 -32
  36. package/{chunk-6NKA6RKF.js → chunk-4Q6HQORG.js} +8 -8
  37. package/{chunk-P2ZLUIW2.js → chunk-4X5AVCM7.js} +94 -4
  38. package/chunk-4ZCTKB27.js +31 -0
  39. package/{chunk-JWXITTQB.js → chunk-5HUO7SEX.js} +9 -107
  40. package/{chunk-4A2JIXR2.js → chunk-5QZSEQSK.js} +1 -1
  41. package/chunk-5ZUOVCKT.js +32 -0
  42. package/{chunk-TRWT3EE3.js → chunk-62HXNQVV.js} +1 -1
  43. package/{chunk-JC5XLWZK.js → chunk-6CKUO32A.js} +27 -15
  44. package/chunk-6D25V6CB.js +133 -0
  45. package/chunk-6WOLPIPY.js +379 -0
  46. package/{chunk-KOXKKHFE.js → chunk-6WZVM33D.js} +9 -4
  47. package/{chunk-YGMBIXCF.js → chunk-6XRPBZRS.js} +4 -2
  48. package/{chunk-KO63FPG3.js → chunk-7AJRJGSQ.js} +1049 -2860
  49. package/chunk-7NIBQ4HY.js +138 -0
  50. package/{chunk-7Z6EW7AH.js → chunk-7TTMMOKH.js} +13 -6
  51. package/{chunk-7WPAI5JJ.js → chunk-A3LUWRQK.js} +15 -15
  52. package/{chunk-C4WTX5TU.js → chunk-A5EVA6HU.js} +2 -2
  53. package/{chunk-O2CYENYJ.js → chunk-A74QP4FI.js} +2614 -1374
  54. package/{chunk-N3J4VDGV.js → chunk-AEQMKYZN.js} +15 -15
  55. package/{chunk-DVQH4BTR.js → chunk-AH5R7BYW.js} +26 -176
  56. package/{chunk-H7R3365N.js → chunk-ANJRDS6U.js} +8 -5
  57. package/{chunk-YFLVRVYK.js → chunk-AVJDELEA.js} +1 -1
  58. package/{chunk-GIABSSWQ.js → chunk-B5SV4H3J.js} +4 -4
  59. package/{chunk-FVZW66K4.js → chunk-B7DE5XJW.js} +387 -347
  60. package/chunk-BEM6LPD2.js +734 -0
  61. package/{chunk-SRL56PI2.js → chunk-BGGAY6OK.js} +46 -8
  62. package/{chunk-T3O6BLYU.js → chunk-BGGV6B5O.js} +555 -328
  63. package/{chunk-BGGHA5DV.js → chunk-BIABIPGW.js} +1 -1
  64. package/chunk-BIDSIRTS.js +307 -0
  65. package/{chunk-6D7NVU66.js → chunk-BXSMFPTG.js} +17 -14
  66. package/{chunk-Q6HOUF4O.js → chunk-CBUZ6DKA.js} +3 -3
  67. package/{chunk-LE6LGAJE.js → chunk-CD3RU7XL.js} +17 -2
  68. package/{chunk-GVGOEMNV.js → chunk-CKZPMJNU.js} +3 -3
  69. package/{chunk-3ESU44FG.js → chunk-CVJRVBJL.js} +3 -3
  70. package/chunk-D374I563.js +62 -0
  71. package/{chunk-XWGDCWXY.js → chunk-DNZ4JJ7C.js} +9 -9
  72. package/chunk-DVYAFH2Q.js +103 -0
  73. package/{chunk-N7HVLYOY.js → chunk-DXW5WDHZ.js} +4 -4
  74. package/{chunk-KFHREHUQ.js → chunk-DXWGFL2Z.js} +89 -1
  75. package/{chunk-65XXHYZ5.js → chunk-E5KJOZWY.js} +4 -4
  76. package/{chunk-GNHMRBYZ.js → chunk-EBKHA63G.js} +106 -14
  77. package/{chunk-PFJNLBRU.js → chunk-EEOOBRA7.js} +6 -6
  78. package/{chunk-M3JEW6N6.js → chunk-F26GAEH3.js} +10 -0
  79. package/{chunk-QLFCTYRH.js → chunk-F3XI6WQP.js} +17 -10
  80. package/{chunk-AFHOCBSP.js → chunk-F6YWDVIB.js} +1 -1
  81. package/{chunk-VHPAA6MT.js → chunk-FFYE5ATM.js} +6 -6
  82. package/{chunk-F3TQURKK.js → chunk-FZKA3XFA.js} +21 -21
  83. package/{chunk-C4VAR65S.js → chunk-G22P367E.js} +153 -117
  84. package/{chunk-4NMHE7CX.js → chunk-GDUC4VS2.js} +12 -12
  85. package/{chunk-2VUZSVAS.js → chunk-GXXY2NL3.js} +22 -20
  86. package/{chunk-IWH5SOU4.js → chunk-H7ZYKHAZ.js} +38 -18
  87. package/{chunk-G2EJ7NL4.js → chunk-HBRDSQ3M.js} +2 -2
  88. package/{chunk-EGXPAWLG.js → chunk-HCNOO374.js} +1 -1
  89. package/{chunk-DJSTBAOU.js → chunk-HOM6LTEW.js} +4 -4
  90. package/{chunk-S2NTVGA2.js → chunk-I2OYPD3Y.js} +1 -1
  91. package/{chunk-QWYFFHCJ.js → chunk-IJTXNLQE.js} +13 -13
  92. package/{chunk-UYOICCYG.js → chunk-IUMS6F53.js} +59 -88
  93. package/{chunk-MOMR7NMG.js → chunk-IUTUWIKE.js} +2 -2
  94. package/{chunk-JVRQ6YVK.js → chunk-JBWXPACD.js} +1 -1
  95. package/{chunk-SASHAZ67.js → chunk-KZPEGO6D.js} +13 -2
  96. package/{chunk-HCJFGH6Y.js → chunk-L32W3PRP.js} +46 -16
  97. package/{chunk-GGKNJ42M.js → chunk-LYDEFPQP.js} +18 -108
  98. package/{chunk-K5FNYHZC.js → chunk-MECDGHLK.js} +420 -120
  99. package/{chunk-EOWLBDY6.js → chunk-MM73SP4K.js} +1 -1
  100. package/{chunk-J6T25AJ6.js → chunk-MYOSN6BT.js} +82 -18
  101. package/{chunk-Q7WP5RPC.js → chunk-MYPKBJJO.js} +5 -5
  102. package/{chunk-6RQFZCKH.js → chunk-N2JROHD3.js} +4 -4
  103. package/{chunk-VREDDN25.js → chunk-O6IPRAVV.js} +14 -9
  104. package/{chunk-VALBGPM6.js → chunk-OBSEKCVK.js} +17 -20
  105. package/{chunk-AMEOV5VZ.js → chunk-OOJNQK6V.js} +33 -33
  106. package/{chunk-PPJYZRSQ.js → chunk-OX6GNNVT.js} +6 -1
  107. package/{chunk-5R63B62U.js → chunk-P3IZUMIC.js} +8 -8
  108. package/{chunk-FRSBYNWI.js → chunk-PGKA77TZ.js} +52 -217
  109. package/{chunk-7UH3DGV6.js → chunk-PRMEU7BT.js} +232 -10
  110. package/{chunk-2ZKFCIJJ.js → chunk-PROOOQZ3.js} +1 -1
  111. package/{chunk-EUCFKKDM.js → chunk-PVFYPUIM.js} +40 -10
  112. package/{chunk-HOCHUZQ7.js → chunk-QJTZ76CP.js} +24 -6
  113. package/{chunk-MK2Q7ZJD.js → chunk-R7XWZDOH.js} +58 -24
  114. package/{chunk-5FUN7EG4.js → chunk-RD3QLZQV.js} +83 -47
  115. package/chunk-RETQOQ4D.js +33394 -0
  116. package/{chunk-AVHRSJUH.js → chunk-RM4UMFY4.js} +32 -25
  117. package/{chunk-2OLYKYNY.js → chunk-RTHFJZ6M.js} +8 -8
  118. package/{chunk-OB6DVWPF.js → chunk-S2MHR4PU.js} +164 -4
  119. package/{chunk-IWQAOW2X.js → chunk-SRCCSTIM.js} +8 -8
  120. package/{chunk-PVZY6P3S.js → chunk-T6VROBY7.js} +2 -2
  121. package/{chunk-2KTUDBG7.js → chunk-TEMLHVGX.js} +1 -1
  122. package/{chunk-TVFRV3UQ.js → chunk-TRHJ4NJB.js} +673 -1279
  123. package/{chunk-QVBXJNZ2.js → chunk-TUSTONB3.js} +1 -1
  124. package/{chunk-UMRI2IRY.js → chunk-TWTJV35S.js} +6 -6
  125. package/{chunk-5OZC7R7Y.js → chunk-U3G7RRXJ.js} +13 -12
  126. package/{chunk-CXDPIPZ4.js → chunk-UFC4J7OY.js} +3 -3
  127. package/{chunk-CKT6QUE2.js → chunk-UHW6SCVK.js} +1 -1
  128. package/{chunk-AGP3YSEC.js → chunk-ULLHVDTZ.js} +48 -3
  129. package/{chunk-SYQR7FQS.js → chunk-VM72HKW2.js} +97 -29
  130. package/{chunk-KEN3N2TN.js → chunk-VMJVAJ6W.js} +13 -10
  131. package/{chunk-3N4ASIP6.js → chunk-VREG6ANQ.js} +103 -100
  132. package/{chunk-SOF4OWDM.js → chunk-VS276URX.js} +0 -2
  133. package/chunk-VSRISJXZ.js +107 -0
  134. package/chunk-WDWZPASX.js +29 -0
  135. package/chunk-WFGNWWJI.js +326 -0
  136. package/{chunk-UJKTI5PG.js → chunk-WRKMXMU7.js} +2 -1
  137. package/{chunk-FIYSMXHY.js → chunk-WWTSEBDF.js} +1 -1
  138. package/{chunk-E2BESSAW.js → chunk-X4O7FJF5.js} +2 -0
  139. package/chunk-X7IA2B7R.js +166 -0
  140. package/{chunk-5ZMIIR23.js → chunk-XBAEM4RI.js} +7 -0
  141. package/{chunk-4JVNURX4.js → chunk-XS5A3EKX.js} +1 -23
  142. package/{chunk-N5Z2V73W.js → chunk-Y2MF4DCJ.js} +1 -1
  143. package/{chunk-KAVGK4ES.js → chunk-Y5OWZQMJ.js} +39 -30
  144. package/{chunk-AK5O76CC.js → chunk-YGCOJNFZ.js} +3 -3
  145. package/{chunk-L5I543VB.js → chunk-YGDYYFRX.js} +20 -24
  146. package/{chunk-XFJ4ZPFC.js → chunk-Z2WZAE4P.js} +128 -149
  147. package/chunk-Z6YTCDU4.js +24 -0
  148. package/chunk-ZEKUFJLW.js +1438 -0
  149. package/{chunk-KN3HEZIQ.js → chunk-ZVOL2MAJ.js} +1 -1
  150. package/{cliAgentConfigHelpers-PO3MVDME.js → cliAgentConfigHelpers-U5OAVAKQ.js} +12 -12
  151. package/{cliAuthorityBrokerClient-XHH7MH2P.js → cliAuthorityBrokerClient-S42VMGB6.js} +1 -1
  152. package/{cliEnvHelpers-VPSJ4XWC.js → cliEnvHelpers-CNMP3RDX.js} +1 -1
  153. package/{cliExecutor-4MAX3PZL.js → cliExecutor-K6FDZTQ2.js} +3 -1
  154. package/{cliLocalAgentRecordReader-Z7CH4K4R.js → cliLocalAgentRecordReader-HVZAQCUD.js} +49 -44
  155. package/{commandRegistry-SDSYBKMC.js → commandRegistry-TME7INFU.js} +98 -94
  156. package/{contentThunks-G3TRPEAU.js → contentThunks-U6OC4R2N.js} +37 -35
  157. package/{cooldownCommands-X7P5M2V5.js → cooldownCommands-U7XSRVJP.js} +4 -4
  158. package/{createAgentAutomationAction-KHA4MXUJ.js → createAgentAutomationAction-IP4LFN3W.js} +37 -35
  159. package/{createDialogAction-KWSBNAPJ.js → createDialogAction-IAGQJ3LH.js} +38 -36
  160. package/{createPageAction-HXKJ7OFG.js → createPageAction-AZ3UIFKA.js} +38 -36
  161. package/{db-CS4ZJQKV.js → db-M7FU2GNK.js} +9 -6
  162. package/{dbSlice-ZJPDIFER.js → dbSlice-DKKMJJYY.js} +13 -12
  163. package/{deleteFile-Q3YDB4ML.js → deleteFile-TQSONMVU.js} +11 -8
  164. package/{dialogCommands-6KQEBHSG.js → dialogCommands-PCDRMBWG.js} +60 -55
  165. package/dialogMessageRecord-OAV77LT7.js +7 -0
  166. package/{dialogNotifyCommand-WIZFFEY3.js → dialogNotifyCommand-O35MWMOS.js} +13 -13
  167. package/{dialogSlice-HXPKFGRL.js → dialogSlice-QAKYN4DE.js} +35 -33
  168. package/{dialogUsageCommand-HTVPR2CX.js → dialogUsageCommand-2SSLTXKO.js} +3 -3
  169. package/{docCreateCommands-XZOLWBRC.js → docCreateCommands-CFQFZOAD.js} +54 -48
  170. package/{docDeleteCommands-ZSO4LGWE.js → docDeleteCommands-5CPNTIIS.js} +56 -50
  171. package/{docReadCommands-TTMXCDER.js → docReadCommands-XQILYSAJ.js} +54 -48
  172. package/{docStore-A2B3GH33.js → docStore-GIVRT7TQ.js} +15 -14
  173. package/{docUpdateCommands-PRG6WOXL.js → docUpdateCommands-VETKSUDD.js} +54 -48
  174. package/fetchMessages-TQEUZD7H.js +1 -1
  175. package/{getPricing-YH3VMSVU.js → getPricing-LF5C4XSI.js} +5 -5
  176. package/{handleSendMessageAction-NWYG3Q72.js → handleSendMessageAction-HKIW4ZNO.js} +70 -66
  177. package/{hostCredentialCreate-WS6D3EHT.js → hostCredentialCreate-6VDJFNDO.js} +118 -104
  178. package/index.js +56 -18
  179. package/keys-RWF7UCB4.js +1 -1
  180. package/{lib-OT5OTXRU.js → lib-62SWPXNF.js} +3 -7
  181. package/{localDialogRead-SVTPA5GY.js → localDialogRead-AV2VKKPG.js} +1 -1
  182. package/{localRecall-2J6QPOK2.js → localRecall-BDYKXB46.js} +3 -1
  183. package/{localRuntimeAdapter-TFYOA6YE.js → localRuntimeAdapter-BQ4F5PZV.js} +120 -107
  184. package/{localRuntimeAuthority-IBJAT62G.js → localRuntimeAuthority-WCNA4A3G.js} +4 -2
  185. package/{localRuntimeDb-N7KHDXS2.js → localRuntimeDb-CRNIBOOM.js} +1 -1
  186. package/{machineCommands-WFWV25IR.js → machineCommands-K6XIGOAD.js} +142 -114
  187. package/{machineWsRunDispatch-ZGXC3F2R.js → machineWsRunDispatch-4OO7Z6UM.js} +114 -101
  188. package/mcpLocalAuthorizeCommand-ZP6ESAGE.js +106 -0
  189. package/{memberThunks-JRYNONYV.js → memberThunks-PBJPZ2JU.js} +22 -17
  190. package/{memoryCommands-5WC3T66U.js → memoryCommands-BC6REPQB.js} +4 -4
  191. package/{models-CXINDUJA.js → models-H5NNZRLH.js} +2 -2
  192. package/{overlay-THLKYIWY.js → overlay-JA3SPVUS.js} +7 -3
  193. package/package.json +1 -1
  194. package/{projectArchive-ULJDLUA6.js → projectArchive-G7AOQPRW.js} +43 -41
  195. package/{providerPresetApply-SHT2SUVB.js → providerPresetApply-OPBCAONX.js} +6 -6
  196. package/{providerRegistry-TA7EGCVZ.js → providerRegistry-J2HCVTHE.js} +6 -6
  197. package/{read-Q7GOHGNP.js → read-JEGPITEW.js} +10 -9
  198. package/{readDocTool-Z5OQ6422.js → readDocTool-TE3XIU4Y.js} +1 -1
  199. package/{readlineWorkspace-LTCV2BFW.js → readlineWorkspace-SOW5QUGZ.js} +4412 -4277
  200. package/{removeDialogAgentAction-U3F2MNAY.js → removeDialogAgentAction-CX3OAH4Y.js} +17 -16
  201. package/{runAgentClientLoop-BVIEQUB3.js → runAgentClientLoop-HQJPDFGQ.js} +95 -69
  202. package/{runtimeDoctorCommands-I47JN4HS.js → runtimeDoctorCommands-GUH2YGMH.js} +17 -17
  203. package/{secretCommands-LJXOOYA7.js → secretCommands-NJXFVHZU.js} +4 -4
  204. package/{setDialogExtraReferencesAction-G3WSJ7EM.js → setDialogExtraReferencesAction-CGM67EEQ.js} +16 -15
  205. package/{setPrimaryDialogAgentAction-6FHAHZBB.js → setPrimaryDialogAgentAction-3ABWPPXR.js} +17 -16
  206. package/{settingThunks-AXTBX3Q5.js → settingThunks-AY76OHYX.js} +181 -62
  207. package/{skillDiscovery-B5V23AXP.js → skillDiscovery-MDDKPTW3.js} +4 -3
  208. package/{spaceCommands-IB6FKWIC.js → spaceCommands-G63QGYQO.js} +59 -53
  209. package/{store-JRVN62NM.js → store-Z53ICFL3.js} +3 -1
  210. package/{streamAgentChatTurn-DNYFHBJM.js → streamAgentChatTurn-E3XH2KFD.js} +160 -154
  211. package/{switchDialogAgentAction-UOFIAGPL.js → switchDialogAgentAction-G6EZRKCQ.js} +15 -14
  212. package/{tableCommands-HITDSLHS.js → tableCommands-JI75ZHDI.js} +14 -11
  213. package/{toolApiClient-OGQEBQVX.js → toolApiClient-62UUPDUA.js} +3 -5
  214. package/{tools-JVOJ5HC4.js → tools-7RSX22FT.js} +64 -58
  215. package/tuiRestart-KAAA7TND.js +41 -0
  216. package/{tuiSummaryLlmCaller-7LWYTHLM.js → tuiSummaryLlmCaller-BVNHMWLR.js} +19 -19
  217. package/{updateCommands-RJVCRSBP.js → updateCommands-ASK5XYPH.js} +8 -6
  218. package/{updateDialogTitleAction-Q57BOSXG.js → updateDialogTitleAction-SEWV252V.js} +37 -35
  219. package/{usageCommand-RVKHEPLU.js → usageCommand-JVT5J3DC.js} +3 -3
  220. package/{usageRebuildCommand-GRAFOZF2.js → usageRebuildCommand-IZYYUTEW.js} +4 -4
  221. package/webapi-24RZDIIQ.js +2488 -0
  222. package/{windowsSelfUpdate-KERHIAB4.js → windowsSelfUpdate-BSDIS2J5.js} +2 -2
  223. package/workContext-MM3P5GP5.js +13 -0
  224. package/workContextAccess-UZHDLBUR.js +11 -0
  225. package/workContextWriteNotice-YCSSMHN4.js +7 -0
  226. package/agentRecordCommands-DX2WE6BH.js +0 -176
  227. package/chunk-2THCNKE4.js +0 -147
  228. package/chunk-2WZXXAQD.js +0 -57
  229. package/chunk-652XYZGP.js +0 -352
  230. package/chunk-KEPOVMF4.js +0 -91
  231. package/chunk-OXKUPBAQ.js +0 -776
  232. package/{chunk-BLVSFYQ3.js → chunk-LISC7BD4.js} +3 -3
  233. package/{chunk-SNBZZPYH.js → chunk-OQHIVPG4.js} +3 -3
  234. package/{chunk-47ITIXO7.js → chunk-USGHJSGO.js} +3 -3
  235. package/{offlineMarxistsAgentCommand-4IC3Y4C6.js → offlineMarxistsAgentCommand-XVXUE6G5.js} +3 -3
  236. 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-OGHP3CTL.js";
4
+ } from "./chunk-2X7WFDT6.js";
5
5
  import {
6
6
  isAgentRunTerminalStatus,
7
7
  normalizeRunTitle,
8
8
  shortAgentKey
9
- } from "./chunk-AMEOV5VZ.js";
9
+ } from "./chunk-OOJNQK6V.js";
10
10
  import {
11
11
  findPowerShellExecutable
12
- } from "./chunk-KEN3N2TN.js";
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
- import {
20
- isCompiledBinary,
21
- resolveCliEntrypointPath
22
- } from "./chunk-2THCNKE4.js";
28
+
29
+ // packages/cli/mcp/mcpApprovalTransport.ts
30
+ import { randomUUID, createHash } from "node:crypto";
31
+
32
+ // packages/cli/client/inheritedApprovalChannel.ts
33
+ function sendInheritedApproval(channel, kind, message, failed) {
34
+ if (channel.connected === false || !channel.send) {
35
+ failed();
36
+ return;
37
+ }
38
+ try {
39
+ channel.send({ kind, ...message }, (error) => {
40
+ if (error) failed();
41
+ });
42
+ } catch {
43
+ failed();
44
+ }
45
+ }
46
+ function bindInheritedApprovalLifetime(channel, close, signal) {
47
+ for (const event of ["disconnect", "exit", "error"]) channel.on(event, close);
48
+ signal?.addEventListener("abort", close, { once: true });
49
+ return () => {
50
+ for (const event of ["disconnect", "exit", "error"]) channel.removeListener(event, close);
51
+ signal?.removeEventListener("abort", close);
52
+ };
53
+ }
54
+
55
+ // packages/cli/mcp/mcpApprovalTransport.ts
56
+ var KIND = "nolo.mcp-approval.v1";
57
+ var TTL = 6e4;
58
+ var MAX = 256;
59
+ function canonical(value) {
60
+ if (Array.isArray(value)) return `[${value.map(canonical).join(",")}]`;
61
+ if (value && typeof value === "object") return `{${Object.keys(value).sort().map((key) => `${JSON.stringify(key)}:${canonical(value[key])}`).join(",")}}`;
62
+ return JSON.stringify(value);
63
+ }
64
+ function snapshot(preview) {
65
+ return createHash("sha256").update(JSON.stringify(preview)).digest("hex");
66
+ }
67
+ function valid(preview, binding) {
68
+ const b = preview?.binding;
69
+ return b && b.authenticatedUserId === binding.ownerUserId && b.agentKey === binding.agentKey && typeof b.dialogId === "string" && b.dialogId.length > 0 && b.placement?.kind === "local" && typeof b.connectionId === "string" && Number.isInteger(b.connectionRevision) && b.connectionRevision > 0 && typeof b.catalogRevision === "string" && typeof b.toolName === "string" && /^[a-f0-9]{64}$/.test(b.argumentsDigest) && preview.arguments && typeof preview.arguments === "object" && !Array.isArray(preview.arguments) && createHash("sha256").update(canonical(preview.arguments)).digest("hex") === b.argumentsDigest && Number.isFinite(preview.expiresAt) && preview.expiresAt > Date.now() && preview.expiresAt <= Date.now() + TTL;
70
+ }
71
+ function attachMcpApprovalHost(channel, host) {
72
+ const binding = Object.freeze({ ...host.binding });
73
+ let closed = false;
74
+ let count = 0;
75
+ const seen = /* @__PURE__ */ new Set();
76
+ const active = /* @__PURE__ */ new Map();
77
+ const send2 = (message) => sendInheritedApproval(channel, KIND, message, close);
78
+ let unbind = () => {
79
+ };
80
+ const close = () => {
81
+ if (closed) return;
82
+ closed = true;
83
+ for (const controller of active.values()) controller.abort();
84
+ active.clear();
85
+ sendInheritedApproval(channel, KIND, { type: "revoke" }, () => {
86
+ });
87
+ channel.removeListener("message", receive);
88
+ unbind();
89
+ };
90
+ const receive = (m) => {
91
+ if (closed || m?.kind !== KIND) return;
92
+ if (m.type === "hello") {
93
+ send2({ type: "binding", binding });
94
+ return;
95
+ }
96
+ if (m.type === "cancel") {
97
+ active.get(m.id)?.abort();
98
+ return;
99
+ }
100
+ if (m.type !== "request") return;
101
+ if (++count > MAX || typeof m.id !== "string" || seen.has(m.id)) {
102
+ close();
103
+ return;
104
+ }
105
+ seen.add(m.id);
106
+ let preview;
107
+ try {
108
+ if (typeof m.snapshot !== "string" || JSON.stringify(m.preview).length > 262144) throw new Error("invalid preview");
109
+ preview = structuredClone(m.preview);
110
+ if (m.runId !== binding.runId || !valid(preview, binding) || snapshot(preview) !== m.snapshot) throw new Error("binding mismatch");
111
+ } catch {
112
+ send2({ type: "decision", id: m.id, runId: binding.runId, snapshot: m.snapshot, decision: "deny" });
113
+ return;
114
+ }
115
+ const controller = new AbortController();
116
+ active.set(m.id, controller);
117
+ const timer = setTimeout(() => controller.abort(), Math.max(0, preview.expiresAt - Date.now()));
118
+ void new Promise((resolve2) => {
119
+ controller.signal.addEventListener("abort", () => resolve2("deny"), { once: true });
120
+ Promise.resolve().then(() => closed || controller.signal.aborted ? "deny" : host.confirm(preview, controller.signal, { runId: binding.runId, requestId: m.id })).then(resolve2, () => resolve2("unavailable"));
121
+ }).then((decision) => {
122
+ clearTimeout(timer);
123
+ active.delete(m.id);
124
+ if (!closed) send2({
125
+ type: "decision",
126
+ id: m.id,
127
+ runId: binding.runId,
128
+ snapshot: m.snapshot,
129
+ decision: !controller.signal.aborted && Date.now() < preview.expiresAt ? decision : "deny"
130
+ });
131
+ });
132
+ };
133
+ channel.on("message", receive);
134
+ unbind = bindInheritedApprovalLifetime(channel, close, host.signal);
135
+ if (host.signal.aborted || channel.connected === false) close();
136
+ return close;
137
+ }
138
+ function createMcpApprovalChild(channel) {
139
+ const lifetime = new AbortController();
140
+ let binding;
141
+ let count = 0;
142
+ let closed = false;
143
+ const pending = /* @__PURE__ */ new Map();
144
+ const readyResolvers = /* @__PURE__ */ new Set();
145
+ let unbind = () => {
146
+ };
147
+ const close = () => {
148
+ if (closed) return;
149
+ closed = true;
150
+ lifetime.abort();
151
+ for (const entry of pending.values()) entry.finish("unavailable");
152
+ for (const resolve2 of readyResolvers) resolve2();
153
+ readyResolvers.clear();
154
+ channel.removeListener("message", receive);
155
+ unbind();
156
+ };
157
+ const send2 = (message) => sendInheritedApproval(channel, KIND, message, close);
158
+ const receive = (m) => {
159
+ if (closed || m?.kind !== KIND) return;
160
+ if (m.type === "revoke") {
161
+ close();
162
+ return;
163
+ }
164
+ if (m.type === "binding") {
165
+ if (binding || !m.binding || typeof m.binding.runId !== "string" || typeof m.binding.ownerUserId !== "string" || typeof m.binding.agentKey !== "string") {
166
+ close();
167
+ return;
168
+ }
169
+ binding = Object.freeze({ ...m.binding });
170
+ for (const resolve2 of readyResolvers) resolve2();
171
+ readyResolvers.clear();
172
+ return;
173
+ }
174
+ if (m.type !== "decision") return;
175
+ const entry = pending.get(m.id);
176
+ if (!entry) return;
177
+ const matches = binding && m.runId === binding.runId && m.snapshot === entry.snapshot && Date.now() < entry.expiresAt;
178
+ entry.finish(!matches ? "deny" : m.decision === "approve" ? "approve" : m.decision === "unavailable" ? "unavailable" : "deny");
179
+ };
180
+ channel.on("message", receive);
181
+ unbind = bindInheritedApprovalLifetime(channel, close);
182
+ send2({ type: "hello" });
183
+ const confirm = async (input, signal) => {
184
+ if (closed || signal.aborted || ++count > MAX) return "unavailable";
185
+ if (!binding) await new Promise((resolve2) => {
186
+ const done = () => {
187
+ clearTimeout(timer);
188
+ readyResolvers.delete(done);
189
+ signal.removeEventListener("abort", done);
190
+ resolve2();
191
+ };
192
+ const timer = setTimeout(done, Math.max(0, Math.min(TTL, input.expiresAt - Date.now())));
193
+ readyResolvers.add(done);
194
+ signal.addEventListener("abort", done, { once: true });
195
+ });
196
+ if (closed || !binding) return "unavailable";
197
+ if (signal.aborted || !valid(input, binding)) return "deny";
198
+ const preview = structuredClone(input), id = randomUUID(), digest = snapshot(preview);
199
+ return new Promise((resolve2) => {
200
+ const abort = () => {
201
+ send2({ type: "cancel", id });
202
+ finish("deny");
203
+ };
204
+ const timer = setTimeout(abort, Math.max(0, preview.expiresAt - Date.now()));
205
+ const finish = (value) => {
206
+ if (!pending.delete(id)) return;
207
+ clearTimeout(timer);
208
+ signal.removeEventListener("abort", abort);
209
+ resolve2(value);
210
+ };
211
+ pending.set(id, { finish, snapshot: digest, expiresAt: preview.expiresAt });
212
+ signal.addEventListener("abort", abort, { once: true });
213
+ if (signal.aborted) abort();
214
+ else send2({ type: "request", id, runId: binding.runId, snapshot: digest, preview });
215
+ });
216
+ };
217
+ return { confirm, signal: lifetime.signal, close };
218
+ }
23
219
 
24
220
  // packages/cli/client/originShellApprovalTransport.ts
25
221
  import { realpathSync } from "node:fs";
26
- import { randomUUID } from "node:crypto";
222
+ import { randomUUID as randomUUID2 } from "node:crypto";
27
223
 
28
224
  // packages/cli/client/originShellApprovalBridge.ts
29
225
  import { isAbsolute } from "node:path";
@@ -40,7 +236,7 @@ function createOriginShellApprovalBridge(deps) {
40
236
  }
41
237
  const requests = /* @__PURE__ */ new Map();
42
238
  const fail = (reason) => ({ ok: false, reason });
43
- const snapshot = (request) => ({ ok: true, request: { ...request } });
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 snapshot(request);
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 snapshot(request);
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 snapshot(request);
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 snapshot(request);
323
+ return snapshot2(request);
128
324
  }
129
325
  };
130
326
  }
131
327
 
132
328
  // packages/cli/client/originShellApprovalTransport.ts
133
- var KIND = "nolo.shell-approval.v1";
134
- var MAX = 256;
135
- var TTL = 6e4;
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: KIND, ...message });
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
- channel.removeListener("disconnect", close);
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 !== KIND) return;
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 > MAX || typeof message.id !== "string" || message.id.length > 100) {
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.on("disconnect", close);
240
- channel.on("exit", close);
241
- channel.on("error", close);
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 = TTL) {
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 !== KIND) return;
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() + TTL || tickets.has(message.ticket)) {
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 > MAX) throw new Error("Shell approval capacity exceeded");
302
- const deadline = Date.now() + Math.min(timeoutMs, TTL);
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 = randomUUID();
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, TTL));
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 randomUUID2, createHash } from "node:crypto";
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 snapshot = readMem(deps.hostMemoryDeps);
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 (!snapshot) {
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(snapshot.source)) throw new Error("Unknown host memory source");
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 (snapshot.source === "cgroup") {
729
- const cgroupAvail = snapshot.availableMb;
730
- const hostAvail = snapshot.hostAvailableMb;
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: snapshot.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: snapshot.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 (snapshot.availableMb === null || typeof snapshot.availableMb !== "number" || Number.isNaN(snapshot.availableMb) || !Number.isFinite(snapshot.availableMb) || snapshot.availableMb < 0) {
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: snapshot.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 = snapshot.availableMb;
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: snapshot.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: snapshot.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: snapshot.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: snapshot.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 || createHash("sha256").update(fs.readFileSync(artifact.path)).digest("hex") !== artifact.sha256) {
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
- if (cliEntrypointPath && fs.existsSync(cliEntrypointPath)) {
2224
- return cliEntrypointPath;
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 = process.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
- return { execPath, childArgs: [...commandParts, ...strippedArgs] };
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 snapshot = readRunRecord(runId, deps);
2333
- if (!snapshot) return "blocked";
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(snapshot)) return "blocked";
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 snapshot = JSON.stringify(record);
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) !== snapshot) return false;
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 canonical = String((fs.realpathSync ?? nodeFs2.realpathSync)(cwd));
2368
- const worktree = trustedLocalWorktree(canonical, deps);
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: canonical, ...worktree ? { worktree } : {}, state: "held" };
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 canonical;
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 canonical = String((fs.realpathSync ?? nodeFs2.realpathSync)(cwd));
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(canonical, deps);
2698
+ const worktree = trustedLocalWorktree(canonical2, deps);
2493
2699
  const record = {
2494
2700
  runId,
2495
2701
  agentKey,
2496
- writerLaunch: { protocol: "fenced-launch-v1", attemptId: randomUUID2(), phase: "prepared" },
2497
- cwd: canonical,
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: canonical,
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, canonical, deps);
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: randomUUID2(), phase: "prepared" } } : {},
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
- const { execPath, childArgs } = buildAgentRunChildCommand(
2645
- {
2646
- rawArgs: rawArgsWithQueue,
2647
- commandPath: input.commandPath,
2648
- cliEntrypointPath: input.cliEntrypointPath,
2649
- messagePath
2650
- },
2651
- deps
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
- finalizeRunRecord(runId, {
2718
- status: "failed",
2719
- exitCode: 1,
2720
- note: `${error}; reservation release failed: ${releaseError}`
2721
- }, resolvedDeps);
2722
- return;
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: createHash("sha256").update(fs.readFileSync(path)).digest("hex")
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}.${randomUUID2()}.pending`;
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}.${randomUUID2()}.bak`;
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,