@google/gemini-cli-a2a-server 0.57.0-preview.0 → 0.57.0-preview.1

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.
@@ -220988,8 +220988,8 @@ var GIT_COMMIT_INFO, CLI_VERSION;
220988
220988
  var init_git_commit = __esm({
220989
220989
  "packages/core/dist/src/generated/git-commit.js"() {
220990
220990
  "use strict";
220991
- GIT_COMMIT_INFO = "eaa30429a";
220992
- CLI_VERSION = "0.57.0-preview.0";
220991
+ GIT_COMMIT_INFO = "3910b2093";
220992
+ CLI_VERSION = "0.57.0-preview.1";
220993
220993
  }
220994
220994
  });
220995
220995
 
@@ -336720,7 +336720,7 @@ function getVersion() {
336720
336720
  }
336721
336721
  versionPromise = (async () => {
336722
336722
  const pkgJson = await getPackageJson(__dirname4);
336723
- return "0.57.0-preview.0";
336723
+ return "0.57.0-preview.1";
336724
336724
  })();
336725
336725
  return versionPromise;
336726
336726
  }
@@ -339243,8 +339243,8 @@ function getErrorReplaceResult(params, occurrences, finalOldString, finalNewStri
339243
339243
  let error2 = void 0;
339244
339244
  if (occurrences === 0) {
339245
339245
  error2 = {
339246
- display: `Failed to edit, could not find the string to replace.`,
339247
- raw: `Failed to edit, 0 occurrences found for old_string in ${params.file_path}. Ensure you're not escaping content incorrectly and check whitespace, indentation, and context. Use ${READ_FILE_TOOL_NAME} tool to verify.`,
339246
+ display: `Could not find an exact match for old_string in '${params.file_path}'.`,
339247
+ raw: `Could not find an exact match for 'old_string' in '${params.file_path}'. If previous edits modified the file or you are modifying lines outside your recent read window, please use ReadFile to inspect the target lines before retrying with an exact 'old_string'.`,
339248
339248
  type: ToolErrorType.EDIT_NO_OCCURRENCE_FOUND
339249
339249
  };
339250
339250
  } else if (!params.allow_multiple && occurrences !== 1) {
@@ -339447,6 +339447,20 @@ var init_edit = __esm({
339447
339447
  };
339448
339448
  }
339449
339449
  async attemptSelfCorrection(params, currentContent, initialError, abortSignal, originalLineEnding) {
339450
+ if (!params.old_string || params.old_string.trim() === "") {
339451
+ return {
339452
+ currentContent,
339453
+ newContent: currentContent,
339454
+ occurrences: 0,
339455
+ isNewFile: false,
339456
+ error: {
339457
+ display: "Edit failed: 'old_string' cannot be empty.",
339458
+ raw: "The 'old_string' parameter is required. The Edit tool performs localized search-and-replace. If you are modifying a section of the file you have not viewed recently, call ReadFile on the target line range to inspect the current code, then provide the exact matching lines in 'old_string'.",
339459
+ type: ToolErrorType.INVALID_TOOL_PARAMS
339460
+ },
339461
+ originalLineEnding
339462
+ };
339463
+ }
339450
339464
  let errorForLlmEditFixer = initialError.raw;
339451
339465
  let contentForLlmEditFixer = currentContent;
339452
339466
  const initialContentHash = hashContent(currentContent);
@@ -339785,7 +339799,7 @@ ${snippet2}`);
339785
339799
  llmSuccessMessageParts.push(fuzzyFeedback);
339786
339800
  }
339787
339801
  if (this.params.modified_by_user) {
339788
- llmSuccessMessageParts.push(`User modified the \`new_string\` content to be: ${this.params.new_string}.`);
339802
+ llmSuccessMessageParts.push(`The confirmation step modified the \`new_string\` content to be: ${this.params.new_string}.`);
339789
339803
  }
339790
339804
  const jitContext = await discoverJitContext(this.config, this.resolvedPath);
339791
339805
  let llmContent = llmSuccessMessageParts.join(" ");
@@ -366341,6 +366355,44 @@ function extractCuratedHistory2(comprehensiveHistory) {
366341
366355
  }
366342
366356
  return curatedHistory;
366343
366357
  }
