diff --git a/src/constants/agent-config.ts b/src/constants/agent-config.ts new file mode 100644 index 0000000..c939283 --- /dev/null +++ b/src/constants/agent-config.ts @@ -0,0 +1,79 @@ +/** + * Centralized configuration for all AI agents + * + * Benefits: + * - Single source of truth for agent settings + * - Easy to adjust settings without hunting through multiple files + * - Type-safe configuration + * + * Usage: + * import { SESSION_TTL, AI_CONFIG, getSessionConfig } from './agent-config'; + * const config = getSessionConfig('server'); + */ + +// Session TTL values (in milliseconds) +export const SESSION_TTL = { + server: 60 * 60 * 1000, // 1 hour + troubleshoot: 60 * 60 * 1000, // 1 hour + domain: 60 * 60 * 1000, // 1 hour + deposit: 30 * 60 * 1000, // 30 minutes +} as const; + +// Maximum messages to keep in session history +export const MAX_SESSION_MESSAGES = { + server: 20, + troubleshoot: 20, + domain: 20, + deposit: 10, +} as const; + +// OpenAI API configuration +export const AI_CONFIG = { + model: 'gpt-4o-mini', + maxToolCalls: 3, + defaultTemperature: 0.7, + // Agent-specific token limits + maxTokens: { + server: 800, + serverReview: 500, + troubleshoot: 1500, + domain: 800, + deposit: 500, + }, + temperature: { + server: 0.7, + serverReview: 0.5, + troubleshoot: 0.5, + domain: 0.7, + deposit: 0.7, + }, +} as const; + +// D1 table names for agent sessions +export const SESSION_TABLES = { + server: 'server_sessions', + troubleshoot: 'troubleshoot_sessions', + domain: 'domain_sessions', + deposit: 'deposit_sessions', +} as const; + +// Agent type definitions for type safety +export type AgentType = keyof typeof SESSION_TTL; + +/** + * Helper to get session manager config for an agent + * + * @param agent - Agent type (server, troubleshoot, domain, deposit) + * @returns Configuration object with tableName, ttlMs, maxMessages + * + * @example + * const config = getSessionConfig('server'); + * // Returns: { tableName: 'server_sessions', ttlMs: 3600000, maxMessages: 20 } + */ +export function getSessionConfig(agent: AgentType) { + return { + tableName: SESSION_TABLES[agent], + ttlMs: SESSION_TTL[agent], + maxMessages: MAX_SESSION_MESSAGES[agent], + }; +} diff --git a/src/constants/index.ts b/src/constants/index.ts index 80528d9..bd628ec 100644 --- a/src/constants/index.ts +++ b/src/constants/index.ts @@ -219,3 +219,8 @@ export type NotificationType = typeof NOTIFICATION_TYPE[keyof typeof NOTIFICATIO export type TroubleshootStatus = typeof TROUBLESHOOT_STATUS[keyof typeof TROUBLESHOOT_STATUS]; export type ServerConsultationStatus = typeof SERVER_CONSULTATION_STATUS[keyof typeof SERVER_CONSULTATION_STATUS]; export type LanguageCode = typeof LANGUAGE_CODE[keyof typeof LANGUAGE_CODE]; + +/** + * Re-export agent configuration + */ +export * from './agent-config';