channel-worker 1.0.8 → 1.0.10

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.
Files changed (2) hide show
  1. package/lib/nst-manager.js +21 -37
  2. package/package.json +1 -1
@@ -114,10 +114,11 @@ class NstManager {
114
114
  profileId = await this.ensureProfile(profileIdOrName, { extensionPath: options.extensionPath });
115
115
  }
116
116
 
117
- // Check if already running
117
+ // If already running, stop first to reload with fresh extension
118
118
  if (await this.isProfileRunning(profileId)) {
119
- console.log(`[nst] Profile ${profileId} already running — skipping`);
120
- return { profileId, alreadyRunning: true };
119
+ console.log(`[nst] Profile ${profileId} already running — restarting to load extension`);
120
+ await this.stopProfile(profileId);
121
+ await new Promise(r => setTimeout(r, 3000)); // wait for browser to close
121
122
  }
122
123
 
123
124
  // Set proxy before launch
@@ -125,43 +126,26 @@ class NstManager {
125
126
  await this.setProxy(profileId, options.proxy);
126
127
  }
127
128
 
128
- console.log(`[nst] Starting browser for profile: ${profileId}`);
129
- const res = await this.client.browsers().startBrowser(profileId);
130
- console.log(`[nst] Browser started`);
129
+ // Use connectBrowser instead of startBrowser — allows passing --load-extension args
130
+ const connectConfig = {
131
+ headless: false,
132
+ autoClose: false,
133
+ };
131
134
 
132
- // Set nstProfileId in chrome.storage via CDP
133
- try {
134
- // Wait for browser to fully start
135
- await new Promise(r => setTimeout(r, 3000));
136
-
137
- const debugInfo = await this.client.browsers().getBrowserDebugger(profileId);
138
- const wsUrl = debugInfo?.data?.webSocketDebuggerUrl;
139
- if (wsUrl) {
140
- const WebSocket = require('ws');
141
- const ws = new WebSocket(wsUrl);
142
- await new Promise((resolve, reject) => {
143
- const timeout = setTimeout(() => { ws.close(); reject(new Error('CDP timeout')); }, 10000);
144
- ws.on('open', () => {
145
- // Navigate a new tab to set storage
146
- ws.send(JSON.stringify({
147
- id: 1,
148
- method: 'Runtime.evaluate',
149
- params: {
150
- expression: `chrome.storage && chrome.storage.local ? chrome.storage.local.set({nstProfileId: "${profileIdOrName}"}) : null`,
151
- awaitPromise: true,
152
- },
153
- }));
154
- setTimeout(() => { clearTimeout(timeout); ws.close(); resolve(); }, 2000);
155
- });
156
- ws.on('error', (e) => { clearTimeout(timeout); reject(e); });
157
- });
158
- console.log(`[nst] Profile ID "${profileIdOrName}" set in extension storage`);
159
- }
160
- } catch (e) {
161
- console.log(`[nst] Could not set profile ID in storage: ${e.message}`);
135
+ // Add extension path if provided
136
+ if (options.extensionPath) {
137
+ connectConfig.args = {
138
+ '--load-extension': options.extensionPath,
139
+ '--disable-extensions-except': options.extensionPath,
140
+ };
141
+ console.log(`[nst] Loading extension: ${options.extensionPath}`);
162
142
  }
163
143
 
164
- return { profileId, response: res };
144
+ console.log(`[nst] Connecting browser for profile: ${profileId}`);
145
+ const res = await this.client.cdpEndpoints().connectBrowser(profileId, connectConfig);
146
+ console.log(`[nst] Browser started`);
147
+
148
+ return { profileId, wsEndpoint: res?.data?.webSocketDebuggerUrl, response: res };
165
149
  }
166
150
 
167
151
  // Stop browser
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "channel-worker",
3
- "version": "1.0.8",
3
+ "version": "1.0.10",
4
4
  "description": "Channel Manager worker daemon — runs on remote machines to execute video pipeline jobs",
5
5
  "main": "lib/daemon.js",
6
6
  "bin": {