@dmsdc-ai/aigentry-telepty 0.1.36 → 0.1.38
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/daemon.js +44 -26
- package/package.json +1 -1
package/daemon.js
CHANGED
|
@@ -633,35 +633,42 @@ app.post('/api/sessions/:id/inject', (req, res) => {
|
|
|
633
633
|
|
|
634
634
|
let submitResult = null;
|
|
635
635
|
if (session.type === 'wrapped' && !no_enter) {
|
|
636
|
-
//
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
636
|
+
// Hybrid: text via WS (allow bridge handles it), Enter via kitty send-key
|
|
637
|
+
if (!writeToSession(finalPrompt)) {
|
|
638
|
+
return res.status(503).json({ error: 'Wrap process is not connected' });
|
|
639
|
+
}
|
|
640
|
+
setTimeout(() => {
|
|
641
|
+
// Try kitty send-key Return (reliable for all CLIs)
|
|
642
|
+
const windowId = findKittyWindowId(findKittySocket(), id);
|
|
643
|
+
if (windowId) {
|
|
644
|
+
try {
|
|
645
|
+
const { execSync } = require('child_process');
|
|
646
|
+
execSync(`kitty @ --to unix:${findKittySocket()} send-key --match id:${windowId} Return`, {
|
|
647
|
+
timeout: 3000, stdio: ['pipe', 'pipe', 'pipe']
|
|
648
|
+
});
|
|
649
|
+
console.log(`[INJECT+SUBMIT] WS text + kitty Return for ${id} (window ${windowId})`);
|
|
650
|
+
// Restore tab title after inject (Claude Code overwrites it)
|
|
651
|
+
try {
|
|
652
|
+
execSync(`kitty @ --to unix:${findKittySocket()} set-tab-title --match id:${windowId} '⚡ telepty :: ${id}'`, {
|
|
653
|
+
timeout: 2000, stdio: ['pipe', 'pipe', 'pipe']
|
|
654
|
+
});
|
|
655
|
+
} catch {}
|
|
656
|
+
} catch {
|
|
650
657
|
writeToSession('\r');
|
|
651
|
-
console.log(`[INJECT+SUBMIT] WS \\r
|
|
658
|
+
console.log(`[INJECT+SUBMIT] WS text + WS \\r fallback for ${id}`);
|
|
652
659
|
}
|
|
653
|
-
}
|
|
654
|
-
|
|
655
|
-
|
|
660
|
+
} else {
|
|
661
|
+
writeToSession('\r');
|
|
662
|
+
console.log(`[INJECT+SUBMIT] WS text + WS \\r (no kitty window) for ${id}`);
|
|
663
|
+
}
|
|
664
|
+
}, 500);
|
|
665
|
+
submitResult = { deferred: true, strategy: 'ws_text_kitty_return' };
|
|
656
666
|
} else if (session.type === 'wrapped') {
|
|
657
667
|
// no_enter=true for wrapped
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
if (!writeToSession(finalPrompt)) {
|
|
661
|
-
return res.status(503).json({ error: 'Wrap process is not connected' });
|
|
662
|
-
}
|
|
668
|
+
if (!writeToSession(finalPrompt)) {
|
|
669
|
+
return res.status(503).json({ error: 'Wrap process is not connected' });
|
|
663
670
|
}
|
|
664
|
-
submitResult = { strategy:
|
|
671
|
+
submitResult = { strategy: 'ws_no_enter' };
|
|
665
672
|
} else {
|
|
666
673
|
if (!writeToSession(finalPrompt)) {
|
|
667
674
|
return res.status(503).json({ error: 'Wrap process is not connected' });
|
|
@@ -1089,8 +1096,19 @@ wss.on('connection', (ws, req) => {
|
|
|
1089
1096
|
};
|
|
1090
1097
|
sessions[sessionId] = autoSession;
|
|
1091
1098
|
console.log(`[WS] Auto-registered wrapped session ${sessionId} on reconnect`);
|
|
1092
|
-
// Trigger CLI redraw via kitty
|
|
1093
|
-
setTimeout(() =>
|
|
1099
|
+
// Trigger CLI redraw + set tab title via kitty after short delay
|
|
1100
|
+
setTimeout(() => {
|
|
1101
|
+
sendViaKitty(sessionId, '\x0c');
|
|
1102
|
+
const sock = findKittySocket();
|
|
1103
|
+
const wid = findKittyWindowId(sock, sessionId);
|
|
1104
|
+
if (sock && wid) {
|
|
1105
|
+
try {
|
|
1106
|
+
require('child_process').execSync(`kitty @ --to unix:${sock} set-tab-title --match id:${wid} '⚡ telepty :: ${sessionId}'`, {
|
|
1107
|
+
timeout: 2000, stdio: ['pipe', 'pipe', 'pipe']
|
|
1108
|
+
});
|
|
1109
|
+
} catch {}
|
|
1110
|
+
}
|
|
1111
|
+
}, 1000);
|
|
1094
1112
|
} else {
|
|
1095
1113
|
session.clients.add(ws);
|
|
1096
1114
|
}
|