366358
+ function applyRetryNudge(contents, nudgeMessage) {
366359
+ if (!nudgeMessage) {
366360
+ return contents;
366361
+ }
366362
+ const lastTurn = contents[contents.length - 1];
366363
+ const hasNudge = lastTurn?.parts?.some((p2) => p2.text?.includes(nudgeMessage));
366364
+ if (hasNudge) {
366365
+ return contents;
366366
+ }
366367
+ const cloned = contents.map((c2) => ({
366368
+ ...c2,
366369
+ parts: c2.parts ? [...c2.parts] : []
366370
+ }));
366371
+ const clonedLastTurn = cloned[cloned.length - 1];
366372
+ const hasFunctionResponse = clonedLastTurn?.parts?.some((p2) => p2.functionResponse);
366373
+ if (clonedLastTurn?.role === "user" && hasFunctionResponse) {
366374
+ cloned.push({
366375
+ role: "model",
366376
+ parts: [{ text: "[Tool execution completed.]" }]
366377
+ });
366378
+ cloned.push({
366379
+ role: "user",
366380
+ parts: [{ text: nudgeMessage }]
366381
+ });
366382
+ } else if (clonedLastTurn?.role === "user") {
366383
+ if (!clonedLastTurn.parts) {
366384
+ clonedLastTurn.parts = [];
366385
+ }
366386
+ clonedLastTurn.parts.push({ text: `
366387
+ ${nudgeMessage}` });
366388
+ } else {
366389
+ cloned.push({
366390
+ role: "user",
366391
+ parts: [{ text: nudgeMessage }]
366392
+ });
366393
+ }
366394
+ return cloned;
366395
+ }
366344
366396
  function isSchemaDepthError(errorMessage) {
366345
366397
  return errorMessage.includes("maximum schema depth exceeded");
366346
366398
  }
@@ -366348,9 +366400,8 @@ function isInvalidArgumentError(errorMessage) {
366348
366400
  return errorMessage.includes("Request contains an invalid argument");
366349
366401
  }
366350
366402
  function stripToolCallIdPrefixes(contents) {
366351
- return contents.map((content) => ({
366352
- ...content,
366353
- parts: (content.parts || []).map((part) => {
366403
+ return contents.map((content) => {
366404
+ const parts2 = (content.parts || []).map((part) => {
366354
366405
  const newPart = { ...part };
366355
366406
  if (newPart.functionCall) {
366356
366407
  const fc = newPart.functionCall;
@@ -366374,9 +366425,23 @@ function stripToolCallIdPrefixes(contents) {
366374
366425
  };
366375
366426
  }
366376
366427
  }
366428
+ const hasOtherKeys = Object.keys(newPart).some((key) => key !== "text" && key !== "thought" && key !== "callIndex" && newPart[key] !== void 0);
366429
+ if (newPart.text !== void 0 && newPart.text === "" && hasOtherKeys) {
366430
+ delete newPart.text;
366431
+ }
366377
366432
  return newPart;
366378
- })
366379
- }));
366433
+ }).filter((part) => {
366434
+ const hasOtherKeys = Object.keys(part).some((key) => key !== "text" && key !== "thought" && key !== "callIndex" && part[key] !== void 0);
366435
+ if (part.text !== void 0 && part.text === "" && !hasOtherKeys) {
366436
+ return false;
366437
+ }
366438
+ return true;
366439
+ });
366440
+ return {
366441
+ ...content,
366442
+ parts: parts2
366443
+ };
366444
+ });
366380
366445
  }
366381
366446
  function coalesceConsecutiveRoles(history) {
366382
366447
  const result2 = [];
@@ -366431,7 +366496,7 @@ function stripThoughts2(history) {
366431
366496
  };
366432
366497
  }).filter((turn) => !turn.content.parts || turn.content.parts.length > 0);
366433
366498
  }
