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 { readRequestOrigin } from '../../common/RequestOrigin'; import { runService } from '../../common/ServiceRuntime'; /** * 助手工具的展示元数据:只回「工具名 → 三态文案」。 * * 刻意不回入参结构、绑定路径、来源工具包等任何实现细节——这是给 Widget 显示 * "正在查订单…"用的,不是工具目录接口。延续助手的隐私纪律:对用户可见的一切 * 都不暴露内部结构。 */ export default class ToolsMetaService implements IService { async get(req: NextRequest): Promise { return runService(async () => { try { return aiSuccessResponse( await AiAssistantRuntime.getInstance().listToolDisplays( readRequestOrigin(req), req.signal, ), ); } catch (error) { return aiErrorResponse(error); } }); } }