nolo-cli 0.240.0-alpha.3 → 0.242.0-alpha.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 (206) hide show
  1. package/README.md +3 -5
  2. package/{_executeModel-5NA4USGG.js → _executeModel-IZ2MCXHO.js} +77 -77
  3. package/{action-X75O3XPH.js → action-VDEW6WLI.js} +9 -9
  4. package/{addContentAction-GVC77QSN.js → addContentAction-7YVXHIPQ.js} +14 -14
  5. package/{addDialogAgentAction-KKDVAMW3.js → addDialogAgentAction-BX7B47HF.js} +17 -17
  6. package/{agentDeleteCommand-2RFGKFAB.js → agentDeleteCommand-N7ELXPLD.js} +107 -108
  7. package/{agentEmailCommands-GQCQKKOR.js → agentEmailCommands-OFS477PV.js} +110 -111
  8. package/{agentListCommands-HSGLDPDQ.js → agentListCommands-IQQHJSXP.js} +202 -164
  9. package/{agentMachineCommands-BISF6PVV.js → agentMachineCommands-NS65BEW7.js} +52 -49
  10. package/{agentProviderCommands-O3Q25PKU.js → agentProviderCommands-SS6M6VGY.js} +2 -2
  11. package/{agentPullCommand-G6U2LHMW.js → agentPullCommand-QQQZSC6S.js} +1 -1
  12. package/{agentRecordCommands-AOXPGYAJ.js → agentRecordCommands-4VE7CNLC.js} +103 -104
  13. package/{agentRunCommand-AFAIP7U7.js → agentRunCommand-2MUXHKNW.js} +109 -108
  14. package/{agentRunControl-VBL7UFSG.js → agentRunControl-55GL6Q3M.js} +11 -9
  15. package/{agentRuntimeLocal-T7BX2WGL.js → agentRuntimeLocal-5DB2P4MU.js} +51 -43
  16. package/{agentSlice-XJNKE3PG.js → agentSlice-5VTAFG43.js} +14 -14
  17. package/{appDeleteCommands-LURUSPY7.js → appDeleteCommands-EDKUPHJM.js} +52 -49
  18. package/{appDeployCommands-SMEW4AK2.js → appDeployCommands-JO74GW4L.js} +52 -49
  19. package/{appDeployStatusCommands-VYPJTBJK.js → appDeployStatusCommands-U77ZUHX7.js} +52 -49
  20. package/{appGetCommands-N4NI5GGJ.js → appGetCommands-QCMHBYPX.js} +52 -49
  21. package/{appListCommands-5C6ONN3Z.js → appListCommands-ZQJYEXI6.js} +52 -49
  22. package/{authCommand-4CVBDADE.js → authCommand-W4KXRZLI.js} +23 -19
  23. package/{authCommands-EHU2BHOX.js → authCommands-6AUYO65N.js} +10 -6
  24. package/{builtinSkillRegistry-AYWYQVA4.js → builtinSkillRegistry-GHE3RD3V.js} +6 -6
  25. package/{chromeCommands-G5UDKVSV.js → chromeCommands-S7AW3AOD.js} +383 -6
  26. package/{chromeOpsCommands-CSDG2HYN.js → chromeOpsCommands-TBPM6MR4.js} +1 -1
  27. package/{chunk-7TTMMOKH.js → chunk-247AAJRK.js} +1 -1
  28. package/{chunk-4X5AVCM7.js → chunk-2BSLGODA.js} +258 -23
  29. package/{chunk-P3IZUMIC.js → chunk-2N4UBHUU.js} +4 -4
  30. package/{chunk-A74QP4FI.js → chunk-2T5BHLID.js} +572 -208
  31. package/{chunk-H7ZYKHAZ.js → chunk-3OQFXODL.js} +102 -31
  32. package/{chunk-BIABIPGW.js → chunk-3ORFJP2Z.js} +1 -1
  33. package/{chunk-3FBAVU2Y.js → chunk-3UNAGTBW.js} +19 -84
  34. package/{chunk-DNZ4JJ7C.js → chunk-4F7SWSWO.js} +19 -6
  35. package/{chunk-2X7WFDT6.js → chunk-4FE3IWRE.js} +1 -1
  36. package/{chunk-N2JROHD3.js → chunk-4UK6UBXF.js} +3 -3
  37. package/{chunk-XS5A3EKX.js → chunk-4YFC3DWW.js} +75 -1
  38. package/chunk-53W5BXLN.js +340 -0
  39. package/{chunk-E5KJOZWY.js → chunk-5GRWWUB4.js} +3 -3
  40. package/{chunk-HCNOO374.js → chunk-6326DRQY.js} +1 -1
  41. package/{chunk-RM4UMFY4.js → chunk-6MQWGA5F.js} +10 -10
  42. package/{chunk-TEMLHVGX.js → chunk-6MX6S6TE.js} +3 -3
  43. package/{chunk-6WOLPIPY.js → chunk-6RSNVJGO.js} +2 -102
  44. package/{chunk-Y5OWZQMJ.js → chunk-6S6CZUXK.js} +19 -19
  45. package/{chunk-PDCV7P5W.js → chunk-6XIE5ZGI.js} +1 -1
  46. package/{chunk-FZKA3XFA.js → chunk-6XLWUNZB.js} +27 -27
  47. package/{chunk-62HXNQVV.js → chunk-776CXKMX.js} +1 -1
  48. package/{chunk-MYPKBJJO.js → chunk-7AWKDRXG.js} +2 -2
  49. package/{chunk-GDUC4VS2.js → chunk-7GTXPS3D.js} +10 -10
  50. package/{chunk-Z2WZAE4P.js → chunk-7HUHOCIY.js} +36 -30
  51. package/{chunk-PWTNI4N7.js → chunk-ANUP75N2.js} +22 -0
  52. package/{chunk-ULLHVDTZ.js → chunk-BH7CEVOH.js} +4 -4
  53. package/{chunk-A3LUWRQK.js → chunk-C4KX626C.js} +5 -5
  54. package/chunk-C5A54QS7.js +108 -0
  55. package/{chunk-DXW5WDHZ.js → chunk-CHYYSFFM.js} +6 -6
  56. package/{chunk-O6IPRAVV.js → chunk-CJTB3OYB.js} +2 -2
  57. package/{chunk-AVJDELEA.js → chunk-DLT2DN4M.js} +1 -1
  58. package/{chunk-LKA64WH4.js → chunk-DMPZMYH4.js} +37 -1
  59. package/{chunk-MM73SP4K.js → chunk-DOK7GDRU.js} +1 -1
  60. package/{chunk-VREG6ANQ.js → chunk-DPAIQLAL.js} +16 -16
  61. package/{chunk-ANJRDS6U.js → chunk-EKXPHL7M.js} +3 -3
  62. package/{chunk-TWTJV35S.js → chunk-ENYTIRIO.js} +3 -3
  63. package/{chunk-PGKA77TZ.js → chunk-ER3P6MBT.js} +170 -107
  64. package/{chunk-EEOOBRA7.js → chunk-F4MCAOWN.js} +2 -2
  65. package/{chunk-7NIBQ4HY.js → chunk-FDZ2GBWO.js} +30 -2
  66. package/{chunk-VSRISJXZ.js → chunk-GAHJLSDO.js} +1 -1
  67. package/{chunk-U3G7RRXJ.js → chunk-GES5GIAU.js} +8 -8
  68. package/{chunk-4IQVE43Z.js → chunk-HQVNO7FH.js} +22 -22
  69. package/{chunk-DVYAFH2Q.js → chunk-HSWEFHFS.js} +1 -1
  70. package/{chunk-MECDGHLK.js → chunk-IIG3TT73.js} +43 -6
  71. package/{chunk-YGCOJNFZ.js → chunk-IZJFTY4R.js} +3 -3
  72. package/{chunk-BXSMFPTG.js → chunk-J25ESVUW.js} +10 -10
  73. package/{chunk-CVJRVBJL.js → chunk-J2XZZXIH.js} +4 -4
  74. package/{chunk-3EMIEC27.js → chunk-JVJ53XCH.js} +1 -1
  75. package/{chunk-AH5R7BYW.js → chunk-KC2QVCI7.js} +6 -6
  76. package/{chunk-MYOSN6BT.js → chunk-KF2DWSAH.js} +34 -13
  77. package/chunk-KK3FCYZM.js +647 -0
  78. package/{chunk-PRMEU7BT.js → chunk-KLD7K5FD.js} +7 -7
  79. package/{chunk-7AJRJGSQ.js → chunk-KMW5CRRM.js} +801 -381
  80. package/{chunk-Y2MF4DCJ.js → chunk-LELADM5Q.js} +1 -1
  81. package/{chunk-RTHFJZ6M.js → chunk-LMFMV5UC.js} +2 -2
  82. package/{chunk-2574ANSV.js → chunk-LZOOUQAZ.js} +4 -4
  83. package/{chunk-HOM6LTEW.js → chunk-M5EA44QU.js} +6 -6
  84. package/{chunk-IUMS6F53.js → chunk-MEDPR36J.js} +9 -5
  85. package/{chunk-6D25V6CB.js → chunk-MFXJY44K.js} +4 -4
  86. package/chunk-MVOZ22RZ.js +26 -0
  87. package/{chunk-CBUZ6DKA.js → chunk-N6EN3HK3.js} +1 -1
  88. package/{chunk-VS276URX.js → chunk-NEG5LYK5.js} +1 -1
  89. package/{chunk-B7DE5XJW.js → chunk-ODGSLWLO.js} +249 -66
  90. package/{chunk-S2MHR4PU.js → chunk-OGZE6BZG.js} +190 -118
  91. package/{chunk-CD3RU7XL.js → chunk-OJRTTERA.js} +62 -2
  92. package/{chunk-GXXY2NL3.js → chunk-OKPC4QNX.js} +37 -2
  93. package/{chunk-5QZSEQSK.js → chunk-ONFFUQYM.js} +1 -1
  94. package/{chunk-BGGAY6OK.js → chunk-P244EH4W.js} +3 -3
  95. package/chunk-P27E22MA.js +203 -0
  96. package/{chunk-UFC4J7OY.js → chunk-PK7VT4ZU.js} +3 -3
  97. package/{chunk-4FIO2S7Z.js → chunk-QLUYDJST.js} +1 -1
  98. package/{chunk-AEQMKYZN.js → chunk-QUJKDFZW.js} +7 -7
  99. package/{chunk-G22P367E.js → chunk-QXUVCIPB.js} +62 -18
  100. package/{chunk-IJTXNLQE.js → chunk-QYNABNNQ.js} +6 -6
  101. package/{chunk-TRHJ4NJB.js → chunk-RGUWOMXU.js} +626 -237
  102. package/{chunk-L32W3PRP.js → chunk-RH44TIHX.js} +165 -16
  103. package/{chunk-EBKHA63G.js → chunk-RIMFTQMC.js} +178 -46
  104. package/{chunk-OOJNQK6V.js → chunk-S25VJYXV.js} +8 -2
  105. package/{chunk-BGGV6B5O.js → chunk-SBRJOYND.js} +280 -139
  106. package/{chunk-KZPEGO6D.js → chunk-SBRSXY67.js} +6 -6
  107. package/chunk-SR4FE5VD.js +9 -0
  108. package/{chunk-4WVJLODK.js → chunk-T23G6PXQ.js} +8 -3
  109. package/{chunk-D374I563.js → chunk-T3WSFTBS.js} +1 -1
  110. package/{chunk-VP3BINY7.js → chunk-TOK555CQ.js} +31 -1
  111. package/{chunk-OBSEKCVK.js → chunk-U4VSBDO5.js} +88 -0
  112. package/{chunk-OX6GNNVT.js → chunk-U5LOKQ2R.js} +24 -13
  113. package/{chunk-LYDEFPQP.js → chunk-UDT4SI37.js} +1 -1
  114. package/{chunk-CKZPMJNU.js → chunk-UQXOORR3.js} +5 -5
  115. package/{chunk-FFYE5ATM.js → chunk-UR7555FE.js} +11 -11
  116. package/{chunk-F3XI6WQP.js → chunk-UWOCASVL.js} +5 -5
  117. package/{chunk-A5EVA6HU.js → chunk-V2V5Q6DU.js} +2 -2
  118. package/{chunk-PROOOQZ3.js → chunk-VCU5GV42.js} +1 -1
  119. package/{chunk-F6YWDVIB.js → chunk-VMWY7TUA.js} +1 -1
  120. package/{chunk-RETQOQ4D.js → chunk-VNALJT32.js} +2 -2
  121. package/{chunk-HGDKT2D6.js → chunk-VTHWBTRE.js} +177 -1
  122. package/{chunk-X7IA2B7R.js → chunk-WBSJAIZP.js} +7 -3
  123. package/{chunk-ZEKUFJLW.js → chunk-WVOZ35E4.js} +7 -7
  124. package/{chunk-B5SV4H3J.js → chunk-XDNXKFWF.js} +4 -4
  125. package/{chunk-4Q6HQORG.js → chunk-XLN2GD6Z.js} +4 -4
  126. package/{chunk-HBRDSQ3M.js → chunk-XNEDFWT4.js} +2 -2
  127. package/{chunk-6CKUO32A.js → chunk-Y22P6ASC.js} +11 -8
  128. package/{chunk-SRCCSTIM.js → chunk-Y3DOUQQQ.js} +4 -4
  129. package/{chunk-6WZVM33D.js → chunk-Y5EBOURK.js} +3 -3
  130. package/{chunk-6OVNSQHN.js → chunk-YLAHYLDQ.js} +5 -0
  131. package/{chunk-T6VROBY7.js → chunk-YTEY27GN.js} +2 -2
  132. package/{chunk-5ZUOVCKT.js → chunk-YUZ2DAIH.js} +3 -1
  133. package/{chunk-IUTUWIKE.js → chunk-ZCVBIIUE.js} +4 -4
  134. package/{chunk-VM72HKW2.js → chunk-ZCZLTJEW.js} +9 -36
  135. package/{cliAgentConfigHelpers-U5OAVAKQ.js → cliAgentConfigHelpers-6OFDHJFT.js} +8 -8
  136. package/{cliAuthorityBrokerClient-S42VMGB6.js → cliAuthorityBrokerClient-SFPC3WVK.js} +1 -1
  137. package/{cliLocalAgentRecordReader-HVZAQCUD.js → cliLocalAgentRecordReader-FHIMCBUK.js} +52 -45
  138. package/{commandRegistry-TME7INFU.js → commandRegistry-OKIWAJIS.js} +101 -93
  139. package/{contentThunks-U6OC4R2N.js → contentThunks-VF2DCU46.js} +33 -32
  140. package/{cooldownCommands-U7XSRVJP.js → cooldownCommands-QL6DWGVU.js} +1 -1
  141. package/{createAgentAutomationAction-IP4LFN3W.js → createAgentAutomationAction-BGET7Q6K.js} +34 -33
  142. package/{createDialogAction-IAGQJ3LH.js → createDialogAction-XYDQZETK.js} +34 -33
  143. package/{createPageAction-AZ3UIFKA.js → createPageAction-74S5RO7U.js} +38 -37
  144. package/{db-M7FU2GNK.js → db-6NRZLEW2.js} +1 -1
  145. package/{dbSlice-DKKMJJYY.js → dbSlice-FI7VNDR5.js} +13 -13
  146. package/{deleteFile-TQSONMVU.js → deleteFile-GD62MPZW.js} +8 -8
  147. package/{dialogCommands-PCDRMBWG.js → dialogCommands-Y6DHZUAM.js} +56 -54
  148. package/{dialogNotifyCommand-O35MWMOS.js → dialogNotifyCommand-MKXL4NGL.js} +10 -10
  149. package/{dialogSlice-QAKYN4DE.js → dialogSlice-XAUKSWZ4.js} +32 -31
  150. package/{dialogUsageCommand-2SSLTXKO.js → dialogUsageCommand-BZPKR3DW.js} +5 -5
  151. package/{docCreateCommands-CFQFZOAD.js → docCreateCommands-PHDFOQBM.js} +51 -48
  152. package/{docDeleteCommands-5CPNTIIS.js → docDeleteCommands-OSHJM67Y.js} +53 -50
  153. package/{docReadCommands-XQILYSAJ.js → docReadCommands-E6QYCFMS.js} +51 -48
  154. package/{docStore-GIVRT7TQ.js → docStore-ZZT2BEBU.js} +15 -15
  155. package/{docUpdateCommands-VETKSUDD.js → docUpdateCommands-DHIOPK2C.js} +51 -48
  156. package/fetchMessages-TQEUZD7H.js +1 -1
  157. package/{getPricing-LF5C4XSI.js → getPricing-RNRITFOP.js} +4 -4
  158. package/{handleSendMessageAction-HKIW4ZNO.js → handleSendMessageAction-ARUU6CNF.js} +71 -70
  159. package/{hostCredentialCreate-6VDJFNDO.js → hostCredentialCreate-SNQT73H4.js} +103 -104
  160. package/index.js +8 -8
  161. package/{localDialogRead-AV2VKKPG.js → localDialogRead-3T2KMCRC.js} +1 -1
  162. package/{localRuntimeAdapter-BQ4F5PZV.js → localRuntimeAdapter-MHI6Y2IZ.js} +112 -111
  163. package/{localRuntimeAuthority-WCNA4A3G.js → localRuntimeAuthority-7DKIT7UH.js} +2 -2
  164. package/{localRuntimeDb-CRNIBOOM.js → localRuntimeDb-5WZ4RJJO.js} +1 -1
  165. package/{machineCommands-K6XIGOAD.js → machineCommands-3O6Y27R4.js} +229 -321
  166. package/{machineWsRunDispatch-4OO7Z6UM.js → machineWsRunDispatch-5PFLR5XC.js} +101 -102
  167. package/markdownToSlate-KIYM7B3P.js +8 -0
  168. package/{mcpLocalAuthorizeCommand-ZP6ESAGE.js → mcpLocalAuthorizeCommand-BQCQ2KRJ.js} +15 -15
  169. package/{memberThunks-PBJPZ2JU.js → memberThunks-TU6A6OBV.js} +16 -16
  170. package/{models-H5NNZRLH.js → models-CINY5UZR.js} +2 -2
  171. package/package.json +1 -1
  172. package/{projectArchive-G7AOQPRW.js → projectArchive-X2EVXU3N.js} +40 -39
  173. package/{providerPresetApply-OPBCAONX.js → providerPresetApply-HUWNV2NI.js} +6 -6
  174. package/{providerRegistry-J2HCVTHE.js → providerRegistry-7FWKDKZJ.js} +6 -6
  175. package/{read-JEGPITEW.js → read-QAHEQID5.js} +8 -8
  176. package/{readDocTool-TE3XIU4Y.js → readDocTool-KG5DP6EM.js} +1 -1
  177. package/{readlineWorkspace-SOW5QUGZ.js → readlineWorkspace-SO3APHVP.js} +3300 -1518
  178. package/rememberExplicit-CPAPONSI.js +15 -0
  179. package/{removeDialogAgentAction-CX3OAH4Y.js → removeDialogAgentAction-QZCCVK2G.js} +19 -19
  180. package/{runAgentClientLoop-HQJPDFGQ.js → runAgentClientLoop-FLHHCOVH.js} +77 -77
  181. package/{runtimeDoctorCommands-GUH2YGMH.js → runtimeDoctorCommands-DN3I52C6.js} +8 -8
  182. package/{secretCommands-NJXFVHZU.js → secretCommands-36BCE3UE.js} +2 -2
  183. package/{setDialogExtraReferencesAction-CGM67EEQ.js → setDialogExtraReferencesAction-PDPTYSEW.js} +15 -15
  184. package/{setPrimaryDialogAgentAction-3ABWPPXR.js → setPrimaryDialogAgentAction-DOUIPR66.js} +19 -19
  185. package/{settingThunks-AY76OHYX.js → settingThunks-MHGGP6UE.js} +23 -23
  186. package/{spaceCommands-G63QGYQO.js → spaceCommands-JH7UYE3K.js} +54 -51
  187. package/{streamAgentChatTurn-E3XH2KFD.js → streamAgentChatTurn-VDDA2TX6.js} +118 -118
  188. package/{switchDialogAgentAction-G6EZRKCQ.js → switchDialogAgentAction-7USK3DAP.js} +17 -17
  189. package/{tableCommands-JI75ZHDI.js → tableCommands-UONBFC7L.js} +6 -6
  190. package/{toolApiClient-62UUPDUA.js → toolApiClient-53YMJ2G6.js} +7 -3
  191. package/{tools-7RSX22FT.js → tools-MIOCXKMG.js} +59 -60
  192. package/{tuiRestart-KAAA7TND.js → tuiRestart-ET3QISZ5.js} +10 -10
  193. package/{tuiSummaryLlmCaller-BVNHMWLR.js → tuiSummaryLlmCaller-MSINBP3M.js} +15 -14
  194. package/{updateCommands-ASK5XYPH.js → updateCommands-5OYND6EF.js} +3 -3
  195. package/{updateDialogTitleAction-SEWV252V.js → updateDialogTitleAction-2L4CC4YO.js} +35 -34
  196. package/{usageCommand-JVT5J3DC.js → usageCommand-JTKDAG6I.js} +2 -2
  197. package/{usageRebuildCommand-IZYYUTEW.js → usageRebuildCommand-4TFZCKXM.js} +3 -3
  198. package/{windowsSelfUpdate-BSDIS2J5.js → windowsSelfUpdate-HIYNL3VR.js} +2 -2
  199. package/{workContext-MM3P5GP5.js → workContext-Y3ADAPZU.js} +2 -1
  200. package/{workloadLifecycle-YIZ7KLUP.js → workloadLifecycle-ZCSQCHG3.js} +6 -6
  201. package/chunk-TUSTONB3.js +0 -81
  202. package/chunk-XBAEM4RI.js +0 -272
  203. package/{accountResolver-EK2S4PWF.js → accountResolver-QETKNC7T.js} +3 -3
  204. package/{chunk-W6RFEDN4.js → chunk-AETZ7AD6.js} +3 -3
  205. package/{chunk-VMJVAJ6W.js → chunk-TB5KTLNB.js} +3 -3
  206. /package/{chunk-FJ23FZXF.js → chunk-VIYVRPMJ.js} +0 -0
