sessioncast-cli 2.0.7 → 2.0.9
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 +14 -0
- package/dist/agent/runner.js +20 -5
- package/dist/agent/tmux-executor.d.ts +4 -0
- package/dist/agent/tmux-executor.js +45 -4
- package/dist/agent/tmux.js +6 -1
- package/dist/index.js +46 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -26,6 +26,20 @@ Expand-Archive -Path "$env:TEMP\itmux.zip" -DestinationPath "C:\itmux" -Force
|
|
|
26
26
|
npm install -g sessioncast-cli
|
|
27
27
|
```
|
|
28
28
|
|
|
29
|
+
#### Use PowerShell in tmux sessions (recommended)
|
|
30
|
+
|
|
31
|
+
By default, itmux opens sessions with bash. Sessions created by SessionCast automatically use PowerShell, but if you also want PowerShell when using itmux manually:
|
|
32
|
+
|
|
33
|
+
```powershell
|
|
34
|
+
# Create tmux config to use PowerShell as default shell
|
|
35
|
+
$tmuxConf = "C:\itmux\home\$env:USERNAME\.tmux.conf"
|
|
36
|
+
New-Item -Path $tmuxConf -ItemType File -Force
|
|
37
|
+
Add-Content -Path $tmuxConf -Value 'set-option -g default-command "powershell.exe"'
|
|
38
|
+
|
|
39
|
+
# For PowerShell 7+ (pwsh), use this instead:
|
|
40
|
+
# Add-Content -Path $tmuxConf -Value 'set-option -g default-command "pwsh.exe"'
|
|
41
|
+
```
|
|
42
|
+
|
|
29
43
|
## Quick Start
|
|
30
44
|
|
|
31
45
|
### 1. Login
|
package/dist/agent/runner.js
CHANGED
|
@@ -105,23 +105,38 @@ class AgentRunner {
|
|
|
105
105
|
console.log(`Machine ID: ${this.config.machineId}`);
|
|
106
106
|
console.log(`Relay: ${this.config.relay}`);
|
|
107
107
|
console.log(`Token: ${this.config.token ? 'present' : 'none'}`);
|
|
108
|
-
// Check tmux availability before starting
|
|
108
|
+
// Check tmux/itmux availability before starting
|
|
109
109
|
if (!tmux.isAvailable()) {
|
|
110
110
|
const platform = os.platform();
|
|
111
111
|
let installHint;
|
|
112
|
-
if (platform === '
|
|
112
|
+
if (platform === 'win32') {
|
|
113
|
+
installHint = ' itmux required for Windows\n\n' +
|
|
114
|
+
' Download: https://github.com/itefixnet/itmux/releases/latest\n' +
|
|
115
|
+
' Or set ITMUX_HOME environment variable\n\n' +
|
|
116
|
+
' Quick install (PowerShell):\n' +
|
|
117
|
+
' Invoke-WebRequest -Uri "https://github.com/itefixnet/itmux/releases/download/v1.1.0/itmux_1.1.0_x64_free.zip" -OutFile "$env:TEMP\\itmux.zip"\n' +
|
|
118
|
+
' Expand-Archive -Path "$env:TEMP\\itmux.zip" -DestinationPath "C:\\itmux" -Force\n\n' +
|
|
119
|
+
' Or with Chocolatey:\n' +
|
|
120
|
+
' choco install itmux\n\n' +
|
|
121
|
+
' PowerShell as default shell (recommended):\n' +
|
|
122
|
+
' Sessions created by SessionCast automatically use PowerShell.\n' +
|
|
123
|
+
' For manual itmux sessions, add to C:\\itmux\\home\\<username>\\.tmux.conf:\n' +
|
|
124
|
+
' set-option -g default-command "powershell.exe"';
|
|
125
|
+
}
|
|
126
|
+
else if (platform === 'darwin') {
|
|
113
127
|
installHint = ' Install: brew install tmux';
|
|
114
128
|
}
|
|
115
129
|
else {
|
|
116
130
|
installHint = ' Install: sudo apt install tmux (Debian/Ubuntu)\n' +
|
|
117
131
|
' sudo yum install tmux (RHEL/CentOS)';
|
|
118
132
|
}
|
|
133
|
+
const binaryName = platform === 'win32' ? 'itmux' : 'tmux';
|
|
119
134
|
throw new Error('\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n' +
|
|
120
|
-
|
|
135
|
+
` ${binaryName} not found - required for SessionCast Agent\n` +
|
|
121
136
|
'━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n\n' +
|
|
122
137
|
`${installHint}\n\n` +
|
|
123
|
-
|
|
124
|
-
|
|
138
|
+
` After installing, start a ${binaryName} session:\n` +
|
|
139
|
+
` ${binaryName} new -s main\n\n` +
|
|
125
140
|
' Then run the agent:\n' +
|
|
126
141
|
' sessioncast agent\n\n' +
|
|
127
142
|
'━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
|
|
@@ -70,6 +70,10 @@ export declare class WindowsTmuxExecutor implements TmuxExecutor {
|
|
|
70
70
|
getVersion(): string | null;
|
|
71
71
|
getActivePane(session: string): string | null;
|
|
72
72
|
getPaneCwd(session: string, paneId?: string): string | null;
|
|
73
|
+
/**
|
|
74
|
+
* Detect the best Windows shell available (PowerShell 7 > Windows PowerShell > bash).
|
|
75
|
+
*/
|
|
76
|
+
private detectWindowsShell;
|
|
73
77
|
private escapeSession;
|
|
74
78
|
private windowsToCygwinPath;
|
|
75
79
|
/**
|
|
@@ -368,6 +368,11 @@ class WindowsTmuxExecutor {
|
|
|
368
368
|
else {
|
|
369
369
|
cmd = `tmux new-session -d -s '${sanitized}'`;
|
|
370
370
|
}
|
|
371
|
+
// Use PowerShell as default shell for Windows sessions
|
|
372
|
+
const shell = this.detectWindowsShell();
|
|
373
|
+
if (shell) {
|
|
374
|
+
cmd += ` '${shell}'`;
|
|
375
|
+
}
|
|
371
376
|
this.executeCommand(cmd);
|
|
372
377
|
return true;
|
|
373
378
|
}
|
|
@@ -414,6 +419,18 @@ class WindowsTmuxExecutor {
|
|
|
414
419
|
return null;
|
|
415
420
|
}
|
|
416
421
|
}
|
|
422
|
+
/**
|
|
423
|
+
* Detect the best Windows shell available (PowerShell 7 > Windows PowerShell > bash).
|
|
424
|
+
*/
|
|
425
|
+
detectWindowsShell() {
|
|
426
|
+
// Prefer PowerShell 7+ (pwsh.exe), then Windows PowerShell (powershell.exe)
|
|
427
|
+
for (const shell of ['pwsh.exe', 'powershell.exe']) {
|
|
428
|
+
const result = this.executeCommand(`command -v ${shell} 2>/dev/null`);
|
|
429
|
+
if (result)
|
|
430
|
+
return shell;
|
|
431
|
+
}
|
|
432
|
+
return null;
|
|
433
|
+
}
|
|
417
434
|
escapeSession(session) {
|
|
418
435
|
return session.replace(/'/g, "'\\''");
|
|
419
436
|
}
|
|
@@ -436,12 +453,31 @@ class WindowsTmuxExecutor {
|
|
|
436
453
|
* Find itmux installation path on Windows.
|
|
437
454
|
*/
|
|
438
455
|
static findItmuxPath() {
|
|
439
|
-
|
|
456
|
+
const checkBashPath = (basePath) => {
|
|
457
|
+
return fs.existsSync(path.join(basePath, 'bin', 'bash.exe'));
|
|
458
|
+
};
|
|
459
|
+
// 1. Check environment variable (highest priority)
|
|
440
460
|
const envPath = process.env.ITMUX_HOME;
|
|
441
|
-
if (envPath &&
|
|
461
|
+
if (envPath && checkBashPath(envPath)) {
|
|
442
462
|
return envPath;
|
|
443
463
|
}
|
|
444
|
-
// 2. Check
|
|
464
|
+
// 2. Check PATH (covers Chocolatey, manual installs, etc.)
|
|
465
|
+
const pathEnv = process.env.PATH || '';
|
|
466
|
+
const pathSep = pathEnv.includes(';') ? ';' : ':';
|
|
467
|
+
const dirs = pathEnv.split(pathSep);
|
|
468
|
+
for (const dir of dirs) {
|
|
469
|
+
const normalizedDir = dir.toLowerCase();
|
|
470
|
+
if (normalizedDir.includes('itmux') || normalizedDir.includes('cygwin')) {
|
|
471
|
+
let checkPath = dir;
|
|
472
|
+
if (dir.endsWith('\\bin') || dir.endsWith('/bin')) {
|
|
473
|
+
checkPath = path.dirname(dir);
|
|
474
|
+
}
|
|
475
|
+
if (checkBashPath(checkPath)) {
|
|
476
|
+
return checkPath;
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
// 3. Check hardcoded paths as fallback
|
|
445
481
|
const locations = [
|
|
446
482
|
path.join(os.homedir(), 'itmux'),
|
|
447
483
|
'C:\\itmux',
|
|
@@ -451,7 +487,7 @@ class WindowsTmuxExecutor {
|
|
|
451
487
|
path.join(process.env.ProgramFiles || '', 'itmux'),
|
|
452
488
|
];
|
|
453
489
|
for (const loc of locations) {
|
|
454
|
-
if (loc &&
|
|
490
|
+
if (loc && checkBashPath(loc)) {
|
|
455
491
|
return loc;
|
|
456
492
|
}
|
|
457
493
|
}
|
|
@@ -481,6 +517,11 @@ function createTmuxExecutor() {
|
|
|
481
517
|
' Quick install (PowerShell):\n' +
|
|
482
518
|
' Invoke-WebRequest -Uri "https://github.com/itefixnet/itmux/releases/download/v1.1.0/itmux_1.1.0_x64_free.zip" -OutFile "$env:TEMP\\itmux.zip"\n' +
|
|
483
519
|
' Expand-Archive -Path "$env:TEMP\\itmux.zip" -DestinationPath "C:\\itmux" -Force\n\n' +
|
|
520
|
+
' PowerShell as default shell (recommended):\n' +
|
|
521
|
+
' SessionCast automatically uses PowerShell for new sessions.\n' +
|
|
522
|
+
' To also use PowerShell when opening itmux manually, create\n' +
|
|
523
|
+
' C:\\itmux\\home\\<username>\\.tmux.conf with:\n' +
|
|
524
|
+
' set-option -g default-command "powershell.exe"\n\n' +
|
|
484
525
|
'━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n');
|
|
485
526
|
}
|
|
486
527
|
return new WindowsTmuxExecutor(itmuxPath);
|
package/dist/agent/tmux.js
CHANGED
|
@@ -127,7 +127,12 @@ function isAvailable() {
|
|
|
127
127
|
try {
|
|
128
128
|
return getExecutor().isAvailable();
|
|
129
129
|
}
|
|
130
|
-
catch {
|
|
130
|
+
catch (error) {
|
|
131
|
+
// If it's the itmux not found error, re-throw to preserve Windows context
|
|
132
|
+
// so the user gets the detailed Windows instructions from runner.ts
|
|
133
|
+
if (error instanceof Error && error.message.includes('itmux not found')) {
|
|
134
|
+
throw error;
|
|
135
|
+
}
|
|
131
136
|
return false;
|
|
132
137
|
}
|
|
133
138
|
}
|
package/dist/index.js
CHANGED
|
@@ -65,20 +65,57 @@ process.on('unhandledRejection', async (reason) => {
|
|
|
65
65
|
function checkTmux() {
|
|
66
66
|
const isWindows = os.platform() === 'win32';
|
|
67
67
|
if (isWindows) {
|
|
68
|
-
//
|
|
68
|
+
// Helper function to check if bash.exe exists in a path
|
|
69
|
+
function checkBashPath(basePath) {
|
|
70
|
+
try {
|
|
71
|
+
const fs = require('fs');
|
|
72
|
+
const path = require('path');
|
|
73
|
+
return fs.existsSync(path.join(basePath, 'bin', 'bash.exe'));
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
// Check PATH for itmux (covers Chocolatey, manual PATH additions, etc.)
|
|
80
|
+
function checkItmuxInPath() {
|
|
81
|
+
const pathEnv = process.env.PATH || '';
|
|
82
|
+
const pathSep = pathEnv.includes(';') ? ';' : ':';
|
|
83
|
+
const dirs = pathEnv.split(pathSep);
|
|
84
|
+
const path = require('path');
|
|
85
|
+
for (const dir of dirs) {
|
|
86
|
+
const normalizedDir = dir.toLowerCase();
|
|
87
|
+
if (normalizedDir.includes('itmux') || normalizedDir.includes('cygwin')) {
|
|
88
|
+
let checkPath = dir;
|
|
89
|
+
// If we're in the bin folder, go up one level
|
|
90
|
+
if (dir.endsWith('\\bin') || dir.endsWith('/bin')) {
|
|
91
|
+
checkPath = path.dirname(dir);
|
|
92
|
+
}
|
|
93
|
+
if (checkBashPath(checkPath)) {
|
|
94
|
+
return checkPath;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
// 1. Check environment variable first (highest priority)
|
|
101
|
+
if (process.env.ITMUX_HOME && checkBashPath(process.env.ITMUX_HOME)) {
|
|
102
|
+
return { available: true, isWindows: true };
|
|
103
|
+
}
|
|
104
|
+
// 2. Check PATH (covers Chocolatey, manual PATH additions, etc.)
|
|
105
|
+
if (checkItmuxInPath()) {
|
|
106
|
+
return { available: true, isWindows: true };
|
|
107
|
+
}
|
|
108
|
+
// 3. Check hardcoded paths as fallback
|
|
69
109
|
const paths = [
|
|
70
|
-
process.env.ITMUX_HOME,
|
|
71
110
|
`${os.homedir()}/itmux`,
|
|
72
111
|
'C:\\itmux',
|
|
73
112
|
`${os.homedir()}\\itmux`,
|
|
74
113
|
'C:\\Program Files\\itmux',
|
|
75
114
|
].filter(Boolean);
|
|
76
115
|
for (const p of paths) {
|
|
77
|
-
|
|
78
|
-
require('fs').accessSync(p);
|
|
116
|
+
if (checkBashPath(p)) {
|
|
79
117
|
return { available: true, isWindows: true };
|
|
80
118
|
}
|
|
81
|
-
catch { }
|
|
82
119
|
}
|
|
83
120
|
return { available: false, isWindows: true };
|
|
84
121
|
}
|
|
@@ -106,6 +143,10 @@ function showWelcome() {
|
|
|
106
143
|
if (isWindows) {
|
|
107
144
|
console.log(chalk_1.default.gray(' Install itmux: https://github.com/itefixnet/itmux'));
|
|
108
145
|
console.log(chalk_1.default.gray(' Or: choco install itmux'));
|
|
146
|
+
console.log('');
|
|
147
|
+
console.log(chalk_1.default.gray(' Use PowerShell in itmux sessions:'));
|
|
148
|
+
console.log(chalk_1.default.gray(' Add to C:\\itmux\\home\\<username>\\.tmux.conf:'));
|
|
149
|
+
console.log(chalk_1.default.gray(' set-option -g default-command "powershell.exe"'));
|
|
109
150
|
}
|
|
110
151
|
else if (os.platform() === 'darwin') {
|
|
111
152
|
console.log(chalk_1.default.gray(' Install: brew install tmux'));
|