nolo-cli 0.108.0-alpha.1 → 0.108.0

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 (608) hide show
  1. package/README.md +1 -1
  2. package/{_executeModel-GTYLDSJW.js → _executeModel-RVAKYU4J.js} +128 -83
  3. package/action-RHUT4OHH.js +23 -0
  4. package/{addContentAction-MB2HHMDZ.js → addContentAction-BQ3LJLUW.js} +19 -13
  5. package/{addDialogAgentAction-MCEABSBA.js → addDialogAgentAction-B6X7BXR4.js} +24 -20
  6. package/{agentDeleteCommand-OWYHN6D6.js → agentDeleteCommand-T5MDAOE7.js} +154 -67
  7. package/{agentEmailCommands-C6J2KUL2.js → agentEmailCommands-UWBQSKLI.js} +125 -104
  8. package/{agentGrantCommands-M3XFO6EN.js → agentGrantCommands-HOJ3JBBQ.js} +3 -3
  9. package/agentListCommands-2Q456VYS.js +800 -0
  10. package/{agentMachineCommands-UDEXV472.js → agentMachineCommands-FPJJ4DCF.js} +54 -57
  11. package/{agentProviderCommands-GNPTL5XR.js → agentProviderCommands-7PCGR77I.js} +97 -2
  12. package/{agentPullCommand-O5MPVJ5E.js → agentPullCommand-7GCDM4BK.js} +7 -7
  13. package/agentRecordCommands-3JGDR4NN.js +149 -0
  14. package/agentRunCommand-3NQOP3SD.js +179 -0
  15. package/{agentRunControl-AVJR4JW4.js → agentRunControl-2CDZNHXV.js} +10 -2
  16. package/{agentRuntimeLocal-KCMC2TBD.js → agentRuntimeLocal-SQUDRZWE.js} +42 -46
  17. package/{agentSlice-TNH7BSUC.js → agentSlice-R4W6MCEW.js} +22 -16
  18. package/{appDeleteCommands-JEPA3EWE.js → appDeleteCommands-CLLYGEBC.js} +55 -55
  19. package/{appDeployCommands-UTB76XFM.js → appDeployCommands-HY2NBNDQ.js} +64 -59
  20. package/{appDeployStatusCommands-LGHF2SBD.js → appDeployStatusCommands-SGO5GEXH.js} +53 -52
  21. package/{appGetCommands-PX2BFHOB.js → appGetCommands-ZPYK2N5D.js} +53 -52
  22. package/{appListCommands-BSMPTWKC.js → appListCommands-O2BHIMKS.js} +54 -55
  23. package/{authCommand-YW42YZA4.js → authCommand-GUIREPHK.js} +213 -72
  24. package/{authCommands-RGOGCPP6.js → authCommands-K3BDSTJ4.js} +10 -7
  25. package/{builtinSkillRegistry-FUAVTRVZ.js → builtinSkillRegistry-MUOUTRNJ.js} +13 -10
  26. package/{chromeCommands-FZYAU75D.js → chromeCommands-Z2WRJB7O.js} +290 -38
  27. package/{chromeOpsCommands-62P2Q2YB.js → chromeOpsCommands-YWYXZTIR.js} +157 -23
  28. package/{chunk-RRPWH4LX.js → chunk-26UZ2Y4Z.js} +26 -31
  29. package/{chunk-2F7RJC6L.js → chunk-2C47W7IJ.js} +1 -1
  30. package/{chunk-VLTIYV3X.js → chunk-2ECUZDEL.js} +37 -11
  31. package/{chunk-ALXHV7NK.js → chunk-2GGXHQIW.js} +43 -4
  32. package/{chunk-AHAHBQMU.js → chunk-2OMUAIKR.js} +2 -2
  33. package/{chunk-DHDMC6FO.js → chunk-3CZM6HGQ.js} +53 -23
  34. package/{chunk-BNGW5ASC.js → chunk-3LI5UCTU.js} +23 -3
  35. package/{chunk-FDTR4QJ6.js → chunk-3MZAGMYY.js} +48 -1
  36. package/chunk-3PVYUPXK.js +40 -0
  37. package/chunk-3SK3J3IF.js +929 -0
  38. package/chunk-4LCOCOR5.js +50 -0
  39. package/{chunk-V7E4PXQD.js → chunk-4MSYSHZD.js} +15 -7
  40. package/{chunk-2GRGFCF6.js → chunk-4VJAC32I.js} +2 -1
  41. package/{chunk-MP64VFGD.js → chunk-4XEYAFLY.js} +60 -18
  42. package/chunk-4YRTZIVN.js +871 -0
  43. package/{chunk-MC4XLIJ7.js → chunk-523DITKR.js} +1 -1
  44. package/{chunk-N7J63Q6C.js → chunk-56GBUMO5.js} +10 -1
  45. package/chunk-5MMAK75Q.js +15 -0
  46. package/{chunk-XT35TTFG.js → chunk-5WLADF62.js} +90 -36
  47. package/chunk-5XN3OSCT.js +164 -0
  48. package/chunk-6CCAXGFK.js +1712 -0
  49. package/{chunk-42V6BK2E.js → chunk-6MXDOUMH.js} +18 -36
  50. package/{chunk-QOKAKDPE.js → chunk-6Q7UTJKR.js} +6 -94
  51. package/{chunk-J4MOO56S.js → chunk-6VRWNU5J.js} +10 -2
  52. package/{chunk-GEPUP7OO.js → chunk-726TCFLQ.js} +5 -5
  53. package/chunk-7DPNBQSV.js +9 -0
  54. package/chunk-7YVPCIEN.js +1858 -0
  55. package/{chunk-AEOE4Z6Q.js → chunk-A337PRRR.js} +41 -17
  56. package/chunk-AGIM7IMJ.js +147 -0
  57. package/{chunk-ABQYVJBJ.js → chunk-AIZE5TDM.js} +3 -3
  58. package/{chunk-GPCZ7UXG.js → chunk-ALKCVCA5.js} +4 -4
  59. package/{chunk-5UTFL4QJ.js → chunk-APO5TOXO.js} +1 -1
  60. package/{chunk-E4MARS3Q.js → chunk-AU7AXHUL.js} +1 -1
  61. package/{chunk-PBA4UJBK.js → chunk-BFYDNHYW.js} +12 -12
  62. package/{chunk-QTGQ2LTL.js → chunk-BIAETTOB.js} +5 -9
  63. package/{chunk-OIVSQH2O.js → chunk-CGEK73JN.js} +311 -12
  64. package/chunk-CHOZJMJS.js +78 -0
  65. package/{chunk-GBRG75BQ.js → chunk-D2MDMY2M.js} +1 -0
  66. package/chunk-DGDGNYI5.js +593 -0
  67. package/{chunk-TRV2MIDW.js → chunk-EXAJ6DCR.js} +1 -0
  68. package/{chunk-PVZT43MU.js → chunk-EXR4XCFE.js} +17 -15
  69. package/chunk-EYLGAEB4.js +784 -0
  70. package/{chunk-3BMYXEUW.js → chunk-F2UJW3EK.js} +1 -1
  71. package/{chunk-P5EVSOPA.js → chunk-FWY6BHIJ.js} +363 -248
  72. package/{chunk-4MK3I7Y4.js → chunk-G23MQWLJ.js} +7 -128
  73. package/chunk-G6OOUQWJ.js +417 -0
  74. package/{chunk-WV42OMV7.js → chunk-GHZ2H2HJ.js} +11 -15
  75. package/chunk-GMZLP5DV.js +82 -0
  76. package/chunk-I42VC5KR.js +15 -0
  77. package/{chunk-GO3Z72MT.js → chunk-IFALJPEX.js} +71 -99
  78. package/{chunk-O6OSWFZQ.js → chunk-IHPDK6UD.js} +6 -0
  79. package/{chunk-UKWGR5SS.js → chunk-IJERIUXS.js} +242 -1146
  80. package/chunk-IRG4OKY6.js +843 -0
  81. package/{chunk-TYYSADX4.js → chunk-IUTHWIZQ.js} +269 -141
  82. package/{chunk-QDSINZM3.js → chunk-IXH3HKY2.js} +1 -22
  83. package/chunk-JJM3WS6W.js +132 -0
  84. package/{chunk-R7RHOSZU.js → chunk-KN6MKCS5.js} +1733 -465
  85. package/{chunk-SH43IESU.js → chunk-KQ7DAEZ7.js} +202 -32
  86. package/{chunk-6OZ36FXI.js → chunk-KY6GPQ7O.js} +36 -12
  87. package/{chunk-MRIHM22T.js → chunk-LAVSW2C2.js} +77 -144
  88. package/{chunk-NA35QHCF.js → chunk-LNEKN523.js} +10 -7
  89. package/chunk-LWLNLZC5.js +265 -0
  90. package/{chunk-I3TQJXQ7.js → chunk-MHD5JBSS.js} +131 -10
  91. package/{chunk-KQ4ONNQD.js → chunk-MW533QT3.js} +190 -8
  92. package/{chunk-62CATUYY.js → chunk-NLEJWKF5.js} +10532 -9444
  93. package/{chunk-BFU6C242.js → chunk-NMFV26UG.js} +1 -1
  94. package/{chunk-GQBOR3G6.js → chunk-NN4UUYGB.js} +18 -4
  95. package/{chunk-FZGV4FGK.js → chunk-NUHHBEJC.js} +378 -187
  96. package/chunk-OKARGYFT.js +15 -0
  97. package/{chunk-KQHGZWSV.js → chunk-OXME3PEE.js} +1 -1
  98. package/{chunk-53HEEOTT.js → chunk-OYBAT7RT.js} +113 -17
  99. package/chunk-P3SFAHIL.js +134 -0
  100. package/{chunk-7U6P3PHS.js → chunk-P6KLYCL3.js} +310 -95
  101. package/{chunk-XD2MJFUG.js → chunk-PBGO5AFD.js} +1 -1
  102. package/{chunk-EYAQT56M.js → chunk-PFEK4SA2.js} +13 -10
  103. package/{chunk-Z77CRGTW.js → chunk-PHHFVGOJ.js} +1 -1
  104. package/{chunk-3VNWWVKB.js → chunk-PJNFNEJE.js} +114 -28
  105. package/{chunk-RRM7AJ3M.js → chunk-PS6XSDHW.js} +35 -30
  106. package/{chunk-HVURBGF3.js → chunk-PWRS2SU2.js} +27 -9
  107. package/chunk-QFEW2ULV.js +42 -0
  108. package/chunk-QH2QSBGP.js +7546 -0
  109. package/{chunk-IIVGDG4I.js → chunk-QLQ573SU.js} +124 -77
  110. package/chunk-QQ56R7KS.js +88 -0
  111. package/chunk-QYPE3TS3.js +43 -0
  112. package/{chunk-VMFTFOWF.js → chunk-RLRYVSCD.js} +31 -14
  113. package/{chunk-VRTTFDBM.js → chunk-RNNWTMKT.js} +56 -63
  114. package/chunk-ROXFUKKL.js +13941 -0
  115. package/{chunk-DUK4OQNO.js → chunk-RRPT5CGT.js} +124 -703
  116. package/{chunk-JRQFUXY7.js → chunk-RRQQAG7W.js} +93 -24
  117. package/chunk-SJ3QFSQS.js +1147 -0
  118. package/chunk-SP4WCECG.js +95 -0
  119. package/{chunk-Q67DOFOO.js → chunk-SZC4REES.js} +212 -105
  120. package/{chunk-BYMV6QZG.js → chunk-TNIX77YM.js} +4 -0
  121. package/{chunk-UZGQNTVW.js → chunk-TSBCYK5F.js} +10 -8
  122. package/chunk-TY3TIUJK.js +89 -0
  123. package/chunk-U4STABYN.js +81 -0
  124. package/chunk-UEILX4EV.js +15 -0
  125. package/{chunk-YYLHWIW6.js → chunk-UKZX3NHN.js} +1 -1
  126. package/{chunk-EEGDMATE.js → chunk-UPFOOGHU.js} +90 -79
  127. package/{chunk-7S4YWN7P.js → chunk-V2UPLOXT.js} +4 -4
  128. package/{chunk-PQFHGD77.js → chunk-V5DCOM6G.js} +185 -16
  129. package/{chunk-LS2ZANRJ.js → chunk-V6WXGTUJ.js} +1 -1
  130. package/{chunk-6YTOJY35.js → chunk-VBG7GWWR.js} +253 -8
  131. package/{chunk-DVINR3PL.js → chunk-VEA7H5FG.js} +3 -3
  132. package/chunk-VIWDGTDA.js +8 -0
  133. package/chunk-VJVNU77E.js +83 -0
  134. package/{chunk-EADNWBAZ.js → chunk-VP3BINY7.js} +13 -0
  135. package/{chunk-HKNXJGEC.js → chunk-VSPO4S33.js} +47 -192
  136. package/{chunk-ETI2NYVF.js → chunk-W2N3ZC4P.js} +7 -7
  137. package/{chunk-EOARMOVD.js → chunk-W4S6OTSC.js} +6 -3
  138. package/{chunk-6Z7MY3V7.js → chunk-WCQNEMXG.js} +3 -3
  139. package/chunk-WJZOQR2J.js +151 -0
  140. package/{chunk-L7OXGGBN.js → chunk-WVES4PHL.js} +69 -57
  141. package/{chunk-BFDFRLLQ.js → chunk-WW2USJ3C.js} +3 -3
  142. package/{chunk-QWL5QZGU.js → chunk-X2VPXJZC.js} +20 -11
  143. package/chunk-X5BIY654.js +29 -0
  144. package/{chunk-Q554LLSI.js → chunk-XETG4RIX.js} +5 -5
  145. package/{chunk-3L2WKC3W.js → chunk-XPWGOTBQ.js} +8 -1
  146. package/{chunk-JEDZAO7L.js → chunk-YBNHPX4S.js} +257 -37
  147. package/{chunk-JPGCXHNM.js → chunk-YLMMECCH.js} +1 -1
  148. package/{chunk-CSC3CU4K.js → chunk-YSZQSZR2.js} +61 -11
  149. package/{chunk-6D6VBVEW.js → chunk-YVTZMLXZ.js} +96 -25
  150. package/{chunk-AG2AZ6GX.js → chunk-YZZLKXCQ.js} +1449 -1094
  151. package/chunk-ZRAU6T47.js +56 -0
  152. package/{chunk-ONXOABJR.js → chunk-ZWQUWF6W.js} +36 -1
  153. package/{cliExecutor-HG3S345O.js → cliExecutor-AWYR3T33.js} +1 -1
  154. package/commandRegistry-C25O2ARU.js +839 -0
  155. package/contentThunks-UWODFKX6.js +83 -0
  156. package/{cooldownCommands-REAWYVTY.js → cooldownCommands-JFKTYS2D.js} +2 -2
  157. package/{createAgentAutomationAction-OBH7GPW5.js → createAgentAutomationAction-SA4IA4CR.js} +51 -43
  158. package/createDialogAction-EDK5IMRG.js +75 -0
  159. package/{createPageAction-JJ7UUTWC.js → createPageAction-VYVF5EIZ.js} +60 -51
  160. package/{chunk-BVGTK7MR.js → cursorProvider-YGGNMVWX.js} +2751 -10185
  161. package/{dbSlice-A6C6H32X.js → dbSlice-JQFBMJ55.js} +18 -12
  162. package/{deleteFile-YG6QMJLU.js → deleteFile-6JWDDRVP.js} +9 -5
  163. package/dialogCommands-K734RXEQ.js +108 -0
  164. package/{dialogSlice-6Z2BPC3T.js → dialogSlice-EEDP6PJ3.js} +66 -41
  165. package/{dist-VODFSGNG.js → dist-NJC2W7I4.js} +61 -54
  166. package/{docCreateCommands-WRG2JLGM.js → docCreateCommands-N3KPGP4A.js} +51 -53
  167. package/{docDeleteCommands-SHWJIBJS.js → docDeleteCommands-4CR4TXZ7.js} +53 -54
  168. package/{docReadCommands-WJN3WT6O.js → docReadCommands-62XK57VS.js} +50 -52
  169. package/{docStore-7WUS6XXX.js → docStore-RB7YBD4Y.js} +24 -15
  170. package/{docUpdateCommands-IE32IL6O.js → docUpdateCommands-DRAAWIDC.js} +51 -53
  171. package/{fetchMessages-EIU7UFFK.js → fetchMessages-LM6OMMQQ.js} +5 -4
  172. package/{getPricing-LUSEABA6.js → getPricing-XDF4OLTC.js} +6 -6
  173. package/handleSendMessageAction-TYDPIC6O.js +1849 -0
  174. package/index.js +91 -884
  175. package/{lib-FRRS27KN.js → lib-PU2G2MSO.js} +523 -191
  176. package/{localDialogRead-BTFJ4V2I.js → localDialogRead-BOETO2TD.js} +2 -2
  177. package/localRuntimeAdapter-VYB2QTU3.js +239 -0
  178. package/{localRuntimeAuthority-6IR6BBXE.js → localRuntimeAuthority-YSE6NH7B.js} +12 -9
  179. package/{localRuntimeDb-SYQGUF4U.js → localRuntimeDb-7FBKDEQY.js} +1 -1
  180. package/{machineCommands-KSN4COGR.js → machineCommands-IQRRLSYP.js} +493 -151
  181. package/machineWsRunDispatch-LIMM5CYE.js +164 -0
  182. package/{memberThunks-P2ECUJ56.js → memberThunks-Y3Q7GZTG.js} +24 -17
  183. package/{models-T3SG6MJ5.js → models-6V4ZCHEE.js} +2 -2
  184. package/node_modules/abstract-level/CHANGELOG.md +150 -0
  185. package/node_modules/abstract-level/LICENSE +21 -0
  186. package/node_modules/abstract-level/README.md +1957 -0
  187. package/node_modules/abstract-level/UPGRADING.md +669 -0
  188. package/node_modules/abstract-level/abstract-chained-batch.js +397 -0
  189. package/node_modules/abstract-level/abstract-iterator.js +404 -0
  190. package/node_modules/abstract-level/abstract-level.js +1127 -0
  191. package/node_modules/abstract-level/abstract-snapshot.js +84 -0
  192. package/node_modules/abstract-level/index.d.ts +52 -0
  193. package/node_modules/abstract-level/index.js +9 -0
  194. package/node_modules/abstract-level/lib/abstract-sublevel-iterator.js +141 -0
  195. package/node_modules/abstract-level/lib/abstract-sublevel.js +290 -0
  196. package/node_modules/abstract-level/lib/common.js +33 -0
  197. package/node_modules/abstract-level/lib/default-chained-batch.js +29 -0
  198. package/node_modules/abstract-level/lib/default-kv-iterator.js +74 -0
  199. package/node_modules/abstract-level/lib/deferred-iterator.js +110 -0
  200. package/node_modules/abstract-level/lib/deferred-queue.js +84 -0
  201. package/node_modules/abstract-level/lib/errors.js +21 -0
  202. package/node_modules/abstract-level/lib/event-monitor.js +30 -0
  203. package/node_modules/abstract-level/lib/hooks.js +78 -0
  204. package/node_modules/abstract-level/lib/prefixes.js +21 -0
  205. package/node_modules/abstract-level/lib/prewrite-batch.js +96 -0
  206. package/node_modules/abstract-level/lib/range-options.js +26 -0
  207. package/node_modules/abstract-level/package.json +66 -0
  208. package/node_modules/abstract-level/test/async-iterator-test.js +132 -0
  209. package/node_modules/abstract-level/test/batch-test.js +214 -0
  210. package/node_modules/abstract-level/test/chained-batch-test.js +315 -0
  211. package/node_modules/abstract-level/test/clear-range-test.js +262 -0
  212. package/node_modules/abstract-level/test/clear-test.js +110 -0
  213. package/node_modules/abstract-level/test/common.js +90 -0
  214. package/node_modules/abstract-level/test/deferred-open-test.js +209 -0
  215. package/node_modules/abstract-level/test/del-test.js +65 -0
  216. package/node_modules/abstract-level/test/encoding-buffer-test.js +336 -0
  217. package/node_modules/abstract-level/test/encoding-custom-test.js +92 -0
  218. package/node_modules/abstract-level/test/encoding-decode-error-test.js +85 -0
  219. package/node_modules/abstract-level/test/encoding-json-test.js +75 -0
  220. package/node_modules/abstract-level/test/encoding-test.js +130 -0
  221. package/node_modules/abstract-level/test/events/write.js +132 -0
  222. package/node_modules/abstract-level/test/factory-test.js +36 -0
  223. package/node_modules/abstract-level/test/get-many-test.js +157 -0
  224. package/node_modules/abstract-level/test/get-sync-test.js +61 -0
  225. package/node_modules/abstract-level/test/get-test.js +83 -0
  226. package/node_modules/abstract-level/test/has-many-test.js +144 -0
  227. package/node_modules/abstract-level/test/has-test.js +81 -0
  228. package/node_modules/abstract-level/test/hooks/newsub.js +57 -0
  229. package/node_modules/abstract-level/test/hooks/postopen.js +229 -0
  230. package/node_modules/abstract-level/test/hooks/prewrite.js +816 -0
  231. package/node_modules/abstract-level/test/hooks/shared.js +38 -0
  232. package/node_modules/abstract-level/test/index.js +86 -0
  233. package/node_modules/abstract-level/test/iterator-explicit-snapshot-test.js +393 -0
  234. package/node_modules/abstract-level/test/iterator-no-snapshot-test.js +49 -0
  235. package/node_modules/abstract-level/test/iterator-range-test.js +277 -0
  236. package/node_modules/abstract-level/test/iterator-seek-test.js +335 -0
  237. package/node_modules/abstract-level/test/iterator-snapshot-test.js +56 -0
  238. package/node_modules/abstract-level/test/iterator-test.js +621 -0
  239. package/node_modules/abstract-level/test/manifest-test.js +21 -0
  240. package/node_modules/abstract-level/test/open-create-if-missing-test.js +39 -0
  241. package/node_modules/abstract-level/test/open-error-if-exists-test.js +25 -0
  242. package/node_modules/abstract-level/test/open-test.js +263 -0
  243. package/node_modules/abstract-level/test/put-get-del-test.js +97 -0
  244. package/node_modules/abstract-level/test/put-test.js +70 -0
  245. package/node_modules/abstract-level/test/self/abstract-iterator-test.js +182 -0
  246. package/node_modules/abstract-level/test/self/async-iterator-test.js +242 -0
  247. package/node_modules/abstract-level/test/self/attach-resource-test.js +74 -0
  248. package/node_modules/abstract-level/test/self/defer-test.js +140 -0
  249. package/node_modules/abstract-level/test/self/deferred-iterator-test.js +314 -0
  250. package/node_modules/abstract-level/test/self/deferred-operations-test.js +86 -0
  251. package/node_modules/abstract-level/test/self/deferred-queue-test.js +93 -0
  252. package/node_modules/abstract-level/test/self/encoding-test.js +391 -0
  253. package/node_modules/abstract-level/test/self/errors-test.js +11 -0
  254. package/node_modules/abstract-level/test/self/iterator-test.js +1050 -0
  255. package/node_modules/abstract-level/test/self/sublevel-test.js +1039 -0
  256. package/node_modules/abstract-level/test/self.js +905 -0
  257. package/node_modules/abstract-level/test/sublevel-test.js +209 -0
  258. package/node_modules/abstract-level/test/traits/closed.js +42 -0
  259. package/node_modules/abstract-level/test/traits/index.js +4 -0
  260. package/node_modules/abstract-level/test/traits/open.js +62 -0
  261. package/node_modules/abstract-level/test/util.js +275 -0
  262. package/node_modules/abstract-level/types/abstract-chained-batch.d.ts +124 -0
  263. package/node_modules/abstract-level/types/abstract-iterator.d.ts +241 -0
  264. package/node_modules/abstract-level/types/abstract-level.d.ts +636 -0
  265. package/node_modules/abstract-level/types/abstract-snapshot.d.ts +30 -0
  266. package/node_modules/abstract-level/types/abstract-sublevel.d.ts +76 -0
  267. package/node_modules/abstract-level/types/interfaces.d.ts +43 -0
  268. package/node_modules/base64-js/LICENSE +21 -0
  269. package/node_modules/base64-js/README.md +34 -0
  270. package/node_modules/base64-js/base64js.min.js +1 -0
  271. package/node_modules/base64-js/index.d.ts +3 -0
  272. package/node_modules/base64-js/index.js +150 -0
  273. package/node_modules/base64-js/package.json +47 -0
  274. package/node_modules/browser-level/CHANGELOG.md +44 -0
  275. package/node_modules/browser-level/LICENSE +21 -0
  276. package/node_modules/browser-level/README.md +124 -0
  277. package/node_modules/browser-level/UPGRADING.md +143 -0
  278. package/node_modules/browser-level/index.d.ts +108 -0
  279. package/node_modules/browser-level/index.js +323 -0
  280. package/node_modules/browser-level/iterator.js +239 -0
  281. package/node_modules/browser-level/package.json +48 -0
  282. package/node_modules/browser-level/util/clear.js +38 -0
  283. package/node_modules/browser-level/util/deserialize.js +17 -0
  284. package/node_modules/browser-level/util/key-range.js +20 -0
  285. package/node_modules/buffer/AUTHORS.md +73 -0
  286. package/node_modules/buffer/LICENSE +21 -0
  287. package/node_modules/buffer/README.md +410 -0
  288. package/node_modules/buffer/index.d.ts +194 -0
  289. package/node_modules/buffer/index.js +2106 -0
  290. package/node_modules/buffer/package.json +93 -0
  291. package/node_modules/classic-level/CHANGELOG.md +115 -0
  292. package/node_modules/classic-level/LICENSE +21 -0
  293. package/node_modules/classic-level/README.md +274 -0
  294. package/node_modules/classic-level/UPGRADING.md +131 -0
  295. package/node_modules/classic-level/binding.cc +2652 -0
  296. package/node_modules/classic-level/binding.gyp +71 -0
  297. package/node_modules/classic-level/binding.js +1 -0
  298. package/node_modules/classic-level/chained-batch.js +35 -0
  299. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/LICENSE +27 -0
  300. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/Makefile +424 -0
  301. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/build_detect_platform +256 -0
  302. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/autocompact_test.cc +118 -0
  303. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/builder.cc +88 -0
  304. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/builder.h +34 -0
  305. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/c.cc +595 -0
  306. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/c_test.c +390 -0
  307. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/corruption_test.cc +374 -0
  308. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/db_bench.cc +1020 -0
  309. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/db_impl.cc +1568 -0
  310. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/db_impl.h +212 -0
  311. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/db_iter.cc +317 -0
  312. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/db_iter.h +28 -0
  313. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/db_test.cc +2158 -0
  314. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/dbformat.cc +140 -0
  315. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/dbformat.h +230 -0
  316. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/dbformat_test.cc +112 -0
  317. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/dumpfile.cc +225 -0
  318. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/fault_injection_test.cc +554 -0
  319. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/filename.cc +144 -0
  320. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/filename.h +85 -0
  321. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/filename_test.cc +123 -0
  322. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/leveldbutil.cc +64 -0
  323. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/log_format.h +35 -0
  324. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/log_reader.cc +284 -0
  325. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/log_reader.h +113 -0
  326. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/log_test.cc +591 -0
  327. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/log_writer.cc +112 -0
  328. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/log_writer.h +54 -0
  329. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/memtable.cc +145 -0
  330. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/memtable.h +89 -0
  331. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/recovery_test.cc +324 -0
  332. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/repair.cc +461 -0
  333. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/skiplist.h +384 -0
  334. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/skiplist_test.cc +378 -0
  335. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/snapshot.h +67 -0
  336. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/table_cache.cc +127 -0
  337. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/table_cache.h +61 -0
  338. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/version_edit.cc +266 -0
  339. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/version_edit.h +107 -0
  340. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/version_edit_test.cc +46 -0
  341. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/version_set.cc +1535 -0
  342. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/version_set.h +399 -0
  343. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/version_set_test.cc +179 -0
  344. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/write_batch.cc +147 -0
  345. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/write_batch_internal.h +50 -0
  346. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/write_batch_test.cc +120 -0
  347. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/helpers/memenv/memenv.cc +398 -0
  348. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/helpers/memenv/memenv.h +20 -0
  349. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/helpers/memenv/memenv_test.cc +241 -0
  350. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/include/leveldb/c.h +290 -0
  351. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/include/leveldb/cache.h +110 -0
  352. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/include/leveldb/comparator.h +63 -0
  353. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/include/leveldb/db.h +164 -0
  354. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/include/leveldb/dumpfile.h +25 -0
  355. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/include/leveldb/env.h +351 -0
  356. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/include/leveldb/filter_policy.h +70 -0
  357. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/include/leveldb/iterator.h +100 -0
  358. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/include/leveldb/options.h +213 -0
  359. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/include/leveldb/slice.h +109 -0
  360. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/include/leveldb/status.h +112 -0
  361. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/include/leveldb/table.h +85 -0
  362. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/include/leveldb/table_builder.h +92 -0
  363. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/include/leveldb/value_sink.h +26 -0
  364. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/include/leveldb/write_batch.h +64 -0
  365. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/issues/issue178_test.cc +92 -0
  366. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/issues/issue200_test.cc +59 -0
  367. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/port/atomic_pointer.h +242 -0
  368. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/port/port.h +21 -0
  369. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/port/port_example.h +141 -0
  370. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/port/port_posix.cc +53 -0
  371. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/port/port_posix.h +156 -0
  372. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/port/port_posix_sse.cc +129 -0
  373. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/port/thread_annotations.h +60 -0
  374. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/port/win/stdint.h +24 -0
  375. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/table/block.cc +268 -0
  376. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/table/block.h +44 -0
  377. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/table/block_builder.cc +109 -0
  378. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/table/block_builder.h +57 -0
  379. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/table/filter_block.cc +111 -0
  380. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/table/filter_block.h +68 -0
  381. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/table/filter_block_test.cc +128 -0
  382. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/table/format.cc +144 -0
  383. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/table/format.h +108 -0
  384. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/table/iterator.cc +67 -0
  385. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/table/iterator_wrapper.h +66 -0
  386. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/table/merger.cc +197 -0
  387. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/table/merger.h +26 -0
  388. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/table/table.cc +285 -0
  389. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/table/table_builder.cc +270 -0
  390. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/table/table_test.cc +876 -0
  391. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/table/two_level_iterator.cc +182 -0
  392. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/table/two_level_iterator.h +34 -0
  393. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/util/arena.cc +68 -0
  394. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/util/arena.h +68 -0
  395. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/util/arena_test.cc +68 -0
  396. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/util/bloom.cc +95 -0
  397. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/util/bloom_test.cc +162 -0
  398. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/util/cache.cc +405 -0
  399. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/util/cache_test.cc +226 -0
  400. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/util/coding.cc +194 -0
  401. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/util/coding.h +104 -0
  402. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/util/coding_test.cc +196 -0
  403. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/util/comparator.cc +81 -0
  404. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/util/crc32c.cc +350 -0
  405. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/util/crc32c.h +45 -0
  406. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/util/crc32c_test.cc +72 -0
  407. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/util/env.cc +100 -0
  408. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/util/env_posix.cc +695 -0
  409. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/util/env_posix_test.cc +66 -0
  410. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/util/env_posix_test_helper.h +28 -0
  411. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/util/env_test.cc +106 -0
  412. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/util/filter_policy.cc +11 -0
  413. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/util/hash.cc +52 -0
  414. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/util/hash.h +19 -0
  415. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/util/hash_test.cc +54 -0
  416. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/util/histogram.cc +139 -0
  417. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/util/histogram.h +42 -0
  418. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/util/logging.cc +72 -0
  419. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/util/logging.h +43 -0
  420. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/util/mutexlock.h +41 -0
  421. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/util/options.cc +30 -0
  422. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/util/posix_logger.h +98 -0
  423. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/util/random.h +64 -0
  424. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/util/status.cc +75 -0
  425. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/util/testharness.cc +77 -0
  426. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/util/testharness.h +138 -0
  427. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/util/testutil.cc +51 -0
  428. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/util/testutil.h +63 -0
  429. package/node_modules/classic-level/deps/leveldb/leveldb.gyp +282 -0
  430. package/node_modules/classic-level/deps/leveldb/patches/001-value-sink.patch +164 -0
  431. package/node_modules/classic-level/deps/leveldb/port-libuv/atomic_pointer_win.h +48 -0
  432. package/node_modules/classic-level/deps/leveldb/port-libuv/env_win.cc +692 -0
  433. package/node_modules/classic-level/deps/leveldb/port-libuv/port_uv.cc +36 -0
  434. package/node_modules/classic-level/deps/leveldb/port-libuv/port_uv.h +157 -0
  435. package/node_modules/classic-level/deps/leveldb/port-libuv/port_uv.h.bak +153 -0
  436. package/node_modules/classic-level/deps/leveldb/port-libuv/stdint-msvc2008.h +247 -0
  437. package/node_modules/classic-level/deps/leveldb/port-libuv/uv_condvar.h +45 -0
  438. package/node_modules/classic-level/deps/leveldb/port-libuv/uv_condvar_posix.cc +139 -0
  439. package/node_modules/classic-level/deps/leveldb/port-libuv/win_logger.cc +79 -0
  440. package/node_modules/classic-level/deps/leveldb/port-libuv/win_logger.h +28 -0
  441. package/node_modules/classic-level/deps/snappy/freebsd/config.h +135 -0
  442. package/node_modules/classic-level/deps/snappy/freebsd/snappy-stubs-public.h +100 -0
  443. package/node_modules/classic-level/deps/snappy/linux/config.h +135 -0
  444. package/node_modules/classic-level/deps/snappy/linux/snappy-stubs-public.h +100 -0
  445. package/node_modules/classic-level/deps/snappy/mac/config.h +137 -0
  446. package/node_modules/classic-level/deps/snappy/mac/snappy-stubs-public.h +100 -0
  447. package/node_modules/classic-level/deps/snappy/openbsd/config.h +135 -0
  448. package/node_modules/classic-level/deps/snappy/openbsd/snappy-stubs-public.h +100 -0
  449. package/node_modules/classic-level/deps/snappy/snappy/COPYING +54 -0
  450. package/node_modules/classic-level/deps/snappy/snappy/cmake/SnappyConfig.cmake +1 -0
  451. package/node_modules/classic-level/deps/snappy/snappy/cmake/config.h.in +62 -0
  452. package/node_modules/classic-level/deps/snappy/snappy/snappy-c.cc +90 -0
  453. package/node_modules/classic-level/deps/snappy/snappy/snappy-c.h +138 -0
  454. package/node_modules/classic-level/deps/snappy/snappy/snappy-internal.h +224 -0
  455. package/node_modules/classic-level/deps/snappy/snappy/snappy-sinksource.cc +104 -0
  456. package/node_modules/classic-level/deps/snappy/snappy/snappy-sinksource.h +182 -0
  457. package/node_modules/classic-level/deps/snappy/snappy/snappy-stubs-internal.cc +42 -0
  458. package/node_modules/classic-level/deps/snappy/snappy/snappy-stubs-internal.h +561 -0
  459. package/node_modules/classic-level/deps/snappy/snappy/snappy-stubs-public.h.in +94 -0
  460. package/node_modules/classic-level/deps/snappy/snappy/snappy-test.cc +612 -0
  461. package/node_modules/classic-level/deps/snappy/snappy/snappy-test.h +573 -0
  462. package/node_modules/classic-level/deps/snappy/snappy/snappy.cc +1515 -0
  463. package/node_modules/classic-level/deps/snappy/snappy/snappy.h +203 -0
  464. package/node_modules/classic-level/deps/snappy/snappy/snappy_unittest.cc +1410 -0
  465. package/node_modules/classic-level/deps/snappy/snappy.gyp +119 -0
  466. package/node_modules/classic-level/deps/snappy/solaris/config.h +135 -0
  467. package/node_modules/classic-level/deps/snappy/solaris/snappy-stubs-public.h +100 -0
  468. package/node_modules/classic-level/deps/snappy/win32/config.h +29 -0
  469. package/node_modules/classic-level/deps/snappy/win32/snappy-stubs-public.h +100 -0
  470. package/node_modules/classic-level/index.d.ts +343 -0
  471. package/node_modules/classic-level/index.js +311 -0
  472. package/node_modules/classic-level/iterator.js +122 -0
  473. package/node_modules/classic-level/package.json +70 -0
  474. package/node_modules/classic-level/prebuilds/android-arm/classic-level.armv7.node +0 -0
  475. package/node_modules/classic-level/prebuilds/android-arm64/classic-level.armv8.node +0 -0
  476. package/node_modules/classic-level/prebuilds/darwin-x64+arm64/classic-level.node +0 -0
  477. package/node_modules/classic-level/prebuilds/linux-arm/classic-level.armv6.node +0 -0
  478. package/node_modules/classic-level/prebuilds/linux-arm/classic-level.armv7.node +0 -0
  479. package/node_modules/classic-level/prebuilds/linux-arm64/classic-level.armv8.node +0 -0
  480. package/node_modules/classic-level/prebuilds/linux-x64/classic-level.musl.node +0 -0
  481. package/node_modules/classic-level/prebuilds/linux-x64/classic-level.node +0 -0
  482. package/node_modules/classic-level/prebuilds/win32-ia32/classic-level.node +0 -0
  483. package/node_modules/classic-level/prebuilds/win32-x64/classic-level.node +0 -0
  484. package/node_modules/ieee754/LICENSE +11 -0
  485. package/node_modules/ieee754/README.md +51 -0
  486. package/node_modules/ieee754/index.d.ts +10 -0
  487. package/node_modules/ieee754/index.js +85 -0
  488. package/node_modules/ieee754/package.json +52 -0
  489. package/node_modules/is-buffer/LICENSE +21 -0
  490. package/node_modules/is-buffer/README.md +54 -0
  491. package/node_modules/is-buffer/index.d.ts +2 -0
  492. package/node_modules/is-buffer/index.js +11 -0
  493. package/node_modules/is-buffer/package.json +65 -0
  494. package/node_modules/level/CHANGELOG.md +532 -0
  495. package/node_modules/level/LICENSE +21 -0
  496. package/node_modules/level/README.md +107 -0
  497. package/node_modules/level/UPGRADING.md +413 -0
  498. package/node_modules/level/browser.js +1 -0
  499. package/node_modules/level/index.d.ts +75 -0
  500. package/node_modules/level/index.js +1 -0
  501. package/node_modules/level/package.json +62 -0
  502. package/node_modules/level-supports/CHANGELOG.md +140 -0
  503. package/node_modules/level-supports/LICENSE +21 -0
  504. package/node_modules/level-supports/README.md +276 -0
  505. package/node_modules/level-supports/index.d.ts +137 -0
  506. package/node_modules/level-supports/index.js +26 -0
  507. package/node_modules/level-supports/package.json +46 -0
  508. package/node_modules/level-supports/test/cloneable.js +26 -0
  509. package/node_modules/level-supports/test/index.js +24 -0
  510. package/node_modules/level-supports/test/self.js +86 -0
  511. package/node_modules/level-supports/test/shape.js +23 -0
  512. package/node_modules/level-transcoder/CHANGELOG.md +15 -0
  513. package/node_modules/level-transcoder/LICENSE +21 -0
  514. package/node_modules/level-transcoder/README.md +214 -0
  515. package/node_modules/level-transcoder/UPGRADING.md +13 -0
  516. package/node_modules/level-transcoder/index.d.ts +27 -0
  517. package/node_modules/level-transcoder/index.js +158 -0
  518. package/node_modules/level-transcoder/lib/encoding.d.ts +158 -0
  519. package/node_modules/level-transcoder/lib/encoding.js +105 -0
  520. package/node_modules/level-transcoder/lib/encodings.d.ts +9 -0
  521. package/node_modules/level-transcoder/lib/encodings.js +135 -0
  522. package/node_modules/level-transcoder/lib/formats.d.ts +13 -0
  523. package/node_modules/level-transcoder/lib/formats.js +111 -0
  524. package/node_modules/level-transcoder/lib/text-endec.d.ts +6 -0
  525. package/node_modules/level-transcoder/lib/text-endec.js +19 -0
  526. package/node_modules/level-transcoder/package.json +46 -0
  527. package/node_modules/maybe-combine-errors/LICENSE.md +21 -0
  528. package/node_modules/maybe-combine-errors/README.md +94 -0
  529. package/node_modules/maybe-combine-errors/index.js +60 -0
  530. package/node_modules/maybe-combine-errors/package.json +33 -0
  531. package/node_modules/module-error/CHANGELOG.md +23 -0
  532. package/node_modules/module-error/LICENSE +21 -0
  533. package/node_modules/module-error/README.md +89 -0
  534. package/node_modules/module-error/index.d.ts +18 -0
  535. package/node_modules/module-error/index.js +22 -0
  536. package/node_modules/module-error/package.json +36 -0
  537. package/node_modules/napi-macros/LICENSE +21 -0
  538. package/node_modules/napi-macros/README.md +277 -0
  539. package/node_modules/napi-macros/index.js +1 -0
  540. package/node_modules/napi-macros/napi-macros.h +255 -0
  541. package/node_modules/napi-macros/package.json +22 -0
  542. package/node_modules/node-gyp-build/LICENSE +21 -0
  543. package/node_modules/node-gyp-build/README.md +58 -0
  544. package/node_modules/node-gyp-build/SECURITY.md +5 -0
  545. package/node_modules/node-gyp-build/bin.js +84 -0
  546. package/node_modules/node-gyp-build/build-test.js +19 -0
  547. package/node_modules/node-gyp-build/index.js +6 -0
  548. package/node_modules/node-gyp-build/node-gyp-build.js +207 -0
  549. package/node_modules/node-gyp-build/optional.js +7 -0
  550. package/node_modules/node-gyp-build/package.json +43 -0
  551. package/oauthTokenStore-PADKLNOC.js +23 -0
  552. package/package.json +6 -3
  553. package/processSpawn-SOAV3FEV.js +11 -0
  554. package/profileConfig-ZGOFORWV.js +43 -0
  555. package/{providerPresetApply-FG6NZ57W.js → providerPresetApply-HIPK67DU.js} +9 -9
  556. package/{providerRegistry-757OWH3O.js → providerRegistry-AI4U2FNM.js} +13 -9
  557. package/{read-COE3ZYR6.js → read-RNUQ7F34.js} +11 -7
  558. package/{readDocTool-5USN4A6V.js → readDocTool-6WIZHE6O.js} +5 -3
  559. package/{readlineWorkspace-HO62DKCG.js → readlineWorkspace-P3I7ZJUP.js} +6948 -3879
  560. package/{removeDialogAgentAction-J6X5QMTA.js → removeDialogAgentAction-EFQ4O2IQ.js} +27 -26
  561. package/{runAgentClientLoop-JLRJIF3F.js → runAgentClientLoop-AYNL3KMJ.js} +150 -90
  562. package/{runtimeDoctorCommands-X6WDBEQX.js → runtimeDoctorCommands-5CIWJEZ3.js} +36 -8
  563. package/runtimeModeArgs-2Y7BALTO.js +31 -0
  564. package/setDialogExtraReferencesAction-MXAH2KPV.js +37 -0
  565. package/{setPrimaryDialogAgentAction-FN22THHT.js → setPrimaryDialogAgentAction-7OPVNK4M.js} +28 -27
  566. package/{chunk-GP5LKBUZ.js → settingThunks-GHVLHABJ.js} +240 -945
  567. package/{skillDiscovery-CYUCJMAG.js → skillDiscovery-QC35EQY4.js} +3 -3
  568. package/{slateUtils-RIZES3PV.js → slateUtils-NGV2NMKM.js} +1 -1
  569. package/{spaceCommands-5GLCWZPO.js → spaceCommands-WZCLRGBO.js} +56 -55
  570. package/{streamAgentChatTurn-DZ3PP7ZH.js → streamAgentChatTurn-O5T3B4B3.js} +325 -1557
  571. package/{switchDialogAgentAction-LVTEV3FR.js → switchDialogAgentAction-4PANDG3L.js} +24 -20
  572. package/{tableCommands-O6NWHFKV.js → tableCommands-U3QDY4L6.js} +19 -17
  573. package/{toolApiClient-QVJ6HDNN.js → toolApiClient-54CXTU7C.js} +5 -4
  574. package/tools-UMU2DYQX.js +122 -0
  575. package/{tuiSummaryLlmCaller-OHHFTHMG.js → tuiSummaryLlmCaller-ISODIW2O.js} +15 -29
  576. package/{updateCommands-2M74UL7P.js → updateCommands-NQXAGFM7.js} +3 -3
  577. package/{updateDialogTitleAction-VWZT4J6J.js → updateDialogTitleAction-TIS2SETN.js} +101 -57
  578. package/action-P4TNFGAD.js +0 -31
  579. package/agentListCommands-B2V4YAC4.js +0 -410
  580. package/agentRecordCommands-XBVDEYVC.js +0 -128
  581. package/agentRunCommand-V6RTNFRH.js +0 -156
  582. package/browser-image-compression-MFDTD7K6.js +0 -1763
  583. package/chatQueueReduxAdapter-XMFWRG3P.js +0 -186
  584. package/chunk-ACTMNVHM.js +0 -93
  585. package/chunk-CQ3WA2NE.js +0 -299
  586. package/chunk-M76ECQRD.js +0 -13658
  587. package/chunk-MEYIRKDN.js +0 -8967
  588. package/chunk-N4G4PKQ6.js +0 -23
  589. package/chunk-PUOC4YRO.js +0 -394
  590. package/chunk-Q5FJJ6XI.js +0 -103
  591. package/chunk-QQWJUHSL.js +0 -34
  592. package/chunk-S7Z2HMCN.js +0 -25
  593. package/chunk-TWQWYIMJ.js +0 -21409
  594. package/chunk-Y5GCAMGP.js +0 -9
  595. package/chunk-YPREESF4.js +0 -225
  596. package/contentThunks-3Z6NAUW6.js +0 -73
  597. package/createDialogAction-7XW3RX2A.js +0 -65
  598. package/dialogCommands-H7FPUYUQ.js +0 -99
  599. package/handleSendMessageAction-GUBOMCGM.js +0 -633
  600. package/machineWsRunDispatch-AAG6PDBY.js +0 -144
  601. package/setDialogExtraReferencesAction-WX5VTY6O.js +0 -30
  602. package/settingSlice-P4ZW7K5X.js +0 -204
  603. package/syncMapping-N6RGXGBW.js +0 -437
  604. package/tools-XA4ZWLH4.js +0 -110
  605. package/{chunk-SV5IJK6K.js → chunk-NBTY7YJF.js} +3 -3
  606. package/{chunk-X7HHHIOZ.js → chunk-Y6ROFCZO.js} +0 -0
  607. package/{db-WK5MDZVN.js → db-VQSAOWAO.js} +1 -1
  608. package/{offlineMarxistsAgentCommand-HGXZV4XJ.js → offlineMarxistsAgentCommand-2QTHJCHV.js} +4 -4
