feat: integrate HAI-001 auto-open browser
This commit is contained in:
@@ -42,7 +42,8 @@ async function main() {
|
||||
const pi = portIdx !== -1 ? portIdx : portIdxShort;
|
||||
const port = pi !== -1 ? parseInt(args[pi + 1], 10) : 4040;
|
||||
const engine = args.includes("--engine");
|
||||
await runDashboard(port, { engine });
|
||||
const open = !args.includes("--no-open");
|
||||
await runDashboard(port, { engine, open });
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,17 @@
|
||||
import { exec } from "node:child_process";
|
||||
import { TaskStore } from "@hai/core";
|
||||
import { createServer } from "@hai/dashboard";
|
||||
import { TriageProcessor, TaskExecutor, Scheduler } from "@hai/engine";
|
||||
|
||||
export async function runDashboard(port: number, opts: { engine?: boolean } = {}) {
|
||||
function openBrowser(url: string): void {
|
||||
const cmd =
|
||||
process.platform === "darwin" ? `open "${url}"`
|
||||
: process.platform === "win32" ? `start "" "${url}"`
|
||||
: `xdg-open "${url}"`;
|
||||
exec(cmd, () => {});
|
||||
}
|
||||
|
||||
export async function runDashboard(port: number, opts: { engine?: boolean; open?: boolean } = {}) {
|
||||
const cwd = process.cwd();
|
||||
const store = new TaskStore(cwd);
|
||||
await store.init();
|
||||
@@ -56,5 +65,9 @@ export async function runDashboard(port: number, opts: { engine?: boolean } = {}
|
||||
}
|
||||
console.log(` Press Ctrl+C to stop`);
|
||||
console.log();
|
||||
|
||||
if (opts.open !== false) {
|
||||
openBrowser(`http://localhost:${port}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user