feat: update webui extensions, models, and agent config
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
*/
|
||||
|
||||
import { existsSync, unlinkSync, writeFileSync } from "node:fs";
|
||||
import { arch, hostname, platform, release, type } from "node:os";
|
||||
import { parsePort } from "./config/cli.ts";
|
||||
import { createWebUiPaths } from "./config/paths.ts";
|
||||
import { closeWebuiDatabase, initWebuiDatabase } from "./db/index.ts";
|
||||
@@ -47,18 +48,27 @@ function shutdown(exitCode = 0): never {
|
||||
|
||||
const webuiDb = initWebuiDatabase(paths.extensionRoot);
|
||||
console.log(`[webui] 配置数据库: ${webuiDb.dbPath}`);
|
||||
console.log(`[webui] 运行环境: Node.js ${process.version} | ${type()} ${release()} (${platform()}/${arch()}) | 主机: ${hostname()}`);
|
||||
|
||||
process.on("SIGTERM", () => shutdown(0));
|
||||
process.on("SIGINT", () => shutdown(0));
|
||||
writePidFile();
|
||||
|
||||
const piClient = createPiClient(paths, () => shutdown(1));
|
||||
const piClient = createPiClient(paths, (code) => {
|
||||
if (code !== 0 && code !== null) {
|
||||
console.error(`[webui] pi RPC 进程异常退出 (code=${code}),WebUI 即将关闭`);
|
||||
setTimeout(() => shutdown(1), 500);
|
||||
return;
|
||||
}
|
||||
shutdown(1);
|
||||
});
|
||||
|
||||
const ctx: WebUiContext = {
|
||||
config: { paths, port },
|
||||
rpc: {
|
||||
sendCmd: piClient.sendCmd,
|
||||
submitPrompt: piClient.submitPrompt,
|
||||
sendExtensionUiResponse: piClient.sendExtensionUiResponse,
|
||||
getRunSnapshot: piClient.getRunSnapshot,
|
||||
connectSseClient: piClient.connectSseClient,
|
||||
removeSseClient: piClient.removeSseClient,
|
||||
@@ -79,5 +89,5 @@ server.on("error", (err: NodeJS.ErrnoException) => {
|
||||
|
||||
server.listen(port, "0.0.0.0", () => {
|
||||
console.log(`[webui] HTTP 服务已启动: http://localhost:${port}`);
|
||||
console.log(`[webui] 局域网访问: http://smallmengya:${port}`);
|
||||
console.log(`[webui] 局域网访问: http://${hostname()}:${port}`);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user