nolo-cli 0.212.0-alpha.1 → 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-KE6MBNUJ.js → _executeModel-CUJLCFWR.js} +35 -35
- package/{addContentAction-N2YC5IL3.js → addContentAction-WERAONNY.js} +5 -5
- package/{addDialogAgentAction-3NKVQCEC.js → addDialogAgentAction-7VI7YRML.js} +4 -4
- package/{agentDeleteCommand-NWK7VU4N.js → agentDeleteCommand-XJORXPGU.js} +42 -42
- package/{agentEmailCommands-UZ4DHEX2.js → agentEmailCommands-XTYYFR6Z.js} +43 -43
- package/{agentListCommands-HE7L2A6L.js → agentListCommands-OBLRBLHS.js} +60 -51
- package/{agentMachineCommands-6TE4MBMP.js → agentMachineCommands-5FMT3OT5.js} +13 -12
- package/{agentRecordCommands-L3QQ7HZ4.js → agentRecordCommands-ZQ7SVYGG.js} +42 -42
- package/{agentRunCommand-2IFGQHCO.js → agentRunCommand-WS7IGO2W.js} +43 -43
- package/{agentRunControl-OI3LOENH.js → agentRunControl-TAMHJQSR.js} +3 -3
- package/{agentRuntimeLocal-HL526DNQ.js → agentRuntimeLocal-SOO2OPJG.js} +10 -10
- package/{agentSlice-TMYP2UEA.js → agentSlice-CHR6KOZN.js} +5 -5
- package/{appDeleteCommands-ZERW4AXY.js → appDeleteCommands-GUP6P5YE.js} +15 -14
- package/{appDeployCommands-DUWSMYHL.js → appDeployCommands-MH2FX4O5.js} +15 -14
- package/{appDeployStatusCommands-N2KIE4BF.js → appDeployStatusCommands-SUHN3HPJ.js} +15 -14
- package/{appGetCommands-YVR4NPVY.js → appGetCommands-YWDEX6Z4.js} +15 -14
- package/{appListCommands-JS6HOHZS.js → appListCommands-ZQVMLPAY.js} +15 -14
- package/{authCommand-FE2C3ZUM.js → authCommand-PWX2ZNUP.js} +2 -2
- package/{builtinSkillRegistry-3YOIGEF6.js → builtinSkillRegistry-2QETTQPM.js} +2 -2
- package/{chromeOpsCommands-HEN5AX2J.js → chromeOpsCommands-DIVM2K3T.js} +1 -1
- package/{chunk-YUXQAVRD.js → chunk-3UKL3HPD.js} +251 -14
- package/{chunk-PDGKOTO7.js → chunk-4T2WNOY7.js} +4 -4
- package/{chunk-NOMIGOST.js → chunk-5MQRBSMW.js} +35 -41
- package/{chunk-5RYBGBQH.js → chunk-6DWMYIUY.js} +3 -3
- package/{chunk-KSTEXKL6.js → chunk-75XIDFBW.js} +4 -3
- package/{chunk-CZM5YTZ7.js → chunk-7BT37FK3.js} +193 -305
- package/{chunk-GPO7FCEZ.js → chunk-7QTZCMKL.js} +159 -106
- package/{chunk-NJR3WKVP.js → chunk-7Y4YTDQF.js} +6 -6
- package/{chunk-CKAHAVMK.js → chunk-A7TFUNZO.js} +35 -25
- package/{chunk-PJNFNEJE.js → chunk-ALQ3657A.js} +28 -2
- package/{chunk-YJMRHHGY.js → chunk-BBJ22CLB.js} +5 -5
- package/{chunk-AVTVGMDY.js → chunk-COFEN36Z.js} +1 -1
- package/{chunk-DM6UMOEL.js → chunk-CRHOO2ZR.js} +1 -1
- package/{chunk-EYUBHHFB.js → chunk-EHGEOAHI.js} +2 -2
- package/{chunk-Y2WUYX4I.js → chunk-EHSZD5OI.js} +1 -1
- package/{chunk-QT6PKHYJ.js → chunk-FUGMREBO.js} +2 -2
- package/{chunk-BFM34N54.js → chunk-FW6YHHLI.js} +4 -4
- package/{chunk-3FOQHGHN.js → chunk-G2BQWAVT.js} +2 -2
- package/{chunk-VPAZOH2D.js → chunk-GPVRUGGY.js} +1 -1
- package/{chunk-JNKSDZFS.js → chunk-H4UOTUOX.js} +162 -48
- package/{chunk-UTV2AYEG.js → chunk-H5HF7TJA.js} +1 -1
- package/{chunk-IJXYFTV7.js → chunk-H7PPIYWP.js} +1 -1
- package/{chunk-NRFKLKRU.js → chunk-HSVBJRF4.js} +1 -1
- package/{chunk-GNDJKC4B.js → chunk-HUBHAQK2.js} +8 -8
- package/{chunk-LKDF3ATR.js → chunk-INUFILG6.js} +1 -1
- package/{chunk-OHNELDTO.js → chunk-IXNGOHV5.js} +2 -2
- package/{chunk-WXYLV624.js → chunk-J2NHJ7WX.js} +4 -4
- package/{chunk-YPD3VJZW.js → chunk-KFLT5KAD.js} +4 -4
- package/{chunk-OOF4UPC5.js → chunk-LLRPJECG.js} +4 -4
- package/{chunk-B7NJ3T4A.js → chunk-MDB67IWP.js} +4 -4
- package/{chunk-IF45XG7K.js → chunk-MOIJOHA5.js} +9 -4
- package/{chunk-IIQ6JGRI.js → chunk-NJLL224W.js} +1 -1
- package/{chunk-YOIW77S2.js → chunk-NOKUNJON.js} +2 -2
- package/{chunk-HIRC32DV.js → chunk-NSAPDIN2.js} +8 -4
- package/{chunk-JIT6FSXJ.js → chunk-O2TZF4AI.js} +1 -1
- package/{chunk-4KH4J3G5.js → chunk-OQPKUBPB.js} +1 -1
- package/{chunk-OXME3PEE.js → chunk-PCLE46CE.js} +1 -1
- package/{chunk-CJRONOYL.js → chunk-QG4AOSON.js} +8 -45
- package/{chunk-6OQUPIQF.js → chunk-QHPRUL4O.js} +3 -3
- package/{chunk-MMNYUVLW.js → chunk-R5O4QAWG.js} +1 -1
- package/{chunk-IAPCBNEE.js → chunk-RLBNLZVC.js} +1 -1
- package/{chunk-FHU44LN3.js → chunk-RSHTSUEG.js} +246 -77
- package/{chunk-25JZEIXN.js → chunk-RZOV7OMV.js} +11 -11
- package/{chunk-D2MDMY2M.js → chunk-SVYO6AO7.js} +7 -1
- package/{chunk-INSBKSBB.js → chunk-TAKB25RM.js} +1 -1
- package/{chunk-RU4SD66C.js → chunk-TX5EYMGT.js} +5 -5
- package/{chunk-D5RCRX4A.js → chunk-UYD5HQ6T.js} +746 -177
- package/{chunk-JTDORD5P.js → chunk-V5Y3R6BT.js} +110 -2
- package/{chunk-3RQVYR4B.js → chunk-VNYYOX3V.js} +59 -20
- package/{chunk-3AKFVZ2I.js → chunk-VO4WSAVP.js} +3 -3
- package/{chunk-6NSSLV67.js → chunk-WMTBPBMP.js} +6 -6
- package/{chunk-EZFQ6XRV.js → chunk-WRYQ35LQ.js} +4 -4
- package/{chunk-SOHTHFV2.js → chunk-WYDI6TGM.js} +14 -14
- package/{chunk-M6RL5JCD.js → chunk-X7SDOJUM.js} +3 -3
- package/{chunk-CQ46IRNN.js → chunk-XHQC4PXX.js} +48 -34
- package/{chunk-2WZXXAQD.js → chunk-YB3YZK56.js} +67 -1
- package/{chunk-22CIEBYO.js → chunk-YJAFKXMU.js} +11 -11
- package/{chunk-GSQNH63I.js → chunk-YTF4WH7J.js} +3 -19
- package/{chunk-5AQR3DGV.js → chunk-ZNWI6OVT.js} +2 -2
- package/{chunk-VZKUKCA6.js → chunk-ZXOUUDCG.js} +49 -40
- package/{commandRegistry-VVMTPFAX.js → commandRegistry-W63CYRZJ.js} +64 -64
- package/{contentThunks-N52O67MI.js → contentThunks-U7PL5MQD.js} +12 -12
- package/{cooldownCommands-YXLWOXWR.js → cooldownCommands-TIGUHXTD.js} +3 -3
- package/{createAgentAutomationAction-ZC57YRSV.js → createAgentAutomationAction-OLBQDD6R.js} +12 -12
- package/{createDialogAction-VQW5WDYX.js → createDialogAction-SVH6B3SB.js} +14 -14
- package/{createPageAction-M5VDA7SC.js → createPageAction-F4DIWZ2Z.js} +14 -14
- package/{dbSlice-HP7G4LX3.js → dbSlice-BVH2YZPQ.js} +4 -4
- package/{deleteFile-7VQGLK2V.js → deleteFile-5YOEKV4U.js} +2 -2
- package/{dialogCommands-JHMR2N2Y.js → dialogCommands-KHIEPY3M.js} +18 -18
- package/{dialogSlice-GRSVGDTF.js → dialogSlice-ZCTDV2PZ.js} +11 -11
- package/{docCreateCommands-F2K3UPSQ.js → docCreateCommands-DPMZI7G5.js} +14 -13
- package/{docDeleteCommands-XGXB5RFT.js → docDeleteCommands-IRQQLUBT.js} +16 -16
- package/{docReadCommands-7HWZZV6J.js → docReadCommands-LK37XH6L.js} +14 -13
- package/{docStore-KNZK6Y2G.js → docStore-V2KECILA.js} +5 -5
- package/{docUpdateCommands-OZZ7NQII.js → docUpdateCommands-O6T3HJHH.js} +14 -13
- package/{fetchMessages-M3QU7ZCQ.js → fetchMessages-NR4KNQLO.js} +2 -2
- package/{handleSendMessageAction-SHIH74GJ.js → handleSendMessageAction-2PE25WM3.js} +25 -25
- package/{hostCredentialCreate-X64WK4JD.js → hostCredentialCreate-S233UMAP.js} +42 -42
- package/index.js +7 -7
- package/{localDialogRead-XRLAH4CZ.js → localDialogRead-7NNDVVF7.js} +1 -1
- package/{localRuntimeAdapter-A7K3ABA6.js → localRuntimeAdapter-KY6WXNBR.js} +41 -41
- package/{machineCommands-DE3MR7CJ.js → machineCommands-Q6HA3IXF.js} +42 -42
- package/{machineWsRunDispatch-R26P5V36.js → machineWsRunDispatch-WWJQ6WR3.js} +42 -42
- package/{memberThunks-7WJAY5V6.js → memberThunks-7EDJADWU.js} +5 -5
- package/package.json +1 -1
- package/{projectArchive-GGL5HLMD.js → projectArchive-DRTDIMEV.js} +14 -14
- package/{read-4VZQODSN.js → read-4V2RMG7N.js} +2 -2
- package/{readDocTool-AVD32RUJ.js → readDocTool-BH6ATGQO.js} +1 -1
- package/{readlineWorkspace-XKYKNL2I.js → readlineWorkspace-2W4WRCOU.js} +322 -159
- package/{removeDialogAgentAction-FKL4BYMR.js → removeDialogAgentAction-LYAZGNKW.js} +5 -5
- package/{runAgentClientLoop-V7E2WBVM.js → runAgentClientLoop-J2VQBS2Z.js} +33 -33
- package/{secretCommands-4QS3HCA2.js → secretCommands-LXDWOLZ6.js} +1 -1
- package/{setDialogExtraReferencesAction-TLIOLWWI.js → setDialogExtraReferencesAction-OCRPGPYH.js} +5 -5
- package/{setPrimaryDialogAgentAction-2OLWRFYR.js → setPrimaryDialogAgentAction-HFJDQIBU.js} +5 -5
- package/{settingThunks-UGBPCNYF.js → settingThunks-RAMHMTGM.js} +7 -7
- package/{spaceCommands-4KSLKVNF.js → spaceCommands-KVJZVKVO.js} +14 -14
- package/{streamAgentChatTurn-7FR7X2NU.js → streamAgentChatTurn-GHBMJJ6S.js} +37 -37
- package/{switchDialogAgentAction-UZSAG2N5.js → switchDialogAgentAction-EBRMW3RA.js} +4 -4
- package/{tools-ZLKCC25W.js → tools-EWKCPKMS.js} +28 -28
- package/{tuiSummaryLlmCaller-WC54MVGP.js → tuiSummaryLlmCaller-ALQYUUWB.js} +41 -12
- package/{updateCommands-4744PL3P.js → updateCommands-ZQYU6SCI.js} +3 -3
- package/{updateDialogTitleAction-U53ZT7PJ.js → updateDialogTitleAction-5GGMBTDF.js} +12 -12
- package/{windowsSelfUpdate-XSQVF2GK.js → windowsSelfUpdate-257DV2T6.js} +2 -2
- package/{workloadLifecycle-4BEQHMSD.js → workloadLifecycle-4C42SVBD.js} +1 -0
|
@@ -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,13 +1,13 @@
|
|
|
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
13
|
} from "./chunk-KC4XDTT3.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";
|