Elffuss BraidHub

kikocis/continue public

main · 1.5 KiBRawPermalink
1import { exec } from "node:child_process";
2import { IDE } from "..";
3
4export async function isLemonadeInstalled(): Promise<boolean> {
5 // On Windows, check if lemonade-server command exists
6 if (process.platform === "win32") {
7 return new Promise((resolve, _reject) => {
8 exec("where.exe lemonade-server", (error, _stdout, _stderr) => {
9 resolve(!error);
10 });
11 });
12 }
13
14 // On Linux, check if the health endpoint is accessible
15 try {
16 const response = await fetch("http://localhost:8000/api/v1/health", {
17 method: "GET",
18 signal: AbortSignal.timeout(3000), // 3 second timeout
19 });
20
21 if (response.ok) {
22 const data = await response.json();
23 return data.status === "ok";
24 }
25 return false;
26 } catch {
27 return false;
28 }
29}
30
31export async function startLocalLemonade(ide: IDE): Promise<any> {
32 let startCommand: string | undefined;
33
34 switch (process.platform) {
35 case "linux": // Linux
36 // On Linux, direct users to start Lemonade manually
37 return ide.showToast(
38 "info",
39 "Please start Lemonade manually. Visit https://lemonade-server.ai for instructions.",
40 );
41
42 case "win32": // Windows
43 startCommand = "lemonade-server serve\n";
44 break;
45
46 default:
47 return ide.showToast(
48 "error",
49 "Cannot start Lemonade: platform not supported!",
50 );
51 }
52
53 if (startCommand) {
54 return ide.runCommand(startCommand, {
55 reuseTerminal: true,
56 terminalName: "Start Lemonade",
57 });
58 }
59}