@dmsdc-ai/aigentry-telepty 0.1.43 → 0.1.46
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 -33
- package/package.json +1 -1
package/daemon.js
CHANGED
|
@@ -655,49 +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
|
-
const ok = writeToSession('\r');
|
|
666
|
-
console.log(`[INJECT+SUBMIT] Split \\r for ${id}: ${ok ? 'success' : 'failed'}`);
|
|
667
|
-
// Kitty send-key Return as backup (handles old allow bridges without queue flush)
|
|
665
|
+
let kittyOk = false;
|
|
666
|
+
if (wid && sock) {
|
|
667
|
+
// Kitty send-text primary (bypasses allow bridge queue)
|
|
668
668
|
try {
|
|
669
|
-
const
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
669
|
+
const escaped = finalPrompt.replace(/\\/g, '\\\\').replace(/'/g, "'\\''");
|
|
670
|
+
require('child_process').execSync(`kitty @ --to unix:${sock} send-text --match id:${wid} '${escaped}'`, {
|
|
671
|
+
timeout: 5000, stdio: ['pipe', 'pipe', 'pipe']
|
|
672
|
+
});
|
|
673
|
+
kittyOk = true;
|
|
674
|
+
console.log(`[INJECT] Kitty send-text for ${id} (window ${wid})`);
|
|
675
|
+
} catch {}
|
|
676
|
+
}
|
|
677
|
+
if (!kittyOk) {
|
|
678
|
+
// Fallback: WS (works with new allow bridges that have queue flush)
|
|
679
|
+
writeToSession(finalPrompt);
|
|
680
|
+
console.log(`[INJECT] WS fallback for ${id}`);
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
if (!no_enter) {
|
|
684
|
+
setTimeout(() => {
|
|
685
|
+
if (wid && sock) {
|
|
686
|
+
try {
|
|
687
|
+
require('child_process').execSync(`kitty @ --to unix:${sock} send-key --match id:${wid} Return`, {
|
|
688
|
+
timeout: 3000, stdio: ['pipe', 'pipe', 'pipe']
|
|
689
|
+
});
|
|
690
|
+
require('child_process').execSync(`kitty @ --to unix:${sock} set-tab-title --match id:${wid} '⚡ telepty :: ${id}'`, {
|
|
691
|
+
timeout: 2000, stdio: ['pipe', 'pipe', 'pipe']
|
|
692
|
+
});
|
|
693
|
+
} catch {
|
|
694
|
+
writeToSession('\r');
|
|
684
695
|
}
|
|
696
|
+
} else {
|
|
697
|
+
writeToSession('\r');
|
|
685
698
|
}
|
|
686
|
-
}
|
|
687
|
-
|
|
688
|
-
|
|
699
|
+
}, 500);
|
|
700
|
+
submitResult = { deferred: true, strategy: kittyOk ? 'kitty_text_key' : 'ws_split_cr' };
|
|
701
|
+
}
|
|
689
702
|
} else {
|
|
703
|
+
// Spawned sessions: direct PTY write
|
|
690
704
|
if (!writeToSession(finalPrompt)) {
|
|
691
|
-
return res.status(503).json({ error: '
|
|
705
|
+
return res.status(503).json({ error: 'Process not connected' });
|
|
692
706
|
}
|
|
693
|
-
|
|
694
707
|
if (!no_enter) {
|
|
695
|
-
// Spawned sessions: send \r separately after delay (proven split_cr strategy)
|
|
696
708
|
setTimeout(() => {
|
|
697
|
-
|
|
698
|
-
console.log(`[INJECT+SUBMIT]
|
|
709
|
+
writeToSession('\r');
|
|
710
|
+
console.log(`[INJECT+SUBMIT] PTY split_cr for ${id}`);
|
|
699
711
|
}, 300);
|
|
700
|
-
submitResult = { deferred: true, strategy: '
|
|
712
|
+
submitResult = { deferred: true, strategy: 'pty_split_cr' };
|
|
701
713
|
}
|
|
702
714
|
}
|
|
703
715
|
|