@dmsdc-ai/aigentry-telepty 0.1.35 → 0.1.37
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 +28 -25
- package/package.json +1 -1
package/daemon.js
CHANGED
|
@@ -461,10 +461,12 @@ function sendViaKitty(sessionId, text) {
|
|
|
461
461
|
if (textOnly.length > 0) {
|
|
462
462
|
const escaped = textOnly.replace(/\\/g, '\\\\').replace(/'/g, "'\\''");
|
|
463
463
|
execSync(`kitty @ --to unix:${socket} send-text --match id:${windowId} '${escaped}'`, {
|
|
464
|
-
timeout:
|
|
464
|
+
timeout: 5000, stdio: ['pipe', 'pipe', 'pipe']
|
|
465
465
|
});
|
|
466
466
|
}
|
|
467
467
|
if (hasCr) {
|
|
468
|
+
// Delay before sending Return — CLI needs time to process text input
|
|
469
|
+
execSync('sleep 0.5', { timeout: 2000 });
|
|
468
470
|
execSync(`kitty @ --to unix:${socket} send-key --match id:${windowId} Return`, {
|
|
469
471
|
timeout: 3000, stdio: ['pipe', 'pipe', 'pipe']
|
|
470
472
|
});
|
|
@@ -631,35 +633,36 @@ app.post('/api/sessions/:id/inject', (req, res) => {
|
|
|
631
633
|
|
|
632
634
|
let submitResult = null;
|
|
633
635
|
if (session.type === 'wrapped' && !no_enter) {
|
|
634
|
-
//
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
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
|
+
} catch {
|
|
648
651
|
writeToSession('\r');
|
|
649
|
-
console.log(`[INJECT+SUBMIT] WS \\r
|
|
652
|
+
console.log(`[INJECT+SUBMIT] WS text + WS \\r fallback for ${id}`);
|
|
650
653
|
}
|
|
651
|
-
}
|
|
652
|
-
|
|
653
|
-
|
|
654
|
+
} else {
|
|
655
|
+
writeToSession('\r');
|
|
656
|
+
console.log(`[INJECT+SUBMIT] WS text + WS \\r (no kitty window) for ${id}`);
|
|
657
|
+
}
|
|
658
|
+
}, 500);
|
|
659
|
+
submitResult = { deferred: true, strategy: 'ws_text_kitty_return' };
|
|
654
660
|
} else if (session.type === 'wrapped') {
|
|
655
661
|
// no_enter=true for wrapped
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
if (!writeToSession(finalPrompt)) {
|
|
659
|
-
return res.status(503).json({ error: 'Wrap process is not connected' });
|
|
660
|
-
}
|
|
662
|
+
if (!writeToSession(finalPrompt)) {
|
|
663
|
+
return res.status(503).json({ error: 'Wrap process is not connected' });
|
|
661
664
|
}
|
|
662
|
-
submitResult = { strategy:
|
|
665
|
+
submitResult = { strategy: 'ws_no_enter' };
|
|
663
666
|
} else {
|
|
664
667
|
if (!writeToSession(finalPrompt)) {
|
|
665
668
|
return res.status(503).json({ error: 'Wrap process is not connected' });
|