@@ -1,6 +1,3 @@
1
- import {
2
- BROWSER_SHELL_BRIDGE_ENV
3
- } from "./chunk-2YGBI2XB.js";
4
1
  import {
5
2
  confirmMcpOnHost,
6
3
  createConnectorApprovalPort,
@@ -10,19 +7,10 @@ import {
10
7
  parsePendingApprovalResult,
11
8
  runConnectorToolWithHostApproval,
12
9
  withHostApprovalRequest
13
- } from "./chunk-RETQOQ4D.js";
10
+ } from "./chunk-VNALJT32.js";
14
11
  import {
15
- clearCredentialAvailability,
16
- markCredentialUnavailable,
17
- readCredentialEntry
18
- } from "./chunk-WWTSEBDF.js";
19
- import {
20
- customNativeAuthHeaders,
21
- detectDeclaredCustomNativeWire,
22
- isCallerCancellation,
23
- resolveCustomNativeApiKeyHeader,
24
- resolveCustomNativeEndpoint
25
- } from "./chunk-WOAZVUSN.js";
12
+ BROWSER_SHELL_BRIDGE_ENV
13
+ } from "./chunk-2YGBI2XB.js";
26
14
  import {
27
15
  adoptRequiredClaudeCodeVersion,
28
16
  anthropicRefresh,
@@ -34,12 +22,12 @@ import {
34
22
  resolveClaudeCodeVersion,
35
23
  resolveServerSyncConfig,
36
24
  xaiRefresh
37
- } from "./chunk-MYOSN6BT.js";
25
+ } from "./chunk-KF2DWSAH.js";
38
26
  import {
39
- DialogNotifyError,
40
- deliverDialogNotification,
41
- sha256Hex
42
- } from "./chunk-TEMLHVGX.js";
27
+ clearCredentialAvailability,
28
+ markCredentialUnavailable,
29
+ readCredentialEntry
30
+ } from "./chunk-WWTSEBDF.js";
43
31
  import {
44
32
  SANDBOX_HELPER_PATH,
45
33
  SANDBOX_OUTPUT_LIMITS,
@@ -48,7 +36,7 @@ import {
48
36
  buildWorkspaceHelperSource,
49
37
  dockerExecutionToolNames,
50
38
  parseToolOutput
51
- } from "./chunk-HGDKT2D6.js";
39
+ } from "./chunk-VTHWBTRE.js";
52
40
  import {
53
41
  createChromeConnectorClientResolver,
54
42
  createVerifiedChromeConnectorClient,
@@ -56,14 +44,20 @@ import {
56
44
  validateChromeConnectorPayload
57
45
  } from "./chunk-UAIHKQIA.js";
58
46
  import {
59
- extractLastUserText,
60
- localTurnHasSubjectRefs,
61
- resolveLocalUserId,
62
- withResolvedRuntimeToolSurface
63
- } from "./chunk-2574ANSV.js";
47
+ customNativeAuthHeaders,
48
+ detectDeclaredCustomNativeWire,
49
+ isCallerCancellation,
50
+ resolveCustomNativeApiKeyHeader,
51
+ resolveCustomNativeEndpoint
52
+ } from "./chunk-WOAZVUSN.js";
53
+ import {
54
+ DialogNotifyError,
55
+ deliverDialogNotification,
56
+ sha256Hex
57
+ } from "./chunk-6MX6S6TE.js";
64
58
  import {
65
59
  createTuiSummaryLlmCaller
66
- } from "./chunk-P3IZUMIC.js";
60
+ } from "./chunk-2N4UBHUU.js";
67
61
  import {
68
62
  CliProviderQuotaError,
69
63
  executeCli,
@@ -75,13 +69,10 @@ import {
75
69
  import {
76
70
  buildCliPrompt
77
71
  } from "./chunk-ATNTHIZI.js";
78
- import {
79
- resolveUserSkillRuntime
80
- } from "./chunk-6D25V6CB.js";
81
72
  import {
82
73
  inlineImageUrlsForCustomProvider,
83
74
  prepareTools
84
- } from "./chunk-CVJRVBJL.js";
75
+ } from "./chunk-J2XZZXIH.js";
85
76
  import {
86
77
  getServerProviderSecret
87
78
  } from "./chunk-HS7MLR74.js";
@@ -104,22 +95,25 @@ import {
104
95
  resolveCliLocalSpawnDispatch,
105
96
  resolveRunContextFacts,
106
97
  resolveStartAgentRunCwd
107
- } from "./chunk-BGGV6B5O.js";
98
+ } from "./chunk-SBRJOYND.js";
108
99
  import {
109
100
  deriveCredentialGroup,
110
101
  deriveCustomProviderCredentialGroup
111
- } from "./chunk-ZEKUFJLW.js";
102
+ } from "./chunk-WVOZ35E4.js";
103
+ import {
104
+ resolveUserSkillRuntime
105
+ } from "./chunk-MFXJY44K.js";
112
106
  import {
113
107
  normalizeEnabledPromptSkills,
114
108
  resolveUserEnabledSkills
115
- } from "./chunk-DVYAFH2Q.js";
109
+ } from "./chunk-HSWEFHFS.js";
116
110
  import {
117
111
  validateAskChoiceInput
118
- } from "./chunk-PRMEU7BT.js";
112
+ } from "./chunk-KLD7K5FD.js";
119
113
  import {
120
114
  prepareTokenUsageData,
121
115
  runKeyed
122
- } from "./chunk-B7DE5XJW.js";
116
+ } from "./chunk-ODGSLWLO.js";
123
117
  import {
124
118
  applyTokenUsageToDayStats,
125
119
  require_format
@@ -130,22 +124,20 @@ import {
130
124
  } from "./chunk-523DITKR.js";
131
125
  import {
132
126
  fetchServerSyncedCredential
133
- } from "./chunk-IJTXNLQE.js";
127
+ } from "./chunk-QYNABNNQ.js";
134
128
  import {
135
- defaultLoopbackRequest
136
- } from "./chunk-VP3BINY7.js";
129
+ defaultLoopbackRequest,
130
+ loadLocalRunChildDialogIds
131
+ } from "./chunk-TOK555CQ.js";
137
132
  import {
138
133
  CREDENTIAL_STORE_SESSION_FALLBACK_WARNING,
139
134
  OAUTH_PROVIDER_REFS,
140
135
  getSharedSessionCredentialBroker
141
- } from "./chunk-BXSMFPTG.js";
136
+ } from "./chunk-J25ESVUW.js";
142
137
  import {
143
138
  fetchWithTransientRetry,
144
139
  isTransientFetchError
145
140
  } from "./chunk-DXWGFL2Z.js";
146
- import {
147
- getDefaultCliLocalRuntimeDb
148
- } from "./chunk-Y2MF4DCJ.js";
149
141
  import {
150
142
  _readQueueEntriesLocked,
151
143
  ackRunRecord,
@@ -154,6 +146,7 @@ import {
154
146
  checkStaleRun,
155
147
  claimRunRecord,
156
148
  commitRunRecordClaim,
149
+ defaultGenerateRunId,
157
150
  findRunRecord,
158
151
  gcRunRecords,
159
152
  isRunTerminalStatus,
@@ -170,12 +163,7 @@ import {
170
163
  terminateRunProcess,
171
164
  transitionRunToTerminal,
172
165
  withQueueLock
173
- } from "./chunk-MECDGHLK.js";
174
- import {
175
- remoteDialogSyncTimeout,
176
- resolveRuntimeAuthToken,
177
- resolveRuntimeServerUrl
178
- } from "./chunk-2X7WFDT6.js";
166
+ } from "./chunk-IIG3TT73.js";
179
167
  import {
180
168
  TASK_PREVIEW_MAX,
181
169
  formatControlRunMessageCard,
@@ -192,21 +180,22 @@ import {
192
180
  resolveAgentRunName,
193
181
  resolveRunLabel,
194
182
  shortRunId
195
- } from "./chunk-OOJNQK6V.js";
183
+ } from "./chunk-S25VJYXV.js";
196
184
  import {
197
- isTombstoneRecord
198
- } from "./chunk-BV3FLP2L.js";
185
+ getDefaultCliLocalRuntimeDb
186
+ } from "./chunk-LELADM5Q.js";
199
187
  import {
200
188
  readAgentFromStore,
201
189
  readDialogMessageRecords,
202
190
  readDialogMessages,
203
191
  resolveBuiltinLocalCliAgentConfig
204
- } from "./chunk-U3G7RRXJ.js";
192
+ } from "./chunk-GES5GIAU.js";
205
193
  import {
206
- LOCAL_CODEX_AGENT_KEY,
207
- isLocalCliAgentKey,
208
- resolveCliAgentKeyInput
209
- } from "./chunk-BR3GT6MR.js";
194
+ applyPublicAgentCatalogOverride
195
+ } from "./chunk-4UK6UBXF.js";
196
+ import {
197
+ applyBuiltinAgentRuntimeOverride
198
+ } from "./chunk-JBWXPACD.js";
210
199
  import {
211
200
  DEFAULT_HYBRID_READ_TIMEOUT_MS,
212
201
  Duration_exports,
@@ -231,14 +220,17 @@ import {
231
220
  executeLocalToolWithPolicy,
232
221
  executeOpenAiCompatibleChatCompletion,
233
222
  filterRetainedLedgerRecords,
223
+ filterToolNamesForRunKind,
234
224
  getAgentRuntimeToolParametersIndex,
235
225
  getLocalShellLifecycle,
226
+ hasRunWakeChannel,
236
227
  hashToolDefinitions,
237
228
  internalListWorkspaceEntries,
238
229
  internalSearchWorkspace,
239
230
  isCommandExecutingTool,
240
231
  isLineRangeCovered,
241
232
  isStableSessionIdentityEnabled,
233
+ isSubtaskRun,
242
234
  normalizeLocalToolName,
243
235
  orderDialogHistory,
244
236
  parseSyncServersEnv,
@@ -254,7 +246,7 @@ import {
254
246
  runExecShellGates,
255
247
  validateConfiguredRootExecutionLease,
256
248
  verifyOwnerRouteAck
257
- } from "./chunk-TRHJ4NJB.js";
249
+ } from "./chunk-RGUWOMXU.js";
258
250
  import {
259
251
  createHostCredentialBrokerChain,
260
252
  createStrictHostCredentialBroker
@@ -271,7 +263,7 @@ import {
271
263
  resolveAntigravityFinishReason,
272
264
  resolveGeminiModelQuirks,
273
265
  shouldUseGeminiNativeToolRoute
274
- } from "./chunk-H7ZYKHAZ.js";
266
+ } from "./chunk-3OQFXODL.js";
275
267
  import {
276
268
  readLocalImage
277
269
  } from "./chunk-AL3TYDIF.js";
@@ -286,24 +278,37 @@ import {
286
278
  readPlatformChatSseCompletion,
287
279
  resolvePlatformChatProviderConfig,
288
280
  shouldUsePlatformChatProvider
289
- } from "./chunk-HOM6LTEW.js";
281
+ } from "./chunk-M5EA44QU.js";
290
282
  import {
291
283
  readSseDataValues,
292
284
  readSseFrames
293
285
  } from "./chunk-HNUWUO75.js";
294
286
  import {
295
- resolveAgentImageInputSupport,
296
- resolveCatalogImageSupport,
297
- resolveToolImagePolicy,
298
- withLiveImageSupport
299
- } from "./chunk-BGGAY6OK.js";
287
+ resolveAgentRuntimeConfigFromRecord
288
+ } from "./chunk-SBRSXY67.js";
289
+ import {
290
+ assertDispatchSelectionAdmission,
291
+ buildNoloWorkspaceOpenAiTools,
292
+ filterClientNoloWorkspaceToolNames,
293
+ parseNoloWorkspaceToolArguments
294
+ } from "./chunk-QXUVCIPB.js";
295
+ import {
296
+ MCP_TOOL_NAMES
297
+ } from "./chunk-FDZ2GBWO.js";
298
+ import {
299
+ extractQuotaSnapshot,
300
+ isCapacitySaturatedRateLimit,
301
+ mergeAvailabilityDeadline,
302
+ resolveAvailabilityAction,
303
+ resolveCredentialKeyWithFallback
304
+ } from "./chunk-QJTZ76CP.js";
300
305
  import {
301
306
  collectStablePromptPrefix,
302
307
  convertMessagesToResponsesInput,
303
308
  findAgentStatePairingIssues,
304
309
  stablePromptCacheKey,
305
310
  toResponsesTools
306
- } from "./chunk-EEOOBRA7.js";
311
+ } from "./chunk-F4MCAOWN.js";
307
312
  import {
308
313
  EMPTY_TOOL_RESULT_TEXT,
309
314
  MAX_TOOL_IMAGES_PER_REQUEST,
@@ -316,35 +321,21 @@ import {
316
321
  toolImages
317
322
  } from "./chunk-X4O7FJF5.js";
318
323
  import {
319
- assertDispatchSelectionAdmission,
320
- buildNoloWorkspaceOpenAiTools,
321
- filterClientNoloWorkspaceToolNames,
322
- parseNoloWorkspaceToolArguments
323
- } from "./chunk-G22P367E.js";
324
- import {
325
- extractQuotaSnapshot,
326
- isCapacitySaturatedRateLimit,
327
- mergeAvailabilityDeadline,
328
- resolveAvailabilityAction,
329
- resolveCredentialKeyWithFallback
330
- } from "./chunk-QJTZ76CP.js";
331
- import {
332
- MCP_TOOL_NAMES
333
- } from "./chunk-7NIBQ4HY.js";
334
- import {
335
- HIGH_RISK_MUTATION_TOOL_NAMES,
336
- resolveRequestToolSurface
337
- } from "./chunk-VS276URX.js";
338
- import {
339
- resolveAgentCallPlan
340
- } from "./chunk-TWTJV35S.js";
324
+ resolveAgentImageInputSupport,
325
+ resolveCatalogImageSupport,
326
+ resolveToolImagePolicy,
327
+ withLiveImageSupport
328
+ } from "./chunk-P244EH4W.js";
341
329
  import {
342
330
  resolveHistoricalToolContentCap
343
331
  } from "./chunk-WFGNWWJI.js";
332
+ import {
333
+ resolveAgentCallPlan
334
+ } from "./chunk-ENYTIRIO.js";
344
335
  import {
345
336
  resolveAgentRequiredPackIds,
346
337
  resolveAgentSkillConfig
347
- } from "./chunk-MM73SP4K.js";
338
+ } from "./chunk-DOK7GDRU.js";
348
339
  import {
349
340
  buildDialogFallbackTitleFromUserInput,
350
341
  normalizeDialogTitle
@@ -358,13 +349,14 @@ import {
358
349
  isCodexOAuthAgent,
359
350
  markCodexOAuthCatalogFailure,
360
351
  resolveCodexOAuthEffectiveModel
361
- } from "./chunk-DNZ4JJ7C.js";
352
+ } from "./chunk-4F7SWSWO.js";
362
353
  import {
363
354
  isDevinOAuthAgent
364
355
  } from "./chunk-5ZUL4CUO.js";
365
356
  import {
366
- normalizeUsage
367
- } from "./chunk-L32W3PRP.js";
357
+ normalizeUsage,
358
+ sanitizeSummarySourceSegments
359
+ } from "./chunk-RH44TIHX.js";
368
360
  import {
369
361
  createProviderCallTimingTracker,
370
362
  finalizeProviderCallTiming,
@@ -389,21 +381,24 @@ import {
389
381
  import {
390
382
  asRecordOrEmpty
391
383
  } from "./chunk-KX6YBIHG.js";
392
- import {
393
- compactWhitespace
394
- } from "./chunk-DWLEOOGR.js";
395
384
  import {
396
385
  withShellChildEnvironment
397
- } from "./chunk-VMJVAJ6W.js";
386
+ } from "./chunk-TB5KTLNB.js";
398
387
  import {
399
388
  estimateTokenCount
400
389
  } from "./chunk-PSCNXBYA.js";
390
+ import {
391
+ compactWhitespace
392
+ } from "./chunk-DWLEOOGR.js";
401
393
  import {
402
394
  createOAuthTokenStore,
403
395
  isTokenExpired,
404
396
  readOAuthCredential,
405
397
  resolveFreshAccessToken
406
398
  } from "./chunk-G7Y4GXTY.js";
399
+ import {
400
+ isTombstoneRecord
401
+ } from "./chunk-BV3FLP2L.js";
407
402
  import {
408
403
  dialogMessageRecordToAgentRuntimeMessage
409
404
  } from "./chunk-4ZCTKB27.js";
@@ -418,17 +413,15 @@ import {
418
413
  expandEnabledPacks,
419
414
  resolveBuiltinSkillEntry,
420
415
  resolveEffectiveEnabledPacks
421
- } from "./chunk-EBKHA63G.js";
422
- import {
423
- CHROME_CONNECTOR_ACCEPTED_TOOL_NAMES,
424
- canonicalizeChromeConnectorToolNames,
425
- canonicalizeToolNames
426
- } from "./chunk-6OVNSQHN.js";
416
+ } from "./chunk-RIMFTQMC.js";
427
417
  import {
418
+ DIALOG_AGENT_LIST_INDEX_PREFIX,
419
+ TOKEN_DIALOG_INDEX_PREFIX,
428
420
  createTokenDialogIndexKey,
429
421
  createTokenKey,
430
422
  createTokenStatsKey,
431
- createUserKey
423
+ createUserKey,
424
+ isTokenStatsKey
432
425
  } from "./chunk-SYTHYBMI.js";
