clay-server 2.34.0-beta.5 → 2.34.0-beta.6
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.
- package/lib/yoke/adapters/claude.js +34 -1
- package/package.json +1 -1
|
@@ -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
|