@auroraflow/code 0.0.21 → 0.0.22

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@auroraflow/code",
3
- "version": "0.0.21",
3
+ "version": "0.0.22",
4
4
  "type": "module",
5
5
  "description": "Aurora launcher and sidecar for official Codex and Claude Code clients.",
6
6
  "repository": {
@@ -5,6 +5,7 @@ import { delimiter, dirname, join, resolve } from "node:path";
5
5
  import { fileURLToPath } from "node:url";
6
6
  import { CLAUDE_HOME, CODEX_HOME, readState } from "../../state/src/index.js";
7
7
  import { ensureSidecarRunning } from "../../service/src/index.js";
8
+ import { codexModelRuntimeLimits } from "../../protocol/src/index.js";
8
9
 
9
10
  const here = dirname(fileURLToPath(import.meta.url));
10
11
  const packageRoot = resolve(here, "..", "..", "..");
@@ -316,11 +317,13 @@ function readOfficialClientVersion(bin) {
316
317
  async function writeCodexRuntimeFiles({ sidecar, model }) {
317
318
  await mkdir(CODEX_HOME, { recursive: true });
318
319
  const modelCatalogPath = join(CODEX_HOME, "model_catalog.json");
319
- await writeCodexModelCatalog(sidecar, modelCatalogPath);
320
+ const limits = await writeCodexModelCatalog(sidecar, modelCatalogPath, model);
320
321
  const config = `model = ${tomlString(model)}
321
322
  model_provider = "aurora"
322
323
  model_catalog_json = ${tomlString(modelCatalogPath)}
323
324
  suppress_unstable_features_warning = true
325
+ model_context_window = ${limits.contextWindow}
326
+ model_auto_compact_token_limit = ${limits.autoCompactTokenLimit}
324
327
 
325
328
  [model_providers.aurora]
326
329
  name = "Aurora"
@@ -341,7 +344,7 @@ stream_idle_timeout_ms = 300000
341
344
  await writeFile(join(CODEX_HOME, "auth.json"), `${JSON.stringify(auth, null, 2)}\n`, { mode: 0o600 });
342
345
  }
343
346
 
344
- async function writeCodexModelCatalog(sidecar, modelCatalogPath) {
347
+ async function writeCodexModelCatalog(sidecar, modelCatalogPath, selectedModelAlias) {
345
348
  const clientVersion = "0.137.0";
346
349
  let response;
347
350
  try {
@@ -362,6 +365,11 @@ async function writeCodexModelCatalog(sidecar, modelCatalogPath) {
362
365
  if (!Array.isArray(payload.models) || payload.models.length === 0) {
363
366
  throw new Error("Aurora Codex model catalog is empty");
364
367
  }
368
+ const selectedModel = payload.models.find(item => item.slug === selectedModelAlias);
369
+ if (!selectedModel) {
370
+ throw new Error(`Aurora Codex model catalog does not include selected model: ${selectedModelAlias}`);
371
+ }
372
+ const limits = codexModelRuntimeLimits(selectedModel);
365
373
  const catalog = { models: payload.models };
366
374
  const cache = {
367
375
  fetched_at: new Date().toISOString(),
@@ -370,6 +378,7 @@ async function writeCodexModelCatalog(sidecar, modelCatalogPath) {
370
378
  };
371
379
  await writeFile(modelCatalogPath, `${JSON.stringify(catalog, null, 2)}\n`, { mode: 0o600 });
372
380
  await writeFile(join(CODEX_HOME, "models_cache.json"), `${JSON.stringify(cache, null, 2)}\n`, { mode: 0o600 });
381
+ return limits;
373
382
  }
374
383
 
375
384
  function selectedModelAlias(state) {
@@ -52,7 +52,7 @@ export function toCodexModelInfo(item, priority = 0) {
52
52
  const supportsTools = Boolean(item.supports_tools);
53
53
  const supportsImages = Boolean(item.supports_images);
54
54
  const supportsWebSearch = Boolean(item.supports_web_search);
55
- const contextWindow = positiveNumber(item.context_window ?? item.context_window_tokens, 256000);
55
+ const contextWindow = positiveNumber(item.context_window ?? item.context_window_tokens, null);
56
56
  const maxContextWindow = positiveNumber(item.max_context_window, contextWindow);
57
57
  const reasoningLevels = Array.isArray(item.supported_reasoning_levels)
58
58
  ? item.supported_reasoning_levels
@@ -114,6 +114,21 @@ export function toCodexModelInfo(item, priority = 0) {
114
114
  };
115
115
  }
116
116
 
117
+ export function codexModelRuntimeLimits(model) {
118
+ const contextWindow = positiveNumber(model?.context_window ?? model?.context_window_tokens, 0);
119
+ if (!contextWindow) {
120
+ throw new Error(`Codex model metadata is missing context_window for ${model?.slug ?? model?.alias ?? model?.id ?? "unknown model"}`);
121
+ }
122
+ const publishedCompactLimit = positiveNumber(model?.auto_compact_token_limit, 0);
123
+ if (!publishedCompactLimit) {
124
+ throw new Error(`Codex model metadata is missing auto_compact_token_limit for ${model?.slug ?? model?.alias ?? model?.id ?? "unknown model"}`);
125
+ }
126
+ return {
127
+ contextWindow,
128
+ autoCompactTokenLimit: publishedCompactLimit
129
+ };
130
+ }
131
+
117
132
  function positiveNumber(value, defaultValue) {
118
133
  const parsed = Number(value);
119
134
  return Number.isFinite(parsed) && parsed > 0 ? parsed : defaultValue;
@@ -1,7 +1,7 @@
1
1
  import assert from "node:assert/strict";
2
2
  import test from "node:test";
3
3
 
4
- import { rewriteRuntimeModel, toCodexModelInfo } from "./index.js";
4
+ import { codexModelRuntimeLimits, rewriteRuntimeModel, toCodexModelInfo } from "./index.js";
5
5
 
6
6
  const CODEX_MODEL_INFO_FIELDS = [
7
7
  "additional_speed_tiers",
@@ -178,3 +178,28 @@ test("keeps hosted web search for supported selected models", () => {
178
178
  assert.equal(rewritten.model, "cx/gpt-5.5");
179
179
  assert.deepEqual(rewritten.tools, [{ type: "web_search" }]);
180
180
  });
181
+
182
+ test("uses published Codex compaction limit", () => {
183
+ const limits = codexModelRuntimeLimits({
184
+ slug: "cx/gpt-5.5",
185
+ context_window: 128000,
186
+ auto_compact_token_limit: 96000
187
+ });
188
+
189
+ assert.equal(limits.contextWindow, 128000);
190
+ assert.equal(limits.autoCompactTokenLimit, 96000);
191
+ });
192
+
193
+ test("rejects Codex model metadata without a context window", () => {
194
+ assert.throws(
195
+ () => codexModelRuntimeLimits({ slug: "cx/missing" }),
196
+ /missing context_window/
197
+ );
198
+ });
199
+
200
+ test("rejects Codex model metadata without a published compaction limit", () => {
201
+ assert.throws(
202
+ () => codexModelRuntimeLimits({ slug: "cx/missing", context_window: 128000 }),
203
+ /missing auto_compact_token_limit/
204
+ );
205
+ });