@ccusage/codex 18.0.7 → 18.0.8

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 (2) hide show
  1. package/dist/index.js +16 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -895,7 +895,7 @@ async function executeCommand(cmd, ctx, name$1) {
895
895
  await resolved.run(ctx);
896
896
  }
897
897
  var name = "@ccusage/codex";
898
- var version = "18.0.7";
898
+ var version = "18.0.8";
899
899
  var description = "Usage analysis tool for OpenAI Codex sessions";
900
900
  var require_debug = /* @__PURE__ */ __commonJSMin(((exports, module) => {
901
901
  let messages = [];
@@ -6959,6 +6959,16 @@ const CODEX_PROVIDER_PREFIXES = [
6959
6959
  "openrouter/openai/"
6960
6960
  ];
6961
6961
  const CODEX_MODEL_ALIASES_MAP = new Map([["gpt-5-codex", "gpt-5"], ["gpt-5.3-codex", "gpt-5.2-codex"]]);
6962
+ const FREE_MODEL_PRICING = {
6963
+ inputCostPerMToken: 0,
6964
+ cachedInputCostPerMToken: 0,
6965
+ outputCostPerMToken: 0
6966
+ };
6967
+ function isOpenRouterFreeModel(model) {
6968
+ const normalized = model.trim().toLowerCase();
6969
+ if (normalized === "openrouter/free") return true;
6970
+ return normalized.startsWith("openrouter/") && normalized.endsWith(":free");
6971
+ }
6962
6972
  function hasNonZeroTokenPricing(pricing) {
6963
6973
  return (pricing.input_cost_per_token ?? 0) > 0 || (pricing.output_cost_per_token ?? 0) > 0 || (pricing.cache_read_input_token_cost ?? 0) > 0;
6964
6974
  }
@@ -7453,6 +7463,7 @@ var CodexPricingSource = class {
7453
7463
  this.fetcher[Symbol.dispose]();
7454
7464
  }
7455
7465
  async getPricing(model) {
7466
+ if (isOpenRouterFreeModel(model)) return FREE_MODEL_PRICING;
7456
7467
  const directLookup = await this.fetcher.getModelPricing(model);
7457
7468
  if (isFailure(directLookup)) throw directLookup.error;
7458
7469
  let pricing = directLookup.value;
@@ -7462,7 +7473,10 @@ var CodexPricingSource = class {
7462
7473
  if (isFailure(aliasLookup)) throw aliasLookup.error;
7463
7474
  if (aliasLookup.value != null && hasNonZeroTokenPricing(aliasLookup.value)) pricing = aliasLookup.value;
7464
7475
  }
7465
- if (pricing == null) throw new Error(`Pricing not found for model ${model}`);
7476
+ if (pricing == null) {
7477
+ logger.warn(`Pricing not found for model ${model}; defaulting to zero-cost pricing.`);
7478
+ return FREE_MODEL_PRICING;
7479
+ }
7466
7480
  return {
7467
7481
  inputCostPerMToken: toPerMillion(pricing.input_cost_per_token),
7468
7482
  cachedInputCostPerMToken: toPerMillion(pricing.cache_read_input_token_cost, pricing.input_cost_per_token),
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ccusage/codex",
3
3
  "type": "module",
4
- "version": "18.0.7",
4
+ "version": "18.0.8",
5
5
  "description": "Usage analysis tool for OpenAI Codex sessions",
6
6
  "author": "ryoppippi",
7
7
  "license": "MIT",