@great-arrow/cli 0.1.68 → 0.6.5

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 +62 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -9373,6 +9373,52 @@ function classifyRequestFailure(error62) {
9373
9373
  }
9374
9374
  return { kind, message, hint: FAILURE_HINTS[kind] };
9375
9375
  }
9376
+ var DEFAULT_ORIGIN = "https://www.greatarrow.ai";
9377
+ var LEVEL_WORDS = {
9378
+ passkey: "a passkey",
9379
+ verified: "a verified identity"
9380
+ };
9381
+ function actionLink(url2, apiUrl) {
9382
+ try {
9383
+ return new URL(url2, apiUrl || DEFAULT_ORIGIN).toString();
9384
+ } catch {
9385
+ return url2;
9386
+ }
9387
+ }
9388
+ function policyRefusal(body, apiUrl) {
9389
+ let record2 = body;
9390
+ if (typeof body === "string") {
9391
+ try {
9392
+ record2 = JSON.parse(body);
9393
+ } catch {
9394
+ return null;
9395
+ }
9396
+ }
9397
+ if (typeof record2 !== "object" || record2 === null) return null;
9398
+ let r = record2;
9399
+ if (typeof r.error === "object" && r.error !== null) {
9400
+ const data = r.error.data;
9401
+ if (typeof data !== "object" || data === null) return null;
9402
+ r = data;
9403
+ }
9404
+ const url2 = typeof r.actionUrl === "string" && r.actionUrl ? actionLink(r.actionUrl, apiUrl) : null;
9405
+ if (r.error === "identity_assurance_required") {
9406
+ const need = LEVEL_WORDS[typeof r.required === "string" ? r.required : ""] ?? "a stronger sign-in";
9407
+ return {
9408
+ code: r.error,
9409
+ message: `This workspace requires ${need} on your account.`,
9410
+ hint: url2 ? `Open ${url2} to add it, then try again.` : "Add it under Account \u2192 Security, then try again."
9411
+ };
9412
+ }
9413
+ if (r.error === "owner_approval_required") {
9414
+ return {
9415
+ code: r.error,
9416
+ message: typeof r.message === "string" && r.message ? r.message : "Only the workspace owner can do this.",
9417
+ hint: url2 ? `Open ${url2} to continue.` : "Ask the workspace owner to do it, or to change it on the Access page."
9418
+ };
9419
+ }
9420
+ return null;
9421
+ }
9376
9422
  var SERVER_CODE = /^[a-z][a-z0-9_]{0,63}$/;
9377
9423
  function withServerCode(error62, body) {
9378
9424
  try {
@@ -9437,7 +9483,7 @@ function isNodeError(value) {
9437
9483
 
9438
9484
  // src/lib/version.ts
9439
9485
  var CLI_PACKAGE_NAME = "@great-arrow/cli";
9440
- var CLI_VERSION = "0.1.68";
9486
+ var CLI_VERSION = "0.6.5";
9441
9487
  var GAD_INSTALL_VERSION = "2026.08.08";
9442
9488
  var GAD_INSTALL_MIN_VERSION = "2026.06.22";
9443
9489
  var GAD_INSTALL_HEADER = "X-GAD-Install-Version";
@@ -11056,6 +11102,8 @@ var ERROR_ENVELOPE_KEYS = /* @__PURE__ */ new Set([
11056
11102
  "details",
11057
11103
  "error_description",
11058
11104
  "reauth_url",
11105
+ "actionUrl",
11106
+ "achieved",
11059
11107
  "required",
11060
11108
  "ok",
11061
11109
  "success",
@@ -11073,6 +11121,8 @@ function cleanErrorText(text3) {
11073
11121
  }
11074
11122
  function hintFrom(record2) {
11075
11123
  if (nonEmpty(record2.hint)) return record2.hint;
11124
+ if (nonEmpty(record2.actionUrl))
11125
+ return `Open ${actionLink(record2.actionUrl, process.env.GAD_API_URL)} to continue.`;
11076
11126
  if (nonEmpty(record2.reauth_url))
11077
11127
  return `Re-authorize this connection: ${record2.reauth_url}`;
11078
11128
  return void 0;
@@ -11700,6 +11750,13 @@ var GadClient = class {
11700
11750
  const status = response.status;
11701
11751
  const body = await response.text().catch(() => "");
11702
11752
  if (status === 403) {
11753
+ const refusal2 = policyRefusal(body, this.apiUrl);
11754
+ if (refusal2) {
11755
+ throw withServerCode(
11756
+ new CliError(refusal2.message, 1 /* AUTH_ERROR */, refusal2.hint),
11757
+ JSON.stringify({ error: refusal2.code })
11758
+ );
11759
+ }
11703
11760
  throw withServerCode(
11704
11761
  new CliError(
11705
11762
  "Permission denied (HTTP 403).",
@@ -11792,6 +11849,10 @@ var GadClient = class {
11792
11849
  message: data.error.message
11793
11850
  }
11794
11851
  });
11852
+ const refusal2 = policyRefusal(data, this.apiUrl);
11853
+ if (refusal2) {
11854
+ throw new CliError(refusal2.message, 1 /* AUTH_ERROR */, refusal2.hint);
11855
+ }
11795
11856
  const code = data.error.code === -32001 ? 1 /* AUTH_ERROR */ : 2 /* NETWORK_ERROR */;
11796
11857
  throw new CliError(
11797
11858
  data.error.message,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@great-arrow/cli",
3
- "version": "0.1.68",
3
+ "version": "0.6.5",
4
4
  "description": "GreatArrow.ai CLI tool",
5
5
  "type": "module",
6
6
  "bin": {