@yansigit/opencodex 2.32.0 → 2.33.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.
Files changed (108) hide show
  1. package/README.md +2 -2
  2. package/gui/dist/assets/index-DKLr4LTE.js +102 -0
  3. package/gui/dist/assets/index-DrSQdTRd.css +1 -0
  4. package/gui/dist/index.html +2 -2
  5. package/package.json +6 -5
  6. package/src/adapters/anthropic.ts +20 -6
  7. package/src/adapters/azure.ts +20 -4
  8. package/src/adapters/base.ts +3 -1
  9. package/src/adapters/command-code.ts +40 -7
  10. package/src/adapters/cursor/live-transport.ts +1 -1
  11. package/src/adapters/cursor/protobuf-events.ts +158 -7
  12. package/src/adapters/cursor/protobuf-request.ts +33 -15
  13. package/src/adapters/cursor/request-builder.ts +4 -3
  14. package/src/adapters/cursor/tool-definitions.ts +27 -1
  15. package/src/adapters/cursor/types.ts +4 -3
  16. package/src/adapters/cursor.ts +9 -0
  17. package/src/adapters/google-antigravity-replay.ts +2 -2
  18. package/src/adapters/google-antigravity-wire.ts +7 -0
  19. package/src/adapters/google-errors.ts +6 -2
  20. package/src/adapters/google-http.ts +30 -7
  21. package/src/adapters/google-truncation.ts +5 -0
  22. package/src/adapters/google-wire-compiler.ts +38 -6
  23. package/src/adapters/google.ts +148 -26
  24. package/src/adapters/kiro-tools.ts +20 -9
  25. package/src/adapters/openai-chat.ts +9 -0
  26. package/src/adapters/openai-responses.ts +1 -1
  27. package/src/bridge.ts +112 -9
  28. package/src/claude/context-windows.ts +16 -9
  29. package/src/cli/doctor.ts +2 -2
  30. package/src/cli/index.ts +9 -2
  31. package/src/cli/provider.ts +6 -0
  32. package/src/cli/status.ts +23 -0
  33. package/src/codex/auth-api.ts +4 -2
  34. package/src/codex/autostart-health.ts +16 -0
  35. package/src/codex/catalog/aggregation.ts +12 -12
  36. package/src/codex/catalog/effort.ts +18 -3
  37. package/src/codex/catalog/metadata.ts +27 -1
  38. package/src/codex/catalog/model-metadata.ts +39 -12
  39. package/src/codex/catalog/parsing.ts +38 -27
  40. package/src/codex/catalog/provider-fetch.ts +198 -133
  41. package/src/codex/catalog/sync.ts +1 -1
  42. package/src/codex/convergence.ts +5 -0
  43. package/src/codex/shim.ts +56 -3
  44. package/src/config/provider-validation.ts +37 -0
  45. package/src/config.ts +78 -2
  46. package/src/generated/compatibility-version.json +120 -96
  47. package/src/images/loop.ts +37 -6
  48. package/src/lib/azure-identity.ts +154 -0
  49. package/src/lib/debug.ts +42 -0
  50. package/src/lib/errors.ts +14 -0
  51. package/src/lib/provider-outbound.ts +45 -33
  52. package/src/lib/provider-tls-profile.ts +309 -0
  53. package/src/lib/proxy-env.ts +49 -0
  54. package/src/lib/redact.ts +10 -1
  55. package/src/oauth/antigravity-routing.ts +282 -236
  56. package/src/oauth/callback-server.ts +22 -2
  57. package/src/oauth/command-code.ts +5 -16
  58. package/src/oauth/google-antigravity.ts +42 -5
  59. package/src/oauth/index.ts +15 -3
  60. package/src/oauth/kimi.ts +9 -1
  61. package/src/oauth/open-browser-choice.ts +26 -0
  62. package/src/oauth/store.ts +6 -0
  63. package/src/providers/antigravity-quota.ts +3 -1
  64. package/src/providers/api-keys.ts +2 -1
  65. package/src/providers/auto-compact-budget.ts +65 -0
  66. package/src/providers/derive.ts +4 -0
  67. package/src/providers/key-failover.ts +5 -1
  68. package/src/providers/openai-tiers.ts +5 -0
  69. package/src/providers/provider-id-rewrite.ts +1 -0
  70. package/src/providers/quota.ts +59 -13
  71. package/src/providers/registry.ts +3 -1
  72. package/src/providers/request-pacing.ts +33 -6
  73. package/src/providers/xai-transport.ts +21 -0
  74. package/src/responses/google-provider-options.ts +36 -0
  75. package/src/responses/namespace-tool-compat.ts +84 -4
  76. package/src/responses/parser.ts +11 -0
  77. package/src/responses/provider-opaque-metadata.ts +3 -3
  78. package/src/responses/schema.ts +37 -0
  79. package/src/responses/state.ts +94 -4
  80. package/src/router.ts +8 -2
  81. package/src/server/auth-cors.ts +28 -0
  82. package/src/server/images.ts +19 -35
  83. package/src/server/management/agent-settings-routes.ts +205 -15
  84. package/src/server/management/combo-routes.ts +6 -0
  85. package/src/server/management/config-routes.ts +31 -5
  86. package/src/server/management/model-rows.ts +4 -0
  87. package/src/server/management/oauth-account-routes.ts +25 -4
  88. package/src/server/management/provider-routes.ts +113 -15
  89. package/src/server/management/routing-profile-routes.ts +3 -0
  90. package/src/server/request-log.ts +21 -0
  91. package/src/server/responses/agent-task-recovery.ts +1 -1
  92. package/src/server/responses/compact.ts +30 -1
  93. package/src/server/responses/core.ts +359 -153
  94. package/src/server/responses/empty-completion-guard.ts +35 -6
  95. package/src/server/responses/fetch-helpers.ts +18 -5
  96. package/src/server/responses/v2-native-parent-override.ts +59 -0
  97. package/src/server/responses/ws-upstream.ts +75 -2
  98. package/src/server/responses-undeclared-tool-guard.ts +90 -8
  99. package/src/service.ts +1 -1
  100. package/src/types/config.ts +16 -1
  101. package/src/types/provider.ts +16 -0
  102. package/src/types/request.ts +28 -0
  103. package/src/types/tools.ts +27 -0
  104. package/src/types.ts +6 -0
  105. package/src/web-search/gemini-executor.ts +6 -4
  106. package/src/web-search/loop.ts +42 -6
  107. package/gui/dist/assets/index-BG43zwVe.js +0 -102
  108. package/gui/dist/assets/index-CiSI-jrP.css +0 -1
