claudish 7.13.0 → 7.14.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 (2) hide show
  1. package/dist/index.js +76 -32
  2. package/package.json +5 -5
package/dist/index.js CHANGED
@@ -581,7 +581,7 @@ var init_onepassword_config = __esm(() => {
581
581
  });
582
582
 
583
583
  // src/version.ts
584
- var VERSION = "7.13.0";
584
+ var VERSION = "7.14.0";
585
585
 
586
586
  // src/logger.ts
587
587
  var exports_logger = {};
@@ -31354,6 +31354,28 @@ var init_base_api_format = __esm(() => {
31354
31354
  };
31355
31355
  });
31356
31356
 
31357
+ // src/adapters/reasoning-cache.ts
31358
+ function rememberReasoningForCall(callId, items) {
31359
+ if (!callId || items.length === 0)
31360
+ return;
31361
+ if (cache.has(callId))
31362
+ cache.delete(callId);
31363
+ cache.set(callId, items);
31364
+ while (cache.size > MAX_ENTRIES) {
31365
+ const oldest = cache.keys().next().value;
31366
+ if (oldest === undefined)
31367
+ break;
31368
+ cache.delete(oldest);
31369
+ }
31370
+ }
31371
+ function reasoningForCall(callId) {
31372
+ return cache.get(callId);
31373
+ }
31374
+ var MAX_ENTRIES = 500, cache;
31375
+ var init_reasoning_cache = __esm(() => {
31376
+ cache = new Map;
31377
+ });
31378
+
31357
31379
  // src/adapters/codex-api-format.ts
