mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-19 09:33:53 +00:00
sync gemini-cli 0.1.17
Co-Authored-By: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
@@ -12,9 +12,11 @@ import { readStdin } from './utils/readStdin.js';
|
||||
import { basename } from 'node:path';
|
||||
import v8 from 'node:v8';
|
||||
import os from 'node:os';
|
||||
import dns from 'node:dns';
|
||||
import { spawn } from 'node:child_process';
|
||||
import { start_sandbox } from './utils/sandbox.js';
|
||||
import {
|
||||
DnsResolutionOrder,
|
||||
LoadedSettings,
|
||||
loadSettings,
|
||||
SettingScope,
|
||||
@@ -40,8 +42,27 @@ import {
|
||||
import { validateAuthMethod } from './config/auth.js';
|
||||
import { setMaxSizedBoxDebugging } from './ui/components/shared/MaxSizedBox.js';
|
||||
import { validateNonInteractiveAuth } from './validateNonInterActiveAuth.js';
|
||||
import { checkForUpdates } from './ui/utils/updateCheck.js';
|
||||
import { handleAutoUpdate } from './utils/handleAutoUpdate.js';
|
||||
import { appEvents, AppEvent } from './utils/events.js';
|
||||
|
||||
export function validateDnsResolutionOrder(
|
||||
order: string | undefined,
|
||||
): DnsResolutionOrder {
|
||||
const defaultValue: DnsResolutionOrder = 'ipv4first';
|
||||
if (order === undefined) {
|
||||
return defaultValue;
|
||||
}
|
||||
if (order === 'ipv4first' || order === 'verbatim') {
|
||||
return order;
|
||||
}
|
||||
// We don't want to throw here, just warn and use the default.
|
||||
console.warn(
|
||||
`Invalid value for dnsResolutionOrder in settings: "${order}". Using default "${defaultValue}".`,
|
||||
);
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
function getNodeMemoryArgs(config: Config): string[] {
|
||||
const totalMemoryMB = os.totalmem() / (1024 * 1024);
|
||||
const heapStats = v8.getHeapStatistics();
|
||||
@@ -136,6 +157,10 @@ export async function main() {
|
||||
argv,
|
||||
);
|
||||
|
||||
dns.setDefaultResultOrder(
|
||||
validateDnsResolutionOrder(settings.merged.dnsResolutionOrder),
|
||||
);
|
||||
|
||||
if (argv.promptInteractive && !process.stdin.isTTY) {
|
||||
console.error(
|
||||
'Error: The --prompt-interactive flag is not supported when piping input from stdin.',
|
||||
@@ -184,7 +209,10 @@ export async function main() {
|
||||
: [];
|
||||
const sandboxConfig = config.getSandbox();
|
||||
if (sandboxConfig) {
|
||||
if (settings.merged.selectedAuthType) {
|
||||
if (
|
||||
settings.merged.selectedAuthType &&
|
||||
!settings.merged.useExternalAuth
|
||||
) {
|
||||
// Validate authentication here because the sandbox will interfere with the Oauth2 web redirect.
|
||||
try {
|
||||
const err = validateAuthMethod(settings.merged.selectedAuthType);
|
||||
@@ -197,7 +225,7 @@ export async function main() {
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
await start_sandbox(sandboxConfig, memoryArgs);
|
||||
await start_sandbox(sandboxConfig, memoryArgs, config);
|
||||
process.exit(0);
|
||||
} else {
|
||||
// Not in a sandbox and not entering one, so relaunch with additional
|
||||
@@ -246,6 +274,17 @@ export async function main() {
|
||||
{ exitOnCtrlC: false },
|
||||
);
|
||||
|
||||
checkForUpdates()
|
||||
.then((info) => {
|
||||
handleAutoUpdate(info, settings, config.getProjectRoot());
|
||||
})
|
||||
.catch((err) => {
|
||||
// Silently ignore update check errors.
|
||||
if (config.getDebugMode()) {
|
||||
console.error('Update check failed:', err);
|
||||
}
|
||||
});
|
||||
|
||||
registerCleanup(() => instance.unmount());
|
||||
return;
|
||||
}
|
||||
@@ -331,6 +370,7 @@ async function loadNonInteractiveConfig(
|
||||
|
||||
return await validateNonInteractiveAuth(
|
||||
settings.merged.selectedAuthType,
|
||||
settings.merged.useExternalAuth,
|
||||
finalConfig,
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user