@dmsdc-ai/aigentry-telepty 0.1.32 → 0.1.34
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.
- package/daemon.js +22 -11
- package/package.json +1 -1
package/daemon.js
CHANGED
|
@@ -429,12 +429,13 @@ function findKittyWindowId(socket, sessionId) {
|
|
|
429
429
|
for (const osw of data) {
|
|
430
430
|
for (const tab of osw.tabs) {
|
|
431
431
|
for (const w of tab.windows) {
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
432
|
+
// Only check process cmdlines for --id SESSION_ID pattern (not output text)
|
|
433
|
+
for (const p of (w.foreground_processes || [])) {
|
|
434
|
+
const cmd = (p.cmdline || []).join(' ');
|
|
435
|
+
if (cmd.includes('--id ' + sessionId) || cmd.includes('--id=' + sessionId)) {
|
|
436
|
+
return w.id;
|
|
437
|
+
}
|
|
438
|
+
}
|
|
438
439
|
}
|
|
439
440
|
}
|
|
440
441
|
}
|
|
@@ -454,11 +455,21 @@ function sendViaKitty(sessionId, text) {
|
|
|
454
455
|
}
|
|
455
456
|
|
|
456
457
|
try {
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
458
|
+
// Split text and CR — send-text for content, send-key for Enter
|
|
459
|
+
const hasCr = text.endsWith('\r') || text.endsWith('\n');
|
|
460
|
+
const textOnly = hasCr ? text.slice(0, -1) : text;
|
|
461
|
+
if (textOnly.length > 0) {
|
|
462
|
+
const escaped = textOnly.replace(/\\/g, '\\\\').replace(/'/g, "'\\''");
|
|
463
|
+
execSync(`kitty @ --to unix:${socket} send-text --match id:${windowId} '${escaped}'`, {
|
|
464
|
+
timeout: 3000, stdio: ['pipe', 'pipe', 'pipe']
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
if (hasCr) {
|
|
468
|
+
execSync(`kitty @ --to unix:${socket} send-key --match id:${windowId} Return`, {
|
|
469
|
+
timeout: 3000, stdio: ['pipe', 'pipe', 'pipe']
|
|
470
|
+
});
|
|
471
|
+
}
|
|
472
|
+
console.log(`[KITTY] Sent ${textOnly.length} chars${hasCr ? ' + Return' : ''} to ${sessionId} (window ${windowId})`);
|
|
462
473
|
return true;
|
|
463
474
|
} catch (err) {
|
|
464
475
|
console.error(`[KITTY] Failed for ${sessionId}:`, err.message);
|