@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.
Files changed (3) hide show
  1. package/cli.js +12 -0
  2. package/daemon.js +20 -33
  3. 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 (session.type === 'wrapped' && !no_enter) {
643
- // Hybrid: text via WS (allow bridge handles it), Enter via kitty send-key
644
- if (!writeToSession(finalPrompt)) {
645
- return res.status(503).json({ error: 'Wrap process is not connected' });
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
- // Try kitty send-key Return (reliable for all CLIs)
649
- const windowId = findKittyWindowId(findKittySocket(), id);
650
- if (windowId) {
651
- try {
652
- const { execSync } = require('child_process');
653
- execSync(`kitty @ --to unix:${findKittySocket()} send-key --match id:${windowId} Return`, {
654
- timeout: 3000, stdio: ['pipe', 'pipe', 'pipe']
655
- });
656
- console.log(`[INJECT+SUBMIT] WS text + kitty Return for ${id} (window ${windowId})`);
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
- } catch {}
663
- } catch {
664
- writeToSession('\r');
665
- console.log(`[INJECT+SUBMIT] WS text + WS \\r fallback for ${id}`);
661
+ }
666
662
  }
667
- } else {
668
- writeToSession('\r');
669
- console.log(`[INJECT+SUBMIT] WS text + WS \\r (no kitty window) for ${id}`);
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' });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dmsdc-ai/aigentry-telepty",
3
- "version": "0.1.40",
3
+ "version": "0.1.41",
4
4
  "main": "daemon.js",
5
5
  "bin": {
6
6
  "aigentry-telepty": "install.js",