claudish 7.13.0 → 7.15.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 +98 -33
  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.15.0";
585
585
 
586
586
  // src/logger.ts
587
587
  var exports_logger = {};
@@ -27508,6 +27508,9 @@ function loadConfig() {
27508
27508
  if (config2.defaultProvider !== undefined) {
27509
27509
  merged.defaultProvider = config2.defaultProvider;
27510
27510
  }
27511
+ if (config2.debug !== undefined) {
27512
+ merged.debug = config2.debug;
27513
+ }
27511
27514
  if (config2.customEndpoints !== undefined) {
27512
27515
  merged.customEndpoints = config2.customEndpoints;
27513
27516
  }
@@ -31354,6 +31357,28 @@ var init_base_api_format = __esm(() => {
31354
31357
  };
31355
31358
  });
31356
31359
 
31360
+ // src/adapters/reasoning-cache.ts
31361
+ function rememberReasoningForCall(callId, items) {
31362
+ if (!callId || items.length === 0)
31363
+ return;
31364
+ if (cache.has(callId))
31365
+ cache.delete(callId);
31366
+ cache.set(callId, items);
31367
+ while (cache.size > MAX_ENTRIES) {
31368
+ const oldest = cache.keys().next().value;
31369
+ if (oldest === undefined)
31370
+ break;
31371
+ cache.delete(oldest);
31372
+ }
31373
+ }
31374
+ function reasoningForCall(callId) {
31375
+ return cache.get(callId);
31376
+ }
31377
+ var MAX_ENTRIES = 500, cache;
31378
+ var init_reasoning_cache = __esm(() => {
31379
+ cache = new Map;
31380
+ });
31381
+
31357
31382
  // src/adapters/codex-api-format.ts
