/** 检查设备内核的 /api/state 是否健康(把关键字段打出来) */ import { spawnSync } from 'node:child_process'; const SERIAL = process.argv[2] || 'emulator-5556'; const ADB = 'C:\\Android\\Sdk\\platform-tools\\adb.exe'; const res = spawnSync(ADB, ['-s', SERIAL, 'shell', 'curl -s --max-time 15 http://127.0.0.1:5199/api/state'], { encoding: 'utf8', timeout: 60000, }); const out = `${res.stdout || ''}`.trim(); let s; try { s = JSON.parse(out); } catch { console.log(' ❌ 不是合法 JSON:', out.slice(0, 200)); process.exit(1); } if (s.error) { console.log(' ❌ 内核返回错误:', s.error); process.exit(1); } const st = s.settings || {}; console.log(' ✅ /api/state 正常'); console.log(' provider =', JSON.stringify(st.provider)); console.log(' model =', JSON.stringify(st.model)); console.log(' nickname =', JSON.stringify(st.nickname)); console.log(' hasApiKey =', st.hasApiKey); console.log(' speech 是对象 =', st.speech && typeof st.speech === 'object' && !Array.isArray(st.speech)); console.log(' speech.ttsEngine =', JSON.stringify(st.speech?.ttsEngine)); console.log(' speech.autoRead =', st.speech?.autoRead); console.log(' 会话数 =', (s.conversations || []).length); console.log(' 智能体数 =', (s.agents || []).length); console.log(' 工具数 =', (s.toolNames || []).length);