feat(sproutclaw): modularize webui, extensions, and agent config layout
Some checks failed
CI / build-check-test (push) Has been cancelled

Restructure local extensions into per-feature directories, split WebUI
into backend modules with slash commands and systemd support, and track
prompts/skills under .pi/agent for portable Gitea deployment.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
root
2026-06-10 16:57:08 +08:00
parent 11c3a3a399
commit cf5edd6394
132 changed files with 9288 additions and 1971 deletions

View File

@@ -0,0 +1,36 @@
import { createServer, type IncomingMessage, type ServerResponse } from "node:http";
import { applyCorsHeaders } from "./cors.ts";
import { serveStatic } from "./static.ts";
import { handleChatRoute } from "../routes/chat.ts";
import { handleCommandsRoute } from "../routes/commands.ts";
import { handleModelsRoute } from "../routes/models.ts";
import { handleSessionsRoute } from "../routes/sessions.ts";
import { handleSettingsRoute } from "../routes/settings.ts";
import { handleWebuiConfigRoute } from "../routes/webui-config.ts";
import type { WebUiContext } from "../types/context.ts";
export function createWebUiServer(ctx: WebUiContext) {
return createServer((req: IncomingMessage, res: ServerResponse) => {
const url = new URL(req.url!, `http://localhost:${ctx.config.port}`);
const pathname = url.pathname;
if (pathname.startsWith("/api/") && applyCorsHeaders(req, res)) {
return;
}
if (req.method === "GET" && !pathname.startsWith("/api/")) {
serveStatic(ctx.config.paths.publicDir, pathname, req, res, true);
return;
}
if (handleChatRoute(req, res, ctx, pathname)) return;
if (handleSessionsRoute(req, res, ctx, pathname)) return;
if (handleModelsRoute(req, res, ctx, pathname)) return;
if (handleWebuiConfigRoute(req, res, ctx, pathname, url)) return;
if (handleSettingsRoute(req, res, ctx, pathname)) return;
if (handleCommandsRoute(req, res, ctx, pathname)) return;
res.writeHead(404);
res.end("Not found");
});
}