@dmsdc-ai/aigentry-telepty 0.0.14 → 0.0.16
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 +22 -8
- package/package.json +2 -2
package/cli.js
CHANGED
|
@@ -27,7 +27,27 @@ const fetchWithAuth = (url, options = {}) => {
|
|
|
27
27
|
return fetch(url, { ...options, headers });
|
|
28
28
|
};
|
|
29
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
|
+
|
|
30
49
|
async function discoverSessions() {
|
|
50
|
+
await ensureDaemonRunning();
|
|
31
51
|
const hosts = ['127.0.0.1'];
|
|
32
52
|
try {
|
|
33
53
|
const tsStatus = execSync('tailscale status --json', { encoding: 'utf8', stdio: ['pipe', 'pipe', 'ignore'] });
|
|
@@ -157,8 +177,6 @@ async function manageInteractive() {
|
|
|
157
177
|
{ type: 'text', name: 'command', message: 'Enter command to run (e.g. bash, zsh, python):', initial: 'bash' }
|
|
158
178
|
]);
|
|
159
179
|
if (!id || !command) continue;
|
|
160
|
-
|
|
161
|
-
await ensureDaemonRunning();
|
|
162
180
|
|
|
163
181
|
const cols = process.stdout.columns || 80;
|
|
164
182
|
const rows = process.stdout.rows || 30;
|
|
@@ -269,6 +287,8 @@ async function main() {
|
|
|
269
287
|
}
|
|
270
288
|
return;
|
|
271
289
|
}
|
|
290
|
+
|
|
291
|
+
if (cmd === 'mcp') {
|
|
272
292
|
require('./mcp.js');
|
|
273
293
|
return;
|
|
274
294
|
}
|
|
@@ -280,7 +300,6 @@ async function main() {
|
|
|
280
300
|
}
|
|
281
301
|
|
|
282
302
|
if (cmd === 'list') {
|
|
283
|
-
await ensureDaemonRunning();
|
|
284
303
|
try {
|
|
285
304
|
const res = await fetchWithAuth(`${DAEMON_URL}/api/sessions`);
|
|
286
305
|
if (!res.ok) throw new Error(`HTTP ${res.status}`);
|
|
@@ -302,7 +321,6 @@ async function main() {
|
|
|
302
321
|
}
|
|
303
322
|
|
|
304
323
|
if (cmd === 'spawn') {
|
|
305
|
-
await ensureDaemonRunning();
|
|
306
324
|
const idIndex = args.indexOf('--id');
|
|
307
325
|
if (idIndex === -1 || !args[idIndex + 1]) { console.error('❌ Usage: telepty spawn --id <session_id> <command> [args...]'); process.exit(1); }
|
|
308
326
|
const sessionId = args[idIndex + 1];
|
|
@@ -326,7 +344,6 @@ async function main() {
|
|
|
326
344
|
}
|
|
327
345
|
|
|
328
346
|
if (cmd === 'attach') {
|
|
329
|
-
await ensureDaemonRunning();
|
|
330
347
|
let sessionId = args[1];
|
|
331
348
|
let targetHost = REMOTE_HOST;
|
|
332
349
|
|
|
@@ -407,7 +424,6 @@ async function main() {
|
|
|
407
424
|
}
|
|
408
425
|
|
|
409
426
|
if (cmd === 'inject') {
|
|
410
|
-
await ensureDaemonRunning();
|
|
411
427
|
const sessionId = args[1]; const prompt = args.slice(2).join(' ');
|
|
412
428
|
if (!sessionId || !prompt) { console.error('❌ Usage: telepty inject <session_id> "<prompt text>"'); process.exit(1); }
|
|
413
429
|
try {
|
|
@@ -422,7 +438,6 @@ async function main() {
|
|
|
422
438
|
}
|
|
423
439
|
|
|
424
440
|
if (cmd === 'multicast') {
|
|
425
|
-
await ensureDaemonRunning();
|
|
426
441
|
const sessionIdsRaw = args[1]; const prompt = args.slice(2).join(' ');
|
|
427
442
|
if (!sessionIdsRaw || !prompt) { console.error('❌ Usage: telepty multicast <id1,id2,...> "<prompt text>"'); process.exit(1); }
|
|
428
443
|
const sessionIds = sessionIdsRaw.split(',').map(s => s.trim()).filter(s => s);
|
|
@@ -441,7 +456,6 @@ async function main() {
|
|
|
441
456
|
}
|
|
442
457
|
|
|
443
458
|
if (cmd === 'broadcast') {
|
|
444
|
-
await ensureDaemonRunning();
|
|
445
459
|
const prompt = args.slice(1).join(' ');
|
|
446
460
|
if (!prompt) { console.error('❌ Usage: telepty broadcast "<prompt text>"'); process.exit(1); }
|
|
447
461
|
try {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dmsdc-ai/aigentry-telepty",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.16",
|
|
4
4
|
"main": "daemon.js",
|
|
5
5
|
"bin": {
|
|
6
6
|
"telepty": "cli.js",
|
|
@@ -19,7 +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": "^
|
|
22
|
+
"update-notifier": "^5.1.0",
|
|
23
23
|
"uuid": "^13.0.0",
|
|
24
24
|
"ws": "^8.19.0",
|
|
25
25
|
"zod": "^4.3.6"
|