nolo-cli 0.261.0-alpha.2 → 0.262.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.
- package/{_executeModel-PODMRXJJ.js → _executeModel-KWURYHY6.js} +97 -96
- package/{accountResolver-NGICIMEE.js → accountResolver-JYG5L7YP.js} +2 -2
- package/{action-NJTYNXXR.js → action-UK3HXGXF.js} +9 -9
- package/{addContentAction-RUPXLROG.js → addContentAction-CAKFVBDM.js} +14 -14
- package/{addDialogAgentAction-57EJ2UBC.js → addDialogAgentAction-KLJ2YWWM.js} +16 -16
- package/{agentDeleteCommand-DRFCOTYP.js → agentDeleteCommand-2U5Q7SNW.js} +135 -131
- package/{agentEmailCommands-FHENHUBF.js → agentEmailCommands-4AWNMWBA.js} +137 -136
- package/{agentGrantCommands-BMVKNYIY.js → agentGrantCommands-2VLLXGIU.js} +10 -9
- package/{agentListCommands-W66W5K3V.js → agentListCommands-436FHOIT.js} +68 -68
- package/{agentMachineCommands-C3BUBCXU.js → agentMachineCommands-EISFUXWT.js} +65 -65
- package/{agentProviderCommands-VIWKP7DM.js → agentProviderCommands-2W3VXDLV.js} +4 -3
- package/{agentPullCommand-5SNSXOY7.js → agentPullCommand-XEGOUYQT.js} +9 -8
- package/{agentRecordCommands-DYMHWTID.js → agentRecordCommands-HDLFE4ZJ.js} +127 -126
- package/{agentRun-QVFG3CI4.js → agentRun-EXDLR6OV.js} +137 -136
- package/{agentRunCommand-YV4V5HSL.js → agentRunCommand-5KXVUONI.js} +139 -138
- package/{agentRunControl-RGBHKPKJ.js → agentRunControl-U2MV74WR.js} +17 -16
- package/{agentRuntimeLocal-LVEMOYS2.js → agentRuntimeLocal-P4MMGIR6.js} +55 -55
- package/{agentSlice-OJCM7OUX.js → agentSlice-ATJWWHSU.js} +17 -17
- package/{appConfigCommands-ZUXQLE7L.js → appConfigCommands-W4JQHMOJ.js} +61 -61
- package/{appDeleteCommands-L5UKUMXY.js → appDeleteCommands-IXR47IAV.js} +61 -61
- package/{appDeployCommands-KX2BRQUW.js → appDeployCommands-LB6DHDF4.js} +61 -61
- package/{appDeployStatusCommands-7LHRSWW7.js → appDeployStatusCommands-UQ6MJL6D.js} +61 -61
- package/{appGetCommands-F7SDFCUK.js → appGetCommands-M5JCTDDQ.js} +61 -61
- package/{appListCommands-U4NJKSMZ.js → appListCommands-TE3ZHE3I.js} +61 -61
- package/{appMigrateCommands-JAPOLYSW.js → appMigrateCommands-FOXH6R4B.js} +61 -61
- package/{appSourceCommands-TLXPWXUH.js → appSourceCommands-3ACYB6I7.js} +61 -61
- package/{authCommand-AU3GZBZ2.js → authCommand-I5OBJP5S.js} +20 -19
- package/{authCommands-JKBWMUQ4.js → authCommands-I6KCGOCN.js} +13 -12
- package/{builtinSkillRegistry-6XUWMAV5.js → builtinSkillRegistry-MIXYSZUU.js} +3 -6
- package/{chromeCommands-O4IIKTBD.js → chromeCommands-MVEEIY4R.js} +2 -2
- package/{chromeOpsCommands-F47WYQWF.js → chromeOpsCommands-IZRCYDSW.js} +7 -6
- package/{chunk-LUTSMSIL.js → chunk-23X7C23G.js} +7 -7
- package/{chunk-GF4LYNNZ.js → chunk-24BICQPB.js} +2 -2
- package/{chunk-LTCZOOAM.js → chunk-2AJLG6PY.js} +4 -4
- package/{chunk-HMFKYZKP.js → chunk-2JMYAH5O.js} +16 -16
- package/{chunk-WMBJDXMY.js → chunk-2LFYMWM3.js} +13 -16
- package/{chunk-VOO3YQQP.js → chunk-2O72G3U2.js} +1 -1
- package/{chunk-2I4R6ZRV.js → chunk-2QAZCYOM.js} +38 -10
- package/{chunk-CNYPQYXT.js → chunk-2R6M34JP.js} +75 -75
- package/{chunk-ULPU4C43.js → chunk-36RT7KMI.js} +24 -24
- package/{chunk-ZB2E724W.js → chunk-37DGW762.js} +4 -4
- package/{chunk-3A5NNQCN.js → chunk-3BQDF4QB.js} +46 -12
- package/{chunk-RWXHGPWJ.js → chunk-3UH7SS4W.js} +1 -1
- package/chunk-3VXVE2LF.js +12 -0
- package/{chunk-HAZ6UVH4.js → chunk-47T3QP4V.js} +3 -3
- package/{chunk-YRPIUIEQ.js → chunk-4DBTBNTX.js} +3 -6
- package/chunk-4MEKE5D3.js +229 -0
- package/{chunk-NJCTPWJU.js → chunk-4X6FTGMU.js} +6 -6
- package/{chunk-2FGFY72B.js → chunk-4ZM3UL4E.js} +14 -14
- package/chunk-526GLZJE.js +275 -0
- package/{chunk-TJXO66M2.js → chunk-5MKPNTJP.js} +5 -5
- package/{chunk-L43DGEPZ.js → chunk-5YI447UL.js} +1 -1
- package/{chunk-U5PSCTMR.js → chunk-6NYQHXMV.js} +13 -13
- package/chunk-6R4IY46J.js +14 -0
- package/{chunk-A4O76A6V.js → chunk-6VQIFSWL.js} +11 -11
- package/{chunk-MMXHIHJZ.js → chunk-7K4J76JQ.js} +20 -20
- package/{chunk-NLS7F5DW.js → chunk-7T54GD3I.js} +22 -22
- package/{chunk-SU4NCTW4.js → chunk-B767MA64.js} +1 -1
- package/{chunk-RNLKWUVY.js → chunk-BAZCS5XG.js} +4 -4
- package/{chunk-NTBTVKKB.js → chunk-BWJLEN6X.js} +7 -7
- package/{chunk-UB7NV7NN.js → chunk-C36L6ZID.js} +1 -1
- package/{chunk-TXMFSGRY.js → chunk-D2LTQAGN.js} +1 -1
- package/{chunk-DDKA6V6X.js → chunk-DBJAJ4UD.js} +3 -3
- package/{chunk-2MIZHEND.js → chunk-DFI7MVCQ.js} +4 -4
- package/{chunk-LHJB4BXJ.js → chunk-E2KZNP6C.js} +1 -1
- package/{chunk-IN4B6Z2D.js → chunk-E5JV4DCB.js} +4 -4
- package/{chunk-OIOMBPCA.js → chunk-EHFDVQF5.js} +2 -2
- package/{chunk-XJW6SLBZ.js → chunk-EZKIRVLJ.js} +6 -6
- package/{chunk-ER6NTALN.js → chunk-FGXG6OLW.js} +1 -1
- package/{chunk-ERCSHBUD.js → chunk-G2JNJRTO.js} +95 -95
- package/{chunk-CL33RFD7.js → chunk-GH34JXNV.js} +1 -1
- package/{chunk-WY6DMHMG.js → chunk-GWB6AGME.js} +1 -1
- package/{chunk-KALCFXQO.js → chunk-HCXCKCNT.js} +200 -151
- package/{chunk-SWJRX4M5.js → chunk-HI5RS2O4.js} +328 -9
- package/{chunk-J22PFCQN.js → chunk-HRWRIPTB.js} +7 -7
- package/{chunk-VZDSNDUD.js → chunk-HT6MY27X.js} +35 -35
- package/{chunk-KAHYBAEN.js → chunk-HYCVEESH.js} +12 -72
- package/{chunk-7X4BFUJV.js → chunk-I5BYFTYK.js} +3 -3
- package/{chunk-AQNWWJLH.js → chunk-I6YIA2TY.js} +1 -1
- package/{chunk-ZQAADXSF.js → chunk-IB5AR52X.js} +1 -1
- package/{chunk-TCOHWKDM.js → chunk-IYRZKHA6.js} +1 -1
- package/{chunk-XUDXQT7R.js → chunk-J44TXB4J.js} +20 -18
- package/{chunk-VC3MAT33.js → chunk-J6Y6ZDS3.js} +195 -151
- package/{chunk-FNLT7NKG.js → chunk-K7HLFORE.js} +3 -3
- package/{chunk-UBOTXA3Z.js → chunk-KGBASAB5.js} +6 -6
- package/chunk-KJ4J2XQB.js +129 -0
- package/{chunk-Z7EP5HDL.js → chunk-KYHNSSL2.js} +1 -1
- package/chunk-KZO2MTVM.js +140 -0
- package/{chunk-FP46RAJQ.js → chunk-LCCDDHAO.js} +3 -3
- package/{chunk-72VWN4VK.js → chunk-LHTXSC2E.js} +18 -6
- package/{chunk-MSFKHPA6.js → chunk-LRLLWD4P.js} +1 -1
- package/{chunk-RIOAPUGV.js → chunk-M75RM77T.js} +9 -0
- package/{chunk-SARJZIGR.js → chunk-MI6HRMCK.js} +1 -1
- package/{chunk-A454UXB6.js → chunk-MKR6KDD3.js} +13 -9
- package/{chunk-MPWQI36J.js → chunk-MTNQNLSE.js} +12 -12
- package/{chunk-JPYOHIHX.js → chunk-NFE75Q5M.js} +18 -18
- package/{chunk-M7VNNPVX.js → chunk-NGGXRK2P.js} +117 -121
- package/{chunk-D3ONA3FP.js → chunk-NH4PUEWK.js} +2 -2
- package/{chunk-OSZNERNW.js → chunk-NICEA4IW.js} +11 -11
- package/{chunk-SRVLHMES.js → chunk-NLADA5ZM.js} +32 -32
- package/{chunk-IWWJSSST.js → chunk-NTUNHTJV.js} +4 -4
- package/{chunk-XREMPMNK.js → chunk-OKUSDVRS.js} +3 -3
- package/{chunk-63G7JWEA.js → chunk-OQH3TAB7.js} +6 -6
- package/{chunk-WEEB2JKA.js → chunk-P62DHV4F.js} +4 -4
- package/{chunk-3QMN3T6L.js → chunk-PEXGRTTQ.js} +4 -4
- package/{chunk-4HZCBA4Q.js → chunk-PHIERFHT.js} +4 -4
- package/{chunk-QZYQ3Y3G.js → chunk-PKDFU6MY.js} +1 -1
- package/{chunk-EQOWWSNQ.js → chunk-PRVXRSDG.js} +13 -13
- package/chunk-PSJJBBWV.js +42 -0
- package/{chunk-3B7OTHDW.js → chunk-Q6FKWH66.js} +14 -14
- package/{chunk-6BBXJGIQ.js → chunk-QUF3LDVD.js} +36 -36
- package/{chunk-7LS5ATRP.js → chunk-QXHFIX7W.js} +82 -2
- package/{chunk-W2Z5E2R7.js → chunk-QY4NZCDA.js} +10 -10
- package/{chunk-BUGLH2A7.js → chunk-RIRFHJTW.js} +4 -4
- package/{chunk-UJL23HBL.js → chunk-RQKCLVCB.js} +24 -24
- package/{chunk-G5IAIGGD.js → chunk-RYMLMTPZ.js} +10 -10
- package/{chunk-XKNDVHF5.js → chunk-S6FAHQDH.js} +4 -4
- package/{chunk-GH6SS2DZ.js → chunk-SVFFKLMR.js} +11 -11
- package/{chunk-YVOUSIIA.js → chunk-SVKWZ3EG.js} +1 -1
- package/{chunk-Q5IXZF3S.js → chunk-T7KODHYS.js} +3 -3
- package/{chunk-P4XAHM4B.js → chunk-TA5QI4MM.js} +1 -1
- package/{chunk-VCESLFF4.js → chunk-TEFD5E2D.js} +3 -3
- package/{chunk-GEC4CHS2.js → chunk-TXLXASSY.js} +5 -5
- package/{chunk-UEZL3RBG.js → chunk-UAO54ORL.js} +37 -36
- package/{chunk-EDKMRDET.js → chunk-UMADT6B2.js} +3 -3
- package/{chunk-3TII7WCF.js → chunk-V6K5U4YE.js} +9 -9
- package/{chunk-LHCIIUCX.js → chunk-VI4SWTUO.js} +7 -7
- package/{chunk-P4I55ASV.js → chunk-VLAPKV76.js} +12 -12
- package/{chunk-Z27AH6A5.js → chunk-VXUQWCEZ.js} +4 -4
- package/{chunk-QXWXRBOL.js → chunk-WJ5IXN23.js} +3 -3
- package/{chunk-T3Y2NA4H.js → chunk-WRHVVIGI.js} +4 -4
- package/chunk-WTIJKWCI.js +118 -0
- package/{chunk-CK2LMTYO.js → chunk-Y3KGWZKF.js} +5 -5
- package/{chunk-SJFL32RD.js → chunk-YCITCYSJ.js} +2 -2
- package/{chunk-HB4J5HA6.js → chunk-YR4J7RFS.js} +3 -3
- package/{chunk-CEIWXKHP.js → chunk-ZCLSM5AK.js} +12 -12
- package/{chunk-L45P4JTE.js → chunk-ZHWTBHT3.js} +17 -17
- package/{chunk-FF5ZRKW7.js → chunk-ZJACPM5O.js} +2 -2
- package/{cliAgentConfigHelpers-BJJEXHSZ.js → cliAgentConfigHelpers-WB2S7PDO.js} +16 -15
- package/{cliAuthorityBrokerProcess-VIJEKQSX.js → cliAuthorityBrokerProcess-BMBVXPKU.js} +7 -17
- package/{chunk-O77F26YB.js → cliAuthorityBrokerServer-27C5YBYP.js} +31 -504
- package/{cliEnvHelpers-NDMKN4X2.js → cliEnvHelpers-7V5ZWUJA.js} +4 -3
- package/{cliLocalAgentRecordReader-KCZS2MZU.js → cliLocalAgentRecordReader-QKKRK53P.js} +61 -61
- package/{cloudAutomationCommands-2WQUGQSW.js → cloudAutomationCommands-S52NKCLL.js} +61 -61
- package/{commandRegistry-C64JBZJ3.js → commandRegistry-I2WAEYSQ.js} +131 -131
- package/{contentThunks-G3HEIRXC.js → contentThunks-W4OUEDRF.js} +48 -47
- package/{cooldownCommands-FPAFS7XG.js → cooldownCommands-ZFDAL4MR.js} +1 -1
- package/{createAgentAutomationAction-DSBL3X3A.js → createAgentAutomationAction-VQBQDCAD.js} +50 -49
- package/{createDialogAction-OHFUHC53.js → createDialogAction-YSZU5IE4.js} +49 -48
- package/{createPageAction-E6JZSZLU.js → createPageAction-HLT7DUBR.js} +51 -50
- package/{db-KTQ3LL2Q.js → db-LTHLW7QA.js} +6 -4
- package/{dbSlice-U3GPLEL3.js → dbSlice-WNUHTF4C.js} +13 -13
- package/{deleteDbKey-DRXKWJX5.js → deleteDbKey-ZFWKDNAP.js} +49 -48
- package/{dialogCommands-4EX2OTIC.js → dialogCommands-4MOLJW4G.js} +71 -71
- package/{dialogNotifyCommand-4SCE2Z2R.js → dialogNotifyCommand-YL2GFKLO.js} +19 -18
- package/{dialogPortabilityCommands-ZSFFHRX4.js → dialogPortabilityCommands-YQJNB2KL.js} +4 -3
- package/{dialogSlice-PRZCIJCH.js → dialogSlice-EOZLTLFB.js} +46 -45
- package/{dialogTraceCommand-RKB76OVX.js → dialogTraceCommand-HWXGIGZX.js} +79 -79
- package/{dialogUsageCommand-BP7HMRYP.js → dialogUsageCommand-IO2BQKL2.js} +6 -5
- package/{docCreateCommands-JGPNGIZ7.js → docCreateCommands-OYLRBK2M.js} +60 -60
- package/{docDeleteCommands-XRJTNRDH.js → docDeleteCommands-3NF6QPJU.js} +61 -61
- package/{docReadCommands-6GFO4ARS.js → docReadCommands-CBAERJAP.js} +60 -60
- package/{docStore-QRLIWFTU.js → docStore-G5NLVWCF.js} +15 -15
- package/{docUpdateCommands-W2GXMUXW.js → docUpdateCommands-BAMCGX6F.js} +60 -60
- package/{ebookDownloaderAgentCommand-2DHPGEOQ.js → ebookDownloaderAgentCommand-NOIZ6U7Y.js} +8 -7
- package/{fetchMessages-RGPIYEPZ.js → fetchMessages-P7FSCSXV.js} +2 -2
- package/{getPricing-BK6CUBAE.js → getPricing-KNXVEIUI.js} +6 -6
- package/{handleSendMessageAction-DHGWURJZ.js → handleSendMessageAction-6U3CWHQZ.js} +95 -93
- package/{hostCredentialCreate-FPUZ7RMI.js → hostCredentialCreate-7Z7JIE57.js} +130 -129
- package/i18n-SAK6DDY4.js +51 -0
- package/index.js +163 -184
- package/levelAuthorityStore-L5SVDM5O.js +10 -0
- package/{localAutomationCommands-ZMU22RQJ.js → localAutomationCommands-P56DPCU7.js} +32 -31
- package/{localAutomationRuntime-MU5FGJ3V.js → localAutomationRuntime-KPMMJZAU.js} +30 -29
- package/{localDialogRead-W2EVXISA.js → localDialogRead-GWGWSL5K.js} +2 -2
- package/{localRuntimeAdapter-YBXQBV4G.js → localRuntimeAdapter-724CCDG5.js} +123 -122
- package/{localRuntimeAuthority-LDXMEDO5.js → localRuntimeAuthority-Q5C2KWGF.js} +11 -10
- package/{localRuntimeDb-6TQZDLNU.js → localRuntimeDb-MM3DINZM.js} +1 -1
- package/{machineCommands-57RTUYRV.js → machineCommands-KLZ73HOC.js} +132 -131
- package/{machineInfo-BJIU3WQ5.js → machineInfo-HNPJHQFU.js} +5 -3
- package/{machineWsRunDispatch-VBKV3FFE.js → machineWsRunDispatch-WFSV66WP.js} +124 -123
- package/{mcpLocalAuthorizeCommand-J76SOJVZ.js → mcpLocalAuthorizeCommand-IKOFKY5U.js} +32 -31
- package/{mcpLocalManageCommands-USETIMHB.js → mcpLocalManageCommands-KUDZQRM4.js} +32 -31
- package/{memberThunks-7UERUEMI.js → memberThunks-NSYL7QZA.js} +20 -20
- package/{memoryCommands-N7NHEE55.js → memoryCommands-SVLAVFCV.js} +4 -3
- package/{offlineMarxistsAgentCommand-WZBJBCPZ.js → offlineMarxistsAgentCommand-MFURGWHL.js} +5 -4
- package/package.json +1 -1
- package/{parityCommands-LYDLWSLK.js → parityCommands-5OCBPVES.js} +61 -61
- package/{projectArchive-KCNQDVWJ.js → projectArchive-63LQ5IOO.js} +55 -54
- package/{read-SPSQ6NLR.js → read-D4WYJQJQ.js} +10 -10
- package/{readDocTool-ENUL2GNL.js → readDocTool-3S3OQFOH.js} +2 -2
- package/{readlineWorkspace-MKS7TAEF.js → readlineWorkspace-ECCRLGE5.js} +223 -222
- package/{rememberExplicit-7KX4HXQC.js → rememberExplicit-ZPI6KK5M.js} +3 -2
- package/{remove-TNNDO635.js → remove-AHRMUDMH.js} +10 -10
- package/{removeDialogAgentAction-POPUZ3WU.js → removeDialogAgentAction-AALRBFSA.js} +19 -19
- package/{runAgentClientLoop-KVILXQNI.js → runAgentClientLoop-4644DF32.js} +93 -92
- package/{runtimeDoctorCommands-4J2DP4LZ.js → runtimeDoctorCommands-52MBG5JN.js} +25 -24
- package/{secretCommands-CSTQYB6T.js → secretCommands-2PSS3QNZ.js} +2 -2
- package/{setDialogExtraReferencesAction-35THMVBP.js → setDialogExtraReferencesAction-SLHQ3GYL.js} +15 -15
- package/{setPrimaryDialogAgentAction-WLXBNIG7.js → setPrimaryDialogAgentAction-XKCSGJ7M.js} +19 -19
- package/{settingThunks-6Y5U5M5N.js → settingThunks-PNC7ZISV.js} +22 -22
- package/{spaceCommands-LXNJBO2U.js → spaceCommands-Z2CTQD6G.js} +62 -62
- package/{spacePruneCommand-2ITUFYBM.js → spacePruneCommand-YKIEUIDQ.js} +4 -3
- package/{streamAgentChatTurn-EY6MFKCA.js → streamAgentChatTurn-EGRXP3Q6.js} +123 -122
- package/{switchDialogAgentAction-TG6BQRDA.js → switchDialogAgentAction-YJIWQGIR.js} +16 -16
- package/{tableCommands-35G34R4B.js → tableCommands-FCPDULSU.js} +19 -18
- package/{toolApiClient-MPQIFYXP.js → toolApiClient-FVXTIIEN.js} +9 -9
- package/{tools-CSLTRRUR.js → tools-X25IU3XJ.js} +73 -72
- package/{tuiRestart-ALR4Q3JM.js → tuiRestart-LU2BDLAW.js} +18 -17
- package/{tuiSummaryLlmCaller-3Y3JEXJK.js → tuiSummaryLlmCaller-Z2ZVBIGN.js} +23 -22
- package/{updateCommands-GHQVP6Z5.js → updateCommands-4QP7WJLA.js} +9 -8
- package/{updateDialogTitleAction-LFAWF5EW.js → updateDialogTitleAction-5WP7TUDJ.js} +51 -50
- package/{usageCommand-5VKW6T4C.js → usageCommand-AZX7D3LB.js} +2 -2
- package/{usageRebuildCommand-VUQETFMW.js → usageRebuildCommand-XV5QQCHK.js} +3 -3
- package/versionChangeNotice-RFABJGJE.js +35 -0
- package/{windowsSelfUpdate-SXSVXK4X.js → windowsSelfUpdate-5OFKSW6Y.js} +2 -2
- package/chunk-AMNZPQCY.js +0 -635
- package/chunk-IVK2KT3H.js +0 -209
- package/chunk-KGWE224L.js +0 -246
- package/{chunk-YY7IGJMN.js → chunk-ADMRXWXJ.js} +3 -3
- package/{chunk-CW6LRDSF.js → chunk-LLP2NDED.js} +6 -6
- package/{chunk-GX2MFKF3.js → chunk-SSGTV4FC.js} +3 -3
- package/{chunk-FOC4TORM.js → chunk-TSBJVMNW.js} +5 -5
- package/{chunk-O7ZY6SUK.js → chunk-UYQILGDR.js} +9 -9
- package/{chunk-HXER7YJF.js → chunk-VXL2FZTP.js} +3 -3
- package/{chunk-WSQLCWLQ.js → chunk-YECCIUYU.js} +3 -3
- package/{chunk-U6RD332P.js → chunk-YQJEXXDK.js} +3 -3
- package/{chunk-HVRG27HI.js → chunk-ZV7ZY46L.js} +7 -7
- package/{providerPresetApply-IRJ56XIZ.js → providerPresetApply-YCVSP2WX.js} +3 -3
|
@@ -1,306 +1,37 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "./chunk-
|
|
2
|
+
compareUtf8Keys
|
|
3
|
+
} from "./chunk-3VXVE2LF.js";
|
|
4
4
|
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
createDialogTurnAuthority,
|
|
6
|
+
isDialogTurnAuthorityReservedKey
|
|
7
|
+
} from "./chunk-526GLZJE.js";
|
|
8
|
+
import "./chunk-EUHMI5KG.js";
|
|
9
|
+
import {
|
|
10
|
+
isLevelNotFoundError
|
|
11
|
+
} from "./chunk-OW765XBU.js";
|
|
12
|
+
import {
|
|
13
|
+
toErrorMessage
|
|
14
|
+
} from "./chunk-HNMXYYJR.js";
|
|
15
|
+
import "./chunk-DLXL4NSL.js";
|
|
16
|
+
import "./chunk-OJKUU3LP.js";
|
|
17
|
+
import "./chunk-YZMNK53S.js";
|
|
18
|
+
import "./chunk-I42VC5KR.js";
|
|
19
|
+
import "./chunk-3EUW3WEO.js";
|
|
20
|
+
import "./chunk-WWC7I6TA.js";
|
|
21
|
+
import "./chunk-U6VC4MU4.js";
|
|
11
22
|
import {
|
|
12
23
|
Level,
|
|
13
24
|
MAX_AUTHORITY_BATCH_GET_KEYS,
|
|
14
|
-
compareUtf8Keys,
|
|
15
25
|
createBatchedStoreIterator,
|
|
16
|
-
createLevelAuthorityStore,
|
|
17
26
|
readIteratorWindow
|
|
18
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-WTIJKWCI.js";
|
|
19
28
|
import {
|
|
20
29
|
CLI_AUTHORITY_BROKER_PROTOCOL_VERSION,
|
|
21
30
|
MAX_BROKER_ITERATE_PAGE_LIMIT,
|
|
22
|
-
createCliAuthorityBrokerClient
|
|
23
|
-
createCliAuthorityBrokerSocketInvoker
|
|
31
|
+
createCliAuthorityBrokerClient
|
|
24
32
|
} from "./chunk-LPXBBC32.js";
|
|
25
|
-
import
|
|
26
|
-
|
|
27
|
-
} from "./chunk-HNMXYYJR.js";
|
|
28
|
-
import {
|
|
29
|
-
isLevelNotFoundError
|
|
30
|
-
} from "./chunk-OW765XBU.js";
|
|
31
|
-
import {
|
|
32
|
-
createKey
|
|
33
|
-
} from "./chunk-DLXL4NSL.js";
|
|
34
|
-
import {
|
|
35
|
-
dialogMessageKey
|
|
36
|
-
} from "./chunk-OJKUU3LP.js";
|
|
37
|
-
import {
|
|
38
|
-
getLogger
|
|
39
|
-
} from "./chunk-EYLGAEB4.js";
|
|
40
|
-
import {
|
|
41
|
-
getHostRuntimeExecutable,
|
|
42
|
-
isCompiledBinary,
|
|
43
|
-
resolveCliEntrypointPath
|
|
44
|
-
} from "./chunk-LTCZOOAM.js";
|
|
45
|
-
|
|
46
|
-
// packages/cli/cliAuthorityBrokerProcess.ts
|
|
47
|
-
import { spawn } from "node:child_process";
|
|
48
|
-
import { dirname, isAbsolute, resolve } from "node:path";
|
|
49
|
-
import { setTimeout as delay } from "node:timers/promises";
|
|
50
|
-
|
|
51
|
-
// packages/database-engine/dialogTurnAuthority.ts
|
|
52
|
-
import { createHash, randomUUID } from "node:crypto";
|
|
53
|
-
var DIALOG_TURN_STATE_PREFIX = "dialog-turn-state:";
|
|
54
|
-
var DIALOG_TURN_IDEM_PREFIX = "dialog-turn-idem:";
|
|
55
|
-
var isDialogTurnAuthorityReservedKey = (key) => typeof key === "string" && (key.startsWith(DIALOG_TURN_STATE_PREFIX) || key.startsWith(DIALOG_TURN_IDEM_PREFIX));
|
|
56
|
-
var dialogTurnNamespaceKey = (dialogId) => `${DIALOG_TURN_STATE_PREFIX}:owner:${dialogId}`;
|
|
57
|
-
var dialogTurnStateKey = ({ userId, dialogId }) => `${DIALOG_TURN_STATE_PREFIX}${userId}:${dialogId}`;
|
|
58
|
-
var keysFor = ({ userId, dialogId }) => ({
|
|
59
|
-
dialogKey: createKey("dialog" /* DIALOG */, userId, dialogId),
|
|
60
|
-
stateKey: dialogTurnStateKey({ userId, dialogId }),
|
|
61
|
-
namespaceKey: dialogTurnNamespaceKey(dialogId),
|
|
62
|
-
idemKey: (commandId) => `${DIALOG_TURN_IDEM_PREFIX}${userId}:${dialogId}:${commandId}`
|
|
63
|
-
});
|
|
64
|
-
var queues = /* @__PURE__ */ new WeakMap();
|
|
65
|
-
function serialize(store, key, task) {
|
|
66
|
-
let tails = queues.get(store);
|
|
67
|
-
if (!tails) queues.set(store, tails = /* @__PURE__ */ new Map());
|
|
68
|
-
const current = (tails.get(key) ?? Promise.resolve()).then(task);
|
|
69
|
-
const settled = current.then(() => void 0, () => void 0);
|
|
70
|
-
tails.set(key, settled);
|
|
71
|
-
void settled.then(() => {
|
|
72
|
-
if (tails.get(key) === settled) tails.delete(key);
|
|
73
|
-
});
|
|
74
|
-
return current;
|
|
75
|
-
}
|
|
76
|
-
async function getOptional(store, key) {
|
|
77
|
-
try {
|
|
78
|
-
return await store.get(key);
|
|
79
|
-
} catch (error) {
|
|
80
|
-
if (isLevelNotFoundError(error)) return void 0;
|
|
81
|
-
throw error;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
function summarize(turn) {
|
|
85
|
-
if (!turn) return null;
|
|
86
|
-
const { runId, holder, holderKind, startedAt, heartbeatAt, expiresAt } = turn;
|
|
87
|
-
return { runId, holder, holderKind, startedAt, heartbeatAt, expiresAt };
|
|
88
|
-
}
|
|
89
|
-
function revisionOf(row) {
|
|
90
|
-
return isDialogTurnRecord(row) && typeof row.dialogRevision === "number" ? row.dialogRevision : 0;
|
|
91
|
-
}
|
|
92
|
-
function fingerprint(value) {
|
|
93
|
-
const hash = createHash("sha256");
|
|
94
|
-
let bytes = 0;
|
|
95
|
-
const tooLarge = Symbol();
|
|
96
|
-
const invalid = Symbol();
|
|
97
|
-
const add = (part) => {
|
|
98
|
-
bytes += Buffer.byteLength(part);
|
|
99
|
-
if (bytes > DIALOG_TURN_MAX_PAYLOAD_BYTES) throw tooLarge;
|
|
100
|
-
hash.update(part);
|
|
101
|
-
};
|
|
102
|
-
const visit = (item, depth) => {
|
|
103
|
-
if (depth > 64) throw invalid;
|
|
104
|
-
if (item === null || typeof item === "boolean" || typeof item === "string" || typeof item === "number" && Number.isFinite(item)) {
|
|
105
|
-
if (typeof item === "string" && item.length > DIALOG_TURN_MAX_PAYLOAD_BYTES) throw tooLarge;
|
|
106
|
-
add(JSON.stringify(item));
|
|
107
|
-
} else if (Array.isArray(item)) {
|
|
108
|
-
add("[");
|
|
109
|
-
for (let i = 0; i < item.length; i++) {
|
|
110
|
-
if (i) add(",");
|
|
111
|
-
visit(item[i], depth + 1);
|
|
112
|
-
}
|
|
113
|
-
add("]");
|
|
114
|
-
} else if (isDialogTurnRecord(item)) {
|
|
115
|
-
add("{");
|
|
116
|
-
for (const [index, key] of Object.keys(item).sort().entries()) {
|
|
117
|
-
if (index) add(",");
|
|
118
|
-
add(JSON.stringify(key));
|
|
119
|
-
add(":");
|
|
120
|
-
visit(item[key], depth + 1);
|
|
121
|
-
}
|
|
122
|
-
add("}");
|
|
123
|
-
} else throw invalid;
|
|
124
|
-
};
|
|
125
|
-
try {
|
|
126
|
-
visit(value, 0);
|
|
127
|
-
return { hash: hash.digest("hex") };
|
|
128
|
-
} catch (error) {
|
|
129
|
-
if (error !== tooLarge && error !== invalid) throw error;
|
|
130
|
-
return { status: error === tooLarge ? "payload_too_large" : "invalid_request", field: "payload" };
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
var titleFields = ["title", "titleSource", "titleUpdatedAt"];
|
|
134
|
-
function createDialogTurnAuthority(store, options = {}) {
|
|
135
|
-
const now = options.now ?? Date.now;
|
|
136
|
-
const guarded = (task) => store.runPublicationBatch && typeof store.batchWrite === "function" ? store.runPublicationBatch((access) => task({
|
|
137
|
-
...access,
|
|
138
|
-
put: (key, value) => access.batchWrite([{ type: "put", key, value }]),
|
|
139
|
-
del: (key) => access.batchWrite([{ type: "del", key }])
|
|
140
|
-
})) : task(store);
|
|
141
|
-
const run = (method, raw, task) => {
|
|
142
|
-
const parsed = validateDialogTurnRequest(method, raw);
|
|
143
|
-
if (!parsed.ok) return Promise.resolve(parsed.error);
|
|
144
|
-
const keys = keysFor(parsed.input.dialogRef);
|
|
145
|
-
return serialize(store, keys.namespaceKey, () => guarded((access) => task(parsed.input, keys, access)));
|
|
146
|
-
};
|
|
147
|
-
const active = async (access, key) => await getOptional(access, key) ?? null;
|
|
148
|
-
const checkNamespace = async (access, { namespaceKey, dialogKey }, ref, row) => {
|
|
149
|
-
const owner = await getOptional(access, namespaceKey);
|
|
150
|
-
if (owner !== void 0 && owner !== dialogKey) return "forbidden";
|
|
151
|
-
if (options.verifyNamespace && (owner === void 0 || row !== void 0) && !await options.verifyNamespace(ref, row)) return "forbidden";
|
|
152
|
-
return owner === void 0 ? "unclaimed" : "claimed";
|
|
153
|
-
};
|
|
154
|
-
return {
|
|
155
|
-
getDialogTurnState: (raw) => run("getDialogTurnState", raw, async (_, { dialogKey, stateKey }, access) => ({
|
|
156
|
-
ok: true,
|
|
157
|
-
dialogKey,
|
|
158
|
-
dialogRevision: revisionOf(await getOptional(access, dialogKey)),
|
|
159
|
-
activeTurn: summarize(await active(access, stateKey))
|
|
160
|
-
})),
|
|
161
|
-
beginDialogTurn: (raw) => run("beginDialogTurn", raw, async (input, { dialogKey, stateKey, namespaceKey }, access) => {
|
|
162
|
-
const current = await active(access, stateKey);
|
|
163
|
-
const row = await getOptional(access, dialogKey);
|
|
164
|
-
const dialogRevision = revisionOf(row);
|
|
165
|
-
const namespace = options.verifyNamespace ? await checkNamespace(access, { namespaceKey, dialogKey }, input.dialogRef, row) : void 0;
|
|
166
|
-
if (namespace === "forbidden") return { status: "forbidden" };
|
|
167
|
-
const replayed = current !== null;
|
|
168
|
-
if (current && (current.runId !== input.runId || current.holder !== input.holder || current.holderKind !== input.holderKind)) {
|
|
169
|
-
return { status: "busy", dialogRevision, activeTurn: summarize(current) };
|
|
170
|
-
}
|
|
171
|
-
const timestamp = now();
|
|
172
|
-
const turn = current ?? {
|
|
173
|
-
runId: input.runId,
|
|
174
|
-
runToken: randomUUID(),
|
|
175
|
-
holder: input.holder,
|
|
176
|
-
holderKind: input.holderKind,
|
|
177
|
-
startedAt: timestamp,
|
|
178
|
-
heartbeatAt: timestamp,
|
|
179
|
-
expiresAt: timestamp + (input.ttlMs ?? DIALOG_TURN_DEFAULT_TTL_MS)
|
|
180
|
-
};
|
|
181
|
-
if (namespace === "unclaimed") {
|
|
182
|
-
if (typeof access.batchWrite !== "function") return { status: "atomic_batch_unsupported" };
|
|
183
|
-
await access.batchWrite([{ type: "put", key: namespaceKey, value: dialogKey }, { type: "put", key: stateKey, value: turn }]);
|
|
184
|
-
} else if (!replayed) await access.put(stateKey, turn);
|
|
185
|
-
return { status: "acquired", replayed, dialogRevision, activeTurn: turn };
|
|
186
|
-
}),
|
|
187
|
-
heartbeatDialogTurn: (raw) => run("heartbeatDialogTurn", raw, async (input, { stateKey }, access) => {
|
|
188
|
-
const current = await active(access, stateKey);
|
|
189
|
-
if (!current || current.runToken !== input.runToken) return { status: "token_mismatch", activeTurn: summarize(current) };
|
|
190
|
-
const heartbeatAt = Math.max(now(), current.heartbeatAt);
|
|
191
|
-
const turn = { ...current, heartbeatAt, expiresAt: heartbeatAt + (input.ttlMs ?? DIALOG_TURN_DEFAULT_TTL_MS) };
|
|
192
|
-
await access.put(stateKey, turn);
|
|
193
|
-
return { status: "renewed", activeTurn: turn };
|
|
194
|
-
}),
|
|
195
|
-
endDialogTurn: (raw) => run("endDialogTurn", raw, async (input, { stateKey }, access) => {
|
|
196
|
-
const current = await active(access, stateKey);
|
|
197
|
-
if (!current) return { status: "already_idle" };
|
|
198
|
-
if (input.runToken !== void 0 ? current.runToken !== input.runToken : current.runId !== input.expectedRunId) {
|
|
199
|
-
return { status: "token_mismatch", activeTurn: summarize(current) };
|
|
200
|
-
}
|
|
201
|
-
await access.del(stateKey);
|
|
202
|
-
return { status: "ended" };
|
|
203
|
-
}),
|
|
204
|
-
commitDialogTurn: (raw) => run("commitDialogTurn", raw, async (input, keys, access) => {
|
|
205
|
-
const { dialogKey, stateKey, namespaceKey, idemKey } = keys;
|
|
206
|
-
if (typeof access.batchWrite !== "function") return { status: "atomic_batch_unsupported" };
|
|
207
|
-
const { mode, dialogRef, runToken, commandId, baseRevision, dialogRecord, messageRecords, keepTurnActive } = input;
|
|
208
|
-
const idleSync = mode === "idle_sync";
|
|
209
|
-
const idleStored = idleSync ? await getOptional(access, dialogKey) : void 0;
|
|
210
|
-
const namespace = idleSync ? await checkNamespace(access, keys, dialogRef, idleStored) : void 0;
|
|
211
|
-
if (namespace === "forbidden") return { status: "forbidden" };
|
|
212
|
-
const { userId, dialogId } = dialogRef;
|
|
213
|
-
if (dialogRecord.id !== void 0 && dialogRecord.id !== dialogId || dialogRecord.userId !== void 0 && dialogRecord.userId !== userId || dialogRecord.type !== void 0 && dialogRecord.type !== "dialog" /* DIALOG */) {
|
|
214
|
-
return { status: "invalid_request", field: "dialogRecord" };
|
|
215
|
-
}
|
|
216
|
-
const prefix = dialogMessageKey(dialogId, "");
|
|
217
|
-
const seen = /* @__PURE__ */ new Set();
|
|
218
|
-
for (const { key, value } of messageRecords) {
|
|
219
|
-
const messageId = key.slice(prefix.length);
|
|
220
|
-
if (!key.startsWith(prefix) || !isDialogTurnMessageId(messageId) || seen.has(key) || value.id !== void 0 && value.id !== messageId) return { status: "invalid_message_key", field: "messageRecords" };
|
|
221
|
-
seen.add(key);
|
|
222
|
-
}
|
|
223
|
-
const digest = fingerprint({
|
|
224
|
-
method: "commit",
|
|
225
|
-
baseRevision,
|
|
226
|
-
dialogRecord,
|
|
227
|
-
messageRecords,
|
|
228
|
-
...idleSync ? { mode } : { runToken, keepTurnActive: keepTurnActive === true }
|
|
229
|
-
});
|
|
230
|
-
if (!("hash" in digest)) return digest;
|
|
231
|
-
const receiptKey = idemKey(commandId);
|
|
232
|
-
const prior = await getOptional(access, receiptKey);
|
|
233
|
-
if (prior !== void 0) return prior.hash === digest.hash ? { status: "committed", replayed: true, dialogRevision: prior.dialogRevision, commandId, committedAt: prior.committedAt } : { status: "idempotency_conflict", commandId };
|
|
234
|
-
const current = await active(access, stateKey);
|
|
235
|
-
const stored = idleSync ? idleStored : await getOptional(access, dialogKey);
|
|
236
|
-
const storedRevision = revisionOf(stored);
|
|
237
|
-
if (idleSync) {
|
|
238
|
-
if (current) return { ok: true, status: "busy", dialogKey, dialogRevision: storedRevision, activeTurn: summarize(current) };
|
|
239
|
-
} else if (!current || current.runToken !== runToken) {
|
|
240
|
-
return { status: "fenced", activeTurn: summarize(current), dialogRevision: storedRevision };
|
|
241
|
-
}
|
|
242
|
-
if (storedRevision !== baseRevision) return { status: "revision_conflict", expectedRevision: baseRevision, actualRevision: storedRevision };
|
|
243
|
-
if (!idleSync && options.verifyNamespace && (await getOptional(access, namespaceKey) !== dialogKey || stored !== void 0 && !await options.verifyNamespace(dialogRef, stored))) return { status: "forbidden" };
|
|
244
|
-
const dialogRevision = baseRevision + 1;
|
|
245
|
-
const committedAt = now();
|
|
246
|
-
await access.batchWrite([
|
|
247
|
-
...messageRecords.map(({ key, value }) => ({ type: "put", key, value })),
|
|
248
|
-
{ type: "put", key: dialogKey, value: {
|
|
249
|
-
...dialogRecord,
|
|
250
|
-
// A history writer may have read the header before a narrow memory patch.
|
|
251
|
-
...isDialogTurnRecord(stored) && Object.hasOwn(stored, "memoryCaptureResult") ? { memoryCaptureResult: stored.memoryCaptureResult } : {},
|
|
252
|
-
...isDialogTurnRecord(stored) && Object.hasOwn(stored, "memoryEvents") ? { memoryEvents: stored.memoryEvents } : {},
|
|
253
|
-
id: dialogId,
|
|
254
|
-
userId,
|
|
255
|
-
type: "dialog" /* DIALOG */,
|
|
256
|
-
dbKey: dialogKey,
|
|
257
|
-
dialogRevision
|
|
258
|
-
} },
|
|
259
|
-
{ type: "put", key: receiptKey, value: { ...digest, dialogRevision, committedAt } },
|
|
260
|
-
...namespace === "unclaimed" ? [{ type: "put", key: namespaceKey, value: dialogKey }] : [],
|
|
261
|
-
...!idleSync && keepTurnActive !== true ? [{ type: "del", key: stateKey }] : []
|
|
262
|
-
]);
|
|
263
|
-
return { status: "committed", replayed: false, dialogRevision, commandId, committedAt };
|
|
264
|
-
}),
|
|
265
|
-
patchDialogMetadata: (raw) => run("patchDialogMetadata", raw, async (input, { dialogKey, idemKey }, access) => {
|
|
266
|
-
const { patch, commandId, expectedTitleUpdatedAt } = input;
|
|
267
|
-
const key = commandId === void 0 ? void 0 : idemKey(commandId);
|
|
268
|
-
if (key && typeof access.batchWrite !== "function") return { status: "atomic_batch_unsupported" };
|
|
269
|
-
const digest = fingerprint({ method: "metadata", patch, ...expectedTitleUpdatedAt !== void 0 ? { expectedTitleUpdatedAt } : {} });
|
|
270
|
-
if (!("hash" in digest)) return digest;
|
|
271
|
-
const prior = key ? await getOptional(access, key) : void 0;
|
|
272
|
-
if (prior !== void 0) return prior.hash === digest.hash ? { status: "patched", replayed: true, dialogRevision: prior.dialogRevision } : { status: "idempotency_conflict", commandId };
|
|
273
|
-
const row = await getOptional(access, dialogKey);
|
|
274
|
-
if (!isDialogTurnRecord(row) || row.deletedAt) return { status: "not_found" };
|
|
275
|
-
if (expectedTitleUpdatedAt !== void 0 && (row.titleUpdatedAt ?? null) !== expectedTitleUpdatedAt) return { status: "title_conflict" };
|
|
276
|
-
if (row.titleSource === "manual" && titleFields.some((field) => Object.hasOwn(patch, field)) && patch.titleSource !== "manual") {
|
|
277
|
-
return { status: "manual_title_protected" };
|
|
278
|
-
}
|
|
279
|
-
const dialogRevision = revisionOf(row);
|
|
280
|
-
const { memoryEvents, ...fields } = patch;
|
|
281
|
-
const value = { ...row, ...fields };
|
|
282
|
-
if (memoryEvents) {
|
|
283
|
-
const events = Array.isArray(row.memoryEvents) ? [...row.memoryEvents] : [];
|
|
284
|
-
const eventKey = (event) => isDialogTurnRecord(event) ? JSON.stringify([event.type, event.sourceKind, event.content]) : void 0;
|
|
285
|
-
const seen = new Set(events.map(eventKey));
|
|
286
|
-
for (const event of memoryEvents) {
|
|
287
|
-
const key2 = eventKey(event);
|
|
288
|
-
if (!seen.has(key2)) {
|
|
289
|
-
events.push(event);
|
|
290
|
-
seen.add(key2);
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
value.memoryEvents = events;
|
|
294
|
-
}
|
|
295
|
-
if (key) await access.batchWrite([
|
|
296
|
-
{ type: "put", key: dialogKey, value },
|
|
297
|
-
{ type: "put", key, value: { ...digest, dialogRevision, committedAt: now() } }
|
|
298
|
-
]);
|
|
299
|
-
else await access.put(dialogKey, value);
|
|
300
|
-
return { status: "patched", dialogRevision, replayed: false };
|
|
301
|
-
})
|
|
302
|
-
};
|
|
303
|
-
}
|
|
33
|
+
import "./chunk-G3SUCT4W.js";
|
|
34
|
+
import "./chunk-U67V476Y.js";
|
|
304
35
|
|
|
305
36
|
// packages/database-engine/cliAuthorityBrokerServer.ts
|
|
306
37
|
import fs3 from "node:fs";
|
|
@@ -813,11 +544,11 @@ async function createBrokerHandle(options) {
|
|
|
813
544
|
try {
|
|
814
545
|
if (socketMode) {
|
|
815
546
|
if (target.kind === "unix") ensureParentDir(target.path);
|
|
816
|
-
await new Promise((
|
|
547
|
+
await new Promise((resolve, reject) => {
|
|
817
548
|
server.once("error", reject);
|
|
818
549
|
const onListening = () => {
|
|
819
550
|
server.off("error", reject);
|
|
820
|
-
|
|
551
|
+
resolve();
|
|
821
552
|
};
|
|
822
553
|
if (target.kind === "unix") server.listen(target.path, onListening);
|
|
823
554
|
else server.listen(target.port, target.host, onListening);
|
|
@@ -877,8 +608,8 @@ async function createBrokerHandle(options) {
|
|
|
877
608
|
await Promise.all(queue.active);
|
|
878
609
|
for (const socket of sockets) socket.destroy();
|
|
879
610
|
if (server.listening) {
|
|
880
|
-
await new Promise((
|
|
881
|
-
server.close((error) => error ? reject(error) :
|
|
611
|
+
await new Promise((resolve, reject) => {
|
|
612
|
+
server.close((error) => error ? reject(error) : resolve());
|
|
882
613
|
});
|
|
883
614
|
}
|
|
884
615
|
await readyStore.close();
|
|
@@ -899,7 +630,7 @@ async function createBrokerHandle(options) {
|
|
|
899
630
|
storeReady = false;
|
|
900
631
|
for (const socket of sockets) socket.destroy();
|
|
901
632
|
if (server.listening) {
|
|
902
|
-
await new Promise((
|
|
633
|
+
await new Promise((resolve) => server.close(() => resolve()));
|
|
903
634
|
}
|
|
904
635
|
if (store) {
|
|
905
636
|
try {
|
|
@@ -1108,212 +839,8 @@ function getOrCreateCliAuthorityBrokerServer(options) {
|
|
|
1108
839
|
brokerRegistry.set(options.endpoint, pending);
|
|
1109
840
|
return pending;
|
|
1110
841
|
}
|
|
1111
|
-
|
|
1112
|
-
// packages/cli/cliAuthorityBrokerProcess.ts
|
|
1113
|
-
var testOwnedBroker = () => process.env.NOLO_TEST_AUTHORITY_BROKER_LIFETIME === "1";
|
|
1114
|
-
function stopOnParentExit(stop) {
|
|
1115
|
-
process.stdin.once("end", stop);
|
|
1116
|
-
process.stdin.once("error", stop);
|
|
1117
|
-
process.stdin.resume();
|
|
1118
|
-
}
|
|
1119
|
-
function describeFailure(error, depth = 0) {
|
|
1120
|
-
if (!(error instanceof Error)) return { message: String(error) };
|
|
1121
|
-
const { message, code, ownerPid, cause } = error;
|
|
1122
|
-
return {
|
|
1123
|
-
message,
|
|
1124
|
-
...typeof code === "string" ? { code } : {},
|
|
1125
|
-
...typeof ownerPid === "number" ? { ownerPid } : {},
|
|
1126
|
-
...cause !== void 0 && depth < 4 ? { cause: describeFailure(cause, depth + 1) } : {}
|
|
1127
|
-
};
|
|
1128
|
-
}
|
|
1129
|
-
async function startCliAuthorityBrokerProcess(options) {
|
|
1130
|
-
const child = await launchBroker(options, true);
|
|
1131
|
-
child.unref();
|
|
1132
|
-
}
|
|
1133
|
-
async function launchBroker(options, detached) {
|
|
1134
|
-
const { endpoint, dbPath, metadataPath, healthPath } = options;
|
|
1135
|
-
if (!dbPath || !metadataPath || !healthPath) throw new Error("Missing authority broker paths");
|
|
1136
|
-
const entrypoint = isCompiledBinary() ? [] : [resolveCliEntrypointPath(import.meta.url)];
|
|
1137
|
-
const { PATH, HOME, USERPROFILE, LOCALAPPDATA, SystemRoot, TMPDIR, TEMP, TMP } = process.env;
|
|
1138
|
-
const testOwned = testOwnedBroker();
|
|
1139
|
-
const child = spawn(getHostRuntimeExecutable(), [
|
|
1140
|
-
...entrypoint,
|
|
1141
|
-
detached ? "__authority-broker-supervise" : "__authority-broker",
|
|
1142
|
-
endpoint,
|
|
1143
|
-
resolve(dbPath),
|
|
1144
|
-
resolve(metadataPath),
|
|
1145
|
-
resolve(healthPath),
|
|
1146
|
-
...detached ? [] : [String(process.pid)]
|
|
1147
|
-
], {
|
|
1148
|
-
detached,
|
|
1149
|
-
windowsHide: true,
|
|
1150
|
-
// Only tests hold a lifetime pipe. Production deliberately outlives its launcher.
|
|
1151
|
-
stdio: [testOwned ? "pipe" : "ignore", "pipe", "ignore"],
|
|
1152
|
-
env: {
|
|
1153
|
-
PATH,
|
|
1154
|
-
HOME,
|
|
1155
|
-
USERPROFILE,
|
|
1156
|
-
LOCALAPPDATA,
|
|
1157
|
-
SystemRoot,
|
|
1158
|
-
TMPDIR,
|
|
1159
|
-
TEMP,
|
|
1160
|
-
TMP,
|
|
1161
|
-
NOLO_HOME: dirname(dirname(resolve(dbPath))),
|
|
1162
|
-
...testOwned ? { NOLO_TEST_AUTHORITY_BROKER_LIFETIME: "1" } : {}
|
|
1163
|
-
}
|
|
1164
|
-
});
|
|
1165
|
-
child.stdin?.on("error", () => {
|
|
1166
|
-
});
|
|
1167
|
-
const output = child.stdout;
|
|
1168
|
-
try {
|
|
1169
|
-
await new Promise((resolve2, reject) => {
|
|
1170
|
-
let response = "";
|
|
1171
|
-
const timer = setTimeout(() => reject(new Error(`Authority broker startup timed out at ${endpoint}`)), 3e4);
|
|
1172
|
-
const done = (error) => {
|
|
1173
|
-
clearTimeout(timer);
|
|
1174
|
-
if (error) reject(error);
|
|
1175
|
-
else resolve2();
|
|
1176
|
-
};
|
|
1177
|
-
child.once("error", done);
|
|
1178
|
-
child.once("exit", (_code, signal) => {
|
|
1179
|
-
if (signal) done(new Error(`Authority broker exited during startup (${signal})`));
|
|
1180
|
-
});
|
|
1181
|
-
output.once("error", done);
|
|
1182
|
-
output.once("end", () => done(new Error("Authority broker exited before reporting readiness")));
|
|
1183
|
-
output.setEncoding("utf8");
|
|
1184
|
-
output.on("data", (chunk) => {
|
|
1185
|
-
response += chunk;
|
|
1186
|
-
if (response.length > 64 * 1024) return done(new Error("Oversized authority broker startup response"));
|
|
1187
|
-
const newline = response.indexOf("\n");
|
|
1188
|
-
if (newline < 0) return;
|
|
1189
|
-
try {
|
|
1190
|
-
const result = JSON.parse(response.slice(0, newline));
|
|
1191
|
-
if (result.ok === true) done();
|
|
1192
|
-
else if (result.error) done(Object.assign(new Error(result.error.message), result.error));
|
|
1193
|
-
else done(new Error("Invalid authority broker startup response"));
|
|
1194
|
-
} catch {
|
|
1195
|
-
done(new Error("Invalid authority broker startup response"));
|
|
1196
|
-
}
|
|
1197
|
-
});
|
|
1198
|
-
});
|
|
1199
|
-
return child;
|
|
1200
|
-
} catch (error) {
|
|
1201
|
-
child.stdin?.end();
|
|
1202
|
-
child.unref();
|
|
1203
|
-
throw error;
|
|
1204
|
-
} finally {
|
|
1205
|
-
output.destroy();
|
|
1206
|
-
}
|
|
1207
|
-
}
|
|
1208
|
-
async function superviseCliAuthorityBrokerProcess(args) {
|
|
1209
|
-
const [endpoint, dbPath, metadataPath, healthPath] = args;
|
|
1210
|
-
const options = { endpoint: endpoint ?? "", dbPath, metadataPath, healthPath };
|
|
1211
|
-
const logger = getLogger("cli.authorityBroker");
|
|
1212
|
-
const stop = new AbortController();
|
|
1213
|
-
const requestStop = () => stop.abort();
|
|
1214
|
-
process.once("SIGTERM", requestStop);
|
|
1215
|
-
process.once("SIGINT", requestStop);
|
|
1216
|
-
if (testOwnedBroker()) stopOnParentExit(requestStop);
|
|
1217
|
-
process.stdout.on("error", () => {
|
|
1218
|
-
});
|
|
1219
|
-
let ready = false;
|
|
1220
|
-
try {
|
|
1221
|
-
if (!metadataPath) throw new Error("Missing authority broker metadata path");
|
|
1222
|
-
const tls = await loadCliAuthorityBrokerTls(metadataPath);
|
|
1223
|
-
while (!stop.signal.aborted) {
|
|
1224
|
-
const child = await launchBroker(options, false);
|
|
1225
|
-
logger.info("Authority broker worker ready", { endpoint, workerPid: child.pid, supervisorPid: process.pid });
|
|
1226
|
-
if (!ready) {
|
|
1227
|
-
process.stdout.write('{"ok":true}\n');
|
|
1228
|
-
ready = true;
|
|
1229
|
-
}
|
|
1230
|
-
const workerExit = new AbortController();
|
|
1231
|
-
const exited = child.exitCode !== null || child.signalCode !== null ? Promise.resolve(workerExit.abort()) : new Promise((resolve2) => child.once("exit", () => {
|
|
1232
|
-
workerExit.abort();
|
|
1233
|
-
resolve2();
|
|
1234
|
-
}));
|
|
1235
|
-
const workerRunning = AbortSignal.any([workerExit.signal, stop.signal]);
|
|
1236
|
-
const invoke = createCliAuthorityBrokerSocketInvoker({ endpoint: options.endpoint, timeoutMs: 2e3, tls });
|
|
1237
|
-
let failures = 0;
|
|
1238
|
-
while (!workerRunning.aborted && failures < 3) {
|
|
1239
|
-
await delay(5e3, void 0, { signal: workerRunning }).catch(() => {
|
|
1240
|
-
});
|
|
1241
|
-
if (workerRunning.aborted) break;
|
|
1242
|
-
try {
|
|
1243
|
-
const health = await invoke({ type: "get", key: "cli-authority-broker-health" });
|
|
1244
|
-
failures = health.ok && health.result.type === "get" ? 0 : failures + 1;
|
|
1245
|
-
} catch (error) {
|
|
1246
|
-
failures += 1;
|
|
1247
|
-
logger.warn("Authority broker storage probe failed", error, { endpoint, workerPid: child.pid, failures });
|
|
1248
|
-
}
|
|
1249
|
-
}
|
|
1250
|
-
invoke.close?.();
|
|
1251
|
-
if (child.exitCode === null && child.signalCode === null) {
|
|
1252
|
-
if (!stop.signal.aborted) logger.warn("Restarting unresponsive authority broker worker", { endpoint, workerPid: child.pid });
|
|
1253
|
-
if (child.stdin) child.stdin.end();
|
|
1254
|
-
else child.kill("SIGTERM");
|
|
1255
|
-
const killed = await Promise.race([exited.then(() => true), delay(5e3, false, { ref: false })]);
|
|
1256
|
-
if (!killed) {
|
|
1257
|
-
child.kill("SIGKILL");
|
|
1258
|
-
await exited;
|
|
1259
|
-
}
|
|
1260
|
-
}
|
|
1261
|
-
if (!stop.signal.aborted) await delay(1e3);
|
|
1262
|
-
}
|
|
1263
|
-
} catch (error) {
|
|
1264
|
-
process.exitCode = 1;
|
|
1265
|
-
const failure = JSON.stringify({ ok: false, error: describeFailure(error) });
|
|
1266
|
-
if (!ready) process.stdout.write(`${failure}
|
|
1267
|
-
`);
|
|
1268
|
-
logger.error("Authority broker supervisor stopped", error, { endpoint, ready });
|
|
1269
|
-
} finally {
|
|
1270
|
-
process.off("SIGTERM", requestStop);
|
|
1271
|
-
process.off("SIGINT", requestStop);
|
|
1272
|
-
if (testOwnedBroker()) process.stdin.destroy();
|
|
1273
|
-
}
|
|
1274
|
-
}
|
|
1275
|
-
async function runCliAuthorityBrokerProcess(args) {
|
|
1276
|
-
const [endpoint, dbPath, metadataPath, healthPath, supervisor] = args;
|
|
1277
|
-
process.stdout.on("error", () => {
|
|
1278
|
-
});
|
|
1279
|
-
try {
|
|
1280
|
-
if (args.length !== 4 && args.length !== 5 || ![dbPath, metadataPath, healthPath].every(isAbsolute)) {
|
|
1281
|
-
throw new Error("Expected authority broker endpoint and absolute database, metadata and health paths");
|
|
1282
|
-
}
|
|
1283
|
-
if (!/^tcp:\/\/127\.0\.0\.1:[0-9]+$/.test(endpoint)) {
|
|
1284
|
-
throw new Error("Authority broker must listen on IPv4 loopback");
|
|
1285
|
-
}
|
|
1286
|
-
const broker = await getOrCreateCliAuthorityBrokerServer({
|
|
1287
|
-
endpoint,
|
|
1288
|
-
dbPath,
|
|
1289
|
-
metadataPath,
|
|
1290
|
-
healthPath,
|
|
1291
|
-
keepProcessAlive: true,
|
|
1292
|
-
tls: await loadCliAuthorityBrokerTls(metadataPath),
|
|
1293
|
-
...supervisor === String(process.ppid) ? { supervisorPid: process.ppid } : {},
|
|
1294
|
-
createStore: () => createLevelAuthorityStore(dbPath)
|
|
1295
|
-
});
|
|
1296
|
-
const close = () => {
|
|
1297
|
-
if (testOwnedBroker()) process.stdin.destroy();
|
|
1298
|
-
void broker.close().catch((error) => {
|
|
1299
|
-
getLogger("cli.authorityBroker").error("Authority broker worker shutdown failed", error);
|
|
1300
|
-
process.exit(1);
|
|
1301
|
-
});
|
|
1302
|
-
};
|
|
1303
|
-
process.once("SIGTERM", close);
|
|
1304
|
-
process.once("SIGINT", close);
|
|
1305
|
-
if (testOwnedBroker()) stopOnParentExit(close);
|
|
1306
|
-
process.stdout.write('{"ok":true}\n');
|
|
1307
|
-
} catch (error) {
|
|
1308
|
-
process.exitCode = 1;
|
|
1309
|
-
process.stdout.write(`${JSON.stringify({ ok: false, error: describeFailure(error) })}
|
|
1310
|
-
`);
|
|
1311
|
-
}
|
|
1312
|
-
}
|
|
1313
|
-
|
|
1314
842
|
export {
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
runCliAuthorityBrokerProcess
|
|
843
|
+
MAX_BROKER_FRAME_CHARS,
|
|
844
|
+
dispatchCliAuthorityBrokerRequest,
|
|
845
|
+
getOrCreateCliAuthorityBrokerServer
|
|
1319
846
|
};
|
|
@@ -9,15 +9,16 @@ import {
|
|
|
9
9
|
resolveServerCandidates,
|
|
10
10
|
resolveServerUrl,
|
|
11
11
|
resolveServerUrlFromEnv
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-2AJLG6PY.js";
|
|
13
13
|
import "./chunk-RF576RYE.js";
|
|
14
|
-
import "./chunk-
|
|
14
|
+
import "./chunk-LHTXSC2E.js";
|
|
15
|
+
import "./chunk-2LFYMWM3.js";
|
|
15
16
|
import "./chunk-JKVOKKMQ.js";
|
|
16
17
|
import "./chunk-IV6VUVLJ.js";
|
|
17
|
-
import "./chunk-G3SUCT4W.js";
|
|
18
18
|
import "./chunk-FI4DPLR7.js";
|
|
19
19
|
import "./chunk-4SN6J65J.js";
|
|
20
20
|
import "./chunk-CF7PE763.js";
|
|
21
|
+
import "./chunk-G3SUCT4W.js";
|
|
21
22
|
import "./chunk-U67V476Y.js";
|
|
22
23
|
export {
|
|
23
24
|
isCompiledBinary,
|