clay-server 2.36.2-beta.6 → 2.36.2-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.
|
@@ -271,6 +271,9 @@ function handleMessage(msg) {
|
|
|
271
271
|
case "stop_task":
|
|
272
272
|
handleStopTask(msg);
|
|
273
273
|
break;
|
|
274
|
+
case "rewind_files":
|
|
275
|
+
handleRewindFiles(msg);
|
|
276
|
+
break;
|
|
274
277
|
case "permission_response":
|
|
275
278
|
handlePermissionResponse(msg);
|
|
276
279
|
break;
|
|
@@ -598,6 +601,22 @@ async function handleSetPermissionMode(msg) {
|
|
|
598
601
|
}
|
|
599
602
|
}
|
|
600
603
|
|
|
604
|
+
async function handleRewindFiles(msg) {
|
|
605
|
+
// Bridge the host's rewindFiles call to the in-process SDK query inside
|
|
606
|
+
// the worker. Both the dryRun preview and the actual restore go through
|
|
607
|
+
// here; the response carries the SDK's preview/result object back.
|
|
608
|
+
if (!queryInstance || typeof queryInstance.rewindFiles !== "function") {
|
|
609
|
+
sendToDaemon({ type: "rewind_files_response", requestId: msg.requestId, error: "rewindFiles not supported by active query" });
|
|
610
|
+
return;
|
|
611
|
+
}
|
|
612
|
+
try {
|
|
613
|
+
var result = await queryInstance.rewindFiles(msg.uuid, msg.opts || {});
|
|
614
|
+
sendToDaemon({ type: "rewind_files_response", requestId: msg.requestId, result: result });
|
|
615
|
+
} catch (e) {
|
|
616
|
+
sendToDaemon({ type: "rewind_files_response", requestId: msg.requestId, error: (e && e.message) ? e.message : String(e) });
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
|
|
601
620
|
async function handleStopTask(msg) {
|
|
602
621
|
if (!queryInstance) return;
|
|
603
622
|
try {
|
|
@@ -688,6 +688,11 @@ function createWorkerQueryHandle(worker, canUseTool, onElicitation, callMcpTool)
|
|
|
688
688
|
var iterEnded = false;
|
|
689
689
|
var iterError = null;
|
|
690
690
|
|
|
691
|
+
// Pending request/response correlation for handle methods that need a
|
|
692
|
+
// result from the worker (e.g. rewindFiles). Each entry is keyed by a
|
|
693
|
+
// requestId and holds { resolve, reject } of the in-flight Promise.
|
|
694
|
+
var pendingRewinds = {};
|
|
695
|
+
|
|
691
696
|
function pushToIter(value) {
|
|
692
697
|
if (iterEnded) return;
|
|
693
698
|
if (iterWaiting) {
|
|
@@ -797,6 +802,16 @@ function createWorkerQueryHandle(worker, canUseTool, onElicitation, callMcpTool)
|
|
|
797
802
|
pushToIter({ type: "_worker_meta", subtype: msg.type, data: msg });
|
|
798
803
|
break;
|
|
799
804
|
|
|
805
|
+
case "rewind_files_response": {
|
|
806
|
+
var rp = pendingRewinds[msg.requestId];
|
|
807
|
+
if (rp) {
|
|
808
|
+
delete pendingRewinds[msg.requestId];
|
|
809
|
+
if (msg.error) rp.reject(new Error(msg.error));
|
|
810
|
+
else rp.resolve(msg.result);
|
|
811
|
+
}
|
|
812
|
+
break;
|
|
813
|
+
}
|
|
814
|
+
|
|
800
815
|
case "query_done":
|
|
801
816
|
console.log("[yoke/claude] IPC query_done received, pid=" + (worker.process ? worker.process.pid : "?"));
|
|
802
817
|
worker._queryEnded = true;
|
|
@@ -934,6 +949,22 @@ function createWorkerQueryHandle(worker, canUseTool, onElicitation, callMcpTool)
|
|
|
934
949
|
endInput: function() {
|
|
935
950
|
worker.send({ type: "end_messages" });
|
|
936
951
|
},
|
|
952
|
+
|
|
953
|
+
// Claude SDK specific: rewind files to a previous state. The in-process
|
|
954
|
+
// handle calls rawQuery.rewindFiles directly; the worker variant has to
|
|
955
|
+
// hop through IPC and correlate the response by requestId.
|
|
956
|
+
rewindFiles: function(uuid, opts) {
|
|
957
|
+
var requestId = crypto.randomUUID();
|
|
958
|
+
return new Promise(function(resolve, reject) {
|
|
959
|
+
pendingRewinds[requestId] = { resolve: resolve, reject: reject };
|
|
960
|
+
try {
|
|
961
|
+
worker.send({ type: "rewind_files", requestId: requestId, uuid: uuid, opts: opts || {} });
|
|
962
|
+
} catch (e) {
|
|
963
|
+
delete pendingRewinds[requestId];
|
|
964
|
+
reject(e);
|
|
965
|
+
}
|
|
966
|
+
});
|
|
967
|
+
},
|
|
937
968
|
};
|
|
938
969
|
|
|
939
970
|
return handle;
|
package/package.json
CHANGED