@dmsdc-ai/aigentry-telepty 0.1.45 → 0.1.47
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 -21
- package/package.json +1 -1
package/daemon.js
CHANGED
|
@@ -633,8 +633,9 @@ app.post('/api/sessions/:id/inject', (req, res) => {
|
|
|
633
633
|
if (from && !prompt.startsWith('[from:')) {
|
|
634
634
|
finalPrompt = `[from: ${from}] [reply-to: ${reply_to}] ${prompt}`;
|
|
635
635
|
}
|
|
636
|
-
// Append reply guide when reply_to is set
|
|
637
|
-
|
|
636
|
+
// Append reply guide when reply_to is set, UNLESS message contains termination signal
|
|
637
|
+
const TERMINATION_SIGNALS = /no further reply needed|thread closed|closed on .+ side|ack received|ack-only|회신 불필요|스레드 종료/i;
|
|
638
|
+
if (reply_to && reply_to !== id && !TERMINATION_SIGNALS.test(prompt)) {
|
|
638
639
|
finalPrompt += `\n\n---\n[reply-to: ${reply_to}] 위 세션에 회신이 필요합니다. 답변 시 아래 명령을 실행하세요:\ntelepty inject --from ${id} ${reply_to} "답변 내용"\n---`;
|
|
639
640
|
}
|
|
640
641
|
const inject_id = crypto.randomUUID();
|
|
@@ -662,42 +663,42 @@ app.post('/api/sessions/:id/inject', (req, res) => {
|
|
|
662
663
|
if (!session.kittyWindowId && sock) session.kittyWindowId = findKittyWindowId(sock, id);
|
|
663
664
|
const wid = session.kittyWindowId;
|
|
664
665
|
|
|
665
|
-
|
|
666
|
-
writeToSession(finalPrompt);
|
|
667
|
-
|
|
666
|
+
let kittyOk = false;
|
|
668
667
|
if (wid && sock) {
|
|
669
|
-
// Kitty send-text
|
|
668
|
+
// Kitty send-text primary (bypasses allow bridge queue)
|
|
670
669
|
try {
|
|
671
670
|
const escaped = finalPrompt.replace(/\\/g, '\\\\').replace(/'/g, "'\\''");
|
|
672
671
|
require('child_process').execSync(`kitty @ --to unix:${sock} send-text --match id:${wid} '${escaped}'`, {
|
|
673
672
|
timeout: 5000, stdio: ['pipe', 'pipe', 'pipe']
|
|
674
673
|
});
|
|
674
|
+
kittyOk = true;
|
|
675
675
|
console.log(`[INJECT] Kitty send-text for ${id} (window ${wid})`);
|
|
676
676
|
} catch {}
|
|
677
|
+
}
|
|
678
|
+
if (!kittyOk) {
|
|
679
|
+
// Fallback: WS (works with new allow bridges that have queue flush)
|
|
680
|
+
writeToSession(finalPrompt);
|
|
681
|
+
console.log(`[INJECT] WS fallback for ${id}`);
|
|
682
|
+
}
|
|
677
683
|
|
|
678
|
-
|
|
679
|
-
|
|
684
|
+
if (!no_enter) {
|
|
685
|
+
setTimeout(() => {
|
|
686
|
+
if (wid && sock) {
|
|
680
687
|
try {
|
|
681
|
-
writeToSession('\r'); // WS \r for new bridges
|
|
682
688
|
require('child_process').execSync(`kitty @ --to unix:${sock} send-key --match id:${wid} Return`, {
|
|
683
689
|
timeout: 3000, stdio: ['pipe', 'pipe', 'pipe']
|
|
684
690
|
});
|
|
685
691
|
require('child_process').execSync(`kitty @ --to unix:${sock} set-tab-title --match id:${wid} '⚡ telepty :: ${id}'`, {
|
|
686
692
|
timeout: 2000, stdio: ['pipe', 'pipe', 'pipe']
|
|
687
693
|
});
|
|
688
|
-
} catch {
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
} else {
|
|
693
|
-
// No kitty — WS only
|
|
694
|
-
if (!no_enter) {
|
|
695
|
-
setTimeout(() => {
|
|
694
|
+
} catch {
|
|
695
|
+
writeToSession('\r');
|
|
696
|
+
}
|
|
697
|
+
} else {
|
|
696
698
|
writeToSession('\r');
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
}
|
|
699
|
+
}
|
|
700
|
+
}, 500);
|
|
701
|
+
submitResult = { deferred: true, strategy: kittyOk ? 'kitty_text_key' : 'ws_split_cr' };
|
|
701
702
|
}
|
|
702
703
|
} else {
|
|
703
704
|
// Spawned sessions: direct PTY write
|