@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
@@ -2,10 +2,10 @@ const require = (await import('node:module')).createRequire(import.meta.url); co
2
2
  import {
3
3
  startCommand,
4
4
  startServer
5
- } from "./chunk-E2O7673V.js";
5
+ } from "./chunk-CB37EK5Y.js";
6
6
  import {
7
7
  formatCliError
8
- } from "./chunk-6MSIVBAV.js";
8
+ } from "./chunk-SPAMAY26.js";
9
9
  import {
10
10
  BuiltinCommandLoader,
11
11
  CommandService,
@@ -14,6 +14,7 @@ import {
14
14
  ExtensionManager,
15
15
  FileCommandLoader,
16
16
  INSTALL_WARNING_MESSAGE,
17
+ LINK_WARNING_MESSAGE,
17
18
  McpPromptLoader,
18
19
  McpServerEnablementManager,
19
20
  canLoadServer,
@@ -48,11 +49,11 @@ import {
48
49
  updateExtension,
49
50
  validateAuthMethod,
50
51
  validateContextFilePath
51
- } from "./chunk-BBQ3J3KD.js";
52
+ } from "./chunk-AMHNNZY2.js";
52
53
  import {
53
54
  exitCli,
54
55
  require_source
55
- } from "./chunk-2NIO2MYP.js";
56
+ } from "./chunk-KV6XIC2Z.js";
56
57
  import {
57
58
  appEvents
58
59
  } from "./chunk-5PS3AYFU.js";
