@google/gemini-cli-a2a-server 0.31.0-preview.1 → 0.31.0-preview.3

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.
@@ -105516,6 +105516,150 @@ var init_open = __esm({
105516
105516
  }
105517
105517
  });
105518
105518
 
105519
+ // packages/core/dist/src/utils/googleErrors.js
105520
+ function parseGoogleApiError(error2) {
105521
+ if (!error2) {
105522
+ return null;
105523
+ }
105524
+ let errorObj = error2;
105525
+ if (typeof errorObj === "string") {
105526
+ try {
105527
+ errorObj = JSON.parse(errorObj);
105528
+ } catch (_) {
105529
+ return null;
105530
+ }
105531
+ }
105532
+ if (Array.isArray(errorObj) && errorObj.length > 0) {
105533
+ errorObj = errorObj[0];
105534
+ }
105535
+ if (typeof errorObj !== "object" || errorObj === null) {
105536
+ return null;
105537
+ }
105538
+ let currentError = fromGaxiosError(errorObj) ?? fromApiError(errorObj);
105539
+ let depth = 0;
105540
+ const maxDepth = 10;
105541
+ while (currentError && typeof currentError.message === "string" && depth < maxDepth) {
105542
+ try {
105543
+ const parsedMessage = JSON.parse(currentError.message.replace(/\u00A0/g, "").replace(/\n/g, " "));
105544
+ if (parsedMessage.error) {
105545
+ currentError = parsedMessage.error;
105546
+ depth++;
105547
+ } else {
105548
+ break;
105549
+ }
105550
+ } catch (_error) {
105551
+ break;
105552
+ }
105553
+ }
105554
+ if (!currentError) {
105555
+ return null;
105556
+ }
105557
+ const code2 = currentError.code;
105558
+ const message = currentError.message;
105559
+ const errorDetails = currentError.details;
105560
+ if (code2 && message) {
105561
+ const details = [];
105562
+ if (Array.isArray(errorDetails)) {
105563
+ for (const detail of errorDetails) {
105564
+ if (detail && typeof detail === "object") {
105565
+ const detailObj = detail;
105566
+ const typeKey = Object.keys(detailObj).find((key) => key.trim() === "@type");
105567
+ if (typeKey) {
105568
+ if (typeKey !== "@type") {
105569
+ detailObj["@type"] = detailObj[typeKey];
105570
+ delete detailObj[typeKey];
105571
+ }
105572
+ if (typeof detailObj["@type"] === "string") {
105573
+ details.push(detailObj);
105574
+ }
105575
+ }
105576
+ }
105577
+ }
105578
+ }
105579
+ return {
105580
+ code: code2,
105581
+ message,
105582
+ details
105583
+ };
105584
+ }
105585
+ return null;
105586
+ }
105587
+ function isErrorShape(obj) {
105588
+ return typeof obj === "object" && obj !== null && ("message" in obj && typeof obj.message === "string" || "code" in obj && typeof obj.code === "number");
105589
+ }
105590
+ function fromGaxiosError(errorObj) {
105591
+ const gaxiosError = errorObj;
105592
+ let outerError;
105593
+ if (gaxiosError.response?.data) {
105594
+ let data = gaxiosError.response.data;
105595
+ if (typeof data === "string") {
105596
+ try {
105597
+ data = JSON.parse(data);
105598
+ } catch (_) {
105599
+ }
105600
+ }
105601
+ if (Array.isArray(data) && data.length > 0) {
105602
+ data = data[0];
105603
+ }
105604
+ if (typeof data === "object" && data !== null) {
105605
+ if ("error" in data) {
105606
+ const potentialError = data.error;
105607
+ if (isErrorShape(potentialError)) {
105608
+ outerError = potentialError;
105609
+ }
105610
+ }
105611
+ }
105612
+ }
105613
+ if (!outerError) {
105614
+ if (gaxiosError.error) {
105615
+ outerError = gaxiosError.error;
105616
+ } else {
105617
+ return void 0;
105618
+ }
105619
+ }
105620
+ return outerError;
105621
+ }
105622
+ function fromApiError(errorObj) {
105623
+ const apiError = errorObj;
105624
+ let outerError;
105625
+ if (apiError.message) {
105626
+ let data = apiError.message;
105627
+ if (typeof data === "string") {
105628
+ try {
105629
+ data = JSON.parse(data);
105630
+ } catch (_) {
105631
+ if (typeof data === "string") {
105632
+ const firstBrace = data.indexOf("{");
105633
+ const lastBrace = data.lastIndexOf("}");
105634
+ if (firstBrace !== -1 && lastBrace !== -1 && lastBrace > firstBrace) {
105635
+ try {
105636
+ data = JSON.parse(data.substring(firstBrace, lastBrace + 1));
105637
+ } catch (__) {
105638
+ }
105639
+ }
105640
+ }
105641
+ }
105642
+ }
105643
+ if (Array.isArray(data) && data.length > 0) {
105644
+ data = data[0];
105645
+ }
105646
+ if (typeof data === "object" && data !== null) {
105647
+ if ("error" in data) {
105648
+ const potentialError = data.error;
105649
+ if (isErrorShape(potentialError)) {
105650
+ outerError = potentialError;
105651
+ }
105652
+ }
105653
+ }
105654
+ }
105655
+ return outerError;
105656
+ }
105657
+ var init_googleErrors = __esm({
105658
+ "packages/core/dist/src/utils/googleErrors.js"() {
105659
+ "use strict";
105660
+ }
105661
+ });
105662
+
105519
105663
  // packages/core/dist/src/utils/errors.js
