nolo-cli 0.228.0-alpha.2 → 0.228.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (260) hide show
  1. package/README.md +3 -5
  2. package/{_executeModel-VYCHHZVT.js → _executeModel-AKCTHGMP.js} +89 -83
  3. package/{accountResolver-QETKNC7T.js → accountResolver-NGICIMEE.js} +1 -1
  4. package/{action-GDZDXPMB.js → action-C6IQAKN4.js} +8 -5
  5. package/{addContentAction-7RO4AMRI.js → addContentAction-53364YDW.js} +13 -12
  6. package/{addDialogAgentAction-EVYBGTXB.js → addDialogAgentAction-U5DD5EN5.js} +16 -15
  7. package/{agentDeleteCommand-QWQKT54A.js → agentDeleteCommand-2E5FAGUO.js} +128 -115
  8. package/{agentEmailCommands-EISMBIRE.js → agentEmailCommands-UGZZAH7E.js} +128 -111
  9. package/{agentListCommands-4WLG32IW.js → agentListCommands-JCTW3J2K.js} +398 -179
  10. package/{agentMachineCommands-DC6NKWTU.js → agentMachineCommands-QPG5ZXF4.js} +58 -47
  11. package/{agentProviderCommands-STI3DQ6A.js → agentProviderCommands-QLTABYR7.js} +2 -2
  12. package/{agentPullCommand-KHV4EELF.js → agentPullCommand-2EYJ5ENC.js} +1 -1
  13. package/agentRecordCommands-4NTVR6MZ.js +194 -0
  14. package/agentRunCommand-VHF34PYC.js +232 -0
  15. package/{agentRunControl-MBG4U6SL.js → agentRunControl-QYTXUQGY.js} +14 -9
  16. package/{agentRuntimeLocal-HOXKWCYO.js → agentRuntimeLocal-U54AKHXH.js} +58 -43
  17. package/{agentSlice-UG76KEBH.js → agentSlice-4JGDEXWK.js} +14 -13
  18. package/{appDeleteCommands-WWCC6WA5.js → appDeleteCommands-XBE5QJ6P.js} +58 -47
  19. package/{appDeployCommands-AU4IUN33.js → appDeployCommands-QIYLXXGA.js} +58 -47
  20. package/{appDeployStatusCommands-STUW7WXL.js → appDeployStatusCommands-JXS6ZQZZ.js} +58 -47
  21. package/{appGetCommands-BGTLIQ4K.js → appGetCommands-SZS7SJPK.js} +58 -47
  22. package/{appListCommands-CUCPRUXW.js → appListCommands-B3GBJSNV.js} +58 -47
  23. package/{authCommand-OZ2KTP4Z.js → authCommand-V6EOMZX6.js} +25 -19
  24. package/{authCommands-55OGQGCR.js → authCommands-T5FODCEG.js} +12 -6
  25. package/{builtinSkillRegistry-BAE2LDXF.js → builtinSkillRegistry-ZQC3IIO2.js} +8 -7
  26. package/{chromeCommands-G5UDKVSV.js → chromeCommands-O4IIKTBD.js} +384 -7
  27. package/{chromeOpsCommands-WAA45NCS.js → chromeOpsCommands-OFX7ZGKP.js} +3 -3
  28. package/{chunk-DBUR22G5.js → chunk-223KZUJ6.js} +19 -15
  29. package/{chunk-3U44JB3O.js → chunk-2C5VN7NH.js} +1 -1
  30. package/{chunk-PWTNI4N7.js → chunk-2E4BYAUE.js} +22 -0
  31. package/{chunk-L32W3PRP.js → chunk-2FZVXOFX.js} +234 -18
  32. package/{chunk-HBRDSQ3M.js → chunk-2JHGUL5K.js} +3 -2
  33. package/chunk-2SXN7LAY.js +15 -0
  34. package/chunk-3A5NNQCN.js +64 -0
  35. package/chunk-3F2FRLIO.js +372 -0
  36. package/{chunk-DEA37IUY.js → chunk-46FETNLF.js} +2 -2
  37. package/{chunk-ZEVQHCLM.js → chunk-4GYVS4PM.js} +8 -6
  38. package/{chunk-CBUZ6DKA.js → chunk-4YPH5KRA.js} +1 -1
  39. package/chunk-4ZCTKB27.js +31 -0
  40. package/chunk-53W5BXLN.js +340 -0
  41. package/{chunk-7FEP5USX.js → chunk-5AYP5QBB.js} +5 -5
  42. package/{chunk-XAG3FWBE.js → chunk-5ISNPTQH.js} +5 -5
  43. package/{chunk-EVGU5P4U.js → chunk-5P3PPQVP.js} +1 -1
  44. package/{chunk-XSW4EXQV.js → chunk-6BMTKYAO.js} +55 -18
  45. package/chunk-6PAHSSD2.js +33401 -0
  46. package/{chunk-ZOHO6MOF.js → chunk-6RSNVJGO.js} +2 -99
  47. package/{chunk-7JGMNKKG.js → chunk-6SOWMEAY.js} +30 -9
  48. package/{chunk-RG2DGNL6.js → chunk-6VEO7Z3Y.js} +3 -3
  49. package/{chunk-PDCV7P5W.js → chunk-6XIE5ZGI.js} +1 -1
  50. package/{chunk-DGYCDA6W.js → chunk-7BIJFGKS.js} +36 -17
  51. package/{chunk-WFDNADFX.js → chunk-7OVOZRZF.js} +8 -8
  52. package/{chunk-WCFFRBL5.js → chunk-7PON4LBY.js} +45 -27
  53. package/{chunk-QRGDJA4B.js → chunk-7WHCIA5V.js} +33 -7
  54. package/{chunk-CMMI3DAT.js → chunk-ADYWV732.js} +59 -30
  55. package/{chunk-QYB23WUH.js → chunk-AIFQKNPP.js} +1 -1
  56. package/{chunk-HGDKT2D6.js → chunk-BPB3T5EU.js} +174 -1
  57. package/{chunk-DUUDXSLX.js → chunk-BZLGPM5B.js} +28 -4
  58. package/{chunk-ATEKLSLR.js → chunk-BZMDWGQQ.js} +14 -9
  59. package/chunk-C5A54QS7.js +108 -0
  60. package/{chunk-S6K5F3KP.js → chunk-CEKRIR22.js} +1 -1
  61. package/{chunk-42OKN2LI.js → chunk-D634SL2Y.js} +9 -107
  62. package/{chunk-DLXMMTGM.js → chunk-DHRPLRIR.js} +1283 -786
  63. package/{chunk-LKA64WH4.js → chunk-DMPZMYH4.js} +37 -1
  64. package/{chunk-OBIC6EG7.js → chunk-DNNPARJK.js} +9 -5
  65. package/{chunk-X3E6EHJW.js → chunk-E3LSO6EI.js} +292 -207
  66. package/{chunk-OQHIVPG4.js → chunk-E6A5NHDH.js} +4 -1
  67. package/chunk-EHFBP6IK.js +791 -0
  68. package/chunk-EJQE5HB7.js +21 -0
  69. package/{chunk-VQ5N5GSV.js → chunk-EL5NRJHI.js} +4 -4
  70. package/chunk-EUGTFFO6.js +42 -0
  71. package/{chunk-7BCG67EI.js → chunk-EVHTYVD2.js} +1199 -442
  72. package/{chunk-6XRPBZRS.js → chunk-EYLGAEB4.js} +0 -134
  73. package/{chunk-262R3XNN.js → chunk-FEIVARWR.js} +377 -112
  74. package/{chunk-3VZLEKV2.js → chunk-FLBJ7IJI.js} +14 -14
  75. package/{chunk-EEOOBRA7.js → chunk-FXEPZKNJ.js} +13 -6
  76. package/{chunk-XTJKU3Z4.js → chunk-FYAMUU55.js} +677 -140
  77. package/{chunk-M3OZRQNH.js → chunk-FZANZZ63.js} +1 -1
  78. package/chunk-GAHJLSDO.js +107 -0
  79. package/{chunk-WWTSEBDF.js → chunk-GIXWVN2W.js} +1 -1
  80. package/{chunk-4N6G2CKP.js → chunk-HDKMVYNJ.js} +47 -1
  81. package/chunk-HEVRQGGH.js +106 -0
  82. package/{chunk-BIWI5M4E.js → chunk-HFHJPHFK.js} +1 -1
  83. package/{chunk-R6Z5S5GA.js → chunk-HPDLPEUG.js} +60 -17
  84. package/{chunk-YKY4OVOX.js → chunk-HQUGB2HM.js} +17 -170
  85. package/chunk-IIRJ4P4I.js +24 -0
  86. package/chunk-IVK2KT3H.js +209 -0
  87. package/{chunk-ALAES342.js → chunk-IYLUK67R.js} +9 -5
  88. package/{chunk-N5Z2V73W.js → chunk-J55F3IEZ.js} +1 -1
  89. package/{chunk-S6FDXXZV.js → chunk-J7JRCOIW.js} +2 -2
  90. package/{chunk-OWKNSIXL.js → chunk-JAKRY74O.js} +470 -83
  91. package/{chunk-VS276URX.js → chunk-JCQ3WCQ3.js} +4 -2
  92. package/chunk-JLZJL3WC.js +988 -0
  93. package/{chunk-OBSEKCVK.js → chunk-JPXACKSW.js} +219 -52
  94. package/{chunk-OTKSESZR.js → chunk-KDBDOXOM.js} +138 -54
  95. package/{chunk-VP3BINY7.js → chunk-KDDHQMSH.js} +31 -1
  96. package/{chunk-RBPUNSG5.js → chunk-KG27JIG4.js} +18 -108
  97. package/{chunk-4WVJLODK.js → chunk-KHYSFS3W.js} +88 -7
  98. package/{chunk-TCZ2VJZQ.js → chunk-KKIQAVDR.js} +9 -9
  99. package/{chunk-4JVNURX4.js → chunk-KQHEGELM.js} +68 -16
  100. package/chunk-KXOPLLFP.js +190 -0
  101. package/{chunk-HS7MLR74.js → chunk-KZ4A7EIV.js} +3 -5
  102. package/{chunk-HYLRQDEE.js → chunk-LLUBUHNT.js} +6 -6
  103. package/{chunk-QJTZ76CP.js → chunk-LS5KAVFQ.js} +1 -0
  104. package/{chunk-RTHFJZ6M.js → chunk-LVZVSLKO.js} +29 -9
  105. package/{chunk-TI2EPRHE.js → chunk-MNFUKRRU.js} +3 -3
  106. package/chunk-MVOZ22RZ.js +26 -0
  107. package/{chunk-CNMY2XM6.js → chunk-O3A2CHAL.js} +6 -6
  108. package/{chunk-TSPMLCWI.js → chunk-OB4FBZXJ.js} +5 -5
  109. package/{chunk-LYD6C7OU.js → chunk-OJSJJKHF.js} +6 -6
  110. package/{chunk-M4SFKP5L.js → chunk-OKAXQFON.js} +3 -3
  111. package/{chunk-CD3RU7XL.js → chunk-OKH74FML.js} +121 -14
  112. package/{chunk-U2HBB7RS.js → chunk-OOV5JN25.js} +130 -30
  113. package/{chunk-ZH3KXFHS.js → chunk-OOVOAG4Q.js} +1 -1
  114. package/chunk-OQFOE4SJ.js +405 -0
  115. package/{chunk-M3JEW6N6.js → chunk-OYUMJMC5.js} +15 -0
  116. package/chunk-P27E22MA.js +203 -0
  117. package/{chunk-SRCCSTIM.js → chunk-P4R5KXU7.js} +4 -4
  118. package/{chunk-FJ23FZXF.js → chunk-PHREU2KZ.js} +5 -3
  119. package/{chunk-HSSBDZLD.js → chunk-PIVTQRX6.js} +43 -13
  120. package/{chunk-XFXFPUO7.js → chunk-PJL7OJRC.js} +13 -39
  121. package/{chunk-RRDRQOEC.js → chunk-PNLDLUMO.js} +276 -303
  122. package/{chunk-4I2MXV5Q.js → chunk-PVFYPUIM.js} +2 -0
  123. package/{chunk-HHFGE2WF.js → chunk-QGFLVQ6E.js} +5 -5
  124. package/{chunk-EGHP7KOY.js → chunk-QONAOHVW.js} +38 -29
  125. package/chunk-R3FZHW4Q.js +103 -0
  126. package/{chunk-ZYKJBRZ3.js → chunk-R3MV2GII.js} +1 -47
  127. package/chunk-R72QWIFO.js +50 -0
  128. package/{chunk-5FUN7EG4.js → chunk-RD3QLZQV.js} +83 -47
  129. package/{chunk-ILHQ2AXT.js → chunk-RIWKZT7E.js} +36 -8
  130. package/{chunk-OOJNQK6V.js → chunk-S25VJYXV.js} +8 -2
  131. package/{chunk-45CAVC35.js → chunk-S7H4KTMB.js} +2568 -337
  132. package/{chunk-OJ45MEEI.js → chunk-SA356NGW.js} +1 -1
  133. package/{chunk-F6Z6ZCUV.js → chunk-SCAC3NM5.js} +3 -3
  134. package/{chunk-YVFH2MFB.js → chunk-SLUN7W6S.js} +7 -7
  135. package/chunk-SQL7YNED.js +650 -0
  136. package/chunk-SR4FE5VD.js +9 -0
  137. package/{chunk-HF7BLF3F.js → chunk-SSOR2EDT.js} +107 -104
  138. package/chunk-TRRXYFTR.js +46 -0
  139. package/{chunk-3QIYD3VM.js → chunk-TUOHSUK5.js} +20068 -18402
  140. package/chunk-TYJCIA2O.js +835 -0
  141. package/{chunk-S2NTVGA2.js → chunk-U35UUM5K.js} +2 -1
  142. package/{chunk-GAYNXB6T.js → chunk-U3BUWDUP.js} +1031 -2155
  143. package/{chunk-BP5ZJ6B4.js → chunk-U6QNVOR5.js} +1 -1
  144. package/{chunk-UAIHKQIA.js → chunk-U6RD332P.js} +18 -2
  145. package/chunk-UAF5VQCE.js +77 -0
  146. package/{chunk-TQEKUOTI.js → chunk-UFGUJ2IH.js} +12 -12
  147. package/{chunk-VMJVAJ6W.js → chunk-UP7KBWLE.js} +109 -33
  148. package/{chunk-2X7WFDT6.js → chunk-UUCYUN6Y.js} +1 -1
  149. package/{chunk-5YMA6DDZ.js → chunk-UZKBVQUX.js} +1 -1
  150. package/chunk-V5TI7HJH.js +133 -0
  151. package/{chunk-WFGNWWJI.js → chunk-VH7UO6E5.js} +252 -114
  152. package/{chunk-MNEZUL5S.js → chunk-VJFDG3ZG.js} +63 -94
  153. package/{chunk-G7IUT2V3.js → chunk-WC3J5SL2.js} +635 -350
  154. package/{chunk-HXB4VDGK.js → chunk-WD5547ZF.js} +33 -30
  155. package/chunk-WDWZPASX.js +29 -0
  156. package/{chunk-4ZGPHFLE.js → chunk-WS36XPJD.js} +2 -2
  157. package/{chunk-6QHKRARD.js → chunk-WSLL7VV4.js} +29 -5
  158. package/chunk-XRGBJHZX.js +136 -0
  159. package/{chunk-MZG5CETE.js → chunk-Y2KWJTOZ.js} +4 -4
  160. package/{dialogUsageCommand-W2WCSGKF.js → chunk-Y2TCTNUD.js} +27 -20
  161. package/chunk-YJPK35HB.js +175 -0
  162. package/{chunk-6OVNSQHN.js → chunk-YLAHYLDQ.js} +5 -0
  163. package/{chunk-547ENH5T.js → chunk-YN23INFZ.js} +4 -4
  164. package/{chunk-4QYJPWHH.js → chunk-YXK3GJF5.js} +232 -10
  165. package/{chunk-MJI3UAXN.js → chunk-Z2OWAYMI.js} +77 -51
  166. package/{chunk-7Z6EW7AH.js → chunk-ZTHAJU3O.js} +106 -14
  167. package/{chunk-YFLVRVYK.js → chunk-ZYPXOQS2.js} +1 -1
  168. package/{cliAgentConfigHelpers-BTRHMPW2.js → cliAgentConfigHelpers-BXHQ3PXP.js} +9 -9
  169. package/{cliAuthorityBrokerClient-XHH7MH2P.js → cliAuthorityBrokerClient-TFNXJLXL.js} +1 -1
  170. package/cliAuthorityBrokerProcess-5ZFBTHLB.js +22 -0
  171. package/cliLocalAgentRecordReader-47PXMHPH.js +104 -0
  172. package/{commandRegistry-FVYPE2IN.js → commandRegistry-CTMPAQH2.js} +111 -162
  173. package/{contentThunks-GNFPG32S.js → contentThunks-CAHIIZO5.js} +38 -36
  174. package/{cooldownCommands-YB5H5BBK.js → cooldownCommands-WDOI5VD7.js} +3 -3
  175. package/{createAgentAutomationAction-PB4QIFQ4.js → createAgentAutomationAction-M25XZSPD.js} +38 -36
  176. package/{createDialogAction-EVTOPY7A.js → createDialogAction-4SN7FKI7.js} +39 -37
  177. package/{createPageAction-2UYF2IDZ.js → createPageAction-N7QPDN3M.js} +43 -41
  178. package/{db-M7FU2GNK.js → db-VR74ADGC.js} +7 -2
  179. package/{dbSlice-XRUZOGSU.js → dbSlice-RWPSVHBC.js} +12 -11
  180. package/{deleteFile-6URDHYRB.js → deleteFile-ECU6FU5C.js} +15 -7
  181. package/{dialogCommands-6SZD4TYP.js → dialogCommands-BBHWCKDP.js} +69 -53
  182. package/dialogMessageRecord-OAV77LT7.js +7 -0
  183. package/{dialogNotifyCommand-SHGPCU22.js → dialogNotifyCommand-IASQGEMW.js} +11 -11
  184. package/{dialogSlice-5EQ2A6LY.js → dialogSlice-JI3J22RV.js} +39 -37
  185. package/dialogTraceCommand-EW2KK6A4.js +961 -0
  186. package/dialogUsageCommand-WJ3U6KZU.js +27 -0
  187. package/{docCreateCommands-25E6PGN3.js → docCreateCommands-QSX3X5U4.js} +57 -46
  188. package/{docDeleteCommands-F7ZVGEHW.js → docDeleteCommands-63JBG2HQ.js} +59 -48
  189. package/{docReadCommands-JY2E5XEN.js → docReadCommands-CQFKRQUI.js} +57 -46
  190. package/{docStore-OKKIKLT3.js → docStore-XLBKGGNM.js} +14 -13
  191. package/{docUpdateCommands-OZ4CUSIQ.js → docUpdateCommands-534LUK25.js} +57 -46
  192. package/ebookDownloaderAgentCommand-DYSKF5ZY.js +677 -0
  193. package/fetchMessages-TQEUZD7H.js +1 -1
  194. package/{getPricing-LF5C4XSI.js → getPricing-5BLZRPTM.js} +4 -4
  195. package/{handleSendMessageAction-LNT7SZND.js → handleSendMessageAction-Q2VMEVOR.js} +127 -81
  196. package/{hostCredentialCreate-XUU2CSHI.js → hostCredentialCreate-C57T7YPE.js} +127 -109
  197. package/index.js +23 -11
  198. package/{localDialogRead-CCOCVGAP.js → localDialogRead-BJJT3TF5.js} +1 -1
  199. package/{localRuntimeAdapter-IBSTMSX7.js → localRuntimeAdapter-OALZPFZU.js} +134 -115
  200. package/localRuntimeAuthority-UF2DAQ3F.js +28 -0
  201. package/{localRuntimeDb-N7KHDXS2.js → localRuntimeDb-ZJFGNHML.js} +1 -1
  202. package/{machineCommands-HSQHDHOT.js → machineCommands-N6IVWRZT.js} +262 -325
  203. package/machineWsRunDispatch-PDWYB33B.js +209 -0
  204. package/markdownToSlate-PXYAIBVL.js +8 -0
  205. package/mcpLocalAuthorizeCommand-KYI4EGF5.js +110 -0
  206. package/{memberThunks-7Y3OYSJQ.js → memberThunks-43B7UYC5.js} +21 -16
  207. package/{models-H5NNZRLH.js → models-ZX2BYIMB.js} +2 -2
  208. package/{overlay-BBQZXGYI.js → overlay-JA3SPVUS.js} +5 -3
  209. package/package.json +2 -1
  210. package/{projectArchive-FQO654Z3.js → projectArchive-TJNW5DLM.js} +46 -44
  211. package/{providerPresetApply-WHAMP2D5.js → providerPresetApply-NTJUINI6.js} +36 -17
  212. package/{providerRegistry-ZI2KORJ7.js → providerRegistry-W45SLUV6.js} +6 -6
  213. package/{read-TYMBGEXO.js → read-KG6INYUT.js} +13 -7
  214. package/{readDocTool-SKQVHBLO.js → readDocTool-N3GA52JR.js} +1 -1
  215. package/{readlineWorkspace-7U272DSA.js → readlineWorkspace-PJZJVGA5.js} +7486 -4492
  216. package/rememberExplicit-CPAPONSI.js +15 -0
  217. package/{removeDialogAgentAction-F5QE2O2B.js → removeDialogAgentAction-EEVSOQOJ.js} +18 -17
  218. package/{runAgentClientLoop-AF4JQIJ7.js → runAgentClientLoop-3VC5TCDW.js} +107 -76
  219. package/{runtimeDoctorCommands-RRKPBGVO.js → runtimeDoctorCommands-V3M3JTUV.js} +14 -11
  220. package/{secretCommands-KZWBZIYS.js → secretCommands-KVVZS7A6.js} +3 -3
  221. package/{setDialogExtraReferencesAction-72L27ERM.js → setDialogExtraReferencesAction-DNO5POHA.js} +15 -14
  222. package/{setPrimaryDialogAgentAction-GJJDUSGJ.js → setPrimaryDialogAgentAction-QABBEO4C.js} +18 -17
  223. package/{settingThunks-ZRGWVGZD.js → settingThunks-DVKG4X4S.js} +181 -66
  224. package/{skillDiscovery-BHHPCUHZ.js → skillDiscovery-ZMJH36AK.js} +4 -3
  225. package/{spaceCommands-5VNWMDBE.js → spaceCommands-AGGZXPY3.js} +235 -87
  226. package/{streamAgentChatTurn-YSPEFY4K.js → streamAgentChatTurn-4GTLL2OF.js} +242 -169
  227. package/{switchDialogAgentAction-IIJBPND3.js → switchDialogAgentAction-KYWJSGOO.js} +16 -15
  228. package/{tableCommands-FTAOCBTX.js → tableCommands-EFA754RE.js} +7 -4
  229. package/{toolApiClient-OGQEBQVX.js → toolApiClient-N5PYW2R3.js} +8 -6
  230. package/{tools-M35PTIFB.js → tools-5AGPOPLW.js} +69 -65
  231. package/{tuiRestart-2IL37YIB.js → tuiRestart-77E7PL4R.js} +11 -10
  232. package/{tuiSummaryLlmCaller-W2QN4VAC.js → tuiSummaryLlmCaller-HROLGN4F.js} +16 -15
  233. package/{updateCommands-CPATDG6J.js → updateCommands-GJGRS6JK.js} +3 -3
  234. package/{updateDialogTitleAction-IMIRJRQQ.js → updateDialogTitleAction-5OSEDGRK.js} +40 -38
  235. package/{usageCommand-2BF74MKF.js → usageCommand-WI6SQOPB.js} +2 -2
  236. package/{usageRebuildCommand-UHB55BQM.js → usageRebuildCommand-WQRLLZAT.js} +3 -3
  237. package/webapi-QVV65DQF.js +2487 -0
  238. package/{windowsSelfUpdate-ZFD6J5HF.js → windowsSelfUpdate-C7LGVWYX.js} +2 -2
  239. package/workContext-Y3ADAPZU.js +14 -0
  240. package/workContextAccess-VU5I4LKZ.js +11 -0
  241. package/workContextWriteNotice-YCSSMHN4.js +7 -0
  242. package/{workloadLifecycle-HFJIN5IZ.js → workloadLifecycle-P2SJVV3S.js} +2 -2
  243. package/agentRecordCommands-IZYUVHME.js +0 -177
  244. package/agentRunCommand-QM7ETUTX.js +0 -209
  245. package/chunk-2YGBI2XB.js +0 -30
  246. package/chunk-5ZMIIR23.js +0 -265
  247. package/chunk-5ZUOVCKT.js +0 -32
  248. package/chunk-62HXNQVV.js +0 -134
  249. package/chunk-FJSNBZXR.js +0 -142
  250. package/chunk-FPBJM2BW.js +0 -689
  251. package/chunk-JQZRSXS5.js +0 -90
  252. package/chunk-P2ZLUIW2.js +0 -795
  253. package/chunk-PPJYZRSQ.js +0 -160
  254. package/chunk-TUSTONB3.js +0 -81
  255. package/chunk-ZXF6D3I6.js +0 -359
  256. package/cliLocalAgentRecordReader-H3HYQRRR.js +0 -91
  257. package/lib-OT5OTXRU.js +0 -21046
  258. package/localRuntimeAuthority-IBJAT62G.js +0 -16
  259. package/machineWsRunDispatch-L6H7J66T.js +0 -192
  260. package/{chunk-W6RFEDN4.js → chunk-AETZ7AD6.js} +3 -3
@@ -1,6 +1,16 @@
1
+ import {
2
+ confirmMcpOnHost,
3
+ createConnectorApprovalPort,
4
+ createMcpLocalRuntimeAdapter,
5
+ getHostApprovalRenderer,
6
+ openMcpLocalRuntimeManagement,
7
+ parsePendingApprovalResult,
8
+ runConnectorToolWithHostApproval,
9
+ withHostApprovalRequest
10
+ } from "./chunk-6PAHSSD2.js";
1
11
  import {
2
12
  BROWSER_SHELL_BRIDGE_ENV
3
- } from "./chunk-2YGBI2XB.js";
13
+ } from "./chunk-R72QWIFO.js";
4
14
  import {
5
15
  adoptRequiredClaudeCodeVersion,
6
16
  anthropicRefresh,
@@ -12,17 +22,12 @@ import {
12
22
  resolveClaudeCodeVersion,
13
23
  resolveServerSyncConfig,
14
24
  xaiRefresh
15
- } from "./chunk-XSW4EXQV.js";
25
+ } from "./chunk-6BMTKYAO.js";
16
26
  import {
17
27
  clearCredentialAvailability,
18
28
  markCredentialUnavailable,
19
29
  readCredentialEntry
20
- } from "./chunk-WWTSEBDF.js";
21
- import {
22
- DialogNotifyError,
23
- deliverDialogNotification,
24
- sha256Hex
25
- } from "./chunk-M4SFKP5L.js";
30
+ } from "./chunk-GIXWVN2W.js";
26
31
  import {
27
32
  SANDBOX_HELPER_PATH,
28
33
  SANDBOX_OUTPUT_LIMITS,
@@ -31,13 +36,13 @@ import {
31
36
  buildWorkspaceHelperSource,
32
37
  dockerExecutionToolNames,
33
38
  parseToolOutput
34
- } from "./chunk-HGDKT2D6.js";
39
+ } from "./chunk-BPB3T5EU.js";
35
40
  import {
36
41
  createChromeConnectorClientResolver,
37
42
  createVerifiedChromeConnectorClient,
38
43
  executeChromeConnectorTool,
39
44
  validateChromeConnectorPayload
40
- } from "./chunk-UAIHKQIA.js";
45
+ } from "./chunk-U6RD332P.js";
41
46
  import {
42
47
  customNativeAuthHeaders,
43
48
  detectDeclaredCustomNativeWire,
@@ -45,9 +50,14 @@ import {
45
50
  resolveCustomNativeApiKeyHeader,
46
51
  resolveCustomNativeEndpoint
47
52
  } from "./chunk-WOAZVUSN.js";
53
+ import {
54
+ DialogNotifyError,
55
+ deliverDialogNotification,
56
+ sha256Hex
57
+ } from "./chunk-OKAXQFON.js";
48
58
  import {
49
59
  createTuiSummaryLlmCaller
50
- } from "./chunk-TSPMLCWI.js";
60
+ } from "./chunk-OB4FBZXJ.js";
51
61
  import {
52
62
  CliProviderQuotaError,
53
63
  executeCli,
@@ -60,22 +70,15 @@ import {
60
70
  buildCliPrompt
61
71
  } from "./chunk-ATNTHIZI.js";
62
72
  import {
63
- extractLastUserText,
64
- localTurnHasSubjectRefs,
65
- resolveLocalUserId,
66
- withResolvedRuntimeToolSurface
67
- } from "./chunk-HHFGE2WF.js";
68
- import {
69
- inferCaptureIntent,
70
73
  resolveUserSkillRuntime
71
- } from "./chunk-ZXF6D3I6.js";
74
+ } from "./chunk-V5TI7HJH.js";
72
75
  import {
73
76
  inlineImageUrlsForCustomProvider,
74
77
  prepareTools
75
- } from "./chunk-OTKSESZR.js";
78
+ } from "./chunk-KDBDOXOM.js";
76
79
  import {
77
80
  getServerProviderSecret
78
- } from "./chunk-HS7MLR74.js";
81
+ } from "./chunk-KZ4A7EIV.js";
79
82
  import {
80
83
  CONTROL_AGENT_RUN_ACTIONS,
81
84
  buildCliLocalRuntimeForwardArgs,
@@ -95,20 +98,18 @@ import {
95
98
  resolveCliLocalSpawnDispatch,
96
99
  resolveRunContextFacts,
97
100
  resolveStartAgentRunCwd
98
- } from "./chunk-GAYNXB6T.js";
99
- import {
100
- deriveCredentialGroup,
101
- deriveCustomProviderCredentialGroup
102
- } from "./chunk-RRDRQOEC.js";
101
+ } from "./chunk-U3BUWDUP.js";
103
102
  import {
104
103
  normalizeEnabledPromptSkills,
105
104
  resolveUserEnabledSkills
106
- } from "./chunk-RBPUNSG5.js";
105
+ } from "./chunk-R3FZHW4Q.js";
107
106
  import {
108
- prepareTokenUsageData,
109
- runKeyed,
110
107
  validateAskChoiceInput
111
- } from "./chunk-7BCG67EI.js";
108
+ } from "./chunk-YXK3GJF5.js";
109
+ import {
110
+ prepareTokenUsageData,
111
+ runKeyed
112
+ } from "./chunk-EVHTYVD2.js";
112
113
  import {
113
114
  applyTokenUsageToDayStats,
114
115
  require_format
@@ -119,22 +120,28 @@ import {
119
120
  } from "./chunk-523DITKR.js";
120
121
  import {
121
122
  fetchServerSyncedCredential
122
- } from "./chunk-WCFFRBL5.js";
123
+ } from "./chunk-7PON4LBY.js";
124
+ import {
125
+ getDefaultCliLocalRuntimeDb
126
+ } from "./chunk-J55F3IEZ.js";
123
127
  import {
124
- defaultLoopbackRequest
125
- } from "./chunk-VP3BINY7.js";
128
+ defaultLoopbackRequest,
129
+ loadLocalRunChildDialogIds
130
+ } from "./chunk-KDDHQMSH.js";
126
131
  import {
127
132
  CREDENTIAL_STORE_SESSION_FALLBACK_WARNING,
128
133
  OAUTH_PROVIDER_REFS,
129
134
  getSharedSessionCredentialBroker
130
- } from "./chunk-TQEKUOTI.js";
135
+ } from "./chunk-UFGUJ2IH.js";
136
+ import {
137
+ deriveCredentialGroup,
138
+ deriveCustomProviderCredentialGroup,
139
+ resolveDispatchReasoningEffort
140
+ } from "./chunk-PNLDLUMO.js";
131
141
  import {
132
142
  fetchWithTransientRetry,
133
143
  isTransientFetchError
134
144
  } from "./chunk-DXWGFL2Z.js";
