nolo-cli 0.228.0-alpha.1 → 0.228.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -5
- package/{_executeModel-WZKT6XEU.js → _executeModel-GIFVXKDT.js} +89 -82
- package/{accountResolver-QETKNC7T.js → accountResolver-NGICIMEE.js} +1 -1
- package/{action-GDZDXPMB.js → action-WZTKEF5H.js} +9 -6
- package/{addContentAction-7RO4AMRI.js → addContentAction-MLI6GOBV.js} +14 -13
- package/{addDialogAgentAction-EVYBGTXB.js → addDialogAgentAction-ARGQM22H.js} +17 -16
- package/{agentDeleteCommand-PZWRHNXY.js → agentDeleteCommand-UF7XVELS.js} +120 -111
- package/{agentEmailCommands-QTKMEICX.js → agentEmailCommands-SFHRPQYC.js} +120 -107
- package/agentListCommands-IXKBP3W5.js +644 -0
- package/{agentMachineCommands-7QGICJLM.js → agentMachineCommands-7NX6PWQ6.js} +56 -48
- package/{agentProviderCommands-STI3DQ6A.js → agentProviderCommands-C5T7C5KZ.js} +2 -2
- package/{agentPullCommand-KHV4EELF.js → agentPullCommand-4EQZYHU4.js} +1 -1
- package/agentRecordCommands-IUNX6XD6.js +188 -0
- package/{agentRunCommand-OFQLOF5Y.js → agentRunCommand-LCR4XADM.js} +127 -111
- package/{agentRunControl-MBG4U6SL.js → agentRunControl-RN2P6AOD.js} +11 -9
- package/{agentRuntimeLocal-TU4LA353.js → agentRuntimeLocal-LVXPQ7QA.js} +57 -43
- package/{agentSlice-L4SBGWTB.js → agentSlice-ZGMOH6TE.js} +15 -14
- package/{appDeleteCommands-JWP3XPUA.js → appDeleteCommands-BESCJOQM.js} +56 -48
- package/{appDeployCommands-6E4TQCWI.js → appDeployCommands-LPTR6IOX.js} +56 -48
- package/{appDeployStatusCommands-ALU4SADG.js → appDeployStatusCommands-BZ7KZ5RD.js} +56 -48
- package/{appGetCommands-JEY4L6L4.js → appGetCommands-EDWGJV4S.js} +56 -48
- package/{appListCommands-PCAVHU7M.js → appListCommands-OPRWYPM6.js} +56 -48
- package/{authCommand-CGRIIOOV.js → authCommand-3C3RN4OU.js} +25 -19
- package/{authCommands-55OGQGCR.js → authCommands-ZMVEDCQD.js} +12 -6
- package/{builtinSkillRegistry-BAE2LDXF.js → builtinSkillRegistry-VRCMQ77Q.js} +7 -7
- package/{chromeCommands-G5UDKVSV.js → chromeCommands-O4IIKTBD.js} +384 -7
- package/{chromeOpsCommands-WAA45NCS.js → chromeOpsCommands-NZITLHWO.js} +3 -3
- package/{chunk-AUAJTAFM.js → chunk-2BKNICGK.js} +4 -4
- package/{chunk-QYB23WUH.js → chunk-2FK2KZSL.js} +1 -1
- package/chunk-2SXN7LAY.js +15 -0
- package/{chunk-H6L2NFHY.js → chunk-3DJJ4CFG.js} +11 -11
- package/{chunk-TSPMLCWI.js → chunk-4IQN6FWY.js} +5 -5
- package/{chunk-GUXZK7SE.js → chunk-4OXPN3WC.js} +17 -6
- package/chunk-4ZCTKB27.js +31 -0
- package/chunk-53W5BXLN.js +340 -0
- package/{chunk-3P54D2E4.js → chunk-5HUO7SEX.js} +9 -107
- package/chunk-6ASGEP5D.js +21 -0
- package/{chunk-DDC6P6EH.js → chunk-6CXQ3YNJ.js} +68 -40
- package/{chunk-G7IUT2V3.js → chunk-6MTVACLN.js} +365 -64
- package/{chunk-ZOHO6MOF.js → chunk-6RSNVJGO.js} +2 -99
- package/{chunk-XSW4EXQV.js → chunk-6TVYUQRM.js} +55 -18
- package/{chunk-PDCV7P5W.js → chunk-6XIE5ZGI.js} +1 -1
- package/{chunk-7Z6EW7AH.js → chunk-6XVPMGXK.js} +97 -11
- package/{chunk-ALAES342.js → chunk-73PZD7JZ.js} +9 -5
- package/{chunk-2MCB7CD7.js → chunk-7UVVLYKC.js} +9 -9
- package/{chunk-S6FDXXZV.js → chunk-ADOOL3PG.js} +2 -2
- package/{chunk-OWKNSIXL.js → chunk-AEZBAFC6.js} +334 -77
- package/{chunk-PWTNI4N7.js → chunk-ANUP75N2.js} +22 -0
- package/{chunk-RG2DGNL6.js → chunk-ARFCL53U.js} +5 -5
- package/{chunk-SRCCSTIM.js → chunk-AS6L5KSD.js} +4 -4
- package/{chunk-GPOV42YM.js → chunk-BAH3BAUZ.js} +8 -8
- package/{chunk-N5Z2V73W.js → chunk-BFKJ2RS3.js} +1 -1
- package/{chunk-F6Z6ZCUV.js → chunk-BVEDT6DM.js} +3 -3
- package/chunk-C5A54QS7.js +108 -0
- package/{chunk-CD3RU7XL.js → chunk-CD2DK5JA.js} +120 -14
- package/{chunk-BP5ZJ6B4.js → chunk-CD64YXRB.js} +1 -1
- package/{chunk-VP3BINY7.js → chunk-CIGCTSBF.js} +31 -1
- package/{chunk-D6YNCNM6.js → chunk-CIUZXD5D.js} +12 -12
- package/{chunk-EVGU5P4U.js → chunk-CO6E7YK6.js} +1 -1
- package/{chunk-VMJVAJ6W.js → chunk-CTIEJRTP.js} +28 -4
- package/{chunk-7JGMNKKG.js → chunk-CTWCZKNS.js} +29 -8
- package/{chunk-YFLVRVYK.js → chunk-D25ONVOH.js} +1 -1
- package/{chunk-LKA64WH4.js → chunk-DMPZMYH4.js} +37 -1
- package/{chunk-262R3XNN.js → chunk-E5RYFR7E.js} +334 -103
- package/{chunk-OQHIVPG4.js → chunk-E6A5NHDH.js} +4 -1
- package/{chunk-HSSBDZLD.js → chunk-EDT65EUE.js} +6 -6
- package/{chunk-IAAIUH64.js → chunk-EQZQUQ33.js} +7 -7
- package/{chunk-HBRDSQ3M.js → chunk-ESN4WNWU.js} +3 -2
- package/{chunk-2YGBI2XB.js → chunk-FE7G6DSP.js} +11 -1
- package/{chunk-547ENH5T.js → chunk-FFFKAOJN.js} +4 -4
- package/{chunk-5ZUOVCKT.js → chunk-FGHEF6WI.js} +3 -1
- package/{chunk-IXG6YXQM.js → chunk-FTWAOKFU.js} +795 -361
- package/chunk-GAHJLSDO.js +107 -0
- package/{chunk-2X7WFDT6.js → chunk-GX6DITLQ.js} +1 -1
- package/{chunk-GYS5FUYR.js → chunk-HCCQEMTK.js} +28 -28
- package/{chunk-CMMI3DAT.js → chunk-HZDK56EK.js} +33 -26
- package/{chunk-UE2EVEYS.js → chunk-IIOSZAJX.js} +4 -4
- package/chunk-IIRJ4P4I.js +24 -0
- package/{chunk-QCB42576.js → chunk-IJZC2KIJ.js} +1 -1
- package/{chunk-RYOLWYBK.js → chunk-ITBX27W6.js} +97 -21
- package/{chunk-VSYTM22R.js → chunk-J2VIGDJN.js} +6 -6
- package/{chunk-QBZCGP34.js → chunk-JEWMQR6J.js} +1 -1
- package/{chunk-6QHKRARD.js → chunk-JFRJEPFI.js} +29 -5
- package/{chunk-S6K5F3KP.js → chunk-JP2BH4NC.js} +1 -1
- package/{chunk-MDZWUD3R.js → chunk-JU7VN4LF.js} +38 -29
- package/{chunk-RTHFJZ6M.js → chunk-K26XPZRB.js} +2 -2
- package/{chunk-ZYKJBRZ3.js → chunk-K7VIXYTZ.js} +1 -3
- package/chunk-KK3FCYZM.js +647 -0
- package/chunk-KLAMJNKQ.js +33394 -0
- package/{chunk-4JVNURX4.js → chunk-KQHEGELM.js} +68 -16
- package/chunk-KXOPLLFP.js +190 -0
- package/{chunk-GOCSSER3.js → chunk-KZ5OD2MO.js} +4 -4
- package/{chunk-ILHQ2AXT.js → chunk-KZAT2M2V.js} +14 -8
- package/chunk-LHCGKAFO.js +739 -0
- package/{chunk-XJPLSAPJ.js → chunk-LMGFVH65.js} +107 -104
- package/{chunk-QRGDJA4B.js → chunk-LTVEOOZL.js} +19 -6
- package/{chunk-L32W3PRP.js → chunk-MAA42MMV.js} +233 -17
- package/{chunk-ATEKLSLR.js → chunk-MTM4LRVG.js} +14 -9
- package/chunk-MVOZ22RZ.js +26 -0
- package/{chunk-2NPD3FTX.js → chunk-MYYNZG2M.js} +139 -39
- package/{chunk-DBUR22G5.js → chunk-MZVCFV3T.js} +19 -15
- package/{chunk-K67C2JUC.js → chunk-N74XL3NI.js} +9 -9
- package/{chunk-VS276URX.js → chunk-NEG5LYK5.js} +1 -1
- package/{chunk-RBPUNSG5.js → chunk-OAZP4TSA.js} +18 -108
- package/{chunk-SMJEXX2S.js → chunk-ODBYGVO2.js} +232 -10
- package/{chunk-M4SFKP5L.js → chunk-OHUYN3YU.js} +3 -3
- package/{chunk-HYLRQDEE.js → chunk-OLGFIQN2.js} +6 -6
- package/{chunk-M3JEW6N6.js → chunk-OYUMJMC5.js} +15 -0
- package/chunk-P27E22MA.js +203 -0
- package/{chunk-BIWI5M4E.js → chunk-PBPXXMWZ.js} +1 -1
- package/{chunk-OBSEKCVK.js → chunk-PQ63BDV3.js} +210 -51
- package/{chunk-4I2MXV5Q.js → chunk-PVFYPUIM.js} +2 -0
- package/{chunk-OG6MQOQG.js → chunk-QMNVV3YM.js} +10 -37
- package/{chunk-GACR7H6T.js → chunk-R5NRFXGD.js} +5 -5
- package/{chunk-5FUN7EG4.js → chunk-RD3QLZQV.js} +83 -47
- package/{chunk-4WVJLODK.js → chunk-RHBD22LV.js} +9 -4
- package/{chunk-EXJK7TQO.js → chunk-RMWDKLBE.js} +1520 -562
- package/{chunk-TGNIKIHR.js → chunk-RR3MB26M.js} +2 -2
- package/{chunk-OOJNQK6V.js → chunk-S25VJYXV.js} +8 -2
- package/{chunk-STJ6LSQE.js → chunk-SCMYAGQE.js} +1135 -712
- package/{chunk-YKY4OVOX.js → chunk-SPU3L3OR.js} +17 -170
- package/chunk-SR4FE5VD.js +9 -0
- package/{chunk-DUUDXSLX.js → chunk-SX6AWTNK.js} +28 -4
- package/{chunk-ZH3KXFHS.js → chunk-TMRJGSK2.js} +1 -1
- package/{chunk-S2NTVGA2.js → chunk-U35UUM5K.js} +2 -1
- package/{chunk-PPJYZRSQ.js → chunk-U5LOKQ2R.js} +30 -14
- package/{chunk-UAIHKQIA.js → chunk-U6RD332P.js} +18 -2
- package/{chunk-3U44JB3O.js → chunk-UF6J7NXV.js} +1 -1
- package/{chunk-Q3IVPFVO.js → chunk-UHW6SCVK.js} +1 -1
- package/chunk-UOUMPHS5.js +103 -0
- package/{chunk-HHFGE2WF.js → chunk-UPOW5HTG.js} +5 -5
- package/{chunk-DEA37IUY.js → chunk-V4IYI3SB.js} +2 -2
- package/{chunk-UWAIJOF2.js → chunk-VKCPKCSS.js} +66 -92
- package/{chunk-HGDKT2D6.js → chunk-VTHWBTRE.js} +177 -1
- package/{chunk-OBIC6EG7.js → chunk-VUHKG4KS.js} +3 -3
- package/{chunk-EEOOBRA7.js → chunk-W3HSD32M.js} +13 -6
- package/{chunk-P2ZLUIW2.js → chunk-W6T4FNZP.js} +351 -26
- package/chunk-WDWZPASX.js +29 -0
- package/chunk-WFGNWWJI.js +326 -0
- package/{chunk-R6Z5S5GA.js → chunk-WQDTSK5U.js} +51 -14
- package/{chunk-OYU2MA5S.js → chunk-X22AUZKL.js} +152 -167
- package/{chunk-4ZGPHFLE.js → chunk-X3OZ655T.js} +2 -2
- package/{chunk-NHY322ZU.js → chunk-XCA4WHX5.js} +588 -64
- package/{chunk-TI2EPRHE.js → chunk-XJSEST7D.js} +3 -3
- package/{chunk-JUSHVFNF.js → chunk-XNTZD4AE.js} +1230 -1356
- package/chunk-XSRSAU3O.js +133 -0
- package/{chunk-CYWNWA77.js → chunk-Y4NPF2UN.js} +6 -3
- package/{chunk-FJSNBZXR.js → chunk-YDRRGVT5.js} +1 -1
- package/{chunk-R3NEQZ53.js → chunk-YFW4H6DL.js} +405 -338
- package/{chunk-BNMPUQW6.js → chunk-YGDYYFRX.js} +20 -24
- package/{chunk-4N6G2CKP.js → chunk-YHNUDTU4.js} +49 -3
- package/chunk-YJPK35HB.js +175 -0
- package/{chunk-6OVNSQHN.js → chunk-YLAHYLDQ.js} +5 -0
- package/{chunk-AGYPUBFW.js → chunk-Z7KE4K3H.js} +195 -123
- package/{chunk-DGYCDA6W.js → chunk-ZM5AZTQG.js} +20 -13
- package/{chunk-CBUZ6DKA.js → chunk-ZQ6K57FJ.js} +1 -1
- package/{cliAgentConfigHelpers-BTRHMPW2.js → cliAgentConfigHelpers-37ZNEY5Y.js} +9 -9
- package/{cliAuthorityBrokerClient-XHH7MH2P.js → cliAuthorityBrokerClient-SFPC3WVK.js} +1 -1
- package/{cliLocalAgentRecordReader-M3F76NIP.js → cliLocalAgentRecordReader-MCQVRWBR.js} +59 -47
- package/{commandRegistry-ZLWHQVAI.js → commandRegistry-NTH5IAN5.js} +104 -92
- package/{contentThunks-4ZX2TO7C.js → contentThunks-SPXTX5U2.js} +38 -36
- package/{cooldownCommands-YB5H5BBK.js → cooldownCommands-TIFCHCUN.js} +1 -1
- package/{createAgentAutomationAction-L4CYUZJG.js → createAgentAutomationAction-KUQKCOXB.js} +38 -36
- package/{createDialogAction-QTU2R2Q3.js → createDialogAction-HJN5U3XS.js} +39 -37
- package/{createPageAction-F3GJTHW2.js → createPageAction-ZAHRDOAU.js} +43 -41
- package/{db-M7FU2GNK.js → db-CMUTP3W5.js} +2 -2
- package/{dbSlice-XRUZOGSU.js → dbSlice-656PMWR2.js} +13 -12
- package/{deleteFile-6URDHYRB.js → deleteFile-ZCQESEEQ.js} +10 -7
- package/{dialogCommands-NRLCOPJR.js → dialogCommands-KZTZLWPZ.js} +61 -54
- package/dialogMessageRecord-OAV77LT7.js +7 -0
- package/{dialogNotifyCommand-SHGPCU22.js → dialogNotifyCommand-PST75COP.js} +11 -11
- package/{dialogSlice-P2S4LXQD.js → dialogSlice-BXIERQHO.js} +39 -37
- package/{dialogUsageCommand-W2WCSGKF.js → dialogUsageCommand-6RW2FY6K.js} +5 -5
- package/{docCreateCommands-YJRDA3RX.js → docCreateCommands-26HJ5NAY.js} +55 -47
- package/{docDeleteCommands-A5QIHZNF.js → docDeleteCommands-UAOHH5XK.js} +57 -49
- package/{docReadCommands-CF2LTMYH.js → docReadCommands-4ADG7YE6.js} +55 -47
- package/{docStore-6O7NYL6A.js → docStore-FZ75HWP2.js} +15 -14
- package/{docUpdateCommands-QRKV4ZXE.js → docUpdateCommands-OGFJZENF.js} +55 -47
- package/fetchMessages-TQEUZD7H.js +1 -1
- package/{getPricing-LF5C4XSI.js → getPricing-FCHYVRJU.js} +4 -4
- package/{handleSendMessageAction-7IHLR37A.js → handleSendMessageAction-KP6GGBFY.js} +84 -79
- package/{hostCredentialCreate-VNCQUAFT.js → hostCredentialCreate-23TX56G7.js} +119 -105
- package/index.js +8 -8
- package/{lib-OT5OTXRU.js → lib-62SWPXNF.js} +3 -7
- package/{localDialogRead-CCOCVGAP.js → localDialogRead-CIOTQM5T.js} +1 -1
- package/{localRuntimeAdapter-FOWVNMIK.js → localRuntimeAdapter-MTUWOYPN.js} +126 -111
- package/{localRuntimeAuthority-IBJAT62G.js → localRuntimeAuthority-TYHQCTZN.js} +5 -3
- package/{localRuntimeDb-N7KHDXS2.js → localRuntimeDb-BO7IVWAZ.js} +1 -1
- package/{machineCommands-ZGC3J4JB.js → machineCommands-4WJUJQHW.js} +260 -323
- package/{machineWsRunDispatch-KK5U4M3G.js → machineWsRunDispatch-V3U4JM67.js} +115 -102
- package/markdownToSlate-KIYM7B3P.js +8 -0
- package/mcpLocalAuthorizeCommand-TI656UWC.js +106 -0
- package/{memberThunks-7Y3OYSJQ.js → memberThunks-JFYC4Z5L.js} +20 -15
- package/{models-H5NNZRLH.js → models-EP7VG6N2.js} +2 -2
- package/{overlay-BBQZXGYI.js → overlay-JA3SPVUS.js} +5 -3
- package/package.json +1 -1
- package/{projectArchive-7ZDYBXAX.js → projectArchive-NU2Z5HOR.js} +45 -43
- package/{providerPresetApply-WHAMP2D5.js → providerPresetApply-4H7YP5D7.js} +6 -6
- package/{providerRegistry-ZI2KORJ7.js → providerRegistry-F3UPOTIY.js} +6 -6
- package/{read-TYMBGEXO.js → read-BRZHXUJ6.js} +9 -8
- package/{readDocTool-SKQVHBLO.js → readDocTool-N7RVFQEE.js} +1 -1
- package/{readlineWorkspace-YHT4SX2C.js → readlineWorkspace-T56MRMS5.js} +6426 -3669
- package/rememberExplicit-CPAPONSI.js +15 -0
- package/{removeDialogAgentAction-F5QE2O2B.js → removeDialogAgentAction-J7XU7OUX.js} +19 -18
- package/{runAgentClientLoop-H4ED5V3K.js → runAgentClientLoop-O2GRCGRZ.js} +97 -75
- package/{runtimeDoctorCommands-RRKPBGVO.js → runtimeDoctorCommands-RDRJXMXC.js} +8 -8
- package/{secretCommands-KZWBZIYS.js → secretCommands-2FEMRUFM.js} +3 -3
- package/{setDialogExtraReferencesAction-72L27ERM.js → setDialogExtraReferencesAction-Q4V2ZZW2.js} +16 -15
- package/{setPrimaryDialogAgentAction-GJJDUSGJ.js → setPrimaryDialogAgentAction-742H5S6T.js} +19 -18
- package/{settingThunks-ZRGWVGZD.js → settingThunks-T4FXSV6M.js} +185 -66
- package/{skillDiscovery-I37M5KJC.js → skillDiscovery-MDDKPTW3.js} +4 -3
- package/{spaceCommands-MEH3HJBC.js → spaceCommands-W5TAVFDT.js} +59 -51
- package/{streamAgentChatTurn-ZXPOXU33.js → streamAgentChatTurn-OWDJMU5E.js} +238 -178
- package/{switchDialogAgentAction-IIJBPND3.js → switchDialogAgentAction-HLDLHRRA.js} +17 -16
- package/{tableCommands-FTAOCBTX.js → tableCommands-44GC4N6J.js} +8 -5
- package/{toolApiClient-OGQEBQVX.js → toolApiClient-N5PYW2R3.js} +8 -6
- package/{tools-2MRWA2PP.js → tools-O7SGGVA3.js} +67 -62
- package/{tuiRestart-2IL37YIB.js → tuiRestart-EOGC2BYY.js} +10 -10
- package/{tuiSummaryLlmCaller-W2QN4VAC.js → tuiSummaryLlmCaller-TM5BU73J.js} +16 -15
- package/{updateCommands-CPATDG6J.js → updateCommands-FBYA5WVG.js} +3 -3
- package/{updateDialogTitleAction-RZ3KZSGQ.js → updateDialogTitleAction-EXSZGTLL.js} +40 -38
- package/{usageCommand-2BF74MKF.js → usageCommand-L4OFWXEU.js} +2 -2
- package/{usageRebuildCommand-UHB55BQM.js → usageRebuildCommand-7JR33UHS.js} +3 -3
- package/webapi-QVV65DQF.js +2487 -0
- package/{windowsSelfUpdate-ZFD6J5HF.js → windowsSelfUpdate-M4V77OUB.js} +2 -2
- package/workContext-Y3ADAPZU.js +14 -0
- package/workContextAccess-VU5I4LKZ.js +11 -0
- package/workContextWriteNotice-YCSSMHN4.js +7 -0
- package/{workloadLifecycle-HFJIN5IZ.js → workloadLifecycle-ZCSQCHG3.js} +2 -2
- package/agentListCommands-GUGMORTK.js +0 -1005
- package/agentRecordCommands-SLLADS5C.js +0 -175
- package/chunk-2WZXXAQD.js +0 -57
- package/chunk-5ZMIIR23.js +0 -265
- package/chunk-62HXNQVV.js +0 -134
- package/chunk-TUSTONB3.js +0 -81
- package/chunk-ZXF6D3I6.js +0 -359
- package/{chunk-W6RFEDN4.js → chunk-AETZ7AD6.js} +3 -3
- /package/{chunk-FJ23FZXF.js → chunk-VIYVRPMJ.js} +0 -0
|
@@ -3,12 +3,13 @@ import {
|
|
|
3
3
|
createLegacyServerDb,
|
|
4
4
|
createLevelAuthorityStore,
|
|
5
5
|
isLevelLockError
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-K7VIXYTZ.js";
|
|
7
7
|
import {
|
|
8
8
|
createCliAuthorityBrokerClient,
|
|
9
9
|
createCliAuthorityBrokerSocketInvoker,
|
|
10
|
+
isCliAuthorityBrokerTimeoutError,
|
|
10
11
|
isCliAuthorityBrokerUnavailableError
|
|
11
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-KK3FCYZM.js";
|
|
12
13
|
import {
|
|
13
14
|
resolveCliAuthorityBrokerEndpoint,
|
|
14
15
|
resolveCliAuthorityBrokerHealthPath,
|
|
@@ -23,6 +24,7 @@ import {
|
|
|
23
24
|
|
|
24
25
|
// packages/cli/localRuntimeAuthority.ts
|
|
25
26
|
import fs4 from "node:fs";
|
|
27
|
+
import { randomUUID } from "node:crypto";
|
|
26
28
|
import path4 from "node:path";
|
|
27
29
|
|
|
28
30
|
// packages/database-engine/cliAuthorityBrokerServer.ts
|
|
@@ -207,6 +209,7 @@ function acquireLevelDbOwnershipLock(dbPath) {
|
|
|
207
209
|
var brokerRegistry = /* @__PURE__ */ new Map();
|
|
208
210
|
var databaseOwners = /* @__PURE__ */ new Map();
|
|
209
211
|
var DEFAULT_ITERATOR_LIMIT = 200;
|
|
212
|
+
var MAX_BROKER_FRAME_CHARS = 64 * 1024 * 1024;
|
|
210
213
|
function resolveBrokerListenTarget(endpoint) {
|
|
211
214
|
if (endpoint.startsWith("unix://")) {
|
|
212
215
|
return { kind: "unix", path: endpoint.slice("unix://".length) };
|
|
@@ -249,18 +252,47 @@ function removeFileIfPresent(filePath) {
|
|
|
249
252
|
}
|
|
250
253
|
}
|
|
251
254
|
async function buildIteratorPage(store, request) {
|
|
252
|
-
const
|
|
253
|
-
|
|
254
|
-
|
|
255
|
+
const base = request.options ?? {};
|
|
256
|
+
const reverse = base.reverse === true;
|
|
257
|
+
const cursor = typeof request.cursor === "string" && request.cursor.length > 0 ? request.cursor : void 0;
|
|
258
|
+
const iterOptions = { ...base };
|
|
259
|
+
if (cursor) {
|
|
260
|
+
if (reverse) {
|
|
261
|
+
if (iterOptions.lte !== void 0 && iterOptions.lte < cursor) {
|
|
262
|
+
} else {
|
|
263
|
+
delete iterOptions.lte;
|
|
264
|
+
iterOptions.lt = iterOptions.lt !== void 0 && iterOptions.lt < cursor ? iterOptions.lt : cursor;
|
|
265
|
+
}
|
|
266
|
+
} else {
|
|
267
|
+
if (iterOptions.gte !== void 0 && iterOptions.gte > cursor) {
|
|
268
|
+
} else {
|
|
269
|
+
delete iterOptions.gte;
|
|
270
|
+
iterOptions.gt = iterOptions.gt !== void 0 && iterOptions.gt > cursor ? iterOptions.gt : cursor;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
const limit = Math.max(0, Math.floor(request.limit ?? DEFAULT_ITERATOR_LIMIT));
|
|
275
|
+
const entries = [];
|
|
276
|
+
let hasMore = false;
|
|
277
|
+
for await (const entry of store.iterator(iterOptions)) {
|
|
278
|
+
const [key] = entry;
|
|
279
|
+
if (cursor && (reverse ? key >= cursor : key <= cursor)) {
|
|
280
|
+
continue;
|
|
281
|
+
}
|
|
282
|
+
if (base.gt !== void 0 && key <= base.gt) {
|
|
283
|
+
continue;
|
|
284
|
+
}
|
|
285
|
+
if (entries.length >= limit) {
|
|
286
|
+
hasMore = true;
|
|
287
|
+
break;
|
|
288
|
+
}
|
|
289
|
+
entries.push(entry);
|
|
255
290
|
}
|
|
256
|
-
const startIndex = request.cursor ? rows.findIndex(([key]) => key === request.cursor) + 1 : 0;
|
|
257
|
-
const limit = request.limit ?? DEFAULT_ITERATOR_LIMIT;
|
|
258
|
-
const entries = rows.slice(startIndex, startIndex + limit);
|
|
259
291
|
const lastEntry = entries.at(-1) ?? null;
|
|
260
292
|
return {
|
|
261
293
|
entries,
|
|
262
294
|
nextCursor: lastEntry ? lastEntry[0] : null,
|
|
263
|
-
done:
|
|
295
|
+
done: !hasMore
|
|
264
296
|
};
|
|
265
297
|
}
|
|
266
298
|
function createErrorResponse(error) {
|
|
@@ -282,9 +314,53 @@ function createErrorResponse(error) {
|
|
|
282
314
|
}
|
|
283
315
|
};
|
|
284
316
|
}
|
|
285
|
-
|
|
317
|
+
var ownerQueues = /* @__PURE__ */ new WeakMap();
|
|
318
|
+
function ownerQueue(store) {
|
|
319
|
+
let state = ownerQueues.get(store);
|
|
320
|
+
if (!state) {
|
|
321
|
+
state = { tail: Promise.resolve(), active: /* @__PURE__ */ new Set(), closed: false };
|
|
322
|
+
ownerQueues.set(store, state);
|
|
323
|
+
}
|
|
324
|
+
return state;
|
|
325
|
+
}
|
|
326
|
+
function validConditionalPut(request) {
|
|
327
|
+
const expected = request.expectedRevision;
|
|
328
|
+
const value = request.value;
|
|
329
|
+
return Object.keys(request).length === 4 && Object.keys(request).every((key) => ["type", "key", "expectedRevision", "value"].includes(key)) && typeof request.key === "string" && request.key.length > 0 && (expected === null || Number.isSafeInteger(expected) && expected >= 0 && expected < Number.MAX_SAFE_INTEGER) && typeof value === "object" && value !== null && !Array.isArray(value) && Object.hasOwn(value, "revision") && value.revision === (expected === null ? 1 : expected + 1);
|
|
330
|
+
}
|
|
331
|
+
function dispatchCliAuthorityBrokerRequest(store, request) {
|
|
332
|
+
const state = ownerQueue(store);
|
|
333
|
+
if (state.closed) return Promise.resolve({ ok: false, error: { code: "BROKER_CLOSING", message: "Authority broker is closing" } });
|
|
334
|
+
const isRead = request?.type === "get" || request?.type === "batchGet" || request?.type === "status" || request?.type === "iterator" || request?.type === "close";
|
|
335
|
+
const execute = () => executeCliAuthorityBrokerRequest(store, request);
|
|
336
|
+
const result = isRead ? Promise.resolve().then(execute) : state.tail.then(execute);
|
|
337
|
+
if (!isRead) state.tail = result.catch(() => void 0);
|
|
338
|
+
const settled = result.then(() => void 0, () => void 0);
|
|
339
|
+
state.active.add(settled);
|
|
340
|
+
void settled.then(() => state.active.delete(settled));
|
|
341
|
+
return result;
|
|
342
|
+
}
|
|
343
|
+
async function executeCliAuthorityBrokerRequest(store, request) {
|
|
286
344
|
try {
|
|
345
|
+
if (!request || typeof request !== "object") {
|
|
346
|
+
return { ok: false, error: { code: "BROKER_INVALID_REQUEST", message: "Invalid broker request" } };
|
|
347
|
+
}
|
|
287
348
|
switch (request.type) {
|
|
349
|
+
case "conditionalPut": {
|
|
350
|
+
if (!validConditionalPut(request)) {
|
|
351
|
+
return { ok: false, error: { code: "BROKER_INVALID_REQUEST", message: "Invalid conditionalPut request" } };
|
|
352
|
+
}
|
|
353
|
+
let current;
|
|
354
|
+
try {
|
|
355
|
+
current = await store.get(request.key);
|
|
356
|
+
} catch (error) {
|
|
357
|
+
if (error?.code !== "LEVEL_NOT_FOUND") throw error;
|
|
358
|
+
}
|
|
359
|
+
const matches = request.expectedRevision === null ? current === void 0 : typeof current === "object" && current !== null && !Array.isArray(current) && Object.hasOwn(current, "revision") && current.revision === request.expectedRevision;
|
|
360
|
+
if (!matches) return { ok: true, result: { type: "conditionalPut", status: "conflict" } };
|
|
361
|
+
await store.put(request.key, request.value);
|
|
362
|
+
return { ok: true, result: { type: "conditionalPut", status: "updated" } };
|
|
363
|
+
}
|
|
288
364
|
case "status":
|
|
289
365
|
return { ok: true, result: { type: "status" } };
|
|
290
366
|
case "open":
|
|
@@ -294,6 +370,25 @@ async function dispatchCliAuthorityBrokerRequest(store, request) {
|
|
|
294
370
|
return { ok: true, result: { type: "close" } };
|
|
295
371
|
case "get":
|
|
296
372
|
return { ok: true, result: { type: "get", value: await store.get(request.key) } };
|
|
373
|
+
case "batchGet": {
|
|
374
|
+
if (!Array.isArray(request.keys) || !request.keys.every((key) => typeof key === "string")) {
|
|
375
|
+
return { ok: false, error: { code: "BROKER_INVALID_REQUEST", message: "Invalid batchGet request" } };
|
|
376
|
+
}
|
|
377
|
+
const items = await Promise.all(
|
|
378
|
+
request.keys.map(async (key) => {
|
|
379
|
+
try {
|
|
380
|
+
return { ok: true, value: await store.get(key) };
|
|
381
|
+
} catch (error) {
|
|
382
|
+
const errRes = createErrorResponse(error);
|
|
383
|
+
return {
|
|
384
|
+
ok: false,
|
|
385
|
+
error: errRes.ok ? { code: "BROKER_INTERNAL_ERROR", message: "Unknown error" } : errRes.error
|
|
386
|
+
};
|
|
387
|
+
}
|
|
388
|
+
})
|
|
389
|
+
);
|
|
390
|
+
return { ok: true, result: { type: "batchGet", items } };
|
|
391
|
+
}
|
|
297
392
|
case "put":
|
|
298
393
|
await store.put(request.key, request.value);
|
|
299
394
|
return { ok: true, result: { type: "put" } };
|
|
@@ -311,8 +406,13 @@ async function dispatchCliAuthorityBrokerRequest(store, request) {
|
|
|
311
406
|
page: await buildIteratorPage(store, request)
|
|
312
407
|
}
|
|
313
408
|
};
|
|
409
|
+
default:
|
|
410
|
+
return { ok: false, error: { code: "BROKER_UNSUPPORTED_REQUEST", message: "Unsupported broker request" } };
|
|
314
411
|
}
|
|
315
412
|
} catch (error) {
|
|
413
|
+
if (request?.type === "conditionalPut") {
|
|
414
|
+
return { ok: false, error: { code: "BROKER_CONDITIONAL_WRITE_FAILED", message: "Conditional write failed" } };
|
|
415
|
+
}
|
|
316
416
|
return createErrorResponse(error);
|
|
317
417
|
}
|
|
318
418
|
}
|
|
@@ -378,7 +478,7 @@ async function createBrokerHandle(options) {
|
|
|
378
478
|
});
|
|
379
479
|
return;
|
|
380
480
|
}
|
|
381
|
-
bindSocketRequestHandler({ socket, store });
|
|
481
|
+
bindSocketRequestHandler({ socket, store, maxFrameChars: options.maxFrameChars });
|
|
382
482
|
});
|
|
383
483
|
let storeReady = false;
|
|
384
484
|
try {
|
|
@@ -421,13 +521,27 @@ async function createBrokerHandle(options) {
|
|
|
421
521
|
return {
|
|
422
522
|
endpoint: options.endpoint,
|
|
423
523
|
listeningEndpoint,
|
|
424
|
-
authorityStore:
|
|
524
|
+
authorityStore: {
|
|
525
|
+
...createCliAuthorityBrokerClient({
|
|
526
|
+
endpoint: listeningEndpoint,
|
|
527
|
+
invoke: (request) => dispatchCliAuthorityBrokerRequest(readyStore, request)
|
|
528
|
+
}),
|
|
529
|
+
get location() {
|
|
530
|
+
return readyStore.location;
|
|
531
|
+
},
|
|
532
|
+
get status() {
|
|
533
|
+
return readyStore.status;
|
|
534
|
+
}
|
|
535
|
+
},
|
|
425
536
|
request(request) {
|
|
426
537
|
return dispatchCliAuthorityBrokerRequest(readyStore, request);
|
|
427
538
|
},
|
|
428
539
|
async close() {
|
|
429
540
|
closing ??= (async () => {
|
|
430
541
|
storeReady = false;
|
|
542
|
+
const queue = ownerQueue(readyStore);
|
|
543
|
+
queue.closed = true;
|
|
544
|
+
await Promise.all(queue.active);
|
|
431
545
|
for (const socket of sockets) socket.destroy();
|
|
432
546
|
if (server.listening) {
|
|
433
547
|
await new Promise((resolve, reject) => {
|
|
@@ -465,25 +579,159 @@ async function createBrokerHandle(options) {
|
|
|
465
579
|
throw error;
|
|
466
580
|
}
|
|
467
581
|
}
|
|
582
|
+
function isMultiplexedEnvelope(value) {
|
|
583
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
584
|
+
const record = value;
|
|
585
|
+
return (typeof record.id === "number" || typeof record.id === "string") && "request" in record && typeof record.request === "object" && record.request !== null && !("type" in record);
|
|
586
|
+
}
|
|
587
|
+
function firstNonWhitespaceChar(text) {
|
|
588
|
+
for (let i = 0; i < text.length; i += 1) {
|
|
589
|
+
const ch = text[i];
|
|
590
|
+
if (ch === " " || ch === " " || ch === "\r" || ch === "\n") {
|
|
591
|
+
continue;
|
|
592
|
+
}
|
|
593
|
+
return ch;
|
|
594
|
+
}
|
|
595
|
+
return void 0;
|
|
596
|
+
}
|
|
468
597
|
function bindSocketRequestHandler(args) {
|
|
598
|
+
const maxFrameChars = args.maxFrameChars ?? MAX_BROKER_FRAME_CHARS;
|
|
469
599
|
let buffer = "";
|
|
600
|
+
let inFlight = 0;
|
|
601
|
+
let clientEnded = false;
|
|
602
|
+
let sawLegacyBareRequest = false;
|
|
603
|
+
let protocolRejected = false;
|
|
604
|
+
let currentFrameVerifiedObjectStart = false;
|
|
470
605
|
args.socket.setEncoding("utf8");
|
|
471
|
-
args.socket.
|
|
472
|
-
|
|
473
|
-
if (!
|
|
474
|
-
|
|
606
|
+
args.socket.setNoDelay?.(true);
|
|
607
|
+
const maybeFinishHalfOpen = () => {
|
|
608
|
+
if (clientEnded && inFlight === 0 && !args.socket.destroyed) {
|
|
609
|
+
args.socket.end();
|
|
610
|
+
}
|
|
611
|
+
};
|
|
612
|
+
const rejectAndDestroy = () => {
|
|
613
|
+
protocolRejected = true;
|
|
475
614
|
buffer = "";
|
|
615
|
+
currentFrameVerifiedObjectStart = false;
|
|
616
|
+
if (!args.socket.destroyed) {
|
|
617
|
+
args.socket.destroy();
|
|
618
|
+
}
|
|
619
|
+
};
|
|
620
|
+
const handleParsedPayload = async (parsed) => {
|
|
621
|
+
inFlight += 1;
|
|
622
|
+
args.socket.ref?.();
|
|
623
|
+
if (isMultiplexedEnvelope(parsed)) {
|
|
624
|
+
let response2;
|
|
625
|
+
try {
|
|
626
|
+
response2 = await dispatchCliAuthorityBrokerRequest(args.store, parsed.request);
|
|
627
|
+
} catch (error) {
|
|
628
|
+
response2 = createErrorResponse(error);
|
|
629
|
+
}
|
|
630
|
+
inFlight -= 1;
|
|
631
|
+
if (!args.socket.destroyed && args.socket.writable) {
|
|
632
|
+
args.socket.write(`${JSON.stringify({ id: parsed.id, response: response2 })}
|
|
633
|
+
`);
|
|
634
|
+
}
|
|
635
|
+
if (inFlight === 0 && !clientEnded) {
|
|
636
|
+
args.socket.unref?.();
|
|
637
|
+
}
|
|
638
|
+
maybeFinishHalfOpen();
|
|
639
|
+
return;
|
|
640
|
+
}
|
|
476
641
|
let response;
|
|
477
642
|
try {
|
|
478
643
|
response = await dispatchCliAuthorityBrokerRequest(
|
|
479
644
|
args.store,
|
|
480
|
-
|
|
645
|
+
parsed
|
|
481
646
|
);
|
|
482
647
|
} catch (error) {
|
|
483
648
|
response = createErrorResponse(error);
|
|
484
649
|
}
|
|
485
|
-
|
|
650
|
+
inFlight -= 1;
|
|
651
|
+
if (!args.socket.destroyed && args.socket.writable) {
|
|
652
|
+
args.socket.end(`${JSON.stringify(response)}
|
|
486
653
|
`);
|
|
654
|
+
}
|
|
655
|
+
};
|
|
656
|
+
args.socket.on("data", (chunk) => {
|
|
657
|
+
if (protocolRejected || sawLegacyBareRequest) return;
|
|
658
|
+
const textChunk = typeof chunk === "string" ? chunk : chunk.toString("utf8");
|
|
659
|
+
if (!currentFrameVerifiedObjectStart) {
|
|
660
|
+
const firstChar = firstNonWhitespaceChar(textChunk);
|
|
661
|
+
if (firstChar !== void 0) {
|
|
662
|
+
if (firstChar !== "{") {
|
|
663
|
+
rejectAndDestroy();
|
|
664
|
+
return;
|
|
665
|
+
}
|
|
666
|
+
currentFrameVerifiedObjectStart = true;
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
buffer += textChunk;
|
|
670
|
+
let newlineIndex;
|
|
671
|
+
while ((newlineIndex = buffer.indexOf("\n")) !== -1) {
|
|
672
|
+
if (newlineIndex > maxFrameChars) {
|
|
673
|
+
rejectAndDestroy();
|
|
674
|
+
break;
|
|
675
|
+
}
|
|
676
|
+
const rawLine = buffer.slice(0, newlineIndex).trim();
|
|
677
|
+
buffer = buffer.slice(newlineIndex + 1);
|
|
678
|
+
currentFrameVerifiedObjectStart = false;
|
|
679
|
+
if (!rawLine) continue;
|
|
680
|
+
if (rawLine[0] !== "{") {
|
|
681
|
+
rejectAndDestroy();
|
|
682
|
+
break;
|
|
683
|
+
}
|
|
684
|
+
let parsed;
|
|
685
|
+
try {
|
|
686
|
+
parsed = JSON.parse(rawLine);
|
|
687
|
+
} catch (error) {
|
|
688
|
+
protocolRejected = true;
|
|
689
|
+
buffer = "";
|
|
690
|
+
args.socket.pause?.();
|
|
691
|
+
if (!args.socket.destroyed && args.socket.writable) {
|
|
692
|
+
args.socket.end(`${JSON.stringify(createErrorResponse(error))}
|
|
693
|
+
`, () => {
|
|
694
|
+
if (!args.socket.destroyed) args.socket.destroy();
|
|
695
|
+
});
|
|
696
|
+
} else if (!args.socket.destroyed) {
|
|
697
|
+
args.socket.destroy();
|
|
698
|
+
}
|
|
699
|
+
break;
|
|
700
|
+
}
|
|
701
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
702
|
+
rejectAndDestroy();
|
|
703
|
+
break;
|
|
704
|
+
}
|
|
705
|
+
if (!isMultiplexedEnvelope(parsed)) {
|
|
706
|
+
sawLegacyBareRequest = true;
|
|
707
|
+
}
|
|
708
|
+
void handleParsedPayload(parsed);
|
|
709
|
+
if (sawLegacyBareRequest) break;
|
|
710
|
+
}
|
|
711
|
+
if (!protocolRejected && !sawLegacyBareRequest) {
|
|
712
|
+
if (buffer.length > maxFrameChars) {
|
|
713
|
+
rejectAndDestroy();
|
|
714
|
+
return;
|
|
715
|
+
}
|
|
716
|
+
if (!currentFrameVerifiedObjectStart && buffer.length > 0) {
|
|
717
|
+
const remainingFirstChar = firstNonWhitespaceChar(buffer);
|
|
718
|
+
if (remainingFirstChar !== void 0) {
|
|
719
|
+
if (remainingFirstChar !== "{") {
|
|
720
|
+
rejectAndDestroy();
|
|
721
|
+
return;
|
|
722
|
+
}
|
|
723
|
+
currentFrameVerifiedObjectStart = true;
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
});
|
|
728
|
+
args.socket.on("end", () => {
|
|
729
|
+
if (protocolRejected) {
|
|
730
|
+
if (!args.socket.destroyed) args.socket.destroy();
|
|
731
|
+
return;
|
|
732
|
+
}
|
|
733
|
+
clientEnded = true;
|
|
734
|
+
maybeFinishHalfOpen();
|
|
487
735
|
});
|
|
488
736
|
}
|
|
489
737
|
function canonicalDatabasePath(dbPath) {
|
|
@@ -573,6 +821,24 @@ function resolveCliLocalRuntimeDbPath(options = {}) {
|
|
|
573
821
|
"leveldb"
|
|
574
822
|
);
|
|
575
823
|
}
|
|
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;
|
|
834
|
+
}
|
|
835
|
+
current = current.cause;
|
|
836
|
+
}
|
|
837
|
+
return void 0;
|
|
838
|
+
}
|
|
839
|
+
function isTransientBrokerOpenError(error) {
|
|
840
|
+
return isCliAuthorityBrokerUnavailableError(error) || isCliAuthorityBrokerTimeoutError(error);
|
|
841
|
+
}
|
|
576
842
|
var defaultCliAuthorityBrokerConnectDeps = {
|
|
577
843
|
createClient: (options) => createCliAuthorityBrokerClient(options),
|
|
578
844
|
startBroker: (options) => getOrCreateCliAuthorityBrokerServer(options),
|
|
@@ -589,14 +855,32 @@ async function connectCliAuthorityBroker(args) {
|
|
|
589
855
|
endpoint: args.endpoint,
|
|
590
856
|
invoke: createCliAuthorityBrokerSocketInvoker({ endpoint: args.endpoint })
|
|
591
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
|
+
};
|
|
592
873
|
async function attachToExistingBroker(attempts) {
|
|
593
874
|
for (let attempt = 0; attempt < attempts; attempt += 1) {
|
|
594
|
-
await
|
|
875
|
+
if (!await waitBackoff()) return false;
|
|
876
|
+
const probeStartedAt = Date.now();
|
|
595
877
|
try {
|
|
596
878
|
await client2.open();
|
|
597
879
|
return true;
|
|
598
880
|
} catch (error) {
|
|
599
|
-
|
|
881
|
+
waitedMs += Date.now() - probeStartedAt;
|
|
882
|
+
if (!isTransientBrokerOpenError(error)) throw error;
|
|
883
|
+
lastAttachError = error;
|
|
600
884
|
}
|
|
601
885
|
}
|
|
602
886
|
return false;
|
|
@@ -606,7 +890,8 @@ async function connectCliAuthorityBroker(args) {
|
|
|
606
890
|
await client2.open();
|
|
607
891
|
return client2;
|
|
608
892
|
} catch (error) {
|
|
609
|
-
if (!
|
|
893
|
+
if (!isTransientBrokerOpenError(error)) throw error;
|
|
894
|
+
lastAttachError = error;
|
|
610
895
|
}
|
|
611
896
|
}
|
|
612
897
|
try {
|
|
@@ -625,8 +910,7 @@ async function connectCliAuthorityBroker(args) {
|
|
|
625
910
|
return client2;
|
|
626
911
|
}
|
|
627
912
|
let lastError = error;
|
|
628
|
-
|
|
629
|
-
await deps.sleep(100);
|
|
913
|
+
while (await waitBackoff()) {
|
|
630
914
|
try {
|
|
631
915
|
await deps.startBroker({
|
|
632
916
|
endpoint: args.endpoint,
|
|
@@ -645,15 +929,30 @@ async function connectCliAuthorityBroker(args) {
|
|
|
645
929
|
}
|
|
646
930
|
continue;
|
|
647
931
|
}
|
|
648
|
-
if (
|
|
932
|
+
if (isTransientBrokerOpenError(retryError)) {
|
|
933
|
+
lastAttachError = retryError;
|
|
649
934
|
continue;
|
|
650
935
|
}
|
|
651
936
|
throwCliAuthorityStartupError(retryError);
|
|
652
937
|
}
|
|
653
938
|
}
|
|
654
939
|
const lastMessage = toErrorMessage(lastError);
|
|
940
|
+
const attachMessage = lastAttachError ? toErrorMessage(lastAttachError) : "";
|
|
655
941
|
const portInUse = lastError !== null && typeof lastError === "object" && "code" in lastError && lastError.code === "EADDRINUSE" || /EADDRINUSE/i.test(lastMessage);
|
|
656
|
-
const
|
|
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("; ")}`;
|
|
954
|
+
}
|
|
955
|
+
}
|
|
657
956
|
throw new Error(`CLI authority broker could not attach or take ownership for ${args.endpoint}${detail}`, {
|
|
658
957
|
cause: lastError
|
|
659
958
|
});
|
|
@@ -689,6 +988,12 @@ async function connectCliAuthorityBroker(args) {
|
|
|
689
988
|
open: () => runWithSelfHealing((activeClient) => activeClient.open()),
|
|
690
989
|
close: () => runWithSelfHealing((activeClient) => activeClient.close()),
|
|
691
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
|
+
}),
|
|
692
997
|
put: (key, value) => runWithSelfHealing((activeClient) => activeClient.put(key, value)),
|
|
693
998
|
del: (key) => runWithSelfHealing((activeClient) => activeClient.del(key)),
|
|
694
999
|
batchWrite: (ops) => runWithSelfHealing((activeClient) => activeClient.batchWrite(ops)),
|
|
@@ -787,9 +1092,29 @@ async function getDefaultCliLocalRuntimeDb(options = {}) {
|
|
|
787
1092
|
const authorityStore = await getDefaultCliLocalRuntimeAuthority(options);
|
|
788
1093
|
return createLegacyServerDb(authorityStore);
|
|
789
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
|
+
};
|
|
1113
|
+
}
|
|
790
1114
|
|
|
791
1115
|
export {
|
|
792
1116
|
connectCliAuthorityBroker,
|
|
793
1117
|
getDefaultCliLocalRuntimeAuthority,
|
|
794
|
-
getDefaultCliLocalRuntimeDb
|
|
1118
|
+
getDefaultCliLocalRuntimeDb,
|
|
1119
|
+
createCliLocalMcpConnectionRevisionWriter
|
|
795
1120
|
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// packages/ai/memory/vnext/workContextWriteNotice.ts
|
|
2
|
+
var text = (value) => typeof value === "string" && value.trim() ? value.trim() : "\u672A\u77E5";
|
|
3
|
+
var revision = (value) => typeof value === "number" && Number.isFinite(value) ? String(value) : "\u672A\u77E5";
|
|
4
|
+
function formatWorkContextWriteNotice(result, options) {
|
|
5
|
+
const activityId = text(result?.activityId);
|
|
6
|
+
const rev = revision(result?.revision);
|
|
7
|
+
const outcome = result?.outcome;
|
|
8
|
+
const storage = options?.storage;
|
|
9
|
+
const storageArg = storage ? `, storage="${storage}"` : "";
|
|
10
|
+
if (outcome === "created" || outcome === "updated") {
|
|
11
|
+
const verb = outcome === "created" ? "\u65B0\u5EFA" : "\u66F4\u65B0";
|
|
12
|
+
return `\u5DF2\u5199\u5165\u5DE5\u4F5C\u8BB0\u5FC6\uFF08${verb}\uFF09\uFF1AactivityId=${activityId}\uFF0Crevision ${rev}\u3002`;
|
|
13
|
+
}
|
|
14
|
+
if (outcome === "unchanged") {
|
|
15
|
+
return `\u5DE5\u4F5C\u8BB0\u5FC6\u5185\u5BB9\u4E0E\u5DF2\u6709\u7248\u672C\u5B8C\u5168\u4E00\u81F4\uFF0C\u672A\u4EA7\u751F\u65B0\u7248\u672C\uFF1AactivityId=${activityId}\uFF0Crevision \u4ECD\u4E3A ${rev}\u3002`;
|
|
16
|
+
}
|
|
17
|
+
if (outcome === "conflict") {
|
|
18
|
+
return [
|
|
19
|
+
`\u672A\u5199\u5165\u5DE5\u4F5C\u8BB0\u5FC6\uFF1A\u672C\u6B21\u4FEE\u6539\u88AB\u62D2\u7EDD\uFF08outcome=conflict\uFF09\uFF0CactivityId=${activityId}\uFF0C\u5F53\u524D revision=${rev}\u3002`,
|
|
20
|
+
"\u5E38\u89C1\u539F\u56E0\uFF1AexpectedRevision \u5DF2\u8FC7\u671F\uFF08\u522B\u4EBA\u5148\u5199\u4E86\uFF09\uFF1B\u6539\u4E86\u5185\u5BB9\u5374\u590D\u7528\u4E86\u65E7 changeId\uFF1B\u6216\u8BE5 activityId \u5C5E\u4E8E\u522B\u7684\u7A7A\u95F4\u3002",
|
|
21
|
+
`\u4E0B\u4E00\u6B65\uFF1A\u8C03\u7528 queryMemory\uFF08mode="work", activityId="${activityId}"${storageArg}\uFF09\u8BFB\u53D6\u6700\u65B0 revision \u4E0E\u5185\u5BB9\uFF0C\u518D\u7528\u8BE5 revision \u4F5C\u4E3A expectedRevision\u3001\u5E76\u6362\u4E00\u4E2A\u65B0\u7684 changeId \u91CD\u5199${storage ? `\uFF08\u91CD\u5199\u65F6\u540C\u6837\u5E26\u4E0A storage="${storage}"\uFF09` : ""}\uFF1B\u82E5\u8FD9\u6761\u4E0D\u8BE5\u6539\uFF0C\u6539\u7528\u65B0\u7684 itemKey \u53E6\u5EFA\u4E00\u6761\u3002`
|
|
22
|
+
].join("\n");
|
|
23
|
+
}
|
|
24
|
+
return `\u672A\u786E\u8BA4\u5DE5\u4F5C\u8BB0\u5FC6\u662F\u5426\u5199\u5165\uFF1A\u670D\u52A1\u7AEF\u8FD4\u56DE\u4E86\u65E0\u6CD5\u8BC6\u522B\u7684 outcome=${text(outcome)}\uFF0CactivityId=${activityId}\u3002\u4E0B\u4E00\u6B65\uFF1A\u8C03\u7528 queryMemory\uFF08mode="work", activityId="${activityId}"${storageArg}\uFF09\u786E\u8BA4\u5F53\u524D revision \u540E\u518D\u51B3\u5B9A\u662F\u5426\u91CD\u5199\u3002`;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export {
|
|
28
|
+
formatWorkContextWriteNotice
|
|
29
|
+
};
|