nolo-cli 0.211.0 → 0.212.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (158) hide show
  1. package/{_executeModel-VVQEOY3D.js → _executeModel-KE6MBNUJ.js} +51 -48
  2. package/{action-U235TV4P.js → action-DF5UYSJF.js} +4 -4
  3. package/{addContentAction-7C76J7ST.js → addContentAction-N2YC5IL3.js} +8 -8
  4. package/{addDialogAgentAction-KTYANUEC.js → addDialogAgentAction-3NKVQCEC.js} +15 -12
  5. package/{agentDeleteCommand-WHRU6VDJ.js → agentDeleteCommand-NWK7VU4N.js} +71 -67
  6. package/{agentEmailCommands-ALLHXPW3.js → agentEmailCommands-UZ4DHEX2.js} +77 -72
  7. package/{agentListCommands-POKMEKMS.js → agentListCommands-HE7L2A6L.js} +190 -77
  8. package/{agentMachineCommands-WJLZLBPI.js → agentMachineCommands-6TE4MBMP.js} +30 -29
  9. package/{agentProviderCommands-MN3ABDME.js → agentProviderCommands-Q5O33MED.js} +33 -4
  10. package/{agentRecordCommands-OULZW3KM.js → agentRecordCommands-L3QQ7HZ4.js} +66 -61
  11. package/{agentRunCommand-ZNG4LGNQ.js → agentRunCommand-2IFGQHCO.js} +68 -64
  12. package/{agentRunControl-AF7BMR22.js → agentRunControl-OI3LOENH.js} +7 -6
  13. package/{agentRuntimeLocal-YMUHFV5M.js → agentRuntimeLocal-HL526DNQ.js} +28 -25
  14. package/{agentSlice-WNGUIMQZ.js → agentSlice-TMYP2UEA.js} +12 -12
  15. package/{appDeleteCommands-6MXPLAVF.js → appDeleteCommands-ZERW4AXY.js} +30 -29
  16. package/{appDeployCommands-ERRSVASW.js → appDeployCommands-DUWSMYHL.js} +30 -29
  17. package/{appDeployStatusCommands-ULICISLI.js → appDeployStatusCommands-N2KIE4BF.js} +30 -29
  18. package/{appGetCommands-WYYYWROF.js → appGetCommands-YVR4NPVY.js} +30 -29
  19. package/{appListCommands-DFCUCRCV.js → appListCommands-JS6HOHZS.js} +30 -29
  20. package/{authCommand-ZJMWXFMA.js → authCommand-FE2C3ZUM.js} +14 -14
  21. package/{authCommands-WK6E42L2.js → authCommands-HV3EAU3V.js} +2 -2
  22. package/{builtinSkillRegistry-HH75G5J3.js → builtinSkillRegistry-3YOIGEF6.js} +5 -4
  23. package/{chunk-JKW6LERJ.js → chunk-22CIEBYO.js} +14 -14
  24. package/{chunk-6HVBI6TI.js → chunk-25JZEIXN.js} +1 -218
  25. package/{chunk-TRZP7JZ7.js → chunk-2QHFH3DR.js} +1 -0
  26. package/{chunk-4LEGTOSR.js → chunk-3AKFVZ2I.js} +1 -1
  27. package/{chunk-XE4Q46FF.js → chunk-3CGG2PAL.js} +1 -1
  28. package/{chunk-25M2K6OA.js → chunk-3FOQHGHN.js} +3 -3
  29. package/{chunk-BSISWVB4.js → chunk-4I7ERB7F.js} +1 -1
  30. package/{chunk-TCTSYFDM.js → chunk-4KH4J3G5.js} +19 -6
  31. package/{chunk-NEZGPBL7.js → chunk-5AQR3DGV.js} +2 -2
  32. package/{chunk-YLTLB5A7.js → chunk-5RYBGBQH.js} +7 -6
  33. package/{chunk-RIALQUSF.js → chunk-6NSSLV67.js} +5 -5
  34. package/{chunk-RXCCWVA2.js → chunk-6OQUPIQF.js} +3 -3
  35. package/chunk-6VLJ6YA7.js +11751 -0
  36. package/{chunk-27E2CBBY.js → chunk-7OCO4TDT.js} +1 -1
  37. package/chunk-7RFNTILS.js +2213 -0
  38. package/{chunk-4WCEC56C.js → chunk-AVTVGMDY.js} +1 -1
  39. package/{chunk-3J3U3KXB.js → chunk-B7NJ3T4A.js} +4 -4
  40. package/{chunk-UMEGDH6A.js → chunk-BFM34N54.js} +7 -7
  41. package/chunk-CJEIOP3E.js +0 -0
  42. package/{chunk-YXOBCDNW.js → chunk-CJRONOYL.js} +5 -5
  43. package/{chunk-LT3EAHJY.js → chunk-CQ46IRNN.js} +38 -36
  44. package/{chunk-NTSRCTUX.js → chunk-CTPXME7U.js} +2 -2
  45. package/{chunk-M4NTDZG3.js → chunk-D5RCRX4A.js} +134 -141
  46. package/{chunk-25OB36GU.js → chunk-DM6UMOEL.js} +4 -4
  47. package/{chunk-TPCDYNJK.js → chunk-EYUBHHFB.js} +1 -1
  48. package/{chunk-Y6M7KJOA.js → chunk-EZFQ6XRV.js} +2 -2
  49. package/{chunk-ZOO3WJIE.js → chunk-FHU44LN3.js} +711 -40
  50. package/chunk-FY7F4Q6X.js +127 -0
  51. package/chunk-G7MLNNEX.js +84 -0
  52. package/{chunk-RYWO5AKN.js → chunk-GNDJKC4B.js} +10 -10
  53. package/{chunk-V3M6IXQI.js → chunk-GPO7FCEZ.js} +187 -36
  54. package/{chunk-RQ22OZD7.js → chunk-H2TJUNCH.js} +1 -1
  55. package/{chunk-C2XZM3K4.js → chunk-HIRC32DV.js} +5 -24
  56. package/{chunk-QQM464AL.js → chunk-HPFCI4SK.js} +3 -3
  57. package/chunk-HRMJUN5J.js +26 -0
  58. package/{chunk-HD3WR3TD.js → chunk-IAPCBNEE.js} +1 -1
  59. package/{chunk-XDMGY5IU.js → chunk-IF45XG7K.js} +220 -9
  60. package/{chunk-NLT32XBZ.js → chunk-IIQ6JGRI.js} +2 -2
  61. package/{chunk-OP7PTBAJ.js → chunk-IJXYFTV7.js} +8 -8
  62. package/{chunk-IIHY4ZAI.js → chunk-INSBKSBB.js} +8 -4
  63. package/{chunk-PAFTGNWA.js → chunk-JIT6FSXJ.js} +1 -1
  64. package/{chunk-WTKYP6QO.js → chunk-JTDORD5P.js} +5 -5
  65. package/{chunk-ECX3NKRD.js → chunk-JY5NGFFH.js} +11 -0
  66. package/chunk-KC4XDTT3.js +227 -0
  67. package/{chunk-PLYWH7XM.js → chunk-KIM6CLW5.js} +7 -7
  68. package/{chunk-SCYQJPGA.js → chunk-M6RL5JCD.js} +147 -20
  69. package/chunk-MMA3LZ3W.js +105 -0
  70. package/{chunk-I5PBXF7O.js → chunk-MMNYUVLW.js} +1 -1
  71. package/{chunk-NHQKWPLP.js → chunk-NJR3WKVP.js} +24 -22
  72. package/{chunk-W5VC7F7V.js → chunk-NOMIGOST.js} +59 -60
  73. package/{chunk-WI6OGHXJ.js → chunk-NRFKLKRU.js} +5 -5
  74. package/{chunk-NXCGNS4N.js → chunk-OHNELDTO.js} +1 -1
  75. package/{chunk-7IYBN7IA.js → chunk-OOF4UPC5.js} +22 -13
  76. package/{chunk-UIOEHFF6.js → chunk-OQHIVPG4.js} +1 -0
  77. package/{chunk-X4F26D5K.js → chunk-P5L7CXOC.js} +58 -33
  78. package/{chunk-5ORJGHTL.js → chunk-PDGKOTO7.js} +5 -5
  79. package/{chunk-UCPAVEQB.js → chunk-PYRUW7XN.js} +1 -1
  80. package/{chunk-SU3QL7YG.js → chunk-QT6PKHYJ.js} +1 -1
  81. package/{chunk-SN5XE6GQ.js → chunk-RPQXPZZF.js} +4 -4
  82. package/{chunk-ZN5AH4BY.js → chunk-RU4SD66C.js} +6 -6
  83. package/{chunk-YKFP6UGT.js → chunk-SOHTHFV2.js} +14 -14
  84. package/{chunk-CKOO42G5.js → chunk-UHJGXRJ4.js} +4 -4
  85. package/{chunk-CVCRAO6Q.js → chunk-UTV2AYEG.js} +9 -7
  86. package/{chunk-DQLB4NQ3.js → chunk-VPAZOH2D.js} +2 -2
  87. package/{chunk-MBS6CTZB.js → chunk-VZKUKCA6.js} +236 -1993
  88. package/{chunk-LNYHAKBP.js → chunk-W4S457LU.js} +1 -1
  89. package/chunk-WPORQFYN.js +74 -0
  90. package/{chunk-ET2CWLIJ.js → chunk-WXYLV624.js} +3 -3
  91. package/chunk-XFYFMTOM.js +92 -0
  92. package/{chunk-NV572QM3.js → chunk-YJMRHHGY.js} +15 -15
  93. package/{chunk-JBOUVTZX.js → chunk-YOIW77S2.js} +13 -2
  94. package/{chunk-ADBWFYJD.js → chunk-YPD3VJZW.js} +9 -9
  95. package/{chunk-DA7CTWT4.js → chunk-YWSEPJ7C.js} +5 -5
  96. package/{chunk-3V2QMRNN.js → chunk-ZL5RAEEB.js} +3 -3
  97. package/cliAgentConfigHelpers-WJBZQTLW.js +41 -0
  98. package/{commandRegistry-FI2IOQ3U.js → commandRegistry-VVMTPFAX.js} +85 -81
  99. package/{contentThunks-5LKNNDGY.js → contentThunks-N52O67MI.js} +25 -24
  100. package/{createAgentAutomationAction-TI4QG4CY.js → createAgentAutomationAction-ZC57YRSV.js} +25 -24
  101. package/{createDialogAction-TJ3JKLO4.js → createDialogAction-VQW5WDYX.js} +27 -26
  102. package/{createPageAction-GKXT6WEH.js → createPageAction-M5VDA7SC.js} +26 -25
  103. package/{dbSlice-LPMZ2DGJ.js → dbSlice-HP7G4LX3.js} +7 -7
  104. package/{deleteFile-EPUQHKPA.js → deleteFile-7VQGLK2V.js} +3 -3
  105. package/{dialogCommands-IWPXIZ5P.js → dialogCommands-JHMR2N2Y.js} +32 -30
  106. package/{dialogSlice-ZWNNS7GZ.js → dialogSlice-GRSVGDTF.js} +23 -22
  107. package/{dialogUsageCommand-ZCPPHPJ5.js → dialogUsageCommand-7KCPYGHG.js} +1 -1
  108. package/{docCreateCommands-HFSPKJSI.js → docCreateCommands-F2K3UPSQ.js} +28 -27
  109. package/{docDeleteCommands-CRL62POH.js → docDeleteCommands-XGXB5RFT.js} +29 -28
  110. package/{docReadCommands-QOTOX3XW.js → docReadCommands-7HWZZV6J.js} +28 -27
  111. package/{docStore-WYLRB7ED.js → docStore-KNZK6Y2G.js} +10 -10
  112. package/{docUpdateCommands-7BMH4MCA.js → docUpdateCommands-OZZ7NQII.js} +28 -27
  113. package/{fetchMessages-YY4SATNR.js → fetchMessages-M3QU7ZCQ.js} +1 -1
  114. package/{getPricing-OQXBJ6VZ.js → getPricing-2MNMXEVG.js} +3 -3
  115. package/{handleSendMessageAction-P27YP2DQ.js → handleSendMessageAction-SHIH74GJ.js} +46 -44
  116. package/hostCredentialCreate-X64WK4JD.js +357 -0
  117. package/index.js +5 -5
  118. package/{keys-P4ZDOVJW.js → keys-BEGDOTRL.js} +3 -1
  119. package/{localDialogRead-5VCMQQZF.js → localDialogRead-XRLAH4CZ.js} +1 -1
  120. package/{localRuntimeAdapter-GP6ZSSO3.js → localRuntimeAdapter-A7K3ABA6.js} +73 -66
  121. package/{machineCommands-6Z6H4BFX.js → machineCommands-DE3MR7CJ.js} +65 -60
  122. package/{machineWsRunDispatch-F2ZIXMYM.js → machineWsRunDispatch-R26P5V36.js} +65 -60
  123. package/{memberThunks-YSEFJF47.js → memberThunks-7WJAY5V6.js} +8 -8
  124. package/package.json +1 -1
  125. package/{projectArchive-PIGEOX3D.js → projectArchive-GGL5HLMD.js} +26 -25
  126. package/{providerPresetApply-ZYMLQA46.js → providerPresetApply-YXGV6NXB.js} +4 -4
  127. package/{providerRegistry-E34XWDLJ.js → providerRegistry-S6UL6UNA.js} +4 -4
  128. package/{read-DIIQBOOO.js → read-4VZQODSN.js} +3 -3
  129. package/{readDocTool-HXYGOEA7.js → readDocTool-AVD32RUJ.js} +1 -1
  130. package/{readlineWorkspace-UG25G7KC.js → readlineWorkspace-XKYKNL2I.js} +157 -100
  131. package/{removeDialogAgentAction-ALJDUJ2E.js → removeDialogAgentAction-FKL4BYMR.js} +17 -14
  132. package/{runAgentClientLoop-IO5F7TCZ.js → runAgentClientLoop-V7E2WBVM.js} +49 -46
  133. package/{runtimeDoctorCommands-PGAA47G5.js → runtimeDoctorCommands-QAI3MBKQ.js} +6 -6
  134. package/{secretCommands-ZCZ4KVET.js → secretCommands-4QS3HCA2.js} +3 -3
  135. package/{setDialogExtraReferencesAction-O3SVMD5A.js → setDialogExtraReferencesAction-TLIOLWWI.js} +10 -10
  136. package/{setPrimaryDialogAgentAction-HE7RVFFF.js → setPrimaryDialogAgentAction-2OLWRFYR.js} +18 -15
  137. package/{settingThunks-BWWJQG4L.js → settingThunks-UGBPCNYF.js} +12 -11
  138. package/{spaceCommands-UAELIFEI.js → spaceCommands-4KSLKVNF.js} +28 -27
  139. package/{streamAgentChatTurn-VUKZQYJR.js → streamAgentChatTurn-7FR7X2NU.js} +57 -54
  140. package/{switchDialogAgentAction-3VZS7SOS.js → switchDialogAgentAction-UZSAG2N5.js} +15 -12
  141. package/{tools-VRXJAVYI.js → tools-ZLKCC25W.js} +43 -40
  142. package/{tuiSummaryLlmCaller-TGCHZLSW.js → tuiSummaryLlmCaller-WC54MVGP.js} +10 -10
  143. package/{updateCommands-Q6CYAEYJ.js → updateCommands-4744PL3P.js} +3 -1
  144. package/{updateDialogTitleAction-MULWCJCW.js → updateDialogTitleAction-U53ZT7PJ.js} +38 -70
  145. package/usageCommand-F4IPVMIZ.js +32 -0
  146. package/usageRebuildCommand-HAW2AD5N.js +626 -0
  147. package/chunk-4LCOCOR5.js +0 -50
  148. package/chunk-7AUQ3WCW.js +0 -51
  149. package/chunk-ZRAU6T47.js +0 -56
  150. package/{agentFavoriteCommands-GAFEXKKP.js → agentFavoriteCommands-EDK743YA.js} +1 -1
  151. package/{agentGrantCommands-V5FOQKFD.js → agentGrantCommands-RQWK2TEV.js} +1 -1
  152. package/{agentPullCommand-2JMJP5BS.js → agentPullCommand-6EM3URVK.js} +1 -1
  153. package/{chunk-BTYQAODF.js → chunk-CZM5YTZ7.js} +3 -3
  154. package/{chunk-A2ZMIRLN.js → chunk-INN4LTAJ.js} +5 -5
  155. package/{chunk-XPHZK3PJ.js → chunk-JNKSDZFS.js} +3 -3
  156. package/{chunk-PV6JJAUB.js → chunk-TCZHTTUU.js} +8 -8
  157. package/{chunk-AKE53VMW.js → chunk-ZCWRMUWT.js} +0 -0
  158. package/{tableCommands-D7WR4QSM.js → tableCommands-MP6VFSVT.js} +3 -3
