nolo-cli 0.211.0 → 0.213.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{_executeModel-VVQEOY3D.js → _executeModel-CUJLCFWR.js} +57 -54
- package/{action-U235TV4P.js → action-DF5UYSJF.js} +4 -4
- package/{addContentAction-7C76J7ST.js → addContentAction-WERAONNY.js} +9 -9
- package/{addDialogAgentAction-KTYANUEC.js → addDialogAgentAction-7VI7YRML.js} +16 -13
- package/{agentDeleteCommand-WHRU6VDJ.js → agentDeleteCommand-XJORXPGU.js} +80 -76
- package/{agentEmailCommands-ALLHXPW3.js → agentEmailCommands-XTYYFR6Z.js} +85 -80
- package/{agentListCommands-POKMEKMS.js → agentListCommands-OBLRBLHS.js} +237 -115
- package/{agentMachineCommands-WJLZLBPI.js → agentMachineCommands-5FMT3OT5.js} +33 -31
- package/{agentProviderCommands-MN3ABDME.js → agentProviderCommands-Q5O33MED.js} +33 -4
- package/{agentRecordCommands-OULZW3KM.js → agentRecordCommands-ZQ7SVYGG.js} +75 -70
- package/{agentRunCommand-ZNG4LGNQ.js → agentRunCommand-WS7IGO2W.js} +77 -73
- package/{agentRunControl-AF7BMR22.js → agentRunControl-TAMHJQSR.js} +8 -7
- package/{agentRuntimeLocal-YMUHFV5M.js → agentRuntimeLocal-SOO2OPJG.js} +30 -27
- package/{agentSlice-WNGUIMQZ.js → agentSlice-CHR6KOZN.js} +13 -13
- package/{appDeleteCommands-6MXPLAVF.js → appDeleteCommands-GUP6P5YE.js} +34 -32
- package/{appDeployCommands-ERRSVASW.js → appDeployCommands-MH2FX4O5.js} +34 -32
- package/{appDeployStatusCommands-ULICISLI.js → appDeployStatusCommands-SUHN3HPJ.js} +34 -32
- package/{appGetCommands-WYYYWROF.js → appGetCommands-YWDEX6Z4.js} +34 -32
- package/{appListCommands-DFCUCRCV.js → appListCommands-ZQVMLPAY.js} +34 -32
- package/{authCommand-ZJMWXFMA.js → authCommand-PWX2ZNUP.js} +15 -15
- package/{authCommands-WK6E42L2.js → authCommands-HV3EAU3V.js} +2 -2
- package/{builtinSkillRegistry-HH75G5J3.js → builtinSkillRegistry-2QETTQPM.js} +5 -4
- package/{chromeOpsCommands-HEN5AX2J.js → chromeOpsCommands-DIVM2K3T.js} +1 -1
- package/{chunk-TRZP7JZ7.js → chunk-2QHFH3DR.js} +1 -0
- package/{chunk-XE4Q46FF.js → chunk-3CGG2PAL.js} +1 -1
- package/{chunk-YUXQAVRD.js → chunk-3UKL3HPD.js} +251 -14
- package/{chunk-BSISWVB4.js → chunk-4I7ERB7F.js} +1 -1
- package/{chunk-5ORJGHTL.js → chunk-4T2WNOY7.js} +6 -6
- package/{chunk-W5VC7F7V.js → chunk-5MQRBSMW.js} +84 -91
- package/{chunk-YLTLB5A7.js → chunk-6DWMYIUY.js} +7 -6
- package/chunk-6VLJ6YA7.js +11751 -0
- package/{chunk-KSTEXKL6.js → chunk-75XIDFBW.js} +4 -3
- package/{chunk-BTYQAODF.js → chunk-7BT37FK3.js} +196 -308
- package/{chunk-27E2CBBY.js → chunk-7OCO4TDT.js} +1 -1
- package/{chunk-V3M6IXQI.js → chunk-7QTZCMKL.js} +335 -131
- package/chunk-7RFNTILS.js +2213 -0
- package/{chunk-NHQKWPLP.js → chunk-7Y4YTDQF.js} +25 -23
- package/{chunk-CKAHAVMK.js → chunk-A7TFUNZO.js} +35 -25
- package/{chunk-PJNFNEJE.js → chunk-ALQ3657A.js} +28 -2
- package/{chunk-NV572QM3.js → chunk-BBJ22CLB.js} +15 -15
- package/chunk-CJEIOP3E.js +0 -0
- package/{chunk-4WCEC56C.js → chunk-COFEN36Z.js} +2 -2
- package/{chunk-25OB36GU.js → chunk-CRHOO2ZR.js} +4 -4
- package/{chunk-NTSRCTUX.js → chunk-CTPXME7U.js} +2 -2
- package/{chunk-TPCDYNJK.js → chunk-EHGEOAHI.js} +3 -3
- package/{chunk-Y2WUYX4I.js → chunk-EHSZD5OI.js} +1 -1
- package/{chunk-SU3QL7YG.js → chunk-FUGMREBO.js} +2 -2
- package/{chunk-UMEGDH6A.js → chunk-FW6YHHLI.js} +8 -8
- package/chunk-FY7F4Q6X.js +127 -0
- package/{chunk-25M2K6OA.js → chunk-G2BQWAVT.js} +3 -3
- package/chunk-G7MLNNEX.js +84 -0
- package/{chunk-DQLB4NQ3.js → chunk-GPVRUGGY.js} +2 -2
- package/{chunk-RQ22OZD7.js → chunk-H2TJUNCH.js} +1 -1
- package/{chunk-XPHZK3PJ.js → chunk-H4UOTUOX.js} +165 -51
- package/{chunk-CVCRAO6Q.js → chunk-H5HF7TJA.js} +9 -7
- package/{chunk-OP7PTBAJ.js → chunk-H7PPIYWP.js} +9 -9
- package/{chunk-QQM464AL.js → chunk-HPFCI4SK.js} +3 -3
- package/chunk-HRMJUN5J.js +26 -0
- package/{chunk-WI6OGHXJ.js → chunk-HSVBJRF4.js} +5 -5
- package/{chunk-RYWO5AKN.js → chunk-HUBHAQK2.js} +10 -10
- package/{chunk-LKDF3ATR.js → chunk-INUFILG6.js} +1 -1
- package/{chunk-NXCGNS4N.js → chunk-IXNGOHV5.js} +2 -2
- package/{chunk-ET2CWLIJ.js → chunk-J2NHJ7WX.js} +4 -4
- package/{chunk-ECX3NKRD.js → chunk-JY5NGFFH.js} +11 -0
- package/chunk-KC4XDTT3.js +227 -0
- package/{chunk-ADBWFYJD.js → chunk-KFLT5KAD.js} +9 -9
- package/{chunk-PLYWH7XM.js → chunk-KIM6CLW5.js} +7 -7
- package/{chunk-7IYBN7IA.js → chunk-LLRPJECG.js} +22 -13
- package/{chunk-3J3U3KXB.js → chunk-MDB67IWP.js} +5 -5
- package/chunk-MMA3LZ3W.js +105 -0
- package/{chunk-XDMGY5IU.js → chunk-MOIJOHA5.js} +227 -11
- package/{chunk-NLT32XBZ.js → chunk-NJLL224W.js} +2 -2
- package/{chunk-JBOUVTZX.js → chunk-NOKUNJON.js} +15 -4
- package/{chunk-C2XZM3K4.js → chunk-NSAPDIN2.js} +12 -27
- package/{chunk-PAFTGNWA.js → chunk-O2TZF4AI.js} +2 -2
- package/{chunk-UIOEHFF6.js → chunk-OQHIVPG4.js} +1 -0
- package/{chunk-TCTSYFDM.js → chunk-OQPKUBPB.js} +19 -6
- package/{chunk-X4F26D5K.js → chunk-P5L7CXOC.js} +58 -33
- package/{chunk-OXME3PEE.js → chunk-PCLE46CE.js} +1 -1
- package/{chunk-UCPAVEQB.js → chunk-PYRUW7XN.js} +1 -1
- package/{chunk-YXOBCDNW.js → chunk-QG4AOSON.js} +12 -49
- package/{chunk-RXCCWVA2.js → chunk-QHPRUL4O.js} +3 -3
- package/{chunk-I5PBXF7O.js → chunk-R5O4QAWG.js} +1 -1
- package/{chunk-HD3WR3TD.js → chunk-RLBNLZVC.js} +1 -1
- package/{chunk-SN5XE6GQ.js → chunk-RPQXPZZF.js} +4 -4
- package/{chunk-ZOO3WJIE.js → chunk-RSHTSUEG.js} +948 -108
- package/{chunk-6HVBI6TI.js → chunk-RZOV7OMV.js} +12 -229
- package/{chunk-D2MDMY2M.js → chunk-SVYO6AO7.js} +7 -1
- package/{chunk-IIHY4ZAI.js → chunk-TAKB25RM.js} +8 -4
- package/{chunk-ZN5AH4BY.js → chunk-TX5EYMGT.js} +6 -6
- package/{chunk-CKOO42G5.js → chunk-UHJGXRJ4.js} +4 -4
- package/{chunk-M4NTDZG3.js → chunk-UYD5HQ6T.js} +857 -295
- package/{chunk-WTKYP6QO.js → chunk-V5Y3R6BT.js} +114 -6
- package/{chunk-3RQVYR4B.js → chunk-VNYYOX3V.js} +59 -20
- package/{chunk-4LEGTOSR.js → chunk-VO4WSAVP.js} +3 -3
- package/{chunk-LNYHAKBP.js → chunk-W4S457LU.js} +1 -1
- package/{chunk-RIALQUSF.js → chunk-WMTBPBMP.js} +6 -6
- package/chunk-WPORQFYN.js +74 -0
- package/{chunk-Y6M7KJOA.js → chunk-WRYQ35LQ.js} +5 -5
- package/{chunk-YKFP6UGT.js → chunk-WYDI6TGM.js} +17 -17
- package/{chunk-SCYQJPGA.js → chunk-X7SDOJUM.js} +147 -20
- package/chunk-XFYFMTOM.js +92 -0
- package/{chunk-LT3EAHJY.js → chunk-XHQC4PXX.js} +65 -49
- package/{chunk-2WZXXAQD.js → chunk-YB3YZK56.js} +67 -1
- package/{chunk-JKW6LERJ.js → chunk-YJAFKXMU.js} +14 -14
- package/{chunk-GSQNH63I.js → chunk-YTF4WH7J.js} +3 -19
- package/{chunk-DA7CTWT4.js → chunk-YWSEPJ7C.js} +5 -5
- package/{chunk-3V2QMRNN.js → chunk-ZL5RAEEB.js} +3 -3
- package/{chunk-NEZGPBL7.js → chunk-ZNWI6OVT.js} +2 -2
- package/{chunk-MBS6CTZB.js → chunk-ZXOUUDCG.js} +266 -2014
- package/cliAgentConfigHelpers-WJBZQTLW.js +41 -0
- package/{commandRegistry-FI2IOQ3U.js → commandRegistry-W63CYRZJ.js} +91 -87
- package/{contentThunks-5LKNNDGY.js → contentThunks-U7PL5MQD.js} +27 -26
- package/{cooldownCommands-YXLWOXWR.js → cooldownCommands-TIGUHXTD.js} +3 -3
- package/{createAgentAutomationAction-TI4QG4CY.js → createAgentAutomationAction-OLBQDD6R.js} +27 -26
- package/{createDialogAction-TJ3JKLO4.js → createDialogAction-SVH6B3SB.js} +29 -28
- package/{createPageAction-GKXT6WEH.js → createPageAction-F4DIWZ2Z.js} +29 -28
- package/{dbSlice-LPMZ2DGJ.js → dbSlice-BVH2YZPQ.js} +8 -8
- package/{deleteFile-EPUQHKPA.js → deleteFile-5YOEKV4U.js} +4 -4
- package/{dialogCommands-IWPXIZ5P.js → dialogCommands-KHIEPY3M.js} +38 -36
- package/{dialogSlice-ZWNNS7GZ.js → dialogSlice-ZCTDV2PZ.js} +25 -24
- package/{dialogUsageCommand-ZCPPHPJ5.js → dialogUsageCommand-7KCPYGHG.js} +1 -1
- package/{docCreateCommands-HFSPKJSI.js → docCreateCommands-DPMZI7G5.js} +32 -30
- package/{docDeleteCommands-CRL62POH.js → docDeleteCommands-IRQQLUBT.js} +34 -33
- package/{docReadCommands-QOTOX3XW.js → docReadCommands-LK37XH6L.js} +32 -30
- package/{docStore-WYLRB7ED.js → docStore-V2KECILA.js} +11 -11
- package/{docUpdateCommands-7BMH4MCA.js → docUpdateCommands-O6T3HJHH.js} +32 -30
- package/{fetchMessages-YY4SATNR.js → fetchMessages-NR4KNQLO.js} +3 -3
- package/{getPricing-OQXBJ6VZ.js → getPricing-2MNMXEVG.js} +3 -3
- package/{handleSendMessageAction-P27YP2DQ.js → handleSendMessageAction-2PE25WM3.js} +49 -47
- package/hostCredentialCreate-S233UMAP.js +357 -0
- package/index.js +7 -7
- package/{keys-P4ZDOVJW.js → keys-BEGDOTRL.js} +3 -1
- package/{localDialogRead-5VCMQQZF.js → localDialogRead-7NNDVVF7.js} +1 -1
- package/{localRuntimeAdapter-GP6ZSSO3.js → localRuntimeAdapter-KY6WXNBR.js} +82 -75
- package/{machineCommands-6Z6H4BFX.js → machineCommands-Q6HA3IXF.js} +74 -69
- package/{machineWsRunDispatch-F2ZIXMYM.js → machineWsRunDispatch-WWJQ6WR3.js} +74 -69
- package/{memberThunks-YSEFJF47.js → memberThunks-7EDJADWU.js} +9 -9
- package/package.json +1 -1
- package/{projectArchive-PIGEOX3D.js → projectArchive-DRTDIMEV.js} +29 -28
- package/{providerPresetApply-ZYMLQA46.js → providerPresetApply-YXGV6NXB.js} +4 -4
- package/{providerRegistry-E34XWDLJ.js → providerRegistry-S6UL6UNA.js} +4 -4
- package/{read-DIIQBOOO.js → read-4V2RMG7N.js} +4 -4
- package/{readDocTool-HXYGOEA7.js → readDocTool-BH6ATGQO.js} +1 -1
- package/{readlineWorkspace-UG25G7KC.js → readlineWorkspace-2W4WRCOU.js} +437 -217
- package/{removeDialogAgentAction-ALJDUJ2E.js → removeDialogAgentAction-LYAZGNKW.js} +18 -15
- package/{runAgentClientLoop-IO5F7TCZ.js → runAgentClientLoop-J2VQBS2Z.js} +55 -52
- package/{runtimeDoctorCommands-PGAA47G5.js → runtimeDoctorCommands-QAI3MBKQ.js} +6 -6
- package/{secretCommands-ZCZ4KVET.js → secretCommands-LXDWOLZ6.js} +4 -4
- package/{setDialogExtraReferencesAction-O3SVMD5A.js → setDialogExtraReferencesAction-OCRPGPYH.js} +11 -11
- package/{setPrimaryDialogAgentAction-HE7RVFFF.js → setPrimaryDialogAgentAction-HFJDQIBU.js} +19 -16
- package/{settingThunks-BWWJQG4L.js → settingThunks-RAMHMTGM.js} +13 -12
- package/{spaceCommands-UAELIFEI.js → spaceCommands-KVJZVKVO.js} +32 -31
- package/{streamAgentChatTurn-VUKZQYJR.js → streamAgentChatTurn-GHBMJJ6S.js} +63 -60
- package/{switchDialogAgentAction-3VZS7SOS.js → switchDialogAgentAction-EBRMW3RA.js} +16 -13
- package/{tools-VRXJAVYI.js → tools-EWKCPKMS.js} +49 -46
- package/{tuiSummaryLlmCaller-TGCHZLSW.js → tuiSummaryLlmCaller-ALQYUUWB.js} +48 -19
- package/{updateCommands-Q6CYAEYJ.js → updateCommands-ZQYU6SCI.js} +5 -3
- package/{updateDialogTitleAction-MULWCJCW.js → updateDialogTitleAction-5GGMBTDF.js} +40 -72
- package/usageCommand-F4IPVMIZ.js +32 -0
- package/usageRebuildCommand-HAW2AD5N.js +626 -0
- package/{windowsSelfUpdate-XSQVF2GK.js → windowsSelfUpdate-257DV2T6.js} +2 -2
- package/{workloadLifecycle-4BEQHMSD.js → workloadLifecycle-4C42SVBD.js} +1 -0
- package/chunk-4LCOCOR5.js +0 -50
- package/chunk-7AUQ3WCW.js +0 -51
- package/chunk-ZRAU6T47.js +0 -56
- package/{agentFavoriteCommands-GAFEXKKP.js → agentFavoriteCommands-EDK743YA.js} +1 -1
- package/{agentGrantCommands-V5FOQKFD.js → agentGrantCommands-RQWK2TEV.js} +1 -1
- package/{agentPullCommand-2JMJP5BS.js → agentPullCommand-6EM3URVK.js} +1 -1
- package/{chunk-A2ZMIRLN.js → chunk-INN4LTAJ.js} +5 -5
- package/{chunk-PV6JJAUB.js → chunk-TCZHTTUU.js} +8 -8
- package/{chunk-AKE53VMW.js → chunk-ZCWRMUWT.js} +0 -0
- package/{tableCommands-D7WR4QSM.js → tableCommands-MP6VFSVT.js} +3 -3
|
@@ -71,6 +71,81 @@ var DEFAULT_QUOTA_BREAKER_MS = 6 * 3600 * 1e3;
|
|
|
71
71
|
var DEFAULT_AGENT_NOT_FOUND_BREAKER_MS = 15 * 60 * 1e3;
|
|
72
72
|
|
|
73
73
|
// packages/ai/agent/quotaSnapshot.ts
|
|
74
|
+
function normalizeHeaders(headers) {
|
|
75
|
+
const out = {};
|
|
76
|
+
if (!headers) return out;
|
|
77
|
+
if (typeof headers.get === "function") {
|
|
78
|
+
headers.forEach((value, key) => {
|
|
79
|
+
out[key.toLowerCase()] = value;
|
|
80
|
+
});
|
|
81
|
+
return out;
|
|
82
|
+
}
|
|
83
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
84
|
+
if (typeof value === "string") out[key.toLowerCase()] = value;
|
|
85
|
+
}
|
|
86
|
+
return out;
|
|
87
|
+
}
|
|
88
|
+
function readNumber(raw) {
|
|
89
|
+
if (typeof raw === "number" && Number.isFinite(raw)) return raw >= 0 ? raw : void 0;
|
|
90
|
+
if (typeof raw === "string") {
|
|
91
|
+
const n = Number(raw.trim());
|
|
92
|
+
if (Number.isFinite(n) && n >= 0) return n;
|
|
93
|
+
}
|
|
94
|
+
return void 0;
|
|
95
|
+
}
|
|
96
|
+
function readResetAt(raw, now) {
|
|
97
|
+
if (typeof raw === "number" && Number.isFinite(raw)) {
|
|
98
|
+
if (raw >= 1e12) return raw;
|
|
99
|
+
if (raw >= 1e9) return raw * 1e3;
|
|
100
|
+
return raw > 0 ? now + raw * 1e3 : now;
|
|
101
|
+
}
|
|
102
|
+
if (typeof raw !== "string") return void 0;
|
|
103
|
+
const text = raw.trim();
|
|
104
|
+
if (!text) return void 0;
|
|
105
|
+
const msMatch = /^(\d+(?:\.\d+)?)ms$/i.exec(text);
|
|
106
|
+
let dur;
|
|
107
|
+
if (msMatch) {
|
|
108
|
+
dur = Number(msMatch[1]) / 1e3;
|
|
109
|
+
} else {
|
|
110
|
+
const m = /^(?:(\d+(?:\.\d+)?)h)?(?:(\d+(?:\.\d+)?)m)?(?:(\d+(?:\.\d+)?)s)?$/i.exec(text);
|
|
111
|
+
dur = m && (m[1] || m[2] || m[3]) ? Number(m[1] ?? 0) * 3600 + Number(m[2] ?? 0) * 60 + Number(m[3] ?? 0) : NaN;
|
|
112
|
+
}
|
|
113
|
+
if (Number.isFinite(dur)) return now + dur * 1e3;
|
|
114
|
+
const n = Number(text);
|
|
115
|
+
if (Number.isFinite(n)) {
|
|
116
|
+
if (n >= 1e12) return n;
|
|
117
|
+
if (n >= 1e9) return n * 1e3;
|
|
118
|
+
return n > 0 ? now + n * 1e3 : now;
|
|
119
|
+
}
|
|
120
|
+
const parsed = Date.parse(text);
|
|
121
|
+
return Number.isFinite(parsed) ? parsed : void 0;
|
|
122
|
+
}
|
|
123
|
+
function readUtilization(raw) {
|
|
124
|
+
const n = readNumber(raw);
|
|
125
|
+
if (n === void 0) return void 0;
|
|
126
|
+
return n > 1 ? n / 100 : n;
|
|
127
|
+
}
|
|
128
|
+
function mergeWindow(into, win) {
|
|
129
|
+
const existing = into.get(win.scope);
|
|
130
|
+
if (!existing) {
|
|
131
|
+
into.set(win.scope, { ...win });
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
if (win.resetAt !== void 0) {
|
|
135
|
+
existing.resetAt = existing.resetAt === void 0 ? win.resetAt : Math.max(existing.resetAt, win.resetAt);
|
|
136
|
+
}
|
|
137
|
+
if (win.remaining !== void 0) {
|
|
138
|
+
existing.remaining = existing.remaining === void 0 ? win.remaining : Math.min(existing.remaining, win.remaining);
|
|
139
|
+
}
|
|
140
|
+
if (win.limit !== void 0) {
|
|
141
|
+
existing.limit = existing.limit === void 0 ? win.limit : Math.min(existing.limit, win.limit);
|
|
142
|
+
}
|
|
143
|
+
if (win.utilization !== void 0) {
|
|
144
|
+
existing.utilization = existing.utilization === void 0 ? win.utilization : Math.max(existing.utilization, win.utilization);
|
|
145
|
+
}
|
|
146
|
+
if (win.unit !== void 0 && existing.unit === void 0) existing.unit = win.unit;
|
|
147
|
+
existing.source = win.source;
|
|
148
|
+
}
|
|
74
149
|
function parseQuotaWindowScope(scope) {
|
|
75
150
|
const matched = /^(gemini|3p)-(.+)$/.exec(scope);
|
|
76
151
|
return matched ? { family: matched[1], period: matched[2] } : { period: scope };
|
|
@@ -95,6 +170,181 @@ function isQuotaWindowExpired(window, now) {
|
|
|
95
170
|
const resetAt = window?.resetAt;
|
|
96
171
|
return typeof resetAt === "number" && Number.isFinite(resetAt) && resetAt <= now;
|
|
97
172
|
}
|
|
173
|
+
function scanOpenAiRateLimitHeaders(headers, now, out) {
|
|
174
|
+
for (const kind of ["requests", "tokens"]) {
|
|
175
|
+
const remaining = readNumber(headers[`x-ratelimit-remaining-${kind}`]);
|
|
176
|
+
const limit = readNumber(headers[`x-ratelimit-limit-${kind}`]);
|
|
177
|
+
const resetAt = readResetAt(headers[`x-ratelimit-reset-${kind}`], now);
|
|
178
|
+
if (remaining === void 0 && limit === void 0 && resetAt === void 0) continue;
|
|
179
|
+
mergeWindow(out, {
|
|
180
|
+
scope: kind,
|
|
181
|
+
...remaining !== void 0 ? { remaining } : {},
|
|
182
|
+
...limit !== void 0 ? { limit } : {},
|
|
183
|
+
...resetAt !== void 0 ? { resetAt } : {},
|
|
184
|
+
unit: kind,
|
|
185
|
+
source: `x-ratelimit-*-${kind}`
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
const genericRemaining = readNumber(headers["x-ratelimit-remaining"]);
|
|
189
|
+
const genericLimit = readNumber(headers["x-ratelimit-limit"]);
|
|
190
|
+
const genericReset = readResetAt(headers["x-ratelimit-reset"], now);
|
|
191
|
+
if (genericRemaining !== void 0 || genericLimit !== void 0 || genericReset !== void 0) {
|
|
192
|
+
mergeWindow(out, {
|
|
193
|
+
scope: "requests",
|
|
194
|
+
...genericRemaining !== void 0 ? { remaining: genericRemaining } : {},
|
|
195
|
+
...genericLimit !== void 0 ? { limit: genericLimit } : {},
|
|
196
|
+
...genericReset !== void 0 ? { resetAt: genericReset } : {},
|
|
197
|
+
unit: "requests",
|
|
198
|
+
source: "x-ratelimit"
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
function scanAnthropicUnifiedHeaders(headers, now, out) {
|
|
203
|
+
for (const scope of ["5h", "7d"]) {
|
|
204
|
+
const utilization = readUtilization(
|
|
205
|
+
headers[`anthropic-ratelimit-unified-${scope}-utilization`]
|
|
206
|
+
);
|
|
207
|
+
const resetAt = readResetAt(
|
|
208
|
+
headers[`anthropic-ratelimit-unified-${scope}-reset`],
|
|
209
|
+
now
|
|
210
|
+
);
|
|
211
|
+
if (utilization === void 0 && resetAt === void 0) continue;
|
|
212
|
+
mergeWindow(out, {
|
|
213
|
+
scope,
|
|
214
|
+
...utilization !== void 0 ? { utilization } : {},
|
|
215
|
+
...resetAt !== void 0 ? { resetAt } : {},
|
|
216
|
+
source: `anthropic-ratelimit-unified-${scope}`
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
function scanGoogleQuotaHeaders(headers, now, out) {
|
|
221
|
+
const genericReset = readResetAt(headers["x-goog-quota-reset"], now);
|
|
222
|
+
const dims = [
|
|
223
|
+
{ prefix: "x-goog-quota-user-", scope: "user" },
|
|
224
|
+
{ prefix: "x-goog-quota-project-", scope: "project" }
|
|
225
|
+
];
|
|
226
|
+
for (const { prefix, scope } of dims) {
|
|
227
|
+
const remaining = readNumber(headers[`${prefix}remaining`]);
|
|
228
|
+
const limit = readNumber(headers[`${prefix}limit`]);
|
|
229
|
+
const resetAt = readResetAt(headers[`${prefix}reset`], now) ?? genericReset;
|
|
230
|
+
if (remaining === void 0 && limit === void 0 && resetAt === void 0) continue;
|
|
231
|
+
mergeWindow(out, {
|
|
232
|
+
scope,
|
|
233
|
+
...remaining !== void 0 ? { remaining } : {},
|
|
234
|
+
...limit !== void 0 ? { limit } : {},
|
|
235
|
+
...resetAt !== void 0 ? { resetAt } : {},
|
|
236
|
+
source: `${prefix}*`
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
function scanSub2ApiHeaders(headers, now, out) {
|
|
241
|
+
const FIELD_RE = /^x-sub2api-quota(?:-([a-z0-9][a-z0-9._:-]*))?-(remaining|limit|reset)$/;
|
|
242
|
+
const groups = /* @__PURE__ */ new Map();
|
|
243
|
+
for (const [name, value] of Object.entries(headers)) {
|
|
244
|
+
const m = FIELD_RE.exec(name);
|
|
245
|
+
if (!m) continue;
|
|
246
|
+
const scope = m[1] ?? "sub2api";
|
|
247
|
+
const group = groups.get(scope) ?? {};
|
|
248
|
+
if (m[2] === "reset") {
|
|
249
|
+
const at = readResetAt(value, now);
|
|
250
|
+
if (at !== void 0) group.resetAt = at;
|
|
251
|
+
} else if (m[2] === "remaining") {
|
|
252
|
+
const n = readNumber(value);
|
|
253
|
+
if (n !== void 0) group.remaining = n;
|
|
254
|
+
} else if (m[2] === "limit") {
|
|
255
|
+
const n = readNumber(value);
|
|
256
|
+
if (n !== void 0) group.limit = n;
|
|
257
|
+
}
|
|
258
|
+
groups.set(scope, group);
|
|
259
|
+
}
|
|
260
|
+
for (const [scope, g] of groups) {
|
|
261
|
+
mergeWindow(out, {
|
|
262
|
+
scope,
|
|
263
|
+
...g.remaining !== void 0 ? { remaining: g.remaining } : {},
|
|
264
|
+
...g.limit !== void 0 ? { limit: g.limit } : {},
|
|
265
|
+
...g.resetAt !== void 0 ? { resetAt: g.resetAt } : {},
|
|
266
|
+
source: "x-sub2api-quota"
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
function scanBody(body, now, out) {
|
|
271
|
+
if (!body || typeof body !== "object") return;
|
|
272
|
+
const root = body;
|
|
273
|
+
const error = root.error && typeof root.error === "object" ? root.error : void 0;
|
|
274
|
+
for (const holder of [root, error]) {
|
|
275
|
+
const quota = holder?.quota;
|
|
276
|
+
if (!quota || typeof quota !== "object") continue;
|
|
277
|
+
const q = quota;
|
|
278
|
+
const remaining = readNumber(q.remaining ?? q.remaining_amount);
|
|
279
|
+
const limit = readNumber(q.limit ?? q.total ?? q.quota);
|
|
280
|
+
const resetAt = readResetAt(
|
|
281
|
+
q.reset_at ?? q.resets_at ?? q.resetAt ?? q.resetTime ?? q.reset_time,
|
|
282
|
+
now
|
|
283
|
+
);
|
|
284
|
+
const unit = typeof q.unit === "string" && q.unit ? q.unit : void 0;
|
|
285
|
+
if (remaining === void 0 && limit === void 0 && resetAt === void 0) continue;
|
|
286
|
+
const scope = typeof q.scope === "string" && q.scope ? q.scope : "daily";
|
|
287
|
+
mergeWindow(out, {
|
|
288
|
+
scope,
|
|
289
|
+
...remaining !== void 0 ? { remaining } : {},
|
|
290
|
+
...limit !== void 0 ? { limit } : {},
|
|
291
|
+
...resetAt !== void 0 ? { resetAt } : {},
|
|
292
|
+
...unit ? { unit } : {},
|
|
293
|
+
source: "body.quota"
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
const details = error?.details ?? root.details;
|
|
297
|
+
if (!Array.isArray(details)) return;
|
|
298
|
+
let retryResetAt;
|
|
299
|
+
const quotaScopes = /* @__PURE__ */ new Set();
|
|
300
|
+
for (const item of details) {
|
|
301
|
+
if (!item || typeof item !== "object") continue;
|
|
302
|
+
const record = item;
|
|
303
|
+
const type = typeof record["@type"] === "string" ? record["@type"] : "";
|
|
304
|
+
if (type.includes("RetryInfo")) {
|
|
305
|
+
const at = readResetAt(record.retryDelay ?? record.retry_delay, now);
|
|
306
|
+
if (at !== void 0) retryResetAt = retryResetAt === void 0 ? at : Math.max(retryResetAt, at);
|
|
307
|
+
}
|
|
308
|
+
if (type.includes("QuotaFailure") && Array.isArray(record.violations)) {
|
|
309
|
+
for (const v of record.violations) {
|
|
310
|
+
const metric = v && typeof v === "object" && typeof v.quotaMetric === "string" ? v.quotaMetric : void 0;
|
|
311
|
+
if (metric) quotaScopes.add(`model:${metric}`);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
if (retryResetAt !== void 0 || quotaScopes.size > 0) {
|
|
316
|
+
if (quotaScopes.size === 0) {
|
|
317
|
+
mergeWindow(out, {
|
|
318
|
+
scope: "user",
|
|
319
|
+
...retryResetAt !== void 0 ? { resetAt: retryResetAt } : {},
|
|
320
|
+
source: "body.details.RetryInfo"
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
for (const scope of quotaScopes) {
|
|
324
|
+
mergeWindow(out, {
|
|
325
|
+
scope,
|
|
326
|
+
...retryResetAt !== void 0 ? { resetAt: retryResetAt } : {},
|
|
327
|
+
source: "body.details.QuotaFailure"
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
function extractQuotaSnapshot(provider, status, headers, body, now) {
|
|
333
|
+
try {
|
|
334
|
+
if (!Number.isFinite(now)) return void 0;
|
|
335
|
+
const bag = normalizeHeaders(headers);
|
|
336
|
+
const windows = /* @__PURE__ */ new Map();
|
|
337
|
+
scanOpenAiRateLimitHeaders(bag, now, windows);
|
|
338
|
+
scanAnthropicUnifiedHeaders(bag, now, windows);
|
|
339
|
+
scanGoogleQuotaHeaders(bag, now, windows);
|
|
340
|
+
scanSub2ApiHeaders(bag, now, windows);
|
|
341
|
+
scanBody(body, now, windows);
|
|
342
|
+
if (windows.size === 0) return void 0;
|
|
343
|
+
return { windows: [...windows.values()], observedAt: now };
|
|
344
|
+
} catch {
|
|
345
|
+
return void 0;
|
|
346
|
+
}
|
|
347
|
+
}
|
|
98
348
|
function findTightestQuotaWindow(quota, now = Date.now(), options) {
|
|
99
349
|
const windows = selectQuotaWindowsForModel(quota, now, options?.model);
|
|
100
350
|
if (windows.length === 0) return void 0;
|
|
@@ -421,18 +671,6 @@ function resolveAvailabilityAction(status, body, now, headers) {
|
|
|
421
671
|
function mergeAvailabilityDeadline(currentDeadline, nextAvailableAt) {
|
|
422
672
|
return typeof currentDeadline === "number" && Number.isFinite(currentDeadline) ? Math.max(currentDeadline, nextAvailableAt) : nextAvailableAt;
|
|
423
673
|
}
|
|
424
|
-
var PROBE_INTERVAL_MS = 10 * 60 * 1e3;
|
|
425
|
-
function resolveCooldownGate(input, now) {
|
|
426
|
-
const nextAvailableAt = input.nextAvailableAt;
|
|
427
|
-
if (typeof nextAvailableAt !== "number" || !Number.isFinite(nextAvailableAt) || nextAvailableAt <= now) {
|
|
428
|
-
return "open";
|
|
429
|
-
}
|
|
430
|
-
const lastProbeAt = input.lastProbeAt;
|
|
431
|
-
if (typeof lastProbeAt !== "number" || !Number.isFinite(lastProbeAt)) {
|
|
432
|
-
return "probe";
|
|
433
|
-
}
|
|
434
|
-
return now - lastProbeAt >= PROBE_INTERVAL_MS ? "probe" : "blocked";
|
|
435
|
-
}
|
|
436
674
|
function isPublicOrSystemAgentRecord(agent) {
|
|
437
675
|
if (!agent || typeof agent !== "object") return false;
|
|
438
676
|
for (const keyField of ["agentKey", "key", "id", "dbKey", "privateKey"]) {
|
|
@@ -665,6 +903,7 @@ function classifyFailureSubclass(input, now = Date.now()) {
|
|
|
665
903
|
export {
|
|
666
904
|
QUOTA_ERROR_PATTERNS,
|
|
667
905
|
isQuotaExhaustedError,
|
|
906
|
+
extractQuotaSnapshot,
|
|
668
907
|
formatQuotaSummary,
|
|
669
908
|
DEFAULT_PROVIDER_RETRY_MS,
|
|
670
909
|
shouldClearCooldownFromQuota,
|
|
@@ -674,8 +913,6 @@ export {
|
|
|
674
913
|
isCapacitySaturatedRateLimit,
|
|
675
914
|
resolveAvailabilityAction,
|
|
676
915
|
mergeAvailabilityDeadline,
|
|
677
|
-
PROBE_INTERVAL_MS,
|
|
678
|
-
resolveCooldownGate,
|
|
679
916
|
resolveCredentialCandidateKeys,
|
|
680
917
|
resolveCredentialKeyWithFallback,
|
|
681
918
|
classifyFailureSubclass
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createCliLocalRuntimeAdapter,
|
|
3
3
|
summarizeEndpoint
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-UYD5HQ6T.js";
|
|
5
5
|
import {
|
|
6
6
|
clipMultilineText
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-HUBHAQK2.js";
|
|
8
8
|
import {
|
|
9
9
|
runLocalAgentTurn
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-RSHTSUEG.js";
|
|
11
11
|
import {
|
|
12
12
|
applyToolSurfaceConstraints
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-KC4XDTT3.js";
|
|
14
14
|
import {
|
|
15
15
|
resolveLocalRuntimeEnvFromPolicy
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-2QHFH3DR.js";
|
|
17
17
|
import {
|
|
18
18
|
asRecordOrEmpty
|
|
19
19
|
} from "./chunk-KX6YBIHG.js";
|
|
@@ -38,7 +38,7 @@ import {
|
|
|
38
38
|
} from "./chunk-4O22PGNQ.js";
|
|
39
39
|
import {
|
|
40
40
|
t
|
|
41
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-VNYYOX3V.js";
|
|
42
42
|
import {
|
|
43
43
|
asTrimmedNonEmptyStringArray
|
|
44
44
|
} from "./chunk-I42VC5KR.js";
|