import type { Server as HttpServer } from "node:http"; import { WebSocketServer } from "ws"; import { CANVAS_HOST_PATH } from "../canvas-host/a2ui.js"; import { type CanvasHostHandler, createCanvasHostHandler } from "../canvas-host/server.js"; import type { CliDeps } from "../cli/deps.types.js"; import type { createSubsystemLogger } from "../logging/subsystem.js"; import type { PluginRegistry } from "../plugins/registry.js"; import {
pinActivePluginChannelRegistry,
pinActivePluginHttpRouteRegistry,
releasePinnedPluginChannelRegistry,
releasePinnedPluginHttpRouteRegistry,
resolveActivePluginHttpRouteRegistry,
} from "../plugins/runtime.js"; import type { RuntimeEnv } from "../runtime.js"; import type { AuthRateLimiter } from "./auth-rate-limit.js"; import type { ResolvedGatewayAuth } from "./auth.js"; import type { ChatAbortControllerEntry } from "./chat-abort.js"; import type { ControlUiRootState } from "./control-ui.js"; import type { HooksConfigResolved } from "./hooks.js"; import { isLoopbackHost, resolveGatewayListenHosts } from "./net.js"; import type { GatewayBroadcastFn, GatewayBroadcastToConnIdsFn } from "./server-broadcast-types.js"; import { createGatewayBroadcaster } from "./server-broadcast.js"; import {
type ChatRunEntry,
createChatRunState,
createToolEventRecipientRegistry,
} from "./server-chat.js"; import { MAX_PREAUTH_PAYLOAD_BYTES } from "./server-constants.js"; import {
attachGatewayUpgradeHandler,
createGatewayHttpServer,
type HookClientIpConfig,
} from "./server-http.js"; import type { DedupeEntry } from "./server-shared.js"; import { createGatewayHooksRequestHandler } from "./server/hooks.js"; import { listenGatewayHttpServer } from "./server/http-listen.js"; import {
createGatewayPluginRequestHandler,
shouldEnforceGatewayAuthForPluginPath,
type PluginRoutePathContext,
} from "./server/plugins-http.js"; import {
createPreauthConnectionBudget,
type PreauthConnectionBudget,
} from "./server/preauth-connection-budget.js"; import type { ReadinessChecker } from "./server/readiness.js"; import type { GatewayTlsRuntime } from "./server/tls.js"; import type { GatewayWsClient } from "./server/ws-types.js";
const bindHosts = await resolveGatewayListenHosts(params.bindHost); if (!isLoopbackHost(params.bindHost)) {
params.log.warn( "⚠️ Gateway is binding to a non-loopback address. " + "Ensure authentication is configured before exposing to public networks.",
);
} if (params.cfg.gateway?.controlUi?.dangerouslyAllowHostHeaderOriginFallback === true) {
params.log.warn( "⚠️ gateway.controlUi.dangerouslyAllowHostHeaderOriginFallback=true is enabled. " + "Host-header origin fallback weakens origin checks and should only be used as break-glass.",
);
} // Create WebSocketServer first (with noServer: true) so we can attach upgrade handlers // before HTTP servers start listening. This prevents a race condition where connections // arrive before the upgrade handler is attached, which causes silent 1006 errors. const wss = new WebSocketServer({
noServer: true,
maxPayload: MAX_PREAUTH_PAYLOAD_BYTES,
}); const preauthConnectionBudget = createPreauthConnectionBudget();
return {
canvasHost,
releasePluginRouteRegistry: () => { // Releases both pinned HTTP-route and channel registries set at startup.
releasePinnedPluginHttpRouteRegistry(params.pluginRegistry); // Release unconditionally (no registry arg): the channel pin may have // been re-pinned to a deferred-reload registry that differs from the // original params.pluginRegistry, so an identity-guarded release would // be a no-op and leak the pin across in-process restarts.
releasePinnedPluginChannelRegistry();
},
httpServer,
httpServers,
httpBindHosts,
startListening,
wss,
preauthConnectionBudget,
clients,
broadcast,
broadcastToConnIds,
agentRunSeq,
dedupe,
chatRunState,
chatRunBuffers,
chatDeltaSentAt,
chatDeltaLastBroadcastLen,
addChatRun,
removeChatRun,
chatAbortControllers,
toolEventRecipients,
};
} catch (err) {
releasePinnedPluginHttpRouteRegistry(params.pluginRegistry);
releasePinnedPluginChannelRegistry(); throw err;
}
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.15 Sekunden
(vorverarbeitet am 2026-06-10)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.