dankgrinder 7.78.0 → 7.81.0

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/grinder.js CHANGED
@@ -339,6 +339,17 @@ function colorBanner() {
339
339
 
340
340
  // ── Simple Logging ─────────────────────────────────────────────
341
341
  function log(type, msg, label) {
342
+ // Route grinding logs through terminal flash events when active
343
+ if (terminal._active) {
344
+ const clean = stripAnsi(String(msg || '')).substring(0, 120);
345
+ const tagClean = stripAnsi(String(label || ''));
346
+ terminal.flashEvent(
347
+ type === 'error' ? 'death' : type === 'warn' ? 'warn' : 'info',
348
+ `${tagClean ? tagClean + ' ' : ''}${clean}`
349
+ );
350
+ return;
351
+ }
352
+
342
353
  const colorIcons = {
343
354
  info: `${c.dim}·${c.reset}`, success: `${rgb(52, 211, 153)}✓${c.reset}`,
344
355
  error: `${rgb(239, 68, 68)}✗${c.reset}`, warn: `${rgb(251, 191, 36)}!${c.reset}`,
@@ -2750,11 +2761,6 @@ async function start(apiKey, apiUrl, opts = {}) {
2750
2761
  const CLOUD_MODE = opts.cloud === true;
2751
2762
  startTime = Date.now();
2752
2763
 
2753
- if (CLOUD_MODE) {
2754
- // In cloud mode, API_KEY is the CLOUD_ADMIN_KEY — not used for user auth.
2755
- // Per-account keys are fetched per-account from /api/cloud/grinders.
2756
- console.log('🌥️ Starting in CLOUD MODE — grinding all cloud-enabled accounts');
2757
- }
2758
2764
  REDIS_URL = process.env.REDIS_URL || '';
2759
2765
  WEBHOOK_URL = process.env.WEBHOOK_URL || '';
2760
2766
 
@@ -2762,15 +2768,14 @@ async function start(apiKey, apiUrl, opts = {}) {
2762
2768
  let hasZlib = false;
2763
2769
  try { require('zlib-sync'); hasZlib = true; } catch {}
2764
2770
 
2765
- console.log(colorBanner());
2766
- console.log(
2767
- ` ${rgb(139, 92, 246)}v${PKG_VERSION}${c.reset}` +
2768
- ` ${c.dim}·${c.reset} ${c.white}${AccountWorker.COMMAND_MAP.length} Commands${c.reset}` +
2769
- ` ${c.dim}·${c.reset} ${rgb(34, 211, 238)}${CLOUD_MODE ? 'Cloud Mode' : (CLUSTER_ENABLED ? 'Cluster Mode' : 'Standalone')}${c.reset}` +
2770
- ` ${c.dim}·${c.reset} ${rgb(52, 211, 153)}Auto-Recovery${c.reset}` +
2771
- ` ${c.dim}·${c.reset} ${rgb(251, 191, 36)}Loss Limiter${c.reset}`
2772
- );
2773
- log('info', `${c.dim}Fetching accounts...${c.reset}`);
2771
+ // Init terminal FIRST — captures all subsequent console.log output
2772
+ terminal.setVersion(PKG_VERSION);
2773
+ terminal.init({ workers: [], startTime });
2774
+
2775
+ if (CLOUD_MODE) {
2776
+ console.log(`${rgb(139, 92, 246)}🌥️ Starting in CLOUD MODE — grinding all cloud-enabled accounts${c.reset}`);
2777
+ }
2778
+ terminal.startPhase('Fetching accounts...');
2774
2779
 
2775
2780
  const fetchOpts = CLOUD_MODE ? { cloud: true } : {};
2776
2781
  let data = await fetchConfig(4, 2000, fetchOpts);
@@ -2781,9 +2786,11 @@ async function start(apiKey, apiUrl, opts = {}) {
2781
2786
  data = await fetchConfig(4, 2000, fetchOpts);
2782
2787
  }
2783
2788
  if (data && data.error) {
2789
+ terminal.endPhase(`API error: ${data.error}`, false);
2784
2790
  log('error', `${data.error}`);
2785
2791
  return;
2786
2792
  }
2793
+ terminal.endPhase(`API connected — ${data.accounts?.length || 0} accounts`);
2787
2794
 
2788
2795
  // Cloud mode: post heartbeat every 30s
2789
2796
  if (CLOUD_MODE) {
@@ -2828,10 +2835,6 @@ async function start(apiKey, apiUrl, opts = {}) {
2828
2835
  }
2829
2836
  }
2830
2837
 
2831
- const checks = [];
2832
- checks.push(`${rgb(52, 211, 153)}✓${c.reset} ${c.white}API${c.reset}`);
2833
- if (REDIS_URL) checks.push(redis ? `${rgb(52, 211, 153)}✓${c.reset} ${c.white}Redis${c.reset}` : `${rgb(251, 191, 36)}○${c.reset} ${c.dim}Redis (connecting...)${c.reset}`);
2834
-
2835
2838
  // Init rawLogger Redis (uses same URL — logs all raw gateway data)
2836
2839
  if (REDIS_URL) {
2837
2840
  rawLogger.init(redis);
@@ -2876,16 +2879,7 @@ async function start(apiKey, apiUrl, opts = {}) {
2876
2879
  }
2877
2880
  }
2878
2881
  });
2879
- checks.push(`${rgb(52, 211, 153)}✓${c.reset} ${c.white}RawLog${c.reset}`);
2880
- }
2881
- if (hasZlib) checks.push(`${rgb(52, 211, 153)}✓${c.reset} ${c.white}zlib${c.reset}`);
2882
- if (WEBHOOK_URL) checks.push(`${rgb(52, 211, 153)}✓${c.reset} ${c.white}Webhook${c.reset}`);
2883
- if (CLUSTER_ENABLED) {
2884
- checks.push(`${rgb(52, 211, 153)}✓${c.reset} ${rgb(34, 211, 238)}Cluster${c.reset} ${c.dim}(${NODE_ID.substring(0, 12)})${c.reset}`);
2885
2882
  }
2886
- checks.push(`${rgb(52, 211, 153)}✓${c.reset} ${c.white}${accounts.length} Account${accounts.length > 1 ? 's' : ''}${c.reset}`);
2887
- console.log(` ${checks.join(' ')}`);
2888
- console.log('');
2889
2883
 
2890
2884
  // ── Terminal renderer init ─────────────────────────────────────
2891
2885
  terminal.setVersion(PKG_VERSION);