Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
refactor(rpc-proxy): name the sessions/messages limit caps (R1-M2)
Diego Zacarias39a045d19fa3
diff --git a/rpc-proxy/package-lock.json b/rpc-proxy/package-lock.jsonindex f0a8ff4a6..a9fbbc03d 100644--- a/rpc-proxy/package-lock.json+++ b/rpc-proxy/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-rpc-proxy",- "version": "0.1.60",+ "version": "0.1.61","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-rpc-proxy",- "version": "0.1.60",+ "version": "0.1.61","dependencies": {"cors": "^2.8.5","express": "^4.21.2",diff --git a/rpc-proxy/package.json b/rpc-proxy/package.jsonindex 2b32adc09..65b63f031 100644--- a/rpc-proxy/package.json+++ b/rpc-proxy/package.json@@ -1,6 +1,6 @@{"name": "clerum-rpc-proxy",- "version": "0.1.60",+ "version": "0.1.61","description": "External-facing RPC proxy for tenant-scoped MCP access","main": "dist/main.js","engines": {diff --git a/rpc-proxy/src/routes/rpc.ts b/rpc-proxy/src/routes/rpc.tsindex af3987e9d..3bd9eefe6 100644--- a/rpc-proxy/src/routes/rpc.ts+++ b/rpc-proxy/src/routes/rpc.ts@@ -36,6 +36,12 @@ import { mintOrReuseDirectTraceContext } from '../traceContext.js'const RFC1123_RE = /^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/+// Edge caps on the client-supplied page size before forwarding upstream. The+// host enforces its own identical caps independently; these are the proxy's+// own copy (the two services share no package, so each names its own).+const SESSIONS_LIMIT_CAP = 100+const MESSAGES_LIMIT_CAP = 200+function isSafeUpstreamPathSegment(value: string): boolean {return (value.length > 0 &&@@ -689,7 +695,7 @@ export function createRpcRouter(): Router {const upstreamUrl = new URL(`${baseUrl}/v1/runtime/sessions`)if (sessionAgent) upstreamUrl.searchParams.set('agent', sessionAgent)if (sessionLimit !== undefined) {- upstreamUrl.searchParams.set('limit', String(Math.min(sessionLimit, 100)))+ upstreamUrl.searchParams.set('limit', String(Math.min(sessionLimit, SESSIONS_LIMIT_CAP)))}if (sessionCursor) upstreamUrl.searchParams.set('cursor', sessionCursor)console.info(`[RPC_PROXY] user=${auth.sub} host=${hostRef} method=list-sessions`)@@ -788,7 +794,7 @@ export function createRpcRouter(): Router {`${baseUrl}/v1/runtime/sessions/${encodeURIComponent(agent)}/${encodeURIComponent(chatId)}/messages`)if (rawLimit !== undefined) {- upstreamUrl.searchParams.set('limit', String(Math.min(rawLimit, 200)))+ upstreamUrl.searchParams.set('limit', String(Math.min(rawLimit, MESSAGES_LIMIT_CAP)))}if (beforeTurn !== undefined) {upstreamUrl.searchParams.set('beforeTurn', String(beforeTurn))