mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-20 16:57:46 +00:00
feat: consolidate sandbox configurations into a single object (#1154)
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||||
import { Config, ConfigParameters } from './config.js';
|
||||
import { Config, ConfigParameters, SandboxConfig } from './config.js';
|
||||
import * as path from 'path';
|
||||
import { setGeminiMdFilename as mockSetGeminiMdFilename } from '../tools/memoryTool.js';
|
||||
import {
|
||||
@@ -53,7 +53,10 @@ vi.mock('../telemetry/index.js', async (importOriginal) => {
|
||||
describe('Server Config (config.ts)', () => {
|
||||
const API_KEY = 'server-api-key';
|
||||
const MODEL = 'gemini-pro';
|
||||
const SANDBOX = false;
|
||||
const SANDBOX: SandboxConfig = {
|
||||
command: 'docker',
|
||||
image: 'gemini-cli-sandbox',
|
||||
};
|
||||
const TARGET_DIR = '/path/to/target';
|
||||
const DEBUG_MODE = false;
|
||||
const QUESTION = 'test question';
|
||||
|
||||
@@ -73,11 +73,16 @@ export class MCPServerConfig {
|
||||
) {}
|
||||
}
|
||||
|
||||
export interface SandboxConfig {
|
||||
command: 'docker' | 'podman' | 'sandbox-exec';
|
||||
image: string;
|
||||
}
|
||||
|
||||
export interface ConfigParameters {
|
||||
sessionId: string;
|
||||
contentGeneratorConfig: ContentGeneratorConfig;
|
||||
embeddingModel?: string;
|
||||
sandbox?: boolean | string;
|
||||
sandbox?: SandboxConfig;
|
||||
targetDir: string;
|
||||
debugMode: boolean;
|
||||
question?: string;
|
||||
@@ -108,7 +113,7 @@ export class Config {
|
||||
private readonly sessionId: string;
|
||||
private readonly contentGeneratorConfig: ContentGeneratorConfig;
|
||||
private readonly embeddingModel: string;
|
||||
private readonly sandbox: boolean | string | undefined;
|
||||
private readonly sandbox: SandboxConfig | undefined;
|
||||
private readonly targetDir: string;
|
||||
private readonly debugMode: boolean;
|
||||
private readonly question: string | undefined;
|
||||
@@ -198,7 +203,7 @@ export class Config {
|
||||
return this.embeddingModel;
|
||||
}
|
||||
|
||||
getSandbox(): boolean | string | undefined {
|
||||
getSandbox(): SandboxConfig | undefined {
|
||||
return this.sandbox;
|
||||
}
|
||||
|
||||
|
||||
@@ -79,8 +79,7 @@ export function logCliConfiguration(config: Config): void {
|
||||
'event.timestamp': new Date().toISOString(),
|
||||
model: config.getModel(),
|
||||
embedding_model: config.getEmbeddingModel(),
|
||||
sandbox_enabled:
|
||||
typeof config.getSandbox() === 'string' ? true : config.getSandbox(),
|
||||
sandbox_enabled: !!config.getSandbox(),
|
||||
core_tools_enabled: (config.getCoreTools() ?? []).join(','),
|
||||
approval_mode: config.getApprovalMode(),
|
||||
api_key_enabled: !!generatorConfig.apiKey,
|
||||
|
||||
@@ -131,7 +131,7 @@ const baseConfigParams: ConfigParameters = {
|
||||
vertexai: false,
|
||||
},
|
||||
embeddingModel: 'test-embedding-model',
|
||||
sandbox: false,
|
||||
sandbox: undefined,
|
||||
targetDir: '/test/dir',
|
||||
debugMode: false,
|
||||
userMemory: '',
|
||||
|
||||
Reference in New Issue
Block a user