omnius 1.0.905 → 1.0.906
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/index.js +2 -2
- package/dist/library.js +2 -146
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
[diffend] Oversized file quarantined before diffing.
|
|
2
2
|
name: package/dist/index.js
|
|
3
|
-
size:
|
|
4
|
-
sha256:
|
|
3
|
+
size: 39000951 bytes
|
|
4
|
+
sha256: 3c496332771e553c64eb7f05f2a3e919c35e70795e46a92b38b1715c09ec1a96
|
package/dist/library.js
CHANGED
|
@@ -345149,21 +345149,7 @@ var CatalogModelUnavailable = class extends Error {
|
|
|
345149
345149
|
};
|
|
345150
345150
|
var OutputReservationUnavailable = class extends Error {
|
|
345151
345151
|
};
|
|
345152
|
-
var InferenceRoutePolicyError = class extends Error {
|
|
345153
|
-
failure;
|
|
345154
|
-
code = "inference_route_failed";
|
|
345155
|
-
fatal = true;
|
|
345156
|
-
retryable = false;
|
|
345157
|
-
constructor(failure, providerLabel) {
|
|
345158
|
-
const provider = failure.category === "authentication" && providerLabel && /^[A-Za-z0-9][A-Za-z0-9 ._()-]{0,63}$/.test(providerLabel) ? providerLabel : "Inference";
|
|
345159
|
-
super(`${provider} request failed (${failure.category}${failure.status === void 0 ? "" : `; HTTP ${failure.status}`}${failure.authReason === "expired_key" ? "; API key expired" : failure.accessReason ? `; ${failure.accessReason}` : failure.validationReason ? `; ${failure.validationReason}` : failure.reason && failure.reason !== "terminal" ? `; ${failure.reason}` : ""}).`);
|
|
345160
|
-
this.failure = failure;
|
|
345161
|
-
this.name = "InferenceRoutePolicyError";
|
|
345162
|
-
}
|
|
345163
|
-
};
|
|
345164
345152
|
var cooldowns = /* @__PURE__ */ new Map();
|
|
345165
|
-
var successfulRoutes = /* @__PURE__ */ new WeakMap();
|
|
345166
|
-
var SAME_MODEL_ATTEMPTS = 3;
|
|
345167
345153
|
var requestTransports = /* @__PURE__ */ new WeakMap();
|
|
345168
345154
|
var responseValidators = /* @__PURE__ */ new WeakMap();
|
|
345169
345155
|
var nextResponseValidator = 0;
|
|
@@ -345233,19 +345219,6 @@ function errorChain(error) {
|
|
|
345233
345219
|
chain.push(current2);
|
|
345234
345220
|
return chain;
|
|
345235
345221
|
}
|
|
345236
|
-
function explicitModelUnavailable(error) {
|
|
345237
|
-
return errorChain(error).some((value) => {
|
|
345238
|
-
if (value instanceof InferenceProviderError && value.status === 429 && value.reason === "upstream")
|
|
345239
|
-
return true;
|
|
345240
|
-
if (!object8(value) || value.name !== "InferenceHttpError" || ![400, 404, 422, 503].includes(Number(value.status)) || !object8(value.responseJson) || !object8(value.responseJson.error))
|
|
345241
|
-
return false;
|
|
345242
|
-
return ["model_not_found", "model_not_available", "model_unavailable", "unsupported_model"].includes(String(value.responseJson.error.code));
|
|
345243
|
-
});
|
|
345244
|
-
}
|
|
345245
|
-
function sameModelTransient(error, request) {
|
|
345246
|
-
const failure = safeFailure(error, request);
|
|
345247
|
-
return !errorChain(error).some((value) => object8(value) && (value.fatal === true || value.retryable === false) || value instanceof AttemptTimeout && (value.deadlineKind === "remote_aggregate" || value.deadlineKind === "caller_request") || value instanceof SyntaxError || value instanceof InvalidInferenceResponse || value instanceof ExpectedInferenceResponseError || object8(value) && value.name === "OpenAIChatResponseError") && (failure.category === "rate_limit" || failure.category === "timeout" || failure.category === "upstream_unavailable" || failure.category === "empty_response" || failure.category === "transport" && transportFailure(error));
|
|
345248
|
-
}
|
|
345249
345222
|
function safeFailure(error, request, route, streamFrames) {
|
|
345250
345223
|
const status2 = errorStatus(error);
|
|
345251
345224
|
const chain = errorChain(error);
|
|
@@ -345345,7 +345318,6 @@ var RemoteInferenceFallback = class _RemoteInferenceFallback {
|
|
|
345345
345318
|
makeBackend;
|
|
345346
345319
|
options;
|
|
345347
345320
|
policy;
|
|
345348
|
-
stickyRouting = false;
|
|
345349
345321
|
now;
|
|
345350
345322
|
env;
|
|
345351
345323
|
lastRoute;
|
|
@@ -345378,51 +345350,6 @@ var RemoteInferenceFallback = class _RemoteInferenceFallback {
|
|
|
345378
345350
|
capacityPolicyScope() {
|
|
345379
345351
|
return createHash45("sha256").update(canonicalContract(this.policy)).digest("hex");
|
|
345380
345352
|
}
|
|
345381
|
-
stickyKey() {
|
|
345382
|
-
return createHash45("sha256").update(canonicalContract({ primary: this.capacityPrimaryScope(), policy: this.capacityPolicyScope() })).digest("hex");
|
|
345383
|
-
}
|
|
345384
|
-
rememberRoute(route) {
|
|
345385
|
-
if (!this.stickyRouting)
|
|
345386
|
-
return;
|
|
345387
|
-
const fetcher = this.options.fetch ?? fetch;
|
|
345388
|
-
let entries = successfulRoutes.get(fetcher);
|
|
345389
|
-
if (!entries)
|
|
345390
|
-
successfulRoutes.set(fetcher, entries = /* @__PURE__ */ new Map());
|
|
345391
|
-
if (entries.size >= 64)
|
|
345392
|
-
entries.delete(entries.keys().next().value);
|
|
345393
|
-
const { policyAttempt: _attempt, transientFailures: _failures, retryPendingMs: _retry, schemaRecoveryPending: _schema, modelAccessRestricted: _access, lastAttemptRateLimited: _rate, ...retained } = route;
|
|
345394
|
-
entries.set(this.stickyKey(), retained);
|
|
345395
|
-
}
|
|
345396
|
-
/** One bounded decision for both unary and streaming attempts. No transcript writes. */
|
|
345397
|
-
handleStickyFailure(request, candidate, deadline, error, frames) {
|
|
345398
|
-
let disposition = "surface_error";
|
|
345399
|
-
const category = safeFailure(error, request, candidate, frames).category;
|
|
345400
|
-
let reason = category === "authentication" ? "authentication" : category === "access_denied" ? "access_restricted" : category === "request_rejected" ? "request_rejected" : category === "invalid_response" ? "response_contract" : category === "transport" ? "adapter_or_configuration" : "terminal";
|
|
345401
|
-
let retryDelayMs;
|
|
345402
|
-
if (this.learnNativeSchemaRestriction(request, candidate, error)) {
|
|
345403
|
-
disposition = "repair_same_model";
|
|
345404
|
-
reason = "unsupported_capability";
|
|
345405
|
-
} else if (explicitModelUnavailable(error) || errorChain(error).some((value) => value instanceof InferenceProviderError && value.reason === "unsupported_schema")) {
|
|
345406
|
-
disposition = "rotate_model";
|
|
345407
|
-
reason = explicitModelUnavailable(error) ? "model_unavailable" : "unsupported_capability";
|
|
345408
|
-
const entries = successfulRoutes.get(this.options.fetch ?? fetch), key = this.stickyKey();
|
|
345409
|
-
if (entries?.get(key) && routeKey(entries.get(key)) === routeKey(candidate))
|
|
345410
|
-
entries.delete(key);
|
|
345411
|
-
} else if (sameModelTransient(error, request)) {
|
|
345412
|
-
reason = "transient";
|
|
345413
|
-
candidate.transientFailures = (candidate.transientFailures ?? 0) + 1;
|
|
345414
|
-
const hint = errorChain(error).find((value) => object8(value) && typeof value.retryAfterMs === "number" && Number.isFinite(value.retryAfterMs));
|
|
345415
|
-
retryDelayMs = Math.max(1e3 * 2 ** (candidate.transientFailures - 1), object8(hint) && typeof hint.retryAfterMs === "number" ? Math.max(0, hint.retryAfterMs) : 0);
|
|
345416
|
-
if (candidate.transientFailures < SAME_MODEL_ATTEMPTS && retryDelayMs < deadline - this.now()) {
|
|
345417
|
-
disposition = "retry_same_model";
|
|
345418
|
-
candidate.retryPendingMs = retryDelayMs;
|
|
345419
|
-
}
|
|
345420
|
-
}
|
|
345421
|
-
const detail = { disposition, reason, attempt: candidate.policyAttempt ?? 1, ...retryDelayMs === void 0 ? {} : { retryDelayMs } };
|
|
345422
|
-
this.lifecycle(request, "failed", candidate, error, frames, void 0, detail);
|
|
345423
|
-
if (disposition === "surface_error")
|
|
345424
|
-
throw new InferenceRoutePolicyError({ ...safeFailure(error, request, candidate, frames), ...detail }, errorChain(error).map(inferenceAuthenticationDiagnostic).find((value) => value !== void 0)?.providerLabel ?? candidate.providerId);
|
|
345425
|
-
}
|
|
345426
345353
|
/** Read-only route discovery; never loads or generates with any local/remote model. */
|
|
345427
345354
|
async prepareContextCapacity(request, options = {}) {
|
|
345428
345355
|
if (request.configuredEndpointOnly === true || request.brokerResumeOnly === true || request.maxTokens <= 0 || !Number.isFinite(request.maxTokens))
|
|
@@ -345657,7 +345584,6 @@ var RemoteInferenceFallback = class _RemoteInferenceFallback {
|
|
|
345657
345584
|
cooldowns.delete(routeKey(candidate));
|
|
345658
345585
|
cooldowns.delete(rateLimitKey(candidate));
|
|
345659
345586
|
cooldowns.delete(contractCooldownKey(candidate, request));
|
|
345660
|
-
this.rememberRoute(candidate);
|
|
345661
345587
|
this.lifecycle(request, "succeeded", candidate, void 0, void 0, completedBinding);
|
|
345662
345588
|
return this.scrubber(candidate)(result);
|
|
345663
345589
|
} catch (error) {
|
|
@@ -345666,10 +345592,6 @@ var RemoteInferenceFallback = class _RemoteInferenceFallback {
|
|
|
345666
345592
|
this.discovery(request, candidate, { stage: "eligibility", outcome: "no_eligible_models", modelCount: 0 });
|
|
345667
345593
|
continue;
|
|
345668
345594
|
}
|
|
345669
|
-
if (this.stickyRouting) {
|
|
345670
|
-
this.handleStickyFailure(request, candidate, deadline, error);
|
|
345671
|
-
continue;
|
|
345672
|
-
}
|
|
345673
345595
|
this.lifecycle(request, "failed", candidate, error);
|
|
345674
345596
|
if (errorChain(error).some((value) => value instanceof AttemptTimeout && value.deadlineKind === "remote_aggregate"))
|
|
345675
345597
|
break;
|
|
@@ -345809,7 +345731,6 @@ var RemoteInferenceFallback = class _RemoteInferenceFallback {
|
|
|
345809
345731
|
cooldowns.delete(routeKey(candidate));
|
|
345810
345732
|
cooldowns.delete(rateLimitKey(candidate));
|
|
345811
345733
|
cooldowns.delete(contractCooldownKey(candidate, request));
|
|
345812
|
-
this.rememberRoute(candidate);
|
|
345813
345734
|
this.lifecycle(request, "succeeded", candidate, void 0, void 0, completedBinding);
|
|
345814
345735
|
return;
|
|
345815
345736
|
} catch (error) {
|
|
@@ -345822,10 +345743,6 @@ var RemoteInferenceFallback = class _RemoteInferenceFallback {
|
|
|
345822
345743
|
this.lifecycle(request, "failed", candidate, error, frames);
|
|
345823
345744
|
throw new StreamInterruptedError(safeFailure(error, request, candidate, frames));
|
|
345824
345745
|
}
|
|
345825
|
-
if (this.stickyRouting) {
|
|
345826
|
-
this.handleStickyFailure(request, candidate, deadline, error, frames);
|
|
345827
|
-
continue;
|
|
345828
|
-
}
|
|
345829
345746
|
this.lifecycle(request, "failed", candidate, error, frames);
|
|
345830
345747
|
if (errorChain(error).some((value) => value instanceof AttemptTimeout && value.deadlineKind === "remote_aggregate"))
|
|
345831
345748
|
break;
|
|
@@ -346429,12 +346346,6 @@ ${line}`).join("");
|
|
|
346429
346346
|
};
|
|
346430
346347
|
for await (const candidate of candidates()) {
|
|
346431
346348
|
const key = routeKey(candidate);
|
|
346432
|
-
if (this.stickyRouting) {
|
|
346433
|
-
if (this.now() >= deadline)
|
|
346434
|
-
return;
|
|
346435
|
-
yield* this.stickyAttempts(request, candidate, deadline);
|
|
346436
|
-
continue;
|
|
346437
|
-
}
|
|
346438
346349
|
if (!priority.has(key))
|
|
346439
346350
|
priority.set(key, priority.size);
|
|
346440
346351
|
if ((routeCooldown(candidate, request)?.until ?? 0) > this.now()) {
|
|
@@ -346498,60 +346409,8 @@ ${line}`).join("");
|
|
|
346498
346409
|
defer(candidate);
|
|
346499
346410
|
}
|
|
346500
346411
|
}
|
|
346501
|
-
async *stickyAttempts(request, candidate, deadline) {
|
|
346502
|
-
let schemaRetries = 0;
|
|
346503
|
-
while (this.now() < deadline) {
|
|
346504
|
-
this.fence(request);
|
|
346505
|
-
candidate.policyAttempt = (candidate.policyAttempt ?? 0) + 1;
|
|
346506
|
-
yield candidate;
|
|
346507
|
-
if (candidate.schemaRecoveryPending && schemaRetries < SUPPORTED_PROVIDER_SCHEMA_ADAPTATIONS.length) {
|
|
346508
|
-
candidate.schemaRecoveryPending = false;
|
|
346509
|
-
schemaRetries++;
|
|
346510
|
-
continue;
|
|
346511
|
-
}
|
|
346512
|
-
if (candidate.retryPendingMs === void 0)
|
|
346513
|
-
return;
|
|
346514
|
-
const delay2 = candidate.retryPendingMs;
|
|
346515
|
-
candidate.retryPendingMs = void 0;
|
|
346516
|
-
await this.waitForRetry(request, delay2);
|
|
346517
|
-
this.fence(request);
|
|
346518
|
-
if (this.now() >= deadline)
|
|
346519
|
-
throw new InferenceRoutePolicyError({ category: "timeout", deadlineKind: "remote_aggregate", disposition: "surface_error", reason: "transient", attempt: candidate.policyAttempt });
|
|
346520
|
-
}
|
|
346521
|
-
}
|
|
346522
|
-
async waitForRetry(request, delay2) {
|
|
346523
|
-
let timer;
|
|
346524
|
-
try {
|
|
346525
|
-
const pause = new Promise((resolve42) => {
|
|
346526
|
-
timer = setTimeout(resolve42, delay2);
|
|
346527
|
-
});
|
|
346528
|
-
await (request.signal ? this.abortable(pause, request.signal) : pause);
|
|
346529
|
-
} finally {
|
|
346530
|
-
clearTimeout(timer);
|
|
346531
|
-
}
|
|
346532
|
-
}
|
|
346533
346412
|
async *candidates(request, deadline, includeCooling = false) {
|
|
346534
|
-
|
|
346535
|
-
const eligible = sticky && this.compatible(request, sticky, true) ? sticky : void 0;
|
|
346536
|
-
const pending = [];
|
|
346537
|
-
let matched = !eligible;
|
|
346538
|
-
for await (const candidate of this.catalogCandidates(request, deadline, includeCooling)) {
|
|
346539
|
-
if (!matched && routeKey(candidate) !== routeKey(eligible)) {
|
|
346540
|
-
pending.push(candidate);
|
|
346541
|
-
continue;
|
|
346542
|
-
}
|
|
346543
|
-
if (!matched) {
|
|
346544
|
-
this.stickyRouting = true;
|
|
346545
|
-
matched = true;
|
|
346546
|
-
yield candidate;
|
|
346547
|
-
for (const prior of pending)
|
|
346548
|
-
yield prior;
|
|
346549
|
-
pending.length = 0;
|
|
346550
|
-
} else
|
|
346551
|
-
yield candidate;
|
|
346552
|
-
}
|
|
346553
|
-
for (const candidate of pending)
|
|
346554
|
-
yield candidate;
|
|
346413
|
+
yield* this.catalogCandidates(request, deadline, includeCooling);
|
|
346555
346414
|
}
|
|
346556
346415
|
async *catalogCandidates(request, deadline, includeCooling = false) {
|
|
346557
346416
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -346673,10 +346532,7 @@ ${line}`).join("");
|
|
|
346673
346532
|
const zeroPrice = (value) => (typeof value === "number" || typeof value === "string" && value.trim().length > 0) && Number.isFinite(Number(value)) && Number(value) === 0;
|
|
346674
346533
|
const models = raw.data.filter((model) => chatCatalogModel(model, anonymousTier) && (!kiloCatalog || object8(model.pricing) && zeroPrice(model.pricing.prompt) && zeroPrice(model.pricing.completion) && Object.values(model.pricing).every(zeroPrice)));
|
|
346675
346534
|
const unique4 = [...new Map(models.map((model) => [String(model.id), model])).values()];
|
|
346676
|
-
const
|
|
346677
|
-
const rememberedHere = remembered && remembered.baseUrl === route.baseUrl && this.compatible(request, remembered, true);
|
|
346678
|
-
const preferredModel = rememberedHere ? remembered.model : route.model;
|
|
346679
|
-
const preferred = unique4.find((model) => model.id === preferredModel);
|
|
346535
|
+
const preferred = unique4.find((model) => model.id === route.model);
|
|
346680
346536
|
const ordered = unique4.sort((a, b) => compareFallbackCatalogModels(a, b, route.model));
|
|
346681
346537
|
const compatible = [];
|
|
346682
346538
|
const modelLimit = MAX_MODELS_PER_PROVIDER;
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "omnius",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.906",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "omnius",
|
|
9
|
-
"version": "1.0.
|
|
9
|
+
"version": "1.0.906",
|
|
10
10
|
"bundleDependencies": [
|
|
11
11
|
"image-to-ascii"
|
|
12
12
|
],
|
package/package.json
CHANGED