nolo-cli 0.224.0-alpha.1 → 0.224.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (236) hide show
  1. package/{_executeModel-WW57SJN4.js → _executeModel-5NA4USGG.js} +77 -70
  2. package/{action-CK64LS6S.js → action-X75O3XPH.js} +11 -8
  3. package/{addContentAction-EQXMFNPR.js → addContentAction-GVC77QSN.js} +14 -13
  4. package/{addDialogAgentAction-RSDZDASD.js → addDialogAgentAction-KKDVAMW3.js} +15 -14
  5. package/{agentDeleteCommand-X2VWEKUA.js → agentDeleteCommand-2RFGKFAB.js} +127 -118
  6. package/{agentEmailCommands-6IE773VW.js → agentEmailCommands-GQCQKKOR.js} +126 -113
  7. package/{agentFavoriteCommands-2LKGKSUD.js → agentFavoriteCommands-7LOP3HUD.js} +5 -5
  8. package/{agentGrantCommands-QQV4N4JW.js → agentGrantCommands-L6O2HVJI.js} +5 -5
  9. package/{agentListCommands-5UNM7CGG.js → agentListCommands-HSGLDPDQ.js} +110 -495
  10. package/{agentMachineCommands-EVWFKK6Q.js → agentMachineCommands-BISF6PVV.js} +63 -57
  11. package/{agentProviderCommands-ZCH37KAL.js → agentProviderCommands-O3Q25PKU.js} +6 -6
  12. package/{agentPullCommand-XN6ZPBUW.js → agentPullCommand-G6U2LHMW.js} +6 -6
  13. package/agentRecordCommands-AOXPGYAJ.js +189 -0
  14. package/{agentRunCommand-KGOT2AFB.js → agentRunCommand-AFAIP7U7.js} +129 -113
  15. package/{agentRunControl-QDFW5P2T.js → agentRunControl-VBL7UFSG.js} +20 -14
  16. package/{agentRuntimeLocal-SD7U2EGY.js → agentRuntimeLocal-T7BX2WGL.js} +47 -41
  17. package/{agentSlice-ACZGTZVW.js → agentSlice-XJNKE3PG.js} +18 -17
  18. package/{appDeleteCommands-NE3NQQJL.js → appDeleteCommands-LURUSPY7.js} +56 -50
  19. package/{appDeployCommands-2BAHY522.js → appDeployCommands-SMEW4AK2.js} +56 -50
  20. package/{appDeployStatusCommands-JTW6LZNC.js → appDeployStatusCommands-VYPJTBJK.js} +56 -50
  21. package/{appGetCommands-WKFEJO6A.js → appGetCommands-N4NI5GGJ.js} +56 -50
  22. package/{appListCommands-HNAZZLFX.js → appListCommands-5C6ONN3Z.js} +56 -50
  23. package/{authCommand-4FDPL7WG.js → authCommand-4CVBDADE.js} +29 -24
  24. package/{authCommands-GAJ3NIXO.js → authCommands-EHU2BHOX.js} +12 -7
  25. package/{builtinSkillRegistry-PXH7EGQB.js → builtinSkillRegistry-AYWYQVA4.js} +4 -4
  26. package/{chromeOpsCommands-YKX2QX3A.js → chromeOpsCommands-CSDG2HYN.js} +6 -6
  27. package/{chunk-OOF7XDZF.js → chunk-2574ANSV.js} +6 -6
  28. package/chunk-2SXN7LAY.js +15 -0
  29. package/{chunk-OGHP3CTL.js → chunk-2X7WFDT6.js} +1 -1
  30. package/{chunk-XI2BWJM5.js → chunk-324FWHUA.js} +20 -3
  31. package/{chunk-D726I5AZ.js → chunk-3EMIEC27.js} +2 -2
  32. package/{chunk-S7SB7L2I.js → chunk-3FBAVU2Y.js} +24 -22
  33. package/{chunk-YL3EFYL3.js → chunk-4D4QD7FT.js} +3 -1
  34. package/{chunk-5RKUPJYL.js → chunk-4FIO2S7Z.js} +11 -3
  35. package/{chunk-MKQ2UTTX.js → chunk-4IQVE43Z.js} +63 -32
  36. package/{chunk-6NKA6RKF.js → chunk-4Q6HQORG.js} +8 -8
  37. package/{chunk-P2ZLUIW2.js → chunk-4X5AVCM7.js} +94 -4
  38. package/chunk-4ZCTKB27.js +31 -0
  39. package/{chunk-JWXITTQB.js → chunk-5HUO7SEX.js} +9 -107
  40. package/{chunk-4A2JIXR2.js → chunk-5QZSEQSK.js} +1 -1
  41. package/chunk-5ZUOVCKT.js +32 -0
  42. package/{chunk-TRWT3EE3.js → chunk-62HXNQVV.js} +1 -1
  43. package/{chunk-JC5XLWZK.js → chunk-6CKUO32A.js} +27 -15
  44. package/chunk-6D25V6CB.js +133 -0
  45. package/chunk-6WOLPIPY.js +379 -0
  46. package/{chunk-KOXKKHFE.js → chunk-6WZVM33D.js} +9 -4
  47. package/{chunk-YGMBIXCF.js → chunk-6XRPBZRS.js} +4 -2
  48. package/{chunk-KO63FPG3.js → chunk-7AJRJGSQ.js} +1049 -2860
  49. package/chunk-7NIBQ4HY.js +138 -0
  50. package/{chunk-7Z6EW7AH.js → chunk-7TTMMOKH.js} +13 -6
  51. package/{chunk-7WPAI5JJ.js → chunk-A3LUWRQK.js} +15 -15
  52. package/{chunk-C4WTX5TU.js → chunk-A5EVA6HU.js} +2 -2
  53. package/{chunk-O2CYENYJ.js → chunk-A74QP4FI.js} +2614 -1374
  54. package/{chunk-N3J4VDGV.js → chunk-AEQMKYZN.js} +15 -15
  55. package/{chunk-DVQH4BTR.js → chunk-AH5R7BYW.js} +26 -176
  56. package/{chunk-H7R3365N.js → chunk-ANJRDS6U.js} +8 -5
  57. package/{chunk-YFLVRVYK.js → chunk-AVJDELEA.js} +1 -1
  58. package/{chunk-GIABSSWQ.js → chunk-B5SV4H3J.js} +4 -4
  59. package/{chunk-FVZW66K4.js → chunk-B7DE5XJW.js} +387 -347
  60. package/chunk-BEM6LPD2.js +734 -0
  61. package/{chunk-SRL56PI2.js → chunk-BGGAY6OK.js} +46 -8
  62. package/{chunk-T3O6BLYU.js → chunk-BGGV6B5O.js} +555 -328
  63. package/{chunk-BGGHA5DV.js → chunk-BIABIPGW.js} +1 -1
  64. package/chunk-BIDSIRTS.js +307 -0
  65. package/{chunk-6D7NVU66.js → chunk-BXSMFPTG.js} +17 -14
  66. package/{chunk-Q6HOUF4O.js → chunk-CBUZ6DKA.js} +3 -3
  67. package/{chunk-LE6LGAJE.js → chunk-CD3RU7XL.js} +17 -2
  68. package/{chunk-GVGOEMNV.js → chunk-CKZPMJNU.js} +3 -3
  69. package/{chunk-3ESU44FG.js → chunk-CVJRVBJL.js} +3 -3
  70. package/chunk-D374I563.js +62 -0
  71. package/{chunk-XWGDCWXY.js → chunk-DNZ4JJ7C.js} +9 -9
  72. package/chunk-DVYAFH2Q.js +103 -0
  73. package/{chunk-N7HVLYOY.js → chunk-DXW5WDHZ.js} +4 -4
  74. package/{chunk-KFHREHUQ.js → chunk-DXWGFL2Z.js} +89 -1
  75. package/{chunk-65XXHYZ5.js → chunk-E5KJOZWY.js} +4 -4
  76. package/{chunk-GNHMRBYZ.js → chunk-EBKHA63G.js} +106 -14
  77. package/{chunk-PFJNLBRU.js → chunk-EEOOBRA7.js} +6 -6
  78. package/{chunk-M3JEW6N6.js → chunk-F26GAEH3.js} +10 -0
  79. package/{chunk-QLFCTYRH.js → chunk-F3XI6WQP.js} +17 -10
  80. package/{chunk-AFHOCBSP.js → chunk-F6YWDVIB.js} +1 -1
  81. package/{chunk-VHPAA6MT.js → chunk-FFYE5ATM.js} +6 -6
  82. package/{chunk-F3TQURKK.js → chunk-FZKA3XFA.js} +21 -21
  83. package/{chunk-C4VAR65S.js → chunk-G22P367E.js} +153 -117
  84. package/{chunk-4NMHE7CX.js → chunk-GDUC4VS2.js} +12 -12
  85. package/{chunk-2VUZSVAS.js → chunk-GXXY2NL3.js} +22 -20
  86. package/{chunk-IWH5SOU4.js → chunk-H7ZYKHAZ.js} +38 -18
  87. package/{chunk-G2EJ7NL4.js → chunk-HBRDSQ3M.js} +2 -2
  88. package/{chunk-EGXPAWLG.js → chunk-HCNOO374.js} +1 -1
  89. package/{chunk-DJSTBAOU.js → chunk-HOM6LTEW.js} +4 -4
  90. package/{chunk-S2NTVGA2.js → chunk-I2OYPD3Y.js} +1 -1
  91. package/{chunk-QWYFFHCJ.js → chunk-IJTXNLQE.js} +13 -13
  92. package/{chunk-UYOICCYG.js → chunk-IUMS6F53.js} +59 -88
  93. package/{chunk-MOMR7NMG.js → chunk-IUTUWIKE.js} +2 -2
  94. package/{chunk-JVRQ6YVK.js → chunk-JBWXPACD.js} +1 -1
  95. package/{chunk-SASHAZ67.js → chunk-KZPEGO6D.js} +13 -2
  96. package/{chunk-HCJFGH6Y.js → chunk-L32W3PRP.js} +46 -16
  97. package/{chunk-GGKNJ42M.js → chunk-LYDEFPQP.js} +18 -108
  98. package/{chunk-K5FNYHZC.js → chunk-MECDGHLK.js} +420 -120
  99. package/{chunk-EOWLBDY6.js → chunk-MM73SP4K.js} +1 -1
  100. package/{chunk-J6T25AJ6.js → chunk-MYOSN6BT.js} +82 -18
  101. package/{chunk-Q7WP5RPC.js → chunk-MYPKBJJO.js} +5 -5
  102. package/{chunk-6RQFZCKH.js → chunk-N2JROHD3.js} +4 -4
  103. package/{chunk-VREDDN25.js → chunk-O6IPRAVV.js} +14 -9
  104. package/{chunk-VALBGPM6.js → chunk-OBSEKCVK.js} +17 -20
  105. package/{chunk-AMEOV5VZ.js → chunk-OOJNQK6V.js} +33 -33
  106. package/{chunk-PPJYZRSQ.js → chunk-OX6GNNVT.js} +6 -1
  107. package/{chunk-5R63B62U.js → chunk-P3IZUMIC.js} +8 -8
  108. package/{chunk-FRSBYNWI.js → chunk-PGKA77TZ.js} +52 -217
  109. package/{chunk-7UH3DGV6.js → chunk-PRMEU7BT.js} +232 -10
  110. package/{chunk-2ZKFCIJJ.js → chunk-PROOOQZ3.js} +1 -1
  111. package/{chunk-EUCFKKDM.js → chunk-PVFYPUIM.js} +40 -10
  112. package/{chunk-HOCHUZQ7.js → chunk-QJTZ76CP.js} +24 -6
  113. package/{chunk-MK2Q7ZJD.js → chunk-R7XWZDOH.js} +58 -24
  114. package/{chunk-5FUN7EG4.js → chunk-RD3QLZQV.js} +83 -47
  115. package/chunk-RETQOQ4D.js +33394 -0
  116. package/{chunk-AVHRSJUH.js → chunk-RM4UMFY4.js} +32 -25
  117. package/{chunk-2OLYKYNY.js → chunk-RTHFJZ6M.js} +8 -8
  118. package/{chunk-OB6DVWPF.js → chunk-S2MHR4PU.js} +164 -4
  119. package/{chunk-IWQAOW2X.js → chunk-SRCCSTIM.js} +8 -8
  120. package/{chunk-PVZY6P3S.js → chunk-T6VROBY7.js} +2 -2
  121. package/{chunk-2KTUDBG7.js → chunk-TEMLHVGX.js} +1 -1
  122. package/{chunk-TVFRV3UQ.js → chunk-TRHJ4NJB.js} +673 -1279
  123. package/{chunk-QVBXJNZ2.js → chunk-TUSTONB3.js} +1 -1
  124. package/{chunk-UMRI2IRY.js → chunk-TWTJV35S.js} +6 -6
  125. package/{chunk-5OZC7R7Y.js → chunk-U3G7RRXJ.js} +13 -12
  126. package/{chunk-CXDPIPZ4.js → chunk-UFC4J7OY.js} +3 -3
  127. package/{chunk-CKT6QUE2.js → chunk-UHW6SCVK.js} +1 -1
  128. package/{chunk-AGP3YSEC.js → chunk-ULLHVDTZ.js} +48 -3
  129. package/{chunk-SYQR7FQS.js → chunk-VM72HKW2.js} +97 -29
  130. package/{chunk-KEN3N2TN.js → chunk-VMJVAJ6W.js} +13 -10
  131. package/{chunk-3N4ASIP6.js → chunk-VREG6ANQ.js} +103 -100
  132. package/{chunk-SOF4OWDM.js → chunk-VS276URX.js} +0 -2
  133. package/chunk-VSRISJXZ.js +107 -0
  134. package/chunk-WDWZPASX.js +29 -0
  135. package/chunk-WFGNWWJI.js +326 -0
  136. package/{chunk-UJKTI5PG.js → chunk-WRKMXMU7.js} +2 -1
  137. package/{chunk-FIYSMXHY.js → chunk-WWTSEBDF.js} +1 -1
  138. package/{chunk-E2BESSAW.js → chunk-X4O7FJF5.js} +2 -0
  139. package/chunk-X7IA2B7R.js +166 -0
  140. package/{chunk-5ZMIIR23.js → chunk-XBAEM4RI.js} +7 -0
  141. package/{chunk-4JVNURX4.js → chunk-XS5A3EKX.js} +1 -23
  142. package/{chunk-N5Z2V73W.js → chunk-Y2MF4DCJ.js} +1 -1
  143. package/{chunk-KAVGK4ES.js → chunk-Y5OWZQMJ.js} +39 -30
  144. package/{chunk-AK5O76CC.js → chunk-YGCOJNFZ.js} +3 -3
  145. package/{chunk-L5I543VB.js → chunk-YGDYYFRX.js} +20 -24
  146. package/{chunk-XFJ4ZPFC.js → chunk-Z2WZAE4P.js} +128 -149
  147. package/chunk-Z6YTCDU4.js +24 -0
  148. package/chunk-ZEKUFJLW.js +1438 -0
  149. package/{chunk-KN3HEZIQ.js → chunk-ZVOL2MAJ.js} +1 -1
  150. package/{cliAgentConfigHelpers-PO3MVDME.js → cliAgentConfigHelpers-U5OAVAKQ.js} +12 -12
  151. package/{cliAuthorityBrokerClient-XHH7MH2P.js → cliAuthorityBrokerClient-S42VMGB6.js} +1 -1
  152. package/{cliEnvHelpers-VPSJ4XWC.js → cliEnvHelpers-CNMP3RDX.js} +1 -1
  153. package/{cliExecutor-4MAX3PZL.js → cliExecutor-K6FDZTQ2.js} +3 -1
  154. package/{cliLocalAgentRecordReader-Z7CH4K4R.js → cliLocalAgentRecordReader-HVZAQCUD.js} +49 -44
  155. package/{commandRegistry-SDSYBKMC.js → commandRegistry-TME7INFU.js} +98 -94
  156. package/{contentThunks-G3TRPEAU.js → contentThunks-U6OC4R2N.js} +37 -35
  157. package/{cooldownCommands-X7P5M2V5.js → cooldownCommands-U7XSRVJP.js} +4 -4
  158. package/{createAgentAutomationAction-KHA4MXUJ.js → createAgentAutomationAction-IP4LFN3W.js} +37 -35
  159. package/{createDialogAction-KWSBNAPJ.js → createDialogAction-IAGQJ3LH.js} +38 -36
  160. package/{createPageAction-HXKJ7OFG.js → createPageAction-AZ3UIFKA.js} +38 -36
  161. package/{db-CS4ZJQKV.js → db-M7FU2GNK.js} +9 -6
  162. package/{dbSlice-ZJPDIFER.js → dbSlice-DKKMJJYY.js} +13 -12
  163. package/{deleteFile-Q3YDB4ML.js → deleteFile-TQSONMVU.js} +11 -8
  164. package/{dialogCommands-6KQEBHSG.js → dialogCommands-PCDRMBWG.js} +60 -55
  165. package/dialogMessageRecord-OAV77LT7.js +7 -0
  166. package/{dialogNotifyCommand-WIZFFEY3.js → dialogNotifyCommand-O35MWMOS.js} +13 -13
  167. package/{dialogSlice-HXPKFGRL.js → dialogSlice-QAKYN4DE.js} +35 -33
  168. package/{dialogUsageCommand-HTVPR2CX.js → dialogUsageCommand-2SSLTXKO.js} +3 -3
  169. package/{docCreateCommands-XZOLWBRC.js → docCreateCommands-CFQFZOAD.js} +54 -48
  170. package/{docDeleteCommands-ZSO4LGWE.js → docDeleteCommands-5CPNTIIS.js} +56 -50
  171. package/{docReadCommands-TTMXCDER.js → docReadCommands-XQILYSAJ.js} +54 -48
  172. package/{docStore-A2B3GH33.js → docStore-GIVRT7TQ.js} +15 -14
  173. package/{docUpdateCommands-PRG6WOXL.js → docUpdateCommands-VETKSUDD.js} +54 -48
  174. package/fetchMessages-TQEUZD7H.js +1 -1
  175. package/{getPricing-YH3VMSVU.js → getPricing-LF5C4XSI.js} +5 -5
  176. package/{handleSendMessageAction-NWYG3Q72.js → handleSendMessageAction-HKIW4ZNO.js} +70 -66
  177. package/{hostCredentialCreate-WS6D3EHT.js → hostCredentialCreate-6VDJFNDO.js} +118 -104
  178. package/index.js +56 -18
  179. package/keys-RWF7UCB4.js +1 -1
  180. package/{lib-OT5OTXRU.js → lib-62SWPXNF.js} +3 -7
  181. package/{localDialogRead-SVTPA5GY.js → localDialogRead-AV2VKKPG.js} +1 -1
  182. package/{localRecall-2J6QPOK2.js → localRecall-BDYKXB46.js} +3 -1
  183. package/{localRuntimeAdapter-TFYOA6YE.js → localRuntimeAdapter-BQ4F5PZV.js} +120 -107
  184. package/{localRuntimeAuthority-IBJAT62G.js → localRuntimeAuthority-WCNA4A3G.js} +4 -2
  185. package/{localRuntimeDb-N7KHDXS2.js → localRuntimeDb-CRNIBOOM.js} +1 -1
  186. package/{machineCommands-WFWV25IR.js → machineCommands-K6XIGOAD.js} +142 -114
  187. package/{machineWsRunDispatch-ZGXC3F2R.js → machineWsRunDispatch-4OO7Z6UM.js} +114 -101
  188. package/mcpLocalAuthorizeCommand-ZP6ESAGE.js +106 -0
  189. package/{memberThunks-JRYNONYV.js → memberThunks-PBJPZ2JU.js} +22 -17
  190. package/{memoryCommands-5WC3T66U.js → memoryCommands-BC6REPQB.js} +4 -4
  191. package/{models-CXINDUJA.js → models-H5NNZRLH.js} +2 -2
  192. package/{overlay-THLKYIWY.js → overlay-JA3SPVUS.js} +7 -3
  193. package/package.json +1 -1
  194. package/{projectArchive-ULJDLUA6.js → projectArchive-G7AOQPRW.js} +43 -41
  195. package/{providerPresetApply-SHT2SUVB.js → providerPresetApply-OPBCAONX.js} +6 -6
  196. package/{providerRegistry-TA7EGCVZ.js → providerRegistry-J2HCVTHE.js} +6 -6
  197. package/{read-Q7GOHGNP.js → read-JEGPITEW.js} +10 -9
  198. package/{readDocTool-Z5OQ6422.js → readDocTool-TE3XIU4Y.js} +1 -1
  199. package/{readlineWorkspace-LTCV2BFW.js → readlineWorkspace-SOW5QUGZ.js} +4412 -4277
  200. package/{removeDialogAgentAction-U3F2MNAY.js → removeDialogAgentAction-CX3OAH4Y.js} +17 -16
  201. package/{runAgentClientLoop-BVIEQUB3.js → runAgentClientLoop-HQJPDFGQ.js} +95 -69
  202. package/{runtimeDoctorCommands-I47JN4HS.js → runtimeDoctorCommands-GUH2YGMH.js} +17 -17
  203. package/{secretCommands-LJXOOYA7.js → secretCommands-NJXFVHZU.js} +4 -4
  204. package/{setDialogExtraReferencesAction-G3WSJ7EM.js → setDialogExtraReferencesAction-CGM67EEQ.js} +16 -15
  205. package/{setPrimaryDialogAgentAction-6FHAHZBB.js → setPrimaryDialogAgentAction-3ABWPPXR.js} +17 -16
  206. package/{settingThunks-AXTBX3Q5.js → settingThunks-AY76OHYX.js} +181 -62
  207. package/{skillDiscovery-B5V23AXP.js → skillDiscovery-MDDKPTW3.js} +4 -3
  208. package/{spaceCommands-IB6FKWIC.js → spaceCommands-G63QGYQO.js} +59 -53
  209. package/{store-JRVN62NM.js → store-Z53ICFL3.js} +3 -1
  210. package/{streamAgentChatTurn-DNYFHBJM.js → streamAgentChatTurn-E3XH2KFD.js} +160 -154
  211. package/{switchDialogAgentAction-UOFIAGPL.js → switchDialogAgentAction-G6EZRKCQ.js} +15 -14
  212. package/{tableCommands-HITDSLHS.js → tableCommands-JI75ZHDI.js} +14 -11
  213. package/{toolApiClient-OGQEBQVX.js → toolApiClient-62UUPDUA.js} +3 -5
  214. package/{tools-JVOJ5HC4.js → tools-7RSX22FT.js} +64 -58
  215. package/tuiRestart-KAAA7TND.js +41 -0
  216. package/{tuiSummaryLlmCaller-7LWYTHLM.js → tuiSummaryLlmCaller-BVNHMWLR.js} +19 -19
  217. package/{updateCommands-RJVCRSBP.js → updateCommands-ASK5XYPH.js} +8 -6
  218. package/{updateDialogTitleAction-Q57BOSXG.js → updateDialogTitleAction-SEWV252V.js} +37 -35
  219. package/{usageCommand-RVKHEPLU.js → usageCommand-JVT5J3DC.js} +3 -3
  220. package/{usageRebuildCommand-GRAFOZF2.js → usageRebuildCommand-IZYYUTEW.js} +4 -4
  221. package/webapi-24RZDIIQ.js +2488 -0
  222. package/{windowsSelfUpdate-KERHIAB4.js → windowsSelfUpdate-BSDIS2J5.js} +2 -2
  223. package/workContext-MM3P5GP5.js +13 -0
  224. package/workContextAccess-UZHDLBUR.js +11 -0
  225. package/workContextWriteNotice-YCSSMHN4.js +7 -0
  226. package/agentRecordCommands-DX2WE6BH.js +0 -176
  227. package/chunk-2THCNKE4.js +0 -147
  228. package/chunk-2WZXXAQD.js +0 -57
  229. package/chunk-652XYZGP.js +0 -352
  230. package/chunk-KEPOVMF4.js +0 -91
  231. package/chunk-OXKUPBAQ.js +0 -776
  232. package/{chunk-BLVSFYQ3.js → chunk-LISC7BD4.js} +3 -3
  233. package/{chunk-SNBZZPYH.js → chunk-OQHIVPG4.js} +3 -3
  234. package/{chunk-47ITIXO7.js → chunk-USGHJSGO.js} +3 -3
  235. package/{offlineMarxistsAgentCommand-4IC3Y4C6.js → offlineMarxistsAgentCommand-XVXUE6G5.js} +3 -3
  236. package/{workloadLifecycle-O2I3NZ2Q.js → workloadLifecycle-YIZ7KLUP.js} +3 -3
