const pageSize = Number(import.meta.env.VITE_SESSION_PAGE_SIZE ?? 25);

export const appConfig = {
  workingDir: import.meta.env.VITE_TKMIND_WORKING_DIR ?? '',
  provider: import.meta.env.VITE_TKMIND_PROVIDER ?? '',
  model: import.meta.env.VITE_TKMIND_MODEL ?? '',
  memoryQuery:
    import.meta.env.VITE_TKMIND_MEMORY_QUERY ??
    'project architecture conventions current goals decisions risks and recent work',
  sessionPageSize: Number.isFinite(pageSize) && pageSize > 0 ? pageSize : 25,
  sessionMaxCount: 100,
} as const;

export function requireWorkingDir(): string {
  if (!appConfig.workingDir) {
    throw new Error('未配置 VITE_TKMIND_WORKING_DIR，请在 ui/h5/.env 中设置工作目录');
  }
  return appConfig.workingDir;
}