@@ -0,0 +1,1849 @@
1
+ import {
2
+ scanValidationDetails
3
+ } from "./chunk-BMQ2MJUK.js";
4
+ import {
5
+ buildForegroundTurnAdmissionFetchInit,
6
+ consumeAgentRunStream,
7
+ mergeAgentToolsWithRuntime,
8
+ projectDesktopToolUiContent,
9
+ resolveTurnToolContext
10
+ } from "./chunk-7YVPCIEN.js";
11
+ import "./chunk-PBGO5AFD.js";
12
+ import {
13
+ CONTEXT_OVERFLOW_ACTIONS,
14
+ CONTEXT_TOO_LARGE_ACTIONS,
15
+ isContextOverflowText,
16
+ performServerProxyFetchWithRetry
17
+ } from "./chunk-IRG4OKY6.js";
18
+ import {
19
+ createSSEParser,
20
+ resolveAgentRequiredPackIds,
21
+ waitForAbortableDelay
22
+ } from "./chunk-DGDGNYI5.js";
23
+ import "./chunk-NF64D32W.js";
24
+ import "./chunk-XPWGOTBQ.js";
25
+ import "./chunk-5XN3OSCT.js";
26
+ import "./chunk-2ECUZDEL.js";
27
+ import "./chunk-6VRWNU5J.js";
28
+ import "./chunk-PFEK4SA2.js";
29
+ import "./chunk-VIDPVFP3.js";
30
+ import "./chunk-AGIM7IMJ.js";
31
+ import "./chunk-X2VPXJZC.js";
32
+ import "./chunk-P6KLYCL3.js";
33
+ import "./chunk-ZJ7UHBJS.js";
34
+ import {
35
+ clearForegroundTurnSettledVisible,
36
+ initMsgs,
37
+ markForegroundTurnSettledVisible,
38
+ messageStreamEnd,
39
+ messageStreaming,
40
+ prepareAndPersistUserMessage,
41
+ protectTransientForCanonicalHandoff,
42
+ releaseTransientCanonicalHandoff,
43
+ removeTransientMessage,
44
+ resolveHandleSendMessageContext,
45
+ selectAllMsgs,
46
+ setMessages,
47
+ setStreamingMessageId,
48
+ toolResultNeedsUserConfirmation,
49
+ updateToolMessage
50
+ } from "./chunk-ROXFUKKL.js";
51
+ import "./chunk-523DITKR.js";
52
+ import "./chunk-UKZX3NHN.js";
53
+ import "./chunk-F2UJW3EK.js";
54
+ import "./chunk-BYXBJQAS.js";
55
+ import "./chunk-QYPE3TS3.js";
56
+ import {
57
+ streamAgentChatTurn
58
+ } from "./chunk-EXR4XCFE.js";
59
+ import "./chunk-AGGIDPCZ.js";
60
+ import "./chunk-WW2USJ3C.js";
61
+ import "./chunk-5RGU3J7P.js";
62
+ import {
63
+ addActiveController,
64
+ getActiveDialogKey,
65
+ removeActiveController
66
+ } from "./chunk-VBG7GWWR.js";
67
+ import "./chunk-ZRAU6T47.js";
68
+ import "./chunk-4LCOCOR5.js";
69
+ import "./chunk-YDH3FDFQ.js";
70
+ import {
71
+ selectCurrentServer
72
+ } from "./chunk-QFEW2ULV.js";
73
+ import "./chunk-V2UPLOXT.js";
74
+ import "./chunk-2OMUAIKR.js";
75
+ import "./chunk-UAD2WT54.js";
76
+ import {
77
+ readAndWait,
78
+ selectById
79
+ } from "./chunk-RNNWTMKT.js";
80
+ import "./chunk-3PVYUPXK.js";
81
+ import "./chunk-GHZ2H2HJ.js";
82
+ import "./chunk-AIZE5TDM.js";
83
+ import "./chunk-4YRTZIVN.js";
84
+ import "./chunk-UEILX4EV.js";
85
+ import "./chunk-IJERIUXS.js";
86
+ import {
87
+ getIsDesktopApp
88
+ } from "./chunk-6Q7UTJKR.js";
89
+ import "./chunk-QQ56R7KS.js";
90
+ import "./chunk-OW765XBU.js";
91
+ import {
92
+ selectIdentityToken,
93
+ selectIdentityUserId
94
+ } from "./chunk-SEJ5OS6F.js";
95
+ import "./chunk-D2MDMY2M.js";
96
+ import "./chunk-RRQQAG7W.js";
97
+ import {
98
+ expandEnabledPacks
99
+ } from "./chunk-3CZM6HGQ.js";
100
+ import "./chunk-IXH3HKY2.js";
101
+ import "./chunk-XETG4RIX.js";
102
+ import "./chunk-OKARGYFT.js";
103
+ import "./chunk-JJM3WS6W.js";
104
+ import "./chunk-WJZOQR2J.js";
105
+ import "./chunk-VSPO4S33.js";
106
+ import "./chunk-FWY6BHIJ.js";
107
+ import "./chunk-5MMAK75Q.js";
108
+ import "./chunk-DWLEOOGR.js";
109
+ import "./chunk-PWRS2SU2.js";
110
+ import "./chunk-KX6YBIHG.js";
111
+ import "./chunk-7DPNBQSV.js";
112
+ import {
113
+ canonicalizeToolName
114
+ } from "./chunk-IHPDK6UD.js";
115
+ import "./chunk-LWLNLZC5.js";
116
+ import "./chunk-3LI5UCTU.js";
117
+ import {
118
+ extractCustomId
119
+ } from "./chunk-M2EJHDJP.js";
120
+ import {
121
+ createDialogMessageKeyAndId
122
+ } from "./chunk-RLRYVSCD.js";
123
+ import "./chunk-I42VC5KR.js";
124
+ import "./chunk-U6VC4MU4.js";
125
+ import "./chunk-WWC7I6TA.js";
126
+ import "./chunk-PSCNXBYA.js";
127
+ import "./chunk-NN4UUYGB.js";
128
+ import "./chunk-CGEK73JN.js";
129
+ import "./chunk-W7XHHYWM.js";
130
+ import "./chunk-KUG52IAP.js";
131
+ import "./chunk-3EUW3WEO.js";
132
+ import "./chunk-HNMXYYJR.js";
133
+ import "./chunk-LCBAMY2M.js";
134
+ import "./chunk-4SN6J65J.js";
135
+ import "./chunk-CF7PE763.js";
136
+ import "./chunk-G3SUCT4W.js";
137
+ import "./chunk-P3SFAHIL.js";
138
+ import {
139
+ PLATFORM_LLM_BUSY_USER_MESSAGE
140
+ } from "./chunk-SZC4REES.js";
141
+ import "./chunk-QSJ3HFEF.js";
142
+ import "./chunk-ZWQUWF6W.js";
143
+ import "./chunk-KHCLMKZZ.js";
144
+ import "./chunk-VEA7H5FG.js";
145
+ import "./chunk-4VJAC32I.js";
146
+ import "./chunk-4VNS5WPM.js";
147
+
148
+ // packages/ai/agent/foregroundTurnStageLog.ts
149
+ var FOREGROUND_TURN_STAGE_LOG_PREFIX = "[foregroundTurn][latency]";
150
+ var isStageLogEnabled = () => {
151
+ try {
152
+ if (globalThis.__NOLO_FOREGROUND_TURN_STAGE_LOG__ === true) {
153
+ return true;
154
+ }
155
+ const storage = globalThis.localStorage;
156
+ return typeof storage?.getItem === "function" ? storage.getItem("nolo.foregroundTurn.stageLog") === "1" : false;
157
+ } catch {
158
+ return false;
159
+ }
160
+ };
161
+ function createForegroundTurnStageLog(args) {
162
+ const t0 = Date.now();
163
+ const identity = `turn=${args.turnKey} runId=${args.runId} dialogId=${args.dialogId} dialogKey=${args.dialogKey} base=${args.base}`;
164
+ const marks = [];
165
+ return {
166
+ stage: (stage, detail) => {
167
+ const at = Date.now() - t0;
168
+ marks.push(`${stage}=+${at}ms`);
169
+ if (!isStageLogEnabled()) return;
170
+ console.info(
171
+ `${FOREGROUND_TURN_STAGE_LOG_PREFIX} stage=${stage} t=+${at}ms ${identity}${detail ? ` ${detail}` : ""}`
172
+ );
173
+ },
174
+ summary: (outcome, detail) => {
175
+ console.info(
176
+ `${FOREGROUND_TURN_STAGE_LOG_PREFIX} SUMMARY outcome=${outcome} total=+${Date.now() - t0}ms ${identity} marks=[${marks.join(" ")}]${detail ? ` ${detail}` : ""}`
177
+ );
178
+ }
179
+ };
180
+ }
181
+
182
+ // packages/ai/tools/effectiveToolSurface.ts
183
+ function readEffectiveToolName(value) {
184
+ if (typeof value === "string") {
185
+ const name2 = canonicalizeToolName(value.trim());
186
+ return name2 || null;
187
+ }
188
+ if (!value || typeof value !== "object") return null;
189
+ const record = value;
190
+ const candidate = typeof record.name === "string" && record.name || typeof record.toolName === "string" && record.toolName || typeof record.function?.name === "string" && record.function.name || "";
191
+ const name = canonicalizeToolName(candidate.trim());
192
+ return name || null;
193
+ }
194
+ function valuesOf(iterable) {
195
+ return iterable ? [...iterable] : [];
196
+ }
197
+ function resolveEffectiveToolSurface(input) {
198
+ const agent = input.agent ?? {};
199
+ const byName = /* @__PURE__ */ new Map();
200
+ const add = (values, source) => {
201
+ for (const value of values) {
202
+ const name = readEffectiveToolName(value);
203
+ if (!name) continue;
204
+ let sources = byName.get(name);
205
+ if (!sources) {
206
+ sources = /* @__PURE__ */ new Set();
207
+ byName.set(name, sources);
208
+ }
209
+ sources.add(source);
210
+ }
211
+ };
212
+ add(Array.isArray(agent.tools) ? agent.tools : [], "explicit");
213
+ add(Array.isArray(agent.toolNames) ? agent.toolNames : [], "explicit");
214
+ const requiredPackIds = resolveAgentRequiredPackIds(agent);
215
+ add(expandEnabledPacks(requiredPackIds), "required-pack");
216
+ const policies = [
217
+ agent.runtimeToolPolicy,
218
+ agent.runtimeBinding?.runtimeToolPolicy,
219
+ agent.runtimeBinding?.runtimeToolPolicySnapshot
220
+ ];
221
+ for (const policy of policies) {
222
+ if (!policy || typeof policy !== "object") continue;
223
+ add(Array.isArray(policy.agentTools) ? policy.agentTools : [], "runtime-policy");
224
+ add(Array.isArray(policy.runtimeTools) ? policy.runtimeTools : [], "runtime-policy");
225
+ }
226
+ add(Array.isArray(agent.referencedTools) ? agent.referencedTools : [], "reference");
227
+ add(valuesOf(input.referencedToolNames), "reference");
228
+ add(valuesOf(input.mentionedToolNames), "mention");
229
+ add(valuesOf(input.hostInjectedToolNames), "host-injected");
230
+ add(valuesOf(input.runtimeExtraToolNames), "runtime-extra");
231
+ const disabled = new Set(
232
+ (Array.isArray(agent.disabledTools) ? agent.disabledTools : []).map(readEffectiveToolName).filter((name) => !!name)
233
+ );
234
+ for (const name of disabled) byName.delete(name);
235
+ const entries = [...byName.entries()].map(
236
+ ([name, sources]) => ({ name, sources: [...sources] })
237
+ );
238
+ const requestedSources = /* @__PURE__ */ new Set([
239
+ "explicit",
240
+ "required-pack",
241
+ "runtime-policy",
242
+ "reference",
243
+ "mention",
244
+ "runtime-extra"
245
+ ]);
246
+ const requestedNames = entries.filter((entry) => entry.sources.some((source) => requestedSources.has(source))).map((entry) => entry.name);
247
+ const hostInjectedNames = entries.filter((entry) => entry.sources.includes("host-injected")).map((entry) => entry.name);
248
+ const shellEnabled = policies.some(
249
+ (policy) => policy && typeof policy === "object" && policy.shell?.enabled === true
250
+ );
251
+ const workspaceModes = [
252
+ ...new Set(
253
+ policies.map(
254
+ (policy) => policy && typeof policy === "object" && typeof policy.workspace?.mode === "string" ? policy.workspace.mode.trim() : ""
255
+ ).filter(Boolean)
256
+ )
257
+ ];
258
+ return {
259
+ names: entries.map((entry) => entry.name),
260
+ entries,
261
+ requestedNames,
262
+ hostInjectedNames,
263
+ shellEnabled,
264
+ workspaceModes,
265
+ workspaceLease: workspaceModes.includes("lease")
266
+ };
267
+ }
268
+
269
+ // packages/ai/tools/toolExecutionSemantics.ts
270
+ var UNKNOWN_TOOL_EXECUTION_CONTRACT = {
271
+ replay: "unknown",
272
+ sideEffects: "unknown",
273
+ locality: "unknown",
274
+ interaction: "unknown",
275
+ concurrency: "exclusive",
276
+ durableWebForeground: false
277
+ };
278
+ var serverPureRead = (durableWebForeground) => ({
279
+ replay: "pure",
280
+ sideEffects: "none",
281
+ locality: "server",
282
+ interaction: "none",
283
+ concurrency: "safe",
284
+ durableWebForeground
285
+ });
286
+ var serverExternalRead = (durableWebForeground) => ({
287
+ // Repeating the request should not mutate the target resource, but may spend
288
+ // provider quota/money and may observe newer remote state; it is not pure.
289
+ replay: "idempotent",
290
+ sideEffects: "observable",
291
+ locality: "server",
292
+ interaction: "none",
293
+ concurrency: "safe",
294
+ durableWebForeground
295
+ });
296
+ var serverConfirmedHandoffStep = () => ({
297
+ replay: "unsafe",
298
+ sideEffects: "observable",
299
+ locality: "server",
300
+ interaction: "handoff",
301
+ concurrency: "exclusive",
302
+ durableWebForeground: false
303
+ });
304
+ var TOOL_EXECUTION_CONTRACT = Object.freeze({
305
+ // Proven durable network reads. They execute on the server but touch external
306
+ // systems, so replay/cost semantics are intentionally not called "pure".
307
+ exa_search: serverExternalRead("read-only"),
308
+ fetchWebpage: serverExternalRead("read-only"),
309
+ // Proven durable server-hosted workspace reads/queries.
310
+ searchDialogMessages: serverPureRead("read-only"),
311
+ listDialogs: serverPureRead("read-only"),
312
+ readDialog: serverPureRead("read-only"),
313
+ queryDialogsBySubjectRef: serverPureRead("read-only"),
314
+ listAgents: serverPureRead("read-only"),
315
+ readAgent: serverPureRead("read-only"),
316
+ listSpaces: serverPureRead("read-only"),
317
+ readSpace: serverPureRead("read-only"),
318
+ readDoc: serverPureRead("read-only"),
319
+ readSkillDoc: serverPureRead("read-only"),
320
+ listTables: serverPureRead("read-only"),
321
+ queryTableRows: serverPureRead("read-only"),
322
+ // Read-only presentation payload. Actions remain inert; this adds no submit or
323
+ // open-app authority to server-owned projection.
324
+ show_interaction: {
325
+ replay: "pure",
326
+ sideEffects: "none",
327
+ locality: "server",
328
+ interaction: "none",
329
+ concurrency: "safe",
330
+ durableWebForeground: "read-only"
331
+ },
332
+ // Durable interactive boundary: the current execution ends and a later user
333
+ // choice starts a new execution. It is intentionally not modeled as a read.
334
+ ask_user: {
335
+ replay: "unsafe",
336
+ sideEffects: "observable",
337
+ locality: "server",
338
+ interaction: "blocking",
339
+ concurrency: "exclusive",
340
+ durableWebForeground: "interactive"
341
+ },
342
+ // Confirmed human hand-off boundary for the media step family. These tools
343
+ // do not start work needing authorization: they return
344
+ // `{ status: "requires_confirmation", ... }` and the run must stop and wait
345
+ // for the user. Registered explicitly (rather than inferred from any status)
346
+ // so a random tool echoing the same status never pauses the run, and kept out
347
+ // of the durable Web foreground plane on purpose (media ServerTool admission
348
+ // is owned elsewhere).
349
+ transcribe: serverConfirmedHandoffStep(),
350
+ translate: serverConfirmedHandoffStep(),
351
+ exportDocument: serverConfirmedHandoffStep(),
352
+ readArtifact: serverConfirmedHandoffStep(),
353
+ // Representative explicitly non-durable execution classes. These entries
354
+ // make the reason machine-readable; unlisted tools remain UNKNOWN.
355
+ execShell: {
356
+ replay: "unsafe",
357
+ sideEffects: "mutation",
358
+ locality: "workspace",
359
+ interaction: "none",
360
+ concurrency: "exclusive",
361
+ durableWebForeground: false
362
+ },
363
+ readFile: {
364
+ replay: "idempotent",
365
+ sideEffects: "none",
366
+ locality: "device",
367
+ interaction: "none",
368
+ concurrency: "safe",
369
+ durableWebForeground: false
370
+ },
371
+ globFiles: {
372
+ replay: "idempotent",
373
+ sideEffects: "none",
374
+ locality: "device",
375
+ interaction: "none",
376
+ concurrency: "safe",
377
+ durableWebForeground: false
378
+ },
379
+ createDoc: {
380
+ replay: "unsafe",
381
+ sideEffects: "mutation",
382
+ locality: "server",
383
+ interaction: "none",
384
+ concurrency: "exclusive",
385
+ durableWebForeground: false
386
+ },
387
+ updateDoc: {
388
+ replay: "unsafe",
389
+ sideEffects: "mutation",
390
+ locality: "server",
391
+ interaction: "none",
392
+ concurrency: "exclusive",
393
+ durableWebForeground: false
394
+ },
395
+ deleteDialogs: {
396
+ replay: "unsafe",
397
+ sideEffects: "mutation",
398
+ locality: "server",
399
+ interaction: "confirm",
400
+ concurrency: "exclusive",
401
+ durableWebForeground: false
402
+ },
403
+ loadSkill: {
404
+ replay: "unsafe",
405
+ sideEffects: "observable",
406
+ locality: "server",
407
+ interaction: "none",
408
+ concurrency: "exclusive",
409
+ durableWebForeground: false
410
+ }
411
+ });
412
+ function resolveToolExecutionContract(toolName) {
413
+ if (typeof toolName !== "string" || !toolName.trim()) {
414
+ return UNKNOWN_TOOL_EXECUTION_CONTRACT;
415
+ }
416
+ const canonicalName = canonicalizeToolName(toolName);
417
+ return TOOL_EXECUTION_CONTRACT[canonicalName] ?? UNKNOWN_TOOL_EXECUTION_CONTRACT;
418
+ }
419
+ function collectDurableWebToolNames(durableClass) {
420
+ return new Set(
421
+ Object.entries(TOOL_EXECUTION_CONTRACT).filter(([, contract]) => contract.durableWebForeground === durableClass).map(([name]) => name)
422
+ );
423
+ }
424
+ var DURABLE_WEB_FOREGROUND_READ_ONLY_TOOL_NAMES = collectDurableWebToolNames("read-only");
425
+ var DURABLE_WEB_FOREGROUND_INTERACTIVE_TOOL_NAMES = collectDurableWebToolNames("interactive");
426
+ var DURABLE_WEB_FOREGROUND_TOOL_NAMES = /* @__PURE__ */ new Set([
427
+ ...DURABLE_WEB_FOREGROUND_READ_ONLY_TOOL_NAMES,
428
+ ...DURABLE_WEB_FOREGROUND_INTERACTIVE_TOOL_NAMES
429
+ ]);
430
+ var CONFIRMED_HANDOFF_TOOL_NAMES = new Set(
431
+ Object.entries(TOOL_EXECUTION_CONTRACT).filter(([, contract]) => contract.interaction === "handoff").map(([name]) => name)
432
+ );
433
+ function hasProvenServerReadOnlySemantics(toolName) {
434
+ const contract = resolveToolExecutionContract(toolName);
435
+ return contract.durableWebForeground === "read-only" && (contract.replay === "pure" || contract.replay === "idempotent") && (contract.sideEffects === "none" || contract.sideEffects === "observable") && contract.locality === "server" && contract.interaction === "none";
436
+ }
437
+ function hasProvenDurableWebForegroundSemantics(toolName) {
438
+ const contract = resolveToolExecutionContract(toolName);
439
+ if (contract.durableWebForeground === "read-only") {
440
+ return hasProvenServerReadOnlySemantics(toolName);
441
+ }
442
+ if (contract.durableWebForeground === "interactive") {
443
+ return contract.locality === "server" && contract.interaction === "blocking" && contract.sideEffects === "observable";
444
+ }
445
+ return false;
446
+ }
447
+
448
+ // packages/ai/agent/serverOwnedWebForegroundEligibility.ts
449
+ var AUDITED_WEB_FOREGROUND_HOST_BASELINE_TOOL_NAMES = /* @__PURE__ */ new Set([
450
+ // TOOL_PACKS.CORE
451
+ "read",
452
+ "readFile",
453
+ "createDoc",
454
+ "updateDoc",
455
+ "search_workspace",
456
+ "updateSelf",
457
+ "ask_user",
458
+ // show_interaction: CORE 宿主注入;服务端纯函数展示(parse + fallback,无 I/O、无客户端通道),只读展示语义,不执行卡片动作
459
+ "show_interaction",
460
+ "createAgentAutomation",
461
+ "updateAgentAutomation",
462
+ "deleteAgentAutomation",
463
+ "notifyUser",
464
+ // ALWAYS_ON_PACK_IDS: long-term-memory + skills
465
+ "queryMemory",
466
+ "rememberMemory",
467
+ "deleteMemory",
468
+ "loadSkill",
469
+ "readSkillDoc",
470
+ // Default system capabilities
471
+ "exa_search",
472
+ "fetchWebpage",
473
+ "startAgentRun",
474
+ "controlAgentRun",
475
+ "listAgents"
476
+ ]);
477
+ function isDurableRequestedToolName(name) {
478
+ if (typeof name !== "string") return false;
479
+ return hasProvenDurableWebForegroundSemantics(canonicalizeToolName(name));
480
+ }
481
+ function hasSupportedDurableToolSurface(agent, suppliedSurface) {
482
+ const surface = suppliedSurface ?? resolveEffectiveToolSurface({
483
+ agent
484
+ });
485
+ if (surface.shellEnabled || surface.workspaceLease) return false;
486
+ if (!surface.requestedNames.every(isDurableRequestedToolName)) {
487
+ return false;
488
+ }
489
+ return surface.hostInjectedNames.every(
490
+ (name) => AUDITED_WEB_FOREGROUND_HOST_BASELINE_TOOL_NAMES.has(canonicalizeToolName(name))
491
+ );
492
+ }
493
+ function shouldUseServerOwnedWebForegroundTurn(input) {
494
+ if (input.surface !== "web") return false;
495
+ if (input.isDesktopApp) return false;
496
+ if (!input.currentServer?.trim() || !input.token?.trim()) return false;
497
+ if (typeof input.userInput !== "string" || !input.userInput.trim()) return false;
498
+ if (input.turnToolContext) {
499
+ if (!input.turnToolContext.complete) return false;
500
+ if (input.turnToolContext.unresolvedReasons?.length) return false;
501
+ if (!input.effectiveToolSurface) {
502
+ const lateBound = [
503
+ ...input.turnToolContext.referencedToolNames,
504
+ ...input.turnToolContext.mentionedToolNames
505
+ ];
506
+ if (lateBound.some((name) => !isDurableRequestedToolName(name))) {
507
+ return false;
508
+ }
509
+ }
510
+ }
511
+ const agent = input.agentConfig;
512
+ if (!agent) return false;
513
+ if (agent.useServerProxy === false) return false;
514
+ if (agent.apiSource === "cli") return false;
515
+ if (agent.runtimeBinding?.machineId) return false;
516
+ if (!hasSupportedDurableToolSurface(agent, input.effectiveToolSurface)) return false;
517
+ const runtimeOptions = input.runtimeOptions;
518
+ if (runtimeOptions?.extraTools?.length) {
519
+ if (!input.effectiveToolSurface) return false;
520
+ if (runtimeOptions.extraTools.some((name) => !isDurableRequestedToolName(name))) {
521
+ return false;
522
+ }
523
+ }
524
+ if (runtimeOptions?.editingTarget) return false;
525
+ if (runtimeOptions?.imageConfigOverride) return false;
526
+ if (runtimeOptions?.quickChatModelOverride) return false;
527
+ if (runtimeOptions?.workspaceToolsHint) return false;
528
+ if (runtimeOptions?.cwd) return false;
529
+ if (runtimeOptions?.restrictShellToWorkspace) return false;
530
+ return true;
531
+ }
532
+
533
+ // packages/ai/agent/serverOwnedToolProjection.ts
534
+ function parseToolArgs(raw) {
535
+ if (typeof raw !== "string" || !raw.trim()) return {};
536
+ try {
537
+ const parsed = JSON.parse(raw);
538
+ return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : {};
539
+ } catch {
540
+ return {};
541
+ }
542
+ }
543
+ function normalizeToolSet(values) {
544
+ return new Set(
545
+ [...values].map((value) => canonicalizeToolName(value)).filter(Boolean)
546
+ );
547
+ }
548
+ function isToolResultFailure(content, metadata) {
549
+ if (metadata?.error) return true;
550
+ if (typeof content !== "string" || !content.trim()) return false;
551
+ try {
552
+ const parsed = JSON.parse(content);
553
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return false;
554
+ const record = parsed;
555
+ return Boolean(record.error) || record.ok === false || record.success === false || record.status === "error";
556
+ } catch {
557
+ return false;
558
+ }
559
+ }
560
+ function createServerOwnedToolProjection(args) {
561
+ const supported = normalizeToolSet(args.supportedToolNames);
562
+ const keepReadOnly = normalizeToolSet(args.keepReadOnlyUntilCanonical ?? []);
563
+ const transientByCallId = /* @__PURE__ */ new Map();
564
+ const handlePayload = (payload) => {
565
+ if (!payload || typeof payload !== "object") return;
566
+ if (payload.type === "assistant_tool_calls") {
567
+ const calls = Array.isArray(payload.tool_calls) ? payload.tool_calls : [];
568
+ for (const call of calls) {
569
+ const callId2 = typeof call?.id === "string" ? call.id : "";
570
+ const toolName2 = canonicalizeToolName(call?.function?.name ?? "");
571
+ if (!callId2 || !toolName2 || !supported.has(toolName2)) continue;
572
+ if (transientByCallId.has(callId2)) continue;
573
+ const { key, messageId } = createDialogMessageKeyAndId(args.dialogId);
574
+ const input = parseToolArgs(call?.function?.arguments);
575
+ const content2 = toolName2 === "ask_user" ? JSON.stringify({ type: "ask_user", ...input }) : "";
576
+ const message2 = {
577
+ id: messageId,
578
+ dialogId: args.dialogId,
579
+ dbKey: key,
580
+ role: "tool",
581
+ content: content2,
582
+ isStreaming: true,
583
+ toolName: toolName2,
584
+ toolCallId: callId2,
585
+ toolPayload: {
586
+ toolName: toolName2,
587
+ status: "running",
588
+ input,
589
+ rawToolCall: call,
590
+ summary: ""
591
+ },
592
+ ...args.messageMetadata
593
+ };
594
+ transientByCallId.set(callId2, message2);
595
+ args.dispatch(messageStreaming(message2));
596
+ }
597
+ return;
598
+ }
599
+ if (payload.type !== "tool_result") return;
600
+ const callId = typeof payload.toolCallId === "string" ? payload.toolCallId : "";
601
+ if (!callId) return;
602
+ const existing = transientByCallId.get(callId);
603
+ const toolName = canonicalizeToolName(payload.toolName ?? existing?.toolName ?? "");
604
+ if (!toolName || !supported.has(toolName)) return;
605
+ const metadata = payload.metadata && typeof payload.metadata === "object" && !Array.isArray(payload.metadata) ? payload.metadata : void 0;
606
+ const failed = isToolResultFailure(payload.content, metadata);
607
+ const content = toolName === "ask_user" ? typeof payload.content === "string" ? payload.content : "" : projectDesktopToolUiContent({ toolName, content: payload.content, metadata });
608
+ const base = existing ?? (() => {
609
+ const { key, messageId } = createDialogMessageKeyAndId(args.dialogId);
610
+ return {
611
+ id: messageId,
612
+ dialogId: args.dialogId,
613
+ dbKey: key,
614
+ role: "tool",
615
+ content: "",
616
+ isStreaming: true,
617
+ toolName,
618
+ toolCallId: callId,
619
+ toolPayload: {
620
+ toolName,
621
+ status: "running",
622
+ input: {},
623
+ summary: ""
624
+ },
625
+ ...args.messageMetadata
626
+ };
627
+ })();
628
+ const staysReadOnly = !failed && keepReadOnly.has(toolName);
629
+ const awaitingUserConfirmation = toolResultNeedsUserConfirmation(toolName, payload.content);
630
+ const toolPayload = {
631
+ ...base.toolPayload ?? {},
632
+ toolName,
633
+ status: staysReadOnly ? "running" : awaitingUserConfirmation ? "pending" : failed ? "failed" : "succeeded"
634
+ };
635
+ const message = {
636
+ ...base,
637
+ content,
638
+ isStreaming: staysReadOnly,
639
+ toolName,
640
+ // F1: surface server-projected metadata (incl. executionLocation) on the
641
+ // message so tool rows can render the actual execution host.
642
+ ...metadata ? { metadata } : {},
643
+ toolPayload
644
+ };
645
+ transientByCallId.set(callId, message);
646
+ if (staysReadOnly) {
647
+ args.dispatch(messageStreaming(message));
648
+ return;
649
+ }
650
+ if (!existing) {
651
+ args.dispatch(messageStreaming(base));
652
+ }
653
+ args.dispatch(
654
+ updateToolMessage({
655
+ id: base.id,
656
+ dialogId: args.dialogId,
657
+ changes: {
658
+ content,
659
+ isStreaming: false,
660
+ toolName,
661
+ toolPayload,
662
+ ...metadata ? { metadata } : {}
663
+ }
664
+ })
665
+ );
666
+ };
667
+ const cleanup = () => {
668
+ for (const message of transientByCallId.values()) {
669
+ args.dispatch(removeTransientMessage({ id: message.id, dialogId: args.dialogId }));
670
+ }
671
+ transientByCallId.clear();
672
+ };
673
+ return { handlePayload, cleanup, transientByCallId };
674
+ }
675
+
676
+ // packages/ai/agent/serverOwnedWebForegroundHandoff.ts
677
+ function normalizeComparableText(value) {
678
+ if (typeof value === "string") {
679
+ return value.replace(/\r\n/g, "\n").trimEnd();
680
+ }
681
+ if (!Array.isArray(value)) return "";
682
+ return value.flatMap((part) => {
683
+ if (!part || typeof part !== "object") return [];
684
+ const record = part;
685
+ if (record.type === "text" && typeof record.text === "string") {
686
+ return [record.text];
687
+ }
688
+ return [];
689
+ }).join("").replace(/\r\n/g, "\n").trimEnd();
690
+ }
691
+ function assistantText(message) {
692
+ return normalizeComparableText(message.content);
693
+ }
694
+ function assistantThinking(message) {
695
+ const value = typeof message.thinkContent === "string" ? message.thinkContent : typeof message.reasoning_content === "string" ? message.reasoning_content : "";
696
+ return normalizeComparableText(value);
697
+ }
698
+ function assistantAgentKey(message) {
699
+ const value = message.agentKey ?? message.cybotKey;
700
+ return typeof value === "string" ? value : "";
701
+ }
702
+ function findNewCanonicalAssistant(messages, initialMessageIds, transientId, expectedText, expectedThinking, expectedAgentKey) {
703
+ const transient = messages.find((message) => message?.id === transientId);
704
+ const completedText = normalizeComparableText(
705
+ expectedText !== void 0 ? expectedText : transient ? assistantText(transient) : ""
706
+ );
707
+ const completedThinking = normalizeComparableText(
708
+ expectedThinking !== void 0 ? expectedThinking : transient ? assistantThinking(transient) : ""
709
+ );
710
+ const candidates = messages.filter((message) => {
711
+ if (!message?.id || message.id === transientId) return false;
712
+ if (initialMessageIds.has(message.id)) return false;
713
+ if (message.role !== "assistant") return false;
714
+ if (message.isStreaming) return false;
715
+ if (completedText) return assistantText(message) === completedText;
716
+ if (completedThinking) return assistantThinking(message) === completedThinking;
717
+ return false;
718
+ });
719
+ if (candidates.length === 0) return null;
720
+ if (candidates.length === 1) return candidates[0] ?? null;
721
+ if (expectedAgentKey) {
722
+ const agentMatches = candidates.filter(
723
+ (message) => assistantAgentKey(message) === expectedAgentKey
724
+ );
725
+ if (agentMatches.length === 1) return agentMatches[0] ?? null;
726
+ }
727
+ return null;
728
+ }
729
+ async function waitForNewCanonicalAssistant(args) {
730
+ const timeoutMs = Math.max(0, args.timeoutMs ?? 5e3);
731
+ const pollMs = Math.max(1, args.pollMs ?? 25);
732
+ const deadline = Date.now() + timeoutMs;
733
+ while (true) {
734
+ const canonical = findNewCanonicalAssistant(
735
+ args.readMessages(),
736
+ args.initialMessageIds,
737
+ args.transientId,
738
+ args.expectedText,
739
+ args.expectedThinking,
740
+ args.expectedAgentKey
741
+ );
742
+ if (canonical) return canonical;
743
+ if (Date.now() >= deadline) return null;
744
+ await new Promise((resolve) => setTimeout(resolve, pollMs));
745
+ }
746
+ }
747
+
748
+ // packages/ai/agent/serverOwnedWebEffectiveToolSurface.ts
749
+ function resolveServerOwnedWebEffectiveToolSurface(args) {
750
+ const referencedToolNames = args.turnToolContext?.referencedToolNames ?? [];
751
+ const mentionedToolNames = args.turnToolContext?.mentionedToolNames ?? [];
752
+ const requested = resolveEffectiveToolSurface({
753
+ agent: args.agentConfig,
754
+ referencedToolNames,
755
+ mentionedToolNames,
756
+ runtimeExtraToolNames: args.runtimeOptions?.extraTools ?? []
757
+ });
758
+ const mergedAgent = mergeAgentToolsWithRuntime(
759
+ args.agentConfig,
760
+ referencedToolNames,
761
+ mentionedToolNames,
762
+ args.runtimeOptions ?? void 0,
763
+ args.state
764
+ );
765
+ const rawNames = (Array.isArray(mergedAgent.tools) ? mergedAgent.tools : []).map(readEffectiveToolName).filter((name) => typeof name === "string" && !!name);
766
+ const finalNames = Array.from(new Set(rawNames));
767
+ const finalSet = new Set(finalNames);
768
+ const requestedSet = new Set(requested.requestedNames);
769
+ const requestedNames = requested.requestedNames.filter((name) => finalSet.has(name));
770
+ const hostInjectedNames = finalNames.filter((name) => !requestedSet.has(name));
771
+ const hostResolved = resolveEffectiveToolSurface({
772
+ agent: args.agentConfig,
773
+ referencedToolNames,
774
+ mentionedToolNames,
775
+ hostInjectedToolNames: hostInjectedNames,
776
+ runtimeExtraToolNames: args.runtimeOptions?.extraTools ?? []
777
+ });
778
+ const entryByName = new Map(hostResolved.entries.map((entry) => [entry.name, entry]));
779
+ const entries = finalNames.flatMap((name) => {
780
+ const entry = entryByName.get(name);
781
+ return entry ? [entry] : [];
782
+ });
783
+ return {
784
+ names: finalNames,
785
+ entries,
786
+ requestedNames,
787
+ hostInjectedNames,
788
+ shellEnabled: hostResolved.shellEnabled,
789
+ workspaceModes: hostResolved.workspaceModes,
790
+ workspaceLease: hostResolved.workspaceLease
791
+ };
792
+ }
793
+
794
+ // packages/ai/agent/serverOwnedAssistantStream.ts
795
+ var EMPTY_SERVER_OWNED_ASSISTANT_STREAM = {
796
+ text: "",
797
+ thinking: "",
798
+ segmentText: "",
799
+ segmentThinking: ""
800
+ };
801
+ function applyServerOwnedAssistantStreamPayload(state, payload) {
802
+ if (payload?.type === "thinking" && typeof payload.content === "string") {
803
+ return {
804
+ ...state,
805
+ thinking: state.thinking + payload.content,
806
+ segmentThinking: state.segmentThinking + payload.content
807
+ };
808
+ }
809
+ if (payload?.type === "text" && typeof payload.content === "string") {
810
+ return {
811
+ ...state,
812
+ text: state.text + payload.content,
813
+ segmentText: state.segmentText + payload.content
814
+ };
815
+ }
816
+ if (payload?.type === "assistant_tool_calls") {
817
+ if (!state.segmentText && !state.segmentThinking) return state;
818
+ return {
819
+ ...state,
820
+ segmentText: "",
821
+ segmentThinking: ""
822
+ };
823
+ }
824
+ return state;
825
+ }
826
+
827
+ // packages/ai/agent/serverOwnedWebForegroundTurn.ts
828
+ var SERVER_OWNED_CANONICAL_HANDOFF_PROTECT_MS = 65e3;
829
+ function resolveServerOwnedWebAllowedToolNames(toolNames) {
830
+ return Array.from(
831
+ new Set(
832
+ toolNames.filter((name) => typeof name === "string").map((name) => canonicalizeToolName(name)).filter((name) => DURABLE_WEB_FOREGROUND_TOOL_NAMES.has(name))
833
+ )
834
+ );
835
+ }
836
+ function detectServerOwnedCandidateSurface() {
837
+ return typeof window !== "undefined" && typeof document !== "undefined" ? "web" : "non-web";
838
+ }
839
+ async function canRunServerOwnedWebForegroundTurn(args, thunk) {
840
+ try {
841
+ let state;
842
+ let currentServer;
843
+ let token;
844
+ try {
845
+ state = thunk.getState();
846
+ currentServer = selectCurrentServer(state);
847
+ const rawToken = selectIdentityToken(state);
848
+ token = typeof rawToken === "string" ? rawToken : void 0;
849
+ } catch {
850
+ return { eligible: false };
851
+ }
852
+ if (!currentServer?.trim() || !token?.trim()) return { eligible: false };
853
+ let agentConfig = args.agentConfig ?? void 0;
854
+ if (!agentConfig) {
855
+ try {
856
+ const { readAndWait: readAndWait2 } = await import("./dbSlice-JQFBMJ55.js");
857
+ agentConfig = await thunk.dispatch(readAndWait2(args.agentKey)).unwrap();
858
+ } catch {
859
+ return { eligible: false };
860
+ }
861
+ }
862
+ if (!agentConfig) return { eligible: false };
863
+ const turnToolContext = await resolveTurnToolContext({
864
+ agentConfig,
865
+ dialogConfig: args.dialogConfig,
866
+ userInput: args.userInput,
867
+ state,
868
+ dispatch: thunk.dispatch,
869
+ runtimeOptions: args.runtimeOptions
870
+ });
871
+ const effectiveToolSurface = resolveServerOwnedWebEffectiveToolSurface({
872
+ agentConfig,
873
+ runtimeOptions: args.runtimeOptions,
874
+ state,
875
+ turnToolContext
876
+ });
877
+ const eligible = shouldUseServerOwnedWebForegroundTurn({
878
+ surface: detectServerOwnedCandidateSurface(),
879
+ agentConfig,
880
+ effectiveToolSurface,
881
+ turnToolContext,
882
+ userInput: args.userInput,
883
+ runtimeOptions: args.runtimeOptions,
884
+ currentServer,
885
+ token,
886
+ isDesktopApp: getIsDesktopApp()
887
+ });
888
+ if (!eligible) {
889
+ return { eligible: false, agentConfig };
890
+ }
891
+ return {
892
+ eligible: true,
893
+ agentConfig: {
894
+ ...agentConfig,
895
+ tools: resolveServerOwnedWebAllowedToolNames(effectiveToolSurface.names)
896
+ }
897
+ };
898
+ } catch {
899
+ return { eligible: false };
900
+ }
901
+ }
902
+ async function runServerOwnedWebForegroundTurn(args, thunk) {
903
+ const state = thunk.getState();
904
+ const currentServer = String(selectCurrentServer(state) ?? "").replace(/\/+$/, "");
905
+ const token = selectIdentityToken(state);
906
+ if (!currentServer || !token) {
907
+ throw new Error("Server-owned foreground turn requires an authenticated server");
908
+ }
909
+ const dialogKey = args.dialogConfig.dbKey;
910
+ const dialogId = args.dialogConfig.id ?? (dialogKey ? extractCustomId(dialogKey) : "");
911
+ if (!dialogId || !dialogKey) {
912
+ throw new Error("Server-owned foreground turn requires an existing dialog");
913
+ }
914
+ const userInput = typeof args.userInput === "string" ? args.userInput : "";
915
+ if (!userInput.trim()) {
916
+ throw new Error("Server-owned foreground turn requires text input");
917
+ }
918
+ const initialMessageIds = new Set(
919
+ selectAllMsgs(thunk.getState(), dialogId).map((message) => message?.id).filter((id) => typeof id === "string" && id.length > 0)
920
+ );
921
+ const userId = selectIdentityUserId(thunk.getState());
922
+ const { key: transientKey, messageId: transientId } = createDialogMessageKeyAndId(dialogId);
923
+ const controller = new AbortController();
924
+ const loopKey = `server-owned:${dialogId}:${transientId}`;
925
+ let assistantStream = EMPTY_SERVER_OWNED_ASSISTANT_STREAM;
926
+ let sawDone = false;
927
+ let clientControllerReleased = false;
928
+ let visibleFinalized = false;
929
+ let sawFirstDelta = false;
930
+ let observedExecutionId = "";
931
+ let canonicalVisible = false;
932
+ const stageLog = createForegroundTurnStageLog({
933
+ turnKey: loopKey,
934
+ // This path's server run identity IS the dialogId; executionId stays in the
935
+ // SUMMARY detail to tell multiple runs of the same dialog apart.
936
+ runId: dialogId,
937
+ dialogKey,
938
+ dialogId,
939
+ base: currentServer
940
+ });
941
+ const toolProjection = createServerOwnedToolProjection({
942
+ dialogId,
943
+ dispatch: thunk.dispatch,
944
+ messageMetadata: {
945
+ cybotKey: args.agentKey,
946
+ agentKey: args.agentKey,
947
+ userId
948
+ },
949
+ supportedToolNames: DURABLE_WEB_FOREGROUND_TOOL_NAMES,
950
+ keepReadOnlyUntilCanonical: ["ask_user", "show_interaction"]
951
+ });
952
+ const projectAssistant = () => {
953
+ thunk.dispatch(
954
+ messageStreaming({
955
+ id: transientId,
956
+ dialogId,
957
+ dbKey: transientKey,
958
+ role: "assistant",
959
+ content: assistantStream.text,
960
+ thinkContent: assistantStream.thinking,
961
+ cybotKey: args.agentKey,
962
+ agentKey: args.agentKey,
963
+ userId
964
+ })
965
+ );
966
+ };
967
+ const releaseClientController = () => {
968
+ if (clientControllerReleased) return;
969
+ clientControllerReleased = true;
970
+ thunk.dispatch(removeActiveController({ messageId: loopKey, dialogKey }));
971
+ clearForegroundTurnSettledVisible(dialogId);
972
+ stageLog.stage("controller-release");
973
+ };
974
+ const finalizeVisibleProjectionOnDone = () => {
975
+ if (visibleFinalized) return;
976
+ visibleFinalized = true;
977
+ protectTransientForCanonicalHandoff(
978
+ dialogId,
979
+ transientId,
980
+ SERVER_OWNED_CANONICAL_HANDOFF_PROTECT_MS
981
+ );
982
+ finishTransientImmediately();
983
+ markForegroundTurnSettledVisible(dialogId);
984
+ };
985
+ const finishTransientImmediately = () => {
986
+ const transient = selectAllMsgs(thunk.getState(), dialogId).find((message) => message?.id === transientId);
987
+ if (transient) {
988
+ thunk.dispatch(
989
+ setMessages({
990
+ dialogId,
991
+ messages: [{
992
+ ...transient,
993
+ content: assistantStream.text,
994
+ thinkContent: assistantStream.thinking,
995
+ isStreaming: false
996
+ }]
997
+ })
998
+ );
999
+ }
1000
+ setStreamingMessageId(dialogId, null);
1001
+ };
1002
+ const removeTransientWhenCanonicalArrives = () => {
1003
+ void waitForNewCanonicalAssistant({
1004
+ readMessages: () => selectAllMsgs(thunk.getState(), dialogId),
1005
+ initialMessageIds,
1006
+ transientId,
1007
+ // The server persists a new assistant trace segment after every tool
1008
+ // boundary. Fingerprint only the final segment here; the live transient
1009
+ // intentionally keeps the concatenated presentation until canonical rows
1010
+ // replace it.
1011
+ expectedText: assistantStream.segmentText,
1012
+ expectedThinking: assistantStream.segmentThinking,
1013
+ expectedAgentKey: args.agentKey,
1014
+ timeoutMs: 6e4,
1015
+ pollMs: 100
1016
+ }).then((canonical) => {
1017
+ if (!canonical) return;
1018
+ toolProjection.cleanup();
1019
+ thunk.dispatch(removeTransientMessage({ id: transientId, dialogId }));
1020
+ }).catch(() => {
1021
+ }).finally(() => {
1022
+ releaseTransientCanonicalHandoff(dialogId, transientId);
1023
+ });
1024
+ };
1025
+ thunk.dispatch(addActiveController({ messageId: loopKey, controller, dialogKey }));
1026
+ projectAssistant();
1027
+ const allowedToolNames = resolveServerOwnedWebAllowedToolNames(
1028
+ Array.isArray(args.agentConfig.tools) ? args.agentConfig.tools : []
1029
+ );
1030
+ const body = JSON.stringify({
1031
+ agentKey: args.agentKey,
1032
+ userInput,
1033
+ stream: true,
1034
+ persistDialog: true,
1035
+ continueDialogId: dialogId,
1036
+ runtimeContext: {
1037
+ surface: "web",
1038
+ host: "browser",
1039
+ runtime: "react",
1040
+ entrypoint: "chat-dialog-server-owned",
1041
+ capabilities: [
1042
+ "streaming",
1043
+ "dialog-ui",
1044
+ "durable-foreground",
1045
+ "client-user-prepersisted",
1046
+ "durable-tool-cards"
1047
+ ],
1048
+ // This is the exact post-filter surface produced during admission, not a
1049
+ // global durable superset. Server-private defaults and machine tools are
1050
+ // injected before this constraint, then intersected back to this turn's
1051
+ // admitted names. Direct run() callers are sanitized again above.
1052
+ allowedToolNames,
1053
+ ...args.dialogConfig.agentMode === "auto" ? { dialogAgentMode: "auto" } : { dialogAgentMode: "fixed" }
1054
+ },
1055
+ ...args.runtimeOptions ? { runtimeOptions: args.runtimeOptions } : {},
1056
+ ...args.contextBlocks?.length ? { contextBlocks: args.contextBlocks } : {},
1057
+ ...args.dialogConfig.spaceId ? { spaceId: args.dialogConfig.spaceId } : {}
1058
+ });
1059
+ const init = buildForegroundTurnAdmissionFetchInit({
1060
+ body,
1061
+ headers: {
1062
+ "Content-Type": "application/json",
1063
+ Accept: "text/event-stream",
1064
+ Authorization: `Bearer ${token}`
1065
+ },
1066
+ signal: controller.signal
1067
+ });
1068
+ stageLog.stage(
1069
+ "run-fetch-start",
1070
+ `endpoint=${currentServer}/api/agent/run agentKey=${args.agentKey}`
1071
+ );
1072
+ try {
1073
+ let response;
1074
+ try {
1075
+ response = await performServerProxyFetchWithRetry({
1076
+ execute: () => fetch(`${currentServer}/api/agent/run`, init),
1077
+ signal: controller.signal,
1078
+ retryNetworkErrors: false,
1079
+ logPrefix: "[serverOwnedWebForegroundTurn]"
1080
+ });
1081
+ } catch (error) {
1082
+ if (controller.signal.aborted) return { serverOwned: true, aborted: true };
1083
+ console.warn("[chat] server-owned foreground detached before response", {
1084
+ dialogId,
1085
+ error
1086
+ });
1087
+ return { serverOwned: true, detached: true };
1088
+ }
1089
+ stageLog.stage("headers", `status=${response.status} ok=${response.ok}`);
1090
+ if (!response.ok) {
1091
+ const text = await response.text().catch(() => "");
1092
+ throw new Error(text || `Agent run failed (${response.status})`);
1093
+ }
1094
+ const reader = response.body?.getReader();
1095
+ if (!reader) {
1096
+ stageLog.stage("no-stream-body");
1097
+ return { serverOwned: true, detached: true };
1098
+ }
1099
+ const parseSSE = createSSEParser();
1100
+ const decoder = new TextDecoder();
1101
+ const outcome = await consumeAgentRunStream({
1102
+ reader,
1103
+ decoder,
1104
+ parseChunk: (raw) => parseSSE(raw),
1105
+ isAborted: () => controller.signal.aborted,
1106
+ signal: controller.signal,
1107
+ isDoneEvent: (payload) => payload?.type === "done",
1108
+ onAbort: async () => {
1109
+ },
1110
+ onPayload: (payload) => {
1111
+ if (payload?.type === "dialog") {
1112
+ observedExecutionId = typeof payload.executionId === "string" ? payload.executionId.trim() : "";
1113
+ }
1114
+ if (payload?.type === "error") {
1115
+ return { reject: payload.message || "Agent execution failed" };
1116
+ }
1117
+ toolProjection.handlePayload(payload);
1118
+ const nextAssistantStream = applyServerOwnedAssistantStreamPayload(
1119
+ assistantStream,
1120
+ payload
1121
+ );
1122
+ if (nextAssistantStream !== assistantStream) {
1123
+ assistantStream = nextAssistantStream;
1124
+ projectAssistant();
1125
+ if (!sawFirstDelta && payload?.type !== "done") {
1126
+ sawFirstDelta = true;
1127
+ stageLog.stage(
1128
+ "first-delta",
1129
+ `payloadType=${payload?.type} executionId=${observedExecutionId}`
1130
+ );
1131
+ }
1132
+ }
1133
+ if (payload?.type === "done" && !visibleFinalized) {
1134
+ stageLog.stage("done-frame", `executionId=${observedExecutionId}`);
1135
+ finalizeVisibleProjectionOnDone();
1136
+ }
1137
+ }
1138
+ });
1139
+ stageLog.stage(
1140
+ "eof",
1141
+ outcome.outcome === "streamEnded" ? `outcome=streamEnded sawDone=${outcome.sawDone} executionId=${observedExecutionId}` : `outcome=${outcome.outcome}`
1142
+ );
1143
+ if (outcome.outcome === "aborted") return { serverOwned: true, aborted: true };
1144
+ if (outcome.outcome === "rejected") throw new Error(outcome.message);
1145
+ if (!outcome.sawDone) return { serverOwned: true, detached: true };
1146
+ sawDone = true;
1147
+ finalizeVisibleProjectionOnDone();
1148
+ try {
1149
+ stageLog.stage("init-msgs-start", `dialogKey=${dialogKey}`);
1150
+ const initMsgsStartedAt = Date.now();
1151
+ await thunk.dispatch(
1152
+ initMsgs({
1153
+ dialogId,
1154
+ dialogKey,
1155
+ preferredServerOrigin: currentServer
1156
+ })
1157
+ ).unwrap();
1158
+ stageLog.stage("init-msgs-end", `ms=${Date.now() - initMsgsStartedAt}`);
1159
+ canonicalVisible = !!await waitForNewCanonicalAssistant({
1160
+ readMessages: () => selectAllMsgs(thunk.getState(), dialogId),
1161
+ initialMessageIds,
1162
+ transientId,
1163
+ expectedText: assistantStream.segmentText,
1164
+ expectedThinking: assistantStream.segmentThinking,
1165
+ expectedAgentKey: args.agentKey,
1166
+ timeoutMs: 350,
1167
+ pollMs: 25
1168
+ });
1169
+ } catch (error) {
1170
+ console.warn("[chat] server-owned canonical handoff refresh failed", {
1171
+ dialogId,
1172
+ error
1173
+ });
1174
+ }
1175
+ if (canonicalVisible) {
1176
+ releaseTransientCanonicalHandoff(dialogId, transientId);
1177
+ toolProjection.cleanup();
1178
+ thunk.dispatch(removeTransientMessage({ id: transientId, dialogId }));
1179
+ } else {
1180
+ toolProjection.cleanup();
1181
+ removeTransientWhenCanonicalArrives();
1182
+ console.warn(
1183
+ "[chat] server-owned canonical message not visible after done; keeping finished transient until canonical arrives",
1184
+ { dialogId, transientId }
1185
+ );
1186
+ }
1187
+ return { serverOwned: true };
1188
+ } finally {
1189
+ releaseClientController();
1190
+ if (!sawDone && !visibleFinalized) {
1191
+ releaseTransientCanonicalHandoff(dialogId, transientId);
1192
+ toolProjection.cleanup();
1193
+ thunk.dispatch(removeTransientMessage({ id: transientId, dialogId }));
1194
+ }
1195
+ if (visibleFinalized && !sawDone) {
1196
+ toolProjection.cleanup();
1197
+ removeTransientWhenCanonicalArrives();
1198
+ }
1199
+ stageLog.summary(
1200
+ controller.signal.aborted ? "aborted" : sawDone ? "done" : visibleFinalized ? "done-visible-only" : "no-done",
1201
+ `runId=${dialogId} executionId=${observedExecutionId} canonicalVisible=${canonicalVisible} settledVisible=${visibleFinalized}`
1202
+ );
1203
+ }
1204
+ }
1205
+
1206
+ // packages/chat/dialog/actions/parseOAuthError.ts
1207
+ var PROVIDER_NAMES = {
1208
+ antigravity: "Antigravity (Google)",
1209
+ claude: "Claude",
1210
+ chatgpt: "ChatGPT",
1211
+ xai: "xAI Grok",
1212
+ cursor: "Cursor",
1213
+ cloudflare: "Cloudflare"
1214
+ };
1215
+ function asRecord(value) {
1216
+ if (value && typeof value === "object" && !Array.isArray(value)) {
1217
+ return value;
1218
+ }
1219
+ return null;
1220
+ }
1221
+ function asString(value) {
1222
+ return typeof value === "string" && value.length > 0 ? value : void 0;
1223
+ }
1224
+ function extractFullErrorText(error) {
1225
+ if (!error) return "Unknown error";
1226
+ if (typeof error === "string") return error;
1227
+ if (error instanceof Error) {
1228
+ let msg = error.message || error.name || String(error);
1229
+ const seen = /* @__PURE__ */ new Set([error]);
1230
+ let current = error.cause;
1231
+ while (current && !seen.has(current)) {
1232
+ seen.add(current);
1233
+ const causeMsg = current instanceof Error ? current.message || String(current) : typeof current === "string" ? current : JSON.stringify(current);
1234
+ if (causeMsg && !msg.includes(causeMsg)) {
1235
+ msg = `${msg}
1236
+ [cause]: ${causeMsg}`;
1237
+ }
1238
+ current = current?.cause;
1239
+ }
1240
+ return msg;
1241
+ }
1242
+ return error?.message || error?.error || String(error);
1243
+ }
1244
+ function collectValidationFromDetails(details) {
1245
+ return scanValidationDetails(details);
1246
+ }
1247
+ function resolveErrorStage(errorText) {
1248
+ if (/127\.0\.0\.1:3233|localhost:3233|desktop daemon|desktop agent runtime|runDesktopAgentRuntime|Local turn stream/i.test(
1249
+ errorText
1250
+ )) {
1251
+ return "desktop_local_runtime";
1252
+ }
1253
+ if (/\/api\/ai\/chat\/proxy|server proxy|core_draining|fetchWithServerProxy/i.test(
1254
+ errorText
1255
+ )) {
1256
+ return "server_proxy";
1257
+ }
1258
+ if (/OAuth provider failed|provider failed|antigravity|claude|chatgpt|openai|gemini|deepseek/i.test(
1259
+ errorText
1260
+ )) {
1261
+ return "provider";
1262
+ }
1263
+ return void 0;
1264
+ }
1265
+ function parseSendError(errorInput) {
1266
+ const fullErrorText = extractFullErrorText(errorInput).trim();
1267
+ const firstLine = fullErrorText.replace(/^local\s+/, "").split("\n")[0].trim();
1268
+ const providerMatch = fullErrorText.match(/local\s+(\w+)\s+OAuth provider failed/i);
1269
+ const providerName = providerMatch ? PROVIDER_NAMES[providerMatch[1].toLowerCase()] ?? providerMatch[1] : void 0;
1270
+ const statusMatch = fullErrorText.match(/HTTP\s+(\d{3})/i) || fullErrorText.match(/\bstatus(?:\s+code)?[:=]?\s*(\d{3})\b/i) || fullErrorText.match(/^(?:HTTP\/[\d.]+\s+)?([45]\d{2})\b/i);
1271
+ const status = statusMatch?.[1];
1272
+ const statusCode = status ? parseInt(status, 10) : void 0;
1273
+ const jsonStart = fullErrorText.indexOf("{");
1274
+ let payload = null;
1275
+ if (jsonStart >= 0) {
1276
+ let candidate = fullErrorText.slice(jsonStart);
1277
+ for (let depth = 0; depth < 3; depth += 1) {
1278
+ try {
1279
+ const parsed = JSON.parse(candidate);
1280
+ payload = parsed;
1281
+ const message = asString(
1282
+ parsed?.error?.message ?? parsed?.message
1283
+ );
1284
+ if (message && message.trim().startsWith("{")) {
1285
+ candidate = message;
1286
+ continue;
1287
+ }
1288
+ break;
1289
+ } catch {
1290
+ break;
1291
+ }
1292
+ }
1293
+ }
1294
+ const errorRec = payload ? asRecord(payload.error) : null;
1295
+ const innerMessage = errorRec ? asString(errorRec.message) : void 0;
1296
+ const statusFromBody = errorRec ? asString(errorRec.status) : void 0;
1297
+ const details = errorRec?.details;
1298
+ const { url, text, learnMoreUrl } = collectValidationFromDetails(details);
1299
+ let reason = errorRec ? asString(errorRec.reason) : void 0;
1300
+ let domain = errorRec ? asString(errorRec.domain) : void 0;
1301
+ if (!reason && Array.isArray(details)) {
1302
+ const first = asRecord(details[0]);
1303
+ reason = first ? asString(first.reason) : void 0;
1304
+ domain = first ? asString(first.domain) : void 0;
1305
+ }
1306
+ const stage = resolveErrorStage(fullErrorText);
1307
+ const inputRecord = asRecord(errorInput);
1308
+ const authCode = asString(inputRecord?.authCode) ?? asString(inputRecord?.code);
1309
+ const hasPlatformAuthCode = /^AUTH_[A-Z0-9_]+$/.test(authCode ?? "") || /\bAUTH_[A-Z0-9_]+\b/.test(fullErrorText);
1310
+ const isPlatformProviderFailure = /\bplatform provider failed\b/i.test(fullErrorText);
1311
+ const isLoginStatus = statusCode === void 0 || statusCode === 401;
1312
+ const requiresLogin = isLoginStatus && !url && !/validation_required|api[_ -]?key/i.test(fullErrorText) && (hasPlatformAuthCode || isPlatformProviderFailure && statusCode === 401);
1313
+ if (requiresLogin) {
1314
+ return {
1315
+ kind: "auth",
1316
+ retryable: false,
1317
+ stage,
1318
+ summary: "\u9700\u8981\u767B\u5F55",
1319
+ actionHint: "\u672A\u68C0\u6D4B\u5230\u767B\u5F55\u72B6\u6001\uFF0C\u8BF7\u5148\u767B\u5F55",
1320
+ extraLinks: [{ text: "\u53BB\u767B\u5F55", url: "/login" }]
1321
+ };
1322
+ }
1323
+ const isPlatformBusy = fullErrorText.includes(PLATFORM_LLM_BUSY_USER_MESSAGE) || /PLATFORM_LLM_BUSY/i.test(fullErrorText);
1324
+ const busyUpstreamDetail = fullErrorText.match(
1325
+ /nolo\s+(?:HTTP\s*\d{3}|[A-Za-z]+Error)/
1326
+ )?.[0];
1327
+ let kind = "unknown";
1328
+ let retryable = true;
1329
+ const isLocalConnRefused = /ECONNREFUSED/i.test(fullErrorText) && (/127\.0\.0\.1/i.test(fullErrorText) || /localhost/i.test(fullErrorText));
1330
+ const hasExplicitAuthKeywords = /unauthorized|unauthenticated|permission_denied|validation_required|invalid_api_key|api key not found|authentication error|forbidden/i.test(
1331
+ fullErrorText
1332
+ );
1333
+ const isContextOverflow = isContextOverflowText(fullErrorText);
1334
+ let contextActions;
1335
+ if (isContextOverflow) {
1336
+ kind = "context_overflow";
1337
+ retryable = true;
1338
+ contextActions = [...CONTEXT_OVERFLOW_ACTIONS];
1339
+ } else if (isPlatformBusy) {
1340
+ kind = "server";
1341
+ retryable = true;
1342
+ } else if (statusCode === 429) {
1343
+ kind = "rate_limit";
1344
+ retryable = true;
1345
+ } else if (statusCode === 413) {
1346
+ kind = "context_too_large";
1347
+ retryable = true;
1348
+ contextActions = [...CONTEXT_TOO_LARGE_ACTIONS];
1349
+ } else if (statusCode === 401 || statusCode === 403 || hasExplicitAuthKeywords) {
1350
+ kind = "auth";
1351
+ retryable = false;
1352
+ } else if (statusCode && statusCode >= 500 && statusCode < 600) {
1353
+ kind = "server";
1354
+ retryable = true;
1355
+ } else if (/timed out|timeout|ETIMEDOUT|deadline exceeded|upstream request timeout/i.test(
1356
+ fullErrorText
1357
+ ) || /aborted due to timeout/i.test(fullErrorText)) {
1358
+ kind = "timeout";
1359
+ retryable = true;
1360
+ } else if (/failed to fetch|network error|fetch failed|load failed|network request failed|networkerror|ECONNREFUSED|ENOTFOUND|ECONNRESET|EHOSTUNREACH|ENETUNREACH|EAI_AGAIN|UND_ERR_CONNECT_TIMEOUT|UND_ERR_SOCKET|socket hang up|socket closed|connection closed|certificate|handshake/i.test(
1361
+ fullErrorText
1362
+ )) {
1363
+ kind = "network";
1364
+ retryable = true;
1365
+ } else if (/rate limit|too many requests|quota exceeded|resource exhausted|insufficient_quota/i.test(
1366
+ fullErrorText
1367
+ )) {
1368
+ kind = "rate_limit";
1369
+ retryable = true;
1370
+ } else if (/internal server error|bad gateway|service unavailable|gateway timeout|core_draining/i.test(
1371
+ fullErrorText
1372
+ )) {
1373
+ kind = "server";
1374
+ retryable = true;
1375
+ } else {
1376
+ kind = "unknown";
1377
+ retryable = true;
1378
+ }
1379
+ const parts = [];
1380
+ if (providerName) {
1381
+ const head = `${providerName} \u8FDE\u63A5\u5931\u8D25`;
1382
+ parts.push(
1383
+ `${head}${status ? ` (HTTP ${status})` : ""}${statusFromBody ? ` ${statusFromBody}` : ""}`
1384
+ );
1385
+ } else {
1386
+ switch (kind) {
1387
+ case "network":
1388
+ if (isLocalConnRefused) {
1389
+ parts.push("\u672C\u5730\u670D\u52A1\u8FDE\u63A5\u5931\u8D25");
1390
+ } else if (/ENOTFOUND/i.test(fullErrorText)) {
1391
+ parts.push("\u57DF\u540D\u89E3\u6790\u5931\u8D25");
1392
+ } else {
1393
+ parts.push("\u8FDE\u63A5\u4E2D\u65AD");
1394
+ }
1395
+ break;
1396
+ case "timeout":
1397
+ parts.push("\u8BF7\u6C42\u8D85\u65F6");
1398
+ break;
1399
+ case "rate_limit":
1400
+ parts.push(`\u8BF7\u6C42\u8FC7\u4E8E\u9891\u7E41${status ? ` (HTTP ${status})` : ""}`);
1401
+ break;
1402
+ case "auth":
1403
+ parts.push(`\u8BA4\u8BC1\u6216\u6743\u9650\u6821\u9A8C\u5931\u8D25${status ? ` (HTTP ${status})` : ""}`);
1404
+ break;
1405
+ case "server":
1406
+ parts.push(
1407
+ isPlatformBusy ? `\u5E73\u53F0\u670D\u52A1\u7E41\u5FD9${busyUpstreamDetail ? `\uFF08\u4E0A\u6E38 ${busyUpstreamDetail}\uFF09` : ""}` : `\u670D\u52A1\u6682\u65F6\u4E0D\u53EF\u7528${status ? ` (HTTP ${status})` : ""}`
1408
+ );
1409
+ break;
1410
+ case "context_overflow":
1411
+ parts.push(`\u4E0A\u4E0B\u6587\u8D85\u51FA\u6A21\u578B\u7A97\u53E3${status ? ` (HTTP ${status})` : ""}`);
1412
+ break;
1413
+ case "context_too_large":
1414
+ parts.push(`\u8BF7\u6C42\u5185\u5BB9\u8FC7\u5927${status ? ` (HTTP ${status})` : ""}`);
1415
+ break;
1416
+ default:
1417
+ parts.push(firstLine.length > 0 ? firstLine : "\u53D1\u9001\u9047\u5230\u5F02\u5E38");
1418
+ break;
1419
+ }
1420
+ }
1421
+ if (reason) {
1422
+ parts.push(`\u539F\u56E0\uFF1A${reason}`);
1423
+ }
1424
+ if (domain) {
1425
+ parts.push(`\u670D\u52A1\uFF1A${domain}`);
1426
+ }
1427
+ const humanMessage = innerMessage && innerMessage.trim() !== "Verify your account to continue." ? innerMessage : void 0;
1428
+ if (humanMessage) {
1429
+ parts.push(`\u63D0\u793A\uFF1A${humanMessage}`);
1430
+ }
1431
+ let actionHint;
1432
+ if (url) {
1433
+ actionHint = "\u8BF7\u70B9\u51FB\u94FE\u63A5\u5B8C\u6210\u9A8C\u8BC1";
1434
+ } else {
1435
+ switch (kind) {
1436
+ case "network":
1437
+ if (isLocalConnRefused) {
1438
+ actionHint = "\u65E0\u6CD5\u8FDE\u63A5\u5230\u672C\u5730\u670D\u52A1\uFF0C\u8BF7\u786E\u8BA4\u684C\u9762\u7AEF\u540E\u53F0\u670D\u52A1\u6B63\u5728\u8FD0\u884C\u540E\u91CD\u8BD5";
1439
+ } else if (/ENOTFOUND/i.test(fullErrorText)) {
1440
+ actionHint = "\u65E0\u6CD5\u89E3\u6790\u670D\u52A1\u5730\u5740\uFF0C\u53EF\u80FD\u662F DNS \u6216\u7F51\u7EDC\u73AF\u5883\u6CE2\u52A8\uFF0C\u70B9\u51FB\u91CD\u8BD5\u901A\u5E38\u53EF\u6062\u590D";
1441
+ } else {
1442
+ actionHint = "\u53EF\u80FD\u662F\u7F51\u7EDC\u6CE2\u52A8\u6216\u670D\u52A1\u7AEF\u77AC\u65F6\u95EE\u9898\uFF0C\u70B9\u51FB\u91CD\u8BD5\u901A\u5E38\u53EF\u6062\u590D";
1443
+ }
1444
+ break;
1445
+ case "timeout":
1446
+ actionHint = "\u670D\u52A1\u54CD\u5E94\u8D85\u65F6\uFF0C\u53EF\u80FD\u662F\u7F51\u7EDC\u6CE2\u52A8\u6216\u670D\u52A1\u8D1F\u8F7D\u8F83\u9AD8\uFF0C\u70B9\u51FB\u91CD\u8BD5\u901A\u5E38\u53EF\u6062\u590D";
1447
+ break;
1448
+ case "rate_limit":
1449
+ actionHint = "\u5DF2\u8FBE\u5230\u8C03\u7528\u9891\u7387\u6216\u914D\u989D\u9650\u5236\uFF0C\u8BF7\u7A0D\u5019\u7247\u523B\u540E\u91CD\u8BD5";
1450
+ break;
1451
+ case "context_overflow":
1452
+ actionHint = "\u4E0A\u4E0B\u6587\u8D85\u51FA\u6A21\u578B\u7A97\u53E3\uFF1A\u53EF\u538B\u7F29\u5386\u53F2\u540E\u91CD\u8BD5\u3001\u5F00\u542F\u65B0\u5BF9\u8BDD\uFF0C\u6216\u5207\u6362\u5230\u66F4\u5927\u7A97\u53E3\u7684\u6A21\u578B\u3002";
1453
+ break;
1454
+ case "context_too_large":
1455
+ actionHint = "\u5355\u6B21\u8BF7\u6C42\u5185\u5BB9\u8FC7\u5927\uFF1A\u8BF7\u51CF\u5C11\u53D1\u9001\u7684\u6D88\u606F\u3001\u6587\u4EF6\u6216\u5DE5\u5177\u7ED3\u679C\uFF0C\u6216\u5F00\u542F\u65B0\u5BF9\u8BDD\u3001\u5207\u6362\u6A21\u578B\u3002";
1456
+ break;
1457
+ case "auth":
1458
+ actionHint = "\u8BF7\u68C0\u67E5\u8D26\u53F7\u767B\u5F55\u72B6\u6001\u6216 API \u5BC6\u94A5\u914D\u7F6E";
1459
+ break;
1460
+ case "server":
1461
+ actionHint = isPlatformBusy ? "\u5E73\u53F0\u7B97\u529B\u6682\u65F6\u7D27\u5F20\uFF0C\u7A0D\u5019\u70B9\u51FB\u91CD\u8BD5\u901A\u5E38\u53EF\u6062\u590D" : "\u670D\u52A1\u7AEF\u53D1\u751F\u77AC\u65F6\u5F02\u5E38\uFF0C\u70B9\u51FB\u91CD\u8BD5\u901A\u5E38\u53EF\u6062\u590D";
1462
+ break;
1463
+ case "unknown":
1464
+ default:
1465
+ actionHint = "\u9047\u5230\u5F02\u5E38\uFF0C\u70B9\u51FB\u91CD\u8BD5\u901A\u5E38\u53EF\u6062\u590D";
1466
+ break;
1467
+ }
1468
+ }
1469
+ const extraLinks = [];
1470
+ if (learnMoreUrl) {
1471
+ extraLinks.push({ text: "\u4E86\u89E3\u66F4\u591A", url: learnMoreUrl });
1472
+ }
1473
+ const summary = parts.join("\n");
1474
+ if (url) {
1475
+ return {
1476
+ kind,
1477
+ retryable,
1478
+ stage,
1479
+ actionHint,
1480
+ summary,
1481
+ validationUrl: url,
1482
+ validationLinkText: text ?? "\u9A8C\u8BC1\u6211\u7684\u8D26\u53F7",
1483
+ extraLinks,
1484
+ ...contextActions ? { actions: contextActions } : {}
1485
+ };
1486
+ }
1487
+ const MAX_FALLBACK = 800;
1488
+ const fallbackText = fullErrorText.length > MAX_FALLBACK ? `${fullErrorText.slice(0, MAX_FALLBACK)}\u2026` : fullErrorText;
1489
+ return {
1490
+ kind,
1491
+ retryable,
1492
+ stage,
1493
+ actionHint,
1494
+ summary,
1495
+ extraLinks,
1496
+ fallbackText,
1497
+ ...contextActions ? { actions: contextActions } : {}
1498
+ };
1499
+ }
1500
+ function buildSendErrorMessageMarkdown(parsed) {
1501
+ const lines = ["[\u53D1\u9001\u5931\u8D25]", "", parsed.summary];
1502
+ if (parsed.actionHint && !parsed.validationUrl) {
1503
+ lines.push("", `\u5EFA\u8BAE\uFF1A${parsed.actionHint}`);
1504
+ }
1505
+ if (parsed.validationUrl) {
1506
+ lines.push(
1507
+ "",
1508
+ `\u8BF7\u70B9\u51FB\u94FE\u63A5\u5B8C\u6210\u9A8C\u8BC1\uFF1A`,
1509
+ `- [${parsed.validationLinkText ?? "\u9A8C\u8BC1\u6211\u7684\u8D26\u53F7"}](${parsed.validationUrl})`
1510
+ );
1511
+ }
1512
+ for (const link of parsed.extraLinks) {
1513
+ lines.push(`- [${link.text}](${link.url})`);
1514
+ }
1515
+ if (parsed.fallbackText && !parsed.validationUrl) {
1516
+ lines.push("", "```", parsed.fallbackText, "```");
1517
+ }
1518
+ return lines.join("\n");
1519
+ }
1520
+
1521
+ // packages/chat/dialog/actions/handleSendMessageAction.ts
1522
+ var getDialogConfig = (state, dialogKey) => {
1523
+ const resolvedDialogKey = dialogKey ?? getActiveDialogKey();
1524
+ if (!resolvedDialogKey) return null;
1525
+ const dialog = selectById(state, resolvedDialogKey);
1526
+ return dialog ?? null;
1527
+ };
1528
+ var ensureDialogConfig = async (dispatch, getState, dialogKey) => {
1529
+ const state = getState();
1530
+ const resolvedDialogKey = dialogKey ?? getActiveDialogKey();
1531
+ if (!resolvedDialogKey) return null;
1532
+ try {
1533
+ const existingDialog = getDialogConfig(state, resolvedDialogKey);
1534
+ if (existingDialog && Array.isArray(existingDialog.cybots) && existingDialog.cybots.length > 0) {
1535
+ return existingDialog;
1536
+ }
1537
+ const persistedDialog = await dispatch(readAndWait(resolvedDialogKey)).unwrap();
1538
+ if (persistedDialog) return persistedDialog;
1539
+ return existingDialog;
1540
+ } catch {
1541
+ return getDialogConfig(getState(), resolvedDialogKey);
1542
+ }
1543
+ };
1544
+ var logQuickChatPerfStage = (startedAt, stage, details = {}) => {
1545
+ if (!startedAt) return;
1546
+ const now = typeof performance !== "undefined" ? performance.now() : Date.now();
1547
+ console.info("[QuickChatPerf]", {
1548
+ stage,
1549
+ elapsedMs: now - startedAt,
1550
+ ...typeof performance !== "undefined" ? { atMs: now } : {},
1551
+ ...details
1552
+ });
1553
+ };
1554
+ var resolveBrowseContextPrefix = async (message) => {
1555
+ try {
1556
+ if (typeof window === "undefined" || typeof location === "undefined") return "";
1557
+ if (typeof process !== "undefined" && (process.env?.NODE_ENV === "test" || process.env?.BUN_TEST)) return "";
1558
+ const host = location.hostname;
1559
+ if (host !== "127.0.0.1" && host !== "localhost") return "";
1560
+ if (typeof fetch !== "function" || typeof AbortSignal?.timeout !== "function") return "";
1561
+ const response = await fetch("/api/desktop/browse-context", {
1562
+ method: "POST",
1563
+ headers: { "Content-Type": "application/json" },
1564
+ body: JSON.stringify({ message }),
1565
+ signal: AbortSignal.timeout(2e3)
1566
+ });
1567
+ if (!response.ok) return "";
1568
+ const payload = await response.json();
1569
+ if (!payload.context || !payload.context.url) return "";
1570
+ const ctx = payload.context;
1571
+ const parts = [`[\u5F53\u524D\u6D4F\u89C8\u4E0A\u4E0B\u6587]`, `URL: ${ctx.url}`, `\u6807\u9898: ${ctx.title}`];
1572
+ if (ctx.textSnippet) parts.push(`\u6458\u8981: ${ctx.textSnippet.slice(0, 2e3)}`);
1573
+ return parts.join("\n");
1574
+ } catch {
1575
+ return "";
1576
+ }
1577
+ };
1578
+ var finalizeQuickChatStreamStartupFailure = async (dispatch, dialogConfig, agentKey) => {
1579
+ const dialogKey = dialogConfig.dbKey;
1580
+ const dialogId = dialogConfig.id ?? (dialogKey ? extractCustomId(dialogKey) : "");
1581
+ const { key: msgKey, messageId } = createDialogMessageKeyAndId(dialogId);
1582
+ await dispatch(
1583
+ messageStreamEnd({
1584
+ finalContentBuffer: [
1585
+ {
1586
+ type: "text",
1587
+ text: "[\u9519\u8BEF: \u672A\u80FD\u542F\u52A8\u6A21\u578B\u56DE\u590D\uFF0C\u8BF7\u91CD\u8BD5\u3002]"
1588
+ }
1589
+ ],
1590
+ totalUsage: null,
1591
+ msgKey,
1592
+ agentConfig: {
1593
+ dbKey: agentKey
1594
+ },
1595
+ dialogId,
1596
+ dialogKey: dialogKey ?? "",
1597
+ messageId,
1598
+ reasoningBuffer: ""
1599
+ })
1600
+ ).unwrap?.();
1601
+ };
1602
+ var finalizeSendFailureInDialog = async (dispatch, dialogConfig, agentKey, errorInput) => {
1603
+ const dialogKey = dialogConfig.dbKey;
1604
+ const dialogId = dialogConfig.id ?? (dialogKey ? extractCustomId(dialogKey) : "");
1605
+ const { key: msgKey, messageId } = createDialogMessageKeyAndId(dialogId);
1606
+ const parsed = parseSendError(errorInput);
1607
+ const errorMeta = {
1608
+ kind: parsed.kind,
1609
+ retryable: parsed.retryable,
1610
+ stage: parsed.stage,
1611
+ summary: parsed.summary,
1612
+ actionHint: parsed.actionHint,
1613
+ // 上下文超窗 / 内容过大时带上结构化动作(review 修复 2):
1614
+ // 没有这个字段,SendErrorCard 的 compact-and-retry / new-dialog /
1615
+ // switch-model 三枚按钮永远不会出现,用户只剩一行文本提示。
1616
+ // 其余 kind 不设 → 卡片只渲染重试。
1617
+ ...parsed.actions ? { actions: parsed.actions } : {},
1618
+ validationUrl: parsed.validationUrl,
1619
+ validationLinkText: parsed.validationLinkText,
1620
+ extraLinks: parsed.extraLinks,
1621
+ fallbackText: parsed.fallbackText,
1622
+ rawError: parsed.fallbackText
1623
+ };
1624
+ await dispatch(
1625
+ messageStreamEnd({
1626
+ finalContentBuffer: [
1627
+ {
1628
+ type: "text",
1629
+ text: buildSendErrorMessageMarkdown(parsed)
1630
+ }
1631
+ ],
1632
+ totalUsage: null,
1633
+ msgKey,
1634
+ agentConfig: {
1635
+ dbKey: agentKey
1636
+ },
1637
+ dialogId,
1638
+ dialogKey: dialogKey ?? "",
1639
+ messageId,
1640
+ reasoningBuffer: "",
1641
+ messageMetadata: {
1642
+ errorMeta
1643
+ }
1644
+ })
1645
+ ).unwrap?.();
1646
+ };
1647
+ var handleSendMessageAction = async (args, { dispatch, getState, rejectWithValue }) => {
1648
+ let dialogConfig = null;
1649
+ let agentKeyToUse;
1650
+ try {
1651
+ logQuickChatPerfStage(args.quickChatPerfStartedAt, "handle-send-message-entered", {
1652
+ dialogKey: args.dialogKey ?? null
1653
+ });
1654
+ dialogConfig = await ensureDialogConfig(dispatch, getState, args.dialogKey);
1655
+ if (!dialogConfig) {
1656
+ throw new Error(
1657
+ "handleSendMessage: Dialog configuration is missing."
1658
+ );
1659
+ }
1660
+ logQuickChatPerfStage(args.quickChatPerfStartedAt, "handle-send-message-dialog-ready", {
1661
+ dialogKey: dialogConfig.dbKey,
1662
+ cybotCount: dialogConfig.cybots?.length ?? 0
1663
+ });
1664
+ let effectiveRawUserInput = args.userInput;
1665
+ if (args.isRetry) {
1666
+ if (!effectiveRawUserInput) {
1667
+ const dialogId = dialogConfig.id ?? (dialogConfig.dbKey ? extractCustomId(dialogConfig.dbKey) : "");
1668
+ const state = getState();
1669
+ try {
1670
+ const messages = selectAllMsgs(state, dialogId);
1671
+ if (Array.isArray(messages) && messages.length > 0) {
1672
+ let targetIndex = messages.length - 1;
1673
+ if (args.retryMessageId) {
1674
+ const foundIdx = messages.findIndex((m) => m?.id === args.retryMessageId);
1675
+ if (foundIdx >= 0) {
1676
+ targetIndex = foundIdx;
1677
+ }
1678
+ }
1679
+ for (let i = targetIndex; i >= 0; i--) {
1680
+ const m = messages[i];
1681
+ if (m?.role === "user" && m.content) {
1682
+ effectiveRawUserInput = m.content;
1683
+ break;
1684
+ }
1685
+ }
1686
+ }
1687
+ } catch {
1688
+ }
1689
+ }
1690
+ if (!effectiveRawUserInput || typeof effectiveRawUserInput === "string" && !effectiveRawUserInput.trim() || Array.isArray(effectiveRawUserInput) && effectiveRawUserInput.length === 0) {
1691
+ console.warn("[handleSendMessage] isRetry: No preceding user message found to retry.");
1692
+ return rejectWithValue("\u672A\u627E\u5230\u53EF\u91CD\u8BD5\u7684\u7528\u6237\u8F93\u5165");
1693
+ }
1694
+ } else {
1695
+ await dispatch(
1696
+ prepareAndPersistUserMessage({
1697
+ userInput: args.userInput ?? "",
1698
+ dialogConfig
1699
+ })
1700
+ ).unwrap();
1701
+ logQuickChatPerfStage(args.quickChatPerfStartedAt, "handle-send-message-user-persisted", {
1702
+ dialogKey: dialogConfig.dbKey
1703
+ });
1704
+ }
1705
+ const selectedRuntimeTarget = dialogConfig.runtimeBinding?.target;
1706
+ const resolvedContext = resolveHandleSendMessageContext({
1707
+ dialogConfig,
1708
+ targetAgentKey: args.targetAgentKey,
1709
+ runtimeOptions: {
1710
+ ...args.runtimeOptions,
1711
+ ...selectedRuntimeTarget && (selectedRuntimeTarget.kind === "server" || selectedRuntimeTarget.kind === "machine") ? { runtimeTarget: selectedRuntimeTarget } : {}
1712
+ }
1713
+ });
1714
+ agentKeyToUse = resolvedContext.agentKeyToUse;
1715
+ const agentConfigToUse = resolvedContext.agentConfigToUse;
1716
+ const effectiveRuntimeOptions = resolvedContext.effectiveRuntimeOptions;
1717
+ if (!agentKeyToUse) {
1718
+ return;
1719
+ }
1720
+ const userInputText = typeof effectiveRawUserInput === "string" ? effectiveRawUserInput : "";
1721
+ const isDesktopContext = typeof window !== "undefined" && typeof location !== "undefined" && (location.hostname === "127.0.0.1" || location.hostname === "localhost");
1722
+ const browseContextPrefix = isDesktopContext ? await resolveBrowseContextPrefix(userInputText) : "";
1723
+ const serverOwnedCandidate = await canRunServerOwnedWebForegroundTurn(
1724
+ {
1725
+ agentKey: agentKeyToUse,
1726
+ agentConfig: agentConfigToUse,
1727
+ userInput: effectiveRawUserInput,
1728
+ dialogConfig,
1729
+ runtimeOptions: effectiveRuntimeOptions,
1730
+ contextBlocks: browseContextPrefix ? [browseContextPrefix] : void 0
1731
+ },
1732
+ { dispatch, getState }
1733
+ );
1734
+ if (serverOwnedCandidate.eligible && serverOwnedCandidate.agentConfig) {
1735
+ const serverOwnedResult = await runServerOwnedWebForegroundTurn(
1736
+ {
1737
+ agentKey: agentKeyToUse,
1738
+ agentConfig: serverOwnedCandidate.agentConfig,
1739
+ userInput: effectiveRawUserInput,
1740
+ dialogConfig,
1741
+ runtimeOptions: effectiveRuntimeOptions,
1742
+ contextBlocks: browseContextPrefix ? [browseContextPrefix] : void 0
1743
+ },
1744
+ { dispatch, getState }
1745
+ );
1746
+ if (serverOwnedResult.aborted || serverOwnedResult.detached) return;
1747
+ logQuickChatPerfStage(args.quickChatPerfStartedAt, "handle-send-message-server-owned-finished", {
1748
+ dialogKey: dialogConfig.dbKey,
1749
+ agentKey: agentKeyToUse
1750
+ });
1751
+ return;
1752
+ }
1753
+ const effectiveUserInput = browseContextPrefix ? `${browseContextPrefix}
1754
+
1755
+ ${userInputText}` : effectiveRawUserInput ?? "";
1756
+ let streamResult;
1757
+ const maxStartupAttempts = 2;
1758
+ for (let attempt = 1; attempt <= maxStartupAttempts; attempt++) {
1759
+ try {
1760
+ streamResult = await dispatch(
1761
+ streamAgentChatTurn({
1762
+ agentKey: agentKeyToUse,
1763
+ ...agentConfigToUse ? { agentConfig: agentConfigToUse } : {},
1764
+ userInput: effectiveUserInput,
1765
+ dialogKey: dialogConfig.dbKey,
1766
+ parentMessageId: void 0,
1767
+ runtimeOptions: effectiveRuntimeOptions,
1768
+ quickChatPerfStartedAt: args.quickChatPerfStartedAt
1769
+ })
1770
+ ).unwrap();
1771
+ if (streamResult && typeof streamResult === "object" && streamResult.aborted) {
1772
+ return;
1773
+ }
1774
+ break;
1775
+ } catch (turnErr) {
1776
+ const parsed = parseSendError(turnErr);
1777
+ if (attempt < maxStartupAttempts && (parsed.kind === "network" || parsed.kind === "timeout")) {
1778
+ const delayMs = attempt * 800;
1779
+ const retryAbortController = new AbortController();
1780
+ const retryKey = `retry:${dialogConfig.dbKey ?? "global"}`;
1781
+ try {
1782
+ dispatch(
1783
+ addActiveController({
1784
+ messageId: retryKey,
1785
+ controller: retryAbortController,
1786
+ dialogKey: dialogConfig.dbKey
1787
+ })
1788
+ );
1789
+ await waitForAbortableDelay(delayMs, retryAbortController.signal);
1790
+ } catch {
1791
+ } finally {
1792
+ dispatch(
1793
+ removeActiveController({
1794
+ messageId: retryKey,
1795
+ dialogKey: dialogConfig.dbKey
1796
+ })
1797
+ );
1798
+ }
1799
+ if (retryAbortController.signal.aborted) {
1800
+ console.info("[handleSendMessage] Auto-retry cancelled by user stop during backoff window.");
1801
+ return;
1802
+ }
1803
+ continue;
1804
+ }
1805
+ throw turnErr;
1806
+ }
1807
+ }
1808
+ if (args.quickChatPerfStartedAt && streamResult === void 0) {
1809
+ logQuickChatPerfStage(args.quickChatPerfStartedAt, "handle-send-message-stream-empty", {
1810
+ dialogKey: dialogConfig.dbKey,
1811
+ agentKey: agentKeyToUse
1812
+ });
1813
+ await finalizeQuickChatStreamStartupFailure(
1814
+ dispatch,
1815
+ dialogConfig,
1816
+ agentKeyToUse
1817
+ );
1818
+ return;
1819
+ }
1820
+ logQuickChatPerfStage(args.quickChatPerfStartedAt, "handle-send-message-stream-finished", {
1821
+ dialogKey: dialogConfig.dbKey,
1822
+ agentKey: agentKeyToUse
1823
+ });
1824
+ return;
1825
+ } catch (error) {
1826
+ console.error("handleSendMessage failed:", error);
1827
+ const errorMessage = error instanceof Error ? error.message : typeof error === "string" ? error : error?.message || error?.error || String(error);
1828
+ try {
1829
+ if (dialogConfig && agentKeyToUse) {
1830
+ await finalizeSendFailureInDialog(
1831
+ dispatch,
1832
+ dialogConfig,
1833
+ agentKeyToUse,
1834
+ error
1835
+ );
1836
+ return rejectWithValue({
1837
+ __errorInDialog: true,
1838
+ message: errorMessage
1839
+ });
1840
+ }
1841
+ } catch (writeError) {
1842
+ console.error("handleSendMessage: failed to write error into dialog:", writeError);
1843
+ }
1844
+ return rejectWithValue(errorMessage);
1845
+ }
1846
+ };
1847
+ export {
1848
+ handleSendMessageAction
1849
+ };