channel-worker 2.4.2 → 2.4.3
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 +16 -2
- package/package.json +1 -1
package/lib/command-poller.js
CHANGED
|
@@ -1367,7 +1367,15 @@ class CommandPoller {
|
|
|
1367
1367
|
if (this._chatgptDispatching) return;
|
|
1368
1368
|
this._chatgptDispatching = true;
|
|
1369
1369
|
try {
|
|
1370
|
-
|
|
1370
|
+
// Lazy-init NstManager — the daemon config often ships with an empty
|
|
1371
|
+
// nst_api_key and relies on fetching it from the user's settings.
|
|
1372
|
+
if (!this.nst) {
|
|
1373
|
+
try {
|
|
1374
|
+
const apiKey = await this.api.getSetting('nst_api_key');
|
|
1375
|
+
if (apiKey) this.nst = new NstManager(apiKey);
|
|
1376
|
+
} catch {}
|
|
1377
|
+
if (!this.nst) return;
|
|
1378
|
+
}
|
|
1371
1379
|
const queue = await this.api.getChatgptQueue().catch(() => null);
|
|
1372
1380
|
if (!queue || !Array.isArray(queue.profiles) || queue.profiles.length === 0) return;
|
|
1373
1381
|
|
|
@@ -1401,7 +1409,13 @@ class CommandPoller {
|
|
|
1401
1409
|
// ─── Profile sync — report local Nstbrowser profile list to API ──────────
|
|
1402
1410
|
async _syncProfiles() {
|
|
1403
1411
|
try {
|
|
1404
|
-
if (!this.nst)
|
|
1412
|
+
if (!this.nst) {
|
|
1413
|
+
try {
|
|
1414
|
+
const apiKey = await this.api.getSetting('nst_api_key');
|
|
1415
|
+
if (apiKey) this.nst = new NstManager(apiKey);
|
|
1416
|
+
} catch {}
|
|
1417
|
+
if (!this.nst) return;
|
|
1418
|
+
}
|
|
1405
1419
|
const profiles = await this.nst.listAllProfiles();
|
|
1406
1420
|
if (!profiles || profiles.length === 0) return;
|
|
1407
1421
|
await this.api.reportNstProfiles(this.config.worker_id, profiles).catch((e) => {
|