claudish 7.17.0 → 7.17.1

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 +81 -5
  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.17.0";
584
+ var VERSION = "7.17.1";
585
585
 
586
586
  // src/logger.ts
587
587
  var exports_logger = {};
@@ -37625,6 +37625,61 @@ function ensureAnthropicErrorFormat(status, body) {
37625
37625
  return wrapAnthropicError(status, String(message), errorType);
37626
37626
  }
37627
37627
 
37628
+ // src/handlers/shared/connection-error.ts
37629
+ function findConnectionCode(error46) {
37630
+ let e = error46;
37631
+ const seen = new Set;
37632
+ for (let depth = 0;e && typeof e === "object" && depth < 8 && !seen.has(e); depth++) {
37633
+ seen.add(e);
37634
+ if (typeof e.code === "string" && e.code in CODE_KIND)
37635
+ return e.code;
37636
+ e = e.cause;
37637
+ }
37638
+ const msg = String(error46?.message ?? error46 ?? "");
37639
+ if (/getaddrinfo|ENOTFOUND|EAI_AGAIN|nodename nor servname/i.test(msg))
37640
+ return "ENOTFOUND";
37641
+ return null;
37642
+ }
37643
+ function classifyConnectionError(error46) {
37644
+ const code = findConnectionCode(error46);
37645
+ if (!code)
37646
+ return null;
37647
+ return { kind: CODE_KIND[code] ?? "unreachable", code };
37648
+ }
37649
+ function hostOf(endpoint) {
37650
+ try {
37651
+ return new URL(endpoint).host || endpoint;
37652
+ } catch {
37653
+ return endpoint;
37654
+ }
37655
+ }
37656
+ function buildConnectionErrorMessage(kind, displayName, endpoint) {
37657
+ const host = hostOf(endpoint);
37658
+ switch (kind) {
37659
+ case "dns":
37660
+ return `Cannot resolve ${host} for ${displayName}. This is a DNS/network problem on your machine \u2014 check your internet connection, VPN, or DNS resolver (e.g. Tailscale MagicDNS) \u2014 not ${displayName}.`;
37661
+ case "refused":
37662
+ return `Cannot connect to ${displayName} at ${endpoint}. Make sure the server is running.`;
37663
+ case "unreachable":
37664
+ return `Cannot reach ${displayName} at ${endpoint}. Check your network connection.`;
37665
+ }
37666
+ }
37667
+ var CODE_KIND;
37668
+ var init_connection_error = __esm(() => {
37669
+ CODE_KIND = {
37670
+ ENOTFOUND: "dns",
37671
+ EAI_AGAIN: "dns",
37672
+ ECONNREFUSED: "refused",
37673
+ ETIMEDOUT: "unreachable",
37674
+ ECONNRESET: "unreachable",
37675
+ ENETUNREACH: "unreachable",
37676
+ EHOSTUNREACH: "unreachable",
37677
+ EPIPE: "unreachable",
37678
+ UND_ERR_CONNECT_TIMEOUT: "unreachable",
37679
+ UND_ERR_SOCKET: "unreachable"
37680
+ };
37681
+ });
37682
+
37628
37683
  // src/handlers/shared/stream-parsers/anthropic-sse.ts
37629
37684
  function createAnthropicPassthroughStream(c, response, opts) {
37630
37685
  const encoder = new TextEncoder;
@@ -38960,10 +39015,11 @@ class ComposedHandler {
38960
39015
  try {
38961
39016
  response = this.provider.enqueueRequest ? await this.provider.enqueueRequest(doFetch) : await doFetch();
38962
39017
  } catch (error46) {
38963
- if (error46.code === "ECONNREFUSED" || error46.cause?.code === "ECONNREFUSED") {
38964
- const msg = `Cannot connect to ${this.provider.displayName} at ${endpoint}. Make sure the server is running.`;
38965
- log(`[${this.provider.displayName}] ${msg}`);
38966
- logStderr(`Error: ${msg} Check the server is running.`);
39018
+ const conn = classifyConnectionError(error46);
39019
+ if (conn) {
39020
+ const msg = buildConnectionErrorMessage(conn.kind, this.provider.displayName, endpoint);
39021
+ log(`[${this.provider.displayName}] ${msg} (code=${conn.code})`);
39022
+ logStderr(`Error: ${msg}`);
38967
39023
  reportError({
38968
39024
  error: error46,
38969
39025
  providerName: this.provider.name,
@@ -39332,6 +39388,7 @@ var init_composed_handler = __esm(() => {
39332
39388
  init_stats();
39333
39389
  init_telemetry();
39334
39390
  init_transform();
39391
+ init_connection_error();
39335
39392
  init_openai_compat();
39336
39393
  init_anthropic_sse();
39337
39394
  init_gemini_sse();
@@ -59875,8 +59932,27 @@ function extractUpstreamStatus(body) {
59875
59932
  return;
59876
59933
  }
59877
59934
  }
59935
+ function extractErrorType(body) {
59936
+ if (!body)
59937
+ return;
59938
+ try {
59939
+ const parsed = JSON.parse(body);
59940
+ const t = parsed?.error?.type;
59941
+ return typeof t === "string" ? t : undefined;
59942
+ } catch {
59943
+ return;
59944
+ }
59945
+ }
59878
59946
  function classifyHttpError(status, body, latencyMs) {
59879
59947
  const lowered = body.toLowerCase();
59948
+ if (extractErrorType(body) === "connection_error") {
59949
+ return {
59950
+ state: "network-error",
59951
+ latencyMs,
59952
+ httpStatus: status,
59953
+ errorMessage: extractErrorMessage(body) || "Cannot reach provider"
59954
+ };
59955
+ }
59880
59956
  const upstream = status === 400 ? extractUpstreamStatus(body) : undefined;
59881
59957
  if (status === 401 || status === 403 || upstream === 401 || upstream === 403) {
59882
59958
  const authStatus = upstream ?? status;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claudish",
3
- "version": "7.17.0",
3
+ "version": "7.17.1",
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.17.0",
64
- "@claudish/magmux-darwin-x64": "7.17.0",
65
- "@claudish/magmux-linux-arm64": "7.17.0",
66
- "@claudish/magmux-linux-x64": "7.17.0"
63
+ "@claudish/magmux-darwin-arm64": "7.17.1",
64
+ "@claudish/magmux-darwin-x64": "7.17.1",
65
+ "@claudish/magmux-linux-arm64": "7.17.1",
66
+ "@claudish/magmux-linux-x64": "7.17.1"
67
67
  },
68
68
  "author": "Jack Rudenko <i@madappgang.com>",
69
69
  "license": "MIT",