433
426
  import {
434
427
  dialogMessageKey
@@ -436,6 +429,31 @@ import {
436
429
  import {
437
430
  dialogIdFromKey
438
431
  } from "./chunk-YZMNK53S.js";
432
+ import {
433
+ extractLastUserText,
434
+ localTurnHasSubjectRefs,
435
+ resolveLocalUserId,
436
+ withResolvedRuntimeToolSurface
437
+ } from "./chunk-LZOOUQAZ.js";
438
+ import {
439
+ LOCAL_CODEX_AGENT_KEY,
440
+ isLocalCliAgentKey,
441
+ resolveCliAgentKeyInput
442
+ } from "./chunk-BR3GT6MR.js";
443
+ import {
444
+ HIGH_RISK_MUTATION_TOOL_NAMES,
445
+ resolveRequestToolSurface
446
+ } from "./chunk-NEG5LYK5.js";
447
+ import {
448
+ remoteDialogSyncTimeout,
449
+ resolveRuntimeAuthToken,
450
+ resolveRuntimeServerUrl
451
+ } from "./chunk-4FE3IWRE.js";
452
+ import {
453
+ CHROME_CONNECTOR_ACCEPTED_TOOL_NAMES,
454
+ canonicalizeChromeConnectorToolNames,
455
+ canonicalizeToolNames
456
+ } from "./chunk-YLAHYLDQ.js";
439
457
  import {
440
458
  asOptionalPositiveFiniteNumber
441
459
  } from "./chunk-U6VC4MU4.js";
@@ -460,17 +478,17 @@ import {
460
478
  import {
461
479
  agentRunCardLabels,
462
480
  t
463
- } from "./chunk-S2MHR4PU.js";
481
+ } from "./chunk-OGZE6BZG.js";
464
482
  import {
465
483
  isAntigravityOAuthAgent
466
- } from "./chunk-6CKUO32A.js";
467
- import {
468
- buildProviderSessionHeaders,
469
- resolvePlatformAuthToken
470
- } from "./chunk-RTHFJZ6M.js";
484
+ } from "./chunk-Y22P6ASC.js";
471
485
  import {
472
486
  toErrorMessage
473
487
  } from "./chunk-HNMXYYJR.js";
488
+ import {
489
+ buildProviderSessionHeaders,
490
+ resolvePlatformAuthToken
491
+ } from "./chunk-LMFMV5UC.js";
474
492
  import {
475
493
  asTrimmedString
476
494
  } from "./chunk-3EUW3WEO.js";
@@ -478,7 +496,7 @@ import {
478
496
  anthropicOAuthModelMaxOutputTokens,
479
497
  findModelConfig,
480
498
  isAdaptiveThinkingModelId
481
- } from "./chunk-CD3RU7XL.js";
499
+ } from "./chunk-OJRTTERA.js";
482
500
  import {
483
501
  CLI_PROVIDER_VALUES,
484
502
  isCliProvider
@@ -512,9 +530,9 @@ function createLiveImageSupportResolver(userId, discover, timeoutMs = 5e3) {
512
530
  const raw = config.rawRecord ?? config;
513
531
  const owner = typeof raw.userId === "string" && raw.userId.trim() ? raw.userId.trim() : typeof raw.ownerUserId === "string" ? raw.ownerUserId.trim() : void 0;
514
532
  if (!userId || owner !== userId) return withLiveImageSupport(config, false);
515
- discovery ??= new Promise((resolve7) => {
516
- const timer = setTimeout(() => resolve7({}), timeoutMs);
517
- Promise.resolve().then(discover).then(resolve7, () => resolve7({})).finally(() => clearTimeout(timer));
533
+ discovery ??= new Promise((resolve8) => {
534
+ const timer = setTimeout(() => resolve8({}), timeoutMs);
535
+ Promise.resolve().then(discover).then(resolve8, () => resolve8({})).finally(() => clearTimeout(timer));
518
536
  });
519
537
  const models = await discovery;
520
538
  const model = config.model?.trim() ?? "";
@@ -1255,6 +1273,57 @@ function clearCliLocalRuntimePreparedAgentCache() {
1255
1273
  preparedAgentRuntimeCache.clear();
1256
1274
  hybridStoreCache.clear();
1257
1275
  }
1276
+ var SCALAR_AGENT_CONFIG_FINGERPRINT_FIELDS = [
1277
+ "apiSource",
1278
+ "customProviderUrl",
1279
+ "model",
1280
+ "name",
1281
+ "prompt",
1282
+ "provider",
1283
+ "revision",
1284
+ "updatedAt",
1285
+ "version"
1286
+ ];
1287
+ var TOOL_LIST_FINGERPRINT_FIELDS = ["toolNames", "tools"];
1288
+ function extractFingerprintToolNames(raw) {
1289
+ if (!Array.isArray(raw)) return void 0;
1290
+ const seen = /* @__PURE__ */ new Set();
1291
+ for (const value of raw) {
1292
+ const rawName = typeof value === "string" ? value : value && typeof value === "object" && !Array.isArray(value) ? typeof value.name === "string" ? value.name : value.function && typeof value.function === "object" && !Array.isArray(value.function) && typeof value.function.name === "string" ? value.function.name : "" : "";
1293
+ const trimmed = rawName.trim();
1294
+ if (trimmed) seen.add(trimmed);
1295
+ }
1296
+ return [...seen].sort((a, b) => a.localeCompare(b));
1297
+ }
1298
+ function buildLocalAgentConfigFingerprint(source) {
1299
+ const record = source && typeof source === "object" ? source : null;
1300
+ const payload = {
1301
+ skillPolicy: Object.entries(resolveAgentSkillConfig(record)).sort(
1302
+ ([a], [b]) => a.localeCompare(b)
1303
+ )
1304
+ };
1305
+ if (record) {
1306
+ for (const field of SCALAR_AGENT_CONFIG_FINGERPRINT_FIELDS) {
1307
+ if (!Object.prototype.hasOwnProperty.call(record, field)) continue;
1308
+ const value = record[field];
1309
+ if (typeof value === "string" || typeof value === "number" && Number.isFinite(value) || typeof value === "boolean") {
1310
+ payload[field] = value;
1311
+ }
1312
+ }
1313
+ for (const field of TOOL_LIST_FINGERPRINT_FIELDS) {
1314
+ if (!Object.prototype.hasOwnProperty.call(record, field)) continue;
1315
+ const names = extractFingerprintToolNames(record[field]);
1316
+ if (names !== void 0) {
1317
+ payload[field] = names;
1318
+ }
1319
+ }
1320
+ }
1321
+ const ordered = {};
1322
+ for (const key of Object.keys(payload).sort((a, b) => a.localeCompare(b))) {
1323
+ ordered[key] = payload[key];
1324
+ }
1325
+ return JSON.stringify(ordered);
1326
+ }
1258
1327
  async function defaultLocalRuntimeDb() {
1259
1328
  return getDefaultCliLocalRuntimeDb();
1260
1329
  }
@@ -1311,44 +1380,6 @@ var REGISTRY_INJECTED_TOOL_NAMES = /* @__PURE__ */ new Set([
1311
1380
  "read_xhs_profile"
1312
1381
  ]);
1313
1382
 
1314
- // packages/agent-runtime/agentRunIsolation.ts
1315
- var ORCHESTRATION_TOOL_NAMES = /* @__PURE__ */ new Set([
1316
- "startAgentRun",
1317
- "controlAgentRun",
1318
- "listAgents",
1319
- "readAgent",
1320
- "runStreamingAgent"
1321
- ]);
1322
- var INTERACTION_REQUIRED_TOOL_NAMES = /* @__PURE__ */ new Set([
1323
- "ask_user",
1324
- // 凭据请求:需要宿主交互面板(Block 1a);desktop 无通道时同 ask_user 剥离。
1325
- "secret-request"
1326
- ]);
1327
- var SELF_MUTATION_TOOL_NAMES = /* @__PURE__ */ new Set([
1328
- "updateSelf",
1329
- "updateAgent"
1330
- ]);
1331
- var SUBTASK_REMOVED_TOOL_NAMES = /* @__PURE__ */ new Set([
1332
- ...ORCHESTRATION_TOOL_NAMES,
1333
- ...INTERACTION_REQUIRED_TOOL_NAMES,
1334
- ...SELF_MUTATION_TOOL_NAMES
1335
- ]);
1336
- function isSubtaskRun(env) {
1337
- if (!env) return false;
1338
- const value = env.NOLO_AGENT_RUN_CHILD;
1339
- return typeof value === "string" && value.length > 0 && value !== "0";
1340
- }
1341
- var RUN_WAKE_CHANNEL_ENV = "NOLO_RUN_WAKE";
1342
- function hasRunWakeChannel(env) {
1343
- if (!env) return false;
1344
- const value = env[RUN_WAKE_CHANNEL_ENV];
1345
- return typeof value === "string" && value.length > 0 && value !== "0";
1346
- }
1347
- function filterToolNamesForRunKind(toolNames, isSubtask) {
1348
- if (!isSubtask) return [...toolNames];
1349
- return toolNames.filter((name) => !SUBTASK_REMOVED_TOOL_NAMES.has(name));
1350
- }
1351
-
1352
1383
  // packages/cli/client/localRuntimeTools.ts
1353
1384
  var CLI_CHROME_CONNECTOR_TOOL_NAME_SET = new Set(
1354
1385
  CHROME_CONNECTOR_ACCEPTED_TOOL_NAMES
@@ -2464,7 +2495,7 @@ var resolveCliProviderTransport = async (ctx) => {
2464
2495
  import { createHash } from "node:crypto";
2465
2496
  import { randomUUID as randomUUID2 } from "node:crypto";
2466
2497
  var CODEX_RESPONSES_URL = "https://chatgpt.com/backend-api/codex/responses";
2467
- var CODEX_CLIENT_VERSION = "0.162.1";
2498
+ var CODEX_CLIENT_VERSION = "0.169.0";
2468
2499
  var CODEX_ORIGINATOR = "codex_cli_rs";
2469
2500
  var CODEX_OPENAI_BETA = "responses=experimental";
2470
2501
  var OPENAI_AUTH_CLAIM = "https://api.openai.com/auth";
@@ -2649,7 +2680,7 @@ function throwIfAborted(signal) {
2649
2680
  }
2650
2681
  function waitBackoff(ms, signal, injectedSleep) {
2651
2682
  throwIfAborted(signal);
2652
- return new Promise((resolve7, reject) => {
2683
+ return new Promise((resolve8, reject) => {
2653
2684
  let timer;
2654
2685
  const cleanup = () => {
2655
2686
  signal?.removeEventListener("abort", onAbort);
@@ -2664,7 +2695,7 @@ function waitBackoff(ms, signal, injectedSleep) {
2664
2695
  injectedSleep(ms).then(
2665
2696
  () => {
2666
2697
  cleanup();
2667
- resolve7();
2698
+ resolve8();
2668
2699
  },
2669
2700
  (error) => {
2670
2701
  cleanup();
@@ -2674,7 +2705,7 @@ function waitBackoff(ms, signal, injectedSleep) {
2674
2705
  } else {
2675
2706
  timer = setTimeout(() => {
2676
2707
  cleanup();
2677
- resolve7();
2708
+ resolve8();
2678
2709
  }, ms);
2679
2710
  }
2680
2711
  });
@@ -2927,14 +2958,14 @@ function countCodexInputChars(messages) {
2927
2958
  }
2928
2959
  function abortableSleep(sleepFn, ms, signal) {
2929
2960
  let timer;
2930
- const waitOnce = () => sleepFn ? Promise.resolve(sleepFn(ms)) : new Promise((resolve7) => {
2931
- timer = setTimeout(resolve7, ms);
2961
+ const waitOnce = () => sleepFn ? Promise.resolve(sleepFn(ms)) : new Promise((resolve8) => {
2962
+ timer = setTimeout(resolve8, ms);
2932
2963
  });
2933
2964
  if (!signal) return waitOnce().then(() => void 0);
2934
2965
  if (signal.aborted) {
2935
2966
  return Promise.reject(signal.reason ?? new DOMException("aborted", "AbortError"));
2936
2967
  }
2937
- return new Promise((resolve7, reject) => {
2968
+ return new Promise((resolve8, reject) => {
2938
2969
  let settled = false;
2939
2970
  const finish = (settle) => {
2940
2971
  if (settled) return;
@@ -2948,7 +2979,7 @@ function abortableSleep(sleepFn, ms, signal) {
2948
2979
  );
2949
2980
  signal.addEventListener("abort", onAbort, { once: true });
2950
2981
  waitOnce().then(
2951
- () => finish(resolve7),
2982
+ () => finish(resolve8),
2952
2983
  (error) => finish(() => reject(error))
2953
2984
  );
2954
2985
  });
@@ -3851,7 +3882,7 @@ function waitWithAbort(ms, signal) {
3851
3882
  if (signal?.aborted) {
3852
3883
  return Promise.reject(signal.reason ?? new Error("owner-required proxy aborted"));
3853
3884
  }
3854
- return new Promise((resolve7, reject) => {
3885
+ return new Promise((resolve8, reject) => {
3855
3886
  let timer;
3856
3887
  const cleanup = () => {
3857
3888
  if (timer !== void 0) clearTimeout(timer);
@@ -3863,7 +3894,7 @@ function waitWithAbort(ms, signal) {
3863
3894
  };
3864
3895
  timer = setTimeout(() => {
3865
3896
  cleanup();
3866
- resolve7();
3897
+ resolve8();
3867
3898
  }, ms);
3868
3899
  signal?.addEventListener("abort", onAbort, { once: true });
3869
3900
  });
@@ -4555,8 +4586,8 @@ function recordLocalRunExecutionIsolation(args) {
4555
4586
  }
4556
4587
  function joinPath(dir, name) {
4557
4588
  if (!dir) return name;
4558
- const sep2 = dir.includes("\\") && !dir.includes("/") ? "\\" : "/";
4559
- return dir.endsWith(sep2) ? `${dir}${name}` : `${dir}${sep2}${name}`;
4589
+ const sep3 = dir.includes("\\") && !dir.includes("/") ? "\\" : "/";
4590
+ return dir.endsWith(sep3) ? `${dir}${name}` : `${dir}${sep3}${name}`;
4560
4591
  }
4561
4592
 
4562
4593
  // packages/core/settingsSyncFreshness.ts
@@ -4623,7 +4654,7 @@ function isBusyProviderStreamError(error) {
4623
4654
  return BUSY_STREAM_ERROR_RE.test(toErrorMessage(error));
4624
4655
  }
4625
4656
  async function defaultSleep(ms) {
4626
- await new Promise((resolve7) => setTimeout(resolve7, ms));
4657
+ await new Promise((resolve8) => setTimeout(resolve8, ms));
4627
4658
  }
4628
4659
  function isRetryableProviderStreamError(error) {
4629
4660
  const message = toErrorMessage(error);
@@ -5099,11 +5130,120 @@ function hasReservedBatchAuthority(metadata) {
5099
5130
  (field) => key === field || key.startsWith(`${field}.`) || key === `metadata.${field}` || key.startsWith(`metadata.${field}.`)
5100
5131
  ));
5101
5132
  }
5133
+ var LOCAL_ONLY_EVIDENCE_KEY_PREFIXES = [
5134
+ `${TOKEN_DIALOG_INDEX_PREFIX}-`,
5135
+ `${DIALOG_AGENT_LIST_INDEX_PREFIX}-`,
5136
+ "idx-tokendlg-backfill-",
5137
+ "token-charge-stats-",
5138
+ "usage-backup-"
5139
+ ];
5140
+ function isRemoteDialogEvidenceExcludedKey(key) {
5141
+ if (!key) return true;
5142
+ if (isTokenStatsKey(key)) return true;
5143
+ return LOCAL_ONLY_EVIDENCE_KEY_PREFIXES.some(
5144
+ (prefix) => key.startsWith(prefix)
5145
+ );
5146
+ }
5147
+ var MAX_REMOTE_ERROR_DETAIL_CHARS = 120;
5148
+ var SAFE_SHORT_ERROR_CODE_RE = /^[A-Za-z0-9_.:-]{1,48}$/;
5149
+ function sanitizeRemoteDiagnosticText(raw) {
5150
+ const singleLine = raw.replace(/\u001b\[[0-9;?]*[ -/]*[@-~]/g, " ").replace(/[\u0000-\u001f\u007f]+/g, " ").replace(/\s+/g, " ").trim();
5151
+ if (!singleLine) return "";
5152
+ return singleLine.replace(/\bBearer\s+[A-Za-z0-9._~+/=-]{6,}/gi, "Bearer [REDACTED]").replace(/\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}(?:\.[A-Za-z0-9_-]+)?/g, "[REDACTED]").replace(/\b(?:sk|rk|pk|nolo|tok)_[A-Za-z0-9_-]{8,}/gi, "[REDACTED]").replace(/\bvault-cred-[A-Za-z0-9_-]+/gi, "[REDACTED]");
5153
+ }
5154
+ function clampSingleLine(text, maxLen) {
5155
+ if (text.length <= maxLen) return text;
5156
+ if (maxLen <= 3) return text.slice(0, maxLen);
5157
+ return `${text.slice(0, maxLen - 3)}...`;
5158
+ }
5159
+ function extractSafeRemoteErrorDetail(status, bodyText) {
5160
+ if (status < 400 || status >= 500 || !bodyText) return "";
5161
+ let parsed;
5162
+ try {
5163
+ parsed = JSON.parse(bodyText);
5164
+ } catch {
5165
+ return "";
5166
+ }
5167
+ if (!isRecord(parsed)) return "";
5168
+ const rawCodeCandidates = [
5169
+ parsed.code,
5170
+ isRecord(parsed.error) ? parsed.error.code : void 0,
5171
+ typeof parsed.error === "string" ? parsed.error : void 0,
5172
+ parsed.reason
5173
+ ];
5174
+ let code = "";
5175
+ let fallbackMessageFromError = "";
5176
+ for (const candidate of rawCodeCandidates) {
5177
+ if (typeof candidate !== "string") continue;
5178
+ const cleaned = sanitizeRemoteDiagnosticText(candidate);
5179
+ if (!cleaned) continue;
5180
+ if (SAFE_SHORT_ERROR_CODE_RE.test(cleaned)) {
5181
+ code = cleaned;
5182
+ break;
5183
+ }
5184
+ if (!fallbackMessageFromError) {
5185
+ fallbackMessageFromError = cleaned;
5186
+ }
5187
+ }
5188
+ const rawMessageCandidates = [
5189
+ parsed.message,
5190
+ isRecord(parsed.error) ? parsed.error.message : void 0,
5191
+ fallbackMessageFromError
5192
+ ];
5193
+ let message = "";
5194
+ for (const candidate of rawMessageCandidates) {
5195
+ if (typeof candidate !== "string") continue;
5196
+ const cleaned = sanitizeRemoteDiagnosticText(candidate);
5197
+ if (cleaned && cleaned !== code) {
5198
+ message = cleaned;
5199
+ break;
5200
+ }
5201
+ }
5202
+ if (!code && !message) return "";
5203
+ const payload = {};
5204
+ if (code) payload.code = code;
5205
+ if (message) payload.message = message;
5206
+ let serialized = JSON.stringify(payload);
5207
+ if (serialized.length <= MAX_REMOTE_ERROR_DETAIL_CHARS) {
5208
+ return serialized;
5209
+ }
5210
+ if (code && message) {
5211
+ const baseLen = JSON.stringify({ code, message: "" }).length;
5212
+ const budget = MAX_REMOTE_ERROR_DETAIL_CHARS - baseLen;
5213
+ if (budget >= 8) {
5214
+ serialized = JSON.stringify({
5215
+ code,
5216
+ message: clampSingleLine(message, budget)
5217
+ });
5218
+ if (serialized.length <= MAX_REMOTE_ERROR_DETAIL_CHARS) return serialized;
5219
+ }
5220
+ serialized = JSON.stringify({ code });
5221
+ return serialized.length <= MAX_REMOTE_ERROR_DETAIL_CHARS ? serialized : clampSingleLine(serialized, MAX_REMOTE_ERROR_DETAIL_CHARS);
5222
+ }
5223
+ if (message) {
5224
+ const baseLen = JSON.stringify({ message: "" }).length;
5225
+ const budget = MAX_REMOTE_ERROR_DETAIL_CHARS - baseLen;
5226
+ return budget > 0 ? JSON.stringify({ message: clampSingleLine(message, budget) }) : "";
5227
+ }
5228
+ return clampSingleLine(serialized, MAX_REMOTE_ERROR_DETAIL_CHARS);
5229
+ }
5102
5230
  function prepareRemoteDialogEvidenceRecord(key, value, options) {
5103
5231
  const record = isRecord(value) ? { ...value } : {};
5104
- if (key.includes("-msg-") && typeof record.type !== "string") {
5232
+ if (key.includes("-msg-") && (typeof record.type !== "string" || !record.type.trim() || record.type === "message")) {
5105
5233
  record.type = "msg";
5106
5234
  }
5235
+ if (key.startsWith("token-") && !isTokenStatsKey(key)) {
5236
+ if (typeof record.type !== "string" || !record.type.trim()) {
5237
+ record.type = "token";
5238
+ }
5239
+ const hasAgentId = typeof record.agentId === "string" && record.agentId.trim().length > 0;
5240
+ const hasCybotId = typeof record.cybotId === "string" && record.cybotId.trim().length > 0;
5241
+ const fallbackAgent = asOptionalTrimmedString(options?.fallbackAgentKey);
5242
+ if (!hasAgentId && !hasCybotId && fallbackAgent) {
5243
+ record.agentId = fallbackAgent;
5244
+ record.cybotId = fallbackAgent;
5245
+ }
5246
+ }
5107
5247
  const metadata = record.metadata;
5108
5248
  if (key.includes("-msg-") && record.role === "user" && isRecord(metadata) && metadata.queueState === "accepted" && (metadata.cliBatchPhase === "requested" || metadata.cliBatchPhase === "completed" || typeof metadata.cliBatchId === "string" && metadata.cliBatchId.length > 0 || options?.isAcceptedBatchMember === true) && !hasReservedBatchAuthority(metadata)) {
5109
5249
  const { queueState: _localQueueState, ...evidenceMetadata } = metadata;
@@ -5214,7 +5354,7 @@ function buildLocalParentWakeMessage(args) {
5214
5354
  var EVIDENCE_WRITE_BATCH_SIZE = 4;
5215
5355
  var EVIDENCE_WRITE_BATCH_GAP_MS = 300;
5216
5356
  async function defaultEvidenceSleep(ms) {
5217
- await new Promise((resolve7) => setTimeout(resolve7, ms));
5357
+ await new Promise((resolve8) => setTimeout(resolve8, ms));
5218
5358
  }
5219
5359
  async function runThrottledBatches(items, run, options = {}) {
5220
5360
  const batchSize = options.batchSize ?? EVIDENCE_WRITE_BATCH_SIZE;
@@ -5242,6 +5382,7 @@ async function postRemoteRecord(args) {
5242
5382
  customKey: args.key,
5243
5383
  userId: args.userId,
5244
5384
  data: prepareRemoteDialogEvidenceRecord(args.key, args.data, {
5385
+ fallbackAgentKey: args.fallbackAgentKey,
5245
5386
  isAcceptedBatchMember: args.isAcceptedBatchMember
5246
5387
  })
5247
5388
  }),
@@ -5260,8 +5401,9 @@ async function postRemoteRecord(args) {
5260
5401
  );
5261
5402
  if (!response.ok) {
5262
5403
  const text = await response.text().catch(() => "");
5404
+ const detail = extractSafeRemoteErrorDetail(response.status, text);
5263
5405
  throw new Error(
5264
- `remote dialog evidence write failed: HTTP ${response.status} ${text.slice(0, 500)}`
5406
+ detail ? `remote dialog evidence write failed: HTTP ${response.status} ${detail}` : `remote dialog evidence write failed: HTTP ${response.status}`
5265
5407
  );
5266
5408
  }
5267
5409
  }
@@ -5336,8 +5478,9 @@ async function maybeWakeParentDialogAfterLocalSync(args) {
5336
5478
  });
5337
5479
  if (!wakeResponse.ok) {
5338
5480
  const text = await wakeResponse.text().catch(() => "");
5481
+ const detail = extractSafeRemoteErrorDetail(wakeResponse.status, text);
5339
5482
  throw new Error(
5340
- `parent dialog wake failed: HTTP ${wakeResponse.status} ${text.slice(0, 500)}`
5483
+ detail ? `parent dialog wake failed: HTTP ${wakeResponse.status} ${detail}` : `parent dialog wake failed: HTTP ${wakeResponse.status}`
5341
5484
  );
5342
5485
  }
5343
5486
  const notifiedAt = Date.now();
@@ -5362,13 +5505,14 @@ async function maybeWakeParentDialogAfterLocalSync(args) {
5362
5505
  async function syncLocalDialogEvidenceToRemote(args) {
5363
5506
  const serverUrl = resolveRuntimeServerUrl(args.env);
5364
5507
  const authToken = resolveRuntimeAuthToken(args.env);
5365
- if (!serverUrl || !authToken) {
5508
+ if (!serverUrl || !authToken || args.userId === "local") {
5366
5509
  return { attempted: false };
5367
5510
  }
5368
5511
  const orderedOps = [];
5369
5512
  const nonMsgOps = [];
5370
5513
  for (const op of args.ops) {
5371
5514
  if (op.type !== "put") continue;
5515
+ if (isRemoteDialogEvidenceExcludedKey(op.key)) continue;
5372
5516
  if (op.key.includes("-msg-")) {
5373
5517
  orderedOps.push(op);
5374
5518
  } else {
@@ -5377,11 +5521,13 @@ async function syncLocalDialogEvidenceToRemote(args) {
5377
5521
  }
5378
5522
  orderedOps.push(...nonMsgOps);
5379
5523
  const acceptedBatchKeys = await collectAcceptedUserBatchMessageKeys(orderedOps, args.localStore);
5524
+ const fallbackAgentKey = asOptionalTrimmedString(args.input?.agentKey);
5380
5525
  await runThrottledBatches(
5381
5526
  orderedOps.filter((op) => op.type === "put"),
5382
5527
  (op) => postRemoteRecord({
5383
5528
  authToken,
5384
5529
  data: op.value,
5530
+ fallbackAgentKey,
5385
5531
  fetchImpl: args.fetchImpl,
5386
5532
  isAcceptedBatchMember: acceptedBatchKeys.has(op.key),
5387
5533
  key: op.key,
@@ -5390,9 +5536,7 @@ async function syncLocalDialogEvidenceToRemote(args) {
5390
5536
  }),
5391
5537
  args.sleep ? { sleep: args.sleep } : {}
5392
5538
  );
5393
- const childDialogOp = args.ops.find(
5394
- (op) => op.type === "put" && !op.key.includes("-msg-")
5395
- );
5539
+ const childDialogOp = nonMsgOps.find((op) => op.key.startsWith("dialog-")) ?? nonMsgOps[0];
5396
5540
  const childDialogRecord = childDialogOp?.value && typeof childDialogOp.value === "object" ? childDialogOp.value : null;
5397
5541
  if (childDialogOp && childDialogRecord) {
5398
5542
  try {
@@ -5936,13 +6080,13 @@ async function createBrowserShellApprovalBridge(args) {
5936
6080
  },
5937
6081
  ...args.awaitHostApproval ? { awaitHostApproval: async (card) => {
5938
6082
  requireActive();
5939
- const decision = await new Promise((resolve7, reject) => {
6083
+ const decision = await new Promise((resolve8, reject) => {
5940
6084
  const abort = () => reject(new Error("Browser approval bridge revoked"));
5941
6085
  lifetime.signal.addEventListener("abort", abort, { once: true });
5942
6086
  Promise.resolve().then(() => {
5943
6087
  requireActive();
5944
6088
  return args.awaitHostApproval(card, lifetime.signal);
5945
- }).then(resolve7, reject).finally(() => lifetime.signal.removeEventListener("abort", abort));
6089
+ }).then(resolve8, reject).finally(() => lifetime.signal.removeEventListener("abort", abort));
5946
6090
  });
5947
6091
  requireActive();
5948
6092
  if (decision !== "allow_once" && decision !== "deny") throw new Error("Invalid host decision");
@@ -5965,17 +6109,17 @@ async function createBrowserShellApprovalBridge(args) {
5965
6109
  clearTimeout(timer);
5966
6110
  args.signal?.removeEventListener("abort", onAbort);
5967
6111
  bindings.clear();
5968
- closing = new Promise((resolve7) => {
5969
- server.close(() => resolve7());
6112
+ closing = new Promise((resolve8) => {
6113
+ server.close(() => resolve8());
5970
6114
  server.closeAllConnections();
5971
6115
  });
5972
6116
  return closing;
5973
6117
  }
5974
- await new Promise((resolve7, reject) => {
6118
+ await new Promise((resolve8, reject) => {
5975
6119
  server.once("error", reject);
5976
6120
  server.listen(0, "127.0.0.1", () => {
5977
6121
  server.removeListener("error", reject);
5978
- resolve7();
6122
+ resolve8();
5979
6123
  });
5980
6124
  });
5981
6125
  const address = server.address();
@@ -6309,7 +6453,7 @@ function buildServerPlatformToolExecutors(args) {
6309
6453
  const shortHash = (value, len) => createHash2("sha256").update(value).digest("hex").slice(0, len);
6310
6454
  const localMemoryContext = async () => {
6311
6455
  const openCliLocalRuntimeDb = async () => {
6312
- const { getDefaultCliLocalRuntimeDb: getDefaultCliLocalRuntimeDb2 } = await import("./localRuntimeDb-CRNIBOOM.js");
6456
+ const { getDefaultCliLocalRuntimeDb: getDefaultCliLocalRuntimeDb2 } = await import("./localRuntimeDb-5WZ4RJJO.js");
6313
6457
  return getDefaultCliLocalRuntimeDb2({ env: args.env });
6314
6458
  };
6315
6459
  try {
@@ -6400,6 +6544,40 @@ function buildServerPlatformToolExecutors(args) {
6400
6544
  const writeLocalMemory = async (input) => {
6401
6545
  const ctx = await localMemoryContext();
6402
6546
  if (!ctx) return false;
6547
+ if (input.topicKey) {
6548
+ const { normalizeTopicKey, rememberExplicitVNext } = await import("./rememberExplicit-CPAPONSI.js");
6549
+ const topicKey = normalizeTopicKey(input.topicKey);
6550
+ if (topicKey) {
6551
+ const now = input.createdAt || (/* @__PURE__ */ new Date()).toISOString();
6552
+ const kind = ["episodic", "semantic", "procedural"].includes(input.kind) ? input.kind : "episodic";
6553
+ const validSubjectTypes = ["user", "agent", "space", "project", "system"];
6554
+ const hasValidSubject = typeof input.subjectType === "string" && validSubjectTypes.includes(input.subjectType) && typeof input.subjectId === "string" && input.subjectId.trim().length > 0;
6555
+ const trimmedAgentKey = args.agentKey?.trim() || "";
6556
+ const useAgentSubject = (input.scope ?? "auto") === "auto" && Boolean(trimmedAgentKey);
6557
+ const subjectType = hasValidSubject ? input.subjectType : useAgentSubject ? "agent" : "user";
6558
+ const subjectId = hasValidSubject ? input.subjectId.trim() : useAgentSubject ? trimmedAgentKey : ctx.userId;
6559
+ await rememberExplicitVNext(ctx.db, {
6560
+ id: "",
6561
+ ownerType: "user",
6562
+ ownerId: ctx.userId,
6563
+ visibility: "private",
6564
+ subjectType,
6565
+ subjectId,
6566
+ kind,
6567
+ content: input.content,
6568
+ createdAt: now,
6569
+ lastActivatedAt: now,
6570
+ activationCount: 0,
6571
+ importance: kind === "procedural" ? 0.88 : 0.82,
6572
+ confidence: input.confidence,
6573
+ ...input.tags?.length ? { tags: input.tags } : {},
6574
+ ...input.provenance === "verified" || input.provenance === "stated" || input.provenance === "inferred" ? { provenance: input.provenance } : {},
6575
+ ...input.sourceKind === "explicit-user-directive" || input.sourceKind === "agent-tool" || input.sourceKind === "inferred-understanding" || input.sourceKind === "dialog-learning" ? { sourceKind: input.sourceKind } : {},
6576
+ topicKey
6577
+ });
6578
+ return true;
6579
+ }
6580
+ }
6403
6581
  const [{ putMemoryEntityVNext, putMemoryStateVNext, putMemoryEvidenceVNext }, { buildLegacyMemoryEvidence }] = await Promise.all([
6404
6582
  import("./store-Z53ICFL3.js"),
6405
6583
  import("./legacyMigration-TF4SYJCZ.js")
@@ -6526,10 +6704,10 @@ function buildServerPlatformToolExecutors(args) {
6526
6704
  }
6527
6705
  const ctx = await localMemoryContext();
6528
6706
  if (!ctx) throw new Error("local work memory unavailable");
6529
- const { resolveLocalUserId: resolveLocalUserId2 } = await import("./cliAgentConfigHelpers-U5OAVAKQ.js");
6707
+ const { resolveLocalUserId: resolveLocalUserId2 } = await import("./cliAgentConfigHelpers-6OFDHJFT.js");
6530
6708
  const localUserId = resolveLocalUserId2(args.env);
6531
6709
  const { resolveWorkContextAccess } = await import("./workContextAccess-UZHDLBUR.js");
6532
- const { updateWorkContext, readWorkContexts } = await import("./workContext-MM3P5GP5.js");
6710
+ const { updateWorkContext, readWorkContexts } = await import("./workContext-Y3ADAPZU.js");
6533
6711
  const { scope, sourceRef } = await resolveWorkContextAccess(ctx.db, localUserId, dialogId, write ? userMessageId : void 0);
6534
6712
  if (scope.spaceId) throw new Error("local work memory cannot verify space membership");
6535
6713
  const result = write ? await updateWorkContext(ctx.db, scope, { ...payload.activityId !== void 0 ? { activityId: payload.activityId, expectedRevision: payload.expectedRevision } : { itemKey: payload.itemKey, originRef: sourceRef }, changeId: payload.changeId, sourceRefs: [sourceRef], patch: payload.patch }) : await readWorkContexts(ctx.db, scope, payload);
@@ -6596,6 +6774,24 @@ function buildServerPlatformToolExecutors(args) {
6596
6774
  if (typeof parsed.recurrenceEvidence === "string" && parsed.recurrenceEvidence.trim()) {
6597
6775
  body.recurrenceEvidence = parsed.recurrenceEvidence.trim();
6598
6776
  }
6777
+ if (parsed.topicKey !== void 0 && parsed.topicKey !== null) {
6778
+ if (typeof parsed.topicKey !== "string") {
6779
+ return {
6780
+ content: JSON.stringify({ error: "rememberMemory: topicKey must be a string" }),
6781
+ metadata: { serverPlatformTool: true, memoryWrite: false }
6782
+ };
6783
+ }
6784
+ const { normalizeTopicKey } = await import("./rememberExplicit-CPAPONSI.js");
6785
+ try {
6786
+ const normalizedTopicKey = normalizeTopicKey(parsed.topicKey);
6787
+ if (normalizedTopicKey) body.topicKey = normalizedTopicKey;
6788
+ } catch (err) {
6789
+ return {
6790
+ content: JSON.stringify({ error: err?.message ?? "invalid topicKey" }),
6791
+ metadata: { serverPlatformTool: true, memoryWrite: false }
6792
+ };
6793
+ }
6794
+ }
6599
6795
  if (args.agentKey) body.agentKey = args.agentKey;
6600
6796
  const raw = await postServer("/api/memory/remember", body, {
6601
6797
  retryTransient: true
@@ -6608,6 +6804,10 @@ function buildServerPlatformToolExecutors(args) {
6608
6804
  } catch {
6609
6805
  }
6610
6806
  const saved = Array.isArray(serverResult?.savedItems) ? serverResult.savedItems[0] : null;
6807
+ const resolvedTopicKey = typeof saved?.topicKey === "string" ? saved.topicKey : typeof body.topicKey === "string" ? body.topicKey : void 0;
6808
+ const validSubjectTypes = ["user", "agent", "space", "project", "system"];
6809
+ const savedSubjectType = typeof saved?.subjectType === "string" && validSubjectTypes.includes(saved.subjectType) ? saved.subjectType : void 0;
6810
+ const savedSubjectId = typeof saved?.subjectId === "string" && saved.subjectId.trim() ? saved.subjectId.trim() : void 0;
6611
6811
  localSaved = await writeLocalMemory({
6612
6812
  content: typeof saved?.content === "string" && saved.content.trim() ? saved.content : content,
6613
6813
  kind: String(saved?.kind ?? serverResult?.savedKind ?? body.kind ?? "episodic"),
@@ -6615,7 +6815,10 @@ function buildServerPlatformToolExecutors(args) {
6615
6815
  confidence: typeof saved?.confidence === "number" ? saved.confidence : 0.8,
6616
6816
  provenance: typeof saved?.provenance === "string" ? saved.provenance : void 0,
6617
6817
  sourceKind: typeof saved?.sourceKind === "string" ? saved.sourceKind : void 0,
6618
- tags: Array.isArray(saved?.tags) ? saved.tags.map(String) : void 0
6818
+ tags: Array.isArray(saved?.tags) ? saved.tags.map(String) : void 0,
6819
+ scope: typeof body.scope === "string" ? body.scope : "auto",
6820
+ ...savedSubjectType && savedSubjectId ? { subjectType: savedSubjectType, subjectId: savedSubjectId } : {},
6821
+ ...resolvedTopicKey ? { topicKey: resolvedTopicKey } : {}
6619
6822
  });
6620
6823
  } catch {
6621
6824
  }
@@ -6749,11 +6952,160 @@ function buildServerPlatformToolExecutors(args) {
6749
6952
  };
6750
6953
  }
6751
6954
 
6955
+ // packages/cli/client/workspaceIsolation.ts
6956
+ import * as fs from "node:fs";
6957
+ import { execFileSync } from "node:child_process";
6958
+ import { createHash as createHash3 } from "node:crypto";
6959
+ import { homedir } from "node:os";
6960
+ import { basename, dirname as dirname2, isAbsolute, join as join2, relative, resolve, sep } from "node:path";
6961
+ var WorkspaceIsolationError = class extends Error {
6962
+ code = "workspace_isolation_refused";
6963
+ };
6964
+ var dependencies = /* @__PURE__ */ new Set(["node_modules", ".venv"]);
6965
+ var refuse = (reason) => {
6966
+ throw new WorkspaceIsolationError(`${reason}\uFF1B\u8BF7\u7F29\u5C0F\u5230\u5177\u4F53\u5B50\u6587\u4EF6\u5939\u540E\u91CD\u8BD5 workspaceIsolation:auto`);
6967
+ };
6968
+ function prepareWorkspaceIsolation(options) {
6969
+ const { baseCwd, runId, mode = "none", readOnly, platform = process.platform } = options;
6970
+ if (mode !== "auto" || readOnly === true) return { mode, kind: "none", effectiveCwd: baseCwd };
6971
+ if (!/^[a-zA-Z0-9_-]{1,128}$/.test(runId)) refuse("\u4E0D\u5B89\u5168\u7684 runId");
6972
+ const exec = options.execFile ?? execFileSync;
6973
+ const command = (file, args) => String(exec(file, args, { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"], timeout: 3e4, env: { ...process.env, LC_ALL: "C", LANG: "C" } }));
6974
+ const source = fs.realpathSync(baseCwd);
6975
+ let repoRoot;
6976
+ try {
6977
+ repoRoot = command("git", ["-C", source, "rev-parse", "--show-toplevel"]).trim();
6978
+ } catch (error) {
6979
+ if (error.code === "ENOENT") {
6980
+ for (let ancestor = source; ; ancestor = dirname2(ancestor)) {
6981
+ try {
6982
+ fs.lstatSync(join2(ancestor, ".git"));
6983
+ throw new WorkspaceIsolationError("\u68C0\u6D4B\u5230 Git \u4ED3\u5E93\uFF0C\u4F46 Git \u547D\u4EE4\u672A\u5B89\u88C5\uFF1B\u8BF7\u5B89\u88C5 Git \u540E\u91CD\u8BD5");
6984
+ } catch (markerError) {
6985
+ if (markerError.code !== "ENOENT") throw markerError;
6986
+ }
6987
+ if (ancestor === dirname2(ancestor)) break;
6988
+ }
6989
+ } else if (!String(error.stderr).includes("not a git repository")) {
6990
+ throw error;
6991
+ }
6992
+ }
6993
+ const linkDependencies = (from, to) => {
6994
+ for (const name of dependencies) {
6995
+ const target = join2(from, name), link = join2(to, name);
6996
+ try {
6997
+ if (fs.statSync(target).isDirectory() && !fs.existsSync(link)) fs.symlinkSync(target, link, platform === "win32" ? "junction" : "dir");
6998
+ } catch {
6999
+ }
7000
+ }
7001
+ };
7002
+ if (repoRoot) {
7003
+ repoRoot = fs.realpathSync(repoRoot);
7004
+ const subRel = relative(repoRoot, source);
7005
+ if (isAbsolute(subRel) || subRel.split(/[\\/]/).includes("..")) refuse("\u76EE\u5F55\u4E0D\u5728\u4ED3\u5E93\u5185");
7006
+ const shortId = createHash3("sha256").update(runId).digest("hex").slice(0, 12);
7007
+ const commonDirOutput = command("git", ["-C", source, "rev-parse", "--git-common-dir"]).trim();
7008
+ const commonDir = fs.realpathSync(resolve(source, commonDirOutput));
7009
+ const worktreeHostRoot = basename(commonDir) === ".git" ? dirname2(commonDir) : repoRoot;
7010
+ const root2 = join2(worktreeHostRoot, ".worktrees", `run-${shortId}`), branch = `nolo/run-${shortId}`;
7011
+ if (platform === "win32" && root2.length > 210) refuse("\u9694\u79BB\u76EE\u5F55\u8DEF\u5F84\u8FC7\u957F");
7012
+ command("git", ["-C", repoRoot, "-c", "checkout.workers=0", "-c", "core.longpaths=true", "worktree", "add", root2, "-b", branch, "HEAD"]);
7013
+ linkDependencies(repoRoot, root2);
7014
+ if (worktreeHostRoot !== repoRoot) linkDependencies(worktreeHostRoot, root2);
7015
+ return { mode, kind: "git-worktree", effectiveCwd: join2(root2, subRel), root: root2, sourceRoot: repoRoot, branch };
7016
+ }
7017
+ if (source === dirname2(source) || source === fs.realpathSync(homedir())) refuse("\u4E0D\u80FD\u9694\u79BB\u6587\u4EF6\u7CFB\u7EDF\u6839\u76EE\u5F55\u6216\u7528\u6237\u4E3B\u76EE\u5F55");
7018
+ let files = 0, bytes = 0, entries = 0;
7019
+ const scan = (dir, top, depth = 0) => {
7020
+ if (depth > 64) refuse("\u76EE\u5F55\u5D4C\u5957\u8D85\u8FC7 64 \u5C42\u4E0A\u9650");
7021
+ const handle = fs.opendirSync(dir);
7022
+ try {
7023
+ let entry;
7024
+ while (entry = handle.readSync()) {
7025
+ if (top && dependencies.has(entry.name)) continue;
7026
+ if (++entries > 4e3) refuse("\u76EE\u5F55\u6761\u76EE\u8D85\u8FC7 4000 \u4E0A\u9650");
7027
+ const path = join2(dir, entry.name), stat = fs.lstatSync(path);
7028
+ if (stat.isSymbolicLink() || !stat.isDirectory() && !stat.isFile()) refuse("\u666E\u901A\u4E1A\u52A1\u76EE\u5F55\u542B\u7B26\u53F7\u94FE\u63A5\u6216\u7279\u6B8A\u6587\u4EF6\uFF0C\u4E0D\u80FD\u5B89\u5168\u590D\u5236");
7029
+ if (stat.isDirectory()) scan(path, false, depth + 1);
7030
+ else if (++files > (options.maxFiles ?? 2e3) || (bytes += stat.size) > (options.maxBytes ?? 200 * 1024 * 1024)) refuse("\u76EE\u5F55\u8D85\u8FC7\u6587\u4EF6\u6570\u6216\u603B\u5927\u5C0F\u4E0A\u9650\uFF082000 \u6587\u4EF6 / 200 MiB\uFF09");
7031
+ }
7032
+ } finally {
7033
+ handle.closeSync();
7034
+ }
7035
+ };
7036
+ scan(source, true);
7037
+ const root = resolve(options.noloHome ?? join2(homedir(), ".nolo"), "workspaces", runId);
7038
+ const rel = relative(source, root);
7039
+ if (!rel || !rel.startsWith(`..${sep}`) && rel !== ".." && !isAbsolute(rel)) refuse("\u5FEB\u7167\u76EE\u6807\u4E0D\u80FD\u4F4D\u4E8E\u6E90\u76EE\u5F55\u5185");
7040
+ fs.mkdirSync(dirname2(root), { recursive: true });
7041
+ fs.mkdirSync(root);
7042
+ try {
7043
+ for (const entry of fs.readdirSync(source)) {
7044
+ if (dependencies.has(entry)) continue;
7045
+ const from = join2(source, entry), to = join2(root, entry);
7046
+ let copied = false;
7047
+ try {
7048
+ if (platform === "darwin") {
7049
+ command("cp", ["-cR", from, to]);
7050
+ copied = true;
7051
+ } else if (platform === "linux") {
7052
+ command("cp", ["-a", "--reflink=always", "--", from, to]);
7053
+ copied = true;
7054
+ }
7055
+ } catch {
7056
+ }
7057
+ if (!copied) fs.cpSync(from, to, { recursive: true, force: true, dereference: false });
7058
+ }
7059
+ linkDependencies(source, root);
7060
+ } catch (error) {
7061
+ try {
7062
+ rollbackWorkspaceIsolation({ mode, kind: "directory-snapshot", effectiveCwd: root, root, sourceRoot: source });
7063
+ } catch (cleanupError) {
7064
+ throw new AggregateError([error, cleanupError], `\u590D\u5236\u5931\u8D25\uFF1B\u9694\u79BB\u76EE\u5F55\u4FDD\u7559\u5F85\u5904\u7406: ${root}`);
7065
+ }
7066
+ throw error;
7067
+ }
7068
+ return { mode, kind: "directory-snapshot", effectiveCwd: root, root, sourceRoot: source };
7069
+ }
7070
+ function rollbackWorkspaceIsolation(workspace) {
7071
+ const { root, sourceRoot, branch, kind } = workspace;
7072
+ if (!root || !sourceRoot) return;
7073
+ if (kind === "git-worktree") {
7074
+ const git = (args) => String(execFileSync("git", ["-C", sourceRoot, ...args], { encoding: "utf8" }));
7075
+ for (const name of dependencies) {
7076
+ const link = join2(root, name), original = join2(sourceRoot, name);
7077
+ if (!git(["-C", root, "ls-files", "--", name]).trim()) {
7078
+ try {
7079
+ if (fs.lstatSync(link).isSymbolicLink() && fs.realpathSync(link) === fs.realpathSync(original)) fs.unlinkSync(link);
7080
+ } catch (error) {
7081
+ if (error.code !== "ENOENT") throw error;
7082
+ }
7083
+ }
7084
+ }
7085
+ if (git(["-C", root, "status", "--porcelain", "--ignored"]).trim()) throw new Error(`\u9694\u79BB\u76EE\u5F55\u542B\u672A\u9A8C\u8BC1\u5185\u5BB9\uFF0C\u4FDD\u7559 ${root}`);
7086
+ execFileSync("git", ["-C", sourceRoot, "merge-base", "--is-ancestor", branch, "HEAD"]);
7087
+ git(["worktree", "remove", root]);
7088
+ git(["branch", "-d", branch]);
7089
+ } else if (kind === "directory-snapshot") {
7090
+ const verify = (path) => {
7091
+ for (const entry of fs.readdirSync(path)) {
7092
+ const target = join2(path, entry), original = join2(sourceRoot, relative(root, target));
7093
+ const stat = fs.lstatSync(target);
7094
+ if (path === root && dependencies.has(entry) && stat.isSymbolicLink() && fs.realpathSync(target) === fs.realpathSync(original)) continue;
7095
+ if (stat.isDirectory() && fs.statSync(original).isDirectory()) verify(target);
7096
+ else if (!stat.isFile() || !fs.statSync(original).isFile() || !fs.readFileSync(target).equals(fs.readFileSync(original))) throw new Error(`\u9694\u79BB\u526F\u672C\u6709\u552F\u4E00\u5185\u5BB9\uFF0C\u4FDD\u7559 ${root}`);
7097
+ }
7098
+ };
7099
+ verify(root);
7100
+ fs.rmSync(root, { recursive: true });
7101
+ }
7102
+ }
7103
+
6752
7104
  // packages/cli/client/childRunImages.ts
6753
- import { isAbsolute } from "node:path";
7105
+ import { isAbsolute as isAbsolute2 } from "node:path";
6754
7106
  function validateChildImagePaths(value) {
6755
7107
  if (value === void 0) return [];
6756
- if (!Array.isArray(value) || value.length < 1 || value.length > MAX_TOOL_IMAGES_PER_REQUEST || value.some((path) => typeof path !== "string" || !isAbsolute(path) || path.includes("\0"))) {
7108
+ if (!Array.isArray(value) || value.length < 1 || value.length > MAX_TOOL_IMAGES_PER_REQUEST || value.some((path) => typeof path !== "string" || !isAbsolute2(path) || path.includes("\0"))) {
6757
7109
  throw new Error("image_input_invalid: expected 1\u20134 absolute local image paths");
6758
7110
  }
6759
7111
  return value;
@@ -6786,8 +7138,8 @@ async function normalizeCliRunImages(inputs, normalizeRemote) {
6786
7138
  }
6787
7139
 
6788
7140
  // packages/cli/agentRunArgs.ts
6789
- import { readFileSync } from "node:fs";
6790
- import { isAbsolute as isAbsolute2 } from "node:path";
7141
+ import { readFileSync as readFileSync2 } from "node:fs";
7142
+ import { isAbsolute as isAbsolute3 } from "node:path";
6791
7143
  function readFlagValue(args, flag) {
6792
7144
  const index = args.indexOf(flag);
6793
7145
  if (index < 0) return void 0;
@@ -6928,7 +7280,7 @@ function parseAgentRunArgs(args, options = {}) {
6928
7280
  const agentKey = rawAgentKey ? resolveCliAgentKeyInput(rawAgentKey) : void 0;
6929
7281
  const explicitMsg = readFlagValue(args, "--msg");
6930
7282
  const msgFile = readFlagValue(args, "--msg-file");
6931
- const fileMessage = msgFile ? (options.readTextFile ?? ((path) => readFileSync(path, "utf8")))(msgFile) : void 0;
7283
+ const fileMessage = msgFile ? (options.readTextFile ?? ((path) => readFileSync2(path, "utf8")))(msgFile) : void 0;
6932
7284
  const rawMessage = explicitMsg ?? fileMessage ?? positional.slice(isNoLoginRunShorthand ? 0 : 1).join(" ");
6933
7285
  if (!agentKey || !rawMessage.trim()) return null;
6934
7286
  const message = rawMessage.trim();
@@ -6989,7 +7341,7 @@ function parseAgentRunArgs(args, options = {}) {
6989
7341
  if (!rawInstaboxArtifactDir) {
6990
7342
  throw new Error("--runtime-key instabox \u5FC5\u987B\u6307\u5B9A --instabox-artifact-dir <\u7EDD\u5BF9\u8DEF\u5F84>");
6991
7343
  }
6992
- if (!isAbsolute2(rawInstaboxArtifactDir) || rawInstaboxArtifactDir.includes("\0") || rawInstaboxArtifactDir.split("/").includes("..")) {
7344
+ if (!isAbsolute3(rawInstaboxArtifactDir) || rawInstaboxArtifactDir.includes("\0") || rawInstaboxArtifactDir.split("/").includes("..")) {
6993
7345
  throw new Error(`--instabox-artifact-dir \u5FC5\u987B\u4E3A\u5408\u6CD5\u7EDD\u5BF9\u8DEF\u5F84\uFF0C\u4E14\u4E0D\u80FD\u5305\u542B .. \u6216\u7A7A\u5B57\u7B26: "${rawInstaboxArtifactDir}"`);
6994
7346
  }
6995
7347
  if (rawInstaboxWorkspace === "snapshot" && !rawInstaboxManifest) {
@@ -7094,7 +7446,7 @@ function parseAgentRunArgs(args, options = {}) {
7094
7446
  }
7095
7447
 
7096
7448
  // packages/cli/client/cliAgentRunToolExecutors.ts
7097
- import { join as join3, resolve as resolve3 } from "node:path";
7449
+ import { dirname as dirname4, join as join4, resolve as resolve4 } from "node:path";
7098
7450
  import { randomUUID as randomUUID3 } from "node:crypto";
7099
7451
  import * as nodeFs2 from "node:fs";
7100
7452
 
@@ -7158,7 +7510,7 @@ function waitForRunTerminal(args) {
7158
7510
  }
7159
7511
 
7160
7512
  // packages/cli/client/cliAgentRunToolExecutors.ts
7161
- import { existsSync as existsSync3, readFileSync as readFileSync4 } from "node:fs";
7513
+ import { existsSync as existsSync4, readFileSync as readFileSync5 } from "node:fs";
7162
7514
 
7163
7515
  // packages/cli/client/agentRunSnapshot.ts
7164
7516
  function readString(value) {
@@ -7404,47 +7756,47 @@ function deriveAgentRunTodoStatus(input) {
7404
7756
  }
7405
7757
 
7406
7758
  // packages/cli/client/fileSystemStores.ts
7407
- import { existsSync as existsSync2, mkdirSync, readFileSync as readFileSync2, writeFileSync } from "node:fs";
7759
+ import { existsSync as existsSync3, mkdirSync as mkdirSync2, readFileSync as readFileSync3, writeFileSync } from "node:fs";
7408
7760
  import { homedir as nodeHomedir } from "node:os";
7409
- import { dirname as dirname2, join as join2 } from "node:path";
7761
+ import { dirname as dirname3, join as join3 } from "node:path";
7410
7762
  var nodeFs = {
7411
- mkdirSync,
7763
+ mkdirSync: mkdirSync2,
7412
7764
  writeFileSync,
7413
- readFileSync: readFileSync2,
7414
- existsSync: existsSync2
7765
+ readFileSync: readFileSync3,
7766
+ existsSync: existsSync3
7415
7767
  };
7416
- function resolveNoloHome(env, homedir2) {
7768
+ function resolveNoloHome(env, homedir3) {
7417
7769
  const custom = env?.NOLO_HOME;
7418
7770
  if (custom && custom.trim()) return custom.trim();
7419
7771
  const ambient = process.env.NOLO_HOME?.trim();
7420
7772
  if (ambient) return ambient;
7421
- return join2(homedir2(), ".nolo");
7773
+ return join3(homedir3(), ".nolo");
7422
7774
  }
7423
- function ensureDir(dir, fs) {
7424
- fs.mkdirSync(dir, { recursive: true });
7775
+ function ensureDir(dir, fs2) {
7776
+ fs2.mkdirSync(dir, { recursive: true });
7425
7777
  }
7426
- function readJson(path, fs) {
7427
- if (!fs.existsSync(path)) return void 0;
7778
+ function readJson(path, fs2) {
7779
+ if (!fs2.existsSync(path)) return void 0;
7428
7780
  try {
7429
- const raw = fs.readFileSync(path, "utf8");
7781
+ const raw = fs2.readFileSync(path, "utf8");
7430
7782
  return JSON.parse(String(raw));
7431
7783
  } catch {
7432
7784
  return void 0;
7433
7785
  }
7434
7786
  }
7435
- function writeJson(path, data, fs) {
7436
- fs.writeFileSync(path, JSON.stringify(data, null, 2));
7787
+ function writeJson(path, data, fs2) {
7788
+ fs2.writeFileSync(path, JSON.stringify(data, null, 2));
7437
7789
  }
7438
7790
  function createFileSystemTodoStore(opts = {}) {
7439
7791
  const env = opts.env ?? process.env;
7440
- const homedir2 = opts.homedir ?? nodeHomedir;
7441
- const fs = opts.fs ?? nodeFs;
7442
- const noloHome = resolveNoloHome(env, homedir2);
7443
- const filePath = opts.filePath ?? join2(noloHome, "agent_run_todos.json");
7444
- const oldFilePath = join2(noloHome, "todos.json");
7792
+ const homedir3 = opts.homedir ?? nodeHomedir;
7793
+ const fs2 = opts.fs ?? nodeFs;
7794
+ const noloHome = resolveNoloHome(env, homedir3);
7795
+ const filePath = opts.filePath ?? join3(noloHome, "agent_run_todos.json");
7796
+ const oldFilePath = join3(noloHome, "todos.json");
7445
7797
  const loadMap = () => {
7446
- if (!opts.filePath && !fs.existsSync(filePath) && fs.existsSync(oldFilePath)) {
7447
- const oldData = readJson(oldFilePath, fs);
7798
+ if (!opts.filePath && !fs2.existsSync(filePath) && fs2.existsSync(oldFilePath)) {
7799
+ const oldData = readJson(oldFilePath, fs2);
7448
7800
  const map2 = /* @__PURE__ */ new Map();
7449
7801
  if (oldData?.todos) {
7450
7802
  for (const item of oldData.todos) {
@@ -7466,11 +7818,11 @@ function createFileSystemTodoStore(opts = {}) {
7466
7818
  }
7467
7819
  }
7468
7820
  }
7469
- ensureDir(dirname2(filePath), fs);
7470
- writeJson(filePath, { todos: [...map2.values()] }, fs);
7821
+ ensureDir(dirname3(filePath), fs2);
7822
+ writeJson(filePath, { todos: [...map2.values()] }, fs2);
7471
7823
  return map2;
7472
7824
  }
7473
- const data = readJson(filePath, fs);
7825
+ const data = readJson(filePath, fs2);
7474
7826
  const map = /* @__PURE__ */ new Map();
7475
7827
  if (data?.todos) {
7476
7828
  for (const todo of data.todos) {
@@ -7480,8 +7832,8 @@ function createFileSystemTodoStore(opts = {}) {
7480
7832
  return map;
7481
7833
  };
7482
7834
  const persist = (map) => {
7483
- ensureDir(dirname2(filePath), fs);
7484
- writeJson(filePath, { todos: [...map.values()] }, fs);
7835
+ ensureDir(dirname3(filePath), fs2);
7836
+ writeJson(filePath, { todos: [...map.values()] }, fs2);
7485
7837
  };
7486
7838
  return {
7487
7839
  async getTodo(id) {
@@ -7511,13 +7863,13 @@ function createFileSystemTodoStore(opts = {}) {
7511
7863
  }
7512
7864
 
7513
7865
  // packages/cli/client/instaboxRunConfig.ts
7514
- import { lstatSync, readFileSync as readFileSync3, realpathSync as realpathSync2 } from "node:fs";
7515
- import { isAbsolute as isAbsolute3, normalize, resolve as resolve2 } from "node:path";
7866
+ import { lstatSync as lstatSync2, readFileSync as readFileSync4, realpathSync as realpathSync3 } from "node:fs";
7867
+ import { isAbsolute as isAbsolute4, normalize, resolve as resolve3 } from "node:path";
7516
7868
 
7517
7869
  // packages/cli/client/localInstaboxWorkspaceDelivery.ts
7518
7870
  import { constants } from "node:fs";
7519
7871
  import { open, realpath } from "node:fs/promises";
7520
- import { createHash as createHash3 } from "node:crypto";
7872
+ import { createHash as createHash4 } from "node:crypto";
7521
7873
 
7522
7874
  // packages/agent-runtime/instaboxBackend.ts
7523
7875
  var INSTABOX_BACKEND_ID = "instabox";
@@ -7692,7 +8044,7 @@ var InstaboxBackend = class {
7692
8044
  ...rawBody === void 0 ? {} : { body: rawBody }
7693
8045
  });
7694
8046
  });
7695
- this.#sleep = options.sleepImpl ?? ((ms) => new Promise((resolve7) => setTimeout(resolve7, ms)));
8047
+ this.#sleep = options.sleepImpl ?? ((ms) => new Promise((resolve8) => setTimeout(resolve8, ms)));
7696
8048
  this.#machineTimeoutSeconds = options.machineTimeoutSeconds ?? 1800;
7697
8049
  this.#createTimeoutMs = options.createTimeoutMs ?? 18e4;
7698
8050
  this.#deleteTimeoutMs = options.deleteTimeoutMs ?? 12e4;
@@ -8249,8 +8601,8 @@ var InstaboxBackend = class {
8249
8601
  try {
8250
8602
  await Promise.race([
8251
8603
  this.#sleep(Math.min(this.#pollIntervalMs, remaining())),
8252
- new Promise((resolve7) => {
8253
- timer = setTimeout(resolve7, remaining());
8604
+ new Promise((resolve8) => {
8605
+ timer = setTimeout(resolve8, remaining());
8254
8606
  })
8255
8607
  ]);
8256
8608
  } finally {
@@ -8553,8 +8905,8 @@ var InstaboxBackend = class {
8553
8905
  try {
8554
8906
  return await Promise.race([
8555
8907
  this.#call({ ...args, timeoutMs: void 0 }),
8556
- new Promise((resolve7) => {
8557
- timer = setTimeout(() => resolve7({ status: 0, payload: null, transportError: "Timeout" }), args.timeoutMs);
8908
+ new Promise((resolve8) => {
8909
+ timer = setTimeout(() => resolve8({ status: 0, payload: null, transportError: "Timeout" }), args.timeoutMs);
8558
8910
  })
8559
8911
  ]);
8560
8912
  } finally {
@@ -8692,7 +9044,7 @@ function extractInstaboxErrorCode(payload) {
8692
9044
 
8693
9045
  // packages/cli/client/localInstaboxWorkspaceDelivery.ts
8694
9046
  var SNAPSHOT_LIMITS = { files: 256, fileBytes: 8 * 1024 * 1024, totalBytes: 32 * 1024 * 1024, chunkBytes: 384 * 1024 };
8695
- var hash = (bytes) => createHash3("sha256").update(bytes).digest("hex");
9047
+ var hash = (bytes) => createHash4("sha256").update(bytes).digest("hex");
8696
9048
  var fail = (code) => {
8697
9049
  throw new Error(`instabox_workspace_delivery:${code}`);
8698
9050
  };
@@ -8914,14 +9266,14 @@ function resolveInstaboxRunConfigPath(options) {
8914
9266
  fail2("missing_path", `\u73AF\u5883\u53D8\u91CF ${INSTABOX_RUN_CONFIG_ENV} \u672A\u8BBE\u7F6E\u6216\u4E3A\u7A7A`);
8915
9267
  }
8916
9268
  const runsDir = options?.runsDir ?? resolveRunsDir(env);
8917
- const normalizedRunsDir = normalize(resolve2(runsDir));
8918
- const resolvedTarget = isAbsolute3(explicitPath) ? normalize(explicitPath) : normalize(resolve2(normalizedRunsDir, explicitPath));
9269
+ const normalizedRunsDir = normalize(resolve3(runsDir));
9270
+ const resolvedTarget = isAbsolute4(explicitPath) ? normalize(explicitPath) : normalize(resolve3(normalizedRunsDir, explicitPath));
8919
9271
  if (resolvedTarget !== normalizedRunsDir && !resolvedTarget.startsWith(normalizedRunsDir.endsWith("/") ? normalizedRunsDir : `${normalizedRunsDir}/`)) {
8920
9272
  fail2("path_traversal", `\u914D\u7F6E\u8DEF\u5F84 "${explicitPath}" \u8D8A\u51FA\u4E86\u9650\u5B9A\u7684 runs \u76EE\u5F55 "${normalizedRunsDir}"`);
8921
9273
  }
8922
9274
  let stats;
8923
9275
  try {
8924
- stats = lstatSync(resolvedTarget);
9276
+ stats = lstatSync2(resolvedTarget);
8925
9277
  } catch (err) {
8926
9278
  fail2("file_unreadable", `\u914D\u7F6E\u6587\u4EF6\u4E0D\u53EF\u8BFB\u6216\u4E0D\u5B58\u5728: ${resolvedTarget}`);
8927
9279
  }
@@ -8935,8 +9287,8 @@ function resolveInstaboxRunConfigPath(options) {
8935
9287
  fail2("file_too_large", `\u914D\u7F6E\u6587\u4EF6\u5927\u5C0F (${stats.size} \u5B57\u8282) \u8D85\u8FC7\u4E0A\u9650 (${INSTABOX_RUN_CONFIG_MAX_BYTES} \u5B57\u8282)`);
8936
9288
  }
8937
9289
  try {
8938
- const realTarget = realpathSync2(resolvedTarget);
8939
- const realRuns = realpathSync2(normalizedRunsDir);
9290
+ const realTarget = realpathSync3(resolvedTarget);
9291
+ const realRuns = realpathSync3(normalizedRunsDir);
8940
9292
  if (realTarget !== realRuns && !realTarget.startsWith(realRuns.endsWith("/") ? realRuns : `${realRuns}/`)) {
8941
9293
  fail2("symlink_traversal", `\u914D\u7F6E\u771F\u5B9E\u8DEF\u5F84 "${realTarget}" \u8D8A\u51FA runs \u771F\u5B9E\u76EE\u5F55 "${realRuns}"`);
8942
9294
  }
@@ -8948,7 +9300,7 @@ function loadInstaboxRunConfig(options) {
8948
9300
  const { resolvedPath } = resolveInstaboxRunConfigPath(options);
8949
9301
  let rawText;
8950
9302
  try {
8951
- rawText = readFileSync3(resolvedPath, "utf8");
9303
+ rawText = readFileSync4(resolvedPath, "utf8");
8952
9304
  } catch (err) {
8953
9305
  fail2("file_read_failed", `\u8BFB\u53D6\u914D\u7F6E\u6587\u4EF6\u5931\u8D25: ${err instanceof Error ? err.message : String(err)}`);
8954
9306
  }
@@ -8997,7 +9349,7 @@ function loadInstaboxRunConfig(options) {
8997
9349
  if (!artifactRootRaw) {
8998
9350
  fail2("missing_artifact_root", "artifactRoot (artifact\u76EE\u7684\u76EE\u5F55) \u5FC5\u987B\u4E3A\u975E\u7A7A\u5B57\u7B26\u4E32\uFF0C\u672A\u914D\u7F6E\u6216\u9ED8\u8BA4\u5747\u88AB\u62D2\u7EDD");
8999
9351
  }
9000
- if (!isAbsolute3(artifactRootRaw) || artifactRootRaw.includes("\0") || artifactRootRaw.split("/").includes("..")) {
9352
+ if (!isAbsolute4(artifactRootRaw) || artifactRootRaw.includes("\0") || artifactRootRaw.split("/").includes("..")) {
9001
9353
  fail2("invalid_artifact_root", `artifactRoot \u5FC5\u987B\u4E3A\u5408\u6CD5\u7EDD\u5BF9\u8DEF\u5F84: "${artifactRootRaw}"`);
9002
9354
  }
9003
9355
  const artifactRoot = normalize(artifactRootRaw);
@@ -9230,10 +9582,10 @@ var parseCallArgs = (call) => {
9230
9582
  return {};
9231
9583
  }
9232
9584
  };
9233
- var resolveFs = (deps) => deps.fs ?? { existsSync: existsSync3, readFileSync: readFileSync4 };
9585
+ var resolveFs = (deps) => deps.fs ?? { existsSync: existsSync4, readFileSync: readFileSync5 };
9234
9586
  var probeRunCwd = (deps) => {
9235
- const fs = deps.fs;
9236
- const stat = fs?.statSync ?? nodeFs2.statSync;
9587
+ const fs2 = deps.fs;
9588
+ const stat = fs2?.statSync ?? nodeFs2.statSync;
9237
9589
  return (absolutePath) => {
9238
9590
  try {
9239
9591
  return stat(absolutePath).isDirectory() ? "directory" : "not-a-directory";
@@ -9242,10 +9594,10 @@ var probeRunCwd = (deps) => {
9242
9594
  }
9243
9595
  };
9244
9596
  };
9245
- var tailFile = (logPath, tailLines, fs) => {
9246
- if (!fs.existsSync(logPath)) return void 0;
9597
+ var tailFile = (logPath, tailLines, fs2) => {
9598
+ if (!fs2.existsSync(logPath)) return void 0;
9247
9599
  try {
9248
- const content = fs.readFileSync(logPath, "utf8");
9600
+ const content = fs2.readFileSync(logPath, "utf8");
9249
9601
  const lines = String(content).split(/\r?\n/);
9250
9602
  if (lines.length > 0 && lines[lines.length - 1] === "") lines.pop();
9251
9603
  return lines.slice(Math.max(0, lines.length - tailLines)).join("\n");
@@ -9407,36 +9759,36 @@ function createCliStartAgentRunExecutor(deps = {}) {
9407
9759
  let previousCacheHitRatio = previousRecord?.cacheHitRatio;
9408
9760
  if (previousRecord && previousCacheHitRatio === void 0 && previousRecord.resultFile) {
9409
9761
  try {
9410
- const fs = deps.fs ?? nodeFs2;
9411
- const runsDir = resolve3(resolveRunsDir(deps.env, deps.homedir));
9412
- const expected = resolve3(runsDir, `${previousRecord.runId}.result.md`);
9413
- if (previousRecord.runId.includes("/") || previousRecord.runId.includes("\\") || resolve3(previousRecord.resultFile) !== expected || !fs.realpathSync || !fs.lstatSync) throw new Error("Unverified result path");
9414
- const stat = fs.lstatSync(expected);
9762
+ const fs2 = deps.fs ?? nodeFs2;
9763
+ const runsDir = resolve4(resolveRunsDir(deps.env, deps.homedir));
9764
+ const expected = resolve4(runsDir, `${previousRecord.runId}.result.md`);
9765
+ if (previousRecord.runId.includes("/") || previousRecord.runId.includes("\\") || resolve4(previousRecord.resultFile) !== expected || !fs2.realpathSync || !fs2.lstatSync) throw new Error("Unverified result path");
9766
+ const stat = fs2.lstatSync(expected);
9415
9767
  if (!stat.isFile() || stat.isSymbolicLink()) throw new Error("Non-regular result file");
9416
- const canonicalDir = String(fs.realpathSync(runsDir));
9417
- if (String(fs.realpathSync(expected)) !== join3(canonicalDir, `${previousRecord.runId}.result.md`)) throw new Error("Result escapes runs directory");
9418
- if ((deps.platform ?? process.platform) !== "linux" || !fs.fstatSync || !fs.readSync || !fs.closeSync || !nodeFs2.constants.O_NOFOLLOW || !nodeFs2.constants.O_DIRECTORY) throw new Error("FD proof unavailable");
9768
+ const canonicalDir = String(fs2.realpathSync(runsDir));
9769
+ if (String(fs2.realpathSync(expected)) !== join4(canonicalDir, `${previousRecord.runId}.result.md`)) throw new Error("Result escapes runs directory");
9770
+ if ((deps.platform ?? process.platform) !== "linux" || !fs2.fstatSync || !fs2.readSync || !fs2.closeSync || !nodeFs2.constants.O_NOFOLLOW || !nodeFs2.constants.O_DIRECTORY) throw new Error("FD proof unavailable");
9419
9771
  let dirFd;
9420
9772
  let resultFd;
9421
9773
  let text = "";
9422
9774
  try {
9423
- dirFd = fs.openSync(runsDir, nodeFs2.constants.O_RDONLY | nodeFs2.constants.O_DIRECTORY | nodeFs2.constants.O_NOFOLLOW);
9424
- if (!fs.fstatSync(dirFd).isDirectory() || String(fs.realpathSync(`/proc/self/fd/${dirFd}`)) !== canonicalDir) throw new Error("Unverified directory fd");
9425
- resultFd = fs.openSync(`/proc/self/fd/${dirFd}/${previousRecord.runId}.result.md`, nodeFs2.constants.O_RDONLY | nodeFs2.constants.O_NOFOLLOW | nodeFs2.constants.O_NONBLOCK);
9426
- if (!fs.fstatSync(resultFd).isFile() || String(fs.realpathSync(`/proc/self/fd/${resultFd}`)) !== join3(canonicalDir, `${previousRecord.runId}.result.md`)) throw new Error("Unverified result fd");
9775
+ dirFd = fs2.openSync(runsDir, nodeFs2.constants.O_RDONLY | nodeFs2.constants.O_DIRECTORY | nodeFs2.constants.O_NOFOLLOW);
9776
+ if (!fs2.fstatSync(dirFd).isDirectory() || String(fs2.realpathSync(`/proc/self/fd/${dirFd}`)) !== canonicalDir) throw new Error("Unverified directory fd");
9777
+ resultFd = fs2.openSync(`/proc/self/fd/${dirFd}/${previousRecord.runId}.result.md`, nodeFs2.constants.O_RDONLY | nodeFs2.constants.O_NOFOLLOW | nodeFs2.constants.O_NONBLOCK);
9778
+ if (!fs2.fstatSync(resultFd).isFile() || String(fs2.realpathSync(`/proc/self/fd/${resultFd}`)) !== join4(canonicalDir, `${previousRecord.runId}.result.md`)) throw new Error("Unverified result fd");
9427
9779
  const bytes = Buffer.alloc(16 * 1024);
9428
9780
  let offset = 0;
9429
9781
  while (offset < bytes.length) {
9430
- const count2 = fs.readSync(resultFd, bytes, offset, bytes.length - offset, offset);
9782
+ const count2 = fs2.readSync(resultFd, bytes, offset, bytes.length - offset, offset);
9431
9783
  if (count2 === 0) break;
9432
9784
  offset += count2;
9433
9785
  }
9434
9786
  text = bytes.subarray(0, offset).toString("utf8");
9435
9787
  } finally {
9436
9788
  try {
9437
- if (resultFd !== void 0) fs.closeSync(resultFd);
9789
+ if (resultFd !== void 0) fs2.closeSync(resultFd);
9438
9790
  } finally {
9439
- if (dirFd !== void 0) fs.closeSync(dirFd);
9791
+ if (dirFd !== void 0) fs2.closeSync(dirFd);
9440
9792
  }
9441
9793
  }
9442
9794
  const header = /^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/.exec(text)?.[1];
@@ -9461,9 +9813,9 @@ function createCliStartAgentRunExecutor(deps = {}) {
9461
9813
  const bindingMachineId = agentKey && deps.resolveAgentRuntimeBindingMachineId ? await deps.resolveAgentRuntimeBindingMachineId(agentKey) : void 0;
9462
9814
  const localMachineId = deps.resolveLocalMachineId ? await deps.resolveLocalMachineId() : void 0;
9463
9815
  let memoryPlacementNote;
9464
- let effectiveRuntimeKey = args.runtimeKey;
9816
+ let effectiveRuntimeKey = args.workspaceIsolation === "auto" && args.readOnly !== true && !args.runtimeKey?.trim() ? "local" : args.runtimeKey;
9465
9817
  const autoPlacement = await evaluateAutoInstaboxPlacement({
9466
- runtimeKey: args.runtimeKey,
9818
+ runtimeKey: effectiveRuntimeKey,
9467
9819
  cwd: args.cwd,
9468
9820
  readOnly: args.readOnly === true,
9469
9821
  env: deps.env,
@@ -9495,6 +9847,8 @@ function createCliStartAgentRunExecutor(deps = {}) {
9495
9847
  ...bindingMachineId ? { bindingMachineId } : {},
9496
9848
  ...localMachineId ? { localMachineId } : {}
9497
9849
  });
9850
+ if (args.workspaceIsolation !== void 0 && args.workspaceIsolation !== "none" && args.workspaceIsolation !== "auto") throw new Error("workspaceIsolation \u5FC5\u987B\u4E3A none \u6216 auto");
9851
+ if (args.workspaceIsolation === "auto" && args.readOnly !== true && dispatch.target !== "host") throw new Error("workspaceIsolation:auto \u53EA\u652F\u6301\u672C\u5730 CLI \u5BBF\u4E3B\u5199\u578B\u4EFB\u52A1\uFF0C\u6C99\u76D2\u4E0D\u80FD\u5151\u73B0\u5BBF\u4E3B\u76EE\u5F55\u9694\u79BB");
9498
9852
  const task = typeof args.task === "string" ? args.task.trim() : "";
9499
9853
  const runTitle = normalizeRunTitle(args.title);
9500
9854
  if (!agentKey) throw new Error(t("agentRunTool.missingAgentKey"));
@@ -9537,7 +9891,7 @@ function createCliStartAgentRunExecutor(deps = {}) {
9537
9891
  const manifest = typeof args.instaboxManifest === "string" ? args.instaboxManifest.trim() : "";
9538
9892
  if (workspace === "snapshot" && !manifest) throw new Error("instaboxWorkspace=snapshot \u5FC5\u987B\u63D0\u4F9B instaboxManifest");
9539
9893
  if (workspace === "empty" && args.instaboxManifest !== void 0) throw new Error("instaboxWorkspace=empty \u4E0D\u5F97\u63D0\u4F9B instaboxManifest");
9540
- const artifactDir = args.instaboxArtifactDir ?? join3(
9894
+ const artifactDir = args.instaboxArtifactDir ?? join4(
9541
9895
  resolveRunsDir(deps.env, deps.homedir),
9542
9896
  "instabox-artifacts",
9543
9897
  randomUUID3()
@@ -9590,44 +9944,64 @@ function createCliStartAgentRunExecutor(deps = {}) {
9590
9944
  });
9591
9945
  const dodCommands = Array.isArray(args.dodCommands) ? args.dodCommands.filter((c) => typeof c === "string" && c.trim().length > 0).map((c) => c.trim()) : typeof args.dod === "string" && args.dod.trim().length > 0 ? [args.dod.trim()] : Array.isArray(args.dod) ? args.dod.filter((c) => typeof c === "string" && c.trim().length > 0).map((c) => c.trim()) : void 0;
9592
9946
  const childPolicy = parseAgentRunArgs(rawArgs, { readTextFile: () => message });
9593
- const { runId, batchId: resolvedBatchId } = await spawnLocalBackgroundRun(
9594
- {
9595
- selectionCheck,
9596
- ...evidenceScope ? { evidenceScope } : {},
9597
- ...dispatchUserId ? { dispatchSpeedProvenance: {
9598
- version: 1,
9599
- source: "cli-startAgentRun",
9600
- userId: dispatchUserId
9601
- } } : {},
9602
- rawArgs,
9603
- commandPath: ["agent", "run"],
9604
- cliEntrypointPath: deps.cliEntrypoint,
9605
- agentKey,
9606
- ...agentName ? { agentName } : {},
9607
- ...runTitle ? { title: runTitle } : {},
9608
- ...batchId ? { batchId } : {},
9609
- ...credentialGroup ? { credentialGroup } : {},
9610
- ...parentDialogId ? { parentDialogId } : {},
9611
- // 续跑目标对话:spawn 时落盘,让"开着这条对话的 TUI"在 running 期间就能
9612
- // 看到另一边在跑(dock 按 dialogId 也能匹配到这条 run)。
9613
- ...continueDialogId ? { dialogId: continueDialogId } : {},
9614
- ...dodCommands && dodCommands.length > 0 ? { dodCommands } : {},
9615
- cwd: requestedCwd ?? deps.cwd ?? process.cwd(),
9616
- ...dispatch.runtimeKey === "local" && !isReadOnlyTask ? { claimLocalWrites: true } : {},
9617
- ...dispatch.target === "host" ? { localExecution: {
9618
- runtimeKey: "local",
9619
- hostWritesAuthorized: args.allowHostWrites === true,
9620
- readOnly: isReadOnlyTask,
9621
- ...childPolicy?.allowedToolNames ? { allowedToolNames: childPolicy.allowedToolNames } : {},
9622
- ...childPolicy?.blockedToolNames ? { blockedToolNames: childPolicy.blockedToolNames } : {},
9623
- provenance: "cli-tool-dispatch-authorized"
9624
- } } : {},
9625
- message,
9626
- ...args.ephemeral === true ? { ephemeral: true } : {},
9627
- output: noopOutput
9628
- },
9629
- { ...deps, mcpApprovalHost: deps.mcpApprovalHostForAgent ? await deps.mcpApprovalHostForAgent(agentKey) : deps.mcpApprovalHost, shellApprovalHost: deps.shellApprovalHostForAgent ? await deps.shellApprovalHostForAgent(agentKey) : deps.shellApprovalHost }
9630
- );
9947
+ const isolationEnabled = args.workspaceIsolation === "auto" && !isReadOnlyTask;
9948
+ const isolationRunId = isolationEnabled ? (deps.generateRunId ?? defaultGenerateRunId)() : void 0;
9949
+ const baseCwd = requestedCwd ?? deps.cwd ?? process.cwd();
9950
+ const workspaceIsolation = isolationEnabled ? (deps.prepareIsolation ?? prepareWorkspaceIsolation)({
9951
+ baseCwd,
9952
+ runId: isolationRunId,
9953
+ mode: "auto",
9954
+ noloHome: dirname4(resolveRunsDir(deps.env, deps.homedir))
9955
+ }) : { mode: args.workspaceIsolation ?? "none", kind: "none", effectiveCwd: baseCwd };
9956
+ let spawned;
9957
+ try {
9958
+ spawned = await spawnLocalBackgroundRun(
9959
+ {
9960
+ selectionCheck,
9961
+ ...evidenceScope ? { evidenceScope } : {},
9962
+ ...dispatchUserId ? { dispatchSpeedProvenance: {
9963
+ version: 1,
9964
+ source: "cli-startAgentRun",
9965
+ userId: dispatchUserId
9966
+ } } : {},
9967
+ rawArgs,
9968
+ commandPath: ["agent", "run"],
9969
+ cliEntrypointPath: deps.cliEntrypoint,
9970
+ agentKey,
9971
+ ...agentName ? { agentName } : {},
9972
+ ...runTitle ? { title: runTitle } : {},
9973
+ ...batchId ? { batchId } : {},
9974
+ ...credentialGroup ? { credentialGroup } : {},
9975
+ ...parentDialogId ? { parentDialogId } : {},
9976
+ // 续跑目标对话:spawn 时落盘,让"开着这条对话的 TUI"在 running 期间就能
9977
+ // 看到另一边在跑(dock 按 dialogId 也能匹配到这条 run)。
9978
+ ...continueDialogId ? { dialogId: continueDialogId } : {},
9979
+ ...dodCommands && dodCommands.length > 0 ? { dodCommands } : {},
9980
+ cwd: workspaceIsolation.effectiveCwd,
9981
+ ...dispatch.runtimeKey === "local" && !isReadOnlyTask ? { claimLocalWrites: true } : {},
9982
+ ...dispatch.target === "host" ? { localExecution: {
9983
+ runtimeKey: "local",
9984
+ hostWritesAuthorized: args.allowHostWrites === true,
9985
+ readOnly: isReadOnlyTask,
9986
+ ...childPolicy?.allowedToolNames ? { allowedToolNames: childPolicy.allowedToolNames } : {},
9987
+ ...childPolicy?.blockedToolNames ? { blockedToolNames: childPolicy.blockedToolNames } : {},
9988
+ provenance: "cli-tool-dispatch-authorized"
9989
+ } } : {},
9990
+ message,
9991
+ ...args.ephemeral === true ? { ephemeral: true } : {},
9992
+ output: noopOutput
9993
+ },
9994
+ { ...deps, ...isolationRunId !== void 0 ? { generateRunId: () => isolationRunId } : {}, mcpApprovalHost: deps.mcpApprovalHostForAgent ? await deps.mcpApprovalHostForAgent(agentKey) : deps.mcpApprovalHost, shellApprovalHost: deps.shellApprovalHostForAgent ? await deps.shellApprovalHostForAgent(agentKey) : deps.shellApprovalHost }
9995
+ );
9996
+ } catch (error) {
9997
+ try {
9998
+ if (isolationEnabled) (deps.rollbackIsolation ?? rollbackWorkspaceIsolation)(workspaceIsolation);
9999
+ } catch (cleanupError) {
10000
+ throw new AggregateError([error, cleanupError], `\u542F\u52A8\u5931\u8D25\uFF1B\u9694\u79BB\u76EE\u5F55\u4FDD\u7559\u5F85\u5904\u7406: ${workspaceIsolation.root}`);
10001
+ }
10002
+ throw error;
10003
+ }
10004
+ const { runId, batchId: resolvedBatchId } = spawned;
9631
10005
  const displayName = resolveRunLabel({ agentName, agentKey, runId });
9632
10006
  const labels = agentRunCardLabels();
9633
10007
  const taskPreview = typeof args.task === "string" ? args.task.replace(/\s+/g, " ").trim().slice(0, TASK_PREVIEW_MAX) : "";
@@ -9662,6 +10036,7 @@ function createCliStartAgentRunExecutor(deps = {}) {
9662
10036
  agentKey,
9663
10037
  status: "running",
9664
10038
  selectionCheck,
10039
+ ...args.workspaceIsolation !== void 0 ? { workspaceIsolation } : {},
9665
10040
  ...contextFacts,
9666
10041
  ...continuationEvidence,
9667
10042
  // batchId is always returned so the caller can later filter by it —
@@ -9942,7 +10317,7 @@ function createCliControlAgentRunExecutor(deps = {}) {
9942
10317
  };
9943
10318
  }
9944
10319
  if (action === "append") {
9945
- if (["runtimeKey", "allowHostWrites", "readOnly", "allowedToolNames", "blockedToolNames", "cwd"].some((key) => args[key] !== void 0)) {
10320
+ if (["runtimeKey", "allowHostWrites", "readOnly", "allowedToolNames", "blockedToolNames", "cwd", "workspaceIsolation"].some((key) => args[key] !== void 0)) {
9946
10321
  throw new Error("[local-continuation] scope overrides are not supported; dispatch a fresh authorized run");
9947
10322
  }
9948
10323
  const dialogKeyArg = typeof args.dialogKey === "string" ? args.dialogKey.trim() : "";
@@ -9982,8 +10357,8 @@ ${userInput}` : userInput;
9982
10357
  const afterCheck = checkStaleRun(reconciled2.runId, deps) ?? reconciled2;
9983
10358
  if (isAgentRunTerminalStatus(afterCheck.status)) {
9984
10359
  return await withQueueLock(queuePath, deps, async () => {
9985
- const fs = deps.fs ?? nodeFs2;
9986
- const remainingEntries = _readQueueEntriesLocked(queuePath, fs);
10360
+ const fs2 = deps.fs ?? nodeFs2;
10361
+ const remainingEntries = _readQueueEntriesLocked(queuePath, fs2);
9987
10362
  const ourEntryFound = remainingEntries.some((e) => e.id === entryId);
9988
10363
  if (!ourEntryFound) {
9989
10364
  return {
@@ -10013,11 +10388,11 @@ ${userInput}` : userInput;
10013
10388
  ${entry.text}`).join("\n\n");
10014
10389
  const result = await spawnContinuationRun(afterCheck, mergedMessage, userInput, deps);
10015
10390
  const transferred = new Set(remainingEntries.map((entry) => entry.id));
10016
- const current = _readQueueEntriesLocked(queuePath, fs);
10017
- if (typeof fs.renameSync !== "function") throw new Error("atomic queue replacement requires renameSync");
10391
+ const current = _readQueueEntriesLocked(queuePath, fs2);
10392
+ if (typeof fs2.renameSync !== "function") throw new Error("atomic queue replacement requires renameSync");
10018
10393
  const pendingQueue = `${queuePath}.${randomUUID3()}.tmp`;
10019
- fs.writeFileSync(pendingQueue, serializeQueueEntries(current.filter((entry) => !transferred.has(entry.id))), { encoding: "utf8", flag: "wx" });
10020
- fs.renameSync(pendingQueue, queuePath);
10394
+ fs2.writeFileSync(pendingQueue, serializeQueueEntries(current.filter((entry) => !transferred.has(entry.id))), { encoding: "utf8", flag: "wx" });
10395
+ fs2.renameSync(pendingQueue, queuePath);
10021
10396
  return result;
10022
10397
  });
10023
10398
  }
@@ -10314,11 +10689,19 @@ function pickAgentRunResolverDeps(args) {
10314
10689
  };
10315
10690
  }
10316
10691
  function buildCliWorkspaceToolExecutors(args) {
10692
+ const resolveDialogStore = args.resolveDialogStore;
10317
10693
  return buildNoloWorkspaceCliToolExecutors({
10318
10694
  cliEntrypoint: args.cliEntrypoint ?? process.argv[1] ?? "",
10319
10695
  env: args.env,
10320
10696
  metadataKind: "cliWorkspaceTool",
10321
- planningCaller: args.planningCaller
10697
+ planningCaller: args.planningCaller,
10698
+ // 只放开 readDialog(本机独占对话)的进程内直读;listDialogs 一律保持
10699
+ // 权威跨端合并路径——本地库只是缓存,抢答会静默漏掉 Web/手机端新对话。
10700
+ ...resolveDialogStore ? {
10701
+ resolveDialogStore,
10702
+ resolveCurrentUserId: () => resolveLocalUserId(args.env),
10703
+ resolveLocalChildDialogIds: args.resolveLocalChildDialogIds ?? (() => loadLocalRunChildDialogIds({ env: args.env }))
10704
+ } : {}
10322
10705
  });
10323
10706
  }
10324
10707
  function buildLocalToolExecutors(args) {
@@ -10344,7 +10727,9 @@ function buildLocalToolExecutors(args) {
10344
10727
  ...buildCliWorkspaceToolExecutors({
10345
10728
  planningCaller: args.planningCaller,
10346
10729
  env: args.env,
10347
- cliEntrypoint: args.cliEntrypoint
10730
+ cliEntrypoint: args.cliEntrypoint,
10731
+ ...args.resolveDialogStore ? { resolveDialogStore: args.resolveDialogStore } : {},
10732
+ ...args.resolveLocalChildDialogIds ? { resolveLocalChildDialogIds: args.resolveLocalChildDialogIds } : {}
10348
10733
  }),
10349
10734
  // loadSkill resolves SKILL.md from the agent's workspace root (local-fs,
10350
10735
  // no `nolo` CLI subcommand), so it is wired here instead of inside
@@ -10685,8 +11070,8 @@ function createOAuthApiKeyRefResolver(options = {}) {
10685
11070
  }
10686
11071
 
10687
11072
  // packages/agent-runtime/localSandboxWorkload.ts
10688
- import { existsSync as existsSync4 } from "node:fs";
10689
- import { resolve as resolve5 } from "node:path";
11073
+ import { existsSync as existsSync5 } from "node:fs";
11074
+ import { resolve as resolve6 } from "node:path";
10690
11075
 
10691
11076
  // packages/agent-runtime/executionChannel.ts
10692
11077
  var EXECUTION_SHELL_TOOL = "execShell";
@@ -10772,12 +11157,12 @@ import {
10772
11157
  openSync,
10773
11158
  readlinkSync,
10774
11159
  rmdirSync,
10775
- unlinkSync,
11160
+ unlinkSync as unlinkSync2,
10776
11161
  writeSync
10777
11162
  } from "node:fs";
10778
11163
  import { access } from "node:fs/promises";
10779
11164
  import { tmpdir } from "node:os";
10780
- import { isAbsolute as isAbsolute4, join as join4, relative, resolve as resolve4 } from "node:path";
11165
+ import { isAbsolute as isAbsolute5, join as join5, relative as relative2, resolve as resolve5 } from "node:path";
10781
11166
 
10782
11167
  // packages/agent-runtime/linuxSandboxSeccomp.ts
10783
11168
  var AUDIT_ARCH_X86_64 = 3221225534;
@@ -10870,14 +11255,14 @@ var MAX_OUTPUT_BYTES = 1024 * 1024;
10870
11255
  var PSEUDO_FS = ["/proc", "/sys", "/dev", "/run"];
10871
11256
  var SANDBOX_MOUNTS = ["/", "/usr", "/bin", "/lib", "/lib64", "/tmp"];
10872
11257
  var inside = (parent, child) => {
10873
- const rel = relative(parent, child);
10874
- return rel === "" || rel !== ".." && !rel.startsWith("../") && !isAbsolute4(rel);
11258
+ const rel = relative2(parent, child);
11259
+ return rel === "" || rel !== ".." && !rel.startsWith("../") && !isAbsolute5(rel);
10875
11260
  };
10876
11261
  function openRootHandle(path) {
10877
- if (typeof path !== "string" || !isAbsolute4(path) || path.includes("\0")) {
11262
+ if (typeof path !== "string" || !isAbsolute5(path) || path.includes("\0")) {
10878
11263
  throw new Error("Sandbox root must be absolute");
10879
11264
  }
10880
- const expected = resolve4(path);
11265
+ const expected = resolve5(path);
10881
11266
  if (SANDBOX_MOUNTS.includes(expected) || PSEUDO_FS.some((reserved) => inside(reserved, expected))) {
10882
11267
  throw new Error("Sandbox root overlaps a reserved sandbox/pseudo filesystem path");
10883
11268
  }
@@ -10901,8 +11286,8 @@ function openRootHandle(path) {
10901
11286
  }
10902
11287
  var SECCOMP_TEMP_DIR_PREFIX = "nolo-bwrap-seccomp-";
10903
11288
  function openSeccompFd(program) {
10904
- const dir = mkdtempSync(join4(tmpdir(), SECCOMP_TEMP_DIR_PREFIX));
10905
- const file = join4(dir, "filter.bpf");
11289
+ const dir = mkdtempSync(join5(tmpdir(), SECCOMP_TEMP_DIR_PREFIX));
11290
+ const file = join5(dir, "filter.bpf");
10906
11291
  let writer = -1;
10907
11292
  let reader = -1;
10908
11293
  try {
@@ -10921,7 +11306,7 @@ function openSeccompFd(program) {
10921
11306
  } finally {
10922
11307
  if (writer >= 0) closeSync(writer);
10923
11308
  try {
10924
- unlinkSync(file);
11309
+ unlinkSync2(file);
10925
11310
  } catch {
10926
11311
  }
10927
11312
  try {
@@ -11060,7 +11445,7 @@ var LinuxBubblewrapBackend = class {
11060
11445
  if (request.timeoutMs !== void 0 && (!Number.isFinite(request.timeoutMs) || request.timeoutMs <= 0)) {
11061
11446
  throw new Error("Sandbox timeout must be finite and positive");
11062
11447
  }
11063
- if (request.cwd && !active.writable.some(({ path: root }) => isAbsolute4(request.cwd) && inside(root, resolve4(request.cwd)))) {
11448
+ if (request.cwd && !active.writable.some(({ path: root }) => isAbsolute5(request.cwd) && inside(root, resolve5(request.cwd)))) {
11064
11449
  throw new Error("Command cwd outside writable sandbox roots");
11065
11450
  }
11066
11451
  if (!validateConfiguredRootExecutionLease(active.ticket, active.lease)) {
@@ -11217,7 +11602,7 @@ async function createLocalSandboxWorkload(args) {
11217
11602
  const envRoots = typeof env.NOLO_LOCAL_SANDBOX_ROOTS === "string" ? env.NOLO_LOCAL_SANDBOX_ROOTS.split(":").map((entry) => entry.trim()) : [];
11218
11603
  const readableRoots = normalizeRoots(
11219
11604
  args.readableRoots && args.readableRoots.length > 0 ? args.readableRoots : [...DEFAULT_SANDBOX_READABLE_ROOTS, ...envRoots]
11220
- ).filter((root) => !FORBIDDEN_EXTRA_ROOTS.has(resolve5(root)));
11605
+ ).filter((root) => !FORBIDDEN_EXTRA_ROOTS.has(resolve6(root)));
11221
11606
  const backend = args.backend ?? new LinuxBubblewrapBackend();
11222
11607
  const ticket = {
11223
11608
  version: 1,
@@ -11265,7 +11650,7 @@ async function createLocalSandboxWorkload(args) {
11265
11650
  if (canonicalToolName(toolName) !== EXECUTION_SHELL_TOOL) return null;
11266
11651
  const callArgs = toolArgs ?? {};
11267
11652
  const command = typeof callArgs.command === "string" ? callArgs.command : "";
11268
- const mountedBins = readableRoots.map((root) => `${root}/bin`).filter((dir) => existsSync4(dir));
11653
+ const mountedBins = readableRoots.map((root) => `${root}/bin`).filter((dir) => existsSync5(dir));
11269
11654
  const sandboxPath = [
11270
11655
  ...mountedBins,
11271
11656
  process.env.PATH ?? "/usr/local/bin:/usr/bin:/bin"
@@ -11695,12 +12080,12 @@ async function executeWorkspaceDelivery(plan, runtime, deps = {}) {
11695
12080
  }
11696
12081
  const tmpDir = deps.tmpDir ?? (await import("node:os")).tmpdir();
11697
12082
  const writeTempFile = deps.writeTempFile ?? (async (filePath, content) => {
11698
- const fs = await import("node:fs/promises");
11699
- await fs.writeFile(filePath, content, "utf8");
12083
+ const fs2 = await import("node:fs/promises");
12084
+ await fs2.writeFile(filePath, content, "utf8");
11700
12085
  });
11701
12086
  const removeTempFile = deps.removeTempFile ?? (async (filePath) => {
11702
- const fs = await import("node:fs/promises");
11703
- await fs.rm(filePath, { force: true });
12087
+ const fs2 = await import("node:fs/promises");
12088
+ await fs2.rm(filePath, { force: true });
11704
12089
  });
11705
12090
  let hostBaselineTemp = null;
11706
12091
  if (plan.baselineUpload) {
@@ -11800,10 +12185,10 @@ async function applyDockerWorkspaceDelivery(runtime, selection) {
11800
12185
 
11801
12186
  // packages/cli/client/localWorkspaceArchive.ts
11802
12187
  import { spawnSync } from "node:child_process";
11803
- import { mkdtempSync as mkdtempSync2, statSync as statSync2, writeFileSync as writeFileSync2 } from "node:fs";
12188
+ import { mkdtempSync as mkdtempSync2, statSync as statSync3, writeFileSync as writeFileSync2 } from "node:fs";
11804
12189
  import { rm } from "node:fs/promises";
11805
12190
  import { tmpdir as tmpdir2 } from "node:os";
11806
- import { join as join5 } from "node:path";
12191
+ import { join as join6 } from "node:path";
11807
12192
  var runHostCommand = (argv, { cwd }) => {
11808
12193
  const result = spawnSync(argv[0], argv.slice(1), {
11809
12194
  cwd,
@@ -11863,11 +12248,11 @@ function prepareHostWorkspaceDelivery(args) {
11863
12248
  `\u5DE5\u4F5C\u533A\u6587\u4EF6\u6570 ${tracked.length} \u8D85\u8FC7\u4E0A\u9650 ${MAX_DELIVERY_FILE_COUNT}\uFF1A\u7591\u4F3C\u628A node_modules / \u6784\u5EFA\u4EA7\u7269\u6253\u8FDB\u4E86\u5F52\u6863\uFF08\u5F52\u6863\u53EA\u53D6 git ls-files\uFF09\u3002`
11864
12249
  );
11865
12250
  }
11866
- const stagingDir = mkdtempSync2(join5(args.tmpDir ?? tmpdir2(), "nolo-workspace-delivery-"));
12251
+ const stagingDir = mkdtempSync2(join6(args.tmpDir ?? tmpdir2(), "nolo-workspace-delivery-"));
11867
12252
  const stamp = `${process.pid}-${Date.now()}`;
11868
- const archivePath = join5(stagingDir, `workspace-${stamp}.tar.gz`);
11869
- const bundlePath = join5(stagingDir, `workspace-${stamp}.bundle`);
11870
- const listPath = join5(stagingDir, `filelist-${stamp}.z`);
12253
+ const archivePath = join6(stagingDir, `workspace-${stamp}.tar.gz`);
12254
+ const bundlePath = join6(stagingDir, `workspace-${stamp}.bundle`);
12255
+ const listPath = join6(stagingDir, `filelist-${stamp}.z`);
11871
12256
  const removeFile = args.removeFile ?? (async (filePath) => {
11872
12257
  await rm(filePath, { force: true });
11873
12258
  });
@@ -11948,7 +12333,7 @@ function prepareHostWorkspaceDelivery(args) {
11948
12333
  }
11949
12334
  let archiveSizeBytes = 0;
11950
12335
  try {
11951
- archiveSizeBytes = statSync2(archivePath).size;
12336
+ archiveSizeBytes = statSync3(archivePath).size;
11952
12337
  } catch (error) {
11953
12338
  return fail3(
11954
12339
  "host_workspace_archive_failed",
@@ -12008,7 +12393,7 @@ function buildHostBundle(args) {
12008
12393
  }
12009
12394
  let sizeBytes = 0;
12010
12395
  try {
12011
- sizeBytes = statSync2(args.bundlePath).size;
12396
+ sizeBytes = statSync3(args.bundlePath).size;
12012
12397
  } catch (error) {
12013
12398
  return {
12014
12399
  ok: false,
@@ -12111,8 +12496,8 @@ async function createLocalDockerWorkload(args) {
12111
12496
  }
12112
12497
  const createLifecycle = args.createLifecycle ?? (async () => {
12113
12498
  const [{ DockerWorkloadLifecycle, createDockerBindingAuthorizer }, accounts] = await Promise.all([
12114
- import("./workloadLifecycle-YIZ7KLUP.js"),
12115
- import("./accountResolver-EK2S4PWF.js")
12499
+ import("./workloadLifecycle-ZCSQCHG3.js"),
12500
+ import("./accountResolver-QETKNC7T.js")
12116
12501
  ]);
12117
12502
  const resolveAccount = args.resolveAccount ?? accounts.createDockerAccountResolver({
12118
12503
  env: args.env,
@@ -12207,28 +12592,28 @@ async function createLocalDockerWorkload(args) {
12207
12592
  };
12208
12593
  let rejectReady = () => {
12209
12594
  };
12210
- const ready = new Promise((resolve7, reject) => {
12211
- resolveReady = resolve7;
12595
+ const ready = new Promise((resolve8, reject) => {
12596
+ resolveReady = resolve8;
12212
12597
  rejectReady = reject;
12213
12598
  });
12214
12599
  let releaseRun = () => {
12215
12600
  };
12216
- const releaseGate = new Promise((resolve7) => {
12217
- releaseRun = resolve7;
12601
+ const releaseGate = new Promise((resolve8) => {
12602
+ releaseRun = resolve8;
12218
12603
  });
12219
12604
  const waitForReleaseOrAbort = () => {
12220
12605
  const signal = args.signal;
12221
12606
  if (!signal) return releaseGate;
12222
12607
  if (signal.aborted) return Promise.resolve();
12223
- return new Promise((resolve7) => {
12608
+ return new Promise((resolve8) => {
12224
12609
  const onAbort = () => {
12225
12610
  signal.removeEventListener("abort", onAbort);
12226
- resolve7();
12611
+ resolve8();
12227
12612
  };
12228
12613
  signal.addEventListener("abort", onAbort, { once: true });
12229
12614
  void releaseGate.then(() => {
12230
12615
  signal.removeEventListener("abort", onAbort);
12231
- resolve7();
12616
+ resolve8();
12232
12617
  });
12233
12618
  });
12234
12619
  };
@@ -12722,12 +13107,12 @@ function describeInstaboxBridgeUnavailable(bridge) {
12722
13107
  // packages/cli/client/localInstaboxWorkspaceRecovery.ts
12723
13108
  import { constants as constants3 } from "node:fs";
12724
13109
  import { open as open2 } from "node:fs/promises";
12725
- import { createHash as createHash5, randomUUID as randomUUID4 } from "node:crypto";
13110
+ import { createHash as createHash6, randomUUID as randomUUID4 } from "node:crypto";
12726
13111
 
12727
13112
  // packages/agent-runtime/artifactStore.ts
12728
- import { createHash as createHash4, createHmac } from "node:crypto";
13113
+ import { createHash as createHash5, createHmac } from "node:crypto";
12729
13114
  import { mkdir, readFile, unlink, writeFile } from "node:fs/promises";
12730
- import { dirname as dirname3, resolve as resolve6, sep } from "node:path";
13115
+ import { dirname as dirname5, resolve as resolve7, sep as sep2 } from "node:path";
12731
13116
  var ArtifactStoreError = class extends Error {
12732
13117
  code;
12733
13118
  key;
@@ -12777,12 +13162,12 @@ function isNotFoundError(error) {
12777
13162
  return error?.code === "ENOENT";
12778
13163
  }
12779
13164
  function createLocalArtifactStore(options) {
12780
- const root = resolve6(options.rootDir);
13165
+ const root = resolve7(options.rootDir);
12781
13166
  const now = options.now ?? Date.now;
12782
13167
  const pathFor = (key) => {
12783
13168
  assertArtifactKey(key);
12784
- const target = resolve6(root, key);
12785
- if (target !== root && !target.startsWith(`${root}${sep}`)) {
13169
+ const target = resolve7(root, key);
13170
+ if (target !== root && !target.startsWith(`${root}${sep2}`)) {
12786
13171
  throw new ArtifactStoreError(
12787
13172
  "invalid_key",
12788
13173
  `artifact key \u89E3\u6790\u540E\u8D8A\u51FA rootDir\uFF1A${describeKey(key)}`,
@@ -12796,7 +13181,7 @@ function createLocalArtifactStore(options) {
12796
13181
  const bytes = toBytes(data);
12797
13182
  const target = pathFor(key);
12798
13183
  try {
12799
- await mkdir(dirname3(target), { recursive: true });
13184
+ await mkdir(dirname5(target), { recursive: true });
12800
13185
  await writeFile(target, bytes);
12801
13186
  } catch (error) {
12802
13187
  if (error instanceof ArtifactStoreError) throw error;
@@ -12852,12 +13237,12 @@ function createLocalArtifactStore(options) {
12852
13237
  };
12853
13238
  }
12854
13239
  function sha256Hex2(data) {
12855
- return createHash4("sha256").update(data).digest("hex");
13240
+ return createHash5("sha256").update(data).digest("hex");
12856
13241
  }
12857
13242
  var EMPTY_SHA256 = sha256Hex2("");
12858
13243
 
12859
13244
  // packages/cli/client/localInstaboxWorkspaceRecovery.ts
12860
- var sha = (b) => createHash5("sha256").update(b).digest("hex");
13245
+ var sha = (b) => createHash6("sha256").update(b).digest("hex");
12861
13246
  function fail4(code) {
12862
13247
  throw Object.assign(new Error(`instabox_workspace_recovery:${code}; cleanup_pending`), { code: "instabox_cleanup_pending", cleanupPending: true });
12863
13248
  }
@@ -13362,8 +13747,8 @@ async function createLocalInstaboxWorkload(args) {
13362
13747
  }
13363
13748
 
13364
13749
  // packages/cli/client/localRunArtifactExport.ts
13365
- import { mkdirSync as mkdirSync2, writeFileSync as writeFileSync3 } from "node:fs";
13366
- import { dirname as dirname4, join as join6 } from "node:path";
13750
+ import { mkdirSync as mkdirSync3, writeFileSync as writeFileSync3 } from "node:fs";
13751
+ import { dirname as dirname6, join as join7 } from "node:path";
13367
13752
 
13368
13753
  // packages/agent-runtime/runArtifactExport.ts
13369
13754
  var RUN_DIFF_COMMAND = "git add -A && git diff --cached --binary";
@@ -13571,13 +13956,13 @@ function serializeRunArtifactAudit(record) {
13571
13956
  // packages/cli/client/localRunArtifactExport.ts
13572
13957
  function resolveRunArtifactsRootDir(runsDir) {
13573
13958
  const normalized = runsDir.replace(/[/\\]+$/, "");
13574
- return join6(dirname4(normalized || runsDir), "artifacts");
13959
+ return join7(dirname6(normalized || runsDir), "artifacts");
13575
13960
  }
13576
13961
  function writeRunArtifactAudit(args) {
13577
- const fs = args.fs ?? { mkdirSync: mkdirSync2, writeFileSync: writeFileSync3 };
13578
- const path = join6(args.runsDir, `${args.record.runId}.artifacts.json`);
13579
- fs.mkdirSync?.(args.runsDir, { recursive: true });
13580
- fs.writeFileSync(path, serializeRunArtifactAudit(args.record));
13962
+ const fs2 = args.fs ?? { mkdirSync: mkdirSync3, writeFileSync: writeFileSync3 };
13963
+ const path = join7(args.runsDir, `${args.record.runId}.artifacts.json`);
13964
+ fs2.mkdirSync?.(args.runsDir, { recursive: true });
13965
+ fs2.writeFileSync(path, serializeRunArtifactAudit(args.record));
13581
13966
  return path;
13582
13967
  }
13583
13968
  function createDockerRunTerminalExport(args) {
@@ -13927,9 +14312,9 @@ function buildTokenDialogIndexOps(args) {
13927
14312
 
13928
14313
  // packages/cli/client/localRuntimeDialog.ts
13929
14314
  var import_format = __toESM(require_format(), 1);
13930
- import { appendFileSync, mkdirSync as mkdirSync3 } from "fs";
13931
- import { homedir } from "os";
13932
- import { join as join7 } from "path";
14315
+ import { appendFileSync, mkdirSync as mkdirSync4 } from "fs";
14316
+ import { homedir as homedir2 } from "os";
14317
+ import { join as join8 } from "path";
13933
14318
 
13934
14319
  // packages/cli/client/cliCompletedTurnCapture.ts
13935
14320
  async function readCliCaptureSources(args) {
@@ -14049,11 +14434,11 @@ function projectRawUsage(usage) {
14049
14434
  function debugCaptureRawUsage(item) {
14050
14435
  if (!process.env.NOLO_DEBUG_RAW_USAGE) return;
14051
14436
  try {
14052
- const noloHome = process.env.NOLO_HOME?.trim() || join7(homedir(), ".nolo");
14053
- const dir = join7(noloHome, "logs");
14054
- mkdirSync3(dir, { recursive: true });
14437
+ const noloHome = process.env.NOLO_HOME?.trim() || join8(homedir2(), ".nolo");
14438
+ const dir = join8(noloHome, "logs");
14439
+ mkdirSync4(dir, { recursive: true });
14055
14440
  appendFileSync(
14056
- join7(dir, "raw-usage.jsonl"),
14441
+ join8(dir, "raw-usage.jsonl"),
14057
14442
  JSON.stringify({
14058
14443
  ts: Date.now(),
14059
14444
  model: item.model,
@@ -14296,14 +14681,26 @@ async function writeDialog(args) {
14296
14681
  existingDialog,
14297
14682
  cwd: args.cwd
14298
14683
  });
14299
- for (const id of plan.captureUserMessageIds) {
14300
- const op = plan.ops.find((op2) => op2.value.id === id && op2.value.role === "user");
14301
- const existing = await args.store.read(op.key, { remote: false });
14302
- if (existing) {
14303
- if (existing.id !== id || existing.dialogId !== plan.dialogId || existing.userId !== args.userId || existing.role !== "user" || JSON.stringify(existing.content) !== JSON.stringify(op.value.content)) {
14304
- throw new Error("CLI persisted turn source conflict");
14684
+ const prefetchedUserMessages = /* @__PURE__ */ new Map();
14685
+ if (plan.captureUserMessageIds.length > 0) {
14686
+ const captureEntries = plan.captureUserMessageIds.map((id) => ({
14687
+ id,
14688
+ op: plan.ops.find((op) => op.value.id === id && op.value.role === "user")
14689
+ }));
14690
+ const uniqueKeys = [...new Set(captureEntries.map((entry) => entry.op.key))];
14691
+ const readResults = await Promise.all(
14692
+ uniqueKeys.map(async (key) => [key, await args.store.read(key, { remote: false })])
14693
+ );
14694
+ const existingByKey = new Map(readResults);
14695
+ for (const { id, op } of captureEntries) {
14696
+ const existing = existingByKey.get(op.key);
14697
+ if (existing) {
14698
+ if (existing.id !== id || existing.dialogId !== plan.dialogId || existing.userId !== args.userId || existing.role !== "user" || JSON.stringify(existing.content) !== JSON.stringify(op.value.content)) {
14699
+ throw new Error("CLI persisted turn source conflict");
14700
+ }
14701
+ op.value = existing;
14305
14702
  }
14306
- op.value = existing;
14703
+ prefetchedUserMessages.set(op.key, op.value);
14307
14704
  }
14308
14705
  }
14309
14706
  const lastInputTokens = extractLastProviderInputTokens(args.input) ?? (typeof existingDialog?.lastInputTokens === "number" && Number.isFinite(existingDialog.lastInputTokens) && existingDialog.lastInputTokens > 0 ? existingDialog.lastInputTokens : void 0);
@@ -14323,9 +14720,12 @@ async function writeDialog(args) {
14323
14720
  source: "cli-local"
14324
14721
  });
14325
14722
  if (args.cliBatchCompletion) {
14326
- for (const batchId of args.cliBatchCompletion.batchIds) {
14327
- plan.ops.push(await buildCliBatchCompletionOp(args.store, plan.dialogId, batchId));
14328
- }
14723
+ const completionOps = await Promise.all(
14724
+ args.cliBatchCompletion.batchIds.map(
14725
+ (batchId) => buildCliBatchCompletionOp(args.store, plan.dialogId, batchId)
14726
+ )
14727
+ );
14728
+ plan.ops.push(...completionOps);
14329
14729
  }
14330
14730
  await args.store.batch(plan.ops);
14331
14731
  if (__perfEnabled) {
@@ -14366,7 +14766,7 @@ async function writeDialog(args) {
14366
14766
  dialogId: plan.dialogId,
14367
14767
  userId: args.userId,
14368
14768
  persistedUserMessageIds: plan.captureUserMessageIds,
14369
- read: (key) => args.store.read(key, { remote: false })
14769
+ read: (key) => prefetchedUserMessages.has(key) ? Promise.resolve(prefetchedUserMessages.get(key)) : args.store.read(key, { remote: false })
14370
14770
  }).catch(() => []);
14371
14771
  const syncAndCapture = async (fetchImpl) => {
14372
14772
  try {
@@ -14451,12 +14851,14 @@ async function loadCliDialogSummary(args) {
14451
14851
  const sourceHash = record.sourceHash;
14452
14852
  const sourceCount = record.sourceCount;
14453
14853
  const schemaVersion = record.schemaVersion;
14854
+ const sourceSegments = sanitizeSummarySourceSegments(record.sourceSegments);
14454
14855
  return {
14455
14856
  summary,
14456
14857
  ...typeof summarizedBeforeId === "string" && summarizedBeforeId ? { summarizedBeforeId } : {},
14457
14858
  ...typeof sourceHash === "string" && sourceHash ? { sourceHash } : {},
14458
14859
  ...typeof sourceCount === "number" && sourceCount > 0 ? { sourceCount } : {},
14459
14860
  ..."schemaVersion" in record ? { schemaVersion } : {},
14861
+ ...sourceSegments ? { sourceSegments } : {},
14460
14862
  ...Array.isArray(record.referenceKeys) ? { referenceKeys: record.referenceKeys.filter((key) => typeof key === "string") } : {}
14461
14863
  };
14462
14864
  }
@@ -14465,6 +14867,7 @@ async function saveCliDialogSummary(args) {
14465
14867
  const existing = await args.store.read(dialogKey) ?? {};
14466
14868
  const bareId = typeof existing.id === "string" && existing.id ? existing.id : args.dialogId.startsWith("dialog-") ? dialogIdFromKey(dialogKey) : args.dialogId;
14467
14869
  const compressionCount = typeof existing.compressionCount === "number" ? existing.compressionCount + 1 : 1;
14870
+ const sanitizedSourceSegments = sanitizeSummarySourceSegments(args.sourceSegments);
14468
14871
  await registerDialogOwner({
14469
14872
  store: { get: (key) => args.store.read(key, { remote: false }), put: (key, value) => args.store.write(key, value) },
14470
14873
  dialogId: bareId,
@@ -14482,6 +14885,7 @@ async function saveCliDialogSummary(args) {
14482
14885
  ...args.sourceHash !== void 0 ? { sourceHash: args.sourceHash } : {},
14483
14886
  ...args.sourceCount !== void 0 ? { sourceCount: args.sourceCount } : {},
14484
14887
  ...args.schemaVersion !== void 0 ? { schemaVersion: args.schemaVersion } : {},
14888
+ ...sanitizedSourceSegments !== void 0 ? { sourceSegments: sanitizedSourceSegments } : {},
14485
14889
  referenceKeys: Array.from(/* @__PURE__ */ new Set([
14486
14890
  ...Array.isArray(existing.referenceKeys) ? existing.referenceKeys.filter((key) => typeof key === "string") : [],
14487
14891
  ...args.referenceKeys ?? []
@@ -14939,15 +15343,15 @@ function createCliLocalRuntimeAdapter(deps) {
14939
15343
  const runId = asOptionalTrimmedString(deps.env?.NOLO_AGENT_RUN_ID) ?? "interactive";
14940
15344
  emitRunIsolationNotice(fact, { runId });
14941
15345
  try {
14942
- const { writeFileSync: writeFileSync4, mkdirSync: mkdirSync4 } = await import("node:fs");
14943
- const { resolveRunsDir: resolveRunsDir2 } = await import("./agentRunControl-VBL7UFSG.js");
15346
+ const { writeFileSync: writeFileSync4, mkdirSync: mkdirSync5 } = await import("node:fs");
15347
+ const { resolveRunsDir: resolveRunsDir2 } = await import("./agentRunControl-55GL6Q3M.js");
14944
15348
  recordLocalRunExecutionIsolation({
14945
15349
  runId,
14946
15350
  runsDir: resolveRunsDir2(deps.env),
14947
15351
  fact,
14948
15352
  fs: {
14949
15353
  writeFileSync: (path, data) => writeFileSync4(path, data),
14950
- mkdirSync: (path, options) => mkdirSync4(path, options)
15354
+ mkdirSync: (path, options) => mkdirSync5(path, options)
14951
15355
  }
14952
15356
  });
14953
15357
  getLogger("cli.localRuntimeAdapter").info(
@@ -14965,7 +15369,7 @@ function createCliLocalRuntimeAdapter(deps) {
14965
15369
  dockerWorkloadReleased = true;
14966
15370
  dockerWorkloadLoad = null;
14967
15371
  if (loaded) {
14968
- const { resolveRunsDir: resolveRunsDir2 } = await import("./agentRunControl-VBL7UFSG.js");
15372
+ const { resolveRunsDir: resolveRunsDir2 } = await import("./agentRunControl-55GL6Q3M.js");
14969
15373
  const exportRunDiff = deps.exportDockerRunDiffArtifact ?? exportDockerRunDiffArtifact;
14970
15374
  const warn = (message) => process.stderr.write(`[nolo] ${message}
14971
15375
  `);
@@ -15046,7 +15450,6 @@ function createCliLocalRuntimeAdapter(deps) {
15046
15450
  }
15047
15451
  };
15048
15452
  let runtimeToolExecutionLimits = {};
15049
- const skillPolicyFingerprint = (source) => JSON.stringify(Object.entries(resolveAgentSkillConfig(source)).sort(([a], [b]) => a.localeCompare(b)));
15050
15453
  let reviewAgentConfig;
15051
15454
  let planningCaller = {};
15052
15455
  const isCanonicalAutoReviewAdmitted = (visits) => {
@@ -15066,6 +15469,10 @@ function createCliLocalRuntimeAdapter(deps) {
15066
15469
  readXPost: deps.readXPost,
15067
15470
  readXhsProfile: deps.readXhsProfile,
15068
15471
  cliEntrypoint: CLI_ENTRYPOINT,
15472
+ // 本地进程内直连:readDialog / listDialogs 走已在手的共享 store
15473
+ // (local-first,未命中才远端回退),不再 spawn `nolo` 子进程 + 试探
15474
+ // 多个 HTTP 端点;本地答不了时 executor 内部自行回退 CLI 桥。
15475
+ resolveDialogStore: () => getOrCreateSharedStore(deps),
15069
15476
  resolveAgentCredentialGroup,
15070
15477
  resolveAgentDisplayName,
15071
15478
  // α:spawn 前从 agent 配置回读真实 name(resolveAgentRunName 的读取来源)。
@@ -15283,7 +15690,17 @@ function createCliLocalRuntimeAdapter(deps) {
15283
15690
  const cached = deps.pastedTextStore ? void 0 : preparedAgentRuntimeCache.get(cacheKey);
15284
15691
  if (cached) {
15285
15692
  const localRecord = await sharedStore.read(cached.agentConfig.key, { remote: false }).catch(() => null);
15286
- const unchanged = !localRecord || cached.localAgentSkillFingerprint !== void 0 && cached.localAgentSkillFingerprint === skillPolicyFingerprint(localRecord);
15693
+ const effectiveLocalRecord = localRecord && typeof localRecord === "object" ? applyBuiltinAgentRuntimeOverride(
15694
+ agentRef,
15695
+ resolveAgentRuntimeConfigFromRecord(
15696
+ cached.agentConfig.key,
15697
+ applyPublicAgentCatalogOverride(
15698
+ localRecord,
15699
+ cached.agentConfig.key
15700
+ )
15701
+ )
15702
+ ).rawRecord : null;
15703
+ const unchanged = !localRecord || cached.localAgentConfigFingerprint !== void 0 && effectiveLocalRecord != null && cached.localAgentConfigFingerprint === buildLocalAgentConfigFingerprint(effectiveLocalRecord);
15287
15704
  if (!unchanged) preparedAgentRuntimeCache.delete(cacheKey);
15288
15705
  if (unchanged) {
15289
15706
  activeAgentToolNames = cached.activeAgentToolNames;
@@ -15371,7 +15788,9 @@ function createCliLocalRuntimeAdapter(deps) {
15371
15788
  if (exposedAgentConfig && !deps.pastedTextStore) {
15372
15789
  preparedAgentRuntimeCache.set(cacheKey, {
15373
15790
  agentConfig: exposedAgentConfig,
15374
- localAgentSkillFingerprint: skillPolicyFingerprint(exposedAgentConfig.rawRecord),
15791
+ localAgentConfigFingerprint: buildLocalAgentConfigFingerprint(
15792
+ exposedAgentConfig.rawRecord
15793
+ ),
15375
15794
  activeAgentToolNames,
15376
15795
  runtimeToolExecutionLimits
15377
15796
  });
@@ -15418,6 +15837,7 @@ function createCliLocalRuntimeAdapter(deps) {
15418
15837
  sourceHash: input.sourceHash,
15419
15838
  sourceCount: input.sourceCount,
15420
15839
  schemaVersion: input.schemaVersion,
15840
+ ...input.sourceSegments !== void 0 ? { sourceSegments: input.sourceSegments } : {},
15421
15841
  referenceKeys: input.referenceKeys
15422
15842
  }),
15423
15843
  loadLastContextUsage: async (dialogId) => {
@@ -15890,14 +16310,14 @@ export {
15890
16310
  readTimestamp,
15891
16311
  parseAgentRunEvent,
15892
16312
  isLiveAgentRunObservation,
15893
- isSubtaskRun,
15894
- RUN_WAKE_CHANNEL_ENV,
15895
16313
  createOriginShellGrant,
16314
+ createCliHybridRecordStore,
15896
16315
  preparedAgentRuntimeCache,
15897
16316
  hybridStoreCache,
15898
16317
  normalizeRuntimeCacheCwd,
15899
16318
  buildPreparedAgentCacheKey,
15900
16319
  clearCliLocalRuntimePreparedAgentCache,
16320
+ buildLocalAgentConfigFingerprint,
15901
16321
  defaultLocalRuntimeDb,
15902
16322
  createFallbackId,
15903
16323
  logLocalRuntimeDiagnostic,