@@ -1,12 +1,9 @@
1
1
  import {
2
+ AGENT_PROMPT_IN_MESSAGES,
2
3
  DEVIN_CONNECT_URL,
3
4
  parseSseDataLineJson,
4
5
  parseSseDataLineObject
5
- } from "./chunk-IWH5SOU4.js";
6
- import {
7
- evaluateFileWritePolicy,
8
- summarizeToolArguments
9
- } from "./chunk-CHOZJMJS.js";
6
+ } from "./chunk-H7ZYKHAZ.js";
10
7
  import {
11
8
  EXECUTION_BACKEND_KINDS
12
9
  } from "./chunk-PWTNI4N7.js";
@@ -22,27 +19,26 @@ import {
22
19
  flushChatCompletionStream,
23
20
  providerHttpFailure,
24
21
  throwIfChatCompletionStreamFailed
25
- } from "./chunk-DJSTBAOU.js";
22
+ } from "./chunk-HOM6LTEW.js";
26
23
  import {
27
24
  readSseFrames
28
25
  } from "./chunk-HNUWUO75.js";
29
26
  import {
30
- resolveToolExecutionContract
31
- } from "./chunk-LKA64WH4.js";
27
+ evaluateFileWritePolicy,
28
+ summarizeToolArguments
29
+ } from "./chunk-CHOZJMJS.js";
32
30
  import {
33
31
  evaluateRequestBudget,
34
32
  hasImageInRuntimeMessages,
35
33
  stripImagePartsFromMessages
36
- } from "./chunk-SASHAZ67.js";
34
+ } from "./chunk-KZPEGO6D.js";
37
35
  import {
38
- clipToolText,
39
- resolveHistoricalToolContentCap,
40
- resolveToolOutputProfile
41
- } from "./chunk-2WZXXAQD.js";
36
+ resolveToolExecutionContract
37
+ } from "./chunk-LKA64WH4.js";
42
38
  import {
43
39
  resolveAgentImageInputSupport,
44
40
  resolveToolImagePolicy
45
- } from "./chunk-SRL56PI2.js";
41
+ } from "./chunk-BGGAY6OK.js";
46
42
  import {
47
43
  applyShapingCounts,
48
44
  attachProjectionFacts,
@@ -53,7 +49,7 @@ import {
53
49
  projectUserPartForModel,
54
50
  resolveOutboundDiagnosticSink,
55
51
  writeThinkingFacts
56
- } from "./chunk-4A2JIXR2.js";
52
+ } from "./chunk-5QZSEQSK.js";
57
53
  import {
58
54
  createThinkParserState,
59
55
  createToolCallAccumulator,
@@ -79,25 +75,7 @@ import {
79
75
  hashStablePrefixContent,
80
76
  resolveResponseGuidelines,
81
77
  resolveToolGuidedSections
82
- } from "./chunk-FRSBYNWI.js";
83
- import {
84
- BRIDGE_STREAM_MAX_CHARS,
85
- CLI_NOLO_WORKSPACE_TOOL_NAMES,
86
- DEFAULT_READ_DIALOG_MAX_RESPONSE_CHARS,
87
- NOLO_WORKSPACE_TOOL_NAMES,
88
- buildDialogReadEnvelope,
89
- buildNoloWorkspaceCommandArgs,
90
- buildNoloWorkspaceOpenAiTools,
91
- createStreamingDialogReadProjector,
92
- noloPositiveIntegerString,
93
- noloStringArg,
94
- parseNoloWorkspaceToolArguments,
95
- readTextStreamUpToChars,
96
- resolveNoloDialogInput
97
- } from "./chunk-C4VAR65S.js";
98
- import {
99
- applyToolSurfaceConstraints
100
- } from "./chunk-SOF4OWDM.js";
78
+ } from "./chunk-PGKA77TZ.js";
101
79
  import {
102
80
  classifyUnparsableToolArgs,
103
81
  collectStablePromptPrefix,
@@ -121,7 +99,7 @@ import {
121
99
  toOpenAiCompatibleMessages,
122
100
  toResponsesTools,
123
101
  transferDowngradedToolTurnOrigin
124
- } from "./chunk-PFJNLBRU.js";
102
+ } from "./chunk-EEOOBRA7.js";
125
103
  import {
126
104
  TOOL_HAD_IMAGES,
127
105
  TOOL_IMAGES,
@@ -134,13 +112,45 @@ import {
134
112
  toolImageDelivery,
135
113
  toolImages,
136
114
  withoutToolImages
137
- } from "./chunk-E2BESSAW.js";
115
+ } from "./chunk-X4O7FJF5.js";
116
+ import {
117
+ BRIDGE_STREAM_MAX_CHARS,
118
+ CLI_NOLO_WORKSPACE_TOOL_NAMES,
119
+ DEFAULT_READ_DIALOG_MAX_RESPONSE_CHARS,
120
+ NOLO_WORKSPACE_TOOL_NAMES,
121
+ buildDialogReadEnvelope,
122
+ buildNoloWorkspaceCommandArgs,
123
+ buildNoloWorkspaceOpenAiTools,
124
+ createStreamingDialogReadProjector,
125
+ noloPositiveIntegerString,
126
+ noloStringArg,
127
+ parseNoloWorkspaceToolArguments,
128
+ readTextStreamUpToChars,
129
+ resolveNoloDialogInput
130
+ } from "./chunk-G22P367E.js";
131
+ import {
132
+ applyToolSurfaceConstraints
133
+ } from "./chunk-VS276URX.js";
138
134
  import {
139
135
  isQuotaExhaustedError
140
136
  } from "./chunk-TLE77UJ5.js";
137
+ import {
138
+ PROJECT_INSTRUCTION_MAX_BYTES,
139
+ PROJECT_INSTRUCTION_MAX_CHARS,
140
+ SECRET_PATTERNS,
141
+ clipToolText,
142
+ hasPotentialSecrets,
143
+ isCompleteInstructionOutput,
144
+ resolveHistoricalToolContentCap,
145
+ resolveToolOutputProfile,
146
+ sanitizeToolOutputContent,
147
+ sanitizeToolOutputText,
148
+ scrubObjectSecrets,
149
+ scrubSecrets
150
+ } from "./chunk-WFGNWWJI.js";
141
151
  import {
142
152
  isAgentSkillDisabled
143
- } from "./chunk-EOWLBDY6.js";
153
+ } from "./chunk-MM73SP4K.js";
144
154
  import {
145
155
  buildDialogFallbackTitleFromUserInput
146
156
  } from "./chunk-2MBTWINN.js";
@@ -152,12 +162,13 @@ import {
152
162
  resolveEmptyAssistantFallbackMessage,
153
163
  resolveEmptyAssistantOutcome,
154
164
  resolveTruncatedReasoningTailLog
155
- } from "./chunk-XWGDCWXY.js";
165
+ } from "./chunk-DNZ4JJ7C.js";
156
166
  import {
157
167
  COMPACTION_SUMMARY_SCHEMA_VERSION,
158
168
  COMPACTION_SUMMARY_SYSTEM_PROMPT,
159
169
  buildBoundedCompactionRequest,
160
170
  buildCompactionMetricsFromPlan,
171
+ buildSummarySourceDiagnostics,
161
172
  classifySummaryError,
162
173
  computeSummarySourceMetadata,
163
174
  createSummaryBudget,
@@ -175,7 +186,7 @@ import {
175
186
  sha256Hex,
176
187
  summaryCompletionTokens,
177
188
  truncateToolOutputForContext
178
- } from "./chunk-HCJFGH6Y.js";
189
+ } from "./chunk-L32W3PRP.js";
179
190
  import {
180
191
  createProviderCallTimingTracker,
181
192
  finalizeProviderCallTiming,
@@ -189,41 +200,21 @@ import {
189
200
  import {
190
201
  asRecordOrEmpty
191
202
  } from "./chunk-KX6YBIHG.js";
192
- import {
193
- assertCredentialRef
194
- } from "./chunk-SNBZZPYH.js";
195
- import {
196
- isLevelNotFoundError
197
- } from "./chunk-OW765XBU.js";
198
203
  import {
199
204
  isAbortError
200
205
  } from "./chunk-7DPNBQSV.js";
201
206
  import {
202
- WORKTREE_ISOLATION_PRELUDE
203
- } from "./chunk-GNHMRBYZ.js";
204
- import {
205
- canonicalizeToolName,
206
- canonicalizeToolNames
207
- } from "./chunk-6OVNSQHN.js";
208
- import {
209
- dialogMessageKey,
210
- dialogMessageRange
211
- } from "./chunk-OJKUU3LP.js";
212
- import {
213
- asTrimmedNonEmptyStringArray
214
- } from "./chunk-I42VC5KR.js";
215
- import {
216
- buildDialogSummaryLayer
217
- } from "./chunk-JWXITTQB.js";
218
- import {
219
- buildUserResponseLanguageContext
220
- } from "./chunk-L5I543VB.js";
207
+ isLevelNotFoundError
208
+ } from "./chunk-OW765XBU.js";
221
209
  import {
210
+ TOOL_OUTPUT_SPILL_BYTES,
211
+ TOOL_OUTPUT_SPILL_LINES,
222
212
  buildInteractiveCommandBlockedResult,
223
213
  buildProcessTaskResultCapsule,
224
214
  buildWorkspaceShellCommand,
225
215
  buildWorkspaceShellEscapeBlockedResult,
226
216
  buildWorkspaceShellPlan,
217
+ countLines,
227
218
  createGlob,
228
219
  deriveLabel,
229
220
  extractActivity,
@@ -242,14 +233,47 @@ import {
242
233
  spillToolOutput,
243
234
  toProcessTaskView,
244
235
  truncateToolOutput
245
- } from "./chunk-KEN3N2TN.js";
236
+ } from "./chunk-VMJVAJ6W.js";
246
237
  import {
247
238
  estimateTokenCount
248
239
  } from "./chunk-PSCNXBYA.js";
240
+ import {
241
+ resolveNoloStateDir
242
+ } from "./chunk-6UBGXX2W.js";
243
+ import {
244
+ dialogMessageRecordToAgentRuntimeMessage
245
+ } from "./chunk-4ZCTKB27.js";
246
+ import {
247
+ WORKTREE_ISOLATION_PRELUDE
248
+ } from "./chunk-EBKHA63G.js";
249
+ import {
250
+ canonicalizeToolName,
251
+ canonicalizeToolNames
252
+ } from "./chunk-6OVNSQHN.js";
253
+ import {
254
+ dialogMessageKey,
255
+ dialogMessageRange
256
+ } from "./chunk-OJKUU3LP.js";
257
+ import {
258
+ asTrimmedNonEmptyStringArray
259
+ } from "./chunk-I42VC5KR.js";
260
+ import {
261
+ asOptionalPositiveFiniteNumber
262
+ } from "./chunk-U6VC4MU4.js";
263
+ import {
264
+ buildAgentsMdLayer,
265
+ buildAgentsMdLayerHeader,
266
+ buildDialogSummaryLayer,
267
+ hasMemoryTools
268
+ } from "./chunk-5HUO7SEX.js";
269
+ import {
270
+ MEMORY_USE_GUIDANCE,
271
+ buildUserResponseLanguageContext
272
+ } from "./chunk-YGDYYFRX.js";
249
273
  import {
250
274
  buildProviderAuthHeaders,
251
275
  buildProviderExecutionPlan
252
- } from "./chunk-2OLYKYNY.js";
276
+ } from "./chunk-RTHFJZ6M.js";
253
277
  import {
254
278
  toErrorMessage
255
279
  } from "./chunk-HNMXYYJR.js";
@@ -259,15 +283,6 @@ import {
259
283
  import {
260
284
  isRecord
261
285
  } from "./chunk-KUG52IAP.js";
262
- import {
263
- PLATFORM_HOSTED_DEEPSEEK_FLASH_MODEL
264
- } from "./chunk-VALBGPM6.js";
265
- import {
266
- asTrimmedLowercaseString
267
- } from "./chunk-QSJ3HFEF.js";
268
- import {
269
- asOptionalPositiveFiniteNumber
270
- } from "./chunk-U6VC4MU4.js";
271
286
  import {
272
287
  asOptionalTrimmedString
273
288
  } from "./chunk-G3SUCT4W.js";
@@ -275,8 +290,11 @@ import {
275
290
  normalizeServerOrigin
276
291
  } from "./chunk-CF7PE763.js";
277
292
  import {
278
- resolveNoloStateDir
279
- } from "./chunk-6UBGXX2W.js";
293
+ PLATFORM_HOSTED_DEEPSEEK_FLASH_MODEL
294
+ } from "./chunk-OBSEKCVK.js";
295
+ import {
296
+ asTrimmedLowercaseString
297
+ } from "./chunk-QSJ3HFEF.js";
280
298
  import {
281
299
  __export
282
300
  } from "./chunk-U67V476Y.js";
@@ -323,6 +341,36 @@ function readTitleParams(value) {
323
341
  return Object.fromEntries(entries);
324
342
  }
325
343
 
344
+ // packages/agent-runtime/dialogHistoryOrder.ts
345
+ import { decodeTime } from "ulid";
346
+ function orderDialogHistory(messages) {
347
+ const time = (message) => {
348
+ if (Number.isFinite(message.cliHistoryOrder)) return message.cliHistoryOrder;
349
+ const id = message.id ?? message.cliMessageId;
350
+ if (!id) return Infinity;
351
+ const timestamp = /^(\d+)-/.exec(id);
352
+ if (timestamp) return Number(timestamp[1]);
353
+ if (/^[0-9A-HJKMNP-TV-Z]{26}$/.test(id)) {
354
+ try {
355
+ return decodeTime(id);
356
+ } catch {
357
+ }
358
+ }
359
+ return Number.isFinite(message.createdAt) ? message.createdAt : -Infinity;
360
+ };
361
+ const identity2 = (message) => message.id ?? message.cliMessageId;
362
+ return messages.map((message, index) => ({ message, index, time: time(message) })).sort((a, b) => {
363
+ if (a.time !== b.time) return a.time < b.time ? -1 : 1;
364
+ const left = identity2(a.message), right = identity2(b.message);
365
+ if (left && right && left !== right) return left < right ? -1 : 1;
366
+ return a.index - b.index;
367
+ }).map(({ message }) => message);
368
+ }
369
+ function dialogTurnUserMessageId(turnId, index) {
370
+ if (typeof turnId !== "string" || !/^turn-[0-9A-HJKMNP-TV-Z]{26}$/.test(turnId)) return void 0;
371
+ return `${decodeTime(turnId.slice(5))}-${String(index + 1).padStart(3, "0")}-${turnId}`;
372
+ }
373
+
326
374
  // packages/agent-runtime/contextRefusal.ts
327
375
  var machineIdentifier = (value) => value && /^[A-Z][A-Z0-9_]{0,63}$/.test(value) ? value : void 0;
