shell-mirror 1.5.12 → 1.5.14
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/public/app/terminal.js +35 -36
package/package.json
CHANGED
package/public/app/terminal.js
CHANGED
|
@@ -92,47 +92,46 @@ function startConnection() {
|
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
async function discoverAgents() {
|
|
95
|
-
console.log('[DISCOVERY] 🔍 Starting agent discovery...');
|
|
95
|
+
console.log('[DISCOVERY] 🔍 Starting agent discovery via PHP backend...');
|
|
96
96
|
agentList.innerHTML = '<p style="color: #ccc;">Searching for Mac agents...</p>';
|
|
97
97
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
displayAvailableAgents(data.agents);
|
|
112
|
-
}
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
discoveryWs.onclose = () => {
|
|
116
|
-
console.log('[DISCOVERY] 🔌 Discovery connection closed');
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
discoveryWs.onerror = (error) => {
|
|
120
|
-
console.error('[DISCOVERY] ❌ WebSocket error:', error);
|
|
121
|
-
agentList.innerHTML = '<p style="color: #f44336;">Discovery failed. Check server connection.</p>';
|
|
122
|
-
showManualBtn.style.display = 'block';
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
// Timeout after 8 seconds (increased from 5)
|
|
126
|
-
setTimeout(() => {
|
|
127
|
-
if (discoveryWs.readyState === WebSocket.OPEN) {
|
|
128
|
-
discoveryWs.close();
|
|
98
|
+
try {
|
|
99
|
+
// Use PHP backend for agent discovery instead of WebSocket
|
|
100
|
+
const response = await fetch('/php-backend/api/list-agents.php', {
|
|
101
|
+
method: 'GET',
|
|
102
|
+
credentials: 'include', // Include session cookies for authentication
|
|
103
|
+
headers: {
|
|
104
|
+
'Accept': 'application/json',
|
|
105
|
+
'Content-Type': 'application/json'
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
if (!response.ok) {
|
|
110
|
+
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
129
111
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
112
|
+
|
|
113
|
+
const data = await response.json();
|
|
114
|
+
console.log('[DISCOVERY] 📨 PHP Backend Response:', data);
|
|
115
|
+
|
|
116
|
+
if (data.success && data.data && data.data.agents) {
|
|
117
|
+
displayAvailableAgents(data.data.agents);
|
|
118
|
+
} else {
|
|
119
|
+
console.log('[DISCOVERY] ⚠️ No agents found in response');
|
|
120
|
+
agentList.innerHTML = '<p style="color: #ff9800;">⚠️ No Mac agents found.<br><small>Make sure your Mac agent is running with: <code>shell-mirror</code></small></p>';
|
|
133
121
|
showManualBtn.style.display = 'block';
|
|
134
122
|
}
|
|
135
|
-
|
|
123
|
+
|
|
124
|
+
} catch (error) {
|
|
125
|
+
console.error('[DISCOVERY] ❌ PHP Backend error:', error);
|
|
126
|
+
|
|
127
|
+
if (error.message.includes('401')) {
|
|
128
|
+
agentList.innerHTML = '<p style="color: #f44336;">Authentication required. <a href="/php-backend/api/auth-login.php" style="color: #4CAF50;">Please log in</a></p>';
|
|
129
|
+
} else {
|
|
130
|
+
agentList.innerHTML = '<p style="color: #f44336;">Discovery failed. Check server connection.</p>';
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
showManualBtn.style.display = 'block';
|
|
134
|
+
}
|
|
136
135
|
}
|
|
137
136
|
|
|
138
137
|
function displayAvailableAgents(agents) {
|