polydev-ai 1.9.11 → 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/mcp/stdio-wrapper.js +49 -14
- package/package.json +1 -1
package/mcp/stdio-wrapper.js
CHANGED
|
@@ -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
|
-
|
|
508
|
-
|
|
509
|
-
|
|
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: `
|
|
555
|
-
|
|
585
|
+
text: `AUTHENTICATION STARTED
|
|
586
|
+
======================
|
|
556
587
|
|
|
557
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
}
|