negotium 0.23.1 → 0.23.3

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 (36) hide show
  1. package/dist/agent-helpers.js +136 -30
  2. package/dist/agent-helpers.js.map +12 -11
  3. package/dist/{chunk-pr8p6pap.js → chunk-6cnpkzkb.js} +7 -2
  4. package/dist/{chunk-pr8p6pap.js.map → chunk-6cnpkzkb.js.map} +3 -3
  5. package/dist/{chunk-w6xavjz2.js → chunk-6gt62j1j.js} +20 -8
  6. package/dist/chunk-6gt62j1j.js.map +12 -0
  7. package/dist/{chunk-z4r7tt2p.js → chunk-cez5m5hm.js} +1 -1
  8. package/dist/hosted-agent.js +97 -13
  9. package/dist/hosted-agent.js.map +8 -7
  10. package/dist/main.js +212 -48
  11. package/dist/main.js.map +15 -14
  12. package/dist/mcp-factories.js +136 -30
  13. package/dist/mcp-factories.js.map +12 -11
  14. package/dist/prompts.js +9 -10
  15. package/dist/prompts.js.map +3 -3
  16. package/dist/registry.js +5 -5
  17. package/dist/registry.js.map +3 -3
  18. package/dist/rollout.js +2 -2
  19. package/dist/runtime/src/agents/codex-native-multi-agent.ts +28 -6
  20. package/dist/runtime/src/agents/codex-provider.ts +14 -1
  21. package/dist/runtime/src/agents/codex-registry.ts +6 -7
  22. package/dist/runtime/src/agents/codex-tier-resolver.ts +74 -0
  23. package/dist/runtime/src/agents/explicit-agent-switch.ts +6 -1
  24. package/dist/runtime/src/agents/model-catalog.ts +34 -23
  25. package/dist/runtime/src/runtime/turn-event-stream.ts +13 -1
  26. package/dist/runtime/src/storage/token-stats.ts +2 -1
  27. package/dist/runtime/src/version.ts +1 -1
  28. package/dist/storage.js +2 -1
  29. package/dist/storage.js.map +3 -3
  30. package/dist/types/packages/core/src/agents/codex-native-multi-agent.d.ts +9 -0
  31. package/dist/types/packages/core/src/agents/codex-tier-resolver.d.ts +10 -0
  32. package/dist/types/packages/core/src/agents/model-catalog.d.ts +2 -2
  33. package/dist/types/packages/core/src/version.d.ts +1 -1
  34. package/package.json +2 -2
  35. package/dist/chunk-w6xavjz2.js.map +0 -12
  36. /package/dist/{chunk-z4r7tt2p.js.map → chunk-cez5m5hm.js.map} +0 -0