328
376
  function classifyContextRefusal(args2) {
@@ -5548,8 +5596,8 @@ var runPromiseExitWith = (context3) => {
5548
5596
  const runFork3 = runForkWith(context3);
5549
5597
  return (effect, options) => {
5550
5598
  const fiber3 = runFork3(effect, options);
5551
- return new Promise((resolve6) => {
5552
- fiber3.addObserver((exit3) => resolve6(exit3));
5599
+ return new Promise((resolve7) => {
5600
+ fiber3.addObserver((exit3) => resolve7(exit3));
5553
5601
  });
5554
5602
  };
5555
5603
  };
@@ -12772,8 +12820,8 @@ var toReadableStreamWith = /* @__PURE__ */ dual((args2) => isStream(args2[0]), (
12772
12820
  }
12773
12821
  },
12774
12822
  pull() {
12775
- return new Promise((resolve6) => {
12776
- currentResolve = resolve6;
12823
+ return new Promise((resolve7) => {
12824
+ currentResolve = resolve7;
12777
12825
  latch.openUnsafe();
12778
12826
  });
12779
12827
  },
@@ -13307,255 +13355,6 @@ function sanitizeToolCallPairing(messages) {
13307
13355
  return output;
13308
13356
  }
13309
13357
 
13310
- // packages/agent-runtime/secretScrubber.ts
13311
- var SECRET_PATTERNS = [
13312
- // 1. PEM 私钥块(高危硬拦截)
13313
- {
13314
- kind: "PRIVATE_KEY",
13315
- placeholder: "[REDACTED:PRIVATE_KEY]",
13316
- regex: /-----BEGIN (?:[A-Z0-9 ]+)?PRIVATE KEY-----[\s\S]+?-----END (?:[A-Z0-9 ]+)?PRIVATE KEY-----/g
13317
- },
13318
- // 2. Anthropic API Key (sk-ant-...)
13319
- {
13320
- kind: "ANTHROPIC_KEY",
13321
- placeholder: "[REDACTED:ANTHROPIC_KEY]",
13322
- regex: /\bsk-ant-[a-zA-Z0-9_\-]{20,}\b/g
13323
- },
13324
- // 3. OpenAI / DeepSeek / 通用 API Key (sk-...)
13325
- {
13326
- kind: "API_KEY",
13327
- placeholder: "[REDACTED:API_KEY]",
13328
- regex: /\bsk-[a-zA-Z0-9_\-]{24,}\b/g
13329
- },
13330
- // 3b. BigModel / 智谱(GLM)API Key:32 位 hex + "." + 16 位字母数字
13331
- // (2026-11 实证:这类 key 没有任何可辨识前缀,此前漏在清洗与入路隔离之外,
13332
- // 用户贴进对话后明文直接进了 prompt / 历史 / 工具日志。)
13333
- {
13334
- kind: "BIGMODEL_KEY",
13335
- placeholder: "[REDACTED:BIGMODEL_KEY]",
13336
- regex: /\b[0-9a-fA-F]{32}\.[A-Za-z0-9]{16}\b/g
13337
- },
13338
- // 4. GitHub 访问令牌 (ghp_..., gho_..., github_pat_...)
13339
- {
13340
- kind: "GITHUB_TOKEN",
13341
- placeholder: "[REDACTED:GITHUB_TOKEN]",
13342
- regex: /\b(?:gh[pousr]_[a-zA-Z0-9]{30,}|github_pat_[a-zA-Z0-9_]{40,})\b/g
13343
- },
13344
- // 5. Bearer Token (JWT / Authorization Bearer)
13345
- {
13346
- kind: "BEARER_TOKEN",
13347
- placeholder: "Bearer [REDACTED:BEARER_TOKEN]",
13348
- regex: /\bBearer\s+[a-zA-Z0-9_\-\.]{25,}\b/gi
13349
- },
13350
- // 6. 常见环境变量或配置中的密码赋值 (PASSWORD=..., PASSWD=...)
13351
- {
13352
- kind: "PASSWORD",
13353
- placeholder: "$1=[REDACTED:PASSWORD]",
13354
- regex: /\b((?:DB_|DATABASE_|ADMIN_|ROOT_|MYSQL_|POSTGRES_)?(?:PASSWORD|PASSWD|SECRET_KEY))\s*=\s*['"]?([^\s'"]{4,})['"]?/gi
13355
- }
13356
- ];
13357
- var QUICK_PROBE_SUBSTRINGS = [
13358
- "sk-",
13359
- "ghp_",
13360
- "gho_",
13361
- "ghu_",
13362
- "ghs_",
13363
- "ghr_",
13364
- "github_pat_",
13365
- "PRIVATE KEY",
13366
- "Bearer ",
13367
- "bearer ",
13368
- "PASSWORD",
13369
- "password",
13370
- "PASSWD",
13371
- "SECRET_KEY"
13372
- ];
13373
- var UNPREFIXED_PROBE_REGEX = /\b[0-9a-fA-F]{32}\.[A-Za-z0-9]{16}\b/;
13374
- function hasPotentialSecrets(text2) {
13375
- if (typeof text2 !== "string" || text2.length === 0) return false;
13376
- if (QUICK_PROBE_SUBSTRINGS.some((probe) => text2.includes(probe))) return true;
13377
- return UNPREFIXED_PROBE_REGEX.test(text2);
13378
- }
13379
- function scrubSecrets(text2) {
13380
- if (typeof text2 !== "string" || text2.length === 0) {
13381
- return { cleaned: text2, redactedCount: 0, matchedKinds: [] };
13382
- }
13383
- if (!hasPotentialSecrets(text2)) {
13384
- return { cleaned: text2, redactedCount: 0, matchedKinds: [] };
13385
- }
13386
- let cleaned = text2;
13387
- let redactedCount = 0;
13388
- const matchedKinds = [];
13389
- for (const pattern of SECRET_PATTERNS) {
13390
- pattern.regex.lastIndex = 0;
13391
- const matches = cleaned.match(pattern.regex);
13392
- if (matches && matches.length > 0) {
13393
- redactedCount += matches.length;
13394
- if (!matchedKinds.includes(pattern.kind)) {
13395
- matchedKinds.push(pattern.kind);
13396
- }
13397
- cleaned = cleaned.replace(pattern.regex, pattern.placeholder);
13398
- }
13399
- }
13400
- return { cleaned, redactedCount, matchedKinds };
13401
- }
13402
- function scrubObjectSecrets(val) {
13403
- if (val === null || val === void 0) return val;
13404
- if (typeof val === "string") {
13405
- return scrubSecrets(val).cleaned;
13406
- }
13407
- if (Array.isArray(val)) {
13408
- return val.map((item) => scrubObjectSecrets(item));
13409
- }
13410
- if (typeof val === "object") {
13411
- if (val instanceof Date || val instanceof RegExp) return val;
13412
- const result4 = {};
13413
- for (const [k, v] of Object.entries(val)) {
13414
- result4[k] = scrubObjectSecrets(v);
13415
- }
13416
- return result4;
13417
- }
13418
- return val;
13419
- }
13420
-
13421
- // packages/agent-runtime/toolOutputSanitizer.ts
13422
- var SANITIZE_REPLACEMENT_CHAR = "\uFFFD";
13423
- var MAX_CONTROL_SEQUENCE_CHARS = 256;
13424
- var ESC = 27;
13425
- var BEL = 7;
13426
- var LINE_FEED = 10;
13427
- var TAB = 9;
13428
- var DEL = 127;
13429
- var C1_DCS = 144;
13430
- var C1_SOS = 152;
13431
- var C1_CSI = 155;
13432
- var C1_ST = 156;
13433
- var C1_OSC = 157;
13434
- var C1_PM = 158;
13435
- var C1_APC = 159;
13436
- var HIGH_SURROGATE_MIN = 55296;
13437
- var HIGH_SURROGATE_MAX = 56319;
13438
- var LOW_SURROGATE_MIN = 56320;
13439
- var LOW_SURROGATE_MAX = 57343;
13440
- var NEEDS_SANITIZE_RE = new RegExp("[\\u0000-\\u0008\\u000b-\\u001f\\u007f-\\u009f]|\\p{Cs}", "u");
13441
- function isC1Introducer(code) {
13442
- return code === C1_CSI || code === C1_OSC || code === C1_DCS || code === C1_SOS || code === C1_PM || code === C1_APC;
13443
- }
13444
- var UNTERMINATED_SEQUENCE = -1;
13445
- function skipCsiBody(text2, start, limit) {
13446
- let i = start;
13447
- while (i < limit) {
13448
- const code = text2.charCodeAt(i);
13449
- if (code >= 64 && code <= 126) return i + 1;
13450
- if (code >= 32 && code <= 63) {
13451
- i += 1;
13452
- continue;
13453
- }
13454
- return i;
13455
- }
13456
- return UNTERMINATED_SEQUENCE;
13457
- }
13458
- function skipControlStringBody(text2, start, limit) {
13459
- const length = text2.length;
13460
- let i = start;
13461
- while (i < limit) {
13462
- const code = text2.charCodeAt(i);
13463
- if (code === BEL || code === C1_ST) return i + 1;
13464
- if (code === ESC && i + 1 < length && text2.charCodeAt(i + 1) === 92) {
13465
- return Math.min(i + 2, limit);
13466
- }
13467
- i += 1;
13468
- }
13469
- return UNTERMINATED_SEQUENCE;
13470
- }
13471
- function skipEscapeSequence(text2, escIndex) {
13472
- const length = text2.length;
13473
- const limit = Math.min(length, escIndex + MAX_CONTROL_SEQUENCE_CHARS);
13474
- const leadIndex = escIndex + 1;
13475
- if (leadIndex >= length) return leadIndex;
13476
- const lead = text2.charCodeAt(leadIndex);
13477
- if (lead === 91) {
13478
- const csiEnd = skipCsiBody(text2, leadIndex + 1, limit);
13479
- return csiEnd === UNTERMINATED_SEQUENCE ? escIndex + 1 : csiEnd;
13480
- }
13481
- if (lead === 93 || lead === 80 || lead === 88 || lead === 94 || lead === 95) {
13482
- const stringEnd = skipControlStringBody(text2, leadIndex + 1, limit);
13483
- return stringEnd === UNTERMINATED_SEQUENCE ? escIndex + 1 : stringEnd;
13484
- }
13485
- let j = leadIndex;
13486
- while (j < limit && text2.charCodeAt(j) >= 32 && text2.charCodeAt(j) <= 47) {
13487
- j += 1;
13488
- }
13489
- if (j < limit) {
13490
- const final = text2.charCodeAt(j);
13491
- if (final >= 48 && final <= 126) return j + 1;
13492
- }
13493
- return escIndex + 1;
13494
- }
13495
- function skipC1Sequence(text2, index) {
13496
- const limit = Math.min(text2.length, index + MAX_CONTROL_SEQUENCE_CHARS);
13497
- const code = text2.charCodeAt(index);
13498
- const bodyEnd = code === C1_CSI ? skipCsiBody(text2, index + 1, limit) : skipControlStringBody(text2, index + 1, limit);
13499
- return bodyEnd === UNTERMINATED_SEQUENCE ? index + 1 : bodyEnd;
13500
- }
13501
- function sanitizeToolOutputText(text2) {
13502
- if (typeof text2 !== "string" || text2.length === 0) return text2;
13503
- if (!NEEDS_SANITIZE_RE.test(text2)) return text2;
13504
- const out = [];
13505
- const length = text2.length;
13506
- let plainStart = 0;
13507
- let i = 0;
13508
- const dropRange = (end3) => {
13509
- if (plainStart < i) out.push(text2.slice(plainStart, i));
13510
- i = end3;
13511
- plainStart = end3;
13512
- };
13513
- while (i < length) {
13514
- const code = text2.charCodeAt(i);
13515
- if (code === LINE_FEED || code === TAB) {
13516
- i += 1;
13517
- continue;
13518
- }
13519
- if (code === ESC) {
13520
- dropRange(skipEscapeSequence(text2, i));
13521
- continue;
13522
- }
13523
- if (isC1Introducer(code)) {
13524
- dropRange(skipC1Sequence(text2, i));
13525
- continue;
13526
- }
13527
- if (code < 32 || code === DEL || code >= 128 && code <= 159) {
13528
- dropRange(i + 1);
13529
- continue;
13530
- }
13531
- if (code >= HIGH_SURROGATE_MIN && code <= HIGH_SURROGATE_MAX) {
13532
- const low = text2.charCodeAt(i + 1);
13533
- if (low >= LOW_SURROGATE_MIN && low <= LOW_SURROGATE_MAX) {
13534
- i += 2;
13535
- continue;
13536
- }
13537
- if (plainStart < i) out.push(text2.slice(plainStart, i));
13538
- out.push(SANITIZE_REPLACEMENT_CHAR);
13539
- i += 1;
13540
- plainStart = i;
13541
- continue;
13542
- }
13543
- if (code >= LOW_SURROGATE_MIN && code <= LOW_SURROGATE_MAX) {
13544
- if (plainStart < i) out.push(text2.slice(plainStart, i));
13545
- out.push(SANITIZE_REPLACEMENT_CHAR);
13546
- i += 1;
13547
- plainStart = i;
13548
- continue;
13549
- }
13550
- i += 1;
13551
- }
13552
- if (plainStart < length) out.push(text2.slice(plainStart));
13553
- return out.join("");
13554
- }
13555
- function sanitizeToolOutputContent(content) {
13556
- return typeof content === "string" ? sanitizeToolOutputText(content) : content;
13557
- }
13558
-
13559
13358
  // packages/agent-runtime/providerMessageProjection.ts
13560
13359
  var TOOL_DURATION_METADATA_KEY = "toolExecMs";
13561
13360
  var OBSERVATION_ONLY_METADATA_KEYS = /* @__PURE__ */ new Set([
@@ -13702,6 +13501,7 @@ function projectToolContentForProvider(args2) {
13702
13501
  const content = typeof rawContent === "string" ? sanitizeToolOutputText(rawContent) : rawContent;
13703
13502
  if (typeof content !== "string") return content;
13704
13503
  if (isSpilledToolOutput(content)) return content;
13504
+ if (isCompleteInstructionOutput(args2.toolName, args2.metadata, content)) return content;
13705
13505
  const metadataText = compactToolMetadata(args2.metadata);
13706
13506
  const embeddedMetadataIndex = metadataText ? content.indexOf("\n\n[tool metadata]\n") : -1;
13707
13507
  const contentForProjection = embeddedMetadataIndex >= 0 ? content.slice(0, embeddedMetadataIndex) : content;
@@ -13900,7 +13700,8 @@ ${args2.input}` : [
13900
13700
  const prefix2 = stableContent ? [{
13901
13701
  role: "system",
13902
13702
  content: stableContent,
13903
- stable_prefix_chars: stableContent.length
13703
+ stable_prefix_chars: stableContent.length,
13704
+ ...args2.prompt?.trim() ? { [AGENT_PROMPT_IN_MESSAGES]: true } : {}
13904
13705
  }] : [];
13905
13706
  const composed2 = composeProviderMessages({
13906
13707
  prefix: prefix2,
@@ -13923,7 +13724,11 @@ ${args2.input}` : [
13923
13724
  }
13924
13725
  const blocks = (args2.contextBlocks ?? []).map((block) => block.trim()).filter(Boolean);
13925
13726
  const systemContent = [args2.prompt?.trim(), ...blocks].filter(Boolean).join("\n\n");
13926
- const prefix = systemContent ? [{ role: "system", content: systemContent }] : [];
13727
+ const prefix = systemContent ? [{
13728
+ role: "system",
13729
+ content: systemContent,
13730
+ ...args2.prompt?.trim() ? { [AGENT_PROMPT_IN_MESSAGES]: true } : {}
13731
+ }] : [];
13927
13732
  const composed = composeProviderMessages({
13928
13733
  prefix,
13929
13734
  history: args2.history,
@@ -15033,12 +14838,255 @@ async function invokeCapability(capabilityOrName, input, ctx = {}) {
15033
14838
  }
15034
14839
 
15035
14840
  // packages/agent-runtime/localWorkspaceTools.ts
15036
- import { existsSync as existsSync2 } from "node:fs";
14841
+ import { existsSync as existsSync3 } from "node:fs";
15037
14842
  import { createHash as createHash3 } from "node:crypto";
15038
14843
 
14844
+ // packages/agent-runtime/agentsMd.ts
14845
+ import { existsSync, readFileSync } from "node:fs";
14846
+ import { resolve } from "node:path";
14847
+ var AGENTS_MD_MAX_BYTES = 8192;
14848
+ var AGENTS_MD_MARKER_RESERVE_BYTES = 512;
14849
+ var AGENTS_MD_CANDIDATES = ["AGENTS.md", "CLAUDE.md"];
14850
+ function truncateAgentsMdContent(content, maxBytes = AGENTS_MD_MAX_BYTES) {
14851
+ const buf = Buffer.from(content, "utf8");
14852
+ if (buf.byteLength <= maxBytes) {
14853
+ return content;
14854
+ }
14855
+ let boundary = Math.min(maxBytes, buf.byteLength);
14856
+ while (boundary > 0 && boundary < buf.byteLength && (buf[boundary] & 192) === 128) {
14857
+ boundary--;
14858
+ }
14859
+ const boundarySlice = buf.subarray(0, boundary).toString("utf8");
14860
+ const slice = buf.subarray(0, maxBytes);
14861
+ const lastNewline = slice.lastIndexOf(10);
14862
+ if (lastNewline > 0) {
14863
+ const lineCandidate = slice.subarray(0, lastNewline).toString("utf8");
14864
+ const lineBytes = Buffer.byteLength(lineCandidate, "utf8");
14865
+ const boundaryBytes = Buffer.byteLength(boundarySlice, "utf8");
14866
+ if (lineCandidate.trim().length > 0 && lineBytes * 2 >= boundaryBytes) {
14867
+ return lineCandidate.replace(/\r$/, "");
14868
+ }
14869
+ }
14870
+ return boundarySlice.replace(/\r$/, "");
14871
+ }
14872
+ var AGENTS_MD_SUMMARY_MAX_BYTES = 3072;
14873
+ var AGENTS_MD_SUMMARY_ITEM_MAX_CHARS = 120;
14874
+ var AGENTS_MD_SUMMARY_PRIORITY_KEYWORDS = [
14875
+ "review",
14876
+ "\u8BC4\u5BA1",
14877
+ "commit",
14878
+ "\u63D0\u4EA4",
14879
+ "worktree",
14880
+ "\u6D4B\u8BD5",
14881
+ "typecheck",
14882
+ "\u7C7B\u578B\u68C0\u67E5",
14883
+ "push",
14884
+ "\u53D1\u5E03",
14885
+ "\u6587\u6863\u843D\u4F4D",
14886
+ "\u5220\u9664",
14887
+ "\u6D3E\u53D1"
14888
+ ];
14889
+ var AGENTS_MD_SUMMARY_POINTER_INSTRUCTION = "\u7528 readFile \u8BFB\u5168\u6587\uFF1A%REL%\uFF08cwd\uFF09/ %PATH%\n\u4EC5\u7D22\u5F15\uFF1A\u63D0\u4EA4/\u8BC4\u5BA1\u95E8\u7981\u3001worktree \u9694\u79BB\u3001\u6D4B\u8BD5/typecheck\u3001\u6587\u6863\u843D\u4F4D\u3001\u5220\u9664\u3001push/\u53D1\u5E03\u524D\uFF0C**\u5FC5\u987B\u5148 readFile \u8BFB\u5168\u6587\u518D\u6267\u884C**\u3002\n\u8DEF\u5F84\uFF1A%REL% \u76F8\u5BF9 cwd\uFF1Bmachine:<id>/\u6C99\u76D2\u6267\u884C\u9762 cwd \u7531\u5176\u51B3\u5B9A\uFF0C\u8BFB\u4E0D\u5230\u8BA9\u5BBF\u4E3B\u6CE8\u5165\u6216\u7528\u7EDD\u5BF9\u8DEF\u5F84\u3002";
14890
+ var AGENTS_MD_SUMMARY_DELETE_REFERENCE = "- \u5220\u9664/\u4E0D\u53EF\u9006\u64CD\u4F5C\uFF1A\u9075\u5B88\u7CFB\u7EDF\u63D0\u793A\u7684\u5220\u9664\u7EA2\u7EBF\uFF08\u5148\u5448\u73B0\u5B8C\u6574\u5F85\u5220\u6E05\u5355\u5E76\u83B7\u7528\u6237\u660E\u786E\u786E\u8BA4\uFF0C\u7981\u6B62\u5148\u5220\u540E\u62A5\u3001\u7981\u6B62\u6A21\u7CCA\u5B9A\u4F4D\uFF09\uFF0C\u4ED3\u5E93\u82E5\u6709\u9644\u52A0\u5220\u9664\u89C4\u5219\u89C1\u5B8C\u6574\u6587\u4EF6\u3002";
14891
+ var clipToChars = (text2, maxChars) => text2.length <= maxChars ? text2 : `${text2.slice(0, maxChars).trimEnd()}\u2026`;
14892
+ var parseAgentsMdItem = (body) => {
14893
+ const bold = /^\*\*(.+?)\*\*/.exec(body);
14894
+ if (bold) {
14895
+ return {
14896
+ label: bold[1].trim().replace(/[::]$/, ""),
14897
+ rest: body.slice(bold[0].length).replace(/^[::\s]+/, "")
14898
+ };
14899
+ }
14900
+ const firstClause = body.split(/[::]/)[0];
14901
+ return {
14902
+ label: clipToChars(firstClause.trim(), 40),
14903
+ rest: body.slice(firstClause.length).replace(/^[::\s]+/, "")
14904
+ };
14905
+ };
14906
+ var AGENTS_MD_COMMAND_TOKEN_PREFIX = /^(bunx?|npx|node|npm|pnpm|yarn|git|gh|tsc|deno)\b\s/;
14907
+ var extractAgentsMdCommandTokens = (body) => {
14908
+ const tokens = [];
14909
+ const seen = /* @__PURE__ */ new Set();
14910
+ for (const match7 of body.matchAll(/`([^`\n]+)`/g)) {
14911
+ const raw = match7[1];
14912
+ if (!AGENTS_MD_COMMAND_TOKEN_PREFIX.test(raw)) continue;
14913
+ if (seen.has(raw)) continue;
14914
+ seen.add(raw);
14915
+ tokens.push(raw);
14916
+ }
14917
+ return tokens;
14918
+ };
14919
+ var buildAgentsMdItemGist = (firstSentence, bulletBody) => {
14920
+ const max4 = AGENTS_MD_SUMMARY_ITEM_MAX_CHARS;
14921
+ const clipped = clipToChars(firstSentence, max4);
14922
+ const missing = extractAgentsMdCommandTokens(bulletBody).filter(
14923
+ (token) => !clipped.includes(token)
14924
+ );
14925
+ if (missing.length === 0) return clipped;
14926
+ let tail = "";
14927
+ for (const token of missing) {
14928
+ const candidate = tail ? `${tail} \`${token}\`` : `\`${token}\``;
14929
+ if (candidate.length > max4) continue;
14930
+ tail = candidate;
14931
+ }
14932
+ if (!tail) return clipped;
14933
+ const room = max4 - tail.length - 2;
14934
+ const head3 = room > 0 ? clipToChars(firstSentence, room) : "";
14935
+ return head3 ? `${head3} ${tail}` : tail;
14936
+ };
14937
+ var priorityOf = (label) => {
14938
+ const lowered = label.toLowerCase();
14939
+ for (let i = 0; i < AGENTS_MD_SUMMARY_PRIORITY_KEYWORDS.length; i += 1) {
14940
+ if (lowered.includes(AGENTS_MD_SUMMARY_PRIORITY_KEYWORDS[i].toLowerCase())) {
14941
+ return i;
14942
+ }
14943
+ }
14944
+ return -1;
14945
+ };
14946
+ var collectAgentsMdSummaryItems = (content) => {
14947
+ const items = [];
14948
+ const seen = /* @__PURE__ */ new Set();
14949
+ let section = null;
14950
+ for (const rawLine of content.split(/\r?\n/)) {
14951
+ const line = rawLine.trim();
14952
+ if (!line) continue;
14953
+ const heading = /^#{2,3}\s+(.+)$/.exec(line);
14954
+ if (heading) {
14955
+ section = heading[1].trim();
14956
+ continue;
14957
+ }
14958
+ if (line.startsWith("#") || line.startsWith("<") || line.startsWith("<!--")) {
14959
+ continue;
14960
+ }
14961
+ const bullet = /^[-*]\s+(.+)$/.exec(line);
14962
+ if (!bullet) continue;
14963
+ const { label, rest } = parseAgentsMdItem(bullet[1]);
14964
+ if (!label || seen.has(label)) continue;
14965
+ seen.add(label);
14966
+ const firstSentence = rest.split("\u3002")[0].trim();
14967
+ items.push({
14968
+ section,
14969
+ label,
14970
+ gist: buildAgentsMdItemGist(firstSentence, bullet[1]),
14971
+ priority: priorityOf(label)
14972
+ });
14973
+ }
14974
+ return items;
14975
+ };
14976
+ function buildAgentsMdSummaryBody(content, filePath, options = {}) {
14977
+ const budgetBytes = options.budgetBytes ?? AGENTS_MD_SUMMARY_MAX_BYTES;
14978
+ const items = collectAgentsMdSummaryItems(content);
14979
+ if (items.length === 0) return null;
14980
+ const relativePath = options.fileName ?? "AGENTS.md";
14981
+ const pointer = AGENTS_MD_SUMMARY_POINTER_INSTRUCTION.replaceAll(
14982
+ "%REL%",
14983
+ relativePath
14984
+ ).replaceAll("%PATH%", filePath);
14985
+ const head3 = `${pointer}
14986
+ ${AGENTS_MD_SUMMARY_DELETE_REFERENCE}
14987
+ `;
14988
+ if (Buffer.byteLength(head3, "utf8") > budgetBytes) return null;
14989
+ const candidates = [
14990
+ ...items.filter((item) => item.priority >= 0).sort((a, b) => a.priority - b.priority),
14991
+ ...items.filter((item) => item.priority < 0)
14992
+ ];
14993
+ const noteBlock = `
14994
+ \u2026\uFF08\u7D22\u5F15\u5DF2\u622A\u65AD\uFF0C\u5176\u4F59\u951A\u70B9\u89C1\u5B8C\u6574\u6587\u4EF6\uFF09`;
14995
+ const noteBytes = Buffer.byteLength(noteBlock, "utf8");
14996
+ let used = Buffer.byteLength(head3, "utf8");
14997
+ const admitted = [];
14998
+ const seenSections = /* @__PURE__ */ new Set();
14999
+ let truncated = false;
15000
+ for (const item of candidates) {
15001
+ const line = item.gist ? `- ${item.label}\uFF1A${item.gist}` : `- ${item.label}`;
15002
+ const headingCost = item.section && !seenSections.has(item.section) ? Buffer.byteLength(`
15003
+ ## ${item.section}`, "utf8") : 0;
15004
+ const cost = headingCost + Buffer.byteLength(`
15005
+ ${line}`, "utf8");
15006
+ if (used + cost + noteBytes > budgetBytes) {
15007
+ truncated = true;
15008
+ continue;
15009
+ }
15010
+ used += cost;
15011
+ if (item.section) seenSections.add(item.section);
15012
+ admitted.push(item);
15013
+ }
15014
+ const groupOrder = [];
15015
+ for (const item of admitted) {
15016
+ if (!groupOrder.includes(item.section)) groupOrder.push(item.section);
15017
+ }
15018
+ const frozen = [];
15019
+ for (const section of groupOrder) {
15020
+ for (const item of admitted) {
15021
+ if (item.section !== section) continue;
15022
+ frozen.push({
15023
+ section,
15024
+ line: item.gist ? `- ${item.label}\uFF1A${item.gist}` : `- ${item.label}`
15025
+ });
15026
+ }
15027
+ }
15028
+ if (admitted.length === 0) return null;
15029
+ return `${head3}${renderSummarySections(frozen)}${truncated ? noteBlock : ""}`;
15030
+ }
15031
+ var renderSummarySections = (entries) => {
15032
+ let rendered = "";
15033
+ let currentSection = null;
15034
+ for (const entry of entries) {
15035
+ if (entry.section && entry.section !== currentSection) {
15036
+ rendered += `
15037
+ ## ${entry.section}`;
15038
+ currentSection = entry.section;
15039
+ }
15040
+ rendered += `
15041
+ ${entry.line}`;
15042
+ }
15043
+ return rendered;
15044
+ };
15045
+ function readAgentsMdLayerFromDisk(cwd) {
15046
+ for (const name of AGENTS_MD_CANDIDATES) {
15047
+ const filePath = resolve(cwd, name);
15048
+ if (!existsSync(filePath)) continue;
15049
+ try {
15050
+ const raw = readFileSync(filePath, "utf8");
15051
+ const content = raw.trim();
15052
+ if (!content) continue;
15053
+ const totalBytes = Buffer.byteLength(raw, "utf8");
15054
+ const trimmedBytes = Buffer.byteLength(content, "utf8");
15055
+ const headerBytes = Buffer.byteLength(buildAgentsMdLayerHeader(name), "utf8");
15056
+ if (headerBytes + trimmedBytes <= AGENTS_MD_MAX_BYTES) {
15057
+ return buildAgentsMdLayer(content, name);
15058
+ }
15059
+ const summaryBody = buildAgentsMdSummaryBody(content, filePath, {
15060
+ // 正文预算 = 摘要上限 − 块头部:buildAgentsMdLayer 会再拼一次头部,
15061
+ // 因此「头部 + 正文」才等于最终注入字节,不得超过摘要上限。
15062
+ budgetBytes: AGENTS_MD_SUMMARY_MAX_BYTES - headerBytes,
15063
+ fileName: name
15064
+ });
15065
+ if (summaryBody) return buildAgentsMdLayer(summaryBody, name);
15066
+ const buildMarker = (omitted2, withPath) => {
15067
+ const pathPart = withPath ? `\u5B8C\u6574\u6587\u4EF6\uFF1A${filePath}` : `\u5B8C\u6574\u6587\u4EF6\uFF1A\u5DE5\u4F5C\u533A\u6839\u76EE\u5F55\u7684 ${name}`;
15068
+ return `<!-- AGENTS.md truncated: \u539F\u6587\u4EF6 ${totalBytes} \u5B57\u8282\uFF0C\u6CE8\u5165\u9884\u7B97 ${AGENTS_MD_MAX_BYTES} \u5B57\u8282\uFF0C\u5DF2\u7701\u7565 ${omitted2} \u5B57\u8282\uFF08\u4E0A\u6587\u53EF\u80FD\u7F3A\u5C11\u6587\u4EF6\u672B\u5C3E\u7684 commit/review \u95E8\u7981\u7EC6\u5219\uFF0C\u63D0\u4EA4/\u8BC4\u5BA1\u524D\u8BF7\u8BFB\u5B8C\u6574\u6587\u4EF6\uFF09\u3002${pathPart} -->`;
15069
+ };
15070
+ const bodyBudget = AGENTS_MD_MAX_BYTES - AGENTS_MD_MARKER_RESERVE_BYTES - 2 - headerBytes;
15071
+ const body = truncateAgentsMdContent(content, bodyBudget);
15072
+ const bodyBytes = Buffer.byteLength(body, "utf8");
15073
+ const omitted = Math.max(0, totalBytes - bodyBytes);
15074
+ let marker = buildMarker(omitted, true);
15075
+ if (Buffer.byteLength(marker, "utf8") > AGENTS_MD_MARKER_RESERVE_BYTES) {
15076
+ marker = buildMarker(omitted, false);
15077
+ }
15078
+ return buildAgentsMdLayer(`${body}
15079
+
15080
+ ${marker}`, name);
15081
+ } catch {
15082
+ }
15083
+ }
15084
+ return null;
15085
+ }
15086
+
15039
15087
  // packages/agent-runtime/visualRenderer.node.ts
15040
15088
  import { createRequire } from "node:module";
15041
- import { existsSync } from "node:fs";
15089
+ import { existsSync as existsSync2 } from "node:fs";
15042
15090
  import { realpath, stat, readFile } from "node:fs/promises";
15043
15091
  import { isAbsolute, relative, win32 } from "node:path";
15044
15092
  import { fileURLToPath, pathToFileURL } from "node:url";
@@ -15091,7 +15139,7 @@ var VisualRenderSemaphore = class {
15091
15139
  active = 0;
15092
15140
  queue = [];
15093
15141
  async run(task) {
15094
- if (this.active >= this.limit) await new Promise((resolve6) => this.queue.push(resolve6));
15142
+ if (this.active >= this.limit) await new Promise((resolve7) => this.queue.push(resolve7));
15095
15143
  else this.active++;
15096
15144
  try {
15097
15145
  return await task();
@@ -15109,7 +15157,7 @@ function visualRendererCapability() {
15109
15157
  if (process.env.NOLO_VISUAL_RENDERER_DISABLED === "1") return { available: false, reasonCode: "disabled", reason: "Platform renderer disabled by NOLO_VISUAL_RENDERER_DISABLED=1 on this runtime host." };
15110
15158
  try {
15111
15159
  const { chromium } = require2("playwright");
15112
- const executablePath = [chromium.executablePath(), resolveExecutableOnPath("google-chrome"), resolveExecutableOnPath("chromium"), resolveExecutableOnPath("chromium-browser")].find((path) => !!path && existsSync(path));
15160
+ const executablePath = [chromium.executablePath(), resolveExecutableOnPath("google-chrome"), resolveExecutableOnPath("chromium"), resolveExecutableOnPath("chromium-browser")].find((path) => !!path && existsSync2(path));
15113
15161
  if (!executablePath) return { available: false, reasonCode: "missing-browser", reason: "No Chromium renderer installed. Install Playwright Chromium (playwright install chromium) or system Chromium/Google Chrome on the runtime host." };
15114
15162
  return { available: true, chromium, executablePath };
15115
15163
  } catch {
@@ -15285,7 +15333,7 @@ finally:
15285
15333
  pass
15286
15334
  bus.signal_unsubscribe(subscription)
15287
15335
  `;
15288
- var capturePortalScreenshot = (signal) => new Promise((resolve6, reject) => {
15336
+ var capturePortalScreenshot = (signal) => new Promise((resolve7, reject) => {
15289
15337
  const child = spawn("/usr/bin/python3", ["-c", PORTAL_SCRIPT], { stdio: ["ignore", "pipe", "pipe"] });
15290
15338
  let stdout = "";
15291
15339
  let stderr = "";
@@ -15306,7 +15354,7 @@ var capturePortalScreenshot = (signal) => new Promise((resolve6, reject) => {
15306
15354
  if (signal.aborted) return reject(new Error("portal capture timeout"));
15307
15355
  if (code !== 0) return reject(new Error(stderr.trim() || `portal helper exited ${code}`));
15308
15356
  try {
15309
- resolve6(JSON.parse(stdout));
15357
+ resolve7(JSON.parse(stdout));
15310
15358
  } catch {
15311
15359
  reject(new Error("invalid portal response"));
15312
15360
  }
@@ -15318,7 +15366,7 @@ function createHostWindowCapture(options = {}) {
15318
15366
  let active = 0;
15319
15367
  const waiters = [];
15320
15368
  function acquire(signal) {
15321
- return new Promise((resolve6, reject) => {
15369
+ return new Promise((resolve7, reject) => {
15322
15370
  const abort = () => {
15323
15371
  const index = waiters.indexOf(start);
15324
15372
  if (index >= 0) waiters.splice(index, 1);
@@ -15327,7 +15375,7 @@ function createHostWindowCapture(options = {}) {
15327
15375
  const start = () => {
15328
15376
  signal.removeEventListener("abort", abort);
15329
15377
  active++;
15330
- resolve6();
15378
+ resolve7();
15331
15379
  };
15332
15380
  if (signal.aborted) return abort();
15333
15381
  if (active < concurrency) start();
@@ -15385,7 +15433,7 @@ var captureHostWindow = createHostWindowCapture();
15385
15433
  // packages/agent-runtime/localWorkspaceTools.ts
15386
15434
  import { lstat as lstat2, readdir as readdir2, readFile as readFile4, realpath as realpath3, stat as stat4 } from "node:fs/promises";
15387
15435
  import { homedir } from "node:os";
15388
- import { dirname as dirname2, relative as relative4, resolve as resolve4, sep as sep2 } from "node:path";
15436
+ import { dirname as dirname2, relative as relative4, resolve as resolve5, sep as sep2 } from "node:path";
15389
15437
  import { spawn as spawnChildProcess2 } from "node:child_process";
15390
15438
 
15391
15439
  // packages/agent-runtime/runResultReadProjection.ts
@@ -15468,12 +15516,12 @@ function isLineRangeCovered(request3, covered) {
15468
15516
 
15469
15517
  // packages/agent-runtime/fileTextSearch.ts
15470
15518
  import { readdir, readFile as readFile3, stat as stat3 } from "node:fs/promises";
15471
- import { basename as basename2, relative as relative2, resolve as resolve2 } from "node:path";
15519
+ import { basename as basename2, relative as relative2, resolve as resolve3 } from "node:path";
15472
15520
  import { spawn as spawnChildProcess } from "node:child_process";
15473
15521
 
15474
15522
  // packages/agent-runtime/gitignore.ts
15475
15523
  import { readFile as readFile2, stat as stat2 } from "node:fs/promises";
15476
- import { resolve } from "node:path";
15524
+ import { resolve as resolve2 } from "node:path";
15477
15525
  function isIgnorableFsError(err) {
15478
15526
  if (err && typeof err === "object" && "code" in err) {
15479
15527
  const code = err.code;
@@ -15484,7 +15532,7 @@ function isIgnorableFsError(err) {
15484
15532
  async function readRootGitignorePatterns(workspaceRoot) {
15485
15533
  let content;
15486
15534
  try {
15487
- content = await readFile2(resolve(workspaceRoot, ".gitignore"), "utf8");
15535
+ content = await readFile2(resolve2(workspaceRoot, ".gitignore"), "utf8");
15488
15536
  } catch (err) {
15489
15537
  if (isIgnorableFsError(err)) return [];
15490
15538
  throw err;
@@ -15498,7 +15546,7 @@ async function readRootGitignorePatterns(workspaceRoot) {
15498
15546
  }
15499
15547
  async function hasRootGitignore(workspaceRoot) {
15500
15548
  try {
15501
- await stat2(resolve(workspaceRoot, ".gitignore"));
15549
+ await stat2(resolve2(workspaceRoot, ".gitignore"));
15502
15550
  return true;
15503
15551
  } catch (err) {
15504
15552
  if (isIgnorableFsError(err)) return false;
@@ -15569,7 +15617,7 @@ function parseMatches(root, output) {
15569
15617
  const records = [];
15570
15618
  const pattern = /(?:^|\n)([^\0\n]+)\0(\d+):(.*?)(?=\n[^\0\n]+\0|$)/gs;
15571
15619
  for (const match7 of output.matchAll(pattern)) {
15572
- records.push({ file: resolve2(root, match7[1] ?? ""), line: Number(match7[2]), text: (match7[3] ?? "").replace(/\n$/, "") });
15620
+ records.push({ file: resolve3(root, match7[1] ?? ""), line: Number(match7[2]), text: (match7[3] ?? "").replace(/\n$/, "") });
15573
15621
  }
15574
15622
  return records;
15575
15623
  }
@@ -15627,7 +15675,7 @@ async function jsSearch(o, targetPath) {
15627
15675
  } else {
15628
15676
  const walk = async (dir) => {
15629
15677
  for (const e of await readdir(dir, { withFileTypes: true })) {
15630
- const f = resolve2(dir, e.name), rel = pathFor(o.root, f);
15678
+ const f = resolve3(dir, e.name), rel = pathFor(o.root, f);
15631
15679
  if (e.isDirectory()) {
15632
15680
  if (!excludes.some((p) => globMatch(p, rel))) await walk(f);
15633
15681
  } else if (e.isFile() && !excludes.some((p) => globMatch(p, rel)) && !isIgnored(rel) && (!o.include || globMatch(o.include, rel))) {
@@ -15676,7 +15724,7 @@ var COMMAND_ENGINES = [
15676
15724
  { engine: "grep", binaryOption: "resolveGrepBinary", binaryName: "grep", argsKey: "grep" }
15677
15725
  ];
15678
15726
  async function searchFileTextMatches(o) {
15679
- const targetPath = resolve2(o.root, o.target || ".");
15727
+ const targetPath = resolve3(o.root, o.target || ".");
15680
15728
  const targetStat = await stat3(targetPath).catch(() => null);
15681
15729
  if (!targetStat) return { matches: [], totalMatches: 0, truncated: false, engine: "js" };
15682
15730
  if (targetStat.isFile()) return jsSearch(o, targetPath);
@@ -15745,7 +15793,7 @@ function resolveCleanupReport(evidence, previousStatus) {
15745
15793
  }
15746
15794
  var TERMINAL_EVENT_TYPES = /* @__PURE__ */ new Set(["exited", "killed"]);
15747
15795
  function defaultSleep(ms) {
15748
- return new Promise((resolve6) => setTimeout(resolve6, ms));
15796
+ return new Promise((resolve7) => setTimeout(resolve7, ms));
15749
15797
  }
15750
15798
  function defaultSignalSender(pid, signal) {
15751
15799
  process.kill(pid, signal);
@@ -16020,13 +16068,13 @@ function buildWorkspacePathProperty() {
16020
16068
  };
16021
16069
  }
16022
16070
  function buildReadWorkspaceDescription() {
16023
- return "Read a UTF-8 text file inside the workspace. Absolute paths and ~/ are also accepted (runtime spill files can be read directly). Use lines for focused range reads after search to save tokens. A range already delivered earlier for an unchanged file answers with a short notice instead of resending (force:true refetches).";
16071
+ return "Read a UTF-8 text file inside the workspace. For multiple files, call readFile concurrently in the same turn. Absolute paths and ~/ are also accepted (runtime spill files can be read directly). Use lines for focused range reads after search to save tokens. A range already delivered earlier for an unchanged file answers with a short notice instead of resending (force:true refetches).";
16024
16072
  }
16025
16073
  function buildReadWorkspaceParameters() {
16026
16074
  const path = buildWorkspacePathProperty();
16027
16075
  const lines = {
16028
16076
  type: "string",
16029
- description: 'Line slice: "40-120" (range, 1-based, inclusive), "120-" (from line to end), "-50" (tail N lines), "50" (head N lines). Omit to read full file.'
16077
+ description: 'Line slice: "40-120" (range, 1-based, inclusive), "120-" (from line to end), "-50" (tail N lines), "50" (head N lines). Omit to read from the start; large results return a bounded window. Continue from metadata endLine + 1.'
16030
16078
  };
16031
16079
  const force = {
16032
16080
  type: "boolean",
@@ -16366,9 +16414,9 @@ function filterDeclaredWorkspaceToolNames(args2) {
16366
16414
  // packages/agent-runtime/workspacePathGuard.ts
16367
16415
  import { constants as fsConstants } from "node:fs";
16368
16416
  import { lstat, mkdir, open, readlink, realpath as realpath2 } from "node:fs/promises";
16369
- import { basename as basename3, dirname, isAbsolute as isAbsolute2, join as join2, relative as relative3, resolve as resolve3, sep } from "node:path";
16417
+ import { basename as basename3, dirname, isAbsolute as isAbsolute2, join as join2, relative as relative3, resolve as resolve4, sep } from "node:path";
16370
16418
  function isPathInsideRoot(root, targetPath) {
16371
- const rel = relative3(resolve3(root), resolve3(targetPath));
16419
+ const rel = relative3(resolve4(root), resolve4(targetPath));
16372
16420
  return rel === "" || rel !== ".." && !rel.startsWith(`..${sep}`) && !isAbsolute2(rel);
16373
16421
  }
16374
16422
  function isNotFoundError(error) {
@@ -16377,7 +16425,7 @@ function isNotFoundError(error) {
16377
16425
  }
16378
16426
  async function realpathAllowMissing(targetPath) {
16379
16427
  const tail = [];
16380
- let current = resolve3(targetPath);
16428
+ let current = resolve4(targetPath);
16381
16429
  for (; ; ) {
16382
16430
  try {
16383
16431
  const real = await realpath2(current);
@@ -16396,8 +16444,8 @@ async function realpathAllowMissing(targetPath) {
16396
16444
  }
16397
16445
  async function resolveWorkspaceSafePath(args2) {
16398
16446
  const requested = args2.requestedPath ?? args2.targetPath;
16399
- const lexicalRoot = resolve3(args2.workspaceRoot);
16400
- const targetPath = resolve3(args2.targetPath);
16447
+ const lexicalRoot = resolve4(args2.workspaceRoot);
16448
+ const targetPath = resolve4(args2.targetPath);
16401
16449
  const lexicalInside = args2.lexicalInside ?? isPathInsideRoot(lexicalRoot, targetPath);
16402
16450
  const [physicalRoot, resolved] = await Promise.all([
16403
16451
  realpath2(lexicalRoot).catch(() => null),
@@ -16553,7 +16601,7 @@ async function openPinnedDirectory(dirPath, guard) {
16553
16601
  }
16554
16602
  async function createMissingDirectoryChain(guard) {
16555
16603
  const missing = [];
16556
- let existing = resolve3(guard.path);
16604
+ let existing = resolve4(guard.path);
16557
16605
  for (; ; ) {
16558
16606
  try {
16559
16607
  await lstat(existing);
@@ -16815,7 +16863,6 @@ function readExpectedReplacementCount(args2) {
16815
16863
  }
16816
16864
  return value;
16817
16865
  }
16818
- var READ_FILE_SLICE_FALLBACK_LINES = 200;
16819
16866
  function isAbsentArg(value) {
16820
16867
  return value === void 0 || value === null;
16821
16868
  }
@@ -16887,17 +16934,9 @@ function parseLinesArg(value) {
16887
16934
  return { slice: { startLine, endLine } };
16888
16935
  }
16889
16936
  function readFileSliceArgs(args2) {
16890
- const warnings = [];
16891
- const withFallback = (slice2, invalidLines) => {
16892
- warnings.push(
16893
- `No usable line range remained; returned the first ${READ_FILE_SLICE_FALLBACK_LINES} lines instead of the whole file.`
16894
- );
16895
- return { ...slice2, maxLines: READ_FILE_SLICE_FALLBACK_LINES, warnings, invalidLines };
16896
- };
16897
- if (isAbsentArg(args2.lines)) return { warnings, invalidLines: void 0 };
16937
+ if (isAbsentArg(args2.lines) || args2.lines === "") return {};
16898
16938
  const { slice, warning } = parseLinesArg(args2.lines);
16899
- if (warning) warnings.push(warning);
16900
- return slice ? { ...slice, warnings, invalidLines: void 0 } : withFallback({}, describeRejectedArgValue(args2.lines));
16939
+ return slice ? { slice } : { error: clipMarkerValue(warning ?? "Invalid line range", 240) };
16901
16940
  }
16902
16941
  function buildReadFileSliceHint(totalLines) {
16903
16942
  return `File has ${totalLines} lines. Use lines: ${LINES_ARG_SYNTAX}, or omit it for the whole file.`;
@@ -17040,7 +17079,7 @@ function resolveRipgrepBinary(env = process.env) {
17040
17079
  const fromEnv = asOptionalTrimmedString(env.NOLO_BUNDLED_RG);
17041
17080
  if (fromEnv) {
17042
17081
  try {
17043
- if (existsSync2(fromEnv)) return fromEnv;
17082
+ if (existsSync3(fromEnv)) return fromEnv;
17044
17083
  } catch {
17045
17084
  }
17046
17085
  }
@@ -17061,14 +17100,14 @@ async function resolveRuntimeOwnedSpillPath(targetPath) {
17061
17100
  }
17062
17101
  function expandHomePath(requestedPath) {
17063
17102
  if (requestedPath === "~") return homedir();
17064
- if (requestedPath.startsWith("~/")) return resolve4(homedir(), requestedPath.slice(2));
17103
+ if (requestedPath.startsWith("~/")) return resolve5(homedir(), requestedPath.slice(2));
17065
17104
  return requestedPath;
17066
17105
  }
17067
17106
  function resolveRequestedWorkspacePath(workspaceRoot, requestedPath) {
17068
- return resolve4(resolve4(workspaceRoot), expandHomePath(requestedPath));
17107
+ return resolve5(resolve5(workspaceRoot), expandHomePath(requestedPath));
17069
17108
  }
17070
17109
  async function resolveLocalWorkspaceToolApproval(args2) {
17071
- const workspaceRoot = resolve4(args2.workspaceRoot);
17110
+ const workspaceRoot = resolve5(args2.workspaceRoot);
17072
17111
  const targetPath = resolveRequestedWorkspacePath(workspaceRoot, args2.requestedPath);
17073
17112
  const insideWorkspace = isPathInsideWorkspace({ workspaceRoot, targetPath });
17074
17113
  const guard = await resolveWorkspaceSafePath({
@@ -17165,14 +17204,69 @@ var READ_FILE_LEDGER_MAX_RECORDS = 64;
17165
17204
  var READ_FILE_LEDGER_MAX_KEYS = 256;
17166
17205
  async function readFileTool(args2) {
17167
17206
  const parsed = parseWorkspaceToolArguments(args2.call.arguments);
17168
- const requestedPath = requireWorkspaceToolPath(parsed);
17169
- const { warnings, invalidLines, ...sliceArgs } = readFileSliceArgs(parsed);
17170
- const approval = await resolveLocalWorkspaceToolApproval({
17171
- workspaceRoot: args2.workspaceRoot,
17172
- requestedPath,
17173
- allowRuntimeOwnedSpill: true,
17174
- ...args2.confirmExternalFileAccess ? { confirmExternalFileAccess: args2.confirmExternalFileAccess } : {}
17175
- });
17207
+ if (parsed.files !== void 0 && !args2.batchItem) {
17208
+ if (!Array.isArray(parsed.files) || parsed.files.length < 1 || parsed.files.length > 8 || pickFirstAlias(parsed, PATH_FIELD_ALIASES) !== void 0) {
17209
+ return { content: "[readFile] Supply either path or files (1\u20138 items), not both.", metadata: { status: "invalid-arguments" } };
17210
+ }
17211
+ if (parsed.files.some((file) => !file || typeof file !== "object" || typeof file.path !== "string" || !file.path || file.path.length > 512 || file.lines !== void 0 && typeof file.lines !== "string")) {
17212
+ return { content: "[readFile] Each batch item requires a path (maximum 512 characters) and optional string lines.", metadata: { status: "invalid-arguments" } };
17213
+ }
17214
+ const items = parsed.files.map((item) => ({ path: item.path, status: "not-delivered" }));
17215
+ const budget = resolveHistoricalToolContentCap("readFile", 0);
17216
+ const batchStartLedger = args2.readLedger ? new Map([...args2.readLedger].map(([key, entry2]) => [key, { ...entry2, records: [...entry2.records] }])) : void 0;
17217
+ for (let i = 0; i < parsed.files.length; i++) {
17218
+ const file = parsed.files[i];
17219
+ if (!file || typeof file !== "object" || typeof file.path !== "string" || !file.path || file.lines !== void 0 && typeof file.lines !== "string") {
17220
+ items[i] = { ...items[i], status: "invalid-arguments" };
17221
+ continue;
17222
+ }
17223
+ const trialLedger = args2.readLedger ? new Map([...args2.readLedger].map(([key, entry2]) => [key, { ...entry2, records: [...entry2.records] }])) : void 0;
17224
+ try {
17225
+ const result4 = await readFileTool({ ...args2, batchItem: true, readLedger: trialLedger, call: { ...args2.call, arguments: JSON.stringify(file) } });
17226
+ const metadata2 = result4.metadata ?? {};
17227
+ const candidate = { path: file.path, status: metadata2.deduped ? "already-delivered" : metadata2.status === "invalid-arguments" ? "invalid-arguments" : metadata2.truncatedByCharLimit || metadata2.partialLine ? "partial" : "complete", content: result4.content, ...metadata2 };
17228
+ const previous = items[i];
17229
+ items[i] = candidate;
17230
+ const formatted = formatToolMessageContent({ toolName: "readFile", content: JSON.stringify(items), metadata: { batch: true, items: items.map(({ path, status, startLine, endLine }) => ({ path, status, startLine, endLine })) } });
17231
+ if (formatted.length > budget) {
17232
+ items[i] = previous;
17233
+ continue;
17234
+ }
17235
+ if (args2.readLedger && trialLedger) {
17236
+ args2.readLedger.clear();
17237
+ for (const [key, value] of trialLedger) args2.readLedger.set(key, value);
17238
+ }
17239
+ } catch {
17240
+ items[i] = { path: file.path, status: "error" };
17241
+ }
17242
+ }
17243
+ const batchContent = JSON.stringify(items);
17244
+ const batchMetadata = { batch: true, items: items.map(({ path, status, startLine, endLine }) => ({ path, status, startLine, endLine })) };
17245
+ if (formatToolMessageContent({ toolName: "readFile", content: batchContent, metadata: batchMetadata }).length > budget) {
17246
+ if (args2.readLedger && batchStartLedger) {
17247
+ args2.readLedger.clear();
17248
+ for (const [key, value] of batchStartLedger) args2.readLedger.set(key, value);
17249
+ }
17250
+ return { content: "[readFile] Batch request exceeds the shared delivery budget; no content delivered. Use fewer or shorter paths.", metadata: { status: "batch-limit-exceeded" } };
17251
+ }
17252
+ return { content: batchContent, metadata: batchMetadata };
17253
+ }
17254
+ const requestedPath = requireWorkspaceToolPath(parsed);
17255
+ const parsedSlice = readFileSliceArgs(parsed);
17256
+ if (parsedSlice.error) {
17257
+ return {
17258
+ content: `[readFile] Invalid lines: ${parsedSlice.error} No file content was read. Use lines: ${LINES_ARG_SYNTAX}, or omit lines.`,
17259
+ metadata: { status: "invalid-arguments", tool: "readFile" }
17260
+ };
17261
+ }
17262
+ const sliceArgs = parsedSlice.slice ?? {};
17263
+ const warnings = [];
17264
+ const approval = await resolveLocalWorkspaceToolApproval({
17265
+ workspaceRoot: args2.workspaceRoot,
17266
+ requestedPath,
17267
+ allowRuntimeOwnedSpill: true,
17268
+ ...args2.confirmExternalFileAccess ? { confirmExternalFileAccess: args2.confirmExternalFileAccess } : {}
17269
+ });
17176
17270
  const absolutePath = approval.path;
17177
17271
  const originalContent = await readGuardApprovedFile(approval);
17178
17272
  const projection = projectRunResultRead(absolutePath, originalContent, parsed.raw === true);
@@ -17182,45 +17276,101 @@ async function readFileTool(args2) {
17182
17276
  content,
17183
17277
  ...sliceArgs
17184
17278
  });
17185
- const truncatedRead = defensivelyTruncateReadFile({
17186
- content: sliced.content,
17187
- totalLines: sliced.totalLines
17188
- });
17189
- const invalidLinesMarker = invalidLines !== void 0 ? `[readFile] lines=${clipMarkerValue(invalidLines)} was rejected (only ONE range: ${LINES_ARG_SYNTAX}); returned lines ${sliced.startLine}-${sliced.endLine} instead. Fix the argument before relying on this window.
17190
- ` : "";
17191
- const finalRead = invalidLinesMarker.length > 0 ? defensivelyTruncateReadFile({
17192
- content: truncatedRead.content,
17193
- totalLines: sliced.totalLines,
17194
- limit: Math.max(1, READ_FILE_MAX_CHAR_LIMIT - invalidLinesMarker.length)
17195
- }) : truncatedRead;
17196
- const finalContent = invalidLinesMarker + finalRead.content;
17197
- const truncatedByCharLimit = truncatedRead.truncatedByCharLimit || finalRead.truncatedByCharLimit;
17198
- const isTruncated = sliced.truncated || truncatedByCharLimit;
17199
17279
  const relativePath = normalizeWorkspaceRelativePath({
17200
- workspaceRoot: resolve4(args2.workspaceRoot),
17280
+ workspaceRoot: resolve5(args2.workspaceRoot),
17201
17281
  targetPath: absolutePath
17202
17282
  });
17283
+ const instructionPath = AGENTS_MD_CANDIDATES.some((name) => absolutePath === resolve5(args2.workspaceRoot, name));
17284
+ const instructionLimit = PROJECT_INSTRUCTION_MAX_BYTES;
17285
+ const instructionOversized = Buffer.byteLength(content) > instructionLimit || countLines(content) > TOOL_OUTPUT_SPILL_LINES;
17286
+ const instruction = !args2.batchItem && instructionPath && !instructionOversized;
17287
+ if (!args2.batchItem && instructionPath && instructionOversized && Object.keys(sliceArgs).length === 0) {
17288
+ return {
17289
+ content: `[readFile] Project instruction exceeds the delivery limit (${instructionLimit} bytes or ${TOOL_OUTPUT_SPILL_LINES} lines); no content delivered. Continue with lines="1-" to inspect the first bounded range.`,
17290
+ metadata: { path: relativePath, status: "instruction-limit-exceeded", truncated: true, totalBytes: Buffer.byteLength(originalContent) }
17291
+ };
17292
+ }
17293
+ const cap = instruction ? PROJECT_INSTRUCTION_MAX_CHARS : resolveHistoricalToolContentCap("readFile", 0);
17294
+ const selectedLines = splitTextLines(sliced.content);
17295
+ const makeMetadata = (body, endLine, windowed2, partialLine) => ({
17296
+ path: relativePath,
17297
+ ...instruction ? { projectInstruction: true } : {},
17298
+ bytes: Buffer.byteLength(body),
17299
+ totalBytes: Buffer.byteLength(originalContent),
17300
+ ...projection.projected ? {
17301
+ projection: "run-result-observations",
17302
+ projectedTotalBytes: Buffer.byteLength(content),
17303
+ rawReadHint: "readFile raw:true reads original evidence; line numbers are unchanged."
17304
+ } : {},
17305
+ startLine: sliced.startLine,
17306
+ ...partialLine ? { partialLine: true } : { endLine },
17307
+ totalLines: sliced.totalLines,
17308
+ truncated: sliced.truncated || windowed2,
17309
+ ...scrubSecrets(sanitizeToolOutputText(body)).cleaned !== body ? { contentSanitized: true } : {},
17310
+ ...windowed2 ? { truncatedByByteLimit: true, truncatedByCharLimit: true } : {},
17311
+ ...sliceArgs.maxLines ? { maxLines: sliceArgs.maxLines } : {},
17312
+ ...sliceArgs.tailLines ? { tailLines: sliceArgs.tailLines } : {},
17313
+ ...activity ? { activity } : {}
17314
+ });
17315
+ const fits = (body, endLine, windowed2) => {
17316
+ if (Buffer.byteLength(body) > TOOL_OUTPUT_SPILL_BYTES || countLines(body) > TOOL_OUTPUT_SPILL_LINES) return false;
17317
+ const metadata2 = makeMetadata(body, endLine, windowed2, false);
17318
+ return formatToolMessageContent({ toolName: "readFile", content: body, metadata: metadata2 }).length <= cap;
17319
+ };
17320
+ let deliveredCount = selectedLines.length;
17321
+ let finalContent = sliced.content;
17322
+ let windowed = false;
17323
+ if (!fits(finalContent, sliced.endLine, false)) {
17324
+ let low = 0;
17325
+ let high = selectedLines.length;
17326
+ while (low < high) {
17327
+ const mid = Math.ceil((low + high) / 2);
17328
+ const candidate = selectedLines.slice(0, mid).join("\n");
17329
+ if (fits(candidate, sliced.startLine + mid - 1, true)) low = mid;
17330
+ else high = mid - 1;
17331
+ }
17332
+ deliveredCount = low;
17333
+ windowed = true;
17334
+ finalContent = selectedLines.slice(0, deliveredCount).join("\n");
17335
+ }
17336
+ const oversizedLine = windowed && deliveredCount === 0;
17337
+ if (oversizedLine) {
17338
+ let low = 0;
17339
+ let high = Math.min(sliced.content.length, cap);
17340
+ while (low < high) {
17341
+ const mid = Math.ceil((low + high) / 2);
17342
+ const candidate = defensivelyTruncateReadFile({ content: sliced.content, totalLines: sliced.totalLines, limit: mid }).content;
17343
+ const metadata2 = makeMetadata(candidate, sliced.startLine, true, true);
17344
+ const fitsPreview = Buffer.byteLength(candidate) <= TOOL_OUTPUT_SPILL_BYTES && countLines(candidate) <= TOOL_OUTPUT_SPILL_LINES && formatToolMessageContent({ toolName: "readFile", content: candidate, metadata: metadata2 }).length <= cap;
17345
+ if (fitsPreview) low = mid;
17346
+ else high = mid - 1;
17347
+ }
17348
+ finalContent = low > 0 ? defensivelyTruncateReadFile({ content: sliced.content, totalLines: sliced.totalLines, limit: low }).content : "[readFile] Line exceeds the delivery budget; use codeSearch or another tool to inspect it.";
17349
+ }
17350
+ const deliveredEndLine = windowed && !oversizedLine ? sliced.startLine + deliveredCount - 1 : sliced.endLine;
17351
+ const metadata = makeMetadata(finalContent, deliveredEndLine, windowed, oversizedLine);
17203
17352
  const force = parsed.force === true;
17204
17353
  const ledger = args2.readLedger;
17205
- const requestRange = { startLine: sliced.startLine, endLine: sliced.endLine };
17354
+ const deliveredRange = { startLine: sliced.startLine, endLine: deliveredEndLine };
17206
17355
  const fingerprint = createHash3("sha1").update(originalContent).update(parsed.raw === true ? "\0raw" : "\0default").digest("hex").slice(0, 20);
17207
17356
  let entry = ledger?.get(relativePath);
17208
17357
  if (entry && entry.fingerprint !== fingerprint) {
17209
17358
  entry = void 0;
17210
17359
  ledger?.delete(relativePath);
17211
17360
  }
17212
- if (!force && entry && ledger) {
17213
- const retainedCap = resolveHistoricalToolContentCap("readFile", 0);
17361
+ if (!force && entry && ledger && !oversizedLine) {
17362
+ const retainedCap = instructionPath && !instructionOversized ? PROJECT_INSTRUCTION_MAX_CHARS : resolveHistoricalToolContentCap("readFile", 0);
17214
17363
  const retained = filterRetainedLedgerRecords(entry.records, retainedCap);
17215
- if (retained.length > 0 && isLineRangeCovered(requestRange, retained)) {
17364
+ if (retained.length > 0 && isLineRangeCovered(deliveredRange, retained)) {
17216
17365
  ledger.delete(relativePath);
17217
17366
  ledger.set(relativePath, entry);
17218
17367
  return {
17219
- content: `[readFile] ${relativePath} lines ${requestRange.startLine}-${requestRange.endLine} were already delivered earlier and the file is unchanged; not resending. Pass force:true to refetch.`,
17368
+ content: `[readFile] ${relativePath} lines ${deliveredRange.startLine}-${deliveredRange.endLine} were already delivered earlier and the file is unchanged; not resending. Pass force:true to refetch.` + (windowed ? ` Continue with lines=${deliveredEndLine + 1}-.` : ""),
17220
17369
  metadata: {
17221
17370
  path: relativePath,
17222
- startLine: requestRange.startLine,
17223
- endLine: requestRange.endLine,
17371
+ startLine: deliveredRange.startLine,
17372
+ endLine: deliveredRange.endLine,
17373
+ ...windowed ? { truncated: true } : {},
17224
17374
  totalLines: sliced.totalLines,
17225
17375
  deduped: true,
17226
17376
  ...warnings.length ? { warnings: [...warnings, buildReadFileSliceHint(sliced.totalLines)] } : {},
@@ -17229,29 +17379,10 @@ async function readFileTool(args2) {
17229
17379
  };
17230
17380
  }
17231
17381
  }
17232
- const metadata = {
17233
- path: relativePath,
17234
- bytes: Buffer.byteLength(finalContent),
17235
- totalBytes: Buffer.byteLength(originalContent),
17236
- ...projection.projected ? {
17237
- projection: "run-result-observations",
17238
- projectedTotalBytes: Buffer.byteLength(content),
17239
- rawReadHint: "readFile raw:true reads original evidence; line numbers are unchanged."
17240
- } : {},
17241
- startLine: sliced.startLine,
17242
- endLine: sliced.endLine,
17243
- totalLines: sliced.totalLines,
17244
- truncated: isTruncated,
17245
- ...truncatedByCharLimit ? { truncatedByByteLimit: true, truncatedByCharLimit: true } : {},
17246
- ...sliceArgs.maxLines ? { maxLines: sliceArgs.maxLines } : {},
17247
- ...sliceArgs.tailLines ? { tailLines: sliceArgs.tailLines } : {},
17248
- ...warnings.length ? { warnings: [...warnings, buildReadFileSliceHint(sliced.totalLines)] } : {},
17249
- ...activity ? { activity } : {}
17250
- };
17251
- if (!isTruncated && ledger) {
17252
- const persistedChars = finalContent.length + "\n\n[tool metadata]\n".length + JSON.stringify(metadata).length;
17382
+ if (!oversizedLine && ledger) {
17383
+ const persistedChars = formatToolMessageContent({ toolName: "readFile", content: finalContent, metadata }).length;
17253
17384
  const records = entry?.records ?? [];
17254
- records.push({ ...requestRange, chars: persistedChars });
17385
+ records.push({ ...deliveredRange, chars: persistedChars });
17255
17386
  ledger.delete(relativePath);
17256
17387
  ledger.set(relativePath, {
17257
17388
  fingerprint,
@@ -17287,7 +17418,7 @@ async function writeFileTool(args2) {
17287
17418
  await ensureGuardedParentDirectory({ workspaceRoot: args2.workspaceRoot, fileApproval: approval });
17288
17419
  await writeGuardApprovedFile(approval, content);
17289
17420
  const relativePath = normalizeWorkspaceRelativePath({
17290
- workspaceRoot: resolve4(args2.workspaceRoot),
17421
+ workspaceRoot: resolve5(args2.workspaceRoot),
17291
17422
  targetPath: absolutePath
17292
17423
  });
17293
17424
  const activity = extractActivity(parsed);
@@ -17410,7 +17541,7 @@ ${hint}` : "")
17410
17541
  }
17411
17542
  await writeGuardApprovedFile(approval, nextContent);
17412
17543
  const relativePath = normalizeWorkspaceRelativePath({
17413
- workspaceRoot: resolve4(args2.workspaceRoot),
17544
+ workspaceRoot: resolve5(args2.workspaceRoot),
17414
17545
  targetPath: absolutePath
17415
17546
  });
17416
17547
  const activity = extractActivity(parsed);
@@ -17450,7 +17581,7 @@ async function listWorkspaceEntries(args2) {
17450
17581
  const names = (await readdir2(dirPath)).sort((left, right) => left.localeCompare(right));
17451
17582
  for (const name of names) {
17452
17583
  if (truncated) break;
17453
- const absolutePath = resolve4(dirPath, name);
17584
+ const absolutePath = resolve5(dirPath, name);
17454
17585
  const info = await stat4(absolutePath);
17455
17586
  const relativePath = relative4(args2.dirPath, absolutePath) || ".";
17456
17587
  const isDirectory = info.isDirectory();
@@ -17479,7 +17610,7 @@ async function internalSearchWorkspace(args2) {
17479
17610
  allowRuntimeOwnedSpill: true,
17480
17611
  ...args2.confirmExternalFileAccess ? { confirmExternalFileAccess: args2.confirmExternalFileAccess } : {}
17481
17612
  });
17482
- const workspaceRoot = resolve4(args2.workspaceRoot);
17613
+ const workspaceRoot = resolve5(args2.workspaceRoot);
17483
17614
  const inside = isPathInsideWorkspace({ workspaceRoot, targetPath: searchPath });
17484
17615
  const result4 = await searchFileTextMatches({
17485
17616
  root: inside ? workspaceRoot : searchPath,
@@ -17559,7 +17690,7 @@ async function globFilesTool(args2) {
17559
17690
  ...args2.confirmExternalFileAccess ? { confirmExternalFileAccess: args2.confirmExternalFileAccess } : {}
17560
17691
  });
17561
17692
  const relativeSearchPath = normalizeWorkspaceRelativePath({
17562
- workspaceRoot: resolve4(args2.workspaceRoot),
17693
+ workspaceRoot: resolve5(args2.workspaceRoot),
17563
17694
  targetPath: searchPath
17564
17695
  });
17565
17696
  const pathPrefix = relativeSearchPath === "." ? "" : `${relativeSearchPath.replace(/\/+$/, "")}/`;
@@ -17856,7 +17987,7 @@ async function launchProcessTool(args2) {
17856
17987
  ];
17857
17988
  const detached = process.platform !== "win32";
17858
17989
  const proc = spawnChildProcess2(cmdArgs[0] ?? "", cmdArgs.slice(1), {
17859
- cwd: resolve4(args2.workspaceRoot),
17990
+ cwd: resolve5(args2.workspaceRoot),
17860
17991
  stdio: ["ignore", "pipe", "pipe"],
17861
17992
  detached,
17862
17993
  windowsHide: true
@@ -18180,12 +18311,12 @@ function createLocalWorkspaceToolExecutors(args2) {
18180
18311
  images: results2.flatMap((result4) => result4.images ?? [])
18181
18312
  };
18182
18313
  },
18183
- readFile: (call) => readFileTool({
18314
+ readFile: Object.assign((call) => readFileTool({
18184
18315
  call,
18185
18316
  workspaceRoot: args2.workspaceRoot,
18186
18317
  ...readFileLedger ? { readLedger: readFileLedger } : {},
18187
18318
  ...fileAccess
18188
- }),
18319
+ }), { resetReadLedger: () => readFileLedger?.clear() }),
18189
18320
  writeFile: (call) => writeFileTool({
18190
18321
  call,
18191
18322
  workspaceRoot: args2.workspaceRoot,
@@ -19185,42 +19316,7 @@ function createTurnUsageLedger(args2) {
19185
19316
  }
19186
19317
 
19187
19318
  // packages/agent-runtime/leafFinalHandoff.ts
19188
- var LEAF_FINAL_HANDOFF_INSTRUCTIONS = `Leaf subtask final: return only the result, blockers/findings, and minimal evidence the parent needs. Do not narrate your process or restate the task. Keep success minimal (a one-line result is enough); on failure include the blocker, severity when relevant, and an evidence reference (file:line, test command, commit, artifact, or run/dialog). If the task explicitly requires a long-form deliverable (document, translation, dataset, code, or other artifact), provide that deliverable in full and keep only the handoff around it concise. During execution, follow the brief as given: report only results incremental to the brief, new evidence, overturned assumptions, and remaining questions; only when new evidence would materially change the goal, risk, irreversibility, or DoD should you surface it as a blocker/finding \u2014 do not silently expand scope or re-litigate the settled direction. Own investigation, implementation, related checks and failure fixes within the brief\u2019s scope and budget; leave goals and critical decisions to the parent. For required DoD checks, include the worktree, checked version (including uncommitted change scope), command, check scope, pass/fail and original-output reference; explicitly mark checks not run or evidence unavailable. Reuse valid same-version evidence; additional checks are warranted for version changes, missing/conflicting evidence or integration risk. Do not invent version metadata or treat a completion summary as independent review approval. Keep success concise without omitting required evidence.`;
19189
-
19190
- // packages/agent-runtime/taskExecutionContract.ts
19191
- var present = (value) => typeof value === "string" && value.trim().length > 0;
19192
- function evaluateTaskExecutionContract(contract, outcome = {}) {
19193
- if (!contract) return void 0;
19194
- const result4 = (status, ...reasons) => ({ taskId: contract.taskId, status, reasons });
19195
- if (outcome.stopped) return result4("blocked", "stopped");
19196
- if (!present(contract.taskId) || !["owner", "implementation-leaf"].includes(contract.role) || !["active", "paused", "revoked"].includes(contract.authorization) || !["pending", "waived", "accepted", "unknown"].includes(contract.acceptance) || !["complete", "incomplete", "unknown"].includes(contract.implementation) || !["changed", "unchanged", "unknown"].includes(contract.changes)) {
19197
- return result4("blocked", "invalid_contract");
19198
- }
19199
- if (contract.authorization === "revoked") return result4("blocked", "authorization_revoked");
19200
- if (contract.authorization === "paused") return result4("blocked", "authorization_paused");
19201
- if (outcome.executionFailed) return result4("blocked", "execution_failed");
19202
- if (outcome.budgetExhausted) return result4("incomplete", "budget_exhausted");
19203
- if (contract.implementation !== "complete") return result4("incomplete", "implementation_incomplete");
19204
- if (contract.acceptance === "pending") return result4("waiting", "acceptance_pending");
19205
- if (contract.acceptance === "unknown") return result4("blocked", "acceptance_unknown");
19206
- if (contract.changes === "unknown") return result4("incomplete", "changes_unknown");
19207
- if (contract.role === "implementation-leaf" || contract.changes === "unchanged") return result4("completed");
19208
- if (!present(contract.revision)) return result4("incomplete", "revision_missing");
19209
- const review = contract.review;
19210
- if (!review || !present(review.evidenceRef)) return result4("incomplete", "review_missing");
19211
- if (review.revision !== contract.revision) return result4("incomplete", "review_stale");
19212
- if (!present(contract.authorInstanceId) || !present(review.reviewerInstanceId) || review.reviewerInstanceId === contract.authorInstanceId) return result4("blocked", "review_not_independent");
19213
- if (review.verdict !== "APPROVE" || review.hasCriticalOrHigh !== false) return result4("blocked", "review_rejected");
19214
- const commit = contract.commit;
19215
- if (!commit || !present(commit.commitId) || !present(commit.evidenceRef)) return result4("incomplete", "commit_missing");
19216
- if (commit.revision !== contract.revision) return result4("incomplete", "commit_stale");
19217
- const merge4 = contract.localMerge;
19218
- if (!merge4 || !present(merge4.targetBranch) || !present(merge4.mergeCommitId) || !present(merge4.evidenceRef)) {
19219
- return result4("incomplete", "local_merge_missing");
19220
- }
19221
- if (merge4.sourceCommitId !== commit.commitId) return result4("incomplete", "local_merge_mismatch");
19222
- return result4("completed");
19223
- }
19319
+ var LEAF_FINAL_HANDOFF_INSTRUCTIONS = `Leaf subtask final: return only the result, blockers/findings, and minimal evidence the parent needs. Do not narrate your process or restate the task. Keep success concise without dropping the current delivery scope, unresolved blockers or evidence references; on failure include the blocker, severity when relevant, and an evidence reference (file:line, test command, commit, artifact, or run/dialog). If the task explicitly requires a long-form deliverable (document, translation, dataset, code, or other artifact), provide that deliverable in full and keep only the handoff around it concise. During execution, follow the brief as given: keep progress updates incremental to the brief; the final report must stand alone with the complete current delivery scope, unresolved blockers and evidence references, including on continuation; only when new evidence would materially change the goal, risk, irreversibility, or DoD should you surface it as a blocker/finding \u2014 do not silently expand scope or re-litigate the settled direction. Own investigation, implementation, related checks and failure fixes within the brief\u2019s scope and budget; leave goals and critical decisions to the parent. For required DoD checks, include the worktree, checked version (including uncommitted change scope), command, check scope, pass/fail and original-output reference; explicitly mark checks not run or evidence unavailable. Reuse valid same-version evidence; additional checks are warranted for version changes, missing/conflicting evidence or integration risk. Do not invent version metadata. Process done/exit 0 and assistant claims do not establish passing tests, user acceptance, independent review approval, integration or release; runtime acceptance is observations only and unknown remains unknown. Preserve a requested reviewer JSON/checkVerdict format; do not wrap it in another report. Keep success concise without omitting required evidence.`;
19224
19320
 
19225
19321
  // packages/agent-runtime/contextBlockScope.ts
19226
19322
  var isContextBlockScope = (value) => {
@@ -19283,6 +19379,16 @@ function findSummaryAnchorIndex(bridged, anchorId) {
19283
19379
  const index = Number(legacy[1]);
19284
19380
  return Number.isSafeInteger(index) && index < bridged.length ? index : -1;
19285
19381
  }
19382
+ function logSummarySourceDiagnostics(phase, dialogId, history, anchor) {
19383
+ const sourceHash = hashSummarySourceSlice(history, anchor)?.slice(0, 16);
19384
+ const rows = buildSummarySourceDiagnostics(toPlanCompressionMessages(history), anchor);
19385
+ for (const row of rows) console.log(`[compaction-source] ${JSON.stringify({
19386
+ phase,
19387
+ dialogId,
19388
+ sourceHash,
19389
+ ...row
19390
+ })}`);
19391
+ }
19286
19392
  function hashSummarySourceSlice(history, summarizedBeforeId) {
19287
19393
  if (!summarizedBeforeId) return void 0;
19288
19394
  const bridged = toPlanCompressionMessages(history);
@@ -19494,6 +19600,7 @@ async function maybeAutoCompactLocalHistory(args2) {
19494
19600
  storedHashPrefix: typeof invalidStored?.sourceHash === "string" && invalidStored.sourceHash ? invalidStored.sourceHash.slice(0, 8) : null
19495
19601
  }
19496
19602
  );
19603
+ logSummarySourceDiagnostics("invalidated", dialogId, history, invalidStored?.summarizedBeforeId);
19497
19604
  stored = null;
19498
19605
  }
19499
19606
  const existingSummary = typeof stored?.summary === "string" ? stored.summary : "";
@@ -19781,7 +19888,7 @@ async function maybeAutoCompactLocalHistory(args2) {
19781
19888
  primaryElapsedMs = Date.now() - compactionT0;
19782
19889
  logCompactionTiming("provider-error", {});
19783
19890
  emitPhase({ kind: "compaction-retry", attempt: attempt + 1, maxAttempts });
19784
- await new Promise((resolve6, reject) => {
19891
+ await new Promise((resolve7, reject) => {
19785
19892
  const signal = requestController.signal;
19786
19893
  const cancel = () => {
19787
19894
  clearTimeout(timer);
@@ -19790,7 +19897,7 @@ async function maybeAutoCompactLocalHistory(args2) {
19790
19897
  };
19791
19898
  const timer = setTimeout(() => {
19792
19899
  signal.removeEventListener("abort", cancel);
19793
- resolve6();
19900
+ resolve7();
19794
19901
  }, delayMs);
19795
19902
  signal.addEventListener("abort", cancel, { once: true });
19796
19903
  if (signal.aborted) cancel();
@@ -19804,16 +19911,16 @@ async function maybeAutoCompactLocalHistory(args2) {
19804
19911
  (error) => ({ kind: "provider-error", error })
19805
19912
  );
19806
19913
  const guards = [];
19807
- if (timeoutMs) guards.push(new Promise((resolve6) => {
19914
+ if (timeoutMs) guards.push(new Promise((resolve7) => {
19808
19915
  timeoutHandle = setTimeout(() => {
19809
19916
  requestController.abort(new DOMException("Summary deadline exceeded", "TimeoutError"));
19810
- resolve6({ kind: "timeout" });
19917
+ resolve7({ kind: "timeout" });
19811
19918
  }, timeoutMs);
19812
19919
  }));
19813
- if (args2.abortSignal) guards.push(new Promise((resolve6) => {
19920
+ if (args2.abortSignal) guards.push(new Promise((resolve7) => {
19814
19921
  abortListener = () => {
19815
19922
  requestController.abort(args2.abortSignal?.reason);
19816
- resolve6({ kind: "aborted" });
19923
+ resolve7({ kind: "aborted" });
19817
19924
  };
19818
19925
  args2.abortSignal?.addEventListener("abort", abortListener, { once: true });
19819
19926
  if (args2.abortSignal?.aborted) abortListener();
@@ -19951,6 +20058,7 @@ async function maybeAutoCompactLocalHistory(args2) {
19951
20058
  )
19952
20059
  });
19953
20060
  saveElapsedMs = Date.now() - saveT0;
20061
+ logSummarySourceDiagnostics("saved", dialogId, history, bounded3.summarizedBeforeId);
19954
20062
  console.log(formatCompactionMetricsLog(metrics));
19955
20063
  logCompactionTiming("success", {
19956
20064
  model: result4?.model ?? args2.model ?? null,
@@ -20517,10 +20625,6 @@ function attachUsageRecordsToError(error, usageRecords) {
20517
20625
  }
20518
20626
  async function persistFailedLocalTurn(args2) {
20519
20627
  const errorMessage = toErrorMessage(args2.error);
20520
- const businessCompletion = evaluateTaskExecutionContract(args2.input.taskExecutionContract, {
20521
- stopped: args2.input.abortSignal?.aborted || args2.error instanceof Error && args2.error.code === LOCAL_TURN_ABORTED_CODE,
20522
- executionFailed: true
20523
- });
20524
20628
  try {
20525
20629
  const saved = await args2.adapter.saveTurn({
20526
20630
  agentKey: args2.agentKey,
@@ -20531,7 +20635,6 @@ async function persistFailedLocalTurn(args2) {
20531
20635
  toolCallCount: args2.toolCallCount ?? 0,
20532
20636
  error: true,
20533
20637
  errorMessage,
20534
- ...businessCompletion ? { businessCompletion } : {},
20535
20638
  ...args2.usage ? { usage: args2.usage } : {}
20536
20639
  },
20537
20640
  ...args2.accountingUsage ? { accountingUsage: args2.accountingUsage } : {},
@@ -20578,6 +20681,7 @@ function combineRollbackError(primary, rollbackError) {
20578
20681
  return combined;
20579
20682
  }
20580
20683
  async function runLocalAgentTurn(input) {
20684
+ input = { ...input, runtimeContext: input.runtimeContext ? { ...input.runtimeContext } : void 0 };
20581
20685
  const legacyCallbacks = {
20582
20686
  onLoopEvent: input.onLoopEvent,
20583
20687
  onToolEvent: input.onToolEvent,
@@ -20722,6 +20826,13 @@ async function runLocalAgentTurn(input) {
20722
20826
  typeof input.input === "string" ? input.input : void 0
20723
20827
  )
20724
20828
  });
20829
+ const callerScopes = normalizeContextBlockScopes(
20830
+ input.contextBlocks,
20831
+ input.contextBlockScopes
20832
+ );
20833
+ const callerHasMemoryGuidance = callerScopes.some(
20834
+ (scope3) => scope3.content.includes(MEMORY_USE_GUIDANCE)
20835
+ );
20725
20836
  const guidanceScopes = [
20726
20837
  ...input.userLanguage?.trim() ? [buildUserResponseLanguageContext({ language: input.userLanguage })] : [],
20727
20838
  guidanceBlocks.startupProtocol,
@@ -20730,12 +20841,14 @@ async function runLocalAgentTurn(input) {
20730
20841
  // 注入顺序遵循 TOOL_GUIDED_SECTION_ORDER(与 buildSystemPrompt 的显式
20731
20842
  // layer 列表同源),禁止用 Object.values 自行定序。
20732
20843
  ...TOOL_GUIDED_SECTION_ORDER.map((id) => toolGuidedSections[id] ?? ""),
20844
+ // 记忆使用指引(session-scope,进稳定前缀):判定真值是 turnContext 的
20845
+ // `hasMemoryTools`(有效工具面),与 web/server 的 buildSystemPrompt 同一条
20846
+ // 规则。放在这里而不是各宿主:CLI/TUI/desktop 都经 runLocalAgentTurn 进入本
20847
+ // 函数,一处即可覆盖三端,并补齐「空库 + 有记忆工具」这一档——此前本地宿主
20848
+ // 只按记忆 overlay 是否为空门控,空库时模型永远不知道该怎么用记忆工具。
20849
+ ...hasMemoryTools(agentTools) && !callerHasMemoryGuidance ? [MEMORY_USE_GUIDANCE] : [],
20733
20850
  ...input.runKind === "subtask" ? [LEAF_FINAL_HANDOFF_INSTRUCTIONS] : []
20734
20851
  ].map((content) => content.trim()).filter((content) => content.length > 0).map((content) => ({ content, cacheScope: "session" }));
20735
- const callerScopes = normalizeContextBlockScopes(
20736
- input.contextBlocks,
20737
- input.contextBlockScopes
20738
- );
20739
20852
  const responseGuidelines = resolveResponseGuidelines(
20740
20853
  input.responseViewport ?? "unknown"
20741
20854
  );
@@ -20821,19 +20934,23 @@ async function runLocalAgentTurn(input) {
20821
20934
  summaryFallback: input.compactionSummaryFallback ?? readHostCompactionSummaryFallback(input.adapter),
20822
20935
  boundary: observationBoundary,
20823
20936
  getContextUsage: () => usageLedger.lastContextUsage(),
20824
- getCanonicalCompactionHistory: () => [
20937
+ getCanonicalCompactionHistory: () => orderDialogHistory([
20825
20938
  ...canonicalHistory,
20826
20939
  ...transcript.persisted(
20827
20940
  sanitizedPersistedInput,
20828
20941
  input.persistedInputReference
20829
- )
20830
- ],
20942
+ ).map((message) => {
20943
+ const receipt = message.cliMessageId;
20944
+ return receipt ? { ...message, id: receipt } : message;
20945
+ })
20946
+ ]),
20831
20947
  getWorkingPrefix: () => transcript.working().slice(0, prefixCount),
20832
20948
  onSelectedSummary: (summary) => {
20833
20949
  selectedSummary = summary;
20834
20950
  },
20835
20951
  replaceWorkingView: (next) => {
20836
20952
  transcript.replaceWorkingHistory(next);
20953
+ input.adapter.onWorkingHistoryReplaced?.();
20837
20954
  summaryProjectedPhase = contextPhase("summary-projected", next);
20838
20955
  },
20839
20956
  contextReferenceResolver: input.adapter.host === "cli" ? input.contextReferenceResolver : void 0,
@@ -20880,6 +20997,11 @@ async function runLocalAgentTurn(input) {
20880
20997
  })));
20881
20998
  messages.splice(currentInputStart, messages.length - currentInputStart, ...sanitizedUsers);
20882
20999
  }
21000
+ if (!input.userMessages?.length && input.adapter.host === "cli") {
21001
+ const userIndex = builtMessages.prefixCount + history.length;
21002
+ const id = dialogTurnUserMessageId(input.runtimeContext?.turnId, 0);
21003
+ if (id && messages[userIndex]?.role === "user") messages[userIndex] = { ...messages[userIndex], id };
21004
+ }
20883
21005
  const acceptToolImages = createToolImageLedger();
20884
21006
  const transcript = createTurnTranscript({
20885
21007
  initialWorking: messages,
@@ -20929,7 +21051,8 @@ async function runLocalAgentTurn(input) {
20929
21051
  transcript.push({
20930
21052
  role: "user",
20931
21053
  content,
20932
- ...message.cliMessageId ? { cliMessageId: message.cliMessageId } : {}
21054
+ ...message.cliMessageId ? { cliMessageId: message.cliMessageId } : {},
21055
+ ...Number.isFinite(message.cliHistoryOrder) ? { cliHistoryOrder: message.cliHistoryOrder } : {}
20933
21056
  });
20934
21057
  }
20935
21058
  pendingInjectionCommits.push({ commit: entry.commit, rollback: entry.rollback, messages: entry.messages });
@@ -21090,6 +21213,16 @@ async function runLocalAgentTurn(input) {
21090
21213
  inFlightTransactions = pendingInjectionCommits.splice(0);
21091
21214
  try {
21092
21215
  for (const transaction of inFlightTransactions) await transaction.commit();
21216
+ input.runtimeContext = { ...input.runtimeContext };
21217
+ delete input.runtimeContext.userMessageId;
21218
+ const admittedMessages = inFlightTransactions.flatMap((transaction) => transaction.messages);
21219
+ if (admittedMessages.length === 1 && admittedMessages[0]?.cliMessageId) {
21220
+ try {
21221
+ const id = await input.resolveInjectedUserMessageId?.(admittedMessages);
21222
+ if (id === admittedMessages[0].cliMessageId) input.runtimeContext.userMessageId = id;
21223
+ } catch {
21224
+ }
21225
+ }
21093
21226
  if (input.abortSignal?.aborted) throw buildAbortedError();
21094
21227
  } catch (error) {
21095
21228
  const toRollback = inFlightTransactions;
@@ -21525,12 +21658,6 @@ ${reasoningTailLog}
21525
21658
  ...result4,
21526
21659
  stopReason: input.abortSignal?.aborted ? "aborted" : result4.error || result4.runtimeProviderFailure || result4.emptyAssistantFallbackReason ? "error" : stopReason
21527
21660
  };
21528
- delete result4.businessCompletion;
21529
- const businessCompletion = evaluateTaskExecutionContract(input.taskExecutionContract, {
21530
- stopped: input.abortSignal?.aborted,
21531
- executionFailed: result4.error === true || !!result4.runtimeProviderFailure || !!result4.emptyAssistantFallbackReason
21532
- });
21533
- if (businessCompletion) result4.businessCompletion = businessCompletion;
21534
21661
  if (!skipFinalAppend) {
21535
21662
  const truncatedReasoningTailLog = resolveTruncatedReasoningTailLog(
21536
21663
  result4.emptyAssistantFallbackReason,
@@ -22535,756 +22662,6 @@ async function resolveOpenAiCompatibleProviderConfig(args2) {
22535
22662
  };
22536
22663
  }
22537
22664
 
22538
- // packages/agent-runtime/macOsKeychainCredentialBroker.ts
22539
- import { spawn as spawn2 } from "node:child_process";
22540
- var MACOS_KEYCHAIN_SERVICE_PREFIX = "nolo.credentials.keys";
22541
- var MACOS_KEYCHAIN_ACCOUNT = "api-key";
22542
- var SECURITY_ITEM_NOT_FOUND_EXIT = 44;
22543
- var DEFAULT_SECURITY_BIN = "/usr/bin/security";
22544
- function safeCredentialRef(ref) {
22545
- try {
22546
- return assertCredentialRef(ref);
22547
- } catch {
22548
- throw new Error("invalid_ref");
22549
- }
22550
- }
22551
- function credentialRefToMacOsKeychainService(ref, servicePrefix = MACOS_KEYCHAIN_SERVICE_PREFIX) {
22552
- const safe = safeCredentialRef(ref);
22553
- const hex = Buffer.from(safe, "utf8").toString("hex");
22554
- if (!hex) {
22555
- throw new Error("invalid_ref");
22556
- }
22557
- return `${servicePrefix}.${hex}`;
22558
- }
22559
- function rethrowBrokerError(op, _error) {
22560
- throw new Error(`credential_broker_${op}_failed`);
22561
- }
22562
- function createDefaultSecurityRunner(securityBin = DEFAULT_SECURITY_BIN) {
22563
- return function defaultSecurityRunner(input) {
22564
- return new Promise((resolve6) => {
22565
- let settled = false;
22566
- const finish = (result4) => {
22567
- if (settled) return;
22568
- settled = true;
22569
- resolve6(result4);
22570
- };
22571
- let child;
22572
- try {
22573
- child = spawn2(securityBin, input.args, {
22574
- stdio: ["pipe", "pipe", "pipe"]
22575
- });
22576
- } catch {
22577
- finish({ exitCode: -1, stdout: "", stderr: "" });
22578
- return;
22579
- }
22580
- let stdout = "";
22581
- let stderr = "";
22582
- child.stdout?.setEncoding("utf8");
22583
- child.stderr?.setEncoding("utf8");
22584
- child.stdout?.on("data", (chunk) => {
22585
- stdout += chunk;
22586
- });
22587
- child.stderr?.on("data", (chunk) => {
22588
- stderr += chunk;
22589
- });
22590
- child.on("error", () => {
22591
- finish({ exitCode: -1, stdout: "", stderr: "" });
22592
- });
22593
- child.on("close", (code) => {
22594
- finish({
22595
- exitCode: typeof code === "number" ? code : -1,
22596
- stdout,
22597
- stderr
22598
- });
22599
- });
22600
- if (input.stdin !== void 0) {
22601
- child.stdin?.write(input.stdin);
22602
- }
22603
- child.stdin?.end();
22604
- });
22605
- };
22606
- }
22607
- function createMacOsKeychainCredentialBroker(options = {}) {
22608
- const runner = options.runner ?? createDefaultSecurityRunner(options.securityBin);
22609
- const servicePrefix = options.servicePrefix ?? MACOS_KEYCHAIN_SERVICE_PREFIX;
22610
- const account = options.account ?? MACOS_KEYCHAIN_ACCOUNT;
22611
- const serviceFor = (ref) => credentialRefToMacOsKeychainService(ref, servicePrefix);
22612
- return {
22613
- async get(ref) {
22614
- const safeRef = safeCredentialRef(ref);
22615
- const service4 = serviceFor(safeRef);
22616
- let result4;
22617
- try {
22618
- result4 = await runner({
22619
- args: [
22620
- "find-generic-password",
22621
- "-a",
22622
- account,
22623
- "-s",
22624
- service4,
22625
- "-w"
22626
- ]
22627
- });
22628
- } catch (error) {
22629
- rethrowBrokerError("get", error);
22630
- }
22631
- if (result4.exitCode === SECURITY_ITEM_NOT_FOUND_EXIT) {
22632
- return null;
22633
- }
22634
- if (result4.exitCode !== 0) {
22635
- rethrowBrokerError("get");
22636
- }
22637
- const secret = result4.stdout.replace(/\n$/, "");
22638
- return secret.length > 0 ? secret : null;
22639
- },
22640
- async put(ref, secret) {
22641
- const safeRef = safeCredentialRef(ref);
22642
- const value = asTrimmedString(secret);
22643
- if (!value) {
22644
- throw new Error("Cannot store an empty credential secret.");
22645
- }
22646
- const service4 = serviceFor(safeRef);
22647
- const stdin = `${value}
22648
- ${value}
22649
- `;
22650
- let result4;
22651
- try {
22652
- result4 = await runner({
22653
- args: [
22654
- "add-generic-password",
22655
- "-a",
22656
- account,
22657
- "-s",
22658
- service4,
22659
- "-U",
22660
- "-w"
22661
- ],
22662
- stdin
22663
- });
22664
- } catch (error) {
22665
- rethrowBrokerError("put", error);
22666
- }
22667
- if (result4.exitCode !== 0) {
22668
- rethrowBrokerError("put");
22669
- }
22670
- },
22671
- async delete(ref) {
22672
- const safeRef = safeCredentialRef(ref);
22673
- const service4 = serviceFor(safeRef);
22674
- let result4;
22675
- try {
22676
- result4 = await runner({
22677
- args: [
22678
- "delete-generic-password",
22679
- "-a",
22680
- account,
22681
- "-s",
22682
- service4
22683
- ]
22684
- });
22685
- } catch (error) {
22686
- rethrowBrokerError("delete", error);
22687
- }
22688
- if (result4.exitCode === 0 || result4.exitCode === SECURITY_ITEM_NOT_FOUND_EXIT) {
22689
- return;
22690
- }
22691
- rethrowBrokerError("delete");
22692
- },
22693
- async has(ref) {
22694
- const safeRef = safeCredentialRef(ref);
22695
- const service4 = serviceFor(safeRef);
22696
- let result4;
22697
- try {
22698
- result4 = await runner({
22699
- args: [
22700
- "find-generic-password",
22701
- "-a",
22702
- account,
22703
- "-s",
22704
- service4
22705
- ]
22706
- });
22707
- } catch (error) {
22708
- rethrowBrokerError("has", error);
22709
- }
22710
- if (result4.exitCode === SECURITY_ITEM_NOT_FOUND_EXIT) {
22711
- return false;
22712
- }
22713
- if (result4.exitCode !== 0) {
22714
- rethrowBrokerError("has");
22715
- }
22716
- return true;
22717
- }
22718
- };
22719
- }
22720
-
22721
- // packages/agent-runtime/windowsCredentialManagerBroker.ts
22722
- import { spawn as spawn3 } from "node:child_process";
22723
- var WINDOWS_CREDENTIAL_TARGET_PREFIX = "nolo.credentials.keys";
22724
- var WIN_ERROR_NOT_FOUND = 1168;
22725
- var WINDOWS_CREDENTIAL_MANAGER_SCRIPT = `
22726
- $ErrorActionPreference = 'Stop'
22727
- try {
22728
- $raw = [Console]::In.ReadToEnd()
22729
- if ([string]::IsNullOrWhiteSpace($raw)) { exit 1 }
22730
- $req = $raw | ConvertFrom-Json
22731
- $op = [string]$req.op
22732
- $target = [string]$req.target
22733
- if ([string]::IsNullOrWhiteSpace($op) -or [string]::IsNullOrWhiteSpace($target)) { exit 1 }
22734
-
22735
- Add-Type @"
22736
- using System;
22737
- using System.Runtime.InteropServices;
22738
- using System.Text;
22739
-
22740
- public class NoloCredNative {
22741
- public const int CRED_TYPE_GENERIC = 1;
22742
- public const int CRED_PERSIST_LOCAL_MACHINE = 2;
22743
- public const int ERROR_NOT_FOUND = 1168;
22744
-
22745
- [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
22746
- public struct CREDENTIAL {
22747
- public int Flags;
22748
- public int Type;
22749
- public string TargetName;
22750
- public string Comment;
22751
- public long LastWritten;
22752
- public int CredentialBlobSize;
22753
- public IntPtr CredentialBlob;
22754
- public int Persist;
22755
- public int AttributeCount;
22756
- public IntPtr Attributes;
22757
- public string TargetAlias;
22758
- public string UserName;
22759
- }
22760
-
22761
- [DllImport("advapi32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
22762
- public static extern bool CredWriteW(ref CREDENTIAL userCredential, uint flags);
22763
-
22764
- [DllImport("advapi32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
22765
- public static extern bool CredReadW(string target, int type, int reservedFlag, out IntPtr credentialPtr);
22766
-
22767
- [DllImport("advapi32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
22768
- public static extern bool CredDeleteW(string target, int type, int flags);
22769
-
22770
- [DllImport("advapi32.dll", SetLastError = true)]
22771
- public static extern void CredFree(IntPtr buffer);
22772
- }
22773
- "@
22774
-
22775
- if ($op -eq 'get') {
22776
- $ptr = [IntPtr]::Zero
22777
- $ok = [NoloCredNative]::CredReadW($target, [NoloCredNative]::CRED_TYPE_GENERIC, 0, [ref]$ptr)
22778
- if (-not $ok) {
22779
- exit [Runtime.InteropServices.Marshal]::GetLastWin32Error()
22780
- }
22781
- try {
22782
- $cred = [Runtime.InteropServices.Marshal]::PtrToStructure($ptr, [type][NoloCredNative+CREDENTIAL])
22783
- if ($cred.CredentialBlobSize -le 0 -or $cred.CredentialBlob -eq [IntPtr]::Zero) {
22784
- $payload = @{ secret = '' } | ConvertTo-Json -Compress
22785
- [Console]::Out.Write($payload)
22786
- exit 0
22787
- }
22788
- $bytes = New-Object byte[] $cred.CredentialBlobSize
22789
- [Runtime.InteropServices.Marshal]::Copy($cred.CredentialBlob, $bytes, 0, $cred.CredentialBlobSize)
22790
- $secret = [Text.Encoding]::UTF8.GetString($bytes)
22791
- $payload = @{ secret = $secret } | ConvertTo-Json -Compress
22792
- [Console]::Out.Write($payload)
22793
- exit 0
22794
- } finally {
22795
- [NoloCredNative]::CredFree($ptr)
22796
- }
22797
- }
22798
-
22799
- if ($op -eq 'has') {
22800
- $ptr = [IntPtr]::Zero
22801
- $ok = [NoloCredNative]::CredReadW($target, [NoloCredNative]::CRED_TYPE_GENERIC, 0, [ref]$ptr)
22802
- if (-not $ok) {
22803
- exit [Runtime.InteropServices.Marshal]::GetLastWin32Error()
22804
- }
22805
- [NoloCredNative]::CredFree($ptr)
22806
- exit 0
22807
- }
22808
-
22809
- if ($op -eq 'put') {
22810
- $secret = [string]$req.secret
22811
- if ([string]::IsNullOrEmpty($secret)) { exit 1 }
22812
- $blob = [Text.Encoding]::UTF8.GetBytes($secret)
22813
- $cred = New-Object NoloCredNative+CREDENTIAL
22814
- $cred.Type = [NoloCredNative]::CRED_TYPE_GENERIC
22815
- $cred.TargetName = $target
22816
- $cred.UserName = 'api-key'
22817
- $cred.Persist = [NoloCredNative]::CRED_PERSIST_LOCAL_MACHINE
22818
- $cred.CredentialBlobSize = $blob.Length
22819
- $cred.CredentialBlob = [Runtime.InteropServices.Marshal]::AllocHGlobal($blob.Length)
22820
- try {
22821
- if ($blob.Length -gt 0) {
22822
- [Runtime.InteropServices.Marshal]::Copy($blob, 0, $cred.CredentialBlob, $blob.Length)
22823
- }
22824
- $ok = [NoloCredNative]::CredWriteW([ref]$cred, 0)
22825
- if (-not $ok) {
22826
- exit [Runtime.InteropServices.Marshal]::GetLastWin32Error()
22827
- }
22828
- exit 0
22829
- } finally {
22830
- [Runtime.InteropServices.Marshal]::FreeHGlobal($cred.CredentialBlob)
22831
- }
22832
- }
22833
-
22834
- if ($op -eq 'delete') {
22835
- $ok = [NoloCredNative]::CredDeleteW($target, [NoloCredNative]::CRED_TYPE_GENERIC, 0)
22836
- if (-not $ok) {
22837
- exit [Runtime.InteropServices.Marshal]::GetLastWin32Error()
22838
- }
22839
- exit 0
22840
- }
22841
-
22842
- exit 1
22843
- } catch {
22844
- exit 1
22845
- }
22846
- `.trim();
22847
- function safeCredentialRef2(ref) {
22848
- try {
22849
- return assertCredentialRef(ref);
22850
- } catch {
22851
- throw new Error("invalid_ref");
22852
- }
22853
- }
22854
- function credentialRefToWindowsCredentialTarget(ref, targetPrefix = WINDOWS_CREDENTIAL_TARGET_PREFIX) {
22855
- const safe = safeCredentialRef2(ref);
22856
- const hex = Buffer.from(safe, "utf8").toString("hex");
22857
- if (!hex) {
22858
- throw new Error("invalid_ref");
22859
- }
22860
- return `${targetPrefix}.${hex}`;
22861
- }
22862
- function rethrowBrokerError2(op, _error) {
22863
- throw new Error(`credential_broker_${op}_failed`);
22864
- }
22865
- function buildWindowsCredentialPowerShellArgs(script = WINDOWS_CREDENTIAL_MANAGER_SCRIPT) {
22866
- const encoded = Buffer.from(script, "utf16le").toString("base64");
22867
- return [
22868
- "-NoProfile",
22869
- "-NonInteractive",
22870
- "-ExecutionPolicy",
22871
- "Bypass",
22872
- "-EncodedCommand",
22873
- encoded
22874
- ];
22875
- }
22876
- function requestStdin(payload) {
22877
- return JSON.stringify(payload);
22878
- }
22879
- function parseGetSecretFromStdout(stdout) {
22880
- const trimmed = asTrimmedString(stdout);
22881
- if (!trimmed) {
22882
- rethrowBrokerError2("get");
22883
- }
22884
- let parsed;
22885
- try {
22886
- parsed = JSON.parse(trimmed);
22887
- } catch {
22888
- rethrowBrokerError2("get");
22889
- }
22890
- if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed) || typeof parsed.secret !== "string") {
22891
- rethrowBrokerError2("get");
22892
- }
22893
- return parsed.secret;
22894
- }
22895
- function spawnShell(bin, args2, stdin) {
22896
- return new Promise((resolve6) => {
22897
- let settled = false;
22898
- const finish = (result4) => {
22899
- if (settled) return;
22900
- settled = true;
22901
- resolve6(result4);
22902
- };
22903
- let child;
22904
- try {
22905
- child = spawn3(bin, args2, {
22906
- stdio: ["pipe", "pipe", "pipe"],
22907
- windowsHide: true
22908
- });
22909
- } catch {
22910
- finish({ exitCode: -1, stdout: "", stderr: "" });
22911
- return;
22912
- }
22913
- let stdout = "";
22914
- let stderr = "";
22915
- child.stdout?.setEncoding("utf8");
22916
- child.stderr?.setEncoding("utf8");
22917
- child.stdout?.on("data", (chunk) => {
22918
- stdout += chunk;
22919
- });
22920
- child.stderr?.on("data", (chunk) => {
22921
- stderr += chunk;
22922
- });
22923
- child.on("error", () => {
22924
- finish({ exitCode: -1, stdout: "", stderr: "" });
22925
- });
22926
- child.on("close", (code) => {
22927
- finish({
22928
- exitCode: typeof code === "number" ? code : -1,
22929
- stdout,
22930
- stderr
22931
- });
22932
- });
22933
- if (stdin !== void 0) {
22934
- child.stdin?.write(stdin);
22935
- }
22936
- child.stdin?.end();
22937
- });
22938
- }
22939
- function createDefaultWindowsCredentialRunner(shellBin) {
22940
- let resolvedBin = shellBin ?? null;
22941
- return async function defaultWindowsCredentialRunner(input) {
22942
- if (resolvedBin) {
22943
- return spawnShell(resolvedBin, input.args, input.stdin);
22944
- }
22945
- const first = await spawnShell("powershell.exe", input.args, input.stdin);
22946
- if (first.exitCode !== -1) {
22947
- resolvedBin = "powershell.exe";
22948
- return first;
22949
- }
22950
- const second = await spawnShell("pwsh", input.args, input.stdin);
22951
- if (second.exitCode !== -1) {
22952
- resolvedBin = "pwsh";
22953
- }
22954
- return second;
22955
- };
22956
- }
22957
- function createWindowsCredentialManagerBroker(options = {}) {
22958
- const runner = options.runner ?? createDefaultWindowsCredentialRunner(options.shellBin);
22959
- const targetPrefix = options.targetPrefix ?? WINDOWS_CREDENTIAL_TARGET_PREFIX;
22960
- const targetFor = (ref) => credentialRefToWindowsCredentialTarget(ref, targetPrefix);
22961
- const staticArgs = buildWindowsCredentialPowerShellArgs();
22962
- return {
22963
- async get(ref) {
22964
- const safeRef = safeCredentialRef2(ref);
22965
- const target = targetFor(safeRef);
22966
- let result4;
22967
- try {
22968
- result4 = await runner({
22969
- args: staticArgs,
22970
- stdin: requestStdin({ op: "get", target })
22971
- });
22972
- } catch (error) {
22973
- rethrowBrokerError2("get", error);
22974
- }
22975
- if (result4.exitCode === WIN_ERROR_NOT_FOUND) {
22976
- return null;
22977
- }
22978
- if (result4.exitCode !== 0) {
22979
- rethrowBrokerError2("get");
22980
- }
22981
- const secret = parseGetSecretFromStdout(result4.stdout);
22982
- return secret.length > 0 ? secret : null;
22983
- },
22984
- async put(ref, secret) {
22985
- const safeRef = safeCredentialRef2(ref);
22986
- const value = asTrimmedString(secret);
22987
- if (!value) {
22988
- throw new Error("Cannot store an empty credential secret.");
22989
- }
22990
- const target = targetFor(safeRef);
22991
- let result4;
22992
- try {
22993
- result4 = await runner({
22994
- args: staticArgs,
22995
- stdin: requestStdin({ op: "put", target, secret: value })
22996
- });
22997
- } catch (error) {
22998
- rethrowBrokerError2("put", error);
22999
- }
23000
- if (result4.exitCode !== 0) {
23001
- rethrowBrokerError2("put");
23002
- }
23003
- },
23004
- async delete(ref) {
23005
- const safeRef = safeCredentialRef2(ref);
23006
- const target = targetFor(safeRef);
23007
- let result4;
23008
- try {
23009
- result4 = await runner({
23010
- args: staticArgs,
23011
- stdin: requestStdin({ op: "delete", target })
23012
- });
23013
- } catch (error) {
23014
- rethrowBrokerError2("delete", error);
23015
- }
23016
- if (result4.exitCode === 0 || result4.exitCode === WIN_ERROR_NOT_FOUND) {
23017
- return;
23018
- }
23019
- rethrowBrokerError2("delete");
23020
- },
23021
- async has(ref) {
23022
- const safeRef = safeCredentialRef2(ref);
23023
- const target = targetFor(safeRef);
23024
- let result4;
23025
- try {
23026
- result4 = await runner({
23027
- args: staticArgs,
23028
- stdin: requestStdin({ op: "has", target })
23029
- });
23030
- } catch (error) {
23031
- rethrowBrokerError2("has", error);
23032
- }
23033
- if (result4.exitCode === WIN_ERROR_NOT_FOUND) {
23034
- return false;
23035
- }
23036
- if (result4.exitCode !== 0) {
23037
- rethrowBrokerError2("has");
23038
- }
23039
- return true;
23040
- }
23041
- };
23042
- }
23043
-
23044
- // packages/agent-runtime/linuxSecretServiceCredentialBroker.ts
23045
- import { spawn as spawn4 } from "node:child_process";
23046
- var LINUX_SECRET_SERVICE_ATTRIBUTE = "nolo-credential";
23047
- var SECRET_TOOL_NO_MATCH_EXIT = 1;
23048
- var DEFAULT_SECRET_TOOL_BIN = "secret-tool";
23049
- function safeCredentialRef3(ref) {
23050
- try {
23051
- return assertCredentialRef(ref);
23052
- } catch {
23053
- throw new Error("invalid_ref");
23054
- }
23055
- }
23056
- function brokerFailure(op) {
23057
- throw new Error(`credential_broker_${op}_failed`);
23058
- }
23059
- function createDefaultSecretToolRunner(secretToolBin = DEFAULT_SECRET_TOOL_BIN) {
23060
- return (input) => new Promise((resolve6) => {
23061
- let stdout = "";
23062
- let stderr = "";
23063
- let settled = false;
23064
- const finish = (result4) => {
23065
- if (settled) return;
23066
- settled = true;
23067
- resolve6(result4);
23068
- };
23069
- let child;
23070
- try {
23071
- child = spawn4(secretToolBin, input.args, {
23072
- stdio: ["pipe", "pipe", "pipe"]
23073
- });
23074
- } catch {
23075
- finish({ exitCode: -1, stdout: "", stderr: "" });
23076
- return;
23077
- }
23078
- child.stdout?.on("data", (chunk) => {
23079
- stdout += chunk;
23080
- });
23081
- child.stderr?.on("data", (chunk) => {
23082
- stderr += chunk;
23083
- });
23084
- child.on("error", () => {
23085
- finish({ exitCode: -1, stdout: "", stderr: "" });
23086
- });
23087
- child.on("close", (code) => {
23088
- finish({
23089
- exitCode: typeof code === "number" ? code : -1,
23090
- stdout,
23091
- stderr
23092
- });
23093
- });
23094
- if (input.stdin !== void 0) {
23095
- child.stdin?.write(input.stdin);
23096
- }
23097
- child.stdin?.end();
23098
- });
23099
- }
23100
- function createLinuxSecretServiceCredentialBroker(options = {}) {
23101
- const runner = options.runner ?? createDefaultSecretToolRunner(options.secretToolBin);
23102
- const attribute = options.attribute ?? LINUX_SECRET_SERVICE_ATTRIBUTE;
23103
- const attrArgs = (ref) => [attribute, ref];
23104
- const lookup3 = async (ref) => {
23105
- try {
23106
- return await runner({ args: ["lookup", ...attrArgs(ref)] });
23107
- } catch {
23108
- brokerFailure("get");
23109
- }
23110
- };
23111
- return {
23112
- async get(ref) {
23113
- const safeRef = safeCredentialRef3(ref);
23114
- const result4 = await lookup3(safeRef);
23115
- if (result4.exitCode === SECRET_TOOL_NO_MATCH_EXIT) return null;
23116
- if (result4.exitCode !== 0) brokerFailure("get");
23117
- const secret = result4.stdout.replace(/\n$/, "");
23118
- return secret.length > 0 ? secret : null;
23119
- },
23120
- async put(ref, secret) {
23121
- const safeRef = safeCredentialRef3(ref);
23122
- const value = asTrimmedString(secret);
23123
- if (!value) {
23124
- throw new Error("Cannot store an empty credential secret.");
23125
- }
23126
- const args2 = [
23127
- "store",
23128
- `--label=nolo-credential:${safeRef}`,
23129
- ...attrArgs(safeRef)
23130
- ];
23131
- if (value.includes("\n") || args2.some((arg) => arg.includes(value))) {
23132
- brokerFailure("put");
23133
- }
23134
- let result4;
23135
- try {
23136
- result4 = await runner({ args: args2, stdin: value });
23137
- } catch {
23138
- brokerFailure("put");
23139
- }
23140
- if (result4.exitCode !== 0) brokerFailure("put");
23141
- },
23142
- async delete(ref) {
23143
- const safeRef = safeCredentialRef3(ref);
23144
- let result4;
23145
- try {
23146
- result4 = await runner({ args: ["clear", ...attrArgs(safeRef)] });
23147
- } catch {
23148
- brokerFailure("delete");
23149
- }
23150
- if (result4.exitCode === 0 || result4.exitCode === SECRET_TOOL_NO_MATCH_EXIT) {
23151
- return;
23152
- }
23153
- brokerFailure("delete");
23154
- },
23155
- async has(ref) {
23156
- const safeRef = safeCredentialRef3(ref);
23157
- const result4 = await lookup3(safeRef);
23158
- if (result4.exitCode === SECRET_TOOL_NO_MATCH_EXIT) return false;
23159
- if (result4.exitCode !== 0) brokerFailure("has");
23160
- return true;
23161
- }
23162
- };
23163
- }
23164
-
23165
- // packages/agent-runtime/desktopHostCredentialBroker.ts
23166
- function createClosedCredentialBroker(code = "credential_store_unavailable") {
23167
- const fail9 = () => {
23168
- throw new Error(code);
23169
- };
23170
- return {
23171
- get: fail9,
23172
- put: fail9,
23173
- delete: fail9,
23174
- has: () => false
23175
- };
23176
- }
23177
- function createHostCredentialBrokerChain(args2) {
23178
- const { strict, session, legacy, notifySessionFallback, notifyLegacyHit } = args2;
23179
- const legacyNoticed = /* @__PURE__ */ new Set();
23180
- let sessionNotified = false;
23181
- const noticeSession = () => {
23182
- if (sessionNotified || !notifySessionFallback) return;
23183
- sessionNotified = true;
23184
- try {
23185
- notifySessionFallback();
23186
- } catch {
23187
- }
23188
- };
23189
- return {
23190
- async get(ref) {
23191
- try {
23192
- const strictValue = await strict.get(ref);
23193
- if (strictValue !== null && strictValue !== void 0) return strictValue;
23194
- } catch {
23195
- }
23196
- const sessionValue = await session.get(ref);
23197
- if (sessionValue !== null && sessionValue !== void 0) return sessionValue;
23198
- if (!legacy) return null;
23199
- const legacyValue = await legacy.get(ref);
23200
- if (legacyValue !== null && legacyValue !== void 0) {
23201
- if (notifyLegacyHit && !legacyNoticed.has(ref)) {
23202
- legacyNoticed.add(ref);
23203
- try {
23204
- notifyLegacyHit(ref);
23205
- } catch {
23206
- }
23207
- }
23208
- return legacyValue;
23209
- }
23210
- return null;
23211
- },
23212
- async put(ref, secret) {
23213
- try {
23214
- await strict.put(ref, secret);
23215
- if (await strict.has(ref)) return;
23216
- } catch {
23217
- }
23218
- await session.put(ref, secret);
23219
- noticeSession();
23220
- },
23221
- async delete(ref) {
23222
- try {
23223
- await strict.delete(ref);
23224
- } catch {
23225
- }
23226
- try {
23227
- await session.delete(ref);
23228
- } catch {
23229
- }
23230
- if (legacy) await legacy.delete(ref);
23231
- },
23232
- async has(ref) {
23233
- try {
23234
- if (await strict.has(ref)) return true;
23235
- } catch {
23236
- }
23237
- if (await session.has(ref)) return true;
23238
- return legacy ? await legacy.has(ref) : false;
23239
- }
23240
- };
23241
- }
23242
- function createStrictHostCredentialBroker(options = {}) {
23243
- const platform = options.platform ?? process.platform;
23244
- const env = options.env ?? process.env;
23245
- const override = String(env.NOLO_DESKTOP_CREDENTIAL_STORE ?? "").trim().toLowerCase();
23246
- if (override === "file") {
23247
- return createClosedCredentialBroker("credential_store_file_not_allowed");
23248
- }
23249
- if (platform === "darwin" || override === "keychain") {
23250
- return options.keychainBroker ?? (options.createKeychainBroker ?? (() => createMacOsKeychainCredentialBroker()))();
23251
- }
23252
- if (platform === "win32" || override === "credman") {
23253
- return options.windowsCredentialBroker ?? (options.createWindowsCredentialBroker ?? (() => createWindowsCredentialManagerBroker()))();
23254
- }
23255
- if (platform === "linux" || override === "secret-service") {
23256
- return options.linuxSecretServiceBroker ?? (options.createLinuxSecretServiceBroker ?? (() => createLinuxSecretServiceCredentialBroker()))();
23257
- }
23258
- return createClosedCredentialBroker("credential_store_unsupported");
23259
- }
23260
-
23261
- // packages/agent-runtime/dialogMessageRecord.ts
23262
- function dialogMessageRecordToAgentRuntimeMessage(record2) {
23263
- if (!record2 || typeof record2 !== "object") return null;
23264
- if (record2.role !== "user" && record2.role !== "assistant" && record2.role !== "tool") return null;
23265
- return {
23266
- ...typeof record2.id === "string" ? { id: record2.id } : {},
23267
- role: record2.role,
23268
- content: record2.content ?? "",
23269
- ...record2.contextReference !== void 0 ? { context_reference: record2.contextReference } : {},
23270
- ...typeof record2.reasoning_content === "string" ? { reasoning_content: record2.reasoning_content } : {},
23271
- ...typeof record2.toolCallId === "string" ? { tool_call_id: record2.toolCallId } : {},
23272
- ...Array.isArray(record2.tool_calls) ? { tool_calls: record2.tool_calls } : {},
23273
- ...record2.toolPayload !== void 0 ? { toolPayload: record2.toolPayload } : {},
23274
- ...typeof record2.toolName === "string" ? { toolName: record2.toolName } : {},
23275
- // 写侧(dialogWritePlan)把 tool_result_metadata 以 `metadata` 字段落库;
23276
- // 回读必须还原,否则跨 turn 投影丢失 metadata 后缀,同一 tool 消息的字节
23277
- // 在 turn 边界漂移 → provider 前缀缓存断裂(stable projection 契约,
23278
- // 见 docs/plans/2026-09-05-tool-output-cache-stability.md)。
23279
- ...record2.metadata && typeof record2.metadata === "object" ? { tool_result_metadata: record2.metadata } : {},
23280
- ...(() => {
23281
- const raw = record2.createdAt;
23282
- const ms = typeof raw === "number" ? raw : typeof raw === "string" ? Date.parse(raw) : NaN;
23283
- return Number.isFinite(ms) ? { createdAt: ms } : {};
23284
- })()
23285
- };
23286
- }
23287
-
23288
22665
  // packages/agent-runtime/dialogWritePlan.ts
23289
22666
  function extractLastUserText(messages) {
23290
22667
  const lastUser = [...messages].reverse().find((message) => message.role === "user");
@@ -23710,11 +23087,11 @@ var E_ALREADY_LOCKED = new Error("mutex already locked");
23710
23087
  var E_CANCELED = new Error("request for lock canceled");
23711
23088
  var __awaiter$2 = function(thisArg, _arguments, P, generator) {
23712
23089
  function adopt(value) {
23713
- return value instanceof P ? value : new P(function(resolve6) {
23714
- resolve6(value);
23090
+ return value instanceof P ? value : new P(function(resolve7) {
23091
+ resolve7(value);
23715
23092
  });
23716
23093
  }
23717
- return new (P || (P = Promise))(function(resolve6, reject) {
23094
+ return new (P || (P = Promise))(function(resolve7, reject) {
23718
23095
  function fulfilled(value) {
23719
23096
  try {
23720
23097
  step(generator.next(value));
@@ -23730,7 +23107,7 @@ var __awaiter$2 = function(thisArg, _arguments, P, generator) {
23730
23107
  }
23731
23108
  }
23732
23109
  function step(result4) {
23733
- result4.done ? resolve6(result4.value) : adopt(result4.value).then(fulfilled, rejected);
23110
+ result4.done ? resolve7(result4.value) : adopt(result4.value).then(fulfilled, rejected);
23734
23111
  }
23735
23112
  step((generator = generator.apply(thisArg, _arguments || [])).next());
23736
23113
  });
@@ -23745,8 +23122,8 @@ var Semaphore = class {
23745
23122
  acquire(weight = 1, priority = 0) {
23746
23123
  if (weight <= 0)
23747
23124
  throw new Error(`invalid weight ${weight}: must be positive`);
23748
- return new Promise((resolve6, reject) => {
23749
- const task = { resolve: resolve6, reject, weight, priority };
23125
+ return new Promise((resolve7, reject) => {
23126
+ const task = { resolve: resolve7, reject, weight, priority };
23750
23127
  const i = findIndexFromEnd(this._queue, (other) => priority <= other.priority);
23751
23128
  if (i === -1 && weight <= this._value) {
23752
23129
  this._dispatchItem(task);
@@ -23771,10 +23148,10 @@ var Semaphore = class {
23771
23148
  if (this._couldLockImmediately(weight, priority)) {
23772
23149
  return Promise.resolve();
23773
23150
  } else {
23774
- return new Promise((resolve6) => {
23151
+ return new Promise((resolve7) => {
23775
23152
  if (!this._weightedWaiters[weight - 1])
23776
23153
  this._weightedWaiters[weight - 1] = [];
23777
- insertSorted(this._weightedWaiters[weight - 1], { resolve: resolve6, priority });
23154
+ insertSorted(this._weightedWaiters[weight - 1], { resolve: resolve7, priority });
23778
23155
  });
23779
23156
  }
23780
23157
  }
@@ -23857,11 +23234,11 @@ function findIndexFromEnd(a, predicate) {
23857
23234
  }
23858
23235
  var __awaiter$1 = function(thisArg, _arguments, P, generator) {
23859
23236
  function adopt(value) {
23860
- return value instanceof P ? value : new P(function(resolve6) {
23861
- resolve6(value);
23237
+ return value instanceof P ? value : new P(function(resolve7) {
23238
+ resolve7(value);
23862
23239
  });
23863
23240
  }
23864
- return new (P || (P = Promise))(function(resolve6, reject) {
23241
+ return new (P || (P = Promise))(function(resolve7, reject) {
23865
23242
  function fulfilled(value) {
23866
23243
  try {
23867
23244
  step(generator.next(value));
@@ -23877,7 +23254,7 @@ var __awaiter$1 = function(thisArg, _arguments, P, generator) {
23877
23254
  }
23878
23255
  }
23879
23256
  function step(result4) {
23880
- result4.done ? resolve6(result4.value) : adopt(result4.value).then(fulfilled, rejected);
23257
+ result4.done ? resolve7(result4.value) : adopt(result4.value).then(fulfilled, rejected);
23881
23258
  }
23882
23259
  step((generator = generator.apply(thisArg, _arguments || [])).next());
23883
23260
  });
@@ -23968,7 +23345,7 @@ async function registerDialogOwner(args2) {
23968
23345
  // packages/cli/client/localDialogRecords.ts
23969
23346
  var localDialogMessageRecordToRuntimeMessage = dialogMessageRecordToAgentRuntimeMessage;
23970
23347
  function buildLocalDialogWritePlan(args2) {
23971
- return buildAgentRuntimeDialogWritePlan({
23348
+ const plan = buildAgentRuntimeDialogWritePlan({
23972
23349
  input: args2.input,
23973
23350
  userId: args2.userId,
23974
23351
  now: args2.now,
@@ -23980,6 +23357,21 @@ function buildLocalDialogWritePlan(args2) {
23980
23357
  },
23981
23358
  ...args2.titleOverride ? { titleOverride: args2.titleOverride } : {}
23982
23359
  });
23360
+ const turnId = args2.input.runtimeContext?.turnId;
23361
+ const captureUserMessageIds = [];
23362
+ if (typeof turnId === "string" && /^turn-[0-9A-HJKMNP-TV-Z]{26}$/.test(turnId)) {
23363
+ const messages = args2.input.messages.filter((message) => message.role !== "system");
23364
+ for (const [index, message] of messages.entries()) {
23365
+ if (message.role !== "user" || message.cliMessageId) continue;
23366
+ const op = plan.ops[index + 1];
23367
+ const id = dialogTurnUserMessageId(turnId, index);
23368
+ const key = `dialog-${plan.dialogId}-msg-${id}`;
23369
+ op.key = key;
23370
+ op.value = { ...op.value, id, dbKey: key };
23371
+ captureUserMessageIds.push(id);
23372
+ }
23373
+ }
23374
+ return { ...plan, captureUserMessageIds };
23983
23375
  }
23984
23376
  async function saveCliPendingUserMessages(args2) {
23985
23377
  const dialogKey = `dialog-${args2.userId}-${args2.dialogId}`;
@@ -24026,7 +23418,7 @@ async function saveCliPendingUserMessages(args2) {
24026
23418
  if (ops.length) await args2.store.batch(ops);
24027
23419
  }
24028
23420
  async function readCliPendingUserMessages(store, dialogId) {
24029
- const { readDialogMessageRecords } = await import("./cliLocalAgentRecordReader-Z7CH4K4R.js");
23421
+ const { readDialogMessageRecords } = await import("./cliLocalAgentRecordReader-HVZAQCUD.js");
24030
23422
  const rows = await readDialogMessageRecords({ store, dialogId });
24031
23423
  const uncertain = rows.filter(({ record: record2 }) => record2.metadata?.cliBatchPhase === "requested" && !record2.metadata?.cliBatchResolution);
24032
23424
  const recovery = uncertain.length ? {
@@ -24075,6 +23467,8 @@ async function markCliUserBatchPhase(store, dialogId, messageId, phase, messageI
24075
23467
  metadata: {
24076
23468
  ...message.metadata,
24077
23469
  queueState: "accepted",
23470
+ cliBatchId: messageId,
23471
+ ...Number.isFinite(prepared?.cliHistoryOrder) ? { cliHistoryOrder: prepared.cliHistoryOrder } : {},
24078
23472
  ...id === messageId ? { cliBatchPhase: phase, acceptedUserMessageIds: [...messageIds] } : {}
24079
23473
  }
24080
23474
  } });
@@ -24089,6 +23483,8 @@ async function rollbackCliUserBatchPhase(store, dialogId, batchId, messageIds) {
24089
23483
  if (!record2) continue;
24090
23484
  const metadata = { ...record2.metadata };
24091
23485
  delete metadata.cliBatchPhase;
23486
+ delete metadata.cliBatchId;
23487
+ delete metadata.acceptedUserMessageIds;
24092
23488
  metadata.queueState = "pending";
24093
23489
  ops.push({ type: "put", key, value: { ...record2, metadata } });
24094
23490
  }
@@ -24121,15 +23517,15 @@ async function readNoloProcessStream(readable) {
24121
23517
  async function runNoloWorkspaceCliTool(call, args2) {
24122
23518
  const cliArgs = buildNoloWorkspaceCommandArgs(call);
24123
23519
  const bunSpawn = globalThis.Bun?.spawn;
24124
- const spawn5 = args2.spawn ?? (typeof bunSpawn === "function" ? bunSpawn : nodeSpawnFallback);
23520
+ const spawn2 = args2.spawn ?? (typeof bunSpawn === "function" ? bunSpawn : nodeSpawnFallback);
24125
23521
  const execPath = args2.processExecPath ?? process.execPath;
24126
23522
  const entrypoint = args2.cliEntrypoint;
24127
23523
  const cmd = entrypoint && entrypoint !== execPath ? [execPath, entrypoint, ...cliArgs] : [execPath, ...cliArgs];
24128
- const proc = spawn5({
23524
+ const proc = spawn2({
24129
23525
  cmd,
24130
23526
  stdout: "pipe",
24131
23527
  stderr: "pipe",
24132
- env: args2.env
23528
+ env: call.name === "listAgents" ? { ...process.env, ...args2.env, NOLO_PLANNING_CALLER: JSON.stringify(args2.planningCaller ?? {}) } : args2.env
24133
23529
  });
24134
23530
  const [stdout, stderr, exitCode] = await Promise.all([
24135
23531
  readNoloProcessStream(proc.stdout),
@@ -24237,10 +23633,10 @@ function buildLoadSkillExecutor(args2) {
24237
23633
  metadata: { loadSkill: true, resolved: false }
24238
23634
  };
24239
23635
  }
24240
- const { resolveSkillByName } = await import("./skillDiscovery-B5V23AXP.js");
23636
+ const { resolveSkillByName } = await import("./skillDiscovery-MDDKPTW3.js");
24241
23637
  const resolved = resolveSkillByName(args2.cwd, name);
24242
23638
  if (!resolved) {
24243
- const { resolveBuiltinSkillByName } = await import("./builtinSkillRegistry-PXH7EGQB.js");
23639
+ const { resolveBuiltinSkillByName } = await import("./builtinSkillRegistry-AYWYQVA4.js");
24244
23640
  const builtin = resolveBuiltinSkillByName(name);
24245
23641
  if (builtin) {
24246
23642
  const denied = await rejectDisabledBuiltin(args2.agentSkillSource, builtin.slug, name, args2.resolveAgentSkillSource);
@@ -24267,8 +23663,8 @@ ${builtin.content}`,
24267
23663
  };
24268
23664
  }
24269
23665
  try {
24270
- const { readFileSync } = await import("node:fs");
24271
- const body = readFileSync(resolved, "utf8");
23666
+ const { readFileSync: readFileSync2 } = await import("node:fs");
23667
+ const body = readFileSync2(resolved, "utf8");
24272
23668
  return {
24273
23669
  content: `Skill "${name}" loaded inline. Follow its instructions.
24274
23670
 
@@ -24319,7 +23715,7 @@ async function loadPreciseSkill(cwd, parsed, agentSkillSource, resolveAgentSkill
24319
23715
  if (!nonEmpty(parsed.slug) || has2("projectBinding") || has2("relativePath")) {
24320
23716
  return reject("builtin requires only an exact slug.");
24321
23717
  }
24322
- const { listBuiltinSkills } = await import("./builtinSkillRegistry-PXH7EGQB.js");
23718
+ const { listBuiltinSkills } = await import("./builtinSkillRegistry-AYWYQVA4.js");
24323
23719
  const builtin = listBuiltinSkills().find((entry) => entry.slug === parsed.slug);
24324
23720
  if (!builtin) return reject("builtin slug not found.");
24325
23721
  const denied = await rejectDisabledBuiltin(agentSkillSource, builtin.slug, builtin.slug, resolveAgentSkillSource);
@@ -24344,8 +23740,8 @@ ${builtin.content}`,
24344
23740
  return reject("project requires projectBinding and relativePath only.");
24345
23741
  }
24346
23742
  try {
24347
- const { realpathSync, statSync, readFileSync } = await import("node:fs");
24348
- const { resolve: resolve6, relative: relative6, isAbsolute: isAbsolute5, basename: basename4, sep: sep3 } = await import("node:path");
23743
+ const { realpathSync, statSync, readFileSync: readFileSync2 } = await import("node:fs");
23744
+ const { resolve: resolve7, relative: relative6, isAbsolute: isAbsolute5, basename: basename4, sep: sep3 } = await import("node:path");
24349
23745
  const inside = (root, target) => {
24350
23746
  const rel = relative6(root, target);
24351
23747
  return rel !== "" && rel !== ".." && !rel.startsWith(`..${sep3}`) && !isAbsolute5(rel);
@@ -24357,8 +23753,8 @@ ${builtin.content}`,
24357
23753
  if (isAbsolute5(parsed.relativePath) || basename4(parsed.relativePath) !== "SKILL.md") {
24358
23754
  return reject("relativePath must reference a project SKILL.md.");
24359
23755
  }
24360
- const skillsRoot = resolve6(realCwd, ".agents", "skills");
24361
- const candidate = resolve6(realCwd, parsed.relativePath);
23756
+ const skillsRoot = resolve7(realCwd, ".agents", "skills");
23757
+ const candidate = resolve7(realCwd, parsed.relativePath);
24362
23758
  if (!inside(skillsRoot, candidate)) return reject("path is outside cwd/.agents/skills/.");
24363
23759
  const realRoot = realpathSync(skillsRoot);
24364
23760
  const realPath = realpathSync(candidate);
@@ -24366,7 +23762,7 @@ ${builtin.content}`,
24366
23762
  return reject("skill path escapes cwd/.agents/skills/ or is not SKILL.md.");
24367
23763
  }
24368
23764
  if (!statSync(realPath).isFile()) return reject("SKILL.md is not a file.");
24369
- const body = readFileSync(realPath, "utf8");
23765
+ const body = readFileSync2(realPath, "utf8");
24370
23766
  return {
24371
23767
  content: `Skill "${parsed.relativePath}" loaded inline. Follow its instructions.
24372
23768
 
@@ -24385,7 +23781,7 @@ ${body}`,
24385
23781
  }
24386
23782
  }
24387
23783
  async function formatUnknownSkillMessage(cwd, requestedName) {
24388
- const { discoverSkills } = await import("./skillDiscovery-B5V23AXP.js");
23784
+ const { discoverSkills } = await import("./skillDiscovery-MDDKPTW3.js");
24389
23785
  let available = [];
24390
23786
  try {
24391
23787
  available = discoverSkills(cwd).map((s) => s.name);
@@ -24957,11 +24353,11 @@ function createDevinProvider(options) {
24957
24353
  }
24958
24354
 
24959
24355
  // packages/agent-runtime/executionLeaseValidation.ts
24960
- import { isAbsolute as isAbsolute4, relative as relative5, resolve as resolve5 } from "node:path";
24356
+ import { isAbsolute as isAbsolute4, relative as relative5, resolve as resolve6 } from "node:path";
24961
24357
  function withinRoot(root, child) {
24962
24358
  if (!isAbsolute4(root) || !isAbsolute4(child)) return false;
24963
- const canonicalRoot = resolve5(root);
24964
- const canonicalChild = resolve5(child);
24359
+ const canonicalRoot = resolve6(root);
24360
+ const canonicalChild = resolve6(child);
24965
24361
  const suffix = relative5(canonicalRoot, canonicalChild);
24966
24362
  return suffix === "" || suffix !== ".." && !suffix.startsWith("../") && !suffix.startsWith("..\\") && !isAbsolute4(suffix);
24967
24363
  }
@@ -25024,17 +24420,16 @@ function verifyOwnerRouteAck(headers, expectedRequestId) {
25024
24420
  }
25025
24421
 
25026
24422
  export {
25027
- createHostCredentialBrokerChain,
25028
- createStrictHostCredentialBroker,
25029
24423
  readCommandActionGatePayload,
25030
24424
  readActionGate,
24425
+ orderDialogHistory,
25031
24426
  Option_exports,
25032
24427
  Duration_exports,
25033
24428
  Exit_exports,
25034
24429
  Effect_exports,
25035
- scrubSecrets,
25036
24430
  isDestructiveShellCommand,
25037
24431
  evaluateShellCommandPolicy,
24432
+ readAgentsMdLayerFromDisk,
25038
24433
  filterRetainedLedgerRecords,
25039
24434
  isLineRangeCovered,
25040
24435
  runTaskStop,
@@ -25058,7 +24453,7 @@ export {
25058
24453
  runExecShellGates,
25059
24454
  executeLocalToolWithPolicy,
25060
24455
  LOCAL_TURN_ABORTED_CODE,
25061
- evaluateTaskExecutionContract,
24456
+ validateStoredSummary,
25062
24457
  projectContextProvenance,
25063
24458
  hashToolDefinitions,
25064
24459
  LOCAL_AGENT_CONFIG_MISSING_CODE,
@@ -25073,7 +24468,6 @@ export {
25073
24468
  executeOpenAiCompatibleChatCompletion,
25074
24469
  describeOpenAiCompatibleRequestBudget,
25075
24470
  resolveOpenAiCompatibleProviderConfig,
25076
- dialogMessageRecordToAgentRuntimeMessage,
25077
24471
  buildAgentRuntimeDialogWritePlan,
25078
24472
  shouldCacheHybridRemoteRecord,
25079
24473
  parseSyncServersEnv,