@dmsdc-ai/aigentry-telepty 0.0.5 → 0.0.7

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/README.md CHANGED
@@ -1,5 +1,41 @@
1
- # aigentry-telepty
1
+ # @dmsdc-ai/aigentry-telepty
2
2
 
3
- **Personal PTY-based remote prompt injection daemon for AI CLIs.**
3
+ **Cross-machine PTY-based remote prompt injection daemon for AI CLIs.**
4
4
 
5
- `telepty` (Tele-Prompt) is a lightweight, personal background daemon that bridges the gap between the network and interactive AI command-line interfaces.
5
+ `telepty` (Tele-Prompt) is a lightweight background daemon that bridges the gap between the network and interactive AI command-line interfaces. It allows you to seamlessly share, attach to, and inject commands into terminal sessions across different machines.
6
+
7
+ ## One-Click Installation
8
+
9
+ To install and set up `telepty` on any machine (macOS, Linux, or Windows). These scripts will automatically install Node.js if it is missing from your system.
10
+
11
+ ### For macOS and Linux (Ubuntu, CentOS, etc.)
12
+ Open your terminal and run:
13
+ ```bash
14
+ curl -fsSL https://raw.githubusercontent.com/dmsdc-ai/aigentry-telepty/main/install.sh | bash
15
+ ```
16
+
17
+ ### For Windows (PowerShell)
18
+ Open PowerShell and run:
19
+ ```powershell
20
+ iwr -useb https://raw.githubusercontent.com/dmsdc-ai/aigentry-telepty/main/install.ps1 | iex
21
+ ```
22
+
23
+ *These single commands will install the package globally and automatically configure it to run as a background service specific to your OS (`systemd` for Linux, `launchd` for macOS, or a detached background process for Windows).*
24
+
25
+ ## Seamless Usage
26
+
27
+ 1. **Start a background session:**
28
+ ```bash
29
+ telepty spawn --id "my-session" bash
30
+ ```
31
+
32
+ 2. **Attach to a session (Local or Remote):**
33
+ ```bash
34
+ telepty attach
35
+ ```
36
+ *telepty will automatically discover active sessions on your local machine and across your Tailscale network!*
37
+
38
+ 3. **Inject commands remotely:**
39
+ ```bash
40
+ telepty inject my-session "echo 'Hello from nowhere!'"
41
+ ```
package/daemon.js CHANGED
@@ -53,7 +53,7 @@ app.post('/api/sessions/spawn', (req, res) => {
53
53
  cols: parseInt(cols),
54
54
  rows: parseInt(rows),
55
55
  cwd,
56
- env: { ...process.env, TERM: isWin ? undefined : 'xterm-256color' }
56
+ env: { ...process.env, TERM: isWin ? undefined : 'xterm-256color', TELEPTY_SESSION_ID: session_id }
57
57
  });
58
58
 
