@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.
Files changed (2) hide show
  1. package/daemon.js +45 -26
  2. 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 (!writeToSession(finalPrompt)) {
659
- return res.status(503).json({ error: 'Wrap process is not connected' });
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
- if (!no_enter) {
663
- // Universal split_cr: text first, \r after delay
664
- // Allow bridge 0.1.40+ has 3s queue flush timeout, so \r always gets delivered
665
- setTimeout(() => {
666
- const ok = writeToSession('\r');
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 sock = findKittySocket();
671
- if (sock) {
672
- if (!session.kittyWindowId) session.kittyWindowId = findKittyWindowId(sock, id);
673
- if (session.kittyWindowId) {
674
- require('child_process').execSync(`kitty @ --to unix:${sock} set-tab-title --match id:${session.kittyWindowId} '⚡ telepty :: ${id}'`, {
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
- } catch {}
680
- }, 300);
681
- submitResult = { deferred: true, strategy: 'split_cr' };
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: 'Wrap process is not connected' });
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
- const ok = writeToSession('\r');
691
- console.log(`[INJECT+SUBMIT] Split \\r for ${id}: ${ok ? 'success' : 'failed'}`);
709
+ writeToSession('\r');
710
+ console.log(`[INJECT+SUBMIT] PTY split_cr for ${id}`);
692
711
  }, 300);
693
- submitResult = { deferred: true, strategy: 'split_cr' };
712
+ submitResult = { deferred: true, strategy: 'pty_split_cr' };
694
713
  }
695
714
  }
696
715
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dmsdc-ai/aigentry-telepty",
3
- "version": "0.1.42",
3
+ "version": "0.1.45",
4
4
  "main": "daemon.js",
5
5
  "bin": {
6
6
  "aigentry-telepty": "install.js",