| 123456789101112131415161718192021222324252627282930313233343536373839 |
- function buildStartupSummary(status = {}, agent = {}) {
- const summary = status.summary || {};
- const data = agent.data || {};
- const account = data.account || {};
- const listener = data.listener || {};
- const ingress = data.ingress || {};
- const product = data.product || { mode: 'personal', label: '个人版', collectionLabel: '本地主动监听', relayReady: false };
- const allowedSenderCount = Number(data.config?.allowedSenderCount || 0);
- const checks = [
- { key: 'auth', label: 'Fmode 鉴权', ready: Boolean(summary.authConfigured), action: '在 Fmode Studio 登录当前账号后重新启动' },
- { key: 'subscription', label: '企微席位', ready: Boolean(summary.subscribed), action: '在工作台打开订阅与登录流程,先开通席位' },
- { key: 'account', label: '企微账号', ready: Boolean(account.online), action: account.configured ? '在工作台点击“恢复登录”' : '在工作台完成企微扫码登录' },
- ...(product.mode === 'enterprise' ? [{ key: 'relay', label: '企业回调', ready: Boolean(ingress.running), action: '等待 MCP 自动连接服务端回调并启动 Relay 消费守护进程' }] : []),
- { key: 'allowlist', label: '测试白名单', ready: allowedSenderCount > 0, action: '配置至少一个测试联系人白名单' },
- ...(product.mode === 'personal' ? [{ key: 'listener', label: 'AI 监听', ready: Boolean(listener.running), action: '账号在线后,在智能会话页点击“启动 AI 监听”' }] : []),
- ];
- const next = checks.find(item => !item.ready);
- return {
- ready: checks.every(item => item.ready),
- checks,
- nextAction: next?.action || '工作台已就绪,可以进入智能会话进行测试',
- authConfigured: Boolean(summary.authConfigured),
- subscribed: Boolean(summary.subscribed),
- accountConfigured: Boolean(account.configured),
- online: Boolean(account.online),
- allowedSenderCount,
- listenerRunning: product.mode === 'personal' ? Boolean(listener.running) : false,
- callbackRunning: product.mode === 'enterprise' ? Boolean(ingress.running) : false,
- product,
- };
- }
- function startupAssistantMessage(startup = {}) {
- const stateText = (startup.checks || []).map(item => `${item.label}${item.ready ? '完成' : '待处理'}`).join(',');
- const productText = startup.product?.label ? `${startup.product.label}(${startup.product.collectionLabel})` : '当前模式';
- return `企微智能工作台已启动,当前为${productText}。${stateText}。下一步:${startup.nextAction}`;
- }
- module.exports = { buildStartupSummary, startupAssistantMessage };
|