nolo-cli 0.250.0-alpha.1 → 0.252.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (186) hide show
  1. package/{_executeModel-F4MT6OPO.js → _executeModel-D6G3B45S.js} +51 -51
  2. package/{action-WZTKEF5H.js → action-QQOQ2LP3.js} +3 -3
  3. package/{addContentAction-MLI6GOBV.js → addContentAction-MB22YIDV.js} +6 -6
  4. package/{addDialogAgentAction-ARGQM22H.js → addDialogAgentAction-KNTBVVGY.js} +5 -5
  5. package/{agentDeleteCommand-DBCRHB4S.js → agentDeleteCommand-YCWDGJSF.js} +87 -82
  6. package/{agentEmailCommands-T4PAJ4KG.js → agentEmailCommands-DTWD5FWC.js} +87 -82
  7. package/{agentListCommands-5ULWKQ3E.js → agentListCommands-JTOONLYL.js} +233 -46
  8. package/{agentMachineCommands-65QUOCEY.js → agentMachineCommands-25X7OTLQ.js} +38 -36
  9. package/{agentProviderCommands-C5T7C5KZ.js → agentProviderCommands-QLTABYR7.js} +2 -2
  10. package/{agentPullCommand-4EQZYHU4.js → agentPullCommand-6OCNLVGC.js} +1 -1
  11. package/{agentRecordCommands-EKANS3A5.js → agentRecordCommands-SXE3WV2X.js} +86 -81
  12. package/{agentRunCommand-336PXBRJ.js → agentRunCommand-QSIED54S.js} +87 -82
  13. package/{agentRunControl-QMWTWV7C.js → agentRunControl-KNNDEEDI.js} +8 -6
  14. package/{agentRuntimeLocal-KKXJOBD3.js → agentRuntimeLocal-HVJJMB4W.js} +32 -31
  15. package/{agentSlice-FWYXP332.js → agentSlice-NBUJJVRI.js} +7 -7
  16. package/{appDeleteCommands-ERJK367V.js → appDeleteCommands-YU6TT6VN.js} +39 -37
  17. package/{appDeployCommands-LUV6QKQJ.js → appDeployCommands-4DEIX7YP.js} +39 -37
  18. package/{appDeployStatusCommands-WW7IYQD4.js → appDeployStatusCommands-3VKS6GBQ.js} +39 -37
  19. package/{appGetCommands-G7XYYSFO.js → appGetCommands-22FNNROT.js} +39 -37
  20. package/{appListCommands-4RXCIDNI.js → appListCommands-FVGMLHVU.js} +39 -37
  21. package/{authCommand-3C3RN4OU.js → authCommand-5DC3ES4Q.js} +15 -15
  22. package/{authCommands-ZMVEDCQD.js → authCommands-BLXNAUF4.js} +2 -2
  23. package/{chromeOpsCommands-NZITLHWO.js → chromeOpsCommands-AA555ANS.js} +1 -1
  24. package/{chunk-MAA42MMV.js → chunk-2FZVXOFX.js} +4 -4
  25. package/chunk-2GAUJDA5.js +594 -0
  26. package/{chunk-ESN4WNWU.js → chunk-2JHGUL5K.js} +2 -2
  27. package/{chunk-222CJNC2.js → chunk-2LANL4B5.js} +3 -3
  28. package/{chunk-W4G25PVP.js → chunk-2PB653F5.js} +196 -253
  29. package/{chunk-UF6J7NXV.js → chunk-3272HU62.js} +1 -1
  30. package/chunk-3A5NNQCN.js +64 -0
  31. package/{chunk-7IQA2VJF.js → chunk-3N3JPQBQ.js} +210 -56
  32. package/{chunk-LXKK7QFI.js → chunk-4HAOOY6G.js} +53 -23
  33. package/{chunk-ZQ6K57FJ.js → chunk-4YPH5KRA.js} +1 -1
  34. package/{chunk-ADOOL3PG.js → chunk-52M4RYVP.js} +1 -1
  35. package/{chunk-U7OMQLRE.js → chunk-5IN2NBDX.js} +9 -9
  36. package/{chunk-BAH3BAUZ.js → chunk-5QEOTC35.js} +5 -5
  37. package/{chunk-E5RYFR7E.js → chunk-5UYDG6HP.js} +19 -0
  38. package/{chunk-Z7A2ZQ5X.js → chunk-64ACTEAE.js} +1 -1
  39. package/{chunk-CTWCZKNS.js → chunk-6SOWMEAY.js} +4 -4
  40. package/{chunk-BFKJ2RS3.js → chunk-7RYODZDD.js} +1 -1
  41. package/{chunk-YWNCRUBZ.js → chunk-7XO73H5X.js} +116 -6
  42. package/{chunk-SMEX763N.js → chunk-7ZOVFB2H.js} +100 -43
  43. package/{chunk-UR4ZMRV3.js → chunk-A5F6DYP2.js} +1 -1
  44. package/{chunk-ZKMS73DK.js → chunk-A6VIMCWI.js} +3 -3
  45. package/{chunk-SX6AWTNK.js → chunk-BZLGPM5B.js} +3 -3
  46. package/{chunk-LTVEOOZL.js → chunk-CIAV4WK2.js} +14 -1
  47. package/{chunk-HZDK56EK.js → chunk-CO2NXG2J.js} +32 -10
  48. package/{chunk-OHUYN3YU.js → chunk-CYGFNMCH.js} +1 -1
  49. package/{chunk-MZVCFV3T.js → chunk-D3WOFN6N.js} +3 -3
  50. package/{chunk-VUHKG4KS.js → chunk-DNNPARJK.js} +9 -5
  51. package/{chunk-VV5IS3ES.js → chunk-DU3DJYVA.js} +5 -5
  52. package/{chunk-SPU3L3OR.js → chunk-EFM2IPZR.js} +3 -3
  53. package/{chunk-73PZD7JZ.js → chunk-EG3JTV7H.js} +2 -2
  54. package/{chunk-6ASGEP5D.js → chunk-EJQE5HB7.js} +1 -1
  55. package/{chunk-6XRPBZRS.js → chunk-EYLGAEB4.js} +0 -134
  56. package/{chunk-CD64YXRB.js → chunk-F6Q64KRV.js} +1 -1
  57. package/{chunk-TMRJGSK2.js → chunk-FRC2DNTN.js} +1 -1
  58. package/{chunk-W3HSD32M.js → chunk-FXEPZKNJ.js} +2 -2
  59. package/{chunk-I3J7HO3U.js → chunk-FZI2P64R.js} +137 -53
  60. package/{chunk-WWTSEBDF.js → chunk-GIXWVN2W.js} +1 -1
  61. package/{chunk-XHG7QROB.js → chunk-GO7UC5VH.js} +5 -5
  62. package/{chunk-RDBDHGU7.js → chunk-GVH2IP2M.js} +5 -5
  63. package/{chunk-AXZ5DDLB.js → chunk-GWS2X7TX.js} +235 -120
  64. package/{chunk-KHVTT4WW.js → chunk-HF4C5WIU.js} +81 -542
  65. package/{chunk-ATRU65OK.js → chunk-HMREADP6.js} +21 -19
  66. package/chunk-HZD5HXUO.js +405 -0
  67. package/{chunk-VHMPJGT4.js → chunk-ITCOQAHS.js} +3 -3
  68. package/{chunk-BQ4CZEVZ.js → chunk-ITMBFT35.js} +1 -1
  69. package/chunk-IVK2KT3H.js +209 -0
  70. package/{chunk-FFFKAOJN.js → chunk-JAYPSNGR.js} +1 -1
  71. package/{chunk-NEG5LYK5.js → chunk-JCQ3WCQ3.js} +3 -1
  72. package/{chunk-3IVFGQIM.js → chunk-JF5QT3YY.js} +2 -2
  73. package/{chunk-V4IYI3SB.js → chunk-JKALGWDL.js} +2 -2
  74. package/{chunk-PQ63BDV3.js → chunk-JPXACKSW.js} +9 -1
  75. package/{chunk-HS7MLR74.js → chunk-KZ4A7EIV.js} +3 -5
  76. package/{chunk-HEIIOJGN.js → chunk-LAQC5FAP.js} +4 -4
  77. package/{chunk-I3OW5RAX.js → chunk-LNIA5JVX.js} +8 -8
  78. package/{chunk-QJTZ76CP.js → chunk-LS5KAVFQ.js} +1 -0
  79. package/{chunk-W6T4FNZP.js → chunk-LUPZLKXL.js} +192 -352
  80. package/{chunk-K26XPZRB.js → chunk-LVZVSLKO.js} +29 -9
  81. package/{chunk-SHDJLJWV.js → chunk-N2ZAY2DK.js} +1 -1
  82. package/{chunk-WEZ27JA7.js → chunk-NMXGIRSG.js} +1 -1
  83. package/{chunk-MTM4LRVG.js → chunk-NNUIVAC2.js} +1 -1
  84. package/{chunk-ARFCL53U.js → chunk-NPUHKEOB.js} +4 -4
  85. package/{chunk-32WTED6G.js → chunk-O6LPLIRS.js} +94 -83
  86. package/{chunk-4IQN6FWY.js → chunk-OB4FBZXJ.js} +4 -4
  87. package/{chunk-CD2DK5JA.js → chunk-OKH74FML.js} +2 -1
  88. package/{chunk-UPOW5HTG.js → chunk-OMIXG25B.js} +2 -2
  89. package/{chunk-MYYNZG2M.js → chunk-OOV5JN25.js} +4 -4
  90. package/{chunk-AS6L5KSD.js → chunk-P4R5KXU7.js} +2 -2
  91. package/{chunk-OKKA4BCM.js → chunk-P6HMEKLL.js} +114 -56
  92. package/{chunk-VTHWBTRE.js → chunk-PENRYZ4D.js} +1 -1
  93. package/{chunk-VIYVRPMJ.js → chunk-PHREU2KZ.js} +5 -3
  94. package/{chunk-EDT65EUE.js → chunk-PIVTQRX6.js} +45 -15
  95. package/{chunk-KJDN2YRH.js → chunk-QMKWSKWA.js} +4 -4
  96. package/{chunk-6TVYUQRM.js → chunk-QV32GSVO.js} +2 -2
  97. package/{chunk-K7VIXYTZ.js → chunk-R3MV2GII.js} +1 -45
  98. package/{chunk-XJSEST7D.js → chunk-SMCKJJXI.js} +2 -2
  99. package/{chunk-JFRJEPFI.js → chunk-SMZFWEMX.js} +1 -1
  100. package/{chunk-KK3FCYZM.js → chunk-SQL7YNED.js} +7 -4
  101. package/{chunk-D25ONVOH.js → chunk-SSZHE2RK.js} +1 -1
  102. package/{chunk-OLGFIQN2.js → chunk-T4VVQHSE.js} +1 -1
  103. package/{chunk-6QL3SUEK.js → chunk-TDI7ARZO.js} +3 -3
  104. package/{chunk-X6LYQDN5.js → chunk-TDLZA6LJ.js} +13 -10
  105. package/chunk-TRRXYFTR.js +46 -0
  106. package/{chunk-WMKA2DPK.js → chunk-TTUIM3PJ.js} +4 -4
  107. package/{chunk-RHBD22LV.js → chunk-TTWNTFTO.js} +39 -4
  108. package/{chunk-ZM5AZTQG.js → chunk-U7BP25PE.js} +18 -6
  109. package/{chunk-X3OZ655T.js → chunk-UI3Z3HDK.js} +1 -1
  110. package/{chunk-GX6DITLQ.js → chunk-UUCYUN6Y.js} +1 -1
  111. package/{chunk-BVEDT6DM.js → chunk-VH7AQEEF.js} +3 -3
  112. package/{chunk-PGDM7AM2.js → chunk-WAOHK3NJ.js} +9 -9
  113. package/{chunk-2FK2KZSL.js → chunk-WLHUANWZ.js} +1 -1
  114. package/{chunk-ZTWDSOXD.js → chunk-WNIBQBOR.js} +1 -1
  115. package/{chunk-SLUZ6FBJ.js → chunk-XBCADGK2.js} +1 -1
  116. package/chunk-XRGBJHZX.js +136 -0
  117. package/{chunk-6XVPMGXK.js → chunk-YB5D2GK4.js} +9 -3
  118. package/{chunk-AKWA6PCE.js → chunk-YQYYYATY.js} +45 -27
  119. package/{chunk-WQDTSK5U.js → chunk-ZMFA2TLE.js} +1 -1
  120. package/{chunk-CFDOIIOZ.js → chunk-ZMXO5G3E.js} +29 -23
  121. package/{chunk-YQO5UKHP.js → chunk-ZNOXY73P.js} +632 -124
  122. package/{cliAgentConfigHelpers-37ZNEY5Y.js → cliAgentConfigHelpers-FKBPFPKR.js} +7 -7
  123. package/{cliAuthorityBrokerClient-SFPC3WVK.js → cliAuthorityBrokerClient-TFNXJLXL.js} +1 -1
  124. package/cliAuthorityBrokerProcess-IUCB4XA6.js +22 -0
  125. package/{cliLocalAgentRecordReader-R4CLUHYO.js → cliLocalAgentRecordReader-DWU3LBO2.js} +36 -35
  126. package/{commandRegistry-UIZRI4JV.js → commandRegistry-7FVATZS2.js} +74 -74
  127. package/{contentThunks-ZQSZA4GH.js → contentThunks-25XCB7VY.js} +20 -20
  128. package/{cooldownCommands-TIFCHCUN.js → cooldownCommands-PT5L4LNB.js} +3 -3
  129. package/{createAgentAutomationAction-RQE4F6PR.js → createAgentAutomationAction-FC5RI2LW.js} +20 -20
  130. package/{createDialogAction-JDSMQ34U.js → createDialogAction-IL3ISSQQ.js} +21 -21
  131. package/{createPageAction-VLF6XCYO.js → createPageAction-RVYBEYZV.js} +23 -23
  132. package/{db-CMUTP3W5.js → db-JMGVD4TB.js} +4 -2
  133. package/{dbSlice-656PMWR2.js → dbSlice-WG3ZG6PZ.js} +5 -5
  134. package/{deleteFile-ZCQESEEQ.js → deleteFile-4TIG54YN.js} +3 -3
  135. package/{dialogCommands-PLM7ZFWH.js → dialogCommands-VUJISJZF.js} +48 -42
  136. package/{dialogNotifyCommand-PST75COP.js → dialogNotifyCommand-JKYVSR6K.js} +8 -8
  137. package/{dialogSlice-63DD2ER2.js → dialogSlice-UMP55UAW.js} +18 -18
  138. package/{dialogUsageCommand-6RW2FY6K.js → dialogUsageCommand-IHAXS7DW.js} +5 -5
  139. package/{docCreateCommands-BST5DO7L.js → docCreateCommands-S46F6GKP.js} +38 -36
  140. package/{docDeleteCommands-YE6G2SO4.js → docDeleteCommands-LJG4NK6J.js} +39 -37
  141. package/{docReadCommands-M6T35U3G.js → docReadCommands-YPAYGHNM.js} +38 -36
  142. package/{docStore-7QNJWRJ2.js → docStore-VK3MVJ5Q.js} +6 -6
  143. package/{docUpdateCommands-6DFWGPVG.js → docUpdateCommands-MPTM6267.js} +38 -36
  144. package/{getPricing-FCHYVRJU.js → getPricing-5BLZRPTM.js} +3 -3
  145. package/{handleSendMessageAction-FCEFFAV4.js → handleSendMessageAction-VPKVNKBU.js} +83 -41
  146. package/{hostCredentialCreate-YEWCAMZN.js → hostCredentialCreate-K56HWPNY.js} +86 -81
  147. package/index.js +23 -11
  148. package/{localDialogRead-CIOTQM5T.js → localDialogRead-NXILOV3T.js} +1 -1
  149. package/{localRuntimeAdapter-Z22ZOZRY.js → localRuntimeAdapter-KVU72FWT.js} +84 -79
  150. package/{localRuntimeAuthority-TYHQCTZN.js → localRuntimeAuthority-QKWTPBQQ.js} +13 -3
  151. package/{localRuntimeDb-BO7IVWAZ.js → localRuntimeDb-3CIC4SKC.js} +1 -1
  152. package/{machineCommands-PT5OJ36V.js → machineCommands-C3O5RKNJ.js} +85 -80
  153. package/{machineWsRunDispatch-DQVNBSVE.js → machineWsRunDispatch-ZLART7ZA.js} +85 -80
  154. package/{markdownToSlate-KIYM7B3P.js → markdownToSlate-PXYAIBVL.js} +1 -1
  155. package/{mcpLocalAuthorizeCommand-GO6AYT63.js → mcpLocalAuthorizeCommand-LO7E4VQ5.js} +15 -11
  156. package/{memberThunks-JFYC4Z5L.js → memberThunks-7DNR6DRD.js} +7 -7
  157. package/{models-EP7VG6N2.js → models-ZX2BYIMB.js} +2 -2
  158. package/package.json +2 -1
  159. package/{projectArchive-4XUC5SLF.js → projectArchive-UBJFYRL7.js} +23 -23
  160. package/{providerPresetApply-4H7YP5D7.js → providerPresetApply-NTJUINI6.js} +35 -16
  161. package/{providerRegistry-F3UPOTIY.js → providerRegistry-W45SLUV6.js} +5 -5
  162. package/{read-BRZHXUJ6.js → read-Z2JOK6F6.js} +3 -3
  163. package/{readDocTool-N7RVFQEE.js → readDocTool-3QYSVWBT.js} +1 -1
  164. package/{readlineWorkspace-7U5QM3OM.js → readlineWorkspace-TSIYF7C6.js} +655 -248
  165. package/{removeDialogAgentAction-J7XU7OUX.js → removeDialogAgentAction-LRKDU4RI.js} +7 -7
  166. package/{runAgentClientLoop-7D7UCAS2.js → runAgentClientLoop-YAHGOWXN.js} +48 -48
  167. package/{runtimeDoctorCommands-RDRJXMXC.js → runtimeDoctorCommands-QGZSKNSE.js} +14 -11
  168. package/{secretCommands-2FEMRUFM.js → secretCommands-BXAQEOES.js} +2 -2
  169. package/{setDialogExtraReferencesAction-Q4V2ZZW2.js → setDialogExtraReferencesAction-KIITOCFP.js} +6 -6
  170. package/{setPrimaryDialogAgentAction-742H5S6T.js → setPrimaryDialogAgentAction-Y36PKFFB.js} +7 -7
  171. package/{settingThunks-IHXUF276.js → settingThunks-YQNG5L6K.js} +5 -5
  172. package/{spaceCommands-WCLD36WH.js → spaceCommands-P644AAZZ.js} +37 -35
  173. package/{streamAgentChatTurn-DVTOINT3.js → streamAgentChatTurn-5CSYAUAY.js} +81 -77
  174. package/{switchDialogAgentAction-HLDLHRRA.js → switchDialogAgentAction-U2VLPPVO.js} +5 -5
  175. package/{tools-BOPINT5S.js → tools-UZ3CDIR2.js} +38 -38
  176. package/{tuiRestart-5F2APN66.js → tuiRestart-GF4DGAAN.js} +7 -7
  177. package/{tuiSummaryLlmCaller-TM5BU73J.js → tuiSummaryLlmCaller-HROLGN4F.js} +13 -13
  178. package/{updateCommands-FBYA5WVG.js → updateCommands-BZ4YDHNM.js} +3 -3
  179. package/{updateDialogTitleAction-S76PUCLQ.js → updateDialogTitleAction-53XCCDK2.js} +20 -20
  180. package/{usageCommand-L4OFWXEU.js → usageCommand-XVJ7ZUTM.js} +2 -2
  181. package/{usageRebuildCommand-7JR33UHS.js → usageRebuildCommand-NK6S3D4J.js} +3 -3
  182. package/{windowsSelfUpdate-M4V77OUB.js → windowsSelfUpdate-4BAXX7C3.js} +2 -2
  183. package/{workloadLifecycle-ZCSQCHG3.js → workloadLifecycle-DYX5ZMAT.js} +2 -2
  184. package/chunk-FGHEF6WI.js +0 -34
  185. package/{chunk-ANUP75N2.js → chunk-2E4BYAUE.js} +0 -0
  186. package/{chunk-CDIRKCPD.js → chunk-6HL6E7ZD.js} +152 -152
