shell-mirror 1.5.11 → 1.5.13

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shell-mirror",
3
- "version": "1.5.11",
3
+ "version": "1.5.13",
4
4
  "description": "Access your Mac shell from any device securely. Perfect for mobile coding with Claude Code CLI, Gemini CLI, and any shell tool.",
5
5
  "main": "server.js",
6
6
  "bin": {
@@ -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
- // WebSocket server on same domain as web app
99
- const signalingUrl = (window.location.protocol === 'https:' ? 'wss://' : 'ws://') + window.location.host;
100
- const discoveryWs = new WebSocket(`${signalingUrl}?role=discovery`);
101
-
102
- discoveryWs.onopen = () => {
103
- console.log('[DISCOVERY] ✅ Connected to signaling server for agent discovery');
104
- discoveryWs.send(JSON.stringify({ type: 'list-agents' }));
105
- };
106
-
107
- discoveryWs.onmessage = (message) => {
108
- const data = JSON.parse(message.data);
109
- console.log('[DISCOVERY] 📨 Received:', data);
110
- if (data.type === 'agent-list') {
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
- if (agentList.children.length === 0 || agentList.textContent.includes('Searching')) {
131
- console.log('[DISCOVERY] Discovery timeout - no agents found');
132
- agentList.innerHTML = '<p style="color: #ff9800;">⚠️ No Mac agents found.<br><small>Make sure your Mac agent is running with: <code>cd mac-agent && npm start</code></small></p>';
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
- }, 8000);
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) {
package/public/index.html CHANGED
@@ -653,9 +653,9 @@
653
653
  </section>
654
654
 
655
655
  <!-- Version Footer -->
656
- <footer style="background: #1a1a1a; color: #666; text-align: center; padding: 20px 0; font-size: 0.8rem;">
656
+ <footer style="background: #ff6b35; color: white; text-align: center; padding: 20px 0; font-size: 0.8rem;">
657
657
  <div class="container">
658
- <p id="version-info">Shell Mirror v1.5.2 • Loading build info...</p>
658
+ <p id="version-info">Shell Mirror v1.5.11 • Loading build info...</p>
659
659
  </div>
660
660
  </footer>
661
661
  </main>