nolo-cli 0.213.0 → 0.223.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/README.md +3 -2
- package/{_executeModel-CUJLCFWR.js → _executeModel-4GGQQHOB.js} +111 -82
- package/{accountResolver-4LKIHEKL.js → accountResolver-EK2S4PWF.js} +6 -6
- package/{action-DF5UYSJF.js → action-CK64LS6S.js} +12 -11
- package/{addContentAction-WERAONNY.js → addContentAction-GDHDOF4U.js} +18 -17
- package/{addDialogAgentAction-7VI7YRML.js → addDialogAgentAction-CAKRU3ZT.js} +21 -20
- package/{agentDeleteCommand-XJORXPGU.js → agentDeleteCommand-BPV2XZL7.js} +128 -119
- package/{agentEmailCommands-XTYYFR6Z.js → agentEmailCommands-EJOS75YL.js} +132 -124
- package/{agentFavoriteCommands-EDK743YA.js → agentFavoriteCommands-2LKGKSUD.js} +7 -8
- package/{agentGrantCommands-RQWK2TEV.js → agentGrantCommands-QQV4N4JW.js} +5 -5
- package/{agentListCommands-OBLRBLHS.js → agentListCommands-HIZODBF3.js} +155 -92
- package/{agentMachineCommands-5FMT3OT5.js → agentMachineCommands-ZMQ2CY7Y.js} +62 -54
- package/{agentProviderCommands-Q5O33MED.js → agentProviderCommands-WKJOAWBP.js} +5 -5
- package/{agentPullCommand-6EM3URVK.js → agentPullCommand-XN6ZPBUW.js} +7 -7
- package/agentRecordCommands-OMXVDLDX.js +176 -0
- package/agentRunCommand-CB34YWMV.js +206 -0
- package/{agentRunControl-TAMHJQSR.js → agentRunControl-JNONH3RP.js} +30 -15
- package/{agentRuntimeLocal-SOO2OPJG.js → agentRuntimeLocal-QZPFWMLG.js} +52 -45
- package/{agentSlice-CHR6KOZN.js → agentSlice-RD2CDU7T.js} +20 -19
- package/{appDeleteCommands-GUP6P5YE.js → appDeleteCommands-QCCFDIEQ.js} +61 -53
- package/{appDeployCommands-MH2FX4O5.js → appDeployCommands-V2T7TNMQ.js} +61 -53
- package/{appDeployStatusCommands-SUHN3HPJ.js → appDeployStatusCommands-6PGH7ZCG.js} +61 -53
- package/{appGetCommands-YWDEX6Z4.js → appGetCommands-3L7WWJA6.js} +61 -53
- package/{appListCommands-ZQVMLPAY.js → appListCommands-ENJCK4PO.js} +61 -53
- package/{authCommand-PWX2ZNUP.js → authCommand-6V47SYGK.js} +29 -28
- package/{authCommands-HV3EAU3V.js → authCommands-GAJ3NIXO.js} +14 -13
- package/{builtinSkillRegistry-2QETTQPM.js → builtinSkillRegistry-2ECA42FC.js} +11 -13
- package/{chromeCommands-REEAH4SX.js → chromeCommands-G5UDKVSV.js} +3 -3
- package/{chromeOpsCommands-DIVM2K3T.js → chromeOpsCommands-YKX2QX3A.js} +20 -10
- package/{chunk-CRHOO2ZR.js → chunk-27PCUMJI.js} +2 -2
- package/chunk-2CI3ZFWD.js +97 -0
- package/{chunk-NSAPDIN2.js → chunk-2GJKRKI6.js} +541 -31
- package/{chunk-SM3NSZJV.js → chunk-2UCBGYO4.js} +20 -1
- package/{chunk-PYRUW7XN.js → chunk-2VUZSVAS.js} +136 -54
- package/{chunk-YB3YZK56.js → chunk-2WZXXAQD.js} +1 -67
- package/chunk-2YGBI2XB.js +30 -0
- package/chunk-2ZKFCIJJ.js +13 -0
- package/{chunk-QG4AOSON.js → chunk-34J5K2YA.js} +13 -32
- package/{chunk-LOEO7LRC.js → chunk-3IK6ILVW.js} +4 -1
- package/{chunk-CTPXME7U.js → chunk-3LMUPOHG.js} +29 -6
- package/chunk-44X52WOJ.js +1621 -0
- package/{chunk-6VLJ6YA7.js → chunk-4DESLZTK.js} +9 -9
- package/{chunk-MYOH447Z.js → chunk-4JVNURX4.js} +1 -1
- package/chunk-5CHGAKRT.js +364 -0
- package/{chunk-YDH3FDFQ.js → chunk-5FUN7EG4.js} +1 -1
- package/{chunk-INUFILG6.js → chunk-5RKUPJYL.js} +1 -1
- package/{chunk-ZC3CMUKU.js → chunk-6OVNSQHN.js} +84 -2
- package/{chunk-MOIJOHA5.js → chunk-6WU5572L.js} +36 -25
- package/{chunk-IXNGOHV5.js → chunk-7EEZJ6BS.js} +11 -152
- package/{chunk-Y6ORVLSS.js → chunk-7ET2U67U.js} +1 -1
- package/{chunk-G7MLNNEX.js → chunk-7JLY4WYF.js} +5 -5
- package/{chunk-P5L7CXOC.js → chunk-7Z6EW7AH.js} +3 -2
- package/{chunk-NJLL224W.js → chunk-AD5EWDFD.js} +2 -2
- package/{chunk-J2NHJ7WX.js → chunk-AIHYNKGV.js} +4 -4
- package/{chunk-HPFCI4SK.js → chunk-AK5O76CC.js} +3 -3
- package/{chunk-Y63ZSOR6.js → chunk-AL3TYDIF.js} +1 -1
- package/{chunk-ALQ3657A.js → chunk-AMEOV5VZ.js} +32 -12
- package/chunk-AN74ON4G.js +675 -0
- package/{chunk-HRMJUN5J.js → chunk-AQZ6BMRK.js} +1 -1
- package/{chunk-XHQC4PXX.js → chunk-B4GOW4MT.js} +424 -194
- package/{chunk-4KB6WQUL.js → chunk-BGP2EDFG.js} +1 -1
- package/{chunk-NBTY7YJF.js → chunk-BR3GT6MR.js} +1 -0
- package/{chunk-7RFNTILS.js → chunk-BUDVRYES.js} +2 -2
- package/{chunk-SVYO6AO7.js → chunk-BV3FLP2L.js} +41 -1
- package/{chunk-RZOV7OMV.js → chunk-C4VAR65S.js} +83 -141
- package/{chunk-COFEN36Z.js → chunk-C4WTX5TU.js} +2 -2
- package/{chunk-ZL5RAEEB.js → chunk-CIRB724Q.js} +1 -1
- package/{chunk-F6UUQOG6.js → chunk-CKT6QUE2.js} +4 -4
- package/{chunk-X7SDOJUM.js → chunk-CMZ3Z5PT.js} +14 -14
- package/{secretCommands-LXDWOLZ6.js → chunk-D726I5AZ.js} +191 -16
- package/{chunk-TAKB25RM.js → chunk-DNKTQ3IN.js} +4 -4
- package/chunk-DVQH4BTR.js +1137 -0
- package/{chunk-WYDI6TGM.js → chunk-DWX2HEVC.js} +91 -132
- package/{chunk-5MQRBSMW.js → chunk-EIAI3PPH.js} +111 -113
- package/chunk-EUCFKKDM.js +247 -0
- package/chunk-EWQ3HGNZ.js +90 -0
- package/{chunk-RPQXPZZF.js → chunk-F3GRJO4Z.js} +908 -13
- package/{chunk-YTF4WH7J.js → chunk-FIYSMXHY.js} +1 -1
- package/{chunk-75XIDFBW.js → chunk-FJ23FZXF.js} +72 -28
- package/{chunk-INN4LTAJ.js → chunk-FJK526XH.js} +2 -2
- package/chunk-FS2XP5D7.js +142 -0
- package/{chunk-FUGMREBO.js → chunk-FYF2TONJ.js} +5 -5
- package/{chunk-PCLE46CE.js → chunk-GBWGPTA7.js} +2 -1
- package/{chunk-TX5EYMGT.js → chunk-GYVCJABP.js} +30 -254
- package/{chunk-3UKL3HPD.js → chunk-HOCHUZQ7.js} +8 -78
- package/{chunk-EHSZD5OI.js → chunk-HXER7YJF.js} +4 -4
- package/chunk-HYIETXA6.js +99 -0
- package/{chunk-H2TJUNCH.js → chunk-I4EADJ4P.js} +6 -6
- package/{chunk-TCZHTTUU.js → chunk-I7WBYGBP.js} +8 -8
- package/{chunk-6DWMYIUY.js → chunk-IILMY4W4.js} +14 -9
- package/chunk-JA3ICVJY.js +271 -0
- package/{chunk-ZRSNONOB.js → chunk-JWXITTQB.js} +8 -3
- package/{chunk-H4UOTUOX.js → chunk-KEN3N2TN.js} +148 -18
- package/{chunk-LEC5ALIN.js → chunk-KEPOVMF4.js} +1 -1
- package/{chunk-UHJGXRJ4.js → chunk-KQSYAIZR.js} +3 -3
- package/{chunk-4VJAC32I.js → chunk-L5I543VB.js} +3 -2
- package/chunk-LKA64WH4.js +227 -0
- package/{chunk-QHPRUL4O.js → chunk-LVL6GFCM.js} +4 -4
- package/{chunk-H5HF7TJA.js → chunk-MAIITKBT.js} +2 -2
- package/chunk-MBG66ZBH.js +226 -0
- package/{chunk-YUA6OAH5.js → chunk-MDLS23JK.js} +2 -2
- package/{chunk-VL5KOY2C.js → chunk-MK2Q7ZJD.js} +67 -5
- package/{chunk-MDB67IWP.js → chunk-MS4NZNKI.js} +10 -10
- package/{chunk-VO4WSAVP.js → chunk-MYHNBEXD.js} +3 -3
- package/{chunk-ZXOUUDCG.js → chunk-MZLE5HQ3.js} +3654 -231
- package/{chunk-AZMYUSVF.js → chunk-N5Z2V73W.js} +1 -1
- package/{chunk-V5Y3R6BT.js → chunk-NIZ2BXFD.js} +213 -210
- package/{chunk-KFLT5KAD.js → chunk-NWP2OYOX.js} +20 -20
- package/{chunk-G2BQWAVT.js → chunk-O6J3OTOP.js} +4 -4
- package/{chunk-VNYYOX3V.js → chunk-OB6DVWPF.js} +141 -48
- package/{chunk-YWSEPJ7C.js → chunk-OBWT45ZU.js} +3 -3
- package/{chunk-ZNWI6OVT.js → chunk-ODJ7BVSI.js} +80 -11
- package/{chunk-XJWWBO34.js → chunk-OJKUU3LP.js} +5 -7
- package/{chunk-HUBHAQK2.js → chunk-ON37YXGX.js} +29 -29
- package/{chunk-UYD5HQ6T.js → chunk-P5ZJRTCH.js} +5429 -1752
- package/{chunk-6XIE5ZGI.js → chunk-PDCV7P5W.js} +1 -1
- package/{chunk-WRYQ35LQ.js → chunk-PJCIP64Z.js} +859 -57
- package/{chunk-7QTZCMKL.js → chunk-PJVKMGPZ.js} +1089 -1639
- package/{chunk-A7TFUNZO.js → chunk-PPJYZRSQ.js} +6 -2
- package/chunk-QHEN7NZ7.js +46 -0
- package/{chunk-OQPKUBPB.js → chunk-QNWG52I4.js} +19 -7
- package/{chunk-YGILMZ7N.js → chunk-QVBXJNZ2.js} +1 -1
- package/{chunk-7BT37FK3.js → chunk-RDH5CQ4T.js} +648 -131
- package/{chunk-C6KNNXWU.js → chunk-RGQ4UUWZ.js} +25 -2
- package/{chunk-OWYYDMGJ.js → chunk-S2NTVGA2.js} +4 -2
- package/{chunk-KC4XDTT3.js → chunk-SOF4OWDM.js} +6 -4
- package/{chunk-RLBNLZVC.js → chunk-SQYIK6HO.js} +1 -1
- package/{chunk-YJAFKXMU.js → chunk-SVT62ULE.js} +50 -48
- package/{chunk-KIM6CLW5.js → chunk-SY3C4SQ7.js} +42 -15
- package/{chunk-JY5NGFFH.js → chunk-SYTHYBMI.js} +5 -5
- package/{chunk-WMTBPBMP.js → chunk-T6DXNI6Z.js} +52 -50
- package/chunk-TLE77UJ5.js +230 -0
- package/{chunk-4VNS5WPM.js → chunk-U67V476Y.js} +1 -8
- package/{chunk-F7CI2ZC5.js → chunk-UAIHKQIA.js} +2 -1
- package/{chunk-R5O4QAWG.js → chunk-UB3D4TRQ.js} +11 -77
- package/{chunk-WPORQFYN.js → chunk-UVLYNWIE.js} +2 -2
- package/{chunk-NOKUNJON.js → chunk-UYOICCYG.js} +29 -19
- package/{chunk-4I7ERB7F.js → chunk-VREDDN25.js} +1 -1
- package/{chunk-O2TZF4AI.js → chunk-WAE3GFCJ.js} +3 -3
- package/{chunk-H7PPIYWP.js → chunk-WI67URFP.js} +20 -20
- package/{chunk-7OCO4TDT.js → chunk-WJVYAO6P.js} +1 -1
- package/{chunk-T43B7LB2.js → chunk-WKGQSYTB.js} +1 -1
- package/{chunk-BBJ22CLB.js → chunk-WUUH4LWZ.js} +60 -30
- package/{chunk-4T2WNOY7.js → chunk-X7UF53VA.js} +33 -22
- package/{chunk-TY3TIUJK.js → chunk-XI2BWJM5.js} +65 -0
- package/{chunk-LLRPJECG.js → chunk-XWVCYUUU.js} +16 -159
- package/{chunk-J5JTMQIA.js → chunk-YFLVRVYK.js} +1 -1
- package/{chunk-EYLGAEB4.js → chunk-YGMBIXCF.js} +132 -0
- package/chunk-YL3EFYL3.js +199 -0
- package/{chunk-MMA3LZ3W.js → chunk-YNIYE47Z.js} +1 -1
- package/{chunk-W4S457LU.js → chunk-YU4ZPWVF.js} +41 -5
- package/{chunk-7Y4YTDQF.js → chunk-YWWDC3O7.js} +281 -159
- package/chunk-YZMNK53S.js +68 -0
- package/{chunk-RSHTSUEG.js → chunk-Z2PITYZN.js} +2060 -602
- package/{chunk-FY7F4Q6X.js → chunk-Z4PCXPUE.js} +2 -2
- package/{cliAgentConfigHelpers-WJBZQTLW.js → cliAgentConfigHelpers-TKYL43MT.js} +15 -16
- package/{cliAuthorityBrokerClient-PM3U6Q6J.js → cliAuthorityBrokerClient-XHH7MH2P.js} +1 -1
- package/{cliAuthorityStoreDriver-TKLXNNTG.js → cliAuthorityStoreDriver-6FE3BJNB.js} +1 -1
- package/{cliEnvHelpers-BVYTMUPJ.js → cliEnvHelpers-VPSJ4XWC.js} +3 -3
- package/{cliExecutor-BWBF2MTI.js → cliExecutor-4MAX3PZL.js} +2 -2
- package/cliLocalAgentRecordReader-MHHD4T7R.js +90 -0
- package/{commandRegistry-W63CYRZJ.js → commandRegistry-5DA5UP7S.js} +105 -97
- package/{contentThunks-U7PL5MQD.js → contentThunks-5GUQ7FWJ.js} +47 -43
- package/{cooldownCommands-TIGUHXTD.js → cooldownCommands-X7P5M2V5.js} +5 -4
- package/{createAgentAutomationAction-OLBQDD6R.js → createAgentAutomationAction-UCLTHQRI.js} +51 -49
- package/{createDialogAction-SVH6B3SB.js → createDialogAction-UPN774AF.js} +46 -48
- package/{createPageAction-F4DIWZ2Z.js → createPageAction-JRQ2TA4O.js} +50 -48
- package/{cursorProvider-YGGNMVWX.js → cursorProvider-2RACMEMF.js} +1 -1
- package/{db-HUCI5R4G.js → db-CS4ZJQKV.js} +1 -1
- package/{dbSlice-BVH2YZPQ.js → dbSlice-WNON7TOL.js} +17 -16
- package/{deleteFile-5YOEKV4U.js → deleteFile-Q3YDB4ML.js} +9 -9
- package/{desktopFolderProjects-SFY5EZS3.js → desktopFolderProjects-4POAMVJN.js} +2 -2
- package/{dialogCommands-KHIEPY3M.js → dialogCommands-VRI7VCXH.js} +64 -57
- package/dialogNotifyCommand-6TMCX4D2.js +36 -0
- package/{dialogSlice-ZCTDV2PZ.js → dialogSlice-LFNVUSAN.js} +42 -40
- package/{dialogUsageCommand-7KCPYGHG.js → dialogUsageCommand-HTVPR2CX.js} +11 -10
- package/{docCreateCommands-DPMZI7G5.js → docCreateCommands-AMPXMOX3.js} +61 -55
- package/{docDeleteCommands-IRQQLUBT.js → docDeleteCommands-I5WFAEHP.js} +63 -57
- package/{docReadCommands-LK37XH6L.js → docReadCommands-X53ELNIE.js} +61 -55
- package/{docStore-V2KECILA.js → docStore-2VAWVLWH.js} +21 -20
- package/{docUpdateCommands-O6T3HJHH.js → docUpdateCommands-6QPNDC7M.js} +64 -58
- package/{fetchMessages-NR4KNQLO.js → fetchMessages-TQEUZD7H.js} +8 -7
- package/{getPricing-2MNMXEVG.js → getPricing-MB2GBXOK.js} +6 -6
- package/{handleSendMessageAction-2PE25WM3.js → handleSendMessageAction-AAJOHXOB.js} +194 -302
- package/{hostCredentialCreate-S233UMAP.js → hostCredentialCreate-GLMJ22M6.js} +123 -114
- package/index.js +29 -29
- package/{keys-BEGDOTRL.js → keys-RWF7UCB4.js} +5 -4
- package/legacyMigration-TF4SYJCZ.js +19 -0
- package/{lib-5KKIBFIT.js → lib-OT5OTXRU.js} +7087 -6664
- package/{localDialogRead-7NNDVVF7.js → localDialogRead-SVTPA5GY.js} +3 -3
- package/{localFirstLog-DHNOY2NA.js → localFirstLog-OIETGK66.js} +1 -1
- package/localRecall-2J6QPOK2.js +15 -0
- package/{localRuntimeAdapter-KY6WXNBR.js → localRuntimeAdapter-BMP57P42.js} +119 -110
- package/{localRuntimeAuthority-OYH4AE4G.js → localRuntimeAuthority-IBJAT62G.js} +1 -1
- package/{localRuntimeDb-VBIMCWUC.js → localRuntimeDb-N7KHDXS2.js} +2 -2
- package/{machineCommands-Q6HA3IXF.js → machineCommands-3MLIAK5Q.js} +128 -119
- package/{machineInfo-UKPTZO5Y.js → machineInfo-LWHTEBHJ.js} +1 -1
- package/machineWsRunDispatch-FKIGROQF.js +191 -0
- package/{memberThunks-7EDJADWU.js → memberThunks-ZGLZ36PK.js} +29 -28
- package/{memoryCommands-ASCE5STX.js → memoryCommands-5WC3T66U.js} +4 -4
- package/models-ULVWLSQ6.js +9 -0
- package/{oauthTokenStore-OEERZFUC.js → oauthTokenStore-RUYNYALS.js} +1 -1
- package/{offlineMarxistsAgentCommand-2QTHJCHV.js → offlineMarxistsAgentCommand-4IC3Y4C6.js} +4 -4
- package/overlay-THLKYIWY.js +11 -0
- package/package.json +2 -2
- package/{pdf-U6KSUEZZ.js → pdf-KE3QI2V7.js} +1 -1
- package/{processSpawn-ZU5QFM43.js → processSpawn-6GEO77KV.js} +1 -1
- package/{profileConfig-KN3N2BLF.js → profileConfig-KOWK4HOG.js} +1 -1
- package/{projectArchive-DRTDIMEV.js → projectArchive-HK63GMF4.js} +52 -50
- package/{providerPresetApply-YXGV6NXB.js → providerPresetApply-OIFQ73LH.js} +19 -12
- package/{providerRegistry-S6UL6UNA.js → providerRegistry-KZ3SDZ3D.js} +10 -10
- package/{read-4V2RMG7N.js → read-MRQHJMJ2.js} +10 -10
- package/{readDocTool-BH6ATGQO.js → readDocTool-4BGTXTXA.js} +2 -2
- package/{readlineWorkspace-2W4WRCOU.js → readlineWorkspace-AKAHSCNY.js} +7982 -6274
- package/{removeDialogAgentAction-LYAZGNKW.js → removeDialogAgentAction-B6H7DXFM.js} +23 -22
- package/{runAgentClientLoop-J2VQBS2Z.js → runAgentClientLoop-UVAWGEON.js} +81 -79
- package/{runtimeDoctorCommands-QAI3MBKQ.js → runtimeDoctorCommands-FW6XKDUG.js} +12 -12
- package/{runtimeModeArgs-2Y7BALTO.js → runtimeModeArgs-X7DL7PUN.js} +1 -1
- package/secretCommands-LJXOOYA7.js +24 -0
- package/{setDialogExtraReferencesAction-OCRPGPYH.js → setDialogExtraReferencesAction-EVCY3TRW.js} +22 -21
- package/{setPrimaryDialogAgentAction-HFJDQIBU.js → setPrimaryDialogAgentAction-KPFVPHCJ.js} +23 -22
- package/{settingThunks-RAMHMTGM.js → settingThunks-ENOAK2WV.js} +97 -88
- package/{skillDiscovery-XKHROSH2.js → skillDiscovery-B5V23AXP.js} +4 -4
- package/{skillSummaryMarker-42HKSXYY.js → skillSummaryMarker-62UW7HI7.js} +1 -1
- package/{slateToRenderMarkdown-Y5IYN73U.js → slateToRenderMarkdown-R3X74MCX.js} +1 -1
- package/{slateUtils-NGV2NMKM.js → slateUtils-ESQAJ6RN.js} +1 -1
- package/{spaceCommands-KVJZVKVO.js → spaceCommands-DTTNAS2L.js} +61 -53
- package/store-JRVN62NM.js +46 -0
- package/{streamAgentChatTurn-GHBMJJ6S.js → streamAgentChatTurn-R5UY25VB.js} +875 -618
- package/{switchDialogAgentAction-EBRMW3RA.js → switchDialogAgentAction-SZ44XDRY.js} +21 -20
- package/{tableCommands-MP6VFSVT.js → tableCommands-HITDSLHS.js} +10 -10
- package/tombstones-FQQMEDOW.js +32 -0
- package/{toolApiClient-HGNO53TC.js → toolApiClient-OGQEBQVX.js} +4 -4
- package/{tools-EWKCPKMS.js → tools-HWFG6GMJ.js} +75 -74
- package/tuiSummaryLlmCaller-HQQZAMYF.js +44 -0
- package/{updateCommands-ZQYU6SCI.js → updateCommands-RJVCRSBP.js} +10 -8
- package/{updateDialogTitleAction-5GGMBTDF.js → updateDialogTitleAction-KNPOAMVS.js} +48 -46
- package/{usageCommand-F4IPVMIZ.js → usageCommand-FWZCB7AM.js} +11 -10
- package/{usageRebuildCommand-HAW2AD5N.js → usageRebuildCommand-SP2BLNJU.js} +12 -11
- package/userDataMerge-HT2ZVHBJ.js +13 -0
- package/{windowsSelfUpdate-257DV2T6.js → windowsSelfUpdate-KERHIAB4.js} +3 -3
- package/{workloadLifecycle-4C42SVBD.js → workloadLifecycle-DYNEYHV5.js} +6 -6
- package/agentRecordCommands-ZQ7SVYGG.js +0 -167
- package/agentRunCommand-WS7IGO2W.js +0 -196
- package/chunk-3CGG2PAL.js +0 -594
- package/chunk-5XBUWM6I.js +0 -89
- package/chunk-CJEIOP3E.js +0 -0
- package/chunk-EHGEOAHI.js +0 -636
- package/chunk-FW6YHHLI.js +0 -842
- package/chunk-GPVRUGGY.js +0 -115
- package/chunk-HSVBJRF4.js +0 -339
- package/chunk-WJZOQR2J.js +0 -151
- package/chunk-ZCWRMUWT.js +0 -89
- package/dist-M676ULYG.js +0 -7314
- package/machineWsRunDispatch-WWJQ6WR3.js +0 -182
- package/models-PJBE6JDV.js +0 -9
- package/tuiSummaryLlmCaller-ALQYUUWB.js +0 -189
- package/{chunk-WACI5I6V.js → chunk-2THCNKE4.js} +3 -3
- package/{chunk-2QHFH3DR.js → chunk-47ITIXO7.js} +6 -6
- package/{chunk-GOO6G4PY.js → chunk-CKG3PRZ7.js} +0 -0
- package/{chunk-OQHIVPG4.js → chunk-SNBZZPYH.js} +3 -3
- package/{chunk-AETZ7AD6.js → chunk-W6RFEDN4.js} +3 -3
|
@@ -0,0 +1,1137 @@
|
|
|
1
|
+
import {
|
|
2
|
+
_appendRetiredStateBatch,
|
|
3
|
+
loadMemoryVNextCatalog
|
|
4
|
+
} from "./chunk-XI2BWJM5.js";
|
|
5
|
+
import {
|
|
6
|
+
resolveMachineId
|
|
7
|
+
} from "./chunk-S73EPYNC.js";
|
|
8
|
+
import {
|
|
9
|
+
getDefaultCliLocalRuntimeDb
|
|
10
|
+
} from "./chunk-N5Z2V73W.js";
|
|
11
|
+
import {
|
|
12
|
+
createMemoryKey,
|
|
13
|
+
createMemoryOwnerIndexKey,
|
|
14
|
+
createMemorySubjectKindIndexKey,
|
|
15
|
+
memoryOwnerRange
|
|
16
|
+
} from "./chunk-SYTHYBMI.js";
|
|
17
|
+
import {
|
|
18
|
+
asTrimmedNonEmptyStringArray
|
|
19
|
+
} from "./chunk-I42VC5KR.js";
|
|
20
|
+
import {
|
|
21
|
+
buildCliRuntimeEnv,
|
|
22
|
+
clearProfileAuthToken,
|
|
23
|
+
getCurrentProfile,
|
|
24
|
+
getDefaultProfileConfigPath,
|
|
25
|
+
getProfileTokens,
|
|
26
|
+
loadProfileConfig,
|
|
27
|
+
saveDefaultProfile
|
|
28
|
+
} from "./chunk-R5GO3YZP.js";
|
|
29
|
+
import {
|
|
30
|
+
asTrimmedString
|
|
31
|
+
} from "./chunk-3EUW3WEO.js";
|
|
32
|
+
import {
|
|
33
|
+
resolveAuthTokenFromEnv
|
|
34
|
+
} from "./chunk-2THCNKE4.js";
|
|
35
|
+
import {
|
|
36
|
+
DEFAULT_NOLO_SERVER_URL
|
|
37
|
+
} from "./chunk-OLZBQWZU.js";
|
|
38
|
+
|
|
39
|
+
// packages/core/crypto.ts
|
|
40
|
+
import nacl from "tweetnacl";
|
|
41
|
+
|
|
42
|
+
// node_modules/js-base64/base64.mjs
|
|
43
|
+
var version = "3.9.6";
|
|
44
|
+
var VERSION = version;
|
|
45
|
+
var _TD = typeof TextDecoder === "function" ? new TextDecoder("utf-8", { ignoreBOM: true }) : void 0;
|
|
46
|
+
var _TE = typeof TextEncoder === "function" ? new TextEncoder() : void 0;
|
|
47
|
+
var b64ch = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
|
48
|
+
var b64chs = Array.prototype.slice.call(b64ch);
|
|
49
|
+
var b64tab = ((a) => {
|
|
50
|
+
let tab = {};
|
|
51
|
+
a.forEach((c, i) => tab[c] = i);
|
|
52
|
+
return tab;
|
|
53
|
+
})(b64chs);
|
|
54
|
+
var b64re = /^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/;
|
|
55
|
+
var _fromCC = String.fromCharCode.bind(String);
|
|
56
|
+
var _U8Afrom = typeof Uint8Array.from === "function" ? Uint8Array.from.bind(Uint8Array) : (it) => new Uint8Array(Array.prototype.slice.call(it, 0));
|
|
57
|
+
var _mkUriSafe = (src) => src.replace(/=/g, "").replace(/[+\/]/g, (m0) => m0 == "+" ? "-" : "_");
|
|
58
|
+
var _tidyB64 = (s) => s.replace(/[^A-Za-z0-9\+\/]/g, "");
|
|
59
|
+
var btoaPolyfill = (bin) => {
|
|
60
|
+
let u32, c0, c1, c2, asc = "";
|
|
61
|
+
const pad = bin.length % 3;
|
|
62
|
+
for (let i = 0; i < bin.length; ) {
|
|
63
|
+
if ((c0 = bin.charCodeAt(i++)) > 255 || (c1 = bin.charCodeAt(i++)) > 255 || (c2 = bin.charCodeAt(i++)) > 255)
|
|
64
|
+
throw new TypeError("invalid character found");
|
|
65
|
+
u32 = c0 << 16 | c1 << 8 | c2;
|
|
66
|
+
asc += b64chs[u32 >> 18 & 63] + b64chs[u32 >> 12 & 63] + b64chs[u32 >> 6 & 63] + b64chs[u32 & 63];
|
|
67
|
+
}
|
|
68
|
+
return pad ? asc.slice(0, pad - 3) + "===".substring(pad) : asc;
|
|
69
|
+
};
|
|
70
|
+
var _btoa = typeof btoa === "function" ? (bin) => btoa(bin) : btoaPolyfill;
|
|
71
|
+
var _fromUint8Array = typeof Uint8Array.prototype.toBase64 === "function" ? Function.prototype.call.bind(Uint8Array.prototype.toBase64) : (u8a) => {
|
|
72
|
+
const maxargs = 4096;
|
|
73
|
+
let strs = [];
|
|
74
|
+
for (let i = 0, l = u8a.length; i < l; i += maxargs) {
|
|
75
|
+
strs.push(_fromCC.apply(null, u8a.subarray(i, i + maxargs)));
|
|
76
|
+
}
|
|
77
|
+
return _btoa(strs.join(""));
|
|
78
|
+
};
|
|
79
|
+
var fromUint8Array = (u8a, urlsafe = false) => urlsafe ? _mkUriSafe(_fromUint8Array(u8a)) : _fromUint8Array(u8a);
|
|
80
|
+
var cb_utob = (c) => {
|
|
81
|
+
if (c.length < 2) {
|
|
82
|
+
var cc = c.charCodeAt(0);
|
|
83
|
+
return cc < 128 ? c : cc < 2048 ? _fromCC(192 | cc >>> 6) + _fromCC(128 | cc & 63) : _fromCC(224 | cc >>> 12 & 15) + _fromCC(128 | cc >>> 6 & 63) + _fromCC(128 | cc & 63);
|
|
84
|
+
} else {
|
|
85
|
+
var cc = 65536 + (c.charCodeAt(0) - 55296) * 1024 + (c.charCodeAt(1) - 56320);
|
|
86
|
+
return _fromCC(240 | cc >>> 18 & 7) + _fromCC(128 | cc >>> 12 & 63) + _fromCC(128 | cc >>> 6 & 63) + _fromCC(128 | cc & 63);
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
var re_utob = /[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\x00-\x7F]/g;
|
|
90
|
+
var utob = (u) => u.replace(re_utob, cb_utob);
|
|
91
|
+
var _encode = _TE ? (s) => _fromUint8Array(_TE.encode(s)) : (s) => _btoa(utob(s));
|
|
92
|
+
var encode = (src, urlsafe = false) => urlsafe ? _mkUriSafe(_encode(src)) : _encode(src);
|
|
93
|
+
var encodeURI = (src) => encode(src, true);
|
|
94
|
+
var re_btou = /[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g;
|
|
95
|
+
var cb_btou = (cccc) => {
|
|
96
|
+
switch (cccc.length) {
|
|
97
|
+
case 4:
|
|
98
|
+
var cp = (7 & cccc.charCodeAt(0)) << 18 | (63 & cccc.charCodeAt(1)) << 12 | (63 & cccc.charCodeAt(2)) << 6 | 63 & cccc.charCodeAt(3), offset = cp - 65536;
|
|
99
|
+
return _fromCC((offset >>> 10) + 55296) + _fromCC((offset & 1023) + 56320);
|
|
100
|
+
case 3:
|
|
101
|
+
return _fromCC((15 & cccc.charCodeAt(0)) << 12 | (63 & cccc.charCodeAt(1)) << 6 | 63 & cccc.charCodeAt(2));
|
|
102
|
+
default:
|
|
103
|
+
return _fromCC((31 & cccc.charCodeAt(0)) << 6 | 63 & cccc.charCodeAt(1));
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
var btou = (b) => b.replace(re_btou, cb_btou);
|
|
107
|
+
var atobPolyfill = (asc) => {
|
|
108
|
+
asc = asc.replace(/\s+/g, "");
|
|
109
|
+
if (!b64re.test(asc))
|
|
110
|
+
throw new TypeError("malformed base64.");
|
|
111
|
+
asc += "==".slice(2 - (asc.length & 3));
|
|
112
|
+
let u24, r1, r2;
|
|
113
|
+
let binArray = [];
|
|
114
|
+
for (let i = 0; i < asc.length; ) {
|
|
115
|
+
u24 = b64tab[asc.charAt(i++)] << 18 | b64tab[asc.charAt(i++)] << 12 | (r1 = b64tab[asc.charAt(i++)]) << 6 | (r2 = b64tab[asc.charAt(i++)]);
|
|
116
|
+
if (r1 === 64) {
|
|
117
|
+
binArray.push(_fromCC(u24 >> 16 & 255));
|
|
118
|
+
} else if (r2 === 64) {
|
|
119
|
+
binArray.push(_fromCC(u24 >> 16 & 255, u24 >> 8 & 255));
|
|
120
|
+
} else {
|
|
121
|
+
binArray.push(_fromCC(u24 >> 16 & 255, u24 >> 8 & 255, u24 & 255));
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return binArray.join("");
|
|
125
|
+
};
|
|
126
|
+
var _atob = typeof atob === "function" ? (asc) => atob(_tidyB64(asc)) : atobPolyfill;
|
|
127
|
+
var _toUint8Array = typeof Uint8Array.fromBase64 === "function" ? (a) => Uint8Array.fromBase64(a) : (a) => _U8Afrom(_atob(a).split("").map((c) => c.charCodeAt(0)));
|
|
128
|
+
var toUint8Array = (a) => _toUint8Array(_unURI(a));
|
|
129
|
+
var _decode = _TD ? (a) => _TD.decode(_toUint8Array(a)) : (a) => btou(_atob(a));
|
|
130
|
+
var _unURI = (a) => _tidyB64(a.replace(/[-_]/g, (m0) => m0 == "-" ? "+" : "/"));
|
|
131
|
+
var decode = (src) => _decode(_unURI(src));
|
|
132
|
+
var isValid = (src) => {
|
|
133
|
+
if (typeof src !== "string")
|
|
134
|
+
return false;
|
|
135
|
+
const s = src.replace(/\s+/g, "").replace(/={0,2}$/, "");
|
|
136
|
+
if (s.length % 4 === 1)
|
|
137
|
+
return false;
|
|
138
|
+
return !/[^\s0-9a-zA-Z\+/]/.test(s) || !/[^\s0-9a-zA-Z\-_]/.test(s);
|
|
139
|
+
};
|
|
140
|
+
var _noEnum = (v) => {
|
|
141
|
+
return {
|
|
142
|
+
value: v,
|
|
143
|
+
enumerable: false,
|
|
144
|
+
writable: true,
|
|
145
|
+
configurable: true
|
|
146
|
+
};
|
|
147
|
+
};
|
|
148
|
+
var extendString = function() {
|
|
149
|
+
const _add = (name, body) => Object.defineProperty(String.prototype, name, _noEnum(body));
|
|
150
|
+
_add("fromBase64", function() {
|
|
151
|
+
return decode(this);
|
|
152
|
+
});
|
|
153
|
+
_add("toBase64", function(urlsafe) {
|
|
154
|
+
return encode(this, urlsafe);
|
|
155
|
+
});
|
|
156
|
+
_add("toBase64URI", function() {
|
|
157
|
+
return encode(this, true);
|
|
158
|
+
});
|
|
159
|
+
_add("toBase64URL", function() {
|
|
160
|
+
return encode(this, true);
|
|
161
|
+
});
|
|
162
|
+
_add("toUint8Array", function() {
|
|
163
|
+
return toUint8Array(this);
|
|
164
|
+
});
|
|
165
|
+
};
|
|
166
|
+
var extendUint8Array = function() {
|
|
167
|
+
const _add = (name, body) => Object.defineProperty(Uint8Array.prototype, name, _noEnum(body));
|
|
168
|
+
_add("toBase64", function(urlsafe) {
|
|
169
|
+
return fromUint8Array(this, urlsafe);
|
|
170
|
+
});
|
|
171
|
+
_add("toBase64URI", function() {
|
|
172
|
+
return fromUint8Array(this, true);
|
|
173
|
+
});
|
|
174
|
+
_add("toBase64URL", function() {
|
|
175
|
+
return fromUint8Array(this, true);
|
|
176
|
+
});
|
|
177
|
+
};
|
|
178
|
+
var extendBuiltins = () => {
|
|
179
|
+
extendString();
|
|
180
|
+
extendUint8Array();
|
|
181
|
+
};
|
|
182
|
+
var gBase64 = {
|
|
183
|
+
version,
|
|
184
|
+
VERSION,
|
|
185
|
+
atob: _atob,
|
|
186
|
+
atobPolyfill,
|
|
187
|
+
btoa: _btoa,
|
|
188
|
+
btoaPolyfill,
|
|
189
|
+
fromBase64: decode,
|
|
190
|
+
toBase64: encode,
|
|
191
|
+
encode,
|
|
192
|
+
encodeURI,
|
|
193
|
+
encodeURL: encodeURI,
|
|
194
|
+
utob,
|
|
195
|
+
btou,
|
|
196
|
+
decode,
|
|
197
|
+
isValid,
|
|
198
|
+
fromUint8Array,
|
|
199
|
+
toUint8Array,
|
|
200
|
+
extendString,
|
|
201
|
+
extendUint8Array,
|
|
202
|
+
extendBuiltins
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
// packages/core/authToken.ts
|
|
206
|
+
var parseToken = (token) => {
|
|
207
|
+
try {
|
|
208
|
+
const [payloadBase64] = token.split(".");
|
|
209
|
+
return JSON.parse(gBase64.decode(payloadBase64));
|
|
210
|
+
} catch {
|
|
211
|
+
return null;
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
// packages/core/accountSession/accountSessionCore.ts
|
|
216
|
+
var isAccountIdentity = (value) => typeof value === "object" && value !== null && typeof value.userId === "string" && value.userId.length > 0;
|
|
217
|
+
var parseUserToken = (token) => {
|
|
218
|
+
if (typeof token !== "string" || !token.trim()) return null;
|
|
219
|
+
const parsed = parseToken(token);
|
|
220
|
+
return isAccountIdentity(parsed) ? parsed : null;
|
|
221
|
+
};
|
|
222
|
+
var parseStoredTokenEntries = (tokens) => {
|
|
223
|
+
if (!Array.isArray(tokens)) return [];
|
|
224
|
+
const seenUserIds = /* @__PURE__ */ new Set();
|
|
225
|
+
const entries = [];
|
|
226
|
+
for (const token of tokens) {
|
|
227
|
+
const account = parseUserToken(token);
|
|
228
|
+
if (!account || seenUserIds.has(account.userId)) continue;
|
|
229
|
+
seenUserIds.add(account.userId);
|
|
230
|
+
entries.push({ token, account });
|
|
231
|
+
}
|
|
232
|
+
return entries;
|
|
233
|
+
};
|
|
234
|
+
var compactUniqueAccounts = (accounts) => {
|
|
235
|
+
if (!Array.isArray(accounts)) return [];
|
|
236
|
+
const seenUserIds = /* @__PURE__ */ new Set();
|
|
237
|
+
const result = [];
|
|
238
|
+
for (const account of accounts) {
|
|
239
|
+
if (!isAccountIdentity(account) || seenUserIds.has(account.userId)) continue;
|
|
240
|
+
seenUserIds.add(account.userId);
|
|
241
|
+
result.push(account);
|
|
242
|
+
}
|
|
243
|
+
return result;
|
|
244
|
+
};
|
|
245
|
+
var mergeAccountState = (existingAccount, nextAccount) => {
|
|
246
|
+
if (!existingAccount || existingAccount.userId !== nextAccount.userId) {
|
|
247
|
+
return nextAccount;
|
|
248
|
+
}
|
|
249
|
+
return {
|
|
250
|
+
...existingAccount,
|
|
251
|
+
...nextAccount
|
|
252
|
+
};
|
|
253
|
+
};
|
|
254
|
+
var SSR_SNAPSHOT = Object.freeze({
|
|
255
|
+
accounts: [],
|
|
256
|
+
activeAccountId: null,
|
|
257
|
+
activeToken: null,
|
|
258
|
+
initialized: false,
|
|
259
|
+
transition: "idle"
|
|
260
|
+
});
|
|
261
|
+
var AccountSessionCore = class {
|
|
262
|
+
snapshot;
|
|
263
|
+
sessionGeneration = 0;
|
|
264
|
+
tokenByUserId = /* @__PURE__ */ new Map();
|
|
265
|
+
listeners = /* @__PURE__ */ new Set();
|
|
266
|
+
constructor(initial) {
|
|
267
|
+
const accounts = compactUniqueAccounts(initial?.accounts ?? []);
|
|
268
|
+
const rawActiveId = initial?.activeAccountId ?? null;
|
|
269
|
+
const rawActiveToken = initial?.activeToken ?? null;
|
|
270
|
+
const parsedActive = rawActiveToken ? parseUserToken(rawActiveToken) : null;
|
|
271
|
+
const hasValidPair = typeof rawActiveId === "string" && rawActiveId.length > 0 && parsedActive !== null && parsedActive.userId === rawActiveId && accounts.some((account) => account.userId === rawActiveId);
|
|
272
|
+
this.snapshot = {
|
|
273
|
+
sessionGeneration: this.sessionGeneration,
|
|
274
|
+
accounts,
|
|
275
|
+
activeAccountId: hasValidPair ? rawActiveId : null,
|
|
276
|
+
activeToken: hasValidPair ? rawActiveToken : null,
|
|
277
|
+
initialized: initial?.initialized ?? false,
|
|
278
|
+
transition: initial?.transition ?? "idle"
|
|
279
|
+
};
|
|
280
|
+
if (hasValidPair && rawActiveId && rawActiveToken) {
|
|
281
|
+
this.tokenByUserId.set(rawActiveId, rawActiveToken);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
getSnapshot = () => {
|
|
285
|
+
return this.snapshot;
|
|
286
|
+
};
|
|
287
|
+
getServerSnapshot = () => {
|
|
288
|
+
return SSR_SNAPSHOT;
|
|
289
|
+
};
|
|
290
|
+
subscribe = (listener) => {
|
|
291
|
+
this.listeners.add(listener);
|
|
292
|
+
return () => {
|
|
293
|
+
this.listeners.delete(listener);
|
|
294
|
+
};
|
|
295
|
+
};
|
|
296
|
+
emit() {
|
|
297
|
+
for (const listener of this.listeners) {
|
|
298
|
+
listener();
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
setSnapshot(next, forceAdvanceSession = false) {
|
|
302
|
+
if (forceAdvanceSession || next.activeAccountId !== this.snapshot.activeAccountId || next.activeToken !== this.snapshot.activeToken) {
|
|
303
|
+
this.sessionGeneration += 1;
|
|
304
|
+
}
|
|
305
|
+
this.snapshot = { ...next, sessionGeneration: this.sessionGeneration };
|
|
306
|
+
this.emit();
|
|
307
|
+
}
|
|
308
|
+
initializeFromTokens(tokens, preferredActiveAccountId) {
|
|
309
|
+
const entries = parseStoredTokenEntries(tokens);
|
|
310
|
+
this.tokenByUserId.clear();
|
|
311
|
+
for (const entry of entries) {
|
|
312
|
+
this.tokenByUserId.set(entry.account.userId, entry.token);
|
|
313
|
+
}
|
|
314
|
+
if (entries.length === 0) {
|
|
315
|
+
this.setSnapshot({
|
|
316
|
+
accounts: [],
|
|
317
|
+
activeAccountId: null,
|
|
318
|
+
activeToken: null,
|
|
319
|
+
initialized: true,
|
|
320
|
+
transition: "idle"
|
|
321
|
+
});
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
const preferredEntry = preferredActiveAccountId ? entries.find((e) => e.account.userId === preferredActiveAccountId) : null;
|
|
325
|
+
const activeEntry = preferredEntry ?? entries[0];
|
|
326
|
+
const accounts = entries.map((entry) => {
|
|
327
|
+
const existing = this.snapshot.accounts.find(
|
|
328
|
+
(a) => a.userId === entry.account.userId
|
|
329
|
+
);
|
|
330
|
+
return mergeAccountState(existing, entry.account);
|
|
331
|
+
});
|
|
332
|
+
const activeAccount = accounts.find(
|
|
333
|
+
(a) => a.userId === activeEntry.account.userId
|
|
334
|
+
) ?? activeEntry.account;
|
|
335
|
+
const orderedAccounts = [
|
|
336
|
+
activeAccount,
|
|
337
|
+
...accounts.filter((a) => a.userId !== activeAccount.userId)
|
|
338
|
+
];
|
|
339
|
+
this.setSnapshot({
|
|
340
|
+
accounts: orderedAccounts,
|
|
341
|
+
activeAccountId: activeAccount.userId,
|
|
342
|
+
activeToken: activeEntry.token,
|
|
343
|
+
initialized: true,
|
|
344
|
+
transition: "idle"
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
beginTransition(transition) {
|
|
348
|
+
if (this.snapshot.transition === transition) return;
|
|
349
|
+
this.setSnapshot({
|
|
350
|
+
...this.snapshot,
|
|
351
|
+
transition
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Activate `token` as the active account and complete the current transition.
|
|
356
|
+
*
|
|
357
|
+
* @returns true when the token was valid and the session moved to it.
|
|
358
|
+
* Returns false for an invalid token WITHOUT completing the transition or
|
|
359
|
+
* touching the active identity — callers (the session service) are
|
|
360
|
+
* responsible for explicitly calling failTransition in that case.
|
|
361
|
+
*/
|
|
362
|
+
activateToken(token, accountOverride) {
|
|
363
|
+
const parsed = parseUserToken(token);
|
|
364
|
+
if (!parsed) {
|
|
365
|
+
return false;
|
|
366
|
+
}
|
|
367
|
+
this.tokenByUserId.set(parsed.userId, token);
|
|
368
|
+
const merged = mergeAccountState(
|
|
369
|
+
this.snapshot.accounts.find((a) => a.userId === parsed.userId),
|
|
370
|
+
{ ...parsed, ...accountOverride }
|
|
371
|
+
);
|
|
372
|
+
const otherAccounts = this.snapshot.accounts.filter(
|
|
373
|
+
(a) => a.userId !== merged.userId
|
|
374
|
+
);
|
|
375
|
+
const nextAccounts = [merged, ...otherAccounts];
|
|
376
|
+
this.setSnapshot({
|
|
377
|
+
accounts: nextAccounts,
|
|
378
|
+
activeAccountId: merged.userId,
|
|
379
|
+
activeToken: token,
|
|
380
|
+
initialized: true,
|
|
381
|
+
transition: "idle"
|
|
382
|
+
}, true);
|
|
383
|
+
return true;
|
|
384
|
+
}
|
|
385
|
+
completeTransition() {
|
|
386
|
+
if (this.snapshot.transition === "idle" && this.snapshot.initialized) return;
|
|
387
|
+
this.setSnapshot({
|
|
388
|
+
...this.snapshot,
|
|
389
|
+
initialized: true,
|
|
390
|
+
transition: "idle"
|
|
391
|
+
});
|
|
392
|
+
}
|
|
393
|
+
failTransition() {
|
|
394
|
+
if (this.snapshot.transition === "idle" && this.snapshot.initialized) return;
|
|
395
|
+
this.setSnapshot({
|
|
396
|
+
...this.snapshot,
|
|
397
|
+
initialized: true,
|
|
398
|
+
transition: "idle"
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
removeAccount(userId) {
|
|
402
|
+
this.tokenByUserId.delete(userId);
|
|
403
|
+
const remainingAccounts = this.snapshot.accounts.filter(
|
|
404
|
+
(a) => a.userId !== userId
|
|
405
|
+
);
|
|
406
|
+
if (this.snapshot.activeAccountId === userId) {
|
|
407
|
+
const nextActive = remainingAccounts.find(
|
|
408
|
+
(a) => Boolean(this.tokenByUserId.get(a.userId))
|
|
409
|
+
);
|
|
410
|
+
if (nextActive) {
|
|
411
|
+
const nextActiveToken = this.tokenByUserId.get(nextActive.userId);
|
|
412
|
+
this.setSnapshot({
|
|
413
|
+
accounts: remainingAccounts,
|
|
414
|
+
activeAccountId: nextActive.userId,
|
|
415
|
+
activeToken: nextActiveToken,
|
|
416
|
+
initialized: true,
|
|
417
|
+
transition: "idle"
|
|
418
|
+
});
|
|
419
|
+
} else {
|
|
420
|
+
this.setSnapshot({
|
|
421
|
+
accounts: remainingAccounts,
|
|
422
|
+
activeAccountId: null,
|
|
423
|
+
activeToken: null,
|
|
424
|
+
initialized: true,
|
|
425
|
+
transition: "idle"
|
|
426
|
+
});
|
|
427
|
+
}
|
|
428
|
+
} else {
|
|
429
|
+
this.setSnapshot({
|
|
430
|
+
...this.snapshot,
|
|
431
|
+
accounts: remainingAccounts,
|
|
432
|
+
transition: "idle"
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
replaceActiveToken(token) {
|
|
437
|
+
const parsed = parseUserToken(token);
|
|
438
|
+
if (!parsed) return;
|
|
439
|
+
if (this.snapshot.activeAccountId && this.snapshot.activeAccountId !== parsed.userId) {
|
|
440
|
+
return;
|
|
441
|
+
}
|
|
442
|
+
this.tokenByUserId.set(parsed.userId, token);
|
|
443
|
+
const existing = this.snapshot.accounts.find(
|
|
444
|
+
(a) => a.userId === parsed.userId
|
|
445
|
+
);
|
|
446
|
+
const merged = mergeAccountState(existing, parsed);
|
|
447
|
+
const otherAccounts = this.snapshot.accounts.filter(
|
|
448
|
+
(a) => a.userId !== parsed.userId
|
|
449
|
+
);
|
|
450
|
+
this.setSnapshot({
|
|
451
|
+
accounts: [merged, ...otherAccounts],
|
|
452
|
+
activeAccountId: parsed.userId,
|
|
453
|
+
activeToken: token,
|
|
454
|
+
initialized: true,
|
|
455
|
+
transition: "idle"
|
|
456
|
+
});
|
|
457
|
+
}
|
|
458
|
+
updateAccount(account) {
|
|
459
|
+
const existingIndex = this.snapshot.accounts.findIndex(
|
|
460
|
+
(a) => a.userId === account.userId
|
|
461
|
+
);
|
|
462
|
+
if (existingIndex === -1) return;
|
|
463
|
+
const existing = this.snapshot.accounts[existingIndex];
|
|
464
|
+
const merged = mergeAccountState(existing, { ...existing, ...account });
|
|
465
|
+
const nextAccounts = [...this.snapshot.accounts];
|
|
466
|
+
nextAccounts[existingIndex] = merged;
|
|
467
|
+
this.setSnapshot({
|
|
468
|
+
...this.snapshot,
|
|
469
|
+
accounts: nextAccounts
|
|
470
|
+
});
|
|
471
|
+
}
|
|
472
|
+
deductActiveBalance(cost) {
|
|
473
|
+
if (!this.snapshot.activeAccountId || typeof cost !== "number" || cost <= 0) {
|
|
474
|
+
return;
|
|
475
|
+
}
|
|
476
|
+
const activeId = this.snapshot.activeAccountId;
|
|
477
|
+
const existing = this.snapshot.accounts.find((a) => a.userId === activeId);
|
|
478
|
+
if (!existing || typeof existing.balance !== "number") return;
|
|
479
|
+
this.updateAccount({
|
|
480
|
+
userId: activeId,
|
|
481
|
+
balance: existing.balance - cost
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
reset() {
|
|
485
|
+
this.tokenByUserId.clear();
|
|
486
|
+
this.setSnapshot({
|
|
487
|
+
accounts: [],
|
|
488
|
+
activeAccountId: null,
|
|
489
|
+
activeToken: null,
|
|
490
|
+
initialized: false,
|
|
491
|
+
transition: "idle"
|
|
492
|
+
});
|
|
493
|
+
}
|
|
494
|
+
};
|
|
495
|
+
var createAccountSessionCore = (initial) => new AccountSessionCore(initial);
|
|
496
|
+
|
|
497
|
+
// packages/core/deviceAuthorization.ts
|
|
498
|
+
var fail = (code) => {
|
|
499
|
+
throw new Error(code);
|
|
500
|
+
};
|
|
501
|
+
function deviceAuthorizationOrigin(value) {
|
|
502
|
+
let url;
|
|
503
|
+
try {
|
|
504
|
+
url = new URL(value);
|
|
505
|
+
} catch {
|
|
506
|
+
return fail("invalid_origin");
|
|
507
|
+
}
|
|
508
|
+
if (!["https:", "http:"].includes(url.protocol) || url.username || url.password || url.pathname !== "/" || url.search || url.hash) return fail("invalid_origin");
|
|
509
|
+
return url.origin;
|
|
510
|
+
}
|
|
511
|
+
function parseDeviceAuthorizationStart(data, origin) {
|
|
512
|
+
if (typeof data.deviceCode !== "string" || !data.deviceCode || data.deviceCode.length > 512 || typeof data.userCode !== "string" || !/^[A-Z0-9]{8}$/.test(data.userCode) || data.verificationUri !== `${origin}/cli/authorize` || data.verificationUriComplete !== `${origin}/cli/authorize?code=${data.userCode}` || typeof data.expiresIn !== "number" || !Number.isFinite(data.expiresIn) || data.expiresIn <= 0 || typeof data.interval !== "number" || !Number.isFinite(data.interval) || data.interval <= 0) return fail("invalid_response");
|
|
513
|
+
return data;
|
|
514
|
+
}
|
|
515
|
+
function parseDeviceAuthorizationPoll(status, data, origin) {
|
|
516
|
+
if (status === 202 && data.status === "pending" && data.error === "authorization_pending") return { status: "pending" };
|
|
517
|
+
if (status < 200 || status >= 300) return fail(data.error === "expired_token" ? "expired" : "authorization_failed");
|
|
518
|
+
if (status === 202 || data.status !== "approved" || data.serverUrl !== origin || typeof data.token !== "string" || typeof data.userId !== "string" || !data.userId || parseUserToken(data.token)?.userId !== data.userId) return fail("invalid_response");
|
|
519
|
+
return { status: "approved", token: data.token, serverUrl: origin, userId: data.userId };
|
|
520
|
+
}
|
|
521
|
+
function createDeviceAuthorizationProtocol(options) {
|
|
522
|
+
const origin = deviceAuthorizationOrigin(options.origin);
|
|
523
|
+
const now = options.now ?? Date.now;
|
|
524
|
+
let deadline = now() + 6e5;
|
|
525
|
+
const check = () => {
|
|
526
|
+
if (options.signal?.aborted) fail("cancelled");
|
|
527
|
+
if (now() >= deadline) fail("expired");
|
|
528
|
+
};
|
|
529
|
+
const bounded = async (work, timeoutMs) => {
|
|
530
|
+
check();
|
|
531
|
+
const abort = new AbortController();
|
|
532
|
+
let timer;
|
|
533
|
+
let onAbort;
|
|
534
|
+
const interruption = new Promise((_, reject) => {
|
|
535
|
+
onAbort = () => {
|
|
536
|
+
abort.abort();
|
|
537
|
+
reject(new Error("cancelled"));
|
|
538
|
+
};
|
|
539
|
+
options.signal?.addEventListener("abort", onAbort, { once: true });
|
|
540
|
+
timer = setTimeout(() => {
|
|
541
|
+
abort.abort();
|
|
542
|
+
reject(new Error(now() >= deadline ? "expired" : "request_timeout"));
|
|
543
|
+
}, Math.max(1, Math.min(timeoutMs, deadline - now())));
|
|
544
|
+
});
|
|
545
|
+
try {
|
|
546
|
+
const result = await Promise.race([interruption, work(abort.signal)]);
|
|
547
|
+
check();
|
|
548
|
+
return result;
|
|
549
|
+
} finally {
|
|
550
|
+
clearTimeout(timer);
|
|
551
|
+
options.signal?.removeEventListener("abort", onAbort);
|
|
552
|
+
}
|
|
553
|
+
};
|
|
554
|
+
const post = (endpoint, body) => bounded(async (signal) => {
|
|
555
|
+
const response = await (options.fetch ?? globalThis.fetch)(`${origin}/api/v1/users/cli-login/${endpoint}`, {
|
|
556
|
+
method: "POST",
|
|
557
|
+
headers: { "Content-Type": "application/json" },
|
|
558
|
+
body: JSON.stringify(body),
|
|
559
|
+
signal,
|
|
560
|
+
redirect: "error",
|
|
561
|
+
credentials: "omit",
|
|
562
|
+
cache: "no-store"
|
|
563
|
+
});
|
|
564
|
+
if (endpoint === "start" && !response.ok) return fail("start_failed");
|
|
565
|
+
const data = await response.json();
|
|
566
|
+
if (!data || typeof data !== "object" || Array.isArray(data)) return fail("invalid_response");
|
|
567
|
+
return { response, data };
|
|
568
|
+
}, options.requestTimeoutMs && Number.isFinite(options.requestTimeoutMs) && options.requestTimeoutMs > 0 ? Math.min(options.requestTimeoutMs, 15e3) : 15e3);
|
|
569
|
+
return {
|
|
570
|
+
check,
|
|
571
|
+
get deadline() {
|
|
572
|
+
return deadline;
|
|
573
|
+
},
|
|
574
|
+
async start(clientName) {
|
|
575
|
+
const { response, data } = await post("start", { clientName });
|
|
576
|
+
if (!response.ok) return fail("start_failed");
|
|
577
|
+
const start = parseDeviceAuthorizationStart(data, origin);
|
|
578
|
+
deadline = Math.min(deadline, now() + Math.min(start.expiresIn, 600) * 1e3);
|
|
579
|
+
return start;
|
|
580
|
+
},
|
|
581
|
+
async poll(deviceCode) {
|
|
582
|
+
const { response, data } = await post("poll", { deviceCode });
|
|
583
|
+
return parseDeviceAuthorizationPoll(response.status, data, origin);
|
|
584
|
+
},
|
|
585
|
+
async wait(intervalSeconds) {
|
|
586
|
+
const delay = Math.min(Math.max(1e3, intervalSeconds * 1e3), 3e4, deadline - now());
|
|
587
|
+
await bounded((signal) => options.sleep ? options.sleep(delay) : new Promise((resolve) => {
|
|
588
|
+
const onAbort = () => clearTimeout(timer);
|
|
589
|
+
const timer = setTimeout(() => {
|
|
590
|
+
signal.removeEventListener("abort", onAbort);
|
|
591
|
+
resolve();
|
|
592
|
+
}, delay);
|
|
593
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
594
|
+
}), delay + 50);
|
|
595
|
+
},
|
|
596
|
+
run: bounded
|
|
597
|
+
};
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
// packages/cli/authCommands.ts
|
|
601
|
+
import { createInterface } from "node:readline/promises";
|
|
602
|
+
import { stdin as input, stdout as output } from "node:process";
|
|
603
|
+
import { spawn } from "node:child_process";
|
|
604
|
+
|
|
605
|
+
// packages/ai/memory/delete.ts
|
|
606
|
+
var VNEXT_STATE_ID_PREFIX = "vnext-state-";
|
|
607
|
+
var toVNextMemoryItem = (state, owner) => ({
|
|
608
|
+
id: `${VNEXT_STATE_ID_PREFIX}${state.id}`,
|
|
609
|
+
ownerType: owner.ownerType,
|
|
610
|
+
ownerId: owner.ownerId,
|
|
611
|
+
visibility: "private",
|
|
612
|
+
subjectType: "user",
|
|
613
|
+
subjectId: owner.ownerId,
|
|
614
|
+
kind: "semantic",
|
|
615
|
+
content: state.text.trim(),
|
|
616
|
+
createdAt: state.createdAt,
|
|
617
|
+
lastActivatedAt: state.createdAt,
|
|
618
|
+
activationCount: 1,
|
|
619
|
+
importance: 0.9,
|
|
620
|
+
confidence: 0.9,
|
|
621
|
+
resident: state.facet === "preference" || state.facet === "style"
|
|
622
|
+
});
|
|
623
|
+
var matchesVNextFilters = (state, idSet, contentSub) => {
|
|
624
|
+
if (!idSet && !contentSub) return false;
|
|
625
|
+
if (idSet && !idSet.has(`${VNEXT_STATE_ID_PREFIX}${state.id}`)) return false;
|
|
626
|
+
if (contentSub && !state.text.toLowerCase().includes(contentSub)) return false;
|
|
627
|
+
return true;
|
|
628
|
+
};
|
|
629
|
+
function hasExplicitDeleteFilters(filters) {
|
|
630
|
+
return Boolean(
|
|
631
|
+
filters.ids && filters.ids.length > 0 || typeof filters.contentSubstring === "string" && filters.contentSubstring.trim().length > 0 || filters.tags && filters.tags.length > 0 || typeof filters.sourceDialogId === "string" && filters.sourceDialogId.trim().length > 0 || typeof filters.patternKeyPrefix === "string" && filters.patternKeyPrefix.trim().length > 0 || filters.facets && filters.facets.length > 0 || typeof filters.subjectId === "string" && filters.subjectId.trim().length > 0
|
|
632
|
+
);
|
|
633
|
+
}
|
|
634
|
+
function generateMemoryDeletionToken(ownerId, itemIds) {
|
|
635
|
+
const sorted = [...itemIds].sort().join(",");
|
|
636
|
+
const seed = `${ownerId}:${sorted}`;
|
|
637
|
+
let hash = 0;
|
|
638
|
+
for (let i = 0; i < seed.length; i++) {
|
|
639
|
+
hash = (hash << 5) - hash + seed.charCodeAt(i) | 0;
|
|
640
|
+
}
|
|
641
|
+
return `tok-${Math.abs(hash).toString(36)}-${itemIds.length}`;
|
|
642
|
+
}
|
|
643
|
+
var normalizeSet = (values) => {
|
|
644
|
+
if (!Array.isArray(values) || values.length === 0) return null;
|
|
645
|
+
const normalized = asTrimmedNonEmptyStringArray(values);
|
|
646
|
+
return normalized.length > 0 ? new Set(normalized) : null;
|
|
647
|
+
};
|
|
648
|
+
var matchesFilters = (item, filters) => {
|
|
649
|
+
const idSet = normalizeSet(filters.ids);
|
|
650
|
+
if (idSet && !idSet.has(item.id)) return false;
|
|
651
|
+
const kindSet = normalizeSet(filters.kinds);
|
|
652
|
+
if (kindSet && !kindSet.has(item.kind)) return false;
|
|
653
|
+
const facetSet = normalizeSet(filters.facets);
|
|
654
|
+
if (facetSet && (!item.facet || !facetSet.has(item.facet))) return false;
|
|
655
|
+
if (filters.subjectType && item.subjectType !== filters.subjectType) return false;
|
|
656
|
+
if (filters.subjectId && item.subjectId !== filters.subjectId) return false;
|
|
657
|
+
const prefix = asTrimmedString(filters.patternKeyPrefix);
|
|
658
|
+
if (prefix && !(item.patternKey ?? "").startsWith(prefix)) return false;
|
|
659
|
+
if (filters.sourceDialogId && item.sourceDialogId !== filters.sourceDialogId) {
|
|
660
|
+
return false;
|
|
661
|
+
}
|
|
662
|
+
const tagSet = normalizeSet(filters.tags);
|
|
663
|
+
if (tagSet) {
|
|
664
|
+
const itemTags = new Set(asTrimmedNonEmptyStringArray(item.tags));
|
|
665
|
+
for (const tag of tagSet) {
|
|
666
|
+
if (!itemTags.has(tag)) return false;
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
const contentSub = asTrimmedString(filters.contentSubstring);
|
|
670
|
+
if (contentSub && !(item.content ?? "").toLowerCase().includes(contentSub.toLowerCase())) {
|
|
671
|
+
return false;
|
|
672
|
+
}
|
|
673
|
+
return true;
|
|
674
|
+
};
|
|
675
|
+
var deleteMemoryItemWithIndexesInBatch = (batch, item) => {
|
|
676
|
+
batch.del(createMemoryKey(item.ownerType, item.ownerId, item.id));
|
|
677
|
+
batch.del(
|
|
678
|
+
createMemoryOwnerIndexKey(
|
|
679
|
+
item.ownerType,
|
|
680
|
+
item.ownerId,
|
|
681
|
+
item.createdAt,
|
|
682
|
+
item.id
|
|
683
|
+
)
|
|
684
|
+
);
|
|
685
|
+
batch.del(
|
|
686
|
+
createMemorySubjectKindIndexKey(
|
|
687
|
+
item.subjectType,
|
|
688
|
+
item.subjectId,
|
|
689
|
+
item.kind,
|
|
690
|
+
item.createdAt,
|
|
691
|
+
item.id
|
|
692
|
+
)
|
|
693
|
+
);
|
|
694
|
+
};
|
|
695
|
+
var deleteMemoriesForOwnerFromDb = async (db, owner, filters = {}) => {
|
|
696
|
+
if (!hasExplicitDeleteFilters(filters)) {
|
|
697
|
+
throw new Error(
|
|
698
|
+
"At least one filter is required; delete operation will not delete all memory implicitly."
|
|
699
|
+
);
|
|
700
|
+
}
|
|
701
|
+
const range = memoryOwnerRange(owner.ownerType, owner.ownerId);
|
|
702
|
+
const matchedItems = [];
|
|
703
|
+
const limit = typeof filters.limit === "number" && filters.limit > 0 ? filters.limit : Number.POSITIVE_INFINITY;
|
|
704
|
+
for await (const [, value] of db.iterator({
|
|
705
|
+
gte: range.start,
|
|
706
|
+
lte: range.end,
|
|
707
|
+
reverse: true
|
|
708
|
+
})) {
|
|
709
|
+
const memoryId = typeof value?.memoryId === "string" ? value.memoryId : "";
|
|
710
|
+
if (!memoryId) continue;
|
|
711
|
+
const item = await db.get(createMemoryKey(owner.ownerType, owner.ownerId, memoryId)).catch(() => null);
|
|
712
|
+
if (!item) continue;
|
|
713
|
+
if (!matchesFilters(item, filters)) continue;
|
|
714
|
+
matchedItems.push(item);
|
|
715
|
+
if (matchedItems.length >= limit) break;
|
|
716
|
+
}
|
|
717
|
+
const idSet = normalizeSet(filters.ids);
|
|
718
|
+
const contentSub = asTrimmedString(filters.contentSubstring).toLowerCase();
|
|
719
|
+
const vnextStateIdsToRetire = [];
|
|
720
|
+
const vnextStatesToRetire = [];
|
|
721
|
+
const vnextMatchedItems = [];
|
|
722
|
+
let vnextPrincipalId = null;
|
|
723
|
+
const hasScopingFilters = Boolean(
|
|
724
|
+
normalizeSet(filters.kinds) || normalizeSet(filters.facets) || normalizeSet(filters.tags) || asTrimmedString(filters.subjectType) || asTrimmedString(filters.subjectId) || asTrimmedString(filters.patternKeyPrefix) || asTrimmedString(filters.sourceDialogId)
|
|
725
|
+
);
|
|
726
|
+
const canMatchVNext = !hasScopingFilters && (contentSub.length > 0 || idSet !== null && [...idSet].some((id) => id.startsWith(VNEXT_STATE_ID_PREFIX)));
|
|
727
|
+
if (canMatchVNext) {
|
|
728
|
+
vnextPrincipalId = `${owner.ownerType}:${encodeURIComponent(owner.ownerId)}`;
|
|
729
|
+
const catalog = await loadMemoryVNextCatalog(db, vnextPrincipalId);
|
|
730
|
+
for (const state of catalog.states) {
|
|
731
|
+
if (matchedItems.length >= limit) break;
|
|
732
|
+
if (state.retiredAt) continue;
|
|
733
|
+
if (!matchesVNextFilters(state, idSet, contentSub)) continue;
|
|
734
|
+
vnextStateIdsToRetire.push(state.id);
|
|
735
|
+
vnextStatesToRetire.push(state);
|
|
736
|
+
const projected = toVNextMemoryItem(state, owner);
|
|
737
|
+
vnextMatchedItems.push(projected);
|
|
738
|
+
matchedItems.push(projected);
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
if (matchedItems.length === 0) {
|
|
742
|
+
return { deletedCount: 0, deletedIds: [], retiredIds: [], matchedItems: [] };
|
|
743
|
+
}
|
|
744
|
+
const token = generateMemoryDeletionToken(
|
|
745
|
+
owner.ownerId,
|
|
746
|
+
matchedItems.map((i) => i.id)
|
|
747
|
+
);
|
|
748
|
+
if (filters.dryRun) {
|
|
749
|
+
return {
|
|
750
|
+
deletedCount: 0,
|
|
751
|
+
deletedIds: [],
|
|
752
|
+
retiredIds: [],
|
|
753
|
+
matchedItems,
|
|
754
|
+
deletionToken: token
|
|
755
|
+
};
|
|
756
|
+
}
|
|
757
|
+
if (filters.deletionToken && filters.deletionToken !== token) {
|
|
758
|
+
throw new Error(
|
|
759
|
+
"deletionToken mismatch: target set differs from preview; preview exact intended targets again."
|
|
760
|
+
);
|
|
761
|
+
}
|
|
762
|
+
const vnextMatchedIdSet = new Set(
|
|
763
|
+
vnextStateIdsToRetire.map((stateId) => `${VNEXT_STATE_ID_PREFIX}${stateId}`)
|
|
764
|
+
);
|
|
765
|
+
const legacyItems = matchedItems.filter((item) => !vnextMatchedIdSet.has(item.id));
|
|
766
|
+
const shouldRetireVNext = vnextStatesToRetire.length > 0;
|
|
767
|
+
if (legacyItems.length > 0 || shouldRetireVNext) {
|
|
768
|
+
const batch = db.batch();
|
|
769
|
+
for (const item of legacyItems) {
|
|
770
|
+
deleteMemoryItemWithIndexesInBatch(batch, item);
|
|
771
|
+
}
|
|
772
|
+
if (shouldRetireVNext) {
|
|
773
|
+
const nowIso = (/* @__PURE__ */ new Date()).toISOString();
|
|
774
|
+
for (const state of vnextStatesToRetire) {
|
|
775
|
+
_appendRetiredStateBatch(batch, { ...state, retiredAt: nowIso });
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
await batch.write();
|
|
779
|
+
}
|
|
780
|
+
return {
|
|
781
|
+
deletedCount: matchedItems.length,
|
|
782
|
+
deletedIds: matchedItems.map((item) => item.id),
|
|
783
|
+
retiredIds: vnextMatchedItems.map((item) => item.id),
|
|
784
|
+
matchedItems,
|
|
785
|
+
deletionToken: token
|
|
786
|
+
};
|
|
787
|
+
};
|
|
788
|
+
|
|
789
|
+
// packages/cli/client/memoryRekey.ts
|
|
790
|
+
async function scanLocalMemoryItems(localDb, machineId) {
|
|
791
|
+
const range = memoryOwnerRange("user", machineId);
|
|
792
|
+
const refs = [];
|
|
793
|
+
for await (const [, value] of localDb.iterator({
|
|
794
|
+
gte: range.start,
|
|
795
|
+
lte: range.end,
|
|
796
|
+
reverse: true
|
|
797
|
+
})) {
|
|
798
|
+
refs.push(value ?? {});
|
|
799
|
+
}
|
|
800
|
+
const items = await Promise.all(
|
|
801
|
+
refs.map(
|
|
802
|
+
(ref) => typeof ref?.memoryId === "string" ? localDb.get(createMemoryKey("user", machineId, ref.memoryId)).catch(() => null) : Promise.resolve(null)
|
|
803
|
+
)
|
|
804
|
+
);
|
|
805
|
+
return items.filter((item) => !!item);
|
|
806
|
+
}
|
|
807
|
+
async function performLocalMemoryRekey(args) {
|
|
808
|
+
const { localDb, authToken, serverUrl, machineId } = args;
|
|
809
|
+
const fetchImpl = args.fetchImpl ?? fetch;
|
|
810
|
+
const items = await scanLocalMemoryItems(localDb, machineId);
|
|
811
|
+
if (items.length === 0) {
|
|
812
|
+
return { migrated: 0, merged: 0 };
|
|
813
|
+
}
|
|
814
|
+
const snapshotIds = items.map((item) => item.id);
|
|
815
|
+
const response = await fetchImpl(`${serverUrl}/api/memory/rekey`, {
|
|
816
|
+
method: "POST",
|
|
817
|
+
headers: {
|
|
818
|
+
Authorization: `Bearer ${authToken}`,
|
|
819
|
+
"Content-Type": "application/json"
|
|
820
|
+
},
|
|
821
|
+
body: JSON.stringify({ items }),
|
|
822
|
+
signal: AbortSignal?.timeout?.(3e4)
|
|
823
|
+
}).catch((e) => {
|
|
824
|
+
if (e?.name === "TimeoutError" || e?.name === "AbortError") {
|
|
825
|
+
throw new Error("memory rekey upload timed out (30s)");
|
|
826
|
+
}
|
|
827
|
+
throw e;
|
|
828
|
+
});
|
|
829
|
+
if (!response.ok) {
|
|
830
|
+
let detail = "";
|
|
831
|
+
try {
|
|
832
|
+
const body2 = await response.json();
|
|
833
|
+
detail = body2?.error?.message ?? "";
|
|
834
|
+
} catch {
|
|
835
|
+
}
|
|
836
|
+
throw new Error(
|
|
837
|
+
`memory rekey upload failed (HTTP ${response.status})${detail ? `: ${detail}` : ""}`
|
|
838
|
+
);
|
|
839
|
+
}
|
|
840
|
+
const body = await response.json().catch(() => ({}));
|
|
841
|
+
const migrated = typeof body?.migratedCount === "number" ? body.migratedCount : 0;
|
|
842
|
+
const merged = typeof body?.mergedCount === "number" ? body.mergedCount : 0;
|
|
843
|
+
await deleteMemoriesForOwnerFromDb(
|
|
844
|
+
localDb,
|
|
845
|
+
{ ownerType: "user", ownerId: machineId },
|
|
846
|
+
{ ids: snapshotIds }
|
|
847
|
+
);
|
|
848
|
+
return { migrated, merged };
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
// packages/cli/authCommands.ts
|
|
852
|
+
var LOGIN_HELP_TEXT = `Log in to Nolo and save a local profile.
|
|
853
|
+
|
|
854
|
+
Usage:
|
|
855
|
+
nolo login [--server <url>] [--no-browser] [--token <jwt>] [--manual]
|
|
856
|
+
|
|
857
|
+
Options:
|
|
858
|
+
--server <url> Nolo server URL (default: ${DEFAULT_NOLO_SERVER_URL})
|
|
859
|
+
--no-browser Print the authorization URL instead of opening a browser
|
|
860
|
+
--token <jwt> Save a token directly without browser authorization
|
|
861
|
+
--manual Prompt to paste a token interactively
|
|
862
|
+
|
|
863
|
+
By default, opens the Nolo website and polls until authorization completes.
|
|
864
|
+
In SSH sessions, use --no-browser and open the printed URL on a machine with a browser
|
|
865
|
+
where you are already logged into Nolo.
|
|
866
|
+
|
|
867
|
+
Note: nolo login only authorizes your Nolo platform account. To let your agents
|
|
868
|
+
call third-party models using your own subscriptions, you also need:
|
|
869
|
+
nolo auth antigravity # Google Antigravity (Gemini 3, Claude, GPT-OSS)
|
|
870
|
+
nolo auth claude # Claude Pro/Max
|
|
871
|
+
nolo auth chatgpt # ChatGPT Plus / OpenAI Codex
|
|
872
|
+
nolo auth xai # xAI Grok (SuperGrok)
|
|
873
|
+
nolo auth cloudflare # Cloudflare OAuth (email routing, etc.)
|
|
874
|
+
See "nolo auth <provider> --help" for details.
|
|
875
|
+
`;
|
|
876
|
+
var LOGOUT_HELP_TEXT = `Log out of Nolo by clearing the saved auth token.
|
|
877
|
+
|
|
878
|
+
Usage:
|
|
879
|
+
nolo logout
|
|
880
|
+
|
|
881
|
+
Keeps other profile settings such as server URL and default agent preferences.
|
|
882
|
+
Does not unset AUTH_TOKEN or other auth-related environment variables.
|
|
883
|
+
`;
|
|
884
|
+
var WHOAMI_HELP_TEXT = `Show the current login state.
|
|
885
|
+
|
|
886
|
+
Usage:
|
|
887
|
+
nolo whoami
|
|
888
|
+
`;
|
|
889
|
+
function wantsHelp(args) {
|
|
890
|
+
return args.includes("--help") || args.includes("-h");
|
|
891
|
+
}
|
|
892
|
+
function formatDuration(ms) {
|
|
893
|
+
const totalSec = Math.max(0, Math.ceil(ms / 1e3));
|
|
894
|
+
const minutes = Math.floor(totalSec / 60);
|
|
895
|
+
const seconds = totalSec % 60;
|
|
896
|
+
if (minutes > 0) return `${minutes}m ${seconds}s`;
|
|
897
|
+
return `${seconds}s`;
|
|
898
|
+
}
|
|
899
|
+
function formatTokenPreview(token) {
|
|
900
|
+
const trimmed = token.trim();
|
|
901
|
+
if (!trimmed) return "";
|
|
902
|
+
return `${trimmed.slice(0, 8)}...`;
|
|
903
|
+
}
|
|
904
|
+
function getArg(args, flag) {
|
|
905
|
+
const index = args.indexOf(flag);
|
|
906
|
+
return index >= 0 ? args[index + 1] : void 0;
|
|
907
|
+
}
|
|
908
|
+
var defaultSleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
909
|
+
var defaultOpenBrowser = async (url) => {
|
|
910
|
+
const command = process.platform === "darwin" ? "open" : process.platform === "win32" ? "cmd" : "xdg-open";
|
|
911
|
+
const args = process.platform === "win32" ? ["/c", "start", "", url.replace(/&/g, "^&")] : [url];
|
|
912
|
+
try {
|
|
913
|
+
const child = spawn(command, args, {
|
|
914
|
+
detached: true,
|
|
915
|
+
stdio: "ignore"
|
|
916
|
+
});
|
|
917
|
+
child.unref();
|
|
918
|
+
return true;
|
|
919
|
+
} catch {
|
|
920
|
+
return false;
|
|
921
|
+
}
|
|
922
|
+
};
|
|
923
|
+
async function saveTokenLogin(args) {
|
|
924
|
+
if (!args.authToken.trim()) {
|
|
925
|
+
args.error.error("No auth token provided.");
|
|
926
|
+
return 1;
|
|
927
|
+
}
|
|
928
|
+
saveDefaultProfile(args.configPath, {
|
|
929
|
+
serverUrl: args.serverUrl,
|
|
930
|
+
authToken: args.authToken.trim()
|
|
931
|
+
});
|
|
932
|
+
args.output.log(`Saved profile default -> ${args.serverUrl}`);
|
|
933
|
+
try {
|
|
934
|
+
const localDb = await getDefaultCliLocalRuntimeDb();
|
|
935
|
+
const machineId = resolveMachineId();
|
|
936
|
+
const result = await performLocalMemoryRekey({
|
|
937
|
+
localDb,
|
|
938
|
+
authToken: args.authToken.trim(),
|
|
939
|
+
serverUrl: args.serverUrl,
|
|
940
|
+
machineId
|
|
941
|
+
});
|
|
942
|
+
if (result.migrated > 0 || result.merged > 0) {
|
|
943
|
+
args.output.log(
|
|
944
|
+
`[nolo] Migrated ${result.migrated} local memor${result.migrated === 1 ? "y" : "ies"} to your account` + (result.merged > 0 ? ` (${result.merged} merged with existing)` : "") + "."
|
|
945
|
+
);
|
|
946
|
+
}
|
|
947
|
+
} catch (error) {
|
|
948
|
+
args.error.error(
|
|
949
|
+
`[nolo] Local memory migration skipped: ${error instanceof Error ? error.message : String(error)}`
|
|
950
|
+
);
|
|
951
|
+
}
|
|
952
|
+
return 0;
|
|
953
|
+
}
|
|
954
|
+
async function runWebLogin(args) {
|
|
955
|
+
try {
|
|
956
|
+
const protocol = createDeviceAuthorizationProtocol({ origin: args.serverUrl, fetch: args.fetchImpl, now: args.now, sleep: args.sleep });
|
|
957
|
+
const start = await protocol.start("nolo-cli");
|
|
958
|
+
args.output.log("Open this URL to authorize nolo-cli:");
|
|
959
|
+
args.output.log(start.verificationUriComplete);
|
|
960
|
+
args.output.log(`Code: ${start.userCode}`);
|
|
961
|
+
if (!args.noBrowser) {
|
|
962
|
+
const opened = await protocol.run(() => Promise.resolve(args.openBrowser(start.verificationUriComplete)), 15e3);
|
|
963
|
+
if (!opened) {
|
|
964
|
+
args.output.log("Could not open a browser automatically. Paste the URL above.");
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
const deadline = protocol.deadline;
|
|
968
|
+
const timeoutMs = deadline - args.now();
|
|
969
|
+
const statusLogIntervalMs = 15e3;
|
|
970
|
+
let lastStatusLogAt = 0;
|
|
971
|
+
args.output.log(
|
|
972
|
+
`[nolo] Waiting for browser authorization (${formatDuration(timeoutMs)} remaining)...`
|
|
973
|
+
);
|
|
974
|
+
while (args.now() <= deadline) {
|
|
975
|
+
const poll = await protocol.poll(start.deviceCode);
|
|
976
|
+
if (poll.status === "pending") {
|
|
977
|
+
const currentTime = args.now();
|
|
978
|
+
if (lastStatusLogAt > 0 && currentTime - lastStatusLogAt >= statusLogIntervalMs) {
|
|
979
|
+
const remainingMs = Math.max(0, deadline - currentTime);
|
|
980
|
+
args.output.log(
|
|
981
|
+
`[nolo] Still waiting... (${formatDuration(remainingMs)} remaining)`
|
|
982
|
+
);
|
|
983
|
+
lastStatusLogAt = currentTime;
|
|
984
|
+
} else if (lastStatusLogAt === 0) {
|
|
985
|
+
lastStatusLogAt = currentTime;
|
|
986
|
+
}
|
|
987
|
+
await protocol.wait(start.interval);
|
|
988
|
+
continue;
|
|
989
|
+
}
|
|
990
|
+
if (poll.status === "approved") {
|
|
991
|
+
const approvedServer = poll.serverUrl;
|
|
992
|
+
protocol.check();
|
|
993
|
+
return saveTokenLogin({
|
|
994
|
+
configPath: args.configPath,
|
|
995
|
+
serverUrl: approvedServer,
|
|
996
|
+
authToken: poll.token,
|
|
997
|
+
output: args.output,
|
|
998
|
+
error: args.error
|
|
999
|
+
});
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
args.error.error("Web login timed out. Run `nolo login` again or use --token.");
|
|
1003
|
+
return 1;
|
|
1004
|
+
} catch (error) {
|
|
1005
|
+
args.error.error(error instanceof Error && error.message === "expired" ? "Web login timed out. Run `nolo login` again or use --token." : `Web login failed: ${error instanceof Error ? error.message : "authorization_failed"}. Use --token to paste a token manually.`);
|
|
1006
|
+
return 1;
|
|
1007
|
+
}
|
|
1008
|
+
}
|
|
1009
|
+
async function runLoginCommand(args, deps = {}) {
|
|
1010
|
+
const outputTarget = deps.output ?? console;
|
|
1011
|
+
const errorTarget = deps.error ?? console;
|
|
1012
|
+
if (wantsHelp(args)) {
|
|
1013
|
+
outputTarget.log(LOGIN_HELP_TEXT);
|
|
1014
|
+
return 0;
|
|
1015
|
+
}
|
|
1016
|
+
const configPath = deps.configPath ?? getDefaultProfileConfigPath();
|
|
1017
|
+
const serverArg = getArg(args, "--server");
|
|
1018
|
+
const tokenArg = getArg(args, "--token");
|
|
1019
|
+
const noBrowser = args.includes("--no-browser");
|
|
1020
|
+
const serverUrl = (serverArg || DEFAULT_NOLO_SERVER_URL).replace(/\/+$/, "");
|
|
1021
|
+
if (tokenArg) {
|
|
1022
|
+
return saveTokenLogin({
|
|
1023
|
+
configPath,
|
|
1024
|
+
serverUrl,
|
|
1025
|
+
authToken: tokenArg,
|
|
1026
|
+
output: outputTarget,
|
|
1027
|
+
error: errorTarget
|
|
1028
|
+
});
|
|
1029
|
+
}
|
|
1030
|
+
if (args.includes("--manual")) {
|
|
1031
|
+
const rl = createInterface({ input, output });
|
|
1032
|
+
const question = deps.question ?? ((prompt) => rl.question(prompt));
|
|
1033
|
+
try {
|
|
1034
|
+
const authToken = await question("paste auth token: ");
|
|
1035
|
+
return saveTokenLogin({
|
|
1036
|
+
configPath,
|
|
1037
|
+
serverUrl,
|
|
1038
|
+
authToken,
|
|
1039
|
+
output: outputTarget,
|
|
1040
|
+
error: errorTarget
|
|
1041
|
+
});
|
|
1042
|
+
} finally {
|
|
1043
|
+
rl.close();
|
|
1044
|
+
}
|
|
1045
|
+
}
|
|
1046
|
+
return runWebLogin({
|
|
1047
|
+
configPath,
|
|
1048
|
+
serverUrl,
|
|
1049
|
+
fetchImpl: deps.fetchImpl ?? fetch,
|
|
1050
|
+
openBrowser: deps.openBrowser ?? defaultOpenBrowser,
|
|
1051
|
+
sleep: deps.sleep ?? defaultSleep,
|
|
1052
|
+
now: deps.now ?? Date.now,
|
|
1053
|
+
output: outputTarget,
|
|
1054
|
+
error: errorTarget,
|
|
1055
|
+
noBrowser
|
|
1056
|
+
});
|
|
1057
|
+
}
|
|
1058
|
+
function runWhoamiCommand(deps = {}) {
|
|
1059
|
+
const output2 = deps.output ?? console;
|
|
1060
|
+
if (wantsHelp(deps.args ?? [])) {
|
|
1061
|
+
output2.log(WHOAMI_HELP_TEXT);
|
|
1062
|
+
return 0;
|
|
1063
|
+
}
|
|
1064
|
+
const env = deps.env ?? process.env;
|
|
1065
|
+
const config = loadProfileConfig(deps.configPath);
|
|
1066
|
+
const profile = getCurrentProfile(config);
|
|
1067
|
+
const profileToken = getProfileTokens(config)[0]?.trim() ?? "";
|
|
1068
|
+
const envToken = resolveAuthTokenFromEnv(env);
|
|
1069
|
+
if (!profileToken && !envToken) {
|
|
1070
|
+
output2.log("Not logged in. Run: nolo login");
|
|
1071
|
+
output2.log(
|
|
1072
|
+
'Or skip login entirely: nolo run "<task>" (local Codex) | nolo auth <provider> (your own subscription)'
|
|
1073
|
+
);
|
|
1074
|
+
return 1;
|
|
1075
|
+
}
|
|
1076
|
+
const runtimeEnv = buildCliRuntimeEnv(env, config);
|
|
1077
|
+
const explicitServer = env.NOLO_SERVER || env.NOLO_SERVER_URL || env.BASE_URL;
|
|
1078
|
+
if (!profileToken && envToken) {
|
|
1079
|
+
output2.log("profile: not logged in (no saved token)");
|
|
1080
|
+
if (profile?.serverUrl) {
|
|
1081
|
+
output2.log(`profile server: ${profile.serverUrl}`);
|
|
1082
|
+
}
|
|
1083
|
+
output2.log(`effective server: ${runtimeEnv.NOLO_SERVER ?? resolveServerUrlFallback(profile)}`);
|
|
1084
|
+
output2.log(`server source: ${explicitServer ? "env" : profile?.serverUrl ? "profile" : "default"}`);
|
|
1085
|
+
output2.log(`env token: ${formatTokenPreview(envToken)} (source: environment)`);
|
|
1086
|
+
return 0;
|
|
1087
|
+
}
|
|
1088
|
+
const effectiveServer = runtimeEnv.NOLO_SERVER ?? profile.serverUrl;
|
|
1089
|
+
const effectiveToken = runtimeEnv.AUTH_TOKEN ?? profileToken;
|
|
1090
|
+
output2.log(`profile: ${config.currentProfile}`);
|
|
1091
|
+
output2.log(`profile server: ${profile.serverUrl}`);
|
|
1092
|
+
output2.log(`effective server: ${effectiveServer}`);
|
|
1093
|
+
output2.log(`server source: ${explicitServer ? "env" : "profile"}`);
|
|
1094
|
+
output2.log(`token: ${formatTokenPreview(effectiveToken)} (source: ${envToken && envToken !== profileToken ? "environment" : "profile"})`);
|
|
1095
|
+
if (envToken && envToken !== profileToken) {
|
|
1096
|
+
output2.log(`profile token: ${formatTokenPreview(profileToken)} (source: profile, overridden by environment)`);
|
|
1097
|
+
}
|
|
1098
|
+
return 0;
|
|
1099
|
+
}
|
|
1100
|
+
function resolveServerUrlFallback(profile) {
|
|
1101
|
+
return profile?.serverUrl ?? DEFAULT_NOLO_SERVER_URL;
|
|
1102
|
+
}
|
|
1103
|
+
function runLogoutCommand(deps = {}) {
|
|
1104
|
+
const output2 = deps.output ?? console;
|
|
1105
|
+
if (wantsHelp(deps.args ?? [])) {
|
|
1106
|
+
output2.log(LOGOUT_HELP_TEXT);
|
|
1107
|
+
return 0;
|
|
1108
|
+
}
|
|
1109
|
+
const env = deps.env ?? process.env;
|
|
1110
|
+
const configPath = deps.configPath ?? getDefaultProfileConfigPath();
|
|
1111
|
+
if (!clearProfileAuthToken(configPath)) {
|
|
1112
|
+
output2.log("Not logged in.");
|
|
1113
|
+
return 0;
|
|
1114
|
+
}
|
|
1115
|
+
output2.log("Logged out.");
|
|
1116
|
+
if (resolveAuthTokenFromEnv(env)) {
|
|
1117
|
+
output2.log(
|
|
1118
|
+
"Note: AUTH_TOKEN in the environment is unchanged and may still authenticate commands."
|
|
1119
|
+
);
|
|
1120
|
+
}
|
|
1121
|
+
return 0;
|
|
1122
|
+
}
|
|
1123
|
+
|
|
1124
|
+
export {
|
|
1125
|
+
parseUserToken,
|
|
1126
|
+
parseStoredTokenEntries,
|
|
1127
|
+
createAccountSessionCore,
|
|
1128
|
+
createDeviceAuthorizationProtocol,
|
|
1129
|
+
LOGIN_HELP_TEXT,
|
|
1130
|
+
LOGOUT_HELP_TEXT,
|
|
1131
|
+
WHOAMI_HELP_TEXT,
|
|
1132
|
+
defaultOpenBrowser,
|
|
1133
|
+
saveTokenLogin,
|
|
1134
|
+
runLoginCommand,
|
|
1135
|
+
runWhoamiCommand,
|
|
1136
|
+
runLogoutCommand
|
|
1137
|
+
};
|