@@ -10,61 +10,60 @@ import {
10
10
  listRemotePublicAgents,
11
11
  normalizeListedAgent,
12
12
  parseAgentListArgs
13
- } from "./chunk-ET2CWLIJ.js";
14
- import {
15
- refreshSubscriptionQuotas
16
- } from "./chunk-YGILMZ7N.js";
13
+ } from "./chunk-WXYLV624.js";
17
14
  import {
18
15
  buildSpaceLookup,
19
16
  getSpaceContentKeys
20
17
  } from "./chunk-ID4G2MAR.js";
21
18
  import {
22
19
  readLiveDbRecordAfterTombstoneMerge
23
- } from "./chunk-4LEGTOSR.js";
20
+ } from "./chunk-3AKFVZ2I.js";
21
+ import {
22
+ refreshSubscriptionQuotas
23
+ } from "./chunk-YGILMZ7N.js";
24
24
  import {
25
25
  getReadableCliDb
26
26
  } from "./chunk-J5JTMQIA.js";
27
- import {
28
- queryUserRecords,
29
- readDbRecord
30
- } from "./chunk-XDMGY5IU.js";
31
27
  import {
32
28
  applyCredentialAvailability,
33
29
  clearCredentialAvailabilityIfMarkedAt,
34
30
  readCredentialAvailability,
35
31
  readEffectiveCredentialEntry
36
32
  } from "./chunk-GSQNH63I.js";
