Sync upstream Gemini-CLI v0.8.2 (#838)

This commit is contained in:
tanzhenxin
2025-10-23 09:27:04 +08:00
committed by GitHub
parent 096fabb5d6
commit eb95c131be
644 changed files with 70389 additions and 23709 deletions

View File

@@ -44,4 +44,7 @@ export class AcpFileSystemService implements FileSystemService {
sessionId: this.sessionId,
});
}
findFiles(fileName: string, searchPaths: readonly string[]): string[] {
return this.fallback.findFiles(fileName, searchPaths);
}
}

View File

@@ -18,28 +18,44 @@ import {
clearCachedCredentialFile,
convertToFunctionResponse,
DiscoveredMCPTool,
getErrorMessage,
getErrorStatus,
isNodeError,
isWithinRoot,
logToolCall,
MCPServerConfig,
StreamEventType,
DEFAULT_GEMINI_MODEL,
DEFAULT_GEMINI_MODEL_AUTO,
DEFAULT_GEMINI_FLASH_MODEL,
MCPServerConfig,
ToolConfirmationOutcome,
logToolCall,
getErrorStatus,
isWithinRoot,
isNodeError,
} from '@qwen-code/qwen-code-core';
import * as fs from 'node:fs/promises';
import * as path from 'node:path';
import { Readable, Writable } from 'node:stream';
import { z } from 'zod';
import type { LoadedSettings } from '../config/settings.js';
import { SettingScope } from '../config/settings.js';
import * as acp from './acp.js';
import { AcpFileSystemService } from './fileSystemService.js';
import { Readable, Writable } from 'node:stream';
import type { LoadedSettings } from '../config/settings.js';
import { SettingScope } from '../config/settings.js';
import * as fs from 'node:fs/promises';
import * as path from 'node:path';
import { z } from 'zod';
import { randomUUID } from 'node:crypto';
import { getErrorMessage } from '../utils/errors.js';
import { ExtensionStorage, type Extension } from '../config/extension.js';
import type { CliArgs } from '../config/config.js';
import { loadCliConfig } from '../config/config.js';
import type { Extension } from '../config/extension.js';
import { ExtensionEnablementManager } from '../config/extensions/extensionEnablement.js';
/**
* Resolves the model to use based on the current configuration.
*
* If the model is set to "auto", it will use the flash model if in fallback
* mode, otherwise it will use the default model.
*/
export function resolveModel(model: string, isInFallbackMode: boolean): string {
if (model === DEFAULT_GEMINI_MODEL_AUTO) {
return isInFallbackMode ? DEFAULT_GEMINI_FLASH_MODEL : DEFAULT_GEMINI_MODEL;
}
return model;
}
export async function runZedIntegration(
config: Config,
@@ -184,6 +200,10 @@ class GeminiAgent {
const config = await loadCliConfig(
settings,
this.extensions,
new ExtensionEnablementManager(
ExtensionStorage.getUserExtensionsDir(),
this.argv.extensions,
),
sessionId,
this.argv,
cwd,
@@ -251,6 +271,7 @@ class Session {
try {
const responseStream = await chat.sendMessageStream(
resolveModel(this.config.getModel(), this.config.isInFallbackMode()),
{
message: nextMessage?.parts ?? [],
config: {
@@ -879,14 +900,16 @@ function toToolCallContent(toolResult: ToolResult): acp.ToolCallContent | null {
type: 'content',
content: { type: 'text', text: planText },
};
} else if ('fileDiff' in toolResult.returnDisplay) {
// Handle FileDiff
return {
type: 'diff',
path: toolResult.returnDisplay.fileName,
oldText: toolResult.returnDisplay.originalContent,
newText: toolResult.returnDisplay.newContent,
};
} else {
if ('fileName' in toolResult.returnDisplay) {
return {
type: 'diff',
path: toolResult.returnDisplay.fileName,
oldText: toolResult.returnDisplay.originalContent,
newText: toolResult.returnDisplay.newContent,
};
}
return null;
}
}
return null;