@google/gemini-cli 0.69.0 → 0.70.0

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 (75) hide show
  1. package/bundle/{chunk-TPD3RZ2B.js → chunk-37D3S3FZ.js} +65559 -51236
  2. package/bundle/{chunk-MJHJIOO6.js → chunk-3VGGGCOZ.js} +35 -29
  3. package/bundle/{chunk-RRELGD6D.js → chunk-4BWP3TDK.js} +1 -1
  4. package/bundle/{chunk-76IL5AQS.js → chunk-5VFAWK3F.js} +1 -1
  5. package/bundle/{chunk-2NIO2MYP.js → chunk-6IKD2NB3.js} +1 -1
  6. package/bundle/{chunk-FZXMW23P.js → chunk-7JS2T75Z.js} +1 -1
  7. package/bundle/{chunk-TEYXLQ5H.js → chunk-AMHNNZY2.js} +1165 -21669
  8. package/bundle/{chunk-SM722TVE.js → chunk-BOIBJEIO.js} +3 -3
  9. package/bundle/{chunk-XXN6WBQW.js → chunk-CB37EK5Y.js} +3 -3
  10. package/bundle/{chunk-BBQ3J3KD.js → chunk-CMKRWIX6.js} +1165 -21669
  11. package/bundle/{chunk-66UT6FAS.js → chunk-EG2BSKPF.js} +1 -1
  12. package/bundle/{chunk-5WVS3LFE.js → chunk-FHK4RNCX.js} +1165 -21669
  13. package/bundle/{chunk-6CG4XKVB.js → chunk-FXAACYC3.js} +1 -1
  14. package/bundle/{chunk-6MSIVBAV.js → chunk-G6SC5BOV.js} +1 -1
  15. package/bundle/{chunk-HFG3LZOT.js → chunk-GFBMTAPD.js} +625 -22
  16. package/bundle/{chunk-2NWFKUZR.js → chunk-JLKRLYZG.js} +35 -29
  17. package/bundle/{chunk-KZYASN6P.js → chunk-KV6XIC2Z.js} +1 -1
  18. package/bundle/{chunk-Y4PW6PYG.js → chunk-LMBUPWFC.js} +65559 -51236
  19. package/bundle/{chunk-RPOY63FV.js → chunk-LMNAB62M.js} +625 -22
  20. package/bundle/{chunk-IUUIT4SU.js → chunk-N7J54YNL.js} +1 -0
  21. package/bundle/{chunk-E2O7673V.js → chunk-QYKA4YD7.js} +3 -3
  22. package/bundle/{chunk-4ICD47UK.js → chunk-RFQXG324.js} +1 -1
  23. package/bundle/{chunk-CU3LIREC.js → chunk-SPAMAY26.js} +1 -1
  24. package/bundle/{chunk-X4P3RZYU.js → chunk-UF44X63P.js} +65411 -51125
  25. package/bundle/{chunk-7JVLRJNT.js → chunk-V4HIE5G5.js} +1 -1
  26. package/bundle/{chunk-TO7WASPI.js → chunk-VHXUWMGE.js} +35 -29
  27. package/bundle/{chunk-664ZODQF.js → chunk-W2AJR23G.js} +137 -58
  28. package/bundle/{chunk-VWFWPAOZ.js → chunk-WRWAVEME.js} +1 -1
  29. package/bundle/{chunk-L7UQY2JQ.js → chunk-YOEWNBDC.js} +625 -22
  30. package/bundle/{cleanup-4RG2PSND.js → cleanup-BMYAIPAL.js} +4 -4
  31. package/bundle/{cleanup-QM4BFPJ4.js → cleanup-CWOSCK57.js} +4 -4
  32. package/bundle/{cleanup-XYZT64H7.js → cleanup-JTPRPYIQ.js} +4 -4
  33. package/bundle/{core-JN57UMDL.js → core-HYVGBZPP.js} +13 -3
  34. package/bundle/{dist-RVQZS637.js → core-XZECNCR2.js} +13 -3
  35. package/bundle/{devtools-TYCPOPV3.js → devtools-WUGMIOCT.js} +1 -1
  36. package/bundle/devtoolsService-ER22TM2Y.js +919 -0
  37. package/bundle/devtoolsService-O5VD5YWD.js +918 -0
  38. package/bundle/devtoolsService-WNJOZ7ZT.js +918 -0
  39. package/bundle/{core-3UXW77KZ.js → dist-75NDR3EX.js} +13 -3
  40. package/bundle/docs/changelogs/index.md +22 -0
  41. package/bundle/docs/changelogs/latest.md +100 -92
  42. package/bundle/docs/changelogs/preview.md +116 -104
  43. package/bundle/docs/cli/enterprise.md +23 -5
  44. package/bundle/docs/ide-integration/ide-companion-spec.md +10 -4
  45. package/bundle/docs/reference/policy-engine.md +45 -6
  46. package/bundle/docs/tools/shell.md +2 -1
  47. package/bundle/{formatError-I6YST2IJ.js → formatError-FYLLVZDF.js} +4 -4
  48. package/bundle/{formatError-R5NIXYBT.js → formatError-M4GLDFGE.js} +4 -4
  49. package/bundle/{formatError-5QTHC2BU.js → formatError-QOZLAZ32.js} +4 -4
  50. package/bundle/{gemini-SS7CDNKE.js → gemini-AYDYW6NZ.js} +676 -288
  51. package/bundle/{gemini-VN2552TI.js → gemini-FRSP6LA3.js} +676 -288
  52. package/bundle/{gemini-BCCY3LUV.js → gemini-PG2FEK5D.js} +676 -288
  53. package/bundle/gemini.js +35 -17
  54. package/bundle/{getMachineId-bsd-TXG52NKR.js → getMachineId-bsd-3TGNBDZQ.js} +1 -1
  55. package/bundle/{getMachineId-darwin-7OE4DDZ6.js → getMachineId-darwin-2CFT4JKO.js} +1 -1
  56. package/bundle/{getMachineId-linux-SHIFKOOX.js → getMachineId-linux-BXATTKN2.js} +1 -1
  57. package/bundle/{getMachineId-unsupported-5U5DOEYY.js → getMachineId-unsupported-VHPOSMKR.js} +1 -1
  58. package/bundle/{getMachineId-win-6KLLGOI4.js → getMachineId-win-IGXROMTR.js} +1 -1
  59. package/bundle/{interactiveCli-X6WWC2C6.js → interactiveCli-6TVFB4R5.js} +36 -18
  60. package/bundle/{interactiveCli-SGZ2VGTY.js → interactiveCli-76LAQB3B.js} +36 -18
  61. package/bundle/{interactiveCli-MX4SNKPZ.js → interactiveCli-BYWR7IEK.js} +36 -18
  62. package/bundle/{liteRtServerManager-CAJIW3PE.js → liteRtServerManager-BYJWS5BO.js} +6 -6
  63. package/bundle/{liteRtServerManager-FQPKIHVD.js → liteRtServerManager-GIRVSE6M.js} +6 -6
  64. package/bundle/{liteRtServerManager-6PM4BXYU.js → liteRtServerManager-KZ62KJW3.js} +6 -6
  65. package/bundle/{oauth2-provider-T3DF3FTA.js → oauth2-provider-SFFQQ6OE.js} +3 -3
  66. package/bundle/{oauth2-provider-RIS25NZW.js → oauth2-provider-SRH6I6G7.js} +3 -3
  67. package/bundle/{oauth2-provider-D4UNDFN3.js → oauth2-provider-ZBFFAIQE.js} +3 -3
  68. package/bundle/{src-XZYPU6PJ.js → src-MVBNXN6P.js} +3 -3504
  69. package/bundle/{start-FVNQP7EB.js → start-OLEVDFQS.js} +8 -8
  70. package/bundle/{start-WSOZZWBK.js → start-PLK5XHJC.js} +8 -8
  71. package/bundle/{start-76F65FZ5.js → start-Q66LTS3Y.js} +8 -8
  72. package/package.json +1 -1
  73. package/bundle/devtoolsService-K3FKQFZP.js +0 -4422
  74. package/bundle/devtoolsService-QLI75YCI.js +0 -4421
  75. package/bundle/devtoolsService-XZRXARUU.js +0 -4421
@@ -1,7 +1,7 @@
1
1
  const require = (await import('node:module')).createRequire(import.meta.url); const __chunk_filename = (await import('node:url')).fileURLToPath(import.meta.url); const __chunk_dirname = (await import('node:path')).dirname(__chunk_filename);
2
2
  import {
3
3
  require_react
4
- } from "./chunk-76IL5AQS.js";
4
+ } from "./chunk-5VFAWK3F.js";
5
5
  import {
6
6
  AuthProviderType,
7
7
  AuthType,
@@ -35,9 +35,10 @@ import {
35
35
  loadConversationRecord,
36
36
  loadTrustedFolders,
37
37
  partListUnionToString,
38
+ require_shell_quote,
38
39
  require_strip_json_comments,
39
40
  sanitizeFilenamePart
40
- } from "./chunk-X4P3RZYU.js";
41
+ } from "./chunk-UF44X63P.js";
41
42
  import {
42
43
  __commonJS,
43
44
  __export,
@@ -9120,7 +9121,7 @@ var require_main = __commonJS({
9120
9121
  return supportsAnsi() ? `\x1B[2m${text}\x1B[0m` : text;
9121
9122
  }
9122
9123
  var LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
9123
- function parse3(src) {
9124
+ function parse4(src) {
9124
9125
  const obj = {};
9125
9126
  let lines = src.toString();
9126
9127
  lines = lines.replace(/\r\n?/mg, "\n");
@@ -9390,7 +9391,7 @@ var require_main = __commonJS({
9390
9391
  _parseVault,
9391
9392
  config,
9392
9393
  decrypt,
9393
- parse: parse3,
9394
+ parse: parse4,
9394
9395
  populate
9395
9396
  };
9396
9397
  module.exports.configDotenv = DotenvModule.configDotenv;
@@ -10724,7 +10725,7 @@ var require_esprima = __commonJS({
10724
10725
  var jsx_parser_1 = __webpack_require__(3);
10725
10726
  var parser_1 = __webpack_require__(8);
10726
10727
  var tokenizer_1 = __webpack_require__(15);
10727
- function parse3(code, options, delegate) {
10728
+ function parse4(code, options, delegate) {
10728
10729
  var commentHandler = null;
10729
10730
  var proxyDelegate = function(node, metadata) {
10730
10731
  if (delegate) {
@@ -10769,17 +10770,17 @@ var require_esprima = __commonJS({
10769
10770
  }
10770
10771
  return ast;
10771
10772
  }
10772
- exports2.parse = parse3;
10773
+ exports2.parse = parse4;
10773
10774
  function parseModule(code, options, delegate) {
10774
10775
  var parsingOptions = options || {};
10775
10776
  parsingOptions.sourceType = "module";
10776
- return parse3(code, parsingOptions, delegate);
10777
+ return parse4(code, parsingOptions, delegate);
10777
10778
  }
10778
10779
  exports2.parseModule = parseModule;
10779
10780
  function parseScript(code, options, delegate) {
10780
10781
  var parsingOptions = options || {};
10781
10782
  parsingOptions.sourceType = "script";
10782
- return parse3(code, parsingOptions, delegate);
10783
+ return parse4(code, parsingOptions, delegate);
10783
10784
  }
10784
10785
  exports2.parseScript = parseScript;
10785
10786
  function tokenize2(code, options, delegate) {
@@ -18287,7 +18288,7 @@ var require_parse = __commonJS({
18287
18288
  }
18288
18289
  }
18289
18290
  var isObject = (subject) => Object(subject) === subject;
18290
- var parse3 = (code, rev, no_comments) => {
18291
+ var parse4 = (code, rev, no_comments) => {
18291
18292
  clean();
18292
18293
  tokens = tokenize2(code);
18293
18294
  reviver = rev;
@@ -18316,7 +18317,7 @@ var require_parse = __commonJS({
18316
18317
  return result;
18317
18318
  };
18318
18319
  module.exports = {
18319
- parse: parse3,
18320
+ parse: parse4,
18320
18321
  tokenize: tokenize2
18321
18322
  };
18322
18323
  }
@@ -18561,12 +18562,12 @@ var require_stringify = __commonJS({
18561
18562
  // node_modules/comment-json/src/index.js
18562
18563
  var require_src2 = __commonJS({
18563
18564
  "node_modules/comment-json/src/index.js"(exports, module) {
18564
- var { parse: parse3, tokenize: tokenize2 } = require_parse();
18565
+ var { parse: parse4, tokenize: tokenize2 } = require_parse();
18565
18566
  var stringify2 = require_stringify();
18566
18567
  var { CommentArray } = require_array();
18567
18568
  var { assign } = require_common();
18568
18569
  module.exports = {
18569
- parse: parse3,
18570
+ parse: parse4,
18570
18571
  stringify: stringify2,
18571
18572
  tokenize: tokenize2,
18572
18573
  CommentArray,
@@ -22847,7 +22848,7 @@ var styles_default = styles3;
22847
22848
  // node_modules/ink/build/reconciler.js
22848
22849
  if (process3.env["DEV"] === "true") {
22849
22850
  try {
22850
- await import("./devtools-TYCPOPV3.js");
22851
+ await import("./devtools-WUGMIOCT.js");
22851
22852
  } catch (error) {
22852
22853
  if (error.code === "ERR_MODULE_NOT_FOUND") {
22853
22854
  console.warn(`
@@ -31415,7 +31416,7 @@ var SessionError = class _SessionError extends Error {
31415
31416
  );
31416
31417
  }
31417
31418
  };
31418
- var cleanMessage = (message) => message.replace(/\n+/g, " ").replace(/\s+/g, " ").replace(/[^\x20-\x7E]+/g, "").trim();
31419
+ var cleanMessage = (message) => stripUnsafeCharacters(message).replace(/\s+/g, " ").trim();
31419
31420
  var extractFirstUserMessage = (messages) => {
31420
31421
  const userMessage = messages.filter((msg) => {
31421
31422
  const content2 = partListUnionToString(msg.content);
@@ -32220,6 +32221,7 @@ import * as fs9 from "node:fs";
32220
32221
  import * as path5 from "node:path";
32221
32222
  import { platform as platform3 } from "node:os";
32222
32223
  import process19 from "node:process";
32224
+ var import_shell_quote = __toESM(require_shell_quote(), 1);
32223
32225
  var import_strip_json_comments = __toESM(require_strip_json_comments(), 1);
32224
32226
 
32225
32227
  // packages/cli/src/ui/themes/theme.ts
@@ -37258,15 +37260,18 @@ function resolveEnvVarsInString(value, customEnv) {
37258
37260
  if (!varName) {
37259
37261
  return match;
37260
37262
  }
37263
+ let val;
37261
37264
  if (customEnv && typeof customEnv[varName] === "string") {
37262
- return customEnv[varName];
37263
- }
37264
- if (process && process.env) {
37265
- const val = process.env[varName];
37266
- if (typeof val === "string") {
37267
- return val;
37265
+ val = customEnv[varName];
37266
+ } else if (process && process.env) {
37267
+ const envVal = process.env[varName];
37268
+ if (typeof envVal === "string") {
37269
+ val = envVal;
37268
37270
  }
37269
37271
  }
37272
+ if (val !== void 0 && (val !== "" || defaultValue === void 0)) {
37273
+ return val;
37274
+ }
37270
37275
  if (defaultValue !== void 0) {
37271
37276
  return defaultValue;
37272
37277
  }
@@ -37887,12 +37892,13 @@ function mergeSettings(system, systemDefaults, user, workspace, isTrusted) {
37887
37892
  }
37888
37893
  var UNTRUSTED_WORKSPACE_SETTINGS_ERROR = "Cannot modify settings in an untrusted workspace. To enable this, verify the source of the repository and set GEMINI_CLI_TRUST_WORKSPACE=true or move your configuration to the global settings file.";
37889
37894
  var LoadedSettings = class {
37890
- constructor(system, systemDefaults, user, workspace, isTrusted, errors = []) {
37895
+ constructor(system, systemDefaults, user, workspace, isTrusted, errors = [], blockedMcpServers = /* @__PURE__ */ new Set()) {
37891
37896
  this.system = system;
37892
37897
  this.systemDefaults = systemDefaults;
37893
37898
  this.user = user;
37894
37899
  this._workspaceFile = workspace;
37895
37900
  this.isTrusted = isTrusted;
37901
+ this._blockedMcpServers = blockedMcpServers;
37896
37902
  this.workspace = isTrusted ? workspace : this.createEmptyWorkspace(workspace);
37897
37903
  this.errors = errors;
37898
37904
  this._merged = this.computeMergedSettings();
@@ -37905,6 +37911,7 @@ var LoadedSettings = class {
37905
37911
  isTrusted;
37906
37912
  errors;
37907
37913
  _workspaceFile;
37914
+ _blockedMcpServers;
37908
37915
  _merged;
37909
37916
  _snapshot;
37910
37917
  _remoteAdminSettings;
@@ -37931,6 +37938,10 @@ var LoadedSettings = class {
37931
37938
  this.errors
37932
37939
  );
37933
37940
  normalizeLegacyTheme(resolvedWorkspaceSettings);
37941
+ stripBlockedMcpServers(
37942
+ resolvedWorkspaceSettings,
37943
+ this._blockedMcpServers
37944
+ );
37934
37945
  this._workspaceFile = {
37935
37946
  ...this._workspaceFile,
37936
37947
  settings: resolvedWorkspaceSettings
@@ -37958,6 +37969,7 @@ var LoadedSettings = class {
37958
37969
  workspaceSettings,
37959
37970
  isTrusted
37960
37971
  );
37972
+ stripBlockedMcpServers(merged, this._blockedMcpServers);
37961
37973
  const adminSettingSchema = getSettingsSchema().admin;
37962
37974
  if (adminSettingSchema?.properties) {
37963
37975
  const adminSchema = adminSettingSchema.properties;
@@ -38285,6 +38297,571 @@ function resolveSettings(rawSettings, filePath, settingsErrors) {
38285
38297
  }
38286
38298
  return validationResult.data ?? expandedSettings;
38287
38299
  }
38300
+ var SCRIPT_INTERPRETERS = /* @__PURE__ */ new Set([
38301
+ "sh",
38302
+ "bash",
38303
+ "zsh",
38304
+ "dash",
38305
+ "ksh",
38306
+ "fish",
38307
+ "csh",
38308
+ "tcsh",
38309
+ "node",
38310
+ "nodejs",
38311
+ "python",
38312
+ "python2",
38313
+ "python3",
38314
+ "py",
38315
+ "ruby",
38316
+ "perl",
38317
+ "php",
38318
+ "lua",
38319
+ "rscript",
38320
+ "pwsh",
38321
+ "powershell",
38322
+ "deno",
38323
+ "bun",
38324
+ "tsx",
38325
+ "ts-node",
38326
+ "ts-node-esm",
38327
+ "cmd",
38328
+ "osascript",
38329
+ "cscript",
38330
+ "wscript"
38331
+ ]);
38332
+ var WINDOWS_SLASH_FLAG_INTERPRETERS = /* @__PURE__ */ new Set(["cmd", "cscript", "wscript"]);
38333
+ var INLINE_EVAL_FLAGS = /* @__PURE__ */ new Set([
38334
+ "-c",
38335
+ "-e",
38336
+ "-E",
38337
+ "--eval",
38338
+ "-p",
38339
+ "--print",
38340
+ "-command",
38341
+ "-encodedcommand"
38342
+ ]);
38343
+ var PRELOAD_FLAGS = /* @__PURE__ */ new Set([
38344
+ "-r",
38345
+ "--require",
38346
+ "--import",
38347
+ "--loader",
38348
+ "--experimental-loader",
38349
+ "--preload",
38350
+ "--env-file",
38351
+ "--env-file-if-exists",
38352
+ "-f",
38353
+ "-file"
38354
+ ]);
38355
+ var SCRIPT_EXTENSIONS = /* @__PURE__ */ new Set([
38356
+ ".js",
38357
+ ".mjs",
38358
+ ".cjs",
38359
+ ".jsx",
38360
+ ".node",
38361
+ ".ts",
38362
+ ".mts",
38363
+ ".cts",
38364
+ ".tsx",
38365
+ ".py",
38366
+ ".pyw",
38367
+ ".py3",
38368
+ ".pyz",
38369
+ ".sh",
38370
+ ".bash",
38371
+ ".zsh",
38372
+ ".ksh",
38373
+ ".fish",
38374
+ ".csh",
38375
+ ".pl",
38376
+ ".pm",
38377
+ ".rb",
38378
+ ".php",
38379
+ ".phar",
38380
+ ".lua",
38381
+ ".r",
38382
+ ".ps1",
38383
+ ".psm1",
38384
+ ".cmd",
38385
+ ".bat",
38386
+ ".vbs",
38387
+ ".vbe",
38388
+ ".jse",
38389
+ ".wsf",
38390
+ ".wsh",
38391
+ ".scpt",
38392
+ ".scptd",
38393
+ ".applescript"
38394
+ ]);
38395
+ var NON_SCRIPT_VALUE_FLAGS = /* @__PURE__ */ new Set([
38396
+ "-W",
38397
+ "-m",
38398
+ "-I",
38399
+ "-M",
38400
+ "-K",
38401
+ "-F",
38402
+ "-C",
38403
+ "-P",
38404
+ "--project",
38405
+ "--config",
38406
+ "--log-file",
38407
+ "--max-old-space-size",
38408
+ "--inspect-port",
38409
+ "--debug-port",
38410
+ "--conditions",
38411
+ "--input-type",
38412
+ "--title",
38413
+ "-executionpolicy"
38414
+ ]);
38415
+ var KNOWN_BOOLEAN_FLAGS = /* @__PURE__ */ new Set([
38416
+ "-x",
38417
+ "-v",
38418
+ "-n",
38419
+ "-u",
38420
+ "-w",
38421
+ "-d",
38422
+ "-O",
38423
+ "-B",
38424
+ "-s",
38425
+ "-S",
38426
+ "-i",
38427
+ "-t",
38428
+ "--watch",
38429
+ "--no-warnings",
38430
+ "--trace-warnings",
38431
+ "--inspect",
38432
+ "--inspect-brk",
38433
+ "--enable-source-maps",
38434
+ "--preserve-symlinks",
38435
+ "--no-deprecation",
38436
+ "--throw-deprecation",
38437
+ "-noprofile",
38438
+ "-noninteractive",
38439
+ "-sta",
38440
+ "-mta"
38441
+ ]);
38442
+ var SUBCOMMAND_INTERPRETERS = /* @__PURE__ */ new Set(["deno", "bun"]);
38443
+ var INTERPRETER_SUBCOMMANDS = /* @__PURE__ */ new Set(["run", "x", "serve", "test", "bench"]);
38444
+ var IMPLICIT_SCRIPT_EXTENSIONS = [
38445
+ ".js",
38446
+ ".mjs",
38447
+ ".cjs",
38448
+ ".ts",
38449
+ ".mts",
38450
+ ".cts",
38451
+ ".py",
38452
+ ".ps1"
38453
+ ];
38454
+ function getCommandBaseName(command) {
38455
+ return command.split(/[\\/]/).pop()?.toLowerCase().replace(/\.(exe|cmd|bat)$/, "");
38456
+ }
38457
+ function isExplicitCommandPath(command) {
38458
+ return path5.isAbsolute(command) || command.includes("/") || command.includes("\\");
38459
+ }
38460
+ function resolveMcpCommandPath(command, cwd2, workspaceDir) {
38461
+ if (path5.isAbsolute(command) || /^[a-zA-Z]:[\\/]/.test(command)) {
38462
+ return command;
38463
+ }
38464
+ const baseDir = cwd2 ? path5.resolve(workspaceDir, cwd2) : workspaceDir;
38465
+ return path5.resolve(baseDir, command);
38466
+ }
38467
+ function hasExistingScriptOnDisk(resolvedPath) {
38468
+ try {
38469
+ if (fs9.existsSync(resolvedPath)) {
38470
+ return true;
38471
+ }
38472
+ for (const ext of IMPLICIT_SCRIPT_EXTENSIONS) {
38473
+ if (fs9.existsSync(`${resolvedPath}${ext}`)) {
38474
+ return true;
38475
+ }
38476
+ }
38477
+ return false;
38478
+ } catch {
38479
+ return true;
38480
+ }
38481
+ }
38482
+ function isScriptPathCandidate(token, cwd2, workspaceDir) {
38483
+ if (/^\d+$/.test(token)) {
38484
+ return false;
38485
+ }
38486
+ const ext = path5.extname(token).toLowerCase();
38487
+ if (ext !== "") {
38488
+ return SCRIPT_EXTENSIONS.has(ext);
38489
+ }
38490
+ if (isExplicitCommandPath(token)) {
38491
+ return true;
38492
+ }
38493
+ return hasExistingScriptOnDisk(
38494
+ resolveMcpCommandPath(token, cwd2, workspaceDir)
38495
+ );
38496
+ }
38497
+ function isPreloadTargetCandidate(token, cwd2, workspaceDir) {
38498
+ return isExplicitCommandPath(token) || isScriptPathCandidate(token, cwd2, workspaceDir);
38499
+ }
38500
+ function expandCandidatePaths(resolvedPath) {
38501
+ const paths = [resolvedPath];
38502
+ if (path5.extname(resolvedPath) !== "") {
38503
+ return paths;
38504
+ }
38505
+ for (const ext of IMPLICIT_SCRIPT_EXTENSIONS) {
38506
+ const withExt = `${resolvedPath}${ext}`;
38507
+ try {
38508
+ if (fs9.existsSync(withExt)) {
38509
+ paths.push(withExt);
38510
+ }
38511
+ } catch {
38512
+ paths.push(withExt);
38513
+ }
38514
+ }
38515
+ return paths;
38516
+ }
38517
+ function unwrapEnvInvocation(command, args, cwd2, workspaceDir) {
38518
+ let currentCmd = command.trim();
38519
+ let currentArgs = [...args ?? []];
38520
+ let effectiveCwd = cwd2;
38521
+ const wrapperPaths = [];
38522
+ while (currentCmd && getCommandBaseName(currentCmd) === "env") {
38523
+ if (isExplicitCommandPath(currentCmd)) {
38524
+ wrapperPaths.push(currentCmd);
38525
+ }
38526
+ let idx = 0;
38527
+ let stopEnvOptions = false;
38528
+ while (idx < currentArgs.length) {
38529
+ const token = currentArgs[idx]?.trim() ?? "";
38530
+ if (!token) {
38531
+ idx++;
38532
+ continue;
38533
+ }
38534
+ if (!stopEnvOptions && token === "--") {
38535
+ stopEnvOptions = true;
38536
+ idx++;
38537
+ continue;
38538
+ }
38539
+ if (!stopEnvOptions && token.startsWith("-") && token !== "-") {
38540
+ if (token === "-u" || token === "--unset") {
38541
+ idx += 2;
38542
+ continue;
38543
+ }
38544
+ if (token === "-C" || token === "--chdir") {
38545
+ const dirArg = currentArgs[idx + 1]?.trim();
38546
+ if (dirArg) {
38547
+ effectiveCwd = effectiveCwd ? path5.resolve(workspaceDir, effectiveCwd, dirArg) : dirArg;
38548
+ }
38549
+ idx += 2;
38550
+ continue;
38551
+ }
38552
+ if (token.startsWith("--chdir=")) {
38553
+ const dirArg = token.slice("--chdir=".length).trim();
38554
+ if (dirArg) {
38555
+ effectiveCwd = effectiveCwd ? path5.resolve(workspaceDir, effectiveCwd, dirArg) : dirArg;
38556
+ }
38557
+ idx++;
38558
+ continue;
38559
+ }
38560
+ if (token === "-S" || token === "--split-string" || token.startsWith("-S") || token.startsWith("--split-string=")) {
38561
+ const splitRaw = token === "-S" || token === "--split-string" ? currentArgs[idx + 1] ?? "" : token.startsWith("--split-string=") ? token.slice("--split-string=".length) : token.slice(2);
38562
+ const consumed = token === "-S" || token === "--split-string" ? 2 : 1;
38563
+ try {
38564
+ const parsed = (0, import_shell_quote.parse)(splitRaw);
38565
+ const strTokens = parsed.filter(
38566
+ (t) => typeof t === "string"
38567
+ );
38568
+ if (strTokens.length !== parsed.length) {
38569
+ return {
38570
+ command: "",
38571
+ args: [],
38572
+ cwd: effectiveCwd,
38573
+ wrapperPaths,
38574
+ unsafeSplitString: splitRaw
38575
+ };
38576
+ }
38577
+ currentArgs = [...strTokens, ...currentArgs.slice(idx + consumed)];
38578
+ idx = 0;
38579
+ continue;
38580
+ } catch {
38581
+ return {
38582
+ command: "",
38583
+ args: [],
38584
+ cwd: effectiveCwd,
38585
+ wrapperPaths,
38586
+ unsafeSplitString: splitRaw
38587
+ };
38588
+ }
38589
+ }
38590
+ idx++;
38591
+ continue;
38592
+ }
38593
+ if (token.includes("=") && !token.startsWith("=")) {
38594
+ idx++;
38595
+ continue;
38596
+ }
38597
+ break;
38598
+ }
38599
+ if (idx < currentArgs.length) {
38600
+ currentCmd = currentArgs[idx]?.trim() ?? "";
38601
+ currentArgs = currentArgs.slice(idx + 1);
38602
+ } else {
38603
+ currentCmd = "";
38604
+ currentArgs = [];
38605
+ }
38606
+ }
38607
+ return {
38608
+ command: currentCmd,
38609
+ args: currentArgs,
38610
+ cwd: effectiveCwd,
38611
+ wrapperPaths
38612
+ };
38613
+ }
38614
+ function extractInterpreterScriptArgs(command, args, cwd2, workspaceDir) {
38615
+ if (!args || args.length === 0) {
38616
+ return [];
38617
+ }
38618
+ const baseName = getCommandBaseName(command);
38619
+ if (!baseName || !SCRIPT_INTERPRETERS.has(baseName)) {
38620
+ return [];
38621
+ }
38622
+ const candidates = [];
38623
+ let expectPreloadValue = false;
38624
+ let skipNextValue = false;
38625
+ let prevWasUnknownFlag = false;
38626
+ let sawSubcommand = false;
38627
+ let afterDoubleDash = false;
38628
+ for (const arg of args) {
38629
+ const trimmed = arg.trim();
38630
+ if (!trimmed) continue;
38631
+ if (afterDoubleDash) {
38632
+ if (isPreloadTargetCandidate(trimmed, cwd2, workspaceDir)) {
38633
+ candidates.push(trimmed);
38634
+ }
38635
+ break;
38636
+ }
38637
+ if (expectPreloadValue) {
38638
+ if (isPreloadTargetCandidate(trimmed, cwd2, workspaceDir)) {
38639
+ candidates.push(trimmed);
38640
+ }
38641
+ expectPreloadValue = false;
38642
+ prevWasUnknownFlag = false;
38643
+ continue;
38644
+ }
38645
+ if (skipNextValue) {
38646
+ skipNextValue = false;
38647
+ prevWasUnknownFlag = false;
38648
+ continue;
38649
+ }
38650
+ if (trimmed === "--") {
38651
+ afterDoubleDash = true;
38652
+ prevWasUnknownFlag = false;
38653
+ continue;
38654
+ }
38655
+ if (WINDOWS_SLASH_FLAG_INTERPRETERS.has(baseName) && /^\/(\/)?[a-zA-Z?][a-zA-Z0-9:_-]*$/.test(trimmed)) {
38656
+ prevWasUnknownFlag = false;
38657
+ continue;
38658
+ }
38659
+ if (trimmed.startsWith("-") && trimmed !== "-") {
38660
+ const eqIndex = trimmed.indexOf("=");
38661
+ const rawFlag = eqIndex >= 0 ? trimmed.slice(0, eqIndex) : trimmed;
38662
+ const flagName = rawFlag.length === 2 ? rawFlag : rawFlag.toLowerCase();
38663
+ if (INLINE_EVAL_FLAGS.has(flagName)) {
38664
+ break;
38665
+ }
38666
+ if (PRELOAD_FLAGS.has(flagName)) {
38667
+ if (eqIndex >= 0) {
38668
+ const inlineValue = trimmed.slice(eqIndex + 1).trim();
38669
+ if (inlineValue && isPreloadTargetCandidate(inlineValue, cwd2, workspaceDir)) {
38670
+ candidates.push(inlineValue);
38671
+ }
38672
+ prevWasUnknownFlag = false;
38673
+ } else {
38674
+ expectPreloadValue = true;
38675
+ prevWasUnknownFlag = false;
38676
+ }
38677
+ } else if (eqIndex < 0 && NON_SCRIPT_VALUE_FLAGS.has(flagName)) {
38678
+ skipNextValue = true;
38679
+ prevWasUnknownFlag = false;
38680
+ } else {
38681
+ prevWasUnknownFlag = eqIndex < 0 && !KNOWN_BOOLEAN_FLAGS.has(flagName);
38682
+ }
38683
+ continue;
38684
+ }
38685
+ if (!sawSubcommand && candidates.length === 0 && SUBCOMMAND_INTERPRETERS.has(baseName) && INTERPRETER_SUBCOMMANDS.has(trimmed.toLowerCase())) {
38686
+ sawSubcommand = true;
38687
+ prevWasUnknownFlag = false;
38688
+ continue;
38689
+ }
38690
+ if (isScriptPathCandidate(trimmed, cwd2, workspaceDir)) {
38691
+ candidates.push(trimmed);
38692
+ if (!prevWasUnknownFlag) {
38693
+ break;
38694
+ }
38695
+ }
38696
+ prevWasUnknownFlag = false;
38697
+ }
38698
+ return candidates;
38699
+ }
38700
+ function findInsecureMcpTarget(command, args, cwd2, ctx) {
38701
+ const initialCmd = command?.trim();
38702
+ if (!initialCmd) {
38703
+ return void 0;
38704
+ }
38705
+ const unwrapped = unwrapEnvInvocation(
38706
+ initialCmd,
38707
+ args,
38708
+ cwd2,
38709
+ ctx.workspaceDir
38710
+ );
38711
+ if (unwrapped.unsafeSplitString !== void 0) {
38712
+ return {
38713
+ target: unwrapped.unsafeSplitString,
38714
+ reason: "Unsupported shell operators or malformed env -S string."
38715
+ };
38716
+ }
38717
+ for (const wrapperPath of unwrapped.wrapperPaths) {
38718
+ const resolvedWrapper = resolveMcpCommandPath(
38719
+ wrapperPath,
38720
+ cwd2,
38721
+ ctx.workspaceDir
38722
+ );
38723
+ const wrapperCheck = isFileAndDirectorySecureSync(
38724
+ resolvedWrapper,
38725
+ ctx.securityCache
38726
+ );
38727
+ if (!wrapperCheck.secure) {
38728
+ return {
38729
+ target: wrapperPath,
38730
+ reason: wrapperCheck.reason ?? "Insecure file or directory."
38731
+ };
38732
+ }
38733
+ }
38734
+ if (!unwrapped.command) {
38735
+ return void 0;
38736
+ }
38737
+ const effectiveCwd = unwrapped.cwd;
38738
+ const candidates = [];
38739
+ if (isExplicitCommandPath(unwrapped.command) || path5.extname(unwrapped.command) !== "" && isScriptPathCandidate(unwrapped.command, effectiveCwd, ctx.workspaceDir)) {
38740
+ candidates.push(unwrapped.command);
38741
+ }
38742
+ candidates.push(
38743
+ ...extractInterpreterScriptArgs(
38744
+ unwrapped.command,
38745
+ unwrapped.args,
38746
+ effectiveCwd,
38747
+ ctx.workspaceDir
38748
+ )
38749
+ );
38750
+ for (const target of candidates) {
38751
+ const resolved = resolveMcpCommandPath(
38752
+ target,
38753
+ effectiveCwd,
38754
+ ctx.workspaceDir
38755
+ );
38756
+ for (const candidatePath of expandCandidatePaths(resolved)) {
38757
+ const check = isFileAndDirectorySecureSync(
38758
+ candidatePath,
38759
+ ctx.securityCache
38760
+ );
38761
+ if (!check.secure) {
38762
+ return {
38763
+ target,
38764
+ reason: check.reason ?? "Insecure file or directory."
38765
+ };
38766
+ }
38767
+ }
38768
+ }
38769
+ return void 0;
38770
+ }
38771
+ function sanitizeSystemMcpServerMap(settings, ctx) {
38772
+ const skipped = [];
38773
+ for (const [serverName, serverConfig] of Object.entries(
38774
+ settings.mcpServers ?? {}
38775
+ )) {
38776
+ const insecure = findInsecureMcpTarget(
38777
+ serverConfig.command,
38778
+ serverConfig.args,
38779
+ serverConfig.cwd,
38780
+ ctx
38781
+ );
38782
+ if (!insecure) continue;
38783
+ ctx.settingsErrors.push({
38784
+ message: `Security Warning: Skipping MCP server '${serverName}' in ${ctx.fileLabel} file '${ctx.settingsFilePath}' due to insecure command path '${insecure.target}': ${insecure.reason}`,
38785
+ path: ctx.settingsFilePath,
38786
+ severity: "warning"
38787
+ });
38788
+ delete settings.mcpServers?.[serverName];
38789
+ skipped.push(serverName);
38790
+ }
38791
+ return skipped;
38792
+ }
38793
+ function sanitizeSystemMcpServerCommand(settings, ctx) {
38794
+ if (!settings.mcp?.serverCommand) {
38795
+ return;
38796
+ }
38797
+ let tokens;
38798
+ try {
38799
+ const parsedTokens = (0, import_shell_quote.parse)(settings.mcp.serverCommand);
38800
+ const stringTokens = parsedTokens.filter(
38801
+ (token) => typeof token === "string"
38802
+ );
38803
+ if (stringTokens.length !== parsedTokens.length) {
38804
+ ctx.settingsErrors.push({
38805
+ message: `Security Warning: Skipping mcp.serverCommand in ${ctx.fileLabel} file '${ctx.settingsFilePath}' due to presence of shell operators.`,
38806
+ path: ctx.settingsFilePath,
38807
+ severity: "warning"
38808
+ });
38809
+ delete settings.mcp.serverCommand;
38810
+ return;
38811
+ }
38812
+ tokens = stringTokens;
38813
+ } catch (err) {
38814
+ ctx.settingsErrors.push({
38815
+ message: `Security Warning: Skipping mcp.serverCommand in ${ctx.fileLabel} file '${ctx.settingsFilePath}' due to parse failure: ${getErrorMessage(err)}`,
38816
+ path: ctx.settingsFilePath,
38817
+ severity: "warning"
38818
+ });
38819
+ delete settings.mcp.serverCommand;
38820
+ return;
38821
+ }
38822
+ const insecure = findInsecureMcpTarget(
38823
+ tokens[0],
38824
+ tokens.slice(1),
38825
+ void 0,
38826
+ ctx
38827
+ );
38828
+ if (!insecure) {
38829
+ return;
38830
+ }
38831
+ ctx.settingsErrors.push({
38832
+ message: `Security Warning: Skipping mcp.serverCommand in ${ctx.fileLabel} file '${ctx.settingsFilePath}' due to insecure command path '${insecure.target}': ${insecure.reason}`,
38833
+ path: ctx.settingsFilePath,
38834
+ severity: "warning"
38835
+ });
38836
+ delete settings.mcp.serverCommand;
38837
+ }
38838
+ function stripBlockedMcpServers(settings, blockedIds) {
38839
+ if (blockedIds.size === 0 || !settings.mcpServers) {
38840
+ return;
38841
+ }
38842
+ for (const key of Object.keys(settings.mcpServers)) {
38843
+ if (blockedIds.has(key.toLowerCase().trim())) {
38844
+ delete settings.mcpServers[key];
38845
+ }
38846
+ }
38847
+ }
38848
+ function blockSkippedSystemMcpServers(skippedServers, allScopes, systemSettings) {
38849
+ const blockedIds = new Set(
38850
+ skippedServers.map((name) => name.toLowerCase().trim())
38851
+ );
38852
+ if (blockedIds.size === 0) {
38853
+ return blockedIds;
38854
+ }
38855
+ for (const scopeSettings of allScopes) {
38856
+ stripBlockedMcpServers(scopeSettings, blockedIds);
38857
+ }
38858
+ const existingExcluded = systemSettings.mcp?.excluded ?? [];
38859
+ systemSettings.mcp = {
38860
+ ...systemSettings.mcp,
38861
+ excluded: [.../* @__PURE__ */ new Set([...existingExcluded, ...skippedServers])]
38862
+ };
38863
+ return blockedIds;
38864
+ }
38288
38865
  function _doLoadSettings(workspaceDir) {
38289
38866
  let systemSettings = {};
38290
38867
  let systemDefaultSettings = {};
@@ -38425,6 +39002,31 @@ function _doLoadSettings(workspaceDir) {
38425
39002
  workspaceSettingsPath,
38426
39003
  settingsErrors
38427
39004
  ) : {};
39005
+ const systemCheckCtx = {
39006
+ workspaceDir,
39007
+ settingsFilePath: systemSettingsPath,
39008
+ fileLabel: "system settings",
39009
+ securityCache,
39010
+ settingsErrors
39011
+ };
39012
+ const defaultsCheckCtx = {
39013
+ workspaceDir,
39014
+ settingsFilePath: systemDefaultsPath,
39015
+ fileLabel: "system defaults",
39016
+ securityCache,
39017
+ settingsErrors
39018
+ };
39019
+ const skippedSystemServers = [
39020
+ ...sanitizeSystemMcpServerMap(systemSettings, systemCheckCtx),
39021
+ ...sanitizeSystemMcpServerMap(systemDefaultSettings, defaultsCheckCtx)
39022
+ ];
39023
+ sanitizeSystemMcpServerCommand(systemSettings, systemCheckCtx);
39024
+ sanitizeSystemMcpServerCommand(systemDefaultSettings, defaultsCheckCtx);
39025
+ const blockedSystemMcpServerIds = blockSkippedSystemMcpServers(
39026
+ skippedSystemServers,
39027
+ [systemSettings, systemDefaultSettings, userSettings, workspaceSettings],
39028
+ systemSettings
39029
+ );
38428
39030
  normalizeLegacyTheme(userSettings);
38429
39031
  normalizeLegacyTheme(workspaceSettings);
38430
39032
  const fatalErrors = settingsErrors.filter((e) => e.severity === "error");
@@ -38467,7 +39069,8 @@ Please fix the configuration file(s) and try again.`
38467
39069
  readOnly: storage.isWorkspaceHomeDir()
38468
39070
  },
38469
39071
  isTrusted,
38470
- settingsErrors
39072
+ settingsErrors,
39073
+ blockedSystemMcpServerIds
38471
39074
  );
38472
39075
  migrateDeprecatedSettings(loadedSettings);
38473
39076
  return loadedSettings;