feat: update webui extensions, models, and agent config
This commit is contained in:
25
.pi/agent/extensions/webui/backend/routes/extension-ui.ts
Normal file
25
.pi/agent/extensions/webui/backend/routes/extension-ui.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import type { IncomingMessage, ServerResponse } from "node:http";
|
||||
import type { WebUiContext } from "../types/context.ts";
|
||||
import { json, readBody } from "../http/request.ts";
|
||||
|
||||
export function handleExtensionUiRoute(
|
||||
req: IncomingMessage,
|
||||
res: ServerResponse,
|
||||
ctx: WebUiContext,
|
||||
pathname: string,
|
||||
): boolean {
|
||||
if (req.method !== "POST" || pathname !== "/api/extension-ui-response") {
|
||||
return false;
|
||||
}
|
||||
|
||||
void readBody(req)
|
||||
.then(({ id, response }) => {
|
||||
if (typeof id !== "string" || !id.trim()) throw new Error("缺少 extension UI 响应 id");
|
||||
if (!response || typeof response !== "object") throw new Error("缺少 extension UI 响应内容");
|
||||
ctx.rpc.sendExtensionUiResponse(id, response as Record<string, unknown>);
|
||||
json(res, { ok: true });
|
||||
})
|
||||
.catch((err) => json(res, { error: err.message }, 500));
|
||||
|
||||
return true;
|
||||
}
|
||||
Reference in New Issue
Block a user