@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-SM722TVE.js";
5
+ } from "./chunk-QYKA4YD7.js";
6
6
  import {
7
7
  formatCliError
8
- } from "./chunk-6CG4XKVB.js";
8
+ } from "./chunk-G6SC5BOV.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-5WVS3LFE.js";
52
+ } from "./chunk-FHK4RNCX.js";
52
53
  import {
53
54
  exitCli,
54
55
  require_source
55
- } from "./chunk-KZYASN6P.js";
56
+ } from "./chunk-7JS2T75Z.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-RPOY63FV.js";
96
+ } from "./chunk-LMNAB62M.js";
96
97
  import {
97
98
  RELAUNCH_EXIT_CODE,
99
+ isIPCAvailable,
98
100
  require_semver
99
- } from "./chunk-TO7WASPI.js";
100
- import "./chunk-76IL5AQS.js";
101
+ } from "./chunk-3VGGGCOZ.js";
102
+ import "./chunk-5VFAWK3F.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-VWFWPAOZ.js";
111
+ } from "./chunk-V4HIE5G5.js";
110
112
  import {
111
113
  ASK_USER_TOOL_NAME,
112
114
  AjvJsonSchemaValidator,
@@ -119,6 +121,8 @@ import {
119
121
  CoreEvent,
120
122
  CoreToolCallStatus,
121
123
  CreateMessageResultSchema,
124
+ CreateMessageResultWithToolsSchema,
125
+ CreateTaskResultSchema,
122
126
  DEFAULT_CONTEXT_FILENAME,
123
127
  DEFAULT_FILE_FILTERING_OPTIONS,
124
128
  DEFAULT_GEMINI_EMBEDDING_MODEL,
@@ -210,6 +214,8 @@ import {
210
214
  WarningPriority,
211
215
  applyAdminAllowlist,
212
216
  applyRequiredServers,
217
+ assertClientRequestTaskCapability,
218
+ assertToolsCallTaskCapability,
213
219
  clearCachedCredentialFile,
214
220
  convertSessionToClientHistory,
215
221
  convertToFunctionResponse,
@@ -242,7 +248,9 @@ import {
242
248
  getErrorStatus,
243
249
  getErrorType,
244
250
  getIdeProcessInfo,
251
+ getLiteralValue,
245
252
  getOauthClient,
253
+ getObjectShape,
246
254
  getPackageJson,
247
255
  getPortFromEnv,
248
256
  getProjectHash,
@@ -270,6 +278,7 @@ import {
270
278
  logUserPrompt,
271
279
  mergeCapabilities,
272
280
  normalizeError,
281
+ outputTokenLimit,
273
282
  parseAndFormatApiError,
274
283
  partListUnionToString,
275
284
  patchStdio,
@@ -286,6 +295,7 @@ import {
286
295
  resolveAtCommandPath,
287
296
  resolveTelemetrySettings,
288
297
  resolveToRealPath,
298
+ safeParse,
289
299
  serializeMessage,
290
300
  setGeminiMdFilename,
291
301
  shouldEnterAlternateScreen,
@@ -296,9 +306,9 @@ import {
296
306
  updatePolicy,
297
307
  writeToStderr,
298
308
  writeToStdout
299
- } from "./chunk-X4P3RZYU.js";
300
- import "./chunk-664ZODQF.js";
301
- import "./chunk-IUUIT4SU.js";
309
+ } from "./chunk-UF44X63P.js";
310
+ import "./chunk-W2AJR23G.js";
311
+ import "./chunk-N7J54YNL.js";
302
312
  import "./chunk-L6PII3GR.js";
303
313
  import {
304
314
  __require,
@@ -1581,11 +1591,11 @@ var parser = new YargsParser({
1581
1591
  resolve: resolve2,
1582
1592
  // TODO: figure out a way to combine ESM and CJS coverage, such that
1583
1593
  // we can exercise all the lines below:
1584
- require: (path19) => {
1594
+ require: (path20) => {
1585
1595
  if (typeof __require !== "undefined") {
1586
- return __require(path19);
1587
- } else if (path19.match(/\.json$/)) {
1588
- return JSON.parse(readFileSync(path19, "utf8"));
1596
+ return __require(path20);
1597
+ } else if (path20.match(/\.json$/)) {
1598
+ return JSON.parse(readFileSync(path20, "utf8"));
1589
1599
  } else {
1590
1600
  throw Error("only .json config files are supported in ESM");
1591
1601
  }
@@ -4110,12 +4120,12 @@ var YargsInstance = class {
4110
4120
  async getCompletion(args, done) {
4111
4121
  argsert("<array> [function]", [args, done], arguments.length);
4112
4122
  if (!done) {
4113
- return new Promise((resolve10, reject) => {
4123
+ return new Promise((resolve11, reject) => {
4114
4124
  __classPrivateFieldGet(this, _YargsInstance_completion, "f").getCompletion(args, (err, completions) => {
4115
4125
  if (err)
4116
4126
  reject(err);
4117
4127
  else
4118
- resolve10(completions);
4128
+ resolve11(completions);
4119
4129
  });
4120
4130
  });
4121
4131
  } else {
@@ -5156,7 +5166,7 @@ var yargs_default = Yargs;
5156
5166
 
5157
5167
  // packages/cli/src/config/config.ts
5158
5168
  import process3 from "node:process";
5159
- import * as path7 from "node:path";
5169
+ import * as path8 from "node:path";
5160
5170
 
5161
5171
  // packages/cli/src/commands/mcp/add.ts
5162
5172
  async function addMcpServer(name, commandOrUrl, args, options) {
@@ -6330,18 +6340,34 @@ var enableCommand2 = {
6330
6340
 
6331
6341
  // packages/cli/src/commands/extensions/link.ts
6332
6342
  var import_chalk3 = __toESM(require_source(), 1);
6343
+ import * as fs from "node:fs";
6344
+ import * as path2 from "node:path";
6333
6345
  async function handleLink(args) {
6334
6346
  try {
6347
+ const trimmedPath = args.path.trim();
6348
+ if (!trimmedPath) {
6349
+ throw new Error("Extension path cannot be empty.");
6350
+ }
6351
+ const workspaceDir = process.cwd();
6352
+ const canonicalPath = fs.realpathSync(
6353
+ path2.resolve(workspaceDir, trimmedPath)
6354
+ );
6335
6355
  const installMetadata = {
6336
- source: args.path,
6356
+ source: canonicalPath,
6337
6357
  type: "link"
6338
6358
  };
6339
- const requestConsent = args.consent ? () => Promise.resolve(true) : requestConsentNonInteractive;
6359
+ const requestConsent = args.consent ? () => Promise.resolve(true) : async (consentDescription) => {
6360
+ if (!process.stdin.isTTY) {
6361
+ debugLogger.log(consentDescription);
6362
+ return false;
6363
+ }
6364
+ return requestConsentNonInteractive(consentDescription);
6365
+ };
6340
6366
  if (args.consent) {
6341
6367
  debugLogger.log("You have consented to the following:");
6368
+ debugLogger.log(LINK_WARNING_MESSAGE);
6342
6369
  debugLogger.log(INSTALL_WARNING_MESSAGE);
6343
6370
  }
6344
- const workspaceDir = process.cwd();
6345
6371
  const extensionManager = new ExtensionManager({
6346
6372
  workspaceDir,
6347
6373
  requestConsent,
@@ -6389,27 +6415,27 @@ import { fileURLToPath as fileURLToPath2 } from "node:url";
6389
6415
  var __filename = fileURLToPath2(import.meta.url);
6390
6416
  var __dirname2 = dirname3(__filename);
6391
6417
  var EXAMPLES_PATH = join(__dirname2, "examples");
6392
- async function pathExists(path19) {
6418
+ async function pathExists(path20) {
6393
6419
  try {
6394
- await access(path19);
6420
+ await access(path20);
6395
6421
  return true;
6396
6422
  } catch {
6397
6423
  return false;
6398
6424
  }
6399
6425
  }
6400
- async function createDirectory(path19) {
6401
- if (await pathExists(path19)) {
6402
- throw new Error(`Path already exists: ${path19}`);
6426
+ async function createDirectory(path20) {
6427
+ if (await pathExists(path20)) {
6428
+ throw new Error(`Path already exists: ${path20}`);
6403
6429
  }
6404
- await mkdir(path19, { recursive: true });
6430
+ await mkdir(path20, { recursive: true });
6405
6431
  }
6406
- async function copyDirectory(template, path19) {
6407
- await createDirectory(path19);
6432
+ async function copyDirectory(template, path20) {
6433
+ await createDirectory(path20);
6408
6434
  const examplePath = join(EXAMPLES_PATH, template);
6409
6435
  const entries = await readdir(examplePath, { withFileTypes: true });
6410
6436
  for (const entry of entries) {
6411
6437
  const srcPath = join(examplePath, entry.name);
6412
- const destPath = join(path19, entry.name);
6438
+ const destPath = join(path20, entry.name);
6413
6439
  await cp(srcPath, destPath, { recursive: true });
6414
6440
  }
6415
6441
  }
@@ -6467,8 +6493,8 @@ var newCommand = {
6467
6493
 
6468
6494
  // packages/cli/src/commands/extensions/validate.ts
6469
6495
  var import_semver = __toESM(require_semver(), 1);
6470
- import * as fs from "node:fs";
6471
- import * as path2 from "node:path";
6496
+ import * as fs2 from "node:fs";
6497
+ import * as path3 from "node:path";
6472
6498
  async function handleValidate(args) {
6473
6499
  try {
6474
6500
  await validateExtension(args);
@@ -6486,7 +6512,7 @@ async function validateExtension(args) {
6486
6512
  requestSetting: promptForSetting,
6487
6513
  settings: loadSettings(workspaceDir).merged
6488
6514
  });
6489
- const absoluteInputPath = path2.resolve(args.path);
6515
+ const absoluteInputPath = path3.resolve(args.path);
6490
6516
  const extensionConfig = await extensionManager.loadExtensionConfig(absoluteInputPath);
6491
6517
  const warnings = [];
6492
6518
  const errors = [];
@@ -6504,7 +6530,7 @@ async function validateExtension(args) {
6504
6530
  );
6505
6531
  continue;
6506
6532
  }
6507
- if (!fs.existsSync(validation2.resolvedPath)) {
6533
+ if (!fs2.existsSync(validation2.resolvedPath)) {
6508
6534
  missingContextFiles.push(contextFilePath);
6509
6535
  }
6510
6536
  }
@@ -6741,7 +6767,7 @@ async function handleEnable3(args) {
6741
6767
  const result = enableSkill(settings, name);
6742
6768
  const feedback = renderSkillActionFeedback(
6743
6769
  result,
6744
- (label, path19) => `${import_chalk5.default.bold(label)} (${import_chalk5.default.dim(path19)})`
6770
+ (label, path20) => `${import_chalk5.default.bold(label)} (${import_chalk5.default.dim(path20)})`
6745
6771
  );
6746
6772
  debugLogger.log(feedback);
6747
6773
  }
@@ -6771,7 +6797,7 @@ async function handleDisable3(args) {
6771
6797
  const result = disableSkill(settings, name, scope);
6772
6798
  const feedback = renderSkillActionFeedback(
6773
6799
  result,
6774
- (label, path19) => `${import_chalk6.default.bold(label)} (${import_chalk6.default.dim(path19)})`
6800
+ (label, path20) => `${import_chalk6.default.bold(label)} (${import_chalk6.default.dim(path20)})`
6775
6801
  );
6776
6802
  debugLogger.log(feedback);
6777
6803
  }
@@ -7006,8 +7032,8 @@ var skillsCommand = {
7006
7032
  };
7007
7033
 
7008
7034
  // packages/cli/src/commands/hooks/migrate.ts
7009
- import * as fs2 from "node:fs";
7010
- import * as path3 from "node:path";
7035
+ import * as fs3 from "node:fs";
7036
+ import * as path4 from "node:path";
7011
7037
  var import_strip_json_comments = __toESM(require_strip_json_comments(), 1);
7012
7038
  var EVENT_MAPPING = {
7013
7039
  PreToolUse: "BeforeTool",
@@ -7114,25 +7140,25 @@ function migrateClaudeHooks(claudeConfig) {
7114
7140
  }
7115
7141
  async function handleMigrateFromClaude() {
7116
7142
  const workingDir = process.cwd();
7117
- const claudeDir = path3.join(workingDir, ".claude");
7118
- const claudeSettingsPath = path3.join(claudeDir, "settings.json");
7119
- const claudeLocalSettingsPath = path3.join(claudeDir, "settings.local.json");
7143
+ const claudeDir = path4.join(workingDir, ".claude");
7144
+ const claudeSettingsPath = path4.join(claudeDir, "settings.json");
7145
+ const claudeLocalSettingsPath = path4.join(claudeDir, "settings.local.json");
7120
7146
  let claudeSettings = null;
7121
7147
  let sourceFile = "";
7122
- if (fs2.existsSync(claudeLocalSettingsPath)) {
7148
+ if (fs3.existsSync(claudeLocalSettingsPath)) {
7123
7149
  sourceFile = claudeLocalSettingsPath;
7124
7150
  try {
7125
- const content = fs2.readFileSync(claudeLocalSettingsPath, "utf-8");
7151
+ const content = fs3.readFileSync(claudeLocalSettingsPath, "utf-8");
7126
7152
  claudeSettings = JSON.parse((0, import_strip_json_comments.default)(content));
7127
7153
  } catch (error) {
7128
7154
  debugLogger.error(
7129
7155
  `Error reading ${claudeLocalSettingsPath}: ${getErrorMessage(error)}`
7130
7156
  );
7131
7157
  }
7132
- } else if (fs2.existsSync(claudeSettingsPath)) {
7158
+ } else if (fs3.existsSync(claudeSettingsPath)) {
7133
7159
  sourceFile = claudeSettingsPath;
7134
7160
  try {
7135
- const content = fs2.readFileSync(claudeSettingsPath, "utf-8");
7161
+ const content = fs3.readFileSync(claudeSettingsPath, "utf-8");
7136
7162
  claudeSettings = JSON.parse((0, import_strip_json_comments.default)(content));
7137
7163
  } catch (error) {
7138
7164
  debugLogger.error(
@@ -7207,8 +7233,8 @@ var hooksCommand = {
7207
7233
  // packages/cli/src/commands/gemma/setup.ts
7208
7234
  var import_chalk10 = __toESM(require_source(), 1);
7209
7235
  import { createHash } from "node:crypto";
7210
- import fs3 from "node:fs";
7211
- import path4 from "node:path";
7236
+ import fs4 from "node:fs";
7237
+ import path5 from "node:path";
7212
7238
  import { execFileSync, spawn as nodeSpawn } from "node:child_process";
7213
7239
  import readline from "node:readline";
7214
7240
  var log = (msg) => debugLogger.log(msg);
@@ -7218,10 +7244,10 @@ async function promptYesNo(question) {
7218
7244
  input: process.stdin,
7219
7245
  output: process.stdout
7220
7246
  });
7221
- return new Promise((resolve10) => {
7247
+ return new Promise((resolve11) => {
7222
7248
  rl.question(`${question} (y/N): `, (answer) => {
7223
7249
  rl.close();
7224
- resolve10(
7250
+ resolve11(
7225
7251
  answer.trim().toLowerCase() === "y" || answer.trim().toLowerCase() === "yes"
7226
7252
  );
7227
7253
  });
@@ -7248,8 +7274,8 @@ function renderProgress(downloaded, total) {
7248
7274
  }
7249
7275
  async function downloadFile(url, destPath) {
7250
7276
  const tmpPath = destPath + ".downloading";
7251
- if (fs3.existsSync(tmpPath)) {
7252
- fs3.unlinkSync(tmpPath);
7277
+ if (fs4.existsSync(tmpPath)) {
7278
+ fs4.unlinkSync(tmpPath);
7253
7279
  }
7254
7280
  const response = await fetch(url, { redirect: "follow" });
7255
7281
  if (!response.ok) {
@@ -7263,7 +7289,7 @@ async function downloadFile(url, destPath) {
7263
7289
  const contentLength = response.headers.get("content-length");
7264
7290
  const totalBytes = contentLength ? parseInt(contentLength, 10) : null;
7265
7291
  let downloadedBytes = 0;
7266
- const fileStream = fs3.createWriteStream(tmpPath);
7292
+ const fileStream = fs4.createWriteStream(tmpPath);
7267
7293
  const reader = response.body.getReader();
7268
7294
  try {
7269
7295
  for (; ; ) {
@@ -7271,7 +7297,7 @@ async function downloadFile(url, destPath) {
7271
7297
  if (done) break;
7272
7298
  const writeOk = fileStream.write(value);
7273
7299
  if (!writeOk) {
7274
- await new Promise((resolve10) => fileStream.once("drain", resolve10));
7300
+ await new Promise((resolve11) => fileStream.once("drain", resolve11));
7275
7301
  }
7276
7302
  downloadedBytes += value.byteLength;
7277
7303
  renderProgress(downloadedBytes, totalBytes);
@@ -7280,22 +7306,22 @@ async function downloadFile(url, destPath) {
7280
7306
  fileStream.end();
7281
7307
  process.stderr.write("\r" + " ".repeat(80) + "\r");
7282
7308
  }
7283
- await new Promise((resolve10, reject) => {
7284
- fileStream.on("finish", resolve10);
7309
+ await new Promise((resolve11, reject) => {
7310
+ fileStream.on("finish", resolve11);
7285
7311
  fileStream.on("error", reject);
7286
7312
  });
7287
- fs3.renameSync(tmpPath, destPath);
7313
+ fs4.renameSync(tmpPath, destPath);
7288
7314
  }
7289
7315
  async function computeFileSha256(filePath) {
7290
7316
  const hash = createHash("sha256");
7291
- const fileStream = fs3.createReadStream(filePath);
7292
- return new Promise((resolve10, reject) => {
7317
+ const fileStream = fs4.createReadStream(filePath);
7318
+ return new Promise((resolve11, reject) => {
7293
7319
  fileStream.on("data", (chunk) => {
7294
7320
  hash.update(chunk);
7295
7321
  });
7296
7322
  fileStream.on("error", reject);
7297
7323
  fileStream.on("end", () => {
7298
- resolve10(hash.digest("hex"));
7324
+ resolve11(hash.digest("hex"));
7299
7325
  });
7300
7326
  });
7301
7327
  }
@@ -7304,11 +7330,11 @@ async function verifyFileSha256(filePath, expectedHash) {
7304
7330
  return actualHash === expectedHash;
7305
7331
  }
7306
7332
  function spawnInherited(command2, args) {
7307
- return new Promise((resolve10, reject) => {
7333
+ return new Promise((resolve11, reject) => {
7308
7334
  const child = nodeSpawn(command2, args, {
7309
7335
  stdio: "inherit"
7310
7336
  });
7311
- child.on("close", (code) => resolve10(code ?? 1));
7337
+ child.on("close", (code) => resolve11(code ?? 1));
7312
7338
  child.on("error", reject);
7313
7339
  });
7314
7340
  }
@@ -7358,8 +7384,8 @@ async function handleSetup(argv) {
7358
7384
  const downloadUrl = getBinaryDownloadUrl(platform2.binaryName);
7359
7385
  debugLogger.log(`Downloading from: ${downloadUrl}`);
7360
7386
  try {
7361
- const binDir = path4.dirname(binaryPath);
7362
- fs3.mkdirSync(binDir, { recursive: true });
7387
+ const binDir = path5.dirname(binaryPath);
7388
+ fs4.mkdirSync(binDir, { recursive: true });
7363
7389
  await downloadFile(downloadUrl, binaryPath);
7364
7390
  log(import_chalk10.default.green(" \u2713 Binary downloaded successfully"));
7365
7391
  } catch (error) {
@@ -7379,7 +7405,7 @@ async function handleSetup(argv) {
7379
7405
  )
7380
7406
  );
7381
7407
  try {
7382
- fs3.rmSync(binaryPath, { force: true });
7408
+ fs4.rmSync(binaryPath, { force: true });
7383
7409
  } catch {
7384
7410
  }
7385
7411
  return 1;
@@ -7393,7 +7419,7 @@ async function handleSetup(argv) {
7393
7419
  )
7394
7420
  );
7395
7421
  try {
7396
- fs3.rmSync(binaryPath, { force: true });
7422
+ fs4.rmSync(binaryPath, { force: true });
7397
7423
  } catch {
7398
7424
  }
7399
7425
  return 1;
@@ -7406,14 +7432,14 @@ async function handleSetup(argv) {
7406
7432
  )
7407
7433
  );
7408
7434
  try {
7409
- fs3.rmSync(binaryPath, { force: true });
7435
+ fs4.rmSync(binaryPath, { force: true });
7410
7436
  } catch {
7411
7437
  }
7412
7438
  return 1;
7413
7439
  }
7414
7440
  if (process.platform !== "win32") {
7415
7441
  try {
7416
- fs3.chmodSync(binaryPath, 493);
7442
+ fs4.chmodSync(binaryPath, 493);
7417
7443
  } catch (error) {
7418
7444
  logError(
7419
7445
  import_chalk10.default.red(
@@ -7614,7 +7640,7 @@ var setupCommand = {
7614
7640
 
7615
7641
  // packages/cli/src/commands/gemma/stop.ts
7616
7642
  var import_chalk11 = __toESM(require_source(), 1);
7617
- import fs4 from "node:fs";
7643
+ import fs5 from "node:fs";
7618
7644
  async function stopServer(expectedPort) {
7619
7645
  const processInfo = readServerProcessInfo();
7620
7646
  const pidPath = getPidFilePath();
@@ -7627,7 +7653,7 @@ async function stopServer(expectedPort) {
7627
7653
  `Stale PID file found (PID ${pid} is not running), removing ${pidPath}`
7628
7654
  );
7629
7655
  try {
7630
- fs4.unlinkSync(pidPath);
7656
+ fs5.unlinkSync(pidPath);
7631
7657
  } catch {
7632
7658
  }
7633
7659
  return "not-running";
@@ -7645,19 +7671,19 @@ async function stopServer(expectedPort) {
7645
7671
  } catch {
7646
7672
  return "failed";
7647
7673
  }
7648
- await new Promise((resolve10) => setTimeout(resolve10, 1e3));
7674
+ await new Promise((resolve11) => setTimeout(resolve11, 1e3));
7649
7675
  if (isProcessRunning(pid)) {
7650
7676
  try {
7651
7677
  process.kill(pid, "SIGKILL");
7652
7678
  } catch {
7653
7679
  }
7654
- await new Promise((resolve10) => setTimeout(resolve10, 500));
7680
+ await new Promise((resolve11) => setTimeout(resolve11, 500));
7655
7681
  if (isProcessRunning(pid)) {
7656
7682
  return "failed";
7657
7683
  }
7658
7684
  }
7659
7685
  try {
7660
- fs4.unlinkSync(pidPath);
7686
+ fs5.unlinkSync(pidPath);
7661
7687
  } catch {
7662
7688
  }
7663
7689
  return "stopped";
@@ -7725,14 +7751,14 @@ var stopCommand = {
7725
7751
  };
7726
7752
 
7727
7753
  // packages/cli/src/commands/gemma/logs.ts
7728
- import fs5 from "node:fs";
7754
+ import fs6 from "node:fs";
7729
7755
  import { spawn } from "node:child_process";
7730
7756
  async function readLastLines(filePath, count) {
7731
7757
  if (count <= 0) {
7732
7758
  return "";
7733
7759
  }
7734
7760
  const CHUNK_SIZE = 64 * 1024;
7735
- const fileHandle = await fs5.promises.open(filePath, fs5.constants.O_RDONLY);
7761
+ const fileHandle = await fs6.promises.open(filePath, fs6.constants.O_RDONLY);
7736
7762
  try {
7737
7763
  const stats = await fileHandle.stat();
7738
7764
  if (stats.size === 0) {
@@ -7785,9 +7811,9 @@ async function readLastLines(filePath, count) {
7785
7811
  }
7786
7812
  }
7787
7813
  function waitForChild(child) {
7788
- return new Promise((resolve10, reject) => {
7814
+ return new Promise((resolve11, reject) => {
7789
7815
  child.once("error", reject);
7790
- child.once("close", (code) => resolve10(code ?? 1));
7816
+ child.once("close", (code) => resolve11(code ?? 1));
7791
7817
  });
7792
7818
  }
7793
7819
  async function runTail(logPath, lines, follow) {
@@ -7821,7 +7847,7 @@ var logsCommand = {
7821
7847
  handler: async (argv) => {
7822
7848
  const logPath = getLogFilePath();
7823
7849
  try {
7824
- await fs5.promises.access(logPath, fs5.constants.F_OK);
7850
+ await fs6.promises.access(logPath, fs6.constants.F_OK);
7825
7851
  } catch {
7826
7852
  debugLogger.log(`No log file found at ${logPath}`);
7827
7853
  debugLogger.log(
@@ -8106,7 +8132,7 @@ function buildAvailableModels(config, settings) {
8106
8132
  const useGemini31 = config.getGemini31LaunchedSync?.() ?? false;
8107
8133
  const useLatestFlash = config.hasLatestFlashGAAccess?.() ?? false;
8108
8134
  const useLatestFlashLite = config.hasLatestFlashLiteGAAccess?.() ?? false;
8109
- const selectedAuthType = settings.merged.security.auth.selectedType;
8135
+ const selectedAuthType = settings.merged.security?.auth?.selectedType ?? config.getContentGeneratorConfig?.()?.authType;
8110
8136
  const useCustomToolModel = useGemini31 && selectedAuthType === AuthType.USE_GEMINI;
8111
8137
  if (config.getExperimentalDynamicModelConfiguration?.() === true && config.getModelConfigService) {
8112
8138
  const options = config.getModelConfigService().getAvailableModelOptions({
@@ -8167,6 +8193,14 @@ function buildAvailableModels(config, settings) {
8167
8193
  }
8168
8194
  manualOptions.unshift(...previewOptions);
8169
8195
  }
8196
+ const seen = /* @__PURE__ */ new Set();
8197
+ const uniqueManualOptions = manualOptions.filter((option) => {
8198
+ if (seen.has(option.value)) {
8199
+ return false;
8200
+ }
8201
+ seen.add(option.value);
8202
+ return true;
8203
+ });
8170
8204
  const scaleOptions = (options) => options.map((o) => ({
8171
8205
  modelId: o.value,
8172
8206
  name: o.title,
@@ -8175,7 +8209,7 @@ function buildAvailableModels(config, settings) {
8175
8209
  return {
8176
8210
  availableModels: [
8177
8211
  ...scaleOptions(mainOptions),
8178
- ...scaleOptions(manualOptions)
8212
+ ...scaleOptions(uniqueManualOptions)
8179
8213
  ],
8180
8214
  currentModelId: preferredModel
8181
8215
  };
@@ -8217,7 +8251,7 @@ function getModelListings(config, settings) {
8217
8251
  const { availableModels } = buildAvailableModels(config, settings);
8218
8252
  return (availableModels ?? []).map((m) => {
8219
8253
  const inputTokens = tokenLimit(m.modelId) ?? DEFAULT_TOKEN_LIMIT;
8220
- const outputTokens = 8192;
8254
+ const outputTokens = outputTokenLimit(m.modelId);
8221
8255
  return {
8222
8256
  modelId: m.modelId,
8223
8257
  id: m.modelId,
@@ -8226,7 +8260,7 @@ function getModelListings(config, settings) {
8226
8260
  description: m.description ?? "",
8227
8261
  contextLimits: {
8228
8262
  inputTokens,
8229
- outputTokens
8263
+ ...outputTokens !== void 0 ? { outputTokens } : {}
8230
8264
  }
8231
8265
  };
8232
8266
  });
@@ -8236,7 +8270,8 @@ async function handleList3(options) {
8236
8270
  const settings = options?.loadedSettings ?? loadSettings(workspaceDir);
8237
8271
  const argv = {
8238
8272
  ...DEFAULT_CLI_ARGS,
8239
- ...options?.argv
8273
+ ...options?.argv,
8274
+ isCommand: true
8240
8275
  };
8241
8276
  const config = await loadCliConfig(
8242
8277
  settings.merged,
@@ -8250,6 +8285,33 @@ async function handleList3(options) {
8250
8285
  );
8251
8286
  initializeOutputListenersAndFlush(config);
8252
8287
  await config.storage.initialize();
8288
+ const authConfig = settings.merged.security?.auth;
8289
+ const authType = authConfig?.selectedType || getAuthTypeFromEnv();
8290
+ const enforcedType = authConfig?.enforcedType;
8291
+ if (enforcedType && authType !== enforcedType) {
8292
+ 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.`;
8293
+ throw new Error(message);
8294
+ }
8295
+ if (authType && !authConfig?.useExternal) {
8296
+ try {
8297
+ if (authType !== AuthType.GATEWAY) {
8298
+ const authError = await validateAuthMethod(authType);
8299
+ if (authError) {
8300
+ throw new Error(authError);
8301
+ }
8302
+ }
8303
+ config.isBrowserLaunchSuppressed = () => true;
8304
+ await config.refreshAuth(authType);
8305
+ } catch (e) {
8306
+ if (enforcedType) {
8307
+ throw e;
8308
+ }
8309
+ debugLogger.debug(
8310
+ "Failed to refresh auth for models list, falling back to default catalog:",
8311
+ e
8312
+ );
8313
+ }
8314
+ }
8253
8315
  const models = getModelListings(config, settings);
8254
8316
  if (options?.outputFormat === "json") {
8255
8317
  process.stdout.write(JSON.stringify(models, null, 2) + "\n");
@@ -8263,8 +8325,9 @@ async function handleList3(options) {
8263
8325
  process.stdout.write(` Description: ${model.description}
8264
8326
  `);
8265
8327
  }
8328
+ const outputLimitText = model.contextLimits.outputTokens !== void 0 ? ` / ${model.contextLimits.outputTokens.toLocaleString()} output tokens` : "";
8266
8329
  process.stdout.write(
8267
- ` Context limit: ${model.contextLimits.inputTokens.toLocaleString()} input tokens / ${model.contextLimits.outputTokens.toLocaleString()} output tokens
8330
+ ` Context limit: ${model.contextLimits.inputTokens.toLocaleString()} input tokens${outputLimitText}
8268
8331
 
8269
8332
  `
8270
8333
  );
@@ -8282,6 +8345,7 @@ var listCommand4 = {
8282
8345
  }),
8283
8346
  handler: async (argv) => {
8284
8347
  const outputFormat = argv["output-format"] === "json" ? "json" : "text";
8348
+ let exitCode;
8285
8349
  try {
8286
8350
  await handleList3({
8287
8351
  outputFormat,
@@ -8293,8 +8357,13 @@ var listCommand4 = {
8293
8357
  "Error: " + (error instanceof Error ? error.stack || error.message : String(error)) + "\n"
8294
8358
  );
8295
8359
  process.exitCode = 1;
8360
+ exitCode = 1;
8296
8361
  } finally {
8297
- await exitCli();
8362
+ if (exitCode !== void 0) {
8363
+ await exitCli(exitCode);
8364
+ } else {
8365
+ await exitCli();
8366
+ }
8298
8367
  }
8299
8368
  }
8300
8369
  };
@@ -8315,9 +8384,9 @@ var modelsCommand = {
8315
8384
  var import_command_exists = __toESM(require_command_exists(), 1);
8316
8385
  import * as os from "node:os";
8317
8386
  import { fileURLToPath as fileURLToPath3 } from "node:url";
8318
- import path5 from "node:path";
8387
+ import path6 from "node:path";
8319
8388
  var __filename2 = fileURLToPath3(import.meta.url);
8320
- var __dirname3 = path5.dirname(__filename2);
8389
+ var __dirname3 = path6.dirname(__filename2);
8321
8390
  var VALID_SANDBOX_COMMANDS = [
8322
8391
  "docker",
8323
8392
  "podman",
@@ -8403,13 +8472,13 @@ async function loadSandboxConfig(settings, argv) {
8403
8472
  }
8404
8473
  const command2 = getSandboxCommand(sandboxValue);
8405
8474
  const packageJson = await getPackageJson(__dirname3);
8406
- const image = process.env["GEMINI_SANDBOX_IMAGE"] ?? "us-docker.pkg.dev/gemini-code-dev/gemini-cli/sandbox:0.69.0" ?? customImage ?? packageJson?.config?.sandboxImageUri;
8475
+ const image = process.env["GEMINI_SANDBOX_IMAGE"] ?? "us-docker.pkg.dev/gemini-code-dev/gemini-cli/sandbox:0.70.0" ?? customImage ?? packageJson?.config?.sandboxImageUri;
8407
8476
  const isNative = command2 === "windows-native" || command2 === "sandbox-exec" || command2 === "lxc";
8408
8477
  return command2 && (image || isNative) ? { enabled: true, allowedPaths, networkAccess, command: command2, image } : void 0;
8409
8478
  }
8410
8479
 
8411
8480
  // packages/cli/src/utils/resolvePath.ts
8412
- import * as path6 from "node:path";
8481
+ import * as path7 from "node:path";
8413
8482
  function resolvePath(p) {
8414
8483
  if (!p) {
8415
8484
  return "";
@@ -8420,7 +8489,7 @@ function resolvePath(p) {
8420
8489
  } else if (p === "~" || p.startsWith("~/")) {
8421
8490
  expandedPath = homedir() + p.substring(1);
8422
8491
  }
8423
- return path6.normalize(expandedPath);
8492
+ return path7.normalize(expandedPath);
8424
8493
  }
8425
8494
 
8426
8495
  // packages/cli/src/config/policy.ts
@@ -8892,7 +8961,7 @@ async function loadCliConfig(settings, sessionId, argv, options = {}) {
8892
8961
  const ideWorkspacePath = process3.env["GEMINI_CLI_IDE_WORKSPACE_PATH"];
8893
8962
  if (ideWorkspacePath) {
8894
8963
  const realCwd = resolveToRealPath(cwd);
8895
- const ideFolders = ideWorkspacePath.split(path7.delimiter).filter((p) => {
8964
+ const ideFolders = ideWorkspacePath.split(path8.delimiter).filter((p) => {
8896
8965
  const trimmedPath = p.trim();
8897
8966
  if (!trimmedPath) return false;
8898
8967
  try {
@@ -8924,7 +8993,7 @@ async function loadCliConfig(settings, sessionId, argv, options = {}) {
8924
8993
  let extensionRegistryURI = process3.env["GEMINI_CLI_EXTENSION_REGISTRY_URI"] ?? (trustedFolder ? settings.experimental?.extensionRegistryURI : void 0);
8925
8994
  if (extensionRegistryURI && !extensionRegistryURI.startsWith("http")) {
8926
8995
  extensionRegistryURI = resolveToRealPath(
8927
- path7.resolve(cwd, resolvePath(extensionRegistryURI))
8996
+ path8.resolve(cwd, resolvePath(extensionRegistryURI))
8928
8997
  );
8929
8998
  }
8930
8999
  const finalExtensionLoader = extensionManager ?? new SimpleExtensionLoader([]);
@@ -9300,7 +9369,7 @@ async function resolveWorktreeSettings(cwd) {
9300
9369
  return void 0;
9301
9370
  }
9302
9371
  return {
9303
- name: path7.basename(worktreePath),
9372
+ name: path8.basename(worktreePath),
9304
9373
  path: worktreePath,
9305
9374
  baseSha: worktreeBaseSha
9306
9375
  };
@@ -9325,7 +9394,7 @@ async function readStdin() {
9325
9394
  return "";
9326
9395
  }
9327
9396
  const MAX_STDIN_SIZE = 8 * 1024 * 1024;
9328
- return new Promise((resolve10, reject) => {
9397
+ return new Promise((resolve11, reject) => {
9329
9398
  let data = "";
9330
9399
  let totalSize = 0;
9331
9400
  let settled = false;
@@ -9365,7 +9434,7 @@ async function readStdin() {
9365
9434
  process.stdin.pause();
9366
9435
  }
9367
9436
  settled = true;
9368
- resolve10(data);
9437
+ resolve11(data);
9369
9438
  break;
9370
9439
  }
9371
9440
  data += chunkBuffer ? chunkBuffer.toString("utf8") : chunkStr;
@@ -9376,7 +9445,7 @@ async function readStdin() {
9376
9445
  if (settled) return;
9377
9446
  settled = true;
9378
9447
  cleanup();
9379
- resolve10(data);
9448
+ resolve11(data);
9380
9449
  };
9381
9450
  const onError = (err) => {
9382
9451
  if (settled) return;
@@ -9409,7 +9478,7 @@ import { createHash as createHash2 } from "node:crypto";
9409
9478
  import v8 from "node:v8";
9410
9479
  import os6 from "node:os";
9411
9480
  import dns from "node:dns";
9412
- import * as path18 from "node:path";
9481
+ import * as path19 from "node:path";
9413
9482
  import * as fsPromises from "node:fs/promises";
9414
9483
 
9415
9484
  // packages/cli/src/utils/sandbox.ts
@@ -9421,8 +9490,8 @@ import {
9421
9490
  spawn as spawn3,
9422
9491
  spawnSync
9423
9492
  } from "node:child_process";
9424
- import path10 from "node:path";
9425
- import fs7 from "node:fs";
9493
+ import path11 from "node:path";
9494
+ import fs8 from "node:fs";
9426
9495
  import os3 from "node:os";
9427
9496
  import { fileURLToPath as fileURLToPath4 } from "node:url";
9428
9497
  import { promisify } from "node:util";
@@ -9432,8 +9501,8 @@ import { randomBytes } from "node:crypto";
9432
9501
  // packages/cli/src/utils/sandboxUtils.ts
9433
9502
  var import_shell_quote = __toESM(require_shell_quote(), 1);
9434
9503
  import os2 from "node:os";
9435
- import path8 from "node:path";
9436
- import fs6 from "node:fs";
9504
+ import path9 from "node:path";
9505
+ import fs7 from "node:fs";
9437
9506
  import { readFile } from "node:fs/promises";
9438
9507
  var LOCAL_DEV_SANDBOX_IMAGE_NAME = "gemini-cli-sandbox";
9439
9508
  var SANDBOX_NETWORK_NAME = "gemini-cli-sandbox";
@@ -9463,10 +9532,10 @@ var SENSITIVE_SETTINGS_FILENAMES = /* @__PURE__ */ new Set([
9463
9532
  "policy_integrity.json"
9464
9533
  ]);
9465
9534
  function safeResolveToRealPath(targetPath) {
9466
- let current = path8.resolve(targetPath);
9535
+ let current = path9.resolve(targetPath);
9467
9536
  const parts = [];
9468
9537
  const visited = /* @__PURE__ */ new Set();
9469
- while (current && current !== path8.dirname(current)) {
9538
+ while (current && current !== path9.dirname(current)) {
9470
9539
  const visitKey = os2.platform() === "win32" ? current.toLowerCase() : current;
9471
9540
  if (visited.has(visitKey)) {
9472
9541
  throw new Error("Circular symlink detected");
@@ -9474,14 +9543,14 @@ function safeResolveToRealPath(targetPath) {
9474
9543
  visited.add(visitKey);
9475
9544
  try {
9476
9545
  const real = resolveToRealPath(current);
9477
- return path8.resolve(real, ...parts.slice().reverse());
9546
+ return path9.resolve(real, ...parts.slice().reverse());
9478
9547
  } catch (err) {
9479
9548
  if (isRecord2(err) && err["code"] === "ENOENT") {
9480
9549
  try {
9481
- const stat3 = fs6.lstatSync(current);
9550
+ const stat3 = fs7.lstatSync(current);
9482
9551
  if (stat3?.isSymbolicLink?.()) {
9483
- const target = fs6.readlinkSync(current);
9484
- current = path8.resolve(path8.dirname(current), target);
9552
+ const target = fs7.readlinkSync(current);
9553
+ current = path9.resolve(path9.dirname(current), target);
9485
9554
  continue;
9486
9555
  }
9487
9556
  } catch (lstatErr) {
@@ -9489,14 +9558,14 @@ function safeResolveToRealPath(targetPath) {
9489
9558
  throw lstatErr;
9490
9559
  }
9491
9560
  }
9492
- parts.push(path8.basename(current));
9493
- current = path8.dirname(current);
9561
+ parts.push(path9.basename(current));
9562
+ current = path9.dirname(current);
9494
9563
  continue;
9495
9564
  }
9496
9565
  throw err;
9497
9566
  }
9498
9567
  }
9499
- return path8.resolve(targetPath);
9568
+ return path9.resolve(targetPath);
9500
9569
  }
9501
9570
  function isSensitiveHostPath(hostPath) {
9502
9571
  try {
@@ -9506,7 +9575,7 @@ function isSensitiveHostPath(hostPath) {
9506
9575
  return true;
9507
9576
  }
9508
9577
  const resolvedPath = safeResolveToRealPath(hostPath);
9509
- const baseName2 = path8.basename(resolvedPath).toLowerCase();
9578
+ const baseName2 = path9.basename(resolvedPath).toLowerCase();
9510
9579
  if (baseName2 === ".env" || baseName2.startsWith(".env.") || SENSITIVE_SETTINGS_FILENAMES.has(baseName2)) {
9511
9580
  return true;
9512
9581
  }
@@ -9517,17 +9586,17 @@ function isSensitiveHostPath(hostPath) {
9517
9586
  if (hostPath === "~" || hostPath === "~/" || hostPath === "~\\") {
9518
9587
  expandedPath = home;
9519
9588
  } else if (hostPath.startsWith("~/") || hostPath.startsWith("~\\")) {
9520
- expandedPath = path8.join(home, hostPath.slice(2));
9589
+ expandedPath = path9.join(home, hostPath.slice(2));
9521
9590
  }
9522
9591
  const normalized = safeResolveToRealPath(expandedPath);
9523
- const geminiDirCandidate = path8.join(home, GEMINI_DIR);
9592
+ const geminiDirCandidate = path9.join(home, GEMINI_DIR);
9524
9593
  const geminiDirOnHost = safeResolveToRealPath(geminiDirCandidate);
9525
9594
  const isWindows = os2.platform() === "win32";
9526
- const arePathsEqual = (p1, p2) => isWindows ? path8.resolve(p1).toLowerCase() === path8.resolve(p2).toLowerCase() : path8.resolve(p1) === path8.resolve(p2);
9595
+ const arePathsEqual = (p1, p2) => isWindows ? path9.resolve(p1).toLowerCase() === path9.resolve(p2).toLowerCase() : path9.resolve(p1) === path9.resolve(p2);
9527
9596
  const isSubpathOf = (child, parent) => {
9528
- const resolvedChild = path8.resolve(child);
9529
- const resolvedParent = path8.resolve(parent);
9530
- const parentWithSep = resolvedParent.endsWith(path8.sep) ? resolvedParent : resolvedParent + path8.sep;
9597
+ const resolvedChild = path9.resolve(child);
9598
+ const resolvedParent = path9.resolve(parent);
9599
+ const parentWithSep = resolvedParent.endsWith(path9.sep) ? resolvedParent : resolvedParent + path9.sep;
9531
9600
  return isWindows ? resolvedChild.toLowerCase().startsWith(parentWithSep.toLowerCase()) : resolvedChild.startsWith(parentWithSep);
9532
9601
  };
9533
9602
  if (arePathsEqual(normalized, home) || isSubpathOf(home, normalized)) {
@@ -9536,7 +9605,7 @@ function isSensitiveHostPath(hostPath) {
9536
9605
  if (arePathsEqual(normalized, geminiDirOnHost) || isSubpathOf(normalized, geminiDirOnHost) || isSubpathOf(geminiDirOnHost, normalized)) {
9537
9606
  return true;
9538
9607
  }
9539
- const baseName = path8.basename(normalized).toLowerCase();
9608
+ const baseName = path9.basename(normalized).toLowerCase();
9540
9609
  if (baseName === ".env" || baseName.startsWith(".env.") || SENSITIVE_SETTINGS_FILENAMES.has(baseName)) {
9541
9610
  return true;
9542
9611
  }
@@ -9647,7 +9716,7 @@ function entrypoint(workdir, cliArgs) {
9647
9716
  shellCmds.push(`export PYTHONPATH="$PYTHONPATH${pythonPathSuffix}";`);
9648
9717
  }
9649
9718
  const projectSandboxBashrc = `${GEMINI_DIR}/sandbox.bashrc`;
9650
- if (fs6.existsSync(projectSandboxBashrc)) {
9719
+ if (fs7.existsSync(projectSandboxBashrc)) {
9651
9720
  shellCmds.push(`source ${getContainerPath(projectSandboxBashrc)};`);
9652
9721
  }
9653
9722
  ports().forEach(
@@ -10652,7 +10721,220 @@ BUILTIN_SEATBELT_PROFILE_CONTENTS["restrictive-closed"] = BUILTIN_SEATBELT_PROFI
10652
10721
 
10653
10722
  // packages/cli/src/utils/ideBridge.ts
10654
10723
  import { spawn as spawn2 } from "node:child_process";
10655
- import * as path9 from "node:path";
10724
+ import * as path10 from "node:path";
10725
+
10726
+ // node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/server.js
10727
+ var ExperimentalServerTasks = class {
10728
+ constructor(_server) {
10729
+ this._server = _server;
10730
+ }
10731
+ /**
10732
+ * Sends a request and returns an AsyncGenerator that yields response messages.
10733
+ * The generator is guaranteed to end with either a 'result' or 'error' message.
10734
+ *
10735
+ * This method provides streaming access to request processing, allowing you to
10736
+ * observe intermediate task status updates for task-augmented requests.
10737
+ *
10738
+ * @param request - The request to send
10739
+ * @param resultSchema - Zod schema for validating the result
10740
+ * @param options - Optional request options (timeout, signal, task creation params, etc.)
10741
+ * @returns AsyncGenerator that yields ResponseMessage objects
10742
+ *
10743
+ * @experimental
10744
+ */
10745
+ requestStream(request, resultSchema, options) {
10746
+ return this._server.requestStream(request, resultSchema, options);
10747
+ }
10748
+ /**
10749
+ * Sends a sampling request and returns an AsyncGenerator that yields response messages.
10750
+ * The generator is guaranteed to end with either a 'result' or 'error' message.
10751
+ *
10752
+ * For task-augmented requests, yields 'taskCreated' and 'taskStatus' messages
10753
+ * before the final result.
10754
+ *
10755
+ * @example
10756
+ * ```typescript
10757
+ * const stream = server.experimental.tasks.createMessageStream({
10758
+ * messages: [{ role: 'user', content: { type: 'text', text: 'Hello' } }],
10759
+ * maxTokens: 100
10760
+ * }, {
10761
+ * onprogress: (progress) => {
10762
+ * // Handle streaming tokens via progress notifications
10763
+ * console.log('Progress:', progress.message);
10764
+ * }
10765
+ * });
10766
+ *
10767
+ * for await (const message of stream) {
10768
+ * switch (message.type) {
10769
+ * case 'taskCreated':
10770
+ * console.log('Task created:', message.task.taskId);
10771
+ * break;
10772
+ * case 'taskStatus':
10773
+ * console.log('Task status:', message.task.status);
10774
+ * break;
10775
+ * case 'result':
10776
+ * console.log('Final result:', message.result);
10777
+ * break;
10778
+ * case 'error':
10779
+ * console.error('Error:', message.error);
10780
+ * break;
10781
+ * }
10782
+ * }
10783
+ * ```
10784
+ *
10785
+ * @param params - The sampling request parameters
10786
+ * @param options - Optional request options (timeout, signal, task creation params, onprogress, etc.)
10787
+ * @returns AsyncGenerator that yields ResponseMessage objects
10788
+ *
10789
+ * @experimental
10790
+ */
10791
+ createMessageStream(params, options) {
10792
+ const clientCapabilities = this._server.getClientCapabilities();
10793
+ if ((params.tools || params.toolChoice) && !clientCapabilities?.sampling?.tools) {
10794
+ throw new Error("Client does not support sampling tools capability.");
10795
+ }
10796
+ if (params.messages.length > 0) {
10797
+ const lastMessage = params.messages[params.messages.length - 1];
10798
+ const lastContent = Array.isArray(lastMessage.content) ? lastMessage.content : [lastMessage.content];
10799
+ const hasToolResults = lastContent.some((c) => c.type === "tool_result");
10800
+ const previousMessage = params.messages.length > 1 ? params.messages[params.messages.length - 2] : void 0;
10801
+ const previousContent = previousMessage ? Array.isArray(previousMessage.content) ? previousMessage.content : [previousMessage.content] : [];
10802
+ const hasPreviousToolUse = previousContent.some((c) => c.type === "tool_use");
10803
+ if (hasToolResults) {
10804
+ if (lastContent.some((c) => c.type !== "tool_result")) {
10805
+ throw new Error("The last message must contain only tool_result content if any is present");
10806
+ }
10807
+ if (!hasPreviousToolUse) {
10808
+ throw new Error("tool_result blocks are not matching any tool_use from the previous message");
10809
+ }
10810
+ }
10811
+ if (hasPreviousToolUse) {
10812
+ const toolUseIds = new Set(previousContent.filter((c) => c.type === "tool_use").map((c) => c.id));
10813
+ const toolResultIds = new Set(lastContent.filter((c) => c.type === "tool_result").map((c) => c.toolUseId));
10814
+ if (toolUseIds.size !== toolResultIds.size || ![...toolUseIds].every((id) => toolResultIds.has(id))) {
10815
+ throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match");
10816
+ }
10817
+ }
10818
+ }
10819
+ return this.requestStream({
10820
+ method: "sampling/createMessage",
10821
+ params
10822
+ }, CreateMessageResultSchema, options);
10823
+ }
10824
+ /**
10825
+ * Sends an elicitation request and returns an AsyncGenerator that yields response messages.
10826
+ * The generator is guaranteed to end with either a 'result' or 'error' message.
10827
+ *
10828
+ * For task-augmented requests (especially URL-based elicitation), yields 'taskCreated'
10829
+ * and 'taskStatus' messages before the final result.
10830
+ *
10831
+ * @example
10832
+ * ```typescript
10833
+ * const stream = server.experimental.tasks.elicitInputStream({
10834
+ * mode: 'url',
10835
+ * message: 'Please authenticate',
10836
+ * elicitationId: 'auth-123',
10837
+ * url: 'https://example.com/auth'
10838
+ * }, {
10839
+ * task: { ttl: 300000 } // Task-augmented for long-running auth flow
10840
+ * });
10841
+ *
10842
+ * for await (const message of stream) {
10843
+ * switch (message.type) {
10844
+ * case 'taskCreated':
10845
+ * console.log('Task created:', message.task.taskId);
10846
+ * break;
10847
+ * case 'taskStatus':
10848
+ * console.log('Task status:', message.task.status);
10849
+ * break;
10850
+ * case 'result':
10851
+ * console.log('User action:', message.result.action);
10852
+ * break;
10853
+ * case 'error':
10854
+ * console.error('Error:', message.error);
10855
+ * break;
10856
+ * }
10857
+ * }
10858
+ * ```
10859
+ *
10860
+ * @param params - The elicitation request parameters
10861
+ * @param options - Optional request options (timeout, signal, task creation params, etc.)
10862
+ * @returns AsyncGenerator that yields ResponseMessage objects
10863
+ *
10864
+ * @experimental
10865
+ */
10866
+ elicitInputStream(params, options) {
10867
+ const clientCapabilities = this._server.getClientCapabilities();
10868
+ const mode = params.mode ?? "form";
10869
+ switch (mode) {
10870
+ case "url": {
10871
+ if (!clientCapabilities?.elicitation?.url) {
10872
+ throw new Error("Client does not support url elicitation.");
10873
+ }
10874
+ break;
10875
+ }
10876
+ case "form": {
10877
+ if (!clientCapabilities?.elicitation?.form) {
10878
+ throw new Error("Client does not support form elicitation.");
10879
+ }
10880
+ break;
10881
+ }
10882
+ }
10883
+ const normalizedParams = mode === "form" && params.mode === void 0 ? { ...params, mode: "form" } : params;
10884
+ return this.requestStream({
10885
+ method: "elicitation/create",
10886
+ params: normalizedParams
10887
+ }, ElicitResultSchema, options);
10888
+ }
10889
+ /**
10890
+ * Gets the current status of a task.
10891
+ *
10892
+ * @param taskId - The task identifier
10893
+ * @param options - Optional request options
10894
+ * @returns The task status
10895
+ *
10896
+ * @experimental
10897
+ */
10898
+ async getTask(taskId, options) {
10899
+ return this._server.getTask({ taskId }, options);
10900
+ }
10901
+ /**
10902
+ * Retrieves the result of a completed task.
10903
+ *
10904
+ * @param taskId - The task identifier
10905
+ * @param resultSchema - Zod schema for validating the result
10906
+ * @param options - Optional request options
10907
+ * @returns The task result
10908
+ *
10909
+ * @experimental
10910
+ */
10911
+ async getTaskResult(taskId, resultSchema, options) {
10912
+ return this._server.getTaskResult({ taskId }, resultSchema, options);
10913
+ }
10914
+ /**
10915
+ * Lists tasks with optional pagination.
10916
+ *
10917
+ * @param cursor - Optional pagination cursor
10918
+ * @param options - Optional request options
10919
+ * @returns List of tasks with optional next cursor
10920
+ *
10921
+ * @experimental
10922
+ */
10923
+ async listTasks(cursor, options) {
10924
+ return this._server.listTasks(cursor ? { cursor } : void 0, options);
10925
+ }
10926
+ /**
10927
+ * Cancels a running task.
10928
+ *
10929
+ * @param taskId - The task identifier
10930
+ * @param options - Optional request options
10931
+ *
10932
+ * @experimental
10933
+ */
10934
+ async cancelTask(taskId, options) {
10935
+ return this._server.cancelTask({ taskId }, options);
10936
+ }
10937
+ };
10656
10938
 
10657
10939
  // node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js
10658
10940
  var Server = class extends Protocol {
@@ -10660,7 +10942,6 @@ var Server = class extends Protocol {
10660
10942
  * Initializes this server with the given name and version information.
10661
10943
  */
10662
10944
  constructor(_serverInfo, options) {
10663
- var _a2, _b2;
10664
10945
  super(options);
10665
10946
  this._serverInfo = _serverInfo;
10666
10947
  this._loggingLevels = /* @__PURE__ */ new Map();
@@ -10669,18 +10950,14 @@ var Server = class extends Protocol {
10669
10950
  const currentLevel = this._loggingLevels.get(sessionId);
10670
10951
  return currentLevel ? this.LOG_LEVEL_SEVERITY.get(level) < this.LOG_LEVEL_SEVERITY.get(currentLevel) : false;
10671
10952
  };
10672
- this._capabilities = (_a2 = options === null || options === void 0 ? void 0 : options.capabilities) !== null && _a2 !== void 0 ? _a2 : {};
10673
- this._instructions = options === null || options === void 0 ? void 0 : options.instructions;
10674
- this._jsonSchemaValidator = (_b2 = options === null || options === void 0 ? void 0 : options.jsonSchemaValidator) !== null && _b2 !== void 0 ? _b2 : new AjvJsonSchemaValidator();
10953
+ this._capabilities = options?.capabilities ?? {};
10954
+ this._instructions = options?.instructions;
10955
+ this._jsonSchemaValidator = options?.jsonSchemaValidator ?? new AjvJsonSchemaValidator();
10675
10956
  this.setRequestHandler(InitializeRequestSchema, (request) => this._oninitialize(request));
10676
- this.setNotificationHandler(InitializedNotificationSchema, () => {
10677
- var _a3;
10678
- return (_a3 = this.oninitialized) === null || _a3 === void 0 ? void 0 : _a3.call(this);
10679
- });
10957
+ this.setNotificationHandler(InitializedNotificationSchema, () => this.oninitialized?.());
10680
10958
  if (this._capabilities.logging) {
10681
10959
  this.setRequestHandler(SetLevelRequestSchema, async (request, extra) => {
10682
- var _a3;
10683
- const transportSessionId = extra.sessionId || ((_a3 = extra.requestInfo) === null || _a3 === void 0 ? void 0 : _a3.headers["mcp-session-id"]) || void 0;
10960
+ const transportSessionId = extra.sessionId || extra.requestInfo?.headers["mcp-session-id"] || void 0;
10684
10961
  const { level } = request.params;
10685
10962
  const parseResult = LoggingLevelSchema.safeParse(level);
10686
10963
  if (parseResult.success) {
@@ -10690,6 +10967,21 @@ var Server = class extends Protocol {
10690
10967
  });
10691
10968
  }
10692
10969
  }
10970
+ /**
10971
+ * Access experimental features.
10972
+ *
10973
+ * WARNING: These APIs are experimental and may change without notice.
10974
+ *
10975
+ * @experimental
10976
+ */
10977
+ get experimental() {
10978
+ if (!this._experimental) {
10979
+ this._experimental = {
10980
+ tasks: new ExperimentalServerTasks(this)
10981
+ };
10982
+ }
10983
+ return this._experimental;
10984
+ }
10693
10985
  /**
10694
10986
  * Registers new capabilities. This can only be called before connecting to a transport.
10695
10987
  *
@@ -10701,21 +10993,62 @@ var Server = class extends Protocol {
10701
10993
  }
10702
10994
  this._capabilities = mergeCapabilities(this._capabilities, capabilities);
10703
10995
  }
10996
+ /**
10997
+ * Override request handler registration to enforce server-side validation for tools/call.
10998
+ */
10999
+ setRequestHandler(requestSchema, handler) {
11000
+ const shape = getObjectShape(requestSchema);
11001
+ const methodSchema = shape?.method;
11002
+ if (!methodSchema) {
11003
+ throw new Error("Schema is missing a method literal");
11004
+ }
11005
+ const methodValue = getLiteralValue(methodSchema);
11006
+ if (typeof methodValue !== "string") {
11007
+ throw new Error("Schema method literal must be a string");
11008
+ }
11009
+ const method = methodValue;
11010
+ if (method === "tools/call") {
11011
+ const wrappedHandler = async (request, extra) => {
11012
+ const validatedRequest = safeParse(CallToolRequestSchema, request);
11013
+ if (!validatedRequest.success) {
11014
+ const errorMessage = validatedRequest.error instanceof Error ? validatedRequest.error.message : String(validatedRequest.error);
11015
+ throw new McpError(ErrorCode.InvalidParams, `Invalid tools/call request: ${errorMessage}`);
11016
+ }
11017
+ const { params } = validatedRequest.data;
11018
+ const result = await Promise.resolve(handler(request, extra));
11019
+ if (params.task) {
11020
+ const taskValidationResult = safeParse(CreateTaskResultSchema, result);
11021
+ if (!taskValidationResult.success) {
11022
+ const errorMessage = taskValidationResult.error instanceof Error ? taskValidationResult.error.message : String(taskValidationResult.error);
11023
+ throw new McpError(ErrorCode.InvalidParams, `Invalid task creation result: ${errorMessage}`);
11024
+ }
11025
+ return taskValidationResult.data;
11026
+ }
11027
+ const validationResult = safeParse(CallToolResultSchema, result);
11028
+ if (!validationResult.success) {
11029
+ const errorMessage = validationResult.error instanceof Error ? validationResult.error.message : String(validationResult.error);
11030
+ throw new McpError(ErrorCode.InvalidParams, `Invalid tools/call result: ${errorMessage}`);
11031
+ }
11032
+ return validationResult.data;
11033
+ };
11034
+ return super.setRequestHandler(requestSchema, wrappedHandler);
11035
+ }
11036
+ return super.setRequestHandler(requestSchema, handler);
11037
+ }
10704
11038
  assertCapabilityForMethod(method) {
10705
- var _a2, _b2, _c2;
10706
11039
  switch (method) {
10707
11040
  case "sampling/createMessage":
10708
- if (!((_a2 = this._clientCapabilities) === null || _a2 === void 0 ? void 0 : _a2.sampling)) {
11041
+ if (!this._clientCapabilities?.sampling) {
10709
11042
  throw new Error(`Client does not support sampling (required for ${method})`);
10710
11043
  }
10711
11044
  break;
10712
11045
  case "elicitation/create":
10713
- if (!((_b2 = this._clientCapabilities) === null || _b2 === void 0 ? void 0 : _b2.elicitation)) {
11046
+ if (!this._clientCapabilities?.elicitation) {
10714
11047
  throw new Error(`Client does not support elicitation (required for ${method})`);
10715
11048
  }
10716
11049
  break;
10717
11050
  case "roots/list":
10718
- if (!((_c2 = this._clientCapabilities) === null || _c2 === void 0 ? void 0 : _c2.roots)) {
11051
+ if (!this._clientCapabilities?.roots) {
10719
11052
  throw new Error(`Client does not support listing roots (required for ${method})`);
10720
11053
  }
10721
11054
  break;
@@ -10724,7 +11057,6 @@ var Server = class extends Protocol {
10724
11057
  }
10725
11058
  }
10726
11059
  assertNotificationCapability(method) {
10727
- var _a2, _b2;
10728
11060
  switch (method) {
10729
11061
  case "notifications/message":
10730
11062
  if (!this._capabilities.logging) {
@@ -10748,7 +11080,7 @@ var Server = class extends Protocol {
10748
11080
  }
10749
11081
  break;
10750
11082
  case "notifications/elicitation/complete":
10751
- if (!((_b2 = (_a2 = this._clientCapabilities) === null || _a2 === void 0 ? void 0 : _a2.elicitation) === null || _b2 === void 0 ? void 0 : _b2.url)) {
11083
+ if (!this._clientCapabilities?.elicitation?.url) {
10752
11084
  throw new Error(`Client does not support URL elicitation (required for ${method})`);
10753
11085
  }
10754
11086
  break;
@@ -10759,6 +11091,9 @@ var Server = class extends Protocol {
10759
11091
  }
10760
11092
  }
10761
11093
  assertRequestHandlerCapability(method) {
11094
+ if (!this._capabilities) {
11095
+ return;
11096
+ }
10762
11097
  switch (method) {
10763
11098
  case "completion/complete":
10764
11099
  if (!this._capabilities.completions) {
@@ -10789,11 +11124,28 @@ var Server = class extends Protocol {
10789
11124
  throw new Error(`Server does not support tools (required for ${method})`);
10790
11125
  }
10791
11126
  break;
11127
+ case "tasks/get":
11128
+ case "tasks/list":
11129
+ case "tasks/result":
11130
+ case "tasks/cancel":
11131
+ if (!this._capabilities.tasks) {
11132
+ throw new Error(`Server does not support tasks capability (required for ${method})`);
11133
+ }
11134
+ break;
10792
11135
  case "ping":
10793
11136
  case "initialize":
10794
11137
  break;
10795
11138
  }
10796
11139
  }
11140
+ assertTaskCapability(method) {
11141
+ assertClientRequestTaskCapability(this._clientCapabilities?.tasks?.requests, method, "Client");
11142
+ }
11143
+ assertTaskHandlerCapability(method) {
11144
+ if (!this._capabilities) {
11145
+ return;
11146
+ }
11147
+ assertToolsCallTaskCapability(this._capabilities.tasks?.requests, method, "Server");
11148
+ }
10797
11149
  async _oninitialize(request) {
10798
11150
  const requestedVersion = request.params.protocolVersion;
10799
11151
  this._clientCapabilities = request.params.capabilities;
@@ -10824,10 +11176,10 @@ var Server = class extends Protocol {
10824
11176
  async ping() {
10825
11177
  return this.request({ method: "ping" }, EmptyResultSchema);
10826
11178
  }
11179
+ // Implementation
10827
11180
  async createMessage(params, options) {
10828
- var _a2, _b2;
10829
11181
  if (params.tools || params.toolChoice) {
10830
- if (!((_b2 = (_a2 = this._clientCapabilities) === null || _a2 === void 0 ? void 0 : _a2.sampling) === null || _b2 === void 0 ? void 0 : _b2.tools)) {
11182
+ if (!this._clientCapabilities?.sampling?.tools) {
10831
11183
  throw new Error("Client does not support sampling tools capability.");
10832
11184
  }
10833
11185
  }
@@ -10854,6 +11206,9 @@ var Server = class extends Protocol {
10854
11206
  }
10855
11207
  }
10856
11208
  }
11209
+ if (params.tools) {
11210
+ return this.request({ method: "sampling/createMessage", params }, CreateMessageResultWithToolsSchema, options);
11211
+ }
10857
11212
  return this.request({ method: "sampling/createMessage", params }, CreateMessageResultSchema, options);
10858
11213
  }
10859
11214
  /**
@@ -10864,18 +11219,17 @@ var Server = class extends Protocol {
10864
11219
  * @returns The result of the elicitation request.
10865
11220
  */
10866
11221
  async elicitInput(params, options) {
10867
- var _a2, _b2, _c2, _d, _e;
10868
- const mode = (_a2 = params.mode) !== null && _a2 !== void 0 ? _a2 : "form";
11222
+ const mode = params.mode ?? "form";
10869
11223
  switch (mode) {
10870
11224
  case "url": {
10871
- if (!((_c2 = (_b2 = this._clientCapabilities) === null || _b2 === void 0 ? void 0 : _b2.elicitation) === null || _c2 === void 0 ? void 0 : _c2.url)) {
11225
+ if (!this._clientCapabilities?.elicitation?.url) {
10872
11226
  throw new Error("Client does not support url elicitation.");
10873
11227
  }
10874
11228
  const urlParams = params;
10875
11229
  return this.request({ method: "elicitation/create", params: urlParams }, ElicitResultSchema, options);
10876
11230
  }
10877
11231
  case "form": {
10878
- if (!((_e = (_d = this._clientCapabilities) === null || _d === void 0 ? void 0 : _d.elicitation) === null || _e === void 0 ? void 0 : _e.form)) {
11232
+ if (!this._clientCapabilities?.elicitation?.form) {
10879
11233
  throw new Error("Client does not support form elicitation.");
10880
11234
  }
10881
11235
  const formParams = params.mode === "form" ? params : { ...params, mode: "form" };
@@ -10907,8 +11261,7 @@ var Server = class extends Protocol {
10907
11261
  * @returns A function that emits the completion notification when awaited.
10908
11262
  */
10909
11263
  createElicitationCompletionNotifier(elicitationId, options) {
10910
- var _a2, _b2;
10911
- if (!((_b2 = (_a2 = this._clientCapabilities) === null || _a2 === void 0 ? void 0 : _a2.elicitation) === null || _b2 === void 0 ? void 0 : _b2.url)) {
11264
+ if (!this._clientCapabilities?.elicitation?.url) {
10912
11265
  throw new Error("Client does not support URL elicitation (required for notifications/elicitation/complete)");
10913
11266
  }
10914
11267
  return () => this.notification({
@@ -10957,19 +11310,24 @@ var Server = class extends Protocol {
10957
11310
  // node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js
10958
11311
  import process4 from "node:process";
10959
11312
  var StdioServerTransport = class {
10960
- constructor(_stdin = process4.stdin, _stdout = process4.stdout) {
11313
+ constructor(_stdin = process4.stdin, _stdout = process4.stdout, options) {
10961
11314
  this._stdin = _stdin;
10962
11315
  this._stdout = _stdout;
10963
- this._readBuffer = new ReadBuffer();
10964
11316
  this._started = false;
10965
11317
  this._ondata = (chunk) => {
10966
- this._readBuffer.append(chunk);
10967
- this.processReadBuffer();
11318
+ try {
11319
+ this._readBuffer.append(chunk);
11320
+ this.processReadBuffer();
11321
+ } catch (error) {
11322
+ this.onerror?.(error);
11323
+ this.close().catch(() => {
11324
+ });
11325
+ }
10968
11326
  };
10969
11327
  this._onerror = (error) => {
10970
- var _a2;
10971
- (_a2 = this.onerror) === null || _a2 === void 0 ? void 0 : _a2.call(this, error);
11328
+ this.onerror?.(error);
10972
11329
  };
11330
+ this._readBuffer = new ReadBuffer({ maxBufferSize: options?.maxBufferSize });
10973
11331
  }
10974
11332
  /**
10975
11333
  * Starts listening for messages on stdin.
@@ -10983,21 +11341,19 @@ var StdioServerTransport = class {
10983
11341
  this._stdin.on("error", this._onerror);
10984
11342
  }
10985
11343
  processReadBuffer() {
10986
- var _a2, _b2;
10987
11344
  while (true) {
10988
11345
  try {
10989
11346
  const message = this._readBuffer.readMessage();
10990
11347
  if (message === null) {
10991
11348
  break;
10992
11349
  }
10993
- (_a2 = this.onmessage) === null || _a2 === void 0 ? void 0 : _a2.call(this, message);
11350
+ this.onmessage?.(message);
10994
11351
  } catch (error) {
10995
- (_b2 = this.onerror) === null || _b2 === void 0 ? void 0 : _b2.call(this, error);
11352
+ this.onerror?.(error);
10996
11353
  }
10997
11354
  }
10998
11355
  }
10999
11356
  async close() {
11000
- var _a2;
11001
11357
  this._stdin.off("data", this._ondata);
11002
11358
  this._stdin.off("error", this._onerror);
11003
11359
  const remainingDataListeners = this._stdin.listenerCount("data");
@@ -11005,15 +11361,15 @@ var StdioServerTransport = class {
11005
11361
  this._stdin.pause();
11006
11362
  }
11007
11363
  this._readBuffer.clear();
11008
- (_a2 = this.onclose) === null || _a2 === void 0 ? void 0 : _a2.call(this);
11364
+ this.onclose?.();
11009
11365
  }
11010
11366
  send(message) {
11011
- return new Promise((resolve10) => {
11367
+ return new Promise((resolve11) => {
11012
11368
  const json = serializeMessage(message);
11013
11369
  if (this._stdout.write(json)) {
11014
- resolve10();
11370
+ resolve11();
11015
11371
  } else {
11016
- this._stdout.once("drain", resolve10);
11372
+ this._stdout.once("drain", resolve11);
11017
11373
  }
11018
11374
  });
11019
11375
  }
@@ -11170,7 +11526,7 @@ async function resolveIdeBridgeUpstream() {
11170
11526
  return void 0;
11171
11527
  }
11172
11528
  const workspacePath = fromFile?.workspacePath ?? process.env["GEMINI_CLI_IDE_WORKSPACE_PATH"];
11173
- const workspacePaths = (workspacePath ?? "").split(path9.delimiter).filter(Boolean).map((p) => path9.resolve(p));
11529
+ const workspacePaths = (workspacePath ?? "").split(path10.delimiter).filter(Boolean).map((p) => path10.resolve(p));
11174
11530
  return {
11175
11531
  port,
11176
11532
  authToken: fromFile?.authToken ?? process.env["GEMINI_CLI_IDE_AUTH_TOKEN"],
@@ -11391,7 +11747,7 @@ var IdeBridge = class {
11391
11747
  "serve",
11392
11748
  this.options.socketPathInContainer
11393
11749
  ];
11394
- return new Promise((resolve10) => {
11750
+ return new Promise((resolve11) => {
11395
11751
  const child = spawn2(command2, args, {
11396
11752
  stdio: ["pipe", "pipe", "pipe"]
11397
11753
  });
@@ -11417,7 +11773,7 @@ var IdeBridge = class {
11417
11773
  logger.debug(`helper exec failed: ${stderr.trim()}`);
11418
11774
  }
11419
11775
  }
11420
- resolve10(result);
11776
+ resolve11(result);
11421
11777
  };
11422
11778
  const timer = setTimeout(
11423
11779
  () => settle(void 0),
@@ -11490,13 +11846,13 @@ var IdeBridge = class {
11490
11846
  * host, before it reaches the IDE.
11491
11847
  */
11492
11848
  assertWithinWorkspace(filePath) {
11493
- if (typeof filePath !== "string" || !path9.isAbsolute(filePath)) {
11849
+ if (typeof filePath !== "string" || !path10.isAbsolute(filePath)) {
11494
11850
  throw new McpError(
11495
11851
  ErrorCode.InvalidParams,
11496
11852
  "filePath must be an absolute path"
11497
11853
  );
11498
11854
  }
11499
- const resolved = path9.resolve(filePath);
11855
+ const resolved = path10.resolve(filePath);
11500
11856
  const allowed = this.upstreamInfo.workspacePaths.some(
11501
11857
  (workspace) => isSubpath(workspace, resolved)
11502
11858
  );
@@ -11535,7 +11891,7 @@ var IdeBridge = class {
11535
11891
  }
11536
11892
  };
11537
11893
  function delay(ms) {
11538
- return new Promise((resolve10) => setTimeout(resolve10, ms));
11894
+ return new Promise((resolve11) => setTimeout(resolve11, ms));
11539
11895
  }
11540
11896
 
11541
11897
  // packages/cli/src/utils/sandbox.ts
@@ -11606,8 +11962,8 @@ async function start_sandbox(config, nodeArgs = [], cliConfig, cliArgs = []) {
11606
11962
  const dirToDelete = sandboxTmpDir;
11607
11963
  sandboxTmpDir = null;
11608
11964
  try {
11609
- if (fs7.existsSync(dirToDelete)) {
11610
- fs7.rmSync(dirToDelete, { recursive: true, force: true });
11965
+ if (fs8.existsSync(dirToDelete)) {
11966
+ fs8.rmSync(dirToDelete, { recursive: true, force: true });
11611
11967
  }
11612
11968
  } catch {
11613
11969
  }
@@ -11616,8 +11972,8 @@ async function start_sandbox(config, nodeArgs = [], cliConfig, cliArgs = []) {
11616
11972
  const fileToDelete = tempProfileFile;
11617
11973
  tempProfileFile = null;
11618
11974
  try {
11619
- if (fs7.existsSync(fileToDelete)) {
11620
- fs7.unlinkSync(fileToDelete);
11975
+ if (fs8.existsSync(fileToDelete)) {
11976
+ fs8.unlinkSync(fileToDelete);
11621
11977
  }
11622
11978
  } catch {
11623
11979
  }
@@ -11654,24 +12010,24 @@ async function start_sandbox(config, nodeArgs = [], cliConfig, cliArgs = []) {
11654
12010
  new URL(`sandbox-macos-${profile}.sb`, import.meta.url)
11655
12011
  );
11656
12012
  if (!BUILTIN_SEATBELT_PROFILES.includes(profile)) {
11657
- const safeProfile = path10.basename(profile);
12013
+ const safeProfile = path11.basename(profile);
11658
12014
  const fileName = `sandbox-macos-${safeProfile}.sb`;
11659
12015
  const userHome = homedir();
11660
- const userProfileFile = userHome ? path10.join(userHome, GEMINI_DIR, fileName) : "";
11661
- const projectProfileFile = path10.join(GEMINI_DIR, fileName);
11662
- profileFile = userProfileFile && fs7.existsSync(userProfileFile) ? userProfileFile : projectProfileFile;
12016
+ const userProfileFile = userHome ? path11.join(userHome, GEMINI_DIR, fileName) : "";
12017
+ const projectProfileFile = path11.join(GEMINI_DIR, fileName);
12018
+ profileFile = userProfileFile && fs8.existsSync(userProfileFile) ? userProfileFile : projectProfileFile;
11663
12019
  } else {
11664
- if (!fs7.existsSync(profileFile)) {
12020
+ if (!fs8.existsSync(profileFile)) {
11665
12021
  const content = BUILTIN_SEATBELT_PROFILE_CONTENTS[profile];
11666
12022
  if (content) {
11667
12023
  try {
11668
- const tempDir = fs7.realpathSync(os3.tmpdir());
12024
+ const tempDir = fs8.realpathSync(os3.tmpdir());
11669
12025
  const rand = randomBytes(8).toString("hex");
11670
- tempProfileFile = path10.join(
12026
+ tempProfileFile = path11.join(
11671
12027
  tempDir,
11672
12028
  `gemini-sandbox-macos-${profile}-${rand}.sb`
11673
12029
  );
11674
- fs7.writeFileSync(tempProfileFile, content, {
12030
+ fs8.writeFileSync(tempProfileFile, content, {
11675
12031
  encoding: "utf8",
11676
12032
  mode: 384
11677
12033
  });
@@ -11685,7 +12041,7 @@ async function start_sandbox(config, nodeArgs = [], cliConfig, cliArgs = []) {
11685
12041
  }
11686
12042
  }
11687
12043
  try {
11688
- if (!fs7.existsSync(profileFile)) {
12044
+ if (!fs8.existsSync(profileFile)) {
11689
12045
  throw new FatalSandboxError(
11690
12046
  `Missing macos seatbelt profile file '${profileFile}'`
11691
12047
  );
@@ -11695,26 +12051,26 @@ async function start_sandbox(config, nodeArgs = [], cliConfig, cliArgs = []) {
11695
12051
  ...process.env["DEBUG"] ? ["--inspect-brk"] : [],
11696
12052
  ...nodeArgs
11697
12053
  ].join(" ");
11698
- const targetDir = fs7.realpathSync(process.cwd());
12054
+ const targetDir = fs8.realpathSync(process.cwd());
11699
12055
  if (isSensitiveHostPath(targetDir)) {
11700
12056
  throw new FatalSandboxError(
11701
12057
  `Running sandbox from a sensitive host directory '${targetDir}' is strictly prohibited`
11702
12058
  );
11703
12059
  }
11704
- const hostTmpDir = fs7.realpathSync(os3.tmpdir());
11705
- const resolvedTmpDir = fs7.mkdtempSync(
11706
- path10.join(hostTmpDir, "gemini-sandbox-")
12060
+ const hostTmpDir = fs8.realpathSync(os3.tmpdir());
12061
+ const resolvedTmpDir = fs8.mkdtempSync(
12062
+ path11.join(hostTmpDir, "gemini-sandbox-")
11707
12063
  );
11708
12064
  try {
11709
- fs7.chmodSync(resolvedTmpDir, 448);
12065
+ fs8.chmodSync(resolvedTmpDir, 448);
11710
12066
  } catch {
11711
12067
  }
11712
12068
  sandboxTmpDir = resolvedTmpDir;
11713
12069
  const userHome = homedir();
11714
12070
  if (userHome) {
11715
- const seatbeltCacheDir = path10.join(userHome, ".cache", GEMINI_DIR);
12071
+ const seatbeltCacheDir = path11.join(userHome, ".cache", GEMINI_DIR);
11716
12072
  try {
11717
- fs7.mkdirSync(seatbeltCacheDir, { recursive: true });
12073
+ fs8.mkdirSync(seatbeltCacheDir, { recursive: true });
11718
12074
  } catch {
11719
12075
  }
11720
12076
  }
@@ -11724,9 +12080,9 @@ async function start_sandbox(config, nodeArgs = [], cliConfig, cliArgs = []) {
11724
12080
  "-D",
11725
12081
  `TMP_DIR=${resolvedTmpDir}`,
11726
12082
  "-D",
11727
- `HOME_DIR=${fs7.realpathSync(homedir())}`,
12083
+ `HOME_DIR=${fs8.realpathSync(homedir())}`,
11728
12084
  "-D",
11729
- `CACHE_DIR=${fs7.realpathSync((await execAsync("getconf DARWIN_USER_CACHE_DIR")).stdout.trim())}`
12085
+ `CACHE_DIR=${fs8.realpathSync((await execAsync("getconf DARWIN_USER_CACHE_DIR")).stdout.trim())}`
11730
12086
  ];
11731
12087
  const MAX_INCLUDE_DIRS = 5;
11732
12088
  const configTargetDir = cliConfig?.getTargetDir() ? resolveToRealPath(cliConfig.getTargetDir()) : targetDir;
@@ -11757,8 +12113,8 @@ async function start_sandbox(config, nodeArgs = [], cliConfig, cliArgs = []) {
11757
12113
  }
11758
12114
  if (config.allowedPaths) {
11759
12115
  for (const hostPath of config.allowedPaths) {
11760
- if (hostPath && path10.isAbsolute(hostPath) && fs7.existsSync(hostPath)) {
11761
- const realDir = fs7.realpathSync(hostPath);
12116
+ if (hostPath && path11.isAbsolute(hostPath) && fs8.existsSync(hostPath)) {
12117
+ const realDir = fs8.realpathSync(hostPath);
11762
12118
  if (!includedDirs.includes(realDir) && realDir !== targetDir && realDir !== configTargetDir) {
11763
12119
  if (isSensitiveHostPath(realDir)) {
11764
12120
  debugLogger.warn(
@@ -11846,7 +12202,7 @@ async function start_sandbox(config, nodeArgs = [], cliConfig, cliArgs = []) {
11846
12202
  stdio: "inherit",
11847
12203
  env: sandboxEnv
11848
12204
  });
11849
- return await new Promise((resolve10, reject) => {
12205
+ return await new Promise((resolve11, reject) => {
11850
12206
  sandboxProcess2?.on("error", (err) => {
11851
12207
  cleanup();
11852
12208
  reject(err);
@@ -11854,7 +12210,7 @@ async function start_sandbox(config, nodeArgs = [], cliConfig, cliArgs = []) {
11854
12210
  sandboxProcess2?.on("close", (code) => {
11855
12211
  process.stdin.resume();
11856
12212
  cleanup();
11857
- resolve10(code ?? 1);
12213
+ resolve11(code ?? 1);
11858
12214
  });
11859
12215
  });
11860
12216
  } catch (err) {
@@ -11868,17 +12224,17 @@ async function start_sandbox(config, nodeArgs = [], cliConfig, cliArgs = []) {
11868
12224
  const command2 = config.command === "runsc" ? "docker" : config.command;
11869
12225
  if (!command2) throw new FatalSandboxError("Sandbox command is required");
11870
12226
  debugLogger.log(`hopping into sandbox (command: ${command2}) ...`);
11871
- const gcPath = process.argv[1] ? fs7.realpathSync(process.argv[1]) : "";
11872
- const projectSandboxDockerfile = path10.join(
12227
+ const gcPath = process.argv[1] ? fs8.realpathSync(process.argv[1]) : "";
12228
+ const projectSandboxDockerfile = path11.join(
11873
12229
  GEMINI_DIR,
11874
12230
  "sandbox.Dockerfile"
11875
12231
  );
11876
- const isCustomProjectSandbox = fs7.existsSync(projectSandboxDockerfile);
12232
+ const isCustomProjectSandbox = fs8.existsSync(projectSandboxDockerfile);
11877
12233
  const image = config.image;
11878
12234
  if (!image) throw new FatalSandboxError("Sandbox image is required");
11879
12235
  if (!/^[a-zA-Z0-9_.:/-]+$/.test(image))
11880
12236
  throw new FatalSandboxError("Invalid sandbox image name");
11881
- const workdir = path10.resolve(process.cwd());
12237
+ const workdir = path11.resolve(process.cwd());
11882
12238
  const containerWorkdir = getContainerPath(workdir);
11883
12239
  if (process.env["BUILD_SANDBOX"]) {
11884
12240
  if (!gcPath.includes("gemini-cli/packages/")) {
@@ -11889,13 +12245,13 @@ async function start_sandbox(config, nodeArgs = [], cliConfig, cliArgs = []) {
11889
12245
  debugLogger.log("building sandbox ...");
11890
12246
  const gcRoot = gcPath.split("/packages/")[0];
11891
12247
  let buildArgs = "";
11892
- const projectSandboxDockerfile2 = path10.join(
12248
+ const projectSandboxDockerfile2 = path11.join(
11893
12249
  GEMINI_DIR,
11894
12250
  "sandbox.Dockerfile"
11895
12251
  );
11896
12252
  if (isCustomProjectSandbox) {
11897
12253
  debugLogger.log(`using ${projectSandboxDockerfile2} for sandbox`);
11898
- buildArgs += `-f ${path10.resolve(projectSandboxDockerfile2)} -i ${image}`;
12254
+ buildArgs += `-f ${path11.resolve(projectSandboxDockerfile2)} -i ${image}`;
11899
12255
  }
11900
12256
  execSync(
11901
12257
  `cd ${gcRoot} && node scripts/build_sandbox.js -s ${buildArgs}`,
@@ -11941,24 +12297,24 @@ async function start_sandbox(config, nodeArgs = [], cliConfig, cliArgs = []) {
11941
12297
  }
11942
12298
  args.push("--volume", `${workdir}:${containerWorkdir}`);
11943
12299
  if (!sandboxTmpDir) {
11944
- const hostTmpDir = fs7.realpathSync(os3.tmpdir());
11945
- sandboxTmpDir = fs7.mkdtempSync(path10.join(hostTmpDir, "gemini-sandbox-"));
12300
+ const hostTmpDir = fs8.realpathSync(os3.tmpdir());
12301
+ sandboxTmpDir = fs8.mkdtempSync(path11.join(hostTmpDir, "gemini-sandbox-"));
11946
12302
  try {
11947
- fs7.chmodSync(sandboxTmpDir, 448);
12303
+ fs8.chmodSync(sandboxTmpDir, 448);
11948
12304
  } catch {
11949
12305
  }
11950
12306
  }
11951
12307
  const userHomeDirOnHost = homedir();
11952
12308
  let rawSettings = {};
11953
12309
  if (userHomeDirOnHost) {
11954
- const userSettingsFileOnHost = path10.join(
12310
+ const userSettingsFileOnHost = path11.join(
11955
12311
  userHomeDirOnHost,
11956
12312
  GEMINI_DIR,
11957
12313
  "settings.json"
11958
12314
  );
11959
- if (fs7.existsSync(userSettingsFileOnHost)) {
12315
+ if (fs8.existsSync(userSettingsFileOnHost)) {
11960
12316
  try {
11961
- const rawContent = fs7.readFileSync(userSettingsFileOnHost, "utf8");
12317
+ const rawContent = fs8.readFileSync(userSettingsFileOnHost, "utf8");
11962
12318
  const parsed = JSON.parse((0, import_strip_json_comments2.default)(rawContent));
11963
12319
  if (isRecord3(parsed)) {
11964
12320
  rawSettings = parsed;
@@ -11971,8 +12327,8 @@ async function start_sandbox(config, nodeArgs = [], cliConfig, cliArgs = []) {
11971
12327
  }
11972
12328
  }
11973
12329
  const sanitizedSettings = sanitizeSettingsForSandbox(rawSettings);
11974
- const sanitizedSettingsFile = path10.join(sandboxTmpDir, "settings.json");
11975
- fs7.writeFileSync(
12330
+ const sanitizedSettingsFile = path11.join(sandboxTmpDir, "settings.json");
12331
+ fs8.writeFileSync(
11976
12332
  sanitizedSettingsFile,
11977
12333
  JSON.stringify(sanitizedSettings, null, 2),
11978
12334
  { mode: 384 }
@@ -11982,8 +12338,8 @@ async function start_sandbox(config, nodeArgs = [], cliConfig, cliArgs = []) {
11982
12338
  );
11983
12339
  args.push("--env", "HOME=/home/node");
11984
12340
  args.push("--volume", `${sandboxTmpDir}:${userSettingsDirInSandbox}:rw`);
11985
- const gcloudConfigDir = userHomeDirOnHost ? path10.join(userHomeDirOnHost, ".config", "gcloud") : "";
11986
- if (gcloudConfigDir && fs7.existsSync(gcloudConfigDir)) {
12341
+ const gcloudConfigDir = userHomeDirOnHost ? path11.join(userHomeDirOnHost, ".config", "gcloud") : "";
12342
+ if (gcloudConfigDir && fs8.existsSync(gcloudConfigDir)) {
11987
12343
  args.push(
11988
12344
  "--volume",
11989
12345
  `${gcloudConfigDir}:${getContainerPath(gcloudConfigDir)}:ro`
@@ -11991,7 +12347,7 @@ async function start_sandbox(config, nodeArgs = [], cliConfig, cliArgs = []) {
11991
12347
  }
11992
12348
  if (process.env["GOOGLE_APPLICATION_CREDENTIALS"]) {
11993
12349
  const adcFile = process.env["GOOGLE_APPLICATION_CREDENTIALS"];
11994
- if (fs7.existsSync(adcFile)) {
12350
+ if (fs8.existsSync(adcFile)) {
11995
12351
  args.push("--volume", `${adcFile}:${getContainerPath(adcFile)}:ro`);
11996
12352
  args.push(
11997
12353
  "--env",
@@ -12006,7 +12362,7 @@ async function start_sandbox(config, nodeArgs = [], cliConfig, cliArgs = []) {
12006
12362
  to = to || from;
12007
12363
  opts = opts || "ro";
12008
12364
  mount = `${from}:${to}:${opts}`;
12009
- if (!path10.isAbsolute(from)) {
12365
+ if (!path11.isAbsolute(from)) {
12010
12366
  throw new FatalSandboxError(
12011
12367
  `Path '${from}' listed in SANDBOX_MOUNTS must be absolute`
12012
12368
  );
@@ -12016,7 +12372,7 @@ async function start_sandbox(config, nodeArgs = [], cliConfig, cliArgs = []) {
12016
12372
  `Mounting sensitive host path '${from}' listed in SANDBOX_MOUNTS is strictly prohibited`
12017
12373
  );
12018
12374
  }
12019
- if (!fs7.existsSync(from)) {
12375
+ if (!fs8.existsSync(from)) {
12020
12376
  throw new FatalSandboxError(
12021
12377
  `Missing mount path '${from}' listed in SANDBOX_MOUNTS`
12022
12378
  );
@@ -12028,7 +12384,7 @@ async function start_sandbox(config, nodeArgs = [], cliConfig, cliArgs = []) {
12028
12384
  }
12029
12385
  if (config.allowedPaths) {
12030
12386
  for (const hostPath of config.allowedPaths) {
12031
- if (hostPath && path10.isAbsolute(hostPath) && fs7.existsSync(hostPath)) {
12387
+ if (hostPath && path11.isAbsolute(hostPath) && fs8.existsSync(hostPath)) {
12032
12388
  if (isSensitiveHostPath(hostPath)) {
12033
12389
  debugLogger.warn(
12034
12390
  `Skipping sensitive path '${hostPath}' in config.allowedPaths`
@@ -12168,13 +12524,13 @@ async function start_sandbox(config, nodeArgs = [], cliConfig, cliArgs = []) {
12168
12524
  if (process.env["TERM_PROGRAM"]) {
12169
12525
  args.push("--env", `TERM_PROGRAM=${process.env["TERM_PROGRAM"]}`);
12170
12526
  }
12171
- const ideWorkspacePath = process.env["GEMINI_CLI_IDE_WORKSPACE_PATH"] ?? ideBridgeUpstream?.workspacePaths.join(path10.delimiter);
12527
+ const ideWorkspacePath = process.env["GEMINI_CLI_IDE_WORKSPACE_PATH"] ?? ideBridgeUpstream?.workspacePaths.join(path11.delimiter);
12172
12528
  if (ideWorkspacePath) {
12173
12529
  args.push("--env", `GEMINI_CLI_IDE_WORKSPACE_PATH=${ideWorkspacePath}`);
12174
12530
  }
12175
12531
  if (ideBridge) {
12176
- fs7.writeFileSync(
12177
- path10.join(sandboxTmpDir, IDE_BRIDGE_HELPER_FILENAME),
12532
+ fs8.writeFileSync(
12533
+ path11.join(sandboxTmpDir, IDE_BRIDGE_HELPER_FILENAME),
12178
12534
  IDE_BRIDGE_HELPER_SOURCE,
12179
12535
  { mode: 384 }
12180
12536
  );
@@ -12189,9 +12545,9 @@ async function start_sandbox(config, nodeArgs = [], cliConfig, cliArgs = []) {
12189
12545
  );
12190
12546
  }
12191
12547
  if (process.env["VIRTUAL_ENV"]?.toLowerCase().startsWith(workdir.toLowerCase())) {
12192
- const sandboxVenvPath = path10.resolve(GEMINI_DIR, "sandbox.venv");
12193
- if (!fs7.existsSync(sandboxVenvPath)) {
12194
- fs7.mkdirSync(sandboxVenvPath, { recursive: true });
12548
+ const sandboxVenvPath = path11.resolve(GEMINI_DIR, "sandbox.venv");
12549
+ if (!fs8.existsSync(sandboxVenvPath)) {
12550
+ fs8.mkdirSync(sandboxVenvPath, { recursive: true });
12195
12551
  }
12196
12552
  args.push(
12197
12553
  "--volume",
@@ -12226,8 +12582,8 @@ async function start_sandbox(config, nodeArgs = [], cliConfig, cliArgs = []) {
12226
12582
  }
12227
12583
  args.push("--env", `SANDBOX=${containerName}`);
12228
12584
  if (command2 === "podman") {
12229
- const emptyAuthFilePath = path10.join(os3.tmpdir(), "empty_auth.json");
12230
- fs7.writeFileSync(emptyAuthFilePath, "{}", "utf-8");
12585
+ const emptyAuthFilePath = path11.join(os3.tmpdir(), "empty_auth.json");
12586
+ fs8.writeFileSync(emptyAuthFilePath, "{}", "utf-8");
12231
12587
  args.push("--authfile", emptyAuthFilePath);
12232
12588
  }
12233
12589
  let userFlag = "";
@@ -12346,7 +12702,7 @@ async function start_sandbox(config, nodeArgs = [], cliConfig, cliArgs = []) {
12346
12702
  isSandboxAlive: () => container.exitCode === null && container.signalCode === null
12347
12703
  });
12348
12704
  }
12349
- return await new Promise((resolve10, reject) => {
12705
+ return await new Promise((resolve11, reject) => {
12350
12706
  sandboxProcess?.on("error", (err) => {
12351
12707
  coreEvents.emitFeedback("error", "Sandbox process error", err);
12352
12708
  reject(err);
@@ -12359,7 +12715,7 @@ async function start_sandbox(config, nodeArgs = [], cliConfig, cliArgs = []) {
12359
12715
  `Sandbox process exited with code: ${code}, signal: ${signal}`
12360
12716
  );
12361
12717
  }
12362
- resolve10(code ?? 1);
12718
+ resolve11(code ?? 1);
12363
12719
  });
12364
12720
  });
12365
12721
  } finally {
@@ -12372,7 +12728,7 @@ async function start_sandbox(config, nodeArgs = [], cliConfig, cliArgs = []) {
12372
12728
  }
12373
12729
  async function start_lxc_sandbox(config, nodeArgs = [], cliArgs = []) {
12374
12730
  const containerName = config.image || "gemini-sandbox";
12375
- const workdir = path10.resolve(process.cwd());
12731
+ const workdir = path11.resolve(process.cwd());
12376
12732
  if (isSensitiveHostPath(workdir)) {
12377
12733
  throw new FatalSandboxError(
12378
12734
  `Running sandbox from a sensitive host directory '${workdir}' is strictly prohibited`
@@ -12458,7 +12814,7 @@ async function start_lxc_sandbox(config, nodeArgs = [], cliArgs = []) {
12458
12814
  }
12459
12815
  if (config.allowedPaths) {
12460
12816
  for (const hostPath of config.allowedPaths) {
12461
- if (hostPath && path10.isAbsolute(hostPath) && fs7.existsSync(hostPath)) {
12817
+ if (hostPath && path11.isAbsolute(hostPath) && fs8.existsSync(hostPath)) {
12462
12818
  if (isSensitiveHostPath(hostPath)) {
12463
12819
  debugLogger.warn(
12464
12820
  `Skipping sensitive path '${hostPath}' in config.allowedPaths for LXC`
@@ -12552,7 +12908,7 @@ async function start_lxc_sandbox(config, nodeArgs = [], cliArgs = []) {
12552
12908
  const sandboxProcess = spawn3("lxc", args, {
12553
12909
  stdio: "inherit"
12554
12910
  });
12555
- return await new Promise((resolve10, reject) => {
12911
+ return await new Promise((resolve11, reject) => {
12556
12912
  sandboxProcess.on("error", (err) => {
12557
12913
  coreEvents.emitFeedback("error", "LXC sandbox process error", err);
12558
12914
  reject(err);
@@ -12564,7 +12920,7 @@ async function start_lxc_sandbox(config, nodeArgs = [], cliArgs = []) {
12564
12920
  `LXC sandbox process exited with code: ${code}, signal: ${signal}`
12565
12921
  );
12566
12922
  }
12567
- resolve10(code ?? 1);
12923
+ resolve11(code ?? 1);
12568
12924
  });
12569
12925
  });
12570
12926
  } finally {
@@ -12573,7 +12929,7 @@ async function start_lxc_sandbox(config, nodeArgs = [], cliArgs = []) {
12573
12929
  }
12574
12930
  }
12575
12931
  async function imageExists(sandbox, image) {
12576
- return new Promise((resolve10) => {
12932
+ return new Promise((resolve11) => {
12577
12933
  const args = ["images", "-q", image];
12578
12934
  const checkProcess = spawn3(sandbox, args);
12579
12935
  let stdoutData = "";
@@ -12586,18 +12942,18 @@ async function imageExists(sandbox, image) {
12586
12942
  debugLogger.warn(
12587
12943
  `Failed to start '${sandbox}' command for image check: ${err.message}`
12588
12944
  );
12589
- resolve10(false);
12945
+ resolve11(false);
12590
12946
  });
12591
12947
  checkProcess.on("close", (code) => {
12592
12948
  if (code !== 0) {
12593
12949
  }
12594
- resolve10(stdoutData.trim() !== "");
12950
+ resolve11(stdoutData.trim() !== "");
12595
12951
  });
12596
12952
  });
12597
12953
  }
12598
12954
  async function pullImage(sandbox, image, cliConfig) {
12599
12955
  debugLogger.debug(`Attempting to pull image ${image} using ${sandbox}...`);
12600
- return new Promise((resolve10) => {
12956
+ return new Promise((resolve11) => {
12601
12957
  const args = ["pull", image];
12602
12958
  const pullProcess = spawn3(sandbox, args, { stdio: "pipe" });
12603
12959
  let stderrData = "";
@@ -12615,13 +12971,13 @@ async function pullImage(sandbox, image, cliConfig) {
12615
12971
  `Failed to start '${sandbox} pull ${image}' command: ${err.message}`
12616
12972
  );
12617
12973
  cleanup();
12618
- resolve10(false);
12974
+ resolve11(false);
12619
12975
  };
12620
12976
  const onClose = (code) => {
12621
12977
  if (code === 0) {
12622
12978
  debugLogger.log(`Successfully pulled image ${image}.`);
12623
12979
  cleanup();
12624
- resolve10(true);
12980
+ resolve11(true);
12625
12981
  } else {
12626
12982
  debugLogger.warn(
12627
12983
  `Failed to pull image ${image}. '${sandbox} pull ${image}' exited with code ${code}.`
@@ -12629,7 +12985,7 @@ async function pullImage(sandbox, image, cliConfig) {
12629
12985
  if (stderrData.trim()) {
12630
12986
  }
12631
12987
  cleanup();
12632
- resolve10(false);
12988
+ resolve11(false);
12633
12989
  }
12634
12990
  };
12635
12991
  const cleanup = () => {
@@ -12684,7 +13040,7 @@ async function ensureSandboxImageIsPresent(sandbox, image, cliConfig) {
12684
13040
  }
12685
13041
 
12686
13042
  // packages/cli/src/utils/sandboxFolderTrust.ts
12687
- import * as path11 from "node:path";
13043
+ import * as path12 from "node:path";
12688
13044
  import * as readline2 from "node:readline";
12689
13045
  import { Writable } from "node:stream";
12690
13046
  var TRUST_WORKSPACE_ENV = "GEMINI_CLI_TRUST_WORKSPACE";
@@ -12738,9 +13094,9 @@ async function resolveFolderTrustForSandbox({
12738
13094
  process.env[TRUST_WORKSPACE_ENV] = isTrusted ? "true" : "false";
12739
13095
  }
12740
13096
  function formatFolderTrustPrompt(workspaceDir, discoveryResults) {
12741
- const folderName = stripAnsi(path11.basename(workspaceDir)).trim() || stripAnsi(workspaceDir);
12742
- const parentDir = path11.dirname(workspaceDir);
12743
- const parentFolderName = stripAnsi(path11.basename(parentDir)).trim() || stripAnsi(parentDir);
13097
+ const folderName = stripAnsi(path12.basename(workspaceDir)).trim() || stripAnsi(workspaceDir);
13098
+ const parentDir = path12.dirname(workspaceDir);
13099
+ const parentFolderName = stripAnsi(path12.basename(parentDir)).trim() || stripAnsi(parentDir);
12744
13100
  const lines = [
12745
13101
  "",
12746
13102
  "Do you trust the files in this folder?",
@@ -12810,7 +13166,7 @@ async function promptForFolderTrustLevel(workspaceDir, input = process.stdin, ou
12810
13166
  } catch {
12811
13167
  }
12812
13168
  output.write(formatFolderTrustPrompt(workspaceDir, discoveryResults));
12813
- return new Promise((resolve10) => {
13169
+ return new Promise((resolve11) => {
12814
13170
  const rl = readline2.createInterface({ input, output, terminal: false });
12815
13171
  let settled = false;
12816
13172
  const finish = (trustLevel) => {
@@ -12819,7 +13175,7 @@ async function promptForFolderTrustLevel(workspaceDir, input = process.stdin, ou
12819
13175
  }
12820
13176
  settled = true;
12821
13177
  rl.close();
12822
- resolve10(trustLevel);
13178
+ resolve11(trustLevel);
12823
13179
  };
12824
13180
  rl.on("line", (line) => {
12825
13181
  const trustLevel = parseTrustChoice(line);
@@ -12837,17 +13193,17 @@ async function promptForFolderTrustLevel(workspaceDir, input = process.stdin, ou
12837
13193
  }
12838
13194
 
12839
13195
  // packages/cli/src/utils/startupWarnings.ts
12840
- import fs8 from "node:fs/promises";
13196
+ import fs9 from "node:fs/promises";
12841
13197
  import os4 from "node:os";
12842
13198
  import { join as pathJoin } from "node:path";
12843
13199
  var warningsFilePath = pathJoin(os4.tmpdir(), "gemini-cli-warnings.txt");
12844
13200
  async function getStartupWarnings() {
12845
13201
  try {
12846
- await fs8.access(warningsFilePath);
12847
- const warningsContent = await fs8.readFile(warningsFilePath, "utf-8");
13202
+ await fs9.access(warningsFilePath);
13203
+ const warningsContent = await fs9.readFile(warningsFilePath, "utf-8");
12848
13204
  const warnings = warningsContent.split("\n").filter((line) => line.trim() !== "");
12849
13205
  try {
12850
- await fs8.unlink(warningsFilePath);
13206
+ await fs9.unlink(warningsFilePath);
12851
13207
  } catch {
12852
13208
  warnings.push("Warning: Could not delete temporary warnings file.");
12853
13209
  }
@@ -12861,9 +13217,9 @@ async function getStartupWarnings() {
12861
13217
  }
12862
13218
 
12863
13219
  // packages/cli/src/utils/userStartupWarnings.ts
12864
- import fs9 from "node:fs/promises";
13220
+ import fs10 from "node:fs/promises";
12865
13221
  import { homedir as osHomedir } from "node:os";
12866
- import path12 from "node:path";
13222
+ import path13 from "node:path";
12867
13223
  import process5 from "node:process";
12868
13224
  var homeDirectoryCheck = {
12869
13225
  id: "home-directory",
@@ -12874,10 +13230,10 @@ var homeDirectoryCheck = {
12874
13230
  }
12875
13231
  try {
12876
13232
  const [workspaceRealPath, homeRealPath] = await Promise.all([
12877
- fs9.realpath(workspaceRoot),
12878
- fs9.realpath(osHomedir())
13233
+ fs10.realpath(workspaceRoot),
13234
+ fs10.realpath(osHomedir())
12879
13235
  ]);
12880
- if (path12.resolve(workspaceRealPath) === path12.resolve(homeRealPath)) {
13236
+ if (path13.resolve(workspaceRealPath) === path13.resolve(homeRealPath)) {
12881
13237
  if (isFolderTrustEnabled(settings) && isWorkspaceTrusted(settings).isTrusted) {
12882
13238
  return null;
12883
13239
  }
@@ -12894,9 +13250,9 @@ var rootDirectoryCheck = {
12894
13250
  priority: WarningPriority.High,
12895
13251
  check: async (workspaceRoot, _settings) => {
12896
13252
  try {
12897
- const workspaceRealPath = await fs9.realpath(workspaceRoot);
13253
+ const workspaceRealPath = await fs10.realpath(workspaceRoot);
12898
13254
  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.";
12899
- if (path12.dirname(workspaceRealPath) === workspaceRealPath) {
13255
+ if (path13.dirname(workspaceRealPath) === workspaceRealPath) {
12900
13256
  return errorMessage;
12901
13257
  }
12902
13258
  return null;
@@ -13300,7 +13656,7 @@ async function runNonInteractive({
13300
13656
  }
13301
13657
  });
13302
13658
  if (process.env["GEMINI_CLI_ACTIVITY_LOG_TARGET"]) {
13303
- const { setupInitialActivityLogger } = await import("./devtoolsService-K3FKQFZP.js");
13659
+ const { setupInitialActivityLogger } = await import("./devtoolsService-ER22TM2Y.js");
13304
13660
  setupInitialActivityLogger(config);
13305
13661
  }
13306
13662
  const { stdout: workingStdout } = createWorkingStdio();
@@ -13841,7 +14197,7 @@ async function runNonInteractive2(params) {
13841
14197
  }
13842
14198
  });
13843
14199
  if (process.env["GEMINI_CLI_ACTIVITY_LOG_TARGET"]) {
13844
- const { setupInitialActivityLogger } = await import("./devtoolsService-K3FKQFZP.js");
14200
+ const { setupInitialActivityLogger } = await import("./devtoolsService-ER22TM2Y.js");
13845
14201
  setupInitialActivityLogger(config);
13846
14202
  }
13847
14203
  const { stdout: workingStdout } = createWorkingStdio();
@@ -14340,6 +14696,37 @@ async function runNonInteractive2(params) {
14340
14696
  }
14341
14697
 
14342
14698
  // packages/cli/src/utils/worktreeSetup.ts
14699
+ var WORKTREE_ACK_TIMEOUT_MS = 500;
14700
+ async function notifyWorktreeSelected(worktreePath) {
14701
+ if (!isIPCAvailable()) {
14702
+ return;
14703
+ }
14704
+ await new Promise((resolve11) => {
14705
+ let resolved = false;
14706
+ const done = () => {
14707
+ if (!resolved) {
14708
+ resolved = true;
14709
+ resolve11();
14710
+ }
14711
+ };
14712
+ const timeout = setTimeout(done, WORKTREE_ACK_TIMEOUT_MS);
14713
+ try {
14714
+ process.send(
14715
+ {
14716
+ type: "worktree-selected",
14717
+ path: worktreePath
14718
+ },
14719
+ () => {
14720
+ clearTimeout(timeout);
14721
+ done();
14722
+ }
14723
+ );
14724
+ } catch {
14725
+ clearTimeout(timeout);
14726
+ done();
14727
+ }
14728
+ });
14729
+ }
14343
14730
  async function setupWorktree(worktreeName) {
14344
14731
  if (process.env["GEMINI_CLI_WORKTREE_HANDLED"] === "1") {
14345
14732
  return void 0;
@@ -14350,6 +14737,7 @@ async function setupWorktree(worktreeName) {
14350
14737
  const worktreeInfo = await service.setup(worktreeName || void 0);
14351
14738
  process.chdir(worktreeInfo.path);
14352
14739
  process.env["GEMINI_CLI_WORKTREE_HANDLED"] = "1";
14740
+ await notifyWorktreeSelected(worktreeInfo.path);
14353
14741
  return worktreeInfo;
14354
14742
  } catch (error) {
14355
14743
  const errorMessage = error instanceof Error ? error.message : String(error);
@@ -15632,8 +16020,8 @@ var Connection = class {
15632
16020
  this.#requestHandler = requestHandler;
15633
16021
  this.#notificationHandler = notificationHandler;
15634
16022
  this.#stream = stream;
15635
- this.#closedPromise = new Promise((resolve10) => {
15636
- this.#abortController.signal.addEventListener("abort", () => resolve10());
16023
+ this.#closedPromise = new Promise((resolve11) => {
16024
+ this.#abortController.signal.addEventListener("abort", () => resolve11());
15637
16025
  });
15638
16026
  this.#receive();
15639
16027
  }
@@ -15782,8 +16170,8 @@ var Connection = class {
15782
16170
  }
15783
16171
  async sendRequest(method, params) {
15784
16172
  const id = this.#nextRequestId++;
15785
- const responsePromise = new Promise((resolve10, reject) => {
15786
- this.#pendingResponses.set(id, { resolve: resolve10, reject });
16173
+ const responsePromise = new Promise((resolve11, reject) => {
16174
+ this.#pendingResponses.set(id, { resolve: resolve11, reject });
15787
16175
  });
15788
16176
  await this.#sendMessage({ jsonrpc: "2.0", id, method, params });
15789
16177
  return responsePromise;
@@ -15903,8 +16291,8 @@ function extractRecursiveMessage(input) {
15903
16291
  import { randomUUID as randomUUID2 } from "node:crypto";
15904
16292
 
15905
16293
  // packages/cli/src/acp/acpSession.ts
15906
- import * as fs12 from "node:fs/promises";
15907
- import * as path15 from "node:path";
16294
+ import * as fs13 from "node:fs/promises";
16295
+ import * as path16 from "node:path";
15908
16296
  import { randomUUID } from "node:crypto";
15909
16297
 
15910
16298
  // packages/cli/src/acp/commands/commandRegistry.ts
@@ -16345,8 +16733,8 @@ var UpdateExtensionCommand = class {
16345
16733
  };
16346
16734
 
16347
16735
  // packages/cli/src/acp/commands/init.ts
16348
- import * as fs10 from "node:fs";
16349
- import * as path13 from "node:path";
16736
+ import * as fs11 from "node:fs";
16737
+ import * as path14 from "node:path";
16350
16738
  var InitCommand = class {
16351
16739
  name = "init";
16352
16740
  description = "Analyzes the project and creates a tailored GEMINI.md file";
@@ -16356,8 +16744,8 @@ var InitCommand = class {
16356
16744
  if (!targetDir) {
16357
16745
  throw new Error("Command requires a workspace.");
16358
16746
  }
16359
- const geminiMdPath = path13.join(targetDir, "GEMINI.md");
16360
- const result = performInit(fs10.existsSync(geminiMdPath));
16747
+ const geminiMdPath = path14.join(targetDir, "GEMINI.md");
16748
+ const result = performInit(fs11.existsSync(geminiMdPath));
16361
16749
  switch (result.type) {
16362
16750
  case "message":
16363
16751
  return {
@@ -16365,7 +16753,7 @@ var InitCommand = class {
16365
16753
  data: result
16366
16754
  };
16367
16755
  case "submit_prompt":
16368
- fs10.writeFileSync(geminiMdPath, "", "utf8");
16756
+ fs11.writeFileSync(geminiMdPath, "", "utf8");
16369
16757
  if (typeof result.content !== "string") {
16370
16758
  throw new Error("Init command content must be a string.");
16371
16759
  }
@@ -16388,8 +16776,8 @@ ${result.content}`
16388
16776
  };
16389
16777
 
16390
16778
  // packages/cli/src/acp/commands/restore.ts
16391
- import * as fs11 from "node:fs/promises";
16392
- import * as path14 from "node:path";
16779
+ import * as fs12 from "node:fs/promises";
16780
+ import * as path15 from "node:path";
16393
16781
  var RestoreCommand = class {
16394
16782
  name = "restore";
16395
16783
  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";
@@ -16411,10 +16799,10 @@ var RestoreCommand = class {
16411
16799
  }
16412
16800
  const selectedFile = argsStr.endsWith(".json") ? argsStr : `${argsStr}.json`;
16413
16801
  const checkpointDir = config.storage.getProjectTempCheckpointsDir();
16414
- const filePath = path14.join(checkpointDir, selectedFile);
16802
+ const filePath = path15.join(checkpointDir, selectedFile);
16415
16803
  let data;
16416
16804
  try {
16417
- data = await fs11.readFile(filePath, "utf-8");
16805
+ data = await fs12.readFile(filePath, "utf-8");
16418
16806
  } catch (error) {
16419
16807
  if (isNodeError(error) && error.code === "ENOENT") {
16420
16808
  return {
@@ -16475,18 +16863,18 @@ var ListCheckpointsCommand = class {
16475
16863
  }
16476
16864
  const checkpointDir = config.storage.getProjectTempCheckpointsDir();
16477
16865
  try {
16478
- await fs11.mkdir(checkpointDir, { recursive: true });
16866
+ await fs12.mkdir(checkpointDir, { recursive: true });
16479
16867
  } catch {
16480
16868
  }
16481
- const files = await fs11.readdir(checkpointDir);
16869
+ const files = await fs12.readdir(checkpointDir);
16482
16870
  const jsonFiles = files.filter((file) => file.endsWith(".json"));
16483
16871
  if (jsonFiles.length === 0) {
16484
16872
  return { name: this.name, data: "No checkpoints found." };
16485
16873
  }
16486
16874
  const checkpointFiles = /* @__PURE__ */ new Map();
16487
16875
  for (const file of jsonFiles) {
16488
- const filePath = path14.join(checkpointDir, file);
16489
- const data = await fs11.readFile(filePath, "utf-8");
16876
+ const filePath = path15.join(checkpointDir, file);
16877
+ const data = await fs12.readFile(filePath, "utf-8");
16490
16878
  checkpointFiles.set(file, data);
16491
16879
  }
16492
16880
  const checkpointInfoList = getCheckpointInfoList(checkpointFiles);
@@ -17522,14 +17910,14 @@ ${event.value.description}`;
17522
17910
  } else if (result.status === "invalid") {
17523
17911
  continue;
17524
17912
  } else {
17525
- absolutePath = path15.resolve(
17913
+ absolutePath = path16.resolve(
17526
17914
  this.context.config.getTargetDir(),
17527
17915
  pathName
17528
17916
  );
17529
17917
  }
17530
17918
  if (!resolved && validationError && !isWithinRoot(absolutePath, this.context.config.getTargetDir())) {
17531
17919
  try {
17532
- const stats = await fs12.stat(absolutePath);
17920
+ const stats = await fs13.stat(absolutePath);
17533
17921
  if (stats.isFile()) {
17534
17922
  const syntheticCallId = `resolve-prompt-${pathName}-${randomUUID()}`;
17535
17923
  const params = {
@@ -17596,12 +17984,12 @@ ${event.value.description}`;
17596
17984
  }
17597
17985
  try {
17598
17986
  if (!validationError) {
17599
- if ((path15.isAbsolute(pathName) || !isWithinRoot(
17987
+ if ((path16.isAbsolute(pathName) || !isWithinRoot(
17600
17988
  absolutePath,
17601
17989
  this.context.config.getTargetDir()
17602
17990
  )) && !readDirectly) {
17603
17991
  try {
17604
- const stats = resolved ? resolved.stats : await fs12.stat(absolutePath);
17992
+ const stats = resolved ? resolved.stats : await fs13.stat(absolutePath);
17605
17993
  if (stats.isFile()) {
17606
17994
  const fileReadResult = await processSingleFileContent(
17607
17995
  absolutePath,
@@ -17657,7 +18045,7 @@ ${contentToPush}`;
17657
18045
  }
17658
18046
  }
17659
18047
  if (!readDirectly) {
17660
- const stats = resolved ? resolved.stats : await fs12.stat(absolutePath);
18048
+ const stats = resolved ? resolved.stats : await fs13.stat(absolutePath);
17661
18049
  isDirectory = stats.isDirectory();
17662
18050
  this.debug(
17663
18051
  `Path ${pathName} resolved to ${isDirectory ? "directory" : "file"}: ${currentPathSpec}`
@@ -17694,7 +18082,7 @@ ${contentToPush}`;
17694
18082
  const lines = globResult.llmContent.split("\n");
17695
18083
  if (lines.length > 1 && lines[1]) {
17696
18084
  const firstMatchAbsolute = lines[1].trim();
17697
- currentPathSpec = path15.relative(
18085
+ currentPathSpec = path16.relative(
17698
18086
  this.context.config.getTargetDir(),
17699
18087
  firstMatchAbsolute
17700
18088
  );
@@ -17917,7 +18305,7 @@ Content from @${contextPart.uri}:
17917
18305
 
17918
18306
  // packages/cli/src/acp/acpFileSystemService.ts
17919
18307
  import os5 from "node:os";
17920
- import path16 from "node:path";
18308
+ import path17 from "node:path";
17921
18309
  var AcpFileSystemService = class {
17922
18310
  constructor(connection, sessionId, capabilities, fallback, root) {
17923
18311
  this.connection = connection;
@@ -17926,7 +18314,7 @@ var AcpFileSystemService = class {
17926
18314
  this.fallback = fallback;
17927
18315
  this.root = root;
17928
18316
  }
17929
- geminiDir = path16.join(os5.homedir(), ".gemini");
18317
+ geminiDir = path17.join(os5.homedir(), ".gemini");
17930
18318
  shouldUseFallback(filePath) {
17931
18319
  return !isWithinRoot(filePath, this.root) || isWithinRoot(filePath, this.geminiDir);
17932
18320
  }
@@ -18660,27 +19048,27 @@ async function setupTerminalAndTheme(config, settings) {
18660
19048
  }
18661
19049
 
18662
19050
  // packages/cli/src/utils/logCleanup.ts
18663
- import { promises as fs13 } from "node:fs";
18664
- import * as path17 from "node:path";
19051
+ import { promises as fs14 } from "node:fs";
19052
+ import * as path18 from "node:path";
18665
19053
  var RETENTION_PERIOD_MS = 7 * 24 * 60 * 60 * 1e3;
18666
19054
  async function cleanupBackgroundLogs(debugMode = false) {
18667
19055
  try {
18668
19056
  const logDir = ShellExecutionService.getLogDir();
18669
19057
  try {
18670
- await fs13.access(logDir);
19058
+ await fs14.access(logDir);
18671
19059
  } catch {
18672
19060
  return;
18673
19061
  }
18674
- const entries = await fs13.readdir(logDir, { withFileTypes: true });
19062
+ const entries = await fs14.readdir(logDir, { withFileTypes: true });
18675
19063
  const now = Date.now();
18676
19064
  let deletedCount = 0;
18677
19065
  for (const entry of entries) {
18678
19066
  if (entry.isFile() && entry.name.endsWith(".log")) {
18679
- const filePath = path17.join(logDir, entry.name);
19067
+ const filePath = path18.join(logDir, entry.name);
18680
19068
  try {
18681
- const stats = await fs13.stat(filePath);
19069
+ const stats = await fs14.stat(filePath);
18682
19070
  if (now - stats.mtime.getTime() > RETENTION_PERIOD_MS) {
18683
- await fs13.unlink(filePath);
19071
+ await fs14.unlink(filePath);
18684
19072
  deletedCount++;
18685
19073
  }
18686
19074
  } catch (error) {
@@ -19021,8 +19409,8 @@ async function resolveSessionId(resumeArg, sessionIdArg, sessionFileArg) {
19021
19409
  sessionData.projectHash = getProjectHash(storage.getProjectRoot());
19022
19410
  sessionData.startTime = isoNow;
19023
19411
  sessionData.lastUpdated = isoNow;
19024
- const chatsDir = path18.join(storage.getProjectTempDir(), "chats");
19025
- const newSessionPath = path18.join(
19412
+ const chatsDir = path19.join(storage.getProjectTempDir(), "chats");
19413
+ const newSessionPath = path19.join(
19026
19414
  chatsDir,
19027
19415
  `session-${now}-${newSessionId.slice(0, 8)}.jsonl`
19028
19416
  );
@@ -19090,7 +19478,7 @@ async function resolveSessionId(resumeArg, sessionIdArg, sessionFileArg) {
19090
19478
  }
19091
19479
  }
19092
19480
  async function startInteractiveUI(config, settings, startupWarnings, workspaceRoot = process.cwd(), resumedSessionData, initializationResult) {
19093
- const { startInteractiveUI: doStartUI } = await import("./interactiveCli-SGZ2VGTY.js");
19481
+ const { startInteractiveUI: doStartUI } = await import("./interactiveCli-76LAQB3B.js");
19094
19482
  await doStartUI(
19095
19483
  config,
19096
19484
  settings,
@@ -19325,7 +19713,7 @@ ${finalArgs[promptIndex + 1]}`;
19325
19713
  await config.storage.initialize();
19326
19714
  adminControlsListner.setConfig(config);
19327
19715
  if (config.isInteractive() && settings.merged.general.devtools) {
19328
- const { setupInitialActivityLogger } = await import("./devtoolsService-K3FKQFZP.js");
19716
+ const { setupInitialActivityLogger } = await import("./devtoolsService-ER22TM2Y.js");
19329
19717
  setupInitialActivityLogger(config);
19330
19718
  }
19331
19719
  registerTelemetryConfig(config);
@@ -19384,7 +19772,7 @@ ${finalArgs[promptIndex + 1]}`;
19384
19772
  const initAppHandle = startupProfiler.start("initialize_app");
19385
19773
  const initializationResult = await initializeApp(config, settings);
19386
19774
  initAppHandle?.end();
19387
- import("./liteRtServerManager-6PM4BXYU.js").then(({ LiteRtServerManager }) => {
19775
+ import("./liteRtServerManager-KZ62KJW3.js").then(({ LiteRtServerManager }) => {
19388
19776
  const mergedGemma = settings.merged.experimental?.gemmaModelRouter;
19389
19777
  if (!mergedGemma) return;
19390
19778
  const userGemma = settings.forScope("User" /* User */).settings.experimental?.gemmaModelRouter;