@dmsdc-ai/aigentry-telepty 0.1.42 → 0.1.45
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 +45 -26
- package/package.json +1 -1
package/daemon.js
CHANGED
|
@@ -655,42 +655,61 @@ app.post('/api/sessions/:id/inject', (req, res) => {
|
|
|
655
655
|
}
|
|
656
656
|
|
|
657
657
|
let submitResult = null;
|
|
658
|
-
if (
|
|
659
|
-
|
|
660
|
-
|
|
658
|
+
if (session.type === 'wrapped') {
|
|
659
|
+
// For wrapped sessions: try kitty send-text (bypasses allow bridge queue)
|
|
660
|
+
// then WS as fallback, then kitty send-key Return for enter
|
|
661
|
+
const sock = findKittySocket();
|
|
662
|
+
if (!session.kittyWindowId && sock) session.kittyWindowId = findKittyWindowId(sock, id);
|
|
663
|
+
const wid = session.kittyWindowId;
|
|
661
664
|
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
console.log(`[INJECT+SUBMIT] Split \\r for ${id}: ${ok ? 'success' : 'failed'}`);
|
|
668
|
-
// Restore kitty tab title (optional, no-op if not kitty)
|
|
665
|
+
// Always send via WS too (for new allow bridges with queue flush)
|
|
666
|
+
writeToSession(finalPrompt);
|
|
667
|
+
|
|
668
|
+
if (wid && sock) {
|
|
669
|
+
// Kitty send-text for reliable text delivery
|
|
669
670
|
try {
|
|
670
|
-
const
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
671
|
+
const escaped = finalPrompt.replace(/\\/g, '\\\\').replace(/'/g, "'\\''");
|
|
672
|
+
require('child_process').execSync(`kitty @ --to unix:${sock} send-text --match id:${wid} '${escaped}'`, {
|
|
673
|
+
timeout: 5000, stdio: ['pipe', 'pipe', 'pipe']
|
|
674
|
+
});
|
|
675
|
+
console.log(`[INJECT] Kitty send-text for ${id} (window ${wid})`);
|
|
676
|
+
} catch {}
|
|
677
|
+
|
|
678
|
+
if (!no_enter) {
|
|
679
|
+
setTimeout(() => {
|
|
680
|
+
try {
|
|
681
|
+
writeToSession('\r'); // WS \r for new bridges
|
|
682
|
+
require('child_process').execSync(`kitty @ --to unix:${sock} send-key --match id:${wid} Return`, {
|
|
683
|
+
timeout: 3000, stdio: ['pipe', 'pipe', 'pipe']
|
|
684
|
+
});
|
|
685
|
+
require('child_process').execSync(`kitty @ --to unix:${sock} set-tab-title --match id:${wid} '⚡ telepty :: ${id}'`, {
|
|
675
686
|
timeout: 2000, stdio: ['pipe', 'pipe', 'pipe']
|
|
676
687
|
});
|
|
677
|
-
}
|
|
678
|
-
}
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
688
|
+
} catch {}
|
|
689
|
+
}, 500);
|
|
690
|
+
submitResult = { deferred: true, strategy: 'kitty_text_key' };
|
|
691
|
+
}
|
|
692
|
+
} else {
|
|
693
|
+
// No kitty — WS only
|
|
694
|
+
if (!no_enter) {
|
|
695
|
+
setTimeout(() => {
|
|
696
|
+
writeToSession('\r');
|
|
697
|
+
console.log(`[INJECT+SUBMIT] WS-only split_cr for ${id}`);
|
|
698
|
+
}, 300);
|
|
699
|
+
submitResult = { deferred: true, strategy: 'ws_split_cr' };
|
|
700
|
+
}
|
|
701
|
+
}
|
|
682
702
|
} else {
|
|
703
|
+
// Spawned sessions: direct PTY write
|
|
683
704
|
if (!writeToSession(finalPrompt)) {
|
|
684
|
-
return res.status(503).json({ error: '
|
|
705
|
+
return res.status(503).json({ error: 'Process not connected' });
|
|
685
706
|
}
|
|
686
|
-
|
|
687
707
|
if (!no_enter) {
|
|
688
|
-
// Spawned sessions: send \r separately after delay (proven split_cr strategy)
|
|
689
708
|
setTimeout(() => {
|
|
690
|
-
|
|
691
|
-
console.log(`[INJECT+SUBMIT]
|
|
709
|
+
writeToSession('\r');
|
|
710
|
+
console.log(`[INJECT+SUBMIT] PTY split_cr for ${id}`);
|
|
692
711
|
}, 300);
|
|
693
|
-
submitResult = { deferred: true, strategy: '
|
|
712
|
+
submitResult = { deferred: true, strategy: 'pty_split_cr' };
|
|
694
713
|
}
|
|
695
714
|
}
|
|
696
715
|
|