sessioncast-cli 1.1.3 → 1.1.5
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/LICENSE +21 -0
- package/README.md +40 -65
- package/dist/agent/runner.js +25 -10
- package/dist/api.js +5 -2
- package/dist/commands/login.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +2 -2
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 SessionCast
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# SessionCast CLI
|
|
2
2
|
|
|
3
|
-
Node.js agent and CLI for SessionCast - a real-time terminal
|
|
3
|
+
Node.js agent and CLI for [SessionCast](https://sessioncast.io) - a real-time terminal sharing platform.
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
@@ -9,7 +9,7 @@ Node.js agent and CLI for SessionCast - a real-time terminal streaming platform.
|
|
|
9
9
|
- **Real-time screen capture**: Streams terminal output with gzip compression
|
|
10
10
|
- **Circuit breaker**: Prevents reconnection storms with exponential backoff
|
|
11
11
|
- **Interactive control**: Supports keyboard input, resize, and session management
|
|
12
|
-
- **
|
|
12
|
+
- **File viewer**: Cmd+Click on file paths to view files in browser
|
|
13
13
|
|
|
14
14
|
### CLI Commands
|
|
15
15
|
- `sessioncast login <api-key>` - Authenticate with API key
|
|
@@ -23,27 +23,36 @@ Node.js agent and CLI for SessionCast - a real-time terminal streaming platform.
|
|
|
23
23
|
## Installation
|
|
24
24
|
|
|
25
25
|
```bash
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
npm install -g sessioncast-cli
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Quick Start
|
|
29
30
|
|
|
30
|
-
|
|
31
|
-
npm install
|
|
31
|
+
1. **Get your agent token** from [app.sessioncast.io](https://app.sessioncast.io)
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
npm run build
|
|
33
|
+
2. **Create config file** `~/.sessioncast.yml`:
|
|
35
34
|
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
```yaml
|
|
36
|
+
machineId: my-machine
|
|
37
|
+
relay: wss://relay.sessioncast.io/ws
|
|
38
|
+
token: agt_your_agent_token_here
|
|
38
39
|
```
|
|
39
40
|
|
|
41
|
+
3. **Start the agent**:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
sessioncast agent
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
4. **View your sessions** at [app.sessioncast.io](https://app.sessioncast.io)
|
|
48
|
+
|
|
40
49
|
## Configuration
|
|
41
50
|
|
|
42
51
|
Create `~/.sessioncast.yml` or `~/.tmux-remote.yml`:
|
|
43
52
|
|
|
44
53
|
```yaml
|
|
45
54
|
machineId: my-machine
|
|
46
|
-
relay: wss://
|
|
55
|
+
relay: wss://relay.sessioncast.io/ws
|
|
47
56
|
token: agt_your_agent_token_here
|
|
48
57
|
|
|
49
58
|
# Optional: API configuration
|
|
@@ -59,9 +68,6 @@ api:
|
|
|
59
68
|
|
|
60
69
|
llm:
|
|
61
70
|
enabled: false
|
|
62
|
-
provider: ollama
|
|
63
|
-
model: codellama
|
|
64
|
-
endpoint: http://localhost:11434
|
|
65
71
|
```
|
|
66
72
|
|
|
67
73
|
### Environment Variables
|
|
@@ -96,56 +102,15 @@ sessioncast send my-machine/dev "Enter"
|
|
|
96
102
|
```
|
|
97
103
|
┌─────────────┐ WebSocket ┌─────────────┐ WebSocket ┌─────────────┐
|
|
98
104
|
│ Agent │ ◄─────────────────► │ Relay │ ◄────────────────► │ Viewer │
|
|
99
|
-
│ (Node.js) │ screen/keys │ (
|
|
105
|
+
│ (Node.js) │ screen/keys │ (Server) │ screen/keys │ (Web) │
|
|
100
106
|
└─────────────┘ └─────────────┘ └─────────────┘
|
|
101
|
-
│
|
|
102
|
-
│ tmux
|
|
103
|
-
▼
|
|
104
|
-
┌─────────────┐
|
|
105
|
-
│ tmux │
|
|
106
|
-
│ sessions │
|
|
107
|
-
└─────────────┘
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
## Development
|
|
111
|
-
|
|
112
|
-
```bash
|
|
113
|
-
# Install dependencies
|
|
114
|
-
npm install
|
|
115
|
-
|
|
116
|
-
# Build TypeScript
|
|
117
|
-
npm run build
|
|
118
|
-
|
|
119
|
-
# Watch mode (if configured)
|
|
120
|
-
npm run dev
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
## Project Structure
|
|
124
|
-
|
|
125
|
-
```
|
|
126
|
-
sessioncast-cli/
|
|
127
|
-
├── src/
|
|
128
|
-
│ ├── agent/
|
|
129
|
-
│ │ ├── api-client.ts # API WebSocket client
|
|
130
|
-
│ │ ├── exec-service.ts # Command execution service
|
|
131
|
-
│ │ ├── llm-service.ts # LLM integration (Ollama/OpenAI)
|
|
132
|
-
│ │ ├── runner.ts # Agent runner with auto-discovery
|
|
133
|
-
│ │ ├── session-handler.ts # tmux session handler
|
|
134
|
-
│ │ ├── tmux.ts # tmux utilities
|
|
135
|
-
│ │ ├── types.ts # Type definitions
|
|
136
|
-
│ │ └── websocket.ts # WebSocket client with circuit breaker
|
|
137
|
-
│ ├── commands/
|
|
138
|
-
│ │ ├── agent.ts # Agent command
|
|
139
|
-
│ │ ├── agents.ts # List agents command
|
|
140
|
-
│ │ ├── login.ts # Login command
|
|
141
|
-
│ │ ├── sendkeys.ts # Send keys command
|
|
142
|
-
│ │ └── sessions.ts # List sessions command
|
|
143
|
-
│ ├── api.ts # API client
|
|
144
|
-
│ ├── config.ts # Configuration management
|
|
145
|
-
│ └── index.ts # CLI entry point
|
|
146
|
-
├── package.json
|
|
147
|
-
├── tsconfig.json
|
|
148
|
-
└── README.md
|
|
107
|
+
│
|
|
108
|
+
│ tmux
|
|
109
|
+
▼
|
|
110
|
+
┌─────────────┐
|
|
111
|
+
│ tmux │
|
|
112
|
+
│ sessions │
|
|
113
|
+
└─────────────┘
|
|
149
114
|
```
|
|
150
115
|
|
|
151
116
|
## Circuit Breaker
|
|
@@ -157,6 +122,16 @@ The agent implements a circuit breaker pattern to prevent reconnection storms:
|
|
|
157
122
|
- **Max delay**: 30 seconds (with exponential backoff + jitter)
|
|
158
123
|
- **Circuit breaker duration**: 2 minutes cooldown after max attempts
|
|
159
124
|
|
|
125
|
+
## Requirements
|
|
126
|
+
|
|
127
|
+
- Node.js >= 18
|
|
128
|
+
- tmux installed on the host machine
|
|
129
|
+
|
|
160
130
|
## License
|
|
161
131
|
|
|
162
|
-
|
|
132
|
+
MIT License - see [LICENSE](LICENSE) for details.
|
|
133
|
+
|
|
134
|
+
## Support
|
|
135
|
+
|
|
136
|
+
- Homepage: https://sessioncast.io
|
|
137
|
+
- Email: devload@sessioncast.io
|
package/dist/agent/runner.js
CHANGED
|
@@ -66,18 +66,33 @@ class AgentRunner {
|
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
69
|
+
// If yml file found, load from file
|
|
70
|
+
if (finalPath && fs.existsSync(finalPath)) {
|
|
71
|
+
console.log(`Loading config from: ${finalPath}`);
|
|
72
|
+
const content = fs.readFileSync(finalPath, 'utf-8');
|
|
73
|
+
const ext = path.extname(finalPath).toLowerCase();
|
|
74
|
+
if (ext === '.json') {
|
|
75
|
+
return JSON.parse(content);
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
return yaml.load(content);
|
|
79
|
+
}
|
|
77
80
|
}
|
|
78
|
-
|
|
79
|
-
|
|
81
|
+
// SaaS mode: load from conf store (after sessioncast login)
|
|
82
|
+
const config_1 = require("../config");
|
|
83
|
+
const agentToken = (0, config_1.getAgentToken)();
|
|
84
|
+
const relayUrl = (0, config_1.getRelayUrl)();
|
|
85
|
+
const machineId = (0, config_1.getMachineId)();
|
|
86
|
+
if (agentToken) {
|
|
87
|
+
const os = require("os");
|
|
88
|
+
console.log('Loading config from login credentials (SaaS mode)');
|
|
89
|
+
return {
|
|
90
|
+
machineId: machineId || os.hostname(),
|
|
91
|
+
relay: relayUrl || 'wss://relay.sessioncast.io/ws',
|
|
92
|
+
token: agentToken,
|
|
93
|
+
};
|
|
80
94
|
}
|
|
95
|
+
throw new Error('No config found. Run "sessioncast login" first, or create ~/.sessioncast.yml');
|
|
81
96
|
}
|
|
82
97
|
async start() {
|
|
83
98
|
if (this.running)
|
package/dist/api.js
CHANGED
|
@@ -9,11 +9,14 @@ const config_1 = require("./config");
|
|
|
9
9
|
class ApiClient {
|
|
10
10
|
getHeaders() {
|
|
11
11
|
const apiKey = (0, config_1.getApiKey)();
|
|
12
|
-
|
|
12
|
+
const accessToken = (0, config_1.getAccessToken)();
|
|
13
|
+
const agentToken = (0, config_1.getAgentToken)();
|
|
14
|
+
const token = accessToken || apiKey || agentToken;
|
|
15
|
+
if (!token) {
|
|
13
16
|
throw new Error('Not logged in. Run: sessioncast login');
|
|
14
17
|
}
|
|
15
18
|
return {
|
|
16
|
-
'Authorization': `Bearer ${
|
|
19
|
+
'Authorization': `Bearer ${token}`,
|
|
17
20
|
'Content-Type': 'application/json'
|
|
18
21
|
};
|
|
19
22
|
}
|
package/dist/commands/login.js
CHANGED
|
@@ -236,7 +236,7 @@ function status() {
|
|
|
236
236
|
console.log(chalk_1.default.gray('Run: sessioncast login'));
|
|
237
237
|
}
|
|
238
238
|
}
|
|
239
|
-
const CURRENT_VERSION = '
|
|
239
|
+
const CURRENT_VERSION = require('../../package.json').version;
|
|
240
240
|
async function checkForUpdates() {
|
|
241
241
|
try {
|
|
242
242
|
const res = await (0, node_fetch_1.default)('https://registry.npmjs.org/sessioncast-cli/latest', { timeout: 3000 });
|
package/dist/index.js
CHANGED
|
@@ -113,7 +113,7 @@ const program = new commander_1.Command();
|
|
|
113
113
|
program
|
|
114
114
|
.name('sessioncast')
|
|
115
115
|
.description('SessionCast CLI - Control your agents from anywhere')
|
|
116
|
-
.version('
|
|
116
|
+
.version(require('../package.json').version);
|
|
117
117
|
// Login command
|
|
118
118
|
program
|
|
119
119
|
.command('login [api-key]')
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sessioncast-cli",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.5",
|
|
4
4
|
"description": "SessionCast CLI - Control your agents from anywhere",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
7
|
-
"sessioncast": "
|
|
7
|
+
"sessioncast": "dist/index.js"
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
10
|
"build": "tsc",
|