135
- import {
136
- getDefaultCliLocalRuntimeDb
137
- } from "./chunk-N5Z2V73W.js";
138
145
  import {
139
146
  _readQueueEntriesLocked,
140
147
  ackRunRecord,
@@ -143,6 +150,7 @@ import {
143
150
  checkStaleRun,
144
151
  claimRunRecord,
145
152
  commitRunRecordClaim,
153
+ defaultGenerateRunId,
146
154
  findRunRecord,
147
155
  gcRunRecords,
148
156
  isRunTerminalStatus,
@@ -159,12 +167,7 @@ import {
159
167
  terminateRunProcess,
160
168
  transitionRunToTerminal,
161
169
  withQueueLock
162
- } from "./chunk-OWKNSIXL.js";
163
- import {
164
- remoteDialogSyncTimeout,
165
- resolveRuntimeAuthToken,
166
- resolveRuntimeServerUrl
167
- } from "./chunk-2X7WFDT6.js";
170
+ } from "./chunk-JAKRY74O.js";
168
171
  import {
169
172
  TASK_PREVIEW_MAX,
170
173
  formatControlRunMessageCard,
@@ -181,21 +184,19 @@ import {
181
184
  resolveAgentRunName,
182
185
  resolveRunLabel,
183
186
  shortRunId
184
- } from "./chunk-OOJNQK6V.js";
185
- import {
186
- isTombstoneRecord
187
- } from "./chunk-BV3FLP2L.js";
187
+ } from "./chunk-S25VJYXV.js";
188
188
  import {
189
189
  readAgentFromStore,
190
190
  readDialogMessageRecords,
191
191
  readDialogMessages,
192
192
  resolveBuiltinLocalCliAgentConfig
193
- } from "./chunk-TCZ2VJZQ.js";
193
+ } from "./chunk-KKIQAVDR.js";
194
194
  import {
195
- LOCAL_CODEX_AGENT_KEY,
196
- isLocalCliAgentKey,
197
- resolveCliAgentKeyInput
198
- } from "./chunk-BR3GT6MR.js";
195
+ applyPublicAgentCatalogOverride
196
+ } from "./chunk-223KZUJ6.js";
197
+ import {
198
+ applyBuiltinAgentRuntimeOverride
199
+ } from "./chunk-CEKRIR22.js";
199
200
  import {
200
201
  DEFAULT_HYBRID_READ_TIMEOUT_MS,
201
202
  Duration_exports,
@@ -212,25 +213,25 @@ import {
212
213
  buildNoloWorkspaceCliToolExecutors,
213
214
  codexStreamFailureStatus,
214
215
  createDevinProvider,
215
- createHostCredentialBrokerChain,
216
216
  createHybridRecordStore,
217
217
  createLocalWorkspaceToolExecutors,
218
218
  createResponsesStreamCollector,
219
- createStrictHostCredentialBroker,
220
219
  deriveStableUuid,
221
220
  describeOpenAiCompatibleRequestBudget,
222
- dialogMessageRecordToAgentRuntimeMessage,
223
221
  executeLocalToolWithPolicy,
224
222
  executeOpenAiCompatibleChatCompletion,
225
223
  filterRetainedLedgerRecords,
224
+ filterToolNamesForRunKind,
226
225
  getAgentRuntimeToolParametersIndex,
227
226
  getLocalShellLifecycle,
227
+ hasRunWakeChannel,
228
228
  hashToolDefinitions,
229
229
  internalListWorkspaceEntries,
230
230
  internalSearchWorkspace,
231
231
  isCommandExecutingTool,
232
232
  isLineRangeCovered,
233
233
  isStableSessionIdentityEnabled,
234
+ isSubtaskRun,
234
235
  normalizeLocalToolName,
235
236
  orderDialogHistory,
236
237
  parseSyncServersEnv,
@@ -246,11 +247,17 @@ import {
246
247
  runExecShellGates,
247
248
  validateConfiguredRootExecutionLease,
248
249
  verifyOwnerRouteAck
249
- } from "./chunk-3QIYD3VM.js";
250
+ } from "./chunk-TUOHSUK5.js";
251
+ import {
252
+ createHostCredentialBrokerChain,
253
+ createStrictHostCredentialBroker
254
+ } from "./chunk-EHFBP6IK.js";
250
255
  import {
256
+ AGENT_PROMPT_IN_MESSAGES,
251
257
  accumulateGeminiChunks,
252
258
  buildGeminiGenerateContentRequest,
253
259
  fetchAntigravityCloudCodeCompletion,
260
+ hasAssembledAgentPrompt,
254
261
  isGemini3Model,
255
262
  parseSseDataLineJson,
256
263
  parseSseDataLineObject,
@@ -258,7 +265,7 @@ import {
258
265
  resolveAntigravityFinishReason,
259
266
  resolveGeminiModelQuirks,
260
267
  shouldUseGeminiNativeToolRoute
261
- } from "./chunk-U2HBB7RS.js";
268
+ } from "./chunk-OOV5JN25.js";
262
269
  import {
263
270
  readLocalImage
264
271
  } from "./chunk-AL3TYDIF.js";
@@ -273,24 +280,39 @@ import {
273
280
  readPlatformChatSseCompletion,
274
281
  resolvePlatformChatProviderConfig,
275
282
  shouldUsePlatformChatProvider
276
- } from "./chunk-HSSBDZLD.js";
283
+ } from "./chunk-PIVTQRX6.js";
277
284
  import {
278
285
  readSseDataValues,
279
286
  readSseFrames
280
287
  } from "./chunk-HNUWUO75.js";
288
+ import {
289
+ resolveAgentRuntimeConfigFromRecord
290
+ } from "./chunk-5ISNPTQH.js";
281
291
  import {
282
292
  resolveAgentImageInputSupport,
283
293
  resolveCatalogImageSupport,
284
294
  resolveToolImagePolicy,
285
295
  withLiveImageSupport
286
- } from "./chunk-DUUDXSLX.js";
296
+ } from "./chunk-BZLGPM5B.js";
297
+ import {
298
+ buildNoloWorkspaceOpenAiTools,
299
+ filterClientNoloWorkspaceToolNames,
300
+ parseNoloWorkspaceToolArguments
301
+ } from "./chunk-VJFDG3ZG.js";
302
+ import {
303
+ extractQuotaSnapshot,
304
+ isCapacitySaturatedRateLimit,
305
+ mergeAvailabilityDeadline,
306
+ resolveAvailabilityAction,
307
+ resolveCredentialKeyWithFallback
308
+ } from "./chunk-LS5KAVFQ.js";
287
309
  import {
288
310
  collectStablePromptPrefix,
289
311
  convertMessagesToResponsesInput,
290
312
  findAgentStatePairingIssues,
291
313
  stablePromptCacheKey,
292
314
  toResponsesTools
293
- } from "./chunk-EEOOBRA7.js";
315
+ } from "./chunk-FXEPZKNJ.js";
294
316
  import {
295
317
  EMPTY_TOOL_RESULT_TEXT,
296
318
  MAX_TOOL_IMAGES_PER_REQUEST,
@@ -303,32 +325,16 @@ import {
303
325
  toolImages
304
326
  } from "./chunk-X4O7FJF5.js";
305
327
  import {
306
- assertDispatchSelectionAdmission,
307
- buildNoloWorkspaceOpenAiTools,
308
- filterClientNoloWorkspaceToolNames,
309
- parseNoloWorkspaceToolArguments
310
- } from "./chunk-MNEZUL5S.js";
311
- import {
312
- extractQuotaSnapshot,
313
- isCapacitySaturatedRateLimit,
314
- mergeAvailabilityDeadline,
315
- resolveAvailabilityAction,
316
- resolveCredentialKeyWithFallback
317
- } from "./chunk-QJTZ76CP.js";
328
+ resolveAgentRequiredPackIds,
329
+ resolveAgentSkillConfig,
330
+ resolveHistoricalToolContentCap
331
+ } from "./chunk-VH7UO6E5.js";
318
332
  import {
319
- HIGH_RISK_MUTATION_TOOL_NAMES,
320
- resolveRequestToolSurface
321
- } from "./chunk-VS276URX.js";
333
+ MCP_TOOL_NAMES
334
+ } from "./chunk-KXOPLLFP.js";
322
335
  import {
323
336
  resolveAgentCallPlan
324
- } from "./chunk-OBIC6EG7.js";
325
- import {
326
- resolveHistoricalToolContentCap
327
- } from "./chunk-WFGNWWJI.js";
328
- import {
329
- resolveAgentRequiredPackIds,
330
- resolveAgentSkillConfig
331
- } from "./chunk-FJSNBZXR.js";
337
+ } from "./chunk-DNNPARJK.js";
332
338
  import {
333
339
  buildDialogFallbackTitleFromUserInput,
334
340
  normalizeDialogTitle
@@ -341,14 +347,16 @@ import {
341
347
  commitCodexOAuthCatalogWindows,
342
348
  isCodexOAuthAgent,
343
349
  markCodexOAuthCatalogFailure,
344
- resolveCodexOAuthEffectiveModel
345
- } from "./chunk-QRGDJA4B.js";
350
+ resolveCodexOAuthEffectiveModel,
351
+ usesCodexDeveloperPrefix
352
+ } from "./chunk-7WHCIA5V.js";
346
353
  import {
347
354
  isDevinOAuthAgent
348
355
  } from "./chunk-5ZUL4CUO.js";
349
356
  import {
350
- normalizeUsage
351
- } from "./chunk-L32W3PRP.js";
357
+ normalizeUsage,
358
+ sanitizeSummarySourceSegments
359
+ } from "./chunk-2FZVXOFX.js";
352
360
  import {
353
361
  createProviderCallTimingTracker,
354
362
  finalizeProviderCallTiming,
@@ -367,27 +375,36 @@ import {
367
375
  resolveLocalWorkspaceExecutorOptionsFromPolicy,
368
376
  resolveRequestedRuntimeToolNames
369
377
  } from "./chunk-USGHJSGO.js";
370
- import {
371
- asRecordOrEmpty
372
- } from "./chunk-KX6YBIHG.js";
373
378
  import {
374
379
  createFileCredentialBroker
375
- } from "./chunk-OQHIVPG4.js";
380
+ } from "./chunk-E6A5NHDH.js";
376
381
  import {
377
- compactWhitespace
378
- } from "./chunk-DWLEOOGR.js";
382
+ asRecordOrEmpty
383
+ } from "./chunk-KX6YBIHG.js";
379
384
  import {
380
385
  withShellChildEnvironment
381
- } from "./chunk-VMJVAJ6W.js";
386
+ } from "./chunk-UP7KBWLE.js";
387
+ import {
388
+ assertDispatchSelectionAdmission
389
+ } from "./chunk-HEVRQGGH.js";
382
390
  import {
383
391
  estimateTokenCount
384
392
  } from "./chunk-PSCNXBYA.js";
393
+ import {
394
+ compactWhitespace
395
+ } from "./chunk-DWLEOOGR.js";
385
396
  import {
386
397
  createOAuthTokenStore,
387
398
  isTokenExpired,
388
399
  readOAuthCredential,
389
400
  resolveFreshAccessToken
390
401
  } from "./chunk-G7Y4GXTY.js";
402
+ import {
403
+ isTombstoneRecord
404
+ } from "./chunk-BV3FLP2L.js";
405
+ import {
406
+ dialogMessageRecordToAgentRuntimeMessage
407
+ } from "./chunk-4ZCTKB27.js";
391
408
  import {
392
409
  FORCED_TOOLS,
393
410
  addDefaultLightWebToolsForConfiguredAgents,
@@ -399,17 +416,15 @@ import {
399
416
  expandEnabledPacks,
400
417
  resolveBuiltinSkillEntry,
401
418
  resolveEffectiveEnabledPacks
402
- } from "./chunk-G7IUT2V3.js";
403
- import {
404
- CHROME_CONNECTOR_ACCEPTED_TOOL_NAMES,
405
- canonicalizeChromeConnectorToolNames,
406
- canonicalizeToolNames
407
- } from "./chunk-6OVNSQHN.js";
419
+ } from "./chunk-WC3J5SL2.js";
408
420
  import {
421
+ DIALOG_AGENT_LIST_INDEX_PREFIX,
422
+ TOKEN_DIALOG_INDEX_PREFIX,
409
423
  createTokenDialogIndexKey,
410
424
  createTokenKey,
411
425
  createTokenStatsKey,
412
- createUserKey
426
+ createUserKey,
427
+ isTokenStatsKey
413
428
  } from "./chunk-SYTHYBMI.js";