37
- import "./chunk-7AUQ3WCW.js";
38
- import "./chunk-NBTY7YJF.js";
33
+ import {
34
+ queryUserRecords,
35
+ readDbRecord
36
+ } from "./chunk-IF45XG7K.js";
39
37
  import "./chunk-LKZPX6YH.js";
38
+ import "./chunk-NBTY7YJF.js";
40
39
  import {
41
40
  buildAgentDiscoveryResult,
42
41
  matchesAgentQuery,
43
42
  resolvePaginationArgs,
44
43
  summarizeCredentialGroups,
45
44
  toDiscoverySafeAgentSummary
46
- } from "./chunk-YXOBCDNW.js";
45
+ } from "./chunk-CJRONOYL.js";
47
46
  import "./chunk-OXME3PEE.js";
48
47
  import {
49
48
  resolveNoloHome
50
49
  } from "./chunk-GLKOYSRU.js";
51
50
  import "./chunk-UEILX4EV.js";
52
51
  import "./chunk-D2MDMY2M.js";
53
- import "./chunk-ZOO3WJIE.js";
52
+ import "./chunk-FHU44LN3.js";
54
53
  import "./chunk-ZNFJWEN4.js";
55
- import "./chunk-NTSRCTUX.js";
56
- import "./chunk-TCTSYFDM.js";
54
+ import "./chunk-4KH4J3G5.js";
55
+ import "./chunk-CTPXME7U.js";
57
56
  import "./chunk-HNUWUO75.js";
58
57
  import "./chunk-CHOZJMJS.js";
59
58
  import "./chunk-PWTNI4N7.js";
60
59
  import "./chunk-Y63ZSOR6.js";
61
- import "./chunk-LNYHAKBP.js";
60
+ import "./chunk-W4S457LU.js";
62
61
  import "./chunk-4KB6WQUL.js";
63
62
  import "./chunk-56GBUMO5.js";
64
- import "./chunk-W5VC7F7V.js";
65
- import "./chunk-CVCRAO6Q.js";
63
+ import "./chunk-NOMIGOST.js";
64
+ import "./chunk-UTV2AYEG.js";
66
65
  import "./chunk-E2BESSAW.js";
