nolo-cli 0.228.0 → 0.228.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (212) hide show
  1. package/{_executeModel-GIFVXKDT.js → _executeModel-AKCTHGMP.js} +62 -61
  2. package/{action-WZTKEF5H.js → action-C6IQAKN4.js} +6 -6
  3. package/{addContentAction-MLI6GOBV.js → addContentAction-53364YDW.js} +10 -10
  4. package/{addDialogAgentAction-ARGQM22H.js → addDialogAgentAction-U5DD5EN5.js} +9 -9
  5. package/{agentDeleteCommand-UF7XVELS.js → agentDeleteCommand-2E5FAGUO.js} +99 -93
  6. package/{agentEmailCommands-SFHRPQYC.js → agentEmailCommands-UGZZAH7E.js} +99 -93
  7. package/{agentListCommands-IXKBP3W5.js → agentListCommands-JCTW3J2K.js} +240 -52
  8. package/{agentMachineCommands-7NX6PWQ6.js → agentMachineCommands-QPG5ZXF4.js} +45 -41
  9. package/{agentProviderCommands-C5T7C5KZ.js → agentProviderCommands-QLTABYR7.js} +2 -2
  10. package/{agentPullCommand-4EQZYHU4.js → agentPullCommand-2EYJ5ENC.js} +1 -1
  11. package/{agentRecordCommands-IUNX6XD6.js → agentRecordCommands-4NTVR6MZ.js} +98 -92
  12. package/{agentRunCommand-LCR4XADM.js → agentRunCommand-VHF34PYC.js} +103 -94
  13. package/{agentRunControl-RN2P6AOD.js → agentRunControl-QYTXUQGY.js} +10 -7
  14. package/{agentRuntimeLocal-LVXPQ7QA.js → agentRuntimeLocal-U54AKHXH.js} +38 -36
  15. package/{agentSlice-ZGMOH6TE.js → agentSlice-4JGDEXWK.js} +10 -10
  16. package/{appDeleteCommands-BESCJOQM.js → appDeleteCommands-XBE5QJ6P.js} +46 -42
  17. package/{appDeployCommands-LPTR6IOX.js → appDeployCommands-QIYLXXGA.js} +46 -42
  18. package/{appDeployStatusCommands-BZ7KZ5RD.js → appDeployStatusCommands-JXS6ZQZZ.js} +46 -42
  19. package/{appGetCommands-EDWGJV4S.js → appGetCommands-SZS7SJPK.js} +46 -42
  20. package/{appListCommands-OPRWYPM6.js → appListCommands-B3GBJSNV.js} +46 -42
  21. package/{authCommand-3C3RN4OU.js → authCommand-V6EOMZX6.js} +15 -15
  22. package/{authCommands-ZMVEDCQD.js → authCommands-T5FODCEG.js} +2 -2
  23. package/{builtinSkillRegistry-VRCMQ77Q.js → builtinSkillRegistry-ZQC3IIO2.js} +4 -3
  24. package/{chromeOpsCommands-NZITLHWO.js → chromeOpsCommands-OFX7ZGKP.js} +2 -2
  25. package/{chunk-MZVCFV3T.js → chunk-223KZUJ6.js} +4 -4
  26. package/{chunk-UF6J7NXV.js → chunk-2C5VN7NH.js} +1 -1
  27. package/{chunk-MAA42MMV.js → chunk-2FZVXOFX.js} +4 -4
  28. package/{chunk-ESN4WNWU.js → chunk-2JHGUL5K.js} +2 -2
  29. package/chunk-3A5NNQCN.js +64 -0
  30. package/chunk-3F2FRLIO.js +372 -0
  31. package/{chunk-V4IYI3SB.js → chunk-46FETNLF.js} +2 -2
  32. package/{chunk-RR3MB26M.js → chunk-4GYVS4PM.js} +8 -6
  33. package/{chunk-ZQ6K57FJ.js → chunk-4YPH5KRA.js} +1 -1
  34. package/{chunk-Y4NPF2UN.js → chunk-5AYP5QBB.js} +5 -5
  35. package/{chunk-4OXPN3WC.js → chunk-5ISNPTQH.js} +4 -4
  36. package/{chunk-CO6E7YK6.js → chunk-5P3PPQVP.js} +1 -1
  37. package/{chunk-6TVYUQRM.js → chunk-6BMTKYAO.js} +2 -2
  38. package/{chunk-KLAMJNKQ.js → chunk-6PAHSSD2.js} +15 -8
  39. package/{chunk-CTWCZKNS.js → chunk-6SOWMEAY.js} +4 -4
  40. package/{chunk-ARFCL53U.js → chunk-6VEO7Z3Y.js} +5 -5
  41. package/{chunk-ZM5AZTQG.js → chunk-7BIJFGKS.js} +20 -8
  42. package/{chunk-BAH3BAUZ.js → chunk-7OVOZRZF.js} +5 -5
  43. package/{chunk-N74XL3NI.js → chunk-7PON4LBY.js} +42 -24
  44. package/{chunk-LTVEOOZL.js → chunk-7WHCIA5V.js} +16 -3
  45. package/{chunk-HZDK56EK.js → chunk-ADYWV732.js} +34 -12
  46. package/{chunk-2FK2KZSL.js → chunk-AIFQKNPP.js} +1 -1
  47. package/{chunk-VTHWBTRE.js → chunk-BPB3T5EU.js} +5 -8
  48. package/{chunk-SX6AWTNK.js → chunk-BZLGPM5B.js} +3 -3
  49. package/{chunk-MTM4LRVG.js → chunk-BZMDWGQQ.js} +2 -2
  50. package/{chunk-JP2BH4NC.js → chunk-CEKRIR22.js} +1 -1
  51. package/{chunk-5HUO7SEX.js → chunk-D634SL2Y.js} +1 -1
  52. package/{chunk-SCMYAGQE.js → chunk-DHRPLRIR.js} +294 -159
  53. package/{chunk-VUHKG4KS.js → chunk-DNNPARJK.js} +9 -5
  54. package/{chunk-X22AUZKL.js → chunk-E3LSO6EI.js} +189 -88
  55. package/{chunk-LHCGKAFO.js → chunk-EHFBP6IK.js} +100 -48
  56. package/{chunk-6ASGEP5D.js → chunk-EJQE5HB7.js} +1 -1
  57. package/{chunk-2BKNICGK.js → chunk-EL5NRJHI.js} +1 -1
  58. package/chunk-EUGTFFO6.js +42 -0
  59. package/{chunk-YFW4H6DL.js → chunk-EVHTYVD2.js} +821 -131
  60. package/{chunk-6XRPBZRS.js → chunk-EYLGAEB4.js} +0 -134
  61. package/{chunk-E5RYFR7E.js → chunk-FEIVARWR.js} +49 -15
  62. package/{chunk-3DJJ4CFG.js → chunk-FLBJ7IJI.js} +9 -9
  63. package/{chunk-W3HSD32M.js → chunk-FXEPZKNJ.js} +2 -2
  64. package/{chunk-VKCPKCSS.js → chunk-FYAMUU55.js} +625 -62
  65. package/{chunk-JEWMQR6J.js → chunk-FZANZZ63.js} +1 -1
  66. package/{chunk-WWTSEBDF.js → chunk-GIXWVN2W.js} +1 -1
  67. package/{chunk-YHNUDTU4.js → chunk-HDKMVYNJ.js} +4 -4
  68. package/chunk-HEVRQGGH.js +106 -0
  69. package/{chunk-PBPXXMWZ.js → chunk-HFHJPHFK.js} +1 -1
  70. package/{chunk-WQDTSK5U.js → chunk-HPDLPEUG.js} +11 -5
  71. package/{chunk-SPU3L3OR.js → chunk-HQUGB2HM.js} +3 -3
  72. package/chunk-IVK2KT3H.js +209 -0
  73. package/{chunk-73PZD7JZ.js → chunk-IYLUK67R.js} +2 -2
  74. package/{chunk-BFKJ2RS3.js → chunk-J55F3IEZ.js} +1 -1
  75. package/{chunk-ADOOL3PG.js → chunk-J7JRCOIW.js} +1 -1
  76. package/{chunk-AEZBAFC6.js → chunk-JAKRY74O.js} +138 -8
  77. package/{chunk-NEG5LYK5.js → chunk-JCQ3WCQ3.js} +3 -1
  78. package/{chunk-W6T4FNZP.js → chunk-JLZJL3WC.js} +219 -351
  79. package/{chunk-PQ63BDV3.js → chunk-JPXACKSW.js} +9 -1
  80. package/{chunk-IIOSZAJX.js → chunk-KDBDOXOM.js} +137 -53
  81. package/{chunk-CIGCTSBF.js → chunk-KDDHQMSH.js} +1 -1
  82. package/{chunk-OAZP4TSA.js → chunk-KG27JIG4.js} +2 -2
  83. package/{chunk-RHBD22LV.js → chunk-KHYSFS3W.js} +80 -4
  84. package/{chunk-7UVVLYKC.js → chunk-KKIQAVDR.js} +5 -5
  85. package/{chunk-HS7MLR74.js → chunk-KZ4A7EIV.js} +3 -5
  86. package/{chunk-OLGFIQN2.js → chunk-LLUBUHNT.js} +1 -1
  87. package/{chunk-QJTZ76CP.js → chunk-LS5KAVFQ.js} +1 -0
  88. package/{chunk-K26XPZRB.js → chunk-LVZVSLKO.js} +29 -9
  89. package/{chunk-XJSEST7D.js → chunk-MNFUKRRU.js} +3 -3
  90. package/{chunk-R5NRFXGD.js → chunk-O3A2CHAL.js} +5 -5
  91. package/{chunk-4IQN6FWY.js → chunk-OB4FBZXJ.js} +4 -4
  92. package/{chunk-J2VIGDJN.js → chunk-OJSJJKHF.js} +3 -3
  93. package/{chunk-OHUYN3YU.js → chunk-OKAXQFON.js} +1 -1
  94. package/{chunk-CD2DK5JA.js → chunk-OKH74FML.js} +2 -1
  95. package/{chunk-MYYNZG2M.js → chunk-OOV5JN25.js} +4 -4
  96. package/{chunk-TMRJGSK2.js → chunk-OOVOAG4Q.js} +1 -1
  97. package/chunk-OQFOE4SJ.js +405 -0
  98. package/{chunk-AS6L5KSD.js → chunk-P4R5KXU7.js} +2 -2
  99. package/{chunk-VIYVRPMJ.js → chunk-PHREU2KZ.js} +5 -3
  100. package/{chunk-EDT65EUE.js → chunk-PIVTQRX6.js} +45 -15
  101. package/{chunk-QMNVV3YM.js → chunk-PJL7OJRC.js} +12 -11
  102. package/{chunk-XCA4WHX5.js → chunk-PNLDLUMO.js} +315 -360
  103. package/{chunk-UPOW5HTG.js → chunk-QGFLVQ6E.js} +3 -3
  104. package/{chunk-JU7VN4LF.js → chunk-QONAOHVW.js} +6 -6
  105. package/{chunk-UOUMPHS5.js → chunk-R3FZHW4Q.js} +13 -13
  106. package/{chunk-K7VIXYTZ.js → chunk-R3MV2GII.js} +1 -45
  107. package/{chunk-FE7G6DSP.js → chunk-R72QWIFO.js} +14 -4
  108. package/{chunk-KZAT2M2V.js → chunk-RIWKZT7E.js} +22 -0
  109. package/{chunk-RMWDKLBE.js → chunk-S7H4KTMB.js} +1099 -71
  110. package/{chunk-IJZC2KIJ.js → chunk-SA356NGW.js} +1 -1
  111. package/{chunk-BVEDT6DM.js → chunk-SCAC3NM5.js} +3 -3
  112. package/{chunk-EQZQUQ33.js → chunk-SLUN7W6S.js} +5 -5
  113. package/{chunk-KK3FCYZM.js → chunk-SQL7YNED.js} +7 -4
  114. package/{chunk-LMGFVH65.js → chunk-SSOR2EDT.js} +10 -10
  115. package/chunk-TRRXYFTR.js +46 -0
  116. package/{chunk-XNTZD4AE.js → chunk-TUOHSUK5.js} +19367 -17503
  117. package/chunk-TYJCIA2O.js +835 -0
  118. package/{chunk-FTWAOKFU.js → chunk-U3BUWDUP.js} +415 -1962
  119. package/{chunk-CD64YXRB.js → chunk-U6QNVOR5.js} +1 -1
  120. package/chunk-UAF5VQCE.js +77 -0
  121. package/{chunk-CIUZXD5D.js → chunk-UFGUJ2IH.js} +5 -5
  122. package/{chunk-CTIEJRTP.js → chunk-UP7KBWLE.js} +81 -29
  123. package/{chunk-GX6DITLQ.js → chunk-UUCYUN6Y.js} +1 -1
  124. package/{chunk-UHW6SCVK.js → chunk-UZKBVQUX.js} +1 -1
  125. package/{chunk-XSRSAU3O.js → chunk-V5TI7HJH.js} +3 -3
  126. package/{chunk-WFGNWWJI.js → chunk-VH7UO6E5.js} +252 -114
  127. package/{chunk-ITBX27W6.js → chunk-VJFDG3ZG.js} +30 -122
  128. package/{chunk-6MTVACLN.js → chunk-WC3J5SL2.js} +277 -293
  129. package/{chunk-HCCQEMTK.js → chunk-WD5547ZF.js} +15 -12
  130. package/{chunk-X3OZ655T.js → chunk-WS36XPJD.js} +2 -2
  131. package/{chunk-JFRJEPFI.js → chunk-WSLL7VV4.js} +2 -2
  132. package/chunk-XRGBJHZX.js +136 -0
  133. package/{chunk-KZ5OD2MO.js → chunk-Y2KWJTOZ.js} +3 -3
  134. package/{dialogUsageCommand-6RW2FY6K.js → chunk-Y2TCTNUD.js} +24 -17
  135. package/{chunk-FFFKAOJN.js → chunk-YN23INFZ.js} +1 -1
  136. package/{chunk-ODBYGVO2.js → chunk-YXK3GJF5.js} +5 -5
  137. package/{chunk-6CXQ3YNJ.js → chunk-Z2OWAYMI.js} +53 -31
  138. package/{chunk-6XVPMGXK.js → chunk-ZTHAJU3O.js} +10 -4
  139. package/{chunk-D25ONVOH.js → chunk-ZYPXOQS2.js} +1 -1
  140. package/{cliAgentConfigHelpers-37ZNEY5Y.js → cliAgentConfigHelpers-BXHQ3PXP.js} +8 -8
  141. package/{cliAuthorityBrokerClient-SFPC3WVK.js → cliAuthorityBrokerClient-TFNXJLXL.js} +1 -1
  142. package/cliAuthorityBrokerProcess-5ZFBTHLB.js +22 -0
  143. package/{cliLocalAgentRecordReader-MCQVRWBR.js → cliLocalAgentRecordReader-47PXMHPH.js} +43 -41
  144. package/{commandRegistry-NTH5IAN5.js → commandRegistry-CTMPAQH2.js} +93 -156
  145. package/{contentThunks-SPXTX5U2.js → contentThunks-CAHIIZO5.js} +25 -25
  146. package/{cooldownCommands-TIFCHCUN.js → cooldownCommands-WDOI5VD7.js} +3 -3
  147. package/{createAgentAutomationAction-KUQKCOXB.js → createAgentAutomationAction-M25XZSPD.js} +25 -25
  148. package/{createDialogAction-HJN5U3XS.js → createDialogAction-4SN7FKI7.js} +26 -26
  149. package/{createPageAction-ZAHRDOAU.js → createPageAction-N7QPDN3M.js} +28 -28
  150. package/{db-CMUTP3W5.js → db-VR74ADGC.js} +7 -2
  151. package/{dbSlice-656PMWR2.js → dbSlice-RWPSVHBC.js} +9 -9
  152. package/{deleteFile-ZCQESEEQ.js → deleteFile-ECU6FU5C.js} +12 -7
  153. package/{dialogCommands-KZTZLWPZ.js → dialogCommands-BBHWCKDP.js} +57 -47
  154. package/{dialogNotifyCommand-PST75COP.js → dialogNotifyCommand-IASQGEMW.js} +9 -9
  155. package/{dialogSlice-BXIERQHO.js → dialogSlice-JI3J22RV.js} +23 -23
  156. package/dialogTraceCommand-EW2KK6A4.js +961 -0
  157. package/dialogUsageCommand-WJ3U6KZU.js +27 -0
  158. package/{docCreateCommands-26HJ5NAY.js → docCreateCommands-QSX3X5U4.js} +45 -41
  159. package/{docDeleteCommands-UAOHH5XK.js → docDeleteCommands-63JBG2HQ.js} +46 -42
  160. package/{docReadCommands-4ADG7YE6.js → docReadCommands-CQFKRQUI.js} +45 -41
  161. package/{docStore-FZ75HWP2.js → docStore-XLBKGGNM.js} +10 -10
  162. package/{docUpdateCommands-OGFJZENF.js → docUpdateCommands-534LUK25.js} +45 -41
  163. package/ebookDownloaderAgentCommand-DYSKF5ZY.js +677 -0
  164. package/{getPricing-FCHYVRJU.js → getPricing-5BLZRPTM.js} +3 -3
  165. package/{handleSendMessageAction-KP6GGBFY.js → handleSendMessageAction-Q2VMEVOR.js} +90 -48
  166. package/{hostCredentialCreate-23TX56G7.js → hostCredentialCreate-C57T7YPE.js} +99 -93
  167. package/index.js +23 -11
  168. package/{localDialogRead-CIOTQM5T.js → localDialogRead-BJJT3TF5.js} +1 -1
  169. package/{localRuntimeAdapter-MTUWOYPN.js → localRuntimeAdapter-OALZPFZU.js} +96 -90
  170. package/{localRuntimeAuthority-TYHQCTZN.js → localRuntimeAuthority-UF2DAQ3F.js} +13 -3
  171. package/{localRuntimeDb-BO7IVWAZ.js → localRuntimeDb-ZJFGNHML.js} +1 -1
  172. package/{machineCommands-4WJUJQHW.js → machineCommands-N6IVWRZT.js} +109 -92
  173. package/{machineWsRunDispatch-V3U4JM67.js → machineWsRunDispatch-PDWYB33B.js} +97 -91
  174. package/{markdownToSlate-KIYM7B3P.js → markdownToSlate-PXYAIBVL.js} +1 -1
  175. package/{mcpLocalAuthorizeCommand-TI656UWC.js → mcpLocalAuthorizeCommand-KYI4EGF5.js} +17 -13
  176. package/{memberThunks-JFYC4Z5L.js → memberThunks-43B7UYC5.js} +11 -11
  177. package/{models-EP7VG6N2.js → models-ZX2BYIMB.js} +2 -2
  178. package/package.json +2 -1
  179. package/{projectArchive-NU2Z5HOR.js → projectArchive-TJNW5DLM.js} +28 -28
  180. package/{providerPresetApply-4H7YP5D7.js → providerPresetApply-NTJUINI6.js} +35 -16
  181. package/{providerRegistry-F3UPOTIY.js → providerRegistry-W45SLUV6.js} +5 -5
  182. package/{read-BRZHXUJ6.js → read-KG6INYUT.js} +12 -7
  183. package/{readDocTool-N7RVFQEE.js → readDocTool-N3GA52JR.js} +1 -1
  184. package/{readlineWorkspace-T56MRMS5.js → readlineWorkspace-PJZJVGA5.js} +1296 -1056
  185. package/{removeDialogAgentAction-J7XU7OUX.js → removeDialogAgentAction-EEVSOQOJ.js} +11 -11
  186. package/{runAgentClientLoop-O2GRCGRZ.js → runAgentClientLoop-3VC5TCDW.js} +69 -58
  187. package/{runtimeDoctorCommands-RDRJXMXC.js → runtimeDoctorCommands-V3M3JTUV.js} +14 -11
  188. package/{secretCommands-2FEMRUFM.js → secretCommands-KVVZS7A6.js} +2 -2
  189. package/{setDialogExtraReferencesAction-Q4V2ZZW2.js → setDialogExtraReferencesAction-DNO5POHA.js} +10 -10
  190. package/{setPrimaryDialogAgentAction-742H5S6T.js → setPrimaryDialogAgentAction-QABBEO4C.js} +11 -11
  191. package/{settingThunks-T4FXSV6M.js → settingThunks-DVKG4X4S.js} +13 -17
  192. package/{skillDiscovery-MDDKPTW3.js → skillDiscovery-ZMJH36AK.js} +3 -3
  193. package/{spaceCommands-W5TAVFDT.js → spaceCommands-AGGZXPY3.js} +218 -77
  194. package/{streamAgentChatTurn-OWDJMU5E.js → streamAgentChatTurn-4GTLL2OF.js} +111 -95
  195. package/{switchDialogAgentAction-HLDLHRRA.js → switchDialogAgentAction-KYWJSGOO.js} +9 -9
  196. package/{tableCommands-44GC4N6J.js → tableCommands-EFA754RE.js} +3 -3
  197. package/{tools-O7SGGVA3.js → tools-5AGPOPLW.js} +48 -47
  198. package/{tuiRestart-EOGC2BYY.js → tuiRestart-77E7PL4R.js} +9 -8
  199. package/{tuiSummaryLlmCaller-TM5BU73J.js → tuiSummaryLlmCaller-HROLGN4F.js} +12 -12
  200. package/{updateCommands-FBYA5WVG.js → updateCommands-GJGRS6JK.js} +3 -3
  201. package/{updateDialogTitleAction-EXSZGTLL.js → updateDialogTitleAction-5OSEDGRK.js} +25 -25
  202. package/{usageCommand-L4OFWXEU.js → usageCommand-WI6SQOPB.js} +2 -2
  203. package/{usageRebuildCommand-7JR33UHS.js → usageRebuildCommand-WQRLLZAT.js} +3 -3
  204. package/{windowsSelfUpdate-M4V77OUB.js → windowsSelfUpdate-C7LGVWYX.js} +2 -2
  205. package/{workloadLifecycle-ZCSQCHG3.js → workloadLifecycle-P2SJVV3S.js} +2 -2
  206. package/chunk-FGHEF6WI.js +0 -34
  207. package/chunk-U5LOKQ2R.js +0 -176
  208. package/chunk-YDRRGVT5.js +0 -142
  209. package/chunk-YGDYYFRX.js +0 -86
  210. package/chunk-Z7KE4K3H.js +0 -758
  211. package/lib-62SWPXNF.js +0 -21042
  212. /package/{chunk-ANUP75N2.js → chunk-2E4BYAUE.js} +0 -0
