MCPcopy Create free account
hub / github.com/Kilo-Org/cloud / parsePtySize

Function parsePtySize

services/cloud-agent-next/wrapper/src/server.ts:204–226  ·  view source on GitHub ↗
(input: PtyCreateBody | PtyResizeBody)

Source from the content-addressed store, hash-verified

202 `commit-co-author: failed to configure git hook: ${error instanceof Error ? error.message : String(error)}`
203 );
204 return errorResponse('SEND_ERROR', 'Failed to configure git commit attribution', 500);
205 }
206}
207
208async function readJsonBody<T>(req: Request, defaultValue: T): Promise<T> {
209 const text = await req.text();
210 if (!text.trim()) return defaultValue;
211 return JSON.parse(text) as T;
212}
213
214function validatePtyId(ptyId: string | undefined): string | null {
215 if (!ptyId || !PTY_ID_RE.test(ptyId)) return null;
216 return ptyId;
217}
218
219function parsePtySize(input: PtyCreateBody | PtyResizeBody): WrapperPtySize | null {
220 const rows = 'size' in input && input.size ? input.size.rows : input.rows;
221 const cols = 'size' in input && input.size ? input.size.cols : input.cols;
222
223 if (rows === undefined && cols === undefined) return null;
224
225 if (
226 typeof rows !== 'number' ||
227 typeof cols !== 'number' ||
228 !Number.isInteger(rows) ||
229 !Number.isInteger(cols) ||

Callers 2

createPtyCreateHandlerFunction · 0.85
createPtyResizeHandlerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected