Skip to content

Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥

chore(api): remove agent livecast (#4170)

tomsideguidec7597dcc6218
diff --git a/apps/api/src/index.ts b/apps/api/src/index.ts
index 580b9d41c..f4d242afa 100644
--- a/apps/api/src/index.ts
+++ b/apps/api/src/index.ts
@@ -28,7 +28,6 @@ import {
import { ZodError } from "zod";
import { QueueFullError } from "./lib/queue-full-error";
import { v7 as uuidv7 } from "uuid";
-import { attachWsProxy } from "./services/agentLivecastWS";
import { cacheableLookup } from "./scraper/scrapeURL/lib/cacheableLookup";
import { v2Router } from "./routes/v2";
import { labsRouter } from "./routes/labs";
@@ -150,9 +149,6 @@ async function startServer(port = DEFAULT_PORT) {
throw error;
}
- // Attach WebSocket proxy to the Express app
- attachWsProxy(app);
-
const mcpActionLogRetention = startMcpActionLogRetentionWorkerIfEnabled({
enabled: config.MCP_ACTION_LOG_STORAGE_ENABLED,
db,
diff --git a/apps/api/src/services/agentLivecastWS.ts b/apps/api/src/services/agentLivecastWS.ts
deleted file mode 100644
index 32af19d86..000000000
--- a/apps/api/src/services/agentLivecastWS.ts
+++ /dev/null
@@ -1,59 +0,0 @@
-import { configDotenv } from "dotenv";
-import { config } from "../config";
-import { logger } from "../lib/logger";
-import type { Request } from "express";
-import WSWebSocket from "ws";
-configDotenv();
-
-/**
- * Attaches WebSocket proxying logic to the Express application
- * This function should be called after creating the Express app but before starting the server
- */
-export function attachWsProxy(app: any) {
- logger.info("Attaching WebSocket proxy to Express app");
-
- // Make sure express-ws is properly initialized
- if (!app.ws) {
- logger.error(
- "Express app does not have WebSocket support. Make sure express-ws is properly initialized.",
- );
- return;
- }
-
- // Define the WebSocket route
- app.ws("/agent-livecast", (clientWs: WSWebSocket, req: Request) => {
- try {
- console.log(req.url);
- const url = new URL(req.url ?? "", "http://placeholder/");
- const sessionIdParam = url.searchParams.get("userProvidedId") || "";
-
- const workerWsUrl = `${config.FIRE_ENGINE_BETA_URL?.replace("http", "ws")}?userProvidedId=${sessionIdParam}`;
- console.log(workerWsUrl);
- const wsWorker = new WebSocket(workerWsUrl);
-
- wsWorker.onopen = () => {
- // clientWs is your user's browser socket
- // wsWorker is the worker's socket
-
- // Forward messages from the user -> worker
- clientWs.on("message", dataFromClient => {
- wsWorker.send(dataFromClient as unknown as string);
- });
-
- // Forward messages from the worker -> user
- wsWorker.onmessage = event => {
- clientWs.send(event.data);
- };
-
- // Close events
- clientWs.on("close", () => wsWorker.close());
- wsWorker.onclose = () => clientWs.close();
- };
- } catch (error) {
- console.error("Error in wsProxy upgrade:", error);
- clientWs.close();
- }
- });
-
- logger.info("WebSocket proxy successfully attached to Express app");
-}