(stdout: string)
| 16 | let inList = false; |
| 17 | for (const line of lines) { |
| 18 | const t = line.trim(); |
| 19 | if (!t) continue; |
| 20 | if (t === 'Available models') { |
| 21 | inList = true; |
| 22 | continue; |
| 23 | } |
| 24 | if (t.startsWith('Tip:')) break; |
| 25 | if (!inList) continue; |
| 26 | const m = /^([a-zA-Z0-9][a-zA-Z0-9._-]*)\s*-\s*(.+)$/.exec(t); |
| 27 | if (m) { |
| 28 | const label = m[2] |
| 29 | .trim() |
| 30 | .replace(/\s*\(current\)\s*$/i, '') |
| 31 | .replace(/\s*\(default\)\s*$/i, '') |
| 32 | .trim(); |
| 33 | models.push({ id: m[1], label }); |
| 34 | } |
| 35 | } |
| 36 | return models; |
| 37 | } |
| 38 | |
| 39 | export async function systemRoutes(app: FastifyInstance) { |
| 40 | // 健康检查 |
| 41 | app.get('/health', async () => { |
| 42 | return { status: 'ok', timestamp: new Date().toISOString() }; |
| 43 | }); |
| 44 | |
| 45 | // 获取可用的 AI 代理列表 |
| 46 | app.get('/agents', async () => { |
no test coverage detected