feat: add plugin HTTP hooks + Zalo plugin
This commit is contained in:
@@ -10,12 +10,14 @@ import type { ChatAbortControllerEntry } from "./chat-abort.js";
|
||||
import type { HooksConfigResolved } from "./hooks.js";
|
||||
import { createGatewayHooksRequestHandler } from "./server/hooks.js";
|
||||
import { listenGatewayHttpServer } from "./server/http-listen.js";
|
||||
import { createGatewayPluginRequestHandler } from "./server/plugins-http.js";
|
||||
import type { GatewayWsClient } from "./server/ws-types.js";
|
||||
import { createGatewayBroadcaster } from "./server-broadcast.js";
|
||||
import { type ChatRunEntry, createChatRunState } from "./server-chat.js";
|
||||
import { MAX_PAYLOAD_BYTES } from "./server-constants.js";
|
||||
import { attachGatewayUpgradeHandler, createGatewayHttpServer } from "./server-http.js";
|
||||
import type { DedupeEntry } from "./server-shared.js";
|
||||
import type { PluginRegistry } from "../plugins/registry.js";
|
||||
|
||||
export async function createGatewayRuntimeState(params: {
|
||||
cfg: {
|
||||
@@ -28,12 +30,14 @@ export async function createGatewayRuntimeState(params: {
|
||||
openAiChatCompletionsEnabled: boolean;
|
||||
resolvedAuth: ResolvedGatewayAuth;
|
||||
hooksConfig: () => HooksConfigResolved | null;
|
||||
pluginRegistry: PluginRegistry;
|
||||
deps: CliDeps;
|
||||
canvasRuntime: RuntimeEnv;
|
||||
canvasHostEnabled: boolean;
|
||||
allowCanvasHostInTests?: boolean;
|
||||
logCanvas: { info: (msg: string) => void; warn: (msg: string) => void };
|
||||
logHooks: ReturnType<typeof createSubsystemLogger>;
|
||||
logPlugins: ReturnType<typeof createSubsystemLogger>;
|
||||
}): Promise<{
|
||||
canvasHost: CanvasHostHandler | null;
|
||||
httpServer: HttpServer;
|
||||
@@ -89,12 +93,18 @@ export async function createGatewayRuntimeState(params: {
|
||||
logHooks: params.logHooks,
|
||||
});
|
||||
|
||||
const handlePluginRequest = createGatewayPluginRequestHandler({
|
||||
registry: params.pluginRegistry,
|
||||
log: params.logPlugins,
|
||||
});
|
||||
|
||||
const httpServer = createGatewayHttpServer({
|
||||
canvasHost,
|
||||
controlUiEnabled: params.controlUiEnabled,
|
||||
controlUiBasePath: params.controlUiBasePath,
|
||||
openAiChatCompletionsEnabled: params.openAiChatCompletionsEnabled,
|
||||
handleHooksRequest,
|
||||
handlePluginRequest,
|
||||
resolvedAuth: params.resolvedAuth,
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user