@kbediako/codex-orchestrator 0.1.5 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -826,7 +826,7 @@ async function runJsonRpcServer(handler, options = {}) {
|
|
|
826
826
|
const body = buffer.slice(0, expectedLength);
|
|
827
827
|
buffer = buffer.slice(expectedLength);
|
|
828
828
|
expectedLength = null;
|
|
829
|
-
await handleMessage(body.toString('utf8'));
|
|
829
|
+
await handleMessage(body.toString('utf8'), 'framed');
|
|
830
830
|
continue;
|
|
831
831
|
}
|
|
832
832
|
const headerEnd = buffer.indexOf('\r\n\r\n');
|
|
@@ -855,7 +855,7 @@ async function runJsonRpcServer(handler, options = {}) {
|
|
|
855
855
|
handleProtocolViolation(`Rejecting MCP payload (${lineBytes} bytes) larger than ${MAX_MCP_MESSAGE_BYTES}`);
|
|
856
856
|
return;
|
|
857
857
|
}
|
|
858
|
-
await handleMessage(line);
|
|
858
|
+
await handleMessage(line, 'jsonl');
|
|
859
859
|
continue;
|
|
860
860
|
}
|
|
861
861
|
if (!restoredHeader && isContentLength) {
|
|
@@ -896,7 +896,7 @@ async function runJsonRpcServer(handler, options = {}) {
|
|
|
896
896
|
if (allJsonLike) {
|
|
897
897
|
buffer = buffer.slice(headerEnd + 4);
|
|
898
898
|
for (const line of lines) {
|
|
899
|
-
await handleMessage(line);
|
|
899
|
+
await handleMessage(line, 'jsonl');
|
|
900
900
|
}
|
|
901
901
|
continue;
|
|
902
902
|
}
|
|
@@ -916,7 +916,7 @@ async function runJsonRpcServer(handler, options = {}) {
|
|
|
916
916
|
buffer = buffer.slice(headerEnd + 4);
|
|
917
917
|
}
|
|
918
918
|
}
|
|
919
|
-
async function handleMessage(raw) {
|
|
919
|
+
async function handleMessage(raw, format) {
|
|
920
920
|
let request;
|
|
921
921
|
try {
|
|
922
922
|
request = JSON.parse(raw);
|
|
@@ -932,7 +932,7 @@ async function runJsonRpcServer(handler, options = {}) {
|
|
|
932
932
|
try {
|
|
933
933
|
const result = await handler(request);
|
|
934
934
|
if (id !== null && typeof id !== 'undefined') {
|
|
935
|
-
sendResponse({ jsonrpc: '2.0', id, result }, output);
|
|
935
|
+
sendResponse({ jsonrpc: '2.0', id, result }, output, format);
|
|
936
936
|
}
|
|
937
937
|
}
|
|
938
938
|
catch (error) {
|
|
@@ -941,7 +941,7 @@ async function runJsonRpcServer(handler, options = {}) {
|
|
|
941
941
|
jsonrpc: '2.0',
|
|
942
942
|
id,
|
|
943
943
|
error: { code: -32603, message: error?.message ?? String(error) }
|
|
944
|
-
}, output);
|
|
944
|
+
}, output, format);
|
|
945
945
|
}
|
|
946
946
|
}
|
|
947
947
|
}
|
|
@@ -969,10 +969,15 @@ function parseContentLengthHeader(header) {
|
|
|
969
969
|
}
|
|
970
970
|
return { length: contentLength };
|
|
971
971
|
}
|
|
972
|
-
function sendResponse(response, output = process.stdout) {
|
|
973
|
-
const payload =
|
|
974
|
-
|
|
975
|
-
|
|
972
|
+
function sendResponse(response, output = process.stdout, format = 'framed') {
|
|
973
|
+
const payload = JSON.stringify(response);
|
|
974
|
+
if (format === 'jsonl') {
|
|
975
|
+
output.write(`${payload}\n`);
|
|
976
|
+
return;
|
|
977
|
+
}
|
|
978
|
+
const buffer = Buffer.from(payload, 'utf8');
|
|
979
|
+
const header = Buffer.from(`Content-Length: ${buffer.length}\r\n\r\n`, 'utf8');
|
|
980
|
+
output.write(Buffer.concat([header, buffer]));
|
|
976
981
|
}
|
|
977
982
|
function safeJsonParse(text) {
|
|
978
983
|
try {
|