mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-04-29 20:20:57 +00:00
merge main
This commit is contained in:
commit
6f914e4f4e
228 changed files with 28059 additions and 2618 deletions
|
|
@ -33,6 +33,7 @@ import {
|
|||
} from '@qwen-code/qwen-code-core';
|
||||
import { extensionsCommand } from '../commands/extensions.js';
|
||||
import { hooksCommand } from '../commands/hooks.js';
|
||||
import { authCommand } from '../commands/auth.js';
|
||||
import type { Settings } from './settings.js';
|
||||
import {
|
||||
resolveCliGenerationConfig,
|
||||
|
|
@ -51,16 +52,16 @@ import { appEvents } from '../utils/events.js';
|
|||
import { mcpCommand } from '../commands/mcp.js';
|
||||
|
||||
// UUID v4 regex pattern for validation
|
||||
const UUID_REGEX =
|
||||
/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
||||
const SESSION_ID_REGEX =
|
||||
/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}(-agent-[a-zA-Z0-9_.-]+)?$/i;
|
||||
|
||||
/**
|
||||
* Validates if a string is a valid UUID format
|
||||
* @param value - The string to validate
|
||||
* @returns True if the string is a valid UUID, false otherwise
|
||||
* Validates if a string is a valid session ID format.
|
||||
* Accepts a standard UUID, or a UUID followed by `-agent-{suffix}`
|
||||
* (used by Arena to give each agent a deterministic session ID).
|
||||
*/
|
||||
function isValidUUID(value: string): boolean {
|
||||
return UUID_REGEX.test(value);
|
||||
function isValidSessionId(value: string): boolean {
|
||||
return SESSION_ID_REGEX.test(value);
|
||||
}
|
||||
|
||||
import { isWorkspaceTrusted } from './trustedFolders.js';
|
||||
|
|
@ -568,10 +569,13 @@ export async function parseArguments(): Promise<CliArgs> {
|
|||
if (argv['sessionId'] && (argv['continue'] || argv['resume'])) {
|
||||
return 'Cannot use --session-id with --continue or --resume. Use --session-id to start a new session with a specific ID, or use --continue/--resume to resume an existing session.';
|
||||
}
|
||||
if (argv['sessionId'] && !isValidUUID(argv['sessionId'] as string)) {
|
||||
if (
|
||||
argv['sessionId'] &&
|
||||
!isValidSessionId(argv['sessionId'] as string)
|
||||
) {
|
||||
return `Invalid --session-id: "${argv['sessionId']}". Must be a valid UUID (e.g., "123e4567-e89b-12d3-a456-426614174000").`;
|
||||
}
|
||||
if (argv['resume'] && !isValidUUID(argv['resume'] as string)) {
|
||||
if (argv['resume'] && !isValidSessionId(argv['resume'] as string)) {
|
||||
return `Invalid --resume: "${argv['resume']}". Must be a valid UUID (e.g., "123e4567-e89b-12d3-a456-426614174000").`;
|
||||
}
|
||||
return true;
|
||||
|
|
@ -581,6 +585,8 @@ export async function parseArguments(): Promise<CliArgs> {
|
|||
.command(mcpCommand)
|
||||
// Register Extension subcommands
|
||||
.command(extensionsCommand)
|
||||
// Register Auth subcommands
|
||||
.command(authCommand)
|
||||
// Register Hooks subcommands
|
||||
.command(hooksCommand);
|
||||
|
||||
|
|
@ -1058,6 +1064,18 @@ export async function loadCliConfig(
|
|||
lsp: {
|
||||
enabled: lspEnabled,
|
||||
},
|
||||
agents: settings.agents
|
||||
? {
|
||||
displayMode: settings.agents.displayMode,
|
||||
arena: settings.agents.arena
|
||||
? {
|
||||
worktreeBaseDir: settings.agents.arena.worktreeBaseDir,
|
||||
preserveArtifacts:
|
||||
settings.agents.arena.preserveArtifacts ?? false,
|
||||
}
|
||||
: undefined,
|
||||
}
|
||||
: undefined,
|
||||
});
|
||||
|
||||
if (lspEnabled) {
|
||||
|
|
|
|||
|
|
@ -1244,6 +1244,104 @@ const SETTINGS_SCHEMA = {
|
|||
description: 'Configuration for web search providers.',
|
||||
showInDialog: false,
|
||||
},
|
||||
agents: {
|
||||
type: 'object',
|
||||
label: 'Agents',
|
||||
category: 'Advanced',
|
||||
requiresRestart: false,
|
||||
default: {},
|
||||
description:
|
||||
'Settings for multi-agent collaboration features (Arena, Team, Swarm).',
|
||||
showInDialog: false,
|
||||
properties: {
|
||||
displayMode: {
|
||||
type: 'enum',
|
||||
label: 'Display Mode',
|
||||
category: 'Advanced',
|
||||
requiresRestart: false,
|
||||
default: undefined as string | undefined,
|
||||
description:
|
||||
'Display mode for multi-agent sessions. Currently only "in-process" is supported.',
|
||||
showInDialog: false,
|
||||
options: [
|
||||
{ value: 'in-process', label: 'In-process' },
|
||||
// { value: 'tmux', label: 'tmux' },
|
||||
// { value: 'iterm2', label: 'iTerm2' },
|
||||
],
|
||||
},
|
||||
arena: {
|
||||
type: 'object',
|
||||
label: 'Arena',
|
||||
category: 'Advanced',
|
||||
requiresRestart: false,
|
||||
default: {},
|
||||
description: 'Settings for Arena (multi-model competitive execution).',
|
||||
showInDialog: false,
|
||||
properties: {
|
||||
worktreeBaseDir: {
|
||||
type: 'string',
|
||||
label: 'Worktree Base Directory',
|
||||
category: 'Advanced',
|
||||
requiresRestart: true,
|
||||
default: undefined as string | undefined,
|
||||
description:
|
||||
'Custom base directory for Arena worktrees. Defaults to ~/.qwen/arena.',
|
||||
showInDialog: false,
|
||||
},
|
||||
preserveArtifacts: {
|
||||
type: 'boolean',
|
||||
label: 'Preserve Arena Artifacts',
|
||||
category: 'Advanced',
|
||||
requiresRestart: false,
|
||||
default: false,
|
||||
description:
|
||||
'When enabled, Arena worktrees and session state files are preserved after the session ends or the main agent exits.',
|
||||
showInDialog: true,
|
||||
},
|
||||
maxRoundsPerAgent: {
|
||||
type: 'number',
|
||||
label: 'Max Rounds Per Agent',
|
||||
category: 'Advanced',
|
||||
requiresRestart: false,
|
||||
default: undefined as number | undefined,
|
||||
description:
|
||||
'Maximum number of rounds (turns) each agent can execute. No limit if unset.',
|
||||
showInDialog: false,
|
||||
},
|
||||
timeoutSeconds: {
|
||||
type: 'number',
|
||||
label: 'Timeout (seconds)',
|
||||
category: 'Advanced',
|
||||
requiresRestart: false,
|
||||
default: undefined as number | undefined,
|
||||
description:
|
||||
'Total timeout in seconds for the Arena session. No limit if unset.',
|
||||
showInDialog: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
team: {
|
||||
type: 'object',
|
||||
label: 'Team',
|
||||
category: 'Advanced',
|
||||
requiresRestart: false,
|
||||
default: {},
|
||||
description:
|
||||
'Settings for Agent Team (role-based collaborative execution). Reserved for future use.',
|
||||
showInDialog: false,
|
||||
},
|
||||
swarm: {
|
||||
type: 'object',
|
||||
label: 'Swarm',
|
||||
category: 'Advanced',
|
||||
requiresRestart: false,
|
||||
default: {},
|
||||
description:
|
||||
'Settings for Agent Swarm (parallel sub-agent execution). Reserved for future use.',
|
||||
showInDialog: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
hooksConfig: {
|
||||
type: 'object',
|
||||
|
|
@ -1418,6 +1516,17 @@ const SETTINGS_SCHEMA = {
|
|||
},
|
||||
},
|
||||
},
|
||||
|
||||
experimental: {
|
||||
type: 'object',
|
||||
label: 'Experimental',
|
||||
category: 'Experimental',
|
||||
requiresRestart: true,
|
||||
default: {},
|
||||
description: 'Setting to enable experimental features',
|
||||
showInDialog: false,
|
||||
properties: {},
|
||||
},
|
||||
} as const satisfies SettingsSchema;
|
||||
|
||||
export type SettingsSchemaType = typeof SETTINGS_SCHEMA;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue