fix: LLM health check via mcplocal instead of spawning gemini directly
Status command now queries mcplocal's /llm/health endpoint instead of spawning the gemini binary. This uses the persistent ACP connection (fast) and works for any configured provider, not just gemini-cli. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -81,6 +81,34 @@ export async function createHttpServer(
|
||||
reply.code(200).send({ status: 'ok' });
|
||||
});
|
||||
|
||||
// LLM health check — tests the active provider with a tiny prompt
|
||||
app.get('/llm/health', async (_request, reply) => {
|
||||
const provider = deps.providerRegistry?.getActive() ?? null;
|
||||
if (!provider) {
|
||||
reply.code(200).send({ status: 'not configured' });
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const result = await provider.complete({
|
||||
messages: [{ role: 'user', content: 'Respond with exactly: ok' }],
|
||||
maxTokens: 10,
|
||||
});
|
||||
const ok = result.content.trim().toLowerCase().includes('ok');
|
||||
reply.code(200).send({
|
||||
status: ok ? 'ok' : 'unexpected response',
|
||||
provider: provider.name,
|
||||
response: result.content.trim().slice(0, 100),
|
||||
});
|
||||
} catch (err) {
|
||||
const msg = (err as Error).message ?? String(err);
|
||||
reply.code(200).send({
|
||||
status: 'error',
|
||||
provider: provider.name,
|
||||
error: msg.slice(0, 200),
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Proxy management routes to mcpd
|
||||
const mcpdClient = new McpdClient(config.mcpdUrl, config.mcpdToken);
|
||||
registerProxyRoutes(app, mcpdClient);
|
||||
|
||||
Reference in New Issue
Block a user