channel-worker 2.4.0 → 2.4.1

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.
@@ -1361,28 +1361,27 @@ class CommandPoller {
1361
1361
  try {
1362
1362
  if (!this.nst) return;
1363
1363
  const queue = await this.api.getChatgptQueue().catch(() => null);
1364
- if (!queue || !queue.profile_id || queue.count <= 0) return;
1365
-
1366
- const profileId = queue.profile_id;
1367
- // Skip launch if already running (check via Nstbrowser running list).
1368
- let alreadyRunning = false;
1369
- try {
1370
- const running = await this.nst.getRunningBrowsers();
1371
- alreadyRunning = running.some(b => b.profileId === profileId || (b.name && b.name.toLowerCase() === profileId.toLowerCase()));
1372
- } catch {}
1373
- if (alreadyRunning) {
1374
- this._profileLastActivity[profileId] = Date.now();
1375
- return;
1376
- }
1377
-
1378
- console.log(`[chatgpt-dispatch] Launching ${profileId} (queue=${queue.count})`);
1379
- try {
1380
- // Reuse _launchRendererProfile contract — it just needs { nst_profile_id, os, proxy }.
1381
- await this._launchRendererProfile({ nst_profile_id: profileId, os: 'windows', proxy: null });
1382
- this._profileLastActivity[profileId] = Date.now();
1383
- console.log(`[chatgpt-dispatch] ${profileId} launched`);
1384
- } catch (err) {
1385
- console.error(`[chatgpt-dispatch] Failed to launch ${profileId}: ${err.message}`);
1364
+ if (!queue || !Array.isArray(queue.profiles) || queue.profiles.length === 0) return;
1365
+
1366
+ let running = [];
1367
+ try { running = await this.nst.getRunningBrowsers(); } catch {}
1368
+
1369
+ for (const item of queue.profiles) {
1370
+ const profileId = item.id;
1371
+ const alreadyRunning = running.some(b =>
1372
+ b.profileId === profileId || (b.name && b.name.toLowerCase() === profileId.toLowerCase()));
1373
+ if (alreadyRunning) {
1374
+ this._profileLastActivity[profileId] = Date.now();
1375
+ continue;
1376
+ }
1377
+ console.log(`[chatgpt-dispatch] Launching ${profileId} (pending=${item.pending})`);
1378
+ try {
1379
+ await this._launchRendererProfile({ nst_profile_id: profileId, os: 'windows', proxy: null });
1380
+ this._profileLastActivity[profileId] = Date.now();
1381
+ console.log(`[chatgpt-dispatch] ${profileId} launched`);
1382
+ } catch (err) {
1383
+ console.error(`[chatgpt-dispatch] Failed to launch ${profileId}: ${err.message}`);
1384
+ }
1386
1385
  }
1387
1386
  } catch (err) {
1388
1387
  console.error(`[chatgpt-dispatch] Error: ${err.message}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "channel-worker",
3
- "version": "2.4.0",
3
+ "version": "2.4.1",
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": {