polydev-ai 1.9.10 → 1.9.12

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/cliManager.js CHANGED
@@ -29,12 +29,15 @@ class CLIManager {
29
29
  this.statusCache = new Map();
30
30
  this.CACHE_TIMEOUT_MS = 5 * 60 * 1000; // 5 minutes
31
31
 
32
- // Initialize status reporter if available
32
+ // StatusReporter is opt-IN only (must explicitly pass enableStatusReporting: true)
33
+ // It's redundant for normal operation since updateCliStatusInDatabase() handles DB updates
34
+ // via /api/cli-status-update. StatusReporter sends to /api/mcp which uses different auth
35
+ // and causes 401 errors. Only enable if explicitly requested via enable_status_reporting tool.
33
36
  this.statusReporter = null;
34
- if (StatusReporter && options.enableStatusReporting !== false) {
37
+ if (StatusReporter && options.enableStatusReporting === true) {
35
38
  this.statusReporter = new StatusReporter({
36
39
  userToken: options.userToken || process.env.POLYDEV_USER_TOKEN,
37
- reportingEnabled: options.reportingEnabled !== false,
40
+ reportingEnabled: true,
38
41
  heartbeatIntervalMs: options.heartbeatIntervalMs,
39
42
  debug: options.debug || process.env.POLYDEV_CLI_DEBUG === 'true'
40
43
  });
@@ -503,11 +503,42 @@ To re-login: npx polydev-ai`
503
503
  const sessionId = crypto.randomBytes(32).toString('hex');
504
504
 
505
505
  try {
506
- // Create session on server
507
- const createResponse = await fetch(`https://www.polydev.ai/api/auth/cli-session/${sessionId}`, {
508
- method: 'POST',
509
- headers: { 'Content-Type': 'application/json' }
510
- });
506
+ // Create session on server (with retry for transient network issues)
507
+ let createResponse;
508
+ let lastError;
509
+ for (let attempt = 0; attempt < 3; attempt++) {
510
+ try {
511
+ createResponse = await fetch(`https://www.polydev.ai/api/auth/cli-session/${sessionId}`, {
512
+ method: 'POST',
513
+ headers: { 'Content-Type': 'application/json' }
514
+ });
515
+ lastError = null;
516
+ break; // Success, exit retry loop
517
+ } catch (fetchErr) {
518
+ lastError = fetchErr;
519
+ const cause = fetchErr.cause ? ` (${fetchErr.cause.code || fetchErr.cause.message || fetchErr.cause})` : '';
520
+ console.error(`[Polydev] Session creation attempt ${attempt + 1}/3 failed: ${fetchErr.message}${cause}`);
521
+ if (attempt < 2) {
522
+ await new Promise(r => setTimeout(r, 1000 * (attempt + 1))); // 1s, 2s backoff
523
+ }
524
+ }
525
+ }
526
+
527
+ if (lastError) {
528
+ const cause = lastError.cause ? ` (${lastError.cause.code || lastError.cause.message || lastError.cause})` : '';
529
+ console.error('[Polydev] All session creation attempts failed:', lastError.message, cause);
530
+ return {
531
+ jsonrpc: '2.0',
532
+ id,
533
+ result: {
534
+ content: [{
535
+ type: 'text',
536
+ text: `Login failed: Could not reach polydev.ai${cause}\n\nThis usually means a network connectivity issue.\n\nAlternative: Run in your terminal:\n npx polydev-ai`
537
+ }],
538
+ isError: true
539
+ }
540
+ };
541
+ }
511
542
 
512
543
  if (!createResponse.ok) {
513
544
  const error = await createResponse.text();
@@ -544,23 +575,26 @@ To re-login: npx polydev-ai`
544
575
  // if this process dies, the new one can resume polling with same session)
545
576
  this.startLoginPolling(sessionId);
546
577
 
547
- // Return immediately
578
+ // Return immediately with accurate status
548
579
  return {
549
580
  jsonrpc: '2.0',
550
581
  id,
551
582
  result: {
552
583
  content: [{
553
584
  type: 'text',
554
- text: `LOGIN SUCCESSFUL
555
- ================
585
+ text: `AUTHENTICATION STARTED
586
+ ======================
556
587
 
557
- Token saved to:
588
+ A browser window is opening for you to sign in.
589
+
590
+ If it doesn't open, visit:
591
+ ${authUrl}
592
+
593
+ Once you sign in, your token will be saved automatically to:
558
594
  ~/.polydev.env
559
595
  ~/.zshrc
560
596
 
561
- IMPORTANT: Restart your IDE to activate.
562
-
563
- After restart, you can:
597
+ After login completes, you can:
564
598
  /polydev:ask Query multiple AI models
565
599
  /polydev:auth Check status & credits
566
600
 
@@ -570,14 +604,15 @@ Dashboard: https://polydev.ai/dashboard`
570
604
  };
571
605
 
572
606
  } catch (error) {
573
- console.error('[Polydev] Login error:', error);
607
+ const cause = error.cause ? ` (${error.cause.code || error.cause.message || error.cause})` : '';
608
+ console.error('[Polydev] Login error:', error.message, cause);
574
609
  return {
575
610
  jsonrpc: '2.0',
576
611
  id,
577
612
  result: {
578
613
  content: [{
579
614
  type: 'text',
580
- text: `Login failed: ${error.message}\n\nPlease try: npx polydev-ai`
615
+ text: `Login failed: ${error.message}${cause}\n\nPlease try: npx polydev-ai`
581
616
  }],
582
617
  isError: true
583
618
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "polydev-ai",
3
- "version": "1.9.10",
3
+ "version": "1.9.12",
4
4
  "engines": {
5
5
  "node": ">=20.x <=22.x"
6
6
  },