414
429
  import {
415
430
  dialogMessageKey
@@ -417,14 +432,41 @@ import {
417
432
  import {
418
433
  dialogIdFromKey
419
434
  } from "./chunk-YZMNK53S.js";
435
+ import {
436
+ extractLastUserText,
437
+ localTurnHasSubjectRefs,
438
+ resolveLocalUserId,
439
+ withResolvedRuntimeToolSurface
440
+ } from "./chunk-QGFLVQ6E.js";
441
+ import {
442
+ LOCAL_CODEX_AGENT_KEY,
443
+ isLocalCliAgentKey,
444
+ resolveCliAgentKeyInput
445
+ } from "./chunk-BR3GT6MR.js";
446
+ import {
447
+ HIGH_RISK_MUTATION_TOOL_NAMES,
448
+ resolveRequestToolSurface
449
+ } from "./chunk-JCQ3WCQ3.js";
450
+ import {
451
+ remoteDialogSyncTimeout,
452
+ resolveRuntimeAuthToken,
453
+ resolveRuntimeServerUrl
454
+ } from "./chunk-UUCYUN6Y.js";
455
+ import {
456
+ CHROME_CONNECTOR_ACCEPTED_TOOL_NAMES,
457
+ canonicalizeChromeConnectorToolNames,
458
+ canonicalizeToolNames
459
+ } from "./chunk-YLAHYLDQ.js";
420
460
  import {
421
461
  asOptionalPositiveFiniteNumber
422
462
  } from "./chunk-U6VC4MU4.js";
423
463
  import {
424
464
  classifyDialogSyncFailure,
425
- getLogger,
426
465
  startOwnedDialogSync
427
- } from "./chunk-6XRPBZRS.js";
466
+ } from "./chunk-XRGBJHZX.js";
467
+ import {
468
+ getLogger
469
+ } from "./chunk-EYLGAEB4.js";
428
470
  import {
429
471
  getHostRuntimeExecutable,
430
472
  isCompiledBinary,
@@ -441,25 +483,26 @@ import {
441
483
  import {
442
484
  agentRunCardLabels,
443
485
  t
444
- } from "./chunk-262R3XNN.js";
486
+ } from "./chunk-FEIVARWR.js";
445
487
  import {
446
488
  isAntigravityOAuthAgent
447
- } from "./chunk-7JGMNKKG.js";
448
- import {
449
- buildProviderSessionHeaders,
450
- resolvePlatformAuthToken
451
- } from "./chunk-RTHFJZ6M.js";
489
+ } from "./chunk-6SOWMEAY.js";
452
490
  import {
453
491
  toErrorMessage
454
492
  } from "./chunk-HNMXYYJR.js";
493
+ import {
494
+ buildProviderSessionHeaders,
495
+ resolvePlatformAuthToken
496
+ } from "./chunk-LVZVSLKO.js";
455
497
  import {
456
498
  asTrimmedString
457
499
  } from "./chunk-3EUW3WEO.js";
458
500
  import {
501
+ REASONING_EFFORT_OPTIONS,
459
502
  anthropicOAuthModelMaxOutputTokens,
460
503
  findModelConfig,
461
504
  isAdaptiveThinkingModelId
462
- } from "./chunk-CD3RU7XL.js";
505
+ } from "./chunk-OKH74FML.js";
463
506
  import {
464
507
  CLI_PROVIDER_VALUES,
465
508
  isCliProvider
@@ -493,9 +536,9 @@ function createLiveImageSupportResolver(userId, discover, timeoutMs = 5e3) {
493
536
  const raw = config.rawRecord ?? config;
494
537
  const owner = typeof raw.userId === "string" && raw.userId.trim() ? raw.userId.trim() : typeof raw.ownerUserId === "string" ? raw.ownerUserId.trim() : void 0;
495
538
  if (!userId || owner !== userId) return withLiveImageSupport(config, false);
496
- discovery ??= new Promise((resolve7) => {
497
- const timer = setTimeout(() => resolve7({}), timeoutMs);
498
- Promise.resolve().then(discover).then(resolve7, () => resolve7({})).finally(() => clearTimeout(timer));
539
+ discovery ??= new Promise((resolve8) => {
540
+ const timer = setTimeout(() => resolve8({}), timeoutMs);
541
+ Promise.resolve().then(discover).then(resolve8, () => resolve8({})).finally(() => clearTimeout(timer));
499
542
  });
500
543
  const models = await discovery;
501
544
  const model = config.model?.trim() ?? "";
@@ -733,7 +776,7 @@ function resolveThinkingSpec(input) {
733
776
  let finalMaxTokens = maxTokens;
734
777
  let finalTemperature = input.temperature;
735
778
  if (isAdaptiveThinkingModelId(model)) {
736
- if (effortDisabled) {
779
+ if (effortDisabled || normalizedEffort === void 0 && input.enableThinking === false) {
737
780
  thinkingBlock = { type: "disabled" };
738
781
  } else {
739
782
  thinkingBlock = { type: "adaptive", display: "summarized" };
@@ -743,7 +786,7 @@ function resolveThinkingSpec(input) {
743
786
  const injected = input.injectedThinking;
744
787
  const injectedBudget = injected?.type === "enabled" && typeof injected.budget_tokens === "number" ? injected.budget_tokens : void 0;
745
788
  const effortBudget = resolveThinkingBudget(input.reasoningEffort);
746
- const fallbackBudget = input.reasoningEffort === void 0 ? injectedBudget ?? (input.enableThinking === true ? typeof input.thinkingBudget === "number" ? input.thinkingBudget : DEFAULT_ENABLE_THINKING_BUDGET : DEFAULT_ENABLED_BUDGET) : void 0;
789
+ const fallbackBudget = input.reasoningEffort === void 0 && input.enableThinking !== false ? injectedBudget ?? (input.enableThinking === true ? typeof input.thinkingBudget === "number" ? input.thinkingBudget : DEFAULT_ENABLE_THINKING_BUDGET : DEFAULT_ENABLED_BUDGET) : void 0;
747
790
  const thinkingBudget = effortBudget ?? fallbackBudget;
748
791
  if (thinkingBudget !== void 0) {
749
792
  thinkingBlock = { type: "enabled", budget_tokens: thinkingBudget };
@@ -891,7 +934,7 @@ function buildAnthropicMessagesBody(args) {
891
934
  const mode = resolveCacheMode();
892
935
  const rawMessages = Array.isArray(args.openAiBody.messages) ? args.openAiBody.messages : [];
893
936
  const system = [];
894
- if (args.agentConfig.prompt?.trim()) {
937
+ if (!hasAssembledAgentPrompt(rawMessages) && args.agentConfig.prompt?.trim()) {
895
938
  system.push({ type: "text", text: args.agentConfig.prompt.trim() });
896
939
  }
897
940
  const messages = [];
@@ -1236,6 +1279,57 @@ function clearCliLocalRuntimePreparedAgentCache() {
1236
1279
  preparedAgentRuntimeCache.clear();
1237
1280
  hybridStoreCache.clear();
1238
1281
  }
1282
+ var SCALAR_AGENT_CONFIG_FINGERPRINT_FIELDS = [
1283
+ "apiSource",
1284
+ "customProviderUrl",
1285
+ "model",
1286
+ "name",
1287
+ "prompt",
1288
+ "provider",
1289
+ "revision",
1290
+ "updatedAt",
1291
+ "version"
1292
+ ];
1293
+ var TOOL_LIST_FINGERPRINT_FIELDS = ["toolNames", "tools"];
1294
+ function extractFingerprintToolNames(raw) {
1295
+ if (!Array.isArray(raw)) return void 0;
1296
+ const seen = /* @__PURE__ */ new Set();
1297
+ for (const value of raw) {
1298
+ const rawName = typeof value === "string" ? value : value && typeof value === "object" && !Array.isArray(value) ? typeof value.name === "string" ? value.name : value.function && typeof value.function === "object" && !Array.isArray(value.function) && typeof value.function.name === "string" ? value.function.name : "" : "";
1299
+ const trimmed = rawName.trim();
1300
+ if (trimmed) seen.add(trimmed);
1301
+ }
1302
+ return [...seen].sort((a, b) => a.localeCompare(b));
1303
+ }
1304
+ function buildLocalAgentConfigFingerprint(source) {
1305
+ const record = source && typeof source === "object" ? source : null;
1306
+ const payload = {
1307
+ skillPolicy: Object.entries(resolveAgentSkillConfig(record)).sort(
1308
+ ([a], [b]) => a.localeCompare(b)
1309
+ )
1310
+ };
1311
+ if (record) {
1312
+ for (const field of SCALAR_AGENT_CONFIG_FINGERPRINT_FIELDS) {
1313
+ if (!Object.prototype.hasOwnProperty.call(record, field)) continue;
1314
+ const value = record[field];
1315
+ if (typeof value === "string" || typeof value === "number" && Number.isFinite(value) || typeof value === "boolean") {
1316
+ payload[field] = value;
1317
+ }
1318
+ }
1319
+ for (const field of TOOL_LIST_FINGERPRINT_FIELDS) {
1320
+ if (!Object.prototype.hasOwnProperty.call(record, field)) continue;
1321
+ const names = extractFingerprintToolNames(record[field]);
1322
+ if (names !== void 0) {
1323
+ payload[field] = names;
1324
+ }
1325
+ }
1326
+ }
1327
+ const ordered = {};
1328
+ for (const key of Object.keys(payload).sort((a, b) => a.localeCompare(b))) {
1329
+ ordered[key] = payload[key];
1330
+ }
1331
+ return JSON.stringify(ordered);
1332
+ }
1239
1333
  async function defaultLocalRuntimeDb() {
1240
1334
  return getDefaultCliLocalRuntimeDb();
1241
1335
  }
@@ -1292,44 +1386,6 @@ var REGISTRY_INJECTED_TOOL_NAMES = /* @__PURE__ */ new Set([
1292
1386
  "read_xhs_profile"
1293
1387
  ]);
1294
1388
 
1295
- // packages/agent-runtime/agentRunIsolation.ts
1296
- var ORCHESTRATION_TOOL_NAMES = /* @__PURE__ */ new Set([
1297
- "startAgentRun",
1298
- "controlAgentRun",
1299
- "listAgents",
1300
- "readAgent",
1301
- "runStreamingAgent"
1302
- ]);
1303
- var INTERACTION_REQUIRED_TOOL_NAMES = /* @__PURE__ */ new Set([
1304
- "ask_user",
1305
- // 凭据请求:需要宿主交互面板(Block 1a);desktop 无通道时同 ask_user 剥离。
1306
- "secret-request"
1307
- ]);
1308
- var SELF_MUTATION_TOOL_NAMES = /* @__PURE__ */ new Set([
1309
- "updateSelf",
1310
- "updateAgent"
1311
- ]);
1312
- var SUBTASK_REMOVED_TOOL_NAMES = /* @__PURE__ */ new Set([
1313
- ...ORCHESTRATION_TOOL_NAMES,
1314
- ...INTERACTION_REQUIRED_TOOL_NAMES,
1315
- ...SELF_MUTATION_TOOL_NAMES
1316
- ]);
1317
- function isSubtaskRun(env) {
1318
- if (!env) return false;
1319
- const value = env.NOLO_AGENT_RUN_CHILD;
1320
- return typeof value === "string" && value.length > 0 && value !== "0";
1321
- }
1322
- var RUN_WAKE_CHANNEL_ENV = "NOLO_RUN_WAKE";
1323
- function hasRunWakeChannel(env) {
1324
- if (!env) return false;
1325
- const value = env[RUN_WAKE_CHANNEL_ENV];
1326
- return typeof value === "string" && value.length > 0 && value !== "0";
1327
- }
1328
- function filterToolNamesForRunKind(toolNames, isSubtask) {
1329
- if (!isSubtask) return [...toolNames];
1330
- return toolNames.filter((name) => !SUBTASK_REMOVED_TOOL_NAMES.has(name));
1331
- }
1332
-
1333
1389
  // packages/cli/client/localRuntimeTools.ts
1334
1390
  var CLI_CHROME_CONNECTOR_TOOL_NAME_SET = new Set(
1335
1391
  CHROME_CONNECTOR_ACCEPTED_TOOL_NAMES
@@ -1416,7 +1472,8 @@ function buildOrchestrationOpenAiTools(args) {
1416
1472
  });
1417
1473
  const startSchema = buildStartAgentRunFunctionSchema({
1418
1474
  supportsWait: false,
1419
- wakeEnabled: wakeChannel
1475
+ wakeEnabled: wakeChannel,
1476
+ includeInstabox: hostExposesInstaboxParams(args.env)
1420
1477
  });
1421
1478
  return [
1422
1479
  ...prepareTools(names).map((tool) => {
@@ -1433,7 +1490,10 @@ function buildOrchestrationOpenAiTools(args) {
1433
1490
  var CLI_DEFAULT_TOOLS = [
1434
1491
  "exa_search",
1435
1492
  "fetchWebpage",
1436
- "ask_user",
1493
+ // ask_user 不在默认面:它只在 agent 显式声明(direct tool 或 enabledPacks
1494
+ // 展开)时才暴露。默认常驻白占 schema/菜单指令上下文,而多轮里真正需要向
1495
+ // 用户提问的比例很低;TUI 的 AskChoice dialog、headless 的编号菜单降级、
1496
+ // executor 与 policy 通道全部照旧,只是不再「未声明也可见」。
1437
1497
  // 凭据请求面板(Block 1a):抬 kind:"input" gate,宿主面板输入后在宿主进程内写 store。
1438
1498
  "secret-request",
1439
1499
  // 非阻塞展示型交互(与 ask_user 的阻塞提问区分)
@@ -1471,6 +1531,14 @@ function withRuntimeEnabledPacksAndPrompt(config) {
1471
1531
  ...prompt ? { prompt } : {}
1472
1532
  };
1473
1533
  }
1534
+ var MCP_EXPOSURE_ENV = "NOLO_EXPOSE_MCP_TOOLS";
1535
+ function hostExposesMcpTools(env) {
1536
+ return String(env[MCP_EXPOSURE_ENV] ?? "").trim() === "1";
1537
+ }
1538
+ var INSTABOX_SCHEMA_EXPOSURE_ENV = "NOLO_EXPOSE_INSTABOX_PARAMS";
1539
+ function hostExposesInstaboxParams(env) {
1540
+ return String(env[INSTABOX_SCHEMA_EXPOSURE_ENV] ?? "").trim() === "1";
1541
+ }
1474
1542
  function resolveCliRequestedToolNames(agentConfig, env, systemBuiltinSkills) {
1475
1543
  const declaredOnly = shouldUseDeclaredOnlyLocalWorkspaceTools(env);
1476
1544
  const isSubtask = isSubtaskRun(env);
@@ -1502,7 +1570,11 @@ function resolveCliRequestedToolNames(agentConfig, env, systemBuiltinSkills) {
1502
1570
  filtered,
1503
1571
  agentConfig?.disabledTools
1504
1572
  );
1505
- return filterToolNamesForRunKind(afterDisabled, isSubtask);
1573
+ const mcpSurface = hostExposesMcpTools(env) ? applyDisabledTools(
1574
+ [.../* @__PURE__ */ new Set([...afterDisabled, ...MCP_TOOL_NAMES])],
1575
+ agentConfig?.disabledTools
1576
+ ) : afterDisabled;
1577
+ return filterToolNamesForRunKind(mcpSurface, isSubtask);
1506
1578
  }
1507
1579
  function resolveProviderOpenAiToolBundle(agentConfig, env, buildTools = buildOpenAiTools, additionalToolNames = []) {
1508
1580
  const requestedToolNames = [
@@ -1530,6 +1602,7 @@ function buildLocalWorkspaceToolsetForEnv(args) {
1530
1602
  return toolset;
1531
1603
  }
1532
1604
  function buildLocalPolicyToolNames(args) {
1605
+ if (args.toolNames?.length === 0) return [];
1533
1606
  const schemaBuilder = args.buildProviderOpenAiTools ?? buildOpenAiTools;
1534
1607
  const tools = schemaBuilder({
1535
1608
  agentKey: args.agentKey,
@@ -2444,7 +2517,7 @@ var resolveCliProviderTransport = async (ctx) => {
2444
2517
  import { createHash } from "node:crypto";
2445
2518
  import { randomUUID as randomUUID2 } from "node:crypto";
2446
2519
  var CODEX_RESPONSES_URL = "https://chatgpt.com/backend-api/codex/responses";
2447
- var CODEX_CLIENT_VERSION = "0.162.1";
2520
+ var CODEX_CLIENT_VERSION = "0.169.0";
2448
2521
  var CODEX_ORIGINATOR = "codex_cli_rs";
2449
2522
  var CODEX_OPENAI_BETA = "responses=experimental";
2450
2523
  var OPENAI_AUTH_CLAIM = "https://api.openai.com/auth";
@@ -2527,26 +2600,50 @@ function buildCodexCompatibilityHeaders(identity, accountId) {
2527
2600
  "x-codex-turn-metadata": identity.turnMetadataJson
2528
2601
  };
2529
2602
  }
2530
- function collectInstructions(messages, agentPrompt) {
2603
+ function getInstructionText(content) {
2604
+ if (!Array.isArray(content)) return asOptionalTrimmedString(content);
2605
+ const text = content.filter(
2606
+ (part) => part?.type === "text" && typeof part.text === "string"
2607
+ ).map((part) => part.text).join("\n");
2608
+ return asOptionalTrimmedString(text);
2609
+ }
2610
+ function hasCodexAssembledPrompt(messages) {
2611
+ return messages.some((raw) => {
2612
+ if (!raw || typeof raw !== "object") return false;
2613
+ const message = raw;
2614
+ return message.role === "system" && (message[AGENT_PROMPT_IN_MESSAGES] === true || message.agent_prompt_in_messages === true) && getInstructionText(message.content) !== void 0;
2615
+ });
2616
+ }
2617
+ function collectInstructions(messages, agentPrompt, splitPrefix) {
2531
2618
  const systemTexts = [];
2619
+ let messageTexts = 0;
2620
+ let prefixEnd;
2532
2621
  const prompt = agentPrompt?.trim();
2533
2622
  if (prompt) systemTexts.push(prompt);
2534
2623
  for (const raw of messages) {
2535
2624
  if (!raw || typeof raw !== "object") continue;
2536
2625
  const role = String(raw.role ?? "");
2537
2626
  if (role !== "system" && role !== "developer") continue;
2538
- const content = raw.content;
2539
- const stringContent = asOptionalTrimmedString(content);
2540
- if (stringContent) {
2541
- systemTexts.push(stringContent);
2542
- } else if (Array.isArray(content)) {
2543
- const text = content.filter(
2544
- (p) => !!p && p.type === "text"
2545
- ).map((p) => p.text).join("\n").trim();
2546
- if (text) systemTexts.push(text);
2627
+ const { content, stable_prefix_chars: boundary } = raw;
2628
+ const text = getInstructionText(content);
2629
+ if (text) {
2630
+ if (splitPrefix && prefixEnd === void 0 && messageTexts === 0 && typeof content === "string" && typeof boundary === "number" && Number.isInteger(boundary) && boundary >= 0 && boundary <= content.length) {
2631
+ const stable = content.slice(0, boundary).trim();
2632
+ if (stable) systemTexts.push(stable);
2633
+ prefixEnd = systemTexts.length;
2634
+ const dynamic = content.slice(boundary).trim();
2635
+ if (dynamic) systemTexts.push(dynamic);
2636
+ } else {
2637
+ systemTexts.push(text);
2638
+ messageTexts += 1;
2639
+ }
2547
2640
  }
2548
2641
  }
2549
- return systemTexts.join("\n\n");
2642
+ const split = splitPrefix ? prefixEnd ?? 0 : 0;
2643
+ return {
2644
+ developerPrefix: systemTexts.slice(0, split).join("\n\n"),
2645
+ instructions: systemTexts.slice(split).join("\n\n")
2646
+ };
2550
2647
  }
2551
2648
  function convertMessagesToCodexInput(messages, supportsToolImages = false) {
2552
2649
  const normalizedToolImages = typeof supportsToolImages === "boolean" ? supportsToolImages : supportsToolImages.supportsToolImages === true;
@@ -2575,8 +2672,17 @@ function buildCodexRequestBody(args, identity = createCodexRequestIdentity(), se
2575
2672
  routeKind: "codex/responses",
2576
2673
  legacySupportsToolImages: false
2577
2674
  }));
2578
- const instructions = collectInstructions(rawMessages, args.agentConfig.prompt);
2579
- const stableInstructions = collectStablePromptPrefix(rawMessages, args.agentConfig.prompt);
2675
+ const fallbackPrompt = hasCodexAssembledPrompt(rawMessages) ? void 0 : args.agentConfig.prompt;
2676
+ const splitPrefix = usesCodexDeveloperPrefix(args.agentConfig, model);
2677
+ const { instructions, developerPrefix } = collectInstructions(rawMessages, fallbackPrompt, splitPrefix);
2678
+ if (developerPrefix) {
2679
+ input.unshift({
2680
+ type: "message",
2681
+ role: "developer",
2682
+ content: [{ type: "input_text", text: developerPrefix }]
2683
+ });
2684
+ }
2685
+ const stableInstructions = collectStablePromptPrefix(rawMessages, fallbackPrompt);
2580
2686
  const tools = toResponsesTools(
2581
2687
  Array.isArray(args.openAiBody.tools) ? args.openAiBody.tools : void 0
2582
2688
  );
@@ -2628,7 +2734,7 @@ function throwIfAborted(signal) {
2628
2734
  }
2629
2735
  function waitBackoff(ms, signal, injectedSleep) {
2630
2736
  throwIfAborted(signal);
2631
- return new Promise((resolve7, reject) => {
2737
+ return new Promise((resolve8, reject) => {
2632
2738
  let timer;
2633
2739
  const cleanup = () => {
2634
2740
  signal?.removeEventListener("abort", onAbort);
@@ -2643,7 +2749,7 @@ function waitBackoff(ms, signal, injectedSleep) {
2643
2749
  injectedSleep(ms).then(
2644
2750
  () => {
2645
2751
  cleanup();
2646
- resolve7();
2752
+ resolve8();
2647
2753
  },
2648
2754
  (error) => {
2649
2755
  cleanup();
@@ -2653,7 +2759,7 @@ function waitBackoff(ms, signal, injectedSleep) {
2653
2759
  } else {
2654
2760
  timer = setTimeout(() => {
2655
2761
  cleanup();
2656
- resolve7();
2762
+ resolve8();
2657
2763
  }, ms);
2658
2764
  }
2659
2765
  });
@@ -2906,14 +3012,14 @@ function countCodexInputChars(messages) {
2906
3012
  }
2907
3013
  function abortableSleep(sleepFn, ms, signal) {
2908
3014
  let timer;
2909
- const waitOnce = () => sleepFn ? Promise.resolve(sleepFn(ms)) : new Promise((resolve7) => {
2910
- timer = setTimeout(resolve7, ms);
3015
+ const waitOnce = () => sleepFn ? Promise.resolve(sleepFn(ms)) : new Promise((resolve8) => {
3016
+ timer = setTimeout(resolve8, ms);
2911
3017
  });
2912
3018
  if (!signal) return waitOnce().then(() => void 0);
2913
3019
  if (signal.aborted) {
2914
3020
  return Promise.reject(signal.reason ?? new DOMException("aborted", "AbortError"));
2915
3021
  }
2916
- return new Promise((resolve7, reject) => {
3022
+ return new Promise((resolve8, reject) => {
2917
3023
  let settled = false;
2918
3024
  const finish = (settle) => {
2919
3025
  if (settled) return;
@@ -2927,7 +3033,7 @@ function abortableSleep(sleepFn, ms, signal) {
2927
3033
  );
2928
3034
  signal.addEventListener("abort", onAbort, { once: true });
2929
3035
  waitOnce().then(
2930
- () => finish(resolve7),
3036
+ () => finish(resolve8),
2931
3037
  (error) => finish(() => reject(error))
2932
3038
  );
2933
3039
  });
@@ -3076,7 +3182,7 @@ function createCustomNativeProvider(args) {
3076
3182
  }
3077
3183
  }
3078
3184
  function buildGeminiCustomNativeProvider(p) {
3079
- const { model, endpoint, nativeEndpoint, apiKey, apiKeyHeader, agentConfig, tools, fetchImpl, fallbackSessionId, requestedToolNames, serverUrl, authToken, transport, log, recordAvailability } = p;
3185
+ const { model, endpoint, nativeEndpoint, apiKey, apiKeyHeader, agentConfig, tools, fetchImpl, fallbackSessionId, requestedToolNames, serverUrl, transport, log, recordAvailability } = p;
3080
3186
  const budgetBody = buildGeminiGenerateContentRequest({
3081
3187
  messages: [],
3082
3188
  tools,
@@ -3092,18 +3198,9 @@ function buildGeminiCustomNativeProvider(p) {
3092
3198
  complete: async (messages, options) => {
3093
3199
  const inlineResult = await inlineImageUrlsForCustomProvider({ messages }, {
3094
3200
  shouldInline: true,
3095
- isAllowedImageUrl: (url) => {
3096
- try {
3097
- return new URL(url).origin === new URL(serverUrl).origin;
3098
- } catch {
3099
- return false;
3100
- }
3101
- },
3102
- fetchImage: async (url) => {
3103
- const image = await fetchImpl(url, { headers: authToken ? { Authorization: `Bearer ${authToken}` } : void 0, signal: options?.signal });
3104
- if (!image.ok) return { ok: false, error: `HTTP ${image.status}` };
3105
- return { ok: true, mimeType: image.headers.get("content-type") ?? "application/octet-stream", bytes: new Uint8Array(await image.arrayBuffer()) };
3106
- }
3201
+ serverUrl,
3202
+ request: fetchImpl,
3203
+ signal: options?.signal
3107
3204
  });
3108
3205
  const toolImagePolicy = {
3109
3206
  routeKind: "gemini-native",
@@ -3531,7 +3628,7 @@ var resolveDevinTransport = async (ctx) => {
3531
3628
 
3532
3629
  // packages/cli/client/providerResolution/directOpenAiCompatibleTransport.ts
3533
3630
  var resolveDirectOpenAiCompatibleTransport = async (ctx) => {
3534
- const { agentConfig, deps, fetchImpl, loopbackRequest, additionalToolNames, buildProviderOpenAiTools, recordLocalAvailability, apiKeyRefResolver, credentialBroker, syncFetcher, serverUrl, authToken } = ctx;
3631
+ const { agentConfig, deps, fetchImpl, loopbackRequest, additionalToolNames, buildProviderOpenAiTools, recordLocalAvailability, apiKeyRefResolver, credentialBroker, syncFetcher, serverUrl } = ctx;
3535
3632
  const providerConfig = await resolveOpenAiCompatibleProviderConfig({
3536
3633
  agentConfig,
3537
3634
  env: deps.env,
@@ -3569,26 +3666,9 @@ var resolveDirectOpenAiCompatibleTransport = async (ctx) => {
3569
3666
  { messages },
3570
3667
  {
3571
3668
  shouldInline: true,
3572
- isAllowedImageUrl: (url) => {
3573
- try {
3574
- return new URL(url).origin === new URL(serverUrl).origin;
3575
- } catch {
3576
- return false;
3577
- }
3578
- },
3579
- fetchImage: async (url) => {
3580
- const response = await fetchImpl(url, {
3581
- headers: authToken ? { Authorization: `Bearer ${authToken}` } : void 0
3582
- });
3583
- if (!response.ok) {
3584
- return { ok: false, error: `HTTP ${response.status}` };
3585
- }
3586
- return {
3587
- ok: true,
3588
- mimeType: response.headers.get("content-type") ?? "application/octet-stream",
3589
- bytes: new Uint8Array(await response.arrayBuffer())
3590
- };
3591
- }
3669
+ serverUrl,
3670
+ request: fetchImpl,
3671
+ signal: options?.signal
3592
3672
  }
3593
3673
  )).messages;
3594
3674
  logLocalRuntimeDiagnostic("provider.request.start", {
@@ -3830,7 +3910,7 @@ function waitWithAbort(ms, signal) {
3830
3910
  if (signal?.aborted) {
3831
3911
  return Promise.reject(signal.reason ?? new Error("owner-required proxy aborted"));
3832
3912
  }
3833
- return new Promise((resolve7, reject) => {
3913
+ return new Promise((resolve8, reject) => {
3834
3914
  let timer;
3835
3915
  const cleanup = () => {
3836
3916
  if (timer !== void 0) clearTimeout(timer);
@@ -3842,7 +3922,7 @@ function waitWithAbort(ms, signal) {
3842
3922
  };
3843
3923
  timer = setTimeout(() => {
3844
3924
  cleanup();
3845
- resolve7();
3925
+ resolve8();
3846
3926
  }, ms);
3847
3927
  signal?.addEventListener("abort", onAbort, { once: true });
3848
3928
  });
@@ -4463,7 +4543,7 @@ function resolveLocalRunExecutionIsolationFact(args) {
4463
4543
  isolation: "none",
4464
4544
  sandbox: "host",
4465
4545
  reason: "host-no-sandbox",
4466
- note: "\u672C run \u5728\u5BBF\u4E3B\u6267\u884C\u4E14**\u65E0\u9694\u79BB**\uFF08\u672A\u8D70 docker \u901A\u9053\uFF0C\u4E5F\u6CA1\u6709\u53EF\u7528\u7684 bwrap workload\uFF09\u3002\u5199\u64CD\u4F5C\u76F4\u63A5\u4F5C\u7528\u4E8E\u5BBF\u4E3B\u5DE5\u4F5C\u533A\uFF1B\u6D3E\u53D1\u578B run \u7684\u9ED8\u8BA4\u843D\u70B9\u662F\u672C\u673A docker \u6C99\u76D2\uFF0C\u4EA4\u4E92\u5F0F run \u53EF\u7528 --runtime-key docker\uFF08\u6216 --local \u663E\u5F0F\u58F0\u660E\u672C\u673A\u6267\u884C\uFF09\u3002",
4546
+ note: "\u672C run \u5728\u5BBF\u4E3B\u6267\u884C\u4E14**\u65E0\u9694\u79BB**\uFF08\u672A\u8D70 docker \u901A\u9053\uFF0C\u4E5F\u6CA1\u6709\u53EF\u7528\u7684 bwrap workload\uFF09\u3002\u5199\u64CD\u4F5C\u76F4\u63A5\u4F5C\u7528\u4E8E\u5BBF\u4E3B\u5DE5\u4F5C\u533A\uFF1BCLI \u672A\u70B9\u540D\u5199\u578B\u6D3E\u53D1\u9ED8\u8BA4\u5BBF\u4E3B\u4E14\u987B allowHostWrites: true\uFF0C\u4EA4\u4E92\u5F0F run \u53EF\u7528 --runtime-key docker\uFF08\u6216 --local \u663E\u5F0F\u58F0\u660E\u672C\u673A\u6267\u884C\uFF09\u3002",
4467
4547
  recordedAt
4468
4548
  });
4469
4549
  }
@@ -4534,8 +4614,8 @@ function recordLocalRunExecutionIsolation(args) {
4534
4614
  }
4535
4615
  function joinPath(dir, name) {
4536
4616
  if (!dir) return name;
4537
- const sep2 = dir.includes("\\") && !dir.includes("/") ? "\\" : "/";
4538
- return dir.endsWith(sep2) ? `${dir}${name}` : `${dir}${sep2}${name}`;
4617
+ const sep3 = dir.includes("\\") && !dir.includes("/") ? "\\" : "/";
4618
+ return dir.endsWith(sep3) ? `${dir}${name}` : `${dir}${sep3}${name}`;
4539
4619
  }
4540
4620
 
4541
4621
  // packages/core/settingsSyncFreshness.ts
@@ -4602,7 +4682,7 @@ function isBusyProviderStreamError(error) {
4602
4682
  return BUSY_STREAM_ERROR_RE.test(toErrorMessage(error));
4603
4683
  }
4604
4684
  async function defaultSleep(ms) {
4605
- await new Promise((resolve7) => setTimeout(resolve7, ms));
4685
+ await new Promise((resolve8) => setTimeout(resolve8, ms));
4606
4686
  }
4607
4687
  function isRetryableProviderStreamError(error) {
4608
4688
  const message = toErrorMessage(error);
@@ -4794,6 +4874,8 @@ function parseBackgroundRuns(text) {
4794
4874
  tasks.push({
4795
4875
  title: title || agent || runId || SUBJECT_RUN.label,
4796
4876
  ...runId ? { identifier: runId } : {},
4877
+ ...status ? { runStatus: status } : {},
4878
+ ...attrValue(attrs, "childDialogId") && attrValue(attrs, "childDialogId") !== "missing" ? { childDialogId: decodeXmlAttribute(attrValue(attrs, "childDialogId")) } : {},
4797
4879
  outcome,
4798
4880
  outcomeLabel: OUTCOME_LABEL[outcome],
4799
4881
  ...duration ? { duration } : {},
@@ -5076,11 +5158,120 @@ function hasReservedBatchAuthority(metadata) {
5076
5158
  (field) => key === field || key.startsWith(`${field}.`) || key === `metadata.${field}` || key.startsWith(`metadata.${field}.`)
5077
5159
  ));
5078
5160
  }
5161
+ var LOCAL_ONLY_EVIDENCE_KEY_PREFIXES = [
5162
+ `${TOKEN_DIALOG_INDEX_PREFIX}-`,
5163
+ `${DIALOG_AGENT_LIST_INDEX_PREFIX}-`,
5164
+ "idx-tokendlg-backfill-",
5165
+ "token-charge-stats-",
5166
+ "usage-backup-"
5167
+ ];
5168
+ function isRemoteDialogEvidenceExcludedKey(key) {
5169
+ if (!key) return true;
5170
+ if (isTokenStatsKey(key)) return true;
5171
+ return LOCAL_ONLY_EVIDENCE_KEY_PREFIXES.some(
5172
+ (prefix) => key.startsWith(prefix)
5173
+ );
5174
+ }
5175
+ var MAX_REMOTE_ERROR_DETAIL_CHARS = 120;
5176
+ var SAFE_SHORT_ERROR_CODE_RE = /^[A-Za-z0-9_.:-]{1,48}$/;
5177
+ function sanitizeRemoteDiagnosticText(raw) {
5178
+ const singleLine = raw.replace(/\u001b\[[0-9;?]*[ -/]*[@-~]/g, " ").replace(/[\u0000-\u001f\u007f]+/g, " ").replace(/\s+/g, " ").trim();
5179
+ if (!singleLine) return "";
5180
+ return singleLine.replace(/\bBearer\s+[A-Za-z0-9._~+/=-]{6,}/gi, "Bearer [REDACTED]").replace(/\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}(?:\.[A-Za-z0-9_-]+)?/g, "[REDACTED]").replace(/\b(?:sk|rk|pk|nolo|tok)_[A-Za-z0-9_-]{8,}/gi, "[REDACTED]").replace(/\bvault-cred-[A-Za-z0-9_-]+/gi, "[REDACTED]");
5181
+ }
5182
+ function clampSingleLine(text, maxLen) {
5183
+ if (text.length <= maxLen) return text;
5184
+ if (maxLen <= 3) return text.slice(0, maxLen);
5185
+ return `${text.slice(0, maxLen - 3)}...`;
5186
+ }
5187
+ function extractSafeRemoteErrorDetail(status, bodyText) {
5188
+ if (status < 400 || status >= 500 || !bodyText) return "";
5189
+ let parsed;
5190
+ try {
5191
+ parsed = JSON.parse(bodyText);
5192
+ } catch {
5193
+ return "";
5194
+ }
5195
+ if (!isRecord(parsed)) return "";
5196
+ const rawCodeCandidates = [
5197
+ parsed.code,
5198
+ isRecord(parsed.error) ? parsed.error.code : void 0,
5199
+ typeof parsed.error === "string" ? parsed.error : void 0,
5200
+ parsed.reason
5201
+ ];
5202
+ let code = "";
5203
+ let fallbackMessageFromError = "";
5204
+ for (const candidate of rawCodeCandidates) {
5205
+ if (typeof candidate !== "string") continue;
5206
+ const cleaned = sanitizeRemoteDiagnosticText(candidate);
5207
+ if (!cleaned) continue;
5208
+ if (SAFE_SHORT_ERROR_CODE_RE.test(cleaned)) {
5209
+ code = cleaned;
5210
+ break;
5211
+ }
5212
+ if (!fallbackMessageFromError) {
5213
+ fallbackMessageFromError = cleaned;
5214
+ }
5215
+ }
5216
+ const rawMessageCandidates = [
5217
+ parsed.message,
5218
+ isRecord(parsed.error) ? parsed.error.message : void 0,
5219
+ fallbackMessageFromError
5220
+ ];
5221
+ let message = "";
5222
+ for (const candidate of rawMessageCandidates) {
5223
+ if (typeof candidate !== "string") continue;
5224
+ const cleaned = sanitizeRemoteDiagnosticText(candidate);
5225
+ if (cleaned && cleaned !== code) {
5226
+ message = cleaned;
5227
+ break;
5228
+ }
5229
+ }
5230
+ if (!code && !message) return "";
5231
+ const payload = {};
5232
+ if (code) payload.code = code;
5233
+ if (message) payload.message = message;
5234
+ let serialized = JSON.stringify(payload);
5235
+ if (serialized.length <= MAX_REMOTE_ERROR_DETAIL_CHARS) {
5236
+ return serialized;
5237
+ }
5238
+ if (code && message) {
5239
+ const baseLen = JSON.stringify({ code, message: "" }).length;
5240
+ const budget = MAX_REMOTE_ERROR_DETAIL_CHARS - baseLen;
5241
+ if (budget >= 8) {
5242
+ serialized = JSON.stringify({
5243
+ code,
5244
+ message: clampSingleLine(message, budget)
5245
+ });
5246
+ if (serialized.length <= MAX_REMOTE_ERROR_DETAIL_CHARS) return serialized;
5247
+ }
5248
+ serialized = JSON.stringify({ code });
5249
+ return serialized.length <= MAX_REMOTE_ERROR_DETAIL_CHARS ? serialized : clampSingleLine(serialized, MAX_REMOTE_ERROR_DETAIL_CHARS);
5250
+ }
5251
+ if (message) {
5252
+ const baseLen = JSON.stringify({ message: "" }).length;
5253
+ const budget = MAX_REMOTE_ERROR_DETAIL_CHARS - baseLen;
5254
+ return budget > 0 ? JSON.stringify({ message: clampSingleLine(message, budget) }) : "";
5255
+ }
5256
+ return clampSingleLine(serialized, MAX_REMOTE_ERROR_DETAIL_CHARS);
5257
+ }
5079
5258
  function prepareRemoteDialogEvidenceRecord(key, value, options) {
5080
5259
  const record = isRecord(value) ? { ...value } : {};
5081
- if (key.includes("-msg-") && typeof record.type !== "string") {
5260
+ if (key.includes("-msg-") && (typeof record.type !== "string" || !record.type.trim() || record.type === "message")) {
5082
5261
  record.type = "msg";
5083
5262
  }
5263
+ if (key.startsWith("token-") && !isTokenStatsKey(key)) {
5264
+ if (typeof record.type !== "string" || !record.type.trim()) {
5265
+ record.type = "token";
5266
+ }
5267
+ const hasAgentId = typeof record.agentId === "string" && record.agentId.trim().length > 0;
5268
+ const hasCybotId = typeof record.cybotId === "string" && record.cybotId.trim().length > 0;
5269
+ const fallbackAgent = asOptionalTrimmedString(options?.fallbackAgentKey);
5270
+ if (!hasAgentId && !hasCybotId && fallbackAgent) {
5271
+ record.agentId = fallbackAgent;
5272
+ record.cybotId = fallbackAgent;
5273
+ }
5274
+ }
5084
5275
  const metadata = record.metadata;
5085
5276
  if (key.includes("-msg-") && record.role === "user" && isRecord(metadata) && metadata.queueState === "accepted" && (metadata.cliBatchPhase === "requested" || metadata.cliBatchPhase === "completed" || typeof metadata.cliBatchId === "string" && metadata.cliBatchId.length > 0 || options?.isAcceptedBatchMember === true) && !hasReservedBatchAuthority(metadata)) {
5086
5277
  const { queueState: _localQueueState, ...evidenceMetadata } = metadata;
@@ -5191,7 +5382,7 @@ function buildLocalParentWakeMessage(args) {
5191
5382
  var EVIDENCE_WRITE_BATCH_SIZE = 4;
5192
5383
  var EVIDENCE_WRITE_BATCH_GAP_MS = 300;
5193
5384
  async function defaultEvidenceSleep(ms) {
5194
- await new Promise((resolve7) => setTimeout(resolve7, ms));
5385
+ await new Promise((resolve8) => setTimeout(resolve8, ms));
5195
5386
  }
5196
5387
  async function runThrottledBatches(items, run, options = {}) {
5197
5388
  const batchSize = options.batchSize ?? EVIDENCE_WRITE_BATCH_SIZE;
@@ -5219,6 +5410,7 @@ async function postRemoteRecord(args) {
5219
5410
  customKey: args.key,
5220
5411
  userId: args.userId,
5221
5412
  data: prepareRemoteDialogEvidenceRecord(args.key, args.data, {
5413
+ fallbackAgentKey: args.fallbackAgentKey,
5222
5414
  isAcceptedBatchMember: args.isAcceptedBatchMember
5223
5415
  })
5224
5416
  }),
@@ -5237,8 +5429,9 @@ async function postRemoteRecord(args) {
5237
5429
  );
5238
5430
  if (!response.ok) {
5239
5431
  const text = await response.text().catch(() => "");
5432
+ const detail = extractSafeRemoteErrorDetail(response.status, text);
5240
5433
  throw new Error(
5241
- `remote dialog evidence write failed: HTTP ${response.status} ${text.slice(0, 500)}`
5434
+ detail ? `remote dialog evidence write failed: HTTP ${response.status} ${detail}` : `remote dialog evidence write failed: HTTP ${response.status}`
5242
5435
  );
5243
5436
  }
5244
5437
  }
@@ -5313,8 +5506,9 @@ async function maybeWakeParentDialogAfterLocalSync(args) {
5313
5506
  });
5314
5507
  if (!wakeResponse.ok) {
5315
5508
  const text = await wakeResponse.text().catch(() => "");
5509
+ const detail = extractSafeRemoteErrorDetail(wakeResponse.status, text);
5316
5510
  throw new Error(
5317
- `parent dialog wake failed: HTTP ${wakeResponse.status} ${text.slice(0, 500)}`
5511
+ detail ? `parent dialog wake failed: HTTP ${wakeResponse.status} ${detail}` : `parent dialog wake failed: HTTP ${wakeResponse.status}`
5318
5512
  );
5319
5513
  }
5320
5514
  const notifiedAt = Date.now();
@@ -5339,13 +5533,14 @@ async function maybeWakeParentDialogAfterLocalSync(args) {
5339
5533
  async function syncLocalDialogEvidenceToRemote(args) {
5340
5534
  const serverUrl = resolveRuntimeServerUrl(args.env);
5341
5535
  const authToken = resolveRuntimeAuthToken(args.env);
5342
- if (!serverUrl || !authToken) {
5536
+ if (!serverUrl || !authToken || args.userId === "local") {
5343
5537
  return { attempted: false };
5344
5538
  }
5345
5539
  const orderedOps = [];
5346
5540
  const nonMsgOps = [];
5347
5541
  for (const op of args.ops) {
5348
5542
  if (op.type !== "put") continue;
5543
+ if (isRemoteDialogEvidenceExcludedKey(op.key)) continue;
5349
5544
  if (op.key.includes("-msg-")) {
5350
5545
  orderedOps.push(op);
5351
5546
  } else {
@@ -5354,11 +5549,13 @@ async function syncLocalDialogEvidenceToRemote(args) {
5354
5549
  }
5355
5550
  orderedOps.push(...nonMsgOps);
5356
5551
  const acceptedBatchKeys = await collectAcceptedUserBatchMessageKeys(orderedOps, args.localStore);
5552
+ const fallbackAgentKey = asOptionalTrimmedString(args.input?.agentKey);
5357
5553
  await runThrottledBatches(
5358
5554
  orderedOps.filter((op) => op.type === "put"),
5359
5555
  (op) => postRemoteRecord({
5360
5556
  authToken,
5361
5557
  data: op.value,
5558
+ fallbackAgentKey,
5362
5559
  fetchImpl: args.fetchImpl,
5363
5560
  isAcceptedBatchMember: acceptedBatchKeys.has(op.key),
5364
5561
  key: op.key,
@@ -5367,9 +5564,7 @@ async function syncLocalDialogEvidenceToRemote(args) {
5367
5564
  }),
5368
5565
  args.sleep ? { sleep: args.sleep } : {}
5369
5566
  );
5370
- const childDialogOp = args.ops.find(
5371
- (op) => op.type === "put" && !op.key.includes("-msg-")
5372
- );
5567
+ const childDialogOp = nonMsgOps.find((op) => op.key.startsWith("dialog-")) ?? nonMsgOps[0];
5373
5568
  const childDialogRecord = childDialogOp?.value && typeof childDialogOp.value === "object" ? childDialogOp.value : null;
5374
5569
  if (childDialogOp && childDialogRecord) {
5375
5570
  try {
@@ -5397,25 +5592,24 @@ async function syncLocalDialogEvidenceToRemote(args) {
5397
5592
  // packages/cli/client/childShellApprovalHostResolver.ts
5398
5593
  function createChildShellApprovalHostResolver(args) {
5399
5594
  return async (agentKey) => {
5400
- const config = await args.readAgentConfig(agentKey);
5401
- const record = config?.rawRecord;
5402
- const ownerUserId = asOptionalTrimmedString(record?.userId) ?? asOptionalTrimmedString(record?.ownerUserId);
5403
- if (!ownerUserId) return void 0;
5404
- const deviceId = asOptionalTrimmedString(await args.resolveDeviceId());
5405
- if (!deviceId) return void 0;
5595
+ const binding = await resolveChildApprovalBinding({ ...args, agentKey });
5596
+ if (!binding) return void 0;
5406
5597
  return {
5407
- binding: {
5408
- runId: "pending-spawn",
5409
- agentKey,
5410
- ownerUserId,
5411
- deviceId,
5412
- workspaceRoot: args.workspaceRoot
5413
- },
5598
+ binding,
5414
5599
  confirm: args.session.confirm,
5415
5600
  signal: args.session.signal
5416
5601
  };
5417
5602
  };
5418
5603
  }
5604
+ async function resolveChildApprovalBinding(args) {
5605
+ const config = await args.readAgentConfig(args.agentKey);
5606
+ const record = config?.rawRecord;
5607
+ const ownerUserId = asOptionalTrimmedString(record?.userId) ?? asOptionalTrimmedString(record?.ownerUserId);
5608
+ if (!ownerUserId) return void 0;
5609
+ const deviceId = asOptionalTrimmedString(await args.resolveDeviceId());
5610
+ if (!deviceId) return void 0;
5611
+ return { runId: "pending-spawn", agentKey: args.agentKey, ownerUserId, deviceId, workspaceRoot: args.workspaceRoot };
5612
+ }
5419
5613
 
5420
5614
  // packages/cli/client/cliDialogHistoryState.ts
5421
5615
  var STATE_KEY_PREFIX = "cli-dialog-history-state";
@@ -5839,253 +6033,27 @@ async function fetchRemoteDialogMessageRecordsViaBridge(args) {
5839
6033
  // packages/cli/client/browserShellApprovalBridge.ts
5840
6034
  import { createServer } from "node:http";
5841
6035
  import { randomBytes, timingSafeEqual } from "node:crypto";
5842
-
5843
- // packages/cli/client/hostApprovalFlow.ts
5844
- var HOST_APPROVAL_SUMMARY_LIMIT = 2500;
5845
- function clipApprovalSummary(text, limit = HOST_APPROVAL_SUMMARY_LIMIT) {
5846
- const value = String(text ?? "").replace(/\r\n?/g, "\n").trim();
5847
- if (value.length <= limit) return value;
5848
- const tailChars = Math.max(1, Math.round(limit * 0.3));
5849
- const headChars = Math.max(1, limit - tailChars);
5850
- const head = value.slice(0, headChars);
5851
- const tail = value.slice(value.length - tailChars);
5852
- const omitted = value.length - head.length - tail.length;
5853
- return `${head}
5854
- \u2026\uFF08\u4E2D\u95F4 ${omitted} \u5B57\u7B26\u672A\u663E\u793A\uFF0C\u4EE5\u4E0B\u662F\u7ED3\u5C3E\uFF1B\u5168\u6587 ${value.length} \u5B57\u7B26\uFF09\u2026
5855
- ${tail}`;
5856
- }
5857
- function toEpochMs(value) {
5858
- if (typeof value === "number" && Number.isFinite(value)) {
5859
- return value < 1e11 ? Math.round(value * 1e3) : Math.round(value);
5860
- }
5861
- if (typeof value === "string" && value.trim()) {
5862
- const asNumber = Number(value);
5863
- if (Number.isFinite(asNumber)) return toEpochMs(asNumber);
5864
- const parsed = Date.parse(value);
5865
- if (Number.isFinite(parsed)) return parsed;
5866
- }
5867
- return void 0;
5868
- }
5869
- function remainingApprovalMs(expiresAt, now) {
5870
- return Math.max(0, expiresAt - now);
5871
- }
5872
- function formatApprovalRemaining(expiresAt, now) {
5873
- const totalSeconds = Math.ceil(remainingApprovalMs(expiresAt, now) / 1e3);
5874
- if (totalSeconds <= 0) return "0s";
5875
- const minutes = Math.floor(totalSeconds / 60);
5876
- const seconds = totalSeconds % 60;
5877
- return minutes > 0 ? `${minutes}m${seconds}s` : `${seconds}s`;
5878
- }
5879
- function isRecordLike(value) {
5880
- return typeof value === "object" && value !== null;
5881
- }
5882
- function asTrimmedString2(value) {
5883
- return typeof value === "string" ? value.trim() : "";
5884
- }
5885
- function normalizePendingApproval(raw) {
5886
- if (!isRecordLike(raw)) return null;
5887
- const approvalId = asTrimmedString2(raw.approvalId);
5888
- const expiresAt = toEpochMs(raw.expiresAt ?? raw.expiresAtMs);
5889
- if (!approvalId || expiresAt === void 0) return null;
5890
- const tabId = asTrimmedString2(raw.tabId);
5891
- return {
5892
- approvalId,
5893
- actionLabel: asTrimmedString2(raw.action) || "unknown",
5894
- ...asTrimmedString2(raw.target) ? { target: asTrimmedString2(raw.target) } : {},
5895
- origin: asTrimmedString2(raw.origin),
5896
- // Passed through verbatim (the connector's preview already has the identity line, the head and
5897
- // the stated tail); only an upper-bound guard may touch it, see clipApprovalSummary.
5898
- summary: clipApprovalSummary(asTrimmedString2(raw.summary)),
5899
- expiresAt,
5900
- ...tabId ? { tabId } : {}
5901
- };
5902
- }
5903
- function parsePendingApprovalResult(result) {
5904
- let parsed;
5905
- try {
5906
- parsed = JSON.parse(result.content);
5907
- } catch {
5908
- return null;
5909
- }
5910
- if (!isRecordLike(parsed)) return null;
5911
- const errorBlock = isRecordLike(parsed.error) ? parsed.error : void 0;
5912
- const details = isRecordLike(errorBlock?.details) ? errorBlock.details : void 0;
5913
- const verdict = isRecordLike(parsed.result) ? parsed.result : void 0;
5914
- const candidates = [verdict, errorBlock, details].filter(isRecordLike);
5915
- const pending = candidates.find((entry) => entry.code === "USER_APPROVAL_PENDING");
5916
- if (!pending) return null;
5917
- const ordered = [pending, details, verdict].filter(isRecordLike);
5918
- const readField = (key) => {
5919
- for (const entry of ordered) {
5920
- const value = asTrimmedString2(entry[key]);
5921
- if (value) return value;
5922
- }
5923
- return "";
5924
- };
5925
- const approvalId = readField("approvalId");
5926
- if (!approvalId) return null;
5927
- let expiresAt;
5928
- for (const entry of ordered) {
5929
- const candidate = toEpochMs(entry.expiresAt ?? entry.expiresAtMs);
5930
- if (candidate !== void 0) {
5931
- expiresAt = candidate;
5932
- break;
5933
- }
5934
- }
5935
- const message = readField("message");
5936
- return {
5937
- approvalId,
5938
- action: readField("action"),
5939
- ...expiresAt !== void 0 ? { expiresAt } : {},
5940
- ...message ? { message } : {}
5941
- };
5942
- }
5943
- function withApprovalId(call, approvalId) {
5944
- let payload;
5945
- try {
5946
- const parsed = JSON.parse(call.arguments || "{}");
5947
- payload = isRecordLike(parsed) ? { ...parsed } : {};
5948
- } catch {
5949
- return call;
5950
- }
5951
- payload.approvalId = approvalId;
5952
- return { ...call, arguments: JSON.stringify(payload) };
5953
- }
5954
- function withHostApprovalRequest(call) {
5955
- let payload;
5956
- try {
5957
- const parsed = JSON.parse(call.arguments || "{}");
5958
- payload = isRecordLike(parsed) ? { ...parsed } : {};
5959
- } catch {
5960
- return call;
5961
- }
5962
- payload.hostApproval = true;
5963
- return { ...call, arguments: JSON.stringify(payload) };
5964
- }
5965
- function createConnectorApprovalPort(getClient) {
5966
- return {
5967
- async listPendingApprovals() {
5968
- const raw = await getClient().request("list_pending_approvals", {});
5969
- const list = isRecordLike(raw) && Array.isArray(raw.approvals) ? raw.approvals : [];
5970
- return list.map(normalizePendingApproval).filter((entry) => entry !== null);
5971
- },
5972
- async submitApprovalDecision(approvalId, decision) {
5973
- try {
5974
- const raw = await getClient().request("submit_approval_decision", {
5975
- approvalId,
5976
- decision
5977
- });
5978
- if (isRecordLike(raw) && raw.ok === false) {
5979
- return { failed: asTrimmedString2(raw.code) || "USER_APPROVAL_REJECTED" };
5980
- }
5981
- const status = isRecordLike(raw) && raw.status === "denied" ? "denied" : "allowed";
5982
- return { status };
5983
- } catch (error) {
5984
- const code = asTrimmedString2(error?.code);
5985
- return { failed: code || "CHROME_CONNECTOR_ERROR" };
5986
- }
5987
- }
5988
- };
5989
- }
5990
- function approvalFailure(code, message, action, extra) {
5991
- return {
5992
- content: JSON.stringify({ ok: false, error: { code, message } }),
5993
- metadata: { chromeConnector: true, error: true, code, action, ...extra ?? {} }
5994
- };
5995
- }
5996
- async function runConnectorToolWithHostApproval(args) {
5997
- const first = await args.execute(
5998
- withHostApprovalRequest(args.call)
5999
- );
6000
- const pending = parsePendingApprovalResult(first);
6001
- if (!pending || !args.awaitHostApproval) return first;
6002
- const now = args.now ?? Date.now;
6003
- let listed;
6004
- try {
6005
- listed = await args.connector.listPendingApprovals();
6006
- } catch {
6007
- return first;
6008
- }
6009
- const card = listed.find((entry) => entry.approvalId === pending.approvalId);
6010
- if (!card) {
6011
- return approvalFailure(
6012
- "USER_APPROVAL_EXPIRED",
6013
- "\u5BA1\u6279\u5DF2\u8FC7\u671F\u6216\u4E0D\u518D\u5F85\u6279\uFF0C\u52A8\u4F5C\u672A\u6267\u884C\u3002",
6014
- args.call.name
6015
- );
6016
- }
6017
- if (card.expiresAt <= now()) {
6018
- return approvalFailure("USER_APPROVAL_EXPIRED", "\u5BA1\u6279\u5DF2\u8FC7\u671F\uFF0C\u52A8\u4F5C\u672A\u6267\u884C\u3002", args.call.name);
6019
- }
6020
- const decision = await args.awaitHostApproval(card);
6021
- if (decision === "deny") {
6022
- await args.connector.submitApprovalDecision(card.approvalId, "deny");
6023
- return approvalFailure("USER_APPROVAL_DENIED", "\u7528\u6237\u5DF2\u62D2\u7EDD", args.call.name, {
6024
- approvalId: card.approvalId
6025
- });
6026
- }
6027
- const submitted = await args.connector.submitApprovalDecision(card.approvalId, "allow_once");
6028
- if ("failed" in submitted) {
6029
- return approvalFailure(
6030
- submitted.failed,
6031
- submitted.failed === "USER_APPROVAL_EXPIRED" ? "\u5BA1\u6279\u5DF2\u8FC7\u671F\uFF0C\u52A8\u4F5C\u672A\u6267\u884C\u3002" : "\u5BA1\u6279\u51B3\u5B9A\u672A\u88AB\u8FDE\u63A5\u5668\u63A5\u53D7\uFF0C\u52A8\u4F5C\u672A\u6267\u884C\u3002",
6032
- args.call.name,
6033
- { approvalId: card.approvalId }
6034
- );
6035
- }
6036
- if (submitted.status === "denied") {
6037
- return approvalFailure("USER_APPROVAL_DENIED", "\u7528\u6237\u5DF2\u62D2\u7EDD", args.call.name, {
6038
- approvalId: card.approvalId
6039
- });
6036
+ var VALID_HOST_APPROVAL_RESULTS = /* @__PURE__ */ new Set([
6037
+ "allow_once",
6038
+ "deny",
6039
+ "cancelled",
6040
+ "expired",
6041
+ "unavailable"
6042
+ ]);
6043
+ function mapBlockedOutcome(code, hasRenderer) {
6044
+ switch (code) {
6045
+ case "USER_APPROVAL_CANCELLED":
6046
+ return { outcome: "cancelled", code: "USER_APPROVAL_CANCELLED" };
6047
+ case "USER_APPROVAL_EXPIRED":
6048
+ return { outcome: "expired", code: "USER_APPROVAL_EXPIRED" };
6049
+ case "USER_APPROVAL_UNAVAILABLE":
6050
+ return { outcome: "unavailable", code: "USER_APPROVAL_UNAVAILABLE" };
6051
+ case "USER_APPROVAL_DENIED":
6052
+ return { outcome: "denied", code: "USER_APPROVAL_DENIED" };
6053
+ default:
6054
+ return hasRenderer ? { outcome: "denied", code: typeof code === "string" && code ? code : "USER_APPROVAL_DENIED" } : { outcome: "unavailable", code: "USER_APPROVAL_UNAVAILABLE" };
6040
6055
  }
6041
- return args.execute(withApprovalId(args.call, card.approvalId));
6042
6056
  }
6043
- function createHostApprovalCardQueue() {
6044
- const waiting = [];
6045
- let active = false;
6046
- const drain = async () => {
6047
- if (active) return;
6048
- active = true;
6049
- try {
6050
- while (waiting.length > 0) {
6051
- waiting.sort((a, b) => a.card.expiresAt - b.card.expiresAt);
6052
- const entry = waiting.shift();
6053
- let decision = "deny";
6054
- try {
6055
- decision = await entry.present(entry.card);
6056
- } catch {
6057
- decision = "deny";
6058
- }
6059
- entry.resolve(decision);
6060
- }
6061
- } finally {
6062
- active = false;
6063
- }
6064
- };
6065
- return {
6066
- /** Resolves with the user's answer once this card reaches the head of the queue. */
6067
- present(card, present) {
6068
- return new Promise((resolve7) => {
6069
- waiting.push({ card, present, resolve: resolve7 });
6070
- void Promise.resolve().then(drain);
6071
- });
6072
- },
6073
- /** Cards currently queued or being shown (tests/telemetry). */
6074
- size: () => waiting.length + (active ? 1 : 0)
6075
- };
6076
- }
6077
- var registeredRenderer = null;
6078
- function registerHostApprovalRenderer(renderer) {
6079
- registeredRenderer = renderer;
6080
- return () => {
6081
- if (registeredRenderer === renderer) registeredRenderer = null;
6082
- };
6083
- }
6084
- function getHostApprovalRenderer() {
6085
- return registeredRenderer ?? void 0;
6086
- }
6087
-
6088
- // packages/cli/client/browserShellApprovalBridge.ts
6089
6057
  async function createBrowserShellApprovalBridge(args) {
6090
6058
  const timeoutMs = args.timeoutMs ?? 6e4;
6091
6059
  if (!Number.isFinite(timeoutMs) || timeoutMs <= 0 || timeoutMs > 6e4) throw new Error("Invalid bridge timeout");
@@ -6097,25 +6065,34 @@ async function createBrowserShellApprovalBridge(args) {
6097
6065
  const bindings = /* @__PURE__ */ new Map();
6098
6066
  let closing;
6099
6067
  let timer;
6068
+ const terminalOutcome = () => Date.now() >= deadline ? { outcome: "expired", code: "USER_APPROVAL_EXPIRED" } : { outcome: "cancelled", code: "USER_APPROVAL_CANCELLED" };
6100
6069
  const active = () => !lifetime.signal.aborted && Date.now() < deadline;
6101
6070
  const requireActive = () => {
6102
6071
  if (!active()) throw new Error("Browser approval bridge revoked");
6103
6072
  };
6104
6073
  const server = createServer(async (request, response) => {
6105
- const reply = (status, result) => {
6106
- if (!response.destroyed) {
6074
+ const reply = (status, result, extra) => {
6075
+ if (!response.destroyed && !response.writableEnded) {
6107
6076
  response.writeHead(200, { "content-type": "application/json", "cache-control": "no-store" });
6108
- response.end(JSON.stringify({ status, ...result === void 0 ? {} : { result } }));
6077
+ response.end(JSON.stringify({
6078
+ status,
6079
+ ...extra?.outcome ? { outcome: extra.outcome } : {},
6080
+ ...extra?.code ? { code: extra.code } : {},
6081
+ ...result === void 0 ? {} : { result }
6082
+ }));
6109
6083
  }
6110
6084
  };
6111
- const disconnect = () => {
6112
- if (!response.writableEnded) void close();
6113
- };
6114
- response.on("close", disconnect);
6085
+ const revoke = () => reply("blocked", void 0, terminalOutcome());
6115
6086
  try {
6116
6087
  const authorization = request.headers.authorization ?? "";
6117
6088
  const expected = `Bearer ${capability}`;
6118
6089
  if (!active() || request.method !== "POST" || request.url !== "/approval" || authorization.length !== expected.length || !timingSafeEqual(Buffer.from(authorization), Buffer.from(expected))) return reply("rejected");
6090
+ response.on("close", () => {
6091
+ lifetime.signal.removeEventListener("abort", revoke);
6092
+ if (!response.writableEnded) void close();
6093
+ });
6094
+ lifetime.signal.addEventListener("abort", revoke, { once: true });
6095
+ response.setTimeout(timeoutMs + 5e3);
6119
6096
  let body = "";
6120
6097
  for await (const chunk of request) {
6121
6098
  body += chunk.toString();
@@ -6134,8 +6111,9 @@ async function createBrowserShellApprovalBridge(args) {
6134
6111
  const current = binding;
6135
6112
  let calls = 0;
6136
6113
  let retry = false;
6137
- await runConnectorToolWithHostApproval({
6114
+ const flowResult = await runConnectorToolWithHostApproval({
6138
6115
  call: current.call,
6116
+ signal: lifetime.signal,
6139
6117
  execute: async () => {
6140
6118
  requireActive();
6141
6119
  if (calls++ === 0) return current.pending;
@@ -6160,22 +6138,27 @@ async function createBrowserShellApprovalBridge(args) {
6160
6138
  },
6161
6139
  ...args.awaitHostApproval ? { awaitHostApproval: async (card) => {
6162
6140
  requireActive();
6163
- const decision = await new Promise((resolve7, reject) => {
6141
+ const decision = await new Promise((resolve8, reject) => {
6164
6142
  const abort = () => reject(new Error("Browser approval bridge revoked"));
6165
6143
  lifetime.signal.addEventListener("abort", abort, { once: true });
6166
6144
  Promise.resolve().then(() => {
6167
6145
  requireActive();
6168
6146
  return args.awaitHostApproval(card, lifetime.signal);
6169
- }).then(resolve7, reject).finally(() => lifetime.signal.removeEventListener("abort", abort));
6147
+ }).then(resolve8, reject).finally(() => lifetime.signal.removeEventListener("abort", abort));
6170
6148
  });
6171
6149
  requireActive();
6172
- if (decision !== "allow_once" && decision !== "deny") throw new Error("Invalid host decision");
6150
+ if (!VALID_HOST_APPROVAL_RESULTS.has(decision)) throw new Error("Invalid host decision");
6173
6151
  return decision;
6174
6152
  } } : {}
6175
6153
  });
6176
- reply(active() && retry ? "retry_once" : "blocked");
6154
+ if (active() && retry) {
6155
+ reply("retry_once", void 0, { outcome: "allowed" });
6156
+ } else {
6157
+ const metaCode = flowResult.metadata?.code;
6158
+ reply("blocked", void 0, mapBlockedOutcome(Date.now() >= deadline ? "USER_APPROVAL_EXPIRED" : metaCode, Boolean(args.awaitHostApproval)));
6159
+ }
6177
6160
  } catch {
6178
- reply("blocked");
6161
+ reply("blocked", void 0, lifetime.signal.aborted || Date.now() >= deadline ? terminalOutcome() : { outcome: "unavailable", code: "USER_APPROVAL_UNAVAILABLE" });
6179
6162
  }
6180
6163
  });
6181
6164
  server.requestTimeout = timeoutMs;
@@ -6185,21 +6168,25 @@ async function createBrowserShellApprovalBridge(args) {
6185
6168
  };
6186
6169
  function close() {
6187
6170
  if (closing) return closing;
6188
- lifetime.abort();
6189
- clearTimeout(timer);
6190
- args.signal?.removeEventListener("abort", onAbort);
6191
- bindings.clear();
6192
- closing = new Promise((resolve7) => {
6193
- server.close(() => resolve7());
6194
- server.closeAllConnections();
6171
+ closing = new Promise((resolve8) => {
6172
+ lifetime.abort();
6173
+ clearTimeout(timer);
6174
+ args.signal?.removeEventListener("abort", onAbort);
6175
+ bindings.clear();
6176
+ const forceClose = setTimeout(() => server.closeAllConnections(), 1e3);
6177
+ server.close(() => {
6178
+ clearTimeout(forceClose);
6179
+ resolve8();
6180
+ });
6181
+ server.closeIdleConnections();
6195
6182
  });
6196
6183
  return closing;
6197
6184
  }
6198
- await new Promise((resolve7, reject) => {
6185
+ await new Promise((resolve8, reject) => {
6199
6186
  server.once("error", reject);
6200
6187
  server.listen(0, "127.0.0.1", () => {
6201
6188
  server.removeListener("error", reject);
6202
- resolve7();
6189
+ resolve8();
6203
6190
  });
6204
6191
  });
6205
6192
  const address = server.address();
@@ -6246,7 +6233,10 @@ async function createBrowserShellApprovalBridge(args) {
6246
6233
 
6247
6234
  // packages/cli/client/browserShellApprovalHost.ts
6248
6235
  async function withBrowserShellApproval(args, run) {
6249
- if (!args.requestUserChoice) return run();
6236
+ const resolveRenderer = () => args.awaitHostApproval ?? getHostApprovalRenderer();
6237
+ if (!resolveRenderer()) {
6238
+ return withShellChildEnvironment({ [BROWSER_SHELL_BRIDGE_ENV]: "" }, run);
6239
+ }
6250
6240
  const resolveClient = createChromeConnectorClientResolver();
6251
6241
  const bridges = [];
6252
6242
  try {
@@ -6257,28 +6247,30 @@ async function withBrowserShellApproval(args, run) {
6257
6247
  browser,
6258
6248
  signal: args.signal,
6259
6249
  connector: createConnectorApprovalPort(client),
6260
- executeInitial: async (call) => ({ content: JSON.stringify({ ok: true, result: await client().request(call.name, JSON.parse(call.arguments)) }) }),
6250
+ executeInitial: async (call) => ({
6251
+ content: JSON.stringify({
6252
+ ok: true,
6253
+ result: await client().request(call.name, JSON.parse(call.arguments))
6254
+ })
6255
+ }),
6261
6256
  awaitHostApproval: async (card, signal) => {
6262
- if (card.actionLabel !== "eval_script" && (!card.target?.trim() || card.target.trim() === "\u672A\u547D\u540D\u63A7\u4EF6")) return "deny";
6263
- if (card.actionLabel === "eval_script" && !card.summary.trim()) return "deny";
6264
- const tab = card.tabId;
6265
- const approvalText = `Browser action requires one-time approval
6266
- Action/risk: ${card.actionLabel} (may change page or external state)
6267
- Browser: ${browser}
6268
- Tab: ${tab ?? "unknown"}
6269
- Origin: ${card.origin}
6270
- Target: ${card.target ?? "script in the bound tab"}
6271
- Script/option summary:
6272
- ${card.summary}
6273
- Expires: ${new Date(card.expiresAt).toISOString()}`;
6274
- const result = await args.requestUserChoice({
6275
- question: "Approve this browser action once?",
6276
- approvalDisplay: { kind: "browser-approval", text: approvalText },
6277
- choices: [{ label: "Allow once", userMessage: "browser-allow-once" }, { label: "Deny", userMessage: "browser-deny" }],
6278
- blocking: true,
6279
- signal
6280
- });
6281
- return !signal.aborted && result.kind === "selected" && result.userMessage === "browser-allow-once" ? "allow_once" : "deny";
6257
+ if (card.actionLabel !== "eval_script" && (!card.target?.trim() || card.target.trim() === "\u672A\u547D\u540D\u63A7\u4EF6")) {
6258
+ return "deny";
6259
+ }
6260
+ if (card.actionLabel === "eval_script" && !card.summary.trim()) {
6261
+ return "deny";
6262
+ }
6263
+ const renderer = resolveRenderer();
6264
+ if (!renderer || signal.aborted) return "unavailable";
6265
+ if (card.expiresAt <= Date.now()) return "expired";
6266
+ const result = await renderer(
6267
+ { ...card, browser },
6268
+ { requestId: card.approvalId, signal, expiresAt: card.expiresAt }
6269
+ );
6270
+ if (signal.aborted) return "cancelled";
6271
+ if (card.expiresAt <= Date.now()) return "expired";
6272
+ if (result === "allow_once" || result === "deny") return result;
6273
+ return result === "cancelled" || result === "expired" || result === "unavailable" ? result : "unavailable";
6282
6274
  }
6283
6275
  });
6284
6276
  bridges.push(bridge);
@@ -6427,11 +6419,9 @@ function buildServerPlatformToolExecutors(args) {
6427
6419
  return text;
6428
6420
  };
6429
6421
  const guardExplicitTableCapture = (call) => {
6430
- if (inferCaptureIntent(String(call.userInput ?? "")) === "strong")
6431
- return null;
6432
6422
  return JSON.stringify({
6433
6423
  error: "knowledge_capture_requires_confirmation",
6434
- message: "\u5F53\u524D\u672C\u5730\u8FD0\u884C\u4E0D\u5141\u8BB8\u81EA\u52A8\u5199\u5165\u8868\u683C\u3002\u53EA\u6709\u5F53\u7528\u6237\u5728\u5F53\u524D\u8BF7\u6C42\u91CC\u660E\u786E\u8981\u6C42\u4FDD\u5B58\u3001\u5EFA\u8868\u3001\u5199\u5165 table \u6216\u505A\u6210\u6570\u636E\u96C6\u65F6\uFF0C\u624D\u80FD\u7EE7\u7EED\uFF1B\u5426\u5219\u8BF7\u5148\u8BE2\u95EE\u7528\u6237\u3002",
6424
+ message: "\u5F53\u524D\u6267\u884C\u9762\u6CA1\u6709\u53EF\u4FE1\u786E\u8BA4\u91CD\u653E\u80FD\u529B\uFF1B\u8BF7\u5728\u652F\u6301\u786E\u8BA4\u7684\u754C\u9762\u6838\u5BF9\u5177\u4F53\u5185\u5BB9\u548C\u76EE\u6807\u540E\u4FDD\u5B58\u3002",
6435
6425
  policy: {
6436
6426
  capability: "knowledge_capture",
6437
6427
  target: "table",
@@ -6535,7 +6525,7 @@ function buildServerPlatformToolExecutors(args) {
6535
6525
  const shortHash = (value, len) => createHash2("sha256").update(value).digest("hex").slice(0, len);
6536
6526
  const localMemoryContext = async () => {
6537
6527
  const openCliLocalRuntimeDb = async () => {
6538
- const { getDefaultCliLocalRuntimeDb: getDefaultCliLocalRuntimeDb2 } = await import("./localRuntimeDb-N7KHDXS2.js");
6528
+ const { getDefaultCliLocalRuntimeDb: getDefaultCliLocalRuntimeDb2 } = await import("./localRuntimeDb-ZJFGNHML.js");
6539
6529
  return getDefaultCliLocalRuntimeDb2({ env: args.env });
6540
6530
  };
6541
6531
  try {
@@ -6566,7 +6556,7 @@ function buildServerPlatformToolExecutors(args) {
6566
6556
  const hits = recallMemoryVNextLocal({
6567
6557
  query,
6568
6558
  entities: catalog.entities,
6569
- states: catalog.states.filter((s) => !s.retiredAt && s.text.trim())
6559
+ states: catalog.states.filter((s) => !s.retiredAt && s.facet !== "work-context" && s.text.trim())
6570
6560
  });
6571
6561
  if (hits.length === 0) return null;
6572
6562
  const { mergeAndDedupUserData } = await import("./userDataMerge-HT2ZVHBJ.js");
@@ -6589,6 +6579,7 @@ function buildServerPlatformToolExecutors(args) {
6589
6579
  activationCount: 1,
6590
6580
  importance: typeof value.importance === "number" ? value.importance : 0.9,
6591
6581
  ...typeof value.confidence === "number" && Number.isFinite(value.confidence) ? { confidence: value.confidence } : {},
6582
+ ...["verified", "stated", "inferred"].includes(value.provenance) ? { provenance: value.provenance } : {},
6592
6583
  ...typeof value.sourceKind === "string" ? { sourceKind: value.sourceKind } : {},
6593
6584
  ...typeof value.sourceDialogId === "string" ? { sourceDialogId: value.sourceDialogId } : {},
6594
6585
  evidence,
@@ -6616,7 +6607,7 @@ function buildServerPlatformToolExecutors(args) {
6616
6607
  for (let i = ordered.length - 1; i >= 0; i -= 1) {
6617
6608
  if (isTombstoneRecord2(ordered[i])) ordered.splice(i, 1);
6618
6609
  }
6619
- const { buildMemoryOverlay, DEFAULT_MEMORY_OVERLAY_TOKEN_BUDGET } = await import("./overlay-BBQZXGYI.js");
6610
+ const { buildMemoryOverlay, DEFAULT_MEMORY_OVERLAY_TOKEN_BUDGET } = await import("./overlay-JA3SPVUS.js");
6620
6611
  const promptBlock = buildMemoryOverlay(ordered, {
6621
6612
  maxTokens: DEFAULT_MEMORY_OVERLAY_TOKEN_BUDGET
6622
6613
  });
@@ -6625,6 +6616,40 @@ function buildServerPlatformToolExecutors(args) {
6625
6616
  const writeLocalMemory = async (input) => {
6626
6617
  const ctx = await localMemoryContext();
6627
6618
  if (!ctx) return false;
6619
+ if (input.topicKey) {
6620
+ const { normalizeTopicKey, rememberExplicitVNext } = await import("./rememberExplicit-CPAPONSI.js");
6621
+ const topicKey = normalizeTopicKey(input.topicKey);
6622
+ if (topicKey) {
6623
+ const now = input.createdAt || (/* @__PURE__ */ new Date()).toISOString();
6624
+ const kind = ["episodic", "semantic", "procedural"].includes(input.kind) ? input.kind : "episodic";
6625
+ const validSubjectTypes = ["user", "agent", "space", "project", "system"];
6626
+ const hasValidSubject = typeof input.subjectType === "string" && validSubjectTypes.includes(input.subjectType) && typeof input.subjectId === "string" && input.subjectId.trim().length > 0;
6627
+ const trimmedAgentKey = args.agentKey?.trim() || "";
6628
+ const useAgentSubject = (input.scope ?? "auto") === "auto" && Boolean(trimmedAgentKey);
6629
+ const subjectType = hasValidSubject ? input.subjectType : useAgentSubject ? "agent" : "user";
6630
+ const subjectId = hasValidSubject ? input.subjectId.trim() : useAgentSubject ? trimmedAgentKey : ctx.userId;
6631
+ await rememberExplicitVNext(ctx.db, {
6632
+ id: "",
6633
+ ownerType: "user",
6634
+ ownerId: ctx.userId,
6635
+ visibility: "private",
6636
+ subjectType,
6637
+ subjectId,
6638
+ kind,
6639
+ content: input.content,
6640
+ createdAt: now,
6641
+ lastActivatedAt: now,
6642
+ activationCount: 0,
6643
+ importance: kind === "procedural" ? 0.88 : 0.82,
6644
+ confidence: input.confidence,
6645
+ ...input.tags?.length ? { tags: input.tags } : {},
6646
+ ...input.provenance === "verified" || input.provenance === "stated" || input.provenance === "inferred" ? { provenance: input.provenance } : {},
6647
+ ...input.sourceKind === "explicit-user-directive" || input.sourceKind === "agent-tool" || input.sourceKind === "inferred-understanding" || input.sourceKind === "dialog-learning" ? { sourceKind: input.sourceKind } : {},
6648
+ topicKey
6649
+ });
6650
+ return true;
6651
+ }
6652
+ }
6628
6653
  const [{ putMemoryEntityVNext, putMemoryStateVNext, putMemoryEvidenceVNext }, { buildLegacyMemoryEvidence }] = await Promise.all([
6629
6654
  import("./store-Z53ICFL3.js"),
6630
6655
  import("./legacyMigration-TF4SYJCZ.js")
@@ -6667,6 +6692,8 @@ function buildServerPlatformToolExecutors(args) {
6667
6692
  kind: input.kind,
6668
6693
  contentKey,
6669
6694
  origin: "cli-local",
6695
+ ...input.provenance ? { provenance: input.provenance } : {},
6696
+ ...input.sourceKind ? { sourceKind: input.sourceKind } : {},
6670
6697
  ...input.tags?.length ? { tags: input.tags } : {}
6671
6698
  },
6672
6699
  text: input.content,
@@ -6722,8 +6749,47 @@ function buildServerPlatformToolExecutors(args) {
6722
6749
  }
6723
6750
  return { retired, localOnlyRetired, skippedRemoteMiss };
6724
6751
  };
6752
+ const workMemory = async (call, parsed, write) => {
6753
+ const context = call.runtimeContext;
6754
+ const dialogId = context?.dialogId;
6755
+ const userMessageId = context?.userMessageId;
6756
+ if (typeof dialogId !== "string" || write && typeof userMessageId !== "string") throw new Error("work memory requires host dialogId and persisted userMessageId");
6757
+ const fields = write ? ["itemKey", "activityId", "expectedRevision", "changeId", "patch"] : ["activityId", "status", "query", "limit", "discovery"];
6758
+ const payload = Object.fromEntries(fields.filter((k) => parsed[k] !== void 0 && parsed[k] !== "").map((k) => [k, parsed[k]]));
6759
+ if (parsed.storage !== void 0 && parsed.storage !== "server" && parsed.storage !== "local") throw new Error("invalid work storage");
6760
+ const { formatWorkContextWriteNotice } = await import("./workContextWriteNotice-YCSSMHN4.js");
6761
+ const writeResult = (result2, priorNotice, storage) => ({
6762
+ ...result2,
6763
+ notice: [formatWorkContextWriteNotice(result2, storage ? { storage } : void 0), priorNotice].filter((v) => typeof v === "string" && v !== "").join("\n")
6764
+ });
6765
+ const workMetadata = { serverPlatformTool: true, memoryWrite: write, memoryRead: !write };
6766
+ if (parsed.storage === "server") {
6767
+ const content2 = await postServer(write ? "/api/memory/remember" : "/api/memory/query", { mode: "work", ...payload, dialogId, ...write ? { userMessageId } : {} });
6768
+ if (!write) return { content: content2, metadata: workMetadata };
6769
+ let served;
6770
+ try {
6771
+ served = JSON.parse(content2);
6772
+ } catch {
6773
+ return { content: content2, metadata: workMetadata };
6774
+ }
6775
+ return { content: JSON.stringify(writeResult(served, typeof served?.notice === "string" ? served.notice : void 0, "server")), metadata: workMetadata };
6776
+ }
6777
+ const ctx = await localMemoryContext();
6778
+ if (!ctx) throw new Error("local work memory unavailable");
6779
+ const { resolveLocalUserId: resolveLocalUserId2 } = await import("./cliAgentConfigHelpers-BXHQ3PXP.js");
6780
+ const localUserId = resolveLocalUserId2(args.env);
6781
+ const { resolveWorkContextAccess } = await import("./workContextAccess-VU5I4LKZ.js");
6782
+ const { updateWorkContext, readWorkContexts } = await import("./workContext-Y3ADAPZU.js");
6783
+ const { scope, sourceRef } = await resolveWorkContextAccess(ctx.db, localUserId, dialogId, write ? userMessageId : void 0);
6784
+ if (scope.spaceId) throw new Error("local work memory cannot verify space membership");
6785
+ const result = write ? await updateWorkContext(ctx.db, scope, { ...payload.activityId !== void 0 ? { activityId: payload.activityId, expectedRevision: payload.expectedRevision } : { itemKey: payload.itemKey, originRef: sourceRef }, changeId: payload.changeId, sourceRefs: [sourceRef], patch: payload.patch }) : await readWorkContexts(ctx.db, scope, payload);
6786
+ const storageNotice = "Local and server stores are independent; changeId deduplication covers actual changes only.";
6787
+ const content = write ? { ...writeResult(result, storageNotice, "local"), storage: "local" } : { ...result, storage: "local", notice: storageNotice };
6788
+ return { content: JSON.stringify(content), metadata: workMetadata };
6789
+ };
6725
6790
  const queryMemory = async (call) => {
6726
6791
  const parsed = parseNoloWorkspaceToolArguments(call.arguments);
6792
+ if (parsed.mode === "work") return workMemory(call, parsed, false);
6727
6793
  const query = typeof parsed.query === "string" ? parsed.query.trim() : "";
6728
6794
  if (!query) {
6729
6795
  return {
@@ -6760,6 +6826,7 @@ function buildServerPlatformToolExecutors(args) {
6760
6826
  };
6761
6827
  const rememberMemory = async (call) => {
6762
6828
  const parsed = parseNoloWorkspaceToolArguments(call.arguments);
6829
+ if (parsed.mode === "work") return workMemory(call, parsed, true);
6763
6830
  const content = typeof parsed.content === "string" ? parsed.content.trim() : "";
6764
6831
  if (!content) {
6765
6832
  return {
@@ -6775,9 +6842,28 @@ function buildServerPlatformToolExecutors(args) {
6775
6842
  kind: parsed.kind ?? "episodic",
6776
6843
  source: "agent-inferred"
6777
6844
  };
6845
+ if (["verified", "stated", "inferred"].includes(parsed.provenance)) body.provenance = parsed.provenance;
6778
6846
  if (typeof parsed.recurrenceEvidence === "string" && parsed.recurrenceEvidence.trim()) {
6779
6847
  body.recurrenceEvidence = parsed.recurrenceEvidence.trim();
6780
6848
  }
6849
+ if (parsed.topicKey !== void 0 && parsed.topicKey !== null) {
6850
+ if (typeof parsed.topicKey !== "string") {
6851
+ return {
6852
+ content: JSON.stringify({ error: "rememberMemory: topicKey must be a string" }),
6853
+ metadata: { serverPlatformTool: true, memoryWrite: false }
6854
+ };
6855
+ }
6856
+ const { normalizeTopicKey } = await import("./rememberExplicit-CPAPONSI.js");
6857
+ try {
6858
+ const normalizedTopicKey = normalizeTopicKey(parsed.topicKey);
6859
+ if (normalizedTopicKey) body.topicKey = normalizedTopicKey;
6860
+ } catch (err) {
6861
+ return {
6862
+ content: JSON.stringify({ error: err?.message ?? "invalid topicKey" }),
6863
+ metadata: { serverPlatformTool: true, memoryWrite: false }
6864
+ };
6865
+ }
6866
+ }
6781
6867
  if (args.agentKey) body.agentKey = args.agentKey;
6782
6868
  const raw = await postServer("/api/memory/remember", body, {
6783
6869
  retryTransient: true
@@ -6790,12 +6876,21 @@ function buildServerPlatformToolExecutors(args) {
6790
6876
  } catch {
6791
6877
  }
6792
6878
  const saved = Array.isArray(serverResult?.savedItems) ? serverResult.savedItems[0] : null;
6879
+ const resolvedTopicKey = typeof saved?.topicKey === "string" ? saved.topicKey : typeof body.topicKey === "string" ? body.topicKey : void 0;
6880
+ const validSubjectTypes = ["user", "agent", "space", "project", "system"];
6881
+ const savedSubjectType = typeof saved?.subjectType === "string" && validSubjectTypes.includes(saved.subjectType) ? saved.subjectType : void 0;
6882
+ const savedSubjectId = typeof saved?.subjectId === "string" && saved.subjectId.trim() ? saved.subjectId.trim() : void 0;
6793
6883
  localSaved = await writeLocalMemory({
6794
6884
  content: typeof saved?.content === "string" && saved.content.trim() ? saved.content : content,
6795
6885
  kind: String(saved?.kind ?? serverResult?.savedKind ?? body.kind ?? "episodic"),
6796
6886
  createdAt: typeof saved?.createdAt === "string" && saved.createdAt ? saved.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
6797
6887
  confidence: typeof saved?.confidence === "number" ? saved.confidence : 0.8,
6798
- tags: Array.isArray(saved?.tags) ? saved.tags.map(String) : void 0
6888
+ provenance: typeof saved?.provenance === "string" ? saved.provenance : void 0,
6889
+ sourceKind: typeof saved?.sourceKind === "string" ? saved.sourceKind : void 0,
6890
+ tags: Array.isArray(saved?.tags) ? saved.tags.map(String) : void 0,
6891
+ scope: typeof body.scope === "string" ? body.scope : "auto",
6892
+ ...savedSubjectType && savedSubjectId ? { subjectType: savedSubjectType, subjectId: savedSubjectId } : {},
6893
+ ...resolvedTopicKey ? { topicKey: resolvedTopicKey } : {}
6799
6894
  });
6800
6895
  } catch {
6801
6896
  }
@@ -6929,11 +7024,160 @@ function buildServerPlatformToolExecutors(args) {
6929
7024
  };
6930
7025
  }
6931
7026
 
7027
+ // packages/cli/client/workspaceIsolation.ts
7028
+ import * as fs from "node:fs";
7029
+ import { execFileSync } from "node:child_process";
7030
+ import { createHash as createHash3 } from "node:crypto";
7031
+ import { homedir } from "node:os";
7032
+ import { basename, dirname as dirname2, isAbsolute, join as join2, relative, resolve, sep } from "node:path";
7033
+ var WorkspaceIsolationError = class extends Error {
7034
+ code = "workspace_isolation_refused";
7035
+ };
7036
+ var dependencies = /* @__PURE__ */ new Set(["node_modules", ".venv"]);
7037
+ var refuse = (reason) => {
7038
+ throw new WorkspaceIsolationError(`${reason}\uFF1B\u8BF7\u7F29\u5C0F\u5230\u5177\u4F53\u5B50\u6587\u4EF6\u5939\u540E\u91CD\u8BD5 workspaceIsolation:auto`);
7039
+ };
7040
+ function prepareWorkspaceIsolation(options) {
7041
+ const { baseCwd, runId, mode = "none", readOnly, platform = process.platform } = options;
7042
+ if (mode !== "auto" || readOnly === true) return { mode, kind: "none", effectiveCwd: baseCwd };
7043
+ if (!/^[a-zA-Z0-9_-]{1,128}$/.test(runId)) refuse("\u4E0D\u5B89\u5168\u7684 runId");
7044
+ const exec = options.execFile ?? execFileSync;
7045
+ const command = (file, args) => String(exec(file, args, { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"], timeout: 3e4, env: { ...process.env, LC_ALL: "C", LANG: "C" } }));
7046
+ const source = fs.realpathSync(baseCwd);
7047
+ let repoRoot;
7048
+ try {
7049
+ repoRoot = command("git", ["-C", source, "rev-parse", "--show-toplevel"]).trim();
7050
+ } catch (error) {
7051
+ if (error.code === "ENOENT") {
7052
+ for (let ancestor = source; ; ancestor = dirname2(ancestor)) {
7053
+ try {
7054
+ fs.lstatSync(join2(ancestor, ".git"));
7055
+ throw new WorkspaceIsolationError("\u68C0\u6D4B\u5230 Git \u4ED3\u5E93\uFF0C\u4F46 Git \u547D\u4EE4\u672A\u5B89\u88C5\uFF1B\u8BF7\u5B89\u88C5 Git \u540E\u91CD\u8BD5");
7056
+ } catch (markerError) {
7057
+ if (markerError.code !== "ENOENT") throw markerError;
7058
+ }
7059
+ if (ancestor === dirname2(ancestor)) break;
7060
+ }
7061
+ } else if (!String(error.stderr).includes("not a git repository")) {
7062
+ throw error;
7063
+ }
7064
+ }
7065
+ const linkDependencies = (from, to) => {
7066
+ for (const name of dependencies) {
7067
+ const target = join2(from, name), link = join2(to, name);
7068
+ try {
7069
+ if (fs.statSync(target).isDirectory() && !fs.existsSync(link)) fs.symlinkSync(target, link, platform === "win32" ? "junction" : "dir");
7070
+ } catch {
7071
+ }
7072
+ }
7073
+ };
7074
+ if (repoRoot) {
7075
+ repoRoot = fs.realpathSync(repoRoot);
7076
+ const subRel = relative(repoRoot, source);
7077
+ if (isAbsolute(subRel) || subRel.split(/[\\/]/).includes("..")) refuse("\u76EE\u5F55\u4E0D\u5728\u4ED3\u5E93\u5185");
7078
+ const shortId = createHash3("sha256").update(runId).digest("hex").slice(0, 12);
7079
+ const commonDirOutput = command("git", ["-C", source, "rev-parse", "--git-common-dir"]).trim();
7080
+ const commonDir = fs.realpathSync(resolve(source, commonDirOutput));
7081
+ const worktreeHostRoot = basename(commonDir) === ".git" ? dirname2(commonDir) : repoRoot;
7082
+ const root2 = join2(worktreeHostRoot, ".worktrees", `run-${shortId}`), branch = `nolo/run-${shortId}`;
7083
+ if (platform === "win32" && root2.length > 210) refuse("\u9694\u79BB\u76EE\u5F55\u8DEF\u5F84\u8FC7\u957F");
7084
+ command("git", ["-C", repoRoot, "-c", "checkout.workers=0", "-c", "core.longpaths=true", "worktree", "add", root2, "-b", branch, "HEAD"]);
7085
+ linkDependencies(repoRoot, root2);
7086
+ if (worktreeHostRoot !== repoRoot) linkDependencies(worktreeHostRoot, root2);
7087
+ return { mode, kind: "git-worktree", effectiveCwd: join2(root2, subRel), root: root2, sourceRoot: repoRoot, branch };
7088
+ }
7089
+ if (source === dirname2(source) || source === fs.realpathSync(homedir())) refuse("\u4E0D\u80FD\u9694\u79BB\u6587\u4EF6\u7CFB\u7EDF\u6839\u76EE\u5F55\u6216\u7528\u6237\u4E3B\u76EE\u5F55");
7090
+ let files = 0, bytes = 0, entries = 0;
7091
+ const scan = (dir, top, depth = 0) => {
7092
+ if (depth > 64) refuse("\u76EE\u5F55\u5D4C\u5957\u8D85\u8FC7 64 \u5C42\u4E0A\u9650");
7093
+ const handle = fs.opendirSync(dir);
7094
+ try {
7095
+ let entry;
7096
+ while (entry = handle.readSync()) {
7097
+ if (top && dependencies.has(entry.name)) continue;
7098
+ if (++entries > 4e3) refuse("\u76EE\u5F55\u6761\u76EE\u8D85\u8FC7 4000 \u4E0A\u9650");
7099
+ const path = join2(dir, entry.name), stat = fs.lstatSync(path);
7100
+ if (stat.isSymbolicLink() || !stat.isDirectory() && !stat.isFile()) refuse("\u666E\u901A\u4E1A\u52A1\u76EE\u5F55\u542B\u7B26\u53F7\u94FE\u63A5\u6216\u7279\u6B8A\u6587\u4EF6\uFF0C\u4E0D\u80FD\u5B89\u5168\u590D\u5236");
7101
+ if (stat.isDirectory()) scan(path, false, depth + 1);
7102
+ else if (++files > (options.maxFiles ?? 2e3) || (bytes += stat.size) > (options.maxBytes ?? 200 * 1024 * 1024)) refuse("\u76EE\u5F55\u8D85\u8FC7\u6587\u4EF6\u6570\u6216\u603B\u5927\u5C0F\u4E0A\u9650\uFF082000 \u6587\u4EF6 / 200 MiB\uFF09");
7103
+ }
7104
+ } finally {
7105
+ handle.closeSync();
7106
+ }
7107
+ };
7108
+ scan(source, true);
7109
+ const root = resolve(options.noloHome ?? join2(homedir(), ".nolo"), "workspaces", runId);
7110
+ const rel = relative(source, root);
7111
+ if (!rel || !rel.startsWith(`..${sep}`) && rel !== ".." && !isAbsolute(rel)) refuse("\u5FEB\u7167\u76EE\u6807\u4E0D\u80FD\u4F4D\u4E8E\u6E90\u76EE\u5F55\u5185");
7112
+ fs.mkdirSync(dirname2(root), { recursive: true });
7113
+ fs.mkdirSync(root);
7114
+ try {
7115
+ for (const entry of fs.readdirSync(source)) {
7116
+ if (dependencies.has(entry)) continue;
7117
+ const from = join2(source, entry), to = join2(root, entry);
7118
+ let copied = false;
7119
+ try {
7120
+ if (platform === "darwin") {
7121
+ command("cp", ["-cR", from, to]);
7122
+ copied = true;
7123
+ } else if (platform === "linux") {
7124
+ command("cp", ["-a", "--reflink=always", "--", from, to]);
7125
+ copied = true;
7126
+ }
7127
+ } catch {
7128
+ }
7129
+ if (!copied) fs.cpSync(from, to, { recursive: true, force: true, dereference: false });
7130
+ }
7131
+ linkDependencies(source, root);
7132
+ } catch (error) {
7133
+ try {
7134
+ rollbackWorkspaceIsolation({ mode, kind: "directory-snapshot", effectiveCwd: root, root, sourceRoot: source });
7135
+ } catch (cleanupError) {
7136
+ throw new AggregateError([error, cleanupError], `\u590D\u5236\u5931\u8D25\uFF1B\u9694\u79BB\u76EE\u5F55\u4FDD\u7559\u5F85\u5904\u7406: ${root}`);
7137
+ }
7138
+ throw error;
7139
+ }
7140
+ return { mode, kind: "directory-snapshot", effectiveCwd: root, root, sourceRoot: source };
7141
+ }
7142
+ function rollbackWorkspaceIsolation(workspace) {
7143
+ const { root, sourceRoot, branch, kind } = workspace;
7144
+ if (!root || !sourceRoot) return;
7145
+ if (kind === "git-worktree") {
7146
+ const git = (args) => String(execFileSync("git", ["-C", sourceRoot, ...args], { encoding: "utf8" }));
7147
+ for (const name of dependencies) {
7148
+ const link = join2(root, name), original = join2(sourceRoot, name);
7149
+ if (!git(["-C", root, "ls-files", "--", name]).trim()) {
7150
+ try {
7151
+ if (fs.lstatSync(link).isSymbolicLink() && fs.realpathSync(link) === fs.realpathSync(original)) fs.unlinkSync(link);
7152
+ } catch (error) {
7153
+ if (error.code !== "ENOENT") throw error;
7154
+ }
7155
+ }
7156
+ }
7157
+ if (git(["-C", root, "status", "--porcelain", "--ignored"]).trim()) throw new Error(`\u9694\u79BB\u76EE\u5F55\u542B\u672A\u9A8C\u8BC1\u5185\u5BB9\uFF0C\u4FDD\u7559 ${root}`);
7158
+ execFileSync("git", ["-C", sourceRoot, "merge-base", "--is-ancestor", branch, "HEAD"]);
7159
+ git(["worktree", "remove", root]);
7160
+ git(["branch", "-d", branch]);
7161
+ } else if (kind === "directory-snapshot") {
7162
+ const verify = (path) => {
7163
+ for (const entry of fs.readdirSync(path)) {
7164
+ const target = join2(path, entry), original = join2(sourceRoot, relative(root, target));
7165
+ const stat = fs.lstatSync(target);
7166
+ if (path === root && dependencies.has(entry) && stat.isSymbolicLink() && fs.realpathSync(target) === fs.realpathSync(original)) continue;
7167
+ if (stat.isDirectory() && fs.statSync(original).isDirectory()) verify(target);
7168
+ else if (!stat.isFile() || !fs.statSync(original).isFile() || !fs.readFileSync(target).equals(fs.readFileSync(original))) throw new Error(`\u9694\u79BB\u526F\u672C\u6709\u552F\u4E00\u5185\u5BB9\uFF0C\u4FDD\u7559 ${root}`);
7169
+ }
7170
+ };
7171
+ verify(root);
7172
+ fs.rmSync(root, { recursive: true });
7173
+ }
7174
+ }
7175
+
6932
7176
  // packages/cli/client/childRunImages.ts
6933
- import { isAbsolute } from "node:path";
7177
+ import { isAbsolute as isAbsolute2 } from "node:path";
6934
7178
  function validateChildImagePaths(value) {
6935
7179
  if (value === void 0) return [];
6936
- if (!Array.isArray(value) || value.length < 1 || value.length > MAX_TOOL_IMAGES_PER_REQUEST || value.some((path) => typeof path !== "string" || !isAbsolute(path) || path.includes("\0"))) {
7180
+ if (!Array.isArray(value) || value.length < 1 || value.length > MAX_TOOL_IMAGES_PER_REQUEST || value.some((path) => typeof path !== "string" || !isAbsolute2(path) || path.includes("\0"))) {
6937
7181
  throw new Error("image_input_invalid: expected 1\u20134 absolute local image paths");
6938
7182
  }
6939
7183
  return value;
@@ -6966,8 +7210,8 @@ async function normalizeCliRunImages(inputs, normalizeRemote) {
6966
7210
  }
6967
7211
 
6968
7212
  // packages/cli/agentRunArgs.ts
6969
- import { readFileSync } from "node:fs";
6970
- import { isAbsolute as isAbsolute2 } from "node:path";
7213
+ import { readFileSync as readFileSync2 } from "node:fs";
7214
+ import { isAbsolute as isAbsolute3 } from "node:path";
6971
7215
  function readFlagValue(args, flag) {
6972
7216
  const index = args.indexOf(flag);
6973
7217
  if (index < 0) return void 0;
@@ -7016,9 +7260,13 @@ var VALUELESS_FLAGS = {
7016
7260
  "--local": true,
7017
7261
  "--server": true,
7018
7262
  "--auto": true,
7263
+ "--auto-route": true,
7264
+ "--allow-host-writes": true,
7019
7265
  "--dangerously-allow-shell": true,
7020
7266
  "--trace-tools": true,
7021
7267
  "--bg": true,
7268
+ "--fresh": true,
7269
+ "--fresh-dialog": true,
7022
7270
  "--strict-continue-history": true,
7023
7271
  "--no-stream": true,
7024
7272
  "--debug": true,
@@ -7026,7 +7274,8 @@ var VALUELESS_FLAGS = {
7026
7274
  "--memory-only": true,
7027
7275
  "--read-only": true,
7028
7276
  "--machine-shell": true,
7029
- "--instabox-allow-remote-release": true
7277
+ "--instabox-allow-remote-release": true,
7278
+ "--instabox-allow-paid": true
7030
7279
  };
7031
7280
  function isValuelessFlag(arg) {
7032
7281
  return Object.prototype.hasOwnProperty.call(VALUELESS_FLAGS, arg);
@@ -7108,7 +7357,7 @@ function parseAgentRunArgs(args, options = {}) {
7108
7357
  const agentKey = rawAgentKey ? resolveCliAgentKeyInput(rawAgentKey) : void 0;
7109
7358
  const explicitMsg = readFlagValue(args, "--msg");
7110
7359
  const msgFile = readFlagValue(args, "--msg-file");
7111
- const fileMessage = msgFile ? (options.readTextFile ?? ((path) => readFileSync(path, "utf8")))(msgFile) : void 0;
7360
+ const fileMessage = msgFile ? (options.readTextFile ?? ((path) => readFileSync2(path, "utf8")))(msgFile) : void 0;
7112
7361
  const rawMessage = explicitMsg ?? fileMessage ?? positional.slice(isNoLoginRunShorthand ? 0 : 1).join(" ");
7113
7362
  if (!agentKey || !rawMessage.trim()) return null;
7114
7363
  const message = rawMessage.trim();
@@ -7169,7 +7418,7 @@ function parseAgentRunArgs(args, options = {}) {
7169
7418
  if (!rawInstaboxArtifactDir) {
7170
7419
  throw new Error("--runtime-key instabox \u5FC5\u987B\u6307\u5B9A --instabox-artifact-dir <\u7EDD\u5BF9\u8DEF\u5F84>");
7171
7420
  }
7172
- if (!isAbsolute2(rawInstaboxArtifactDir) || rawInstaboxArtifactDir.includes("\0") || rawInstaboxArtifactDir.split("/").includes("..")) {
7421
+ if (!isAbsolute3(rawInstaboxArtifactDir) || rawInstaboxArtifactDir.includes("\0") || rawInstaboxArtifactDir.split("/").includes("..")) {
7173
7422
  throw new Error(`--instabox-artifact-dir \u5FC5\u987B\u4E3A\u5408\u6CD5\u7EDD\u5BF9\u8DEF\u5F84\uFF0C\u4E14\u4E0D\u80FD\u5305\u542B .. \u6216\u7A7A\u5B57\u7B26: "${rawInstaboxArtifactDir}"`);
7174
7423
  }
7175
7424
  if (rawInstaboxWorkspace === "snapshot" && !rawInstaboxManifest) {
@@ -7202,6 +7451,27 @@ function parseAgentRunArgs(args, options = {}) {
7202
7451
  const allowedToolNames = readRepeatedFlagValues(args, "--allowed-tool").map((value) => value.trim()).filter(Boolean);
7203
7452
  const cwd = readFlagValue(args, "--cwd");
7204
7453
  const timeoutMs = parsePositiveInteger(readFlagValue(args, "--timeout-ms"));
7454
+ const reasoningEffortHits = [];
7455
+ for (let index = 0; index < args.length; index += 1) {
7456
+ const arg = args[index];
7457
+ if (isValuelessFlag(arg)) continue;
7458
+ if (arg === "--reasoning-effort") {
7459
+ reasoningEffortHits.push({ index, value: args[index + 1] });
7460
+ index += 1;
7461
+ continue;
7462
+ }
7463
+ if (arg.startsWith("--")) index += 1;
7464
+ }
7465
+ if (reasoningEffortHits.length > 1) {
7466
+ throw new Error("--reasoning-effort \u53EA\u80FD\u51FA\u73B0\u4E00\u6B21\uFF08\u91CD\u590D\u53C2\u6570\u4E0D\u4F1A\u88AB\u9759\u9ED8\u53D6\u7B2C\u4E00\u4E2A\uFF09");
7467
+ }
7468
+ const rawReasoningEffort = reasoningEffortHits[0]?.value?.trim().toLowerCase();
7469
+ if (reasoningEffortHits.length === 1 && !REASONING_EFFORT_OPTIONS.includes(rawReasoningEffort ?? "")) {
7470
+ throw new Error(
7471
+ `--reasoning-effort \u5FC5\u987B\u662F ${REASONING_EFFORT_OPTIONS.join("|")} \u4E4B\u4E00`
7472
+ );
7473
+ }
7474
+ const reasoningEffort = rawReasoningEffort ? rawReasoningEffort : void 0;
7205
7475
  const rawEventsMode = readFlagValue(args, "--events");
7206
7476
  const eventsMode = rawEventsMode === "jsonl" ? "jsonl" : void 0;
7207
7477
  const inheritedRef = inheritedFromDialog ? parseDialogReference(inheritedFromDialog) : void 0;
@@ -7269,12 +7539,13 @@ function parseAgentRunArgs(args, options = {}) {
7269
7539
  ...blockedToolNames.length ? { blockedToolNames } : {},
7270
7540
  ...dodCommands.length ? { dodCommands } : {},
7271
7541
  ...typeof timeoutMs === "number" ? { timeoutMs } : {},
7542
+ ...reasoningEffort ? { reasoningEffort } : {},
7272
7543
  ...queueFile ? { queueFile } : {}
7273
7544
  };
7274
7545
  }
7275
7546
 
7276
7547
  // packages/cli/client/cliAgentRunToolExecutors.ts
7277
- import { join as join3, resolve as resolve3 } from "node:path";
7548
+ import { dirname as dirname4, join as join4, resolve as resolve4 } from "node:path";
7278
7549
  import { randomUUID as randomUUID3 } from "node:crypto";
7279
7550
  import * as nodeFs2 from "node:fs";
7280
7551
 
@@ -7338,7 +7609,7 @@ function waitForRunTerminal(args) {
7338
7609
  }
7339
7610
 
7340
7611
  // packages/cli/client/cliAgentRunToolExecutors.ts
7341
- import { existsSync as existsSync3, readFileSync as readFileSync4 } from "node:fs";
7612
+ import { existsSync as existsSync4, readFileSync as readFileSync5 } from "node:fs";
7342
7613
 
7343
7614
  // packages/cli/client/agentRunSnapshot.ts
7344
7615
  function readString(value) {
@@ -7458,13 +7729,13 @@ function isFailureStatus(status) {
7458
7729
  function isOrphanedStatus(status) {
7459
7730
  return status === "orphaned";
7460
7731
  }
7461
- function toEpochMs2(iso) {
7732
+ function toEpochMs(iso) {
7462
7733
  if (!iso) return void 0;
7463
7734
  const ms = Date.parse(iso);
7464
7735
  return Number.isFinite(ms) ? ms : void 0;
7465
7736
  }
7466
7737
  function isOverTimeout(run, nowMs, timeoutMs) {
7467
- const startedMs = toEpochMs2(run.startedAt);
7738
+ const startedMs = toEpochMs(run.startedAt);
7468
7739
  if (startedMs === void 0) return false;
7469
7740
  return nowMs - startedMs >= timeoutMs;
7470
7741
  }
@@ -7510,7 +7781,7 @@ function aggregateBatch(input) {
7510
7781
  const { batchId, runs, now } = input;
7511
7782
  const timeoutMs = input.timeoutMs ?? DEFAULT_BATCH_TIMEOUT_MS;
7512
7783
  const notified = new Set(input.notifiedReasons ?? []);
7513
- const nowMs = toEpochMs2(now) ?? 0;
7784
+ const nowMs = toEpochMs(now) ?? 0;
7514
7785
  let success = 0;
7515
7786
  let failed = 0;
7516
7787
  let orphaned = 0;
@@ -7584,47 +7855,47 @@ function deriveAgentRunTodoStatus(input) {
7584
7855
  }
7585
7856
 
7586
7857
  // packages/cli/client/fileSystemStores.ts
7587
- import { existsSync as existsSync2, mkdirSync, readFileSync as readFileSync2, writeFileSync } from "node:fs";
7858
+ import { existsSync as existsSync3, mkdirSync as mkdirSync2, readFileSync as readFileSync3, writeFileSync } from "node:fs";
7588
7859
  import { homedir as nodeHomedir } from "node:os";
7589
- import { dirname as dirname2, join as join2 } from "node:path";
7860
+ import { dirname as dirname3, join as join3 } from "node:path";
7590
7861
  var nodeFs = {
7591
- mkdirSync,
7862
+ mkdirSync: mkdirSync2,
7592
7863
  writeFileSync,
7593
- readFileSync: readFileSync2,
7594
- existsSync: existsSync2
7864
+ readFileSync: readFileSync3,
7865
+ existsSync: existsSync3
7595
7866
  };
7596
- function resolveNoloHome(env, homedir2) {
7867
+ function resolveNoloHome(env, homedir3) {
7597
7868
  const custom = env?.NOLO_HOME;
7598
7869
  if (custom && custom.trim()) return custom.trim();
7599
7870
  const ambient = process.env.NOLO_HOME?.trim();
7600
7871
  if (ambient) return ambient;
7601
- return join2(homedir2(), ".nolo");
7872
+ return join3(homedir3(), ".nolo");
7602
7873
  }
7603
- function ensureDir(dir, fs) {
7604
- fs.mkdirSync(dir, { recursive: true });
7874
+ function ensureDir(dir, fs2) {
7875
+ fs2.mkdirSync(dir, { recursive: true });
7605
7876
  }
7606
- function readJson(path, fs) {
7607
- if (!fs.existsSync(path)) return void 0;
7877
+ function readJson(path, fs2) {
7878
+ if (!fs2.existsSync(path)) return void 0;
7608
7879
  try {
7609
- const raw = fs.readFileSync(path, "utf8");
7880
+ const raw = fs2.readFileSync(path, "utf8");
7610
7881
  return JSON.parse(String(raw));
7611
7882
  } catch {
7612
7883
  return void 0;
7613
7884
  }
7614
7885
  }
7615
- function writeJson(path, data, fs) {
7616
- fs.writeFileSync(path, JSON.stringify(data, null, 2));
7886
+ function writeJson(path, data, fs2) {
7887
+ fs2.writeFileSync(path, JSON.stringify(data, null, 2));
7617
7888
  }
7618
7889
  function createFileSystemTodoStore(opts = {}) {
7619
7890
  const env = opts.env ?? process.env;
7620
- const homedir2 = opts.homedir ?? nodeHomedir;
7621
- const fs = opts.fs ?? nodeFs;
7622
- const noloHome = resolveNoloHome(env, homedir2);
7623
- const filePath = opts.filePath ?? join2(noloHome, "agent_run_todos.json");
7624
- const oldFilePath = join2(noloHome, "todos.json");
7891
+ const homedir3 = opts.homedir ?? nodeHomedir;
7892
+ const fs2 = opts.fs ?? nodeFs;
7893
+ const noloHome = resolveNoloHome(env, homedir3);
7894
+ const filePath = opts.filePath ?? join3(noloHome, "agent_run_todos.json");
7895
+ const oldFilePath = join3(noloHome, "todos.json");
7625
7896
  const loadMap = () => {
7626
- if (!opts.filePath && !fs.existsSync(filePath) && fs.existsSync(oldFilePath)) {
7627
- const oldData = readJson(oldFilePath, fs);
7897
+ if (!opts.filePath && !fs2.existsSync(filePath) && fs2.existsSync(oldFilePath)) {
7898
+ const oldData = readJson(oldFilePath, fs2);
7628
7899
  const map2 = /* @__PURE__ */ new Map();
7629
7900
  if (oldData?.todos) {
7630
7901
  for (const item of oldData.todos) {
@@ -7646,11 +7917,11 @@ function createFileSystemTodoStore(opts = {}) {
7646
7917
  }
7647
7918
  }
7648
7919
  }
7649
- ensureDir(dirname2(filePath), fs);
7650
- writeJson(filePath, { todos: [...map2.values()] }, fs);
7920
+ ensureDir(dirname3(filePath), fs2);
7921
+ writeJson(filePath, { todos: [...map2.values()] }, fs2);
7651
7922
  return map2;
7652
7923
  }
7653
- const data = readJson(filePath, fs);
7924
+ const data = readJson(filePath, fs2);
7654
7925
  const map = /* @__PURE__ */ new Map();
7655
7926
  if (data?.todos) {
7656
7927
  for (const todo of data.todos) {
@@ -7660,8 +7931,8 @@ function createFileSystemTodoStore(opts = {}) {
7660
7931
  return map;
7661
7932
  };
7662
7933
  const persist = (map) => {
7663
- ensureDir(dirname2(filePath), fs);
7664
- writeJson(filePath, { todos: [...map.values()] }, fs);
7934
+ ensureDir(dirname3(filePath), fs2);
7935
+ writeJson(filePath, { todos: [...map.values()] }, fs2);
7665
7936
  };
7666
7937
  return {
7667
7938
  async getTodo(id) {
@@ -7691,13 +7962,13 @@ function createFileSystemTodoStore(opts = {}) {
7691
7962
  }
7692
7963
 
7693
7964
  // packages/cli/client/instaboxRunConfig.ts
7694
- import { lstatSync, readFileSync as readFileSync3, realpathSync as realpathSync2 } from "node:fs";
7695
- import { isAbsolute as isAbsolute3, normalize, resolve as resolve2 } from "node:path";
7965
+ import { lstatSync as lstatSync2, readFileSync as readFileSync4, realpathSync as realpathSync3 } from "node:fs";
7966
+ import { isAbsolute as isAbsolute4, normalize, resolve as resolve3 } from "node:path";
7696
7967
 
7697
7968
  // packages/cli/client/localInstaboxWorkspaceDelivery.ts
7698
7969
  import { constants } from "node:fs";
7699
7970
  import { open, realpath } from "node:fs/promises";
7700
- import { createHash as createHash3 } from "node:crypto";
7971
+ import { createHash as createHash4 } from "node:crypto";
7701
7972
 
7702
7973
  // packages/agent-runtime/instaboxBackend.ts
7703
7974
  var INSTABOX_BACKEND_ID = "instabox";
@@ -7872,7 +8143,7 @@ var InstaboxBackend = class {
7872
8143
  ...rawBody === void 0 ? {} : { body: rawBody }
7873
8144
  });
7874
8145
  });
7875
- this.#sleep = options.sleepImpl ?? ((ms) => new Promise((resolve7) => setTimeout(resolve7, ms)));
8146
+ this.#sleep = options.sleepImpl ?? ((ms) => new Promise((resolve8) => setTimeout(resolve8, ms)));
7876
8147
  this.#machineTimeoutSeconds = options.machineTimeoutSeconds ?? 1800;
7877
8148
  this.#createTimeoutMs = options.createTimeoutMs ?? 18e4;
7878
8149
  this.#deleteTimeoutMs = options.deleteTimeoutMs ?? 12e4;
@@ -8429,8 +8700,8 @@ var InstaboxBackend = class {
8429
8700
  try {
8430
8701
  await Promise.race([
8431
8702
  this.#sleep(Math.min(this.#pollIntervalMs, remaining())),
8432
- new Promise((resolve7) => {
8433
- timer = setTimeout(resolve7, remaining());
8703
+ new Promise((resolve8) => {
8704
+ timer = setTimeout(resolve8, remaining());
8434
8705
  })
8435
8706
  ]);
8436
8707
  } finally {
@@ -8733,8 +9004,8 @@ var InstaboxBackend = class {
8733
9004
  try {
8734
9005
  return await Promise.race([
8735
9006
  this.#call({ ...args, timeoutMs: void 0 }),
8736
- new Promise((resolve7) => {
8737
- timer = setTimeout(() => resolve7({ status: 0, payload: null, transportError: "Timeout" }), args.timeoutMs);
9007
+ new Promise((resolve8) => {
9008
+ timer = setTimeout(() => resolve8({ status: 0, payload: null, transportError: "Timeout" }), args.timeoutMs);
8738
9009
  })
8739
9010
  ]);
8740
9011
  } finally {
@@ -8872,7 +9143,7 @@ function extractInstaboxErrorCode(payload) {
8872
9143
 
8873
9144
  // packages/cli/client/localInstaboxWorkspaceDelivery.ts
8874
9145
  var SNAPSHOT_LIMITS = { files: 256, fileBytes: 8 * 1024 * 1024, totalBytes: 32 * 1024 * 1024, chunkBytes: 384 * 1024 };
8875
- var hash = (bytes) => createHash3("sha256").update(bytes).digest("hex");
9146
+ var hash = (bytes) => createHash4("sha256").update(bytes).digest("hex");
8876
9147
  var fail = (code) => {
8877
9148
  throw new Error(`instabox_workspace_delivery:${code}`);
8878
9149
  };
@@ -9094,14 +9365,14 @@ function resolveInstaboxRunConfigPath(options) {
9094
9365
  fail2("missing_path", `\u73AF\u5883\u53D8\u91CF ${INSTABOX_RUN_CONFIG_ENV} \u672A\u8BBE\u7F6E\u6216\u4E3A\u7A7A`);
9095
9366
  }
9096
9367
  const runsDir = options?.runsDir ?? resolveRunsDir(env);
9097
- const normalizedRunsDir = normalize(resolve2(runsDir));
9098
- const resolvedTarget = isAbsolute3(explicitPath) ? normalize(explicitPath) : normalize(resolve2(normalizedRunsDir, explicitPath));
9368
+ const normalizedRunsDir = normalize(resolve3(runsDir));
9369
+ const resolvedTarget = isAbsolute4(explicitPath) ? normalize(explicitPath) : normalize(resolve3(normalizedRunsDir, explicitPath));
9099
9370
  if (resolvedTarget !== normalizedRunsDir && !resolvedTarget.startsWith(normalizedRunsDir.endsWith("/") ? normalizedRunsDir : `${normalizedRunsDir}/`)) {
9100
9371
  fail2("path_traversal", `\u914D\u7F6E\u8DEF\u5F84 "${explicitPath}" \u8D8A\u51FA\u4E86\u9650\u5B9A\u7684 runs \u76EE\u5F55 "${normalizedRunsDir}"`);
9101
9372
  }
9102
9373
  let stats;
9103
9374
  try {
9104
- stats = lstatSync(resolvedTarget);
9375
+ stats = lstatSync2(resolvedTarget);
9105
9376
  } catch (err) {
9106
9377
  fail2("file_unreadable", `\u914D\u7F6E\u6587\u4EF6\u4E0D\u53EF\u8BFB\u6216\u4E0D\u5B58\u5728: ${resolvedTarget}`);
9107
9378
  }
@@ -9115,8 +9386,8 @@ function resolveInstaboxRunConfigPath(options) {
9115
9386
  fail2("file_too_large", `\u914D\u7F6E\u6587\u4EF6\u5927\u5C0F (${stats.size} \u5B57\u8282) \u8D85\u8FC7\u4E0A\u9650 (${INSTABOX_RUN_CONFIG_MAX_BYTES} \u5B57\u8282)`);
9116
9387
  }
9117
9388
  try {
9118
- const realTarget = realpathSync2(resolvedTarget);
9119
- const realRuns = realpathSync2(normalizedRunsDir);
9389
+ const realTarget = realpathSync3(resolvedTarget);
9390
+ const realRuns = realpathSync3(normalizedRunsDir);
9120
9391
  if (realTarget !== realRuns && !realTarget.startsWith(realRuns.endsWith("/") ? realRuns : `${realRuns}/`)) {
9121
9392
  fail2("symlink_traversal", `\u914D\u7F6E\u771F\u5B9E\u8DEF\u5F84 "${realTarget}" \u8D8A\u51FA runs \u771F\u5B9E\u76EE\u5F55 "${realRuns}"`);
9122
9393
  }
@@ -9128,7 +9399,7 @@ function loadInstaboxRunConfig(options) {
9128
9399
  const { resolvedPath } = resolveInstaboxRunConfigPath(options);
9129
9400
  let rawText;
9130
9401
  try {
9131
- rawText = readFileSync3(resolvedPath, "utf8");
9402
+ rawText = readFileSync4(resolvedPath, "utf8");
9132
9403
  } catch (err) {
9133
9404
  fail2("file_read_failed", `\u8BFB\u53D6\u914D\u7F6E\u6587\u4EF6\u5931\u8D25: ${err instanceof Error ? err.message : String(err)}`);
9134
9405
  }
@@ -9177,7 +9448,7 @@ function loadInstaboxRunConfig(options) {
9177
9448
  if (!artifactRootRaw) {
9178
9449
  fail2("missing_artifact_root", "artifactRoot (artifact\u76EE\u7684\u76EE\u5F55) \u5FC5\u987B\u4E3A\u975E\u7A7A\u5B57\u7B26\u4E32\uFF0C\u672A\u914D\u7F6E\u6216\u9ED8\u8BA4\u5747\u88AB\u62D2\u7EDD");
9179
9450
  }
9180
- if (!isAbsolute3(artifactRootRaw) || artifactRootRaw.includes("\0") || artifactRootRaw.split("/").includes("..")) {
9451
+ if (!isAbsolute4(artifactRootRaw) || artifactRootRaw.includes("\0") || artifactRootRaw.split("/").includes("..")) {
9181
9452
  fail2("invalid_artifact_root", `artifactRoot \u5FC5\u987B\u4E3A\u5408\u6CD5\u7EDD\u5BF9\u8DEF\u5F84: "${artifactRootRaw}"`);
9182
9453
  }
9183
9454
  const artifactRoot = normalize(artifactRootRaw);
@@ -9296,7 +9567,7 @@ async function evaluateAutoInstaboxPlacement(input) {
9296
9567
  }
9297
9568
  }
9298
9569
  if (effectiveAvailableMb === null) {
9299
- const note2 = `\u5BBF\u4E3B\u53EF\u7528\u5185\u5B58\u63A2\u6D4B\u5931\u8D25\u6216\u672A\u77E5\uFF08${memoryDiagnosis}\uFF09\uFF1B\u65E0\u6CD5\u5224\u65AD\u662F\u5426\u4F4E\u4E8E\u9884\u7B97\uFF08${LOCAL_TOOL_MEMORY_BUDGET_MB}MB\uFF09\uFF0C\u4FDD\u6301\u9ED8\u8BA4\u672C\u5730\u6C99\u76D2\uFF0C\u4E0D\u81EA\u52A8\u8FC1\u79FB\u3002`;
9570
+ const note2 = `\u5BBF\u4E3B\u53EF\u7528\u5185\u5B58\u63A2\u6D4B\u5931\u8D25\u6216\u672A\u77E5\uFF08${memoryDiagnosis}\uFF09\uFF1B\u65E0\u6CD5\u5224\u65AD\u662F\u5426\u4F4E\u4E8E\u9884\u7B97\uFF08${LOCAL_TOOL_MEMORY_BUDGET_MB}MB\uFF09\uFF0C\u4FDD\u6301\u9ED8\u8BA4\u5BBF\u4E3B\uFF08\u5199\u578B\u6D3E\u53D1\u4ECD\u987B allowHostWrites: true\uFF09\uFF0C\u4E0D\u81EA\u52A8\u8FC1\u79FB\u3002`;
9300
9571
  return {
9301
9572
  selectedRuntimeKey: void 0,
9302
9573
  reason: "memory_unknown",
@@ -9313,7 +9584,7 @@ async function evaluateAutoInstaboxPlacement(input) {
9313
9584
  }
9314
9585
  const autoEnabled = input.autoEnabled === true || input.env?.NOLO_INSTABOX_AUTO === "1" || typeof process !== "undefined" && process.env?.NOLO_INSTABOX_AUTO === "1";
9315
9586
  if (!autoEnabled) {
9316
- const note2 = `\u5BBF\u4E3B\u53EF\u7528\u5185\u5B58\u7D27\u7F3A\uFF08${effectiveAvailableMb}MB < ${LOCAL_TOOL_MEMORY_BUDGET_MB}MB\uFF09\uFF0C\u4F46\u672A\u542F\u7528\u81EA\u52A8 Instabox\uFF08\u9700\u8BBE\u7F6E NOLO_INSTABOX_AUTO=1 \u6216\u914D\u7F6E\u5F00\u542F\uFF09\uFF1B\u4FDD\u6301\u9ED8\u8BA4 docker \u6C99\u76D2\u3002`;
9587
+ const note2 = `\u5BBF\u4E3B\u53EF\u7528\u5185\u5B58\u7D27\u7F3A\uFF08${effectiveAvailableMb}MB < ${LOCAL_TOOL_MEMORY_BUDGET_MB}MB\uFF09\uFF0C\u4F46\u672A\u542F\u7528\u81EA\u52A8 Instabox\uFF08\u9700\u8BBE\u7F6E NOLO_INSTABOX_AUTO=1 \u6216\u914D\u7F6E\u5F00\u542F\uFF09\uFF1B\u4FDD\u6301\u9ED8\u8BA4\u5BBF\u4E3B\uFF08\u5199\u578B\u6D3E\u53D1\u4ECD\u987B allowHostWrites: true\uFF09\u3002`;
9317
9588
  return {
9318
9589
  selectedRuntimeKey: void 0,
9319
9590
  reason: "auto_disabled",
@@ -9328,7 +9599,7 @@ async function evaluateAutoInstaboxPlacement(input) {
9328
9599
  });
9329
9600
  } catch (error) {
9330
9601
  const errorMsg = error instanceof Error ? error.message : String(error);
9331
- const note2 = `\u5BBF\u4E3B\u53EF\u7528\u5185\u5B58\u7D27\u7F3A\uFF08${effectiveAvailableMb}MB < ${LOCAL_TOOL_MEMORY_BUDGET_MB}MB\uFF09\uFF0C\u5C1D\u8BD5\u81EA\u52A8\u6539\u7528 Instabox \u53D7\u963B\uFF1A${errorMsg}\uFF1B\u4FDD\u6301\u9ED8\u8BA4 docker \u6C99\u76D2\u3002`;
9602
+ const note2 = `\u5BBF\u4E3B\u53EF\u7528\u5185\u5B58\u7D27\u7F3A\uFF08${effectiveAvailableMb}MB < ${LOCAL_TOOL_MEMORY_BUDGET_MB}MB\uFF09\uFF0C\u5C1D\u8BD5\u81EA\u52A8\u6539\u7528 Instabox \u53D7\u963B\uFF1A${errorMsg}\uFF1B\u4FDD\u6301\u9ED8\u8BA4\u5BBF\u4E3B\uFF08\u5199\u578B\u6D3E\u53D1\u4ECD\u987B allowHostWrites: true\uFF09\u3002`;
9332
9603
  return {
9333
9604
  selectedRuntimeKey: void 0,
9334
9605
  reason: "config_unavailable",
@@ -9340,7 +9611,7 @@ async function evaluateAutoInstaboxPlacement(input) {
9340
9611
  try {
9341
9612
  const readiness = await input.checkReadiness();
9342
9613
  if (readiness && readiness.ready === false) {
9343
- const note2 = `\u5BBF\u4E3B\u53EF\u7528\u5185\u5B58\u7D27\u7F3A\uFF08${effectiveAvailableMb}MB < ${LOCAL_TOOL_MEMORY_BUDGET_MB}MB\uFF09\uFF0C\u5C1D\u8BD5\u81EA\u52A8\u6539\u7528 Instabox \u4F46\u88AB\u670D\u52A1\u7AEF\u51C6\u5165/\u5C31\u7EEA\u660E\u786E\u62D2\u7EDD\uFF1A${readiness.reason ?? "\u670D\u52A1\u7AEF\u672A\u5C31\u7EEA"}\uFF1B\u4FDD\u6301\u9ED8\u8BA4 docker \u6C99\u76D2\u3002`;
9614
+ const note2 = `\u5BBF\u4E3B\u53EF\u7528\u5185\u5B58\u7D27\u7F3A\uFF08${effectiveAvailableMb}MB < ${LOCAL_TOOL_MEMORY_BUDGET_MB}MB\uFF09\uFF0C\u5C1D\u8BD5\u81EA\u52A8\u6539\u7528 Instabox \u4F46\u88AB\u670D\u52A1\u7AEF\u51C6\u5165/\u5C31\u7EEA\u660E\u786E\u62D2\u7EDD\uFF1A${readiness.reason ?? "\u670D\u52A1\u7AEF\u672A\u5C31\u7EEA"}\uFF1B\u4FDD\u6301\u9ED8\u8BA4\u5BBF\u4E3B\uFF08\u5199\u578B\u6D3E\u53D1\u4ECD\u987B allowHostWrites: true\uFF09\u3002`;
9344
9615
  return {
9345
9616
  selectedRuntimeKey: void 0,
9346
9617
  reason: "readiness_rejected",
@@ -9350,7 +9621,7 @@ async function evaluateAutoInstaboxPlacement(input) {
9350
9621
  }
9351
9622
  } catch (error) {
9352
9623
  const errorMsg = error instanceof Error ? error.message : String(error);
9353
- const note2 = `\u5BBF\u4E3B\u53EF\u7528\u5185\u5B58\u7D27\u7F3A\uFF08${effectiveAvailableMb}MB < ${LOCAL_TOOL_MEMORY_BUDGET_MB}MB\uFF09\uFF0C\u5C1D\u8BD5\u81EA\u52A8\u6539\u7528 Instabox \u4F46\u5C31\u7EEA\u68C0\u67E5\u629B\u9519\uFF1A${errorMsg}\uFF1B\u4FDD\u6301\u9ED8\u8BA4 docker \u6C99\u76D2\u3002`;
9624
+ const note2 = `\u5BBF\u4E3B\u53EF\u7528\u5185\u5B58\u7D27\u7F3A\uFF08${effectiveAvailableMb}MB < ${LOCAL_TOOL_MEMORY_BUDGET_MB}MB\uFF09\uFF0C\u5C1D\u8BD5\u81EA\u52A8\u6539\u7528 Instabox \u4F46\u5C31\u7EEA\u68C0\u67E5\u629B\u9519\uFF1A${errorMsg}\uFF1B\u4FDD\u6301\u9ED8\u8BA4\u5BBF\u4E3B\uFF08\u5199\u578B\u6D3E\u53D1\u4ECD\u987B allowHostWrites: true\uFF09\u3002`;
9354
9625
  return {
9355
9626
  selectedRuntimeKey: void 0,
9356
9627
  reason: "readiness_error",
@@ -9401,6 +9672,8 @@ async function assertAutoInstaboxPlacementAvailable(readEvidence, options) {
9401
9672
  }
9402
9673
 
9403
9674
  // packages/cli/client/cliAgentRunToolExecutors.ts
9675
+ var normalizeNonEmptyString = (value) => typeof value === "string" && value.trim() ? value.trim() : "";
9676
+ var resolveHostCallerAgentKey = (deps) => normalizeNonEmptyString(deps.currentAgentKey) || normalizeNonEmptyString(deps.source?.agentKey);
9404
9677
  var noopOutput = { write: () => {
9405
9678
  } };
9406
9679
  var parseCallArgs = (call) => {
@@ -9410,10 +9683,10 @@ var parseCallArgs = (call) => {
9410
9683
  return {};
9411
9684
  }
9412
9685
  };
9413
- var resolveFs = (deps) => deps.fs ?? { existsSync: existsSync3, readFileSync: readFileSync4 };
9686
+ var resolveFs = (deps) => deps.fs ?? { existsSync: existsSync4, readFileSync: readFileSync5 };
9414
9687
  var probeRunCwd = (deps) => {
9415
- const fs = deps.fs;
9416
- const stat = fs?.statSync ?? nodeFs2.statSync;
9688
+ const fs2 = deps.fs;
9689
+ const stat = fs2?.statSync ?? nodeFs2.statSync;
9417
9690
  return (absolutePath) => {
9418
9691
  try {
9419
9692
  return stat(absolutePath).isDirectory() ? "directory" : "not-a-directory";
@@ -9422,10 +9695,10 @@ var probeRunCwd = (deps) => {
9422
9695
  }
9423
9696
  };
9424
9697
  };
9425
- var tailFile = (logPath, tailLines, fs) => {
9426
- if (!fs.existsSync(logPath)) return void 0;
9698
+ var tailFile = (logPath, tailLines, fs2) => {
9699
+ if (!fs2.existsSync(logPath)) return void 0;
9427
9700
  try {
9428
- const content = fs.readFileSync(logPath, "utf8");
9701
+ const content = fs2.readFileSync(logPath, "utf8");
9429
9702
  const lines = String(content).split(/\r?\n/);
9430
9703
  if (lines.length > 0 && lines[lines.length - 1] === "") lines.pop();
9431
9704
  return lines.slice(Math.max(0, lines.length - tailLines)).join("\n");
@@ -9487,6 +9760,11 @@ function buildRunStatusPayload(reconciled, deps, opts = {}) {
9487
9760
  // 结构化失败分类 + 可重试性:编排者据此决策,不再肉读 logTail。
9488
9761
  ...reconciled.failureClass ? { failureClass: reconciled.failureClass } : {},
9489
9762
  ...typeof reconciled.retryable === "boolean" ? { retryable: reconciled.retryable } : {},
9763
+ // 只读观测:本 run 实际跑的模型 / 熔断升级标记 / 正文里明确的 review 结论。
9764
+ // 三者缺省即「未观察到」,不回填猜测值。
9765
+ ...reconciled.model ? { model: reconciled.model } : {},
9766
+ ...reconciled.escalated === true ? { escalated: true } : {},
9767
+ ...reconciled.reviewVerdict ? { reviewVerdict: reconciled.reviewVerdict } : {},
9490
9768
  // 日志落盘路径始终暴露:stalled/failed 且 dialogId 缺失(如 ephemeral)
9491
9769
  // 时 logTail 只能靠它读,不能只留在进程内存。
9492
9770
  ...reconciled.logPath ? { logPath: reconciled.logPath } : {},
@@ -9587,36 +9865,36 @@ function createCliStartAgentRunExecutor(deps = {}) {
9587
9865
  let previousCacheHitRatio = previousRecord?.cacheHitRatio;
9588
9866
  if (previousRecord && previousCacheHitRatio === void 0 && previousRecord.resultFile) {
9589
9867
  try {
9590
- const fs = deps.fs ?? nodeFs2;
9591
- const runsDir = resolve3(resolveRunsDir(deps.env, deps.homedir));
9592
- const expected = resolve3(runsDir, `${previousRecord.runId}.result.md`);
9593
- if (previousRecord.runId.includes("/") || previousRecord.runId.includes("\\") || resolve3(previousRecord.resultFile) !== expected || !fs.realpathSync || !fs.lstatSync) throw new Error("Unverified result path");
9594
- const stat = fs.lstatSync(expected);
9868
+ const fs2 = deps.fs ?? nodeFs2;
9869
+ const runsDir = resolve4(resolveRunsDir(deps.env, deps.homedir));
9870
+ const expected = resolve4(runsDir, `${previousRecord.runId}.result.md`);
9871
+ if (previousRecord.runId.includes("/") || previousRecord.runId.includes("\\") || resolve4(previousRecord.resultFile) !== expected || !fs2.realpathSync || !fs2.lstatSync) throw new Error("Unverified result path");
9872
+ const stat = fs2.lstatSync(expected);
9595
9873
  if (!stat.isFile() || stat.isSymbolicLink()) throw new Error("Non-regular result file");
9596
- const canonicalDir = String(fs.realpathSync(runsDir));
9597
- if (String(fs.realpathSync(expected)) !== join3(canonicalDir, `${previousRecord.runId}.result.md`)) throw new Error("Result escapes runs directory");
9598
- if ((deps.platform ?? process.platform) !== "linux" || !fs.fstatSync || !fs.readSync || !fs.closeSync || !nodeFs2.constants.O_NOFOLLOW || !nodeFs2.constants.O_DIRECTORY) throw new Error("FD proof unavailable");
9874
+ const canonicalDir = String(fs2.realpathSync(runsDir));
9875
+ if (String(fs2.realpathSync(expected)) !== join4(canonicalDir, `${previousRecord.runId}.result.md`)) throw new Error("Result escapes runs directory");
9876
+ if ((deps.platform ?? process.platform) !== "linux" || !fs2.fstatSync || !fs2.readSync || !fs2.closeSync || !nodeFs2.constants.O_NOFOLLOW || !nodeFs2.constants.O_DIRECTORY) throw new Error("FD proof unavailable");
9599
9877
  let dirFd;
9600
9878
  let resultFd;
9601
9879
  let text = "";
9602
9880
  try {
9603
- dirFd = fs.openSync(runsDir, nodeFs2.constants.O_RDONLY | nodeFs2.constants.O_DIRECTORY | nodeFs2.constants.O_NOFOLLOW);
9604
- if (!fs.fstatSync(dirFd).isDirectory() || String(fs.realpathSync(`/proc/self/fd/${dirFd}`)) !== canonicalDir) throw new Error("Unverified directory fd");
9605
- resultFd = fs.openSync(`/proc/self/fd/${dirFd}/${previousRecord.runId}.result.md`, nodeFs2.constants.O_RDONLY | nodeFs2.constants.O_NOFOLLOW | nodeFs2.constants.O_NONBLOCK);
9606
- if (!fs.fstatSync(resultFd).isFile() || String(fs.realpathSync(`/proc/self/fd/${resultFd}`)) !== join3(canonicalDir, `${previousRecord.runId}.result.md`)) throw new Error("Unverified result fd");
9881
+ dirFd = fs2.openSync(runsDir, nodeFs2.constants.O_RDONLY | nodeFs2.constants.O_DIRECTORY | nodeFs2.constants.O_NOFOLLOW);
9882
+ if (!fs2.fstatSync(dirFd).isDirectory() || String(fs2.realpathSync(`/proc/self/fd/${dirFd}`)) !== canonicalDir) throw new Error("Unverified directory fd");
9883
+ resultFd = fs2.openSync(`/proc/self/fd/${dirFd}/${previousRecord.runId}.result.md`, nodeFs2.constants.O_RDONLY | nodeFs2.constants.O_NOFOLLOW | nodeFs2.constants.O_NONBLOCK);
9884
+ if (!fs2.fstatSync(resultFd).isFile() || String(fs2.realpathSync(`/proc/self/fd/${resultFd}`)) !== join4(canonicalDir, `${previousRecord.runId}.result.md`)) throw new Error("Unverified result fd");
9607
9885
  const bytes = Buffer.alloc(16 * 1024);
9608
9886
  let offset = 0;
9609
9887
  while (offset < bytes.length) {
9610
- const count2 = fs.readSync(resultFd, bytes, offset, bytes.length - offset, offset);
9888
+ const count2 = fs2.readSync(resultFd, bytes, offset, bytes.length - offset, offset);
9611
9889
  if (count2 === 0) break;
9612
9890
  offset += count2;
9613
9891
  }
9614
9892
  text = bytes.subarray(0, offset).toString("utf8");
9615
9893
  } finally {
9616
9894
  try {
9617
- if (resultFd !== void 0) fs.closeSync(resultFd);
9895
+ if (resultFd !== void 0) fs2.closeSync(resultFd);
9618
9896
  } finally {
9619
- if (dirFd !== void 0) fs.closeSync(dirFd);
9897
+ if (dirFd !== void 0) fs2.closeSync(dirFd);
9620
9898
  }
9621
9899
  }
9622
9900
  const header = /^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/.exec(text)?.[1];
@@ -9637,13 +9915,14 @@ function createCliStartAgentRunExecutor(deps = {}) {
9637
9915
  } : {};
9638
9916
  const rawAgentKey = typeof args.agentKey === "string" ? args.agentKey.trim() : "";
9639
9917
  const agentKey = !rawAgentKey || rawAgentKey.toLowerCase() === "self" ? deps.currentAgentKey ?? rawAgentKey : rawAgentKey;
9918
+ const callerAgentKey = resolveHostCallerAgentKey(deps);
9640
9919
  const contextFacts = resolveRunContextFacts(continuedRecord ? typeof continuedRecord === "object" ? continuedRecord : {} : void 0, agentKey);
9641
9920
  const bindingMachineId = agentKey && deps.resolveAgentRuntimeBindingMachineId ? await deps.resolveAgentRuntimeBindingMachineId(agentKey) : void 0;
9642
9921
  const localMachineId = deps.resolveLocalMachineId ? await deps.resolveLocalMachineId() : void 0;
9643
9922
  let memoryPlacementNote;
9644
- let effectiveRuntimeKey = args.runtimeKey;
9923
+ let effectiveRuntimeKey = args.workspaceIsolation === "auto" && args.readOnly !== true && !args.runtimeKey?.trim() ? "local" : args.runtimeKey;
9645
9924
  const autoPlacement = await evaluateAutoInstaboxPlacement({
9646
- runtimeKey: args.runtimeKey,
9925
+ runtimeKey: effectiveRuntimeKey,
9647
9926
  cwd: args.cwd,
9648
9927
  readOnly: args.readOnly === true,
9649
9928
  env: deps.env,
@@ -9663,7 +9942,7 @@ function createCliStartAgentRunExecutor(deps = {}) {
9663
9942
  const dispatch = resolveCliLocalSpawnDispatch({
9664
9943
  runtimeKey: effectiveRuntimeKey,
9665
9944
  readOnly: args.readOnly === true,
9666
- // F1:runtimeKey=local 是「在宿主文件系统上改代码」,需要调用方的显式确认
9945
+ // F1:默认写型派发及 runtimeKey=local 是「在宿主文件系统上改代码」,需要调用方的显式确认
9667
9946
  // (allowHostWrites: true);缺失即派发前拒绝(零 spawn、零 run 记录)。
9668
9947
  allowHostWrites: args.allowHostWrites,
9669
9948
  // 政策第 5 条:显式宿主 cwd × 沙盒落点必须在派发前失败(沙盒不兑现宿主
@@ -9675,6 +9954,8 @@ function createCliStartAgentRunExecutor(deps = {}) {
9675
9954
  ...bindingMachineId ? { bindingMachineId } : {},
9676
9955
  ...localMachineId ? { localMachineId } : {}
9677
9956
  });
9957
+ if (args.workspaceIsolation !== void 0 && args.workspaceIsolation !== "none" && args.workspaceIsolation !== "auto") throw new Error("workspaceIsolation \u5FC5\u987B\u4E3A none \u6216 auto");
9958
+ if (args.workspaceIsolation === "auto" && args.readOnly !== true && dispatch.target !== "host") throw new Error("workspaceIsolation:auto \u53EA\u652F\u6301\u672C\u5730 CLI \u5BBF\u4E3B\u5199\u578B\u4EFB\u52A1\uFF0C\u6C99\u76D2\u4E0D\u80FD\u5151\u73B0\u5BBF\u4E3B\u76EE\u5F55\u9694\u79BB");
9678
9959
  const task = typeof args.task === "string" ? args.task.trim() : "";
9679
9960
  const runTitle = normalizeRunTitle(args.title);
9680
9961
  if (!agentKey) throw new Error(t("agentRunTool.missingAgentKey"));
@@ -9717,7 +9998,7 @@ function createCliStartAgentRunExecutor(deps = {}) {
9717
9998
  const manifest = typeof args.instaboxManifest === "string" ? args.instaboxManifest.trim() : "";
9718
9999
  if (workspace === "snapshot" && !manifest) throw new Error("instaboxWorkspace=snapshot \u5FC5\u987B\u63D0\u4F9B instaboxManifest");
9719
10000
  if (workspace === "empty" && args.instaboxManifest !== void 0) throw new Error("instaboxWorkspace=empty \u4E0D\u5F97\u63D0\u4F9B instaboxManifest");
9720
- const artifactDir = args.instaboxArtifactDir ?? join3(
10001
+ const artifactDir = args.instaboxArtifactDir ?? join4(
9721
10002
  resolveRunsDir(deps.env, deps.homedir),
9722
10003
  "instabox-artifacts",
9723
10004
  randomUUID3()
@@ -9733,6 +10014,12 @@ function createCliStartAgentRunExecutor(deps = {}) {
9733
10014
  if (args.instaboxAllowRemoteRelease === true) instaboxArgs.push("--instabox-allow-remote-release");
9734
10015
  if (args.instaboxAllowPaid === true) instaboxArgs.push("--instabox-allow-paid");
9735
10016
  }
10017
+ const dispatchReasoningEffort = await resolveRunDispatchReasoningEffort({
10018
+ deps,
10019
+ agentKey,
10020
+ difficulty: args.difficulty,
10021
+ model: selectedModel
10022
+ });
9736
10023
  const rawArgs = [
9737
10024
  "--agent",
9738
10025
  agentKey,
@@ -9745,11 +10032,12 @@ function createCliStartAgentRunExecutor(deps = {}) {
9745
10032
  ...args.ephemeral === true ? ["--ephemeral"] : [],
9746
10033
  // 只读角色安全收敛:审查类任务物理剥离写/改/删工具,遵循最小特权原则。
9747
10034
  ...isReadOnlyTask ? ["--read-only"] : [],
9748
- // 执行后端(默认 docker 沙盒;只读派发留宿主):唯一产出 `--runtime-key`
10035
+ // 执行后端(默认宿主;写型须确认,沙盒须显式指定):唯一产出 `--runtime-key`
9749
10036
  // 的地方,成对不变式在 buildCliLocalRuntimeForwardArgs 内机械断言。
9750
10037
  ...buildCliLocalRuntimeForwardArgs(dispatch),
9751
10038
  ...instaboxArgs,
9752
- ...imagePaths.flatMap((path) => ["--image", path])
10039
+ ...imagePaths.flatMap((path) => ["--image", path]),
10040
+ ...dispatchReasoningEffort ? ["--reasoning-effort", dispatchReasoningEffort] : []
9753
10041
  ];
9754
10042
  const agentName = await resolveAgentRunName(
9755
10043
  agentKey,
@@ -9770,44 +10058,65 @@ function createCliStartAgentRunExecutor(deps = {}) {
9770
10058
  });
9771
10059
  const dodCommands = Array.isArray(args.dodCommands) ? args.dodCommands.filter((c) => typeof c === "string" && c.trim().length > 0).map((c) => c.trim()) : typeof args.dod === "string" && args.dod.trim().length > 0 ? [args.dod.trim()] : Array.isArray(args.dod) ? args.dod.filter((c) => typeof c === "string" && c.trim().length > 0).map((c) => c.trim()) : void 0;
9772
10060
  const childPolicy = parseAgentRunArgs(rawArgs, { readTextFile: () => message });
9773
- const { runId, batchId: resolvedBatchId } = await spawnLocalBackgroundRun(
9774
- {
9775
- selectionCheck,
9776
- ...evidenceScope ? { evidenceScope } : {},
9777
- ...dispatchUserId ? { dispatchSpeedProvenance: {
9778
- version: 1,
9779
- source: "cli-startAgentRun",
9780
- userId: dispatchUserId
9781
- } } : {},
9782
- rawArgs,
9783
- commandPath: ["agent", "run"],
9784
- cliEntrypointPath: deps.cliEntrypoint,
9785
- agentKey,
9786
- ...agentName ? { agentName } : {},
9787
- ...runTitle ? { title: runTitle } : {},
9788
- ...batchId ? { batchId } : {},
9789
- ...credentialGroup ? { credentialGroup } : {},
9790
- ...parentDialogId ? { parentDialogId } : {},
9791
- // 续跑目标对话:spawn 时落盘,让"开着这条对话的 TUI"在 running 期间就能
9792
- // 看到另一边在跑(dock 按 dialogId 也能匹配到这条 run)。
9793
- ...continueDialogId ? { dialogId: continueDialogId } : {},
9794
- ...dodCommands && dodCommands.length > 0 ? { dodCommands } : {},
9795
- cwd: requestedCwd ?? deps.cwd ?? process.cwd(),
9796
- ...dispatch.runtimeKey === "local" && !isReadOnlyTask ? { claimLocalWrites: true } : {},
9797
- ...dispatch.target === "host" ? { localExecution: {
9798
- runtimeKey: "local",
9799
- hostWritesAuthorized: args.allowHostWrites === true,
9800
- readOnly: isReadOnlyTask,
9801
- ...childPolicy?.allowedToolNames ? { allowedToolNames: childPolicy.allowedToolNames } : {},
9802
- ...childPolicy?.blockedToolNames ? { blockedToolNames: childPolicy.blockedToolNames } : {},
9803
- provenance: "cli-tool-dispatch-authorized"
9804
- } } : {},
9805
- message,
9806
- ...args.ephemeral === true ? { ephemeral: true } : {},
9807
- output: noopOutput
9808
- },
9809
- { ...deps, shellApprovalHost: deps.shellApprovalHostForAgent ? await deps.shellApprovalHostForAgent(agentKey) : deps.shellApprovalHost }
9810
- );
10061
+ const isolationEnabled = args.workspaceIsolation === "auto" && !isReadOnlyTask;
10062
+ const isolationRunId = isolationEnabled ? (deps.generateRunId ?? defaultGenerateRunId)() : void 0;
10063
+ const baseCwd = requestedCwd ?? deps.cwd ?? process.cwd();
10064
+ const workspaceIsolation = isolationEnabled ? (deps.prepareIsolation ?? prepareWorkspaceIsolation)({
10065
+ baseCwd,
10066
+ runId: isolationRunId,
10067
+ mode: "auto",
10068
+ noloHome: dirname4(resolveRunsDir(deps.env, deps.homedir))
10069
+ }) : { mode: args.workspaceIsolation ?? "none", kind: "none", effectiveCwd: baseCwd };
10070
+ let spawned;
10071
+ try {
10072
+ spawned = await spawnLocalBackgroundRun(
10073
+ {
10074
+ selectionCheck,
10075
+ ...evidenceScope ? { evidenceScope } : {},
10076
+ ...dispatchUserId ? { dispatchSpeedProvenance: {
10077
+ version: 1,
10078
+ source: "cli-startAgentRun",
10079
+ userId: dispatchUserId
10080
+ } } : {},
10081
+ rawArgs,
10082
+ commandPath: ["agent", "run"],
10083
+ cliEntrypointPath: deps.cliEntrypoint,
10084
+ agentKey,
10085
+ ...agentName ? { agentName } : {},
10086
+ ...callerAgentKey ? { callerAgentKey } : {},
10087
+ ...runTitle ? { title: runTitle } : {},
10088
+ ...batchId ? { batchId } : {},
10089
+ ...credentialGroup ? { credentialGroup } : {},
10090
+ ...parentDialogId ? { parentDialogId } : {},
10091
+ // 续跑目标对话:spawn 时落盘,让"开着这条对话的 TUI"在 running 期间就能
10092
+ // 看到另一边在跑(dock 按 dialogId 也能匹配到这条 run)。
10093
+ ...continueDialogId ? { dialogId: continueDialogId } : {},
10094
+ ...dodCommands && dodCommands.length > 0 ? { dodCommands } : {},
10095
+ cwd: workspaceIsolation.effectiveCwd,
10096
+ ...dispatch.runtimeKey === "local" && !isReadOnlyTask ? { claimLocalWrites: true } : {},
10097
+ ...dispatch.target === "host" ? { localExecution: {
10098
+ runtimeKey: "local",
10099
+ hostWritesAuthorized: args.allowHostWrites === true,
10100
+ readOnly: isReadOnlyTask,
10101
+ ...childPolicy?.allowedToolNames ? { allowedToolNames: childPolicy.allowedToolNames } : {},
10102
+ ...childPolicy?.blockedToolNames ? { blockedToolNames: childPolicy.blockedToolNames } : {},
10103
+ provenance: "cli-tool-dispatch-authorized"
10104
+ } } : {},
10105
+ message,
10106
+ ...args.ephemeral === true ? { ephemeral: true } : {},
10107
+ output: noopOutput
10108
+ },
10109
+ { ...deps, ...isolationRunId !== void 0 ? { generateRunId: () => isolationRunId } : {}, mcpApprovalHost: deps.mcpApprovalHostForAgent ? await deps.mcpApprovalHostForAgent(agentKey) : deps.mcpApprovalHost, shellApprovalHost: deps.shellApprovalHostForAgent ? await deps.shellApprovalHostForAgent(agentKey) : deps.shellApprovalHost }
10110
+ );
10111
+ } catch (error) {
10112
+ try {
10113
+ if (isolationEnabled) (deps.rollbackIsolation ?? rollbackWorkspaceIsolation)(workspaceIsolation);
10114
+ } catch (cleanupError) {
10115
+ throw new AggregateError([error, cleanupError], `\u542F\u52A8\u5931\u8D25\uFF1B\u9694\u79BB\u76EE\u5F55\u4FDD\u7559\u5F85\u5904\u7406: ${workspaceIsolation.root}`);
10116
+ }
10117
+ throw error;
10118
+ }
10119
+ const { runId, batchId: resolvedBatchId } = spawned;
9811
10120
  const displayName = resolveRunLabel({ agentName, agentKey, runId });
9812
10121
  const labels = agentRunCardLabels();
9813
10122
  const taskPreview = typeof args.task === "string" ? args.task.replace(/\s+/g, " ").trim().slice(0, TASK_PREVIEW_MAX) : "";
@@ -9842,6 +10151,7 @@ function createCliStartAgentRunExecutor(deps = {}) {
9842
10151
  agentKey,
9843
10152
  status: "running",
9844
10153
  selectionCheck,
10154
+ ...args.workspaceIsolation !== void 0 ? { workspaceIsolation } : {},
9845
10155
  ...contextFacts,
9846
10156
  ...continuationEvidence,
9847
10157
  // batchId is always returned so the caller can later filter by it —
@@ -9866,6 +10176,28 @@ function createCliStartAgentRunExecutor(deps = {}) {
9866
10176
  };
9867
10177
  };
9868
10178
  }
10179
+ async function resolveRunDispatchReasoningEffort(args) {
10180
+ try {
10181
+ const profile = await args.deps.resolveAgentReasoningProfile?.(args.agentKey);
10182
+ if (!profile) return void 0;
10183
+ let model = args.model;
10184
+ if (!model) {
10185
+ try {
10186
+ model = await args.deps.resolveAgentModel?.(args.agentKey);
10187
+ } catch {
10188
+ model = void 0;
10189
+ }
10190
+ }
10191
+ return resolveDispatchReasoningEffort({
10192
+ difficulty: typeof args.difficulty === "string" ? args.difficulty : void 0,
10193
+ provider: profile.provider,
10194
+ model,
10195
+ agentReasoningEffort: profile.reasoningEffort
10196
+ });
10197
+ } catch {
10198
+ return void 0;
10199
+ }
10200
+ }
9869
10201
  function controlMessageLabels(queuedCount) {
9870
10202
  const labels = agentRunCardLabels().controlMessage;
9871
10203
  return { ...labels, queued: queuedCount === void 0 ? labels.queued : labels.enqueued(queuedCount) };
@@ -9877,6 +10209,12 @@ async function spawnContinuationRun(reconciled, message, userInput, deps) {
9877
10209
  const continuation = resolveLocalContinuation(reconciled, deps);
9878
10210
  const agentKey = reconciled.agentKey;
9879
10211
  const agentName = reconciled.agentName;
10212
+ const callerAgentKey = resolveHostCallerAgentKey(deps);
10213
+ const continuationReasoningEffort = await resolveRunDispatchReasoningEffort({
10214
+ deps,
10215
+ agentKey,
10216
+ difficulty: reconciled.selectionCheck?.difficulty
10217
+ });
9880
10218
  const rawArgs = [
9881
10219
  "--agent",
9882
10220
  agentKey,
@@ -9888,6 +10226,7 @@ async function spawnContinuationRun(reconciled, message, userInput, deps) {
9888
10226
  "PLACEHOLDER",
9889
10227
  "--bg",
9890
10228
  ...reconciled.ephemeral ? ["--ephemeral"] : [],
10229
+ ...continuationReasoningEffort ? ["--reasoning-effort", continuationReasoningEffort] : [],
9891
10230
  ...continuation.rawArgs
9892
10231
  ];
9893
10232
  const continuedFrom = reconciled.runId;
@@ -9899,11 +10238,15 @@ async function spawnContinuationRun(reconciled, message, userInput, deps) {
9899
10238
  cliEntrypointPath: deps.cliEntrypoint,
9900
10239
  agentKey,
9901
10240
  ...agentName ? { agentName } : {},
10241
+ ...callerAgentKey ? { callerAgentKey } : {},
9902
10242
  ...continuedTitle ? { title: continuedTitle } : {},
9903
10243
  ...reconciled.batchId ? { batchId: reconciled.batchId } : {},
9904
10244
  // 续跑也要在 running 阶段就带上目标对话,否则"开着那条对话的 TUI"看不到它。
9905
10245
  ...reconciled.dialogId ? { dialogId: reconciled.dialogId } : {},
9906
10246
  ...reconciled.parentDialogId ? { parentDialogId: reconciled.parentDialogId } : {},
10247
+ // 续跑继承原 run 的难度判定:不传的话第 2 次、第 N 次终态续跑都会丢掉
10248
+ // 原任务的 difficulty,自动联动推理档随之掉回 normal 档。
10249
+ ...reconciled.selectionCheck ? { selectionCheck: reconciled.selectionCheck } : {},
9907
10250
  // 续跑继承原 run 的凭证组(同一 agent),供并发扇出守卫判定。
9908
10251
  ...reconciled.credentialGroup ? { credentialGroup: reconciled.credentialGroup } : {},
9909
10252
  cwd: continuation.cwd,
@@ -9914,7 +10257,7 @@ async function spawnContinuationRun(reconciled, message, userInput, deps) {
9914
10257
  continuedFrom,
9915
10258
  output: noopOutput
9916
10259
  },
9917
- { ...deps, shellApprovalHost: deps.shellApprovalHostForAgent ? await deps.shellApprovalHostForAgent(agentKey) : deps.shellApprovalHost }
10260
+ { ...deps, mcpApprovalHost: deps.mcpApprovalHostForAgent ? await deps.mcpApprovalHostForAgent(agentKey) : deps.mcpApprovalHost, shellApprovalHost: deps.shellApprovalHostForAgent ? await deps.shellApprovalHostForAgent(agentKey) : deps.shellApprovalHost }
9918
10261
  );
9919
10262
  const taskPreview = userInput.replace(/\s+/g, " ").trim().slice(0, TASK_PREVIEW_MAX);
9920
10263
  return {
@@ -10122,7 +10465,7 @@ function createCliControlAgentRunExecutor(deps = {}) {
10122
10465
  };
10123
10466
  }
10124
10467
  if (action === "append") {
10125
- if (["runtimeKey", "allowHostWrites", "readOnly", "allowedToolNames", "blockedToolNames", "cwd"].some((key) => args[key] !== void 0)) {
10468
+ if (["runtimeKey", "allowHostWrites", "readOnly", "allowedToolNames", "blockedToolNames", "cwd", "workspaceIsolation"].some((key) => args[key] !== void 0)) {
10126
10469
  throw new Error("[local-continuation] scope overrides are not supported; dispatch a fresh authorized run");
10127
10470
  }
10128
10471
  const dialogKeyArg = typeof args.dialogKey === "string" ? args.dialogKey.trim() : "";
@@ -10162,8 +10505,8 @@ ${userInput}` : userInput;
10162
10505
  const afterCheck = checkStaleRun(reconciled2.runId, deps) ?? reconciled2;
10163
10506
  if (isAgentRunTerminalStatus(afterCheck.status)) {
10164
10507
  return await withQueueLock(queuePath, deps, async () => {
10165
- const fs = deps.fs ?? nodeFs2;
10166
- const remainingEntries = _readQueueEntriesLocked(queuePath, fs);
10508
+ const fs2 = deps.fs ?? nodeFs2;
10509
+ const remainingEntries = _readQueueEntriesLocked(queuePath, fs2);
10167
10510
  const ourEntryFound = remainingEntries.some((e) => e.id === entryId);
10168
10511
  if (!ourEntryFound) {
10169
10512
  return {
@@ -10193,11 +10536,11 @@ ${userInput}` : userInput;
10193
10536
  ${entry.text}`).join("\n\n");
10194
10537
  const result = await spawnContinuationRun(afterCheck, mergedMessage, userInput, deps);
10195
10538
  const transferred = new Set(remainingEntries.map((entry) => entry.id));
10196
- const current = _readQueueEntriesLocked(queuePath, fs);
10197
- if (typeof fs.renameSync !== "function") throw new Error("atomic queue replacement requires renameSync");
10539
+ const current = _readQueueEntriesLocked(queuePath, fs2);
10540
+ if (typeof fs2.renameSync !== "function") throw new Error("atomic queue replacement requires renameSync");
10198
10541
  const pendingQueue = `${queuePath}.${randomUUID3()}.tmp`;
10199
- fs.writeFileSync(pendingQueue, serializeQueueEntries(current.filter((entry) => !transferred.has(entry.id))), { encoding: "utf8", flag: "wx" });
10200
- fs.renameSync(pendingQueue, queuePath);
10542
+ fs2.writeFileSync(pendingQueue, serializeQueueEntries(current.filter((entry) => !transferred.has(entry.id))), { encoding: "utf8", flag: "wx" });
10543
+ fs2.renameSync(pendingQueue, queuePath);
10201
10544
  return result;
10202
10545
  });
10203
10546
  }
@@ -10348,11 +10691,21 @@ function buildCliChromeConnectorToolExecutors(args) {
10348
10691
  return Object.fromEntries(
10349
10692
  CHROME_CONNECTOR_ACCEPTED_TOOL_NAMES.map((toolName) => [
10350
10693
  toolName,
10351
- (call) => {
10694
+ (call, options) => {
10352
10695
  const target = approvalTargetForCall(call);
10353
10696
  const connector = createConnectorApprovalPort(() => clientForTarget(target));
10354
10697
  return runConnectorToolWithHostApproval({
10355
10698
  call,
10699
+ signal: options?.abortSignal,
10700
+ // Foreground TUI turns have dialogId/turnId, not a persisted runId.
10701
+ // Preserve runId only when supplied by a real host owner; never mint
10702
+ // one from call.id or turnId (neither identifies a background run).
10703
+ context: {
10704
+ requestId: call.id,
10705
+ dialogId: call.runtimeContext?.dialogId,
10706
+ turnId: call.runtimeContext?.turnId,
10707
+ runId: call.runtimeContext?.runId
10708
+ },
10356
10709
  execute: (nextCall) => executeChromeConnectorTool({ clientForTarget, call: nextCall }),
10357
10710
  connector,
10358
10711
  // Read the registry per call so a TUI that installs its renderer after the table is
@@ -10480,15 +10833,24 @@ function pickAgentRunResolverDeps(args) {
10480
10833
  ...args.resolveAgentModel ? { resolveAgentModel: args.resolveAgentModel } : {},
10481
10834
  ...args.resolveAgentDisplayName ? { resolveAgentDisplayName: args.resolveAgentDisplayName } : {},
10482
10835
  ...args.resolveAgentRuntimeBindingMachineId ? { resolveAgentRuntimeBindingMachineId: args.resolveAgentRuntimeBindingMachineId } : {},
10483
- ...args.resolveLocalMachineId ? { resolveLocalMachineId: args.resolveLocalMachineId } : {}
10836
+ ...args.resolveLocalMachineId ? { resolveLocalMachineId: args.resolveLocalMachineId } : {},
10837
+ ...args.resolveAgentReasoningProfile ? { resolveAgentReasoningProfile: args.resolveAgentReasoningProfile } : {}
10484
10838
  };
10485
10839
  }
10486
10840
  function buildCliWorkspaceToolExecutors(args) {
10841
+ const resolveDialogStore = args.resolveDialogStore;
10487
10842
  return buildNoloWorkspaceCliToolExecutors({
10488
10843
  cliEntrypoint: args.cliEntrypoint ?? process.argv[1] ?? "",
10489
10844
  env: args.env,
10490
10845
  metadataKind: "cliWorkspaceTool",
10491
- planningCaller: args.planningCaller
10846
+ planningCaller: args.planningCaller,
10847
+ // 只放开 readDialog(本机独占对话)的进程内直读;listDialogs 一律保持
10848
+ // 权威跨端合并路径——本地库只是缓存,抢答会静默漏掉 Web/手机端新对话。
10849
+ ...resolveDialogStore ? {
10850
+ resolveDialogStore,
10851
+ resolveCurrentUserId: () => resolveLocalUserId(args.env),
10852
+ resolveLocalChildDialogIds: args.resolveLocalChildDialogIds ?? (() => loadLocalRunChildDialogIds({ env: args.env }))
10853
+ } : {}
10492
10854
  });
10493
10855
  }
10494
10856
  function buildLocalToolExecutors(args) {
@@ -10514,7 +10876,9 @@ function buildLocalToolExecutors(args) {
10514
10876
  ...buildCliWorkspaceToolExecutors({
10515
10877
  planningCaller: args.planningCaller,
10516
10878
  env: args.env,
10517
- cliEntrypoint: args.cliEntrypoint
10879
+ cliEntrypoint: args.cliEntrypoint,
10880
+ ...args.resolveDialogStore ? { resolveDialogStore: args.resolveDialogStore } : {},
10881
+ ...args.resolveLocalChildDialogIds ? { resolveLocalChildDialogIds: args.resolveLocalChildDialogIds } : {}
10518
10882
  }),
10519
10883
  // loadSkill resolves SKILL.md from the agent's workspace root (local-fs,
10520
10884
  // no `nolo` CLI subcommand), so it is wired here instead of inside
@@ -10662,6 +11026,7 @@ function buildLocalToolExecutors(args) {
10662
11026
  // (复用 ~/.nolo/runs/ 注册表,MED-1 修复)。
10663
11027
  startAgentRun: createCliStartAgentRunExecutor({
10664
11028
  shellApprovalHostForAgent: args.shellApprovalHostForAgent,
11029
+ mcpApprovalHostForAgent: args.mcpApprovalHostForAgent,
10665
11030
  ...pickAgentRunResolverDeps(args),
10666
11031
  // α:展示名回读器——resolveAgentRunName 的读取来源(显式 agentName 优先,绝不覆盖)。
10667
11032
  resolveAgentName: args.resolveAgentName,
@@ -10672,7 +11037,13 @@ function buildLocalToolExecutors(args) {
10672
11037
  }),
10673
11038
  controlAgentRun: createCliControlAgentRunExecutor({
10674
11039
  source: { parentDialogId: args.sourceParentDialogId, agentKey: args.agentKey },
11040
+ // 终态续跑(append)要按原 run 的 difficulty 重新算档,因此与 startAgentRun
11041
+ // 共用同一套可信解析器:漏转发会让续跑静默掉回记录默认档。
11042
+ ...pickAgentRunResolverDeps(args),
11043
+ // 派发者身份同样只由宿主注入(controlAgentRun 触发的续跑也要落 callerAgentKey)。
11044
+ currentAgentKey: args.agentKey,
10675
11045
  shellApprovalHostForAgent: args.shellApprovalHostForAgent,
11046
+ mcpApprovalHostForAgent: args.mcpApprovalHostForAgent,
10676
11047
  cwd: args.workspaceRoot,
10677
11048
  cliEntrypoint: args.cliEntrypoint,
10678
11049
  env: args.env
@@ -10681,14 +11052,15 @@ function buildLocalToolExecutors(args) {
10681
11052
  // Nolo Browser Connector: the CLI drives the user's real Chrome through the same verified
10682
11053
  // client + executor as the desktop runtime (before this, every chrome_* call answered
10683
11054
  // "only executable in the Nolo desktop local runtime").
10684
- ...buildCliChromeConnectorToolExecutors(
10685
- args.chromeConnectorClient ? { client: args.chromeConnectorClient } : {}
10686
- ),
11055
+ ...buildCliChromeConnectorToolExecutors({
11056
+ ...args.chromeConnectorClient ? { client: args.chromeConnectorClient } : {},
11057
+ ...args.hostApprovalRenderer ? { awaitHostApproval: args.hostApprovalRenderer } : {}
11058
+ }),
10687
11059
  ...args.localToolExecutors ?? {}
10688
11060
  };
10689
11061
  const execShell = executors.execShell;
10690
11062
  const lifecycle = (run, signal) => withBrowserShellApproval({
10691
- requestUserChoice: args.requestUserChoice,
11063
+ awaitHostApproval: args.hostApprovalRenderer,
10692
11064
  client: args.chromeConnectorClient,
10693
11065
  signal
10694
11066
  }, run);
@@ -10853,8 +11225,8 @@ function createOAuthApiKeyRefResolver(options = {}) {
10853
11225
  }
10854
11226
 
10855
11227
  // packages/agent-runtime/localSandboxWorkload.ts
10856
- import { existsSync as existsSync4 } from "node:fs";
10857
- import { resolve as resolve5 } from "node:path";
11228
+ import { existsSync as existsSync5 } from "node:fs";
11229
+ import { resolve as resolve6 } from "node:path";
10858
11230
 
10859
11231
  // packages/agent-runtime/executionChannel.ts
10860
11232
  var EXECUTION_SHELL_TOOL = "execShell";
@@ -10940,12 +11312,12 @@ import {
10940
11312
  openSync,
10941
11313
  readlinkSync,
10942
11314
  rmdirSync,
10943
- unlinkSync,
11315
+ unlinkSync as unlinkSync2,
10944
11316
  writeSync
10945
11317
  } from "node:fs";
10946
11318
  import { access } from "node:fs/promises";
10947
11319
  import { tmpdir } from "node:os";
10948
- import { isAbsolute as isAbsolute4, join as join4, relative, resolve as resolve4 } from "node:path";
11320
+ import { isAbsolute as isAbsolute5, join as join5, relative as relative2, resolve as resolve5 } from "node:path";
10949
11321
 
10950
11322
  // packages/agent-runtime/linuxSandboxSeccomp.ts
10951
11323
  var AUDIT_ARCH_X86_64 = 3221225534;
@@ -11038,14 +11410,14 @@ var MAX_OUTPUT_BYTES = 1024 * 1024;
11038
11410
  var PSEUDO_FS = ["/proc", "/sys", "/dev", "/run"];
11039
11411
  var SANDBOX_MOUNTS = ["/", "/usr", "/bin", "/lib", "/lib64", "/tmp"];
11040
11412
  var inside = (parent, child) => {
11041
- const rel = relative(parent, child);
11042
- return rel === "" || rel !== ".." && !rel.startsWith("../") && !isAbsolute4(rel);
11413
+ const rel = relative2(parent, child);
11414
+ return rel === "" || rel !== ".." && !rel.startsWith("../") && !isAbsolute5(rel);
11043
11415
  };
11044
11416
  function openRootHandle(path) {
11045
- if (typeof path !== "string" || !isAbsolute4(path) || path.includes("\0")) {
11417
+ if (typeof path !== "string" || !isAbsolute5(path) || path.includes("\0")) {
11046
11418
  throw new Error("Sandbox root must be absolute");
11047
11419
  }
11048
- const expected = resolve4(path);
11420
+ const expected = resolve5(path);
11049
11421
  if (SANDBOX_MOUNTS.includes(expected) || PSEUDO_FS.some((reserved) => inside(reserved, expected))) {
11050
11422
  throw new Error("Sandbox root overlaps a reserved sandbox/pseudo filesystem path");
11051
11423
  }
@@ -11069,8 +11441,8 @@ function openRootHandle(path) {
11069
11441
  }
11070
11442
  var SECCOMP_TEMP_DIR_PREFIX = "nolo-bwrap-seccomp-";
11071
11443
  function openSeccompFd(program) {
11072
- const dir = mkdtempSync(join4(tmpdir(), SECCOMP_TEMP_DIR_PREFIX));
11073
- const file = join4(dir, "filter.bpf");
11444
+ const dir = mkdtempSync(join5(tmpdir(), SECCOMP_TEMP_DIR_PREFIX));
11445
+ const file = join5(dir, "filter.bpf");
11074
11446
  let writer = -1;
11075
11447
  let reader = -1;
11076
11448
  try {
@@ -11089,7 +11461,7 @@ function openSeccompFd(program) {
11089
11461
  } finally {
11090
11462
  if (writer >= 0) closeSync(writer);
11091
11463
  try {
11092
- unlinkSync(file);
11464
+ unlinkSync2(file);
11093
11465
  } catch {
11094
11466
  }
11095
11467
  try {
@@ -11228,7 +11600,7 @@ var LinuxBubblewrapBackend = class {
11228
11600
  if (request.timeoutMs !== void 0 && (!Number.isFinite(request.timeoutMs) || request.timeoutMs <= 0)) {
11229
11601
  throw new Error("Sandbox timeout must be finite and positive");
11230
11602
  }
11231
- if (request.cwd && !active.writable.some(({ path: root }) => isAbsolute4(request.cwd) && inside(root, resolve4(request.cwd)))) {
11603
+ if (request.cwd && !active.writable.some(({ path: root }) => isAbsolute5(request.cwd) && inside(root, resolve5(request.cwd)))) {
11232
11604
  throw new Error("Command cwd outside writable sandbox roots");
11233
11605
  }
11234
11606
  if (!validateConfiguredRootExecutionLease(active.ticket, active.lease)) {
@@ -11385,7 +11757,7 @@ async function createLocalSandboxWorkload(args) {
11385
11757
  const envRoots = typeof env.NOLO_LOCAL_SANDBOX_ROOTS === "string" ? env.NOLO_LOCAL_SANDBOX_ROOTS.split(":").map((entry) => entry.trim()) : [];
11386
11758
  const readableRoots = normalizeRoots(
11387
11759
  args.readableRoots && args.readableRoots.length > 0 ? args.readableRoots : [...DEFAULT_SANDBOX_READABLE_ROOTS, ...envRoots]
11388
- ).filter((root) => !FORBIDDEN_EXTRA_ROOTS.has(resolve5(root)));
11760
+ ).filter((root) => !FORBIDDEN_EXTRA_ROOTS.has(resolve6(root)));
11389
11761
  const backend = args.backend ?? new LinuxBubblewrapBackend();
11390
11762
  const ticket = {
11391
11763
  version: 1,
@@ -11433,7 +11805,7 @@ async function createLocalSandboxWorkload(args) {
11433
11805
  if (canonicalToolName(toolName) !== EXECUTION_SHELL_TOOL) return null;
11434
11806
  const callArgs = toolArgs ?? {};
11435
11807
  const command = typeof callArgs.command === "string" ? callArgs.command : "";
11436
- const mountedBins = readableRoots.map((root) => `${root}/bin`).filter((dir) => existsSync4(dir));
11808
+ const mountedBins = readableRoots.map((root) => `${root}/bin`).filter((dir) => existsSync5(dir));
11437
11809
  const sandboxPath = [
11438
11810
  ...mountedBins,
11439
11811
  process.env.PATH ?? "/usr/local/bin:/usr/bin:/bin"
@@ -11863,12 +12235,12 @@ async function executeWorkspaceDelivery(plan, runtime, deps = {}) {
11863
12235
  }
11864
12236
  const tmpDir = deps.tmpDir ?? (await import("node:os")).tmpdir();
11865
12237
  const writeTempFile = deps.writeTempFile ?? (async (filePath, content) => {
11866
- const fs = await import("node:fs/promises");
11867
- await fs.writeFile(filePath, content, "utf8");
12238
+ const fs2 = await import("node:fs/promises");
12239
+ await fs2.writeFile(filePath, content, "utf8");
11868
12240
  });
11869
12241
  const removeTempFile = deps.removeTempFile ?? (async (filePath) => {
11870
- const fs = await import("node:fs/promises");
11871
- await fs.rm(filePath, { force: true });
12242
+ const fs2 = await import("node:fs/promises");
12243
+ await fs2.rm(filePath, { force: true });
11872
12244
  });
11873
12245
  let hostBaselineTemp = null;
11874
12246
  if (plan.baselineUpload) {
@@ -11968,10 +12340,10 @@ async function applyDockerWorkspaceDelivery(runtime, selection) {
11968
12340
 
11969
12341
  // packages/cli/client/localWorkspaceArchive.ts
11970
12342
  import { spawnSync } from "node:child_process";
11971
- import { mkdtempSync as mkdtempSync2, statSync as statSync2, writeFileSync as writeFileSync2 } from "node:fs";
12343
+ import { mkdtempSync as mkdtempSync2, statSync as statSync3, writeFileSync as writeFileSync2 } from "node:fs";
11972
12344
  import { rm } from "node:fs/promises";
11973
12345
  import { tmpdir as tmpdir2 } from "node:os";
11974
- import { join as join5 } from "node:path";
12346
+ import { join as join6 } from "node:path";
11975
12347
  var runHostCommand = (argv, { cwd }) => {
11976
12348
  const result = spawnSync(argv[0], argv.slice(1), {
11977
12349
  cwd,
@@ -12031,11 +12403,11 @@ function prepareHostWorkspaceDelivery(args) {
12031
12403
  `\u5DE5\u4F5C\u533A\u6587\u4EF6\u6570 ${tracked.length} \u8D85\u8FC7\u4E0A\u9650 ${MAX_DELIVERY_FILE_COUNT}\uFF1A\u7591\u4F3C\u628A node_modules / \u6784\u5EFA\u4EA7\u7269\u6253\u8FDB\u4E86\u5F52\u6863\uFF08\u5F52\u6863\u53EA\u53D6 git ls-files\uFF09\u3002`
12032
12404
  );
12033
12405
  }
12034
- const stagingDir = mkdtempSync2(join5(args.tmpDir ?? tmpdir2(), "nolo-workspace-delivery-"));
12406
+ const stagingDir = mkdtempSync2(join6(args.tmpDir ?? tmpdir2(), "nolo-workspace-delivery-"));
12035
12407
  const stamp = `${process.pid}-${Date.now()}`;
12036
- const archivePath = join5(stagingDir, `workspace-${stamp}.tar.gz`);
12037
- const bundlePath = join5(stagingDir, `workspace-${stamp}.bundle`);
12038
- const listPath = join5(stagingDir, `filelist-${stamp}.z`);
12408
+ const archivePath = join6(stagingDir, `workspace-${stamp}.tar.gz`);
12409
+ const bundlePath = join6(stagingDir, `workspace-${stamp}.bundle`);
12410
+ const listPath = join6(stagingDir, `filelist-${stamp}.z`);
12039
12411
  const removeFile = args.removeFile ?? (async (filePath) => {
12040
12412
  await rm(filePath, { force: true });
12041
12413
  });
@@ -12116,7 +12488,7 @@ function prepareHostWorkspaceDelivery(args) {
12116
12488
  }
12117
12489
  let archiveSizeBytes = 0;
12118
12490
  try {
12119
- archiveSizeBytes = statSync2(archivePath).size;
12491
+ archiveSizeBytes = statSync3(archivePath).size;
12120
12492
  } catch (error) {
12121
12493
  return fail3(
12122
12494
  "host_workspace_archive_failed",
@@ -12176,7 +12548,7 @@ function buildHostBundle(args) {
12176
12548
  }
12177
12549
  let sizeBytes = 0;
12178
12550
  try {
12179
- sizeBytes = statSync2(args.bundlePath).size;
12551
+ sizeBytes = statSync3(args.bundlePath).size;
12180
12552
  } catch (error) {
12181
12553
  return {
12182
12554
  ok: false,
@@ -12279,8 +12651,8 @@ async function createLocalDockerWorkload(args) {
12279
12651
  }
12280
12652
  const createLifecycle = args.createLifecycle ?? (async () => {
12281
12653
  const [{ DockerWorkloadLifecycle, createDockerBindingAuthorizer }, accounts] = await Promise.all([
12282
- import("./workloadLifecycle-HFJIN5IZ.js"),
12283
- import("./accountResolver-QETKNC7T.js")
12654
+ import("./workloadLifecycle-P2SJVV3S.js"),
12655
+ import("./accountResolver-NGICIMEE.js")
12284
12656
  ]);
12285
12657
  const resolveAccount = args.resolveAccount ?? accounts.createDockerAccountResolver({
12286
12658
  env: args.env,
@@ -12375,28 +12747,28 @@ async function createLocalDockerWorkload(args) {
12375
12747
  };
12376
12748
  let rejectReady = () => {
12377
12749
  };
12378
- const ready = new Promise((resolve7, reject) => {
12379
- resolveReady = resolve7;
12750
+ const ready = new Promise((resolve8, reject) => {
12751
+ resolveReady = resolve8;
12380
12752
  rejectReady = reject;
12381
12753
  });
12382
12754
  let releaseRun = () => {
12383
12755
  };
12384
- const releaseGate = new Promise((resolve7) => {
12385
- releaseRun = resolve7;
12756
+ const releaseGate = new Promise((resolve8) => {
12757
+ releaseRun = resolve8;
12386
12758
  });
12387
12759
  const waitForReleaseOrAbort = () => {
12388
12760
  const signal = args.signal;
12389
12761
  if (!signal) return releaseGate;
12390
12762
  if (signal.aborted) return Promise.resolve();
12391
- return new Promise((resolve7) => {
12763
+ return new Promise((resolve8) => {
12392
12764
  const onAbort = () => {
12393
12765
  signal.removeEventListener("abort", onAbort);
12394
- resolve7();
12766
+ resolve8();
12395
12767
  };
12396
12768
  signal.addEventListener("abort", onAbort, { once: true });
12397
12769
  void releaseGate.then(() => {
12398
12770
  signal.removeEventListener("abort", onAbort);
12399
- resolve7();
12771
+ resolve8();
12400
12772
  });
12401
12773
  });
12402
12774
  };
@@ -12890,12 +13262,12 @@ function describeInstaboxBridgeUnavailable(bridge) {
12890
13262
  // packages/cli/client/localInstaboxWorkspaceRecovery.ts
12891
13263
  import { constants as constants3 } from "node:fs";
12892
13264
  import { open as open2 } from "node:fs/promises";
12893
- import { createHash as createHash5, randomUUID as randomUUID4 } from "node:crypto";
13265
+ import { createHash as createHash6, randomUUID as randomUUID4 } from "node:crypto";
12894
13266
 
12895
13267
  // packages/agent-runtime/artifactStore.ts
12896
- import { createHash as createHash4, createHmac } from "node:crypto";
13268
+ import { createHash as createHash5, createHmac } from "node:crypto";
12897
13269
  import { mkdir, readFile, unlink, writeFile } from "node:fs/promises";
12898
- import { dirname as dirname3, resolve as resolve6, sep } from "node:path";
13270
+ import { dirname as dirname5, resolve as resolve7, sep as sep2 } from "node:path";
12899
13271
  var ArtifactStoreError = class extends Error {
12900
13272
  code;
12901
13273
  key;
@@ -12945,12 +13317,12 @@ function isNotFoundError(error) {
12945
13317
  return error?.code === "ENOENT";
12946
13318
  }
12947
13319
  function createLocalArtifactStore(options) {
12948
- const root = resolve6(options.rootDir);
13320
+ const root = resolve7(options.rootDir);
12949
13321
  const now = options.now ?? Date.now;
12950
13322
  const pathFor = (key) => {
12951
13323
  assertArtifactKey(key);
12952
- const target = resolve6(root, key);
12953
- if (target !== root && !target.startsWith(`${root}${sep}`)) {
13324
+ const target = resolve7(root, key);
13325
+ if (target !== root && !target.startsWith(`${root}${sep2}`)) {
12954
13326
  throw new ArtifactStoreError(
12955
13327
  "invalid_key",
12956
13328
  `artifact key \u89E3\u6790\u540E\u8D8A\u51FA rootDir\uFF1A${describeKey(key)}`,
@@ -12964,7 +13336,7 @@ function createLocalArtifactStore(options) {
12964
13336
  const bytes = toBytes(data);
12965
13337
  const target = pathFor(key);
12966
13338
  try {
12967
- await mkdir(dirname3(target), { recursive: true });
13339
+ await mkdir(dirname5(target), { recursive: true });
12968
13340
  await writeFile(target, bytes);
12969
13341
  } catch (error) {
12970
13342
  if (error instanceof ArtifactStoreError) throw error;
@@ -13020,12 +13392,12 @@ function createLocalArtifactStore(options) {
13020
13392
  };
13021
13393
  }
13022
13394
  function sha256Hex2(data) {
13023
- return createHash4("sha256").update(data).digest("hex");
13395
+ return createHash5("sha256").update(data).digest("hex");
13024
13396
  }
13025
13397
  var EMPTY_SHA256 = sha256Hex2("");
13026
13398
 
13027
13399
  // packages/cli/client/localInstaboxWorkspaceRecovery.ts
13028
- var sha = (b) => createHash5("sha256").update(b).digest("hex");
13400
+ var sha = (b) => createHash6("sha256").update(b).digest("hex");
13029
13401
  function fail4(code) {
13030
13402
  throw Object.assign(new Error(`instabox_workspace_recovery:${code}; cleanup_pending`), { code: "instabox_cleanup_pending", cleanupPending: true });
13031
13403
  }
@@ -13530,8 +13902,8 @@ async function createLocalInstaboxWorkload(args) {
13530
13902
  }
13531
13903
 
13532
13904
  // packages/cli/client/localRunArtifactExport.ts
13533
- import { mkdirSync as mkdirSync2, writeFileSync as writeFileSync3 } from "node:fs";
13534
- import { dirname as dirname4, join as join6 } from "node:path";
13905
+ import { mkdirSync as mkdirSync3, writeFileSync as writeFileSync3 } from "node:fs";
13906
+ import { dirname as dirname6, join as join7 } from "node:path";
13535
13907
 
13536
13908
  // packages/agent-runtime/runArtifactExport.ts
13537
13909
  var RUN_DIFF_COMMAND = "git add -A && git diff --cached --binary";
@@ -13739,13 +14111,13 @@ function serializeRunArtifactAudit(record) {
13739
14111
  // packages/cli/client/localRunArtifactExport.ts
13740
14112
  function resolveRunArtifactsRootDir(runsDir) {
13741
14113
  const normalized = runsDir.replace(/[/\\]+$/, "");
13742
- return join6(dirname4(normalized || runsDir), "artifacts");
14114
+ return join7(dirname6(normalized || runsDir), "artifacts");
13743
14115
  }
13744
14116
  function writeRunArtifactAudit(args) {
13745
- const fs = args.fs ?? { mkdirSync: mkdirSync2, writeFileSync: writeFileSync3 };
13746
- const path = join6(args.runsDir, `${args.record.runId}.artifacts.json`);
13747
- fs.mkdirSync?.(args.runsDir, { recursive: true });
13748
- fs.writeFileSync(path, serializeRunArtifactAudit(args.record));
14117
+ const fs2 = args.fs ?? { mkdirSync: mkdirSync3, writeFileSync: writeFileSync3 };
14118
+ const path = join7(args.runsDir, `${args.record.runId}.artifacts.json`);
14119
+ fs2.mkdirSync?.(args.runsDir, { recursive: true });
14120
+ fs2.writeFileSync(path, serializeRunArtifactAudit(args.record));
13749
14121
  return path;
13750
14122
  }
13751
14123
  function createDockerRunTerminalExport(args) {
@@ -14095,9 +14467,9 @@ function buildTokenDialogIndexOps(args) {
14095
14467
 
14096
14468
  // packages/cli/client/localRuntimeDialog.ts
14097
14469
  var import_format = __toESM(require_format(), 1);
14098
- import { appendFileSync, mkdirSync as mkdirSync3 } from "fs";
14099
- import { homedir } from "os";
14100
- import { join as join7 } from "path";
14470
+ import { appendFileSync, mkdirSync as mkdirSync4 } from "fs";
14471
+ import { homedir as homedir2 } from "os";
14472
+ import { join as join8 } from "path";
14101
14473
 
14102
14474
  // packages/cli/client/cliCompletedTurnCapture.ts
14103
14475
  async function readCliCaptureSources(args) {
@@ -14217,11 +14589,11 @@ function projectRawUsage(usage) {
14217
14589
  function debugCaptureRawUsage(item) {
14218
14590
  if (!process.env.NOLO_DEBUG_RAW_USAGE) return;
14219
14591
  try {
14220
- const noloHome = process.env.NOLO_HOME?.trim() || join7(homedir(), ".nolo");
14221
- const dir = join7(noloHome, "logs");
14222
- mkdirSync3(dir, { recursive: true });
14592
+ const noloHome = process.env.NOLO_HOME?.trim() || join8(homedir2(), ".nolo");
14593
+ const dir = join8(noloHome, "logs");
14594
+ mkdirSync4(dir, { recursive: true });
14223
14595
  appendFileSync(
14224
- join7(dir, "raw-usage.jsonl"),
14596
+ join8(dir, "raw-usage.jsonl"),
14225
14597
  JSON.stringify({
14226
14598
  ts: Date.now(),
14227
14599
  model: item.model,
@@ -14464,14 +14836,26 @@ async function writeDialog(args) {
14464
14836
  existingDialog,
14465
14837
  cwd: args.cwd
14466
14838
  });
14467
- for (const id of plan.captureUserMessageIds) {
14468
- const op = plan.ops.find((op2) => op2.value.id === id && op2.value.role === "user");
14469
- const existing = await args.store.read(op.key, { remote: false });
14470
- if (existing) {
14471
- if (existing.id !== id || existing.dialogId !== plan.dialogId || existing.userId !== args.userId || existing.role !== "user" || JSON.stringify(existing.content) !== JSON.stringify(op.value.content)) {
14472
- throw new Error("CLI persisted turn source conflict");
14839
+ const prefetchedUserMessages = /* @__PURE__ */ new Map();
14840
+ if (plan.captureUserMessageIds.length > 0) {
14841
+ const captureEntries = plan.captureUserMessageIds.map((id) => ({
14842
+ id,
14843
+ op: plan.ops.find((op) => op.value.id === id && op.value.role === "user")
14844
+ }));
14845
+ const uniqueKeys = [...new Set(captureEntries.map((entry) => entry.op.key))];
14846
+ const readResults = await Promise.all(
14847
+ uniqueKeys.map(async (key) => [key, await args.store.read(key, { remote: false })])
14848
+ );
14849
+ const existingByKey = new Map(readResults);
14850
+ for (const { id, op } of captureEntries) {
14851
+ const existing = existingByKey.get(op.key);
14852
+ if (existing) {
14853
+ if (existing.id !== id || existing.dialogId !== plan.dialogId || existing.userId !== args.userId || existing.role !== "user" || JSON.stringify(existing.content) !== JSON.stringify(op.value.content)) {
14854
+ throw new Error("CLI persisted turn source conflict");
14855
+ }
14856
+ op.value = existing;
14473
14857
  }
14474
- op.value = existing;
14858
+ prefetchedUserMessages.set(op.key, op.value);
14475
14859
  }
14476
14860
  }
14477
14861
  const lastInputTokens = extractLastProviderInputTokens(args.input) ?? (typeof existingDialog?.lastInputTokens === "number" && Number.isFinite(existingDialog.lastInputTokens) && existingDialog.lastInputTokens > 0 ? existingDialog.lastInputTokens : void 0);
@@ -14491,9 +14875,12 @@ async function writeDialog(args) {
14491
14875
  source: "cli-local"
14492
14876
  });
14493
14877
  if (args.cliBatchCompletion) {
14494
- for (const batchId of args.cliBatchCompletion.batchIds) {
14495
- plan.ops.push(await buildCliBatchCompletionOp(args.store, plan.dialogId, batchId));
14496
- }
14878
+ const completionOps = await Promise.all(
14879
+ args.cliBatchCompletion.batchIds.map(
14880
+ (batchId) => buildCliBatchCompletionOp(args.store, plan.dialogId, batchId)
14881
+ )
14882
+ );
14883
+ plan.ops.push(...completionOps);
14497
14884
  }
14498
14885
  await args.store.batch(plan.ops);
14499
14886
  if (__perfEnabled) {
@@ -14534,7 +14921,7 @@ async function writeDialog(args) {
14534
14921
  dialogId: plan.dialogId,
14535
14922
  userId: args.userId,
14536
14923
  persistedUserMessageIds: plan.captureUserMessageIds,
14537
- read: (key) => args.store.read(key, { remote: false })
14924
+ read: (key) => prefetchedUserMessages.has(key) ? Promise.resolve(prefetchedUserMessages.get(key)) : args.store.read(key, { remote: false })
14538
14925
  }).catch(() => []);
14539
14926
  const syncAndCapture = async (fetchImpl) => {
14540
14927
  try {
@@ -14619,12 +15006,14 @@ async function loadCliDialogSummary(args) {
14619
15006
  const sourceHash = record.sourceHash;
14620
15007
  const sourceCount = record.sourceCount;
14621
15008
  const schemaVersion = record.schemaVersion;
15009
+ const sourceSegments = sanitizeSummarySourceSegments(record.sourceSegments);
14622
15010
  return {
14623
15011
  summary,
14624
15012
  ...typeof summarizedBeforeId === "string" && summarizedBeforeId ? { summarizedBeforeId } : {},
14625
15013
  ...typeof sourceHash === "string" && sourceHash ? { sourceHash } : {},
14626
15014
  ...typeof sourceCount === "number" && sourceCount > 0 ? { sourceCount } : {},
14627
15015
  ..."schemaVersion" in record ? { schemaVersion } : {},
15016
+ ...sourceSegments ? { sourceSegments } : {},
14628
15017
  ...Array.isArray(record.referenceKeys) ? { referenceKeys: record.referenceKeys.filter((key) => typeof key === "string") } : {}
14629
15018
  };
14630
15019
  }
@@ -14633,6 +15022,7 @@ async function saveCliDialogSummary(args) {
14633
15022
  const existing = await args.store.read(dialogKey) ?? {};
14634
15023
  const bareId = typeof existing.id === "string" && existing.id ? existing.id : args.dialogId.startsWith("dialog-") ? dialogIdFromKey(dialogKey) : args.dialogId;
14635
15024
  const compressionCount = typeof existing.compressionCount === "number" ? existing.compressionCount + 1 : 1;
15025
+ const sanitizedSourceSegments = sanitizeSummarySourceSegments(args.sourceSegments);
14636
15026
  await registerDialogOwner({
14637
15027
  store: { get: (key) => args.store.read(key, { remote: false }), put: (key, value) => args.store.write(key, value) },
14638
15028
  dialogId: bareId,
@@ -14650,6 +15040,7 @@ async function saveCliDialogSummary(args) {
14650
15040
  ...args.sourceHash !== void 0 ? { sourceHash: args.sourceHash } : {},
14651
15041
  ...args.sourceCount !== void 0 ? { sourceCount: args.sourceCount } : {},
14652
15042
  ...args.schemaVersion !== void 0 ? { schemaVersion: args.schemaVersion } : {},
15043
+ ...sanitizedSourceSegments !== void 0 ? { sourceSegments: sanitizedSourceSegments } : {},
14653
15044
  referenceKeys: Array.from(/* @__PURE__ */ new Set([
14654
15045
  ...Array.isArray(existing.referenceKeys) ? existing.referenceKeys.filter((key) => typeof key === "string") : [],
14655
15046
  ...args.referenceKeys ?? []
@@ -14921,6 +15312,17 @@ function createCliLocalRuntimeAdapter(deps) {
14921
15312
  const defaultCompactionSummary = createTuiSummaryLlmCaller(deps.env, { fetchImpl, platformPrimary: true });
14922
15313
  const loopbackRequest = deps.loopbackRequest ?? (deps.fetchImpl ? void 0 : defaultLoopbackRequest);
14923
15314
  const userId = resolveLocalUserId(deps.env);
15315
+ const prependManualCompactHistory = async (dialogId, history) => {
15316
+ const record = await (await getOrCreateSharedStore(deps)).read(`dialog-${userId}-${dialogId}`);
15317
+ if (!Array.isArray(record?.manualCompactHistory)) return history;
15318
+ const { dialogMessageRecordToAgentRuntimeMessage: dialogMessageRecordToAgentRuntimeMessage2 } = await import("./dialogMessageRecord-OAV77LT7.js");
15319
+ const seed = record.manualCompactHistory.map((message) => {
15320
+ const parsed = dialogMessageRecordToAgentRuntimeMessage2(message);
15321
+ if (!parsed) throw new Error("Invalid manual compact history");
15322
+ return parsed;
15323
+ });
15324
+ return [...seed, ...history];
15325
+ };
14924
15326
  const resolveLiveImageSupport = createLiveImageSupportResolver(userId, async () => {
14925
15327
  const token = await createOAuthApiKeyRefResolver({
14926
15328
  migration: { enableLegacyMigration: true },
@@ -14962,6 +15364,24 @@ function createCliLocalRuntimeAdapter(deps) {
14962
15364
  return void 0;
14963
15365
  }
14964
15366
  };
15367
+ const resolveAgentReasoningProfile = async (agentRef) => {
15368
+ try {
15369
+ const record = await readAgentFromStore({
15370
+ agentRef,
15371
+ store: await getOrCreateSharedStore(deps),
15372
+ userId
15373
+ });
15374
+ if (!record) return void 0;
15375
+ const provider = typeof record.provider === "string" ? record.provider.trim() : "";
15376
+ const reasoningEffort = typeof record.reasoning_effort === "string" ? record.reasoning_effort.trim() : "";
15377
+ return {
15378
+ ...provider ? { provider } : {},
15379
+ ...reasoningEffort ? { reasoningEffort } : {}
15380
+ };
15381
+ } catch {
15382
+ return void 0;
15383
+ }
15384
+ };
14965
15385
  const resolveAgentDisplayName = async (agentRef) => {
14966
15386
  try {
14967
15387
  const record = await readAgentFromStore({
@@ -15096,15 +15516,15 @@ function createCliLocalRuntimeAdapter(deps) {
15096
15516
  const runId = asOptionalTrimmedString(deps.env?.NOLO_AGENT_RUN_ID) ?? "interactive";
15097
15517
  emitRunIsolationNotice(fact, { runId });
15098
15518
  try {
15099
- const { writeFileSync: writeFileSync4, mkdirSync: mkdirSync4 } = await import("node:fs");
15100
- const { resolveRunsDir: resolveRunsDir2 } = await import("./agentRunControl-MBG4U6SL.js");
15519
+ const { writeFileSync: writeFileSync4, mkdirSync: mkdirSync5 } = await import("node:fs");
15520
+ const { resolveRunsDir: resolveRunsDir2 } = await import("./agentRunControl-QYTXUQGY.js");
15101
15521
  recordLocalRunExecutionIsolation({
15102
15522
  runId,
15103
15523
  runsDir: resolveRunsDir2(deps.env),
15104
15524
  fact,
15105
15525
  fs: {
15106
15526
  writeFileSync: (path, data) => writeFileSync4(path, data),
15107
- mkdirSync: (path, options) => mkdirSync4(path, options)
15527
+ mkdirSync: (path, options) => mkdirSync5(path, options)
15108
15528
  }
15109
15529
  });
15110
15530
  getLogger("cli.localRuntimeAdapter").info(
@@ -15122,7 +15542,7 @@ function createCliLocalRuntimeAdapter(deps) {
15122
15542
  dockerWorkloadReleased = true;
15123
15543
  dockerWorkloadLoad = null;
15124
15544
  if (loaded) {
15125
- const { resolveRunsDir: resolveRunsDir2 } = await import("./agentRunControl-MBG4U6SL.js");
15545
+ const { resolveRunsDir: resolveRunsDir2 } = await import("./agentRunControl-QYTXUQGY.js");
15126
15546
  const exportRunDiff = deps.exportDockerRunDiffArtifact ?? exportDockerRunDiffArtifact;
15127
15547
  const warn = (message) => process.stderr.write(`[nolo] ${message}
15128
15548
  `);
@@ -15203,7 +15623,6 @@ function createCliLocalRuntimeAdapter(deps) {
15203
15623
  }
15204
15624
  };
15205
15625
  let runtimeToolExecutionLimits = {};
15206
- const skillPolicyFingerprint = (source) => JSON.stringify(Object.entries(resolveAgentSkillConfig(source)).sort(([a], [b]) => a.localeCompare(b)));
15207
15626
  let reviewAgentConfig;
15208
15627
  let planningCaller = {};
15209
15628
  const isCanonicalAutoReviewAdmitted = (visits) => {
@@ -15223,6 +15642,10 @@ function createCliLocalRuntimeAdapter(deps) {
15223
15642
  readXPost: deps.readXPost,
15224
15643
  readXhsProfile: deps.readXhsProfile,
15225
15644
  cliEntrypoint: CLI_ENTRYPOINT,
15645
+ // 本地进程内直连:readDialog / listDialogs 走已在手的共享 store
15646
+ // (local-first,未命中才远端回退),不再 spawn `nolo` 子进程 + 试探
15647
+ // 多个 HTTP 端点;本地答不了时 executor 内部自行回退 CLI 桥。
15648
+ resolveDialogStore: () => getOrCreateSharedStore(deps),
15226
15649
  resolveAgentCredentialGroup,
15227
15650
  resolveAgentDisplayName,
15228
15651
  // α:spawn 前从 agent 配置回读真实 name(resolveAgentRunName 的读取来源)。
@@ -15242,6 +15665,7 @@ function createCliLocalRuntimeAdapter(deps) {
15242
15665
  return !!record && resolveAgentImageInputSupport(await resolveLiveImageSupport({ ...record, hasVision: record.hasVision ?? false }));
15243
15666
  },
15244
15667
  resolveAgentModel,
15668
+ resolveAgentReasoningProfile,
15245
15669
  dialogExistsForCurrentUser: async (dialogId) => {
15246
15670
  const store = await getOrCreateSharedStore(deps);
15247
15671
  const record = await store.read(`dialog-${userId}-${dialogId}`);
@@ -15249,6 +15673,20 @@ function createCliLocalRuntimeAdapter(deps) {
15249
15673
  },
15250
15674
  resolveAgentRuntimeBindingMachineId,
15251
15675
  resolveLocalMachineId,
15676
+ mcpApprovalHostForAgent: async (childAgentKey) => {
15677
+ const approvalSignal = deps.mcpApprovalSignal ?? deps.shellApprovalSession?.signal;
15678
+ if (!getHostApprovalRenderer() || !approvalSignal || approvalSignal.aborted) return void 0;
15679
+ const binding = await resolveChildApprovalBinding({
15680
+ readAgentConfig: async (key) => readAgentFromStore({ agentRef: key, store: await getOrCreateSharedStore(deps), userId }),
15681
+ resolveDeviceId: async () => {
15682
+ const { detectMachineInfo } = await import("./machineInfo-LWHTEBHJ.js");
15683
+ return (await detectMachineInfo({ probeLaunchable: false }))?.machineId;
15684
+ },
15685
+ workspaceRoot,
15686
+ agentKey: childAgentKey
15687
+ });
15688
+ return binding ? { binding, signal: approvalSignal, confirm: confirmMcpOnHost } : void 0;
15689
+ },
15252
15690
  ...deps.shellApprovalSession ? {
15253
15691
  shellApprovalHostForAgent: createChildShellApprovalHostResolver({
15254
15692
  readAgentConfig: async (childAgentKey) => readAgentFromStore({
@@ -15281,6 +15719,13 @@ function createCliLocalRuntimeAdapter(deps) {
15281
15719
  } } : {},
15282
15720
  ...runtimeToolExecutionLimits
15283
15721
  });
15722
+ let localMcpManagement;
15723
+ const getLocalMcpManagement = () => localMcpManagement ??= openMcpLocalRuntimeManagement({
15724
+ authenticatedUserId: userId,
15725
+ env: deps.env,
15726
+ createOAuthManager: deps.createMcpOAuthManager
15727
+ });
15728
+ const localMcpSessions = /* @__PURE__ */ new Map();
15284
15729
  let localToolExecutors = buildCurrentToolExecutors();
15285
15730
  const credentialBroker = createHostCredentialBrokerChain({
15286
15731
  strict: createStrictHostCredentialBroker(),
@@ -15419,7 +15864,17 @@ function createCliLocalRuntimeAdapter(deps) {
15419
15864
  const cached = deps.pastedTextStore ? void 0 : preparedAgentRuntimeCache.get(cacheKey);
15420
15865
  if (cached) {
15421
15866
  const localRecord = await sharedStore.read(cached.agentConfig.key, { remote: false }).catch(() => null);
15422
- const unchanged = !localRecord || cached.localAgentSkillFingerprint !== void 0 && cached.localAgentSkillFingerprint === skillPolicyFingerprint(localRecord);
15867
+ const effectiveLocalRecord = localRecord && typeof localRecord === "object" ? applyBuiltinAgentRuntimeOverride(
15868
+ agentRef,
15869
+ resolveAgentRuntimeConfigFromRecord(
15870
+ cached.agentConfig.key,
15871
+ applyPublicAgentCatalogOverride(
15872
+ localRecord,
15873
+ cached.agentConfig.key
15874
+ )
15875
+ )
15876
+ ).rawRecord : null;
15877
+ const unchanged = !localRecord || cached.localAgentConfigFingerprint !== void 0 && effectiveLocalRecord != null && cached.localAgentConfigFingerprint === buildLocalAgentConfigFingerprint(effectiveLocalRecord);
15423
15878
  if (!unchanged) preparedAgentRuntimeCache.delete(cacheKey);
15424
15879
  if (unchanged) {
15425
15880
  activeAgentToolNames = cached.activeAgentToolNames;
@@ -15458,10 +15913,10 @@ function createCliLocalRuntimeAdapter(deps) {
15458
15913
  const userPromptPatches = accountAutoReviewPrompt ? [...userSkills.skillPromptPatches, accountAutoReviewPrompt] : userSkills.skillPromptPatches;
15459
15914
  const agentConfig = packAgentConfig && userPromptPatches.length ? {
15460
15915
  ...packAgentConfig,
15461
- prompt: [
15462
- packAgentConfig.prompt,
15463
- ...userPromptPatches.filter((patch) => !String(packAgentConfig.prompt ?? "").includes(patch))
15464
- ].filter(Boolean).join("\n\n")
15916
+ // Patches are admitted by the account skill graph and arrive once per
15917
+ // canonical skill identity. Keep them separate from arbitrary prompt
15918
+ // text: substring matching cannot establish runtime contribution ownership.
15919
+ prompt: [packAgentConfig.prompt, ...userPromptPatches].filter(Boolean).join("\n\n")
15465
15920
  } : packAgentConfig;
15466
15921
  const requestedToolNames = agentConfig ? resolveCliRequestedToolNames(
15467
15922
  agentConfig,
@@ -15507,7 +15962,9 @@ function createCliLocalRuntimeAdapter(deps) {
15507
15962
  if (exposedAgentConfig && !deps.pastedTextStore) {
15508
15963
  preparedAgentRuntimeCache.set(cacheKey, {
15509
15964
  agentConfig: exposedAgentConfig,
15510
- localAgentSkillFingerprint: skillPolicyFingerprint(exposedAgentConfig.rawRecord),
15965
+ localAgentConfigFingerprint: buildLocalAgentConfigFingerprint(
15966
+ exposedAgentConfig.rawRecord
15967
+ ),
15511
15968
  activeAgentToolNames,
15512
15969
  runtimeToolExecutionLimits
15513
15970
  });
@@ -15521,21 +15978,25 @@ function createCliLocalRuntimeAdapter(deps) {
15521
15978
  env: deps.env,
15522
15979
  fetchImpl
15523
15980
  });
15524
- return loaded.messages;
15981
+ return prependManualCompactHistory(dialogId, loaded.messages);
15525
15982
  },
15526
15983
  // Source-aware variant so a cross-machine resume that could not load the
15527
15984
  // remote history reports `none` instead of looking like a new dialog.
15528
- loadDialogHistoryWithSource: async (dialogId, options) => loadCliDialogHistoryWithSource({
15529
- strictContinueHistory: options?.strictContinueHistory,
15530
- freshDialog: options?.freshDialog,
15531
- dialogId,
15532
- store: await getOrCreateSharedStore(deps),
15533
- env: deps.env,
15534
- fetchImpl,
15535
- log: (message) => {
15536
- logLocalRuntimeDiagnostic("dialog-history", { dialogId, message });
15537
- }
15538
- }),
15985
+ loadDialogHistoryWithSource: async (dialogId, options) => {
15986
+ const loaded = await loadCliDialogHistoryWithSource({
15987
+ strictContinueHistory: options?.strictContinueHistory,
15988
+ freshDialog: options?.freshDialog,
15989
+ dialogId,
15990
+ store: await getOrCreateSharedStore(deps),
15991
+ env: deps.env,
15992
+ fetchImpl,
15993
+ log: (message) => {
15994
+ logLocalRuntimeDiagnostic("dialog-history", { dialogId, message });
15995
+ }
15996
+ });
15997
+ const messages = await prependManualCompactHistory(dialogId, loaded.messages);
15998
+ return { ...loaded, messages };
15999
+ },
15539
16000
  loadDialogSummary: async (dialogId) => loadCliDialogSummary({
15540
16001
  store: await getOrCreateSharedStore(deps),
15541
16002
  userId,
@@ -15550,6 +16011,7 @@ function createCliLocalRuntimeAdapter(deps) {
15550
16011
  sourceHash: input.sourceHash,
15551
16012
  sourceCount: input.sourceCount,
15552
16013
  schemaVersion: input.schemaVersion,
16014
+ ...input.sourceSegments !== void 0 ? { sourceSegments: input.sourceSegments } : {},
15553
16015
  referenceKeys: input.referenceKeys
15554
16016
  }),
15555
16017
  loadLastContextUsage: async (dialogId) => {
@@ -15905,7 +16367,43 @@ function createCliLocalRuntimeAdapter(deps) {
15905
16367
  workspaceRoot,
15906
16368
  execShellApproval: deps.execShellApproval,
15907
16369
  ...runtimeToolExecutionLimits,
15908
- executors: localToolExecutors,
16370
+ executors: call.name === "listMcpConnections" || call.name === "listMcpTools" || call.name === "callMcpTool" ? { ...localToolExecutors, [call.name]: async (mcpCall) => {
16371
+ const dialogId = opts?.runtimeContext?.dialogId ?? deps.parentDialogId;
16372
+ const agentKey = planningCaller.agentKey;
16373
+ const signal = opts?.abortSignal;
16374
+ if (!userId || !agentKey || typeof dialogId !== "string" || !dialogId || !signal) {
16375
+ return { content: JSON.stringify({ ok: false, error: { code: "forbidden" } }) };
16376
+ }
16377
+ try {
16378
+ let entries = localMcpSessions.get(signal);
16379
+ if (!entries) {
16380
+ entries = /* @__PURE__ */ new Map();
16381
+ localMcpSessions.set(signal, entries);
16382
+ signal.addEventListener("abort", () => {
16383
+ localMcpSessions.delete(signal);
16384
+ for (const pending2 of entries.values()) void pending2.then((mcp2) => mcp2.close()).catch(() => {
16385
+ });
16386
+ }, { once: true });
16387
+ }
16388
+ const key = JSON.stringify([agentKey, dialogId]);
16389
+ let pending = entries.get(key);
16390
+ if (!pending) {
16391
+ pending = getLocalMcpManagement().then((repository) => createMcpLocalRuntimeAdapter({
16392
+ repository,
16393
+ identity: { authenticatedUserId: userId, agentKey, dialogId },
16394
+ signal: deps.mcpApprovalSignal ? AbortSignal.any([signal, deps.mcpApprovalSignal]) : signal,
16395
+ confirm: deps.mcpConfirmation
16396
+ }));
16397
+ entries.set(key, pending);
16398
+ }
16399
+ const mcp = await pending;
16400
+ const input = JSON.parse(mcpCall.arguments);
16401
+ const output = call.name === "listMcpConnections" ? await mcp.listMcpConnections() : call.name === "listMcpTools" ? await mcp.listMcpTools(input) : await mcp.callMcpTool(input);
16402
+ return { content: JSON.stringify(output) };
16403
+ } catch {
16404
+ return { content: JSON.stringify({ ok: false, error: { code: signal.aborted ? "cancelled" : "transport_error" } }) };
16405
+ }
16406
+ } } : localToolExecutors,
15909
16407
  // 沙盒分支的 gate 已经跑过(channel 未接管才会落回这里):把
15910
16408
  // confirmed 传下去,避免破坏性确认在同一调用里弹第二次。
15911
16409
  ...sandboxGatePassed ? { confirmed: true } : {},
@@ -15986,33 +16484,16 @@ export {
15986
16484
  readTimestamp,
15987
16485
  parseAgentRunEvent,
15988
16486
  isLiveAgentRunObservation,
15989
- formatApprovalRemaining,
15990
- createHostApprovalCardQueue,
15991
- registerHostApprovalRenderer,
15992
- isSubtaskRun,
15993
- RUN_WAKE_CHANNEL_ENV,
15994
- createOriginShellGrant,
15995
16487
  preparedAgentRuntimeCache,
15996
16488
  hybridStoreCache,
15997
16489
  normalizeRuntimeCacheCwd,
15998
16490
  buildPreparedAgentCacheKey,
15999
16491
  clearCliLocalRuntimePreparedAgentCache,
16492
+ buildLocalAgentConfigFingerprint,
16000
16493
  defaultLocalRuntimeDb,
16001
16494
  createFallbackId,
16002
16495
  logLocalRuntimeDiagnostic,
16003
16496
  summarizeOpenAiToolNames,
16004
- prepareRemoteDialogEvidenceRecord,
16005
- postRemoteRecord,
16006
- syncLocalDialogEvidenceToRemote,
16007
- resolveStore,
16008
- getOrCreateSharedStore,
16009
- createLocalDialogTitleGenerator,
16010
- writeLocalTokenRecord,
16011
- writeDialog,
16012
- resolveCliDialogRecordKey,
16013
- loadCliDialogSummary,
16014
- saveCliDialogSummary,
16015
- loadCliDialogLastContextUsage,
16016
16497
  LOCAL_SERVER_TABLE_TOOL_NAMES,
16017
16498
  LOCAL_SERVER_TABLE_TOOL_NAME_SET,
16018
16499
  LOCAL_SERVER_WEB_TOOL_NAMES,
@@ -16021,11 +16502,27 @@ export {
16021
16502
  buildOpenAiTools,
16022
16503
  resolveCliEffectiveEnabledPacks,
16023
16504
  withRuntimeEnabledPacksAndPrompt,
16505
+ MCP_EXPOSURE_ENV,
16506
+ INSTABOX_SCHEMA_EXPOSURE_ENV,
16024
16507
  resolveCliRequestedToolNames,
16025
16508
  resolveProviderOpenAiToolBundle,
16026
16509
  buildLocalWorkspaceToolsetForEnv,
16027
16510
  buildLocalPolicyToolNames,
16028
16511
  buildServerPlatformOpenAiTools,
16512
+ createOriginShellGrant,
16513
+ createCliHybridRecordStore,
16514
+ prepareRemoteDialogEvidenceRecord,
16515
+ postRemoteRecord,
16516
+ syncLocalDialogEvidenceToRemote,
16517
+ resolveStore,
16518
+ getOrCreateSharedStore,
16519
+ createLocalDialogTitleGenerator,
16520
+ writeLocalTokenRecord,
16521
+ writeDialog,
16522
+ resolveCliDialogRecordKey,
16523
+ loadCliDialogSummary,
16524
+ saveCliDialogSummary,
16525
+ loadCliDialogLastContextUsage,
16029
16526
  summarizeEndpoint,
16030
16527
  resolveAuthToken2 as resolveAuthToken,
16031
16528
  resolveFileWriteGateEnabled,