import type { NextRequest } from 'next/server'; import type { IService } from 'soma-core'; import { AiAssistantRuntime } from '../../../../domain/ai-assistant/AiAssistantRuntime'; import { aiErrorResponse, aiSuccessResponse } from '../../../../domain/ai-shared/AiResponse'; import { readQueryParams, runService } from '../../../common/ServiceRuntime'; export default class KnowledgeListService implements IService { async get(req: NextRequest): Promise { return runService(async () => { try { const params = readQueryParams(req); const dir = typeof params.dir === 'string' ? params.dir : undefined; return aiSuccessResponse( AiAssistantRuntime.getInstance().listKnowledge(dir, req.signal), ); } catch (error) { return aiErrorResponse(error); } }); } }