@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.
Files changed (2) hide show
  1. package/daemon.js +45 -33
  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;
661
664
 
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)
665
+ let kittyOk = false;
666
+ if (wid && sock) {
667
+ // Kitty send-text primary (bypasses allow bridge queue)
668
668
  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);
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
- } catch {}
687
- }, 300);
688
- submitResult = { deferred: true, strategy: 'split_cr_kitty_backup' };
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: '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.46",
4
4
  "main": "daemon.js",
5
5
  "bin": {
6
6
  "aigentry-telepty": "install.js",