59
59
  sessions[session_id] = {
package/install.js ADDED
@@ -0,0 +1,114 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { execSync, spawn } = require('child_process');
4
+ const os = require('os');
5
+ const fs = require('fs');
6
+ const path = require('path');
7
+
8
+ console.log("🚀 Installing @dmsdc-ai/aigentry-telepty...");
9
+
10
+ function run(cmd) {
11
+ try {
12
+ execSync(cmd, { stdio: 'inherit' });
13
+ } catch (e) {
14
+ console.error(`❌ Command failed: ${cmd}`);
15
+ process.exit(1);
16
+ }
17
+ }
18
+
19
+ // 1. Install globally via npm
20
+ console.log("📦 Installing package globally...");
21
+ run("npm install -g @dmsdc-ai/aigentry-telepty");
22
+
23
+ // 2. Find executable
24
+ let teleptyPath = '';
25
+ try {
26
+ teleptyPath = execSync(os.platform() === 'win32' ? 'where telepty' : 'which telepty', { encoding: 'utf8' }).split('\n')[0].trim();
27
+ } catch (e) {
28
+ teleptyPath = 'telepty'; // fallback
29
+ }
30
+
31
+ // 3. Setup OS-specific autostart or background daemon
32
+ const platform = os.platform();
33
+
34
+ if (platform === 'win32') {
35
+ console.log("⚙️ Setting up Windows background process...");
36
+ // Launch daemon in background detaching from current console
37
+ const subprocess = spawn(teleptyPath, ['daemon'], {
38
+ detached: true,
39
+ stdio: 'ignore',
40
+ windowsHide: true
41
+ });
42
+ subprocess.unref();
43
+ console.log("✅ Windows daemon started in background.");
44
+
45
+ } else if (platform === 'darwin') {
46
+ console.log("⚙️ Setting up macOS launchd service...");
47
+ const plistPath = path.join(os.homedir(), 'Library', 'LaunchAgents', 'com.aigentry.telepty.plist');
48
+ fs.mkdirSync(path.dirname(plistPath), { recursive: true });
49
+
50
+ const plistContent = `<?xml version="1.0" encoding="UTF-8"?>
51
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
52
+ <plist version="1.0">
53
+ <dict>
54
+ <key>Label</key>
55
+ <string>com.aigentry.telepty</string>
56
+ <key>ProgramArguments</key>
57
+ <array>
58
+ <string>${teleptyPath}</string>
59
+ <string>daemon</string>
60
+ </array>
61
+ <key>RunAtLoad</key>
62
+ <true/>
63
+ <key>KeepAlive</key>
64
+ <true/>
65
+ </dict>
66
+ </plist>`;
67
+
68
+ fs.writeFileSync(plistPath, plistContent);
69
+ try { execSync(`launchctl unload "${plistPath}" 2>/dev/null`); } catch(e){}
70
+ run(`launchctl load "${plistPath}"`);
71
+ console.log("✅ macOS LaunchAgent installed and started.");
72
+
73
+ } else {
74
+ // Linux
75
+ try {
76
+ // Check if systemd is available and running as root/sudo
77
+ execSync('systemctl --version', { stdio: 'ignore' });
78
+ if (process.getuid && process.getuid() === 0) {
79
+ console.log("⚙️ Setting up systemd service for Linux...");
80
+ const serviceContent = `[Unit]
81
+ Description=Telepty Daemon
82
+ After=network.target
83
+
84
+ [Service]
85
+ ExecStart=${teleptyPath} daemon
86
+ Restart=always
87
+ User=${process.env.SUDO_USER || process.env.USER || 'root'}
88
+ Environment=PATH=/usr/bin:/usr/local/bin:$PATH
89
+ Environment=NODE_ENV=production
90
+
91
+ [Install]
92
+ WantedBy=multi-user.target`;
93
+
94
+ fs.writeFileSync('/etc/systemd/system/telepty.service', serviceContent);
95
+ run('systemctl daemon-reload');
96
+ run('systemctl enable telepty');
97
+ run('systemctl start telepty');
98
+ console.log("✅ Systemd service installed and started.");
99
+ process.exit(0);
100
+ }
101
+ } catch(e) {}
102
+
103
+ // Fallback for Linux without systemd or non-root
104
+ console.log("⚠️ Skipping systemd (no root or no systemd). Starting in background...");
105
+ const subprocess = spawn(teleptyPath, ['daemon'], {
106
+ detached: true,
107
+ stdio: 'ignore'
108
+ });
109
+ subprocess.unref();
110
+ console.log("✅ Linux daemon started in background using nohup equivalent.");
111
+ }
112
+
113
+ console.log("\n🎉 Installation complete! Telepty daemon is running.");
114
+ console.log("👉 Try running: telepty attach\n");
package/install.ps1 ADDED
@@ -0,0 +1,33 @@
1
+ Write-Host "🚀 Installing @dmsdc-ai/aigentry-telepty..." -ForegroundColor Cyan
2
+
3
+ # 1. Check for Node.js/npm and install if missing
4
+ if (!(Get-Command npm -ErrorAction SilentlyContinue)) {
5
+ Write-Host "⚠️ Node.js/npm not found. Attempting to install via winget..." -ForegroundColor Yellow
6
+ if (Get-Command winget -ErrorAction SilentlyContinue) {
7
+ winget install OpenJS.NodeJS --accept-package-agreements --accept-source-agreements
8
+ Write-Host "🔄 Refreshing environment variables..." -ForegroundColor Cyan
9
+ $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
10
+ } else {
11
+ Write-Host "❌ winget not found. Please install Node.js manually: https://nodejs.org/" -ForegroundColor Red
12
+ exit 1
13
+ }
14
+ }
15
+
16
+ # 2. Install telepty via npm
17
+ Write-Host "📦 Installing telepty globally..." -ForegroundColor Cyan
18
+ npm install -g @dmsdc-ai/aigentry-telepty
19
+
20
+ # 3. Setup Daemon
21
+ Write-Host "⚙️ Setting up Windows background process..." -ForegroundColor Cyan
22
+ $teleptyCmd = Get-Command telepty -ErrorAction SilentlyContinue
23
+ if (!$teleptyCmd) {
24
+ Write-Host "❌ Failed to locate telepty executable after installation." -ForegroundColor Red
25
+ exit 1
26
+ }
27
+
28
+ $teleptyPath = $teleptyCmd.Source
29
+ Start-Process -NoNewWindow -FilePath node -ArgumentList "$teleptyPath daemon" -WindowStyle Hidden
30
+ Write-Host "✅ Windows daemon started in background." -ForegroundColor Green
31
+
32
+ Write-Host "`n🎉 Installation complete! Telepty daemon is running." -ForegroundColor Cyan
33
+ Write-Host "👉 Try running: telepty attach" -ForegroundColor Yellow
package/install.sh CHANGED
@@ -1,43 +1,118 @@
1
1
  #!/usr/bin/env bash
2
2
  set -e
3
3
 
4
- echo "🚀 Installing aigentry-telepty..."
4
+ echo "🚀 Installing @dmsdc-ai/aigentry-telepty..."
5
+
6
+ # 1. Check for Node.js and install if missing
5
7
  if ! command -v npm &> /dev/null; then
6
- echo " Error: npm is not installed. Please install Node.js first."
7
- exit 1
8
+ echo "⚠️ Node.js/npm not found. Attempting to install Node.js..."
9
+ if [[ "$OSTYPE" == "darwin"* ]]; then
10
+ if ! command -v brew &> /dev/null; then
11
+ echo "❌ Homebrew not found. Please install Node.js manually: https://nodejs.org/"
12
+ exit 1
13
+ fi
14
+ brew install node
15
+ elif command -v apt-get &> /dev/null; then
16
+ curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
17
+ sudo apt-get install -y nodejs
18
+ elif command -v yum &> /dev/null; then
19
+ curl -fsSL https://rpm.nodesource.com/setup_20.x | sudo bash -
20
+ sudo yum install -y nodejs
21
+ elif command -v dnf &> /dev/null; then
22
+ curl -fsSL https://rpm.nodesource.com/setup_20.x | sudo bash -
23
+ sudo dnf install -y nodejs
24
+ elif command -v pacman &> /dev/null; then
25
+ sudo pacman -Sy nodejs npm --noconfirm
26
+ elif command -v pkg &> /dev/null; then
27
+ # Termux environment
28
+ pkg install -y nodejs
29
+ else
30
+ echo "❌ Could not determine package manager. Please install Node.js manually: https://nodejs.org/"
31
+ exit 1
32
+ fi
8
33
  fi
9
34
 
10
- npm install -g git+https://github.com/dmsdc-ai/aigentry-telepty.git
35
+ # 2. Install telepty via npm
36
+ echo "📦 Installing telepty globally..."
37
+ if [[ "$OSTYPE" == "darwin"* ]] || command -v pkg &> /dev/null || [ "$EUID" -eq 0 ]; then
38
+ npm install -g @dmsdc-ai/aigentry-telepty
39
+ else
40
+ # Linux non-root might need sudo for global install depending on npm setup
41
+ sudo npm install -g @dmsdc-ai/aigentry-telepty || npm install -g @dmsdc-ai/aigentry-telepty
42
+ fi
11
43
 
12
- # Set up systemd service if systemd is available
13
- if command -v systemctl &> /dev/null && [ -d "/etc/systemd/system" ] && [ "$EUID" -eq 0 ]; then
14
- echo "⚙️ Setting up systemd service..."
15
- TELEPTY_PATH=$(which telepty)
16
- cat <<SYSTEMD_EOF > /etc/systemd/system/telepty.service
44
+ TELEPTY_PATH=$(which telepty || true)
45
+ if [ -z "$TELEPTY_PATH" ]; then
46
+ TELEPTY_PATH="$(npm prefix -g)/bin/telepty"
47
+ fi
48
+
49
+ # 3. Setup Daemon
50
+ echo "⚙️ Setting up daemon..."
51
+ if command -v systemctl &> /dev/null && [ -d "/etc/systemd/system" ]; then
52
+ if [ "$EUID" -ne 0 ]; then
53
+ echo "⚠️ systemd requires root to install service. Prompting for sudo..."
54
+ SUDO_CMD="sudo"
55
+ else
56
+ SUDO_CMD=""
57
+ fi
58
+
59
+ $SUDO_CMD bash -c "cat <<EOF > /etc/systemd/system/telepty.service
17
60
  [Unit]
18
61
  Description=Telepty Daemon
19
- After=network.target tailscaled.service
62
+ After=network.target
20
63
 
21
64
  [Service]
22
65
  ExecStart=$TELEPTY_PATH daemon
23
66
  Restart=always
24
- User=$SUDO_USER
25
- Environment=PATH=/usr/bin:/usr/local/bin:$PATH
67
+ User=${SUDO_USER:-$USER}
68
+ Environment=PATH=/usr/bin:/usr/local/bin:\$PATH
26
69
  Environment=NODE_ENV=production
27
70
 
28
71
  [Install]
29
72
  WantedBy=multi-user.target
30
- SYSTEMD_EOF
73
+ EOF"
74
+
75
+ $SUDO_CMD systemctl daemon-reload
76
+ $SUDO_CMD systemctl enable telepty
77
+ $SUDO_CMD systemctl start telepty
78
+ echo "✅ Linux systemd service installed and started. (Auto-starts on boot)"
31
79
 
32
- systemctl daemon-reload
33
- systemctl enable telepty
34
- systemctl start telepty
35
- echo "✅ Systemd service installed and started. Daemon will run automatically on boot."
80
+ elif [[ "$OSTYPE" == "darwin"* ]]; then
81
+ PLIST_PATH="$HOME/Library/LaunchAgents/com.aigentry.telepty.plist"
82
+ mkdir -p "$HOME/Library/LaunchAgents"
83
+ cat <<EOF > "$PLIST_PATH"
84
+ <?xml version="1.0" encoding="UTF-8"?>
85
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
86
+ <plist version="1.0">
87
+ <dict>
88
+ <key>Label</key>
89
+ <string>com.aigentry.telepty</string>
90
+ <key>ProgramArguments</key>
91
+ <array>
92
+ <string>$TELEPTY_PATH</string>
93
+ <string>daemon</string>
94
+ </array>
95
+ <key>RunAtLoad</key>
96
+ <true/>
97
+ <key>KeepAlive</key>
98
+ <true/>
99
+ <key>EnvironmentVariables</key>
100
+ <dict>
101
+ <key>PATH</key>
102
+ <string>/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin</string>
103
+ </dict>
104
+ </dict>
105
+ </plist>
106
+ EOF
107
+ launchctl unload "$PLIST_PATH" 2>/dev/null || true
108
+ launchctl load "$PLIST_PATH"
109
+ echo "✅ macOS LaunchAgent installed and started. (Auto-starts on boot)"
36
110
  else
37
- echo "⚠️ Skipping systemd setup (requires root and systemd). Starting daemon in background..."
38
- nohup telepty daemon > /dev/null 2>&1 &
39
- echo "✅ Daemon started in background. (Note: It will not auto-start on reboot)"
111
+ echo "⚠️ Skipping OS-level service setup (Termux or missing systemd). Starting in background..."
112
+ nohup $TELEPTY_PATH daemon > /dev/null 2>&1 &
113
+ echo "✅ Daemon started in background. (Note: Will not auto-start on device reboot)"
40
114
  fi
41
115
 
42
- echo "🎉 Installation complete!"
43
- echo "You can now use 'telepty spawn --id <name> <command>' to create sessions."
116
+ echo ""
117
+ echo "🎉 Installation complete! Telepty daemon is running in the background."
118
+ echo "👉 Try running: telepty attach"
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "@dmsdc-ai/aigentry-telepty",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "main": "daemon.js",
5
5
  "bin": {
6
- "telepty": "cli.js"
6
+ "telepty": "cli.js",
7
+ "telepty-install": "install.js"
7
8
  },
8
9
  "scripts": {
9
10
  "test": "echo \"Error: no test specified\" && exit 1"