MCPcopy Index your code
hub / github.com/garrytan/gstack / buildCommandResponse

Function buildCommandResponse

browse/src/server.ts:1325–1332  ·  view source on GitHub ↗
(cr: CommandResult)

Source from the content-addressed store, hash-verified

1323 * misses when the body has already been JSON-stringified.
1324 */
1325export function buildCommandResponse(cr: CommandResult): Response {
1326 const contentType = cr.json ? 'application/json' : 'text/plain';
1327 const safeBody = typeof cr.result === 'string' ? sanitizeBody(cr.result, !!cr.json) : cr.result;
1328 return new Response(safeBody, {
1329 status: cr.status,
1330 headers: { 'Content-Type': contentType, ...cr.headers },
1331 });
1332}
1333
1334/** HTTP wrapper — converts CommandResult to Response. Used by the /command
1335 * route dispatcher (line ~2158). The wrapper layer exists so

Callers 2

handleCommandFunction · 0.85

Calls 1

sanitizeBodyFunction · 0.90

Tested by

no test coverage detected