@dmsdc-ai/aigentry-telepty 0.1.24 → 0.1.25
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/cli.js +15 -12
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -725,23 +725,26 @@ async function main() {
|
|
|
725
725
|
let lastInjectTextTime = 0;
|
|
726
726
|
const MAX_RECONNECT_DELAY = 30000;
|
|
727
727
|
|
|
728
|
-
function connectDaemonWs() {
|
|
728
|
+
async function connectDaemonWs() {
|
|
729
|
+
// Re-register session BEFORE WebSocket connect (daemon rejects WS if session unknown)
|
|
730
|
+
if (reconnectAttempts > 0) {
|
|
731
|
+
try {
|
|
732
|
+
await fetchWithAuth(`${DAEMON_URL}/api/sessions/register`, {
|
|
733
|
+
method: 'POST',
|
|
734
|
+
headers: { 'Content-Type': 'application/json' },
|
|
735
|
+
body: JSON.stringify({ session_id: sessionId, command, cwd: process.cwd() })
|
|
736
|
+
});
|
|
737
|
+
} catch (e) {
|
|
738
|
+
// Registration may fail if session already exists or daemon not ready
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
|
|
729
742
|
daemonWs = new WebSocket(wsUrl);
|
|
730
743
|
|
|
731
|
-
daemonWs.on('open',
|
|
744
|
+
daemonWs.on('open', () => {
|
|
732
745
|
wsReady = true;
|
|
733
746
|
if (reconnectAttempts > 0) {
|
|
734
747
|
console.error(`\n\x1b[32m⚡ Reconnected to daemon. Inject restored.\x1b[0m`);
|
|
735
|
-
// Re-register session on reconnect
|
|
736
|
-
try {
|
|
737
|
-
await fetchWithAuth(`${DAEMON_URL}/api/sessions/register`, {
|
|
738
|
-
method: 'POST',
|
|
739
|
-
headers: { 'Content-Type': 'application/json' },
|
|
740
|
-
body: JSON.stringify({ session_id: sessionId, command, cwd: process.cwd() })
|
|
741
|
-
});
|
|
742
|
-
} catch (e) {
|
|
743
|
-
// Registration may fail if session already exists, that's fine
|
|
744
|
-
}
|
|
745
748
|
}
|
|
746
749
|
reconnectAttempts = 0;
|
|
747
750
|
});
|