@@ -13,6 +13,7 @@ import { PROTOCOL_VERSION } from "../../dist/gateway/protocol/index.js";
|
13 | 13 | import { formatErrorMessage } from "../../dist/infra/errors.js"; |
14 | 14 | import { rawDataToString } from "../../dist/infra/ws.js"; |
15 | 15 | import { readStringValue } from "../../dist/shared/string-coerce.js"; |
| 16 | +import { readMcpChannelLimits } from "./mcp-channel-limits.ts"; |
16 | 17 | import { connectMcpWithTimeout } from "./mcp-connect-timeout.ts"; |
17 | 18 | import { waitForWebSocketOpen } from "./mcp-websocket-open.ts"; |
18 | 19 | |
@@ -50,30 +51,17 @@ const GATEWAY_WS_OPEN_TIMEOUT_MS = 45_000;
|
50 | 51 | const GATEWAY_RPC_TIMEOUT_MS = 60_000; |
51 | 52 | const GATEWAY_REQUEST_TIMEOUT_MS = 45_000; |
52 | 53 | const GATEWAY_CONNECT_RETRY_WINDOW_MS = 420_000; |
53 | | -const MCP_CONNECT_TIMEOUT_MS = readPositiveInt( |
54 | | -process.env.OPENCLAW_MCP_CHANNELS_CONNECT_TIMEOUT_MS, |
55 | | -60_000, |
56 | | -); |
57 | | -const GATEWAY_EVENT_RETAIN_LIMIT = readPositiveInt( |
58 | | -process.env.OPENCLAW_MCP_CHANNELS_GATEWAY_EVENT_RETAIN_LIMIT, |
59 | | -2_000, |
60 | | -); |
61 | | -const MCP_RAW_MESSAGE_RETAIN_LIMIT = readPositiveInt( |
62 | | -process.env.OPENCLAW_MCP_CHANNELS_RAW_MESSAGE_RETAIN_LIMIT, |
63 | | -2_000, |
64 | | -); |
| 54 | +const MCP_CHANNEL_LIMITS = readMcpChannelLimits(); |
| 55 | +const MCP_CONNECT_TIMEOUT_MS = MCP_CHANNEL_LIMITS.connectTimeoutMs; |
| 56 | +const GATEWAY_EVENT_RETAIN_LIMIT = MCP_CHANNEL_LIMITS.gatewayEventRetainLimit; |
| 57 | +const MCP_RAW_MESSAGE_RETAIN_LIMIT = MCP_CHANNEL_LIMITS.rawMessageRetainLimit; |
65 | 58 | |
66 | 59 | export function assert(condition: unknown, message: string): asserts condition { |
67 | 60 | if (!condition) { |
68 | 61 | throw new Error(message); |
69 | 62 | } |
70 | 63 | } |
71 | 64 | |
72 | | -function readPositiveInt(raw: string | undefined, fallback: number) { |
73 | | -const parsed = Number.parseInt(raw ?? "", 10); |
74 | | -return Number.isInteger(parsed) && parsed > 0 ? parsed : fallback; |
75 | | -} |
76 | | - |
77 | 65 | function pushBounded<T>(items: T[], item: T, limit: number): void { |
78 | 66 | items.push(item); |
79 | 67 | if (items.length > limit) { |
|