@dmsdc-ai/aigentry-telepty 0.1.77 → 0.1.79
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 +5 -1
- package/daemon.js +37 -15
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -1100,6 +1100,10 @@ async function main() {
|
|
|
1100
1100
|
scheduleIdleFlush();
|
|
1101
1101
|
}
|
|
1102
1102
|
}
|
|
1103
|
+
// Reset readyNotified so next prompt detection re-notifies daemon (auto-report)
|
|
1104
|
+
if (rawData && rawData !== '\r') {
|
|
1105
|
+
readyNotified = false;
|
|
1106
|
+
}
|
|
1103
1107
|
} else if (msg.type === 'resize') {
|
|
1104
1108
|
child.resize(msg.cols, msg.rows);
|
|
1105
1109
|
}
|
|
@@ -1521,7 +1525,7 @@ async function main() {
|
|
|
1521
1525
|
const submitRes = await fetchWithAuth(`http://${target.host}:${PORT}/api/sessions/${encodeURIComponent(target.id)}/submit`, {
|
|
1522
1526
|
method: 'POST',
|
|
1523
1527
|
headers: { 'Content-Type': 'application/json' },
|
|
1524
|
-
body: JSON.stringify({ pre_delay_ms:
|
|
1528
|
+
body: JSON.stringify({ pre_delay_ms: 600, retries: 2, retry_delay_ms: 500 })
|
|
1525
1529
|
});
|
|
1526
1530
|
const submitData = await submitRes.json();
|
|
1527
1531
|
if (submitRes.ok) {
|
package/daemon.js
CHANGED
|
@@ -160,6 +160,9 @@ if (!daemonClaim.claimed) {
|
|
|
160
160
|
process.exit(0);
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
+
const pendingReports = {}; // {targetSessionId: {source, injectedAt, injectId}}
|
|
164
|
+
const AUTO_REPORT_IDLE_SECONDS = Number(process.env.TELEPTY_AUTO_REPORT_IDLE_SECONDS) || 10;
|
|
165
|
+
|
|
163
166
|
const sessions = {};
|
|
164
167
|
const handoffs = {};
|
|
165
168
|
const threads = {};
|
|
@@ -1175,28 +1178,16 @@ app.post('/api/sessions/:id/submit', async (req, res) => {
|
|
|
1175
1178
|
const retryDelayMs = Math.min(Math.max(Number(req.body?.retry_delay_ms) || 500, 100), 2000);
|
|
1176
1179
|
const preDelayMs = Math.min(Math.max(Number(req.body?.pre_delay_ms) || 0, 0), 1000);
|
|
1177
1180
|
|
|
1178
|
-
const strategy =
|
|
1181
|
+
const strategy = 'pty_cr';
|
|
1179
1182
|
console.log(`[SUBMIT] Session ${id} (${session.command}) strategy: ${strategy}${retries > 0 ? `, retries: ${retries}, pre_delay: ${preDelayMs}ms` : ''}`);
|
|
1180
1183
|
|
|
1181
|
-
// Pre-delay: wait for paste
|
|
1184
|
+
// Pre-delay: wait for paste rendering to complete before sending CR
|
|
1182
1185
|
if (preDelayMs > 0) {
|
|
1183
1186
|
await new Promise(resolve => setTimeout(resolve, preDelayMs));
|
|
1184
1187
|
}
|
|
1185
1188
|
|
|
1186
1189
|
function executeSubmit() {
|
|
1187
|
-
|
|
1188
|
-
if (session.backend === 'cmux') {
|
|
1189
|
-
if (terminalBackend.cmuxSendEnter(id)) return true;
|
|
1190
|
-
}
|
|
1191
|
-
if (session.backend === 'cmux' && session.cmuxWorkspaceId) {
|
|
1192
|
-
if (submitViaCmux(id)) return true;
|
|
1193
|
-
}
|
|
1194
|
-
if (strategy === 'pty_cr') {
|
|
1195
|
-
return submitViaPty(session);
|
|
1196
|
-
} else if (strategy === 'osascript_cmd_enter') {
|
|
1197
|
-
return submitViaOsascript(id, 'cmd_enter');
|
|
1198
|
-
}
|
|
1199
|
-
return submitViaPty(session); // fallback
|
|
1190
|
+
return submitViaPty(session);
|
|
1200
1191
|
}
|
|
1201
1192
|
|
|
1202
1193
|
let success = executeSubmit();
|
|
@@ -1309,6 +1300,11 @@ app.post('/api/sessions/:id/inject', async (req, res) => {
|
|
|
1309
1300
|
}
|
|
1310
1301
|
});
|
|
1311
1302
|
|
|
1303
|
+
// Auto-report: track pending inject for idle notification back to source
|
|
1304
|
+
if (from) {
|
|
1305
|
+
pendingReports[id] = { source: from, injectedAt: injectTimestamp, injectId: inject_id };
|
|
1306
|
+
}
|
|
1307
|
+
|
|
1312
1308
|
// Notify all attached viewers (telepty attach clients) about the inject
|
|
1313
1309
|
// This enables aterm and other viewers to show inject events in real-time
|
|
1314
1310
|
if (session.clients && session.clients.size > 0) {
|
|
@@ -1828,6 +1824,19 @@ setInterval(() => {
|
|
|
1828
1824
|
});
|
|
1829
1825
|
console.log(`[IDLE] Session ${id} idle for ${idleSeconds}s`);
|
|
1830
1826
|
}
|
|
1827
|
+
// Auto-report for non-wrapped sessions: use idle threshold
|
|
1828
|
+
const pendingRpt = pendingReports[id];
|
|
1829
|
+
if (pendingRpt && session.type !== 'wrapped' && idleSeconds !== null && idleSeconds >= AUTO_REPORT_IDLE_SECONDS) {
|
|
1830
|
+
delete pendingReports[id];
|
|
1831
|
+
const elapsed = ((Date.now() - new Date(pendingRpt.injectedAt).getTime()) / 1000).toFixed(1);
|
|
1832
|
+
const reportMsg = `TASK_COMPLETE: ${id} is now idle after processing inject (${elapsed}s)`;
|
|
1833
|
+
const srcId = resolveSessionAlias(pendingRpt.source) || pendingRpt.source;
|
|
1834
|
+
const srcSession = sessions[srcId];
|
|
1835
|
+
if (srcSession) {
|
|
1836
|
+
deliverInjectionToSession(srcId, srcSession, reportMsg, { noEnter: false, source: 'auto_report' });
|
|
1837
|
+
console.log(`[AUTO-REPORT] ${id} → ${srcId}: idle after ${elapsed}s (threshold)`);
|
|
1838
|
+
}
|
|
1839
|
+
}
|
|
1831
1840
|
// Reset idle flag when activity resumes
|
|
1832
1841
|
if (idleSeconds !== null && idleSeconds < IDLE_THRESHOLD_SECONDS) {
|
|
1833
1842
|
session._idleEmitted = false;
|
|
@@ -1989,6 +1998,19 @@ wss.on('connection', (ws, req) => {
|
|
|
1989
1998
|
busClients.forEach(client => {
|
|
1990
1999
|
if (client.readyState === 1) client.send(readyMsg);
|
|
1991
2000
|
});
|
|
2001
|
+
// Auto-report: notify source that target completed inject task
|
|
2002
|
+
const pendingReport = pendingReports[sessionId];
|
|
2003
|
+
if (pendingReport) {
|
|
2004
|
+
delete pendingReports[sessionId];
|
|
2005
|
+
const elapsed = ((Date.now() - new Date(pendingReport.injectedAt).getTime()) / 1000).toFixed(1);
|
|
2006
|
+
const reportMsg = `TASK_COMPLETE: ${sessionId} is now idle after processing inject (${elapsed}s)`;
|
|
2007
|
+
const srcId = resolveSessionAlias(pendingReport.source) || pendingReport.source;
|
|
2008
|
+
const srcSession = sessions[srcId];
|
|
2009
|
+
if (srcSession) {
|
|
2010
|
+
deliverInjectionToSession(srcId, srcSession, reportMsg, { noEnter: false, source: 'auto_report' });
|
|
2011
|
+
console.log(`[AUTO-REPORT] ${sessionId} → ${srcId}: idle after ${elapsed}s`);
|
|
2012
|
+
}
|
|
2013
|
+
}
|
|
1992
2014
|
}
|
|
1993
2015
|
} else {
|
|
1994
2016
|
// Non-owner client input -> forward to owner as inject
|