@@ -603,9 +603,14 @@ function agentAliases(agent) {
603
603
  return [
604
604
  "codex",
605
605
  "\uCF54\uB371\uC2A4",
606
+ "astra",
607
+ "sol",
608
+ "luna",
609
+ "terra",
606
610
  "gpt-6-luna",
607
611
  "gpt-6-sol",
608
612
  "gpt-5.6-luna",
613
+ "gpt-6.1-terra",
609
614
  "gpt-5.6-terra",
610
615
  "gpt-5.6-sol",
611
616
  "gpt-6-astra"
@@ -633,7 +638,7 @@ function hasExplicitAgentSwitchRequest(prompt, agent) {
633
638
  if (!prompt?.trim())
634
639
  return false;
635
640
  const text = prompt.toLowerCase().replace(/\s+/g, " ").trim();
636
- const target = `(?:${agentAliases(agent).map(escapeRegExp).join("|")})`;
641
+ const target = `(?<![A-Za-z0-9_-])(?:${agentAliases(agent).map(escapeRegExp).join("|")})(?![A-Za-z0-9_-])`;
637
642
  const switchVerb = "(?:\uBC14\uAFD4|\uBC14\uAFD4\uC918|\uBCC0\uACBD|\uBCC0\uACBD\uD574|\uC804\uD658|\uC804\uD658\uD574|\uC124\uC815|\uC124\uC815\uD574|\uC368\uC918|\uC0AC\uC6A9|\uAC00|switch|change|set|use)";
638
643
  const switchSubject = "(?:agent|runtime|model|\uC5D0\uC774\uC804\uD2B8|\uB7F0\uD0C0\uC784|\uBAA8\uB378)";
639
644
  return [
@@ -5241,7 +5246,7 @@ var init_codex = __esm(async () => {
5241
5246
  });
5242
5247
 
5243
5248
  // ../../packages/core/src/version.ts
5244
- var NEGOTIUM_VERSION = "0.23.1";
5249
+ var NEGOTIUM_VERSION = "0.23.3";
5245
5250
 
5246
5251
  // ../../packages/core/src/agents/codex-native-multi-agent.ts
5247
5252
  import { spawn as spawn2 } from "child_process";
@@ -5257,9 +5262,22 @@ import {
5257
5262
  unlinkSync as unlinkSync5,
5258
5263
  writeFileSync as writeFileSync4
5259
5264
  } from "fs";
5260
- import { createRequire as createRequire2 } from "module";
5261
5265
  import { tmpdir } from "os";
5262
5266
  import { dirname as dirname7, join as join7 } from "path";
5267
+ import { fileURLToPath as fileURLToPath2 } from "url";
5268
+ function findPackageJson(specifier, searchFromDir) {
5269
+ let dir = searchFromDir;
5270
+ for (;; ) {
5271
+ const candidate = join7(dir, "node_modules", specifier, "package.json");
5272
+ if (existsSync6(candidate))
5273
+ return candidate;
5274
+ const parent = dirname7(dir);
5275
+ if (parent === dir) {
5276
+ throw new Error(`Could not locate node_modules/${specifier} starting from ${searchFromDir}`);
5277
+ }
5278
+ dir = parent;
5279
+ }
5280
+ }
5263
5281
  function readPackageVersion(packageJsonPath) {
5264
5282
  const parsed = JSON.parse(readFileSync5(packageJsonPath, "utf8"));
5265
5283
  if (typeof parsed.version !== "string" || !parsed.version.trim()) {
@@ -5484,12 +5502,11 @@ function writeCodexCatalogWithNativeMultiAgentDisabled(authFilePath, sourcePath)
5484
5502
  writePrivateFileAtomic(outputPath, contents);
5485
5503
  return outputPath;
5486
5504
  }
5487
- var moduleRequire, codexSdkPackagePath, codexSdkRequire, bundledCodexPackagePath, BUNDLED_CODEX_VERSION, SAFE_BUNDLED_CODEX_VERSION, NEGOTIUM_MODEL_CACHE, NEGOTIUM_MODEL_CATALOG, CODEX_BOOTSTRAP_EXIT_WAIT_MS = 3000;
5505
+ var thisModuleDir, codexSdkPackagePath, bundledCodexPackagePath, BUNDLED_CODEX_VERSION, SAFE_BUNDLED_CODEX_VERSION, NEGOTIUM_MODEL_CACHE, NEGOTIUM_MODEL_CATALOG, CODEX_BOOTSTRAP_EXIT_WAIT_MS = 3000;
5488
5506
  var init_codex_native_multi_agent = __esm(() => {
5489
- moduleRequire = createRequire2(import.meta.url);
5490
- codexSdkPackagePath = moduleRequire.resolve("@openai/codex-sdk/package.json");
5491
- codexSdkRequire = createRequire2(codexSdkPackagePath);
5492
- bundledCodexPackagePath = codexSdkRequire.resolve("@openai/codex/package.json");
5507
+ thisModuleDir = dirname7(fileURLToPath2(import.meta.url));
5508
+ codexSdkPackagePath = findPackageJson("@openai/codex-sdk", thisModuleDir);
5509
+ bundledCodexPackagePath = findPackageJson("@openai/codex", dirname7(codexSdkPackagePath));
5493
5510
  BUNDLED_CODEX_VERSION = readPackageVersion(bundledCodexPackagePath);
5494
5511
  SAFE_BUNDLED_CODEX_VERSION = BUNDLED_CODEX_VERSION.replace(/[^a-zA-Z0-9._-]/g, "_");
5495
5512
  NEGOTIUM_MODEL_CACHE = `negotium-models-cache-${SAFE_BUNDLED_CODEX_VERSION}.json`;
@@ -5633,7 +5650,7 @@ var init_codex_registry = __esm(async () => {
5633
5650
  VALID_EFFORTS2 = new Set(CODEX_EFFORT_VALUES);
5634
5651
  codexRegistry = {
5635
5652
  kind: "codex",
5636
- defaultModel: "gpt-6-luna",
5653
+ defaultModel: "luna",
5637
5654
  expandModelAlias(s) {
5638
5655
  return s;
5639
5656
  },
@@ -6791,6 +6808,76 @@ var init_claude_provider = __esm(async () => {
6791
6808
  claudeProcessExitListeners = new WeakMap;
6792
6809
  });
6793
6810
 
6811
+ // ../../packages/core/src/agents/codex-tier-resolver.ts
6812
+ function codexTiersFromCache(cache) {
6813
+ const result = {};
6814
+ const priorities = {};
6815
+ if (!cache || typeof cache !== "object" || !("models" in cache))
6816
+ return result;
6817
+ const models = cache.models;
6818
+ if (!Array.isArray(models))
6819
+ return result;
6820
+ for (const model of models) {
6821
+ if (!model || typeof model !== "object")
6822
+ continue;
6823
+ const { slug, visibility, priority } = model;
6824
+ if (typeof slug !== "string" || visibility !== "list")
6825
+ continue;
6826
+ if (typeof priority !== "number" || !Number.isFinite(priority))
6827
+ continue;
6828
+ const suffix = slug.slice(slug.lastIndexOf("-") + 1);
6829
+ if (!Object.hasOwn(CODEX_TIER_FALLBACKS, suffix))
6830
+ continue;
6831
+ const tier = suffix;
6832
+ if (priorities[tier] === undefined || priority < priorities[tier]) {
6833
+ priorities[tier] = priority;
6834
+ result[tier] = slug;
6835
+ }
6836
+ }
6837
+ return result;
6838
+ }
6839
+ function resolveCodexTierModel(tier, cachePath = process.env.NEGOTIUM_CODEX_MODELS_CACHE_FILE ?? bundledCodexModelCachePath(hostedCodexAuthFilePath())) {
6840
+ try {
6841
+ const selected = codexTiersFromCache(readCompatibleCodexModelCache(cachePath).parsed)[tier];
6842
+ if (selected) {
6843
+ if (!pricedSlugs.has(selected) && !warnedUnpricedSlugs.has(selected)) {
6844
+ warnedUnpricedSlugs.add(selected);
6845
+ logger.warn({ tier, model: selected }, "Codex tier model has no token-stats price");
6846
+ }
6847
+ return selected;
6848
+ }
6849
+ } catch (error) {
6850
+ if (!warnedCachePaths.has(cachePath)) {
6851
+ warnedCachePaths.add(cachePath);
6852
+ logger.warn({ err: error, cachePath }, "Codex tier cache unavailable; using fallback ids");
6853
+ }
6854
+ }
6855
+ return CODEX_TIER_FALLBACKS[tier];
6856
+ }
6857
+ var CODEX_TIER_FALLBACKS, warnedCachePaths, warnedUnpricedSlugs, pricedSlugs;
6858
+ var init_codex_tier_resolver = __esm(async () => {
6859
+ init_codex_native_multi_agent();
6860
+ init_logger();
6861
+ await init_execution_host();
6862
+ CODEX_TIER_FALLBACKS = {
6863
+ astra: "gpt-6-astra",
6864
+ sol: "gpt-6-sol",
6865
+ luna: "gpt-6-luna",
6866
+ terra: "gpt-6.1-terra"
6867
+ };
6868
+ warnedCachePaths = new Set;
6869
+ warnedUnpricedSlugs = new Set;
6870
+ pricedSlugs = new Set([
6871
+ "gpt-6-astra",
6872
+ "gpt-6-sol",
6873
+ "gpt-6-luna",
6874
+ "gpt-6.1-terra",
6875
+ "gpt-5.6-sol",
6876
+ "gpt-5.6-luna",
6877
+ "gpt-5.6-terra"
6878
+ ]);
6879
+ });
6880
+
6794
6881
  // ../../packages/core/src/agents/codex-tree-manager.ts
6795
6882
  function createCodexTreeManager(host, options = {}) {
6796
6883
  const sigkillDelayMs = options.sigkillDelayMs ?? 5000;
@@ -7176,7 +7263,7 @@ import { chmod, copyFile, mkdtemp, rm as rm2, writeFile as writeFile2 } from "fs
7176
7263
  import { createServer } from "net";
7177
7264
  import { tmpdir as tmpdir2 } from "os";
7178
7265
  import { dirname as dirname10, join as join13, resolve as resolve8 } from "path";
7179
- import { fileURLToPath as fileURLToPath2 } from "url";
7266
+ import { fileURLToPath as fileURLToPath3 } from "url";
7180
7267
  function evaluateCodexVaultPreToolUse(input, userId, operations) {
7181
7268
  if (operations.referencesSensitiveStorage(input.tool_input)) {
7182
7269
  return {
@@ -7204,7 +7291,7 @@ function shellQuote(value) {
7204
7291
  return `'${value.replaceAll("'", `'"'"'`)}'`;
7205
7292
  }
7206
7293
  function hookClientPath() {
7207
- const moduleDir = dirname10(fileURLToPath2(import.meta.url));
7294
+ const moduleDir = dirname10(fileURLToPath3(import.meta.url));
7208
7295
  const adjacent = resolve8(moduleDir, "codex-vault-hook.mjs");
7209
7296
  if (existsSync13(adjacent))
7210
7297
  return adjacent;
@@ -8273,6 +8360,7 @@ async function* codexProvider(opts) {
8273
8360
  ...codexEnvironment ? { env: codexEnvironment } : {},
8274
8361
  config: {
8275
8362
  agents: { enabled: false },
8363
+ tools: { update_plan: { enabled: false } },
8276
8364
  features: {
8277
8365
  hooks: true,
8278
8366
  goals: false,
@@ -8296,7 +8384,9 @@ async function* codexProvider(opts) {
8296
8384
  webSearchMode: "disabled",
8297
8385
  webSearchEnabled: false
8298
8386
  } : {},
8299
- ...opts.model ? { model: opts.model } : {},
8387
+ ...opts.model ? {
8388
+ model: Object.hasOwn(CODEX_TIER_FALLBACKS, opts.model) ? resolveCodexTierModel(opts.model) : opts.model
8389
+ } : {},
8300
8390
  ...opts.effort ? { modelReasoningEffort: mapEffort(opts.effort) } : {}
8301
8391
  };
8302
8392
  let currentSessionId = opts.sessionId;
@@ -8558,6 +8648,7 @@ var init_codex_provider = __esm(async () => {
8558
8648
  init_file_events();
8559
8649
  init_logger();
8560
8650
  await __promiseAll([
8651
+ init_codex_tier_resolver(),
8561
8652
  init_codex_vault_hook_bridge(),
8562
8653
  init_execution_host(),
8563
8654
  init_codex(),
@@ -8851,10 +8942,13 @@ __export(exports_model_catalog, {
8851
8942
  FALLBACK_ORDER: () => FALLBACK_ORDER,
8852
8943
  AGENT_DISPLAY_NAME: () => AGENT_DISPLAY_NAME
8853
8944
  });
8945
+ function canonicalModelCasing() {
8946
+ return Object.fromEntries(SELECTABLE_MODELS.map((candidate) => [candidate.model.toLowerCase(), candidate.model]));
8947
+ }
8854
8948
  function canonicalModelId(value) {
8855
8949
  const trimmed = value.trim();
8856
8950
  const lower = trimmed.toLowerCase();
8857
- return SELECTABLE_MODEL_ALIASES[lower] ?? CANONICAL_MODEL_CASING[lower] ?? trimmed;
8951
+ return SELECTABLE_MODEL_ALIASES[lower] ?? canonicalModelCasing()[lower] ?? trimmed;
8858
8952
  }
8859
8953
  function formatSelectableModel(candidate) {
8860
8954
  const tier = `${candidate.intelligenceTier[0].toUpperCase()}${candidate.intelligenceTier.slice(1)}`;
@@ -8899,7 +8993,7 @@ function resolveModelForAgent(agent, requested, registry) {
8899
8993
  return registry.validateModel(candidate) ? candidate : defaultModel;
8900
8994
  }
8901
8995
  function resolveWorkerDefaultModel(agent, registry) {
8902
- return agent === "codex" ? "gpt-5.6-terra" : registry.defaultModel;
8996
+ return agent === "codex" ? "terra" : registry.defaultModel;
8903
8997
  }
8904
8998
  function resolveWorkerModel(agent, requested, registry) {
8905
8999
  const workerDefault = resolveWorkerDefaultModel(agent, registry);
@@ -8916,7 +9010,7 @@ function resolveCompactionExecution(agent, registry) {
8916
9010
  const effort = registry.validateEffort("medium") ? "medium" : registry.defaultEffort;
8917
9011
  return { model, ...effort ? { effort } : {} };
8918
9012
  }
8919
- var MODEL_OWNER, MODEL_COST_RESEARCHED_AT = "2026-09-05", MODEL_COST_ROUTING_SUMMARY = "Cost basis (2026-09-05): Codex Pro 20x and Claude Max 20x are each $200/month; Maestro models are pay-per-token. DeepSeek Flash is cheapest. gpt-6-astra and Claude Fable 5.1 are the newest flagships, both priced at $10/M input / $50/M output.", CODEX_PRO_20X_COST = "ChatGPT Pro 20x subscription: $200/month", CODEX_COMMUNITY_WEEKLY = "Community plan-level observation: roughly 2\u20134B raw/cached tokens per week; fresh-input equivalent is much lower and unstable (low confidence)", CLAUDE_MAX_20X_COST = "Claude Max 20x subscription: $200/month", CLAUDE_COMMUNITY_SESSION = "Community observations vary from roughly 220\u2013250K locally displayed tokens per 5-hour session to billions of cache-heavy raw tokens per week; calibrated reports value a full weekly allowance around $680\u2013$1,900 at API rates. Recent heavy-model reports reach the weekly cap after about 4\u20135 full sessions (low confidence; not a token cap)", SELECTABLE_MODELS, SELECTABLE_MODEL_ALIASES, CANONICAL_MODEL_CASING, FALLBACK_ORDER, AGENT_DISPLAY_NAME;
9013
+ var MODEL_OWNER, MODEL_COST_RESEARCHED_AT = "2026-09-05", MODEL_COST_ROUTING_SUMMARY = "Cost basis (2026-09-05): Codex Pro 20x and Claude Max 20x are each $200/month; Maestro models are pay-per-token. DeepSeek Flash is cheapest. gpt-6-astra and Claude Fable 5.1 are the newest flagships, both priced at $10/M input / $50/M output.", CODEX_PRO_20X_COST = "ChatGPT Pro 20x subscription: $200/month", CODEX_COMMUNITY_WEEKLY = "Community plan-level observation: roughly 2\u20134B raw/cached tokens per week; fresh-input equivalent is much lower and unstable (low confidence)", CLAUDE_MAX_20X_COST = "Claude Max 20x subscription: $200/month", CLAUDE_COMMUNITY_SESSION = "Community observations vary from roughly 220\u2013250K locally displayed tokens per 5-hour session to billions of cache-heavy raw tokens per week; calibrated reports value a full weekly allowance around $680\u2013$1,900 at API rates. Recent heavy-model reports reach the weekly cap after about 4\u20135 full sessions (low confidence; not a token cap)", SELECTABLE_MODELS, SELECTABLE_MODEL_ALIASES, FALLBACK_ORDER, AGENT_DISPLAY_NAME;
8920
9014
  var init_model_catalog = __esm(() => {
8921
9015
  init_config();
8922
9016
  MODEL_OWNER = {
@@ -8924,9 +9018,14 @@ var init_model_catalog = __esm(() => {
8924
9018
  opus: "claude",
8925
9019
  haiku: "claude",
8926
9020
  fable: "claude",
9021
+ astra: "codex",
9022
+ sol: "codex",
9023
+ luna: "codex",
9024
+ terra: "codex",
8927
9025
  "gpt-6-astra": "codex",
8928
9026
  "gpt-6-sol": "codex",
8929
9027
  "gpt-6-luna": "codex",
9028
+ "gpt-6.1-terra": "codex",
8930
9029
  "gpt-5.6-luna": "codex",
8931
9030
  "gpt-5.6-terra": "codex",
8932
9031
  "gpt-5.6-sol": "codex",
@@ -8947,7 +9046,7 @@ var init_model_catalog = __esm(() => {
8947
9046
  };
8948
9047
  SELECTABLE_MODELS = [
8949
9048
  {
8950
- model: "gpt-6-astra",
9049
+ model: "astra",
8951
9050
  agent: "codex",
8952
9051
  description: "Newest OpenAI flagship; Codex's highest-capability route.",
8953
9052
  intelligenceTier: "fable",
@@ -8957,7 +9056,7 @@ var init_model_catalog = __esm(() => {
8957
9056
  estimatedUsage: `Released 2026-09-03; became Codex CLI's bundled default in v0.153.4 (2026-09-05). Local message-count/quota-weight ranges not yet published as of the last catalog check \u2014 expect a quota weight above gpt-6-sol given the higher per-token cost. ${CODEX_COMMUNITY_WEEKLY}`
8958
9057
  },
8959
9058
  {
8960
- model: "gpt-6-sol",
9059
+ model: "sol",
8961
9060
  agent: "codex",
8962
9061
  description: "GPT-6 generation Sol route (2026-09-22) for demanding coding and agentic work.",
8963
9062
  intelligenceTier: "opus",
@@ -8967,7 +9066,7 @@ var init_model_catalog = __esm(() => {
8967
9066
  estimatedUsage: `Released 2026-09-22; local message-count/quota-weight ranges not yet published. ${CODEX_COMMUNITY_WEEKLY}`
8968
9067
  },
8969
9068
  {
8970
- model: "gpt-6-luna",
9069
+ model: "luna",
8971
9070
  agent: "codex",
8972
9071
  description: "Default Codex route (GPT-6 Luna, 2026-09-22): fast, high-volume, lowest cost.",
8973
9072
  intelligenceTier: "sonnet",
@@ -8977,14 +9076,14 @@ var init_model_catalog = __esm(() => {
8977
9076
  estimatedUsage: `Released 2026-09-22; local message-count/quota-weight ranges not yet published. ${CODEX_COMMUNITY_WEEKLY}`
8978
9077
  },
8979
9078
  {
8980
- model: "gpt-5.6-terra",
9079
+ model: "terra",
8981
9080
  agent: "codex",
8982
- description: "High-capability Codex route for complex coding and reasoning.",
9081
+ description: "GPT-6.1 Terra route (2026-10-26) for complex coding, visual reasoning, and computer use.",
8983
9082
  intelligenceTier: "opus",
8984
- routingSummary: "complex coding and reasoning; 2.5x Codex quota cost",
9083
+ routingSummary: "capable coding and computer use at a lower cost than GPT-5.6 Terra",
8985
9084
  accessCost: CODEX_PRO_20X_COST,
8986
- marginalTokenCost: "Codex credits: $2.50/M uncached input, $0.25/M cached input, $15/M output",
8987
- estimatedUsage: `Official Pro 20x range: 400\u20132,200 local messages per 5 hours; quota weight 2.5x the retired GPT-5.6 Luna. ${CODEX_COMMUNITY_WEEKLY}`
9085
+ marginalTokenCost: "Codex credits (OpenAI API rate): $1/M uncached input, $0.05/M cached input, $5/M output",
9086
+ estimatedUsage: `Released 2026-10-26; local message-count/quota-weight ranges not yet published. ${CODEX_COMMUNITY_WEEKLY}`
8988
9087
  },
8989
9088
  {
8990
9089
  model: "fable",
@@ -9078,8 +9177,13 @@ var init_model_catalog = __esm(() => {
9078
9177
  }
9079
9178
  ];
9080
9179
  SELECTABLE_MODEL_ALIASES = {
9081
- "gpt-5.6-sol": "gpt-6-sol",
9082
- "gpt-5.6-luna": "gpt-6-luna",
9180
+ "gpt-6-astra": "astra",
9181
+ "gpt-5.6-sol": "sol",
9182
+ "gpt-6-sol": "sol",
9183
+ "gpt-5.6-luna": "luna",
9184
+ "gpt-6-luna": "luna",
9185
+ "gpt-5.6-terra": "terra",
9186
+ "gpt-6.1-terra": "terra",
9083
9187
  kimi: "kimi-k3",
9084
9188
  "kimi-pro": "kimi-k3",
9085
9189
  "kimi-code": "kimi-k2.7-code",
@@ -9087,18 +9191,17 @@ var init_model_catalog = __esm(() => {
9087
9191
  "glm-pro": "glm-5.3",
9088
9192
  "glm-flash": "glm-5.3-flash"
9089
9193
  };
9090
- CANONICAL_MODEL_CASING = Object.fromEntries(SELECTABLE_MODELS.map((candidate) => [candidate.model.toLowerCase(), candidate.model]));
9091
9194
  FALLBACK_ORDER = {
9092
9195
  claude: [
9093
9196
  { agent: "maestro", model: "deepseek-pro" },
9094
- { agent: "codex", model: "gpt-6-luna" }
9197
+ { agent: "codex", model: "luna" }
9095
9198
  ],
9096
9199
  codex: [
9097
9200
  { agent: "maestro", model: "deepseek-pro" },
9098
9201
  { agent: "claude", model: "sonnet" }
9099
9202
  ],
9100
9203
  maestro: [
9101
- { agent: "codex", model: "gpt-6-luna" },
9204
+ { agent: "codex", model: "luna" },
9102
9205
  { agent: "claude", model: "sonnet" }
9103
9206
  ]
9104
9207
  };
@@ -14151,6 +14254,7 @@ var init_token_stats = __esm(async () => {
14151
14254
  "codex:gpt-6-astra": { input: 10, cacheWrite: 12.5, cacheRead: 1, output: 50 },
14152
14255
  "codex:gpt-6-sol": { input: 2, cacheRead: 0.2, output: 10 },
14153
14256
  "codex:gpt-6-luna": { input: 0.1, cacheRead: 0.01, output: 0.5 },
14257
+ "codex:gpt-6.1-terra": { input: 1, cacheRead: 0.05, output: 5 },
14154
14258
  "codex:gpt-5.6-sol": { input: 5, cacheRead: 0.5, output: 30 },
14155
14259
  "codex:gpt-5.6-terra": { input: 2.5, cacheRead: 0.25, output: 15 },
14156
14260
  "codex:gpt-5.6-luna": { input: 1, cacheRead: 0.1, output: 6 },
@@ -19336,12 +19440,13 @@ async function runTurnEventStream(topicId, topicTitle, queryId, events, control,
19336
19440
  const toolSummaryOptions = {
19337
19441
  cwd: control.injectParams?.cwd ?? workspaceCwdFor(topicId)
19338
19442
  };
19443
+ const pricedModel = agentType === "codex" && Object.hasOwn(CODEX_TIER_FALLBACKS, model) ? resolveCodexTierModel(model) : model;
19339
19444
  const recordEventUsage = (usage) => {
19340
19445
  recordUsage(userId, topicTitle, usage, {
19341
19446
  topicId,
19342
19447
  ...control.sessionId ? { providerSessionId: control.sessionId } : {},
19343
19448
  agent: agentType,
19344
- model
19449
+ model: pricedModel
19345
19450
  });
19346
19451
  };
19347
19452
  const broadcastContextProgress = (force = false) => {
@@ -19923,6 +20028,7 @@ var init_turn_event_stream = __esm(async () => {
19923
20028
  init_usage_alert();
19924
20029
  init_sensitive_path();
19925
20030
  await __promiseAll([
20031
+ init_codex_tier_resolver(),
19926
20032
  init_fork(),
19927
20033
  init_idle_archiver(),
19928
20034
  init_idle_compact(),
@@ -23477,4 +23583,4 @@ export {
23477
23583
  DEFAULT_SELF_CONFIG_PRODUCT
23478
23584
  };
23479
23585
 
23480
- //# debugId=54CABEB880CA0A4C64756E2164756E21
23586
+ //# debugId=CC840147C9D89D8164756E2164756E21