@dmsdc-ai/aigentry-telepty 0.1.40 → 0.1.41
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 +12 -0
- package/daemon.js +20 -33
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -705,7 +705,9 @@ async function main() {
|
|
|
705
705
|
let promptReady = true; // assume ready initially for first inject
|
|
706
706
|
const injectQueue = [];
|
|
707
707
|
|
|
708
|
+
let queueFlushTimer = null;
|
|
708
709
|
function flushInjectQueue() {
|
|
710
|
+
if (queueFlushTimer) { clearTimeout(queueFlushTimer); queueFlushTimer = null; }
|
|
709
711
|
if (injectQueue.length === 0) return;
|
|
710
712
|
const batch = injectQueue.splice(0);
|
|
711
713
|
let delay = 0;
|
|
@@ -715,6 +717,15 @@ async function main() {
|
|
|
715
717
|
}
|
|
716
718
|
promptReady = false;
|
|
717
719
|
}
|
|
720
|
+
function scheduleQueueFlush() {
|
|
721
|
+
if (queueFlushTimer) return;
|
|
722
|
+
queueFlushTimer = setTimeout(() => {
|
|
723
|
+
queueFlushTimer = null;
|
|
724
|
+
if (injectQueue.length > 0) {
|
|
725
|
+
flushInjectQueue();
|
|
726
|
+
}
|
|
727
|
+
}, 3000);
|
|
728
|
+
}
|
|
718
729
|
|
|
719
730
|
// Connect to daemon WebSocket with auto-reconnect
|
|
720
731
|
const wsUrl = `ws://${REMOTE_HOST}:${PORT}/api/sessions/${encodeURIComponent(sessionId)}?token=${encodeURIComponent(TOKEN)}`;
|
|
@@ -767,6 +778,7 @@ async function main() {
|
|
|
767
778
|
}
|
|
768
779
|
} else {
|
|
769
780
|
injectQueue.push(msg.data);
|
|
781
|
+
scheduleQueueFlush();
|
|
770
782
|
}
|
|
771
783
|
} else if (msg.type === 'resize') {
|
|
772
784
|
child.resize(msg.cols, msg.rows);
|
package/daemon.js
CHANGED
|
@@ -639,43 +639,30 @@ app.post('/api/sessions/:id/inject', (req, res) => {
|
|
|
639
639
|
}
|
|
640
640
|
|
|
641
641
|
let submitResult = null;
|
|
642
|
-
if (
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
642
|
+
if (!writeToSession(finalPrompt)) {
|
|
643
|
+
return res.status(503).json({ error: 'Wrap process is not connected' });
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
if (!no_enter) {
|
|
647
|
+
// Universal split_cr: text first, \r after delay
|
|
648
|
+
// Allow bridge 0.1.40+ has 3s queue flush timeout, so \r always gets delivered
|
|
647
649
|
setTimeout(() => {
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
if
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
// Restore tab title after inject (Claude Code overwrites it)
|
|
658
|
-
try {
|
|
659
|
-
execSync(`kitty @ --to unix:${findKittySocket()} set-tab-title --match id:${windowId} '⚡ telepty :: ${id}'`, {
|
|
650
|
+
const ok = writeToSession('\r');
|
|
651
|
+
console.log(`[INJECT+SUBMIT] Split \\r for ${id}: ${ok ? 'success' : 'failed'}`);
|
|
652
|
+
// Restore kitty tab title (optional, no-op if not kitty)
|
|
653
|
+
try {
|
|
654
|
+
const sock = findKittySocket();
|
|
655
|
+
if (sock) {
|
|
656
|
+
if (!session.kittyWindowId) session.kittyWindowId = findKittyWindowId(sock, id);
|
|
657
|
+
if (session.kittyWindowId) {
|
|
658
|
+
require('child_process').execSync(`kitty @ --to unix:${sock} set-tab-title --match id:${session.kittyWindowId} '⚡ telepty :: ${id}'`, {
|
|
660
659
|
timeout: 2000, stdio: ['pipe', 'pipe', 'pipe']
|
|
661
660
|
});
|
|
662
|
-
}
|
|
663
|
-
} catch {
|
|
664
|
-
writeToSession('\r');
|
|
665
|
-
console.log(`[INJECT+SUBMIT] WS text + WS \\r fallback for ${id}`);
|
|
661
|
+
}
|
|
666
662
|
}
|
|
667
|
-
}
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
}
|
|
671
|
-
}, 500);
|
|
672
|
-
submitResult = { deferred: true, strategy: 'ws_text_kitty_return' };
|
|
673
|
-
} else if (session.type === 'wrapped') {
|
|
674
|
-
// no_enter=true for wrapped
|
|
675
|
-
if (!writeToSession(finalPrompt)) {
|
|
676
|
-
return res.status(503).json({ error: 'Wrap process is not connected' });
|
|
677
|
-
}
|
|
678
|
-
submitResult = { strategy: 'ws_no_enter' };
|
|
663
|
+
} catch {}
|
|
664
|
+
}, 300);
|
|
665
|
+
submitResult = { deferred: true, strategy: 'split_cr' };
|
|
679
666
|
} else {
|
|
680
667
|
if (!writeToSession(finalPrompt)) {
|
|
681
668
|
return res.status(503).json({ error: 'Wrap process is not connected' });
|