sessioncast-cli 1.1.1 → 1.1.3
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/dist/commands/login.js +24 -2
- package/dist/config.d.ts +3 -0
- package/dist/config.js +9 -0
- package/dist/index.js +104 -1
- package/package.json +3 -5
- package/scripts/postinstall.js +0 -75
package/dist/commands/login.js
CHANGED
|
@@ -198,8 +198,14 @@ async function browserLogin(options = {}) {
|
|
|
198
198
|
}
|
|
199
199
|
spinner.succeed('Login successful!');
|
|
200
200
|
console.log(chalk_1.default.green('\n✓ You are now logged in to SessionCast\n'));
|
|
201
|
-
console.log(chalk_1.default.gray('
|
|
202
|
-
console.log(chalk_1.default.
|
|
201
|
+
console.log(chalk_1.default.gray(' Start the agent:'));
|
|
202
|
+
console.log(chalk_1.default.white(' sessioncast agent\n'));
|
|
203
|
+
console.log(chalk_1.default.gray(' Run in background:'));
|
|
204
|
+
console.log(chalk_1.default.white(' nohup sessioncast agent > agent.log 2>&1 &\n'));
|
|
205
|
+
console.log(chalk_1.default.gray(' Check logs:'));
|
|
206
|
+
console.log(chalk_1.default.white(' tail -f agent.log\n'));
|
|
207
|
+
await checkForUpdates();
|
|
208
|
+
process.exit(0);
|
|
203
209
|
}
|
|
204
210
|
catch (err) {
|
|
205
211
|
spinner.fail(`Login failed: ${err.message}`);
|
|
@@ -230,3 +236,19 @@ function status() {
|
|
|
230
236
|
console.log(chalk_1.default.gray('Run: sessioncast login'));
|
|
231
237
|
}
|
|
232
238
|
}
|
|
239
|
+
const CURRENT_VERSION = '1.1.3';
|
|
240
|
+
async function checkForUpdates() {
|
|
241
|
+
try {
|
|
242
|
+
const res = await (0, node_fetch_1.default)('https://registry.npmjs.org/sessioncast-cli/latest', { timeout: 3000 });
|
|
243
|
+
if (!res.ok) return;
|
|
244
|
+
const data = await res.json();
|
|
245
|
+
const latest = data.version;
|
|
246
|
+
if (latest && latest !== CURRENT_VERSION) {
|
|
247
|
+
console.log(chalk_1.default.yellow(` ⬆ Update available: ${CURRENT_VERSION} → ${latest}`));
|
|
248
|
+
console.log(chalk_1.default.white(` npm install -g sessioncast-cli@latest\n`));
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
catch (_e) {
|
|
252
|
+
// silently ignore - network errors shouldn't block login
|
|
253
|
+
}
|
|
254
|
+
}
|
package/dist/config.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ interface ConfigSchema {
|
|
|
9
9
|
tokenExpiresAt?: number;
|
|
10
10
|
agentToken?: string;
|
|
11
11
|
machineId?: string;
|
|
12
|
+
hasSeenWelcome?: boolean;
|
|
12
13
|
}
|
|
13
14
|
declare const config: Conf<ConfigSchema>;
|
|
14
15
|
export declare function getApiKey(): string | undefined;
|
|
@@ -30,4 +31,6 @@ export declare function getMachineId(): string | undefined;
|
|
|
30
31
|
export declare function setMachineId(id: string): void;
|
|
31
32
|
export declare function clearAuth(): void;
|
|
32
33
|
export declare function isLoggedIn(): boolean;
|
|
34
|
+
export declare function hasSeenWelcome(): boolean;
|
|
35
|
+
export declare function setSeenWelcome(): void;
|
|
33
36
|
export default config;
|
package/dist/config.js
CHANGED
|
@@ -22,6 +22,8 @@ exports.getMachineId = getMachineId;
|
|
|
22
22
|
exports.setMachineId = setMachineId;
|
|
23
23
|
exports.clearAuth = clearAuth;
|
|
24
24
|
exports.isLoggedIn = isLoggedIn;
|
|
25
|
+
exports.hasSeenWelcome = hasSeenWelcome;
|
|
26
|
+
exports.setSeenWelcome = setSeenWelcome;
|
|
25
27
|
const conf_1 = __importDefault(require("conf"));
|
|
26
28
|
const config = new conf_1.default({
|
|
27
29
|
projectName: 'sessioncast',
|
|
@@ -101,4 +103,11 @@ function clearAuth() {
|
|
|
101
103
|
function isLoggedIn() {
|
|
102
104
|
return !!(getApiKey() || getAccessToken() || getAgentToken());
|
|
103
105
|
}
|
|
106
|
+
// First run detection
|
|
107
|
+
function hasSeenWelcome() {
|
|
108
|
+
return config.get('hasSeenWelcome') === true;
|
|
109
|
+
}
|
|
110
|
+
function setSeenWelcome() {
|
|
111
|
+
config.set('hasSeenWelcome', true);
|
|
112
|
+
}
|
|
104
113
|
exports.default = config;
|
package/dist/index.js
CHANGED
|
@@ -1,21 +1,119 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
3
36
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
37
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
38
|
};
|
|
6
39
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
40
|
const commander_1 = require("commander");
|
|
8
41
|
const chalk_1 = __importDefault(require("chalk"));
|
|
42
|
+
const child_process_1 = require("child_process");
|
|
43
|
+
const os = __importStar(require("os"));
|
|
9
44
|
const login_1 = require("./commands/login");
|
|
10
45
|
const agents_1 = require("./commands/agents");
|
|
11
46
|
const sessions_1 = require("./commands/sessions");
|
|
12
47
|
const sendkeys_1 = require("./commands/sendkeys");
|
|
13
48
|
const agent_1 = require("./commands/agent");
|
|
49
|
+
const config_1 = require("./config");
|
|
50
|
+
// Check if tmux/itmux is available
|
|
51
|
+
function checkTmux() {
|
|
52
|
+
const isWindows = os.platform() === 'win32';
|
|
53
|
+
if (isWindows) {
|
|
54
|
+
// Check for itmux on Windows
|
|
55
|
+
const paths = [
|
|
56
|
+
process.env.ITMUX_HOME,
|
|
57
|
+
`${os.homedir()}/itmux`,
|
|
58
|
+
'C:\\itmux',
|
|
59
|
+
`${os.homedir()}\\itmux`,
|
|
60
|
+
'C:\\Program Files\\itmux',
|
|
61
|
+
].filter(Boolean);
|
|
62
|
+
for (const p of paths) {
|
|
63
|
+
try {
|
|
64
|
+
require('fs').accessSync(p);
|
|
65
|
+
return { available: true, isWindows: true };
|
|
66
|
+
}
|
|
67
|
+
catch { }
|
|
68
|
+
}
|
|
69
|
+
return { available: false, isWindows: true };
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
// Check for tmux on Unix
|
|
73
|
+
try {
|
|
74
|
+
(0, child_process_1.execSync)('which tmux', { stdio: 'pipe' });
|
|
75
|
+
return { available: true, isWindows: false };
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
return { available: false, isWindows: false };
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
// Show welcome message on first run
|
|
83
|
+
function showWelcome() {
|
|
84
|
+
if ((0, config_1.hasSeenWelcome)())
|
|
85
|
+
return;
|
|
86
|
+
const { available, isWindows } = checkTmux();
|
|
87
|
+
console.log('');
|
|
88
|
+
console.log(chalk_1.default.green.bold('✓ SessionCast CLI installed'));
|
|
89
|
+
console.log('');
|
|
90
|
+
if (!available) {
|
|
91
|
+
console.log(chalk_1.default.yellow('⚠ tmux not found'));
|
|
92
|
+
if (isWindows) {
|
|
93
|
+
console.log(chalk_1.default.gray(' Install itmux: https://github.com/phayte/itmux'));
|
|
94
|
+
console.log(chalk_1.default.gray(' Or: choco install itmux'));
|
|
95
|
+
}
|
|
96
|
+
else if (os.platform() === 'darwin') {
|
|
97
|
+
console.log(chalk_1.default.gray(' Install: brew install tmux'));
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
console.log(chalk_1.default.gray(' Install: sudo apt install tmux'));
|
|
101
|
+
}
|
|
102
|
+
console.log('');
|
|
103
|
+
}
|
|
104
|
+
console.log(chalk_1.default.bold('Quick Start:'));
|
|
105
|
+
console.log(` ${chalk_1.default.cyan('sessioncast login')} ${chalk_1.default.gray('# Login via browser')}`);
|
|
106
|
+
console.log(` ${chalk_1.default.cyan('sessioncast agent')} ${chalk_1.default.gray('# Start streaming')}`);
|
|
107
|
+
console.log('');
|
|
108
|
+
console.log(chalk_1.default.gray('Web Console: https://app.sessioncast.io'));
|
|
109
|
+
console.log('');
|
|
110
|
+
(0, config_1.setSeenWelcome)();
|
|
111
|
+
}
|
|
14
112
|
const program = new commander_1.Command();
|
|
15
113
|
program
|
|
16
114
|
.name('sessioncast')
|
|
17
115
|
.description('SessionCast CLI - Control your agents from anywhere')
|
|
18
|
-
.version('
|
|
116
|
+
.version('1.1.2');
|
|
19
117
|
// Login command
|
|
20
118
|
program
|
|
21
119
|
.command('login [api-key]')
|
|
@@ -78,6 +176,11 @@ program.on('--help', () => {
|
|
|
78
176
|
});
|
|
79
177
|
// Default action (no command)
|
|
80
178
|
program.action(() => {
|
|
179
|
+
// Show welcome message on first run
|
|
180
|
+
if (!(0, config_1.hasSeenWelcome)()) {
|
|
181
|
+
showWelcome();
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
81
184
|
console.log(chalk_1.default.bold('\n SessionCast CLI\n'));
|
|
82
185
|
console.log(' Control your agents from anywhere.\n');
|
|
83
186
|
console.log(chalk_1.default.gray(' Run `sessioncast --help` for usage.\n'));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sessioncast-cli",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"description": "SessionCast CLI - Control your agents from anywhere",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -10,8 +10,7 @@
|
|
|
10
10
|
"build": "tsc",
|
|
11
11
|
"dev": "ts-node src/index.ts",
|
|
12
12
|
"start": "node dist/index.js",
|
|
13
|
-
"prepublishOnly": "
|
|
14
|
-
"postinstall": "node scripts/postinstall.js || true"
|
|
13
|
+
"prepublishOnly": "echo 'skip build'"
|
|
15
14
|
},
|
|
16
15
|
"keywords": [
|
|
17
16
|
"sessioncast",
|
|
@@ -24,8 +23,7 @@
|
|
|
24
23
|
"license": "MIT",
|
|
25
24
|
"type": "commonjs",
|
|
26
25
|
"files": [
|
|
27
|
-
"dist"
|
|
28
|
-
"scripts"
|
|
26
|
+
"dist"
|
|
29
27
|
],
|
|
30
28
|
"dependencies": {
|
|
31
29
|
"chalk": "^4.1.2",
|
package/scripts/postinstall.js
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const { execSync } = require('child_process');
|
|
4
|
-
const os = require('os');
|
|
5
|
-
|
|
6
|
-
const GREEN = '\x1b[32m';
|
|
7
|
-
const YELLOW = '\x1b[33m';
|
|
8
|
-
const CYAN = '\x1b[36m';
|
|
9
|
-
const RESET = '\x1b[0m';
|
|
10
|
-
const BOLD = '\x1b[1m';
|
|
11
|
-
const DIM = '\x1b[2m';
|
|
12
|
-
|
|
13
|
-
function checkTmux() {
|
|
14
|
-
try {
|
|
15
|
-
execSync('which tmux', { stdio: 'pipe' });
|
|
16
|
-
return true;
|
|
17
|
-
} catch {
|
|
18
|
-
return false;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function checkItmux() {
|
|
23
|
-
const possiblePaths = [
|
|
24
|
-
process.env.ITMUX_HOME,
|
|
25
|
-
`${os.homedir()}/itmux`,
|
|
26
|
-
'C:\\itmux',
|
|
27
|
-
`${os.homedir()}\\itmux`,
|
|
28
|
-
'C:\\Program Files\\itmux',
|
|
29
|
-
].filter(Boolean);
|
|
30
|
-
|
|
31
|
-
for (const path of possiblePaths) {
|
|
32
|
-
try {
|
|
33
|
-
require('fs').accessSync(path);
|
|
34
|
-
return true;
|
|
35
|
-
} catch {
|
|
36
|
-
continue;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
return false;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function main() {
|
|
43
|
-
const isWindows = os.platform() === 'win32';
|
|
44
|
-
const isMac = os.platform() === 'darwin';
|
|
45
|
-
|
|
46
|
-
console.log('');
|
|
47
|
-
console.log(`${GREEN}${BOLD}✓ SessionCast CLI installed${RESET}`);
|
|
48
|
-
console.log('');
|
|
49
|
-
|
|
50
|
-
// Check tmux/itmux
|
|
51
|
-
const hasTmux = isWindows ? checkItmux() : checkTmux();
|
|
52
|
-
|
|
53
|
-
if (!hasTmux) {
|
|
54
|
-
console.log(`${YELLOW}⚠ tmux not found${RESET}`);
|
|
55
|
-
if (isWindows) {
|
|
56
|
-
console.log(` Install itmux: ${CYAN}https://github.com/phayte/itmux${RESET}`);
|
|
57
|
-
console.log(` Or: ${DIM}choco install itmux${RESET}`);
|
|
58
|
-
} else if (isMac) {
|
|
59
|
-
console.log(` Install: ${DIM}brew install tmux${RESET}`);
|
|
60
|
-
} else {
|
|
61
|
-
console.log(` Install: ${DIM}sudo apt install tmux${RESET} or ${DIM}sudo yum install tmux${RESET}`);
|
|
62
|
-
}
|
|
63
|
-
console.log('');
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// Quick start guide
|
|
67
|
-
console.log(`${BOLD}Quick Start:${RESET}`);
|
|
68
|
-
console.log(` ${CYAN}sessioncast login${RESET} ${DIM}# Login via browser${RESET}`);
|
|
69
|
-
console.log(` ${CYAN}sessioncast agent${RESET} ${DIM}# Start streaming${RESET}`);
|
|
70
|
-
console.log('');
|
|
71
|
-
console.log(`${DIM}Web Console: https://app.sessioncast.io${RESET}`);
|
|
72
|
-
console.log('');
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
main();
|