mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-21 01:07:46 +00:00
refactor: Centralize session ID generation and propagation
This commit is contained in:
@@ -49,6 +49,7 @@ describe('Server Config (config.ts)', () => {
|
||||
const USER_MEMORY = 'Test User Memory';
|
||||
const TELEMETRY = false;
|
||||
const EMBEDDING_MODEL = 'gemini-embedding';
|
||||
const SESSION_ID = 'test-session-id';
|
||||
const baseParams: ConfigParameters = {
|
||||
contentGeneratorConfig: {
|
||||
apiKey: API_KEY,
|
||||
@@ -62,6 +63,7 @@ describe('Server Config (config.ts)', () => {
|
||||
fullContext: FULL_CONTEXT,
|
||||
userMemory: USER_MEMORY,
|
||||
telemetry: TELEMETRY,
|
||||
sessionId: SESSION_ID,
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
|
||||
@@ -55,6 +55,7 @@ export class MCPServerConfig {
|
||||
}
|
||||
|
||||
export interface ConfigParameters {
|
||||
sessionId: string;
|
||||
contentGeneratorConfig: ContentGeneratorConfig;
|
||||
embeddingModel: string;
|
||||
sandbox?: boolean | string;
|
||||
@@ -83,6 +84,7 @@ export interface ConfigParameters {
|
||||
|
||||
export class Config {
|
||||
private toolRegistry: Promise<ToolRegistry>;
|
||||
private readonly sessionId: string;
|
||||
private readonly contentGeneratorConfig: ContentGeneratorConfig;
|
||||
private readonly embeddingModel: string;
|
||||
private readonly sandbox: boolean | string | undefined;
|
||||
@@ -111,6 +113,7 @@ export class Config {
|
||||
private fileDiscoveryService: FileDiscoveryService | null = null;
|
||||
|
||||
constructor(params: ConfigParameters) {
|
||||
this.sessionId = params.sessionId;
|
||||
this.contentGeneratorConfig = params.contentGeneratorConfig;
|
||||
this.embeddingModel = params.embeddingModel;
|
||||
this.sandbox = params.sandbox;
|
||||
@@ -155,6 +158,10 @@ export class Config {
|
||||
}
|
||||
}
|
||||
|
||||
getSessionId(): string {
|
||||
return this.sessionId;
|
||||
}
|
||||
|
||||
getContentGeneratorConfig(): ContentGeneratorConfig {
|
||||
return this.contentGeneratorConfig;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user