@google/gemini-cli 0.69.0-preview.0 → 0.70.0-preview.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-LYKP3S67.js → chunk-65MRMUKB.js} +625 -22
  2. package/bundle/{chunk-CGQSFR2I.js → chunk-6XLLXGZQ.js} +1 -1
  3. package/bundle/{chunk-U5FJ6OGB.js → chunk-AMGYQYS7.js} +35 -29
  4. package/bundle/{chunk-SYOIMUZI.js → chunk-BCL7DJOQ.js} +1165 -21669
  5. package/bundle/{chunk-6KCLIS6W.js → chunk-BOYVA4SV.js} +1 -1
  6. package/bundle/{chunk-YODS6HR2.js → chunk-CJ7YZ55P.js} +3 -3
  7. package/bundle/{chunk-BRHBBQC5.js → chunk-CMUPNBQQ.js} +35 -29
  8. package/bundle/{chunk-V7L3FMBE.js → chunk-ECLDXLDB.js} +3 -3
  9. package/bundle/{chunk-VQTELFV3.js → chunk-F6P6PQSG.js} +1 -1
  10. package/bundle/{chunk-CWHEOJXF.js → chunk-FDIF7V5C.js} +1 -1
  11. package/bundle/{chunk-UW3ZS3BH.js → chunk-FGTABIOQ.js} +1 -1
  12. package/bundle/{chunk-2ONJU4V7.js → chunk-HBTS2REO.js} +1 -1
  13. package/bundle/{chunk-DWMZSQYG.js → chunk-I5QSCSQU.js} +65559 -51236
  14. package/bundle/{chunk-4SOPZCNA.js → chunk-IS5SQ7HP.js} +625 -22
  15. package/bundle/{chunk-RBDD6IBU.js → chunk-L5UVIFFB.js} +1165 -21669
  16. package/bundle/{chunk-IUUIT4SU.js → chunk-N7J54YNL.js} +1 -0
  17. package/bundle/{chunk-PH5XENTH.js → chunk-NFAJ5FW5.js} +1 -1
  18. package/bundle/{chunk-GQ7FZNO2.js → chunk-NFBC76U4.js} +1 -1
  19. package/bundle/{chunk-KUXCUQKX.js → chunk-O2DXIYZO.js} +65411 -51125
  20. package/bundle/{chunk-C5BED6L6.js → chunk-O5EBPO5F.js} +35 -29
  21. package/bundle/{chunk-2KKDGWF2.js → chunk-RTIGPATB.js} +1 -1
  22. package/bundle/{chunk-JJWPYMIO.js → chunk-RVYQZ73V.js} +3 -3
  23. package/bundle/{chunk-MP4TVGOP.js → chunk-SA2VIQNQ.js} +65559 -51236
  24. package/bundle/{chunk-GDCMMKZ2.js → chunk-STY67ND2.js} +1 -1
  25. package/bundle/{chunk-3HEOCQDN.js → chunk-SXOGAWDG.js} +1 -1
  26. package/bundle/{chunk-UAHZWXSG.js → chunk-T7277DWX.js} +1 -1
  27. package/bundle/{chunk-U3FFDEKY.js → chunk-TX3SX2WI.js} +625 -22
  28. package/bundle/{chunk-664ZODQF.js → chunk-W2AJR23G.js} +137 -58
  29. package/bundle/{chunk-YP5TA33N.js → chunk-ZUQTNDGH.js} +1165 -21669
  30. package/bundle/{cleanup-3T2KXSP4.js → cleanup-44LV7E4R.js} +4 -4
  31. package/bundle/{cleanup-NNQCI4KC.js → cleanup-O4QBMRVU.js} +4 -4
  32. package/bundle/{cleanup-TA4VYDXQ.js → cleanup-WMYSWXJR.js} +4 -4
  33. package/bundle/{core-TUJHM7E7.js → core-DJ7VMWCC.js} +13 -3
  34. package/bundle/{core-6XF5EO7Z.js → core-LJXCBOFM.js} +13 -3
  35. package/bundle/{devtools-TYCPOPV3.js → devtools-WUGMIOCT.js} +1 -1
  36. package/bundle/devtoolsService-D4VCGQMJ.js +919 -0
  37. package/bundle/devtoolsService-EBOCEFTO.js +918 -0
  38. package/bundle/devtoolsService-G4CPAW3U.js +918 -0
  39. package/bundle/{dist-OSQFIX7F.js → dist-QSS2VWMY.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-LJFIC7G3.js → formatError-3QIVJAE5.js} +4 -4
  48. package/bundle/{formatError-MIUNQEYE.js → formatError-I5Q2HGMN.js} +4 -4
  49. package/bundle/{formatError-KEQ3HU3Y.js → formatError-NLKMYJNL.js} +4 -4
  50. package/bundle/{gemini-ZZZEFPSK.js → gemini-4325ARIU.js} +676 -288
  51. package/bundle/{gemini-22ON2CZG.js → gemini-J7ZRUAXR.js} +676 -288
  52. package/bundle/{gemini-HLS52ZNZ.js → gemini-LOYZXP6I.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-5HMWVTK2.js → interactiveCli-AQ67IY7V.js} +36 -18
  60. package/bundle/{interactiveCli-NKFQZXB5.js → interactiveCli-CEIWZCYF.js} +36 -18
  61. package/bundle/{interactiveCli-HQBE3C3C.js → interactiveCli-O2L63RLG.js} +36 -18
  62. package/bundle/{liteRtServerManager-AG4Y5JMZ.js → liteRtServerManager-EZFHT2B3.js} +6 -6
  63. package/bundle/{liteRtServerManager-OFNVXXQ4.js → liteRtServerManager-HMCB6A65.js} +6 -6
  64. package/bundle/{liteRtServerManager-2IOXWO76.js → liteRtServerManager-MH32CAZ5.js} +6 -6
  65. package/bundle/{oauth2-provider-2DHNJ2S3.js → oauth2-provider-3TFNA7VY.js} +3 -3
  66. package/bundle/{oauth2-provider-YDNSNN32.js → oauth2-provider-NPOZQDQO.js} +3 -3
  67. package/bundle/{oauth2-provider-OEGXLWIL.js → oauth2-provider-UXC7XFV6.js} +3 -3
  68. package/bundle/{src-XZYPU6PJ.js → src-MVBNXN6P.js} +3 -3504
  69. package/bundle/{start-JSVKPUTV.js → start-I2GOKFKQ.js} +8 -8
  70. package/bundle/{start-N33LF5WK.js → start-JIKLB3S3.js} +8 -8
  71. package/bundle/{start-7GJH3MKY.js → start-NSYEL7UE.js} +8 -8
  72. package/package.json +1 -1
  73. package/bundle/devtoolsService-7EMPANTX.js +0 -4421
  74. package/bundle/devtoolsService-I7WFRUEA.js +0 -4422
  75. package/bundle/devtoolsService-RCBUZGYD.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-2KKDGWF2.js";
4
+ } from "./chunk-STY67ND2.js";
5
5
  import {
6
6
  AuthProviderType,
7
7
  AuthType,
@@ -33,9 +33,10 @@ import {
33
33
  loadConversationRecord,
34
34
  loadTrustedFolders,
35
35
  partListUnionToString,
36
+ require_shell_quote,
36
37
  require_strip_json_comments,
37
38
  sanitizeFilenamePart
38
- } from "./chunk-MP4TVGOP.js";
39
+ } from "./chunk-I5QSCSQU.js";
39
40
  import {
40
41
  __commonJS,
41
42
  __export,
@@ -9118,7 +9119,7 @@ var require_main = __commonJS({
9118
9119
  return supportsAnsi() ? `\x1B[2m${text}\x1B[0m` : text;
9119
9120
  }
9120
9121
  var LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
9121
- function parse3(src) {
9122
+ function parse4(src) {
9122
9123
  const obj = {};
9123
9124
  let lines = src.toString();
9124
9125
  lines = lines.replace(/\r\n?/mg, "\n");
@@ -9388,7 +9389,7 @@ var require_main = __commonJS({
9388
9389
  _parseVault,
9389
9390
  config,
9390
9391
  decrypt,
9391
- parse: parse3,
9392
+ parse: parse4,
9392
9393
  populate
9393
9394
  };
9394
9395
  module.exports.configDotenv = DotenvModule.configDotenv;
@@ -10722,7 +10723,7 @@ var require_esprima = __commonJS({
10722
10723
  var jsx_parser_1 = __webpack_require__(3);
10723
10724
  var parser_1 = __webpack_require__(8);
10724
10725
  var tokenizer_1 = __webpack_require__(15);
10725
- function parse3(code, options, delegate) {
10726
+ function parse4(code, options, delegate) {
10726
10727
  var commentHandler = null;
10727
10728
  var proxyDelegate = function(node, metadata) {
10728
10729
  if (delegate) {
@@ -10767,17 +10768,17 @@ var require_esprima = __commonJS({
10767
10768
  }
10768
10769
  return ast;
10769
10770
  }
10770
- exports2.parse = parse3;
10771
+ exports2.parse = parse4;
10771
10772
  function parseModule(code, options, delegate) {
10772
10773
  var parsingOptions = options || {};
10773
10774
  parsingOptions.sourceType = "module";
10774
- return parse3(code, parsingOptions, delegate);
10775
+ return parse4(code, parsingOptions, delegate);
10775
10776
  }
10776
10777
  exports2.parseModule = parseModule;
10777
10778
  function parseScript(code, options, delegate) {
10778
10779
  var parsingOptions = options || {};
10779
10780
  parsingOptions.sourceType = "script";
10780
- return parse3(code, parsingOptions, delegate);
10781
+ return parse4(code, parsingOptions, delegate);
10781
10782
  }
10782
10783
  exports2.parseScript = parseScript;
10783
10784
  function tokenize2(code, options, delegate) {
@@ -18285,7 +18286,7 @@ var require_parse = __commonJS({
18285
18286
  }
18286
18287
  }
18287
18288
  var isObject = (subject) => Object(subject) === subject;
18288
- var parse3 = (code, rev, no_comments) => {
18289
+ var parse4 = (code, rev, no_comments) => {
18289
18290
  clean();
18290
18291
  tokens = tokenize2(code);
18291
18292
  reviver = rev;
@@ -18314,7 +18315,7 @@ var require_parse = __commonJS({
18314
18315
  return result;
18315
18316
  };
18316
18317
  module.exports = {
18317
- parse: parse3,
18318
+ parse: parse4,
18318
18319
  tokenize: tokenize2
18319
18320
  };
18320
18321
  }
@@ -18559,12 +18560,12 @@ var require_stringify = __commonJS({
18559
18560
  // node_modules/comment-json/src/index.js
18560
18561
  var require_src2 = __commonJS({
18561
18562
  "node_modules/comment-json/src/index.js"(exports, module) {
18562
- var { parse: parse3, tokenize: tokenize2 } = require_parse();
18563
+ var { parse: parse4, tokenize: tokenize2 } = require_parse();
18563
18564
  var stringify2 = require_stringify();
18564
18565
  var { CommentArray } = require_array();
18565
18566
  var { assign } = require_common();
18566
18567
  module.exports = {
18567
- parse: parse3,
18568
+ parse: parse4,
18568
18569
  stringify: stringify2,
18569
18570
  tokenize: tokenize2,
18570
18571
  CommentArray,
@@ -22845,7 +22846,7 @@ var styles_default = styles3;
22845
22846
  // node_modules/ink/build/reconciler.js
22846
22847
  if (process3.env["DEV"] === "true") {
22847
22848
  try {
22848
- await import("./devtools-TYCPOPV3.js");
22849
+ await import("./devtools-WUGMIOCT.js");
22849
22850
  } catch (error) {
22850
22851
  if (error.code === "ERR_MODULE_NOT_FOUND") {
22851
22852
  console.warn(`
@@ -31413,7 +31414,7 @@ var SessionError = class _SessionError extends Error {
31413
31414
  );
31414
31415
  }
31415
31416
  };
31416
- var cleanMessage = (message) => message.replace(/\n+/g, " ").replace(/\s+/g, " ").replace(/[^\x20-\x7E]+/g, "").trim();
31417
+ var cleanMessage = (message) => stripUnsafeCharacters(message).replace(/\s+/g, " ").trim();
31417
31418
  var extractFirstUserMessage = (messages) => {
31418
31419
  const userMessage = messages.filter((msg) => {
31419
31420
  const content2 = partListUnionToString(msg.content);
@@ -32218,6 +32219,7 @@ import * as fs9 from "node:fs";
32218
32219
  import * as path5 from "node:path";
32219
32220
  import { platform as platform3 } from "node:os";
32220
32221
  import process19 from "node:process";
32222
+ var import_shell_quote = __toESM(require_shell_quote(), 1);
32221
32223
  var import_strip_json_comments = __toESM(require_strip_json_comments(), 1);
32222
32224
 
32223
32225
  // packages/cli/src/ui/themes/theme.ts
@@ -37256,15 +37258,18 @@ function resolveEnvVarsInString(value, customEnv) {
37256
37258
  if (!varName) {
37257
37259
  return match;
37258
37260
  }
37261
+ let val;
37259
37262
  if (customEnv && typeof customEnv[varName] === "string") {
37260
- return customEnv[varName];
37261
- }
37262
- if (process && process.env) {
37263
- const val = process.env[varName];
37264
- if (typeof val === "string") {
37265
- return val;
37263
+ val = customEnv[varName];
37264
+ } else if (process && process.env) {
37265
+ const envVal = process.env[varName];
37266
+ if (typeof envVal === "string") {
37267
+ val = envVal;
37266
37268
  }
37267
37269
  }
37270
+ if (val !== void 0 && (val !== "" || defaultValue === void 0)) {
37271
+ return val;
37272
+ }
37268
37273
  if (defaultValue !== void 0) {
37269
37274
  return defaultValue;
37270
37275
  }
@@ -37885,12 +37890,13 @@ function mergeSettings(system, systemDefaults, user, workspace, isTrusted) {
37885
37890
  }
37886
37891
  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.";
37887
37892
  var LoadedSettings = class {
37888
- constructor(system, systemDefaults, user, workspace, isTrusted, errors = []) {
37893
+ constructor(system, systemDefaults, user, workspace, isTrusted, errors = [], blockedMcpServers = /* @__PURE__ */ new Set()) {
37889
37894
  this.system = system;
37890
37895
  this.systemDefaults = systemDefaults;
37891
37896
  this.user = user;
37892
37897
  this._workspaceFile = workspace;
37893
37898
  this.isTrusted = isTrusted;
37899
+ this._blockedMcpServers = blockedMcpServers;
37894
37900
  this.workspace = isTrusted ? workspace : this.createEmptyWorkspace(workspace);
37895
37901
  this.errors = errors;
37896
37902
  this._merged = this.computeMergedSettings();
@@ -37903,6 +37909,7 @@ var LoadedSettings = class {
37903
37909
  isTrusted;
37904
37910
  errors;
37905
37911
  _workspaceFile;
37912
+ _blockedMcpServers;
37906
37913
  _merged;
37907
37914
  _snapshot;
37908
37915
  _remoteAdminSettings;
@@ -37929,6 +37936,10 @@ var LoadedSettings = class {
37929
37936
  this.errors
37930
37937
  );
37931
37938
  normalizeLegacyTheme(resolvedWorkspaceSettings);
37939
+ stripBlockedMcpServers(
37940
+ resolvedWorkspaceSettings,
37941
+ this._blockedMcpServers
37942
+ );
37932
37943
  this._workspaceFile = {
37933
37944
  ...this._workspaceFile,
37934
37945
  settings: resolvedWorkspaceSettings
@@ -37956,6 +37967,7 @@ var LoadedSettings = class {
37956
37967
  workspaceSettings,
37957
37968
  isTrusted
37958
37969
  );
37970
+ stripBlockedMcpServers(merged, this._blockedMcpServers);
37959
37971
  const adminSettingSchema = getSettingsSchema().admin;
37960
37972
  if (adminSettingSchema?.properties) {
37961
37973
  const adminSchema = adminSettingSchema.properties;
@@ -38283,6 +38295,571 @@ function resolveSettings(rawSettings, filePath, settingsErrors) {
38283
38295
  }
38284
38296
  return validationResult.data ?? expandedSettings;
38285
38297
  }
38298
+ var SCRIPT_INTERPRETERS = /* @__PURE__ */ new Set([
38299
+ "sh",
38300
+ "bash",
38301
+ "zsh",
38302
+ "dash",
38303
+ "ksh",
38304
+ "fish",
38305
+ "csh",
38306
+ "tcsh",
38307
+ "node",
38308
+ "nodejs",
38309
+ "python",
38310
+ "python2",
38311
+ "python3",
38312
+ "py",
38313
+ "ruby",
38314
+ "perl",
38315
+ "php",
38316
+ "lua",
38317
+ "rscript",
38318
+ "pwsh",
38319
+ "powershell",
38320
+ "deno",
38321
+ "bun",
38322
+ "tsx",
38323
+ "ts-node",
38324
+ "ts-node-esm",
38325
+ "cmd",
38326
+ "osascript",
38327
+ "cscript",
38328
+ "wscript"
38329
+ ]);
38330
+ var WINDOWS_SLASH_FLAG_INTERPRETERS = /* @__PURE__ */ new Set(["cmd", "cscript", "wscript"]);
38331
+ var INLINE_EVAL_FLAGS = /* @__PURE__ */ new Set([
38332
+ "-c",
38333
+ "-e",
38334
+ "-E",
38335
+ "--eval",
38336
+ "-p",
38337
+ "--print",
38338
+ "-command",
38339
+ "-encodedcommand"
38340
+ ]);
38341
+ var PRELOAD_FLAGS = /* @__PURE__ */ new Set([
38342
+ "-r",
38343
+ "--require",
38344
+ "--import",
38345
+ "--loader",
38346
+ "--experimental-loader",
38347
+ "--preload",
38348
+ "--env-file",
38349
+ "--env-file-if-exists",
38350
+ "-f",
38351
+ "-file"
38352
+ ]);
38353
+ var SCRIPT_EXTENSIONS = /* @__PURE__ */ new Set([
38354
+ ".js",
38355
+ ".mjs",
38356
+ ".cjs",
38357
+ ".jsx",
38358
+ ".node",
38359
+ ".ts",
38360
+ ".mts",
38361
+ ".cts",
38362
+ ".tsx",
38363
+ ".py",
38364
+ ".pyw",
38365
+ ".py3",
38366
+ ".pyz",
38367
+ ".sh",
38368
+ ".bash",
38369
+ ".zsh",
38370
+ ".ksh",
38371
+ ".fish",
38372
+ ".csh",
38373
+ ".pl",
38374
+ ".pm",
38375
+ ".rb",
38376
+ ".php",
38377
+ ".phar",
38378
+ ".lua",
38379
+ ".r",
38380
+ ".ps1",
38381
+ ".psm1",
38382
+ ".cmd",
38383
+ ".bat",
38384
+ ".vbs",
38385
+ ".vbe",
38386
+ ".jse",
38387
+ ".wsf",
38388
+ ".wsh",
38389
+ ".scpt",
38390
+ ".scptd",
38391
+ ".applescript"
38392
+ ]);
38393
+ var NON_SCRIPT_VALUE_FLAGS = /* @__PURE__ */ new Set([
38394
+ "-W",
38395
+ "-m",
38396
+ "-I",
38397
+ "-M",
38398
+ "-K",
38399
+ "-F",
38400
+ "-C",
38401
+ "-P",
38402
+ "--project",
38403
+ "--config",
38404
+ "--log-file",
38405
+ "--max-old-space-size",
38406
+ "--inspect-port",
38407
+ "--debug-port",
38408
+ "--conditions",
38409
+ "--input-type",
38410
+ "--title",
38411
+ "-executionpolicy"
38412
+ ]);
38413
+ var KNOWN_BOOLEAN_FLAGS = /* @__PURE__ */ new Set([
38414
+ "-x",
38415
+ "-v",
38416
+ "-n",
38417
+ "-u",
38418
+ "-w",
38419
+ "-d",
38420
+ "-O",
38421
+ "-B",
38422
+ "-s",
38423
+ "-S",
38424
+ "-i",
38425
+ "-t",
38426
+ "--watch",
38427
+ "--no-warnings",
38428
+ "--trace-warnings",
38429
+ "--inspect",
38430
+ "--inspect-brk",
38431
+ "--enable-source-maps",
38432
+ "--preserve-symlinks",
38433
+ "--no-deprecation",
38434
+ "--throw-deprecation",
38435
+ "-noprofile",
38436
+ "-noninteractive",
38437
+ "-sta",
38438
+ "-mta"
38439
+ ]);
38440
+ var SUBCOMMAND_INTERPRETERS = /* @__PURE__ */ new Set(["deno", "bun"]);
38441
+ var INTERPRETER_SUBCOMMANDS = /* @__PURE__ */ new Set(["run", "x", "serve", "test", "bench"]);
38442
+ var IMPLICIT_SCRIPT_EXTENSIONS = [
38443
+ ".js",
38444
+ ".mjs",
38445
+ ".cjs",
38446
+ ".ts",
38447
+ ".mts",
38448
+ ".cts",
38449
+ ".py",
38450
+ ".ps1"
38451
+ ];
38452
+ function getCommandBaseName(command) {
38453
+ return command.split(/[\\/]/).pop()?.toLowerCase().replace(/\.(exe|cmd|bat)$/, "");
38454
+ }
38455
+ function isExplicitCommandPath(command) {
38456
+ return path5.isAbsolute(command) || command.includes("/") || command.includes("\\");
38457
+ }
38458
+ function resolveMcpCommandPath(command, cwd2, workspaceDir) {
38459
+ if (path5.isAbsolute(command) || /^[a-zA-Z]:[\\/]/.test(command)) {
38460
+ return command;
38461
+ }
38462
+ const baseDir = cwd2 ? path5.resolve(workspaceDir, cwd2) : workspaceDir;
38463
+ return path5.resolve(baseDir, command);
38464
+ }
38465
+ function hasExistingScriptOnDisk(resolvedPath) {
38466
+ try {
38467
+ if (fs9.existsSync(resolvedPath)) {
38468
+ return true;
38469
+ }
38470
+ for (const ext of IMPLICIT_SCRIPT_EXTENSIONS) {
38471
+ if (fs9.existsSync(`${resolvedPath}${ext}`)) {
38472
+ return true;
38473
+ }
38474
+ }
38475
+ return false;
38476
+ } catch {
38477
+ return true;
38478
+ }
38479
+ }
38480
+ function isScriptPathCandidate(token, cwd2, workspaceDir) {
38481
+ if (/^\d+$/.test(token)) {
38482
+ return false;
38483
+ }
38484
+ const ext = path5.extname(token).toLowerCase();
38485
+ if (ext !== "") {
38486
+ return SCRIPT_EXTENSIONS.has(ext);
38487
+ }
38488
+ if (isExplicitCommandPath(token)) {
38489
+ return true;
38490
+ }
38491
+ return hasExistingScriptOnDisk(
38492
+ resolveMcpCommandPath(token, cwd2, workspaceDir)
38493
+ );
38494
+ }
38495
+ function isPreloadTargetCandidate(token, cwd2, workspaceDir) {
38496
+ return isExplicitCommandPath(token) || isScriptPathCandidate(token, cwd2, workspaceDir);
38497
+ }
38498
+ function expandCandidatePaths(resolvedPath) {
38499
+ const paths = [resolvedPath];
38500
+ if (path5.extname(resolvedPath) !== "") {
38501
+ return paths;
38502
+ }
38503
+ for (const ext of IMPLICIT_SCRIPT_EXTENSIONS) {
38504
+ const withExt = `${resolvedPath}${ext}`;
38505
+ try {
38506
+ if (fs9.existsSync(withExt)) {
38507
+ paths.push(withExt);
38508
+ }
38509
+ } catch {
38510
+ paths.push(withExt);
38511
+ }
38512
+ }
38513
+ return paths;
38514
+ }
38515
+ function unwrapEnvInvocation(command, args, cwd2, workspaceDir) {
38516
+ let currentCmd = command.trim();
38517
+ let currentArgs = [...args ?? []];
38518
+ let effectiveCwd = cwd2;
38519
+ const wrapperPaths = [];
38520
+ while (currentCmd && getCommandBaseName(currentCmd) === "env") {
38521
+ if (isExplicitCommandPath(currentCmd)) {
38522
+ wrapperPaths.push(currentCmd);
38523
+ }
38524
+ let idx = 0;
38525
+ let stopEnvOptions = false;
38526
+ while (idx < currentArgs.length) {
38527
+ const token = currentArgs[idx]?.trim() ?? "";
38528
+ if (!token) {
38529
+ idx++;
38530
+ continue;
38531
+ }
38532
+ if (!stopEnvOptions && token === "--") {
38533
+ stopEnvOptions = true;
38534
+ idx++;
38535
+ continue;
38536
+ }
38537
+ if (!stopEnvOptions && token.startsWith("-") && token !== "-") {
38538
+ if (token === "-u" || token === "--unset") {
38539
+ idx += 2;
38540
+ continue;
38541
+ }
38542
+ if (token === "-C" || token === "--chdir") {
38543
+ const dirArg = currentArgs[idx + 1]?.trim();
38544
+ if (dirArg) {
38545
+ effectiveCwd = effectiveCwd ? path5.resolve(workspaceDir, effectiveCwd, dirArg) : dirArg;
38546
+ }
38547
+ idx += 2;
38548
+ continue;
38549
+ }
38550
+ if (token.startsWith("--chdir=")) {
38551
+ const dirArg = token.slice("--chdir=".length).trim();
38552
+ if (dirArg) {
38553
+ effectiveCwd = effectiveCwd ? path5.resolve(workspaceDir, effectiveCwd, dirArg) : dirArg;
38554
+ }
38555
+ idx++;
38556
+ continue;
38557
+ }
38558
+ if (token === "-S" || token === "--split-string" || token.startsWith("-S") || token.startsWith("--split-string=")) {
38559
+ const splitRaw = token === "-S" || token === "--split-string" ? currentArgs[idx + 1] ?? "" : token.startsWith("--split-string=") ? token.slice("--split-string=".length) : token.slice(2);
38560
+ const consumed = token === "-S" || token === "--split-string" ? 2 : 1;
38561
+ try {
38562
+ const parsed = (0, import_shell_quote.parse)(splitRaw);
38563
+ const strTokens = parsed.filter(
38564
+ (t) => typeof t === "string"
38565
+ );
38566
+ if (strTokens.length !== parsed.length) {
38567
+ return {
38568
+ command: "",
38569
+ args: [],
38570
+ cwd: effectiveCwd,
38571
+ wrapperPaths,
38572
+ unsafeSplitString: splitRaw
38573
+ };
38574
+ }
38575
+ currentArgs = [...strTokens, ...currentArgs.slice(idx + consumed)];
38576
+ idx = 0;
38577
+ continue;
38578
+ } catch {
38579
+ return {
38580
+ command: "",
38581
+ args: [],
38582
+ cwd: effectiveCwd,
38583
+ wrapperPaths,
38584
+ unsafeSplitString: splitRaw
38585
+ };
38586
+ }
38587
+ }
38588
+ idx++;
38589
+ continue;
38590
+ }
38591
+ if (token.includes("=") && !token.startsWith("=")) {
38592
+ idx++;
38593
+ continue;
38594
+ }
38595
+ break;
38596
+ }
38597
+ if (idx < currentArgs.length) {
38598
+ currentCmd = currentArgs[idx]?.trim() ?? "";
38599
+ currentArgs = currentArgs.slice(idx + 1);
38600
+ } else {
38601
+ currentCmd = "";
38602
+ currentArgs = [];
38603
+ }
38604
+ }
38605
+ return {
38606
+ command: currentCmd,
38607
+ args: currentArgs,
38608
+ cwd: effectiveCwd,
38609
+ wrapperPaths
38610
+ };
38611
+ }
38612
+ function extractInterpreterScriptArgs(command, args, cwd2, workspaceDir) {
38613
+ if (!args || args.length === 0) {
38614
+ return [];
38615
+ }
38616
+ const baseName = getCommandBaseName(command);
38617
+ if (!baseName || !SCRIPT_INTERPRETERS.has(baseName)) {
38618
+ return [];
38619
+ }
38620
+ const candidates = [];
38621
+ let expectPreloadValue = false;
38622
+ let skipNextValue = false;
38623
+ let prevWasUnknownFlag = false;
38624
+ let sawSubcommand = false;
38625
+ let afterDoubleDash = false;
38626
+ for (const arg of args) {
38627
+ const trimmed = arg.trim();
38628
+ if (!trimmed) continue;
38629
+ if (afterDoubleDash) {
38630
+ if (isPreloadTargetCandidate(trimmed, cwd2, workspaceDir)) {
38631
+ candidates.push(trimmed);
38632
+ }
38633
+ break;
38634
+ }
38635
+ if (expectPreloadValue) {
38636
+ if (isPreloadTargetCandidate(trimmed, cwd2, workspaceDir)) {
38637
+ candidates.push(trimmed);
38638
+ }
38639
+ expectPreloadValue = false;
38640
+ prevWasUnknownFlag = false;
38641
+ continue;
38642
+ }
38643
+ if (skipNextValue) {
38644
+ skipNextValue = false;
38645
+ prevWasUnknownFlag = false;
38646
+ continue;
38647
+ }
38648
+ if (trimmed === "--") {
38649
+ afterDoubleDash = true;
38650
+ prevWasUnknownFlag = false;
38651
+ continue;
38652
+ }
38653
+ if (WINDOWS_SLASH_FLAG_INTERPRETERS.has(baseName) && /^\/(\/)?[a-zA-Z?][a-zA-Z0-9:_-]*$/.test(trimmed)) {
38654
+ prevWasUnknownFlag = false;
38655
+ continue;
38656
+ }
38657
+ if (trimmed.startsWith("-") && trimmed !== "-") {
38658
+ const eqIndex = trimmed.indexOf("=");
38659
+ const rawFlag = eqIndex >= 0 ? trimmed.slice(0, eqIndex) : trimmed;
38660
+ const flagName = rawFlag.length === 2 ? rawFlag : rawFlag.toLowerCase();
38661
+ if (INLINE_EVAL_FLAGS.has(flagName)) {
38662
+ break;
38663
+ }
38664
+ if (PRELOAD_FLAGS.has(flagName)) {
38665
+ if (eqIndex >= 0) {
38666
+ const inlineValue = trimmed.slice(eqIndex + 1).trim();
38667
+ if (inlineValue && isPreloadTargetCandidate(inlineValue, cwd2, workspaceDir)) {
38668
+ candidates.push(inlineValue);
38669
+ }
38670
+ prevWasUnknownFlag = false;
38671
+ } else {
38672
+ expectPreloadValue = true;
38673
+ prevWasUnknownFlag = false;
38674
+ }
38675
+ } else if (eqIndex < 0 && NON_SCRIPT_VALUE_FLAGS.has(flagName)) {
38676
+ skipNextValue = true;
38677
+ prevWasUnknownFlag = false;
38678
+ } else {
38679
+ prevWasUnknownFlag = eqIndex < 0 && !KNOWN_BOOLEAN_FLAGS.has(flagName);
38680
+ }
38681
+ continue;
38682
+ }
38683
+ if (!sawSubcommand && candidates.length === 0 && SUBCOMMAND_INTERPRETERS.has(baseName) && INTERPRETER_SUBCOMMANDS.has(trimmed.toLowerCase())) {
38684
+ sawSubcommand = true;
38685
+ prevWasUnknownFlag = false;
38686
+ continue;
38687
+ }
38688
+ if (isScriptPathCandidate(trimmed, cwd2, workspaceDir)) {
38689
+ candidates.push(trimmed);
38690
+ if (!prevWasUnknownFlag) {
38691
+ break;
38692
+ }
38693
+ }
38694
+ prevWasUnknownFlag = false;
38695
+ }
38696
+ return candidates;
38697
+ }
38698
+ function findInsecureMcpTarget(command, args, cwd2, ctx) {
38699
+ const initialCmd = command?.trim();
38700
+ if (!initialCmd) {
38701
+ return void 0;
38702
+ }
38703
+ const unwrapped = unwrapEnvInvocation(
38704
+ initialCmd,
38705
+ args,
38706
+ cwd2,
38707
+ ctx.workspaceDir
38708
+ );
38709
+ if (unwrapped.unsafeSplitString !== void 0) {
38710
+ return {
38711
+ target: unwrapped.unsafeSplitString,
38712
+ reason: "Unsupported shell operators or malformed env -S string."
38713
+ };
38714
+ }
38715
+ for (const wrapperPath of unwrapped.wrapperPaths) {
38716
+ const resolvedWrapper = resolveMcpCommandPath(
38717
+ wrapperPath,
38718
+ cwd2,
38719
+ ctx.workspaceDir
38720
+ );
38721
+ const wrapperCheck = isFileAndDirectorySecureSync(
38722
+ resolvedWrapper,
38723
+ ctx.securityCache
38724
+ );
38725
+ if (!wrapperCheck.secure) {
38726
+ return {
38727
+ target: wrapperPath,
38728
+ reason: wrapperCheck.reason ?? "Insecure file or directory."
38729
+ };
38730
+ }
38731
+ }
38732
+ if (!unwrapped.command) {
38733
+ return void 0;
38734
+ }
38735
+ const effectiveCwd = unwrapped.cwd;
38736
+ const candidates = [];
38737
+ if (isExplicitCommandPath(unwrapped.command) || path5.extname(unwrapped.command) !== "" && isScriptPathCandidate(unwrapped.command, effectiveCwd, ctx.workspaceDir)) {
38738
+ candidates.push(unwrapped.command);
38739
+ }
38740
+ candidates.push(
38741
+ ...extractInterpreterScriptArgs(
38742
+ unwrapped.command,
38743
+ unwrapped.args,
38744
+ effectiveCwd,
38745
+ ctx.workspaceDir
38746
+ )
38747
+ );
38748
+ for (const target of candidates) {
38749
+ const resolved = resolveMcpCommandPath(
38750
+ target,
38751
+ effectiveCwd,
38752
+ ctx.workspaceDir
38753
+ );
38754
+ for (const candidatePath of expandCandidatePaths(resolved)) {
38755
+ const check = isFileAndDirectorySecureSync(
38756
+ candidatePath,
38757
+ ctx.securityCache
38758
+ );
38759
+ if (!check.secure) {
38760
+ return {
38761
+ target,
38762
+ reason: check.reason ?? "Insecure file or directory."
38763
+ };
38764
+ }
38765
+ }
38766
+ }
38767
+ return void 0;
38768
+ }
38769
+ function sanitizeSystemMcpServerMap(settings, ctx) {
38770
+ const skipped = [];
38771
+ for (const [serverName, serverConfig] of Object.entries(
38772
+ settings.mcpServers ?? {}
38773
+ )) {
38774
+ const insecure = findInsecureMcpTarget(
38775
+ serverConfig.command,
38776
+ serverConfig.args,
38777
+ serverConfig.cwd,
38778
+ ctx
38779
+ );
38780
+ if (!insecure) continue;
38781
+ ctx.settingsErrors.push({
38782
+ message: `Security Warning: Skipping MCP server '${serverName}' in ${ctx.fileLabel} file '${ctx.settingsFilePath}' due to insecure command path '${insecure.target}': ${insecure.reason}`,
38783
+ path: ctx.settingsFilePath,
38784
+ severity: "warning"
38785
+ });
38786
+ delete settings.mcpServers?.[serverName];
38787
+ skipped.push(serverName);
38788
+ }
38789
+ return skipped;
38790
+ }
38791
+ function sanitizeSystemMcpServerCommand(settings, ctx) {
38792
+ if (!settings.mcp?.serverCommand) {
38793
+ return;
38794
+ }
38795
+ let tokens;
38796
+ try {
38797
+ const parsedTokens = (0, import_shell_quote.parse)(settings.mcp.serverCommand);
38798
+ const stringTokens = parsedTokens.filter(
38799
+ (token) => typeof token === "string"
38800
+ );
38801
+ if (stringTokens.length !== parsedTokens.length) {
38802
+ ctx.settingsErrors.push({
38803
+ message: `Security Warning: Skipping mcp.serverCommand in ${ctx.fileLabel} file '${ctx.settingsFilePath}' due to presence of shell operators.`,
38804
+ path: ctx.settingsFilePath,
38805
+ severity: "warning"
38806
+ });
38807
+ delete settings.mcp.serverCommand;
38808
+ return;
38809
+ }
38810
+ tokens = stringTokens;
38811
+ } catch (err) {
38812
+ ctx.settingsErrors.push({
38813
+ message: `Security Warning: Skipping mcp.serverCommand in ${ctx.fileLabel} file '${ctx.settingsFilePath}' due to parse failure: ${getErrorMessage(err)}`,
38814
+ path: ctx.settingsFilePath,
38815
+ severity: "warning"
38816
+ });
38817
+ delete settings.mcp.serverCommand;
38818
+ return;
38819
+ }
38820
+ const insecure = findInsecureMcpTarget(
38821
+ tokens[0],
38822
+ tokens.slice(1),
38823
+ void 0,
38824
+ ctx
38825
+ );
38826
+ if (!insecure) {
38827
+ return;
38828
+ }
38829
+ ctx.settingsErrors.push({
38830
+ message: `Security Warning: Skipping mcp.serverCommand in ${ctx.fileLabel} file '${ctx.settingsFilePath}' due to insecure command path '${insecure.target}': ${insecure.reason}`,
38831
+ path: ctx.settingsFilePath,
38832
+ severity: "warning"
38833
+ });
38834
+ delete settings.mcp.serverCommand;
38835
+ }
38836
+ function stripBlockedMcpServers(settings, blockedIds) {
38837
+ if (blockedIds.size === 0 || !settings.mcpServers) {
38838
+ return;
38839
+ }
38840
+ for (const key of Object.keys(settings.mcpServers)) {
38841
+ if (blockedIds.has(key.toLowerCase().trim())) {
38842
+ delete settings.mcpServers[key];
38843
+ }
38844
+ }
38845
+ }
38846
+ function blockSkippedSystemMcpServers(skippedServers, allScopes, systemSettings) {
38847
+ const blockedIds = new Set(
38848
+ skippedServers.map((name) => name.toLowerCase().trim())
38849
+ );
38850
+ if (blockedIds.size === 0) {
38851
+ return blockedIds;
38852
+ }
38853
+ for (const scopeSettings of allScopes) {
38854
+ stripBlockedMcpServers(scopeSettings, blockedIds);
38855
+ }
38856
+ const existingExcluded = systemSettings.mcp?.excluded ?? [];
38857
+ systemSettings.mcp = {
38858
+ ...systemSettings.mcp,
38859
+ excluded: [.../* @__PURE__ */ new Set([...existingExcluded, ...skippedServers])]
38860
+ };
38861
+ return blockedIds;
38862
+ }
38286
38863
  function _doLoadSettings(workspaceDir) {
38287
38864
  let systemSettings = {};
38288
38865
  let systemDefaultSettings = {};
@@ -38423,6 +39000,31 @@ function _doLoadSettings(workspaceDir) {
38423
39000
  workspaceSettingsPath,
38424
39001
  settingsErrors
38425
39002
  ) : {};
39003
+ const systemCheckCtx = {
39004
+ workspaceDir,
39005
+ settingsFilePath: systemSettingsPath,
39006
+ fileLabel: "system settings",
39007
+ securityCache,
39008
+ settingsErrors
39009
+ };
39010
+ const defaultsCheckCtx = {
39011
+ workspaceDir,
39012
+ settingsFilePath: systemDefaultsPath,
39013
+ fileLabel: "system defaults",
39014
+ securityCache,
39015
+ settingsErrors
39016
+ };
39017
+ const skippedSystemServers = [
39018
+ ...sanitizeSystemMcpServerMap(systemSettings, systemCheckCtx),
39019
+ ...sanitizeSystemMcpServerMap(systemDefaultSettings, defaultsCheckCtx)
39020
+ ];
39021
+ sanitizeSystemMcpServerCommand(systemSettings, systemCheckCtx);
39022
+ sanitizeSystemMcpServerCommand(systemDefaultSettings, defaultsCheckCtx);
39023
+ const blockedSystemMcpServerIds = blockSkippedSystemMcpServers(
39024
+ skippedSystemServers,
39025
+ [systemSettings, systemDefaultSettings, userSettings, workspaceSettings],
39026
+ systemSettings
39027
+ );
38426
39028
  normalizeLegacyTheme(userSettings);
38427
39029
  normalizeLegacyTheme(workspaceSettings);
38428
39030
  const fatalErrors = settingsErrors.filter((e) => e.severity === "error");
@@ -38465,7 +39067,8 @@ Please fix the configuration file(s) and try again.`
38465
39067
  readOnly: storage.isWorkspaceHomeDir()
38466
39068
  },
38467
39069
  isTrusted,
38468
- settingsErrors
39070
+ settingsErrors,
39071
+ blockedSystemMcpServerIds
38469
39072
  );
38470
39073
  migrateDeprecatedSettings(loadedSettings);
38471
39074
  return loadedSettings;