@dmsdc-ai/aigentry-telepty 0.1.43 → 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 +46 -34
  2. 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 (!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;
664
+
665
+ // Always send via WS too (for new allow bridges with queue flush)
666
+ writeToSession(finalPrompt);
661
667
 
662
- if (!no_enter) {
663
- // Split_cr: text first, \r after delay + kitty send-key Return as backup
664
- setTimeout(() => {
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)
668
+ if (wid && sock) {
669
+ // Kitty send-text for reliable text delivery
668
670
  try {
669
- const sock = findKittySocket();
670
- if (sock) {
671
- if (!session.kittyWindowId) session.kittyWindowId = findKittyWindowId(sock, id);
672
- if (session.kittyWindowId) {
673
- const { execSync } = require('child_process');
674
- setTimeout(() => {
675
- try {
676
- execSync(`kitty @ --to unix:${sock} send-key --match id:${session.kittyWindowId} Return`, {
677
- timeout: 3000, stdio: ['pipe', 'pipe', 'pipe']
678
- });
679
- execSync(`kitty @ --to unix:${sock} set-tab-title --match id:${session.kittyWindowId} '⚡ telepty :: ${id}'`, {
680
- timeout: 2000, stdio: ['pipe', 'pipe', 'pipe']
681
- });
682
- } catch {}
683
- }, 500);
684
- }
685
- }
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})`);
686
676
  } catch {}
687
- }, 300);
688
- submitResult = { deferred: true, strategy: 'split_cr_kitty_backup' };
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}'`, {
686
+ timeout: 2000, stdio: ['pipe', 'pipe', 'pipe']
687
+ });
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
+ }
689
702
  } else {
703
+ // Spawned sessions: direct PTY write
690
704
  if (!writeToSession(finalPrompt)) {
691
- return res.status(503).json({ error: 'Wrap process is not connected' });
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
- const ok = writeToSession('\r');
698
- console.log(`[INJECT+SUBMIT] Split \\r for ${id}: ${ok ? 'success' : 'failed'}`);
709
+ writeToSession('\r');
710
+ console.log(`[INJECT+SUBMIT] PTY split_cr for ${id}`);
699
711
  }, 300);
700
- submitResult = { deferred: true, strategy: 'split_cr' };
712
+ submitResult = { deferred: true, strategy: 'pty_split_cr' };
701
713
  }
702
714
  }
703
715
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dmsdc-ai/aigentry-telepty",
3
- "version": "0.1.43",
3
+ "version": "0.1.45",
4
4
  "main": "daemon.js",
5
5
  "bin": {
6
6
  "aigentry-telepty": "install.js",