cascade-ai 0.48.0 → 0.48.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.
@@ -222595,7 +222595,7 @@ Anthropic.Models = Models2;
222595
222595
  Anthropic.Beta = Beta;
222596
222596
 
222597
222597
  // src/constants.ts
222598
- var CASCADE_VERSION = "0.48.0";
222598
+ var CASCADE_VERSION = "0.48.1";
222599
222599
  var CASCADE_CONFIG_DIR = ".cascade";
222600
222600
  var CASCADE_MD_FILE = "CASCADE.md";
222601
222601
  var CASCADE_IGNORE_FILE = ".cascadeignore";
@@ -305333,12 +305333,19 @@ var CloudClient = class _CloudClient {
305333
305333
  );
305334
305334
  await openUrl(authorizeUrl);
305335
305335
  const code = await listener.waitForCode;
305336
- const res = await fetch(this.url("/api/native/token"), {
305337
- method: "POST",
305338
- headers: { "Content-Type": "application/json" },
305339
- body: JSON.stringify({ code, code_verifier: verifier })
305340
- });
305341
- if (!res.ok) throw new Error("Sign-in could not be completed. Please try again.");
305336
+ let res;
305337
+ try {
305338
+ res = await fetch(this.url("/api/native/token"), {
305339
+ method: "POST",
305340
+ headers: { "Content-Type": "application/json" },
305341
+ body: JSON.stringify({ code, code_verifier: verifier })
305342
+ });
305343
+ } catch (err) {
305344
+ throw new Error(
305345
+ `Signed in, but could not reach Cascade at ${this.serverUrl} to finish. Check your connection and that the server URL is correct. (${err instanceof Error ? err.message : String(err)})`
305346
+ );
305347
+ }
305348
+ if (!res.ok) throw new Error(await loginFailureMessage(res, this.serverUrl));
305342
305349
  const tokens = await res.json();
305343
305350
  return await this.finishLogin(tokens);
305344
305351
  } finally {
@@ -305512,6 +305519,22 @@ function sleep4(ms2, signal) {
305512
305519
  }, { once: true });
305513
305520
  });
305514
305521
  }
305522
+ async function loginFailureMessage(res, serverUrl) {
305523
+ const body = await res.text().catch(() => "");
305524
+ let apiError = "";
305525
+ try {
305526
+ apiError = String(JSON.parse(body).error ?? "");
305527
+ } catch {
305528
+ }
305529
+ if (apiError === "invalid_grant") {
305530
+ return "Sign-in expired before it completed \u2014 the code is single-use and short-lived, and restarting the server during sign-in also invalidates it. Please try again.";
305531
+ }
305532
+ if (apiError) return `Sign-in failed: ${apiError} (HTTP ${res.status}).`;
305533
+ if (res.status === 404 || /<html/i.test(body)) {
305534
+ return `Signed in, but ${serverUrl} did not answer the Cascade API (HTTP ${res.status}). If this host was recently pointed at a new server, DNS may still be propagating.`;
305535
+ }
305536
+ return `Sign-in could not be completed (HTTP ${res.status}). Please try again.`;
305537
+ }
305515
305538
  function base64url2(buf) {
305516
305539
  return buf.toString("base64").replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
305517
305540
  }
package/dist/index.cjs CHANGED
@@ -239,7 +239,7 @@ var init_audit_logger = __esm({
239
239
  });
240
240
 
241
241
  // src/constants.ts
242
- var CASCADE_VERSION = "0.48.0";
242
+ var CASCADE_VERSION = "0.48.1";
243
243
  var CASCADE_CONFIG_DIR = ".cascade";
244
244
  var CASCADE_MD_FILE = "CASCADE.md";
245
245
  var CASCADE_IGNORE_FILE = ".cascadeignore";
@@ -15984,12 +15984,19 @@ var CloudClient = class _CloudClient {
15984
15984
  );
15985
15985
  await openUrl(authorizeUrl);
15986
15986
  const code = await listener.waitForCode;
15987
- const res = await fetch(this.url("/api/native/token"), {
15988
- method: "POST",
15989
- headers: { "Content-Type": "application/json" },
15990
- body: JSON.stringify({ code, code_verifier: verifier })
15991
- });
15992
- if (!res.ok) throw new Error("Sign-in could not be completed. Please try again.");
15987
+ let res;
15988
+ try {
15989
+ res = await fetch(this.url("/api/native/token"), {
15990
+ method: "POST",
15991
+ headers: { "Content-Type": "application/json" },
15992
+ body: JSON.stringify({ code, code_verifier: verifier })
15993
+ });
15994
+ } catch (err) {
15995
+ throw new Error(
15996
+ `Signed in, but could not reach Cascade at ${this.serverUrl} to finish. Check your connection and that the server URL is correct. (${err instanceof Error ? err.message : String(err)})`
15997
+ );
15998
+ }
15999
+ if (!res.ok) throw new Error(await loginFailureMessage(res, this.serverUrl));
15993
16000
  const tokens = await res.json();
15994
16001
  return await this.finishLogin(tokens);
15995
16002
  } finally {
@@ -16163,6 +16170,22 @@ function sleep(ms, signal) {
16163
16170
  }, { once: true });
16164
16171
  });
16165
16172
  }
16173
+ async function loginFailureMessage(res, serverUrl) {
16174
+ const body = await res.text().catch(() => "");
16175
+ let apiError = "";
16176
+ try {
16177
+ apiError = String(JSON.parse(body).error ?? "");
16178
+ } catch {
16179
+ }
16180
+ if (apiError === "invalid_grant") {
16181
+ return "Sign-in expired before it completed \u2014 the code is single-use and short-lived, and restarting the server during sign-in also invalidates it. Please try again.";
16182
+ }
16183
+ if (apiError) return `Sign-in failed: ${apiError} (HTTP ${res.status}).`;
16184
+ if (res.status === 404 || /<html/i.test(body)) {
16185
+ return `Signed in, but ${serverUrl} did not answer the Cascade API (HTTP ${res.status}). If this host was recently pointed at a new server, DNS may still be propagating.`;
16186
+ }
16187
+ return `Sign-in could not be completed (HTTP ${res.status}). Please try again.`;
16188
+ }
16166
16189
  function base64url(buf) {
16167
16190
  return buf.toString("base64").replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
16168
16191
  }