@@ -31,7 +31,8 @@ import { redactSecretString } from "../../lib/redact";
31
31
  import upstreamModelsSnapshot from "../data/upstream-models.json";
32
32
 
33
33
 
34
- import { NATIVE_OPENAI_CONTEXT_OVERRIDES, SUPPORTED_NATIVE_OPENAI_SLUGS, UPSTREAM_NATIVE_ENTRIES, isNativeOpenAiCapabilityAliasModel, nativeMultiAgentVersion, nativeOpenAiContextWindow, nativeOpenAiMaxInputTokens, type NativeContextLimitsInput } from "./metadata";
34
+ import { NATIVE_OPENAI_CONTEXT_OVERRIDES, SUPPORTED_NATIVE_OPENAI_SLUGS, UPSTREAM_NATIVE_ENTRIES, isNativeOpenAiCapabilityAliasModel, nativeMultiAgentVersion, nativeOpenAiAutoCompactTokenLimit, nativeOpenAiContextWindow, nativeOpenAiMaxInputTokens, type NativeContextLimitsInput } from "./metadata";
35
+ import { clampAutoCompactTokenLimit } from "../../providers/auto-compact-budget";
35
36
  import { trustedAccountBoundNativeCatalogSlug } from "./account-models";
36
37
  import { CODEX_NATIVE_ALIAS_CATALOG_KIND } from "./kinds";
37
38
 
