clay-server 2.36.2-beta.5 → 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.
- package/lib/pages.js +3 -29
- package/lib/yoke/adapters/claude-worker.js +19 -0
- package/lib/yoke/adapters/claude.js +31 -0
- package/package.json +1 -1
package/lib/pages.js
CHANGED
|
@@ -964,7 +964,9 @@ function multiUserLoginPageHtml() {
|
|
|
964
964
|
'body:JSON.stringify({username:usernameEl.value,pin:pinEl.value})})' +
|
|
965
965
|
'.then(function(r){return r.json()})' +
|
|
966
966
|
'.then(function(d){' +
|
|
967
|
-
|
|
967
|
+
// mustChangePin is handled by the main app overlay
|
|
968
|
+
// (showForceChangePinOverlay in app-misc.js): it has a logout escape
|
|
969
|
+
// hatch and proper error display. Reload either way to enter it.
|
|
968
970
|
'if(d.ok){location.reload();return}' +
|
|
969
971
|
'if(d.locked){var boxes=document.querySelectorAll(".pin-digit");' +
|
|
970
972
|
'for(var i=0;i<boxes.length;i++)boxes[i].disabled=true;' +
|
|
@@ -976,34 +978,6 @@ function multiUserLoginPageHtml() {
|
|
|
976
978
|
'.catch(function(){errs[1].textContent="Connection error";btns[1].disabled=false})}' +
|
|
977
979
|
'btns[1].onclick=doLogin;' +
|
|
978
980
|
|
|
979
|
-
// Force PIN change: reuse the same login screen, switch step1 to "Set new PIN" mode
|
|
980
|
-
'function showChangePinOverlay(){' +
|
|
981
|
-
// Hide step dots (no longer a 2-step flow)
|
|
982
|
-
'var bar=document.querySelector(".steps-bar");if(bar)bar.style.display="none";' +
|
|
983
|
-
// Hide step 0 (username), show step 1 (PIN) with new labels
|
|
984
|
-
'steps[0].classList.remove("active");' +
|
|
985
|
-
'steps[1].classList.add("active");' +
|
|
986
|
-
'var h1=steps[1].querySelector("h1");if(h1)h1.textContent="Set your new PIN";' +
|
|
987
|
-
'var sub=steps[1].querySelector(".sub");if(sub)sub.textContent="Your temporary PIN has expired. Please set a new 6-digit PIN to continue.";' +
|
|
988
|
-
'btns[1].textContent="Save PIN";' +
|
|
989
|
-
// Re-init PIN boxes for fresh input
|
|
990
|
-
'resetPin();' +
|
|
991
|
-
'initPinBoxes("pin-boxes","pin",function(){if(!btns[1].disabled)doSaveNewPin()});' +
|
|
992
|
-
'var boxes=document.querySelectorAll(".pin-digit");' +
|
|
993
|
-
'for(var i=0;i<boxes.length;i++)boxes[i].addEventListener("input",function(){btns[1].disabled=pinEl.value.length!==6});' +
|
|
994
|
-
// Override button handler to save new PIN instead of login
|
|
995
|
-
'btns[1].onclick=doSaveNewPin;' +
|
|
996
|
-
'function doSaveNewPin(){' +
|
|
997
|
-
'btns[1].disabled=true;errs[1].textContent="";' +
|
|
998
|
-
'fetch("/api/user/pin",{method:"PUT",headers:{"Content-Type":"application/json"},' +
|
|
999
|
-
'body:JSON.stringify({newPin:pinEl.value})})' +
|
|
1000
|
-
'.then(function(r){return r.json()})' +
|
|
1001
|
-
'.then(function(d){' +
|
|
1002
|
-
'if(d.ok){location.reload();return}' +
|
|
1003
|
-
'errs[1].textContent=d.error||"Failed to save PIN";btns[1].disabled=false})' +
|
|
1004
|
-
'.catch(function(){errs[1].textContent="Connection error";btns[1].disabled=false})}' +
|
|
1005
|
-
'}' +
|
|
1006
|
-
|
|
1007
981
|
'</script></div></body></html>';
|
|
1008
982
|
}
|
|
1009
983
|
|
|
@@ -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