@certalis/agent-smith 0.1.3 → 0.1.4
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/dist/bin.js +7 -14
- package/dist/post-processor.worker.js +3 -0
- package/dist/server.js +7 -14
- package/package.json +1 -1
package/dist/bin.js
CHANGED
|
@@ -705,6 +705,9 @@ function quotaThresholdFor(account, bucket, fleetThreshold) {
|
|
|
705
705
|
function isCurrentQuotaWindow(window, now) {
|
|
706
706
|
return (window.resetAt === null || window.resetAt > now) && now - window.seenAt <= QUOTA_STALE_MS;
|
|
707
707
|
}
|
|
708
|
+
function isOpenQuotaWindow(window, now) {
|
|
709
|
+
return window.resetAt === null ? isCurrentQuotaWindow(window, now) : window.resetAt > now;
|
|
710
|
+
}
|
|
708
711
|
var QUOTA_STALE_MS;
|
|
709
712
|
var init_quota = __esm(() => {
|
|
710
713
|
QUOTA_STALE_MS = 30 * 60000;
|
|
@@ -8186,14 +8189,7 @@ var init_background_tasks = __esm(() => {
|
|
|
8186
8189
|
function liveUtilization(window2, now) {
|
|
8187
8190
|
if (window2.utilization === null)
|
|
8188
8191
|
return 0;
|
|
8189
|
-
|
|
8190
|
-
return windowOpen ? window2.utilization : 0;
|
|
8191
|
-
}
|
|
8192
|
-
function isAheadOfWeeklyPace(window2, now) {
|
|
8193
|
-
if (window2.resetAt === null || window2.resetAt <= now)
|
|
8194
|
-
return false;
|
|
8195
|
-
const elapsedShareOfWeek = 1 - (window2.resetAt - now) / WEEK_MS;
|
|
8196
|
-
return liveUtilization(window2, now) > elapsedShareOfWeek;
|
|
8192
|
+
return isOpenQuotaWindow(window2, now) ? window2.utilization : 0;
|
|
8197
8193
|
}
|
|
8198
8194
|
function highestUtilization(windows, now) {
|
|
8199
8195
|
return Math.max(0, ...windows.map(([, window2]) => liveUtilization(window2, now)));
|
|
@@ -8204,7 +8200,6 @@ function seatUsage(provider, account2, model, now) {
|
|
|
8204
8200
|
const weekly = windows.filter(([bucket]) => provider.isWeeklyBucket(bucket));
|
|
8205
8201
|
const fiveHour = windows.filter(([bucket]) => provider.isFiveHourBucket(bucket));
|
|
8206
8202
|
return {
|
|
8207
|
-
aheadOfWeeklyPace: weekly.some(([, window2]) => isAheadOfWeeklyPace(window2, now)),
|
|
8208
8203
|
fiveHour: highestUtilization(fiveHour, now),
|
|
8209
8204
|
weekly: highestUtilization(weekly, now)
|
|
8210
8205
|
};
|
|
@@ -8217,13 +8212,11 @@ function compareSeatUsage(provider, model, now) {
|
|
|
8217
8212
|
return (left, right) => {
|
|
8218
8213
|
const a = seatUsage(provider, left, model, now);
|
|
8219
8214
|
const b = seatUsage(provider, right, model, now);
|
|
8220
|
-
return
|
|
8215
|
+
return a.fiveHour - b.fiveHour || a.weekly - b.weekly || soonestWeeklyReset(provider, left, now) - soonestWeeklyReset(provider, right, now);
|
|
8221
8216
|
};
|
|
8222
8217
|
}
|
|
8223
|
-
var WEEK_MS;
|
|
8224
8218
|
var init_seat_usage = __esm(() => {
|
|
8225
8219
|
init_src();
|
|
8226
|
-
WEEK_MS = 7 * 24 * 60 * 60 * 1000;
|
|
8227
8220
|
});
|
|
8228
8221
|
|
|
8229
8222
|
// ../../packages/proxy/src/team-router.ts
|
|
@@ -8357,7 +8350,7 @@ var init_team_router = __esm(() => {
|
|
|
8357
8350
|
// ../../packages/proxy/src/handlers/account-selector.ts
|
|
8358
8351
|
function isQuotaBlocking(provider, account2, bucket, window2, fleetThreshold, now, model, maxUsage) {
|
|
8359
8352
|
const threshold = Math.min(quotaThresholdFor(account2, bucket, fleetThreshold), maxUsage ?? Number.POSITIVE_INFINITY);
|
|
8360
|
-
return (provider.quotaBucketsFor(model)?.includes(bucket) ?? true) && isCurrentQuotaWindow(window2, now) && (window2.status === "rejected" || window2.utilization !== null && window2.utilization >= threshold);
|
|
8353
|
+
return (provider.quotaBucketsFor(model)?.includes(bucket) ?? true) && (maxUsage === undefined ? isCurrentQuotaWindow(window2, now) : isOpenQuotaWindow(window2, now)) && (window2.status === "rejected" || window2.utilization !== null && window2.utilization >= threshold);
|
|
8361
8354
|
}
|
|
8362
8355
|
function pooledMaxUsage(account2, ctx) {
|
|
8363
8356
|
const teamRouting = ctx.runtime.teamRouting;
|
|
@@ -9628,7 +9621,7 @@ async function classifyUpstreamResponse(input, upstream) {
|
|
|
9628
9621
|
retryAfterMs: perMinuteRetryAfterMs
|
|
9629
9622
|
};
|
|
9630
9623
|
}
|
|
9631
|
-
if (isRateLimited) {
|
|
9624
|
+
if (isRateLimited && !response.ok) {
|
|
9632
9625
|
return response.status === 429 ? {
|
|
9633
9626
|
discard: discardUpstreamResponse(state),
|
|
9634
9627
|
forward,
|
|
@@ -704,6 +704,9 @@ function quotaThresholdFor(account, bucket, fleetThreshold) {
|
|
|
704
704
|
function isCurrentQuotaWindow(window, now) {
|
|
705
705
|
return (window.resetAt === null || window.resetAt > now) && now - window.seenAt <= QUOTA_STALE_MS;
|
|
706
706
|
}
|
|
707
|
+
function isOpenQuotaWindow(window, now) {
|
|
708
|
+
return window.resetAt === null ? isCurrentQuotaWindow(window, now) : window.resetAt > now;
|
|
709
|
+
}
|
|
707
710
|
var QUOTA_STALE_MS;
|
|
708
711
|
var init_quota = __esm(() => {
|
|
709
712
|
QUOTA_STALE_MS = 30 * 60000;
|
package/dist/server.js
CHANGED
|
@@ -704,6 +704,9 @@ function quotaThresholdFor(account, bucket, fleetThreshold) {
|
|
|
704
704
|
function isCurrentQuotaWindow(window, now) {
|
|
705
705
|
return (window.resetAt === null || window.resetAt > now) && now - window.seenAt <= QUOTA_STALE_MS;
|
|
706
706
|
}
|
|
707
|
+
function isOpenQuotaWindow(window, now) {
|
|
708
|
+
return window.resetAt === null ? isCurrentQuotaWindow(window, now) : window.resetAt > now;
|
|
709
|
+
}
|
|
707
710
|
var QUOTA_STALE_MS;
|
|
708
711
|
var init_quota = __esm(() => {
|
|
709
712
|
QUOTA_STALE_MS = 30 * 60000;
|
|
@@ -8185,14 +8188,7 @@ var init_background_tasks = __esm(() => {
|
|
|
8185
8188
|
function liveUtilization(window2, now) {
|
|
8186
8189
|
if (window2.utilization === null)
|
|
8187
8190
|
return 0;
|
|
8188
|
-
|
|
8189
|
-
return windowOpen ? window2.utilization : 0;
|
|
8190
|
-
}
|
|
8191
|
-
function isAheadOfWeeklyPace(window2, now) {
|
|
8192
|
-
if (window2.resetAt === null || window2.resetAt <= now)
|
|
8193
|
-
return false;
|
|
8194
|
-
const elapsedShareOfWeek = 1 - (window2.resetAt - now) / WEEK_MS;
|
|
8195
|
-
return liveUtilization(window2, now) > elapsedShareOfWeek;
|
|
8191
|
+
return isOpenQuotaWindow(window2, now) ? window2.utilization : 0;
|
|
8196
8192
|
}
|
|
8197
8193
|
function highestUtilization(windows, now) {
|
|
8198
8194
|
return Math.max(0, ...windows.map(([, window2]) => liveUtilization(window2, now)));
|
|
@@ -8203,7 +8199,6 @@ function seatUsage(provider, account2, model, now) {
|
|
|
8203
8199
|
const weekly = windows.filter(([bucket]) => provider.isWeeklyBucket(bucket));
|
|
8204
8200
|
const fiveHour = windows.filter(([bucket]) => provider.isFiveHourBucket(bucket));
|
|
8205
8201
|
return {
|
|
8206
|
-
aheadOfWeeklyPace: weekly.some(([, window2]) => isAheadOfWeeklyPace(window2, now)),
|
|
8207
8202
|
fiveHour: highestUtilization(fiveHour, now),
|
|
8208
8203
|
weekly: highestUtilization(weekly, now)
|
|
8209
8204
|
};
|
|
@@ -8216,13 +8211,11 @@ function compareSeatUsage(provider, model, now) {
|
|
|
8216
8211
|
return (left, right) => {
|
|
8217
8212
|
const a = seatUsage(provider, left, model, now);
|
|
8218
8213
|
const b = seatUsage(provider, right, model, now);
|
|
8219
|
-
return
|
|
8214
|
+
return a.fiveHour - b.fiveHour || a.weekly - b.weekly || soonestWeeklyReset(provider, left, now) - soonestWeeklyReset(provider, right, now);
|
|
8220
8215
|
};
|
|
8221
8216
|
}
|
|
8222
|
-
var WEEK_MS;
|
|
8223
8217
|
var init_seat_usage = __esm(() => {
|
|
8224
8218
|
init_src();
|
|
8225
|
-
WEEK_MS = 7 * 24 * 60 * 60 * 1000;
|
|
8226
8219
|
});
|
|
8227
8220
|
|
|
8228
8221
|
// ../../packages/proxy/src/team-router.ts
|
|
@@ -8356,7 +8349,7 @@ var init_team_router = __esm(() => {
|
|
|
8356
8349
|
// ../../packages/proxy/src/handlers/account-selector.ts
|
|
8357
8350
|
function isQuotaBlocking(provider, account2, bucket, window2, fleetThreshold, now, model, maxUsage) {
|
|
8358
8351
|
const threshold = Math.min(quotaThresholdFor(account2, bucket, fleetThreshold), maxUsage ?? Number.POSITIVE_INFINITY);
|
|
8359
|
-
return (provider.quotaBucketsFor(model)?.includes(bucket) ?? true) && isCurrentQuotaWindow(window2, now) && (window2.status === "rejected" || window2.utilization !== null && window2.utilization >= threshold);
|
|
8352
|
+
return (provider.quotaBucketsFor(model)?.includes(bucket) ?? true) && (maxUsage === undefined ? isCurrentQuotaWindow(window2, now) : isOpenQuotaWindow(window2, now)) && (window2.status === "rejected" || window2.utilization !== null && window2.utilization >= threshold);
|
|
8360
8353
|
}
|
|
8361
8354
|
function pooledMaxUsage(account2, ctx) {
|
|
8362
8355
|
const teamRouting = ctx.runtime.teamRouting;
|
|
@@ -9627,7 +9620,7 @@ async function classifyUpstreamResponse(input, upstream) {
|
|
|
9627
9620
|
retryAfterMs: perMinuteRetryAfterMs
|
|
9628
9621
|
};
|
|
9629
9622
|
}
|
|
9630
|
-
if (isRateLimited) {
|
|
9623
|
+
if (isRateLimited && !response.ok) {
|
|
9631
9624
|
return response.status === 429 ? {
|
|
9632
9625
|
discard: discardUpstreamResponse(state),
|
|
9633
9626
|
forward,
|
package/package.json
CHANGED