@@ -1,36 +1,36 @@
1
+ import {
2
+ loadCliAuthorityBrokerTls
3
+ } from "./chunk-3A5NNQCN.js";
1
4
  import {
2
5
  Level,
3
- createLegacyServerDb,
4
- createLevelAuthorityStore,
5
- isLevelLockError
6
- } from "./chunk-K7VIXYTZ.js";
6
+ createLevelAuthorityStore
7
+ } from "./chunk-R3MV2GII.js";
7
8
  import {
8
9
  createCliAuthorityBrokerClient,
9
- createCliAuthorityBrokerSocketInvoker,
10
- isCliAuthorityBrokerTimeoutError,
11
- isCliAuthorityBrokerUnavailableError
12
- } from "./chunk-KK3FCYZM.js";
10
+ createCliAuthorityBrokerSocketInvoker
11
+ } from "./chunk-SQL7YNED.js";
13
12
  import {
14
- resolveCliAuthorityBrokerEndpoint,
15
- resolveCliAuthorityBrokerHealthPath,
16
- resolveCliAuthorityBrokerMetadataPath
17
- } from "./chunk-CVMMWN6P.js";
13
+ getLogger
14
+ } from "./chunk-EYLGAEB4.js";
18
15
  import {
19
- resolveNoloHome
20
- } from "./chunk-GLKOYSRU.js";
16
+ getHostRuntimeExecutable,
17
+ isCompiledBinary,
18
+ resolveCliEntrypointPath
19
+ } from "./chunk-BIDSIRTS.js";
21
20
  import {
22
21
  toErrorMessage
23
22
  } from "./chunk-HNMXYYJR.js";
