@dmsdc-ai/aigentry-telepty 0.1.78 → 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.
Files changed (3) hide show
  1. package/cli.js +4 -0
  2. package/daemon.js +34 -0
  3. 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
  }
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 = {};
@@ -1297,6 +1300,11 @@ app.post('/api/sessions/:id/inject', async (req, res) => {
1297
1300
  }
1298
1301
  });
1299
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
+
1300
1308
  // Notify all attached viewers (telepty attach clients) about the inject
1301
1309
  // This enables aterm and other viewers to show inject events in real-time
1302
1310
  if (session.clients && session.clients.size > 0) {
@@ -1816,6 +1824,19 @@ setInterval(() => {
1816
1824
  });
1817
1825
  console.log(`[IDLE] Session ${id} idle for ${idleSeconds}s`);
1818
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
+ }
1819
1840
  // Reset idle flag when activity resumes
1820
1841
  if (idleSeconds !== null && idleSeconds < IDLE_THRESHOLD_SECONDS) {
1821
1842
  session._idleEmitted = false;
@@ -1977,6 +1998,19 @@ wss.on('connection', (ws, req) => {
1977
1998
  busClients.forEach(client => {
1978
1999
  if (client.readyState === 1) client.send(readyMsg);
1979
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
+ }
1980
2014
  }
1981
2015
  } else {
1982
2016
  // Non-owner client input -> forward to owner as inject
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dmsdc-ai/aigentry-telepty",
3
- "version": "0.1.78",
3
+ "version": "0.1.79",
4
4
  "main": "daemon.js",
5
5
  "bin": {
6
6
  "aigentry-telepty": "install.js",