@hydra-acp/browser 0.1.6 → 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.
- package/dist/ui/index.html +92 -80
- package/package.json +1 -1
package/dist/ui/index.html
CHANGED
|
@@ -707,85 +707,6 @@ pre code { background: transparent; padding: 0; }
|
|
|
707
707
|
);
|
|
708
708
|
}
|
|
709
709
|
|
|
710
|
-
// src/ui/bridge.ts
|
|
711
|
-
function send(method, params) {
|
|
712
|
-
const c = state.current;
|
|
713
|
-
if (!c || !c.ws || c.ws.readyState !== WebSocket.OPEN) {
|
|
714
|
-
return void 0;
|
|
715
|
-
}
|
|
716
|
-
const id = c.nextId = c.nextId ?? 1;
|
|
717
|
-
c.nextId = id + 1;
|
|
718
|
-
c.ws.send(JSON.stringify({ jsonrpc: "2.0", id, method, params }));
|
|
719
|
-
return id;
|
|
720
|
-
}
|
|
721
|
-
function notify(method, params) {
|
|
722
|
-
const c = state.current;
|
|
723
|
-
if (!c || !c.ws || c.ws.readyState !== WebSocket.OPEN) {
|
|
724
|
-
return;
|
|
725
|
-
}
|
|
726
|
-
c.ws.send(JSON.stringify({ jsonrpc: "2.0", method, params }));
|
|
727
|
-
}
|
|
728
|
-
function reply(id, result) {
|
|
729
|
-
const c = state.current;
|
|
730
|
-
if (!c || !c.ws || c.ws.readyState !== WebSocket.OPEN) {
|
|
731
|
-
return;
|
|
732
|
-
}
|
|
733
|
-
c.ws.send(JSON.stringify({ jsonrpc: "2.0", id, result }));
|
|
734
|
-
}
|
|
735
|
-
function handleFrame(frame) {
|
|
736
|
-
if (!state.current) return;
|
|
737
|
-
if (frame.method === "bridge/ready") {
|
|
738
|
-
state.current.ready = true;
|
|
739
|
-
state.banner = null;
|
|
740
|
-
const listeners = state.current.readyListeners;
|
|
741
|
-
state.current.readyListeners = [];
|
|
742
|
-
for (const fn of listeners) {
|
|
743
|
-
try {
|
|
744
|
-
fn();
|
|
745
|
-
} catch {
|
|
746
|
-
}
|
|
747
|
-
}
|
|
748
|
-
render();
|
|
749
|
-
return;
|
|
750
|
-
}
|
|
751
|
-
if (frame.method === "bridge/error") {
|
|
752
|
-
pushLog({
|
|
753
|
-
kind: "error",
|
|
754
|
-
text: `Bridge error: ${frame.params?.["message"] ?? "?"}`
|
|
755
|
-
});
|
|
756
|
-
render();
|
|
757
|
-
return;
|
|
758
|
-
}
|
|
759
|
-
if (frame.method && "id" in frame) {
|
|
760
|
-
handleAgentRequest(frame);
|
|
761
|
-
render();
|
|
762
|
-
return;
|
|
763
|
-
}
|
|
764
|
-
if (frame.method) {
|
|
765
|
-
handleNotification(frame);
|
|
766
|
-
render();
|
|
767
|
-
return;
|
|
768
|
-
}
|
|
769
|
-
if ("id" in frame && frame.id !== void 0 && state.current.ownPromptIds.has(String(frame.id))) {
|
|
770
|
-
state.current.ownPromptIds.delete(String(frame.id));
|
|
771
|
-
finalizeTurn();
|
|
772
|
-
render();
|
|
773
|
-
}
|
|
774
|
-
}
|
|
775
|
-
function respondPermission(toolCallId, optionId) {
|
|
776
|
-
if (!state.current) return;
|
|
777
|
-
const entry = state.current.pendingPermissions.get(toolCallId);
|
|
778
|
-
if (!entry) return;
|
|
779
|
-
state.current.pendingPermissions.delete(toolCallId);
|
|
780
|
-
state.current.log = state.current.log.filter(
|
|
781
|
-
(e) => !(e.kind === "perm" && e.toolCallId === toolCallId)
|
|
782
|
-
);
|
|
783
|
-
reply(entry.requestId, {
|
|
784
|
-
outcome: optionId === "__cancel__" ? { outcome: "cancelled" } : { outcome: "selected", optionId }
|
|
785
|
-
});
|
|
786
|
-
render();
|
|
787
|
-
}
|
|
788
|
-
|
|
789
710
|
// src/ui/queue.ts
|
|
790
711
|
function sendPrompt() {
|
|
791
712
|
const c = state.current;
|
|
@@ -945,6 +866,97 @@ pre code { background: transparent; padding: 0; }
|
|
|
945
866
|
}
|
|
946
867
|
}
|
|
947
868
|
|
|
869
|
+
// src/ui/bridge.ts
|
|
870
|
+
function send(method, params) {
|
|
871
|
+
const c = state.current;
|
|
872
|
+
if (!c || !c.ws || c.ws.readyState !== WebSocket.OPEN) {
|
|
873
|
+
return void 0;
|
|
874
|
+
}
|
|
875
|
+
const id = c.nextId = c.nextId ?? 1;
|
|
876
|
+
c.nextId = id + 1;
|
|
877
|
+
c.ws.send(JSON.stringify({ jsonrpc: "2.0", id, method, params }));
|
|
878
|
+
return id;
|
|
879
|
+
}
|
|
880
|
+
function notify(method, params) {
|
|
881
|
+
const c = state.current;
|
|
882
|
+
if (!c || !c.ws || c.ws.readyState !== WebSocket.OPEN) {
|
|
883
|
+
return;
|
|
884
|
+
}
|
|
885
|
+
c.ws.send(JSON.stringify({ jsonrpc: "2.0", method, params }));
|
|
886
|
+
}
|
|
887
|
+
function reply(id, result) {
|
|
888
|
+
const c = state.current;
|
|
889
|
+
if (!c || !c.ws || c.ws.readyState !== WebSocket.OPEN) {
|
|
890
|
+
return;
|
|
891
|
+
}
|
|
892
|
+
c.ws.send(JSON.stringify({ jsonrpc: "2.0", id, result }));
|
|
893
|
+
}
|
|
894
|
+
function handleFrame(frame) {
|
|
895
|
+
if (!state.current) return;
|
|
896
|
+
if (frame.method === "bridge/ready") {
|
|
897
|
+
state.current.ready = true;
|
|
898
|
+
state.banner = null;
|
|
899
|
+
const listeners = state.current.readyListeners;
|
|
900
|
+
state.current.readyListeners = [];
|
|
901
|
+
for (const fn of listeners) {
|
|
902
|
+
try {
|
|
903
|
+
fn();
|
|
904
|
+
} catch {
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
render();
|
|
908
|
+
return;
|
|
909
|
+
}
|
|
910
|
+
if (frame.method === "bridge/error") {
|
|
911
|
+
pushLog({
|
|
912
|
+
kind: "error",
|
|
913
|
+
text: `Bridge error: ${frame.params?.["message"] ?? "?"}`
|
|
914
|
+
});
|
|
915
|
+
render();
|
|
916
|
+
return;
|
|
917
|
+
}
|
|
918
|
+
if (frame.method === "hydra-acp/session_closed") {
|
|
919
|
+
if (state.current) {
|
|
920
|
+
state.current.ready = false;
|
|
921
|
+
cancelAllQueued(state.current);
|
|
922
|
+
}
|
|
923
|
+
state.banner = {
|
|
924
|
+
kind: "warn",
|
|
925
|
+
text: "Session is now cold \u2014 opening a new prompt will resurrect it."
|
|
926
|
+
};
|
|
927
|
+
render();
|
|
928
|
+
return;
|
|
929
|
+
}
|
|
930
|
+
if (frame.method && "id" in frame) {
|
|
931
|
+
handleAgentRequest(frame);
|
|
932
|
+
render();
|
|
933
|
+
return;
|
|
934
|
+
}
|
|
935
|
+
if (frame.method) {
|
|
936
|
+
handleNotification(frame);
|
|
937
|
+
render();
|
|
938
|
+
return;
|
|
939
|
+
}
|
|
940
|
+
if ("id" in frame && frame.id !== void 0 && state.current.ownPromptIds.has(String(frame.id))) {
|
|
941
|
+
state.current.ownPromptIds.delete(String(frame.id));
|
|
942
|
+
finalizeTurn();
|
|
943
|
+
render();
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
function respondPermission(toolCallId, optionId) {
|
|
947
|
+
if (!state.current) return;
|
|
948
|
+
const entry = state.current.pendingPermissions.get(toolCallId);
|
|
949
|
+
if (!entry) return;
|
|
950
|
+
state.current.pendingPermissions.delete(toolCallId);
|
|
951
|
+
state.current.log = state.current.log.filter(
|
|
952
|
+
(e) => !(e.kind === "perm" && e.toolCallId === toolCallId)
|
|
953
|
+
);
|
|
954
|
+
reply(entry.requestId, {
|
|
955
|
+
outcome: optionId === "__cancel__" ? { outcome: "cancelled" } : { outcome: "selected", optionId }
|
|
956
|
+
});
|
|
957
|
+
render();
|
|
958
|
+
}
|
|
959
|
+
|
|
948
960
|
// src/ui/routing.ts
|
|
949
961
|
function buildSessionHash(sessionId, load) {
|
|
950
962
|
const id = encodeURIComponent(sessionId);
|
|
@@ -1213,7 +1225,7 @@ pre code { background: transparent; padding: 0; }
|
|
|
1213
1225
|
},
|
|
1214
1226
|
"Import"
|
|
1215
1227
|
),
|
|
1216
|
-
el("button", { onclick: openSessionModal
|
|
1228
|
+
el("button", { onclick: openSessionModal }, "New Session")
|
|
1217
1229
|
);
|
|
1218
1230
|
}
|
|
1219
1231
|
function renderList() {
|