24
23
 
25
- // packages/cli/localRuntimeAuthority.ts
26
- import fs4 from "node:fs";
27
- import { randomUUID } from "node:crypto";
28
- import path4 from "node:path";
24
+ // packages/cli/cliAuthorityBrokerProcess.ts
25
+ import { spawn } from "node:child_process";
26
+ import { dirname, isAbsolute, resolve } from "node:path";
27
+ import { setTimeout as delay } from "node:timers/promises";
29
28
 
30
29
  // packages/database-engine/cliAuthorityBrokerServer.ts
31
30
  import fs3 from "node:fs";
32
31
  import path3 from "node:path";
33
32
  import { createServer } from "node:net";
33
+ import { createServer as createTlsServer } from "node:tls";
34
34
 
35
35
  // packages/database-engine/levelDbCorruptionRecovery.ts
36
36
  import fs from "node:fs";
@@ -362,7 +362,7 @@ async function executeCliAuthorityBrokerRequest(store, request) {
362
362
  return { ok: true, result: { type: "conditionalPut", status: "updated" } };
363
363
  }
364
364
  case "status":
365
- return { ok: true, result: { type: "status" } };
365
+ return { ok: true, result: { type: "status", ...request.includeLocation && store.location ? { location: store.location } : {} } };
366
366
  case "open":
