@dmsdc-ai/aigentry-telepty 0.1.94 → 0.1.95
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 +20 -10
- package/package.json +1 -1
package/daemon.js
CHANGED
|
@@ -561,11 +561,9 @@ async function deliverInjectionToSession(id, session, prompt, options = {}) {
|
|
|
561
561
|
return { success: false, ...injectFailure };
|
|
562
562
|
}
|
|
563
563
|
|
|
564
|
-
//
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
: prompt;
|
|
568
|
-
|
|
564
|
+
// Mailbox payload is TEXT ONLY — CR is sent separately after a delay.
|
|
565
|
+
// Reason: combining text+CR in one write triggers bracketed paste mode in modern
|
|
566
|
+
// terminals. CLIs ignore \r inside paste brackets, so Enter never fires.
|
|
569
567
|
const from = options.from || 'daemon';
|
|
570
568
|
const msgId = `${from}:${Date.now()}:${crypto.randomUUID().slice(0, 8)}`;
|
|
571
569
|
|
|
@@ -574,7 +572,7 @@ async function deliverInjectionToSession(id, session, prompt, options = {}) {
|
|
|
574
572
|
msg_id: msgId,
|
|
575
573
|
from,
|
|
576
574
|
to: id,
|
|
577
|
-
payload,
|
|
575
|
+
payload: prompt,
|
|
578
576
|
created_at: Math.floor(now / 1000),
|
|
579
577
|
attempt: 0,
|
|
580
578
|
});
|
|
@@ -584,13 +582,25 @@ async function deliverInjectionToSession(id, session, prompt, options = {}) {
|
|
|
584
582
|
mailboxNotifier.notify(id);
|
|
585
583
|
}
|
|
586
584
|
|
|
587
|
-
// Deliver synchronously — ensures text is written before inject returns success.
|
|
588
|
-
// Mailbox gives us persistence/retry, but the initial delivery must complete
|
|
589
|
-
// before the HTTP response so --submit timing and CR delivery are reliable.
|
|
585
|
+
// Deliver text synchronously — ensures text is written before inject returns success.
|
|
590
586
|
try {
|
|
591
587
|
await mailboxDelivery.tick();
|
|
592
588
|
} catch {}
|
|
593
589
|
|
|
590
|
+
// Send CR separately after delay (outside paste brackets)
|
|
591
|
+
if (!options.noEnter && session.type !== 'aterm') {
|
|
592
|
+
const submitDelay = session.type === 'wrapped' ? 500 : 300;
|
|
593
|
+
setTimeout(async () => {
|
|
594
|
+
const submitResult = await writeDataToSession(id, session, '\r');
|
|
595
|
+
if (!submitResult.success) {
|
|
596
|
+
emitInjectFailureEvent(id, submitResult.code, submitResult.error, {
|
|
597
|
+
phase: 'submit',
|
|
598
|
+
source: options.source || 'inject'
|
|
599
|
+
}, session);
|
|
600
|
+
}
|
|
601
|
+
}, submitDelay);
|
|
602
|
+
}
|
|
603
|
+
|
|
594
604
|
session.lastActivityAt = new Date(now).toISOString();
|
|
595
605
|
return {
|
|
596
606
|
success: true,
|
|
@@ -598,7 +608,7 @@ async function deliverInjectionToSession(id, session, prompt, options = {}) {
|
|
|
598
608
|
queued: ack.queued,
|
|
599
609
|
pending: ack.pending,
|
|
600
610
|
strategy: 'mailbox',
|
|
601
|
-
submit: options.noEnter ? 'skipped' : '
|
|
611
|
+
submit: options.noEnter ? 'skipped' : 'deferred'
|
|
602
612
|
};
|
|
603
613
|
} catch (err) {
|
|
604
614
|
console.error(`[MAILBOX] Enqueue failed for ${id}: ${err.message}`);
|