31358
31380
  function normalizeCodexModel(modelId) {
31359
31381
  if (!modelId)
@@ -31365,6 +31387,7 @@ var CodexAPIFormat;
31365
31387
  var init_codex_api_format = __esm(() => {
31366
31388
  init_logger();
31367
31389
  init_base_api_format();
31390
+ init_reasoning_cache();
31368
31391
  CodexAPIFormat = class CodexAPIFormat extends BaseAPIFormat {
31369
31392
  processTextContent(textContent, _accumulatedText) {
31370
31393
  return {
@@ -31387,6 +31410,10 @@ var init_codex_api_format = __esm(() => {
31387
31410
  }
31388
31411
  buildPayload(claudeRequest, messages, tools) {
31389
31412
  const convertedMessages = this.convertMessagesToResponsesAPI(messages);
31413
+ const replayedReasoning = convertedMessages.filter((i) => i.type === "reasoning").length;
31414
+ if (replayedReasoning > 0) {
31415
+ log(`[CodexAPIFormat] replaying ${replayedReasoning} cached reasoning item(s)`);
31416
+ }
31390
31417
  const normalizedModel = normalizeCodexModel(this.modelId);
31391
31418
  const strippedMessages = convertedMessages.map((item) => {
31392
31419
  const { id, ...rest } = item;
@@ -31491,6 +31518,9 @@ var init_codex_api_format = __esm(() => {
31491
31518
  }
31492
31519
  for (const toolCall of msg.tool_calls) {
31493
31520
  if (toolCall.type === "function") {
31521
+ const reasoning = reasoningForCall(toolCall.id);
31522
+ if (reasoning?.length)
31523
+ result.push(...reasoning);
31494
31524
  result.push({
31495
31525
  type: "function_call",
31496
31526
  call_id: toolCall.id,
@@ -36157,10 +36187,10 @@ function getCachedEntries() {
36157
36187
  if (mtimeMs === _memoMtimeMs && _memoEntries !== null) {
36158
36188
  return _memoEntries;
36159
36189
  }
36160
- const cache = readAllModelsCache();
36161
- if (!cache)
36190
+ const cache2 = readAllModelsCache();
36191
+ if (!cache2)
36162
36192
  return null;
36163
- _memoEntries = cache.entries;
36193
+ _memoEntries = cache2.entries;
36164
36194
  _memoMtimeMs = mtimeMs;
36165
36195
  return _memoEntries;
36166
36196
  }
@@ -38150,6 +38180,7 @@ function createResponsesStreamHandler(c, response, opts) {
38150
38180
  let reasoningIdx = -1;
38151
38181
  let lastSummaryIndex = -1;
38152
38182
  let incompleteReason = null;
38183
+ let pendingReasoning = [];
38153
38184
  let inputTokens = 0;
38154
38185
  let outputTokens = 0;
38155
38186
  let hasToolUse = false;
@@ -38266,6 +38297,10 @@ data: ${JSON.stringify(data)}
38266
38297
  functionCalls.set(itemId, fnCallData);
38267
38298
  }
38268
38299
  openToolBlocks.add(fnCallData);
38300
+ if (pendingReasoning.length > 0) {
38301
+ rememberReasoningForCall(callId, pendingReasoning);
38302
+ pendingReasoning = [];
38303
+ }
38269
38304
  send("content_block_start", {
38270
38305
  type: "content_block_start",
38271
38306
  index: fnCallData.index,
@@ -38311,6 +38346,14 @@ data: ${JSON.stringify(data)}
38311
38346
  });
38312
38347
  }
38313
38348
  } else if (event.type === "response.output_item.done") {
38349
+ if (event.item?.type === "reasoning" && event.item.encrypted_content) {
38350
+ pendingReasoning.push({
38351
+ type: "reasoning",
38352
+ content: event.item.content ?? [],
38353
+ encrypted_content: event.item.encrypted_content,
38354
+ summary: event.item.summary ?? []
38355
+ });
38356
+ }
38314
38357
  if (event.item?.type === "function_call") {
38315
38358
  const callId = event.item.call_id || event.item.id;
38316
38359
  const fnCall = functionCalls.get(callId) || functionCalls.get(event.item.id);
@@ -38449,6 +38492,7 @@ data: ${JSON.stringify(data)}
38449
38492
  });
38450
38493
  }
38451
38494
  var init_openai_responses_sse = __esm(() => {
38495
+ init_reasoning_cache();
38452
38496
  init_logger();
38453
38497
  });
38454
38498
 
@@ -39446,15 +39490,15 @@ class OpenRouterCatalogResolver {
39446
39490
  _getEntries() {
39447
39491
  if (_memCache)
39448
39492
  return _memCache;
39449
- const cache = readAllModelsCache();
39450
- if (!cache)
39493
+ const cache2 = readAllModelsCache();
39494
+ if (!cache2)
39451
39495
  return null;
39452
- if (cache.entries.length > 0) {
39453
- _memCache = cache.entries;
39496
+ if (cache2.entries.length > 0) {
39497
+ _memCache = cache2.entries;
39454
39498
  return _memCache;
39455
39499
  }
39456
- if (cache.models.length > 0) {
39457
- _memCache = cache.models.map((m) => ({
39500
+ if (cache2.models.length > 0) {
39501
+ _memCache = cache2.models.map((m) => ({
39458
39502
  modelId: m.id.includes("/") ? m.id.split("/").slice(1).join("/") : m.id,
39459
39503
  aliases: [],
39460
39504
  sources: { "openrouter-api": { externalId: m.id } }
@@ -58397,8 +58441,8 @@ async function codexQuotaHandler() {
58397
58441
  try {
58398
58442
  const modelsPath = join22(homedir21(), ".codex", "models_cache.json");
58399
58443
  if (existsSync20(modelsPath)) {
58400
- const cache = JSON.parse(readFileSync18(modelsPath, "utf-8"));
58401
- modelSlugs = (cache.models || []).map((m) => m.slug || m.id).filter(Boolean);
58444
+ const cache2 = JSON.parse(readFileSync18(modelsPath, "utf-8"));
58445
+ modelSlugs = (cache2.models || []).map((m) => m.slug || m.id).filter(Boolean);
58402
58446
  }
58403
58447
  } catch {}
58404
58448
  const W = 58;
@@ -58636,13 +58680,13 @@ function slimEntryToCatalogModel(entry) {
58636
58680
  };
58637
58681
  }
58638
58682
  function readSlimCacheWithFreshness(reader) {
58639
- const cache = reader();
58640
- if (!cache)
58683
+ const cache2 = reader();
58684
+ if (!cache2)
58641
58685
  return { entries: [], stale: true };
58642
- const lastUpdatedMs = new Date(cache.lastUpdated).getTime();
58686
+ const lastUpdatedMs = new Date(cache2.lastUpdated).getTime();
58643
58687
  const ageMs = Date.now() - lastUpdatedMs;
58644
58688
  const stale = !Number.isFinite(lastUpdatedMs) || ageMs > FIREBASE_CACHE_TTL_MS;
58645
- return { entries: cache.entries ?? [], stale };
58689
+ return { entries: cache2.entries ?? [], stale };
58646
58690
  }
58647
58691
  function createCatalogClient(deps = {}) {
58648
58692
  const _getModelsByProvider = deps.getModelsByProvider ?? getModelsByProvider;
@@ -63916,8 +63960,8 @@ function writeCache(latestVersion) {
63916
63960
  writeFileSync15(cachePath, JSON.stringify(data), "utf-8");
63917
63961
  } catch {}
63918
63962
  }
63919
- function isCacheValid(cache) {
63920
- const age = Date.now() - cache.lastCheck;
63963
+ function isCacheValid(cache2) {
63964
+ const age = Date.now() - cache2.lastCheck;
63921
63965
  return age < CACHE_MAX_AGE_MS;
63922
63966
  }
63923
63967
  function clearCache() {
@@ -63981,9 +64025,9 @@ async function fetchLatestVersion(options = {}) {
63981
64025
  async function checkForUpdates(currentVersion, options = {}) {
63982
64026
  const { quiet = false } = options;
63983
64027
  let latestVersion = null;
63984
- const cache = readCache();
63985
- if (cache && isCacheValid(cache)) {
63986
- latestVersion = cache.latestVersion;
64028
+ const cache2 = readCache();
64029
+ if (cache2 && isCacheValid(cache2)) {
64030
+ latestVersion = cache2.latestVersion;
63987
64031
  } else {
63988
64032
  latestVersion = await fetchLatestVersion();
63989
64033
  writeCache(latestVersion);
@@ -64894,10 +64938,10 @@ async function forceRefreshProbeModels() {
64894
64938
  }
64895
64939
  }
64896
64940
  function getProbeModel(claudishSlug) {
64897
- const cache = readProbeModelsCache();
64898
- if (!cache)
64941
+ const cache2 = readProbeModelsCache();
64942
+ if (!cache2)
64899
64943
  return null;
64900
- const entry = cache.providers[claudishSlug];
64944
+ const entry = cache2.providers[claudishSlug];
64901
64945
  return typeof entry === "string" && entry.length > 0 ? entry : null;
64902
64946
  }
64903
64947
  async function discoverProbeModelFromEndpoint(proxyUrl, providerSlug, exclude) {
@@ -71763,12 +71807,12 @@ function shouldWarmCatalog(args) {
71763
71807
  }
71764
71808
  return true;
71765
71809
  }
71766
- function classifyCatalogState(cache, ttlHours, now) {
71767
- if (cache === null)
71810
+ function classifyCatalogState(cache2, ttlHours, now) {
71811
+ if (cache2 === null)
71768
71812
  return "missing";
71769
- if (cache.entries.length === 0 && cache.models.length === 0)
71813
+ if (cache2.entries.length === 0 && cache2.models.length === 0)
71770
71814
  return "missing";
71771
- const lastUpdatedMs = Date.parse(cache.lastUpdated);
71815
+ const lastUpdatedMs = Date.parse(cache2.lastUpdated);
71772
71816
  if (Number.isNaN(lastUpdatedMs))
71773
71817
  return "missing";
71774
71818
  const ageMs = now.getTime() - lastUpdatedMs;
@@ -71829,8 +71873,8 @@ async function warmCatalogIfNeeded(config3, opts) {
71829
71873
  const ttlHoursRaw = opts?.ttlHours ?? Number.parseFloat(process.env.CLAUDISH_CATALOG_TTL_HOURS ?? "24");
71830
71874
  const ttlHours = Number.isFinite(ttlHoursRaw) && ttlHoursRaw > 0 ? ttlHoursRaw : 24;
71831
71875
  const now = opts?.now ?? new Date;
71832
- const cache = readAllModelsCache();
71833
- const state = classifyCatalogState(cache, ttlHours, now);
71876
+ const cache2 = readAllModelsCache();
71877
+ const state = classifyCatalogState(cache2, ttlHours, now);
71834
71878
  if (state === "fresh" && !config3.forceUpdate) {
71835
71879
  return "ok";
71836
71880
  }
@@ -71857,14 +71901,14 @@ async function warmCatalogIfNeeded(config3, opts) {
71857
71901
  return "ok";
71858
71902
  }
71859
71903
  if (state === "stale") {
71860
- const ageMs = now.getTime() - Date.parse(cache.lastUpdated);
71904
+ const ageMs = now.getTime() - Date.parse(cache2.lastUpdated);
71861
71905
  const ageStr = humanizeAge(ageMs);
71862
71906
  process.stderr.write(`WARNING: Catalog stale (${ageStr}). Using cached version. Run \`claudish --models-refresh\` to retry.
71863
71907
  `);
71864
71908
  return "warned";
71865
71909
  }
71866
71910
  if (state === "fresh") {
71867
- const ageMs = now.getTime() - Date.parse(cache.lastUpdated);
71911
+ const ageMs = now.getTime() - Date.parse(cache2.lastUpdated);
71868
71912
  const ageStr = humanizeAge(ageMs);
71869
71913
  process.stderr.write(`WARNING: Catalog refresh failed (cache age ${ageStr}). Using cached version.
71870
71914
  `);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claudish",
3
- "version": "7.13.0",
3
+ "version": "7.14.0",
4
4
  "description": "Run Claude Code with any model - OpenRouter, Ollama, LM Studio & local models",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -60,10 +60,10 @@
60
60
  "ai"
61
61
  ],
62
62
  "optionalDependencies": {
63
- "@claudish/magmux-darwin-arm64": "7.13.0",
64
- "@claudish/magmux-darwin-x64": "7.13.0",
65
- "@claudish/magmux-linux-arm64": "7.13.0",
66
- "@claudish/magmux-linux-x64": "7.13.0"
63
+ "@claudish/magmux-darwin-arm64": "7.14.0",
64
+ "@claudish/magmux-darwin-x64": "7.14.0",
65
+ "@claudish/magmux-linux-arm64": "7.14.0",
66
+ "@claudish/magmux-linux-x64": "7.14.0"
67
67
  },
68
68
  "author": "Jack Rudenko <i@madappgang.com>",
69
69
  "license": "MIT",