@lightcone-ai/daemon 0.9.12 → 0.9.13

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightcone-ai/daemon",
3
- "version": "0.9.12",
3
+ "version": "0.9.13",
4
4
  "type": "module",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -26,7 +26,7 @@ export class AgentManager {
26
26
  case 'agent:start': return this._startAgent(msg, connection);
27
27
  case 'agent:stop': return this._stopAgent(msg.agentId, msg.teamId, connection);
28
28
  case 'agent:deliver': return this._deliverMessage(msg, connection);
29
- case 'xhs:start_login': return this._startXhsLogin(connection);
29
+ case 'xhs:start_login': return this._startXhsLogin(msg, connection);
30
30
  case 'xhs:stop_login': return this._stopXhsLogin();
31
31
  case 'ping': return connection.send({ type: 'pong' });
32
32
  default:
@@ -369,10 +369,10 @@ export class AgentManager {
369
369
  this._flushPending(key, connection);
370
370
  }
371
371
 
372
- async _startXhsLogin(connection) {
372
+ async _startXhsLogin(msg, connection) {
373
373
  console.log('[AgentManager] Starting XHS login session');
374
374
  try {
375
- await startSession(connection);
375
+ await startSession(connection, msg.userId ?? 'default');
376
376
  } catch (err) {
377
377
  console.error('[AgentManager] XHS login start failed:', err.message);
378
378
  connection.send({ type: 'xhs:login_error', error: err.message });
package/src/xhs-login.js CHANGED
@@ -9,7 +9,10 @@ import path from 'path';
9
9
  import http from 'http';
10
10
  import { WebSocket } from 'ws';
11
11
 
12
- export const XHS_PROFILE_DIR = path.join(homedir(), '.lightcone', 'chrome-profiles', 'xhs');
12
+ export function xhsProfileDir(userId) {
13
+ // User-scoped so multiple users on the same hosted machine don't conflict
14
+ return path.join(homedir(), '.lightcone', 'chrome-profiles', `xhs-${userId}`);
15
+ }
13
16
 
14
17
  const CDP_PORT = 9225;
15
18
  const CHROME_BIN = process.env.CHROME_BIN ?? '/usr/bin/google-chrome';
@@ -40,14 +43,15 @@ export class XhsLoginSession {
40
43
  this._loginCheckTimer = null;
41
44
  }
42
45
 
43
- async start(connection) {
46
+ async start(connection, userId) {
47
+ this._profileDir = xhsProfileDir(userId);
44
48
  // Spawn Chrome
45
49
  this._proc = spawn(CHROME_BIN, [
46
50
  `--remote-debugging-port=${CDP_PORT}`,
47
51
  '--no-sandbox',
48
52
  '--disable-dev-shm-usage',
49
53
  '--headless=new',
50
- `--user-data-dir=${XHS_PROFILE_DIR}`,
54
+ `--user-data-dir=${this._profileDir}`,
51
55
  '--window-size=800,900',
52
56
  'about:blank',
53
57
  ], {
@@ -164,7 +168,7 @@ export class XhsLoginSession {
164
168
  const loggedIn = await this.isLoggedIn();
165
169
  if (loggedIn) {
166
170
  this._stopTimers();
167
- connection.send({ type: 'xhs:login_complete', profileDir: XHS_PROFILE_DIR });
171
+ connection.send({ type: 'xhs:login_complete', profileDir: this._profileDir });
168
172
  this.close();
169
173
  }
170
174
  } catch (err) {
@@ -196,10 +200,10 @@ let _session = null;
196
200
 
197
201
  export function getSession() { return _session; }
198
202
 
199
- export async function startSession(connection) {
203
+ export async function startSession(connection, userId) {
200
204
  if (_session) { _session.close(); _session = null; }
201
205
  _session = new XhsLoginSession();
202
- await _session.start(connection);
206
+ await _session.start(connection, userId);
203
207
  return _session;
204
208
  }
205
209