sessioncast-cli 1.1.2 → 1.1.4

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.
@@ -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
  }
@@ -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(' Run `sessioncast agent` to start the agent'));
202
- console.log(chalk_1.default.gray(' Run `sessioncast status` to check your login status\n'));
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.4';
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sessioncast-cli",
3
- "version": "1.1.2",
3
+ "version": "1.1.4",
4
4
  "description": "SessionCast CLI - Control your agents from anywhere",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -10,7 +10,7 @@
10
10
  "build": "tsc",
11
11
  "dev": "ts-node src/index.ts",
12
12
  "start": "node dist/index.js",
13
- "prepublishOnly": "npm run build"
13
+ "prepublishOnly": "echo 'skip build'"
14
14
  },
15
15
  "keywords": [
16
16
  "sessioncast",