@dmsdc-ai/aigentry-telepty 0.1.30 → 0.1.32

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 +39 -11
  2. package/package.json +1 -1
package/daemon.js CHANGED
@@ -414,24 +414,51 @@ function submitViaPty(session) {
414
414
  }
415
415
 
416
416
  // Send text directly to Kitty tab via remote control (bypasses allow bridge entirely)
417
- function sendViaKitty(sessionId, text) {
417
+ function findKittySocket() {
418
+ try {
419
+ const files = require('fs').readdirSync('/tmp').filter(f => f.startsWith('kitty-sock'));
420
+ return files.length > 0 ? '/tmp/' + files[0] : null;
421
+ } catch { return null; }
422
+ }
423
+
424
+ function findKittyWindowId(socket, sessionId) {
418
425
  const { execSync } = require('child_process');
419
- // Find kitty socket: /tmp/kitty-sock or /tmp/kitty-sock-PID
420
- const fs = require('fs');
421
- let socket = null;
422
426
  try {
423
- const files = fs.readdirSync('/tmp').filter(f => f.startsWith('kitty-sock'));
424
- if (files.length > 0) socket = '/tmp/' + files[0];
425
- } catch { /* /tmp not readable */ }
427
+ const raw = execSync(`kitty @ --to unix:${socket} ls`, { timeout: 3000, encoding: 'utf8', stdio: ['pipe', 'pipe', 'pipe'] });
428
+ const data = JSON.parse(raw);
429
+ for (const osw of data) {
430
+ for (const tab of osw.tabs) {
431
+ for (const w of tab.windows) {
432
+ const cmds = (w.foreground_processes || []).map(p => (p.cmdline || []).join(' ')).join(' ');
433
+ // Check full process tree cmdline for session ID
434
+ if (cmds.includes(sessionId)) return w.id;
435
+ // Also check the window's own cmdline/title
436
+ const allCmds = JSON.stringify(w);
437
+ if (allCmds.includes(sessionId)) return w.id;
438
+ }
439
+ }
440
+ }
441
+ } catch {}
442
+ return null;
443
+ }
444
+
445
+ function sendViaKitty(sessionId, text) {
446
+ const { execSync } = require('child_process');
447
+ const socket = findKittySocket();
426
448
  if (!socket) return false;
427
449
 
450
+ const windowId = findKittyWindowId(socket, sessionId);
451
+ if (!windowId) {
452
+ console.error(`[KITTY] No window found for ${sessionId}`);
453
+ return false;
454
+ }
455
+
428
456
  try {
429
- // Match by tab title containing session ID
430
457
  const escaped = text.replace(/\\/g, '\\\\').replace(/'/g, "'\\''");
431
- execSync(`kitty @ --to unix:${socket} send-text --match title:${sessionId} '${escaped}'`, {
458
+ execSync(`kitty @ --to unix:${socket} send-text --match id:${windowId} '${escaped}'`, {
432
459
  timeout: 3000, stdio: ['pipe', 'pipe', 'pipe']
433
460
  });
434
- console.log(`[KITTY] Sent ${text.length} chars to ${sessionId}`);
461
+ console.log(`[KITTY] Sent ${text.length} chars to ${sessionId} (window ${windowId})`);
435
462
  return true;
436
463
  } catch (err) {
437
464
  console.error(`[KITTY] Failed for ${sessionId}:`, err.message);
@@ -1045,7 +1072,8 @@ wss.on('connection', (ws, req) => {
1045
1072
  };
1046
1073
  sessions[sessionId] = autoSession;
1047
1074
  console.log(`[WS] Auto-registered wrapped session ${sessionId} on reconnect`);
1048
- // Skip to message/close handlers below (ownerWs already set)
1075
+ // Trigger CLI redraw via kitty Ctrl+L after short delay
1076
+ setTimeout(() => sendViaKitty(sessionId, '\x0c'), 1000);
1049
1077
  } else {
1050
1078
  session.clients.add(ws);
1051
1079
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dmsdc-ai/aigentry-telepty",
3
- "version": "0.1.30",
3
+ "version": "0.1.32",
4
4
  "main": "daemon.js",
5
5
  "bin": {
6
6
  "aigentry-telepty": "install.js",