366434
- var StreamEventType, MID_STREAM_RETRY_OPTIONS, SYNTHETIC_THOUGHT_SIGNATURE2, INTERRUPTED_RESPONSE_PLACEHOLDER, InvalidStreamError, AgentExecutionStoppedError, AgentExecutionBlockedError, GeminiChat;
366499
+ var StreamEventType, MID_STREAM_RETRY_OPTIONS, SYNTHETIC_THOUGHT_SIGNATURE2, INTERRUPTED_RESPONSE_PLACEHOLDER, THINKING_ONLY_NUDGE_MESSAGE, NO_RESPONSE_TEXT_NUDGE_MESSAGE, InvalidStreamError, AgentExecutionStoppedError, AgentExecutionBlockedError, GeminiChat;
366435
366500
  var init_geminiChat = __esm({
366436
366501
  "packages/core/dist/src/core/geminiChat.js"() {
366437
366502
  "use strict";
@@ -366468,6 +366533,8 @@ var init_geminiChat = __esm({
366468
366533
  };
366469
366534
  SYNTHETIC_THOUGHT_SIGNATURE2 = "skip_thought_signature_validator";
366470
366535
  INTERRUPTED_RESPONSE_PLACEHOLDER = "[The previous response was interrupted before it completed.]";
366536
+ THINKING_ONLY_NUDGE_MESSAGE = "[System: You previously generated thoughts but failed to provide a final user-facing response. Please ensure you provide your final answer or call a tool now.]";
366537
+ NO_RESPONSE_TEXT_NUDGE_MESSAGE = "[System: You previously returned an empty response with no text or thoughts. Please ensure you provide your final answer or call a tool now.]";
366471
366538
  InvalidStreamError = class extends Error {
366472
366539
  type;
366473
366540
  constructor(message, type2) {
@@ -366856,23 +366923,19 @@ var init_geminiChat = __esm({
366856
366923
  tools: this.tools,
366857
366924
  abortSignal
366858
366925
  };
366926
+ let nudgeMessage = "";
366859
366927
  if (modelConfigKey.isRetry && modelConfigKey.lastStreamError instanceof InvalidStreamError) {
366860
366928
  const lastError = modelConfigKey.lastStreamError;
366861
- let nudgeMessage = "";
366862
366929
  if (lastError.type === "THINKING_ONLY_RESPONSE") {
366863
- nudgeMessage = "\n[System: You previously generated thoughts but failed to provide a final user-facing response. Please ensure you provide your final answer or call a tool now.]";
366930
+ nudgeMessage = THINKING_ONLY_NUDGE_MESSAGE;
366864
366931
  } else if (lastError.type === "NO_RESPONSE_TEXT") {
366865
- nudgeMessage = "\n[System: You previously returned an empty response with no text or thoughts. Please ensure you provide your final answer or call a tool now.]";
366866
- }
366867
- if (nudgeMessage) {
366868
- if (typeof config2.systemInstruction === "string") {
366869
- config2.systemInstruction += nudgeMessage;
366870
- } else if (config2.systemInstruction === void 0) {
366871
- config2.systemInstruction = nudgeMessage;
366872
- }
366932
+ nudgeMessage = NO_RESPONSE_TEXT_NUDGE_MESSAGE;
366873
366933
  }
366874
366934
  }
366875
366935
  let contentsToUse = supportsModernFeatures(modelToUse) || isGemini2Model(modelToUse) ? [...contentsForPreviewModel] : [...requestContents];
366936
+ if (nudgeMessage) {
366937
+ contentsToUse = applyRetryNudge(contentsToUse, nudgeMessage);
366938
+ }
366876
366939
  const hookSystem = this.context.config.getHookSystem();
366877
366940
  if (hookSystem) {
366878
366941
  const beforeModelResult = await hookSystem.fireBeforeModelEvent({
@@ -366896,12 +366959,18 @@ var init_geminiChat = __esm({
366896
366959
  modelToUse = resolveModel(beforeModelResult.modifiedModel, useGemini3_1, false, hasAccessToPreview, this.context.config, this.context.config.hasGemini35FlashGAAccess?.() ?? false);
366897
366960
  lastModelToUse = modelToUse;
366898
366961
  contentsToUse = supportsModernFeatures(modelToUse) || isGemini2Model(modelToUse) ? [...contentsForPreviewModel] : [...requestContents];
366962
+ if (nudgeMessage) {
366963
+ contentsToUse = applyRetryNudge(contentsToUse, nudgeMessage);
366964
+ }
366899
366965
  }
366900
366966
  if (beforeModelResult.modifiedConfig) {
366901
366967
  Object.assign(config2, beforeModelResult.modifiedConfig);
366902
366968
  }
366903
366969
  if (beforeModelResult.modifiedContents && Array.isArray(beforeModelResult.modifiedContents)) {
366904
366970
  contentsToUse = beforeModelResult.modifiedContents;
366971
+ if (nudgeMessage) {
366972
+ contentsToUse = applyRetryNudge(contentsToUse, nudgeMessage);
366973
+ }
366905
366974
  }
366906
366975
  const toolSelectionResult = await hookSystem.fireBeforeToolSelectionEvent({
366907
366976
  model: modelToUse,