@@ -92,12 +93,13 @@ import {
92
93
  saveModelChange,
93
94
  setAmbiguousCharactersWide,
94
95
  stripAnsi
95
- } from "./chunk-L7UQY2JQ.js";
96
+ } from "./chunk-YOEWNBDC.js";
96
97
  import {
97
98
  RELAUNCH_EXIT_CODE,
99
+ isIPCAvailable,
98
100
  require_semver
99
- } from "./chunk-MJHJIOO6.js";
100
- import "./chunk-4ICD47UK.js";
101
+ } from "./chunk-VHXUWMGE.js";
102
+ import "./chunk-RFQXG324.js";
101
103
  import {
102
104
  cleanupCheckpoints,
103
105
  registerCleanup,
@@ -106,7 +108,7 @@ import {
106
108
  runExitCleanup,
107
109
  runSyncCleanup,
108
110
  setupSignalHandlers
109
- } from "./chunk-66UT6FAS.js";
111
+ } from "./chunk-EG2BSKPF.js";
110
112
  import {
111
113
  ASK_USER_TOOL_NAME,
112
114
  AjvJsonSchemaValidator,
@@ -116,6 +118,8 @@ import {
116
118
  Client,
117
119
  Config,
118
120
  CreateMessageResultSchema,
121
+ CreateMessageResultWithToolsSchema,
122
+ CreateTaskResultSchema,
119
123
  DEFAULT_CONTEXT_FILENAME,
120
124
  DEFAULT_FILE_FILTERING_OPTIONS,
121
125
  DEFAULT_GEMINI_EMBEDDING_MODEL,
@@ -194,6 +198,8 @@ import {
194
198
  ValidationRequiredError,
195
199
  applyAdminAllowlist,
196
200
  applyRequiredServers,
201
+ assertClientRequestTaskCapability,
202
+ assertToolsCallTaskCapability,
197
203
  clearCachedCredentialFile,
198
204
  convertSessionToClientHistory,
199
205
  convertToFunctionResponse,
@@ -226,7 +232,9 @@ import {
226
232
  getErrorStatus,
227
233
  getErrorType,
228
234
  getIdeProcessInfo,
235
+ getLiteralValue,
229
236
  getOauthClient,
237
+ getObjectShape,
230
238
  getPackageJson,
231
239
  getPortFromEnv,
232
240
  getProjectHash,
@@ -254,6 +262,7 @@ import {
254
262
  logUserPrompt,
255
263
  mergeCapabilities,
256
264
  normalizeError,
265
+ outputTokenLimit,
257
266
  parseAndFormatApiError,
258
267
  partListUnionToString,
259
268
  patchStdio,
@@ -270,6 +279,7 @@ import {
270
279
  resolveAtCommandPath,
271
280
  resolveTelemetrySettings,
272
281
  resolveToRealPath,
282
+ safeParse,
273
283
  serializeMessage,
274
284
  setGeminiMdFilename,
275
285
  shouldEnterAlternateScreen,
@@ -280,9 +290,9 @@ import {
280
290
  updatePolicy,
281
291
  writeToStderr,
282
292
  writeToStdout
283
- } from "./chunk-TPD3RZ2B.js";
284
- import "./chunk-664ZODQF.js";
285
- import "./chunk-IUUIT4SU.js";
293
+ } from "./chunk-LMBUPWFC.js";
294
+ import "./chunk-W2AJR23G.js";
295
+ import "./chunk-N7J54YNL.js";
286
296
  import "./chunk-L6PII3GR.js";
287
297
  import {
288
298
  __require,
@@ -1565,11 +1575,11 @@ var parser = new YargsParser({
1565
1575
  resolve: resolve2,
1566
1576
  // TODO: figure out a way to combine ESM and CJS coverage, such that
1567
1577
  // we can exercise all the lines below:
1568
- require: (path19) => {
1578
+ require: (path20) => {
1569
1579
  if (typeof __require !== "undefined") {
1570
- return __require(path19);
1571
- } else if (path19.match(/\.json$/)) {
1572
- return JSON.parse(readFileSync(path19, "utf8"));
1580
+ return __require(path20);
1581
+ } else if (path20.match(/\.json$/)) {
1582
+ return JSON.parse(readFileSync(path20, "utf8"));
1573
1583
  } else {
1574
1584
  throw Error("only .json config files are supported in ESM");
1575
1585
  }
@@ -4094,12 +4104,12 @@ var YargsInstance = class {
4094
4104
  async getCompletion(args, done) {
4095
4105
  argsert("<array> [function]", [args, done], arguments.length);
4096
4106
  if (!done) {
4097
- return new Promise((resolve10, reject) => {
4107
+ return new Promise((resolve11, reject) => {
4098
4108
  __classPrivateFieldGet(this, _YargsInstance_completion, "f").getCompletion(args, (err, completions) => {
4099
4109
  if (err)
4100
4110
  reject(err);
4101
4111
  else
4102
- resolve10(completions);
4112
+ resolve11(completions);
4103
4113
  });
4104
4114
  });
4105
4115
  } else {
@@ -5140,7 +5150,7 @@ var yargs_default = Yargs;
5140
5150
 
5141
5151
  // packages/cli/src/config/config.ts
5142
5152
  import process3 from "node:process";
5143
- import * as path7 from "node:path";
5153
+ import * as path8 from "node:path";
5144
5154
 
5145
5155
  // packages/cli/src/commands/mcp/add.ts
5146
5156
  async function addMcpServer(name, commandOrUrl, args, options) {
@@ -6314,18 +6324,34 @@ var enableCommand2 = {
6314
6324
 
6315
6325
  // packages/cli/src/commands/extensions/link.ts
6316
6326
  var import_chalk3 = __toESM(require_source(), 1);
6327
+ import * as fs from "node:fs";
6328
+ import * as path2 from "node:path";
6317
6329
  async function handleLink(args) {
6318
6330
  try {
6331
+ const trimmedPath = args.path.trim();
6332
+ if (!trimmedPath) {
6333
+ throw new Error("Extension path cannot be empty.");
6334
+ }
6335
+ const workspaceDir = process.cwd();
6336
+ const canonicalPath = fs.realpathSync(
6337
+ path2.resolve(workspaceDir, trimmedPath)
6338
+ );
6319
6339
  const installMetadata = {
6320
- source: args.path,
6340
+ source: canonicalPath,
6321
6341
  type: "link"
6322
6342
  };
6323
- const requestConsent = args.consent ? () => Promise.resolve(true) : requestConsentNonInteractive;
6343
+ const requestConsent = args.consent ? () => Promise.resolve(true) : async (consentDescription) => {
6344
+ if (!process.stdin.isTTY) {
6345
+ debugLogger.log(consentDescription);
6346
+ return false;
6347
+ }
6348
+ return requestConsentNonInteractive(consentDescription);
6349
+ };
6324
6350
  if (args.consent) {
6325
6351
  debugLogger.log("You have consented to the following:");
6352
+ debugLogger.log(LINK_WARNING_MESSAGE);
6326
6353
  debugLogger.log(INSTALL_WARNING_MESSAGE);
6327
6354
  }
6328
- const workspaceDir = process.cwd();
6329
6355
  const extensionManager = new ExtensionManager({
6330
6356
  workspaceDir,
6331
6357
  requestConsent,
@@ -6373,27 +6399,27 @@ import { fileURLToPath as fileURLToPath2 } from "node:url";
6373
6399
  var __filename = fileURLToPath2(import.meta.url);
6374
6400
  var __dirname2 = dirname3(__filename);
6375
6401
  var EXAMPLES_PATH = join(__dirname2, "examples");
6376
- async function pathExists(path19) {
6402
+ async function pathExists(path20) {
6377
6403
  try {
6378
- await access(path19);
6404
+ await access(path20);
6379
6405
  return true;
6380
6406
  } catch {
6381
6407
  return false;
6382
6408
  }
6383
6409
  }
6384
- async function createDirectory(path19) {
6385
- if (await pathExists(path19)) {
6386
- throw new Error(`Path already exists: ${path19}`);
6410
+ async function createDirectory(path20) {
6411
+ if (await pathExists(path20)) {
6412
+ throw new Error(`Path already exists: ${path20}`);
6387
6413
  }
6388
- await mkdir(path19, { recursive: true });
6414
+ await mkdir(path20, { recursive: true });
6389
6415
  }
6390
- async function copyDirectory(template, path19) {
6391
- await createDirectory(path19);
6416
+ async function copyDirectory(template, path20) {
6417
+ await createDirectory(path20);
6392
6418
  const examplePath = join(EXAMPLES_PATH, template);
6393
6419
  const entries = await readdir(examplePath, { withFileTypes: true });
6394
6420
  for (const entry of entries) {
6395
6421
  const srcPath = join(examplePath, entry.name);
6396
- const destPath = join(path19, entry.name);
6422
+ const destPath = join(path20, entry.name);
6397
6423
  await cp(srcPath, destPath, { recursive: true });
6398
6424
  }
6399
6425
  }
@@ -6451,8 +6477,8 @@ var newCommand = {
6451
6477
 
6452
6478
  // packages/cli/src/commands/extensions/validate.ts
6453
6479
  var import_semver = __toESM(require_semver(), 1);
6454
- import * as fs from "node:fs";
6455
- import * as path2 from "node:path";
6480
+ import * as fs2 from "node:fs";
6481
+ import * as path3 from "node:path";
6456
6482
  async function handleValidate(args) {
6457
6483
  try {
6458
6484
  await validateExtension(args);
@@ -6470,7 +6496,7 @@ async function validateExtension(args) {
6470
6496
  requestSetting: promptForSetting,
6471
6497
  settings: loadSettings(workspaceDir).merged
6472
6498
  });
6473
- const absoluteInputPath = path2.resolve(args.path);
6499
+ const absoluteInputPath = path3.resolve(args.path);
6474
6500
  const extensionConfig = await extensionManager.loadExtensionConfig(absoluteInputPath);
6475
6501
  const warnings = [];
6476
6502
  const errors = [];
@@ -6488,7 +6514,7 @@ async function validateExtension(args) {
6488
6514
  );
6489
6515
  continue;
6490
6516
  }
6491
- if (!fs.existsSync(validation2.resolvedPath)) {
6517
+ if (!fs2.existsSync(validation2.resolvedPath)) {
6492
6518
  missingContextFiles.push(contextFilePath);
6493
6519
  }
6494
6520
  }
@@ -6725,7 +6751,7 @@ async function handleEnable3(args) {
6725
6751
  const result = enableSkill(settings, name);
6726
6752
  const feedback = renderSkillActionFeedback(
6727
6753
  result,
6728
- (label, path19) => `${import_chalk5.default.bold(label)} (${import_chalk5.default.dim(path19)})`
6754
+ (label, path20) => `${import_chalk5.default.bold(label)} (${import_chalk5.default.dim(path20)})`
6729
6755
  );
6730
6756
  debugLogger.log(feedback);
6731
6757
  }
@@ -6755,7 +6781,7 @@ async function handleDisable3(args) {
6755
6781
  const result = disableSkill(settings, name, scope);
6756
6782
  const feedback = renderSkillActionFeedback(
6757
6783
  result,
6758
- (label, path19) => `${import_chalk6.default.bold(label)} (${import_chalk6.default.dim(path19)})`
6784
+ (label, path20) => `${import_chalk6.default.bold(label)} (${import_chalk6.default.dim(path20)})`
6759
6785
  );
6760
6786
  debugLogger.log(feedback);
6761
6787
  }
@@ -6990,8 +7016,8 @@ var skillsCommand = {
6990
7016
  };
6991
7017
 
6992
7018
  // packages/cli/src/commands/hooks/migrate.ts
6993
- import * as fs2 from "node:fs";
6994
- import * as path3 from "node:path";
7019
+ import * as fs3 from "node:fs";
7020
+ import * as path4 from "node:path";
6995
7021
  var import_strip_json_comments = __toESM(require_strip_json_comments(), 1);
6996
7022
  var EVENT_MAPPING = {
6997
7023
  PreToolUse: "BeforeTool",
@@ -7098,25 +7124,25 @@ function migrateClaudeHooks(claudeConfig) {
7098
7124
  }
7099
7125
  async function handleMigrateFromClaude() {
7100
7126
  const workingDir = process.cwd();
7101
- const claudeDir = path3.join(workingDir, ".claude");
7102
- const claudeSettingsPath = path3.join(claudeDir, "settings.json");
7103
- const claudeLocalSettingsPath = path3.join(claudeDir, "settings.local.json");
7127
+ const claudeDir = path4.join(workingDir, ".claude");
7128
+ const claudeSettingsPath = path4.join(claudeDir, "settings.json");
7129
+ const claudeLocalSettingsPath = path4.join(claudeDir, "settings.local.json");
7104
7130
  let claudeSettings = null;
7105
7131
  let sourceFile = "";
7106
- if (fs2.existsSync(claudeLocalSettingsPath)) {
7132
+ if (fs3.existsSync(claudeLocalSettingsPath)) {
7107
7133
  sourceFile = claudeLocalSettingsPath;
7108
7134
  try {
7109
- const content = fs2.readFileSync(claudeLocalSettingsPath, "utf-8");
7135
+ const content = fs3.readFileSync(claudeLocalSettingsPath, "utf-8");
7110
7136
  claudeSettings = JSON.parse((0, import_strip_json_comments.default)(content));
7111
7137
  } catch (error) {
7112
7138
  debugLogger.error(
7113
7139
  `Error reading ${claudeLocalSettingsPath}: ${getErrorMessage(error)}`
7114
7140
  );
7115
7141
  }
7116
- } else if (fs2.existsSync(claudeSettingsPath)) {
7142
+ } else if (fs3.existsSync(claudeSettingsPath)) {
7117
7143
  sourceFile = claudeSettingsPath;
7118
7144
  try {
7119
- const content = fs2.readFileSync(claudeSettingsPath, "utf-8");
7145
+ const content = fs3.readFileSync(claudeSettingsPath, "utf-8");
7120
7146
  claudeSettings = JSON.parse((0, import_strip_json_comments.default)(content));
7121
7147
  } catch (error) {
7122
7148
  debugLogger.error(
@@ -7191,8 +7217,8 @@ var hooksCommand = {
7191
7217
  // packages/cli/src/commands/gemma/setup.ts
7192
7218
  var import_chalk10 = __toESM(require_source(), 1);
7193
7219
  import { createHash } from "node:crypto";
7194
- import fs3 from "node:fs";
7195
- import path4 from "node:path";
7220
+ import fs4 from "node:fs";
7221
+ import path5 from "node:path";
7196
7222
  import { execFileSync, spawn as nodeSpawn } from "node:child_process";
7197
7223
  import readline from "node:readline";
7198
7224
  var log = (msg) => debugLogger.log(msg);
@@ -7202,10 +7228,10 @@ async function promptYesNo(question) {
7202
7228
  input: process.stdin,
7203
7229
  output: process.stdout
7204
7230
  });
7205
- return new Promise((resolve10) => {
7231
+ return new Promise((resolve11) => {
7206
7232
  rl.question(`${question} (y/N): `, (answer) => {
7207
7233
  rl.close();
7208
- resolve10(
7234
+ resolve11(
7209
7235
  answer.trim().toLowerCase() === "y" || answer.trim().toLowerCase() === "yes"
7210
7236
  );
7211
7237
  });
@@ -7232,8 +7258,8 @@ function renderProgress(downloaded, total) {
7232
7258
  }
7233
7259
  async function downloadFile(url, destPath) {
7234
7260
  const tmpPath = destPath + ".downloading";
7235
- if (fs3.existsSync(tmpPath)) {
7236
- fs3.unlinkSync(tmpPath);
7261
+ if (fs4.existsSync(tmpPath)) {
7262
+ fs4.unlinkSync(tmpPath);
7237
7263
  }
7238
7264
  const response = await fetch(url, { redirect: "follow" });
7239
7265
  if (!response.ok) {
@@ -7247,7 +7273,7 @@ async function downloadFile(url, destPath) {
7247
7273
  const contentLength = response.headers.get("content-length");
7248
7274
  const totalBytes = contentLength ? parseInt(contentLength, 10) : null;
7249
7275
  let downloadedBytes = 0;
7250
- const fileStream = fs3.createWriteStream(tmpPath);
7276
+ const fileStream = fs4.createWriteStream(tmpPath);
7251
7277
  const reader = response.body.getReader();
7252
7278
  try {
7253
7279
  for (; ; ) {
@@ -7255,7 +7281,7 @@ async function downloadFile(url, destPath) {
7255
7281
  if (done) break;
7256
7282
  const writeOk = fileStream.write(value);
7257
7283
  if (!writeOk) {
7258
- await new Promise((resolve10) => fileStream.once("drain", resolve10));
7284
+ await new Promise((resolve11) => fileStream.once("drain", resolve11));
7259
7285
  }
7260
7286
  downloadedBytes += value.byteLength;
7261
7287
  renderProgress(downloadedBytes, totalBytes);
@@ -7264,22 +7290,22 @@ async function downloadFile(url, destPath) {
7264
7290
  fileStream.end();
7265
7291
  process.stderr.write("\r" + " ".repeat(80) + "\r");
7266
7292
  }
7267
- await new Promise((resolve10, reject) => {
7268
- fileStream.on("finish", resolve10);
7293
+ await new Promise((resolve11, reject) => {
7294
+ fileStream.on("finish", resolve11);
7269
7295
  fileStream.on("error", reject);
7270
7296
  });
7271
- fs3.renameSync(tmpPath, destPath);
7297
+ fs4.renameSync(tmpPath, destPath);
7272
7298
  }
7273
7299
  async function computeFileSha256(filePath) {
7274
7300
  const hash = createHash("sha256");
7275
- const fileStream = fs3.createReadStream(filePath);
7276
- return new Promise((resolve10, reject) => {
7301
+ const fileStream = fs4.createReadStream(filePath);
7302
+ return new Promise((resolve11, reject) => {
7277
7303
  fileStream.on("data", (chunk) => {
7278
7304
  hash.update(chunk);
7279
7305
  });
7280
7306
  fileStream.on("error", reject);
7281
7307
  fileStream.on("end", () => {
7282
- resolve10(hash.digest("hex"));
7308
+ resolve11(hash.digest("hex"));
7283
7309
  });
7284
7310
  });
7285
7311
  }
@@ -7288,11 +7314,11 @@ async function verifyFileSha256(filePath, expectedHash) {
7288
7314
  return actualHash === expectedHash;
7289
7315
  }
7290
7316
  function spawnInherited(command2, args) {
7291
- return new Promise((resolve10, reject) => {
7317
+ return new Promise((resolve11, reject) => {
7292
7318
  const child = nodeSpawn(command2, args, {
7293
7319
  stdio: "inherit"
7294
7320
  });
7295
- child.on("close", (code) => resolve10(code ?? 1));
7321
+ child.on("close", (code) => resolve11(code ?? 1));
7296
7322
  child.on("error", reject);
7297
7323
  });
7298
7324
  }
@@ -7342,8 +7368,8 @@ async function handleSetup(argv) {
7342
7368
  const downloadUrl = getBinaryDownloadUrl(platform2.binaryName);
7343
7369
  debugLogger.log(`Downloading from: ${downloadUrl}`);
7344
7370
  try {
7345
- const binDir = path4.dirname(binaryPath);
7346
- fs3.mkdirSync(binDir, { recursive: true });
7371
+ const binDir = path5.dirname(binaryPath);
7372
+ fs4.mkdirSync(binDir, { recursive: true });
7347
7373
  await downloadFile(downloadUrl, binaryPath);
7348
7374
  log(import_chalk10.default.green(" \u2713 Binary downloaded successfully"));
7349
7375
  } catch (error) {
@@ -7363,7 +7389,7 @@ async function handleSetup(argv) {
7363
7389
  )
7364
7390
  );
7365
7391
  try {
7366
- fs3.rmSync(binaryPath, { force: true });
7392
+ fs4.rmSync(binaryPath, { force: true });
7367
7393
  } catch {
7368
7394
  }
7369
7395
  return 1;
@@ -7377,7 +7403,7 @@ async function handleSetup(argv) {
7377
7403
  )
7378
7404
  );
7379
7405
  try {
7380
- fs3.rmSync(binaryPath, { force: true });
7406
+ fs4.rmSync(binaryPath, { force: true });
7381
7407
  } catch {
7382
7408
  }
7383
7409
  return 1;
@@ -7390,14 +7416,14 @@ async function handleSetup(argv) {
7390
7416
  )
7391
7417
  );
7392
7418
  try {
7393
- fs3.rmSync(binaryPath, { force: true });
7419
+ fs4.rmSync(binaryPath, { force: true });
7394
7420
  } catch {
7395
7421
  }
7396
7422
  return 1;
7397
7423
  }
7398
7424
  if (process.platform !== "win32") {
7399
7425
  try {
7400
- fs3.chmodSync(binaryPath, 493);
7426
+ fs4.chmodSync(binaryPath, 493);
7401
7427
  } catch (error) {
7402
7428
  logError(
7403
7429
  import_chalk10.default.red(
@@ -7598,7 +7624,7 @@ var setupCommand = {
7598
7624
 
7599
7625
  // packages/cli/src/commands/gemma/stop.ts
7600
7626
  var import_chalk11 = __toESM(require_source(), 1);
7601
- import fs4 from "node:fs";
7627
+ import fs5 from "node:fs";
7602
7628
  async function stopServer(expectedPort) {
7603
7629
  const processInfo = readServerProcessInfo();
7604
7630
  const pidPath = getPidFilePath();
@@ -7611,7 +7637,7 @@ async function stopServer(expectedPort) {
7611
7637
  `Stale PID file found (PID ${pid} is not running), removing ${pidPath}`
7612
7638
  );
7613
7639
  try {
7614
- fs4.unlinkSync(pidPath);
7640
+ fs5.unlinkSync(pidPath);
7615
7641
  } catch {
7616
7642
  }
7617
7643
  return "not-running";
@@ -7629,19 +7655,19 @@ async function stopServer(expectedPort) {
7629
7655
  } catch {
7630
7656
  return "failed";
7631
7657
  }
7632
- await new Promise((resolve10) => setTimeout(resolve10, 1e3));
7658
+ await new Promise((resolve11) => setTimeout(resolve11, 1e3));
7633
7659
  if (isProcessRunning(pid)) {
7634
7660
  try {
7635
7661
  process.kill(pid, "SIGKILL");
7636
7662
  } catch {
7637
7663
  }
7638
- await new Promise((resolve10) => setTimeout(resolve10, 500));
7664
+ await new Promise((resolve11) => setTimeout(resolve11, 500));
7639
7665
  if (isProcessRunning(pid)) {
7640
7666
  return "failed";
7641
7667
  }
7642
7668
  }
7643
7669
  try {
7644
- fs4.unlinkSync(pidPath);
7670
+ fs5.unlinkSync(pidPath);
7645
7671
  } catch {
7646
7672
  }
7647
7673
  return "stopped";
@@ -7709,14 +7735,14 @@ var stopCommand = {
7709
7735
  };
7710
7736
 
7711
7737
  // packages/cli/src/commands/gemma/logs.ts
7712
- import fs5 from "node:fs";
7738
+ import fs6 from "node:fs";
7713
7739
  import { spawn } from "node:child_process";
7714
7740
  async function readLastLines(filePath, count) {
7715
7741
  if (count <= 0) {
7716
7742
  return "";
7717
7743
  }
7718
7744
  const CHUNK_SIZE = 64 * 1024;
7719
- const fileHandle = await fs5.promises.open(filePath, fs5.constants.O_RDONLY);
7745
+ const fileHandle = await fs6.promises.open(filePath, fs6.constants.O_RDONLY);
7720
7746
  try {
7721
7747
  const stats = await fileHandle.stat();
7722
7748
  if (stats.size === 0) {
@@ -7769,9 +7795,9 @@ async function readLastLines(filePath, count) {
7769
7795
  }
7770
7796
  }
7771
7797
  function waitForChild(child) {
7772
- return new Promise((resolve10, reject) => {
7798
+ return new Promise((resolve11, reject) => {
7773
7799
  child.once("error", reject);
7774
- child.once("close", (code) => resolve10(code ?? 1));
7800
+ child.once("close", (code) => resolve11(code ?? 1));
7775
7801
  });
7776
7802
  }
7777
7803
  async function runTail(logPath, lines, follow) {
@@ -7805,7 +7831,7 @@ var logsCommand = {
7805
7831
  handler: async (argv) => {
7806
7832
  const logPath = getLogFilePath();
7807
7833
  try {
7808
- await fs5.promises.access(logPath, fs5.constants.F_OK);
7834
+ await fs6.promises.access(logPath, fs6.constants.F_OK);
7809
7835
  } catch {
7810
7836
  debugLogger.log(`No log file found at ${logPath}`);
7811
7837
  debugLogger.log(
@@ -8090,7 +8116,7 @@ function buildAvailableModels(config, settings) {
8090
8116
  const useGemini31 = config.getGemini31LaunchedSync?.() ?? false;
8091
8117
  const useLatestFlash = config.hasLatestFlashGAAccess?.() ?? false;
8092
8118
  const useLatestFlashLite = config.hasLatestFlashLiteGAAccess?.() ?? false;
8093
- const selectedAuthType = settings.merged.security.auth.selectedType;
8119
+ const selectedAuthType = settings.merged.security?.auth?.selectedType ?? config.getContentGeneratorConfig?.()?.authType;
8094
8120
  const useCustomToolModel = useGemini31 && selectedAuthType === "gemini-api-key" /* USE_GEMINI */;
8095
8121
  if (config.getExperimentalDynamicModelConfiguration?.() === true && config.getModelConfigService) {
8096
8122
  const options = config.getModelConfigService().getAvailableModelOptions({
@@ -8151,6 +8177,14 @@ function buildAvailableModels(config, settings) {
8151
8177
  }
8152
8178
  manualOptions.unshift(...previewOptions);
8153
8179
  }
8180
+ const seen = /* @__PURE__ */ new Set();
8181
+ const uniqueManualOptions = manualOptions.filter((option) => {
8182
+ if (seen.has(option.value)) {
8183
+ return false;
8184
+ }
8185
+ seen.add(option.value);
8186
+ return true;
8187
+ });
8154
8188
  const scaleOptions = (options) => options.map((o) => ({
8155
8189
  modelId: o.value,
8156
8190
  name: o.title,
@@ -8159,7 +8193,7 @@ function buildAvailableModels(config, settings) {
8159
8193
  return {
8160
8194
  availableModels: [
8161
8195
  ...scaleOptions(mainOptions),
8162
- ...scaleOptions(manualOptions)
8196
+ ...scaleOptions(uniqueManualOptions)
8163
8197
  ],
8164
8198
  currentModelId: preferredModel
8165
8199
  };
@@ -8201,7 +8235,7 @@ function getModelListings(config, settings) {
8201
8235
  const { availableModels } = buildAvailableModels(config, settings);
8202
8236
  return (availableModels ?? []).map((m) => {
8203
8237
  const inputTokens = tokenLimit(m.modelId) ?? DEFAULT_TOKEN_LIMIT;
8204
- const outputTokens = 8192;
8238
+ const outputTokens = outputTokenLimit(m.modelId);
8205
8239
  return {
8206
8240
  modelId: m.modelId,
8207
8241
  id: m.modelId,
@@ -8210,7 +8244,7 @@ function getModelListings(config, settings) {
8210
8244
  description: m.description ?? "",
8211
8245
  contextLimits: {
8212
8246
  inputTokens,
8213
- outputTokens
8247
+ ...outputTokens !== void 0 ? { outputTokens } : {}
8214
8248
  }
8215
8249
  };
8216
8250
  });
@@ -8220,7 +8254,8 @@ async function handleList3(options) {
8220
8254
  const settings = options?.loadedSettings ?? loadSettings(workspaceDir);
8221
8255
  const argv = {
8222
8256
  ...DEFAULT_CLI_ARGS,
8223
- ...options?.argv
8257
+ ...options?.argv,
8258
+ isCommand: true
8224
8259
  };
8225
8260
  const config = await loadCliConfig(
8226
8261
  settings.merged,
@@ -8234,6 +8269,33 @@ async function handleList3(options) {
8234
8269
  );
8235
8270
  initializeOutputListenersAndFlush(config);
8236
8271
  await config.storage.initialize();
8272
+ const authConfig = settings.merged.security?.auth;
8273
+ const authType = authConfig?.selectedType || getAuthTypeFromEnv();
8274
+ const enforcedType = authConfig?.enforcedType;
8275
+ if (enforcedType && authType !== enforcedType) {
8276
+ const message = authType ? `The enforced authentication type is '${enforcedType}', but the current type is '${authType}'. Please re-authenticate with the correct type.` : `The auth type '${enforcedType}' is enforced, but no authentication is configured.`;
8277
+ throw new Error(message);
8278
+ }
8279
+ if (authType && !authConfig?.useExternal) {
8280
+ try {
8281
+ if (authType !== "gateway" /* GATEWAY */) {
8282
+ const authError = await validateAuthMethod(authType);
8283
+ if (authError) {
8284
+ throw new Error(authError);
8285
+ }
8286
+ }
8287
+ config.isBrowserLaunchSuppressed = () => true;
8288
+ await config.refreshAuth(authType);
8289
+ } catch (e) {
8290
+ if (enforcedType) {
8291
+ throw e;
8292
+ }
8293
+ debugLogger.debug(
8294
+ "Failed to refresh auth for models list, falling back to default catalog:",
8295
+ e
8296
+ );
8297
+ }
8298
+ }
8237
8299
  const models = getModelListings(config, settings);
8238
8300
  if (options?.outputFormat === "json") {
8239
8301
  process.stdout.write(JSON.stringify(models, null, 2) + "\n");
@@ -8247,8 +8309,9 @@ async function handleList3(options) {
8247
8309
  process.stdout.write(` Description: ${model.description}
8248
8310
  `);
8249
8311
  }
8312
+ const outputLimitText = model.contextLimits.outputTokens !== void 0 ? ` / ${model.contextLimits.outputTokens.toLocaleString()} output tokens` : "";
8250
8313
  process.stdout.write(
8251
- ` Context limit: ${model.contextLimits.inputTokens.toLocaleString()} input tokens / ${model.contextLimits.outputTokens.toLocaleString()} output tokens
8314
+ ` Context limit: ${model.contextLimits.inputTokens.toLocaleString()} input tokens${outputLimitText}
8252
8315
 
8253
8316
  `
8254
8317
  );
@@ -8266,6 +8329,7 @@ var listCommand4 = {
8266
8329
  }),
8267
8330
  handler: async (argv) => {
8268
8331
  const outputFormat = argv["output-format"] === "json" ? "json" : "text";
8332
+ let exitCode;
8269
8333
  try {
8270
8334
  await handleList3({
8271
8335
  outputFormat,
@@ -8277,8 +8341,13 @@ var listCommand4 = {
8277
8341
  "Error: " + (error instanceof Error ? error.stack || error.message : String(error)) + "\n"
8278
8342
  );
8279
8343
  process.exitCode = 1;
8344
+ exitCode = 1;
8280
8345
  } finally {
8281
- await exitCli();
8346
+ if (exitCode !== void 0) {
8347
+ await exitCli(exitCode);
8348
+ } else {
8349
+ await exitCli();
8350
+ }
8282
8351
  }
8283
8352
  }
8284
8353
  };
@@ -8299,9 +8368,9 @@ var modelsCommand = {
8299
8368
  var import_command_exists = __toESM(require_command_exists(), 1);
8300
8369
  import * as os from "node:os";
8301
8370
  import { fileURLToPath as fileURLToPath3 } from "node:url";
8302
- import path5 from "node:path";
8371
+ import path6 from "node:path";
8303
8372
  var __filename2 = fileURLToPath3(import.meta.url);
8304
- var __dirname3 = path5.dirname(__filename2);
8373
+ var __dirname3 = path6.dirname(__filename2);
8305
8374
  var VALID_SANDBOX_COMMANDS = [
8306
8375
  "docker",
8307
8376
  "podman",
@@ -8387,13 +8456,13 @@ async function loadSandboxConfig(settings, argv) {
8387
8456
  }
8388
8457
  const command2 = getSandboxCommand(sandboxValue);
8389
8458
  const packageJson = await getPackageJson(__dirname3);
8390
- const image = process.env["GEMINI_SANDBOX_IMAGE"] ?? "us-docker.pkg.dev/gemini-code-dev/gemini-cli/sandbox:0.69.0-preview.0" ?? customImage ?? packageJson?.config?.sandboxImageUri;
8459
+ const image = process.env["GEMINI_SANDBOX_IMAGE"] ?? "us-docker.pkg.dev/gemini-code-dev/gemini-cli/sandbox:0.70.0-preview.0" ?? customImage ?? packageJson?.config?.sandboxImageUri;
8391
8460
  const isNative = command2 === "windows-native" || command2 === "sandbox-exec" || command2 === "lxc";
8392
8461
  return command2 && (image || isNative) ? { enabled: true, allowedPaths, networkAccess, command: command2, image } : void 0;
8393
8462
  }
8394
8463
 
8395
8464
  // packages/cli/src/utils/resolvePath.ts
8396
- import * as path6 from "node:path";
8465
+ import * as path7 from "node:path";
8397
8466
  function resolvePath(p) {
8398
8467
  if (!p) {
8399
8468
  return "";
@@ -8404,7 +8473,7 @@ function resolvePath(p) {
8404
8473
  } else if (p === "~" || p.startsWith("~/")) {
8405
8474
  expandedPath = homedir() + p.substring(1);
8406
8475
  }
8407
- return path6.normalize(expandedPath);
8476
+ return path7.normalize(expandedPath);
8408
8477
  }
8409
8478
 
8410
8479
  // packages/cli/src/config/policy.ts
@@ -8876,7 +8945,7 @@ async function loadCliConfig(settings, sessionId, argv, options = {}) {
8876
8945
  const ideWorkspacePath = process3.env["GEMINI_CLI_IDE_WORKSPACE_PATH"];
8877
8946
  if (ideWorkspacePath) {
8878
8947
  const realCwd = resolveToRealPath(cwd);
8879
- const ideFolders = ideWorkspacePath.split(path7.delimiter).filter((p) => {
8948
+ const ideFolders = ideWorkspacePath.split(path8.delimiter).filter((p) => {
8880
8949
  const trimmedPath = p.trim();
8881
8950
  if (!trimmedPath) return false;
8882
8951
  try {
@@ -8908,7 +8977,7 @@ async function loadCliConfig(settings, sessionId, argv, options = {}) {
8908
8977
  let extensionRegistryURI = process3.env["GEMINI_CLI_EXTENSION_REGISTRY_URI"] ?? (trustedFolder ? settings.experimental?.extensionRegistryURI : void 0);
8909
8978
  if (extensionRegistryURI && !extensionRegistryURI.startsWith("http")) {
8910
8979
  extensionRegistryURI = resolveToRealPath(
8911
- path7.resolve(cwd, resolvePath(extensionRegistryURI))
8980
+ path8.resolve(cwd, resolvePath(extensionRegistryURI))
8912
8981
  );
8913
8982
  }
8914
8983
  const finalExtensionLoader = extensionManager ?? new SimpleExtensionLoader([]);
@@ -9284,7 +9353,7 @@ async function resolveWorktreeSettings(cwd) {
9284
9353
  return void 0;
9285
9354
  }
9286
9355
  return {
9287
- name: path7.basename(worktreePath),
9356
+ name: path8.basename(worktreePath),
9288
9357
  path: worktreePath,
9289
9358
  baseSha: worktreeBaseSha
9290
9359
  };
@@ -9309,7 +9378,7 @@ async function readStdin() {
9309
9378
  return "";
9310
9379
  }
9311
9380
  const MAX_STDIN_SIZE = 8 * 1024 * 1024;
9312
- return new Promise((resolve10, reject) => {
9381
+ return new Promise((resolve11, reject) => {
9313
9382
  let data = "";
9314
9383
  let totalSize = 0;
9315
9384
  let settled = false;
@@ -9349,7 +9418,7 @@ async function readStdin() {
9349
9418
  process.stdin.pause();
9350
9419
  }
9351
9420
  settled = true;
9352
- resolve10(data);
9421
+ resolve11(data);
9353
9422
  break;
9354
9423
  }
9355
9424
  data += chunkBuffer ? chunkBuffer.toString("utf8") : chunkStr;
@@ -9360,7 +9429,7 @@ async function readStdin() {
9360
9429
  if (settled) return;
9361
9430
  settled = true;
9362
9431
  cleanup();
9363
- resolve10(data);
9432
+ resolve11(data);
9364
9433
  };
9365
9434
  const onError = (err) => {
9366
9435
  if (settled) return;
@@ -9393,7 +9462,7 @@ import { createHash as createHash2 } from "node:crypto";
9393
9462
  import v8 from "node:v8";
9394
9463
  import os6 from "node:os";
9395
9464
  import dns from "node:dns";
9396
- import * as path18 from "node:path";
9465
+ import * as path19 from "node:path";
9397
9466
  import * as fsPromises from "node:fs/promises";
9398
9467
 
9399
9468
  // packages/cli/src/utils/sandbox.ts
@@ -9405,8 +9474,8 @@ import {
9405
9474
  spawn as spawn3,
9406
9475
  spawnSync
9407
9476
  } from "node:child_process";
9408
- import path10 from "node:path";
9409
- import fs7 from "node:fs";
9477
+ import path11 from "node:path";
9478
+ import fs8 from "node:fs";
9410
9479
  import os3 from "node:os";
9411
9480
  import { fileURLToPath as fileURLToPath4 } from "node:url";
9412
9481
  import { promisify } from "node:util";
@@ -9416,8 +9485,8 @@ import { randomBytes } from "node:crypto";
9416
9485
  // packages/cli/src/utils/sandboxUtils.ts
9417
9486
  var import_shell_quote = __toESM(require_shell_quote(), 1);
9418
9487
  import os2 from "node:os";
9419
- import path8 from "node:path";
9420
- import fs6 from "node:fs";
9488
+ import path9 from "node:path";
9489
+ import fs7 from "node:fs";
9421
9490
  import { readFile } from "node:fs/promises";
9422
9491
  var LOCAL_DEV_SANDBOX_IMAGE_NAME = "gemini-cli-sandbox";
9423
9492
  var SANDBOX_NETWORK_NAME = "gemini-cli-sandbox";
@@ -9447,10 +9516,10 @@ var SENSITIVE_SETTINGS_FILENAMES = /* @__PURE__ */ new Set([
9447
9516
  "policy_integrity.json"
9448
9517
  ]);
9449
9518
  function safeResolveToRealPath(targetPath) {
9450
- let current = path8.resolve(targetPath);
9519
+ let current = path9.resolve(targetPath);
9451
9520
  const parts = [];
9452
9521
  const visited = /* @__PURE__ */ new Set();
9453
- while (current && current !== path8.dirname(current)) {
9522
+ while (current && current !== path9.dirname(current)) {
9454
9523
  const visitKey = os2.platform() === "win32" ? current.toLowerCase() : current;
9455
9524
  if (visited.has(visitKey)) {
9456
9525
  throw new Error("Circular symlink detected");
@@ -9458,14 +9527,14 @@ function safeResolveToRealPath(targetPath) {
9458
9527
  visited.add(visitKey);
9459
9528
  try {
9460
9529
  const real = resolveToRealPath(current);
9461
- return path8.resolve(real, ...parts.slice().reverse());
9530
+ return path9.resolve(real, ...parts.slice().reverse());
9462
9531
  } catch (err) {
9463
9532
  if (isRecord2(err) && err["code"] === "ENOENT") {
9464
9533
  try {
9465
- const stat3 = fs6.lstatSync(current);
9534
+ const stat3 = fs7.lstatSync(current);
9466
9535
  if (stat3?.isSymbolicLink?.()) {
9467
- const target = fs6.readlinkSync(current);
9468
- current = path8.resolve(path8.dirname(current), target);
9536
+ const target = fs7.readlinkSync(current);
9537
+ current = path9.resolve(path9.dirname(current), target);
9469
9538
  continue;
9470
9539
  }
9471
9540
  } catch (lstatErr) {
@@ -9473,14 +9542,14 @@ function safeResolveToRealPath(targetPath) {
9473
9542
  throw lstatErr;
9474
9543
  }
9475
9544
  }
9476
- parts.push(path8.basename(current));
9477
- current = path8.dirname(current);
9545
+ parts.push(path9.basename(current));
9546
+ current = path9.dirname(current);
9478
9547
  continue;
9479
9548
  }
9480
9549
  throw err;
9481
9550
  }
9482
9551
  }
9483
- return path8.resolve(targetPath);
9552
+ return path9.resolve(targetPath);
9484
9553
  }
9485
9554
  function isSensitiveHostPath(hostPath) {
9486
9555
  try {
@@ -9490,7 +9559,7 @@ function isSensitiveHostPath(hostPath) {
9490
9559
  return true;
9491
9560
  }
9492
9561
  const resolvedPath = safeResolveToRealPath(hostPath);
9493
- const baseName2 = path8.basename(resolvedPath).toLowerCase();
9562
+ const baseName2 = path9.basename(resolvedPath).toLowerCase();
9494
9563
  if (baseName2 === ".env" || baseName2.startsWith(".env.") || SENSITIVE_SETTINGS_FILENAMES.has(baseName2)) {
9495
9564
  return true;
9496
9565
  }
@@ -9501,17 +9570,17 @@ function isSensitiveHostPath(hostPath) {
9501
9570
  if (hostPath === "~" || hostPath === "~/" || hostPath === "~\\") {
9502
9571
  expandedPath = home;
9503
9572
  } else if (hostPath.startsWith("~/") || hostPath.startsWith("~\\")) {
9504
- expandedPath = path8.join(home, hostPath.slice(2));
9573
+ expandedPath = path9.join(home, hostPath.slice(2));
9505
9574
  }
9506
9575
  const normalized = safeResolveToRealPath(expandedPath);
9507
- const geminiDirCandidate = path8.join(home, GEMINI_DIR);
9576
+ const geminiDirCandidate = path9.join(home, GEMINI_DIR);
9508
9577
  const geminiDirOnHost = safeResolveToRealPath(geminiDirCandidate);
9509
9578
  const isWindows = os2.platform() === "win32";
9510
- const arePathsEqual = (p1, p2) => isWindows ? path8.resolve(p1).toLowerCase() === path8.resolve(p2).toLowerCase() : path8.resolve(p1) === path8.resolve(p2);
9579
+ const arePathsEqual = (p1, p2) => isWindows ? path9.resolve(p1).toLowerCase() === path9.resolve(p2).toLowerCase() : path9.resolve(p1) === path9.resolve(p2);
9511
9580
  const isSubpathOf = (child, parent) => {
9512
- const resolvedChild = path8.resolve(child);
9513
- const resolvedParent = path8.resolve(parent);
9514
- const parentWithSep = resolvedParent.endsWith(path8.sep) ? resolvedParent : resolvedParent + path8.sep;
9581
+ const resolvedChild = path9.resolve(child);
9582
+ const resolvedParent = path9.resolve(parent);
9583
+ const parentWithSep = resolvedParent.endsWith(path9.sep) ? resolvedParent : resolvedParent + path9.sep;
9515
9584
  return isWindows ? resolvedChild.toLowerCase().startsWith(parentWithSep.toLowerCase()) : resolvedChild.startsWith(parentWithSep);
9516
9585
  };
9517
9586
  if (arePathsEqual(normalized, home) || isSubpathOf(home, normalized)) {
@@ -9520,7 +9589,7 @@ function isSensitiveHostPath(hostPath) {
9520
9589
  if (arePathsEqual(normalized, geminiDirOnHost) || isSubpathOf(normalized, geminiDirOnHost) || isSubpathOf(geminiDirOnHost, normalized)) {
9521
9590
  return true;
9522
9591
  }
9523
- const baseName = path8.basename(normalized).toLowerCase();
9592
+ const baseName = path9.basename(normalized).toLowerCase();
9524
9593
  if (baseName === ".env" || baseName.startsWith(".env.") || SENSITIVE_SETTINGS_FILENAMES.has(baseName)) {
9525
9594
  return true;
9526
9595
  }
@@ -9631,7 +9700,7 @@ function entrypoint(workdir, cliArgs) {
9631
9700
  shellCmds.push(`export PYTHONPATH="$PYTHONPATH${pythonPathSuffix}";`);
9632
9701
  }
9633
9702
  const projectSandboxBashrc = `${GEMINI_DIR}/sandbox.bashrc`;
9634
- if (fs6.existsSync(projectSandboxBashrc)) {
9703
+ if (fs7.existsSync(projectSandboxBashrc)) {
9635
9704
  shellCmds.push(`source ${getContainerPath(projectSandboxBashrc)};`);
9636
9705
  }
9637
9706
  ports().forEach(
@@ -10636,7 +10705,220 @@ BUILTIN_SEATBELT_PROFILE_CONTENTS["restrictive-closed"] = BUILTIN_SEATBELT_PROFI
10636
10705
 
10637
10706
  // packages/cli/src/utils/ideBridge.ts
10638
10707
  import { spawn as spawn2 } from "node:child_process";
10639
- import * as path9 from "node:path";
10708
+ import * as path10 from "node:path";
10709
+
10710
+ // node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/server.js
10711
+ var ExperimentalServerTasks = class {
10712
+ constructor(_server) {
10713
+ this._server = _server;
10714
+ }
10715
+ /**
10716
+ * Sends a request and returns an AsyncGenerator that yields response messages.
10717
+ * The generator is guaranteed to end with either a 'result' or 'error' message.
10718
+ *
10719
+ * This method provides streaming access to request processing, allowing you to
10720
+ * observe intermediate task status updates for task-augmented requests.
10721
+ *
10722
+ * @param request - The request to send
10723
+ * @param resultSchema - Zod schema for validating the result
10724
+ * @param options - Optional request options (timeout, signal, task creation params, etc.)
10725
+ * @returns AsyncGenerator that yields ResponseMessage objects
10726
+ *
10727
+ * @experimental
10728
+ */
10729
+ requestStream(request, resultSchema, options) {
10730
+ return this._server.requestStream(request, resultSchema, options);
10731
+ }
10732
+ /**
10733
+ * Sends a sampling request and returns an AsyncGenerator that yields response messages.
10734
+ * The generator is guaranteed to end with either a 'result' or 'error' message.
10735
+ *
10736
+ * For task-augmented requests, yields 'taskCreated' and 'taskStatus' messages
10737
+ * before the final result.
10738
+ *
10739
+ * @example
10740
+ * ```typescript
10741
+ * const stream = server.experimental.tasks.createMessageStream({
10742
+ * messages: [{ role: 'user', content: { type: 'text', text: 'Hello' } }],
10743
+ * maxTokens: 100
10744
+ * }, {
10745
+ * onprogress: (progress) => {
10746
+ * // Handle streaming tokens via progress notifications
10747
+ * console.log('Progress:', progress.message);
10748
+ * }
10749
+ * });
10750
+ *
10751
+ * for await (const message of stream) {
10752
+ * switch (message.type) {
10753
+ * case 'taskCreated':
10754
+ * console.log('Task created:', message.task.taskId);
10755
+ * break;
10756
+ * case 'taskStatus':
10757
+ * console.log('Task status:', message.task.status);
10758
+ * break;
10759
+ * case 'result':
10760
+ * console.log('Final result:', message.result);
10761
+ * break;
10762
+ * case 'error':
10763
+ * console.error('Error:', message.error);
10764
+ * break;
10765
+ * }
10766
+ * }
10767
+ * ```
10768
+ *
10769
+ * @param params - The sampling request parameters
10770
+ * @param options - Optional request options (timeout, signal, task creation params, onprogress, etc.)
10771
+ * @returns AsyncGenerator that yields ResponseMessage objects
10772
+ *
10773
+ * @experimental
10774
+ */
10775
+ createMessageStream(params, options) {
10776
+ const clientCapabilities = this._server.getClientCapabilities();
10777
+ if ((params.tools || params.toolChoice) && !clientCapabilities?.sampling?.tools) {
10778
+ throw new Error("Client does not support sampling tools capability.");
10779
+ }
10780
+ if (params.messages.length > 0) {
10781
+ const lastMessage = params.messages[params.messages.length - 1];
10782
+ const lastContent = Array.isArray(lastMessage.content) ? lastMessage.content : [lastMessage.content];
10783
+ const hasToolResults = lastContent.some((c) => c.type === "tool_result");
10784
+ const previousMessage = params.messages.length > 1 ? params.messages[params.messages.length - 2] : void 0;
10785
+ const previousContent = previousMessage ? Array.isArray(previousMessage.content) ? previousMessage.content : [previousMessage.content] : [];
10786
+ const hasPreviousToolUse = previousContent.some((c) => c.type === "tool_use");
10787
+ if (hasToolResults) {
10788
+ if (lastContent.some((c) => c.type !== "tool_result")) {
10789
+ throw new Error("The last message must contain only tool_result content if any is present");
10790
+ }
10791
+ if (!hasPreviousToolUse) {
10792
+ throw new Error("tool_result blocks are not matching any tool_use from the previous message");
10793
+ }
10794
+ }
10795
+ if (hasPreviousToolUse) {
10796
+ const toolUseIds = new Set(previousContent.filter((c) => c.type === "tool_use").map((c) => c.id));
10797
+ const toolResultIds = new Set(lastContent.filter((c) => c.type === "tool_result").map((c) => c.toolUseId));
10798
+ if (toolUseIds.size !== toolResultIds.size || ![...toolUseIds].every((id) => toolResultIds.has(id))) {
10799
+ throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match");
10800
+ }
10801
+ }
10802
+ }
10803
+ return this.requestStream({
10804
+ method: "sampling/createMessage",
10805
+ params
10806
+ }, CreateMessageResultSchema, options);
10807
+ }
10808
+ /**
10809
+ * Sends an elicitation request and returns an AsyncGenerator that yields response messages.
10810
+ * The generator is guaranteed to end with either a 'result' or 'error' message.
10811
+ *
10812
+ * For task-augmented requests (especially URL-based elicitation), yields 'taskCreated'
10813
+ * and 'taskStatus' messages before the final result.
10814
+ *
10815
+ * @example
10816
+ * ```typescript
10817
+ * const stream = server.experimental.tasks.elicitInputStream({
10818
+ * mode: 'url',
10819
+ * message: 'Please authenticate',
10820
+ * elicitationId: 'auth-123',
10821
+ * url: 'https://example.com/auth'
10822
+ * }, {
10823
+ * task: { ttl: 300000 } // Task-augmented for long-running auth flow
10824
+ * });
10825
+ *
10826
+ * for await (const message of stream) {
10827
+ * switch (message.type) {
10828
+ * case 'taskCreated':
10829
+ * console.log('Task created:', message.task.taskId);
10830
+ * break;
10831
+ * case 'taskStatus':
10832
+ * console.log('Task status:', message.task.status);
10833
+ * break;
10834
+ * case 'result':
10835
+ * console.log('User action:', message.result.action);
10836
+ * break;
10837
+ * case 'error':
10838
+ * console.error('Error:', message.error);
10839
+ * break;
10840
+ * }
10841
+ * }
10842
+ * ```
10843
+ *
10844
+ * @param params - The elicitation request parameters
10845
+ * @param options - Optional request options (timeout, signal, task creation params, etc.)
10846
+ * @returns AsyncGenerator that yields ResponseMessage objects
10847
+ *
10848
+ * @experimental
10849
+ */
10850
+ elicitInputStream(params, options) {
10851
+ const clientCapabilities = this._server.getClientCapabilities();
10852
+ const mode = params.mode ?? "form";
10853
+ switch (mode) {
10854
+ case "url": {
10855
+ if (!clientCapabilities?.elicitation?.url) {
10856
+ throw new Error("Client does not support url elicitation.");
10857
+ }
10858
+ break;
10859
+ }
10860
+ case "form": {
10861
+ if (!clientCapabilities?.elicitation?.form) {
10862
+ throw new Error("Client does not support form elicitation.");
10863
+ }
10864
+ break;
10865
+ }
10866
+ }
10867
+ const normalizedParams = mode === "form" && params.mode === void 0 ? { ...params, mode: "form" } : params;
10868
+ return this.requestStream({
10869
+ method: "elicitation/create",
10870
+ params: normalizedParams
10871
+ }, ElicitResultSchema, options);
10872
+ }
10873
+ /**
10874
+ * Gets the current status of a task.
10875
+ *
10876
+ * @param taskId - The task identifier
10877
+ * @param options - Optional request options
10878
+ * @returns The task status
10879
+ *
10880
+ * @experimental
10881
+ */
10882
+ async getTask(taskId, options) {
10883
+ return this._server.getTask({ taskId }, options);
10884
+ }
10885
+ /**
10886
+ * Retrieves the result of a completed task.
10887
+ *
10888
+ * @param taskId - The task identifier
10889
+ * @param resultSchema - Zod schema for validating the result
10890
+ * @param options - Optional request options
10891
+ * @returns The task result
10892
+ *
10893
+ * @experimental
10894
+ */
10895
+ async getTaskResult(taskId, resultSchema, options) {
10896
+ return this._server.getTaskResult({ taskId }, resultSchema, options);
10897
+ }
10898
+ /**
10899
+ * Lists tasks with optional pagination.
10900
+ *
10901
+ * @param cursor - Optional pagination cursor
10902
+ * @param options - Optional request options
10903
+ * @returns List of tasks with optional next cursor
10904
+ *
10905
+ * @experimental
10906
+ */
10907
+ async listTasks(cursor, options) {
10908
+ return this._server.listTasks(cursor ? { cursor } : void 0, options);
10909
+ }
10910
+ /**
10911
+ * Cancels a running task.
10912
+ *
10913
+ * @param taskId - The task identifier
10914
+ * @param options - Optional request options
10915
+ *
10916
+ * @experimental
10917
+ */
10918
+ async cancelTask(taskId, options) {
10919
+ return this._server.cancelTask({ taskId }, options);
10920
+ }
10921
+ };
10640
10922
 
10641
10923
  // node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js
10642
10924
  var Server = class extends Protocol {
@@ -10644,7 +10926,6 @@ var Server = class extends Protocol {
10644
10926
  * Initializes this server with the given name and version information.
10645
10927
  */
10646
10928
  constructor(_serverInfo, options) {
10647
- var _a2, _b2;
10648
10929
  super(options);
10649
10930
  this._serverInfo = _serverInfo;
10650
10931
  this._loggingLevels = /* @__PURE__ */ new Map();
@@ -10653,18 +10934,14 @@ var Server = class extends Protocol {
10653
10934
  const currentLevel = this._loggingLevels.get(sessionId);
10654
10935
  return currentLevel ? this.LOG_LEVEL_SEVERITY.get(level) < this.LOG_LEVEL_SEVERITY.get(currentLevel) : false;
10655
10936
  };
10656
- this._capabilities = (_a2 = options === null || options === void 0 ? void 0 : options.capabilities) !== null && _a2 !== void 0 ? _a2 : {};
10657
- this._instructions = options === null || options === void 0 ? void 0 : options.instructions;
10658
- this._jsonSchemaValidator = (_b2 = options === null || options === void 0 ? void 0 : options.jsonSchemaValidator) !== null && _b2 !== void 0 ? _b2 : new AjvJsonSchemaValidator();
10937
+ this._capabilities = options?.capabilities ?? {};
10938
+ this._instructions = options?.instructions;
10939
+ this._jsonSchemaValidator = options?.jsonSchemaValidator ?? new AjvJsonSchemaValidator();
10659
10940
  this.setRequestHandler(InitializeRequestSchema, (request) => this._oninitialize(request));
10660
- this.setNotificationHandler(InitializedNotificationSchema, () => {
10661
- var _a3;
10662
- return (_a3 = this.oninitialized) === null || _a3 === void 0 ? void 0 : _a3.call(this);
10663
- });
10941
+ this.setNotificationHandler(InitializedNotificationSchema, () => this.oninitialized?.());
10664
10942
  if (this._capabilities.logging) {
10665
10943
  this.setRequestHandler(SetLevelRequestSchema, async (request, extra) => {
10666
- var _a3;
10667
- const transportSessionId = extra.sessionId || ((_a3 = extra.requestInfo) === null || _a3 === void 0 ? void 0 : _a3.headers["mcp-session-id"]) || void 0;
10944
+ const transportSessionId = extra.sessionId || extra.requestInfo?.headers["mcp-session-id"] || void 0;
10668
10945
  const { level } = request.params;
10669
10946
  const parseResult = LoggingLevelSchema.safeParse(level);
10670
10947
  if (parseResult.success) {
@@ -10674,6 +10951,21 @@ var Server = class extends Protocol {
10674
10951
  });
10675
10952
  }
10676
10953
  }
10954
+ /**
10955
+ * Access experimental features.
10956
+ *
10957
+ * WARNING: These APIs are experimental and may change without notice.
10958
+ *
10959
+ * @experimental
10960
+ */
10961
+ get experimental() {
10962
+ if (!this._experimental) {
10963
+ this._experimental = {
10964
+ tasks: new ExperimentalServerTasks(this)
10965
+ };
10966
+ }
10967
+ return this._experimental;
10968
+ }
10677
10969
  /**
10678
10970
  * Registers new capabilities. This can only be called before connecting to a transport.
10679
10971
  *
@@ -10685,21 +10977,62 @@ var Server = class extends Protocol {
10685
10977
  }
10686
10978
  this._capabilities = mergeCapabilities(this._capabilities, capabilities);
10687
10979
  }
10980
+ /**
10981
+ * Override request handler registration to enforce server-side validation for tools/call.
10982
+ */
10983
+ setRequestHandler(requestSchema, handler) {
10984
+ const shape = getObjectShape(requestSchema);
10985
+ const methodSchema = shape?.method;
10986
+ if (!methodSchema) {
10987
+ throw new Error("Schema is missing a method literal");
10988
+ }
10989
+ const methodValue = getLiteralValue(methodSchema);
10990
+ if (typeof methodValue !== "string") {
10991
+ throw new Error("Schema method literal must be a string");
10992
+ }
10993
+ const method = methodValue;
10994
+ if (method === "tools/call") {
10995
+ const wrappedHandler = async (request, extra) => {
10996
+ const validatedRequest = safeParse(CallToolRequestSchema, request);
10997
+ if (!validatedRequest.success) {
10998
+ const errorMessage = validatedRequest.error instanceof Error ? validatedRequest.error.message : String(validatedRequest.error);
10999
+ throw new McpError(ErrorCode.InvalidParams, `Invalid tools/call request: ${errorMessage}`);
11000
+ }
11001
+ const { params } = validatedRequest.data;
11002
+ const result = await Promise.resolve(handler(request, extra));
11003
+ if (params.task) {
11004
+ const taskValidationResult = safeParse(CreateTaskResultSchema, result);
11005
+ if (!taskValidationResult.success) {
11006
+ const errorMessage = taskValidationResult.error instanceof Error ? taskValidationResult.error.message : String(taskValidationResult.error);
11007
+ throw new McpError(ErrorCode.InvalidParams, `Invalid task creation result: ${errorMessage}`);
11008
+ }
11009
+ return taskValidationResult.data;
11010
+ }
11011
+ const validationResult = safeParse(CallToolResultSchema, result);
11012
+ if (!validationResult.success) {
11013
+ const errorMessage = validationResult.error instanceof Error ? validationResult.error.message : String(validationResult.error);
11014
+ throw new McpError(ErrorCode.InvalidParams, `Invalid tools/call result: ${errorMessage}`);
11015
+ }
11016
+ return validationResult.data;
11017
+ };
11018
+ return super.setRequestHandler(requestSchema, wrappedHandler);
11019
+ }
11020
+ return super.setRequestHandler(requestSchema, handler);
11021
+ }
10688
11022
  assertCapabilityForMethod(method) {
10689
- var _a2, _b2, _c2;
10690
11023
  switch (method) {
10691
11024
  case "sampling/createMessage":
10692
- if (!((_a2 = this._clientCapabilities) === null || _a2 === void 0 ? void 0 : _a2.sampling)) {
11025
+ if (!this._clientCapabilities?.sampling) {
10693
11026
  throw new Error(`Client does not support sampling (required for ${method})`);
10694
11027
  }
10695
11028
  break;
10696
11029
  case "elicitation/create":
10697
- if (!((_b2 = this._clientCapabilities) === null || _b2 === void 0 ? void 0 : _b2.elicitation)) {
11030
+ if (!this._clientCapabilities?.elicitation) {
10698
11031
  throw new Error(`Client does not support elicitation (required for ${method})`);
10699
11032
  }
10700
11033
  break;
10701
11034
  case "roots/list":
10702
- if (!((_c2 = this._clientCapabilities) === null || _c2 === void 0 ? void 0 : _c2.roots)) {
11035
+ if (!this._clientCapabilities?.roots) {
10703
11036
  throw new Error(`Client does not support listing roots (required for ${method})`);
10704
11037
  }
10705
11038
  break;
@@ -10708,7 +11041,6 @@ var Server = class extends Protocol {
10708
11041
  }
10709
11042
  }
10710
11043
  assertNotificationCapability(method) {
10711
- var _a2, _b2;
10712
11044
  switch (method) {
10713
11045
  case "notifications/message":
10714
11046
  if (!this._capabilities.logging) {
@@ -10732,7 +11064,7 @@ var Server = class extends Protocol {
10732
11064
  }
10733
11065
  break;
10734
11066
  case "notifications/elicitation/complete":
10735
- if (!((_b2 = (_a2 = this._clientCapabilities) === null || _a2 === void 0 ? void 0 : _a2.elicitation) === null || _b2 === void 0 ? void 0 : _b2.url)) {
11067
+ if (!this._clientCapabilities?.elicitation?.url) {
10736
11068
  throw new Error(`Client does not support URL elicitation (required for ${method})`);
10737
11069
  }
10738
11070
  break;
@@ -10743,6 +11075,9 @@ var Server = class extends Protocol {
10743
11075
  }
10744
11076
  }
10745
11077
  assertRequestHandlerCapability(method) {
11078
+ if (!this._capabilities) {
11079
+ return;
11080
+ }
10746
11081
  switch (method) {
10747
11082
  case "completion/complete":
10748
11083
  if (!this._capabilities.completions) {
@@ -10773,11 +11108,28 @@ var Server = class extends Protocol {
10773
11108
  throw new Error(`Server does not support tools (required for ${method})`);
10774
11109
  }
10775
11110
  break;
11111
+ case "tasks/get":
11112
+ case "tasks/list":
11113
+ case "tasks/result":
11114
+ case "tasks/cancel":
11115
+ if (!this._capabilities.tasks) {
11116
+ throw new Error(`Server does not support tasks capability (required for ${method})`);
11117
+ }
11118
+ break;
10776
11119
  case "ping":
10777
11120
  case "initialize":
10778
11121
  break;
10779
11122
  }
10780
11123
  }
11124
+ assertTaskCapability(method) {
11125
+ assertClientRequestTaskCapability(this._clientCapabilities?.tasks?.requests, method, "Client");
11126
+ }
11127
+ assertTaskHandlerCapability(method) {
11128
+ if (!this._capabilities) {
11129
+ return;
11130
+ }
11131
+ assertToolsCallTaskCapability(this._capabilities.tasks?.requests, method, "Server");
11132
+ }
10781
11133
  async _oninitialize(request) {
10782
11134
  const requestedVersion = request.params.protocolVersion;
10783
11135
  this._clientCapabilities = request.params.capabilities;
@@ -10808,10 +11160,10 @@ var Server = class extends Protocol {
10808
11160
  async ping() {
10809
11161
  return this.request({ method: "ping" }, EmptyResultSchema);
10810
11162
  }
11163
+ // Implementation
10811
11164
  async createMessage(params, options) {
10812
- var _a2, _b2;
10813
11165
  if (params.tools || params.toolChoice) {
10814
- if (!((_b2 = (_a2 = this._clientCapabilities) === null || _a2 === void 0 ? void 0 : _a2.sampling) === null || _b2 === void 0 ? void 0 : _b2.tools)) {
11166
+ if (!this._clientCapabilities?.sampling?.tools) {
10815
11167
  throw new Error("Client does not support sampling tools capability.");
10816
11168
  }
10817
11169
  }
@@ -10838,6 +11190,9 @@ var Server = class extends Protocol {
10838
11190
  }
10839
11191
  }
10840
11192
  }
11193
+ if (params.tools) {
11194
+ return this.request({ method: "sampling/createMessage", params }, CreateMessageResultWithToolsSchema, options);
11195
+ }
10841
11196
  return this.request({ method: "sampling/createMessage", params }, CreateMessageResultSchema, options);
10842
11197
  }
10843
11198
  /**
@@ -10848,18 +11203,17 @@ var Server = class extends Protocol {
10848
11203
  * @returns The result of the elicitation request.
10849
11204
  */
10850
11205
  async elicitInput(params, options) {
10851
- var _a2, _b2, _c2, _d, _e;
10852
- const mode = (_a2 = params.mode) !== null && _a2 !== void 0 ? _a2 : "form";
11206
+ const mode = params.mode ?? "form";
10853
11207
  switch (mode) {
10854
11208
  case "url": {
10855
- if (!((_c2 = (_b2 = this._clientCapabilities) === null || _b2 === void 0 ? void 0 : _b2.elicitation) === null || _c2 === void 0 ? void 0 : _c2.url)) {
11209
+ if (!this._clientCapabilities?.elicitation?.url) {
10856
11210
  throw new Error("Client does not support url elicitation.");
10857
11211
  }
10858
11212
  const urlParams = params;
10859
11213
  return this.request({ method: "elicitation/create", params: urlParams }, ElicitResultSchema, options);
10860
11214
  }
10861
11215
  case "form": {
10862
- if (!((_e = (_d = this._clientCapabilities) === null || _d === void 0 ? void 0 : _d.elicitation) === null || _e === void 0 ? void 0 : _e.form)) {
11216
+ if (!this._clientCapabilities?.elicitation?.form) {
10863
11217
  throw new Error("Client does not support form elicitation.");
10864
11218
  }
10865
11219
  const formParams = params.mode === "form" ? params : { ...params, mode: "form" };
@@ -10891,8 +11245,7 @@ var Server = class extends Protocol {
10891
11245
  * @returns A function that emits the completion notification when awaited.
10892
11246
  */
10893
11247
  createElicitationCompletionNotifier(elicitationId, options) {
10894
- var _a2, _b2;
10895
- if (!((_b2 = (_a2 = this._clientCapabilities) === null || _a2 === void 0 ? void 0 : _a2.elicitation) === null || _b2 === void 0 ? void 0 : _b2.url)) {
11248
+ if (!this._clientCapabilities?.elicitation?.url) {
10896
11249
  throw new Error("Client does not support URL elicitation (required for notifications/elicitation/complete)");
10897
11250
  }
10898
11251
  return () => this.notification({
@@ -10941,19 +11294,24 @@ var Server = class extends Protocol {
10941
11294
  // node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js
10942
11295
  import process4 from "node:process";
10943
11296
  var StdioServerTransport = class {
10944
- constructor(_stdin = process4.stdin, _stdout = process4.stdout) {
11297
+ constructor(_stdin = process4.stdin, _stdout = process4.stdout, options) {
10945
11298
  this._stdin = _stdin;
10946
11299
  this._stdout = _stdout;
10947
- this._readBuffer = new ReadBuffer();
10948
11300
  this._started = false;
10949
11301
  this._ondata = (chunk) => {
10950
- this._readBuffer.append(chunk);
10951
- this.processReadBuffer();
11302
+ try {
11303
+ this._readBuffer.append(chunk);
11304
+ this.processReadBuffer();
11305
+ } catch (error) {
11306
+ this.onerror?.(error);
11307
+ this.close().catch(() => {
11308
+ });
11309
+ }
10952
11310
  };
10953
11311
  this._onerror = (error) => {
10954
- var _a2;
10955
- (_a2 = this.onerror) === null || _a2 === void 0 ? void 0 : _a2.call(this, error);
11312
+ this.onerror?.(error);
10956
11313
  };
11314
+ this._readBuffer = new ReadBuffer({ maxBufferSize: options?.maxBufferSize });
10957
11315
  }
10958
11316
  /**
10959
11317
  * Starts listening for messages on stdin.
@@ -10967,21 +11325,19 @@ var StdioServerTransport = class {
10967
11325
  this._stdin.on("error", this._onerror);
10968
11326
  }
10969
11327
  processReadBuffer() {
10970
- var _a2, _b2;
10971
11328
  while (true) {
10972
11329
  try {
10973
11330
  const message = this._readBuffer.readMessage();
10974
11331
  if (message === null) {
10975
11332
  break;
10976
11333
  }
10977
- (_a2 = this.onmessage) === null || _a2 === void 0 ? void 0 : _a2.call(this, message);
11334
+ this.onmessage?.(message);
10978
11335
  } catch (error) {
10979
- (_b2 = this.onerror) === null || _b2 === void 0 ? void 0 : _b2.call(this, error);
11336
+ this.onerror?.(error);
10980
11337
  }
10981
11338
  }
10982
11339
  }
10983
11340
  async close() {
10984
- var _a2;
10985
11341
  this._stdin.off("data", this._ondata);
10986
11342
  this._stdin.off("error", this._onerror);
10987
11343
  const remainingDataListeners = this._stdin.listenerCount("data");
@@ -10989,15 +11345,15 @@ var StdioServerTransport = class {
10989
11345
  this._stdin.pause();
10990
11346
  }
10991
11347
  this._readBuffer.clear();
10992
- (_a2 = this.onclose) === null || _a2 === void 0 ? void 0 : _a2.call(this);
11348
+ this.onclose?.();
10993
11349
  }
10994
11350
  send(message) {
10995
- return new Promise((resolve10) => {
11351
+ return new Promise((resolve11) => {
10996
11352
  const json = serializeMessage(message);
10997
11353
  if (this._stdout.write(json)) {
10998
- resolve10();
11354
+ resolve11();
10999
11355
  } else {
11000
- this._stdout.once("drain", resolve10);
11356
+ this._stdout.once("drain", resolve11);
11001
11357
  }
11002
11358
  });
11003
11359
  }
@@ -11154,7 +11510,7 @@ async function resolveIdeBridgeUpstream() {
11154
11510
  return void 0;
11155
11511
  }
11156
11512
  const workspacePath = fromFile?.workspacePath ?? process.env["GEMINI_CLI_IDE_WORKSPACE_PATH"];
11157
- const workspacePaths = (workspacePath ?? "").split(path9.delimiter).filter(Boolean).map((p) => path9.resolve(p));
11513
+ const workspacePaths = (workspacePath ?? "").split(path10.delimiter).filter(Boolean).map((p) => path10.resolve(p));
11158
11514
  return {
11159
11515
  port,
11160
11516
  authToken: fromFile?.authToken ?? process.env["GEMINI_CLI_IDE_AUTH_TOKEN"],
@@ -11375,7 +11731,7 @@ var IdeBridge = class {
11375
11731
  "serve",
11376
11732
  this.options.socketPathInContainer
11377
11733
  ];
11378
- return new Promise((resolve10) => {
11734
+ return new Promise((resolve11) => {
11379
11735
  const child = spawn2(command2, args, {
11380
11736
  stdio: ["pipe", "pipe", "pipe"]
11381
11737
  });
@@ -11401,7 +11757,7 @@ var IdeBridge = class {
11401
11757
  logger.debug(`helper exec failed: ${stderr.trim()}`);
11402
11758
  }
11403
11759
  }
11404
- resolve10(result);
11760
+ resolve11(result);
11405
11761
  };
11406
11762
  const timer = setTimeout(
11407
11763
  () => settle(void 0),
@@ -11474,13 +11830,13 @@ var IdeBridge = class {
11474
11830
  * host, before it reaches the IDE.
11475
11831
  */
11476
11832
  assertWithinWorkspace(filePath) {
11477
- if (typeof filePath !== "string" || !path9.isAbsolute(filePath)) {
11833
+ if (typeof filePath !== "string" || !path10.isAbsolute(filePath)) {
11478
11834
  throw new McpError(
11479
11835
  ErrorCode.InvalidParams,
11480
11836
  "filePath must be an absolute path"
11481
11837
  );
11482
11838
  }
11483
- const resolved = path9.resolve(filePath);
11839
+ const resolved = path10.resolve(filePath);
11484
11840
  const allowed = this.upstreamInfo.workspacePaths.some(
11485
11841
  (workspace) => isSubpath(workspace, resolved)
11486
11842
  );
@@ -11519,7 +11875,7 @@ var IdeBridge = class {
11519
11875
  }
11520
11876
  };
11521
11877
  function delay(ms) {
11522
- return new Promise((resolve10) => setTimeout(resolve10, ms));
11878
+ return new Promise((resolve11) => setTimeout(resolve11, ms));
11523
11879
  }
11524
11880
 
11525
11881
  // packages/cli/src/utils/sandbox.ts
@@ -11590,8 +11946,8 @@ async function start_sandbox(config, nodeArgs = [], cliConfig, cliArgs = []) {
11590
11946
  const dirToDelete = sandboxTmpDir;
11591
11947
  sandboxTmpDir = null;
11592
11948
  try {
11593
- if (fs7.existsSync(dirToDelete)) {
11594
- fs7.rmSync(dirToDelete, { recursive: true, force: true });
11949
+ if (fs8.existsSync(dirToDelete)) {
11950
+ fs8.rmSync(dirToDelete, { recursive: true, force: true });
11595
11951
  }
11596
11952
  } catch {
11597
11953
  }
@@ -11600,8 +11956,8 @@ async function start_sandbox(config, nodeArgs = [], cliConfig, cliArgs = []) {
11600
11956
  const fileToDelete = tempProfileFile;
11601
11957
  tempProfileFile = null;
11602
11958
  try {
11603
- if (fs7.existsSync(fileToDelete)) {
11604
- fs7.unlinkSync(fileToDelete);
11959
+ if (fs8.existsSync(fileToDelete)) {
11960
+ fs8.unlinkSync(fileToDelete);
11605
11961
  }
11606
11962
  } catch {
11607
11963
  }
@@ -11638,24 +11994,24 @@ async function start_sandbox(config, nodeArgs = [], cliConfig, cliArgs = []) {
11638
11994
  new URL(`sandbox-macos-${profile}.sb`, import.meta.url)
11639
11995
  );
11640
11996
  if (!BUILTIN_SEATBELT_PROFILES.includes(profile)) {
11641
- const safeProfile = path10.basename(profile);
11997
+ const safeProfile = path11.basename(profile);
11642
11998
  const fileName = `sandbox-macos-${safeProfile}.sb`;
11643
11999
  const userHome = homedir();
11644
- const userProfileFile = userHome ? path10.join(userHome, GEMINI_DIR, fileName) : "";
11645
- const projectProfileFile = path10.join(GEMINI_DIR, fileName);
11646
- profileFile = userProfileFile && fs7.existsSync(userProfileFile) ? userProfileFile : projectProfileFile;
12000
+ const userProfileFile = userHome ? path11.join(userHome, GEMINI_DIR, fileName) : "";
12001
+ const projectProfileFile = path11.join(GEMINI_DIR, fileName);
12002
+ profileFile = userProfileFile && fs8.existsSync(userProfileFile) ? userProfileFile : projectProfileFile;
11647
12003
  } else {
11648
- if (!fs7.existsSync(profileFile)) {
12004
+ if (!fs8.existsSync(profileFile)) {
11649
12005
  const content = BUILTIN_SEATBELT_PROFILE_CONTENTS[profile];
11650
12006
  if (content) {
11651
12007
  try {
11652
- const tempDir = fs7.realpathSync(os3.tmpdir());
12008
+ const tempDir = fs8.realpathSync(os3.tmpdir());
11653
12009
  const rand = randomBytes(8).toString("hex");
11654
- tempProfileFile = path10.join(
12010
+ tempProfileFile = path11.join(
11655
12011
  tempDir,
11656
12012
  `gemini-sandbox-macos-${profile}-${rand}.sb`
11657
12013
  );
11658
- fs7.writeFileSync(tempProfileFile, content, {
12014
+ fs8.writeFileSync(tempProfileFile, content, {
11659
12015
  encoding: "utf8",
11660
12016
  mode: 384
11661
12017
  });
@@ -11669,7 +12025,7 @@ async function start_sandbox(config, nodeArgs = [], cliConfig, cliArgs = []) {
11669
12025
  }
11670
12026
  }
11671
12027
  try {
11672
- if (!fs7.existsSync(profileFile)) {
12028
+ if (!fs8.existsSync(profileFile)) {
11673
12029
  throw new FatalSandboxError(
11674
12030
  `Missing macos seatbelt profile file '${profileFile}'`
11675
12031
  );
@@ -11679,26 +12035,26 @@ async function start_sandbox(config, nodeArgs = [], cliConfig, cliArgs = []) {
11679
12035
  ...process.env["DEBUG"] ? ["--inspect-brk"] : [],
11680
12036
  ...nodeArgs
11681
12037
  ].join(" ");
11682
- const targetDir = fs7.realpathSync(process.cwd());
12038
+ const targetDir = fs8.realpathSync(process.cwd());
11683
12039
  if (isSensitiveHostPath(targetDir)) {
11684
12040
  throw new FatalSandboxError(
11685
12041
  `Running sandbox from a sensitive host directory '${targetDir}' is strictly prohibited`
11686
12042
  );
11687
12043
  }
11688
- const hostTmpDir = fs7.realpathSync(os3.tmpdir());
11689
- const resolvedTmpDir = fs7.mkdtempSync(
11690
- path10.join(hostTmpDir, "gemini-sandbox-")
12044
+ const hostTmpDir = fs8.realpathSync(os3.tmpdir());
12045
+ const resolvedTmpDir = fs8.mkdtempSync(
12046
+ path11.join(hostTmpDir, "gemini-sandbox-")
11691
12047
  );
11692
12048
  try {
11693
- fs7.chmodSync(resolvedTmpDir, 448);
12049
+ fs8.chmodSync(resolvedTmpDir, 448);
11694
12050
  } catch {
11695
12051
  }
11696
12052
  sandboxTmpDir = resolvedTmpDir;
11697
12053
  const userHome = homedir();
11698
12054
  if (userHome) {
11699
- const seatbeltCacheDir = path10.join(userHome, ".cache", GEMINI_DIR);
12055
+ const seatbeltCacheDir = path11.join(userHome, ".cache", GEMINI_DIR);
11700
12056
  try {
11701
- fs7.mkdirSync(seatbeltCacheDir, { recursive: true });
12057
+ fs8.mkdirSync(seatbeltCacheDir, { recursive: true });
11702
12058
  } catch {
11703
12059
  }
11704
12060
  }
@@ -11708,9 +12064,9 @@ async function start_sandbox(config, nodeArgs = [], cliConfig, cliArgs = []) {
11708
12064
  "-D",
11709
12065
  `TMP_DIR=${resolvedTmpDir}`,
11710
12066
  "-D",
11711
- `HOME_DIR=${fs7.realpathSync(homedir())}`,
12067
+ `HOME_DIR=${fs8.realpathSync(homedir())}`,
11712
12068
  "-D",
11713
- `CACHE_DIR=${fs7.realpathSync((await execAsync("getconf DARWIN_USER_CACHE_DIR")).stdout.trim())}`
12069
+ `CACHE_DIR=${fs8.realpathSync((await execAsync("getconf DARWIN_USER_CACHE_DIR")).stdout.trim())}`
11714
12070
  ];
11715
12071
  const MAX_INCLUDE_DIRS = 5;
11716
12072
  const configTargetDir = cliConfig?.getTargetDir() ? resolveToRealPath(cliConfig.getTargetDir()) : targetDir;
@@ -11741,8 +12097,8 @@ async function start_sandbox(config, nodeArgs = [], cliConfig, cliArgs = []) {
11741
12097
  }
11742
12098
  if (config.allowedPaths) {
11743
12099
  for (const hostPath of config.allowedPaths) {
11744
- if (hostPath && path10.isAbsolute(hostPath) && fs7.existsSync(hostPath)) {
11745
- const realDir = fs7.realpathSync(hostPath);
12100
+ if (hostPath && path11.isAbsolute(hostPath) && fs8.existsSync(hostPath)) {
12101
+ const realDir = fs8.realpathSync(hostPath);
11746
12102
  if (!includedDirs.includes(realDir) && realDir !== targetDir && realDir !== configTargetDir) {
11747
12103
  if (isSensitiveHostPath(realDir)) {
11748
12104
  debugLogger.warn(
@@ -11830,7 +12186,7 @@ async function start_sandbox(config, nodeArgs = [], cliConfig, cliArgs = []) {
11830
12186
  stdio: "inherit",
11831
12187
  env: sandboxEnv
11832
12188
  });
11833
- return await new Promise((resolve10, reject) => {
12189
+ return await new Promise((resolve11, reject) => {
11834
12190
  sandboxProcess2?.on("error", (err) => {
11835
12191
  cleanup();
11836
12192
  reject(err);
@@ -11838,7 +12194,7 @@ async function start_sandbox(config, nodeArgs = [], cliConfig, cliArgs = []) {
11838
12194
  sandboxProcess2?.on("close", (code) => {
11839
12195
  process.stdin.resume();
11840
12196
  cleanup();
11841
- resolve10(code ?? 1);
12197
+ resolve11(code ?? 1);
11842
12198
  });
11843
12199
  });
11844
12200
  } catch (err) {
@@ -11852,17 +12208,17 @@ async function start_sandbox(config, nodeArgs = [], cliConfig, cliArgs = []) {
11852
12208
  const command2 = config.command === "runsc" ? "docker" : config.command;
11853
12209
  if (!command2) throw new FatalSandboxError("Sandbox command is required");
11854
12210
  debugLogger.log(`hopping into sandbox (command: ${command2}) ...`);
11855
- const gcPath = process.argv[1] ? fs7.realpathSync(process.argv[1]) : "";
11856
- const projectSandboxDockerfile = path10.join(
12211
+ const gcPath = process.argv[1] ? fs8.realpathSync(process.argv[1]) : "";
12212
+ const projectSandboxDockerfile = path11.join(
11857
12213
  GEMINI_DIR,
11858
12214
  "sandbox.Dockerfile"
11859
12215
  );
11860
- const isCustomProjectSandbox = fs7.existsSync(projectSandboxDockerfile);
12216
+ const isCustomProjectSandbox = fs8.existsSync(projectSandboxDockerfile);
11861
12217
  const image = config.image;
11862
12218
  if (!image) throw new FatalSandboxError("Sandbox image is required");
11863
12219
  if (!/^[a-zA-Z0-9_.:/-]+$/.test(image))
11864
12220
  throw new FatalSandboxError("Invalid sandbox image name");
11865
- const workdir = path10.resolve(process.cwd());
12221
+ const workdir = path11.resolve(process.cwd());
11866
12222
  const containerWorkdir = getContainerPath(workdir);
11867
12223
  if (process.env["BUILD_SANDBOX"]) {
11868
12224
  if (!gcPath.includes("gemini-cli/packages/")) {
@@ -11873,13 +12229,13 @@ async function start_sandbox(config, nodeArgs = [], cliConfig, cliArgs = []) {
11873
12229
  debugLogger.log("building sandbox ...");
11874
12230
  const gcRoot = gcPath.split("/packages/")[0];
11875
12231
  let buildArgs = "";
11876
- const projectSandboxDockerfile2 = path10.join(
12232
+ const projectSandboxDockerfile2 = path11.join(
11877
12233
  GEMINI_DIR,
11878
12234
  "sandbox.Dockerfile"
11879
12235
  );
11880
12236
  if (isCustomProjectSandbox) {
11881
12237
  debugLogger.log(`using ${projectSandboxDockerfile2} for sandbox`);
11882
- buildArgs += `-f ${path10.resolve(projectSandboxDockerfile2)} -i ${image}`;
12238
+ buildArgs += `-f ${path11.resolve(projectSandboxDockerfile2)} -i ${image}`;
11883
12239
  }
11884
12240
  execSync(
11885
12241
  `cd ${gcRoot} && node scripts/build_sandbox.js -s ${buildArgs}`,
@@ -11925,24 +12281,24 @@ async function start_sandbox(config, nodeArgs = [], cliConfig, cliArgs = []) {
11925
12281
  }
11926
12282
  args.push("--volume", `${workdir}:${containerWorkdir}`);
11927
12283
  if (!sandboxTmpDir) {
11928
- const hostTmpDir = fs7.realpathSync(os3.tmpdir());
11929
- sandboxTmpDir = fs7.mkdtempSync(path10.join(hostTmpDir, "gemini-sandbox-"));
12284
+ const hostTmpDir = fs8.realpathSync(os3.tmpdir());
12285
+ sandboxTmpDir = fs8.mkdtempSync(path11.join(hostTmpDir, "gemini-sandbox-"));
11930
12286
  try {
11931
- fs7.chmodSync(sandboxTmpDir, 448);
12287
+ fs8.chmodSync(sandboxTmpDir, 448);
11932
12288
  } catch {
11933
12289
  }
11934
12290
  }
11935
12291
  const userHomeDirOnHost = homedir();
11936
12292
  let rawSettings = {};
11937
12293
  if (userHomeDirOnHost) {
11938
- const userSettingsFileOnHost = path10.join(
12294
+ const userSettingsFileOnHost = path11.join(
11939
12295
  userHomeDirOnHost,
11940
12296
  GEMINI_DIR,
11941
12297
  "settings.json"
11942
12298
  );
11943
- if (fs7.existsSync(userSettingsFileOnHost)) {
12299
+ if (fs8.existsSync(userSettingsFileOnHost)) {
11944
12300
  try {
11945
- const rawContent = fs7.readFileSync(userSettingsFileOnHost, "utf8");
12301
+ const rawContent = fs8.readFileSync(userSettingsFileOnHost, "utf8");
11946
12302
  const parsed = JSON.parse((0, import_strip_json_comments2.default)(rawContent));
11947
12303
  if (isRecord3(parsed)) {
11948
12304
  rawSettings = parsed;
@@ -11955,8 +12311,8 @@ async function start_sandbox(config, nodeArgs = [], cliConfig, cliArgs = []) {
11955
12311
  }
11956
12312
  }
11957
12313
  const sanitizedSettings = sanitizeSettingsForSandbox(rawSettings);
11958
- const sanitizedSettingsFile = path10.join(sandboxTmpDir, "settings.json");
11959
- fs7.writeFileSync(
12314
+ const sanitizedSettingsFile = path11.join(sandboxTmpDir, "settings.json");
12315
+ fs8.writeFileSync(
11960
12316
  sanitizedSettingsFile,
11961
12317
  JSON.stringify(sanitizedSettings, null, 2),
11962
12318
  { mode: 384 }
@@ -11966,8 +12322,8 @@ async function start_sandbox(config, nodeArgs = [], cliConfig, cliArgs = []) {
11966
12322
  );
11967
12323
  args.push("--env", "HOME=/home/node");
11968
12324
  args.push("--volume", `${sandboxTmpDir}:${userSettingsDirInSandbox}:rw`);
11969
- const gcloudConfigDir = userHomeDirOnHost ? path10.join(userHomeDirOnHost, ".config", "gcloud") : "";
11970
- if (gcloudConfigDir && fs7.existsSync(gcloudConfigDir)) {
12325
+ const gcloudConfigDir = userHomeDirOnHost ? path11.join(userHomeDirOnHost, ".config", "gcloud") : "";
12326
+ if (gcloudConfigDir && fs8.existsSync(gcloudConfigDir)) {
11971
12327
  args.push(
11972
12328
  "--volume",
11973
12329
  `${gcloudConfigDir}:${getContainerPath(gcloudConfigDir)}:ro`
@@ -11975,7 +12331,7 @@ async function start_sandbox(config, nodeArgs = [], cliConfig, cliArgs = []) {
11975
12331
  }
11976
12332
  if (process.env["GOOGLE_APPLICATION_CREDENTIALS"]) {
11977
12333
  const adcFile = process.env["GOOGLE_APPLICATION_CREDENTIALS"];
11978
- if (fs7.existsSync(adcFile)) {
12334
+ if (fs8.existsSync(adcFile)) {
11979
12335
  args.push("--volume", `${adcFile}:${getContainerPath(adcFile)}:ro`);
11980
12336
  args.push(
11981
12337
  "--env",
@@ -11990,7 +12346,7 @@ async function start_sandbox(config, nodeArgs = [], cliConfig, cliArgs = []) {
11990
12346
  to = to || from;
11991
12347
  opts = opts || "ro";
11992
12348
  mount = `${from}:${to}:${opts}`;
11993
- if (!path10.isAbsolute(from)) {
12349
+ if (!path11.isAbsolute(from)) {
11994
12350
  throw new FatalSandboxError(
11995
12351
  `Path '${from}' listed in SANDBOX_MOUNTS must be absolute`
11996
12352
  );
@@ -12000,7 +12356,7 @@ async function start_sandbox(config, nodeArgs = [], cliConfig, cliArgs = []) {
12000
12356
  `Mounting sensitive host path '${from}' listed in SANDBOX_MOUNTS is strictly prohibited`
12001
12357
  );
12002
12358
  }
12003
- if (!fs7.existsSync(from)) {
12359
+ if (!fs8.existsSync(from)) {
12004
12360
  throw new FatalSandboxError(
12005
12361
  `Missing mount path '${from}' listed in SANDBOX_MOUNTS`
12006
12362
  );
@@ -12012,7 +12368,7 @@ async function start_sandbox(config, nodeArgs = [], cliConfig, cliArgs = []) {
12012
12368
  }
12013
12369
  if (config.allowedPaths) {
12014
12370
  for (const hostPath of config.allowedPaths) {
12015
- if (hostPath && path10.isAbsolute(hostPath) && fs7.existsSync(hostPath)) {
12371
+ if (hostPath && path11.isAbsolute(hostPath) && fs8.existsSync(hostPath)) {
12016
12372
  if (isSensitiveHostPath(hostPath)) {
12017
12373
  debugLogger.warn(
12018
12374
  `Skipping sensitive path '${hostPath}' in config.allowedPaths`
@@ -12152,13 +12508,13 @@ async function start_sandbox(config, nodeArgs = [], cliConfig, cliArgs = []) {
12152
12508
  if (process.env["TERM_PROGRAM"]) {
12153
12509
  args.push("--env", `TERM_PROGRAM=${process.env["TERM_PROGRAM"]}`);
12154
12510
  }
12155
- const ideWorkspacePath = process.env["GEMINI_CLI_IDE_WORKSPACE_PATH"] ?? ideBridgeUpstream?.workspacePaths.join(path10.delimiter);
12511
+ const ideWorkspacePath = process.env["GEMINI_CLI_IDE_WORKSPACE_PATH"] ?? ideBridgeUpstream?.workspacePaths.join(path11.delimiter);
12156
12512
  if (ideWorkspacePath) {
12157
12513
  args.push("--env", `GEMINI_CLI_IDE_WORKSPACE_PATH=${ideWorkspacePath}`);
12158
12514
  }
12159
12515
  if (ideBridge) {
12160
- fs7.writeFileSync(
12161
- path10.join(sandboxTmpDir, IDE_BRIDGE_HELPER_FILENAME),
12516
+ fs8.writeFileSync(
12517
+ path11.join(sandboxTmpDir, IDE_BRIDGE_HELPER_FILENAME),
12162
12518
  IDE_BRIDGE_HELPER_SOURCE,
12163
12519
  { mode: 384 }
12164
12520
  );
@@ -12173,9 +12529,9 @@ async function start_sandbox(config, nodeArgs = [], cliConfig, cliArgs = []) {
12173
12529
  );
12174
12530
  }
12175
12531
  if (process.env["VIRTUAL_ENV"]?.toLowerCase().startsWith(workdir.toLowerCase())) {
12176
- const sandboxVenvPath = path10.resolve(GEMINI_DIR, "sandbox.venv");
12177
- if (!fs7.existsSync(sandboxVenvPath)) {
12178
- fs7.mkdirSync(sandboxVenvPath, { recursive: true });
12532
+ const sandboxVenvPath = path11.resolve(GEMINI_DIR, "sandbox.venv");
12533
+ if (!fs8.existsSync(sandboxVenvPath)) {
12534
+ fs8.mkdirSync(sandboxVenvPath, { recursive: true });
12179
12535
  }
12180
12536
  args.push(
12181
12537
  "--volume",
@@ -12210,8 +12566,8 @@ async function start_sandbox(config, nodeArgs = [], cliConfig, cliArgs = []) {
12210
12566
  }
12211
12567
  args.push("--env", `SANDBOX=${containerName}`);
12212
12568
  if (command2 === "podman") {
12213
- const emptyAuthFilePath = path10.join(os3.tmpdir(), "empty_auth.json");
12214
- fs7.writeFileSync(emptyAuthFilePath, "{}", "utf-8");
12569
+ const emptyAuthFilePath = path11.join(os3.tmpdir(), "empty_auth.json");
12570
+ fs8.writeFileSync(emptyAuthFilePath, "{}", "utf-8");
12215
12571
  args.push("--authfile", emptyAuthFilePath);
12216
12572
  }
12217
12573
  let userFlag = "";
@@ -12330,7 +12686,7 @@ async function start_sandbox(config, nodeArgs = [], cliConfig, cliArgs = []) {
12330
12686
  isSandboxAlive: () => container.exitCode === null && container.signalCode === null
12331
12687
  });
12332
12688
  }
12333
- return await new Promise((resolve10, reject) => {
12689
+ return await new Promise((resolve11, reject) => {
12334
12690
  sandboxProcess?.on("error", (err) => {
12335
12691
  coreEvents.emitFeedback("error", "Sandbox process error", err);
12336
12692
  reject(err);
@@ -12343,7 +12699,7 @@ async function start_sandbox(config, nodeArgs = [], cliConfig, cliArgs = []) {
12343
12699
  `Sandbox process exited with code: ${code}, signal: ${signal}`
12344
12700
  );
12345
12701
  }
12346
- resolve10(code ?? 1);
12702
+ resolve11(code ?? 1);
12347
12703
  });
12348
12704
  });
12349
12705
  } finally {
@@ -12356,7 +12712,7 @@ async function start_sandbox(config, nodeArgs = [], cliConfig, cliArgs = []) {
12356
12712
  }
12357
12713
  async function start_lxc_sandbox(config, nodeArgs = [], cliArgs = []) {
12358
12714
  const containerName = config.image || "gemini-sandbox";
12359
- const workdir = path10.resolve(process.cwd());
12715
+ const workdir = path11.resolve(process.cwd());
12360
12716
  if (isSensitiveHostPath(workdir)) {
12361
12717
  throw new FatalSandboxError(
12362
12718
  `Running sandbox from a sensitive host directory '${workdir}' is strictly prohibited`
@@ -12442,7 +12798,7 @@ async function start_lxc_sandbox(config, nodeArgs = [], cliArgs = []) {
12442
12798
  }
12443
12799
  if (config.allowedPaths) {
12444
12800
  for (const hostPath of config.allowedPaths) {
12445
- if (hostPath && path10.isAbsolute(hostPath) && fs7.existsSync(hostPath)) {
12801
+ if (hostPath && path11.isAbsolute(hostPath) && fs8.existsSync(hostPath)) {
12446
12802
  if (isSensitiveHostPath(hostPath)) {
12447
12803
  debugLogger.warn(
12448
12804
  `Skipping sensitive path '${hostPath}' in config.allowedPaths for LXC`
@@ -12536,7 +12892,7 @@ async function start_lxc_sandbox(config, nodeArgs = [], cliArgs = []) {
12536
12892
  const sandboxProcess = spawn3("lxc", args, {
12537
12893
  stdio: "inherit"
12538
12894
  });
12539
- return await new Promise((resolve10, reject) => {
12895
+ return await new Promise((resolve11, reject) => {
12540
12896
  sandboxProcess.on("error", (err) => {
12541
12897
  coreEvents.emitFeedback("error", "LXC sandbox process error", err);
12542
12898
  reject(err);
@@ -12548,7 +12904,7 @@ async function start_lxc_sandbox(config, nodeArgs = [], cliArgs = []) {
12548
12904
  `LXC sandbox process exited with code: ${code}, signal: ${signal}`
12549
12905
  );
12550
12906
  }
12551
- resolve10(code ?? 1);
12907
+ resolve11(code ?? 1);
12552
12908
  });
12553
12909
  });
12554
12910
  } finally {
@@ -12557,7 +12913,7 @@ async function start_lxc_sandbox(config, nodeArgs = [], cliArgs = []) {
12557
12913
  }
12558
12914
  }
12559
12915
  async function imageExists(sandbox, image) {
12560
- return new Promise((resolve10) => {
12916
+ return new Promise((resolve11) => {
12561
12917
  const args = ["images", "-q", image];
12562
12918
  const checkProcess = spawn3(sandbox, args);
12563
12919
  let stdoutData = "";
@@ -12570,18 +12926,18 @@ async function imageExists(sandbox, image) {
12570
12926
  debugLogger.warn(
12571
12927
  `Failed to start '${sandbox}' command for image check: ${err.message}`
12572
12928
  );
12573
- resolve10(false);
12929
+ resolve11(false);
12574
12930
  });
12575
12931
  checkProcess.on("close", (code) => {
12576
12932
  if (code !== 0) {
12577
12933
  }
12578
- resolve10(stdoutData.trim() !== "");
12934
+ resolve11(stdoutData.trim() !== "");
12579
12935
  });
12580
12936
  });
12581
12937
  }
12582
12938
  async function pullImage(sandbox, image, cliConfig) {
12583
12939
  debugLogger.debug(`Attempting to pull image ${image} using ${sandbox}...`);
12584
- return new Promise((resolve10) => {
12940
+ return new Promise((resolve11) => {
12585
12941
  const args = ["pull", image];
12586
12942
  const pullProcess = spawn3(sandbox, args, { stdio: "pipe" });
12587
12943
  let stderrData = "";
@@ -12599,13 +12955,13 @@ async function pullImage(sandbox, image, cliConfig) {
12599
12955
  `Failed to start '${sandbox} pull ${image}' command: ${err.message}`
12600
12956
  );
12601
12957
  cleanup();
12602
- resolve10(false);
12958
+ resolve11(false);
12603
12959
  };
12604
12960
  const onClose = (code) => {
12605
12961
  if (code === 0) {
12606
12962
  debugLogger.log(`Successfully pulled image ${image}.`);
12607
12963
  cleanup();
12608
- resolve10(true);
12964
+ resolve11(true);
12609
12965
  } else {
12610
12966
  debugLogger.warn(
12611
12967
  `Failed to pull image ${image}. '${sandbox} pull ${image}' exited with code ${code}.`
@@ -12613,7 +12969,7 @@ async function pullImage(sandbox, image, cliConfig) {
12613
12969
  if (stderrData.trim()) {
12614
12970
  }
12615
12971
  cleanup();
12616
- resolve10(false);
12972
+ resolve11(false);
12617
12973
  }
12618
12974
  };
12619
12975
  const cleanup = () => {
@@ -12668,7 +13024,7 @@ async function ensureSandboxImageIsPresent(sandbox, image, cliConfig) {
12668
13024
  }
12669
13025
 
12670
13026
  // packages/cli/src/utils/sandboxFolderTrust.ts
12671
- import * as path11 from "node:path";
13027
+ import * as path12 from "node:path";
12672
13028
  import * as readline2 from "node:readline";
12673
13029
  import { Writable } from "node:stream";
12674
13030
  var TRUST_WORKSPACE_ENV = "GEMINI_CLI_TRUST_WORKSPACE";
@@ -12722,9 +13078,9 @@ async function resolveFolderTrustForSandbox({
12722
13078
  process.env[TRUST_WORKSPACE_ENV] = isTrusted ? "true" : "false";
12723
13079
  }
12724
13080
  function formatFolderTrustPrompt(workspaceDir, discoveryResults) {
12725
- const folderName = stripAnsi(path11.basename(workspaceDir)).trim() || stripAnsi(workspaceDir);
12726
- const parentDir = path11.dirname(workspaceDir);
12727
- const parentFolderName = stripAnsi(path11.basename(parentDir)).trim() || stripAnsi(parentDir);
13081
+ const folderName = stripAnsi(path12.basename(workspaceDir)).trim() || stripAnsi(workspaceDir);
13082
+ const parentDir = path12.dirname(workspaceDir);
13083
+ const parentFolderName = stripAnsi(path12.basename(parentDir)).trim() || stripAnsi(parentDir);
12728
13084
  const lines = [
12729
13085
  "",
12730
13086
  "Do you trust the files in this folder?",
@@ -12794,7 +13150,7 @@ async function promptForFolderTrustLevel(workspaceDir, input = process.stdin, ou
12794
13150
  } catch {
12795
13151
  }
12796
13152
  output.write(formatFolderTrustPrompt(workspaceDir, discoveryResults));
12797
- return new Promise((resolve10) => {
13153
+ return new Promise((resolve11) => {
12798
13154
  const rl = readline2.createInterface({ input, output, terminal: false });
12799
13155
  let settled = false;
12800
13156
  const finish = (trustLevel) => {
@@ -12803,7 +13159,7 @@ async function promptForFolderTrustLevel(workspaceDir, input = process.stdin, ou
12803
13159
  }
12804
13160
  settled = true;
12805
13161
  rl.close();
12806
- resolve10(trustLevel);
13162
+ resolve11(trustLevel);
12807
13163
  };
12808
13164
  rl.on("line", (line) => {
12809
13165
  const trustLevel = parseTrustChoice(line);
@@ -12821,17 +13177,17 @@ async function promptForFolderTrustLevel(workspaceDir, input = process.stdin, ou
12821
13177
  }
12822
13178
 
12823
13179
  // packages/cli/src/utils/startupWarnings.ts
12824
- import fs8 from "node:fs/promises";
13180
+ import fs9 from "node:fs/promises";
12825
13181
  import os4 from "node:os";
12826
13182
  import { join as pathJoin } from "node:path";
12827
13183
  var warningsFilePath = pathJoin(os4.tmpdir(), "gemini-cli-warnings.txt");
12828
13184
  async function getStartupWarnings() {
12829
13185
  try {
12830
- await fs8.access(warningsFilePath);
12831
- const warningsContent = await fs8.readFile(warningsFilePath, "utf-8");
13186
+ await fs9.access(warningsFilePath);
13187
+ const warningsContent = await fs9.readFile(warningsFilePath, "utf-8");
12832
13188
  const warnings = warningsContent.split("\n").filter((line) => line.trim() !== "");
12833
13189
  try {
12834
- await fs8.unlink(warningsFilePath);
13190
+ await fs9.unlink(warningsFilePath);
12835
13191
  } catch {
12836
13192
  warnings.push("Warning: Could not delete temporary warnings file.");
12837
13193
  }
@@ -12845,9 +13201,9 @@ async function getStartupWarnings() {
12845
13201
  }
12846
13202
 
12847
13203
  // packages/cli/src/utils/userStartupWarnings.ts
12848
- import fs9 from "node:fs/promises";
13204
+ import fs10 from "node:fs/promises";
12849
13205
  import { homedir as osHomedir } from "node:os";
12850
- import path12 from "node:path";
13206
+ import path13 from "node:path";
12851
13207
  import process5 from "node:process";
12852
13208
  var homeDirectoryCheck = {
12853
13209
  id: "home-directory",
@@ -12858,10 +13214,10 @@ var homeDirectoryCheck = {
12858
13214
  }
12859
13215
  try {
12860
13216
  const [workspaceRealPath, homeRealPath] = await Promise.all([
12861
- fs9.realpath(workspaceRoot),
12862
- fs9.realpath(osHomedir())
13217
+ fs10.realpath(workspaceRoot),
13218
+ fs10.realpath(osHomedir())
12863
13219
  ]);
12864
- if (path12.resolve(workspaceRealPath) === path12.resolve(homeRealPath)) {
13220
+ if (path13.resolve(workspaceRealPath) === path13.resolve(homeRealPath)) {
12865
13221
  if (isFolderTrustEnabled(settings) && isWorkspaceTrusted(settings).isTrusted) {
12866
13222
  return null;
12867
13223
  }
@@ -12878,9 +13234,9 @@ var rootDirectoryCheck = {
12878
13234
  priority: "high" /* High */,
12879
13235
  check: async (workspaceRoot, _settings) => {
12880
13236
  try {
12881
- const workspaceRealPath = await fs9.realpath(workspaceRoot);
13237
+ const workspaceRealPath = await fs10.realpath(workspaceRoot);
12882
13238
  const errorMessage = "Warning: You are running Gemini CLI in the root directory. Your entire folder structure will be used for context. It is strongly recommended to run in a project-specific directory.";
12883
- if (path12.dirname(workspaceRealPath) === workspaceRealPath) {
13239
+ if (path13.dirname(workspaceRealPath) === workspaceRealPath) {
12884
13240
  return errorMessage;
12885
13241
  }
12886
13242
  return null;
@@ -13284,7 +13640,7 @@ async function runNonInteractive({
13284
13640
  }
13285
13641
  });
13286
13642
  if (process.env["GEMINI_CLI_ACTIVITY_LOG_TARGET"]) {
13287
- const { setupInitialActivityLogger } = await import("./devtoolsService-XZRXARUU.js");
13643
+ const { setupInitialActivityLogger } = await import("./devtoolsService-O5VD5YWD.js");
13288
13644
  setupInitialActivityLogger(config);
13289
13645
  }
13290
13646
  const { stdout: workingStdout } = createWorkingStdio();
@@ -13825,7 +14181,7 @@ async function runNonInteractive2(params) {
13825
14181
  }
13826
14182
  });
13827
14183
  if (process.env["GEMINI_CLI_ACTIVITY_LOG_TARGET"]) {
13828
- const { setupInitialActivityLogger } = await import("./devtoolsService-XZRXARUU.js");
14184
+ const { setupInitialActivityLogger } = await import("./devtoolsService-O5VD5YWD.js");
13829
14185
  setupInitialActivityLogger(config);
13830
14186
  }
13831
14187
  const { stdout: workingStdout } = createWorkingStdio();
@@ -14324,6 +14680,37 @@ async function runNonInteractive2(params) {
14324
14680
  }
14325
14681
 
14326
14682
  // packages/cli/src/utils/worktreeSetup.ts
14683
+ var WORKTREE_ACK_TIMEOUT_MS = 500;
14684
+ async function notifyWorktreeSelected(worktreePath) {
14685
+ if (!isIPCAvailable()) {
14686
+ return;
14687
+ }
14688
+ await new Promise((resolve11) => {
14689
+ let resolved = false;
14690
+ const done = () => {
14691
+ if (!resolved) {
14692
+ resolved = true;
14693
+ resolve11();
14694
+ }
14695
+ };
14696
+ const timeout = setTimeout(done, WORKTREE_ACK_TIMEOUT_MS);
14697
+ try {
14698
+ process.send(
14699
+ {
14700
+ type: "worktree-selected",
14701
+ path: worktreePath
14702
+ },
14703
+ () => {
14704
+ clearTimeout(timeout);
14705
+ done();
14706
+ }
14707
+ );
14708
+ } catch {
14709
+ clearTimeout(timeout);
14710
+ done();
14711
+ }
14712
+ });
14713
+ }
14327
14714
  async function setupWorktree(worktreeName) {
14328
14715
  if (process.env["GEMINI_CLI_WORKTREE_HANDLED"] === "1") {
14329
14716
  return void 0;
@@ -14334,6 +14721,7 @@ async function setupWorktree(worktreeName) {
14334
14721
  const worktreeInfo = await service.setup(worktreeName || void 0);
14335
14722
  process.chdir(worktreeInfo.path);
14336
14723
  process.env["GEMINI_CLI_WORKTREE_HANDLED"] = "1";
14724
+ await notifyWorktreeSelected(worktreeInfo.path);
14337
14725
  return worktreeInfo;
14338
14726
  } catch (error) {
14339
14727
  const errorMessage = error instanceof Error ? error.message : String(error);
@@ -15616,8 +16004,8 @@ var Connection = class {
15616
16004
  this.#requestHandler = requestHandler;
15617
16005
  this.#notificationHandler = notificationHandler;
15618
16006
  this.#stream = stream;
15619
- this.#closedPromise = new Promise((resolve10) => {
15620
- this.#abortController.signal.addEventListener("abort", () => resolve10());
16007
+ this.#closedPromise = new Promise((resolve11) => {
16008
+ this.#abortController.signal.addEventListener("abort", () => resolve11());
15621
16009
  });
15622
16010
  this.#receive();
15623
16011
  }
@@ -15766,8 +16154,8 @@ var Connection = class {
15766
16154
  }
15767
16155
  async sendRequest(method, params) {
15768
16156
  const id = this.#nextRequestId++;
15769
- const responsePromise = new Promise((resolve10, reject) => {
15770
- this.#pendingResponses.set(id, { resolve: resolve10, reject });
16157
+ const responsePromise = new Promise((resolve11, reject) => {
16158
+ this.#pendingResponses.set(id, { resolve: resolve11, reject });
15771
16159
  });
15772
16160
  await this.#sendMessage({ jsonrpc: "2.0", id, method, params });
15773
16161
  return responsePromise;
@@ -15887,8 +16275,8 @@ function extractRecursiveMessage(input) {
15887
16275
  import { randomUUID as randomUUID2 } from "node:crypto";
15888
16276
 
15889
16277
  // packages/cli/src/acp/acpSession.ts
15890
- import * as fs12 from "node:fs/promises";
15891
- import * as path15 from "node:path";
16278
+ import * as fs13 from "node:fs/promises";
16279
+ import * as path16 from "node:path";
15892
16280
  import { randomUUID } from "node:crypto";
15893
16281
 
15894
16282
  // packages/cli/src/acp/commands/commandRegistry.ts
@@ -16329,8 +16717,8 @@ var UpdateExtensionCommand = class {
16329
16717
  };
16330
16718
 
16331
16719
  // packages/cli/src/acp/commands/init.ts
16332
- import * as fs10 from "node:fs";
16333
- import * as path13 from "node:path";
16720
+ import * as fs11 from "node:fs";
16721
+ import * as path14 from "node:path";
16334
16722
  var InitCommand = class {
16335
16723
  name = "init";
16336
16724
  description = "Analyzes the project and creates a tailored GEMINI.md file";
@@ -16340,8 +16728,8 @@ var InitCommand = class {
16340
16728
  if (!targetDir) {
16341
16729
  throw new Error("Command requires a workspace.");
16342
16730
  }
16343
- const geminiMdPath = path13.join(targetDir, "GEMINI.md");
16344
- const result = performInit(fs10.existsSync(geminiMdPath));
16731
+ const geminiMdPath = path14.join(targetDir, "GEMINI.md");
16732
+ const result = performInit(fs11.existsSync(geminiMdPath));
16345
16733
  switch (result.type) {
16346
16734
  case "message":
16347
16735
  return {
@@ -16349,7 +16737,7 @@ var InitCommand = class {
16349
16737
  data: result
16350
16738
  };
16351
16739
  case "submit_prompt":
16352
- fs10.writeFileSync(geminiMdPath, "", "utf8");
16740
+ fs11.writeFileSync(geminiMdPath, "", "utf8");
16353
16741
  if (typeof result.content !== "string") {
16354
16742
  throw new Error("Init command content must be a string.");
16355
16743
  }
@@ -16372,8 +16760,8 @@ ${result.content}`
16372
16760
  };
16373
16761
 
16374
16762
  // packages/cli/src/acp/commands/restore.ts
16375
- import * as fs11 from "node:fs/promises";
16376
- import * as path14 from "node:path";
16763
+ import * as fs12 from "node:fs/promises";
16764
+ import * as path15 from "node:path";
16377
16765
  var RestoreCommand = class {
16378
16766
  name = "restore";
16379
16767
  description = "Restore to a previous checkpoint, or list available checkpoints to restore. This will reset the conversation and file history to the state it was in when the checkpoint was created";
@@ -16395,10 +16783,10 @@ var RestoreCommand = class {
16395
16783
  }
16396
16784
  const selectedFile = argsStr.endsWith(".json") ? argsStr : `${argsStr}.json`;
16397
16785
  const checkpointDir = config.storage.getProjectTempCheckpointsDir();
16398
- const filePath = path14.join(checkpointDir, selectedFile);
16786
+ const filePath = path15.join(checkpointDir, selectedFile);
16399
16787
  let data;
16400
16788
  try {
16401
- data = await fs11.readFile(filePath, "utf-8");
16789
+ data = await fs12.readFile(filePath, "utf-8");
16402
16790
  } catch (error) {
16403
16791
  if (isNodeError(error) && error.code === "ENOENT") {
16404
16792
  return {
@@ -16459,18 +16847,18 @@ var ListCheckpointsCommand = class {
16459
16847
  }
16460
16848
  const checkpointDir = config.storage.getProjectTempCheckpointsDir();
16461
16849
  try {
16462
- await fs11.mkdir(checkpointDir, { recursive: true });
16850
+ await fs12.mkdir(checkpointDir, { recursive: true });
16463
16851
  } catch {
16464
16852
  }
16465
- const files = await fs11.readdir(checkpointDir);
16853
+ const files = await fs12.readdir(checkpointDir);
16466
16854
  const jsonFiles = files.filter((file) => file.endsWith(".json"));
16467
16855
  if (jsonFiles.length === 0) {
16468
16856
  return { name: this.name, data: "No checkpoints found." };
16469
16857
  }
16470
16858
  const checkpointFiles = /* @__PURE__ */ new Map();
16471
16859
  for (const file of jsonFiles) {
16472
- const filePath = path14.join(checkpointDir, file);
16473
- const data = await fs11.readFile(filePath, "utf-8");
16860
+ const filePath = path15.join(checkpointDir, file);
16861
+ const data = await fs12.readFile(filePath, "utf-8");
16474
16862
  checkpointFiles.set(file, data);
16475
16863
  }
16476
16864
  const checkpointInfoList = getCheckpointInfoList(checkpointFiles);
@@ -17506,14 +17894,14 @@ ${event.value.description}`;
17506
17894
  } else if (result.status === "invalid") {
17507
17895
  continue;
17508
17896
  } else {
17509
- absolutePath = path15.resolve(
17897
+ absolutePath = path16.resolve(
17510
17898
  this.context.config.getTargetDir(),
17511
17899
  pathName
17512
17900
  );
17513
17901
  }
17514
17902
  if (!resolved && validationError && !isWithinRoot(absolutePath, this.context.config.getTargetDir())) {
17515
17903
  try {
17516
- const stats = await fs12.stat(absolutePath);
17904
+ const stats = await fs13.stat(absolutePath);
17517
17905
  if (stats.isFile()) {
17518
17906
  const syntheticCallId = `resolve-prompt-${pathName}-${randomUUID()}`;
17519
17907
  const params = {
@@ -17580,12 +17968,12 @@ ${event.value.description}`;
17580
17968
  }
17581
17969
  try {
17582
17970
  if (!validationError) {
17583
- if ((path15.isAbsolute(pathName) || !isWithinRoot(
17971
+ if ((path16.isAbsolute(pathName) || !isWithinRoot(
17584
17972
  absolutePath,
17585
17973
  this.context.config.getTargetDir()
17586
17974
  )) && !readDirectly) {
17587
17975
  try {
17588
- const stats = resolved ? resolved.stats : await fs12.stat(absolutePath);
17976
+ const stats = resolved ? resolved.stats : await fs13.stat(absolutePath);
17589
17977
  if (stats.isFile()) {
17590
17978
  const fileReadResult = await processSingleFileContent(
17591
17979
  absolutePath,
@@ -17641,7 +18029,7 @@ ${contentToPush}`;
17641
18029
  }
17642
18030
  }
17643
18031
  if (!readDirectly) {
17644
- const stats = resolved ? resolved.stats : await fs12.stat(absolutePath);
18032
+ const stats = resolved ? resolved.stats : await fs13.stat(absolutePath);
17645
18033
  isDirectory = stats.isDirectory();
17646
18034
  this.debug(
17647
18035
  `Path ${pathName} resolved to ${isDirectory ? "directory" : "file"}: ${currentPathSpec}`
@@ -17678,7 +18066,7 @@ ${contentToPush}`;
17678
18066
  const lines = globResult.llmContent.split("\n");
17679
18067
  if (lines.length > 1 && lines[1]) {
17680
18068
  const firstMatchAbsolute = lines[1].trim();
17681
- currentPathSpec = path15.relative(
18069
+ currentPathSpec = path16.relative(
17682
18070
  this.context.config.getTargetDir(),
17683
18071
  firstMatchAbsolute
17684
18072
  );
@@ -17901,7 +18289,7 @@ Content from @${contextPart.uri}:
17901
18289
 
17902
18290
  // packages/cli/src/acp/acpFileSystemService.ts
17903
18291
  import os5 from "node:os";
17904
- import path16 from "node:path";
18292
+ import path17 from "node:path";
17905
18293
  var AcpFileSystemService = class {
17906
18294
  constructor(connection, sessionId, capabilities, fallback, root) {
17907
18295
  this.connection = connection;
@@ -17910,7 +18298,7 @@ var AcpFileSystemService = class {
17910
18298
  this.fallback = fallback;
17911
18299
  this.root = root;
17912
18300
  }
17913
- geminiDir = path16.join(os5.homedir(), ".gemini");
18301
+ geminiDir = path17.join(os5.homedir(), ".gemini");
17914
18302
  shouldUseFallback(filePath) {
17915
18303
  return !isWithinRoot(filePath, this.root) || isWithinRoot(filePath, this.geminiDir);
17916
18304
  }
@@ -18644,27 +19032,27 @@ async function setupTerminalAndTheme(config, settings) {
18644
19032
  }
18645
19033
 
18646
19034
  // packages/cli/src/utils/logCleanup.ts
18647
- import { promises as fs13 } from "node:fs";
18648
- import * as path17 from "node:path";
19035
+ import { promises as fs14 } from "node:fs";
19036
+ import * as path18 from "node:path";
18649
19037
  var RETENTION_PERIOD_MS = 7 * 24 * 60 * 60 * 1e3;
18650
19038
  async function cleanupBackgroundLogs(debugMode = false) {
18651
19039
  try {
18652
19040
  const logDir = ShellExecutionService.getLogDir();
18653
19041
  try {
18654
- await fs13.access(logDir);
19042
+ await fs14.access(logDir);
18655
19043
  } catch {
18656
19044
  return;
18657
19045
  }
18658
- const entries = await fs13.readdir(logDir, { withFileTypes: true });
19046
+ const entries = await fs14.readdir(logDir, { withFileTypes: true });
18659
19047
  const now = Date.now();
18660
19048
  let deletedCount = 0;
18661
19049
  for (const entry of entries) {
18662
19050
  if (entry.isFile() && entry.name.endsWith(".log")) {
18663
- const filePath = path17.join(logDir, entry.name);
19051
+ const filePath = path18.join(logDir, entry.name);
18664
19052
  try {
18665
- const stats = await fs13.stat(filePath);
19053
+ const stats = await fs14.stat(filePath);
18666
19054
  if (now - stats.mtime.getTime() > RETENTION_PERIOD_MS) {
18667
- await fs13.unlink(filePath);
19055
+ await fs14.unlink(filePath);
18668
19056
  deletedCount++;
18669
19057
  }
18670
19058
  } catch (error) {
@@ -19005,8 +19393,8 @@ async function resolveSessionId(resumeArg, sessionIdArg, sessionFileArg) {
19005
19393
  sessionData.projectHash = getProjectHash(storage.getProjectRoot());
19006
19394
  sessionData.startTime = isoNow;
19007
19395
  sessionData.lastUpdated = isoNow;
19008
- const chatsDir = path18.join(storage.getProjectTempDir(), "chats");
19009
- const newSessionPath = path18.join(
19396
+ const chatsDir = path19.join(storage.getProjectTempDir(), "chats");
19397
+ const newSessionPath = path19.join(
19010
19398
  chatsDir,
19011
19399
  `session-${now}-${newSessionId.slice(0, 8)}.jsonl`
19012
19400
  );
@@ -19074,7 +19462,7 @@ async function resolveSessionId(resumeArg, sessionIdArg, sessionFileArg) {
19074
19462
  }
19075
19463
  }
19076
19464
  async function startInteractiveUI(config, settings, startupWarnings, workspaceRoot = process.cwd(), resumedSessionData, initializationResult) {
19077
- const { startInteractiveUI: doStartUI } = await import("./interactiveCli-X6WWC2C6.js");
19465
+ const { startInteractiveUI: doStartUI } = await import("./interactiveCli-BYWR7IEK.js");
19078
19466
  await doStartUI(
19079
19467
  config,
19080
19468
  settings,
@@ -19309,7 +19697,7 @@ ${finalArgs[promptIndex + 1]}`;
19309
19697
  await config.storage.initialize();
19310
19698
  adminControlsListner.setConfig(config);
19311
19699
  if (config.isInteractive() && settings.merged.general.devtools) {
19312
- const { setupInitialActivityLogger } = await import("./devtoolsService-XZRXARUU.js");
19700
+ const { setupInitialActivityLogger } = await import("./devtoolsService-O5VD5YWD.js");
19313
19701
  setupInitialActivityLogger(config);
19314
19702
  }
19315
19703
  registerTelemetryConfig(config);
@@ -19368,7 +19756,7 @@ ${finalArgs[promptIndex + 1]}`;
19368
19756
  const initAppHandle = startupProfiler.start("initialize_app");
19369
19757
  const initializationResult = await initializeApp(config, settings);
19370
19758
  initAppHandle?.end();
19371
- import("./liteRtServerManager-CAJIW3PE.js").then(({ LiteRtServerManager }) => {
19759
+ import("./liteRtServerManager-BYJWS5BO.js").then(({ LiteRtServerManager }) => {
19372
19760
  const mergedGemma = settings.merged.experimental?.gemmaModelRouter;
19373
19761
  if (!mergedGemma) return;
19374
19762
  const userGemma = settings.forScope("User" /* User */).settings.experimental?.gemmaModelRouter;