@wayai/cli 0.3.58 → 0.3.59

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.
package/dist/index.js CHANGED
@@ -43,6 +43,37 @@ var init_redact = __esm({
43
43
  }
44
44
  });
45
45
 
46
+ // src/lib/network-error.ts
47
+ function errorCode(value) {
48
+ if (value && typeof value === "object" && "code" in value) {
49
+ const code = value.code;
50
+ if (typeof code === "string") return code;
51
+ }
52
+ return void 0;
53
+ }
54
+ function isNetworkError(err) {
55
+ if (err instanceof TypeError && err.message === "fetch failed") return true;
56
+ if (!err || typeof err !== "object") return false;
57
+ const code = errorCode(err) ?? errorCode(err.cause);
58
+ return code !== void 0 && NETWORK_ERROR_CODES.has(code);
59
+ }
60
+ var NETWORK_ERROR_CODES;
61
+ var init_network_error = __esm({
62
+ "src/lib/network-error.ts"() {
63
+ "use strict";
64
+ NETWORK_ERROR_CODES = /* @__PURE__ */ new Set([
65
+ "ECONNREFUSED",
66
+ "ENOTFOUND",
67
+ "ETIMEDOUT",
68
+ "ECONNRESET",
69
+ "EAI_AGAIN",
70
+ "ECONNABORTED",
71
+ "EHOSTUNREACH",
72
+ "ENETUNREACH"
73
+ ]);
74
+ }
75
+ });
76
+
46
77
  // src/lib/sentry.ts
47
78
  import * as Sentry from "@sentry/node";
48
79
  import { readFileSync } from "fs";
@@ -111,6 +142,7 @@ function initSentry(command2) {
111
142
  initialized = true;
112
143
  }
113
144
  function shouldReportToSentry(error) {
145
+ if (isNetworkError(error)) return false;
114
146
  if (error instanceof Error) {
115
147
  const e = error;
116
148
  if (e.isExpected === true || e.isRetryable === true) return false;
@@ -168,6 +200,7 @@ var init_sentry = __esm({
168
200
  "src/lib/sentry.ts"() {
169
201
  "use strict";
170
202
  init_redact();
203
+ init_network_error();
171
204
  HARDCODED_DSN = "https://ffe500121277babcabf32e5868f00f9e@o4510669417807872.ingest.us.sentry.io/4510960145465344";
172
205
  initialized = false;
173
206
  }
@@ -18315,7 +18348,11 @@ import { dirname as dirname9, join as join24 } from "path";
18315
18348
 
18316
18349
  // src/lib/errors.ts
18317
18350
  init_api_client();
18351
+ init_network_error();
18318
18352
  function friendlyHint(err) {
18353
+ if (isNetworkError(err)) {
18354
+ return "Couldn't reach WayAI \u2014 check your network connection and try again.";
18355
+ }
18319
18356
  if (!(err instanceof ApiError)) return null;
18320
18357
  const { status } = err;
18321
18358
  if (status === 401) return "Your session may have expired. Run `wayai login` to re-authenticate.";