function registerLocalRuntimeRoutes(app, { embeddedRuntime }) {
  app.get('/api/local-runtime/status', async (_req, res) => {
    try {
      res.json(await embeddedRuntime.getStatus());
    } catch (error) {
      res.status(500).json({ error: error.message || 'Local runtime status failed' });
    }
  });

  app.post('/api/local-runtime/install', async (_req, res) => {
    try {
      await embeddedRuntime.ensurePackages();
      res.json({ ok: true });
    } catch (error) {
      res.status(500).json({ error: error.message || 'Local runtime install failed' });
    }
  });

  app.post('/api/local-runtime/pull', async (req, res) => {
    try {
      res.json(await embeddedRuntime.downloadModel(String(req.body?.model_slug || '').trim()));
    } catch (error) {
      res.status(500).json({ error: error.message || 'Local runtime model download failed' });
    }
  });
}

module.exports = { registerLocalRuntimeRoutes };
