channel-worker 1.0.12 → 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.
- package/lib/command-poller.js +13 -2
- package/lib/nst-manager.js +22 -1
- package/package.json +1 -1
package/lib/command-poller.js
CHANGED
|
@@ -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${
|
|
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()
|
|
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}`);
|
package/lib/nst-manager.js
CHANGED
|
@@ -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;
|
|
@@ -140,7 +152,16 @@ class NstManager {
|
|
|
140
152
|
if (res.err) throw new Error(res.msg || 'Failed to connect browser');
|
|
141
153
|
|
|
142
154
|
console.log(`[nst] Browser started`);
|
|
143
|
-
|
|
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
|
+
};
|
|
144
165
|
}
|
|
145
166
|
|
|
146
167
|
// Stop browser
|