@dmsdc-ai/aigentry-telepty 0.0.13 → 0.0.15

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 (2) hide show
  1. package/cli.js +25 -8
  2. package/package.json +2 -1
package/cli.js CHANGED
@@ -5,9 +5,14 @@ const WebSocket = require('ws');
5
5
  const { execSync, spawn } = require('child_process');
6
6
  const readline = require('readline');
7
7
  const prompts = require('prompts');
8
+ const updateNotifier = require('update-notifier');
9
+ const pkg = require('./package.json');
8
10
  const { getConfig } = require('./auth');
9
11
  const args = process.argv.slice(2);
10
12
 
13
+ // Check for updates
14
+ updateNotifier({pkg}).notify({ isGlobal: true });
15
+
11
16
  // Support remote host via environment variable or default to localhost
12
17
  let REMOTE_HOST = process.env.TELEPTY_HOST || '127.0.0.1';
13
18
  const PORT = 3848;
@@ -22,7 +27,27 @@ const fetchWithAuth = (url, options = {}) => {
22
27
  return fetch(url, { ...options, headers });
23
28
  };
24
29
 
30
+ async function ensureDaemonRunning() {
31
+ if (REMOTE_HOST !== '127.0.0.1') return; // Only auto-start local daemon
32
+ try {
33
+ const res = await fetchWithAuth(`${DAEMON_URL}/api/sessions`);
34
+ if (res.ok) return; // Already running
35
+ } catch (e) {
36
+ // Not running, let's start it
37
+ process.stdout.write('\x1b[33m⚙️ Auto-starting local telepty daemon...\x1b[0m\n');
38
+ const cp = spawn(process.argv[0], [process.argv[1], 'daemon'], {
39
+ detached: true,
40
+ stdio: 'ignore'
41
+ });
42
+ cp.unref();
43
+
44
+ // Wait a brief moment for the daemon to boot up
45
+ await new Promise(r => setTimeout(r, 1000));
46
+ }
47
+ }
48
+
25
49
  async function discoverSessions() {
50
+ await ensureDaemonRunning();
26
51
  const hosts = ['127.0.0.1'];
27
52
  try {
28
53
  const tsStatus = execSync('tailscale status --json', { encoding: 'utf8', stdio: ['pipe', 'pipe', 'ignore'] });
@@ -152,8 +177,6 @@ async function manageInteractive() {
152
177
  { type: 'text', name: 'command', message: 'Enter command to run (e.g. bash, zsh, python):', initial: 'bash' }
153
178
  ]);
154
179
  if (!id || !command) continue;
155
-
156
- await ensureDaemonRunning();
157
180
 
158
181
  const cols = process.stdout.columns || 80;
159
182
  const rows = process.stdout.rows || 30;
@@ -275,7 +298,6 @@ async function main() {
275
298
  }
276
299
 
277
300
  if (cmd === 'list') {
278
- await ensureDaemonRunning();
279
301
  try {
280
302
  const res = await fetchWithAuth(`${DAEMON_URL}/api/sessions`);
281
303
  if (!res.ok) throw new Error(`HTTP ${res.status}`);
@@ -297,7 +319,6 @@ async function main() {
297
319
  }
298
320
 
299
321
  if (cmd === 'spawn') {
300
- await ensureDaemonRunning();
301
322
  const idIndex = args.indexOf('--id');
302
323
  if (idIndex === -1 || !args[idIndex + 1]) { console.error('❌ Usage: telepty spawn --id <session_id> <command> [args...]'); process.exit(1); }
303
324
  const sessionId = args[idIndex + 1];
@@ -321,7 +342,6 @@ async function main() {
321
342
  }
322
343
 
323
344
  if (cmd === 'attach') {
324
- await ensureDaemonRunning();
325
345
  let sessionId = args[1];
326
346
  let targetHost = REMOTE_HOST;
327
347
 
@@ -402,7 +422,6 @@ async function main() {
402
422
  }
403
423
 
404
424
  if (cmd === 'inject') {
405
- await ensureDaemonRunning();
406
425
  const sessionId = args[1]; const prompt = args.slice(2).join(' ');
407
426
  if (!sessionId || !prompt) { console.error('❌ Usage: telepty inject <session_id> "<prompt text>"'); process.exit(1); }
408
427
  try {
@@ -417,7 +436,6 @@ async function main() {
417
436
  }
418
437
 
419
438
  if (cmd === 'multicast') {
420
- await ensureDaemonRunning();
421
439
  const sessionIdsRaw = args[1]; const prompt = args.slice(2).join(' ');
422
440
  if (!sessionIdsRaw || !prompt) { console.error('❌ Usage: telepty multicast <id1,id2,...> "<prompt text>"'); process.exit(1); }
423
441
  const sessionIds = sessionIdsRaw.split(',').map(s => s.trim()).filter(s => s);
@@ -436,7 +454,6 @@ async function main() {
436
454
  }
437
455
 
438
456
  if (cmd === 'broadcast') {
439
- await ensureDaemonRunning();
440
457
  const prompt = args.slice(1).join(' ');
441
458
  if (!prompt) { console.error('❌ Usage: telepty broadcast "<prompt text>"'); process.exit(1); }
442
459
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dmsdc-ai/aigentry-telepty",
3
- "version": "0.0.13",
3
+ "version": "0.0.15",
4
4
  "main": "daemon.js",
5
5
  "bin": {
6
6
  "telepty": "cli.js",
@@ -19,6 +19,7 @@
19
19
  "express": "^5.2.1",
20
20
  "node-pty": "^1.2.0-beta.11",
21
21
  "prompts": "^2.4.2",
22
+ "update-notifier": "^7.3.1",
22
23
  "uuid": "^13.0.0",
23
24
  "ws": "^8.19.0",
24
25
  "zod": "^4.3.6"