@google/gemini-cli-a2a-server 0.44.0 → 0.45.0-nightly.20260527.g41c9260ca

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.
@@ -69002,23 +69002,12 @@ import fs11 from "node:fs";
69002
69002
  import path9 from "node:path";
69003
69003
  import { spawn, spawnSync } from "node:child_process";
69004
69004
  import * as readline from "node:readline";
69005
- function stripHupGuard(command) {
69006
- const trimmed2 = command.trimStart();
69007
- const prefix = `${BASH_HUP_GUARD} `;
69008
- if (trimmed2.startsWith(prefix)) {
69009
- return trimmed2.slice(prefix.length);
69010
- }
69011
- if (trimmed2 === BASH_HUP_GUARD) {
69012
- return "";
69013
- }
69014
- return command;
69015
- }
69016
69005
  async function getCommandName(command, args2) {
69017
69006
  await initializeShellParsers();
69018
69007
  const fullCmd = [command, ...args2].join(" ");
69019
69008
  const stripped = stripShellWrapper(fullCmd);
69020
69009
  const roots = getCommandRoots(stripped).filter((r4) => r4 !== "shopt" && r4 !== "set");
69021
- if (roots.length === 1) {
69010
+ if (roots.length > 0) {
69022
69011
  return roots[0];
69023
69012
  }
69024
69013
  return path9.basename(command);
@@ -69482,17 +69471,14 @@ function getCommandRoots(command) {
69482
69471
  function stripShellWrapper(command) {
69483
69472
  const pattern = /^\s*(?:(?:(?:\S+\/)?(?:sh|bash|zsh))\s+-c|cmd\.exe\s+\/c|powershell(?:\.exe)?\s+(?:-NoProfile\s+)?-Command|pwsh(?:\.exe)?\s+(?:-NoProfile\s+)?-Command)\s+/i;
69484
69473
  const match2 = command.match(pattern);
69485
- let result2;
69486
69474
  if (match2) {
69487
69475
  let newCommand = command.substring(match2[0].length).trim();
69488
69476
  if (newCommand.startsWith('"') && newCommand.endsWith('"') || newCommand.startsWith("'") && newCommand.endsWith("'")) {
69489
69477
  newCommand = newCommand.substring(1, newCommand.length - 1);
69490
69478
  }
69491
- result2 = newCommand;
69492
- } else {
69493
- result2 = command.trim();
69479
+ return newCommand;
69494
69480
  }
69495
- return stripHupGuard(result2);
69481
+ return command.trim();
69496
69482
  }
69497
69483
  async function* execStreaming(command, args2, options) {
69498
69484
  const sandboxManager = options?.sandboxManager ?? new NoopSandboxManager();
@@ -69692,7 +69678,7 @@ function detectPowerShellSubstitution(command) {
69692
69678
  }
69693
69679
  return false;
69694
69680
  }
69695
- var import_shell_quote, BASH_HUP_GUARD, SHELL_TOOL_NAMES, bashLanguage, treeSitterInitialization, treeSitterInitializationError, ShellParserInitializationError, POWERSHELL_COMMAND_ENV, PARSE_TIMEOUT_MICROS, POWERSHELL_PARSER_SCRIPT, REDIRECTION_NAMES, isWindows, spawnAsync, POWERSHELL_KEYWORD_RE;
69681
+ var import_shell_quote, SHELL_TOOL_NAMES, bashLanguage, treeSitterInitialization, treeSitterInitializationError, ShellParserInitializationError, POWERSHELL_COMMAND_ENV, PARSE_TIMEOUT_MICROS, POWERSHELL_PARSER_SCRIPT, REDIRECTION_NAMES, isWindows, spawnAsync, POWERSHELL_KEYWORD_RE;
69696
69682
  var init_shell_utils = __esm({
69697
69683
  "packages/core/dist/src/utils/shell-utils.js"() {
69698
69684
  "use strict";
@@ -69701,7 +69687,6 @@ var init_shell_utils = __esm({
69701
69687
  init_fileUtils();
69702
69688
  init_debugLogger();
69703
69689
  init_sandboxManager();
69704
- BASH_HUP_GUARD = `trap '' HUP;`;
69705
69690
  SHELL_TOOL_NAMES = ["run_shell_command", "ShellTool"];
69706
69691
  bashLanguage = null;
69707
69692
  treeSitterInitialization = null;
@@ -70492,7 +70477,7 @@ async function getCommandName2(req) {
70492
70477
  const fullCmd = [req.command, ...req.args].join(" ");
70493
70478
  const stripped = stripShellWrapper(fullCmd);
70494
70479
  const roots = getCommandRoots(stripped).filter((r4) => r4 !== "shopt" && r4 !== "set");
70495
- if (roots.length === 1) {
70480
+ if (roots.length > 0) {
70496
70481
  return roots[0];
70497
70482
  }
70498
70483
  return path12.basename(req.command);
@@ -130343,16 +130328,15 @@ var init_types8 = __esm({
130343
130328
 
130344
130329
  // packages/core/dist/src/config/models.js
130345
130330
  function getAutoModelDescription(hasAccessToPreview, useGemini3_1 = false) {
130346
- const proModel = hasAccessToPreview ? useGemini3_1 ? "gemini-3.1-pro" : "gemini-3-pro" : "gemini-2.5-pro";
130347
- const flashModel = hasAccessToPreview ? "gemini-3-flash" : "gemini-2.5-flash";
130331
+ const proModel = hasAccessToPreview ? useGemini3_1 ? PREVIEW_GEMINI_3_1_MODEL : PREVIEW_GEMINI_MODEL : DEFAULT_GEMINI_MODEL;
130332
+ const flashModel = hasAccessToPreview ? PREVIEW_GEMINI_FLASH_MODEL : DEFAULT_GEMINI_FLASH_MODEL;
130348
130333
  return `Let Gemini CLI decide the best model for the task: ${proModel}, ${flashModel}`;
130349
130334
  }
130350
- function resolveModel(requestedModel, useGemini3_1 = false, useGemini3_1FlashLite = false, useCustomToolModel = false, hasAccessToPreview = true, config3) {
130335
+ function resolveModel(requestedModel, useGemini3_1 = false, useCustomToolModel = false, hasAccessToPreview = true, config3) {
130351
130336
  const normalizedModel = Array.isArray(requestedModel) ? String(requestedModel.at(-1) ?? "").trim() || "" : typeof requestedModel !== "string" ? String(requestedModel ?? "").trim() || "" : requestedModel.trim() || "";
130352
130337
  if (config3?.getExperimentalDynamicModelConfiguration?.() === true) {
130353
130338
  const resolved2 = config3.modelConfigService.resolveModelId(normalizedModel, {
130354
130339
  useGemini3_1,
130355
- useGemini3_1FlashLite,
130356
130340
  useCustomTools: useCustomToolModel,
130357
130341
  hasAccessToPreview
130358
130342
  });
@@ -130394,7 +130378,7 @@ function resolveModel(requestedModel, useGemini3_1 = false, useGemini3_1FlashLit
130394
130378
  break;
130395
130379
  }
130396
130380
  case GEMINI_MODEL_ALIAS_FLASH_LITE: {
130397
- resolved = useGemini3_1FlashLite ? PREVIEW_GEMINI_3_1_FLASH_LITE_MODEL : DEFAULT_GEMINI_FLASH_LITE_MODEL;
130381
+ resolved = DEFAULT_GEMINI_FLASH_LITE_MODEL;
130398
130382
  break;
130399
130383
  }
130400
130384
  default: {
@@ -130402,12 +130386,13 @@ function resolveModel(requestedModel, useGemini3_1 = false, useGemini3_1FlashLit
130402
130386
  break;
130403
130387
  }
130404
130388
  }
130389
+ if (resolved === "none") {
130390
+ return DEFAULT_GEMINI_FLASH_LITE_MODEL;
130391
+ }
130405
130392
  if (!hasAccessToPreview && isPreviewModel(resolved)) {
130406
130393
  switch (resolved) {
130407
130394
  case PREVIEW_GEMINI_FLASH_MODEL:
130408
130395
  return DEFAULT_GEMINI_FLASH_MODEL;
130409
- case PREVIEW_GEMINI_3_1_FLASH_LITE_MODEL:
130410
- return DEFAULT_GEMINI_FLASH_LITE_MODEL;
130411
130396
  case PREVIEW_GEMINI_MODEL:
130412
130397
  case PREVIEW_GEMINI_3_1_MODEL:
130413
130398
  case PREVIEW_GEMINI_3_1_CUSTOM_TOOLS_MODEL:
@@ -130424,11 +130409,10 @@ function resolveModel(requestedModel, useGemini3_1 = false, useGemini3_1FlashLit
130424
130409
  }
130425
130410
  return resolved;
130426
130411
  }
130427
- function resolveClassifierModel(requestedModel, modelAlias, useGemini3_1 = false, useGemini3_1FlashLite = false, useCustomToolModel = false, hasAccessToPreview = true, config3) {
130412
+ function resolveClassifierModel(requestedModel, modelAlias, useGemini3_1 = false, useCustomToolModel = false, hasAccessToPreview = true, config3) {
130428
130413
  if (config3?.getExperimentalDynamicModelConfiguration?.() === true) {
130429
130414
  return config3.modelConfigService.resolveClassifierModelId(modelAlias, requestedModel, {
130430
130415
  useGemini3_1,
130431
- useGemini3_1FlashLite,
130432
130416
  useCustomTools: useCustomToolModel,
130433
130417
  hasAccessToPreview
130434
130418
  });
@@ -130440,9 +130424,9 @@ function resolveClassifierModel(requestedModel, modelAlias, useGemini3_1 = false
130440
130424
  if (requestedModel === PREVIEW_GEMINI_MODEL_AUTO || requestedModel === PREVIEW_GEMINI_MODEL || requestedModel === GEMINI_MODEL_ALIAS_AUTO) {
130441
130425
  return hasAccessToPreview ? PREVIEW_GEMINI_FLASH_MODEL : DEFAULT_GEMINI_FLASH_MODEL;
130442
130426
  }
130443
- return resolveModel(GEMINI_MODEL_ALIAS_FLASH, false, false, false, hasAccessToPreview);
130427
+ return resolveModel(GEMINI_MODEL_ALIAS_FLASH, false, false, hasAccessToPreview);
130444
130428
  }
130445
- return resolveModel(requestedModel, useGemini3_1, useGemini3_1FlashLite, useCustomToolModel, hasAccessToPreview);
130429
+ return resolveModel(requestedModel, useGemini3_1, useCustomToolModel, hasAccessToPreview, config3);
130446
130430
  }
130447
130431
  function getDisplayString(model, config3) {
130448
130432
  if (config3?.getExperimentalDynamicModelConfiguration?.() === true) {
@@ -130468,17 +130452,20 @@ function getDisplayString(model, config3) {
130468
130452
  return PREVIEW_GEMINI_FLASH_MODEL;
130469
130453
  case PREVIEW_GEMINI_3_1_CUSTOM_TOOLS_MODEL:
130470
130454
  return PREVIEW_GEMINI_3_1_MODEL;
130471
- case PREVIEW_GEMINI_3_1_FLASH_LITE_MODEL:
130472
- return PREVIEW_GEMINI_3_1_FLASH_LITE_MODEL;
130455
+ case PREVIEW_GEMINI_FLASH_LITE_MODEL:
130456
+ return PREVIEW_GEMINI_FLASH_LITE_MODEL;
130473
130457
  default:
130474
130458
  return model;
130475
130459
  }
130476
130460
  }
130477
130461
  function isPreviewModel(model, config3) {
130462
+ if (model === "none") {
130463
+ return false;
130464
+ }
130478
130465
  if (config3?.getExperimentalDynamicModelConfiguration?.() === true) {
130479
130466
  return config3.modelConfigService.getModelDefinition(model)?.isPreview === true;
130480
130467
  }
130481
- return model === PREVIEW_GEMINI_MODEL || model === PREVIEW_GEMINI_3_1_MODEL || model === PREVIEW_GEMINI_3_1_CUSTOM_TOOLS_MODEL || model === PREVIEW_GEMINI_FLASH_MODEL || model === PREVIEW_GEMINI_MODEL_AUTO || model === GEMINI_MODEL_ALIAS_AUTO || model === PREVIEW_GEMINI_3_1_FLASH_LITE_MODEL;
130468
+ return model === PREVIEW_GEMINI_MODEL || model === PREVIEW_GEMINI_3_1_MODEL || model === PREVIEW_GEMINI_3_1_CUSTOM_TOOLS_MODEL || model === PREVIEW_GEMINI_FLASH_MODEL || model === PREVIEW_GEMINI_MODEL_AUTO || model === GEMINI_MODEL_ALIAS_AUTO || model === PREVIEW_GEMINI_FLASH_LITE_MODEL;
130482
130469
  }
130483
130470
  function isProModel(model, config3) {
130484
130471
  if (config3?.getExperimentalDynamicModelConfiguration?.() === true) {
@@ -130488,7 +130475,7 @@ function isProModel(model, config3) {
130488
130475
  }
130489
130476
  function isGemini3Model(model, config3) {
130490
130477
  if (config3?.getExperimentalDynamicModelConfiguration?.() === true) {
130491
- const resolved2 = resolveModel(model, false, false, false, true, config3);
130478
+ const resolved2 = resolveModel(model, false, false, true, config3);
130492
130479
  return config3.modelConfigService.getModelDefinition(resolved2)?.family === "gemini-3";
130493
130480
  }
130494
130481
  const resolved = resolveModel(model);
@@ -130499,7 +130486,7 @@ function isGemini2Model(model) {
130499
130486
  }
130500
130487
  function isCustomModel(model, config3) {
130501
130488
  if (config3?.getExperimentalDynamicModelConfiguration?.() === true) {
130502
- const resolved2 = resolveModel(model, false, false, false, true, config3);
130489
+ const resolved2 = resolveModel(model, false, false, true, config3);
130503
130490
  return config3.modelConfigService.getModelDefinition(resolved2)?.tier === "custom" || !resolved2.startsWith("gemini-");
130504
130491
  }
130505
130492
  const resolved = resolveModel(model);
@@ -130522,7 +130509,7 @@ function supportsMultimodalFunctionResponse(model, config3) {
130522
130509
  }
130523
130510
  return model.startsWith("gemini-3-");
130524
130511
  }
130525
- var PREVIEW_GEMINI_MODEL, PREVIEW_GEMINI_3_1_MODEL, PREVIEW_GEMINI_3_1_CUSTOM_TOOLS_MODEL, PREVIEW_GEMINI_FLASH_MODEL, PREVIEW_GEMINI_3_1_FLASH_LITE_MODEL, DEFAULT_GEMINI_MODEL, DEFAULT_GEMINI_FLASH_MODEL, DEFAULT_GEMINI_FLASH_LITE_MODEL, GEMMA_4_31B_IT_MODEL, GEMMA_4_26B_A4B_IT_MODEL, PREVIEW_GEMINI_MODEL_AUTO, DEFAULT_GEMINI_MODEL_AUTO, GEMINI_MODEL_ALIAS_AUTO, GEMINI_MODEL_ALIAS_PRO, GEMINI_MODEL_ALIAS_FLASH, GEMINI_MODEL_ALIAS_FLASH_LITE, DEFAULT_GEMINI_EMBEDDING_MODEL, DEFAULT_THINKING_MODE;
130512
+ var PREVIEW_GEMINI_MODEL, PREVIEW_GEMINI_3_1_MODEL, PREVIEW_GEMINI_3_1_CUSTOM_TOOLS_MODEL, PREVIEW_GEMINI_FLASH_MODEL, DEFAULT_GEMINI_MODEL, DEFAULT_GEMINI_FLASH_MODEL, DEFAULT_GEMINI_FLASH_LITE_MODEL, PREVIEW_GEMINI_FLASH_LITE_MODEL, GEMMA_4_31B_IT_MODEL, GEMMA_4_26B_A4B_IT_MODEL, PREVIEW_GEMINI_MODEL_AUTO, DEFAULT_GEMINI_MODEL_AUTO, GEMINI_MODEL_ALIAS_AUTO, GEMINI_MODEL_ALIAS_PRO, GEMINI_MODEL_ALIAS_FLASH, GEMINI_MODEL_ALIAS_FLASH_LITE, DEFAULT_GEMINI_EMBEDDING_MODEL, DEFAULT_THINKING_MODE;
130526
130513
  var init_models = __esm({
130527
130514
  "packages/core/dist/src/config/models.js"() {
130528
130515
  "use strict";
@@ -130530,10 +130517,10 @@ var init_models = __esm({
130530
130517
  PREVIEW_GEMINI_3_1_MODEL = "gemini-3.1-pro-preview";
130531
130518
  PREVIEW_GEMINI_3_1_CUSTOM_TOOLS_MODEL = "gemini-3.1-pro-preview-customtools";
130532
130519
  PREVIEW_GEMINI_FLASH_MODEL = "gemini-3-flash-preview";
130533
- PREVIEW_GEMINI_3_1_FLASH_LITE_MODEL = "gemini-3.1-flash-lite-preview";
130534
130520
  DEFAULT_GEMINI_MODEL = "gemini-2.5-pro";
130535
130521
  DEFAULT_GEMINI_FLASH_MODEL = "gemini-2.5-flash";
130536
- DEFAULT_GEMINI_FLASH_LITE_MODEL = "gemini-2.5-flash-lite";
130522
+ DEFAULT_GEMINI_FLASH_LITE_MODEL = "gemini-3.1-flash-lite";
130523
+ PREVIEW_GEMINI_FLASH_LITE_MODEL = "none";
130537
130524
  GEMMA_4_31B_IT_MODEL = "gemma-4-31b-it";
130538
130525
  GEMMA_4_26B_A4B_IT_MODEL = "gemma-4-26b-a4b-it";
130539
130526
  PREVIEW_GEMINI_MODEL_AUTO = "auto-gemini-3";
@@ -211651,8 +211638,8 @@ var GIT_COMMIT_INFO, CLI_VERSION;
211651
211638
  var init_git_commit = __esm({
211652
211639
  "packages/core/dist/src/generated/git-commit.js"() {
211653
211640
  "use strict";
211654
- GIT_COMMIT_INFO = "b82ca5f8d";
211655
- CLI_VERSION = "0.44.0";
211641
+ GIT_COMMIT_INFO = "41c9260ca";
211642
+ CLI_VERSION = "0.45.0-nightly.20260527.g41c9260ca";
211656
211643
  }
211657
211644
  });
211658
211645
 
@@ -332677,7 +332664,7 @@ function getVersion() {
332677
332664
  }
332678
332665
  versionPromise = (async () => {
332679
332666
  const pkgJson = await getPackageJson(__dirname4);
332680
- return "0.44.0";
332667
+ return "0.45.0-nightly.20260527.g41c9260ca";
332681
332668
  })();
332682
332669
  return versionPromise;
332683
332670
  }
@@ -333516,7 +333503,7 @@ var init_errorClassification = __esm({
333516
333503
  function getModelPolicyChain(options) {
333517
333504
  const isAuto = options.isAutoSelection ?? false;
333518
333505
  if (options.previewEnabled) {
333519
- const proModel = resolveModel(PREVIEW_GEMINI_MODEL, options.useGemini31, options.useGemini31FlashLite, options.useCustomToolModel);
333506
+ const proModel = resolveModel(PREVIEW_GEMINI_MODEL, options.useGemini31, options.useCustomToolModel);
333520
333507
  return [
333521
333508
  definePolicy({
333522
333509
  model: proModel,
@@ -333642,18 +333629,16 @@ function resolvePolicyChain(config3, preferredModel, wrapsAround = false) {
333642
333629
  const configuredModel = normalizeModelId(config3.getModel());
333643
333630
  let chain2;
333644
333631
  const useGemini31 = config3.getGemini31LaunchedSync?.() ?? false;
333645
- const useGemini31FlashLite = config3.getGemini31FlashLiteLaunchedSync?.() ?? false;
333646
333632
  const useCustomToolModel = config3.getUseCustomToolModelSync?.() ?? false;
333647
333633
  const hasAccessToPreview = config3.getHasAccessToPreviewModel?.() ?? false;
333648
333634
  const isOriginallyGemini3 = isGemini3Model(modelFromConfig, config3);
333649
- const resolvedModel = normalizeModelId(resolveModel(modelFromConfig, useGemini31, useGemini31FlashLite, useCustomToolModel, hasAccessToPreview, config3));
333635
+ const resolvedModel = normalizeModelId(resolveModel(modelFromConfig, useGemini31, useCustomToolModel, hasAccessToPreview, config3));
333650
333636
  const isAutoPreferred = normalizedPreferredModel ? isAutoModel(normalizedPreferredModel, config3) : false;
333651
333637
  const isAutoConfigured = isAutoModel(configuredModel, config3);
333652
333638
  const effectiveWrapsAround = wrapsAround || isAutoPreferred || isAutoConfigured || isOriginallyGemini3;
333653
333639
  if (config3.getExperimentalDynamicModelConfiguration?.() === true) {
333654
333640
  const context2 = {
333655
333641
  useGemini3_1: useGemini31,
333656
- useGemini3_1FlashLite: useGemini31FlashLite,
333657
333642
  useCustomTools: useCustomToolModel
333658
333643
  };
333659
333644
  if (resolvedModel === DEFAULT_GEMINI_FLASH_LITE_MODEL) {
@@ -333686,7 +333671,6 @@ function resolvePolicyChain(config3, preferredModel, wrapsAround = false) {
333686
333671
  isAutoSelection,
333687
333672
  userTier: config3.getUserTier(),
333688
333673
  useGemini31,
333689
- useGemini31FlashLite,
333690
333674
  useCustomToolModel
333691
333675
  });
333692
333676
  } else {
@@ -333695,7 +333679,6 @@ function resolvePolicyChain(config3, preferredModel, wrapsAround = false) {
333695
333679
  isAutoSelection,
333696
333680
  userTier: config3.getUserTier(),
333697
333681
  useGemini31,
333698
- useGemini31FlashLite,
333699
333682
  useCustomToolModel
333700
333683
  });
333701
333684
  }
@@ -337764,7 +337747,7 @@ async function createContentGenerator(config3, gcConfig, sessionId) {
337764
337747
  return new LoggingContentGenerator(fakeGenerator, gcConfig);
337765
337748
  }
337766
337749
  const version4 = await getVersion();
337767
- const model = resolveModel(gcConfig.getModel(), config3.authType === AuthType2.USE_GEMINI || config3.authType === AuthType2.USE_VERTEX_AI || (await gcConfig.getGemini31Launched?.() ?? false), config3.authType === AuthType2.USE_GEMINI || config3.authType === AuthType2.USE_VERTEX_AI || (await gcConfig.getGemini31FlashLiteLaunched?.() ?? false), false, gcConfig.getHasAccessToPreviewModel?.() ?? true, gcConfig);
337750
+ const model = resolveModel(gcConfig.getModel(), config3.authType === AuthType2.USE_GEMINI || config3.authType === AuthType2.USE_VERTEX_AI || (await gcConfig.getGemini31Launched?.() ?? false), false, gcConfig.getHasAccessToPreviewModel?.() ?? true, gcConfig);
337768
337751
  const customHeadersEnv = process.env["GEMINI_CLI_CUSTOM_HEADERS"] || void 0;
337769
337752
  const clientName = gcConfig.getClientName();
337770
337753
  const surface = determineSurface2();
@@ -353026,17 +353009,6 @@ function injectUtf8CodepageForPty(command, shell, isWindows2, usingPty) {
353026
353009
  }
353027
353010
  return command;
353028
353011
  }
353029
- function ensureHupIgnored(command, shell) {
353030
- if (shell !== "bash") {
353031
- return command;
353032
- }
353033
- const trimmed2 = command.trimStart();
353034
- const prefix = `${BASH_HUP_GUARD} `;
353035
- if (trimmed2.startsWith(prefix) || trimmed2 === BASH_HUP_GUARD) {
353036
- return command;
353037
- }
353038
- return `${BASH_HUP_GUARD} ${command}`;
353039
- }
353040
353012
  var import_headless2, Terminal, MAX_CHILD_PROCESS_BUFFER_SIZE, GEMINI_CLI_IDENTIFICATION_ENV_VAR, GEMINI_CLI_IDENTIFICATION_ENV_VAR_VALUE, SCROLLBACK_LIMIT, BASH_SHOPT_OPTIONS, BASH_SHOPT_GUARD, findLastContentLine, getFullBufferText, writeBufferToLogStream, ShellExecutionService;
353041
353013
  var init_shellExecutionService = __esm({
353042
353014
  "packages/core/dist/src/services/shellExecutionService.js"() {
@@ -353226,9 +353198,8 @@ ${truncated}`;
353226
353198
  executable = "cmd.exe";
353227
353199
  }
353228
353200
  const resolvedExecutable = resolveExecutable(executable) ?? executable;
353229
- const promptGuarded = ensurePromptvarsDisabled(commandToExecute, shell);
353230
- const hupGuarded = !isWindows2 ? ensureHupIgnored(promptGuarded, shell) : promptGuarded;
353231
- const finalCommand = injectUtf8CodepageForPty(hupGuarded, shell, isWindows2, usingPty);
353201
+ const guardedCommand = ensurePromptvarsDisabled(commandToExecute, shell);
353202
+ const finalCommand = injectUtf8CodepageForPty(guardedCommand, shell, isWindows2, usingPty);
353232
353203
  const spawnArgs = [...argsPrefix, finalCommand];
353233
353204
  const gitConfigKeys = [];
353234
353205
  if (!isInteractive) {
@@ -354006,8 +353977,9 @@ ${truncated}`;
354006
353977
  } catch (e3) {
354007
353978
  const err2 = e3;
354008
353979
  const isEsrch = err2.code === "ESRCH";
353980
+ const isEbadf = err2.code === "EBADF" || err2.message?.includes("EBADF");
354009
353981
  const isWindowsPtyError = err2.message?.includes("Cannot resize a pty that has already exited");
354010
- if (isEsrch || isWindowsPtyError) {
353982
+ if (isEsrch || isEbadf || isWindowsPtyError) {
354011
353983
  } else {
354012
353984
  throw e3;
354013
353985
  }
@@ -362271,11 +362243,10 @@ var init_geminiChat = __esm({
362271
362243
  const initialActiveModel = this.context.config.getActiveModel();
362272
362244
  const apiCall = async () => {
362273
362245
  const useGemini3_1 = await this.context.config.getGemini31Launched?.() ?? false;
362274
- const useGemini3_1FlashLite = await this.context.config.getGemini31FlashLiteLaunched?.() ?? false;
362275
362246
  const hasAccessToPreview = this.context.config.getHasAccessToPreviewModel?.() ?? true;
362276
- let modelToUse = resolveModel(lastModelToUse, useGemini3_1, useGemini3_1FlashLite, false, hasAccessToPreview, this.context.config);
362247
+ let modelToUse = resolveModel(lastModelToUse, useGemini3_1, false, hasAccessToPreview, this.context.config);
362277
362248
  if (this.context.config.getActiveModel() !== initialActiveModel) {
362278
- modelToUse = resolveModel(this.context.config.getActiveModel(), useGemini3_1, useGemini3_1FlashLite, false, hasAccessToPreview, this.context.config);
362249
+ modelToUse = resolveModel(this.context.config.getActiveModel(), useGemini3_1, false, hasAccessToPreview, this.context.config);
362279
362250
  }
362280
362251
  if (modelToUse !== lastModelToUse) {
362281
362252
  const { generateContentConfig: newConfig } = this.context.config.modelConfigService.getResolvedConfig({
@@ -362314,7 +362285,7 @@ var init_geminiChat = __esm({
362314
362285
  throw new AgentExecutionBlockedError(beforeModelResult.reason || "Model call blocked by hook", syntheticResponse);
362315
362286
  }
362316
362287
  if (beforeModelResult.modifiedModel) {
362317
- modelToUse = resolveModel(beforeModelResult.modifiedModel, useGemini3_1, useGemini3_1FlashLite, false, hasAccessToPreview, this.context.config);
362288
+ modelToUse = resolveModel(beforeModelResult.modifiedModel, useGemini3_1, false, hasAccessToPreview, this.context.config);
362318
362289
  lastModelToUse = modelToUse;
362319
362290
  contentsToUse = supportsModernFeatures(modelToUse) ? [...contentsForPreviewModel] : [...requestContents];
362320
362291
  }
@@ -364712,7 +364683,7 @@ var init_promptProvider = __esm({
364712
364683
  const isTopicUpdateNarrationEnabled = topicUpdateNarrationOverride ?? context2.config.isTopicUpdateNarrationEnabled();
364713
364684
  const enabledToolNames = new Set(toolNames);
364714
364685
  const approvedPlanPath = context2.config.getApprovedPlanPath();
364715
- const desiredModel = resolveModel(context2.config.getActiveModel(), context2.config.getGemini31LaunchedSync?.() ?? false, context2.config.getGemini31FlashLiteLaunchedSync?.() ?? false, false, context2.config.getHasAccessToPreviewModel?.() ?? true, context2.config);
364686
+ const desiredModel = resolveModel(context2.config.getActiveModel(), context2.config.getGemini31LaunchedSync?.() ?? false, false, context2.config.getHasAccessToPreviewModel?.() ?? true, context2.config);
364716
364687
  const isModernModel = supportsModernFeatures(desiredModel);
364717
364688
  const activeSnippets = isModernModel ? snippets_exports : snippets_legacy_exports;
364718
364689
  const contextFilenames = getAllGeminiMdFilenames();
@@ -364830,7 +364801,7 @@ var init_promptProvider = __esm({
364830
364801
  return sanitizedPrompt;
364831
364802
  }
364832
364803
  getCompressionPrompt(context2) {
364833
- const desiredModel = resolveModel(context2.config.getActiveModel(), context2.config.getGemini31LaunchedSync?.() ?? false, context2.config.getGemini31FlashLiteLaunchedSync?.() ?? false, false, context2.config.getHasAccessToPreviewModel?.() ?? true, context2.config);
364804
+ const desiredModel = resolveModel(context2.config.getActiveModel(), context2.config.getGemini31LaunchedSync?.() ?? false, false, context2.config.getHasAccessToPreviewModel?.() ?? true, context2.config);
364834
364805
  const isModernModel = supportsModernFeatures(desiredModel);
364835
364806
  const activeSnippets = isModernModel ? snippets_exports : snippets_legacy_exports;
364836
364807
  return activeSnippets.getCompressionPrompt(context2.config.getApprovedPlanPath());
@@ -365456,14 +365427,16 @@ function modelStringToModelConfigAlias(model) {
365456
365427
  return "chat-compression-3-pro";
365457
365428
  case PREVIEW_GEMINI_FLASH_MODEL:
365458
365429
  return "chat-compression-3-flash";
365459
- case PREVIEW_GEMINI_3_1_FLASH_LITE_MODEL:
365430
+ case PREVIEW_GEMINI_FLASH_LITE_MODEL:
365431
+ // fallthrough
365432
+ case DEFAULT_GEMINI_FLASH_LITE_MODEL:
365460
365433
  return "chat-compression-3.1-flash-lite";
365434
+ case "gemini-2.5-flash-lite":
365435
+ return "chat-compression-2.5-flash-lite";
365461
365436
  case DEFAULT_GEMINI_MODEL:
365462
365437
  return "chat-compression-2.5-pro";
365463
365438
  case DEFAULT_GEMINI_FLASH_MODEL:
365464
365439
  return "chat-compression-2.5-flash";
365465
- case DEFAULT_GEMINI_FLASH_LITE_MODEL:
365466
- return "chat-compression-2.5-flash-lite";
365467
365440
  default:
365468
365441
  return "chat-compression-default";
365469
365442
  }
@@ -374179,7 +374152,6 @@ var init_modelConfigService = __esm({
374179
374152
  const definitions = this.config.modelDefinitions ?? {};
374180
374153
  const shouldShowPreviewModels = context2.hasAccessToPreview ?? false;
374181
374154
  const useGemini31 = context2.useGemini3_1 ?? false;
374182
- const useGemini31FlashLite = context2.useGemini3_1FlashLite ?? false;
374183
374155
  const mainOptions = Object.entries(definitions).filter(([_3, m3]) => {
374184
374156
  if (m3.isVisible !== true)
374185
374157
  return false;
@@ -374213,14 +374185,11 @@ var init_modelConfigService = __esm({
374213
374185
  return false;
374214
374186
  if (id === PREVIEW_GEMINI_3_1_MODEL && !useGemini31)
374215
374187
  return false;
374216
- if (id === PREVIEW_GEMINI_3_1_FLASH_LITE_MODEL && !useGemini31FlashLite)
374217
- return false;
374218
374188
  return true;
374219
374189
  }).map(([id, m3]) => {
374220
374190
  const resolvedId = this.resolveModelId(id, context2);
374221
374191
  const titleId = this.resolveModelId(id, {
374222
- useGemini3_1: useGemini31,
374223
- useGemini3_1FlashLite: useGemini31FlashLite
374192
+ useGemini3_1: useGemini31
374224
374193
  });
374225
374194
  return {
374226
374195
  modelId: resolvedId,
@@ -378315,7 +378284,7 @@ function resolveProcessorOptions(config3, id, defaultOptions3) {
378315
378284
  }
378316
378285
  return defaultOptions3;
378317
378286
  }
378318
- var generalistProfile, stressTestProfile;
378287
+ var generalistProfile, stressTestProfile, powerUserProfile;
378319
378288
  var init_profiles = __esm({
378320
378289
  "packages/core/dist/src/context/config/profiles.js"() {
378321
378290
  "use strict";
@@ -378428,6 +378397,86 @@ var init_profiles = __esm({
378428
378397
  buildPipelines: generalistProfile.buildPipelines,
378429
378398
  buildAsyncPipelines: generalistProfile.buildAsyncPipelines
378430
378399
  };
378400
+ powerUserProfile = {
378401
+ name: "Power User (Experimental)",
378402
+ sentinels: generalistProfile.sentinels,
378403
+ config: {
378404
+ budget: {
378405
+ retainedTokens: 65e3,
378406
+ normalizedTokens: 1e5,
378407
+ maxTokens: 15e4,
378408
+ coalescingThresholdTokens: 5e3
378409
+ },
378410
+ gcStrategy: "incremental"
378411
+ },
378412
+ buildPipelines: (env, config3) => [
378413
+ {
378414
+ name: "Immediate Sanitization",
378415
+ triggers: ["new_message"],
378416
+ processors: [
378417
+ createToolMaskingProcessor("ToolMasking", env, resolveProcessorOptions(config3, "ToolMasking", {
378418
+ stringLengthThresholdTokens: 8e3
378419
+ })),
378420
+ createBlobDegradationProcessor("BlobDegradation", env),
378421
+ createNodeDistillationProcessor("ImmediateNodeDistillation", env, resolveProcessorOptions(config3, "ImmediateNodeDistillation", {
378422
+ nodeThresholdTokens: 15e3
378423
+ }))
378424
+ ]
378425
+ },
378426
+ {
378427
+ name: "Normalization",
378428
+ triggers: ["retained_exceeded"],
378429
+ processors: [
378430
+ createNodeDistillationProcessor("NodeDistillation", env, resolveProcessorOptions(config3, "NodeDistillation", {
378431
+ nodeThresholdTokens: 3e3
378432
+ })),
378433
+ createNodeTruncationProcessor("NodeTruncation", env, resolveProcessorOptions(config3, "NodeTruncation", {
378434
+ maxTokensPerNode: 4e3
378435
+ }))
378436
+ ]
378437
+ },
378438
+ {
378439
+ name: "Archiving",
378440
+ triggers: ["normalized_exceeded"],
378441
+ processors: [
378442
+ createNodeDistillationProcessor("ArchiveNodeDistillation", env, resolveProcessorOptions(config3, "ArchiveNodeDistillation", {
378443
+ nodeThresholdTokens: 1e3
378444
+ })),
378445
+ createNodeTruncationProcessor("ArchiveNodeTruncation", env, resolveProcessorOptions(config3, "ArchiveNodeTruncation", {
378446
+ maxTokensPerNode: 1500
378447
+ }))
378448
+ ]
378449
+ },
378450
+ {
378451
+ name: "Emergency Backstop",
378452
+ triggers: ["gc_backstop"],
378453
+ processors: [
378454
+ createStateSnapshotProcessor("StateSnapshotSync", env, resolveProcessorOptions(config3, "StateSnapshotSync", {
378455
+ target: "max",
378456
+ maxStateTokens: 2e3,
378457
+ maxSummaryTurns: 10
378458
+ })),
378459
+ // If we STILL exceed max tokens, aggressively truncate
378460
+ createNodeTruncationProcessor("EmergencyNodeTruncation", env, resolveProcessorOptions(config3, "EmergencyNodeTruncation", {
378461
+ maxTokensPerNode: 500
378462
+ }))
378463
+ ]
378464
+ }
378465
+ ],
378466
+ buildAsyncPipelines: (env, config3) => [
378467
+ {
378468
+ name: "Async Background GC",
378469
+ triggers: ["nodes_aged_out"],
378470
+ processors: [
378471
+ createStateSnapshotAsyncProcessor("StateSnapshotAsync", env, resolveProcessorOptions(config3, "StateSnapshotAsync", {
378472
+ type: "accumulate",
378473
+ maxStateTokens: 4e3,
378474
+ maxSummaryTurns: 5
378475
+ }))
378476
+ ]
378477
+ }
378478
+ ]
378479
+ };
378431
378480
  }
378432
378481
  });
378433
378482
 
@@ -378509,6 +378558,9 @@ async function loadContextManagementConfig(sidecarPath, registry2) {
378509
378558
  if (sidecarPath === "stressTestProfile") {
378510
378559
  return stressTestProfile;
378511
378560
  }
378561
+ if (sidecarPath === "powerUserProfile") {
378562
+ return powerUserProfile;
378563
+ }
378512
378564
  if (sidecarPath === "generalistProfile") {
378513
378565
  return generalistProfile;
378514
378566
  }
@@ -378638,6 +378690,12 @@ var init_eventBus = __esm({
378638
378690
  onConsolidationNeeded(listener) {
378639
378691
  this.on("BUDGET_RETAINED_CROSSED", listener);
378640
378692
  }
378693
+ emitNormalizeNeeded(event) {
378694
+ this.emit("BUDGET_NORMALIZED_CROSSED", event);
378695
+ }
378696
+ onNormalizeNeeded(listener) {
378697
+ this.on("BUDGET_NORMALIZED_CROSSED", listener);
378698
+ }
378641
378699
  emitProcessorResult(event) {
378642
378700
  this.emit("PROCESSOR_RESULT", event);
378643
378701
  }
@@ -378792,13 +378850,13 @@ var init_toGraph = __esm({
378792
378850
  const msg = turn.content;
378793
378851
  if (!msg.parts)
378794
378852
  continue;
378795
- const turnSalt = turn.id;
378853
+ const hasEnvHeader = msg.parts?.some((p3) => isTextPart2(p3) && p3.text.trim().startsWith("<session_context>"));
378854
+ const turnSalt = hasEnvHeader && turnIdx === 0 ? deriveStableId(["environment-context"]) : turn.id;
378796
378855
  const turnId = turnSalt.startsWith("turn_") ? turnSalt : `turn_${turnSalt}`;
378797
378856
  if (msg.role === "user") {
378798
378857
  for (let partIdx = 0; partIdx < msg.parts.length; partIdx++) {
378799
378858
  const part = msg.parts[partIdx];
378800
- const envTurnId = deriveStableId(["environment-context"]);
378801
- if (isTextPart2(part) && part.text.trim().startsWith("<session_context>") && turnSalt !== envTurnId) {
378859
+ if (isTextPart2(part) && part.text.trim().startsWith("<session_context>") && turnIdx > 0) {
378802
378860
  debugLogger.log("[ContextGraphBuilder] Skipping legacy environment header turn from graph.");
378803
378861
  continue;
378804
378862
  }
@@ -379242,13 +379300,13 @@ var init_orchestrator = __esm({
379242
379300
  isNodeAllowed(node, triggerTargets, protectedTurnIds = /* @__PURE__ */ new Set()) {
379243
379301
  return triggerTargets.has(node.id) && !protectedTurnIds.has(node.id) && !protectedTurnIds.has(node.turnId);
379244
379302
  }
379245
- async executeTriggerSync(trigger, nodes, triggerTargets, protectedTurnIds = /* @__PURE__ */ new Set()) {
379303
+ async executeTriggerSync(trigger, buffer, triggerTargets, protectedTurnIds = /* @__PURE__ */ new Set()) {
379246
379304
  this.tracer.logEvent("Orchestrator", "Strategy Intent", {
379247
379305
  trigger,
379248
- totalNodes: nodes.length,
379306
+ totalNodes: buffer.nodes.length,
379249
379307
  targetNodes: triggerTargets.size
379250
379308
  });
379251
- let currentBuffer = ContextWorkingBufferImpl.initialize(nodes);
379309
+ let currentBuffer = buffer;
379252
379310
  const triggerPipelines = this.pipelines.filter((p3) => p3.triggers.includes(trigger));
379253
379311
  const inboxSnapshot = new InboxSnapshotImpl(this.env.inbox.getMessages() || []);
379254
379312
  for (const pipeline3 of triggerPipelines) {
@@ -379283,7 +379341,7 @@ var init_orchestrator = __esm({
379283
379341
  }
379284
379342
  void this.executeTriggerAsync(trigger, currentBuffer.nodes, triggerTargets);
379285
379343
  this.env.inbox.drainConsumed(inboxSnapshot.getConsumedIds());
379286
- return currentBuffer.nodes;
379344
+ return currentBuffer;
379287
379345
  }
379288
379346
  async executeTriggerAsync(trigger, nodes, triggerTargets) {
379289
379347
  const asyncPipelines = this.asyncPipelines.filter((p3) => p3.triggers.includes(trigger));
@@ -379455,7 +379513,15 @@ async function render2(nodes, orchestrator, sidecar, tracer, env, advancedTokenC
379455
379513
  const nodeTokens = env.tokenCalculator.calculateConcreteListTokens([node]);
379456
379514
  rollingTokens += nodeTokens;
379457
379515
  if (priorTokens > sidecar.config.budget.retainedTokens) {
379458
- agedOutNodes.add(node.id);
379516
+ if (sidecar.config.gcStrategy === "incremental") {
379517
+ if (priorTokens > maxTokens) {
379518
+ agedOutNodes.add(node.id);
379519
+ } else if (rollingTokens > maxTokens) {
379520
+ agedOutNodes.add(node.id);
379521
+ }
379522
+ } else {
379523
+ agedOutNodes.add(node.id);
379524
+ }
379459
379525
  }
379460
379526
  }
379461
379527
  if (lateBindPrompt && lastTurnId) {
@@ -379465,7 +379531,8 @@ async function render2(nodes, orchestrator, sidecar, tracer, env, advancedTokenC
379465
379531
  }
379466
379532
  }
379467
379533
  }
379468
- const processedNodes = await orchestrator.executeTriggerSync("gc_backstop", nodes, agedOutNodes, protectedIds);
379534
+ const processedBuffer = await orchestrator.executeTriggerSync("gc_backstop", ContextWorkingBufferImpl.initialize(nodes), agedOutNodes, protectedIds);
379535
+ const processedNodes = processedBuffer.nodes;
379469
379536
  const skipList = /* @__PURE__ */ new Set();
379470
379537
  for (const node of processedNodes) {
379471
379538
  if (node.abstractsIds) {
@@ -379501,6 +379568,7 @@ var init_render = __esm({
379501
379568
  "use strict";
379502
379569
  init_debugLogger();
379503
379570
  init_tokenCalibration();
379571
+ init_contextWorkingBuffer();
379504
379572
  }
379505
379573
  });
379506
379574
 
@@ -379561,6 +379629,7 @@ var init_contextManager = __esm({
379561
379629
  evaluatedNodeIds = /* @__PURE__ */ new Set();
379562
379630
  // Hysteresis tracking to prevent utility call churn
379563
379631
  lastTriggeredDeficit = 0;
379632
+ lastTriggeredNormalizeDeficit = 0;
379564
379633
  // Cache for Anomaly 3 (Redundant Renders)
379565
379634
  lastRenderCache;
379566
379635
  hasPerformedHotStart = false;
@@ -379575,107 +379644,14 @@ var init_contextManager = __esm({
379575
379644
  this.orchestrator = orchestrator;
379576
379645
  this.orchestrator.setNodeProvider(() => this.buffer.nodes);
379577
379646
  this.eventBus.onProcessorResult((event) => {
379578
- const currentIds = new Set(this.buffer.nodes.map((n2) => n2.id));
379579
- const allTargetsPresent = event.targets.every((t4) => currentIds.has(t4.id));
379580
- if (!allTargetsPresent) {
379581
- debugLogger.log(`[ContextManager] Dropping stale processor result from ${event.processorId}. One or more targets were already removed.`);
379647
+ const bufferIds = new Set(this.buffer.nodes.map((n2) => n2.id));
379648
+ if (!event.targets.every((t4) => bufferIds.has(t4.id))) {
379649
+ debugLogger.warn(`[ContextManager] Dropping processor result from ${event.processorId}: targets no longer in buffer.`);
379582
379650
  return;
379583
379651
  }
379584
379652
  this.buffer = this.buffer.applyProcessorResult(event.processorId, event.targets, event.returnedNodes);
379585
379653
  });
379586
379654
  }
379587
- /**
379588
- * Returns a promise that resolves when all currently executing async pipelines have finished.
379589
- */
379590
- async waitForPipelines() {
379591
- return this.orchestrator.waitForPipelines();
379592
- }
379593
- /**
379594
- * Safely stops background async pipelines and clears event listeners.
379595
- */
379596
- shutdown() {
379597
- this.orchestrator.shutdown();
379598
- }
379599
- /**
379600
- * Evaluates if the current working buffer exceeds configured budget thresholds,
379601
- * firing consolidation events if necessary.
379602
- */
379603
- async evaluateTriggers(newNodes) {
379604
- if (!this.sidecar.config.budget)
379605
- return;
379606
- if (newNodes.size > 0) {
379607
- await this.orchestrator.executeTriggerSync("new_message", this.buffer.nodes, newNodes);
379608
- }
379609
- const currentTokens = this.env.tokenCalculator.calculateConcreteListTokens(this.buffer.nodes);
379610
- if (currentTokens > this.sidecar.config.budget.retainedTokens) {
379611
- const agedOutNodes = /* @__PURE__ */ new Set();
379612
- let rollingTokens = 0;
379613
- const protectedIds = this.getProtectedNodeIds(this.buffer.nodes);
379614
- for (let i4 = this.buffer.nodes.length - 1; i4 >= 0; i4--) {
379615
- const node = this.buffer.nodes[i4];
379616
- const priorTokens = rollingTokens;
379617
- rollingTokens += this.env.tokenCalculator.calculateConcreteListTokens([
379618
- node
379619
- ]);
379620
- if (priorTokens > this.sidecar.config.budget.retainedTokens) {
379621
- if (!protectedIds.has(node.id)) {
379622
- agedOutNodes.add(node.id);
379623
- }
379624
- }
379625
- }
379626
- if (agedOutNodes.size > 0) {
379627
- const targetDeficit = currentTokens - this.sidecar.config.budget.retainedTokens;
379628
- if (targetDeficit < this.lastTriggeredDeficit) {
379629
- this.lastTriggeredDeficit = targetDeficit;
379630
- }
379631
- const threshold = this.sidecar.config.budget.coalescingThresholdTokens || 0;
379632
- const growthSinceLast = targetDeficit - this.lastTriggeredDeficit;
379633
- if (targetDeficit >= threshold && (growthSinceLast >= threshold || this.lastTriggeredDeficit === 0)) {
379634
- this.lastTriggeredDeficit = targetDeficit;
379635
- this.env.tokenCalculator.garbageCollectCache(new Set(this.buffer.nodes.map((n2) => n2.id)));
379636
- await this.orchestrator.executeTriggerSync("nodes_aged_out", this.buffer.nodes, agedOutNodes, new Set(protectedIds.keys()));
379637
- }
379638
- } else {
379639
- this.lastTriggeredDeficit = 0;
379640
- }
379641
- }
379642
- }
379643
- getProtectedNodeIds(nodes, extraProtectedIds = /* @__PURE__ */ new Set()) {
379644
- const protectionMap = /* @__PURE__ */ new Map();
379645
- if (nodes.length === 0)
379646
- return protectionMap;
379647
- const lastNode = nodes[nodes.length - 1];
379648
- const lastTurnId = lastNode.turnId;
379649
- const envTurnId = `turn_${deriveStableId(["environment-context"])}`;
379650
- for (const node of nodes) {
379651
- if (node.turnId === lastTurnId) {
379652
- protectionMap.set(node.id, "recent_turn");
379653
- } else if (node.turnId === envTurnId) {
379654
- protectionMap.set(node.id, "environment_context");
379655
- }
379656
- }
379657
- for (const id of extraProtectedIds) {
379658
- protectionMap.set(id, "external_active_task");
379659
- }
379660
- return protectionMap;
379661
- }
379662
- getPristineGraph() {
379663
- const pristineSet = /* @__PURE__ */ new Map();
379664
- for (const node of this.buffer.nodes) {
379665
- const roots = this.buffer.getPristineNodes(node.id);
379666
- for (const root of roots) {
379667
- pristineSet.set(root.id, root);
379668
- }
379669
- }
379670
- return Array.from(pristineSet.values()).sort((a, b3) => a.timestamp - b3.timestamp);
379671
- }
379672
- getNodes() {
379673
- return [...this.buffer.nodes];
379674
- }
379675
- /**
379676
- * Generates a virtual view of the pristine graph, substituting in variants
379677
- * up to the configured token budget.
379678
- */
379679
379655
  async renderHistory(pendingRequest, activeTaskIds = /* @__PURE__ */ new Set(), abortSignal) {
379680
379656
  this.tracer.logEvent("ContextManager", "Starting rendering of LLM context");
379681
379657
  const currentHistory = this.chatHistory.get();
@@ -379690,11 +379666,12 @@ var init_contextManager = __esm({
379690
379666
  }
379691
379667
  let previewNodes = [];
379692
379668
  if (pendingRequest) {
379693
- previewNodes = this.env.graphMapper.sync([pendingRequest]);
379694
- const previewNodeIds2 = new Set(previewNodes.map((n2) => n2.id));
379695
- previewNodes = await this.orchestrator.executeTriggerSync("new_message", previewNodes, previewNodeIds2);
379669
+ const syncedNodes = this.env.graphMapper.sync([pendingRequest]);
379670
+ const previewNodeIds2 = new Set(syncedNodes.map((n2) => n2.id));
379671
+ const previewBuffer = ContextWorkingBufferImpl.initialize(syncedNodes);
379672
+ const processedPreviewBuffer = await this.orchestrator.executeTriggerSync("new_message", previewBuffer, previewNodeIds2);
379673
+ previewNodes = processedPreviewBuffer.nodes;
379696
379674
  }
379697
- await this.evaluateTriggers(newPrimalNodes);
379698
379675
  const hotStartPromise = (async () => {
379699
379676
  if (!this.hasPerformedHotStart) {
379700
379677
  this.hasPerformedHotStart = true;
@@ -379708,17 +379685,20 @@ var init_contextManager = __esm({
379708
379685
  let nodes = this.buffer.nodes;
379709
379686
  const previewNodeIds = /* @__PURE__ */ new Set();
379710
379687
  if (previewNodes.length > 0) {
379711
- for (const n2 of previewNodes) {
379712
- previewNodeIds.add(n2.id);
379713
- }
379714
379688
  nodes = [...nodes, ...previewNodes];
379689
+ for (const node of previewNodes) {
379690
+ previewNodeIds.add(node.id);
379691
+ }
379715
379692
  }
379693
+ await this.evaluateTriggers(nodes, newPrimalNodes, activeTaskIds);
379694
+ nodes = [...this.buffer.nodes, ...previewNodes];
379716
379695
  const header = this.headerProvider ? await this.headerProvider() : void 0;
379717
- const graphHash = nodes.map((n2) => n2.id).join("|");
379718
- const headerHash = header ? JSON.stringify(header.parts) : "no-header";
379719
- const totalHash = `${graphHash}::${headerHash}`;
379720
- if (this.lastRenderCache?.nodesHash === totalHash) {
379721
- debugLogger.log("[ContextManager] Render cache hit. Skipping redundant render.");
379696
+ const nodesHash = deriveStableId([
379697
+ ...nodes.map((n2) => n2.id),
379698
+ header ? JSON.stringify(header.parts) : "no-header"
379699
+ ]);
379700
+ if (this.lastRenderCache?.nodesHash === nodesHash) {
379701
+ this.tracer.logEvent("ContextManager", "Render Cache Hit", { nodesHash });
379722
379702
  return this.lastRenderCache.result;
379723
379703
  }
379724
379704
  const protectionReasons = this.getProtectedNodeIds(nodes, activeTaskIds);
@@ -379729,41 +379709,168 @@ var init_contextManager = __esm({
379729
379709
  });
379730
379710
  const { history: renderedHistory, pendingHistory, didApplyManagement, baseUnits, processedNodes } = renderResult;
379731
379711
  if (didApplyManagement) {
379732
- this.buffer = this.buffer.applyProcessorResult("sync_backstop", this.buffer.nodes, processedNodes.filter((n2) => !previewNodeIds.has(n2.id)));
379712
+ const masterIdsInResult = new Set(this.buffer.nodes.map((n2) => n2.id));
379713
+ const processedMasterNodes = processedNodes.filter((n2) => !previewNodeIds.has(n2.id) || masterIdsInResult.has(n2.id));
379714
+ this.buffer = this.buffer.applyProcessorResult("sync_backstop", this.buffer.nodes, processedMasterNodes);
379733
379715
  }
379734
379716
  checkContextInvariants(this.buffer.nodes, "RenderHistory");
379735
- this.tracer.logEvent("ContextManager", "Finished rendering");
379736
- const allHistory = [...renderedHistory, ...pendingHistory];
379737
- const hardenedAllHistory = hardenHistory(allHistory, {
379717
+ const fullHistoryToHarden = [...renderedHistory, ...pendingHistory];
379718
+ const hardenedFullHistory = hardenHistory(fullHistoryToHarden, {
379738
379719
  sentinels: this.sidecar.sentinels
379739
379720
  });
379740
- const firstPendingId = pendingHistory[0]?.id;
379741
- let splitIndex = renderedHistory.length;
379742
- if (firstPendingId) {
379743
- const foundIndex = hardenedAllHistory.findIndex((h3) => h3.id === firstPendingId);
379744
- if (foundIndex !== -1) {
379745
- splitIndex = foundIndex;
379721
+ const envContextId = deriveStableId(["environment-context"]);
379722
+ const pendingIds = new Set(pendingHistory.map((t4) => t4.id));
379723
+ const resultHistory = [];
379724
+ const resultPending = [];
379725
+ let foundPending = false;
379726
+ for (const turn of hardenedFullHistory) {
379727
+ if (!foundPending && (pendingIds.has(turn.id) || turn.id.startsWith("turn_") && pendingIds.has(turn.id.substring(5))) && turn.id !== envContextId && turn.id !== `turn_${envContextId}`) {
379728
+ foundPending = true;
379729
+ }
379730
+ if (foundPending) {
379731
+ resultPending.push(turn);
379732
+ } else {
379733
+ resultHistory.push(turn);
379746
379734
  }
379747
379735
  }
379748
- const apiHistory = hardenedAllHistory.slice(0, splitIndex).map((h3) => h3.content);
379749
- const pendingApiHistory = hardenedAllHistory.slice(splitIndex).map((h3) => h3.content);
379750
- if (header) {
379751
- apiHistory.unshift(header);
379752
- }
379753
379736
  const result2 = {
379754
379737
  history: renderedHistory,
379755
- apiHistory,
379756
- pendingApiHistory,
379738
+ apiHistory: resultHistory.map((h3) => h3.content),
379739
+ pendingApiHistory: resultPending.map((h3) => h3.content),
379757
379740
  didApplyManagement,
379758
379741
  baseUnits,
379759
379742
  processedNodes
379760
379743
  };
379761
- this.lastRenderCache = {
379762
- nodesHash: totalHash,
379763
- result: result2
379764
- };
379744
+ if (header) {
379745
+ result2.apiHistory.unshift(header);
379746
+ }
379747
+ this.lastRenderCache = { nodesHash, result: result2 };
379748
+ this.tracer.logEvent("ContextManager", "Rendering Complete", {
379749
+ historySize: renderedHistory.length,
379750
+ pendingSize: pendingHistory.length,
379751
+ didApplyManagement
379752
+ });
379765
379753
  return result2;
379766
379754
  }
379755
+ async waitForPipelines() {
379756
+ await this.orchestrator.waitForPipelines();
379757
+ }
379758
+ shutdown() {
379759
+ this.orchestrator.shutdown();
379760
+ }
379761
+ getNodes() {
379762
+ return this.buffer.nodes;
379763
+ }
379764
+ getEnvironment() {
379765
+ return this.env;
379766
+ }
379767
+ getPristineGraph() {
379768
+ const pristineSet = /* @__PURE__ */ new Map();
379769
+ for (const node of this.buffer.nodes) {
379770
+ const roots = this.buffer.getPristineNodes(node.id);
379771
+ for (const root of roots) {
379772
+ pristineSet.set(root.id, root);
379773
+ }
379774
+ }
379775
+ return Array.from(pristineSet.values()).sort((a, b3) => a.timestamp - b3.timestamp);
379776
+ }
379777
+ async evaluateTriggers(nodes, newPrimalNodes, activeTaskIds) {
379778
+ if (newPrimalNodes.size > 0) {
379779
+ this.buffer = await this.orchestrator.executeTriggerSync("nodes_added", this.buffer, newPrimalNodes);
379780
+ }
379781
+ const bufferIds = new Set(this.buffer.nodes.map((n2) => n2.id));
379782
+ const previewNodes = nodes.filter((n2) => !bufferIds.has(n2.id));
379783
+ const currentNodes = [...this.buffer.nodes, ...previewNodes];
379784
+ const currentTokens = this.env.tokenCalculator.calculateConcreteListTokens(currentNodes);
379785
+ if (currentTokens > this.sidecar.config.budget.retainedTokens) {
379786
+ const agedOutRetainedNodes = /* @__PURE__ */ new Set();
379787
+ const agedOutNormalizedNodes = /* @__PURE__ */ new Set();
379788
+ const protectionMap = this.getProtectedNodeIds(currentNodes, activeTaskIds);
379789
+ const protectedIds = new Set(protectionMap.keys());
379790
+ const envTurnId = `turn_${deriveStableId(["environment-context"])}`;
379791
+ const turn0Nodes = currentNodes.filter((n2) => n2.turnId === envTurnId);
379792
+ for (const n2 of turn0Nodes) {
379793
+ protectedIds.add(n2.id);
379794
+ }
379795
+ let rollingTokens = 0;
379796
+ for (let i4 = currentNodes.length - 1; i4 >= 0; i4--) {
379797
+ const node = currentNodes[i4];
379798
+ const priorTokens = rollingTokens;
379799
+ rollingTokens += this.env.tokenCalculator.calculateConcreteListTokens([
379800
+ node
379801
+ ]);
379802
+ if (priorTokens > this.sidecar.config.budget.retainedTokens) {
379803
+ if (!protectedIds.has(node.id)) {
379804
+ const hasNormalizedTier = this.sidecar.config.budget.normalizedTokens !== void 0;
379805
+ if (!hasNormalizedTier || priorTokens <= this.sidecar.config.budget.normalizedTokens) {
379806
+ agedOutRetainedNodes.add(node.id);
379807
+ }
379808
+ if (hasNormalizedTier && priorTokens > this.sidecar.config.budget.normalizedTokens) {
379809
+ agedOutNormalizedNodes.add(node.id);
379810
+ }
379811
+ }
379812
+ }
379813
+ }
379814
+ if (agedOutRetainedNodes.size > 0) {
379815
+ const targetDeficit = currentTokens - this.sidecar.config.budget.retainedTokens;
379816
+ const threshold = this.sidecar.config.budget.coalescingThresholdTokens || 0;
379817
+ if (targetDeficit < this.lastTriggeredDeficit) {
379818
+ this.lastTriggeredDeficit = targetDeficit;
379819
+ }
379820
+ if (targetDeficit > this.lastTriggeredDeficit + threshold) {
379821
+ this.lastTriggeredDeficit = targetDeficit;
379822
+ this.eventBus.emitConsolidationNeeded({
379823
+ nodes: this.buffer.nodes,
379824
+ targetDeficit,
379825
+ targetNodeIds: agedOutRetainedNodes
379826
+ });
379827
+ this.env.tokenCalculator.garbageCollectCache(new Set(this.buffer.nodes.map((n2) => n2.id)));
379828
+ this.buffer = await this.orchestrator.executeTriggerSync("nodes_aged_out", this.buffer, agedOutRetainedNodes, protectedIds);
379829
+ }
379830
+ } else {
379831
+ this.lastTriggeredDeficit = 0;
379832
+ }
379833
+ if (agedOutNormalizedNodes.size > 0) {
379834
+ const targetDeficit = currentTokens - this.sidecar.config.budget.normalizedTokens;
379835
+ const threshold = this.sidecar.config.budget.coalescingThresholdTokens || 0;
379836
+ if (targetDeficit < this.lastTriggeredNormalizeDeficit) {
379837
+ this.lastTriggeredNormalizeDeficit = targetDeficit;
379838
+ }
379839
+ if (targetDeficit > this.lastTriggeredNormalizeDeficit + threshold) {
379840
+ this.lastTriggeredNormalizeDeficit = targetDeficit;
379841
+ this.eventBus.emitNormalizeNeeded({
379842
+ nodes: this.buffer.nodes,
379843
+ targetDeficit,
379844
+ targetNodeIds: agedOutNormalizedNodes
379845
+ });
379846
+ this.buffer = await this.orchestrator.executeTriggerSync("normalized_exceeded", this.buffer, agedOutNormalizedNodes, protectedIds);
379847
+ }
379848
+ } else {
379849
+ this.lastTriggeredNormalizeDeficit = 0;
379850
+ }
379851
+ }
379852
+ }
379853
+ getProtectedNodeIds(nodes, extraProtectedIds = /* @__PURE__ */ new Set()) {
379854
+ const protectionMap = /* @__PURE__ */ new Map();
379855
+ if (nodes.length === 0)
379856
+ return protectionMap;
379857
+ const lastNode = nodes[nodes.length - 1];
379858
+ const lastTurnId = lastNode.turnId;
379859
+ const envContextId = deriveStableId(["environment-context"]);
379860
+ const envContextTurnId = `turn_${envContextId}`;
379861
+ for (const node of nodes) {
379862
+ if (node.turnId === envContextTurnId || node.turnId === envContextId) {
379863
+ protectionMap.set(node.id, "environment_context");
379864
+ }
379865
+ if (node.turnId === lastTurnId) {
379866
+ protectionMap.set(node.id, "recent_turn");
379867
+ }
379868
+ }
379869
+ for (const id of extraProtectedIds) {
379870
+ protectionMap.set(id, "external_active_task");
379871
+ }
379872
+ return protectionMap;
379873
+ }
379767
379874
  async performHotStartCalibration(nodes, abortSignal) {
379768
379875
  const history = this.env.graphMapper.fromGraph(nodes);
379769
379876
  const contents = history.map((h3) => h3.content);
@@ -379783,9 +379890,6 @@ var init_contextManager = __esm({
379783
379890
  debugLogger.warn("[ContextManager] Hot start calibration failed", e3);
379784
379891
  }
379785
379892
  }
379786
- getEnvironment() {
379787
- return this.env;
379788
- }
379789
379893
  };
379790
379894
  }
379791
379895
  });
@@ -380686,7 +380790,7 @@ var init_client4 = __esm({
380686
380790
  if (this.currentSequenceModel) {
380687
380791
  return this.currentSequenceModel;
380688
380792
  }
380689
- return resolveModel(this.config.getActiveModel(), this.config.getGemini31LaunchedSync?.() ?? false, this.config.getGemini31FlashLiteLaunchedSync?.() ?? false, false, this.config.getHasAccessToPreviewModel?.() ?? true, this.config);
380793
+ return resolveModel(this.config.getActiveModel(), this.config.getGemini31LaunchedSync?.() ?? false, false, this.config.getHasAccessToPreviewModel?.() ?? true, this.config);
380690
380794
  }
380691
380795
  async *processTurn(request, signal, prompt_id, boundedTurns, displayContent) {
380692
380796
  let turn = new Turn(this.getChat(), prompt_id);
@@ -381919,6 +382023,9 @@ var init_scheduler = __esm({
381919
382023
  return false;
381920
382024
  }
381921
382025
  _isParallelizable(request) {
382026
+ if (request.name === UPDATE_TOPIC_TOOL_NAME) {
382027
+ return false;
382028
+ }
381922
382029
  if (request.args) {
381923
382030
  const wait = request.args["wait_for_previous"];
381924
382031
  if (typeof wait === "boolean") {
@@ -394580,13 +394687,12 @@ ${formattedHistory}
394580
394687
  const routerResponse = ClassifierResponseSchema.parse(jsonResponse);
394581
394688
  const reasoning = routerResponse.reasoning;
394582
394689
  const latencyMs = Date.now() - startTime;
394583
- const [useGemini3_1, useGemini3_1FlashLite, useCustomToolModel, hasAccessToPreview] = await Promise.all([
394690
+ const [useGemini3_1, useCustomToolModel, hasAccessToPreview] = await Promise.all([
394584
394691
  config3.getGemini31Launched(),
394585
- config3.getGemini31FlashLiteLaunched(),
394586
394692
  config3.getUseCustomToolModel(),
394587
- config3.getHasAccessToPreviewModel?.() ?? true
394693
+ config3.getHasAccessToPreviewModel()
394588
394694
  ]);
394589
- const selectedModel = resolveClassifierModel(context2.requestedModel ?? config3.getModel(), routerResponse.model_choice, useGemini3_1, useGemini3_1FlashLite, useCustomToolModel, hasAccessToPreview, config3);
394695
+ const selectedModel = resolveClassifierModel(context2.requestedModel ?? config3.getModel(), routerResponse.model_choice, useGemini3_1, useCustomToolModel, hasAccessToPreview, config3);
394590
394696
  return {
394591
394697
  model: selectedModel,
394592
394698
  metadata: {
@@ -394613,7 +394719,7 @@ var init_defaultStrategy = __esm({
394613
394719
  DefaultStrategy = class {
394614
394720
  name = "default";
394615
394721
  async route(_context, config3, _baseLlmClient, _localLiteRtLmClient) {
394616
- const defaultModel = resolveModel(config3.getModel(), config3.getGemini31LaunchedSync?.() ?? false, config3.getGemini31FlashLiteLaunchedSync?.() ?? false, false, config3.getHasAccessToPreviewModel?.() ?? true, config3);
394722
+ const defaultModel = resolveModel(config3.getModel(), config3.getGemini31LaunchedSync?.() ?? false, false, config3.getHasAccessToPreviewModel?.() ?? true, config3);
394617
394723
  return {
394618
394724
  model: defaultModel,
394619
394725
  metadata: {
@@ -394744,6 +394850,10 @@ Respond *only* in JSON format according to the following schema. Do not include
394744
394850
  if (await config3.getNumericalRoutingEnabled() && isGemini3Model(model, config3)) {
394745
394851
  return null;
394746
394852
  }
394853
+ if (isFunctionResponse(createUserContent(context2.request))) {
394854
+ debugLogger.log("[Routing] Bypassing Classifier: request is FunctionResponse.");
394855
+ return null;
394856
+ }
394747
394857
  const promptId = getPromptIdWithFallback("classifier-router");
394748
394858
  const historySlice = context2.history.slice(-HISTORY_SEARCH_WINDOW2);
394749
394859
  const cleanHistory = historySlice.filter((content) => !isFunctionCall(content) && !isFunctionResponse(content));
@@ -394760,12 +394870,11 @@ Respond *only* in JSON format according to the following schema. Do not include
394760
394870
  const routerResponse = ClassifierResponseSchema2.parse(jsonResponse);
394761
394871
  const reasoning = routerResponse.reasoning;
394762
394872
  const latencyMs = Date.now() - startTime;
394763
- const [useGemini3_1, useGemini3_1FlashLite, useCustomToolModel] = await Promise.all([
394873
+ const [useGemini3_1, useCustomToolModel] = await Promise.all([
394764
394874
  config3.getGemini31Launched(),
394765
- config3.getGemini31FlashLiteLaunched(),
394766
394875
  config3.getUseCustomToolModel()
394767
394876
  ]);
394768
- const selectedModel = normalizeModelId(resolveClassifierModel(normalizeModelId(model), routerResponse.model_choice, useGemini3_1, useGemini3_1FlashLite, useCustomToolModel, config3.getHasAccessToPreviewModel?.() ?? true, config3));
394877
+ const selectedModel = normalizeModelId(resolveClassifierModel(normalizeModelId(model), routerResponse.model_choice, useGemini3_1, useCustomToolModel, config3.getHasAccessToPreviewModel?.() ?? true, config3));
394769
394878
  const service = config3.getModelAvailabilityService();
394770
394879
  const snapshot = service.snapshot(selectedModel);
394771
394880
  if (!snapshot.available) {
@@ -394893,6 +395002,10 @@ Model: {"complexity_reasoning": "High-level architecture and strategic planning.
394893
395002
  }
394894
395003
  const finalHistory = firstTextIndex === -1 ? [] : candidateSlice.slice(firstTextIndex);
394895
395004
  const requestParts = Array.isArray(context2.request) ? context2.request : [context2.request];
395005
+ if (finalHistory.length === 0 && isFunctionResponse(createUserContent(context2.request))) {
395006
+ debugLogger.log("[Routing] Bypassing NumericalClassifier: request is FunctionResponse but history is empty after slicing.");
395007
+ return null;
395008
+ }
394896
395009
  const sanitizedRequest = requestParts.map((part) => {
394897
395010
  if (typeof part === "string") {
394898
395011
  return { text: part };
@@ -394914,12 +395027,11 @@ Model: {"complexity_reasoning": "High-level architecture and strategic planning.
394914
395027
  const routerResponse = ClassifierResponseSchema3.parse(jsonResponse);
394915
395028
  const score = routerResponse.complexity_score;
394916
395029
  const { threshold, groupLabel, modelAlias } = await this.getRoutingDecision(score, config3);
394917
- const [useGemini3_1, useGemini3_1FlashLite, useCustomToolModel] = await Promise.all([
395030
+ const [useGemini3_1, useCustomToolModel] = await Promise.all([
394918
395031
  config3.getGemini31Launched(),
394919
- config3.getGemini31FlashLiteLaunched(),
394920
395032
  config3.getUseCustomToolModel()
394921
395033
  ]);
394922
- const selectedModel = normalizeModelId(resolveClassifierModel(normalizeModelId(model), modelAlias, useGemini3_1, useGemini3_1FlashLite, useCustomToolModel, config3.getHasAccessToPreviewModel?.() ?? true, config3));
395034
+ const selectedModel = normalizeModelId(resolveClassifierModel(normalizeModelId(model), modelAlias, useGemini3_1, useCustomToolModel, config3.getHasAccessToPreviewModel?.() ?? true, config3));
394923
395035
  const service = config3.getModelAvailabilityService();
394924
395036
  const snapshot = service.snapshot(selectedModel);
394925
395037
  if (!snapshot.available) {
@@ -395029,7 +395141,7 @@ var init_fallbackStrategy = __esm({
395029
395141
  name = "fallback";
395030
395142
  async route(context2, config3, _baseLlmClient, _localLiteRtLmClient) {
395031
395143
  const requestedModel = context2.requestedModel ?? config3.getModel();
395032
- const resolvedModel = resolveModel(requestedModel, config3.getGemini31LaunchedSync?.() ?? false, config3.getGemini31FlashLiteLaunchedSync?.() ?? false, false, config3.getHasAccessToPreviewModel?.() ?? true, config3);
395144
+ const resolvedModel = resolveModel(requestedModel, config3.getGemini31LaunchedSync?.() ?? false, false, config3.getHasAccessToPreviewModel?.() ?? true, config3);
395033
395145
  const service = config3.getModelAvailabilityService();
395034
395146
  const snapshot = service.snapshot(resolvedModel);
395035
395147
  if (snapshot.available) {
@@ -395066,7 +395178,7 @@ var init_overrideStrategy = __esm({
395066
395178
  return null;
395067
395179
  }
395068
395180
  return {
395069
- model: resolveModel(overrideModel, config3.getGemini31LaunchedSync?.() ?? false, config3.getGemini31FlashLiteLaunchedSync?.() ?? false, false, config3.getHasAccessToPreviewModel?.() ?? true, config3),
395181
+ model: resolveModel(overrideModel, config3.getGemini31LaunchedSync?.() ?? false, false, config3.getHasAccessToPreviewModel?.() ?? true, config3),
395070
395182
  metadata: {
395071
395183
  source: this.name,
395072
395184
  latencyMs: 0,
@@ -395098,14 +395210,13 @@ var init_approvalModeStrategy = __esm({
395098
395210
  const startTime = Date.now();
395099
395211
  const approvalMode = config3.getApprovalMode();
395100
395212
  const approvedPlanPath = config3.getApprovedPlanPath();
395101
- const [useGemini3_1, useGemini3_1FlashLite, useCustomToolModel, hasAccessToPreview] = await Promise.all([
395213
+ const [useGemini3_1, useCustomToolModel, hasAccessToPreview] = await Promise.all([
395102
395214
  config3.getGemini31Launched(),
395103
- config3.getGemini31FlashLiteLaunched(),
395104
395215
  config3.getUseCustomToolModel(),
395105
395216
  config3.getHasAccessToPreviewModel()
395106
395217
  ]);
395107
395218
  if (approvalMode === ApprovalMode.PLAN) {
395108
- const proModel = resolveClassifierModel(model, GEMINI_MODEL_ALIAS_PRO, useGemini3_1, useGemini3_1FlashLite, useCustomToolModel, hasAccessToPreview, config3);
395219
+ const proModel = resolveClassifierModel(model, GEMINI_MODEL_ALIAS_PRO, useGemini3_1, useCustomToolModel, hasAccessToPreview, config3);
395109
395220
  return {
395110
395221
  model: proModel,
395111
395222
  metadata: {
@@ -395115,7 +395226,7 @@ var init_approvalModeStrategy = __esm({
395115
395226
  }
395116
395227
  };
395117
395228
  } else if (approvedPlanPath) {
395118
- const flashModel = resolveClassifierModel(model, GEMINI_MODEL_ALIAS_FLASH, useGemini3_1, useGemini3_1FlashLite, useCustomToolModel, hasAccessToPreview, config3);
395229
+ const flashModel = resolveClassifierModel(model, GEMINI_MODEL_ALIAS_FLASH, useGemini3_1, useCustomToolModel, hasAccessToPreview, config3);
395119
395230
  return {
395120
395231
  model: flashModel,
395121
395232
  metadata: {
@@ -395335,6 +395446,12 @@ var init_defaultModelConfigs = __esm({
395335
395446
  model: "gemini-2.5-flash-lite"
395336
395447
  }
395337
395448
  },
395449
+ "gemini-3.1-flash-lite": {
395450
+ extends: "chat-base-3",
395451
+ modelConfig: {
395452
+ model: "gemini-3.1-flash-lite"
395453
+ }
395454
+ },
395338
395455
  "gemma-4-31b-it": {
395339
395456
  extends: "chat-base-3",
395340
395457
  modelConfig: {
@@ -395363,7 +395480,7 @@ var init_defaultModelConfigs = __esm({
395363
395480
  classifier: {
395364
395481
  extends: "base",
395365
395482
  modelConfig: {
395366
- model: "gemini-2.5-flash-lite",
395483
+ model: "flash-lite",
395367
395484
  generateContentConfig: {
395368
395485
  maxOutputTokens: 1024,
395369
395486
  thinkingConfig: {
@@ -395375,7 +395492,7 @@ var init_defaultModelConfigs = __esm({
395375
395492
  "prompt-completion": {
395376
395493
  extends: "base",
395377
395494
  modelConfig: {
395378
- model: "gemini-2.5-flash-lite",
395495
+ model: "flash-lite",
395379
395496
  generateContentConfig: {
395380
395497
  temperature: 0.3,
395381
395498
  maxOutputTokens: 16e3,
@@ -395388,7 +395505,7 @@ var init_defaultModelConfigs = __esm({
395388
395505
  "fast-ack-helper": {
395389
395506
  extends: "base",
395390
395507
  modelConfig: {
395391
- model: "gemini-2.5-flash-lite",
395508
+ model: "flash-lite",
395392
395509
  generateContentConfig: {
395393
395510
  temperature: 0.2,
395394
395511
  maxOutputTokens: 120,
@@ -395401,7 +395518,7 @@ var init_defaultModelConfigs = __esm({
395401
395518
  "edit-corrector": {
395402
395519
  extends: "base",
395403
395520
  modelConfig: {
395404
- model: "gemini-2.5-flash-lite",
395521
+ model: "flash-lite",
395405
395522
  generateContentConfig: {
395406
395523
  thinkingConfig: {
395407
395524
  thinkingBudget: 0
@@ -395412,7 +395529,7 @@ var init_defaultModelConfigs = __esm({
395412
395529
  "summarizer-default": {
395413
395530
  extends: "base",
395414
395531
  modelConfig: {
395415
- model: "gemini-2.5-flash-lite",
395532
+ model: "flash-lite",
395416
395533
  generateContentConfig: {
395417
395534
  maxOutputTokens: 2e3
395418
395535
  }
@@ -395421,7 +395538,7 @@ var init_defaultModelConfigs = __esm({
395421
395538
  "summarizer-shell": {
395422
395539
  extends: "base",
395423
395540
  modelConfig: {
395424
- model: "gemini-2.5-flash-lite",
395541
+ model: "flash-lite",
395425
395542
  generateContentConfig: {
395426
395543
  maxOutputTokens: 2e3
395427
395544
  }
@@ -395491,7 +395608,7 @@ var init_defaultModelConfigs = __esm({
395491
395608
  },
395492
395609
  "chat-compression-3.1-flash-lite": {
395493
395610
  modelConfig: {
395494
- model: "gemini-3.1-flash-lite-preview"
395611
+ model: "gemini-3.1-flash-lite"
395495
395612
  }
395496
395613
  },
395497
395614
  "chat-compression-2.5-pro": {
@@ -395532,10 +395649,10 @@ var init_defaultModelConfigs = __esm({
395532
395649
  ],
395533
395650
  modelDefinitions: {
395534
395651
  // Concrete Models
395535
- "gemini-3.1-flash-lite-preview": {
395652
+ "gemini-3.1-flash-lite": {
395536
395653
  tier: "flash-lite",
395537
395654
  family: "gemini-3",
395538
- isPreview: true,
395655
+ isPreview: false,
395539
395656
  isVisible: true,
395540
395657
  features: { thinking: false, multimodalToolUse: true }
395541
395658
  },
@@ -395717,14 +395834,8 @@ var init_defaultModelConfigs = __esm({
395717
395834
  }
395718
395835
  ]
395719
395836
  },
395720
- "gemini-3.1-flash-lite-preview": {
395721
- default: "gemini-3.1-flash-lite-preview",
395722
- contexts: [
395723
- {
395724
- condition: { useGemini3_1FlashLite: false },
395725
- target: "gemini-2.5-flash-lite"
395726
- }
395727
- ]
395837
+ "gemini-3.1-flash-lite": {
395838
+ default: "gemini-3.1-flash-lite"
395728
395839
  },
395729
395840
  flash: {
395730
395841
  default: "gemini-3-flash-preview",
@@ -395736,13 +395847,7 @@ var init_defaultModelConfigs = __esm({
395736
395847
  ]
395737
395848
  },
395738
395849
  "flash-lite": {
395739
- default: "gemini-2.5-flash-lite",
395740
- contexts: [
395741
- {
395742
- condition: { useGemini3_1FlashLite: true },
395743
- target: "gemini-3.1-flash-lite-preview"
395744
- }
395745
- ]
395850
+ default: "gemini-3.1-flash-lite"
395746
395851
  },
395747
395852
  "auto-gemini-3": {
395748
395853
  default: "gemini-3-pro-preview",
@@ -395939,7 +396044,7 @@ var init_defaultModelConfigs = __esm({
395939
396044
  ],
395940
396045
  lite: [
395941
396046
  {
395942
- model: "gemini-2.5-flash-lite",
396047
+ model: "flash-lite",
395943
396048
  actions: {
395944
396049
  terminal: "silent",
395945
396050
  transient: "silent",
@@ -399234,7 +399339,6 @@ var init_flagNames = __esm({
399234
399339
  MASKING_PROTECT_LATEST_TURN: 45758819,
399235
399340
  GEMINI_3_1_PRO_LAUNCHED: 45760185,
399236
399341
  PRO_MODEL_NO_ACCESS: 45768879,
399237
- GEMINI_3_1_FLASH_LITE_LAUNCHED: 45771641,
399238
399342
  DEFAULT_REQUEST_TIMEOUT: 45773134
399239
399343
  };
399240
399344
  }
@@ -410303,7 +410407,7 @@ var init_config4 = __esm({
410303
410407
  if (!isAutoModel(model, this)) {
410304
410408
  return {};
410305
410409
  }
410306
- const primaryModel = resolveModel(model, this.getGemini31LaunchedSync(), this.getGemini31FlashLiteLaunchedSync(), this.getUseCustomToolModelSync(), this.getHasAccessToPreviewModel(), this);
410410
+ const primaryModel = resolveModel(model, this.getGemini31LaunchedSync(), this.getUseCustomToolModelSync(), this.getHasAccessToPreviewModel(), this);
410307
410411
  const isPreview = isPreviewModel(primaryModel, this);
410308
410412
  const proModel = primaryModel;
410309
410413
  const flashModel = isPreview ? PREVIEW_GEMINI_FLASH_MODEL : DEFAULT_GEMINI_FLASH_MODEL;
@@ -410324,7 +410428,7 @@ var init_config4 = __esm({
410324
410428
  if (pooled.remaining !== void 0) {
410325
410429
  return pooled.remaining;
410326
410430
  }
410327
- const primaryModel = resolveModel(this.getModel(), this.getGemini31LaunchedSync(), this.getGemini31FlashLiteLaunchedSync(), this.getUseCustomToolModelSync(), this.getHasAccessToPreviewModel(), this);
410431
+ const primaryModel = resolveModel(this.getModel(), this.getGemini31LaunchedSync(), this.getUseCustomToolModelSync(), this.getHasAccessToPreviewModel(), this);
410328
410432
  return this.modelQuotas.get(primaryModel)?.remaining;
410329
410433
  }
410330
410434
  getQuotaLimit() {
@@ -410332,7 +410436,7 @@ var init_config4 = __esm({
410332
410436
  if (pooled.limit !== void 0) {
410333
410437
  return pooled.limit;
410334
410438
  }
410335
- const primaryModel = resolveModel(this.getModel(), this.getGemini31LaunchedSync(), this.getGemini31FlashLiteLaunchedSync(), this.getUseCustomToolModelSync(), this.getHasAccessToPreviewModel(), this);
410439
+ const primaryModel = resolveModel(this.getModel(), this.getGemini31LaunchedSync(), this.getUseCustomToolModelSync(), this.getHasAccessToPreviewModel(), this);
410336
410440
  return this.modelQuotas.get(primaryModel)?.limit;
410337
410441
  }
410338
410442
  getQuotaResetTime() {
@@ -410340,7 +410444,7 @@ var init_config4 = __esm({
410340
410444
  if (pooled.resetTime !== void 0) {
410341
410445
  return pooled.resetTime;
410342
410446
  }
410343
- const primaryModel = resolveModel(this.getModel(), this.getGemini31LaunchedSync(), this.getGemini31FlashLiteLaunchedSync(), this.getUseCustomToolModelSync(), this.getHasAccessToPreviewModel(), this);
410447
+ const primaryModel = resolveModel(this.getModel(), this.getGemini31LaunchedSync(), this.getUseCustomToolModelSync(), this.getHasAccessToPreviewModel(), this);
410344
410448
  return this.modelQuotas.get(primaryModel)?.resetTime;
410345
410449
  }
410346
410450
  getEmbeddingModel() {
@@ -411303,14 +411407,6 @@ ${sections.join("\n")}
411303
411407
  await this.ensureExperimentsLoaded();
411304
411408
  return this.getGemini31LaunchedSync();
411305
411409
  }
411306
- /**
411307
- * Returns whether Gemini 3.1 Flash Lite has been launched.
411308
- * This method is async and ensures that experiments are loaded before returning the result.
411309
- */
411310
- async getGemini31FlashLiteLaunched() {
411311
- await this.ensureExperimentsLoaded();
411312
- return this.getGemini31FlashLiteLaunchedSync();
411313
- }
411314
411410
  /**
411315
411411
  * Returns whether the custom tool model should be used.
411316
411412
  */
@@ -411359,20 +411455,6 @@ ${sections.join("\n")}
411359
411455
  }
411360
411456
  return void 0;
411361
411457
  }
411362
- /**
411363
- * Returns whether Gemini 3.1 Flash Lite has been launched.
411364
- *
411365
- * Note: This method should only be called after startup, once experiments have been loaded.
411366
- * If you need to call this during startup or from an async context, use
411367
- * getGemini31FlashLiteLaunched instead.
411368
- */
411369
- getGemini31FlashLiteLaunchedSync() {
411370
- const authType = this.contentGeneratorConfig?.authType;
411371
- if (this.isGemini31LaunchedForAuthType(authType)) {
411372
- return true;
411373
- }
411374
- return this.experiments?.flags[ExperimentFlags.GEMINI_3_1_FLASH_LITE_LAUNCHED]?.boolValue ?? false;
411375
- }
411376
411458
  /**
411377
411459
  * Returns the client version.
411378
411460
  */
@@ -433887,6 +433969,7 @@ var Task4 = class _Task {
433887
433969
  currentAgentMessageId = v4_default2();
433888
433970
  promptCount = 0;
433889
433971
  autoExecute;
433972
+ usageMetadata;
433890
433973
  get isYoloMatch() {
433891
433974
  return this.autoExecute || this.config.getApprovalMode() === ApprovalMode.YOLO;
433892
433975
  }
@@ -434034,6 +434117,9 @@ var Task4 = class _Task {
434034
434117
  if (traceId) {
434035
434118
  metadata2.traceId = traceId;
434036
434119
  }
434120
+ if (final && this.usageMetadata) {
434121
+ metadata2.usageMetadata = this.usageMetadata;
434122
+ }
434037
434123
  return {
434038
434124
  kind: "status-update",
434039
434125
  taskId: this.id,
@@ -434439,8 +434525,12 @@ var Task4 = class _Task {
434439
434525
  break;
434440
434526
  case GeminiEventType.Finished:
434441
434527
  logger.info(`[Task ${this.id}] Agent finished its turn.`);
434528
+ if (event.value && typeof event.value === "object" && "usageMetadata" in event.value) {
434529
+ this.usageMetadata = event.value.usageMetadata;
434530
+ }
434442
434531
  break;
434443
434532
  case GeminiEventType.ModelInfo:
434533
+ this.usageMetadata = void 0;
434444
434534
  this.modelInfo = event.value;
434445
434535
  break;
434446
434536
  case GeminiEventType.Retry: