channel-worker 1.0.13 → 1.0.15

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,22 +84,11 @@ 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${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
- }
87
+ console.log(`[commands] Profile ${profile_id} launched${extensionPath ? ' (ext)' : ''}`);
99
88
 
100
89
  await this.api.updateCommand(command._id, {
101
90
  status: 'done',
102
- result: { profile_id: result.profileId, profile_name: result.profileName, launched_at: new Date().toISOString() },
91
+ result: { profile_id: result.profileId, launched_at: new Date().toISOString() },
103
92
  });
104
93
  } catch (err) {
105
94
  console.error(`[commands] Failed to launch profile: ${err.message}`);
@@ -37,8 +37,8 @@ class NstManager {
37
37
  // Find profile by name, return profileId
38
38
  async findProfile(name) {
39
39
  try {
40
+ // Try SDK first
40
41
  const res = await this.client.profiles().getProfiles({ keyword: name });
41
- // Response: { data: { docs: [...], totalDocs, ... } }
42
42
  let profiles = [];
43
43
  if (res?.data?.docs && Array.isArray(res.data.docs)) {
44
44
  profiles = res.data.docs;
@@ -47,9 +47,17 @@ class NstManager {
47
47
  }
48
48
 
49
49
  const match = profiles.find(p => p.name === name);
50
- if (match) {
51
- return match.profileId || match._id;
52
- }
50
+ if (match) return match.profileId || match._id;
51
+
52
+ // Fallback: fetch all profiles via local API
53
+ const rawRes = await fetch('http://localhost:8848/api/v2/profiles/', {
54
+ headers: { 'x-api-key': this.apiKey },
55
+ });
56
+ const rawData = await rawRes.json();
57
+ const allProfiles = rawData?.data?.docs || rawData?.data || [];
58
+ const fallback = allProfiles.find(p => p.name === name);
59
+ if (fallback) return fallback.profileId || fallback._id;
60
+
53
61
  return null;
54
62
  } catch (err) {
55
63
  console.error(`[nst] Error finding profile "${name}":`, err.message);
@@ -90,18 +98,6 @@ class NstManager {
90
98
  return profileId;
91
99
  }
92
100
 
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
-
105
101
  // Set proxy on profile
106
102
  async setProxy(profileId, proxyUrl) {
107
103
  if (!proxyUrl) return;
@@ -152,16 +148,7 @@ class NstManager {
152
148
  if (res.err) throw new Error(res.msg || 'Failed to connect browser');
153
149
 
154
150
  console.log(`[nst] Browser started`);
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
- };
151
+ return { profileId, wsEndpoint: res?.data?.webSocketDebuggerUrl, response: res };
165
152
  }
166
153
 
167
154
  // Stop browser
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "channel-worker",
3
- "version": "1.0.13",
3
+ "version": "1.0.15",
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": {