nolo-cli 0.227.0-alpha.1 → 0.227.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 -5
- package/{_executeModel-JKQGZ3HU.js → _executeModel-CXOFYVHC.js} +93 -87
- package/{action-CK64LS6S.js → action-R2EIXR7I.js} +11 -8
- package/{addContentAction-CARFID6E.js → addContentAction-W6JVLQ6H.js} +17 -16
- package/{addDialogAgentAction-APLZLFW5.js → addDialogAgentAction-LVNKMXKZ.js} +20 -19
- package/{agentDeleteCommand-NVR2V2HH.js → agentDeleteCommand-VFSZPEQ5.js} +145 -137
- package/{agentEmailCommands-UCVOWD3S.js → agentEmailCommands-KRUIF4EH.js} +149 -137
- package/{agentFavoriteCommands-4PDOP3GW.js → agentFavoriteCommands-7LOP3HUD.js} +6 -6
- package/{agentGrantCommands-FLCEXLUH.js → agentGrantCommands-L6O2HVJI.js} +7 -7
- package/agentListCommands-TDFOLWN3.js +644 -0
- package/{agentMachineCommands-V3DGEJU4.js → agentMachineCommands-PSH7Q5PF.js} +76 -67
- package/{agentProviderCommands-7QBFRFRK.js → agentProviderCommands-C5T7C5KZ.js} +7 -7
- package/{agentPullCommand-E6JBGBVG.js → agentPullCommand-QQQZSC6S.js} +7 -7
- package/agentRecordCommands-KCKCW2QU.js +188 -0
- package/agentRunCommand-EF2T2QWD.js +223 -0
- package/{agentRunControl-SNZZ5XP4.js → agentRunControl-CSMSJFFB.js} +25 -17
- package/{agentRuntimeLocal-GOX2DIY7.js → agentRuntimeLocal-6QXQS3TS.js} +64 -50
- package/{agentSlice-N7H2FRJA.js → agentSlice-IZ5ANAF7.js} +19 -18
- package/{appDeleteCommands-LZDN26FU.js → appDeleteCommands-4M7ETEEG.js} +68 -59
- package/{appDeployCommands-6IO6TTZH.js → appDeployCommands-2VJ2NDW5.js} +68 -59
- package/{appDeployStatusCommands-FG3LX24J.js → appDeployStatusCommands-LDFSWOPQ.js} +68 -59
- package/{appGetCommands-NAKVDVD4.js → appGetCommands-RHVNOPT4.js} +68 -59
- package/{appListCommands-KL56RN73.js → appListCommands-U3XEVTL4.js} +68 -59
- package/{authCommand-AUN5MXV2.js → authCommand-PVZ45QRO.js} +36 -31
- package/{authCommands-D2IPS6ES.js → authCommands-6AUYO65N.js} +18 -13
- package/{builtinSkillRegistry-UQGLKRYP.js → builtinSkillRegistry-LRVAQCPW.js} +6 -6
- package/{chromeCommands-G5UDKVSV.js → chromeCommands-S7AW3AOD.js} +383 -6
- package/{chromeOpsCommands-UJWN5HWH.js → chromeOpsCommands-TBPM6MR4.js} +8 -8
- package/{chunk-ABGULE7H.js → chunk-22YUCKMK.js} +16 -16
- package/{chunk-P2ZLUIW2.js → chunk-2BSLGODA.js} +350 -25
- package/{chunk-GOLPOTG5.js → chunk-2COM7SAH.js} +4 -4
- package/{chunk-ULAQPRHX.js → chunk-2FK2KZSL.js} +1 -1
- package/{chunk-PLPLH2XZ.js → chunk-2IPR4PBB.js} +2 -2
- package/chunk-2SXN7LAY.js +15 -0
- package/{chunk-XI2BWJM5.js → chunk-324FWHUA.js} +20 -3
- package/{chunk-7Z3WUZ4Q.js → chunk-3YYFU6H7.js} +74 -46
- package/{chunk-C2B7M567.js → chunk-4OXPN3WC.js} +17 -6
- package/chunk-4TVOZGOS.js +62 -0
- package/chunk-4ZCTKB27.js +31 -0
- package/chunk-53AEDFBL.js +33394 -0
- package/chunk-53W5BXLN.js +340 -0
- package/{chunk-OXA5GWHU.js → chunk-56O2J2Y4.js} +3 -3
- package/{chunk-IAJJYHIB.js → chunk-56PB7FEN.js} +8 -8
- package/{chunk-JWXITTQB.js → chunk-5HUO7SEX.js} +9 -107
- package/{chunk-AGP3YSEC.js → chunk-5PASH2MB.js} +46 -1
- package/{chunk-PHOSZT3E.js → chunk-5UAKGCQG.js} +1 -1
- package/{chunk-5RKRXQ2H.js → chunk-5VVP7DW3.js} +20 -13
- package/chunk-6ASGEP5D.js +21 -0
- package/chunk-6PXFEPHL.js +103 -0
- package/chunk-6RSNVJGO.js +279 -0
- package/{chunk-YGMBIXCF.js → chunk-6XRPBZRS.js} +4 -2
- package/{chunk-KMRKZNGT.js → chunk-6YYTTLJV.js} +14 -13
- package/{chunk-VREDDN25.js → chunk-76HAJUOJ.js} +14 -9
- package/{chunk-FKEZOMIF.js → chunk-7DXFOL5B.js} +1410 -768
- package/{chunk-LA7JYAKF.js → chunk-AKPKOI5Z.js} +6 -6
- package/{chunk-PWTNI4N7.js → chunk-ANUP75N2.js} +22 -0
- package/{chunk-F5AY2UZL.js → chunk-AO6T7U62.js} +592 -68
- package/{chunk-LJSNEV7M.js → chunk-AS6L5KSD.js} +8 -8
- package/{chunk-GOQ6ZVTN.js → chunk-AVSZ6PBM.js} +5 -5
- package/chunk-BIDSIRTS.js +307 -0
- package/chunk-C5A54QS7.js +108 -0
- package/{chunk-KYH7XW3K.js → chunk-CD2DK5JA.js} +135 -14
- package/{chunk-G6HJUMST.js → chunk-CJQBWHNM.js} +2 -2
- package/{chunk-EVGU5P4U.js → chunk-CO6E7YK6.js} +1 -1
- package/{chunk-ZYA2YDB6.js → chunk-CT5JXREL.js} +17 -17
- package/{chunk-VPAZ6BEN.js → chunk-CTWCZKNS.js} +42 -17
- package/{chunk-4OKTPFNX.js → chunk-CX2LYFZQ.js} +107 -66
- package/{chunk-YFLVRVYK.js → chunk-DLT2DN4M.js} +1 -1
- package/{chunk-LKA64WH4.js → chunk-DMPZMYH4.js} +37 -1
- package/{chunk-KFHREHUQ.js → chunk-DXWGFL2Z.js} +89 -1
- package/{chunk-OQHIVPG4.js → chunk-E6A5NHDH.js} +4 -1
- package/{chunk-IX2BXN2K.js → chunk-EDT65EUE.js} +6 -6
- package/{chunk-VP3BINY7.js → chunk-EQZZASCD.js} +31 -1
- package/{chunk-45LZIYXB.js → chunk-ESN4WNWU.js} +3 -2
- package/{chunk-M3JEW6N6.js → chunk-F26GAEH3.js} +10 -0
- package/{chunk-CVERLOJM.js → chunk-F4XIS5DL.js} +1215 -1431
- package/chunk-FDZ2GBWO.js +166 -0
- package/chunk-FGHEF6WI.js +34 -0
- package/{chunk-CSW7IPVD.js → chunk-FMYNIAI6.js} +61 -24
- package/{chunk-VIHDJ3FK.js → chunk-FNT5VENS.js} +15 -15
- package/{chunk-PMDVQBGA.js → chunk-GAHJLSDO.js} +14 -7
- package/{chunk-GRXSJR2Z.js → chunk-GVTFSLNI.js} +112 -109
- package/{chunk-UN7HIYMH.js → chunk-GX6DITLQ.js} +1 -1
- package/{chunk-3VFYQH3I.js → chunk-HIDVLMZC.js} +203 -156
- package/{chunk-5LQDHFBN.js → chunk-IDFGIROZ.js} +20 -17
- package/{chunk-UCFPVYP7.js → chunk-IFWXH7LH.js} +1 -1
- package/{chunk-LXTC53TN.js → chunk-J45ACAOQ.js} +815 -361
- package/{chunk-S6K5F3KP.js → chunk-JP2BH4NC.js} +1 -1
- package/{chunk-X2KRQP7V.js → chunk-JV5FHHF7.js} +1 -1
- package/{chunk-6EDAMVG6.js → chunk-K26XPZRB.js} +11 -11
- package/{chunk-RU6DULV4.js → chunk-KB5RQRSJ.js} +1 -1
- package/{chunk-T43K75CK.js → chunk-KC2QVCI7.js} +24 -178
- package/chunk-KK3FCYZM.js +647 -0
- package/{chunk-XZODOEKU.js → chunk-KMDHRVS7.js} +29 -5
- package/{chunk-4JVNURX4.js → chunk-KQHEGELM.js} +68 -16
- package/{chunk-UAPNPNSG.js → chunk-KW72WVHO.js} +2085 -1046
- package/{chunk-ILHQ2AXT.js → chunk-KZAT2M2V.js} +14 -8
- package/{chunk-L42CBKBZ.js → chunk-KZKMH374.js} +3 -3
- package/{chunk-ZI5SZ3MV.js → chunk-L6BLA6BT.js} +40 -31
- package/{chunk-AK5O76CC.js → chunk-LC5CVWP2.js} +3 -3
- package/{chunk-N5Z2V73W.js → chunk-LELADM5Q.js} +1 -1
- package/chunk-LHCGKAFO.js +739 -0
- package/{chunk-YOT437BH.js → chunk-LOF2EFUE.js} +203 -123
- package/{chunk-YQETUZ5V.js → chunk-LTVEOOZL.js} +29 -16
- package/{chunk-T2BEPTAG.js → chunk-MAA42MMV.js} +272 -26
- package/{chunk-NAOO4PVX.js → chunk-MECW2HJG.js} +16 -16
- package/{chunk-5HL4KC4A.js → chunk-MEDPR36J.js} +62 -87
- package/chunk-MVOZ22RZ.js +26 -0
- package/{chunk-YPPKC6FL.js → chunk-MYYNZG2M.js} +140 -40
- package/{chunk-UVUVQVZ6.js → chunk-MZVCFV3T.js} +19 -15
- package/{chunk-CQVGR3MX.js → chunk-N7MXFYLU.js} +7 -7
- package/{chunk-IC2I373Q.js → chunk-NEG5LYK5.js} +4 -4
- package/chunk-NJJK3PDA.js +133 -0
- package/{chunk-OB6DVWPF.js → chunk-OGZE6BZG.js} +331 -99
- package/{chunk-M3Y4IBIR.js → chunk-OHUYN3YU.js} +6 -6
- package/chunk-P27E22MA.js +203 -0
- package/{chunk-SFTTXGPM.js → chunk-PDAXMBLW.js} +35 -28
- package/{chunk-OBSEKCVK.js → chunk-PQ63BDV3.js} +210 -51
- package/{chunk-EUCFKKDM.js → chunk-PVFYPUIM.js} +40 -10
- package/{chunk-SRG5CNLC.js → chunk-QIVE5WJE.js} +8 -8
- package/{chunk-HOCHUZQ7.js → chunk-QJTZ76CP.js} +24 -6
- package/{chunk-5RKUPJYL.js → chunk-QLUYDJST.js} +11 -3
- package/{chunk-7Z6EW7AH.js → chunk-QOURTDZL.js} +97 -11
- package/{chunk-VZW34YUL.js → chunk-QWSH3UAQ.js} +8 -5
- package/{chunk-MK2Q7ZJD.js → chunk-R7XWZDOH.js} +58 -24
- package/{chunk-5FUN7EG4.js → chunk-RD3QLZQV.js} +83 -47
- package/{chunk-SW6OD4KE.js → chunk-RDPAIR67.js} +351 -18
- package/{chunk-NO3VBWTL.js → chunk-RXTZB2DH.js} +4 -4
- package/{chunk-AXYH4734.js → chunk-S25VJYXV.js} +21 -15
- package/{chunk-MWHOH4RJ.js → chunk-SESKIWB4.js} +6 -6
- package/{chunk-GUVXQSFZ.js → chunk-SF4GMDZO.js} +18 -108
- package/{chunk-TINJKQSO.js → chunk-SQRKAYQW.js} +25 -25
- package/chunk-SR4FE5VD.js +9 -0
- package/{chunk-3HTP4WZQ.js → chunk-SX6AWTNK.js} +46 -8
- package/{chunk-4WVJLODK.js → chunk-T23G6PXQ.js} +8 -3
- package/{chunk-CLCXHIBS.js → chunk-T4QY3HZ5.js} +1 -1
- package/{chunk-HVUDBOQG.js → chunk-TB5KTLNB.js} +9 -6
- package/{chunk-KRRE4A7D.js → chunk-TKE4OJ4B.js} +280 -56
- package/{chunk-S2NTVGA2.js → chunk-U35UUM5K.js} +2 -1
- package/{chunk-PPJYZRSQ.js → chunk-U5LOKQ2R.js} +30 -14
- package/{chunk-CKT6QUE2.js → chunk-UHW6SCVK.js} +1 -1
- package/{chunk-T5N6NHAT.js → chunk-UPOW5HTG.js} +6 -6
- package/{chunk-WJP4TH6U.js → chunk-VEVLLBFK.js} +2 -2
- package/{chunk-HGDKT2D6.js → chunk-VTHWBTRE.js} +177 -1
- package/{chunk-KJAAPGBE.js → chunk-VUHKG4KS.js} +6 -6
- package/{chunk-TOKPHZ55.js → chunk-W3HSD32M.js} +17 -10
- package/{chunk-2SKTCNWO.js → chunk-W5OJBZLZ.js} +4 -4
- package/chunk-WBSJAIZP.js +170 -0
- package/chunk-WDWZPASX.js +29 -0
- package/chunk-WFGNWWJI.js +326 -0
- package/{chunk-FIYSMXHY.js → chunk-WWTSEBDF.js} +1 -1
- package/{chunk-E2BESSAW.js → chunk-X4O7FJF5.js} +2 -0
- package/{chunk-HYKGIXNO.js → chunk-XGWRH3OF.js} +114 -29
- package/{chunk-XIEYGCN6.js → chunk-XKV53E4E.js} +460 -117
- package/{chunk-JHF6VLVL.js → chunk-XYRTC2Y3.js} +155 -170
- package/{chunk-L5I543VB.js → chunk-YGDYYFRX.js} +20 -24
- package/{chunk-ZADGPNTV.js → chunk-YHWMKGOX.js} +77 -103
- package/{chunk-6OVNSQHN.js → chunk-YLAHYLDQ.js} +5 -0
- package/chunk-Z6YTCDU4.js +24 -0
- package/{chunk-PVAWNHP5.js → chunk-ZP26NIZE.js} +647 -387
- package/{chunk-2G3YSVO6.js → chunk-ZQ6K57FJ.js} +3 -3
- package/{cliAgentConfigHelpers-QVSQYTKC.js → cliAgentConfigHelpers-37ZNEY5Y.js} +16 -16
- package/{cliAuthorityBrokerClient-XHH7MH2P.js → cliAuthorityBrokerClient-SFPC3WVK.js} +1 -1
- package/{cliEnvHelpers-D6HMC46Z.js → cliEnvHelpers-CNMP3RDX.js} +2 -2
- package/{cliExecutor-4MAX3PZL.js → cliExecutor-K6FDZTQ2.js} +3 -1
- package/cliLocalAgentRecordReader-53773JID.js +102 -0
- package/{commandRegistry-TKR6OWXP.js → commandRegistry-RJUO2VOD.js} +113 -101
- package/{contentThunks-BQWRPCTM.js → contentThunks-4EFHLUTB.js} +44 -41
- package/{cooldownCommands-FZYQOWI5.js → cooldownCommands-QL6DWGVU.js} +3 -3
- package/{createAgentAutomationAction-GFI6SJZV.js → createAgentAutomationAction-ZFFGJ7CZ.js} +44 -41
- package/{createDialogAction-MMBIHFFU.js → createDialogAction-SDUGVTPS.js} +45 -43
- package/{createPageAction-EEYUE5FB.js → createPageAction-NNM3OFLY.js} +49 -46
- package/{db-CS4ZJQKV.js → db-6NRZLEW2.js} +10 -7
- package/{dbSlice-X4Z4E4QU.js → dbSlice-5MQ3ELID.js} +16 -15
- package/{deleteFile-QOOP2UK7.js → deleteFile-VCCHS72Y.js} +12 -9
- package/{dialogCommands-OXBQ73DD.js → dialogCommands-SJK5KWXU.js} +73 -66
- package/dialogMessageRecord-OAV77LT7.js +7 -0
- package/{dialogNotifyCommand-VWS5G4OO.js → dialogNotifyCommand-PST75COP.js} +19 -19
- package/{dialogSlice-KGYIABDY.js → dialogSlice-2KLMHECR.js} +44 -41
- package/{dialogUsageCommand-FEWCN7IA.js → dialogUsageCommand-BZPKR3DW.js} +8 -8
- package/{docCreateCommands-LS32VKY3.js → docCreateCommands-K7CDL2HY.js} +66 -57
- package/{docDeleteCommands-JTYR5RPH.js → docDeleteCommands-ZEY5YCSP.js} +69 -60
- package/{docReadCommands-E5LTVKWN.js → docReadCommands-A4ROLIQG.js} +66 -57
- package/{docStore-TVS2FNER.js → docStore-A4O6YJAM.js} +19 -18
- package/{docUpdateCommands-I3J3JDZ2.js → docUpdateCommands-6HTFQY4O.js} +66 -57
- package/{fetchMessages-Q3INLN5F.js → fetchMessages-TQEUZD7H.js} +3 -3
- package/{getPricing-VNGFM4PN.js → getPricing-FCHYVRJU.js} +6 -6
- package/{handleSendMessageAction-SSON36TJ.js → handleSendMessageAction-6WEFYBUC.js} +87 -82
- package/{hostCredentialCreate-WTW4THJF.js → hostCredentialCreate-WOWCNOYM.js} +136 -123
- package/index.js +54 -16
- package/keys-RWF7UCB4.js +1 -1
- package/{lib-OT5OTXRU.js → lib-62SWPXNF.js} +3 -7
- package/{localDialogRead-V36DX2Q2.js → localDialogRead-3T2KMCRC.js} +2 -2
- package/{localRuntimeAdapter-MI2JGXSF.js → localRuntimeAdapter-7EDBDRYW.js} +147 -133
- package/{localRuntimeAuthority-IBJAT62G.js → localRuntimeAuthority-7DKIT7UH.js} +4 -2
- package/{localRuntimeDb-N7KHDXS2.js → localRuntimeDb-5WZ4RJJO.js} +1 -1
- package/{machineCommands-3LROJZDK.js → machineCommands-XRPC67LL.js} +290 -354
- package/machineWsRunDispatch-SOGFW472.js +203 -0
- package/markdownToSlate-KIYM7B3P.js +8 -0
- package/mcpLocalAuthorizeCommand-VOJARP3M.js +106 -0
- package/{memberThunks-CFEPHAND.js → memberThunks-KC3WJGL3.js} +26 -21
- package/{memoryCommands-JQMEJO7J.js → memoryCommands-BC6REPQB.js} +6 -6
- package/{models-H5NNZRLH.js → models-EP7VG6N2.js} +2 -2
- package/{overlay-THLKYIWY.js → overlay-JA3SPVUS.js} +7 -3
- package/package.json +1 -1
- package/{projectArchive-3X54XFVN.js → projectArchive-GDVPIZX2.js} +50 -47
- package/{providerPresetApply-FO36N5TX.js → providerPresetApply-4H7YP5D7.js} +9 -9
- package/{providerRegistry-U2BSFE6K.js → providerRegistry-F3UPOTIY.js} +9 -9
- package/{read-KA3L2V7O.js → read-T7VU2IMO.js} +11 -10
- package/{readDocTool-AMAZAPAW.js → readDocTool-BPQ3QJSD.js} +1 -1
- package/{readlineWorkspace-Z3YUH4SX.js → readlineWorkspace-OWQIIUGH.js} +9406 -6791
- package/rememberExplicit-CPAPONSI.js +15 -0
- package/{removeDialogAgentAction-JQOJSUM7.js → removeDialogAgentAction-FEUUVMYC.js} +23 -22
- package/{runAgentClientLoop-4FCFLMDJ.js → runAgentClientLoop-SJREK2B7.js} +107 -86
- package/{runtimeDoctorCommands-CXOCVDPU.js → runtimeDoctorCommands-XQD4MN4I.js} +19 -19
- package/{secretCommands-GGUAWAE7.js → secretCommands-LH7QTJO2.js} +3 -3
- package/{setDialogExtraReferencesAction-YXQTGXIN.js → setDialogExtraReferencesAction-JSTQJPXL.js} +19 -18
- package/{setPrimaryDialogAgentAction-YNLB66WE.js → setPrimaryDialogAgentAction-Z2BQE3IY.js} +23 -22
- package/{settingThunks-E6N7RSSS.js → settingThunks-C2YWCNYI.js} +186 -67
- package/{skillDiscovery-B5V23AXP.js → skillDiscovery-MDDKPTW3.js} +4 -3
- package/{spaceCommands-DB5DKC2J.js → spaceCommands-YRBQ52PG.js} +71 -62
- package/{store-JRVN62NM.js → store-Z53ICFL3.js} +3 -1
- package/{streamAgentChatTurn-FCBGMD4D.js → streamAgentChatTurn-NCA4BKDZ.js} +244 -185
- package/{switchDialogAgentAction-LAHLUECU.js → switchDialogAgentAction-G7XVAOGH.js} +20 -19
- package/{tableCommands-VNSXHAMG.js → tableCommands-UHEA5QNL.js} +14 -11
- package/{toolApiClient-OGQEBQVX.js → toolApiClient-N5PYW2R3.js} +8 -6
- package/{tools-6JD36D6K.js → tools-6WQVUGKV.js} +74 -70
- package/tuiRestart-3J7LRMPR.js +41 -0
- package/{tuiSummaryLlmCaller-UHZIPGAX.js → tuiSummaryLlmCaller-2J6NG53N.js} +24 -23
- package/{updateCommands-KZ54HCU5.js → updateCommands-5OYND6EF.js} +8 -6
- package/{updateDialogTitleAction-RV3EUEN3.js → updateDialogTitleAction-QCSN3RYO.js} +46 -43
- package/{usageCommand-KFVV6UL3.js → usageCommand-SK7JTEPC.js} +3 -3
- package/{usageRebuildCommand-HHFSNK46.js → usageRebuildCommand-DF3HUP6F.js} +4 -4
- package/webapi-QVV65DQF.js +2487 -0
- package/{windowsSelfUpdate-KERHIAB4.js → windowsSelfUpdate-HIYNL3VR.js} +2 -2
- package/workContext-Y3ADAPZU.js +14 -0
- package/workContextAccess-UZHDLBUR.js +11 -0
- package/workContextWriteNotice-YCSSMHN4.js +7 -0
- package/{workloadLifecycle-O2I3NZ2Q.js → workloadLifecycle-ZCSQCHG3.js} +9 -9
- package/agentListCommands-C65UESYM.js +0 -1004
- package/agentRecordCommands-6RCJS2EY.js +0 -176
- package/agentRunCommand-P3GRKXKS.js +0 -208
- package/chunk-2WZXXAQD.js +0 -57
- package/chunk-5ZMIIR23.js +0 -265
- package/chunk-62HXNQVV.js +0 -134
- package/chunk-BJF2MHJ3.js +0 -118
- package/chunk-KEPOVMF4.js +0 -91
- package/chunk-PXKF5CV4.js +0 -357
- package/chunk-WACI5I6V.js +0 -147
- package/chunk-YGILMZ7N.js +0 -81
- package/cliLocalAgentRecordReader-SPKAJYME.js +0 -90
- package/machineWsRunDispatch-BUUJRUUB.js +0 -191
- package/{accountResolver-EK2S4PWF.js → accountResolver-QETKNC7T.js} +4 -4
- package/{chunk-VXL2FZTP.js → chunk-HXER7YJF.js} +3 -3
- package/{chunk-BLVSFYQ3.js → chunk-LISC7BD4.js} +3 -3
- package/{chunk-SSGTV4FC.js → chunk-USGHJSGO.js} +5 -5
- package/{chunk-FJ23FZXF.js → chunk-VIYVRPMJ.js} +0 -0
- package/{offlineMarxistsAgentCommand-AGA2X5E4.js → offlineMarxistsAgentCommand-XVXUE6G5.js} +5 -5
|
@@ -1,31 +1,40 @@
|
|
|
1
|
+
import {
|
|
2
|
+
resolveObservedSpeed
|
|
3
|
+
} from "./chunk-AMWMV56B.js";
|
|
1
4
|
import {
|
|
2
5
|
fnv1a32Hex
|
|
3
6
|
} from "./chunk-UEILX4EV.js";
|
|
4
7
|
import {
|
|
5
8
|
compareAgentSelection,
|
|
6
9
|
resolveModelTier
|
|
7
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-LOF2EFUE.js";
|
|
8
11
|
import {
|
|
9
12
|
DEFAULT_PROVIDER_RETRY_MS,
|
|
10
13
|
isAgentUnavailableNow,
|
|
11
14
|
resolveAgentAvailability
|
|
12
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-QJTZ76CP.js";
|
|
16
|
+
import {
|
|
17
|
+
LIST_AGENTS_PAGE_BUDGET,
|
|
18
|
+
sanitizeToolOutputText,
|
|
19
|
+
scrubSecrets
|
|
20
|
+
} from "./chunk-WFGNWWJI.js";
|
|
13
21
|
import {
|
|
14
22
|
isOAuthApiKeyRef
|
|
15
23
|
} from "./chunk-UKZX3NHN.js";
|
|
16
24
|
import {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
isAntigravityOAuthAgent,
|
|
21
|
-
isSubscriptionEndpoint,
|
|
22
|
-
isSubscriptionOAuthCredential
|
|
23
|
-
} from "./chunk-VPAZ6BEN.js";
|
|
25
|
+
createKey,
|
|
26
|
+
createTokenKey
|
|
27
|
+
} from "./chunk-SYTHYBMI.js";
|
|
24
28
|
import {
|
|
25
29
|
isOwnedAgentKey,
|
|
26
30
|
ownedAgentKey,
|
|
27
31
|
publicAgentKey
|
|
28
32
|
} from "./chunk-M2EJHDJP.js";
|
|
33
|
+
import {
|
|
34
|
+
isAntigravityOAuthAgent,
|
|
35
|
+
isSubscriptionEndpoint,
|
|
36
|
+
isSubscriptionOAuthCredential
|
|
37
|
+
} from "./chunk-CTWCZKNS.js";
|
|
29
38
|
import {
|
|
30
39
|
asTrimmedLowercaseString
|
|
31
40
|
} from "./chunk-QSJ3HFEF.js";
|
|
@@ -43,7 +52,15 @@ var GPT_SOL_RE = /^(?:openai\/)?gpt-\d+(?:\.\d+)*-sol(?:-[a-z0-9]+(?:[.-][a-z0-9
|
|
|
43
52
|
var GPT_ASTRA_RE = /^(?:openai\/)?gpt-\d+(?:\.\d+)*-astra(?:-[a-z0-9]+(?:[.-][a-z0-9]+)*)?$/i;
|
|
44
53
|
var KIMI_K3_MODELS = /* @__PURE__ */ new Set([
|
|
45
54
|
"kimi-k3",
|
|
46
|
-
"moonshotai/kimi-k3"
|
|
55
|
+
"moonshotai/kimi-k3",
|
|
56
|
+
// 2026-11-18:K3 由 K3.1 Pro 接替(目录换成 kimi-k3.1-pro),旗舰档门槛保持一致 —
|
|
57
|
+
// 不因换代把 199 档位约束漏掉。
|
|
58
|
+
"kimi-k3.1-pro",
|
|
59
|
+
"moonshotai/kimi-k3.1-pro",
|
|
60
|
+
// 旧 K2.6 经 PLATFORM_MODEL_ALIASES 执行同一 K3.1 Pro 上游与计费:档位判定按
|
|
61
|
+
// 请求 id 直查,不带这一条就会出现「换个旧 id 绕过 premium 门槛」。
|
|
62
|
+
"kimi-k2.6",
|
|
63
|
+
"moonshotai/kimi-k2.6"
|
|
47
64
|
]);
|
|
48
65
|
function classifyPremiumModel(model) {
|
|
49
66
|
const normalizedModel = asTrimmedLowercaseString(model);
|
|
@@ -73,7 +90,7 @@ function isGptProModel(provider, model) {
|
|
|
73
90
|
}
|
|
74
91
|
return classifyPremiumModel(model) !== void 0;
|
|
75
92
|
}
|
|
76
|
-
var GPT_PRO_BLOCKED_MESSAGE = `GPT Pro / Kimi K3 \u7B49\u9AD8\u7EA7\u6A21\u578B\u9700\u8981\u5148\u5F00\u901A ${GPT_PRO_REQUIRED_RECHARGE_AMOUNT} \u79EF\u5206\u6863\u4F4D\u3002`;
|
|
93
|
+
var GPT_PRO_BLOCKED_MESSAGE = `GPT Pro / Kimi K3.1 Pro \u7B49\u9AD8\u7EA7\u6A21\u578B\u9700\u8981\u5148\u5F00\u901A ${GPT_PRO_REQUIRED_RECHARGE_AMOUNT} \u79EF\u5206\u6863\u4F4D\u3002`;
|
|
77
94
|
function shouldBlockForGptPro(input) {
|
|
78
95
|
if (input?.premium !== true || input?.platformPaid !== true) {
|
|
79
96
|
return { blocked: false };
|
|
@@ -350,17 +367,17 @@ function parseAgentRecordId(privateKey, explicitId) {
|
|
|
350
367
|
}
|
|
351
368
|
return null;
|
|
352
369
|
}
|
|
353
|
-
function resolveFavoriteStatus(
|
|
370
|
+
function resolveFavoriteStatus(record2, options) {
|
|
354
371
|
if (options?.isFavorite !== void 0) {
|
|
355
372
|
return {
|
|
356
373
|
isFavorite: !!options.isFavorite,
|
|
357
374
|
favoritedAt: safeTimestamp(options.favoritedAt)
|
|
358
375
|
};
|
|
359
376
|
}
|
|
360
|
-
if (
|
|
377
|
+
if (record2?.isFavorite === true) {
|
|
361
378
|
return {
|
|
362
379
|
isFavorite: true,
|
|
363
|
-
favoritedAt: safeTimestamp(
|
|
380
|
+
favoritedAt: safeTimestamp(record2?.favoritedAt)
|
|
364
381
|
};
|
|
365
382
|
}
|
|
366
383
|
const favoritesMap = options?.favoritesMap;
|
|
@@ -368,17 +385,17 @@ function resolveFavoriteStatus(record, options) {
|
|
|
368
385
|
return { isFavorite: false, favoritedAt: null };
|
|
369
386
|
}
|
|
370
387
|
const candidateKeys = [];
|
|
371
|
-
if (typeof
|
|
372
|
-
if (typeof
|
|
373
|
-
if (typeof
|
|
374
|
-
if (typeof
|
|
375
|
-
candidateKeys.push(
|
|
376
|
-
}
|
|
377
|
-
if (typeof
|
|
378
|
-
candidateKeys.push(
|
|
379
|
-
candidateKeys.push(publicAgentKey(
|
|
388
|
+
if (typeof record2?.dbKey === "string" && record2.dbKey) candidateKeys.push(record2.dbKey);
|
|
389
|
+
if (typeof record2?.privateKey === "string" && record2.privateKey) candidateKeys.push(record2.privateKey);
|
|
390
|
+
if (typeof record2?.publicKey === "string" && record2.publicKey) candidateKeys.push(record2.publicKey);
|
|
391
|
+
if (typeof record2?.verifiedAgentKey === "string" && record2.verifiedAgentKey) {
|
|
392
|
+
candidateKeys.push(record2.verifiedAgentKey);
|
|
393
|
+
}
|
|
394
|
+
if (typeof record2?.id === "string" && record2.id) {
|
|
395
|
+
candidateKeys.push(record2.id);
|
|
396
|
+
candidateKeys.push(publicAgentKey(record2.id));
|
|
380
397
|
if (options?.userId) {
|
|
381
|
-
candidateKeys.push(ownedAgentKey(options.userId,
|
|
398
|
+
candidateKeys.push(ownedAgentKey(options.userId, record2.id));
|
|
382
399
|
}
|
|
383
400
|
}
|
|
384
401
|
let matched = false;
|
|
@@ -405,55 +422,54 @@ function resolveFavoriteStatus(record, options) {
|
|
|
405
422
|
}
|
|
406
423
|
return { isFavorite: false, favoritedAt: null };
|
|
407
424
|
}
|
|
408
|
-
function isOwnedAgentRecord(
|
|
425
|
+
function isOwnedAgentRecord(record2, userId) {
|
|
409
426
|
if (!userId) return false;
|
|
410
|
-
if (typeof
|
|
427
|
+
if (typeof record2?.userId === "string" && record2.userId === userId || typeof record2?.ownerId === "string" && record2.ownerId === userId) {
|
|
411
428
|
return true;
|
|
412
429
|
}
|
|
413
|
-
return [
|
|
430
|
+
return [record2?.dbKey, record2?.privateKey].some(
|
|
414
431
|
(key) => isOwnedAgentKey(key, userId)
|
|
415
432
|
);
|
|
416
433
|
}
|
|
417
|
-
function toSafeAgentSummary(
|
|
434
|
+
function toSafeAgentSummary(record2, options) {
|
|
418
435
|
const rawId = parseAgentRecordId(
|
|
419
|
-
typeof
|
|
420
|
-
typeof
|
|
436
|
+
typeof record2?.privateKey === "string" ? record2.privateKey : record2?.dbKey,
|
|
437
|
+
typeof record2?.id === "string" ? record2.id : void 0
|
|
421
438
|
);
|
|
422
|
-
const id = rawId ?? (typeof
|
|
423
|
-
const publicRecordDenied =
|
|
424
|
-
const publicRecordConfirmed =
|
|
439
|
+
const id = rawId ?? (typeof record2?.id === "string" ? record2.id : null);
|
|
440
|
+
const publicRecordDenied = record2?.publicRecordExists === false || options?.publicRecordExists === false;
|
|
441
|
+
const publicRecordConfirmed = record2?.publicRecordExists === true || options?.publicRecordExists === true;
|
|
425
442
|
let publicKey;
|
|
426
|
-
if (typeof
|
|
427
|
-
publicKey =
|
|
443
|
+
if (typeof record2?.publicKey === "string" && record2.publicKey && !publicRecordDenied) {
|
|
444
|
+
publicKey = record2.publicKey;
|
|
428
445
|
} else if (publicRecordConfirmed && id) {
|
|
429
446
|
publicKey = publicAgentKey(id);
|
|
430
447
|
}
|
|
431
|
-
const name = typeof
|
|
432
|
-
const handle = typeof
|
|
433
|
-
const introduction = typeof
|
|
434
|
-
const model = typeof
|
|
435
|
-
const provider = typeof
|
|
436
|
-
const apiSource = typeof
|
|
437
|
-
const cliProvider = typeof
|
|
438
|
-
const tools = Array.isArray(
|
|
439
|
-
const inputPrice = typeof
|
|
440
|
-
const outputPrice = typeof
|
|
441
|
-
const
|
|
442
|
-
const
|
|
443
|
-
const
|
|
444
|
-
const
|
|
445
|
-
const
|
|
446
|
-
const
|
|
447
|
-
const rawQuota = record?.quota;
|
|
448
|
+
const name = typeof record2?.name === "string" && record2.name ? record2.name : "(unnamed)";
|
|
449
|
+
const handle = typeof record2?.handle === "string" && record2.handle ? record2.handle : null;
|
|
450
|
+
const introduction = typeof record2?.introduction === "string" && record2.introduction ? record2.introduction : typeof record2?.description === "string" && record2.description ? record2.description : null;
|
|
451
|
+
const model = typeof record2?.model === "string" && record2.model ? record2.model : null;
|
|
452
|
+
const provider = typeof record2?.provider === "string" && record2.provider ? record2.provider : typeof record2?.apiSource === "string" && record2.apiSource ? record2.apiSource : null;
|
|
453
|
+
const apiSource = typeof record2?.apiSource === "string" && record2.apiSource ? record2.apiSource : null;
|
|
454
|
+
const cliProvider = typeof record2?.cliProvider === "string" && record2.cliProvider ? record2.cliProvider : null;
|
|
455
|
+
const tools = Array.isArray(record2?.tools) ? record2.tools.filter((t) => typeof t === "string") : [];
|
|
456
|
+
const inputPrice = typeof record2?.inputPrice === "number" && Number.isFinite(record2.inputPrice) ? record2.inputPrice : null;
|
|
457
|
+
const outputPrice = typeof record2?.outputPrice === "number" && Number.isFinite(record2.outputPrice) ? record2.outputPrice : null;
|
|
458
|
+
const favStatus = resolveFavoriteStatus(record2, options);
|
|
459
|
+
const isPublic = record2?.isPublic === true || record2?.isPublicFlag === true || record2?.publicRecordExists === true;
|
|
460
|
+
const updatedAt = safeTimestamp(record2?.updatedAt ?? record2?.createdAt ?? record2?.created);
|
|
461
|
+
const nextAvailableAt = typeof record2?.nextAvailableAt === "number" && Number.isFinite(record2.nextAvailableAt) ? record2.nextAvailableAt : void 0;
|
|
462
|
+
const quotaExhaustion = record2?.quotaExhaustion && typeof record2.quotaExhaustion.observedAt === "number" && Number.isFinite(record2.quotaExhaustion.observedAt) ? { observedAt: record2.quotaExhaustion.observedAt } : void 0;
|
|
463
|
+
const rawQuota = record2?.quota;
|
|
448
464
|
const quota = rawQuota && typeof rawQuota === "object" && Array.isArray(rawQuota.windows) && typeof rawQuota.observedAt === "number" && Number.isFinite(rawQuota.observedAt) ? rawQuota : void 0;
|
|
449
465
|
const currentUserId = options?.userId;
|
|
450
|
-
const ownedKey = currentUserId ? [
|
|
466
|
+
const ownedKey = currentUserId ? [record2?.dbKey, record2?.privateKey].find(
|
|
451
467
|
(key) => isOwnedAgentKey(key, currentUserId)
|
|
452
468
|
) : void 0;
|
|
453
|
-
const isOwned = isOwnedAgentRecord(
|
|
454
|
-
const isOAuth = isOAuthApiKeyRef(
|
|
469
|
+
const isOwned = isOwnedAgentRecord(record2, currentUserId);
|
|
470
|
+
const isOAuth = isOAuthApiKeyRef(record2?.apiKeyRef);
|
|
455
471
|
const billingSource = resolveBillingSource({
|
|
456
|
-
...
|
|
472
|
+
...record2,
|
|
457
473
|
isOAuth,
|
|
458
474
|
isOwned,
|
|
459
475
|
apiSource,
|
|
@@ -465,11 +481,11 @@ function toSafeAgentSummary(record, options) {
|
|
|
465
481
|
{
|
|
466
482
|
provider,
|
|
467
483
|
apiSource,
|
|
468
|
-
customProviderUrl: typeof
|
|
484
|
+
customProviderUrl: typeof record2?.customProviderUrl === "string" ? record2.customProviderUrl : null
|
|
469
485
|
},
|
|
470
486
|
options?.now ?? Date.now()
|
|
471
487
|
);
|
|
472
|
-
const verifiedSharedKey = typeof
|
|
488
|
+
const verifiedSharedKey = typeof record2?.verifiedAgentKey === "string" && record2.verifiedAgentKey ? record2.verifiedAgentKey : void 0;
|
|
473
489
|
let agentKey;
|
|
474
490
|
if (currentUserId) {
|
|
475
491
|
if (isOwned) {
|
|
@@ -480,10 +496,10 @@ function toSafeAgentSummary(record, options) {
|
|
|
480
496
|
agentKey = verifiedSharedKey;
|
|
481
497
|
}
|
|
482
498
|
}
|
|
483
|
-
const rawCredRef = (typeof
|
|
484
|
-
const credInfo = deriveCredentialGroup(
|
|
485
|
-
const credentialGroup =
|
|
486
|
-
const credentialKind =
|
|
499
|
+
const rawCredRef = (typeof record2?.apiKeyRef === "string" && record2.apiKeyRef ? record2.apiKeyRef : void 0) ?? (typeof record2?.credentialRef === "string" && record2.credentialRef ? record2.credentialRef : void 0);
|
|
500
|
+
const credInfo = deriveCredentialGroup(record2?.credentialGroup ?? rawCredRef);
|
|
501
|
+
const credentialGroup = record2?.credentialGroup ?? credInfo?.credentialGroup;
|
|
502
|
+
const credentialKind = record2?.credentialKind ?? credInfo?.credentialKind;
|
|
487
503
|
const availability = resolveAgentAvailability(
|
|
488
504
|
{ nextAvailableAt, quota, quotaExhaustion },
|
|
489
505
|
options?.now ?? Date.now()
|
|
@@ -504,7 +520,6 @@ function toSafeAgentSummary(record, options) {
|
|
|
504
520
|
tools,
|
|
505
521
|
inputPrice,
|
|
506
522
|
outputPrice,
|
|
507
|
-
modelAbility,
|
|
508
523
|
isFavorite: favStatus.isFavorite,
|
|
509
524
|
favoritedAt: favStatus.favoritedAt,
|
|
510
525
|
isPublic,
|
|
@@ -513,7 +528,7 @@ function toSafeAgentSummary(record, options) {
|
|
|
513
528
|
// 例如 apiSource==="cli" 的本地 CLI Agent 在 resolveBillingSource 里会落到
|
|
514
529
|
// platform_credits,但 isPlatformPaidAgentCall 显式短路为「非平台垫付」。
|
|
515
530
|
requiresPaidApproval: isPlatformPaidAgentCall({
|
|
516
|
-
agentConfig:
|
|
531
|
+
agentConfig: record2 ?? void 0,
|
|
517
532
|
callerUserId: currentUserId ?? void 0
|
|
518
533
|
}),
|
|
519
534
|
...economics ? { economics } : {},
|
|
@@ -888,6 +903,7 @@ function buildAgentDiscoveryResult(options) {
|
|
|
888
903
|
...typeof limit === "number" ? { limit } : {},
|
|
889
904
|
...isTruncated ? { truncated: true } : {},
|
|
890
905
|
unavailableCount,
|
|
906
|
+
availableCount: sortedAgents.length,
|
|
891
907
|
agents: projectedAgents,
|
|
892
908
|
planningRecommendation: recommendPlanning(
|
|
893
909
|
sortedAgents,
|
|
@@ -897,9 +913,514 @@ function buildAgentDiscoveryResult(options) {
|
|
|
897
913
|
credentialGroups
|
|
898
914
|
};
|
|
899
915
|
}
|
|
900
|
-
function toDiscoverySafeAgentSummary(
|
|
901
|
-
const mergedOptions =
|
|
902
|
-
return toSafeAgentSummary(
|
|
916
|
+
function toDiscoverySafeAgentSummary(record2, options) {
|
|
917
|
+
const mergedOptions = record2?.publicRecordExists === true ? { ...options, publicRecordExists: true } : options;
|
|
918
|
+
return toSafeAgentSummary(record2, mergedOptions);
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
// packages/ai/agent/speedSampleCache.ts
|
|
922
|
+
var SPEED_SAMPLE_DISK_CACHE_TTL_MS = 10 * 6e4;
|
|
923
|
+
var SPEED_SAMPLE_SCAN_BUDGET_MS = 2500;
|
|
924
|
+
var SPEED_SAMPLE_CACHE_VERSION = 4;
|
|
925
|
+
var isFiniteNumber = (value) => typeof value === "number" && Number.isFinite(value);
|
|
926
|
+
var sanitizeSample = (value) => {
|
|
927
|
+
if (!value || typeof value !== "object") return null;
|
|
928
|
+
const sample = value;
|
|
929
|
+
const clean = {};
|
|
930
|
+
if (isFiniteNumber(sample.firstOutputMs)) clean.firstOutputMs = sample.firstOutputMs;
|
|
931
|
+
if (isFiniteNumber(sample.callDurationMs)) clean.callDurationMs = sample.callDurationMs;
|
|
932
|
+
if (isFiniteNumber(sample.output_tokens)) clean.output_tokens = sample.output_tokens;
|
|
933
|
+
if (isFiniteNumber(sample.t)) clean.t = sample.t;
|
|
934
|
+
return clean.firstOutputMs === void 0 && clean.callDurationMs === void 0 ? null : clean;
|
|
935
|
+
};
|
|
936
|
+
var SPEED_SAMPLE_STALE_SNAPSHOT_MAX_MS = 7 * 24 * 60 * 6e4;
|
|
937
|
+
async function parseCacheFile(cachePath, userId) {
|
|
938
|
+
try {
|
|
939
|
+
const fs = await import("node:fs/promises");
|
|
940
|
+
const raw = await fs.readFile(cachePath, "utf8");
|
|
941
|
+
const parsed = JSON.parse(raw);
|
|
942
|
+
if (!parsed || typeof parsed !== "object") return null;
|
|
943
|
+
const version = parsed.version;
|
|
944
|
+
if (version !== SPEED_SAMPLE_CACHE_VERSION) {
|
|
945
|
+
return null;
|
|
946
|
+
}
|
|
947
|
+
if (parsed.userId !== userId) return null;
|
|
948
|
+
if (!isFiniteNumber(parsed.at)) return null;
|
|
949
|
+
const source = parsed.samples;
|
|
950
|
+
if (!source || typeof source !== "object") return null;
|
|
951
|
+
const samples = /* @__PURE__ */ new Map();
|
|
952
|
+
for (const [model, list] of Object.entries(source)) {
|
|
953
|
+
if (!model || !Array.isArray(list)) continue;
|
|
954
|
+
const cleaned = [];
|
|
955
|
+
for (const entry of list) {
|
|
956
|
+
const sample = sanitizeSample(entry);
|
|
957
|
+
if (sample) cleaned.push(sample);
|
|
958
|
+
}
|
|
959
|
+
samples.set(model, cleaned);
|
|
960
|
+
}
|
|
961
|
+
const complete = parsed.complete === true;
|
|
962
|
+
const cursor = typeof parsed.cursor === "string" && parsed.cursor.length > 0 ? parsed.cursor : void 0;
|
|
963
|
+
return { samples, at: parsed.at, complete, cursor: complete ? void 0 : cursor };
|
|
964
|
+
} catch {
|
|
965
|
+
return null;
|
|
966
|
+
}
|
|
967
|
+
}
|
|
968
|
+
async function readSpeedSamplesSnapshot(cachePath, options) {
|
|
969
|
+
const maxAgeMs = isFiniteNumber(options.maxAgeMs) ? options.maxAgeMs : SPEED_SAMPLE_STALE_SNAPSHOT_MAX_MS;
|
|
970
|
+
const parsed = await parseCacheFile(cachePath, options.userId);
|
|
971
|
+
if (!parsed || !parsed.complete) return null;
|
|
972
|
+
const age = options.now - parsed.at;
|
|
973
|
+
if (age < 0 || age >= maxAgeMs) return null;
|
|
974
|
+
return { samples: parsed.samples, ageMs: age };
|
|
975
|
+
}
|
|
976
|
+
async function readSpeedSamplesProgress(cachePath, userId) {
|
|
977
|
+
const parsed = await parseCacheFile(cachePath, userId);
|
|
978
|
+
if (!parsed) return null;
|
|
979
|
+
return {
|
|
980
|
+
samples: parsed.samples,
|
|
981
|
+
at: parsed.at,
|
|
982
|
+
complete: parsed.complete,
|
|
983
|
+
...parsed.cursor === void 0 ? {} : { cursor: parsed.cursor }
|
|
984
|
+
};
|
|
985
|
+
}
|
|
986
|
+
function resolveSpeedSamplesProgressPath(cachePath) {
|
|
987
|
+
return `${cachePath}.progress`;
|
|
988
|
+
}
|
|
989
|
+
async function writeSpeedSamplesCache(cachePath, payload) {
|
|
990
|
+
try {
|
|
991
|
+
const fs = await import("node:fs/promises");
|
|
992
|
+
const path = await import("node:path");
|
|
993
|
+
await fs.mkdir(path.dirname(cachePath), { recursive: true });
|
|
994
|
+
const tmpPath = `${cachePath}.tmp-${process.pid}-${Math.random().toString(36).slice(2, 8)}`;
|
|
995
|
+
await fs.writeFile(tmpPath, JSON.stringify(payload), "utf8");
|
|
996
|
+
await fs.rename(tmpPath, cachePath);
|
|
997
|
+
} catch {
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
// packages/ai/agent/candidateSpeedContext.ts
|
|
1002
|
+
var OBSERVED_SPEED_WINDOW = 50;
|
|
1003
|
+
var MIN_OBSERVED_FIRST_OUTPUT_SAMPLES = 5;
|
|
1004
|
+
var SPEED_SAMPLES_CACHE_TTL_MS = 5 * 6e4;
|
|
1005
|
+
var SPEED_SAMPLES_CACHE_MAX_ENTRIES = 500;
|
|
1006
|
+
function normalizeSpeedModelName(raw) {
|
|
1007
|
+
const name = raw.trim().toLowerCase();
|
|
1008
|
+
const slash = name.lastIndexOf("/");
|
|
1009
|
+
return slash === -1 ? name : name.slice(slash + 1);
|
|
1010
|
+
}
|
|
1011
|
+
var isFiniteNumber2 = (value) => typeof value === "number" && Number.isFinite(value);
|
|
1012
|
+
var REASONING_EFFORT_SUFFIXES = ["minimal", "low", "medium", "high", "xhigh"];
|
|
1013
|
+
var REASONING_EFFORT_SUFFIX_RE = new RegExp(`-(?:${REASONING_EFFORT_SUFFIXES.join("|")})$`);
|
|
1014
|
+
function stripReasoningEffortSuffix(model) {
|
|
1015
|
+
const base = model.replace(REASONING_EFFORT_SUFFIX_RE, "");
|
|
1016
|
+
return base && base !== model ? base : null;
|
|
1017
|
+
}
|
|
1018
|
+
function resolveOneBare(model, samplesByModel) {
|
|
1019
|
+
const observed = resolveObservedSpeed(samplesByModel.get(model) ?? [], {
|
|
1020
|
+
limit: OBSERVED_SPEED_WINDOW
|
|
1021
|
+
});
|
|
1022
|
+
if (observed.firstOutputSampleCount >= MIN_OBSERVED_FIRST_OUTPUT_SAMPLES && observed.medianFirstOutputMs !== void 0) {
|
|
1023
|
+
return {
|
|
1024
|
+
source: "observed",
|
|
1025
|
+
firstOutputMs: observed.medianFirstOutputMs,
|
|
1026
|
+
...observed.medianOutputTokensPerSecond !== void 0 ? { outputTps: observed.medianOutputTokensPerSecond } : {},
|
|
1027
|
+
firstOutputSamples: observed.firstOutputSampleCount,
|
|
1028
|
+
tpsSamples: observed.throughputSampleCount
|
|
1029
|
+
};
|
|
1030
|
+
}
|
|
1031
|
+
return null;
|
|
1032
|
+
}
|
|
1033
|
+
function resolveOne(model, samplesByModel) {
|
|
1034
|
+
const direct = resolveOneBare(model, samplesByModel);
|
|
1035
|
+
if (direct) return { model, ...direct };
|
|
1036
|
+
const base = stripReasoningEffortSuffix(model);
|
|
1037
|
+
if (!base) return null;
|
|
1038
|
+
const stripped = resolveOneBare(base, samplesByModel);
|
|
1039
|
+
return stripped ? { model, ...stripped } : null;
|
|
1040
|
+
}
|
|
1041
|
+
function resolveCandidateSpeedFacts(models, samplesByModel) {
|
|
1042
|
+
const unique = [
|
|
1043
|
+
...new Set(
|
|
1044
|
+
models.filter((model) => typeof model === "string").map(normalizeSpeedModelName).filter(Boolean)
|
|
1045
|
+
)
|
|
1046
|
+
];
|
|
1047
|
+
return unique.map((model) => resolveOne(model, samplesByModel)).filter((fact) => fact !== null);
|
|
1048
|
+
}
|
|
1049
|
+
var formatSeconds = (ms) => `${(ms / 1e3).toFixed(1)}s`;
|
|
1050
|
+
var formatTps = (tps) => String(Math.round(tps));
|
|
1051
|
+
var SPEED_CONTEXT_HEADER = "speed (observed=\u672C\u7528\u6237\u5B9E\u6D4B\u8C03\u7528\u4E2D\u4F4D\u6570, firstOutput \u542B\u63A8\u7406\u8F93\u51FA; tps=generation\uFF08\u4E0D\u542B\u7AEF\u5230\u7AEF\u53E3\u5F84\uFF09, tps=n/a \u8868\u793A\u65E0\u53EF\u4FE1\u541E\u5410\u6837\u672C\u3002\u672A\u5217\u51FA\u7684 model \u8868\u793A\u6CA1\u6709\u5B9E\u6D4B\u6837\u672C\uFF0C\u4E0D\u4EE3\u8868\u6162):";
|
|
1052
|
+
function formatSnapshotAge(ageMs) {
|
|
1053
|
+
const minutes = Math.floor(ageMs / 6e4);
|
|
1054
|
+
if (minutes < 1) return "<1min";
|
|
1055
|
+
if (minutes < 60) return `${minutes}min`;
|
|
1056
|
+
const hours = Math.floor(minutes / 60);
|
|
1057
|
+
if (hours < 24) return `${hours}h`;
|
|
1058
|
+
return `${Math.floor(hours / 24)}d`;
|
|
1059
|
+
}
|
|
1060
|
+
function formatCandidateSpeedFacts(facts, options = {}) {
|
|
1061
|
+
if (facts.length === 0) return null;
|
|
1062
|
+
const lines = facts.map((fact) => {
|
|
1063
|
+
const tps = fact.outputTps !== void 0 ? formatTps(fact.outputTps) : "n/a";
|
|
1064
|
+
return ` ${fact.model}: firstOutput=${formatSeconds(fact.firstOutputMs ?? 0)} tps=${tps} [observed n=${fact.firstOutputSamples ?? 0} tpsN=${fact.tpsSamples ?? 0}]`;
|
|
1065
|
+
});
|
|
1066
|
+
const age = options.snapshotAgeMs;
|
|
1067
|
+
const note = typeof age === "number" && age > 0 ? ` (snapshot=${formatSnapshotAge(age)}\u524D\u91C7\u96C6\u7684\u5B8C\u6574\u7A97\u53E3, \u975E\u672C\u6B21\u5B9E\u65F6\u626B\u63CF)` : "";
|
|
1068
|
+
return `${SPEED_CONTEXT_HEADER}${note}
|
|
1069
|
+
${lines.join("\n")}`;
|
|
1070
|
+
}
|
|
1071
|
+
function buildCandidateSpeedContext(models, samplesByModel, options = {}) {
|
|
1072
|
+
return formatCandidateSpeedFacts(resolveCandidateSpeedFacts(models, samplesByModel), options);
|
|
1073
|
+
}
|
|
1074
|
+
var SPEED_SAMPLE_PAGE_SIZE = 2e3;
|
|
1075
|
+
var DISPATCH_ENTRY_PATH = "agent-run";
|
|
1076
|
+
var eventTime = (value) => {
|
|
1077
|
+
if (isFiniteNumber2(value.timestamp)) return value.timestamp;
|
|
1078
|
+
if (isFiniteNumber2(value.createdAt)) return value.createdAt;
|
|
1079
|
+
return 0;
|
|
1080
|
+
};
|
|
1081
|
+
function collectSample(collected, value) {
|
|
1082
|
+
if (typeof value.model !== "string") return;
|
|
1083
|
+
if (!isFiniteNumber2(value.firstOutputMs) && !isFiniteNumber2(value.callDurationMs)) return;
|
|
1084
|
+
const model = normalizeSpeedModelName(value.model);
|
|
1085
|
+
if (!model) return;
|
|
1086
|
+
const list = collected.get(model) ?? [];
|
|
1087
|
+
list.push({
|
|
1088
|
+
t: eventTime(value),
|
|
1089
|
+
firstOutputMs: value.firstOutputMs,
|
|
1090
|
+
callDurationMs: value.callDurationMs,
|
|
1091
|
+
output_tokens: value.output_tokens
|
|
1092
|
+
});
|
|
1093
|
+
collected.set(model, list);
|
|
1094
|
+
}
|
|
1095
|
+
function finalizeSamples(collected, keepTime = false) {
|
|
1096
|
+
const result = /* @__PURE__ */ new Map();
|
|
1097
|
+
for (const [model, list] of collected) {
|
|
1098
|
+
list.sort((a, b) => b.t - a.t);
|
|
1099
|
+
const window = list.slice(0, OBSERVED_SPEED_WINDOW);
|
|
1100
|
+
result.set(
|
|
1101
|
+
model,
|
|
1102
|
+
keepTime ? window : window.map(({ t: _t, ...sample }) => sample)
|
|
1103
|
+
);
|
|
1104
|
+
}
|
|
1105
|
+
return result;
|
|
1106
|
+
}
|
|
1107
|
+
async function collectRecentSpeedSamples(db, userId, options = {}) {
|
|
1108
|
+
const pageSize = isFiniteNumber2(options.pageSize) && options.pageSize > 0 ? Math.floor(options.pageSize) : SPEED_SAMPLE_PAGE_SIZE;
|
|
1109
|
+
const budgetMs = isFiniteNumber2(options.budgetMs) ? options.budgetMs : Number.POSITIVE_INFINITY;
|
|
1110
|
+
const { start, end } = createTokenKey.rangeOfUser(userId);
|
|
1111
|
+
const failedPrefix = createKey("token", userId, "failed-call", "");
|
|
1112
|
+
const dispatchRunCache = /* @__PURE__ */ new Map();
|
|
1113
|
+
const isDispatchSampleRecord = async (record2, resolver, cache) => {
|
|
1114
|
+
if (record2.entry_path !== DISPATCH_ENTRY_PATH && record2.entry_path !== "cli-local") return false;
|
|
1115
|
+
const runId = typeof record2.dialogId === "string" ? record2.dialogId.trim() : "";
|
|
1116
|
+
if (!runId) return false;
|
|
1117
|
+
const cacheKey = `${record2.entry_path}:${runId}`;
|
|
1118
|
+
const cached = cache.get(cacheKey);
|
|
1119
|
+
if (cached !== void 0) return cached;
|
|
1120
|
+
let dispatch = false;
|
|
1121
|
+
if (resolver) {
|
|
1122
|
+
try {
|
|
1123
|
+
dispatch = await resolver(runId, record2.entry_path) === true;
|
|
1124
|
+
} catch {
|
|
1125
|
+
dispatch = false;
|
|
1126
|
+
}
|
|
1127
|
+
}
|
|
1128
|
+
cache.set(cacheKey, dispatch);
|
|
1129
|
+
return dispatch;
|
|
1130
|
+
};
|
|
1131
|
+
const collected = /* @__PURE__ */ new Map();
|
|
1132
|
+
const startedAt = Date.now();
|
|
1133
|
+
let lastKey = options.startAfter;
|
|
1134
|
+
let budgetExhausted = false;
|
|
1135
|
+
let scanned = 0;
|
|
1136
|
+
while (true) {
|
|
1137
|
+
if (Date.now() - startedAt >= budgetMs) {
|
|
1138
|
+
budgetExhausted = true;
|
|
1139
|
+
break;
|
|
1140
|
+
}
|
|
1141
|
+
const pageOptions = {
|
|
1142
|
+
...lastKey === void 0 ? { gte: start } : { gt: lastKey },
|
|
1143
|
+
lte: end,
|
|
1144
|
+
limit: pageSize
|
|
1145
|
+
};
|
|
1146
|
+
let accepted = 0;
|
|
1147
|
+
let newestKey = lastKey;
|
|
1148
|
+
for await (const [key, raw] of db.iterator(pageOptions)) {
|
|
1149
|
+
if (typeof key !== "string") continue;
|
|
1150
|
+
if (lastKey !== void 0 && key <= lastKey) continue;
|
|
1151
|
+
accepted += 1;
|
|
1152
|
+
scanned += 1;
|
|
1153
|
+
newestKey = key;
|
|
1154
|
+
if (key.startsWith(failedPrefix)) continue;
|
|
1155
|
+
if (!raw || typeof raw !== "object") continue;
|
|
1156
|
+
const record2 = raw;
|
|
1157
|
+
const resolver = options.isDispatchRun ?? db.isDispatchRun;
|
|
1158
|
+
if (!await isDispatchSampleRecord(
|
|
1159
|
+
record2,
|
|
1160
|
+
resolver ? (runId, entryPath) => resolver.call(db, runId, entryPath) : void 0,
|
|
1161
|
+
dispatchRunCache
|
|
1162
|
+
))
|
|
1163
|
+
continue;
|
|
1164
|
+
collectSample(collected, record2);
|
|
1165
|
+
}
|
|
1166
|
+
if (accepted === 0 || accepted < pageSize) break;
|
|
1167
|
+
lastKey = newestKey;
|
|
1168
|
+
}
|
|
1169
|
+
return {
|
|
1170
|
+
samples: finalizeSamples(collected, options.keepTime === true),
|
|
1171
|
+
budgetExhausted,
|
|
1172
|
+
scanned,
|
|
1173
|
+
...budgetExhausted && lastKey !== void 0 ? { nextCursor: lastKey } : {}
|
|
1174
|
+
};
|
|
1175
|
+
}
|
|
1176
|
+
function mergeNewestSamples(into, from) {
|
|
1177
|
+
for (const [model, list] of from) {
|
|
1178
|
+
const merged = [...into.get(model) ?? [], ...list];
|
|
1179
|
+
merged.sort(
|
|
1180
|
+
(a, b) => (b.t ?? 0) - (a.t ?? 0)
|
|
1181
|
+
);
|
|
1182
|
+
into.set(model, merged.slice(0, OBSERVED_SPEED_WINDOW));
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
1185
|
+
async function loadSpeedSamplesWithDiskCache(db, userId, now, cache) {
|
|
1186
|
+
try {
|
|
1187
|
+
const ttlMs = isFiniteNumber2(cache.ttlMs) ? cache.ttlMs : SPEED_SAMPLE_DISK_CACHE_TTL_MS;
|
|
1188
|
+
const snapshot = await readSpeedSamplesSnapshot(cache.cachePath, { userId, now });
|
|
1189
|
+
if (snapshot && snapshot.ageMs < ttlMs) return { samples: snapshot.samples };
|
|
1190
|
+
const progressPath = resolveSpeedSamplesProgressPath(cache.cachePath);
|
|
1191
|
+
const progress = await readSpeedSamplesProgress(progressPath, userId);
|
|
1192
|
+
const resumable = progress && !progress.complete && progress.cursor ? progress : void 0;
|
|
1193
|
+
const collected = new Map(resumable?.samples ?? []);
|
|
1194
|
+
let step;
|
|
1195
|
+
try {
|
|
1196
|
+
step = await collectRecentSpeedSamples(db, userId, {
|
|
1197
|
+
pageSize: cache.pageSize,
|
|
1198
|
+
budgetMs: isFiniteNumber2(cache.budgetMs) ? cache.budgetMs : SPEED_SAMPLE_SCAN_BUDGET_MS,
|
|
1199
|
+
keepTime: true,
|
|
1200
|
+
...resumable?.cursor ? { startAfter: resumable.cursor } : {}
|
|
1201
|
+
});
|
|
1202
|
+
} catch {
|
|
1203
|
+
return snapshot ? { samples: snapshot.samples, snapshotAgeMs: snapshot.ageMs } : { samples: /* @__PURE__ */ new Map() };
|
|
1204
|
+
}
|
|
1205
|
+
if (!resumable && step.scanned === 0 && !step.budgetExhausted) {
|
|
1206
|
+
return snapshot ? { samples: snapshot.samples, snapshotAgeMs: snapshot.ageMs } : { samples: /* @__PURE__ */ new Map() };
|
|
1207
|
+
}
|
|
1208
|
+
mergeNewestSamples(collected, step.samples);
|
|
1209
|
+
if (!step.budgetExhausted) {
|
|
1210
|
+
await writeSpeedSamplesCache(cache.cachePath, {
|
|
1211
|
+
version: SPEED_SAMPLE_CACHE_VERSION,
|
|
1212
|
+
userId,
|
|
1213
|
+
at: now,
|
|
1214
|
+
complete: true,
|
|
1215
|
+
samples: Object.fromEntries(collected)
|
|
1216
|
+
});
|
|
1217
|
+
await writeSpeedSamplesCache(progressPath, {
|
|
1218
|
+
version: SPEED_SAMPLE_CACHE_VERSION,
|
|
1219
|
+
userId,
|
|
1220
|
+
at: now,
|
|
1221
|
+
complete: true,
|
|
1222
|
+
samples: {}
|
|
1223
|
+
});
|
|
1224
|
+
return { samples: collected };
|
|
1225
|
+
}
|
|
1226
|
+
await writeSpeedSamplesCache(progressPath, {
|
|
1227
|
+
version: SPEED_SAMPLE_CACHE_VERSION,
|
|
1228
|
+
userId,
|
|
1229
|
+
// Progress keeps the cycle's collection start so a later stale label stays honest.
|
|
1230
|
+
at: resumable?.at ?? now,
|
|
1231
|
+
complete: false,
|
|
1232
|
+
samples: Object.fromEntries(collected),
|
|
1233
|
+
...step.nextCursor ? { cursor: step.nextCursor } : {}
|
|
1234
|
+
});
|
|
1235
|
+
return snapshot ? { samples: snapshot.samples, snapshotAgeMs: snapshot.ageMs } : { samples: /* @__PURE__ */ new Map() };
|
|
1236
|
+
} catch {
|
|
1237
|
+
return { samples: /* @__PURE__ */ new Map() };
|
|
1238
|
+
}
|
|
1239
|
+
}
|
|
1240
|
+
var samplesCache = /* @__PURE__ */ new Map();
|
|
1241
|
+
function writeSamplesCache(userId, now, samples) {
|
|
1242
|
+
for (const [key, entry] of samplesCache) {
|
|
1243
|
+
if (now - entry.at >= SPEED_SAMPLES_CACHE_TTL_MS) samplesCache.delete(key);
|
|
1244
|
+
}
|
|
1245
|
+
samplesCache.delete(userId);
|
|
1246
|
+
samplesCache.set(userId, { at: now, samples });
|
|
1247
|
+
while (samplesCache.size > SPEED_SAMPLES_CACHE_MAX_ENTRIES) {
|
|
1248
|
+
const oldest = samplesCache.keys().next().value;
|
|
1249
|
+
if (oldest === void 0) break;
|
|
1250
|
+
samplesCache.delete(oldest);
|
|
1251
|
+
}
|
|
1252
|
+
}
|
|
1253
|
+
var SPEED_SAMPLE_REFRESH_BUDGET_MS = 6e4;
|
|
1254
|
+
var snapshotRefreshes = /* @__PURE__ */ new Map();
|
|
1255
|
+
function startSpeedSnapshotRefresh(db, userId, now = Date.now()) {
|
|
1256
|
+
const inFlight = snapshotRefreshes.get(userId);
|
|
1257
|
+
if (inFlight) return inFlight;
|
|
1258
|
+
const job = (async () => {
|
|
1259
|
+
try {
|
|
1260
|
+
const { samples, budgetExhausted } = await collectRecentSpeedSamples(db, userId, {
|
|
1261
|
+
budgetMs: SPEED_SAMPLE_REFRESH_BUDGET_MS
|
|
1262
|
+
});
|
|
1263
|
+
if (!budgetExhausted) writeSamplesCache(userId, now, samples);
|
|
1264
|
+
} catch {
|
|
1265
|
+
}
|
|
1266
|
+
})().finally(() => {
|
|
1267
|
+
snapshotRefreshes.delete(userId);
|
|
1268
|
+
});
|
|
1269
|
+
snapshotRefreshes.set(userId, job);
|
|
1270
|
+
return job;
|
|
1271
|
+
}
|
|
1272
|
+
async function loadCachedSpeedSamples(db, userId, now) {
|
|
1273
|
+
const hit = samplesCache.get(userId);
|
|
1274
|
+
if (hit) {
|
|
1275
|
+
const age = now - hit.at;
|
|
1276
|
+
if (age >= 0 && age < SPEED_SAMPLE_STALE_SNAPSHOT_MAX_MS) {
|
|
1277
|
+
if (age >= SPEED_SAMPLES_CACHE_TTL_MS) void startSpeedSnapshotRefresh(db, userId);
|
|
1278
|
+
return age >= SPEED_SAMPLES_CACHE_TTL_MS ? { samples: hit.samples, snapshotAgeMs: age } : { samples: hit.samples };
|
|
1279
|
+
}
|
|
1280
|
+
}
|
|
1281
|
+
void startSpeedSnapshotRefresh(db, userId);
|
|
1282
|
+
return { samples: /* @__PURE__ */ new Map() };
|
|
1283
|
+
}
|
|
1284
|
+
async function injectSpeedContextIntoListAgentsResult(result, options = {}) {
|
|
1285
|
+
try {
|
|
1286
|
+
let parsed;
|
|
1287
|
+
try {
|
|
1288
|
+
parsed = JSON.parse(result);
|
|
1289
|
+
} catch {
|
|
1290
|
+
return result;
|
|
1291
|
+
}
|
|
1292
|
+
if (!parsed || typeof parsed !== "object" || !Array.isArray(parsed.agents)) return result;
|
|
1293
|
+
const models = parsed.agents.map((agent) => agent?.model).filter((model) => typeof model === "string");
|
|
1294
|
+
if (models.length === 0 && !options.compactPage) return result;
|
|
1295
|
+
const now = options.now ?? Date.now();
|
|
1296
|
+
let samples = /* @__PURE__ */ new Map();
|
|
1297
|
+
let snapshotAgeMs;
|
|
1298
|
+
const userId = typeof options.userId === "string" ? options.userId.trim() : "";
|
|
1299
|
+
if (options.db && userId) {
|
|
1300
|
+
try {
|
|
1301
|
+
const loaded = options.diskCache ? await loadSpeedSamplesWithDiskCache(options.db, userId, now, options.diskCache) : await loadCachedSpeedSamples(options.db, userId, now);
|
|
1302
|
+
samples = loaded.samples;
|
|
1303
|
+
snapshotAgeMs = loaded.snapshotAgeMs;
|
|
1304
|
+
} catch {
|
|
1305
|
+
samples = /* @__PURE__ */ new Map();
|
|
1306
|
+
}
|
|
1307
|
+
}
|
|
1308
|
+
if (options.compactPage) {
|
|
1309
|
+
return await serializeCompactAgentPage(parsed, samples, snapshotAgeMs, options);
|
|
1310
|
+
}
|
|
1311
|
+
const speedContext = buildCandidateSpeedContext(models, samples, { snapshotAgeMs });
|
|
1312
|
+
return speedContext ? JSON.stringify({ ...parsed, speedContext }) : result;
|
|
1313
|
+
} catch {
|
|
1314
|
+
return options.compactPage ? JSON.stringify({ success: false, error: "LIST_AGENTS_PAGE_SERIALIZATION_FAILED" }) : result;
|
|
1315
|
+
}
|
|
1316
|
+
}
|
|
1317
|
+
async function serializeCompactAgentPage(parsed, samples, snapshotAgeMs, options) {
|
|
1318
|
+
const maxChars = LIST_AGENTS_PAGE_BUDGET;
|
|
1319
|
+
const maxBytes = LIST_AGENTS_PAGE_BUDGET;
|
|
1320
|
+
const fits = (page) => page.length <= maxChars && new TextEncoder().encode(page).length <= maxBytes;
|
|
1321
|
+
const offset = typeof parsed.offset === "number" ? parsed.offset : 0;
|
|
1322
|
+
const candidates = parsed.agents;
|
|
1323
|
+
const availableCount = typeof parsed.availableCount === "number" ? parsed.availableCount : parsed.total;
|
|
1324
|
+
const groups = Array.isArray(parsed.credentialGroups) ? parsed.credentialGroups : [];
|
|
1325
|
+
if (options.fragmentOffset !== void 0) {
|
|
1326
|
+
const fragmentOffset = Number(options.fragmentOffset);
|
|
1327
|
+
const agentKey2 = candidates[0]?.agentKey;
|
|
1328
|
+
if (typeof options.fragmentOffset !== "number" && (typeof options.fragmentOffset !== "string" || !/^\d+$/.test(options.fragmentOffset)) || !Number.isSafeInteger(fragmentOffset) || fragmentOffset < 0 || typeof agentKey2 !== "string" || agentKey2 !== options.fragmentAgentKey) {
|
|
1329
|
+
return JSON.stringify({ success: false, error: "LIST_AGENTS_FRAGMENT_INVALID", offset });
|
|
1330
|
+
}
|
|
1331
|
+
const agent = candidates[0];
|
|
1332
|
+
const speedContext = buildCandidateSpeedContext(typeof agent.model === "string" ? [agent.model] : [], samples, { snapshotAgeMs });
|
|
1333
|
+
const payload = { agent, credentialGroups: groups.filter((group) => group.credentialGroup === agent.credentialGroup) };
|
|
1334
|
+
let keyCollision = false;
|
|
1335
|
+
const cleanText = (value) => scrubSecrets(sanitizeToolOutputText(value)).cleaned;
|
|
1336
|
+
const sanitize = (value) => {
|
|
1337
|
+
if (typeof value === "string") return cleanText(value);
|
|
1338
|
+
if (Array.isArray(value)) return value.map(sanitize);
|
|
1339
|
+
if (value && typeof value === "object") {
|
|
1340
|
+
const entries = [];
|
|
1341
|
+
const keys = /* @__PURE__ */ new Set();
|
|
1342
|
+
for (const [key, item] of Object.entries(value)) {
|
|
1343
|
+
const cleanedKey = cleanText(key);
|
|
1344
|
+
if (keys.has(cleanedKey)) keyCollision = true;
|
|
1345
|
+
keys.add(cleanedKey);
|
|
1346
|
+
entries.push([cleanedKey, sanitize(item)]);
|
|
1347
|
+
}
|
|
1348
|
+
return Object.fromEntries(entries);
|
|
1349
|
+
}
|
|
1350
|
+
return value;
|
|
1351
|
+
};
|
|
1352
|
+
const safePayload = sanitize(payload);
|
|
1353
|
+
if (keyCollision) return JSON.stringify({ success: false, error: "LIST_AGENTS_SANITIZED_KEY_COLLISION", offset });
|
|
1354
|
+
const serialized = JSON.stringify(safePayload);
|
|
1355
|
+
const bytes = new TextEncoder().encode(serialized);
|
|
1356
|
+
const hash = await globalThis.crypto.subtle.digest("SHA-256", bytes);
|
|
1357
|
+
const digest = Array.from(new Uint8Array(hash), (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
1358
|
+
if (fragmentOffset > 0 && !options.fragmentDigest || options.fragmentDigest && options.fragmentDigest !== digest) {
|
|
1359
|
+
return JSON.stringify({ success: false, error: "LIST_AGENTS_FRAGMENT_CHANGED", offset });
|
|
1360
|
+
}
|
|
1361
|
+
if (fragmentOffset >= serialized.length) return JSON.stringify({ success: false, error: "LIST_AGENTS_FRAGMENT_INVALID", offset });
|
|
1362
|
+
if (fragmentOffset > 0 && /[\uDC00-\uDFFF]/.test(serialized[fragmentOffset]) && /[\uD800-\uDBFF]/.test(serialized[fragmentOffset - 1])) return JSON.stringify({ success: false, error: "LIST_AGENTS_FRAGMENT_INVALID", offset });
|
|
1363
|
+
let end = Math.min(serialized.length, fragmentOffset + 3e3);
|
|
1364
|
+
if (end < serialized.length && /[\uD800-\uDBFF]/.test(serialized[end - 1]) && /[\uDC00-\uDFFF]/.test(serialized[end])) end--;
|
|
1365
|
+
const fragment = serialized.slice(fragmentOffset, end);
|
|
1366
|
+
const result = JSON.stringify({ success: true, agentKey: agentKey2, offset, digest, fragment, fragmentOffset, nextFragmentOffset: end, hasMoreFragments: end < serialized.length, nextOffset: offset + 1, ...speedContext ? { speedContext: cleanText(speedContext) } : {} });
|
|
1367
|
+
return fits(result) ? result : JSON.stringify({ success: false, error: "LIST_AGENTS_FRAGMENT_METADATA_TOO_LARGE", offset });
|
|
1368
|
+
}
|
|
1369
|
+
const makePage = (count) => {
|
|
1370
|
+
const agents = candidates.slice(0, count);
|
|
1371
|
+
const groupKeys = new Set(agents.map((agent) => agent.credentialGroup).filter(Boolean));
|
|
1372
|
+
const speedContext = buildCandidateSpeedContext(agents.map((agent) => agent.model).filter((model) => typeof model === "string"), samples, { snapshotAgeMs });
|
|
1373
|
+
const nextOffset = offset + count;
|
|
1374
|
+
const hasMore = nextOffset < availableCount;
|
|
1375
|
+
return JSON.stringify({
|
|
1376
|
+
...parsed,
|
|
1377
|
+
offset,
|
|
1378
|
+
agents,
|
|
1379
|
+
credentialGroups: groups.filter((group) => groupKeys.has(group.credentialGroup)),
|
|
1380
|
+
hasMore,
|
|
1381
|
+
...hasMore ? { nextOffset } : {},
|
|
1382
|
+
...speedContext ? { speedContext } : {}
|
|
1383
|
+
});
|
|
1384
|
+
};
|
|
1385
|
+
if (!candidates.length) {
|
|
1386
|
+
const empty = makePage(0);
|
|
1387
|
+
if (fits(empty)) return empty;
|
|
1388
|
+
} else {
|
|
1389
|
+
let best;
|
|
1390
|
+
for (let count = 1; count <= candidates.length; count++) {
|
|
1391
|
+
const page = makePage(count);
|
|
1392
|
+
if (!fits(page)) break;
|
|
1393
|
+
best = page;
|
|
1394
|
+
}
|
|
1395
|
+
if (best) return best;
|
|
1396
|
+
}
|
|
1397
|
+
const agentKey = typeof candidates[0]?.agentKey === "string" ? candidates[0].agentKey : void 0;
|
|
1398
|
+
const error = {
|
|
1399
|
+
success: false,
|
|
1400
|
+
error: candidates.length ? "LIST_AGENTS_CANDIDATE_TOO_LARGE" : "LIST_AGENTS_PAGE_METADATA_TOO_LARGE",
|
|
1401
|
+
offset,
|
|
1402
|
+
...agentKey ? { agentKey, recovery: {
|
|
1403
|
+
tool: "listAgents",
|
|
1404
|
+
arguments: { compact: true, offset, fragmentOffset: 0, fragmentAgentKey: agentKey },
|
|
1405
|
+
note: "Repeat with the same filters and returned digest and nextFragmentOffset; concatenate fragments and parse JSON before continuing at nextOffset."
|
|
1406
|
+
} } : {},
|
|
1407
|
+
...candidates.length ? { nextOffset: offset + 1, truncated: parsed.truncated === true, poolComplete: parsed.planningRecommendation?.poolComplete === true, hasMore: offset + 1 < availableCount } : {}
|
|
1408
|
+
};
|
|
1409
|
+
const encoded = JSON.stringify(error);
|
|
1410
|
+
return fits(encoded) ? encoded : JSON.stringify({ success: false, error: "LIST_AGENTS_RECOVERY_ID_TOO_LARGE", offset });
|
|
1411
|
+
}
|
|
1412
|
+
|
|
1413
|
+
// packages/ai/agent/dispatchSpeedProvenance.ts
|
|
1414
|
+
var record = (value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
1415
|
+
function isServerDispatchSpeedSource(value, dialogId, userId) {
|
|
1416
|
+
const dialog = record(value);
|
|
1417
|
+
const proof = record(dialog.dispatchSpeedProvenance);
|
|
1418
|
+
return proof.version === 1 && proof.source === "server-startAgentRun" && proof.userId === userId && record(dialog.runtimeBinding).tenantUserId === userId && dialog.id === dialogId;
|
|
1419
|
+
}
|
|
1420
|
+
function isLocalDispatchSpeedSource(value, dialogId, userId) {
|
|
1421
|
+
const run = record(value);
|
|
1422
|
+
const proof = record(run.dispatchSpeedProvenance);
|
|
1423
|
+
return proof.version === 1 && proof.source === "cli-startAgentRun" && proof.userId === userId && typeof run.runId === "string" && run.runId.length > 0 && run.dialogId === dialogId && run.ephemeral !== true;
|
|
903
1424
|
}
|
|
904
1425
|
|
|
905
1426
|
export {
|
|
@@ -913,5 +1434,8 @@ export {
|
|
|
913
1434
|
resolvePaginationArgs,
|
|
914
1435
|
matchesAgentQuery,
|
|
915
1436
|
buildAgentDiscoveryResult,
|
|
916
|
-
toDiscoverySafeAgentSummary
|
|
1437
|
+
toDiscoverySafeAgentSummary,
|
|
1438
|
+
injectSpeedContextIntoListAgentsResult,
|
|
1439
|
+
isServerDispatchSpeedSource,
|
|
1440
|
+
isLocalDispatchSpeedSource
|
|
917
1441
|
};
|