105520
105664
  function isGaxiosError(error2) {
105521
105665
  return typeof error2 === "object" && error2 !== null && "response" in error2 && typeof error2.response === "object" && error2.response !== null;
@@ -105560,6 +105704,13 @@ function isResponseData(data) {
105560
105704
  return true;
105561
105705
  }
105562
105706
  function toFriendlyError(error2) {
105707
+ const googleApiError = parseGoogleApiError(error2);
105708
+ if (googleApiError && googleApiError.code === 403) {
105709
+ const tosDetail = googleApiError.details.find((d) => d["@type"] === "type.googleapis.com/google.rpc.ErrorInfo" && "reason" in d && d.reason === "TOS_VIOLATION");
105710
+ if (tosDetail) {
105711
+ return new AccountSuspendedError(googleApiError.message, tosDetail.metadata);
105712
+ }
105713
+ }
105563
105714
  if (isGaxiosError(error2)) {
105564
105715
  const data = parseResponseData(error2);
105565
105716
  if (data && data.error && data.error.message && data.error.code) {
@@ -105609,10 +105760,11 @@ function isAuthenticationError(error2) {
105609
105760
  }
105610
105761
  return false;
105611
105762
  }
105612
- var FatalError, FatalAuthenticationError, FatalCancellationError, ForbiddenError, UnauthorizedError, BadRequestError2, ChangeAuthRequestedError;
105763
+ var FatalError, FatalAuthenticationError, FatalCancellationError, ForbiddenError, AccountSuspendedError, UnauthorizedError, BadRequestError2, ChangeAuthRequestedError;
105613
105764
  var init_errors = __esm({
105614
105765
  "packages/core/dist/src/utils/errors.js"() {
105615
105766
  "use strict";
105767
+ init_googleErrors();
105616
105768
  FatalError = class extends Error {
105617
105769
  exitCode;
105618
105770
  constructor(message, exitCode) {
@@ -105632,6 +105784,16 @@ var init_errors = __esm({
105632
105784
  };
105633
105785
  ForbiddenError = class extends Error {
105634
105786
  };
105787
+ AccountSuspendedError = class extends ForbiddenError {
105788
+ appealUrl;
105789
+ appealLinkText;
105790
+ constructor(message, metadata2) {
105791
+ super(message);
105792
+ this.name = "AccountSuspendedError";
105793
+ this.appealUrl = metadata2?.["appeal_url"];
105794
+ this.appealLinkText = metadata2?.["appeal_url_link_text"];
105795
+ }
105796
+ };
105635
105797
  UnauthorizedError = class extends Error {
105636
105798
  };
105637
105799
  BadRequestError2 = class extends Error {
@@ -107093,7 +107255,7 @@ var init_storage = __esm({
107093
107255
  return path14.join(this.getGeminiDir(), "policies");
107094
107256
  }
107095
107257
  getAutoSavedPolicyPath() {
107096
- return path14.join(this.getWorkspacePoliciesDir(), AUTO_SAVED_POLICY_FILENAME);
107258
+ return path14.join(_Storage.getUserPoliciesDir(), AUTO_SAVED_POLICY_FILENAME);
107097
107259
  }
107098
107260
  ensureProjectTempDirExists() {
107099
107261
  fs24.mkdirSync(this.getProjectTempDir(), { recursive: true });
@@ -141950,7 +142112,7 @@ function getVersion() {
141950
142112
  }
141951
142113
  versionPromise = (async () => {
141952
142114
  const pkgJson = await getPackageJson(__dirname3);
141953
- return "0.31.0-preview.1";
142115
+ return "0.31.0-preview.3";
141954
142116
  })();
141955
142117
  return versionPromise;
141956
142118
  }
@@ -142237,150 +142399,6 @@ var init_server = __esm({
142237
142399
  }
142238
142400
  });
142239
142401
 
142240
- // packages/core/dist/src/utils/googleErrors.js
142241
- function parseGoogleApiError(error2) {
142242
- if (!error2) {
142243
- return null;
142244
- }
142245
- let errorObj = error2;
142246
- if (typeof errorObj === "string") {
142247
- try {
142248
- errorObj = JSON.parse(errorObj);
142249
- } catch (_) {
142250
- return null;
142251
- }
142252
- }
142253
- if (Array.isArray(errorObj) && errorObj.length > 0) {
142254
- errorObj = errorObj[0];
142255
- }
142256
- if (typeof errorObj !== "object" || errorObj === null) {
142257
- return null;
142258
- }
142259
- let currentError = fromGaxiosError(errorObj) ?? fromApiError(errorObj);
142260
- let depth = 0;
142261
- const maxDepth = 10;
142262
- while (currentError && typeof currentError.message === "string" && depth < maxDepth) {
142263
- try {
142264
- const parsedMessage = JSON.parse(currentError.message.replace(/\u00A0/g, "").replace(/\n/g, " "));
142265
- if (parsedMessage.error) {
142266
- currentError = parsedMessage.error;
142267
- depth++;
142268
- } else {
142269
- break;
142270
- }
142271
- } catch (_error) {
142272
- break;
142273
- }
142274
- }
142275
- if (!currentError) {
142276
- return null;
142277
- }
142278
- const code2 = currentError.code;
142279
- const message = currentError.message;
142280
- const errorDetails = currentError.details;
142281
- if (code2 && message) {
142282
- const details = [];
142283
- if (Array.isArray(errorDetails)) {
142284
- for (const detail of errorDetails) {
142285
- if (detail && typeof detail === "object") {
142286
- const detailObj = detail;
142287
- const typeKey = Object.keys(detailObj).find((key) => key.trim() === "@type");
142288
- if (typeKey) {
142289
- if (typeKey !== "@type") {
142290
- detailObj["@type"] = detailObj[typeKey];
142291
- delete detailObj[typeKey];
142292
- }
142293
- if (typeof detailObj["@type"] === "string") {
142294
- details.push(detailObj);
142295
- }
142296
- }
142297
- }
142298
- }
142299
- }
142300
- return {
142301
- code: code2,
142302
- message,
142303
- details
142304
- };
142305
- }
142306
- return null;
142307
- }
142308
- function isErrorShape(obj) {
142309
- return typeof obj === "object" && obj !== null && ("message" in obj && typeof obj.message === "string" || "code" in obj && typeof obj.code === "number");
142310
- }
142311
- function fromGaxiosError(errorObj) {
142312
- const gaxiosError = errorObj;
142313
- let outerError;
142314
- if (gaxiosError.response?.data) {
142315
- let data = gaxiosError.response.data;
142316
- if (typeof data === "string") {
142317
- try {
142318
- data = JSON.parse(data);
142319
- } catch (_) {
142320
- }
142321
- }
142322
- if (Array.isArray(data) && data.length > 0) {
142323
- data = data[0];
142324
- }
142325
- if (typeof data === "object" && data !== null) {
142326
- if ("error" in data) {
142327
- const potentialError = data.error;
142328
- if (isErrorShape(potentialError)) {
142329
- outerError = potentialError;
142330
- }
142331
- }
142332
- }
142333
- }
142334
- if (!outerError) {
142335
- if (gaxiosError.error) {
142336
- outerError = gaxiosError.error;
142337
- } else {
142338
- return void 0;
142339
- }
142340
- }
142341
- return outerError;
142342
- }
142343
- function fromApiError(errorObj) {
142344
- const apiError = errorObj;
142345
- let outerError;
142346
- if (apiError.message) {
142347
- let data = apiError.message;
142348
- if (typeof data === "string") {
142349
- try {
142350
- data = JSON.parse(data);
142351
- } catch (_) {
142352
- if (typeof data === "string") {
142353
- const firstBrace = data.indexOf("{");
142354
- const lastBrace = data.lastIndexOf("}");
142355
- if (firstBrace !== -1 && lastBrace !== -1 && lastBrace > firstBrace) {
142356
- try {
142357
- data = JSON.parse(data.substring(firstBrace, lastBrace + 1));
142358
- } catch (__) {
142359
- }
142360
- }
142361
- }
142362
- }
142363
- }
142364
- if (Array.isArray(data) && data.length > 0) {
142365
- data = data[0];
142366
- }
142367
- if (typeof data === "object" && data !== null) {
142368
- if ("error" in data) {
142369
- const potentialError = data.error;
142370
- if (isErrorShape(potentialError)) {
142371
- outerError = potentialError;
142372
- }
142373
- }
142374
- }
142375
- }
142376
- return outerError;
142377
- }
142378
- var init_googleErrors = __esm({
142379
- "packages/core/dist/src/utils/googleErrors.js"() {
142380
- "use strict";
142381
- }
142382
- });
142383
-
142384
142402
  // packages/core/dist/src/utils/httpErrors.js
142385
142403
  function getErrorStatus(error2) {
142386
142404
  if (typeof error2 === "object" && error2 !== null) {
@@ -219396,8 +219414,8 @@ var GIT_COMMIT_INFO, CLI_VERSION;
219396
219414
  var init_git_commit = __esm({
219397
219415
  "packages/core/dist/src/generated/git-commit.js"() {
219398
219416
  "use strict";
219399
- GIT_COMMIT_INFO = "b15330140";
219400
- CLI_VERSION = "0.31.0-preview.1";
219417
+ GIT_COMMIT_INFO = "8553c3866";
219418
+ CLI_VERSION = "0.31.0-preview.3";
219401
219419
  }
219402
219420
  });
219403
219421