nolo-cli 0.224.0-alpha.1 → 0.224.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (236) hide show
  1. package/{_executeModel-WW57SJN4.js → _executeModel-5NA4USGG.js} +77 -70
  2. package/{action-CK64LS6S.js → action-X75O3XPH.js} +11 -8
  3. package/{addContentAction-EQXMFNPR.js → addContentAction-GVC77QSN.js} +14 -13
  4. package/{addDialogAgentAction-RSDZDASD.js → addDialogAgentAction-KKDVAMW3.js} +15 -14
  5. package/{agentDeleteCommand-X2VWEKUA.js → agentDeleteCommand-2RFGKFAB.js} +127 -118
  6. package/{agentEmailCommands-6IE773VW.js → agentEmailCommands-GQCQKKOR.js} +126 -113
  7. package/{agentFavoriteCommands-2LKGKSUD.js → agentFavoriteCommands-7LOP3HUD.js} +5 -5
  8. package/{agentGrantCommands-QQV4N4JW.js → agentGrantCommands-L6O2HVJI.js} +5 -5
  9. package/{agentListCommands-5UNM7CGG.js → agentListCommands-HSGLDPDQ.js} +110 -495
  10. package/{agentMachineCommands-EVWFKK6Q.js → agentMachineCommands-BISF6PVV.js} +63 -57
  11. package/{agentProviderCommands-ZCH37KAL.js → agentProviderCommands-O3Q25PKU.js} +6 -6
  12. package/{agentPullCommand-XN6ZPBUW.js → agentPullCommand-G6U2LHMW.js} +6 -6
  13. package/agentRecordCommands-AOXPGYAJ.js +189 -0
  14. package/{agentRunCommand-KGOT2AFB.js → agentRunCommand-AFAIP7U7.js} +129 -113
  15. package/{agentRunControl-QDFW5P2T.js → agentRunControl-VBL7UFSG.js} +20 -14
  16. package/{agentRuntimeLocal-SD7U2EGY.js → agentRuntimeLocal-T7BX2WGL.js} +47 -41
  17. package/{agentSlice-ACZGTZVW.js → agentSlice-XJNKE3PG.js} +18 -17
  18. package/{appDeleteCommands-NE3NQQJL.js → appDeleteCommands-LURUSPY7.js} +56 -50
  19. package/{appDeployCommands-2BAHY522.js → appDeployCommands-SMEW4AK2.js} +56 -50
  20. package/{appDeployStatusCommands-JTW6LZNC.js → appDeployStatusCommands-VYPJTBJK.js} +56 -50
  21. package/{appGetCommands-WKFEJO6A.js → appGetCommands-N4NI5GGJ.js} +56 -50
  22. package/{appListCommands-HNAZZLFX.js → appListCommands-5C6ONN3Z.js} +56 -50
  23. package/{authCommand-4FDPL7WG.js → authCommand-4CVBDADE.js} +29 -24
  24. package/{authCommands-GAJ3NIXO.js → authCommands-EHU2BHOX.js} +12 -7
  25. package/{builtinSkillRegistry-PXH7EGQB.js → builtinSkillRegistry-AYWYQVA4.js} +4 -4
  26. package/{chromeOpsCommands-YKX2QX3A.js → chromeOpsCommands-CSDG2HYN.js} +6 -6
  27. package/{chunk-OOF7XDZF.js → chunk-2574ANSV.js} +6 -6
  28. package/chunk-2SXN7LAY.js +15 -0
  29. package/{chunk-OGHP3CTL.js → chunk-2X7WFDT6.js} +1 -1
  30. package/{chunk-XI2BWJM5.js → chunk-324FWHUA.js} +20 -3
  31. package/{chunk-D726I5AZ.js → chunk-3EMIEC27.js} +2 -2
  32. package/{chunk-S7SB7L2I.js → chunk-3FBAVU2Y.js} +24 -22
  33. package/{chunk-YL3EFYL3.js → chunk-4D4QD7FT.js} +3 -1
  34. package/{chunk-5RKUPJYL.js → chunk-4FIO2S7Z.js} +11 -3
  35. package/{chunk-MKQ2UTTX.js → chunk-4IQVE43Z.js} +63 -32
  36. package/{chunk-6NKA6RKF.js → chunk-4Q6HQORG.js} +8 -8
  37. package/{chunk-P2ZLUIW2.js → chunk-4X5AVCM7.js} +94 -4
  38. package/chunk-4ZCTKB27.js +31 -0
  39. package/{chunk-JWXITTQB.js → chunk-5HUO7SEX.js} +9 -107
  40. package/{chunk-4A2JIXR2.js → chunk-5QZSEQSK.js} +1 -1
  41. package/chunk-5ZUOVCKT.js +32 -0
  42. package/{chunk-TRWT3EE3.js → chunk-62HXNQVV.js} +1 -1
  43. package/{chunk-JC5XLWZK.js → chunk-6CKUO32A.js} +27 -15
  44. package/chunk-6D25V6CB.js +133 -0
  45. package/chunk-6WOLPIPY.js +379 -0
  46. package/{chunk-KOXKKHFE.js → chunk-6WZVM33D.js} +9 -4
  47. package/{chunk-YGMBIXCF.js → chunk-6XRPBZRS.js} +4 -2
  48. package/{chunk-KO63FPG3.js → chunk-7AJRJGSQ.js} +1049 -2860
  49. package/chunk-7NIBQ4HY.js +138 -0
  50. package/{chunk-7Z6EW7AH.js → chunk-7TTMMOKH.js} +13 -6
  51. package/{chunk-7WPAI5JJ.js → chunk-A3LUWRQK.js} +15 -15
  52. package/{chunk-C4WTX5TU.js → chunk-A5EVA6HU.js} +2 -2
  53. package/{chunk-O2CYENYJ.js → chunk-A74QP4FI.js} +2614 -1374
  54. package/{chunk-N3J4VDGV.js → chunk-AEQMKYZN.js} +15 -15
  55. package/{chunk-DVQH4BTR.js → chunk-AH5R7BYW.js} +26 -176
  56. package/{chunk-H7R3365N.js → chunk-ANJRDS6U.js} +8 -5
  57. package/{chunk-YFLVRVYK.js → chunk-AVJDELEA.js} +1 -1
  58. package/{chunk-GIABSSWQ.js → chunk-B5SV4H3J.js} +4 -4
  59. package/{chunk-FVZW66K4.js → chunk-B7DE5XJW.js} +387 -347
  60. package/chunk-BEM6LPD2.js +734 -0
  61. package/{chunk-SRL56PI2.js → chunk-BGGAY6OK.js} +46 -8
  62. package/{chunk-T3O6BLYU.js → chunk-BGGV6B5O.js} +555 -328
  63. package/{chunk-BGGHA5DV.js → chunk-BIABIPGW.js} +1 -1
  64. package/chunk-BIDSIRTS.js +307 -0
  65. package/{chunk-6D7NVU66.js → chunk-BXSMFPTG.js} +17 -14
  66. package/{chunk-Q6HOUF4O.js → chunk-CBUZ6DKA.js} +3 -3
  67. package/{chunk-LE6LGAJE.js → chunk-CD3RU7XL.js} +17 -2
  68. package/{chunk-GVGOEMNV.js → chunk-CKZPMJNU.js} +3 -3
  69. package/{chunk-3ESU44FG.js → chunk-CVJRVBJL.js} +3 -3
  70. package/chunk-D374I563.js +62 -0
  71. package/{chunk-XWGDCWXY.js → chunk-DNZ4JJ7C.js} +9 -9
  72. package/chunk-DVYAFH2Q.js +103 -0
  73. package/{chunk-N7HVLYOY.js → chunk-DXW5WDHZ.js} +4 -4
  74. package/{chunk-KFHREHUQ.js → chunk-DXWGFL2Z.js} +89 -1
  75. package/{chunk-65XXHYZ5.js → chunk-E5KJOZWY.js} +4 -4
  76. package/{chunk-GNHMRBYZ.js → chunk-EBKHA63G.js} +106 -14
  77. package/{chunk-PFJNLBRU.js → chunk-EEOOBRA7.js} +6 -6
  78. package/{chunk-M3JEW6N6.js → chunk-F26GAEH3.js} +10 -0
  79. package/{chunk-QLFCTYRH.js → chunk-F3XI6WQP.js} +17 -10
  80. package/{chunk-AFHOCBSP.js → chunk-F6YWDVIB.js} +1 -1
  81. package/{chunk-VHPAA6MT.js → chunk-FFYE5ATM.js} +6 -6
  82. package/{chunk-F3TQURKK.js → chunk-FZKA3XFA.js} +21 -21
  83. package/{chunk-C4VAR65S.js → chunk-G22P367E.js} +153 -117
  84. package/{chunk-4NMHE7CX.js → chunk-GDUC4VS2.js} +12 -12
  85. package/{chunk-2VUZSVAS.js → chunk-GXXY2NL3.js} +22 -20
  86. package/{chunk-IWH5SOU4.js → chunk-H7ZYKHAZ.js} +38 -18
  87. package/{chunk-G2EJ7NL4.js → chunk-HBRDSQ3M.js} +2 -2
  88. package/{chunk-EGXPAWLG.js → chunk-HCNOO374.js} +1 -1
  89. package/{chunk-DJSTBAOU.js → chunk-HOM6LTEW.js} +4 -4
  90. package/{chunk-S2NTVGA2.js → chunk-I2OYPD3Y.js} +1 -1
  91. package/{chunk-QWYFFHCJ.js → chunk-IJTXNLQE.js} +13 -13
  92. package/{chunk-UYOICCYG.js → chunk-IUMS6F53.js} +59 -88
  93. package/{chunk-MOMR7NMG.js → chunk-IUTUWIKE.js} +2 -2
  94. package/{chunk-JVRQ6YVK.js → chunk-JBWXPACD.js} +1 -1
  95. package/{chunk-SASHAZ67.js → chunk-KZPEGO6D.js} +13 -2
  96. package/{chunk-HCJFGH6Y.js → chunk-L32W3PRP.js} +46 -16
  97. package/{chunk-GGKNJ42M.js → chunk-LYDEFPQP.js} +18 -108
  98. package/{chunk-K5FNYHZC.js → chunk-MECDGHLK.js} +420 -120
  99. package/{chunk-EOWLBDY6.js → chunk-MM73SP4K.js} +1 -1
  100. package/{chunk-J6T25AJ6.js → chunk-MYOSN6BT.js} +82 -18
  101. package/{chunk-Q7WP5RPC.js → chunk-MYPKBJJO.js} +5 -5
  102. package/{chunk-6RQFZCKH.js → chunk-N2JROHD3.js} +4 -4
  103. package/{chunk-VREDDN25.js → chunk-O6IPRAVV.js} +14 -9
  104. package/{chunk-VALBGPM6.js → chunk-OBSEKCVK.js} +17 -20
  105. package/{chunk-AMEOV5VZ.js → chunk-OOJNQK6V.js} +33 -33
  106. package/{chunk-PPJYZRSQ.js → chunk-OX6GNNVT.js} +6 -1
  107. package/{chunk-5R63B62U.js → chunk-P3IZUMIC.js} +8 -8
  108. package/{chunk-FRSBYNWI.js → chunk-PGKA77TZ.js} +52 -217
  109. package/{chunk-7UH3DGV6.js → chunk-PRMEU7BT.js} +232 -10
  110. package/{chunk-2ZKFCIJJ.js → chunk-PROOOQZ3.js} +1 -1
  111. package/{chunk-EUCFKKDM.js → chunk-PVFYPUIM.js} +40 -10
  112. package/{chunk-HOCHUZQ7.js → chunk-QJTZ76CP.js} +24 -6
  113. package/{chunk-MK2Q7ZJD.js → chunk-R7XWZDOH.js} +58 -24
  114. package/{chunk-5FUN7EG4.js → chunk-RD3QLZQV.js} +83 -47
  115. package/chunk-RETQOQ4D.js +33394 -0
  116. package/{chunk-AVHRSJUH.js → chunk-RM4UMFY4.js} +32 -25
  117. package/{chunk-2OLYKYNY.js → chunk-RTHFJZ6M.js} +8 -8
  118. package/{chunk-OB6DVWPF.js → chunk-S2MHR4PU.js} +164 -4
  119. package/{chunk-IWQAOW2X.js → chunk-SRCCSTIM.js} +8 -8
  120. package/{chunk-PVZY6P3S.js → chunk-T6VROBY7.js} +2 -2
  121. package/{chunk-2KTUDBG7.js → chunk-TEMLHVGX.js} +1 -1
  122. package/{chunk-TVFRV3UQ.js → chunk-TRHJ4NJB.js} +673 -1279
  123. package/{chunk-QVBXJNZ2.js → chunk-TUSTONB3.js} +1 -1
  124. package/{chunk-UMRI2IRY.js → chunk-TWTJV35S.js} +6 -6
  125. package/{chunk-5OZC7R7Y.js → chunk-U3G7RRXJ.js} +13 -12
  126. package/{chunk-CXDPIPZ4.js → chunk-UFC4J7OY.js} +3 -3
  127. package/{chunk-CKT6QUE2.js → chunk-UHW6SCVK.js} +1 -1
  128. package/{chunk-AGP3YSEC.js → chunk-ULLHVDTZ.js} +48 -3
  129. package/{chunk-SYQR7FQS.js → chunk-VM72HKW2.js} +97 -29
  130. package/{chunk-KEN3N2TN.js → chunk-VMJVAJ6W.js} +13 -10
  131. package/{chunk-3N4ASIP6.js → chunk-VREG6ANQ.js} +103 -100
  132. package/{chunk-SOF4OWDM.js → chunk-VS276URX.js} +0 -2
  133. package/chunk-VSRISJXZ.js +107 -0
  134. package/chunk-WDWZPASX.js +29 -0
  135. package/chunk-WFGNWWJI.js +326 -0
  136. package/{chunk-UJKTI5PG.js → chunk-WRKMXMU7.js} +2 -1
  137. package/{chunk-FIYSMXHY.js → chunk-WWTSEBDF.js} +1 -1
  138. package/{chunk-E2BESSAW.js → chunk-X4O7FJF5.js} +2 -0
  139. package/chunk-X7IA2B7R.js +166 -0
  140. package/{chunk-5ZMIIR23.js → chunk-XBAEM4RI.js} +7 -0
  141. package/{chunk-4JVNURX4.js → chunk-XS5A3EKX.js} +1 -23
  142. package/{chunk-N5Z2V73W.js → chunk-Y2MF4DCJ.js} +1 -1
  143. package/{chunk-KAVGK4ES.js → chunk-Y5OWZQMJ.js} +39 -30
  144. package/{chunk-AK5O76CC.js → chunk-YGCOJNFZ.js} +3 -3
  145. package/{chunk-L5I543VB.js → chunk-YGDYYFRX.js} +20 -24
  146. package/{chunk-XFJ4ZPFC.js → chunk-Z2WZAE4P.js} +128 -149
  147. package/chunk-Z6YTCDU4.js +24 -0
  148. package/chunk-ZEKUFJLW.js +1438 -0
  149. package/{chunk-KN3HEZIQ.js → chunk-ZVOL2MAJ.js} +1 -1
  150. package/{cliAgentConfigHelpers-PO3MVDME.js → cliAgentConfigHelpers-U5OAVAKQ.js} +12 -12
  151. package/{cliAuthorityBrokerClient-XHH7MH2P.js → cliAuthorityBrokerClient-S42VMGB6.js} +1 -1
  152. package/{cliEnvHelpers-VPSJ4XWC.js → cliEnvHelpers-CNMP3RDX.js} +1 -1
  153. package/{cliExecutor-4MAX3PZL.js → cliExecutor-K6FDZTQ2.js} +3 -1
  154. package/{cliLocalAgentRecordReader-Z7CH4K4R.js → cliLocalAgentRecordReader-HVZAQCUD.js} +49 -44
  155. package/{commandRegistry-SDSYBKMC.js → commandRegistry-TME7INFU.js} +98 -94
  156. package/{contentThunks-G3TRPEAU.js → contentThunks-U6OC4R2N.js} +37 -35
  157. package/{cooldownCommands-X7P5M2V5.js → cooldownCommands-U7XSRVJP.js} +4 -4
  158. package/{createAgentAutomationAction-KHA4MXUJ.js → createAgentAutomationAction-IP4LFN3W.js} +37 -35
  159. package/{createDialogAction-KWSBNAPJ.js → createDialogAction-IAGQJ3LH.js} +38 -36
  160. package/{createPageAction-HXKJ7OFG.js → createPageAction-AZ3UIFKA.js} +38 -36
  161. package/{db-CS4ZJQKV.js → db-M7FU2GNK.js} +9 -6
  162. package/{dbSlice-ZJPDIFER.js → dbSlice-DKKMJJYY.js} +13 -12
  163. package/{deleteFile-Q3YDB4ML.js → deleteFile-TQSONMVU.js} +11 -8
  164. package/{dialogCommands-6KQEBHSG.js → dialogCommands-PCDRMBWG.js} +60 -55
  165. package/dialogMessageRecord-OAV77LT7.js +7 -0
  166. package/{dialogNotifyCommand-WIZFFEY3.js → dialogNotifyCommand-O35MWMOS.js} +13 -13
  167. package/{dialogSlice-HXPKFGRL.js → dialogSlice-QAKYN4DE.js} +35 -33
  168. package/{dialogUsageCommand-HTVPR2CX.js → dialogUsageCommand-2SSLTXKO.js} +3 -3
  169. package/{docCreateCommands-XZOLWBRC.js → docCreateCommands-CFQFZOAD.js} +54 -48
  170. package/{docDeleteCommands-ZSO4LGWE.js → docDeleteCommands-5CPNTIIS.js} +56 -50
  171. package/{docReadCommands-TTMXCDER.js → docReadCommands-XQILYSAJ.js} +54 -48
  172. package/{docStore-A2B3GH33.js → docStore-GIVRT7TQ.js} +15 -14
  173. package/{docUpdateCommands-PRG6WOXL.js → docUpdateCommands-VETKSUDD.js} +54 -48
  174. package/fetchMessages-TQEUZD7H.js +1 -1
  175. package/{getPricing-YH3VMSVU.js → getPricing-LF5C4XSI.js} +5 -5
  176. package/{handleSendMessageAction-NWYG3Q72.js → handleSendMessageAction-HKIW4ZNO.js} +70 -66
  177. package/{hostCredentialCreate-WS6D3EHT.js → hostCredentialCreate-6VDJFNDO.js} +118 -104
  178. package/index.js +56 -18
  179. package/keys-RWF7UCB4.js +1 -1
  180. package/{lib-OT5OTXRU.js → lib-62SWPXNF.js} +3 -7
  181. package/{localDialogRead-SVTPA5GY.js → localDialogRead-AV2VKKPG.js} +1 -1
  182. package/{localRecall-2J6QPOK2.js → localRecall-BDYKXB46.js} +3 -1
  183. package/{localRuntimeAdapter-TFYOA6YE.js → localRuntimeAdapter-BQ4F5PZV.js} +120 -107
  184. package/{localRuntimeAuthority-IBJAT62G.js → localRuntimeAuthority-WCNA4A3G.js} +4 -2
  185. package/{localRuntimeDb-N7KHDXS2.js → localRuntimeDb-CRNIBOOM.js} +1 -1
  186. package/{machineCommands-WFWV25IR.js → machineCommands-K6XIGOAD.js} +142 -114
  187. package/{machineWsRunDispatch-ZGXC3F2R.js → machineWsRunDispatch-4OO7Z6UM.js} +114 -101
  188. package/mcpLocalAuthorizeCommand-ZP6ESAGE.js +106 -0
  189. package/{memberThunks-JRYNONYV.js → memberThunks-PBJPZ2JU.js} +22 -17
  190. package/{memoryCommands-5WC3T66U.js → memoryCommands-BC6REPQB.js} +4 -4
  191. package/{models-CXINDUJA.js → models-H5NNZRLH.js} +2 -2
  192. package/{overlay-THLKYIWY.js → overlay-JA3SPVUS.js} +7 -3
  193. package/package.json +1 -1
  194. package/{projectArchive-ULJDLUA6.js → projectArchive-G7AOQPRW.js} +43 -41
  195. package/{providerPresetApply-SHT2SUVB.js → providerPresetApply-OPBCAONX.js} +6 -6
  196. package/{providerRegistry-TA7EGCVZ.js → providerRegistry-J2HCVTHE.js} +6 -6
  197. package/{read-Q7GOHGNP.js → read-JEGPITEW.js} +10 -9
  198. package/{readDocTool-Z5OQ6422.js → readDocTool-TE3XIU4Y.js} +1 -1
  199. package/{readlineWorkspace-LTCV2BFW.js → readlineWorkspace-SOW5QUGZ.js} +4412 -4277
  200. package/{removeDialogAgentAction-U3F2MNAY.js → removeDialogAgentAction-CX3OAH4Y.js} +17 -16
  201. package/{runAgentClientLoop-BVIEQUB3.js → runAgentClientLoop-HQJPDFGQ.js} +95 -69
  202. package/{runtimeDoctorCommands-I47JN4HS.js → runtimeDoctorCommands-GUH2YGMH.js} +17 -17
  203. package/{secretCommands-LJXOOYA7.js → secretCommands-NJXFVHZU.js} +4 -4
  204. package/{setDialogExtraReferencesAction-G3WSJ7EM.js → setDialogExtraReferencesAction-CGM67EEQ.js} +16 -15
  205. package/{setPrimaryDialogAgentAction-6FHAHZBB.js → setPrimaryDialogAgentAction-3ABWPPXR.js} +17 -16
  206. package/{settingThunks-AXTBX3Q5.js → settingThunks-AY76OHYX.js} +181 -62
  207. package/{skillDiscovery-B5V23AXP.js → skillDiscovery-MDDKPTW3.js} +4 -3
  208. package/{spaceCommands-IB6FKWIC.js → spaceCommands-G63QGYQO.js} +59 -53
  209. package/{store-JRVN62NM.js → store-Z53ICFL3.js} +3 -1
  210. package/{streamAgentChatTurn-DNYFHBJM.js → streamAgentChatTurn-E3XH2KFD.js} +160 -154
  211. package/{switchDialogAgentAction-UOFIAGPL.js → switchDialogAgentAction-G6EZRKCQ.js} +15 -14
  212. package/{tableCommands-HITDSLHS.js → tableCommands-JI75ZHDI.js} +14 -11
  213. package/{toolApiClient-OGQEBQVX.js → toolApiClient-62UUPDUA.js} +3 -5
  214. package/{tools-JVOJ5HC4.js → tools-7RSX22FT.js} +64 -58
  215. package/tuiRestart-KAAA7TND.js +41 -0
  216. package/{tuiSummaryLlmCaller-7LWYTHLM.js → tuiSummaryLlmCaller-BVNHMWLR.js} +19 -19
  217. package/{updateCommands-RJVCRSBP.js → updateCommands-ASK5XYPH.js} +8 -6
  218. package/{updateDialogTitleAction-Q57BOSXG.js → updateDialogTitleAction-SEWV252V.js} +37 -35
  219. package/{usageCommand-RVKHEPLU.js → usageCommand-JVT5J3DC.js} +3 -3
  220. package/{usageRebuildCommand-GRAFOZF2.js → usageRebuildCommand-IZYYUTEW.js} +4 -4
  221. package/webapi-24RZDIIQ.js +2488 -0
  222. package/{windowsSelfUpdate-KERHIAB4.js → windowsSelfUpdate-BSDIS2J5.js} +2 -2
  223. package/workContext-MM3P5GP5.js +13 -0
  224. package/workContextAccess-UZHDLBUR.js +11 -0
  225. package/workContextWriteNotice-YCSSMHN4.js +7 -0
  226. package/agentRecordCommands-DX2WE6BH.js +0 -176
  227. package/chunk-2THCNKE4.js +0 -147
  228. package/chunk-2WZXXAQD.js +0 -57
  229. package/chunk-652XYZGP.js +0 -352
  230. package/chunk-KEPOVMF4.js +0 -91
  231. package/chunk-OXKUPBAQ.js +0 -776
  232. package/{chunk-BLVSFYQ3.js → chunk-LISC7BD4.js} +3 -3
  233. package/{chunk-SNBZZPYH.js → chunk-OQHIVPG4.js} +3 -3
  234. package/{chunk-47ITIXO7.js → chunk-USGHJSGO.js} +3 -3
  235. package/{offlineMarxistsAgentCommand-4IC3Y4C6.js → offlineMarxistsAgentCommand-XVXUE6G5.js} +3 -3
  236. package/{workloadLifecycle-O2I3NZ2Q.js → workloadLifecycle-YIZ7KLUP.js} +3 -3
