refactor: Centralize session ID generation and propagation

This commit is contained in:
jerop
2025-06-11 04:46:39 +00:00
committed by Jerop Kipruto
parent 95fdc66e7d
commit d1e23b7c71
20 changed files with 96 additions and 71 deletions

View File

@@ -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(() => {

View File

@@ -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;
}