367
367
  await store.open();
368
368
  return { ok: true, result: { type: "open" } };
@@ -466,7 +466,7 @@ async function createBrokerHandle(options) {
466
466
  let store;
467
467
  let ownershipLock;
468
468
  const sockets = /* @__PURE__ */ new Set();
469
- const server = createServer((socket) => {
469
+ const onConnection = (socket) => {
470
470
  sockets.add(socket);
471
471
  socket.once("close", () => sockets.delete(socket));
472
472
  socket.on("error", () => {
@@ -479,21 +479,22 @@ async function createBrokerHandle(options) {
479
479
  return;
480
480
  }
481
481
  bindSocketRequestHandler({ socket, store, maxFrameChars: options.maxFrameChars });
482
- });
482
+ };
483
+ const server = options.tls ? createTlsServer({ ...options.tls, requestCert: true, rejectUnauthorized: true, handshakeTimeout: 5e3 }, onConnection) : createServer(onConnection);
483
484
  let storeReady = false;
484
485
  try {
485
486
  if (socketMode) {
486
487
  if (target.kind === "unix") ensureParentDir(target.path);
487
- await new Promise((resolve, reject) => {
488
+ await new Promise((resolve2, reject) => {
488
489
  server.once("error", reject);
489
490
  const onListening = () => {
490
491
  server.off("error", reject);
491
- resolve();
492
+ resolve2();
492
493
  };
493
494
  if (target.kind === "unix") server.listen(target.path, onListening);
494
495
  else server.listen(target.port, target.host, onListening);
495
496
  });
496
- server.unref();
497
+ if (!options.keepProcessAlive) server.unref();
497
498
  }
498
499
  if (options.dbPath) {
499
500
  ownershipLock = acquireLevelDbOwnershipLock(options.dbPath);
@@ -507,6 +508,8 @@ async function createBrokerHandle(options) {
507
508
  const listeningEndpoint = (options.transportMode ?? "socket") === "socket" ? buildListeningEndpoint(server, target) : options.endpoint;
508
509
  writeJsonFile(options.metadataPath, {
509
510
  pid: process.pid,
511
+ ...options.tls ? { transportSecurity: "mutual-tls" } : {},
512
+ ...options.supervisorPid === void 0 ? {} : { supervisorPid: options.supervisorPid },
510
513
  endpoint: listeningEndpoint,
511
514
  location: readyStore.location ?? listeningEndpoint,
512
515
  startedAt: new Date(now()).toISOString()
@@ -544,8 +547,8 @@ async function createBrokerHandle(options) {
544
547
  await Promise.all(queue.active);
545
548
  for (const socket of sockets) socket.destroy();
546
549
  if (server.listening) {
547
- await new Promise((resolve, reject) => {
548
- server.close((error) => error ? reject(error) : resolve());
550
+ await new Promise((resolve2, reject) => {
551
+ server.close((error) => error ? reject(error) : resolve2());
549
552
  });
550
553
  }
551
554
  await readyStore.close();
@@ -566,7 +569,7 @@ async function createBrokerHandle(options) {
566
569
  storeReady = false;
567
570
  for (const socket of sockets) socket.destroy();
568
571
  if (server.listening) {
569
- await new Promise((resolve) => server.close(() => resolve()));
572
+ await new Promise((resolve2) => server.close(() => resolve2()));
570
573
  }
571
574
  if (store) {
572
575
  try {
@@ -776,345 +779,210 @@ function getOrCreateCliAuthorityBrokerServer(options) {
776
779
  return pending;
777
780
  }
778
781
 
779
- // packages/cli/localRuntimeAuthority.ts
780
- function ensureDbParentDir(dbPath) {
781
- fs4.mkdirSync(path4.dirname(dbPath), { recursive: true });
782
- }
783
- function findCliAuthorityCorruption(error) {
784
- const seen = /* @__PURE__ */ new Set();
785
- let current = error;
786
- while (current && !seen.has(current)) {
787
- seen.add(current);
788
- if (current.code === "LEVEL_CORRUPTION" || /Corruption:|missing files/i.test(toErrorMessage(current))) return current;
789
- current = current.cause;
790
- }
791
- return void 0;
792
- }
793
- function throwCliAuthorityStartupError(error) {
794
- const corruption = findCliAuthorityCorruption(error);
795
- if (corruption) {
796
- throw new Error(`Local authority database corruption: ${toErrorMessage(corruption)}`, { cause: error });
797
- }
798
- throw error;
799
- }
800
- function isCliAuthorityLockError(error) {
801
- if (findCliAuthorityCorruption(error)) return false;
802
- const seen = /* @__PURE__ */ new Set();
803
- let current = error;
804
- while (current && !seen.has(current)) {
805
- seen.add(current);
806
- if (isLevelLockError(current)) return true;
807
- current = current.cause;
808
- }
809
- return /EADDRINUSE|Failed to listen/i.test(toErrorMessage(error));
810
- }
811
- async function sleep(ms) {
812
- await new Promise((resolve) => setTimeout(resolve, ms));
813
- }
814
- function resolveCliLocalRuntimeDbPath(options = {}) {
815
- return path4.join(
816
- resolveNoloHome({
817
- env: options.env,
818
- homeDir: options.homeDir
819
- }),
820
- "data",
821
- "leveldb"
822
- );
782
+ // packages/cli/cliAuthorityBrokerProcess.ts
783
+ var testOwnedBroker = () => process.env.NOLO_TEST_AUTHORITY_BROKER_LIFETIME === "1";
784
+ function stopOnParentExit(stop) {
785
+ process.stdin.once("end", stop);
786
+ process.stdin.once("error", stop);
787
+ process.stdin.resume();
788
+ }
789
+ function describeFailure(error, depth = 0) {
790
+ if (!(error instanceof Error)) return { message: String(error) };
791
+ const { message, code, ownerPid, cause } = error;
792
+ return {
793
+ message,
794
+ ...typeof code === "string" ? { code } : {},
795
+ ...typeof ownerPid === "number" ? { ownerPid } : {},
796
+ ...cause !== void 0 && depth < 4 ? { cause: describeFailure(cause, depth + 1) } : {}
797
+ };
823
798
  }
824
- var DEFAULT_ATTACH_BACKOFF_MS = [100, 200, 400, 800];
825
- var DEFAULT_ATTACH_RETRY_BUDGET_MS = 9e3;
826
- function findOwnerPid(error) {
827
- const seen = /* @__PURE__ */ new Set();
828
- let current = error;
829
- while (current && typeof current === "object" && !seen.has(current)) {
830
- seen.add(current);
831
- const pid = current.ownerPid;
832
- if (typeof pid === "number" && Number.isInteger(pid) && pid > 0) {
833
- return pid;
799
+ async function startCliAuthorityBrokerProcess(options) {
800
+ const child = await launchBroker(options, true);
801
+ child.unref();
802
+ }
803
+ async function launchBroker(options, detached) {
804
+ const { endpoint, dbPath, metadataPath, healthPath } = options;
805
+ if (!dbPath || !metadataPath || !healthPath) throw new Error("Missing authority broker paths");
806
+ const entrypoint = isCompiledBinary() ? [] : [resolveCliEntrypointPath(import.meta.url)];
807
+ const { PATH, HOME, USERPROFILE, LOCALAPPDATA, SystemRoot, TMPDIR, TEMP, TMP } = process.env;
808
+ const testOwned = testOwnedBroker();
809
+ const child = spawn(getHostRuntimeExecutable(), [
810
+ ...entrypoint,
811
+ detached ? "__authority-broker-supervise" : "__authority-broker",
812
+ endpoint,
813
+ resolve(dbPath),
814
+ resolve(metadataPath),
815
+ resolve(healthPath),
816
+ ...detached ? [] : [String(process.pid)]
817
+ ], {
818
+ detached,
819
+ windowsHide: true,
820
+ // Only tests hold a lifetime pipe. Production deliberately outlives its launcher.
821
+ stdio: [testOwned ? "pipe" : "ignore", "pipe", "ignore"],
822
+ env: {
823
+ PATH,
824
+ HOME,
825
+ USERPROFILE,
826
+ LOCALAPPDATA,
827
+ SystemRoot,
828
+ TMPDIR,
829
+ TEMP,
830
+ TMP,
831
+ NOLO_HOME: dirname(dirname(resolve(dbPath))),
832
+ ...testOwned ? { NOLO_TEST_AUTHORITY_BROKER_LIFETIME: "1" } : {}
834
833
  }
835
- current = current.cause;
836
- }
837
- return void 0;
838
- }
839
- function isTransientBrokerOpenError(error) {
840
- return isCliAuthorityBrokerUnavailableError(error) || isCliAuthorityBrokerTimeoutError(error);
841
- }
842
- var defaultCliAuthorityBrokerConnectDeps = {
843
- createClient: (options) => createCliAuthorityBrokerClient(options),
844
- startBroker: (options) => getOrCreateCliAuthorityBrokerServer(options),
845
- sleep,
846
- useFastPath: true
847
- };
848
- async function connectCliAuthorityBroker(args) {
849
- const deps = {
850
- ...defaultCliAuthorityBrokerConnectDeps,
851
- ...args.deps
852
- };
853
- async function connectClient() {
854
- const client2 = deps.createClient({
855
- endpoint: args.endpoint,
856
- invoke: createCliAuthorityBrokerSocketInvoker({ endpoint: args.endpoint })
857
- });
858
- const backoffSchedule = deps.attachBackoffMs?.length ? deps.attachBackoffMs : DEFAULT_ATTACH_BACKOFF_MS;
859
- const retryBudgetMs = deps.attachRetryBudgetMs ?? DEFAULT_ATTACH_RETRY_BUDGET_MS;
860
- let waitedMs = 0;
861
- let backoffStep = 0;
862
- let lastAttachError;
863
- const waitBackoff = async () => {
864
- if (waitedMs >= retryBudgetMs) return false;
865
- const delay = backoffSchedule[Math.min(backoffStep, backoffSchedule.length - 1)];
866
- if (waitedMs > 0 && waitedMs + delay > retryBudgetMs) return false;
867
- backoffStep += 1;
868
- const startedAt = Date.now();
869
- await deps.sleep(delay);
870
- waitedMs += Math.max(delay, Date.now() - startedAt);
871
- return true;
872
- };
873
- async function attachToExistingBroker(attempts) {
874
- for (let attempt = 0; attempt < attempts; attempt += 1) {
875
- if (!await waitBackoff()) return false;
876
- const probeStartedAt = Date.now();
834
+ });
835
+ child.stdin?.on("error", () => {
836
+ });
837
+ const output = child.stdout;
838
+ try {
839
+ await new Promise((resolve2, reject) => {
840
+ let response = "";
841
+ const timer = setTimeout(() => reject(new Error(`Authority broker startup timed out at ${endpoint}`)), 3e4);
842
+ const done = (error) => {
843
+ clearTimeout(timer);
844
+ if (error) reject(error);
845
+ else resolve2();
846
+ };
847
+ child.once("error", done);
848
+ child.once("exit", (_code, signal) => {
849
+ if (signal) done(new Error(`Authority broker exited during startup (${signal})`));
850
+ });
851
+ output.once("error", done);
852
+ output.once("end", () => done(new Error("Authority broker exited before reporting readiness")));
853
+ output.setEncoding("utf8");
854
+ output.on("data", (chunk) => {
855
+ response += chunk;
856
+ if (response.length > 64 * 1024) return done(new Error("Oversized authority broker startup response"));
857
+ const newline = response.indexOf("\n");
858
+ if (newline < 0) return;
877
859
  try {
878
- await client2.open();
879
- return true;
880
- } catch (error) {
881
- waitedMs += Date.now() - probeStartedAt;
882
- if (!isTransientBrokerOpenError(error)) throw error;
883
- lastAttachError = error;
860
+ const result = JSON.parse(response.slice(0, newline));
861
+ if (result.ok === true) done();
862
+ else if (result.error) done(Object.assign(new Error(result.error.message), result.error));
863
+ else done(new Error("Invalid authority broker startup response"));
864
+ } catch {
865
+ done(new Error("Invalid authority broker startup response"));
884
866
  }
885
- }
886
- return false;
887
- }
888
- if (deps.useFastPath) {
889
- try {
890
- await client2.open();
891
- return client2;
892
- } catch (error) {
893
- if (!isTransientBrokerOpenError(error)) throw error;
894
- lastAttachError = error;
895
- }
896
- }
897
- try {
898
- await deps.startBroker({
899
- endpoint: args.endpoint,
900
- metadataPath: args.metadataPath,
901
- healthPath: args.healthPath,
902
- dbPath: args.dbPath,
903
- createStore: () => createLevelAuthorityStore(args.dbPath)
904
867
  });
905
- await client2.open();
906
- return client2;
907
- } catch (error) {
908
- if (!isCliAuthorityLockError(error)) throwCliAuthorityStartupError(error);
909
- if (await attachToExistingBroker(5)) {
910
- return client2;
911
- }
912
- let lastError = error;
913
- while (await waitBackoff()) {
868
+ });
869
+ return child;
870
+ } catch (error) {
871
+ child.stdin?.end();
872
+ child.unref();
873
+ throw error;
874
+ } finally {
875
+ output.destroy();
876
+ }
877
+ }
878
+ async function superviseCliAuthorityBrokerProcess(args) {
879
+ const [endpoint, dbPath, metadataPath, healthPath] = args;
880
+ const options = { endpoint: endpoint ?? "", dbPath, metadataPath, healthPath };
881
+ const logger = getLogger("cli.authorityBroker");
882
+ const stop = new AbortController();
883
+ const requestStop = () => stop.abort();
884
+ process.once("SIGTERM", requestStop);
885
+ process.once("SIGINT", requestStop);
886
+ if (testOwnedBroker()) stopOnParentExit(requestStop);
887
+ process.stdout.on("error", () => {
888
+ });
889
+ let ready = false;
890
+ try {
891
+ if (!metadataPath) throw new Error("Missing authority broker metadata path");
892
+ const tls = await loadCliAuthorityBrokerTls(metadataPath);
893
+ while (!stop.signal.aborted) {
894
+ const child = await launchBroker(options, false);
895
+ logger.info("Authority broker worker ready", { endpoint, workerPid: child.pid, supervisorPid: process.pid });
896
+ if (!ready) {
897
+ process.stdout.write('{"ok":true}\n');
898
+ ready = true;
899
+ }
900
+ const workerExit = new AbortController();
901
+ const exited = child.exitCode !== null || child.signalCode !== null ? Promise.resolve(workerExit.abort()) : new Promise((resolve2) => child.once("exit", () => {
902
+ workerExit.abort();
903
+ resolve2();
904
+ }));
905
+ const workerRunning = AbortSignal.any([workerExit.signal, stop.signal]);
906
+ const invoke = createCliAuthorityBrokerSocketInvoker({ endpoint: options.endpoint, timeoutMs: 2e3, tls });
907
+ let failures = 0;
908
+ while (!workerRunning.aborted && failures < 3) {
909
+ await delay(5e3, void 0, { signal: workerRunning }).catch(() => {
910
+ });
911
+ if (workerRunning.aborted) break;
914
912
  try {
915
- await deps.startBroker({
916
- endpoint: args.endpoint,
917
- metadataPath: args.metadataPath,
918
- healthPath: args.healthPath,
919
- dbPath: args.dbPath,
920
- createStore: () => createLevelAuthorityStore(args.dbPath)
921
- });
922
- await client2.open();
923
- return client2;
924
- } catch (retryError) {
925
- lastError = retryError;
926
- if (isCliAuthorityLockError(retryError)) {
927
- if (await attachToExistingBroker(2)) {
928
- return client2;
929
- }
930
- continue;
931
- }
932
- if (isTransientBrokerOpenError(retryError)) {
933
- lastAttachError = retryError;
934
- continue;
935
- }
936
- throwCliAuthorityStartupError(retryError);
913
+ const health = await invoke({ type: "get", key: "cli-authority-broker-health" });
914
+ failures = health.ok && health.result.type === "get" ? 0 : failures + 1;
915
+ } catch (error) {
916
+ failures += 1;
917
+ logger.warn("Authority broker storage probe failed", error, { endpoint, workerPid: child.pid, failures });
937
918
  }
938
919
  }
939
- const lastMessage = toErrorMessage(lastError);
940
- const attachMessage = lastAttachError ? toErrorMessage(lastAttachError) : "";
941
- const portInUse = lastError !== null && typeof lastError === "object" && "code" in lastError && lastError.code === "EADDRINUSE" || /EADDRINUSE/i.test(lastMessage);
942
- const ownerPid = findOwnerPid(lastError);
943
- let detail = "";
944
- if (portInUse) {
945
- detail = `: EADDRINUSE (${lastMessage}). The broker endpoint is already in use; check the process using it or set NOLO_CLI_AUTHORITY_BROKER_PORT to a free port for all local CLI processes`;
946
- } else {
947
- const parts = [
948
- ownerPid !== void 0 ? `ownerPid=${ownerPid}` : void 0,
949
- lastMessage || void 0,
950
- attachMessage && attachMessage !== lastMessage ? `attach=${attachMessage}` : void 0
951
- ].filter(Boolean);
952
- if (parts.length > 0) {
953
- detail = `: ${parts.join("; ")}`;
920
+ invoke.close?.();
921
+ if (child.exitCode === null && child.signalCode === null) {
922
+ if (!stop.signal.aborted) logger.warn("Restarting unresponsive authority broker worker", { endpoint, workerPid: child.pid });
923
+ if (child.stdin) child.stdin.end();
924
+ else child.kill("SIGTERM");
925
+ const killed = await Promise.race([exited.then(() => true), delay(5e3, false, { ref: false })]);
926
+ if (!killed) {
927
+ child.kill("SIGKILL");
928
+ await exited;
954
929
  }
955
930
  }
956
- throw new Error(`CLI authority broker could not attach or take ownership for ${args.endpoint}${detail}`, {
957
- cause: lastError
958
- });
959
- }
960
- }
961
- let client = await connectClient();
962
- let reconnecting = null;
963
- async function reconnect() {
964
- reconnecting ??= connectClient();
965
- try {
966
- client = await reconnecting;
967
- return client;
968
- } finally {
969
- reconnecting = null;
970
- }
971
- }
972
- async function runWithSelfHealing(operation) {
973
- try {
974
- return await operation(client);
975
- } catch (error) {
976
- if (!isCliAuthorityBrokerUnavailableError(error)) throw error;
977
- const recoveredClient = await reconnect();
978
- return operation(recoveredClient);
931
+ if (!stop.signal.aborted) await delay(1e3);
979
932
  }
933
+ } catch (error) {
934
+ process.exitCode = 1;
935
+ const failure = JSON.stringify({ ok: false, error: describeFailure(error) });
936
+ if (!ready) process.stdout.write(`${failure}
937
+ `);
938
+ logger.error("Authority broker supervisor stopped", error, { endpoint, ready });
939
+ } finally {
940
+ process.off("SIGTERM", requestStop);
941
+ process.off("SIGINT", requestStop);
942
+ if (testOwnedBroker()) process.stdin.destroy();
980
943
  }
981
- return {
982
- get location() {
983
- return client.location;
984
- },
985
- get status() {
986
- return client.status;
987
- },
988
- open: () => runWithSelfHealing((activeClient) => activeClient.open()),
989
- close: () => runWithSelfHealing((activeClient) => activeClient.close()),
990
- get: (key) => runWithSelfHealing((activeClient) => activeClient.get(key)),
991
- conditionalPut: (key, expectedRevision, value) => runWithSelfHealing((activeClient) => {
992
- if (!activeClient.conditionalPut) {
993
- throw new Error("CLI authority broker does not support conditionalPut");
994
- }
995
- return activeClient.conditionalPut(key, expectedRevision, value);
996
- }),
997
- put: (key, value) => runWithSelfHealing((activeClient) => activeClient.put(key, value)),
998
- del: (key) => runWithSelfHealing((activeClient) => activeClient.del(key)),
999
- batchWrite: (ops) => runWithSelfHealing((activeClient) => activeClient.batchWrite(ops)),
1000
- createBatch() {
1001
- const ops = [];
1002
- return {
1003
- put(key, value) {
1004
- ops.push({ type: "put", key, value });
1005
- },
1006
- del(key) {
1007
- ops.push({ type: "del", key });
1008
- },
1009
- write: () => runWithSelfHealing((activeClient) => activeClient.batchWrite(ops))
1010
- };
1011
- },
1012
- iterator(options = {}) {
1013
- return async function* iterate() {
1014
- let activeOptions = options;
1015
- let lastYieldedKey;
1016
- let skipResumeKey = false;
1017
- let recovered = false;
1018
- while (true) {
1019
- try {
1020
- for await (const entry of client.iterator(activeOptions)) {
1021
- if (skipResumeKey && entry[0] === lastYieldedKey) {
1022
- skipResumeKey = false;
1023
- continue;
1024
- }
1025
- skipResumeKey = false;
1026
- lastYieldedKey = entry[0];
1027
- yield entry;
1028
- }
1029
- return;
1030
- } catch (error) {
1031
- if (recovered || !isCliAuthorityBrokerUnavailableError(error)) {
1032
- throw error;
1033
- }
1034
- recovered = true;
1035
- await reconnect();
1036
- if (lastYieldedKey === void 0) {
1037
- activeOptions = options;
1038
- continue;
1039
- }
1040
- if (options.reverse) {
1041
- activeOptions = {
1042
- ...options,
1043
- lt: lastYieldedKey
1044
- };
1045
- continue;
1046
- }
1047
- activeOptions = {
1048
- ...options,
1049
- gte: lastYieldedKey
1050
- };
1051
- skipResumeKey = true;
1052
- }
1053
- }
1054
- }();
1055
- }
1056
- };
1057
944
  }
1058
- async function getDefaultCliLocalRuntimeAuthority(options = {}) {
1059
- const ambientNoloHome = process.env.NOLO_HOME?.trim();
1060
- const env = {
1061
- ...ambientNoloHome ? { NOLO_HOME: ambientNoloHome } : {},
1062
- ...options.env ?? process.env
1063
- };
1064
- const dbPath = resolveCliLocalRuntimeDbPath({
1065
- env,
1066
- homeDir: options.homeDir
1067
- });
1068
- ensureDbParentDir(dbPath);
1069
- const endpoint = resolveCliAuthorityBrokerEndpoint({
1070
- transport: "tcp",
1071
- env,
1072
- homeDir: options.homeDir
1073
- });
1074
- const metadataPath = resolveCliAuthorityBrokerMetadataPath({
1075
- transport: "tcp",
1076
- env,
1077
- homeDir: options.homeDir
1078
- });
1079
- const healthPath = resolveCliAuthorityBrokerHealthPath({
1080
- transport: "tcp",
1081
- env,
1082
- homeDir: options.homeDir
1083
- });
1084
- return connectCliAuthorityBroker({
1085
- endpoint,
1086
- metadataPath,
1087
- healthPath,
1088
- dbPath
945
+ async function runCliAuthorityBrokerProcess(args) {
946
+ const [endpoint, dbPath, metadataPath, healthPath, supervisor] = args;
947
+ process.stdout.on("error", () => {
1089
948
  });
1090
- }
1091
- async function getDefaultCliLocalRuntimeDb(options = {}) {
1092
- const authorityStore = await getDefaultCliLocalRuntimeAuthority(options);
1093
- return createLegacyServerDb(authorityStore);
1094
- }
1095
- function createCliLocalMcpConnectionRevisionWriter(authority, authenticatedUserId) {
1096
- if (!authenticatedUserId) throw new Error("Local MCP connection owner is required");
1097
- const prefix = `mcp-private:v1:${encodeURIComponent(authenticatedUserId)}:connection:`;
1098
- const conditionalPut = authority.conditionalPut?.bind(authority);
1099
- if (!conditionalPut) throw new Error("CLI authority broker does not support conditionalPut");
1100
- return {
1101
- async create(value) {
1102
- const id = randomUUID();
1103
- const result = await conditionalPut(prefix + id, null, { ...value, revision: 1 });
1104
- return { id, ...result };
1105
- },
1106
- async update(id, expectedRevision, value) {
1107
- if (!/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(id) || !Number.isSafeInteger(expectedRevision) || expectedRevision < 1 || expectedRevision >= Number.MAX_SAFE_INTEGER) {
1108
- throw new Error("Invalid local MCP connection identity or revision");
1109
- }
1110
- return conditionalPut(prefix + id, expectedRevision, { ...value, revision: expectedRevision + 1 });
1111
- }
1112
- };
949
+ try {
950
+ if (args.length !== 4 && args.length !== 5 || ![dbPath, metadataPath, healthPath].every(isAbsolute)) {
951
+ throw new Error("Expected authority broker endpoint and absolute database, metadata and health paths");
952
+ }
953
+ if (!/^tcp:\/\/127\.0\.0\.1:[0-9]+$/.test(endpoint)) {
954
+ throw new Error("Authority broker must listen on IPv4 loopback");
955
+ }
956
+ const broker = await getOrCreateCliAuthorityBrokerServer({
957
+ endpoint,
958
+ dbPath,
959
+ metadataPath,
960
+ healthPath,
961
+ keepProcessAlive: true,
962
+ tls: await loadCliAuthorityBrokerTls(metadataPath),
963
+ ...supervisor === String(process.ppid) ? { supervisorPid: process.ppid } : {},
964
+ createStore: () => createLevelAuthorityStore(dbPath)
965
+ });
966
+ const close = () => {
967
+ if (testOwnedBroker()) process.stdin.destroy();
968
+ void broker.close().catch((error) => {
969
+ getLogger("cli.authorityBroker").error("Authority broker worker shutdown failed", error);
970
+ process.exit(1);
971
+ });
972
+ };
973
+ process.once("SIGTERM", close);
974
+ process.once("SIGINT", close);
975
+ if (testOwnedBroker()) stopOnParentExit(close);
976
+ process.stdout.write('{"ok":true}\n');
977
+ } catch (error) {
978
+ process.exitCode = 1;
979
+ process.stdout.write(`${JSON.stringify({ ok: false, error: describeFailure(error) })}
980
+ `);
981
+ }
1113
982
  }
1114
983
 
1115
984
  export {
1116
- connectCliAuthorityBroker,
1117
- getDefaultCliLocalRuntimeAuthority,
1118
- getDefaultCliLocalRuntimeDb,
1119
- createCliLocalMcpConnectionRevisionWriter
985
+ startCliAuthorityBrokerProcess,
986
+ superviseCliAuthorityBrokerProcess,
987
+ runCliAuthorityBrokerProcess
1120
988
  };