clay-server 2.34.0-beta.5 → 2.34.0-beta.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.
|
@@ -16,6 +16,7 @@ try { require("fs").writeSync(2, "[sdk-worker] BOOT pid=" + process.pid + " uid=
|
|
|
16
16
|
var net = require("net");
|
|
17
17
|
var crypto = require("crypto");
|
|
18
18
|
var path = require("path");
|
|
19
|
+
var fs = require("fs");
|
|
19
20
|
|
|
20
21
|
var socketPath = process.argv[2];
|
|
21
22
|
if (!socketPath) {
|
|
@@ -355,8 +356,11 @@ async function handleQueryStart(msg) {
|
|
|
355
356
|
// This is needed because the CLI's Axios-based HTTP client ignores
|
|
356
357
|
// NODE_OPTIONS dns flags and still attempts IPv6 connections via its
|
|
357
358
|
// custom TLS agent, causing 5-10s timeouts on IPv6-less servers.
|
|
358
|
-
var preloadScript =
|
|
359
|
-
var extraOpts = "
|
|
359
|
+
var preloadScript = path.join(__dirname, "..", "..", "ipv4-only.js");
|
|
360
|
+
var extraOpts = "";
|
|
361
|
+
if (fs.existsSync(preloadScript)) {
|
|
362
|
+
extraOpts += " --require " + JSON.stringify(preloadScript);
|
|
363
|
+
}
|
|
360
364
|
extraOpts += " --dns-result-order=ipv4first --no-network-family-autoselection";
|
|
361
365
|
spawnOpts.env.NODE_OPTIONS = (spawnOpts.env.NODE_OPTIONS || "") + extraOpts;
|
|
362
366
|
console.log("[sdk-worker] spawnClaudeCodeProcess called, command=" + spawnOpts.command);
|
|
@@ -600,7 +600,7 @@ function spawnWorker(linuxUser, workerScriptPath, cwd) {
|
|
|
600
600
|
worker.send = function(msg) {
|
|
601
601
|
if (!worker.connection || worker.connection.destroyed) return;
|
|
602
602
|
try {
|
|
603
|
-
worker.connection.write(JSON.stringify(msg) + "\n");
|
|
603
|
+
worker.connection.write(JSON.stringify(serializeWorkerValue(msg)) + "\n");
|
|
604
604
|
} catch (e) {
|
|
605
605
|
console.error("[yoke/claude] Failed to send to worker:", e.message);
|
|
606
606
|
}
|
|
@@ -643,6 +643,39 @@ function cleanupWorker(worker) {
|
|
|
643
643
|
worker.ready = false;
|
|
644
644
|
}
|
|
645
645
|
|
|
646
|
+
function serializeWorkerValue(value, seen) {
|
|
647
|
+
if (value == null) return value;
|
|
648
|
+
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") return value;
|
|
649
|
+
if (typeof value === "bigint") return String(value);
|
|
650
|
+
if (typeof value === "function" || typeof value === "symbol" || typeof value === "undefined") return undefined;
|
|
651
|
+
if (value instanceof Date) return value.toISOString();
|
|
652
|
+
if (Buffer.isBuffer(value)) return value.toString("base64");
|
|
653
|
+
|
|
654
|
+
if (!seen) seen = new WeakSet();
|
|
655
|
+
if (typeof value === "object") {
|
|
656
|
+
if (seen.has(value)) return undefined;
|
|
657
|
+
seen.add(value);
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
if (Array.isArray(value)) {
|
|
661
|
+
var arr = [];
|
|
662
|
+
for (var i = 0; i < value.length; i++) {
|
|
663
|
+
var item = serializeWorkerValue(value[i], seen);
|
|
664
|
+
if (item !== undefined) arr.push(item);
|
|
665
|
+
}
|
|
666
|
+
return arr;
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
var out = {};
|
|
670
|
+
var keys = Object.keys(value);
|
|
671
|
+
for (var j = 0; j < keys.length; j++) {
|
|
672
|
+
var key = keys[j];
|
|
673
|
+
var child = serializeWorkerValue(value[key], seen);
|
|
674
|
+
if (child !== undefined) out[key] = child;
|
|
675
|
+
}
|
|
676
|
+
return out;
|
|
677
|
+
}
|
|
678
|
+
|
|
646
679
|
// --- Worker QueryHandle ---
|
|
647
680
|
// Wraps worker IPC into the same async iterable + control interface as the
|
|
648
681
|
// in-process QueryHandle. This allows processQueryStream to iterate a worker
|