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 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 streaming platform.
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
- - **API integration**: External command execution and LLM service support
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
- # Clone the repository
27
- git clone git@github.com:your-org/sessioncast-cli.git
28
- cd sessioncast-cli
26
+ npm install -g sessioncast-cli
27
+ ```
28
+
29
+ ## Quick Start
29
30
 
30
- # Install dependencies
31
- npm install
31
+ 1. **Get your agent token** from [app.sessioncast.io](https://app.sessioncast.io)
32
32
 
33
- # Build
34
- npm run build
33
+ 2. **Create config file** `~/.sessioncast.yml`:
35
34
 
36
- # Link globally (optional)
37
- npm link
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://your-relay.sessioncast.io/ws
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 │ (Spring) │ screen/keys │ (Web) │
105
+ │ (Node.js) │ screen/keys │ (Server) │ screen/keys │ (Web) │
100
106
  └─────────────┘ └─────────────┘ └─────────────┘
101
-
102
- │ tmux │ DynamoDB
103
-
104
- ┌─────────────┐ ┌─────────────┐
105
- │ tmux │ │ Sessions │
106
- │ sessions │ │ metadata │
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
- Private - All rights reserved.
132
+ MIT License - see [LICENSE](LICENSE) for details.
133
+
134
+ ## Support
135
+
136
+ - Homepage: https://sessioncast.io
137
+ - Email: devload@sessioncast.io
@@ -66,18 +66,33 @@ class AgentRunner {
66
66
  }
67
67
  }
68
68
  }
69
- if (!finalPath || !fs.existsSync(finalPath)) {
70
- throw new Error(`Config file not found. Tried: ${configPath || envPath || defaultPaths.join(', ')}`);
71
- }
72
- console.log(`Loading config from: ${finalPath}`);
73
- const content = fs.readFileSync(finalPath, 'utf-8');
74
- const ext = path.extname(finalPath).toLowerCase();
75
- if (ext === '.json') {
76
- return JSON.parse(content);
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
- else {
79
- return yaml.load(content);
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
- if (!apiKey) {
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 ${apiKey}`,
19
+ 'Authorization': `Bearer ${token}`,
17
20
  'Content-Type': 'application/json'
18
21
  };
19
22
  }
@@ -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 = '1.1.3';
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('1.1.2');
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",
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": "./dist/index.js"
7
+ "sessioncast": "dist/index.js"
8
8
  },
9
9
  "scripts": {
10
10
  "build": "tsc",