@mupt-ai/dari-gateway 1.0.375 → 1.0.376
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.
|
@@ -43,7 +43,10 @@ function codexCatalogEntry(args) {
|
|
|
43
43
|
supports_image_detail_original: false,
|
|
44
44
|
context_window: args.contextWindow,
|
|
45
45
|
max_context_window: args.contextWindow,
|
|
46
|
-
|
|
46
|
+
// Codex compacts at 90% of the window by default, judged by the last
|
|
47
|
+
// response's usage. The standard-price check counts the next prompt by
|
|
48
|
+
// estimate, before the new tool output is measured, so compact earlier.
|
|
49
|
+
auto_compact_token_limit: Math.floor(args.contextWindow * 0.8),
|
|
47
50
|
comp_hash: null,
|
|
48
51
|
effective_context_window_percent: 95,
|
|
49
52
|
experimental_supported_tools: [],
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DEFAULT_RESET_MIN_HOURS } from "../models/sources.js";
|
|
2
|
+
import { isContextOverflow } from "@mupt-ai/pi-ai";
|
|
2
3
|
import { HttpError } from "../http/errors.js";
|
|
3
4
|
import { linkUnavailableError, plansExhausted } from "../link/errors.js";
|
|
4
5
|
import { piMessageToInteractionOutput } from "./pi_output.js";
|
|
@@ -279,6 +280,12 @@ async function throwProviderFailure(args) {
|
|
|
279
280
|
const codex = codexUsageLimitError(limit, accountsUrl);
|
|
280
281
|
throw new HttpError(429, subscriptionUsageLimitMessage(limit, accountsUrl), "subscription_usage_limit", undefined, { "retry-after": String(retryAfterSeconds(limit)), ...codex?.headers }, codex?.body);
|
|
281
282
|
}
|
|
283
|
+
// An overflow stays a context error, as hosted Dari's own refusal is when a
|
|
284
|
+
// connected gateway relays it, so the client compacts instead of retrying.
|
|
285
|
+
if (isContextOverflow({ ...result.failure, stopReason: "error" })
|
|
286
|
+
|| providerFailureMessage(result.failure).includes("standard-price context range")) {
|
|
287
|
+
throw new HttpError(400, providerFailureMessage(result.failure), "context_length_exceeded");
|
|
288
|
+
}
|
|
282
289
|
const rejected = credentialRejectionFromFailure(result.failure);
|
|
283
290
|
if (rejected !== null) {
|
|
284
291
|
const accountsUrl = gatewayPlatform().accountsUrl;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mupt-ai/dari-gateway",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.376",
|
|
4
4
|
"description": "Self-hostable LLM gateway for coding agents and APIs: one endpoint for Anthropic Messages, OpenAI Chat Completions, and OpenAI Responses, with subscription pooling, failover, and prompt-cache-aware routing.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
54
|
"@aws-sdk/client-sts": "3.1063.0",
|
|
55
|
-
"@mupt-ai/dari-router": "1.0.
|
|
55
|
+
"@mupt-ai/dari-router": "1.0.376",
|
|
56
56
|
"@mupt-ai/pi-ai": "1.5.2-mupt.3"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
@@ -63,7 +63,10 @@ function codexCatalogEntry(args: CodexCatalogEntry): Record<string, unknown> {
|
|
|
63
63
|
supports_image_detail_original: false,
|
|
64
64
|
context_window: args.contextWindow,
|
|
65
65
|
max_context_window: args.contextWindow,
|
|
66
|
-
|
|
66
|
+
// Codex compacts at 90% of the window by default, judged by the last
|
|
67
|
+
// response's usage. The standard-price check counts the next prompt by
|
|
68
|
+
// estimate, before the new tool output is measured, so compact earlier.
|
|
69
|
+
auto_compact_token_limit: Math.floor(args.contextWindow * 0.8),
|
|
67
70
|
comp_hash: null,
|
|
68
71
|
effective_context_window_percent: 95,
|
|
69
72
|
experimental_supported_tools: [],
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { DEFAULT_RESET_MIN_HOURS } from "../models/sources.js";
|
|
2
2
|
import type { RoutingDecision } from "@mupt-ai/dari-router/policy-engine";
|
|
3
|
+
import { isContextOverflow, type AssistantMessage } from "@mupt-ai/pi-ai";
|
|
3
4
|
import { HttpError } from "../http/errors.js";
|
|
4
5
|
import { linkUnavailableError, plansExhausted } from "../link/errors.js";
|
|
5
6
|
import { piMessageToInteractionOutput } from "./pi_output.js";
|
|
@@ -497,6 +498,14 @@ async function throwProviderFailure(args: {
|
|
|
497
498
|
codex?.body,
|
|
498
499
|
);
|
|
499
500
|
}
|
|
501
|
+
// An overflow stays a context error, as hosted Dari's own refusal is when a
|
|
502
|
+
// connected gateway relays it, so the client compacts instead of retrying.
|
|
503
|
+
if (
|
|
504
|
+
isContextOverflow({ ...result.failure, stopReason: "error" } as unknown as AssistantMessage)
|
|
505
|
+
|| providerFailureMessage(result.failure).includes("standard-price context range")
|
|
506
|
+
) {
|
|
507
|
+
throw new HttpError(400, providerFailureMessage(result.failure), "context_length_exceeded");
|
|
508
|
+
}
|
|
500
509
|
const rejected = credentialRejectionFromFailure(result.failure);
|
|
501
510
|
if (rejected !== null) {
|
|
502
511
|
const accountsUrl = gatewayPlatform().accountsUrl;
|