@@ -1,5 +1,6 @@
1
1
  // packages/database-engine/cliAuthorityBrokerClient.ts
2
2
  import { createConnection } from "node:net";
3
+ import { connect as connectTls } from "node:tls";
3
4
  var DEFAULT_ITERATOR_PAGE_SIZE = 200;
4
5
  var CliAuthorityBrokerUnavailableError = class extends Error {
5
6
  reason = "cli_authority_broker_unavailable";
@@ -112,6 +113,8 @@ function isNotFoundBrokerError(error) {
112
113
  }
113
114
  function createCliAuthorityBrokerSocketInvoker(options) {
114
115
  const target = resolveBrokerSocketTarget(options.endpoint);
116
+ const connectedEvent = options.tls ? "secureConnect" : "connect";
117
+ const connect = () => target.kind === "unix" ? createConnection(target.path) : options.tls ? connectTls({ host: target.host, port: target.port, servername: "localhost", ...options.tls, rejectUnauthorized: true }) : createConnection({ host: target.host, port: target.port });
115
118
  const timeoutMs = options.timeoutMs ?? 5e3;
116
119
  const idleTimeoutMs = options.idleTimeoutMs ?? 5e3;
117
120
  let nextRequestId = 1;
@@ -164,7 +167,7 @@ function createCliAuthorityBrokerSocketInvoker(options) {
164
167
  return Promise.reject(createClosedError());
165
168
  }
166
169
  return new Promise((resolve, reject) => {
167
- const socket = target.kind === "unix" ? createConnection(target.path) : createConnection({ host: target.host, port: target.port });
170
+ const socket = connect();
168
171
  let settled = false;
169
172
  let buffer = "";
170
173
  let timer;
@@ -196,7 +199,7 @@ function createCliAuthorityBrokerSocketInvoker(options) {
196
199
  finishReject(new CliAuthorityBrokerTimeoutError(options.endpoint, timeoutMs));
197
200
  }, timeoutMs);
198
201
  socket.setEncoding("utf8");
199
- socket.on("connect", () => {
202
+ socket.on(connectedEvent, () => {
200
203
  if (settled || explicitlyClosed) return;
201
204
  socket.write(`${JSON.stringify(request)}
202
205
  `);
@@ -340,7 +343,7 @@ function createCliAuthorityBrokerSocketInvoker(options) {
340
343
  activeConn.socket.ref?.();
341
344
  return activeConn;
342
345
  }
343
- const socket = target.kind === "unix" ? createConnection(target.path) : createConnection({ host: target.host, port: target.port });
346
+ const socket = connect();
344
347
  const conn = {
345
348
  socket,
346
349
  connected: false,
@@ -354,7 +357,7 @@ function createCliAuthorityBrokerSocketInvoker(options) {
354
357
  activeConn = conn;
355
358
  socket.setEncoding("utf8");
356
359
  socket.setNoDelay?.(true);
357
- socket.on("connect", () => {
360
+ socket.on(connectedEvent, () => {
358
361
  if (conn.closed) return;
359
362
  conn.connected = true;
360
363
  const queued = conn.writeQueue.splice(0, conn.writeQueue.length);
@@ -4,7 +4,7 @@ import {
4
4
 
5
5
  // packages/cli/agentCommandSupport.ts
6
6
  async function getDefaultCliDb() {
7
- const { getDefaultCliLocalRuntimeDb } = await import("./localRuntimeDb-BO7IVWAZ.js");
7
+ const { getDefaultCliLocalRuntimeDb } = await import("./localRuntimeDb-3CIC4SKC.js");
8
8
  return getDefaultCliLocalRuntimeDb();
9
9
  }
10
10
  function createNullCliDb() {
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  patch,
6
6
  selectById
7
- } from "./chunk-HZDK56EK.js";
7
+ } from "./chunk-CO2NXG2J.js";
8
8
  import {
9
9
  getActiveDialogKey
10
10
  } from "./chunk-U35UUM5K.js";
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  fetchReferenceContents,
3
3
  resolveReferenceAssets
4
- } from "./chunk-XHG7QROB.js";
4
+ } from "./chunk-GO7UC5VH.js";
5
5
  import {
6
6
  updateTokensAction
7
- } from "./chunk-YQO5UKHP.js";
7
+ } from "./chunk-ZNOXY73P.js";
8
8
  import {
9
9
  applyUpdateTokensFulfilled
10
10
  } from "./chunk-U35UUM5K.js";
@@ -12,7 +12,7 @@ import {
12
12
  extractReasoningFromResponseOutput,
13
13
  extractTextFromResponseOutput,
14
14
  extractToolCallsFromResponseOutput
15
- } from "./chunk-W3HSD32M.js";
15
+ } from "./chunk-FXEPZKNJ.js";
16
16
  import {
17
17
  isRecord
18
18
  } from "./chunk-KUG52IAP.js";
@@ -2,13 +2,13 @@ import {
2
2
  deleteDialog,
3
3
  runtime_default,
4
4
  toast
5
- } from "./chunk-YQO5UKHP.js";
5
+ } from "./chunk-ZNOXY73P.js";
6
6
  import {
7
7
  getAllMemberSpaces,
8
8
  getCurrentSpaceId,
9
9
  getCurrentSpaceIdRaw,
10
10
  updateCurrentSpaceIfMatch
11
- } from "./chunk-FFFKAOJN.js";
11
+ } from "./chunk-JAYPSNGR.js";
12
12
  import {
13
13
  require_formatISO
14
14
  } from "./chunk-UVLYNWIE.js";
@@ -23,7 +23,7 @@ import {
23
23
  patchIndividualContentRecord,
24
24
  readContentRecordForSpaceSync,
25
25
  syncContentRecordSpaceId
26
- } from "./chunk-V4IYI3SB.js";
26
+ } from "./chunk-JKALGWDL.js";
27
27
  import {
28
28
  createSpaceKey,
29
29
  normalizeSpaceId
@@ -36,7 +36,7 @@ import {
36
36
  uploadFileAction,
37
37
  upsertSSREntity,
38
38
  write
39
- } from "./chunk-HZDK56EK.js";
39
+ } from "./chunk-CO2NXG2J.js";
40
40
  import {
41
41
  resolveFileCategory
42
42
  } from "./chunk-3PVYUPXK.js";
@@ -50,10 +50,10 @@ import {
50
50
  resolveReplicationServers,
51
51
  scheduleDeleteReplication,
52
52
  scheduleWriteReplication
53
- } from "./chunk-WQDTSK5U.js";
53
+ } from "./chunk-ZMFA2TLE.js";
54
54
  import {
55
55
  createAsyncThunk
56
- } from "./chunk-6XVPMGXK.js";
56
+ } from "./chunk-YB5D2GK4.js";
57
57
  import {
58
58
  getIsDesktopApp
59
59
  } from "./chunk-YHNUDTU4.js";
@@ -1513,11 +1513,11 @@ var ENTITY_DELETE_STRATEGIES = {
1513
1513
  await dispatch(deleteTable({ dbKey: key })).unwrap();
1514
1514
  },
1515
1515
  file: async (key, { thunkAPI }) => {
1516
- const { deleteFileAction } = await import("./deleteFile-ZCQESEEQ.js");
1516
+ const { deleteFileAction } = await import("./deleteFile-4TIG54YN.js");
1517
1517
  await deleteFileAction(key, thunkAPI);
1518
1518
  },
1519
1519
  image: async (key, { thunkAPI }) => {
1520
- const { deleteFileAction } = await import("./deleteFile-ZCQESEEQ.js");
1520
+ const { deleteFileAction } = await import("./deleteFile-4TIG54YN.js");
1521
1521
  await deleteFileAction(key, thunkAPI);
1522
1522
  },
1523
1523
  agent: async (key, { dispatch, userId, sourceServerOrigin }) => {
@@ -2439,7 +2439,11 @@ var uploadOnce = async (payload, thunkAPI, userId) => {
2439
2439
  fileName: file.name
2440
2440
  });
2441
2441
  const fileMetadata = await uploadFileAction(
2442
- { file, customKey: dbKey, userId },
2442
+ // 这是「上传为 Space 资产」,不是「把个人文件收录进 Space」:
2443
+ // 明确声明 Space 归属,服务端校验成员身份后落库
2444
+ // `ownerType:"space"` + `ownerId:<spaceId>`,其他成员据此可读原件。
2445
+ // 声明只是请求,服务端(uploadOwnership.ts)才是归属权威。
2446
+ { file, customKey: dbKey, userId, ownerType: "space", spaceId },
2443
2447
  thunkAPI
2444
2448
  );
2445
2449
  if (!fileMetadata) {
@@ -2476,7 +2480,6 @@ var uploadOnce = async (payload, thunkAPI, userId) => {
2476
2480
  title,
2477
2481
  spaceId,
2478
2482
  fileCategory,
2479
- mimeType: file.type || void 0,
2480
2483
  fileSize,
2481
2484
  originalName: file.name
2482
2485
  }
@@ -0,0 +1,46 @@
1
+ // packages/database/levelLockError.ts
2
+ function isLevelLockError(error) {
3
+ return typeof error === "object" && error !== null && error.code === "LEVEL_LOCKED";
4
+ }
5
+
6
+ // packages/database-engine/legacyServerDb.ts
7
+ function createLegacyServerDb(store) {
8
+ const batch = (ops) => {
9
+ if (Array.isArray(ops)) {
10
+ return store.batchWrite(ops);
11
+ }
12
+ return store.createBatch();
13
+ };
14
+ return {
15
+ get location() {
16
+ return store.location;
17
+ },
18
+ get status() {
19
+ return store.status;
20
+ },
21
+ async open() {
22
+ await store.open();
23
+ },
24
+ async close() {
25
+ await store.close();
26
+ },
27
+ async get(key) {
28
+ return store.get(key);
29
+ },
30
+ async put(key, value) {
31
+ await store.put(key, value);
32
+ },
33
+ async del(key) {
34
+ await store.del(key);
35
+ },
36
+ batch,
37
+ iterator(options = {}) {
38
+ return store.iterator(options);
39
+ }
40
+ };
41
+ }
42
+
43
+ export {
44
+ isLevelLockError,
45
+ createLegacyServerDb
46
+ };
@@ -1,15 +1,15 @@
1
+ import {
2
+ resolveAgentImageInputSupport
3
+ } from "./chunk-BZLGPM5B.js";
1
4
  import {
2
5
  TOOL_HAD_IMAGES,
3
6
  hadToolImages
4
7
  } from "./chunk-X4O7FJF5.js";
5
- import {
6
- resolveAgentImageInputSupport
7
- } from "./chunk-SX6AWTNK.js";
8
8
  import {
9
9
  isCompleteInstructionOutput,
10
10
  sanitizeToolOutputText,
11
11
  scrubSecrets
12
- } from "./chunk-CDIRKCPD.js";
12
+ } from "./chunk-6HL6E7ZD.js";
13
13
  import {
14
14
  asTrimmedString
15
15
  } from "./chunk-3EUW3WEO.js";
@@ -1,11 +1,16 @@
1
1
  import {
2
2
  Database
3
3
  } from "./chunk-IT3ZZRJE.js";
4
+ import {
5
+ createLegacyServerDb
6
+ } from "./chunk-TRRXYFTR.js";
4
7
  import {
5
8
  Level,
6
- createLegacyServerDb,
7
9
  createLevelAuthorityStore
8
- } from "./chunk-K7VIXYTZ.js";
10
+ } from "./chunk-R3MV2GII.js";
11
+ import {
12
+ Mutex
13
+ } from "./chunk-IVK2KT3H.js";
9
14
  import {
10
15
  asTrimmedLowercaseString
11
16
  } from "./chunk-QSJ3HFEF.js";
@@ -53,6 +58,36 @@ var SERVER_DB_ROLE_VIOLATION_MESSAGE = "\u5F53\u524D\u8FDB\u7A0B\u89D2\u8272\u4E
53
58
  import fs from "fs";
54
59
  import path from "path";
55
60
 
61
+ // packages/database-engine/publicationBatch.ts
62
+ function withPublicationBatch(store) {
63
+ const lock = new Mutex();
64
+ const wrapped = {
65
+ get location() {
66
+ return store.location;
67
+ },
68
+ get status() {
69
+ return store.status;
70
+ },
71
+ open: () => store.open(),
72
+ close: () => lock.runExclusive(() => store.close()),
73
+ get: (key) => store.get(key),
74
+ iterator: (options) => store.iterator(options),
75
+ put: (key, value) => lock.runExclusive(() => store.put(key, value)),
76
+ del: (key) => lock.runExclusive(() => store.del(key)),
77
+ batchWrite: (ops) => lock.runExclusive(() => store.batchWrite(ops)),
78
+ createBatch: () => {
79
+ const batch = store.createBatch();
80
+ return {
81
+ put: (key, value) => batch.put(key, value),
82
+ del: (key) => batch.del(key),
83
+ write: () => lock.runExclusive(() => batch.write())
84
+ };
85
+ },
86
+ runPublicationBatch: (task) => lock.runExclusive(() => task(store))
87
+ };
88
+ return wrapped;
89
+ }
90
+
56
91
  // packages/database-engine/memoryAuthorityStore.ts
57
92
  var createNotFoundError = () => {
58
93
  const error = new Error("NotFound");
@@ -394,10 +429,10 @@ function getOrCreateServerStoreRuntime(dbPath, options = {}) {
394
429
  );
395
430
  }
396
431
  if (!globalScope.__serverAuthorityStore) {
397
- globalScope.__serverAuthorityStore = createAuthorityStoreForDriver(
432
+ globalScope.__serverAuthorityStore = withPublicationBatch(createAuthorityStoreForDriver(
398
433
  driver,
399
434
  dbPath
400
- );
435
+ ));
401
436
  globalScope.__serverAuthorityStoreDriver = driver;
402
437
  } else if (!cachedDriver) {
403
438
  globalScope.__serverAuthorityStoreDriver = driver;
@@ -7,7 +7,7 @@ import {
7
7
  scheduleExistingRecordReplication,
8
8
  shouldReplaceLocalWithRemoteRecord,
9
9
  shouldReplicateLocalRecord
10
- } from "./chunk-WQDTSK5U.js";
10
+ } from "./chunk-ZMFA2TLE.js";
11
11
  import {
12
12
  fetchFromClientDb,
13
13
  fetchFromServer,
@@ -192,6 +192,8 @@ var saveRemoteDataToClientDb = async (clientDb, dbKey, remoteData, serverOrigin)
192
192
  } catch (err) {
193
193
  }
194
194
  };
195
+ var REJECTED_RECORD = Symbol("rejected read record");
196
+ var hasRejectedRecord = (results) => results.some((result) => result.status === "fulfilled" && result.value === REJECTED_RECORD);
195
197
  var processRemoteDataInBackground = async (clientDb, dbKey, remotePromises, remoteServers, localData, replicationContext) => {
196
198
  if (!clientDb) return;
197
199
  try {
@@ -214,7 +216,7 @@ var processRemoteDataInBackground = async (clientDb, dbKey, remotePromises, remo
214
216
  localData
215
217
  );
216
218
  }
217
- if (shouldReplicateLocalRecord({
219
+ if (!hasRejectedRecord(settledResults) && shouldReplicateLocalRecord({
218
220
  localData,
219
221
  remoteData: validRemoteData,
220
222
  remoteTargetCount: remotePromises.length
@@ -251,10 +253,16 @@ var readAction = async (payload, thunkApi) => {
251
253
  userAuthorityRegistry
252
254
  } = getRuntimeServerContext(state, preferredServerOrigin);
253
255
  const allServers = resolveAgentReadServers({ dbKey, configuredServers });
254
- const fetchScopedFromServer = (server, key, token, signal2) => fetchFromServer(server, key, googleSessionRequestToken(token, server, isPublicBuiltinPlatformAgentKey(key)), signal2);
256
+ const { validateRecord } = payload;
257
+ const fetchScopedFromServer = async (server, key, token, signal2) => {
258
+ const record = await fetchFromServer(server, key, googleSessionRequestToken(token, server, isPublicBuiltinPlatformAgentKey(key)), signal2);
259
+ return record && validateRecord && !validateRecord(record, "remote") ? REJECTED_RECORD : record;
260
+ };
255
261
  const isLoggedIn = !!currentToken;
256
262
  const now = Date.now();
257
- const localData = await fetchFromClientDb(clientDb, dbKey);
263
+ const rawLocalData = await fetchFromClientDb(clientDb, dbKey);
264
+ const localRejected = !!rawLocalData && !!validateRecord && !validateRecord(rawLocalData, "local");
265
+ const localData = localRejected ? null : rawLocalData;
258
266
  if (isDialogKey) {
259
267
  console.info("[readAction-perf] dialog local-read", {
260
268
  dbKey,
@@ -316,6 +324,7 @@ var readAction = async (payload, thunkApi) => {
316
324
  }
317
325
  return normalizeReadRecord(dbKey, localData);
318
326
  }
327
+ if (localRejected) return null;
319
328
  readRequestManager.markMiss(dbKey, now);
320
329
  throw new Error(
321
330
  `Failed to fetch data for key "${dbKey}" because network is offline and no local data is available.`
@@ -363,6 +372,7 @@ var readAction = async (payload, thunkApi) => {
363
372
  preferredServer = authoritativeServerOrigin;
364
373
  fallbackServers = [];
365
374
  }
375
+ let preferredRejected = false;
366
376
  if (preferredServer) {
367
377
  try {
368
378
  const preferredRemoteData = await fetchScopedFromServer(
@@ -371,7 +381,8 @@ var readAction = async (payload, thunkApi) => {
371
381
  isLoggedIn ? currentToken : void 0,
372
382
  signal
373
383
  );
374
- if (preferredRemoteData) {
384
+ preferredRejected = preferredRemoteData === REJECTED_RECORD;
385
+ if (preferredRemoteData && !preferredRejected) {
375
386
  await saveRemoteDataToClientDb(
376
387
  clientDb,
377
388
  dbKey,
@@ -439,12 +450,13 @@ var readAction = async (payload, thunkApi) => {
439
450
  const remoteData = serverOrigin ? { ...validRemoteData, dbKey, serverOrigin } : { ...validRemoteData, dbKey };
440
451
  return normalizeReadRecord(dbKey, remoteData);
441
452
  }
453
+ if (localRejected || preferredRejected || hasRejectedRecord(settledResults)) return null;
442
454
  readRequestManager.markMiss(dbKey, Date.now());
443
455
  throw new Error(
444
456
  `Failed to fetch data for key "${dbKey}" from all sources.`
445
457
  );
446
458
  };
447
- const canDedup = !signal;
459
+ const canDedup = !signal && !payload.validateRecord;
448
460
  if (canDedup) {
449
461
  const existing = readRequestManager.getInFlight(dbKey);
450
462
  if (existing) return existing;
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  getRuntimeServerContext,
3
3
  scheduleDeleteReplication
4
- } from "./chunk-WQDTSK5U.js";
4
+ } from "./chunk-ZMFA2TLE.js";
5
5
  import {
6
6
  fetchFromClientDb
7
7
  } from "./chunk-YHNUDTU4.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  resolvePlatformAuthToken
3
- } from "./chunk-K26XPZRB.js";
3
+ } from "./chunk-LVZVSLKO.js";
4
4
 
5
5
  // packages/cli/client/localRuntimeHelpers.ts
6
6
  var REMOTE_DIALOG_SYNC_TIMEOUT_MS = 1e4;
@@ -36,7 +36,7 @@ import {
36
36
  } from "./chunk-YNIYE47Z.js";
37
37
  import {
38
38
  getDefaultCliLocalRuntimeDb
39
- } from "./chunk-BFKJ2RS3.js";
39
+ } from "./chunk-7RYODZDD.js";
40
40
  import {
41
41
  createTokenStatsKey
42
42
  } from "./chunk-SYTHYBMI.js";
@@ -11658,7 +11658,7 @@ async function runUsageCommand(args, deps) {
11658
11658
  const output = deps.output ?? process.stdout;
11659
11659
  const errorOutput = deps.errorOutput ?? process.stderr;
11660
11660
  if (args[0] === "rebuild") {
11661
- const { runUsageRebuildCommand } = await import("./usageRebuildCommand-7JR33UHS.js");
11661
+ const { runUsageRebuildCommand } = await import("./usageRebuildCommand-NK6S3D4J.js");
11662
11662
  return runUsageRebuildCommand(args.slice(1), deps);
11663
11663
  }
11664
11664
  if (hasFlag(args, "-h") || hasFlag(args, "--help")) {
@@ -11729,7 +11729,7 @@ async function runUsageCommand(args, deps) {
11729
11729
  return 0;
11730
11730
  }
11731
11731
  async function resolveUsageUserId(env) {
11732
- const { resolveLocalUserId } = await import("./cliAgentConfigHelpers-37ZNEY5Y.js");
11732
+ const { resolveLocalUserId } = await import("./cliAgentConfigHelpers-FKBPFPKR.js");
11733
11733
  return resolveLocalUserId(env);
11734
11734
  }
11735
11735
  function isLocalDbMissingError(error) {
@@ -3,34 +3,34 @@ import {
3
3
  } from "./chunk-VF4K2QE6.js";
4
4
  import {
5
5
  setDialogExtraReferencesAction
6
- } from "./chunk-OLGFIQN2.js";
6
+ } from "./chunk-T4VVQHSE.js";
7
7
  import {
8
8
  fetchAndCacheTableRows
9
- } from "./chunk-X6LYQDN5.js";
9
+ } from "./chunk-TDLZA6LJ.js";
10
10
  import {
11
11
  resolveDialogRuntimeAgentKey
12
- } from "./chunk-YQO5UKHP.js";
12
+ } from "./chunk-ZNOXY73P.js";
13
13
  import {
14
14
  createSpaceKey
15
15
  } from "./chunk-UAD2WT54.js";
16
16
  import {
17
17
  selectById
18
- } from "./chunk-HZDK56EK.js";
18
+ } from "./chunk-CO2NXG2J.js";
19
19
  import {
20
20
  require_react
21
21
  } from "./chunk-RD3QLZQV.js";
22
22
  import {
23
23
  selectRuntimeSnapshot
24
- } from "./chunk-WQDTSK5U.js";
24
+ } from "./chunk-ZMFA2TLE.js";
25
25
  import {
26
26
  createAsyncThunk
27
- } from "./chunk-6XVPMGXK.js";
27
+ } from "./chunk-YB5D2GK4.js";
28
28
  import {
29
29
  selectIdentityUserId
30
30
  } from "./chunk-PXYBUFDB.js";
31
31
  import {
32
32
  isAgentSkillDisabled
33
- } from "./chunk-CDIRKCPD.js";
33
+ } from "./chunk-6HL6E7ZD.js";
34
34
  import {
35
35
  listBuiltinSkills,
36
36
  resolveBuiltinSkillByName
@@ -791,7 +791,7 @@ var executeToolRun = createAsyncThunk(
791
791
  if (!executionInput) {
792
792
  throw new Error(`ToolRun ${id} has no input to execute with.`);
793
793
  }
794
- const { findToolExecutor } = await import("./tools-BOPINT5S.js");
794
+ const { findToolExecutor } = await import("./tools-UZ3CDIR2.js");
795
795
  const { executor } = findToolExecutor(run.toolName);
796
796
  toolRunStarted({
797
797
  id: run.id,
@@ -815,7 +815,7 @@ var executeToolRun = createAsyncThunk(
815
815
  const latestState = thunkApi.getState();
816
816
  const userId = selectIdentityUserId(latestState);
817
817
  if (userId) {
818
- const { fetchUserSpaceMemberships } = await import("./memberThunks-JFYC4Z5L.js");
818
+ const { fetchUserSpaceMemberships } = await import("./memberThunks-7DNR6DRD.js");
819
819
  await thunkApi.dispatch(fetchUserSpaceMemberships(userId));
820
820
  }
821
821
  }
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  describeAttachmentForModel
3
- } from "./chunk-LTVEOOZL.js";
3
+ } from "./chunk-CIAV4WK2.js";
4
4
 
5
5
  // packages/ai/attachments/projectUserPart.ts
6
6
  var isRecord = (value) => typeof value === "object" && value !== null;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  isPidGone
3
- } from "./chunk-YWNCRUBZ.js";
3
+ } from "./chunk-7XO73H5X.js";
4
4
 
5
5
  // packages/cli/tui/tuiRestart.ts
6
6
  import { realpathSync } from "node:fs";
@@ -7,7 +7,7 @@ import {
7
7
  import {
8
8
  readDbRecord,
9
9
  writeAgentRecord
10
- } from "./chunk-KJDN2YRH.js";
10
+ } from "./chunk-QMKWSKWA.js";
11
11
  import {
12
12
  parseUserIdFromAuthToken,
13
13
  readOption,
@@ -0,0 +1,136 @@
1
+ // packages/cli/client/cliExitSync.ts
2
+ import { AsyncLocalStorage } from "node:async_hooks";
3
+ var scopes = new AsyncLocalStorage();
4
+ var KNOWN_SYNC_FAILURE_CODES = /* @__PURE__ */ new Set([
5
+ "owner_mismatch",
6
+ "owner_origin_mismatch",
7
+ "owner_grant_revoked",
8
+ "owner_oauth_unavailable",
9
+ "invalid_grant",
10
+ "auth_no_token",
11
+ "token_expired",
12
+ "user_batch_authority_controlled",
13
+ "tombstone_conflict"
14
+ ]);
15
+ var SYNC_FAILURE_CODE_RE = /"(?:code|error|reason)"\s*:\s*"([A-Za-z0-9_.:-]{1,48})"/;
16
+ function classifyDialogSyncFailure(error) {
17
+ if (error instanceof Error && error.name === "AbortError") return "aborted";
18
+ if (error instanceof Error && error.name === "TimeoutError") return "timeout";
19
+ const match = error instanceof Error ? /^remote dialog evidence write failed: HTTP (\d{3})\b([\s\S]*)$/.exec(error.message) : null;
20
+ if (!match) return "transport_or_sync";
21
+ const candidate = SYNC_FAILURE_CODE_RE.exec(match[2] ?? "")?.[1]?.toLowerCase();
22
+ const code = candidate && KNOWN_SYNC_FAILURE_CODES.has(candidate) ? candidate : void 0;
23
+ return code ? `http_${match[1]}(${code})` : `http_${match[1]}`;
24
+ }
25
+ function startOwnedDialogSync(fetchImpl, start) {
26
+ const scope = scopes.getStore();
27
+ if (!scope) return start(fetchImpl);
28
+ if (scope.closed) return Promise.reject(new Error("dialog_sync_scope_closed"));
29
+ const entry = { watermark: scope.entries.length + 1, httpOkRecords: 0, controller: new AbortController(), state: "pending", done: Promise.resolve() };
30
+ scope.entries.push(entry);
31
+ const trackedFetch = async (url, init) => {
32
+ entry.controller.signal.throwIfAborted();
33
+ const signal = init?.signal ? AbortSignal.any([init.signal, entry.controller.signal]) : entry.controller.signal;
34
+ const response = await fetchImpl(url, { ...init, signal });
35
+ signal.throwIfAborted();
36
+ if (response.ok && String(url).includes("/api/v1/db/write/")) entry.httpOkRecords++;
37
+ return response;
38
+ };
39
+ entry.done = Promise.resolve().then(() => start(trackedFetch)).then((result) => {
40
+ if (entry.state === "pending") entry.state = "completed";
41
+ return result;
42
+ }, (error) => {
43
+ if (entry.state === "pending") {
44
+ entry.state = "failed";
45
+ entry.failureClass = classifyDialogSyncFailure(error);
46
+ }
47
+ throw error;
48
+ });
49
+ void entry.done.catch(() => {
50
+ });
51
+ return entry.done;
52
+ }
53
+ function drain(scope, unsafeRunner = false) {
54
+ if (scope.drain) return scope.drain;
55
+ scope.closed = true;
56
+ scope.drain = (async () => {
57
+ const entries = scope.entries.slice();
58
+ let timer;
59
+ const abortPending = (classification) => {
60
+ for (const entry of entries) if (entry.state === "pending") {
61
+ entry.state = "timeout";
62
+ entry.failureClass = classification;
63
+ entry.controller.abort(new Error("dialog_sync_drain_stopped"));
64
+ }
65
+ };
66
+ try {
67
+ if (unsafeRunner) abortPending("runner_not_stopped");
68
+ else if (entries.length) await Promise.race([
69
+ Promise.allSettled(entries.map((entry) => entry.done)),
70
+ new Promise((resolve) => {
71
+ timer = setTimeout(() => {
72
+ abortPending("timeout");
73
+ resolve();
74
+ }, scope.timeoutMs);
75
+ })
76
+ ]);
77
+ } finally {
78
+ if (timer) clearTimeout(timer);
79
+ }
80
+ const failed = entries.filter((entry) => entry.state !== "completed");
81
+ for (const entry of failed) scope.output.write(`[nolo] dialog_sync ${entry.state}: watermark=${entry.watermark} httpOkRecords=${entry.httpOkRecords} class=${entry.failureClass ?? entry.state}; local history retained; remote sync incomplete.
82
+ `);
83
+ return failed.length === 0;
84
+ })();
85
+ return scope.drain;
86
+ }
87
+ function exitCliFromWatchdog(code, exit, stopRunner) {
88
+ const scope = scopes.getStore();
89
+ if (!scope) {
90
+ exit(code);
91
+ return Promise.resolve();
92
+ }
93
+ if (scope.watchdogExit) return scope.watchdogExit;
94
+ scope.closed = true;
95
+ scope.watchdogExit = (async () => {
96
+ let stopped = false;
97
+ try {
98
+ stopped = await stopRunner();
99
+ } catch {
100
+ }
101
+ if (!stopped) scope.output.write("[nolo] dialog_sync failed: class=runner_not_stopped; cancelling pending sync before hard exit.\n");
102
+ const complete = await drain(scope, !stopped);
103
+ exit(code === 0 || !complete ? 1 : code);
104
+ })();
105
+ return scope.watchdogExit;
106
+ }
107
+ async function runCliCommandWithSyncDrain(command, options) {
108
+ const timeoutMs = Number.isFinite(options.timeoutMs) && (options.timeoutMs ?? 0) > 0 ? options.timeoutMs : 15e3;
109
+ await scopes.run({ entries: [], closed: false, output: options.output, timeoutMs }, async () => {
110
+ const scope = scopes.getStore();
111
+ let code = 70;
112
+ let commandError;
113
+ let commandThrew = false;
114
+ try {
115
+ code = await command();
116
+ } catch (error) {
117
+ commandThrew = true;
118
+ commandError = error;
119
+ }
120
+ if (scope.watchdogExit) {
121
+ await scope.watchdogExit;
122
+ if (commandThrew) throw commandError;
123
+ return;
124
+ }
125
+ const complete = await drain(scope);
126
+ if (commandThrew) throw commandError;
127
+ await options.exit(code === 0 && !complete ? 1 : code);
128
+ });
129
+ }
130
+
131
+ export {
132
+ classifyDialogSyncFailure,
133
+ startOwnedDialogSync,
134
+ exitCliFromWatchdog,
135
+ runCliCommandWithSyncDrain
136
+ };