67
- import "./chunk-6HVBI6TI.js";
66
+ import "./chunk-25JZEIXN.js";
68
67
  import {
69
68
  DEFAULT_PROVIDER_RETRY_MS,
70
69
  formatQuotaSummary,
@@ -74,34 +73,35 @@ import {
74
73
  resolveCredentialKeyWithFallback,
75
74
  shouldClearCooldownFromQuota
76
75
  } from "./chunk-YUXQAVRD.js";
76
+ import "./chunk-KC4XDTT3.js";
77
77
  import "./chunk-2WZXXAQD.js";
78
- import "./chunk-DA7CTWT4.js";
78
+ import "./chunk-YWSEPJ7C.js";
79
79
  import "./chunk-WJZOQR2J.js";
80
- import "./chunk-CKOO42G5.js";
80
+ import "./chunk-UHJGXRJ4.js";
81
81
  import "./chunk-2MBTWINN.js";
82
- import "./chunk-WTKYP6QO.js";
83
- import "./chunk-5ZUL4CUO.js";
84
- import "./chunk-BTYQAODF.js";
82
+ import "./chunk-JTDORD5P.js";
83
+ import "./chunk-CZM5YTZ7.js";
85
84
  import "./chunk-H57T64RA.js";
85
+ import "./chunk-5ZUL4CUO.js";
86
86
  import "./chunk-UKZX3NHN.js";
87
87
  import "./chunk-5MMAK75Q.js";
88
- import "./chunk-TRZP7JZ7.js";
89
- import "./chunk-UIOEHFF6.js";
88
+ import "./chunk-2QHFH3DR.js";
89
+ import "./chunk-OQHIVPG4.js";
90
90
  import "./chunk-KX6YBIHG.js";
91
91
  import "./chunk-DWLEOOGR.js";
92
92
  import "./chunk-7DPNBQSV.js";
93
- import "./chunk-G7Y4GXTY.js";
93
+ import "./chunk-T43B7LB2.js";
94
94
  import "./chunk-ZRSNONOB.js";
95
95
  import "./chunk-4VJAC32I.js";
96
- import "./chunk-AKE53VMW.js";
96
+ import "./chunk-CJEIOP3E.js";
97
+ import "./chunk-ZCWRMUWT.js";
97
98
  import "./chunk-ZC3CMUKU.js";
98
99
  import "./chunk-LOEO7LRC.js";
99
100
  import "./chunk-M2EJHDJP.js";
100
- import "./chunk-PLYWH7XM.js";
101
- import "./chunk-XPHZK3PJ.js";
101
+ import "./chunk-KIM6CLW5.js";
102
+ import "./chunk-JNKSDZFS.js";
102
103
  import "./chunk-PSCNXBYA.js";
103
- import "./chunk-6UBGXX2W.js";
104
- import "./chunk-PV6JJAUB.js";
104
+ import "./chunk-TCZHTTUU.js";
105
105
  import "./chunk-YUA6OAH5.js";
106
106
  import "./chunk-SM3NSZJV.js";
107
107
  import "./chunk-JRTNUU5Z.js";
@@ -109,6 +109,8 @@ import {
109
109
  toErrorMessage
110
110
  } from "./chunk-HNMXYYJR.js";
111
111
  import "./chunk-KUG52IAP.js";
112
+ import "./chunk-GOO6G4PY.js";
113
+ import "./chunk-QSJ3HFEF.js";
112
114
  import {
113
115
  parseUserIdFromAuthToken,
114
116
  readOption,
@@ -124,25 +126,25 @@ import "./chunk-4O22PGNQ.js";
124
126
  import {
125
127
  t
126
128
  } from "./chunk-3RQVYR4B.js";
129
+ import "./chunk-G7Y4GXTY.js";
130
+ import "./chunk-6UBGXX2W.js";
127
131
  import {
128
132
  createKey,
129
133
  createTokenKey
130
- } from "./chunk-ECX3NKRD.js";
134
+ } from "./chunk-JY5NGFFH.js";
131
135
  import "./chunk-XJWWBO34.js";
132
136
  import "./chunk-I42VC5KR.js";
133
137
  import "./chunk-U6VC4MU4.js";
134
138
  import "./chunk-WWC7I6TA.js";
135
139
  import "./chunk-3EUW3WEO.js";
136
140
  import "./chunk-G3SUCT4W.js";
137
- import "./chunk-T43B7LB2.js";
138
- import "./chunk-GOO6G4PY.js";
139
- import "./chunk-QSJ3HFEF.js";
140
141
  import "./chunk-4VNS5WPM.js";
141
142
 
142
143
  // packages/ai/agent/speedSampleCache.ts
143
144
  var SPEED_SAMPLE_DISK_CACHE_TTL_MS = 10 * 6e4;
144
- var SPEED_SAMPLE_SCAN_BUDGET_MS = 8e3;
145
- var SPEED_SAMPLE_CACHE_VERSION = 1;
145
+ var SPEED_SAMPLE_SCAN_BUDGET_MS = 2500;
146
+ var SPEED_SAMPLE_CACHE_VERSION = 2;
147
+ var SPEED_SAMPLE_LEGACY_CACHE_VERSION = 1;
146
148
  var isFiniteNumber = (value) => typeof value === "number" && Number.isFinite(value);
147
149
  var sanitizeSample = (value) => {
148
150
  if (!value || typeof value !== "object") return null;
@@ -151,23 +153,25 @@ var sanitizeSample = (value) => {
151
153
  if (isFiniteNumber(sample.firstOutputMs)) clean.firstOutputMs = sample.firstOutputMs;
152
154
  if (isFiniteNumber(sample.callDurationMs)) clean.callDurationMs = sample.callDurationMs;
153
155
  if (isFiniteNumber(sample.output_tokens)) clean.output_tokens = sample.output_tokens;
156
+ if (isFiniteNumber(sample.t)) clean.t = sample.t;
154
157
  return clean.firstOutputMs === void 0 && clean.callDurationMs === void 0 ? null : clean;
155
158
  };
156
- async function readSpeedSamplesCache(cachePath, options) {
157
- const ttlMs = isFiniteNumber(options.ttlMs) ? options.ttlMs : SPEED_SAMPLE_DISK_CACHE_TTL_MS;
159
+ var SPEED_SAMPLE_STALE_SNAPSHOT_MAX_MS = 7 * 24 * 60 * 6e4;
160
+ async function parseCacheFile(cachePath, userId) {
158
161
  try {
159
162
  const fs = await import("node:fs/promises");
160
163
  const raw = await fs.readFile(cachePath, "utf8");
161
164
  const parsed = JSON.parse(raw);
162
165
  if (!parsed || typeof parsed !== "object") return null;
163
- if (parsed.version !== SPEED_SAMPLE_CACHE_VERSION) return null;
164
- if (parsed.userId !== options.userId) return null;
166
+ const version = parsed.version;
167
+ if (version !== SPEED_SAMPLE_CACHE_VERSION && version !== SPEED_SAMPLE_LEGACY_CACHE_VERSION) {
168
+ return null;
169
+ }
170
+ if (parsed.userId !== userId) return null;
165
171
  if (!isFiniteNumber(parsed.at)) return null;
166
- const age = options.now - parsed.at;
167
- if (age < 0 || age >= ttlMs) return null;
168
- const samples = /* @__PURE__ */ new Map();
169
172
  const source = parsed.samples;
170
173
  if (!source || typeof source !== "object") return null;
174
+ const samples = /* @__PURE__ */ new Map();
171
175
  for (const [model, list] of Object.entries(source)) {
172
176
  if (!model || !Array.isArray(list)) continue;
173
177
  const cleaned = [];
@@ -177,17 +181,42 @@ async function readSpeedSamplesCache(cachePath, options) {
177
181
  }
178
182
  samples.set(model, cleaned);
179
183
  }
180
- return samples;
184
+ const complete = version === SPEED_SAMPLE_LEGACY_CACHE_VERSION ? true : parsed.complete === true;
185
+ const cursor = typeof parsed.cursor === "string" && parsed.cursor.length > 0 ? parsed.cursor : void 0;
186
+ return { samples, at: parsed.at, complete, cursor: complete ? void 0 : cursor };
181
187
  } catch {
182
188
  return null;
183
189
  }
184
190
  }
191
+ async function readSpeedSamplesSnapshot(cachePath, options) {
192
+ const maxAgeMs = isFiniteNumber(options.maxAgeMs) ? options.maxAgeMs : SPEED_SAMPLE_STALE_SNAPSHOT_MAX_MS;
193
+ const parsed = await parseCacheFile(cachePath, options.userId);
194
+ if (!parsed || !parsed.complete) return null;
195
+ const age = options.now - parsed.at;
196
+ if (age < 0 || age >= maxAgeMs) return null;
197
+ return { samples: parsed.samples, ageMs: age };
198
+ }
199
+ async function readSpeedSamplesProgress(cachePath, userId) {
200
+ const parsed = await parseCacheFile(cachePath, userId);
201
+ if (!parsed) return null;
202
+ return {
203
+ samples: parsed.samples,
204
+ at: parsed.at,
205
+ complete: parsed.complete,
206
+ ...parsed.cursor === void 0 ? {} : { cursor: parsed.cursor }
207
+ };
208
+ }
209
+ function resolveSpeedSamplesProgressPath(cachePath) {
210
+ return `${cachePath}.progress`;
211
+ }
185
212
  async function writeSpeedSamplesCache(cachePath, payload) {
186
213
  try {
187
214
  const fs = await import("node:fs/promises");
188
215
  const path2 = await import("node:path");
189
216
  await fs.mkdir(path2.dirname(cachePath), { recursive: true });
190
- await fs.writeFile(cachePath, JSON.stringify(payload), "utf8");
217
+ const tmpPath = `${cachePath}.tmp-${process.pid}-${Math.random().toString(36).slice(2, 8)}`;
218
+ await fs.writeFile(tmpPath, JSON.stringify(payload), "utf8");
219
+ await fs.rename(tmpPath, cachePath);
191
220
  } catch {
192
221
  }
193
222
  }
@@ -242,18 +271,28 @@ function resolveCandidateSpeedFacts(models, samplesByModel) {
242
271
  }
243
272
  var formatSeconds = (ms) => `${(ms / 1e3).toFixed(1)}s`;
244
273
  var formatTps = (tps) => String(Math.round(tps));
245
- var SPEED_CONTEXT_HEADER = "speed (observed=\u672C\u7528\u6237\u6700\u8FD1\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):";
246
- function formatCandidateSpeedFacts(facts) {
274
+ 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):";
275
+ function formatSnapshotAge(ageMs) {
276
+ const minutes = Math.floor(ageMs / 6e4);
277
+ if (minutes < 1) return "<1min";
278
+ if (minutes < 60) return `${minutes}min`;
279
+ const hours = Math.floor(minutes / 60);
280
+ if (hours < 24) return `${hours}h`;
281
+ return `${Math.floor(hours / 24)}d`;
282
+ }
283
+ function formatCandidateSpeedFacts(facts, options = {}) {
247
284
  if (facts.length === 0) return null;
248
285
  const lines = facts.map((fact) => {
249
286
  const tps = fact.outputTps !== void 0 ? formatTps(fact.outputTps) : "n/a";
250
287
  return ` ${fact.model}: firstOutput=${formatSeconds(fact.firstOutputMs ?? 0)} tps=${tps} [observed n=${fact.firstOutputSamples ?? 0} tpsN=${fact.tpsSamples ?? 0}]`;
251
288
  });
252
- return `${SPEED_CONTEXT_HEADER}
289
+ const age = options.snapshotAgeMs;
290
+ 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)` : "";
291
+ return `${SPEED_CONTEXT_HEADER}${note}
253
292
  ${lines.join("\n")}`;
254
293
  }
255
- function buildCandidateSpeedContext(models, samplesByModel) {
256
- return formatCandidateSpeedFacts(resolveCandidateSpeedFacts(models, samplesByModel));
294
+ function buildCandidateSpeedContext(models, samplesByModel, options = {}) {
295
+ return formatCandidateSpeedFacts(resolveCandidateSpeedFacts(models, samplesByModel), options);
257
296
  }
258
297
  var SPEED_SAMPLE_PAGE_SIZE = 2e3;
259
298
  var eventTime = (value) => {
@@ -275,13 +314,14 @@ function collectSample(collected, value) {
275
314
  });
276
315
  collected.set(model, list);
277
316
  }
278
- function finalizeSamples(collected) {
317
+ function finalizeSamples(collected, keepTime = false) {
279
318
  const result = /* @__PURE__ */ new Map();
280
319
  for (const [model, list] of collected) {
281
320
  list.sort((a, b) => b.t - a.t);
321
+ const window = list.slice(0, OBSERVED_SPEED_WINDOW);
282
322
  result.set(
283
323
  model,
284
- list.slice(0, OBSERVED_SPEED_WINDOW).map(({ t: _t, ...sample }) => sample)
324
+ keepTime ? window : window.map(({ t: _t, ...sample }) => sample)
285
325
  );
286
326
  }
287
327
  return result;
@@ -293,8 +333,9 @@ async function collectRecentSpeedSamples(db, userId, options = {}) {
293
333
  const failedPrefix = createKey("token", userId, "failed-call", "");
294
334
  const collected = /* @__PURE__ */ new Map();
295
335
  const startedAt = Date.now();
296
- let lastKey;
336
+ let lastKey = options.startAfter;
297
337
  let budgetExhausted = false;
338
+ let scanned = 0;
298
339
  while (true) {
299
340
  if (Date.now() - startedAt >= budgetMs) {
300
341
  budgetExhausted = true;
@@ -311,6 +352,7 @@ async function collectRecentSpeedSamples(db, userId, options = {}) {
311
352
  if (typeof key !== "string") continue;
312
353
  if (lastKey !== void 0 && key <= lastKey) continue;
313
354
  accepted += 1;
355
+ scanned += 1;
314
356
  newestKey = key;
315
357
  if (key.startsWith(failedPrefix)) continue;
316
358
  if (!raw || typeof raw !== "object") continue;
@@ -319,31 +361,75 @@ async function collectRecentSpeedSamples(db, userId, options = {}) {
319
361
  if (accepted === 0 || accepted < pageSize) break;
320
362
  lastKey = newestKey;
321
363
  }
322
- return { samples: finalizeSamples(collected), budgetExhausted };
364
+ return {
365
+ samples: finalizeSamples(collected, options.keepTime === true),
366
+ budgetExhausted,
367
+ scanned,
368
+ ...budgetExhausted && lastKey !== void 0 ? { nextCursor: lastKey } : {}
369
+ };
323
370
  }
324
- async function loadRecentSpeedSamples(db, userId, options = {}) {
325
- const { samples } = await collectRecentSpeedSamples(db, userId, options);
326
- return samples;
371
+ function mergeNewestSamples(into, from) {
372
+ for (const [model, list] of from) {
373
+ const merged = [...into.get(model) ?? [], ...list];
374
+ merged.sort(
375
+ (a, b) => (b.t ?? 0) - (a.t ?? 0)
376
+ );
377
+ into.set(model, merged.slice(0, OBSERVED_SPEED_WINDOW));
378
+ }
327
379
  }
328
380
  async function loadSpeedSamplesWithDiskCache(db, userId, now, cache) {
329
381
  try {
330
382
  const ttlMs = isFiniteNumber2(cache.ttlMs) ? cache.ttlMs : SPEED_SAMPLE_DISK_CACHE_TTL_MS;
331
- const cached = await readSpeedSamplesCache(cache.cachePath, { userId, now, ttlMs });
332
- if (cached) return cached;
333
- const { samples, budgetExhausted } = await collectRecentSpeedSamples(db, userId, {
334
- pageSize: cache.pageSize,
335
- budgetMs: isFiniteNumber2(cache.budgetMs) ? cache.budgetMs : SPEED_SAMPLE_SCAN_BUDGET_MS
336
- });
337
- if (budgetExhausted) return /* @__PURE__ */ new Map();
338
- await writeSpeedSamplesCache(cache.cachePath, {
383
+ const snapshot = await readSpeedSamplesSnapshot(cache.cachePath, { userId, now });
384
+ if (snapshot && snapshot.ageMs < ttlMs) return { samples: snapshot.samples };
385
+ const progressPath = resolveSpeedSamplesProgressPath(cache.cachePath);
386
+ const progress = await readSpeedSamplesProgress(progressPath, userId);
387
+ const resumable = progress && !progress.complete && progress.cursor ? progress : void 0;
388
+ const collected = new Map(resumable?.samples ?? []);
389
+ let step;
390
+ try {
391
+ step = await collectRecentSpeedSamples(db, userId, {
392
+ pageSize: cache.pageSize,
393
+ budgetMs: isFiniteNumber2(cache.budgetMs) ? cache.budgetMs : SPEED_SAMPLE_SCAN_BUDGET_MS,
394
+ keepTime: true,
395
+ ...resumable?.cursor ? { startAfter: resumable.cursor } : {}
396
+ });
397
+ } catch {
398
+ return snapshot ? { samples: snapshot.samples, snapshotAgeMs: snapshot.ageMs } : { samples: /* @__PURE__ */ new Map() };
399
+ }
400
+ if (!resumable && step.scanned === 0 && !step.budgetExhausted) {
401
+ return snapshot ? { samples: snapshot.samples, snapshotAgeMs: snapshot.ageMs } : { samples: /* @__PURE__ */ new Map() };
402
+ }
403
+ mergeNewestSamples(collected, step.samples);
404
+ if (!step.budgetExhausted) {
405
+ await writeSpeedSamplesCache(cache.cachePath, {
406
+ version: SPEED_SAMPLE_CACHE_VERSION,
407
+ userId,
408
+ at: now,
409
+ complete: true,
410
+ samples: Object.fromEntries(collected)
411
+ });
412
+ await writeSpeedSamplesCache(progressPath, {
413
+ version: SPEED_SAMPLE_CACHE_VERSION,
414
+ userId,
415
+ at: now,
416
+ complete: true,
417
+ samples: {}
418
+ });
419
+ return { samples: collected };
420
+ }
421
+ await writeSpeedSamplesCache(progressPath, {
339
422
  version: SPEED_SAMPLE_CACHE_VERSION,
340
423
  userId,
341
- at: now,
342
- samples: Object.fromEntries(samples)
424
+ // Progress keeps the cycle's collection start so a later stale label stays honest.
425
+ at: resumable?.at ?? now,
426
+ complete: false,
427
+ samples: Object.fromEntries(collected),
428
+ ...step.nextCursor ? { cursor: step.nextCursor } : {}
343
429
  });
344
- return samples;
430
+ return snapshot ? { samples: snapshot.samples, snapshotAgeMs: snapshot.ageMs } : { samples: /* @__PURE__ */ new Map() };
345
431
  } catch {
346
- return /* @__PURE__ */ new Map();
432
+ return { samples: /* @__PURE__ */ new Map() };
347
433
  }
348
434
  }
349
435
  var samplesCache = /* @__PURE__ */ new Map();
@@ -359,12 +445,36 @@ function writeSamplesCache(userId, now, samples) {
359
445
  samplesCache.delete(oldest);
360
446
  }
361
447
  }
448
+ var SPEED_SAMPLE_REFRESH_BUDGET_MS = 6e4;
449
+ var snapshotRefreshes = /* @__PURE__ */ new Map();
450
+ function startSpeedSnapshotRefresh(db, userId, now = Date.now()) {
451
+ const inFlight = snapshotRefreshes.get(userId);
452
+ if (inFlight) return inFlight;
453
+ const job = (async () => {
454
+ try {
455
+ const { samples, budgetExhausted } = await collectRecentSpeedSamples(db, userId, {
456
+ budgetMs: SPEED_SAMPLE_REFRESH_BUDGET_MS
457
+ });
458
+ if (!budgetExhausted) writeSamplesCache(userId, now, samples);
459
+ } catch {
460
+ }
461
+ })().finally(() => {
462
+ snapshotRefreshes.delete(userId);
463
+ });
464
+ snapshotRefreshes.set(userId, job);
465
+ return job;
466
+ }
362
467
  async function loadCachedSpeedSamples(db, userId, now) {
363
468
  const hit = samplesCache.get(userId);
364
- if (hit && now - hit.at < SPEED_SAMPLES_CACHE_TTL_MS) return hit.samples;
365
- const samples = await loadRecentSpeedSamples(db, userId);
366
- writeSamplesCache(userId, now, samples);
367
- return samples;
469
+ if (hit) {
470
+ const age = now - hit.at;
471
+ if (age >= 0 && age < SPEED_SAMPLE_STALE_SNAPSHOT_MAX_MS) {
472
+ if (age >= SPEED_SAMPLES_CACHE_TTL_MS) void startSpeedSnapshotRefresh(db, userId);
473
+ return age >= SPEED_SAMPLES_CACHE_TTL_MS ? { samples: hit.samples, snapshotAgeMs: age } : { samples: hit.samples };
474
+ }
475
+ }
476
+ void startSpeedSnapshotRefresh(db, userId);
477
+ return { samples: /* @__PURE__ */ new Map() };
368
478
  }
369
479
  async function injectSpeedContextIntoListAgentsResult(result, options = {}) {
370
480
  try {
@@ -379,15 +489,18 @@ async function injectSpeedContextIntoListAgentsResult(result, options = {}) {
379
489
  if (models.length === 0) return result;
380
490
  const now = options.now ?? Date.now();
381
491
  let samples = /* @__PURE__ */ new Map();
492
+ let snapshotAgeMs;
382
493
  const userId = typeof options.userId === "string" ? options.userId.trim() : "";
383
494
  if (options.db && userId) {
384
495
  try {
385
- samples = options.diskCache ? await loadSpeedSamplesWithDiskCache(options.db, userId, now, options.diskCache) : await loadCachedSpeedSamples(options.db, userId, now);
496
+ const loaded = options.diskCache ? await loadSpeedSamplesWithDiskCache(options.db, userId, now, options.diskCache) : await loadCachedSpeedSamples(options.db, userId, now);
497
+ samples = loaded.samples;
498
+ snapshotAgeMs = loaded.snapshotAgeMs;
386
499
  } catch {
387
500
  samples = /* @__PURE__ */ new Map();
388
501
  }
389
502
  }
390
- const speedContext = buildCandidateSpeedContext(models, samples);
503
+ const speedContext = buildCandidateSpeedContext(models, samples, { snapshotAgeMs });
391
504
  return speedContext ? JSON.stringify({ ...parsed, speedContext }) : result;
392
505
  } catch {
393
506
  return result;
@@ -9,59 +9,59 @@ import {
9
9
  readAgentRecord,
10
10
  resolveAgentRecordFromHybridStore,
11
11
  writeAgentRecord
12
- } from "./chunk-XDMGY5IU.js";
13
- import "./chunk-7AUQ3WCW.js";
12
+ } from "./chunk-IF45XG7K.js";
14
13
  import {
15
14
  resolveCliAgentKeyInput
16
15
  } from "./chunk-NBTY7YJF.js";
17
16
  import "./chunk-NF64D32W.js";
18
17
  import "./chunk-3L2WKC3W.js";
19
- import "./chunk-ZOO3WJIE.js";
18
+ import "./chunk-FHU44LN3.js";
20
19
  import "./chunk-ZNFJWEN4.js";
21
- import "./chunk-NTSRCTUX.js";
22
- import "./chunk-TCTSYFDM.js";
20
+ import "./chunk-4KH4J3G5.js";
21
+ import "./chunk-CTPXME7U.js";
23
22
  import "./chunk-HNUWUO75.js";
24
23
  import "./chunk-CHOZJMJS.js";
25
24
  import "./chunk-PWTNI4N7.js";
26
25
  import "./chunk-Y63ZSOR6.js";
27
- import "./chunk-LNYHAKBP.js";
26
+ import "./chunk-W4S457LU.js";
28
27
  import "./chunk-4KB6WQUL.js";
29
28
  import "./chunk-56GBUMO5.js";
30
- import "./chunk-W5VC7F7V.js";
31
- import "./chunk-CVCRAO6Q.js";
29
+ import "./chunk-NOMIGOST.js";
30
+ import "./chunk-UTV2AYEG.js";
32
31
  import "./chunk-E2BESSAW.js";
33
- import "./chunk-6HVBI6TI.js";
32
+ import "./chunk-25JZEIXN.js";
34
33
  import "./chunk-YUXQAVRD.js";
34
+ import "./chunk-KC4XDTT3.js";
35
35
  import "./chunk-2WZXXAQD.js";
36
- import "./chunk-DA7CTWT4.js";
36
+ import "./chunk-YWSEPJ7C.js";
37
37
  import "./chunk-WJZOQR2J.js";
38
- import "./chunk-CKOO42G5.js";
38
+ import "./chunk-UHJGXRJ4.js";
39
39
  import "./chunk-2MBTWINN.js";
40
- import "./chunk-WTKYP6QO.js";
41
- import "./chunk-5ZUL4CUO.js";
42
- import "./chunk-BTYQAODF.js";
40
+ import "./chunk-JTDORD5P.js";
41
+ import "./chunk-CZM5YTZ7.js";
43
42
  import "./chunk-H57T64RA.js";
43
+ import "./chunk-5ZUL4CUO.js";
44
44
  import "./chunk-UKZX3NHN.js";
45
45
  import "./chunk-5MMAK75Q.js";
46
- import "./chunk-TRZP7JZ7.js";
47
- import "./chunk-UIOEHFF6.js";
46
+ import "./chunk-2QHFH3DR.js";
47
+ import "./chunk-OQHIVPG4.js";
48
48
  import {
49
49
  asRecordOrEmpty
50
50
  } from "./chunk-KX6YBIHG.js";
51
51
  import "./chunk-DWLEOOGR.js";
52
52
  import "./chunk-7DPNBQSV.js";
53
- import "./chunk-G7Y4GXTY.js";
53
+ import "./chunk-T43B7LB2.js";
54
54
  import "./chunk-ZRSNONOB.js";
55
55
  import "./chunk-4VJAC32I.js";
56
- import "./chunk-AKE53VMW.js";
56
+ import "./chunk-CJEIOP3E.js";
57
+ import "./chunk-ZCWRMUWT.js";
57
58
  import "./chunk-ZC3CMUKU.js";
58
59
  import "./chunk-LOEO7LRC.js";
59
60
  import "./chunk-M2EJHDJP.js";
60
- import "./chunk-PLYWH7XM.js";
61
- import "./chunk-XPHZK3PJ.js";
61
+ import "./chunk-KIM6CLW5.js";
62
+ import "./chunk-JNKSDZFS.js";
62
63
  import "./chunk-PSCNXBYA.js";
63
- import "./chunk-6UBGXX2W.js";
64
- import "./chunk-PV6JJAUB.js";
64
+ import "./chunk-TCZHTTUU.js";
65
65
  import "./chunk-YUA6OAH5.js";
66
66
  import "./chunk-SM3NSZJV.js";
67
67
  import "./chunk-JRTNUU5Z.js";
@@ -69,6 +69,10 @@ import {
69
69
  toErrorMessage
70
70
  } from "./chunk-HNMXYYJR.js";
71
71
  import "./chunk-KUG52IAP.js";
72
+ import "./chunk-GOO6G4PY.js";
73
+ import {
74
+ asTrimmedLowercaseString
75
+ } from "./chunk-QSJ3HFEF.js";
72
76
  import {
73
77
  parseUserIdFromAuthToken,
74
78
  readOption,
@@ -80,18 +84,15 @@ import "./chunk-LCBAMY2M.js";
80
84
  import "./chunk-4SN6J65J.js";
81
85
  import "./chunk-CF7PE763.js";
82
86
  import "./chunk-4O22PGNQ.js";
83
- import "./chunk-ECX3NKRD.js";
87
+ import "./chunk-G7Y4GXTY.js";
88
+ import "./chunk-6UBGXX2W.js";
89
+ import "./chunk-JY5NGFFH.js";
84
90
  import "./chunk-XJWWBO34.js";
85
91
  import "./chunk-I42VC5KR.js";
86
92
  import "./chunk-U6VC4MU4.js";
87
93
  import "./chunk-WWC7I6TA.js";
88
94
  import "./chunk-3EUW3WEO.js";
89
95
  import "./chunk-G3SUCT4W.js";
90
- import "./chunk-T43B7LB2.js";
91
- import "./chunk-GOO6G4PY.js";
92
- import {
93
- asTrimmedLowercaseString
94
- } from "./chunk-QSJ3HFEF.js";
95
96
  import "./chunk-4VNS5WPM.js";
96
97
 
97
98
  // packages/cli/agentMachineCommands.ts
@@ -100,7 +101,7 @@ async function defaultExecuteCli(provider, prompt, options) {
100
101
  return executeCli(provider, prompt, options);
101
102
  }
102
103
  async function forwardConnectorRunMessage(machine, message, pushMessage, executeCli, env, fetchImpl) {
103
- const { handleConnectorRunMessage } = await import("./machineWsRunDispatch-F2ZIXMYM.js");
104
+ const { handleConnectorRunMessage } = await import("./machineWsRunDispatch-R26P5V36.js");
104
105
  return handleConnectorRunMessage(message, pushMessage, executeCli, env, fetchImpl);
105
106
  }
106
107
  async function detectLaunchableMachineInfo() {
@@ -1,3 +1,6 @@
1
+ import {
2
+ normalizeOrigin
3
+ } from "./chunk-XFYFMTOM.js";
1
4
  import {
2
5
  customNativeAuthHeaders,
3
6
  detectDeclaredCustomNativeWire
@@ -71,7 +74,7 @@ ${AGENT_MODELS_USAGE}`);
71
74
  let diagnostic;
72
75
  if (res.status === 409 || body?.code === "PRESET_NOT_WHITELISTED") {
73
76
  try {
74
- const { ALL_PROVIDER_REGISTRY } = await import("./providerRegistry-E34XWDLJ.js");
77
+ const { ALL_PROVIDER_REGISTRY } = await import("./providerRegistry-S6UL6UNA.js");
75
78
  const provider = ALL_PROVIDER_REGISTRY.find((p) => p.id === presetId) ?? ALL_PROVIDER_REGISTRY.find((p) => p.provider === presetId);
76
79
  const isOpenAICompatBearer = provider && provider.kind === "api_key_template" && "baseUrl" in provider && typeof provider.baseUrl === "string" && provider.baseUrl && (!("apiKeyHeader" in provider) || !provider.apiKeyHeader || provider.apiKeyHeader.toLowerCase() === "authorization");
77
80
  if (isOpenAICompatBearer) {
@@ -241,10 +244,26 @@ function extractVerifyReply(data) {
241
244
  if (responsesReply) return responsesReply;
242
245
  return (data.content ?? []).map((part) => typeof part?.text === "string" ? part.text : "").join("").trim();
243
246
  }
247
+ function redactVerifyReason(error, apiKey) {
248
+ const raw = toErrorMessage(error);
249
+ if (!apiKey) return raw;
250
+ return raw.split(apiKey).join("[REDACTED:SECRET]");
251
+ }
244
252
  async function verifyCustomProvider(options) {
245
253
  const { providerUrl, apiKey, model, prompt = "\u53EA\u56DE\u590D OK" } = options;
246
254
  const fetchImpl = options.fetchImpl ?? fetch;
247
255
  const provider = providerUrl?.replace(/\/+$/, "") ?? "";
256
+ if (options.allowedOrigin) {
257
+ const origin = normalizeOrigin(provider);
258
+ if (!origin || origin !== options.allowedOrigin) {
259
+ return {
260
+ ok: false,
261
+ providerUrl: provider,
262
+ model,
263
+ reason: "blocked-cross-origin: request target is not the authorized provider origin"
264
+ };
265
+ }
266
+ }
248
267
  if (!provider || !apiKey || !model) {
249
268
  return {
250
269
  ok: false,
@@ -266,13 +285,23 @@ async function verifyCustomProvider(options) {
266
285
  const res = await fetchImpl(targetUrl, {
267
286
  method: "POST",
268
287
  headers,
269
- body: JSON.stringify(probeBody)
288
+ body: JSON.stringify(probeBody),
289
+ ...options.allowedOrigin ? { redirect: "manual" } : {}
270
290
  });
291
+ if (options.allowedOrigin && res.status >= 300 && res.status < 400) {
292
+ return {
293
+ ok: false,
294
+ status: res.status,
295
+ providerUrl: provider,
296
+ model,
297
+ reason: "blocked-redirect: provider answered with a redirect"
298
+ };
299
+ }
271
300
  const data = await res.json().catch(() => null);
272
301
  const reply = extractVerifyReply(data);
273
302
  return { ok: res.ok, status: res.status, providerUrl: provider, model, reply };
274
303
  } catch (error) {
275
- return { ok: false, providerUrl: provider, model, reason: toErrorMessage(error) };
304
+ return { ok: false, providerUrl: provider, model, reason: redactVerifyReason(error, apiKey) };
276
305
  }
277
306
  }
278
307
  async function runAgentProvidersCommand(args, deps = {}) {
@@ -287,7 +316,7 @@ async function runAgentProvidersCommand(args, deps = {}) {
287
316
  const {
288
317
  CUSTOM_API_KEY_TEMPLATES,
289
318
  SUBSCRIPTION_OAUTH_PROVIDERS
290
- } = await import("./providerRegistry-E34XWDLJ.js");
319
+ } = await import("./providerRegistry-S6UL6UNA.js");
291
320
  const keyTemplates = CUSTOM_API_KEY_TEMPLATES.map((p) => ({
292
321
  id: p.id,
293
322
  label: p.label,