@@ -113,6 +114,8 @@ export interface CatalogModel {
113
114
  maxInputTokens?: number;
114
115
  /** Generated `maxTokens` and live output limits; never treated as context. */
115
116
  maxOutputTokens?: number;
117
+ /** Soft client compaction threshold; hard context/input limits remain authoritative. */
118
+ autoCompactTokenLimit?: number;
116
119
  contextCap?: number;
117
120
  contextCapped?: boolean;
118
121
  /** Pre-cap discovered window for Models UI copy when a cap lowered it. */
@@ -307,22 +310,6 @@ export function isNativeOpenAiEntry(entry: RawEntry): boolean {
307
310
  return typeof entry.slug === "string" && !entry.slug.includes("/");
308
311
  }
309
312
 
310
- /**
311
- * Auto-compaction threshold for a native row.
312
- *
313
- * The usual rule is 90% of the window, but a row whose input ceiling sits below that has to
314
- * clamp to the ceiling instead — otherwise the client keeps filling until upstream answers
315
- * `context_length_exceeded` and compaction never gets a chance to run. Native GPT-5.6 no
316
- * longer trips this (922,000 window, 829,800 at 90%), but the routed and API-key rows carry
317
- * the same family at a 1,050,000 window where 90% would be 945,000 — past the ceiling.
318
- */
319
- function nativeAutoCompactLimit(contextWindow: number, maxInputTokens: number | undefined, contextCap?: number): number {
320
- const ninety = Math.floor(contextWindow * 0.9);
321
- if (typeof maxInputTokens !== "number" || maxInputTokens <= 0) return ninety;
322
- const cappedMaxInput = applyProviderContextCap(maxInputTokens, contextCap) ?? maxInputTokens;
323
- return Math.min(ninety, cappedMaxInput, contextWindow);
324
- }
325
-
326
313
  /**
327
314
  * Narrow any already-resolved native window by the user levers.
328
315
  *
@@ -348,6 +335,9 @@ export function applyNativeOpenAiContextOverride(entry: RawEntry, limits?: Nativ
348
335
  ?? (isNativeOpenAiEntry(entry) ? entry.slug as string : undefined);
349
336
  if (!nativeSlug) return;
350
337
  const override = NATIVE_OPENAI_CONTEXT_OVERRIDES[nativeSlug];
338
+ // Captured before any override/cap rewrites the row: a retained compaction threshold only
339
+ // describes the window it arrived with.
340
+ const incomingContextWindow = typeof entry.context_window === "number" ? entry.context_window : undefined;
351
341
  if (override) {
352
342
  // Read the effective values through the accessors rather than re-deriving them from the
353
343
  // static table: this function used to apply only the provider cap, so a per-model window
@@ -355,11 +345,6 @@ export function applyNativeOpenAiContextOverride(entry: RawEntry, limits?: Nativ
355
345
  if (typeof override.contextWindow === "number") {
356
346
  const contextWindow = nativeOpenAiContextWindow(nativeSlug, limits) ?? override.contextWindow;
357
347
  entry.context_window = contextWindow;
358
- entry.auto_compact_token_limit = nativeAutoCompactLimit(
359
- contextWindow,
360
- nativeOpenAiMaxInputTokens(nativeSlug, limits) ?? override.maxInputTokens,
361
- undefined,
362
- );
363
348
  }
364
349
  if (typeof override.maxContextWindow === "number") {
365
350
  const maxContextWindow = narrowNativeMaxContextWindow(nativeSlug, override.maxContextWindow, limits);
@@ -374,17 +359,43 @@ export function applyNativeOpenAiContextOverride(entry: RawEntry, limits?: Nativ
374
359
  const cappedContext = narrowNativeMaxContextWindow(nativeSlug, currentContext, limits);
375
360
  if (cappedContext !== currentContext && typeof cappedContext === "number") {
376
361
  entry.context_window = cappedContext;
377
- entry.auto_compact_token_limit = nativeAutoCompactLimit(
378
- cappedContext,
379
- nativeOpenAiMaxInputTokens(nativeSlug, limits) ?? override?.maxInputTokens,
380
- undefined,
381
- );
382
362
  }
383
363
  const currentMax = typeof entry.max_context_window === "number" ? entry.max_context_window : undefined;
384
364
  const cappedMax = narrowNativeMaxContextWindow(nativeSlug, currentMax, limits);
385
365
  if (cappedMax !== currentMax) {
386
366
  entry.max_context_window = cappedMax;
387
367
  }
368
+ const effectiveContext = typeof entry.context_window === "number" && entry.context_window > 0
369
+ ? entry.context_window
370
+ : undefined;
371
+ if (effectiveContext !== undefined) {
372
+ const derivedAutoCompactTokenLimit = nativeOpenAiAutoCompactTokenLimit(nativeSlug, limits);
373
+ // Only trust a retained threshold that still describes THIS window. When sync corrects the
374
+ // window, the old number is an artifact of the old one: a 115_200 limit retained from a
375
+ // 128k row would pin a corrected 272k model to 42% of its real window and compact every
376
+ // long turn early. Lower-is-policy still holds whenever the window is unchanged.
377
+ const retainedDescribesCurrentContext = incomingContextWindow === undefined
378
+ || incomingContextWindow === effectiveContext;
379
+ const retainedAutoCompactTokenLimit = retainedDescribesCurrentContext
380
+ && isNativeOpenAiEntry(entry)
381
+ && typeof entry.auto_compact_token_limit === "number"
382
+ && Number.isSafeInteger(entry.auto_compact_token_limit)
383
+ && entry.auto_compact_token_limit > 0
384
+ ? entry.auto_compact_token_limit
385
+ : undefined;
386
+ // A smaller threshold retained from Codex is policy evidence too. Configuration may
387
+ // lower it further, but catalog sync must never replace it with a larger default.
388
+ const loweringAutoCompactTokenLimit = retainedAutoCompactTokenLimit === undefined
389
+ ? derivedAutoCompactTokenLimit
390
+ : derivedAutoCompactTokenLimit === undefined
391
+ ? retainedAutoCompactTokenLimit
392
+ : Math.min(retainedAutoCompactTokenLimit, derivedAutoCompactTokenLimit);
393
+ entry.auto_compact_token_limit = clampAutoCompactTokenLimit(
394
+ effectiveContext,
395
+ nativeOpenAiMaxInputTokens(nativeSlug, limits) ?? override?.maxInputTokens,
396
+ loweringAutoCompactTokenLimit,
397
+ );
398
+ }
388
399
  }
389
400
 
390
401
  export function ensureStrictCatalogFields(