agentgui 1.0.402 → 1.0.404
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/package.json +1 -1
- package/scripts/patch-fsbrowse.js +1 -1
- package/static/js/client.js +5 -5
- package/static/js/ws-client.js +29 -10
package/package.json
CHANGED
|
@@ -54,7 +54,7 @@ try {
|
|
|
54
54
|
// to avoid duplication like C:\\C:\\dev
|
|
55
55
|
if (baseDriveLetter && sanitizedIsAbsoluteOnDrive && sanitizedDriveLetter === baseDriveLetter) {
|
|
56
56
|
// Remove drive letter and leading slashes to make it relative
|
|
57
|
-
const relativePath = sanitized.replace(/^[A-Z]:
|
|
57
|
+
const relativePath = sanitized.replace(/^[A-Z]:(?:\/|\\)?/i, '');
|
|
58
58
|
fullPath = path.resolve(normalizedBase, relativePath);
|
|
59
59
|
} else {
|
|
60
60
|
fullPath = path.resolve(normalizedBase, sanitized);
|
package/static/js/client.js
CHANGED
|
@@ -107,6 +107,11 @@ class AgentGUIClient {
|
|
|
107
107
|
// Setup UI elements (must happen before loading data so DOM refs exist)
|
|
108
108
|
this.setupUI();
|
|
109
109
|
|
|
110
|
+
// Connect WebSocket before loading data (RPC requires connection)
|
|
111
|
+
if (this.config.autoConnect) {
|
|
112
|
+
await this.connectWebSocket();
|
|
113
|
+
}
|
|
114
|
+
|
|
110
115
|
// Load initial data
|
|
111
116
|
await this.loadAgents();
|
|
112
117
|
await this.loadConversations();
|
|
@@ -117,11 +122,6 @@ class AgentGUIClient {
|
|
|
117
122
|
// Enable controls for initial interaction
|
|
118
123
|
this.enableControls();
|
|
119
124
|
|
|
120
|
-
// Connect WebSocket
|
|
121
|
-
if (this.config.autoConnect) {
|
|
122
|
-
await this.connectWebSocket();
|
|
123
|
-
}
|
|
124
|
-
|
|
125
125
|
// Restore state from URL on page load
|
|
126
126
|
this.restoreStateFromUrl();
|
|
127
127
|
|
package/static/js/ws-client.js
CHANGED
|
@@ -3,6 +3,7 @@ class WsClient {
|
|
|
3
3
|
this._ws = wsManager;
|
|
4
4
|
this._pending = new Map();
|
|
5
5
|
this._installed = false;
|
|
6
|
+
this._connectPromise = null;
|
|
6
7
|
this._install();
|
|
7
8
|
}
|
|
8
9
|
|
|
@@ -42,6 +43,17 @@ class WsClient {
|
|
|
42
43
|
this._ws.on('disconnected', () => this.cancelAll());
|
|
43
44
|
}
|
|
44
45
|
|
|
46
|
+
_ensureConnected() {
|
|
47
|
+
if (this._ws.isConnected) return Promise.resolve();
|
|
48
|
+
if (this._connectPromise) return this._connectPromise;
|
|
49
|
+
this._connectPromise = this._ws.connect().then(() => {
|
|
50
|
+
this._connectPromise = null;
|
|
51
|
+
}).catch(() => {
|
|
52
|
+
this._connectPromise = null;
|
|
53
|
+
});
|
|
54
|
+
return this._connectPromise;
|
|
55
|
+
}
|
|
56
|
+
|
|
45
57
|
_id() {
|
|
46
58
|
let id = '';
|
|
47
59
|
for (let i = 0; i < 8; i++) id += ((Math.random() * 16) | 0).toString(16);
|
|
@@ -49,14 +61,16 @@ class WsClient {
|
|
|
49
61
|
}
|
|
50
62
|
|
|
51
63
|
request(method, params = {}, timeout = 30000) {
|
|
52
|
-
return
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
64
|
+
return this._ensureConnected().then(() => {
|
|
65
|
+
return new Promise((resolve, reject) => {
|
|
66
|
+
const r = this._id();
|
|
67
|
+
const timer = setTimeout(() => {
|
|
68
|
+
this._pending.delete(r);
|
|
69
|
+
reject(new Error(`RPC timeout: ${method}`));
|
|
70
|
+
}, timeout);
|
|
71
|
+
this._pending.set(r, { resolve, reject, timer });
|
|
72
|
+
this._ws.sendMessage({ r, m: method, p: params });
|
|
73
|
+
});
|
|
60
74
|
});
|
|
61
75
|
}
|
|
62
76
|
|
|
@@ -79,5 +93,10 @@ class WsClient {
|
|
|
79
93
|
|
|
80
94
|
window.WsClient = WsClient;
|
|
81
95
|
|
|
82
|
-
|
|
83
|
-
window.
|
|
96
|
+
try {
|
|
97
|
+
window.wsManager = new WebSocketManager();
|
|
98
|
+
window.wsClient = new WsClient(window.wsManager);
|
|
99
|
+
window.wsManager.connect().catch(function() {});
|
|
100
|
+
} catch (e) {
|
|
101
|
+
console.error('[ws-client] Failed to initialize:', e);
|
|
102
|
+
}
|