package/chunk-OXKUPBAQ.js DELETED
@@ -1,776 +0,0 @@
1
- import {
2
- fnv1a32Hex
3
- } from "./chunk-UEILX4EV.js";
4
- import {
5
- compareAgentSelection,
6
- resolveModelTier
7
- } from "./chunk-C4VAR65S.js";
8
- import {
9
- DEFAULT_PROVIDER_RETRY_MS,
10
- isAgentUnavailableNow,
11
- resolveAgentAvailability
12
- } from "./chunk-HOCHUZQ7.js";
13
- import {
14
- isOAuthApiKeyRef
15
- } from "./chunk-UKZX3NHN.js";
16
- import {
17
- getModelAbility
18
- } from "./chunk-TRWT3EE3.js";
19
- import {
20
- isAntigravityOAuthAgent,
21
- isSubscriptionEndpoint,
22
- isSubscriptionOAuthCredential
23
- } from "./chunk-JC5XLWZK.js";
24
- import {
25
- isOwnedAgentKey,
26
- ownedAgentKey,
27
- publicAgentKey
28
- } from "./chunk-M2EJHDJP.js";
29
-
30
- // packages/ai/agent/agentBilling.ts
31
- function resolveBillingSource(candidate) {
32
- if (candidate?.local === true || candidate?.isLocal === true || candidate?.cliProvider === "local" || candidate?.apiSource === "local" || candidate?.provider === "local" || candidate?.billingSource === "local") return "local";
33
- if (candidate?.isOwned !== true) {
34
- const ownerUserId = typeof candidate?.userId === "string" && candidate.userId.trim() ? candidate.userId.trim() : typeof candidate?.ownerId === "string" && candidate.ownerId.trim() ? candidate.ownerId.trim() : "";
35
- if (ownerUserId && (candidate?.isOAuth === true || isOAuthApiKeyRef(candidate?.apiKeyRef) || isAntigravityOAuthAgent({
36
- key: "billing-source-probe",
37
- apiKeyRef: candidate?.apiKeyRef ?? void 0,
38
- provider: candidate?.provider ?? void 0,
39
- customProviderUrl: candidate?.customProviderUrl ?? void 0
40
- }))) {
41
- return "owner_subscription";
42
- }
43
- return "platform_credits";
44
- }
45
- if (candidate?.isOAuth === true || candidate?.billingSource === "user_subscription" || candidate?.apiSource === "oauth" || isOAuthApiKeyRef(candidate?.apiKeyRef)) return "user_subscription";
46
- if (candidate?.apiSource === "custom" || candidate?.billingSource === "user_api") {
47
- if (isSubscriptionEndpoint(candidate?.customProviderUrl) || isSubscriptionOAuthCredential(candidate?.apiKeyRef)) {
48
- return "user_subscription";
49
- }
50
- return "user_api";
51
- }
52
- return "platform_credits";
53
- }
54
-
55
- // packages/ai/economics/economicsPolicy.ts
56
- var DEEPSEEK_PRICING_DOC = "https://api-docs.deepseek.com/quick_start/pricing";
57
- var BIGMODEL_CODING_PLAN_USAGE_NOTES = "https://docs.bigmodel.cn/cn/coding-plan/usage-notes";
58
- var WEEKDAYS_MON_FRI = [1, 2, 3, 4, 5];
59
- var DEEPSEEK_API_POLICY = {
60
- id: "deepseek_api",
61
- version: "2026-09-weekday-utc-peak-2x",
62
- windows: [
63
- { timezone: "UTC", weekdays: WEEKDAYS_MON_FRI, startMinute: 60, endMinute: 240 },
64
- { timezone: "UTC", weekdays: WEEKDAYS_MON_FRI, startMinute: 360, endMinute: 600 }
65
- ],
66
- effectiveFrom: Date.UTC(2026, 7, 16, 16, 0, 0),
67
- peakPriceMultiplier: 2,
68
- offPeakPriceMultiplier: 1,
69
- sourceUrl: DEEPSEEK_PRICING_DOC
70
- };
71
- var BIGMODEL_GLM_CODING_PLAN_POLICY = {
72
- id: "bigmodel_glm_coding_plan",
73
- version: "2026-09-coding-plan-sh-peak-14-18",
74
- windows: [
75
- { timezone: "Asia/Shanghai", weekdays: WEEKDAYS_MON_FRI, startMinute: 840, endMinute: 1080 }
76
- ],
77
- peakQuotaMultiplier: 1,
78
- offPeakQuotaMultiplier: 0.5,
79
- sourceUrl: BIGMODEL_CODING_PLAN_USAGE_NOTES
80
- };
81
- var ECONOMICS_POLICIES = [
82
- DEEPSEEK_API_POLICY,
83
- BIGMODEL_GLM_CODING_PLAN_POLICY
84
- ];
85
- function resolveEconomicsSourceId(input) {
86
- const provider = typeof input?.provider === "string" ? input.provider.trim().toLowerCase() : "";
87
- if (input?.apiSource?.trim().toLowerCase() === "platform") return null;
88
- const rawUrl = typeof input?.customProviderUrl === "string" ? input.customProviderUrl.trim() : "";
89
- let hostname = "";
90
- let pathname = "";
91
- if (rawUrl) {
92
- try {
93
- const parsed = new URL(rawUrl);
94
- hostname = parsed.hostname.toLowerCase();
95
- pathname = parsed.pathname;
96
- } catch {
97
- return null;
98
- }
99
- }
100
- if (provider === "deepseek") {
101
- if (rawUrl && hostname !== "api.deepseek.com") return null;
102
- return rawUrl ? "deepseek_api" : null;
103
- }
104
- if (provider === "bigmodel") {
105
- if (hostname === "open.bigmodel.cn" && pathname.startsWith("/api/coding/")) {
106
- return "bigmodel_glm_coding_plan";
107
- }
108
- return null;
109
- }
110
- return null;
111
- }
112
-
113
- // packages/ai/economics/economicsSnapshot.ts
114
- var wallClockFormatterCache = /* @__PURE__ */ new Map();
115
- function getWallClockFormatter(timezone) {
116
- let formatter = wallClockFormatterCache.get(timezone);
117
- if (!formatter) {
118
- formatter = new Intl.DateTimeFormat("en-US", {
119
- timeZone: timezone,
120
- hourCycle: "h23",
121
- year: "numeric",
122
- month: "2-digit",
123
- day: "2-digit",
124
- hour: "2-digit",
125
- minute: "2-digit",
126
- second: "2-digit"
127
- });
128
- wallClockFormatterCache.set(timezone, formatter);
129
- }
130
- return formatter;
131
- }
132
- function getZonedWallClock(timezone, at) {
133
- const parts = getWallClockFormatter(timezone).formatToParts(new Date(at));
134
- const values = {};
135
- for (const part of parts) {
136
- if (part.type !== "literal") values[part.type] = Number(part.value);
137
- }
138
- const year = values.year;
139
- const month = values.month;
140
- const day = values.day;
141
- const hour = values.hour;
142
- const minute = values.minute;
143
- const second = values.second;
144
- const weekday = new Date(Date.UTC(year, month - 1, day)).getUTCDay();
145
- return { year, month, day, hour, minute, second, weekday, minutesOfDay: hour * 60 + minute };
146
- }
147
- function getTimeZoneOffsetMs(timezone, at) {
148
- const atSecond = Math.floor(at / 1e3) * 1e3;
149
- const clock = getZonedWallClock(timezone, atSecond);
150
- return Date.UTC(clock.year, clock.month - 1, clock.day, clock.hour, clock.minute, clock.second) - atSecond;
151
- }
152
- function zonedWallClockToEpochMs(timezone, year, month, day, minutesOfDay) {
153
- const guess = Date.UTC(year, month - 1, day, Math.floor(minutesOfDay / 60), minutesOfDay % 60);
154
- let instant = guess - getTimeZoneOffsetMs(timezone, guess);
155
- instant = guess - getTimeZoneOffsetMs(timezone, instant);
156
- return instant;
157
- }
158
- function resolveEconomicsPeriod(policy, at) {
159
- for (const window of policy.windows) {
160
- const clock = getZonedWallClock(window.timezone, at);
161
- if (!window.weekdays.includes(clock.weekday)) continue;
162
- if (clock.minutesOfDay >= window.startMinute && clock.minutesOfDay < window.endMinute) {
163
- return "peak";
164
- }
165
- }
166
- return "off_peak";
167
- }
168
- function findNextEconomicsBoundary(policy, at) {
169
- let best;
170
- for (const window of policy.windows) {
171
- const anchor = getZonedWallClock(window.timezone, at);
172
- for (let dayOffset = 0; dayOffset <= 7; dayOffset++) {
173
- const dayUtc = new Date(Date.UTC(anchor.year, anchor.month - 1, anchor.day + dayOffset));
174
- const weekday = dayUtc.getUTCDay();
175
- if (!window.weekdays.includes(weekday)) continue;
176
- const year = dayUtc.getUTCFullYear();
177
- const month = dayUtc.getUTCMonth() + 1;
178
- const day = dayUtc.getUTCDate();
179
- for (const edge of [window.startMinute, window.endMinute]) {
180
- const instant = zonedWallClockToEpochMs(window.timezone, year, month, day, edge);
181
- if (instant > at && (best === void 0 || instant < best)) best = instant;
182
- }
183
- }
184
- }
185
- return best;
186
- }
187
- function selectEconomicsPolicyVersion(policies, sourceId, at) {
188
- const applicable = policies.filter(
189
- (policy) => policy.id === sourceId && (policy.effectiveFrom === void 0 || policy.effectiveFrom <= at) && (policy.effectiveUntil === void 0 || at < policy.effectiveUntil)
190
- );
191
- if (applicable.length === 0) return null;
192
- return applicable.reduce(
193
- (latest, candidate) => (candidate.effectiveFrom ?? -Infinity) >= (latest.effectiveFrom ?? -Infinity) ? candidate : latest
194
- );
195
- }
196
- function findNextPolicyBoundary(policy, at, policies) {
197
- const boundaries = [
198
- policy.effectiveUntil,
199
- ...policies.filter((candidate) => candidate.id === policy.id).map((candidate) => candidate.effectiveFrom).filter((value) => value !== void 0 && value > at)
200
- ].filter((value) => value !== void 0 && value > at);
201
- return boundaries.length > 0 ? Math.min(...boundaries) : void 0;
202
- }
203
- function resolveEconomicsSnapshot(input, at, policies = ECONOMICS_POLICIES) {
204
- const sourceId = resolveEconomicsSourceId(input);
205
- if (!sourceId) return null;
206
- const policy = selectEconomicsPolicyVersion(policies, sourceId, at);
207
- if (!policy) return null;
208
- const period = resolveEconomicsPeriod(policy, at);
209
- const priceMultiplier = period === "peak" ? policy.peakPriceMultiplier : policy.offPeakPriceMultiplier;
210
- const quotaMultiplier = period === "peak" ? policy.peakQuotaMultiplier : policy.offPeakQuotaMultiplier;
211
- const windowBoundary = findNextEconomicsBoundary(policy, at);
212
- const policyBoundary = findNextPolicyBoundary(policy, at, policies);
213
- const changesAt = [windowBoundary, policyBoundary].filter((value) => value !== void 0).sort((a, b) => a - b)[0];
214
- return {
215
- source: sourceId,
216
- policyVersion: policy.version,
217
- period,
218
- ...priceMultiplier !== void 0 ? { priceMultiplier } : {},
219
- ...quotaMultiplier !== void 0 ? { quotaMultiplier } : {},
220
- ...changesAt !== void 0 ? { changesAt } : {}
221
- };
222
- }
223
-
224
- // packages/ai/agent/safeAgentSummary.ts
225
- function deriveCredentialGroup(ref) {
226
- if (!ref || typeof ref !== "string") return void 0;
227
- const trimmed = ref.trim();
228
- if (!trimmed) return void 0;
229
- if (isOAuthApiKeyRef(trimmed)) {
230
- return {
231
- credentialGroup: trimmed.toLowerCase(),
232
- credentialKind: "oauth"
233
- };
234
- }
235
- const hash = fnv1a32Hex(trimmed);
236
- return {
237
- credentialGroup: `cred-${hash}`,
238
- credentialKind: "api-key"
239
- };
240
- }
241
- function deriveCustomProviderCredentialGroup(userId, customProviderUrl) {
242
- if (typeof customProviderUrl !== "string" || !customProviderUrl.trim()) {
243
- return void 0;
244
- }
245
- const basis = `${userId ?? ""}|${customProviderUrl.trim().toLowerCase()}`;
246
- return {
247
- credentialGroup: `custom-${fnv1a32Hex(basis)}`,
248
- credentialKind: "api-key"
249
- };
250
- }
251
- function summarizeCredentialGroups(agents, now = Date.now()) {
252
- const groups = /* @__PURE__ */ new Map();
253
- for (const agent of agents) {
254
- if (!agent.credentialGroup || !agent.credentialKind) continue;
255
- if (agent.isOwned === false) continue;
256
- const existing = groups.get(agent.credentialGroup);
257
- const at = typeof agent.nextAvailableAt === "number" && agent.nextAvailableAt > now ? agent.nextAvailableAt : void 0;
258
- if (!existing) {
259
- groups.set(agent.credentialGroup, {
260
- credentialGroup: agent.credentialGroup,
261
- credentialKind: agent.credentialKind,
262
- agentCount: 1,
263
- ...at !== void 0 ? { availableAt: at } : {}
264
- });
265
- } else {
266
- existing.agentCount += 1;
267
- if (at !== void 0) {
268
- existing.availableAt = Math.max(existing.availableAt ?? 0, at);
269
- }
270
- }
271
- }
272
- return Array.from(groups.values()).sort(
273
- (a, b) => a.credentialGroup.localeCompare(b.credentialGroup)
274
- );
275
- }
276
- function parseTimestamp(val) {
277
- if (typeof val === "number" && Number.isFinite(val)) return val;
278
- if (typeof val === "string") return Date.parse(val) || 0;
279
- return 0;
280
- }
281
- function safeTimestamp(val) {
282
- if (typeof val === "number" && Number.isFinite(val)) return val;
283
- if (typeof val === "string") return val;
284
- return null;
285
- }
286
- function parseAgentRecordId(privateKey, explicitId) {
287
- if (explicitId && typeof explicitId === "string" && explicitId.trim()) {
288
- return explicitId.trim();
289
- }
290
- if (privateKey && typeof privateKey === "string") {
291
- const match = privateKey.match(/^agent-[^-]+-(.+)$/i);
292
- if (match?.[1]) return match[1];
293
- }
294
- return null;
295
- }
296
- function resolveFavoriteStatus(record, options) {
297
- if (options?.isFavorite !== void 0) {
298
- return {
299
- isFavorite: !!options.isFavorite,
300
- favoritedAt: safeTimestamp(options.favoritedAt)
301
- };
302
- }
303
- if (record?.isFavorite === true) {
304
- return {
305
- isFavorite: true,
306
- favoritedAt: safeTimestamp(record?.favoritedAt)
307
- };
308
- }
309
- const favoritesMap = options?.favoritesMap;
310
- if (!favoritesMap) {
311
- return { isFavorite: false, favoritedAt: null };
312
- }
313
- const candidateKeys = [];
314
- if (typeof record?.dbKey === "string" && record.dbKey) candidateKeys.push(record.dbKey);
315
- if (typeof record?.privateKey === "string" && record.privateKey) candidateKeys.push(record.privateKey);
316
- if (typeof record?.publicKey === "string" && record.publicKey) candidateKeys.push(record.publicKey);
317
- if (typeof record?.verifiedAgentKey === "string" && record.verifiedAgentKey) {
318
- candidateKeys.push(record.verifiedAgentKey);
319
- }
320
- if (typeof record?.id === "string" && record.id) {
321
- candidateKeys.push(record.id);
322
- candidateKeys.push(publicAgentKey(record.id));
323
- if (options?.userId) {
324
- candidateKeys.push(ownedAgentKey(options.userId, record.id));
325
- }
326
- }
327
- let matched = false;
328
- let highestFavAt = null;
329
- let highestFavTime = -1;
330
- for (const key of candidateKeys) {
331
- const val = favoritesMap instanceof Map ? favoritesMap.get(key) : favoritesMap[key];
332
- if (val !== void 0 && val !== false && val !== null) {
333
- const favAt = val === true ? 1 : safeTimestamp(val);
334
- if (favAt === null) continue;
335
- matched = true;
336
- const time = parseTimestamp(favAt);
337
- if (time > highestFavTime) {
338
- highestFavTime = time;
339
- highestFavAt = favAt;
340
- }
341
- }
342
- }
343
- if (matched) {
344
- return {
345
- isFavorite: true,
346
- favoritedAt: highestFavAt ?? 1
347
- };
348
- }
349
- return { isFavorite: false, favoritedAt: null };
350
- }
351
- function isOwnedAgentRecord(record, userId) {
352
- if (!userId) return false;
353
- if (typeof record?.userId === "string" && record.userId === userId || typeof record?.ownerId === "string" && record.ownerId === userId) {
354
- return true;
355
- }
356
- return [record?.dbKey, record?.privateKey].some(
357
- (key) => isOwnedAgentKey(key, userId)
358
- );
359
- }
360
- function toSafeAgentSummary(record, options) {
361
- const rawId = parseAgentRecordId(
362
- typeof record?.privateKey === "string" ? record.privateKey : record?.dbKey,
363
- typeof record?.id === "string" ? record.id : void 0
364
- );
365
- const id = rawId ?? (typeof record?.id === "string" ? record.id : null);
366
- const publicRecordDenied = record?.publicRecordExists === false || options?.publicRecordExists === false;
367
- const publicRecordConfirmed = record?.publicRecordExists === true || options?.publicRecordExists === true;
368
- let publicKey;
369
- if (typeof record?.publicKey === "string" && record.publicKey && !publicRecordDenied) {
370
- publicKey = record.publicKey;
371
- } else if (publicRecordConfirmed && id) {
372
- publicKey = publicAgentKey(id);
373
- }
374
- const name = typeof record?.name === "string" && record.name ? record.name : "(unnamed)";
375
- const handle = typeof record?.handle === "string" && record.handle ? record.handle : null;
376
- const introduction = typeof record?.introduction === "string" && record.introduction ? record.introduction : typeof record?.description === "string" && record.description ? record.description : null;
377
- const model = typeof record?.model === "string" && record.model ? record.model : null;
378
- const provider = typeof record?.provider === "string" && record.provider ? record.provider : typeof record?.apiSource === "string" && record.apiSource ? record.apiSource : null;
379
- const apiSource = typeof record?.apiSource === "string" && record.apiSource ? record.apiSource : null;
380
- const cliProvider = typeof record?.cliProvider === "string" && record.cliProvider ? record.cliProvider : null;
381
- const tools = Array.isArray(record?.tools) ? record.tools.filter((t) => typeof t === "string") : [];
382
- const inputPrice = typeof record?.inputPrice === "number" && Number.isFinite(record.inputPrice) ? record.inputPrice : null;
383
- const outputPrice = typeof record?.outputPrice === "number" && Number.isFinite(record.outputPrice) ? record.outputPrice : null;
384
- const modelAbility = model ? getModelAbility(model) ?? null : null;
385
- const favStatus = resolveFavoriteStatus(record, options);
386
- const isPublic = record?.isPublic === true || record?.isPublicFlag === true || record?.publicRecordExists === true;
387
- const updatedAt = safeTimestamp(record?.updatedAt ?? record?.createdAt ?? record?.created);
388
- const nextAvailableAt = typeof record?.nextAvailableAt === "number" && Number.isFinite(record.nextAvailableAt) ? record.nextAvailableAt : void 0;
389
- const quotaExhaustion = record?.quotaExhaustion && typeof record.quotaExhaustion.observedAt === "number" && Number.isFinite(record.quotaExhaustion.observedAt) ? { observedAt: record.quotaExhaustion.observedAt } : void 0;
390
- const rawQuota = record?.quota;
391
- const quota = rawQuota && typeof rawQuota === "object" && Array.isArray(rawQuota.windows) && typeof rawQuota.observedAt === "number" && Number.isFinite(rawQuota.observedAt) ? rawQuota : void 0;
392
- const currentUserId = options?.userId;
393
- const ownedKey = currentUserId ? [record?.dbKey, record?.privateKey].find(
394
- (key) => isOwnedAgentKey(key, currentUserId)
395
- ) : void 0;
396
- const isOwned = isOwnedAgentRecord(record, currentUserId);
397
- const isOAuth = isOAuthApiKeyRef(record?.apiKeyRef);
398
- const billingSource = resolveBillingSource({
399
- ...record,
400
- isOAuth,
401
- isOwned,
402
- apiSource,
403
- cliProvider,
404
- provider,
405
- isPublic
406
- });
407
- const economics = resolveEconomicsSnapshot(
408
- {
409
- provider,
410
- apiSource,
411
- customProviderUrl: typeof record?.customProviderUrl === "string" ? record.customProviderUrl : null
412
- },
413
- options?.now ?? Date.now()
414
- );
415
- const verifiedSharedKey = typeof record?.verifiedAgentKey === "string" && record.verifiedAgentKey ? record.verifiedAgentKey : void 0;
416
- let agentKey;
417
- if (currentUserId) {
418
- if (isOwned) {
419
- agentKey = ownedKey ?? (id ? ownedAgentKey(currentUserId, id) : void 0);
420
- } else if (publicKey) {
421
- agentKey = publicKey;
422
- } else {
423
- agentKey = verifiedSharedKey;
424
- }
425
- }
426
- const rawCredRef = (typeof record?.apiKeyRef === "string" && record.apiKeyRef ? record.apiKeyRef : void 0) ?? (typeof record?.credentialRef === "string" && record.credentialRef ? record.credentialRef : void 0);
427
- const credInfo = deriveCredentialGroup(record?.credentialGroup ?? rawCredRef);
428
- const credentialGroup = record?.credentialGroup ?? credInfo?.credentialGroup;
429
- const credentialKind = record?.credentialKind ?? credInfo?.credentialKind;
430
- const availability = resolveAgentAvailability(
431
- { nextAvailableAt, quota, quotaExhaustion },
432
- options?.now ?? Date.now()
433
- );
434
- return {
435
- id,
436
- ...agentKey !== void 0 ? { agentKey } : {},
437
- ...publicKey !== void 0 ? { publicKey } : {},
438
- name,
439
- handle,
440
- introduction,
441
- model,
442
- modelTier: resolveModelTier(model),
443
- provider,
444
- apiSource,
445
- cliProvider,
446
- billingSource,
447
- tools,
448
- inputPrice,
449
- outputPrice,
450
- modelAbility,
451
- isFavorite: favStatus.isFavorite,
452
- favoritedAt: favStatus.favoritedAt,
453
- isPublic,
454
- ...economics ? { economics } : {},
455
- isOwned,
456
- isOAuth,
457
- ...nextAvailableAt !== void 0 ? { nextAvailableAt } : {},
458
- availabilityStatus: availability.status,
459
- availabilityReason: availability.reason,
460
- ...quota !== void 0 ? { quota } : {},
461
- ...quotaExhaustion ? { quotaExhaustion } : {},
462
- ...credentialGroup !== void 0 ? { credentialGroup } : {},
463
- ...credentialKind !== void 0 ? { credentialKind } : {},
464
- // 「未知 ≠ 独立」:无 credentialGroup 时显式 credentialed:false,调用方
465
- // 不得把缺失解读成独立凭证(并发扇出守卫依赖这个区分)。
466
- credentialed: credentialGroup !== void 0,
467
- updatedAt
468
- };
469
- }
470
- function sortSafeAgentSummaries(agents) {
471
- return [...agents].sort(compareAgentSelection);
472
- }
473
- var COMPACT_AGENT_SUMMARY_FIELDS = [
474
- // —— 派发决策必需(短字段,必须排最前)——
475
- // agentKey 是唯一不可推导、必须逐字复制的字段;截断时它首先被保住。
476
- "agentKey",
477
- "name",
478
- "model",
479
- "modelTier",
480
- "billingSource",
481
- "availabilityStatus",
482
- "credentialGroup",
483
- "isFavorite",
484
- "isOAuth",
485
- "isOwned",
486
- "isPublic",
487
- // —— 次要身份/来源字段(仍很短)——
488
- "provider",
489
- "apiSource",
490
- "credentialKind",
491
- "credentialed",
492
- // 仅限流中的 agent 才会带(可用 agent 上不存在)。额度/冷却只作参考信息,
493
- // 不参与派发门控:这类 agent 同样在 agents 主列表里(带标注),不做过滤,
494
- // 所以这两个字段只在确实限流时才占字节。
495
- "nextAvailableAt",
496
- "availabilityReason",
497
- // —— 体积大的说明性字段(排在每条记录最后,截断时先牺牲它们)——
498
- // Phase 2A economics 快照(period/multipliers/changesAt 等小对象)。
499
- // 只对 DeepSeek API / BigModel GLM Coding Plan 存在;不含完整 policy/windows。
500
- "economics",
501
- "tools",
502
- // 额度快照(windows 数组,体积最大):只有上游真上报过窗口的 agent 才带。
503
- "quota"
504
- ];
505
- function omitNullishAgentSummaryFields(summary) {
506
- const result = {};
507
- for (const [key, value] of Object.entries(summary)) {
508
- if (value !== null && value !== void 0) {
509
- result[key] = value;
510
- }
511
- }
512
- return result;
513
- }
514
- function toCompactAgentSummary(summary) {
515
- const compact = {};
516
- for (const field of COMPACT_AGENT_SUMMARY_FIELDS) {
517
- const value = summary[field];
518
- if (value !== null && value !== void 0) {
519
- compact[field] = value;
520
- }
521
- }
522
- return compact;
523
- }
524
- var ULTRA_COMPACT_AGENT_SUMMARY_FIELDS = [
525
- // —— 派发决策与关键准入语义(必须保留,不能宣称安全但丢证据)——
526
- "agentKey",
527
- "name",
528
- "model",
529
- "modelTier",
530
- "billingSource",
531
- "availabilityStatus",
532
- "credentialGroup",
533
- "isFavorite",
534
- "isOAuth",
535
- "isOwned",
536
- "isPublic",
537
- "provider",
538
- "apiSource",
539
- "credentialKind",
540
- "credentialed",
541
- "nextAvailableAt",
542
- "availabilityReason",
543
- "economics",
544
- "tools",
545
- "quota"
546
- ];
547
- function toUltraCompactAgentSummary(summary) {
548
- const compact = {};
549
- for (const field of ULTRA_COMPACT_AGENT_SUMMARY_FIELDS) {
550
- const value = summary[field];
551
- if (value !== null && value !== void 0) {
552
- compact[field] = value;
553
- }
554
- }
555
- return compact;
556
- }
557
-
558
- // packages/ai/agent/agentDiscovery.ts
559
- function isPreferredAgent(agent) {
560
- return agent.isFavorite === true || agent.isOwned === true || agent.isOAuth === true || agent.billingSource === "user_subscription" || agent.billingSource === "user_api" || agent.billingSource === "local";
561
- }
562
- function isPublicDiscoveryAgent(agent) {
563
- return agent.isPublic === true && !isPreferredAgent(agent);
564
- }
565
- function resolveDiscoveryScope(args) {
566
- const rawScope = typeof args?.scope === "string" ? args.scope.trim().toLowerCase() : void 0;
567
- const hasScope = rawScope !== void 0 && rawScope !== "";
568
- const hasPublicOnly = typeof args?.publicOnly === "boolean";
569
- const publicOnly = args?.publicOnly === true;
570
- if (hasScope) {
571
- if (rawScope !== "preferred" && rawScope !== "public" && rawScope !== "all") {
572
- throw new Error(`Invalid scope '${args?.scope}': must be 'preferred', 'public', or 'all'.`);
573
- }
574
- const scope = rawScope;
575
- if (hasPublicOnly) {
576
- if (publicOnly && scope !== "public") {
577
- throw new Error(
578
- `Conflicting arguments: scope='${args?.scope}' conflicts with publicOnly=true.`
579
- );
580
- }
581
- if (!publicOnly && scope === "public") {
582
- throw new Error(
583
- `Conflicting arguments: scope='${args?.scope}' conflicts with publicOnly=false.`
584
- );
585
- }
586
- }
587
- return scope;
588
- }
589
- if (hasPublicOnly && publicOnly) {
590
- return "public";
591
- }
592
- return "all";
593
- }
594
- function agentIdentityKeys(agent) {
595
- return [agent.agentKey, agent.publicKey, agent.id].filter(
596
- (key) => typeof key === "string" && key.length > 0
597
- );
598
- }
599
- function deduplicateAgentSummaries(agents) {
600
- const byIdentity = /* @__PURE__ */ new Map();
601
- for (const agent of agents) {
602
- const keys = agentIdentityKeys(agent);
603
- const existing = keys.map((key) => byIdentity.get(key)).find(Boolean);
604
- if (!existing) {
605
- for (const key of keys) byIdentity.set(key, agent);
606
- continue;
607
- }
608
- const winner = isPreferredAgent(agent) && !isPreferredAgent(existing) ? agent : existing;
609
- for (const key of /* @__PURE__ */ new Set([...agentIdentityKeys(existing), ...keys])) byIdentity.set(key, winner);
610
- }
611
- return [...new Set(byIdentity.values())];
612
- }
613
- function filterAgentsByScope(agents, scope) {
614
- const unique = deduplicateAgentSummaries(agents);
615
- if (scope === "preferred") return unique.filter((agent) => isPreferredAgent(agent));
616
- if (scope === "public") return unique.filter((agent) => isPublicDiscoveryAgent(agent));
617
- return unique.filter((agent) => isPreferredAgent(agent) || agent.isPublic === true);
618
- }
619
- function resolvePaginationArgs(args) {
620
- let limit;
621
- let offset;
622
- if (args?.limit !== void 0 && args?.limit !== null) {
623
- const raw = args.limit;
624
- if (typeof raw === "boolean") {
625
- throw new Error(`Invalid limit '${raw}': must be a positive integer.`);
626
- }
627
- if (typeof raw === "number") {
628
- if (!Number.isInteger(raw) || raw <= 0) {
629
- throw new Error(`Invalid limit '${raw}': must be a positive integer.`);
630
- }
631
- limit = Math.min(raw, 500);
632
- } else if (typeof raw === "string") {
633
- if (raw.trim() !== "") {
634
- if (!/^\d+$/.test(raw.trim())) {
635
- throw new Error(`Invalid limit '${raw}': must be a positive integer.`);
636
- }
637
- const parsed = Number(raw.trim());
638
- if (!Number.isInteger(parsed) || parsed <= 0) {
639
- throw new Error(`Invalid limit '${raw}': must be a positive integer.`);
640
- }
641
- limit = Math.min(parsed, 500);
642
- }
643
- } else {
644
- throw new Error(`Invalid limit '${String(raw)}': must be a positive integer.`);
645
- }
646
- }
647
- if (args?.offset !== void 0 && args?.offset !== null) {
648
- const raw = args.offset;
649
- if (typeof raw === "boolean") {
650
- throw new Error(`Invalid offset '${raw}': must be a non-negative integer.`);
651
- }
652
- if (typeof raw === "number") {
653
- if (!Number.isInteger(raw) || raw < 0) {
654
- throw new Error(`Invalid offset '${raw}': must be a non-negative integer.`);
655
- }
656
- offset = raw;
657
- } else if (typeof raw === "string") {
658
- if (raw.trim() !== "") {
659
- if (!/^\d+$/.test(raw.trim())) {
660
- throw new Error(`Invalid offset '${raw}': must be a non-negative integer.`);
661
- }
662
- const parsed = Number(raw.trim());
663
- if (!Number.isInteger(parsed) || parsed < 0) {
664
- throw new Error(`Invalid offset '${raw}': must be a non-negative integer.`);
665
- }
666
- offset = parsed;
667
- }
668
- } else {
669
- throw new Error(`Invalid offset '${String(raw)}': must be a non-negative integer.`);
670
- }
671
- }
672
- return { limit, offset };
673
- }
674
- function matchesAgentQuery(agent, query) {
675
- if (!query || typeof query !== "string") return true;
676
- const q = query.trim().toLowerCase();
677
- if (!q) return true;
678
- const candidates = [
679
- agent.name,
680
- agent.model,
681
- agent.provider,
682
- agent.handle,
683
- agent.agentKey,
684
- agent.publicKey,
685
- agent.id
686
- ];
687
- return candidates.some((text) => typeof text === "string" && text.toLowerCase().includes(q));
688
- }
689
- function buildAgentDiscoveryResult(options) {
690
- const scope = resolveDiscoveryScope({
691
- scope: options.scope,
692
- publicOnly: options.publicOnly
693
- });
694
- const now = options.now ?? Date.now();
695
- let scopedAgents = filterAgentsByScope(options.agents, scope);
696
- if (options.query && typeof options.query === "string" && options.query.trim()) {
697
- scopedAgents = scopedAgents.filter((a) => matchesAgentQuery(a, options.query));
698
- }
699
- scopedAgents = scopedAgents.map((agent) => {
700
- const decision = resolveAgentAvailability(agent, now);
701
- if (decision.status === "quota_exhausted") {
702
- const resetAt = decision.resetAt ?? now + DEFAULT_PROVIDER_RETRY_MS;
703
- const nextAvailableAt = typeof agent.nextAvailableAt === "number" && agent.nextAvailableAt > resetAt ? agent.nextAvailableAt : resetAt;
704
- return {
705
- ...agent,
706
- nextAvailableAt,
707
- availableAt: nextAvailableAt,
708
- availabilityStatus: decision.status,
709
- availabilityReason: decision.reason
710
- };
711
- }
712
- return {
713
- ...agent,
714
- availabilityStatus: decision.status,
715
- availabilityReason: decision.reason
716
- };
717
- });
718
- const unavailableCount = scopedAgents.filter((a) => isAgentUnavailableNow(a, now)).length;
719
- const credentialGroups = summarizeCredentialGroups(scopedAgents, now);
720
- const pagination = resolvePaginationArgs({
721
- limit: options.limit,
722
- offset: options.offset
723
- });
724
- const offset = pagination.offset;
725
- const limit = pagination.limit;
726
- const sortedAgents = sortSafeAgentSummaries(scopedAgents);
727
- const hasQuery = Boolean(options.query && typeof options.query === "string" && options.query.trim());
728
- const hasFilteredCandidates = sortedAgents.length < options.agents.length;
729
- let total;
730
- if (hasQuery) {
731
- total = sortedAgents.length;
732
- } else if (hasFilteredCandidates) {
733
- total = sortedAgents.length;
734
- } else if (scope === "public") {
735
- total = typeof options.upstreamTotal === "number" && options.upstreamTotal > sortedAgents.length ? options.upstreamTotal : sortedAgents.length;
736
- } else if (scope === "all") {
737
- const privateOnlyCount = scopedAgents.filter((a) => isPreferredAgent(a) && a.isPublic !== true).length;
738
- const publicPulledCount = scopedAgents.filter((a) => a.isPublic === true).length;
739
- const effectivePublicTotal = typeof options.upstreamTotal === "number" && options.upstreamTotal > publicPulledCount ? options.upstreamTotal : publicPulledCount;
740
- total = options.upstreamTruncated === true ? privateOnlyCount + effectivePublicTotal : sortedAgents.length;
741
- } else {
742
- total = typeof options.upstreamTotal === "number" && options.upstreamTotal > sortedAgents.length ? options.upstreamTotal : sortedAgents.length;
743
- }
744
- const isTruncated = options.upstreamTruncated === true || !hasQuery && !hasFilteredCandidates && typeof options.upstreamTotal === "number" && options.upstreamTotal > sortedAgents.length;
745
- const pagedAgents = typeof limit === "number" || typeof offset === "number" ? sortedAgents.slice(
746
- offset ?? 0,
747
- (offset ?? 0) + (limit ?? sortedAgents.length)
748
- ) : sortedAgents;
749
- const projectedAgents = options.verbose === true ? pagedAgents.map(omitNullishAgentSummaryFields) : options.compact === true ? pagedAgents.map(toUltraCompactAgentSummary) : pagedAgents.map(toCompactAgentSummary);
750
- return {
751
- total,
752
- ...typeof offset === "number" ? { offset } : {},
753
- ...typeof limit === "number" ? { limit } : {},
754
- ...isTruncated ? { truncated: true } : {},
755
- unavailableCount,
756
- agents: projectedAgents,
757
- credentialGroups
758
- };
759
- }
760
- function toDiscoverySafeAgentSummary(record, options) {
761
- const mergedOptions = record?.publicRecordExists === true ? { ...options, publicRecordExists: true } : options;
762
- return toSafeAgentSummary(record, mergedOptions);
763
- }
764
-
765
- export {
766
- resolveBillingSource,
767
- deriveCredentialGroup,
768
- deriveCustomProviderCredentialGroup,
769
- summarizeCredentialGroups,
770
- isOwnedAgentRecord,
771
- resolveDiscoveryScope,
772
- resolvePaginationArgs,
773
- matchesAgentQuery,
774
- buildAgentDiscoveryResult,
775
- toDiscoverySafeAgentSummary
776
- };