31358
31383
  function normalizeCodexModel(modelId) {
31359
31384
  if (!modelId)
@@ -31365,6 +31390,7 @@ var CodexAPIFormat;
31365
31390
  var init_codex_api_format = __esm(() => {
31366
31391
  init_logger();
31367
31392
  init_base_api_format();
31393
+ init_reasoning_cache();
31368
31394
  CodexAPIFormat = class CodexAPIFormat extends BaseAPIFormat {
31369
31395
  processTextContent(textContent, _accumulatedText) {
31370
31396
  return {
@@ -31387,6 +31413,10 @@ var init_codex_api_format = __esm(() => {
31387
31413
  }
31388
31414
  buildPayload(claudeRequest, messages, tools) {
31389
31415
  const convertedMessages = this.convertMessagesToResponsesAPI(messages);
31416
+ const replayedReasoning = convertedMessages.filter((i) => i.type === "reasoning").length;
31417
+ if (replayedReasoning > 0) {
31418
+ log(`[CodexAPIFormat] replaying ${replayedReasoning} cached reasoning item(s)`);
31419
+ }
31390
31420
  const normalizedModel = normalizeCodexModel(this.modelId);
31391
31421
  const strippedMessages = convertedMessages.map((item) => {
31392
31422
  const { id, ...rest } = item;
@@ -31491,6 +31521,9 @@ var init_codex_api_format = __esm(() => {
31491
31521
  }
31492
31522
  for (const toolCall of msg.tool_calls) {
31493
31523
  if (toolCall.type === "function") {
31524
+ const reasoning = reasoningForCall(toolCall.id);
31525
+ if (reasoning?.length)
31526
+ result.push(...reasoning);
31494
31527
  result.push({
31495
31528
  type: "function_call",
31496
31529
  call_id: toolCall.id,
@@ -36157,10 +36190,10 @@ function getCachedEntries() {
36157
36190
  if (mtimeMs === _memoMtimeMs && _memoEntries !== null) {
36158
36191
  return _memoEntries;
36159
36192
  }
36160
- const cache = readAllModelsCache();
36161
- if (!cache)
36193
+ const cache2 = readAllModelsCache();
36194
+ if (!cache2)
36162
36195
  return null;
36163
- _memoEntries = cache.entries;
36196
+ _memoEntries = cache2.entries;
36164
36197
  _memoMtimeMs = mtimeMs;
36165
36198
  return _memoEntries;
36166
36199
  }
@@ -38150,6 +38183,7 @@ function createResponsesStreamHandler(c, response, opts) {
38150
38183
  let reasoningIdx = -1;
38151
38184
  let lastSummaryIndex = -1;
38152
38185
  let incompleteReason = null;
38186
+ let pendingReasoning = [];
38153
38187
  let inputTokens = 0;
38154
38188
  let outputTokens = 0;
38155
38189
  let hasToolUse = false;
@@ -38266,6 +38300,10 @@ data: ${JSON.stringify(data)}
38266
38300
  functionCalls.set(itemId, fnCallData);
38267
38301
  }
38268
38302
  openToolBlocks.add(fnCallData);
38303
+ if (pendingReasoning.length > 0) {
38304
+ rememberReasoningForCall(callId, pendingReasoning);
38305
+ pendingReasoning = [];
38306
+ }
38269
38307
  send("content_block_start", {
38270
38308
  type: "content_block_start",
38271
38309
  index: fnCallData.index,
@@ -38311,6 +38349,14 @@ data: ${JSON.stringify(data)}
38311
38349
  });
38312
38350
  }
38313
38351
  } else if (event.type === "response.output_item.done") {
38352
+ if (event.item?.type === "reasoning" && event.item.encrypted_content) {
38353
+ pendingReasoning.push({
38354
+ type: "reasoning",
38355
+ content: event.item.content ?? [],
38356
+ encrypted_content: event.item.encrypted_content,
38357
+ summary: event.item.summary ?? []
38358
+ });
38359
+ }
38314
38360
  if (event.item?.type === "function_call") {
38315
38361
  const callId = event.item.call_id || event.item.id;
38316
38362
  const fnCall = functionCalls.get(callId) || functionCalls.get(event.item.id);
@@ -38449,6 +38495,7 @@ data: ${JSON.stringify(data)}
38449
38495
  });
38450
38496
  }
38451
38497
  var init_openai_responses_sse = __esm(() => {
38498
+ init_reasoning_cache();
38452
38499
  init_logger();
38453
38500
  });
38454
38501
 
@@ -39446,15 +39493,15 @@ class OpenRouterCatalogResolver {
39446
39493
  _getEntries() {
39447
39494
  if (_memCache)
39448
39495
  return _memCache;
39449
- const cache = readAllModelsCache();
39450
- if (!cache)
39496
+ const cache2 = readAllModelsCache();
39497
+ if (!cache2)
39451
39498
  return null;
39452
- if (cache.entries.length > 0) {
39453
- _memCache = cache.entries;
39499
+ if (cache2.entries.length > 0) {
39500
+ _memCache = cache2.entries;
39454
39501
  return _memCache;
39455
39502
  }
39456
- if (cache.models.length > 0) {
39457
- _memCache = cache.models.map((m) => ({
39503
+ if (cache2.models.length > 0) {
39504
+ _memCache = cache2.models.map((m) => ({
39458
39505
  modelId: m.id.includes("/") ? m.id.split("/").slice(1).join("/") : m.id,
39459
39506
  aliases: [],
39460
39507
  sources: { "openrouter-api": { externalId: m.id } }
@@ -58397,8 +58444,8 @@ async function codexQuotaHandler() {
58397
58444
  try {
58398
58445
  const modelsPath = join22(homedir21(), ".codex", "models_cache.json");
58399
58446
  if (existsSync20(modelsPath)) {
58400
- const cache = JSON.parse(readFileSync18(modelsPath, "utf-8"));
58401
- modelSlugs = (cache.models || []).map((m) => m.slug || m.id).filter(Boolean);
58447
+ const cache2 = JSON.parse(readFileSync18(modelsPath, "utf-8"));
58448
+ modelSlugs = (cache2.models || []).map((m) => m.slug || m.id).filter(Boolean);
58402
58449
  }
58403
58450
  } catch {}
58404
58451
  const W = 58;
@@ -58556,7 +58603,8 @@ var init_config = __esm(() => {
58556
58603
  OPENAI_API_KEY: "OPENAI_API_KEY",
58557
58604
  OPENAI_BASE_URL: "OPENAI_BASE_URL",
58558
58605
  CLAUDISH_SUMMARIZE_TOOLS: "CLAUDISH_SUMMARIZE_TOOLS",
58559
- CLAUDISH_DIAG_MODE: "CLAUDISH_DIAG_MODE"
58606
+ CLAUDISH_DIAG_MODE: "CLAUDISH_DIAG_MODE",
58607
+ CLAUDISH_DEBUG: "CLAUDISH_DEBUG"
58560
58608
  };
58561
58609
  OPENROUTER_HEADERS = {
58562
58610
  "HTTP-Referer": "https://claudish.com",
@@ -58636,13 +58684,13 @@ function slimEntryToCatalogModel(entry) {
58636
58684
  };
58637
58685
  }
58638
58686
  function readSlimCacheWithFreshness(reader) {
58639
- const cache = reader();
58640
- if (!cache)
58687
+ const cache2 = reader();
58688
+ if (!cache2)
58641
58689
  return { entries: [], stale: true };
58642
- const lastUpdatedMs = new Date(cache.lastUpdated).getTime();
58690
+ const lastUpdatedMs = new Date(cache2.lastUpdated).getTime();
58643
58691
  const ageMs = Date.now() - lastUpdatedMs;
58644
58692
  const stale = !Number.isFinite(lastUpdatedMs) || ageMs > FIREBASE_CACHE_TTL_MS;
58645
- return { entries: cache.entries ?? [], stale };
58693
+ return { entries: cache2.entries ?? [], stale };
58646
58694
  }
58647
58695
  function createCatalogClient(deps = {}) {
58648
58696
  const _getModelsByProvider = deps.getModelsByProvider ?? getModelsByProvider;
@@ -62372,11 +62420,23 @@ async function parseArgs(args) {
62372
62420
  if (fileConfig.diagMode && ["auto", "logfile", "off"].includes(fileConfig.diagMode)) {
62373
62421
  config3.diagMode = fileConfig.diagMode;
62374
62422
  }
62423
+ if (fileConfig.debug === true) {
62424
+ config3.debug = true;
62425
+ }
62375
62426
  } catch {}
62376
62427
  const envDiagMode = process.env[ENV.CLAUDISH_DIAG_MODE]?.toLowerCase();
62377
62428
  if (envDiagMode && ["auto", "logfile", "off"].includes(envDiagMode)) {
62378
62429
  config3.diagMode = envDiagMode;
62379
62430
  }
62431
+ const envDebug = process.env[ENV.CLAUDISH_DEBUG]?.toLowerCase();
62432
+ if (envDebug === "1" || envDebug === "true") {
62433
+ config3.debug = true;
62434
+ } else if (envDebug === "0" || envDebug === "false") {
62435
+ config3.debug = false;
62436
+ }
62437
+ if (config3.debug && config3.logLevel === "info") {
62438
+ config3.logLevel = "debug";
62439
+ }
62380
62440
  let i = 0;
62381
62441
  while (i < args.length) {
62382
62442
  const arg = args[i];
@@ -62429,6 +62489,8 @@ async function parseArgs(args) {
62429
62489
  if (config3.logLevel === "info") {
62430
62490
  config3.logLevel = "debug";
62431
62491
  }
62492
+ } else if (arg === "--no-debug-claudish") {
62493
+ config3.debug = false;
62432
62494
  } else if (arg === "--log-debug") {
62433
62495
  console.error("--log-debug was renamed to --debug-claudish (it enables claudish's own debug log, not Claude Code's --debug).");
62434
62496
  process.exit(1);
@@ -63534,6 +63596,8 @@ ${h("OPTIONS")}
63534
63596
  ${green("--op-env")} ${yellow("<id>")} Load env vars from a 1Password Environment (highest priority)
63535
63597
  ${green("--port")} ${yellow("<port>")} Proxy server port (default: random)
63536
63598
  ${green("-d, --debug-claudish")} Enable claudish debug logging to file (logs/claudish_*.log)
63599
+ ${dim('Always-on: CLAUDISH_DEBUG=1 env var or "debug": true in config.json')}
63600
+ ${green("--no-debug-claudish")} Force debug logging off for this run (when globally enabled)
63537
63601
  ${green("--log-off")} Disable always-on structural logging (~/.claudish/logs/)
63538
63602
  ${green("--log-diag")} ${yellow("<mode>")} Diagnostic output: auto (default), logfile, off
63539
63603
  ${dim('Also: CLAUDISH_DIAG_MODE env var or "diagMode" in config.json')}
@@ -63697,6 +63761,7 @@ ${h("ENVIRONMENT VARIABLES")}
63697
63761
  ${blue("CLAUDISH_PORT")} Default proxy port
63698
63762
  ${blue("CLAUDISH_CONTEXT_WINDOW")} Override context window size
63699
63763
  ${blue("CLAUDISH_DIAG_MODE")} Diagnostic output: auto / logfile / off
63764
+ ${blue("CLAUDISH_DEBUG")} Always enable debug logging: 1 / true ${dim("(same as -d)")}
63700
63765
  ${blue("CLAUDISH_MCP_TOOLS")} MCP tool gating: all / low-level / agentic / channel
63701
63766
  ${blue("CLAUDISH_MODEL_OPUS")} Override model for Opus role
63702
63767
  ${blue("CLAUDISH_MODEL_SONNET")} Override model for Sonnet role
@@ -63916,8 +63981,8 @@ function writeCache(latestVersion) {
63916
63981
  writeFileSync15(cachePath, JSON.stringify(data), "utf-8");
63917
63982
  } catch {}
63918
63983
  }
63919
- function isCacheValid(cache) {
63920
- const age = Date.now() - cache.lastCheck;
63984
+ function isCacheValid(cache2) {
63985
+ const age = Date.now() - cache2.lastCheck;
63921
63986
  return age < CACHE_MAX_AGE_MS;
63922
63987
  }
63923
63988
  function clearCache() {
@@ -63981,9 +64046,9 @@ async function fetchLatestVersion(options = {}) {
63981
64046
  async function checkForUpdates(currentVersion, options = {}) {
63982
64047
  const { quiet = false } = options;
63983
64048
  let latestVersion = null;
63984
- const cache = readCache();
63985
- if (cache && isCacheValid(cache)) {
63986
- latestVersion = cache.latestVersion;
64049
+ const cache2 = readCache();
64050
+ if (cache2 && isCacheValid(cache2)) {
64051
+ latestVersion = cache2.latestVersion;
63987
64052
  } else {
63988
64053
  latestVersion = await fetchLatestVersion();
63989
64054
  writeCache(latestVersion);
@@ -64894,10 +64959,10 @@ async function forceRefreshProbeModels() {
64894
64959
  }
64895
64960
  }
64896
64961
  function getProbeModel(claudishSlug) {
64897
- const cache = readProbeModelsCache();
64898
- if (!cache)
64962
+ const cache2 = readProbeModelsCache();
64963
+ if (!cache2)
64899
64964
  return null;
64900
- const entry = cache.providers[claudishSlug];
64965
+ const entry = cache2.providers[claudishSlug];
64901
64966
  return typeof entry === "string" && entry.length > 0 ? entry : null;
64902
64967
  }
64903
64968
  async function discoverProbeModelFromEndpoint(proxyUrl, providerSlug, exclude) {
@@ -71763,12 +71828,12 @@ function shouldWarmCatalog(args) {
71763
71828
  }
71764
71829
  return true;
71765
71830
  }
71766
- function classifyCatalogState(cache, ttlHours, now) {
71767
- if (cache === null)
71831
+ function classifyCatalogState(cache2, ttlHours, now) {
71832
+ if (cache2 === null)
71768
71833
  return "missing";
71769
- if (cache.entries.length === 0 && cache.models.length === 0)
71834
+ if (cache2.entries.length === 0 && cache2.models.length === 0)
71770
71835
  return "missing";
71771
- const lastUpdatedMs = Date.parse(cache.lastUpdated);
71836
+ const lastUpdatedMs = Date.parse(cache2.lastUpdated);
71772
71837
  if (Number.isNaN(lastUpdatedMs))
71773
71838
  return "missing";
71774
71839
  const ageMs = now.getTime() - lastUpdatedMs;
@@ -71829,8 +71894,8 @@ async function warmCatalogIfNeeded(config3, opts) {
71829
71894
  const ttlHoursRaw = opts?.ttlHours ?? Number.parseFloat(process.env.CLAUDISH_CATALOG_TTL_HOURS ?? "24");
71830
71895
  const ttlHours = Number.isFinite(ttlHoursRaw) && ttlHoursRaw > 0 ? ttlHoursRaw : 24;
71831
71896
  const now = opts?.now ?? new Date;
71832
- const cache = readAllModelsCache();
71833
- const state = classifyCatalogState(cache, ttlHours, now);
71897
+ const cache2 = readAllModelsCache();
71898
+ const state = classifyCatalogState(cache2, ttlHours, now);
71834
71899
  if (state === "fresh" && !config3.forceUpdate) {
71835
71900
  return "ok";
71836
71901
  }
@@ -71857,14 +71922,14 @@ async function warmCatalogIfNeeded(config3, opts) {
71857
71922
  return "ok";
71858
71923
  }
71859
71924
  if (state === "stale") {
71860
- const ageMs = now.getTime() - Date.parse(cache.lastUpdated);
71925
+ const ageMs = now.getTime() - Date.parse(cache2.lastUpdated);
71861
71926
  const ageStr = humanizeAge(ageMs);
71862
71927
  process.stderr.write(`WARNING: Catalog stale (${ageStr}). Using cached version. Run \`claudish --models-refresh\` to retry.
71863
71928
  `);
71864
71929
  return "warned";
71865
71930
  }
71866
71931
  if (state === "fresh") {
71867
- const ageMs = now.getTime() - Date.parse(cache.lastUpdated);
71932
+ const ageMs = now.getTime() - Date.parse(cache2.lastUpdated);
71868
71933
  const ageStr = humanizeAge(ageMs);
71869
71934
  process.stderr.write(`WARNING: Catalog refresh failed (cache age ${ageStr}). Using cached version.
71870
71935
  `);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claudish",
3
- "version": "7.13.0",
3
+ "version": "7.15.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.15.0",
64
+ "@claudish/magmux-darwin-x64": "7.15.0",
65
+ "@claudish/magmux-linux-arm64": "7.15.0",
66
+ "@claudish/magmux-linux-x64": "7.15.0"
67
67
  },
68
68
  "author": "Jack Rudenko <i@madappgang.com>",
69
69
  "license": "MIT",