channel-worker 1.0.11 → 1.0.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.
@@ -84,11 +84,22 @@ class CommandPoller {
84
84
 
85
85
  const extensionPath = this.config.extension_path || '';
86
86
  const result = await this.nst.launchProfile(profile_id, { proxy, extensionPath });
87
- console.log(`[commands] Profile ${profile_id} launched${proxy ? ' (proxy: ' + proxy + ')' : ''}${extensionPath ? ' (ext: ' + extensionPath + ')' : ''}`);
87
+ console.log(`[commands] Profile ${profile_id} launched${result.profileName ? ' (name: ' + result.profileName + ')' : ''}${extensionPath ? ' (ext)' : ''}`);
88
+
89
+ // Sync profile name + UUID back to dashboard
90
+ if (channel_id && (result.profileName || result.profileId)) {
91
+ try {
92
+ const update = {};
93
+ if (result.profileName) update.nst_profile_name = result.profileName;
94
+ if (result.profileId) update.nst_profile_uuid = result.profileId;
95
+ await this.api.request('PUT', `/channels/${channel_id}`, update);
96
+ console.log(`[commands] Synced profile info to channel: name=${result.profileName}, uuid=${result.profileId}`);
97
+ } catch { /* ignore sync errors */ }
98
+ }
88
99
 
89
100
  await this.api.updateCommand(command._id, {
90
101
  status: 'done',
91
- result: { profile_id: result.profileId, launched_at: new Date().toISOString(), proxy: proxy || null },
102
+ result: { profile_id: result.profileId, profile_name: result.profileName, launched_at: new Date().toISOString() },
92
103
  });
93
104
  } catch (err) {
94
105
  console.error(`[commands] Failed to launch profile: ${err.message}`);
@@ -90,6 +90,18 @@ class NstManager {
90
90
  return profileId;
91
91
  }
92
92
 
93
+ // Get profile info by ID (name, etc.)
94
+ async getProfileInfo(profileId) {
95
+ try {
96
+ const res = await this.client.profiles().getProfiles({ s: profileId });
97
+ const profiles = res?.data?.docs || [];
98
+ const match = profiles.find(p => p.profileId === profileId);
99
+ return match || null;
100
+ } catch {
101
+ return null;
102
+ }
103
+ }
104
+
93
105
  // Set proxy on profile
94
106
  async setProxy(profileId, proxyUrl) {
95
107
  if (!proxyUrl) return;
@@ -105,11 +117,10 @@ class NstManager {
105
117
  profileId = await this.ensureProfile(profileIdOrName);
106
118
  }
107
119
 
108
- // If already running, stop first to reload with fresh extension
120
+ // If already running, skip don't restart
109
121
  if (await this.isProfileRunning(profileId)) {
110
- console.log(`[nst] Profile ${profileId} already running — restarting to load extension`);
111
- await this.stopProfile(profileId);
112
- await new Promise(r => setTimeout(r, 3000)); // wait for browser to close
122
+ console.log(`[nst] Profile ${profileId} already running — skipping`);
123
+ return { profileId, alreadyRunning: true };
113
124
  }
114
125
 
115
126
  // Set proxy before launch
@@ -141,7 +152,16 @@ class NstManager {
141
152
  if (res.err) throw new Error(res.msg || 'Failed to connect browser');
142
153
 
143
154
  console.log(`[nst] Browser started`);
144
- return { profileId, wsEndpoint: res?.data?.webSocketDebuggerUrl, response: res };
155
+
156
+ // Get profile info (name) for sync back to dashboard
157
+ const profileInfo = await this.getProfileInfo(profileId);
158
+
159
+ return {
160
+ profileId,
161
+ profileName: profileInfo?.name || null,
162
+ wsEndpoint: res?.data?.webSocketDebuggerUrl,
163
+ response: res,
164
+ };
145
165
  }
146
166
 
147
167
  // Stop browser
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "channel-worker",
3
- "version": "1.0.11",
3
+ "version": "1.0.13",
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": {