@dmsdc-ai/aigentry-telepty 0.1.72 → 0.1.74
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/cli.js +4 -6
- package/daemon.js +20 -1
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -871,21 +871,19 @@ async function main() {
|
|
|
871
871
|
const isCr = msg.data === '\r';
|
|
872
872
|
if (isCr && injectQueue.length > 0) {
|
|
873
873
|
// CR with pending queued text — queue CR too and flush immediately.
|
|
874
|
-
// Prevents the busy-session bug where CR fires before queued text,
|
|
875
|
-
// causing empty submit followed by orphaned text without Return.
|
|
876
874
|
injectQueue.push(msg.data);
|
|
877
875
|
if (queueFlushTimer) { clearTimeout(queueFlushTimer); queueFlushTimer = null; }
|
|
878
876
|
flushInjectQueue();
|
|
879
|
-
} else if (isCr
|
|
880
|
-
// CR
|
|
877
|
+
} else if (isCr) {
|
|
878
|
+
// CR always written immediately — never idle-gated
|
|
881
879
|
child.write(msg.data);
|
|
882
|
-
} else if (
|
|
880
|
+
} else if (isIdle()) {
|
|
883
881
|
// Text when idle — write immediately
|
|
884
882
|
child.write(msg.data);
|
|
885
883
|
promptReady = false;
|
|
886
884
|
lastInjectTextTime = Date.now();
|
|
887
885
|
} else {
|
|
888
|
-
//
|
|
886
|
+
// Text when not idle — queue for safe delivery
|
|
889
887
|
injectQueue.push(msg.data);
|
|
890
888
|
scheduleIdleFlush();
|
|
891
889
|
}
|
package/daemon.js
CHANGED
|
@@ -1035,6 +1035,7 @@ app.post('/api/sessions/:id/inject', (req, res) => {
|
|
|
1035
1035
|
|
|
1036
1036
|
console.log(`[INJECT] Wrote to session ${id} (inject_id: ${inject_id})`);
|
|
1037
1037
|
|
|
1038
|
+
const injectTimestamp = new Date().toISOString();
|
|
1038
1039
|
const busMsg = JSON.stringify({
|
|
1039
1040
|
type: 'inject_written',
|
|
1040
1041
|
inject_id,
|
|
@@ -1045,12 +1046,30 @@ app.post('/api/sessions/:id/inject', (req, res) => {
|
|
|
1045
1046
|
reply_to: reply_to || null,
|
|
1046
1047
|
thread_id: thread_id || null,
|
|
1047
1048
|
reply_expected: !!reply_expected,
|
|
1048
|
-
timestamp:
|
|
1049
|
+
timestamp: injectTimestamp
|
|
1049
1050
|
});
|
|
1050
1051
|
busClients.forEach(client => {
|
|
1051
1052
|
if (client.readyState === 1) client.send(busMsg);
|
|
1052
1053
|
});
|
|
1053
1054
|
|
|
1055
|
+
// Notify all attached viewers (telepty attach clients) about the inject
|
|
1056
|
+
// This enables aterm and other viewers to show inject events in real-time
|
|
1057
|
+
if (session.clients && session.clients.size > 0) {
|
|
1058
|
+
const viewerMsg = JSON.stringify({
|
|
1059
|
+
type: 'inject_notification',
|
|
1060
|
+
inject_id,
|
|
1061
|
+
session_id: id,
|
|
1062
|
+
from: from || null,
|
|
1063
|
+
content: prompt,
|
|
1064
|
+
timestamp: injectTimestamp
|
|
1065
|
+
});
|
|
1066
|
+
session.clients.forEach(client => {
|
|
1067
|
+
if (client !== session.ownerWs && client.readyState === 1) {
|
|
1068
|
+
client.send(viewerMsg);
|
|
1069
|
+
}
|
|
1070
|
+
});
|
|
1071
|
+
}
|
|
1072
|
+
|
|
1054
1073
|
if (requestedId !== resolvedId) {
|
|
1055
1074
|
console.log(`[ALIAS] Resolved '${requestedId}' → '${resolvedId}'`);
|
|
1056
1075
|
}
|