polydev-ai 1.4.3 → 1.4.4
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/package.json +1 -1
- package/stdio-wrapper.js +18 -13
package/package.json
CHANGED
package/stdio-wrapper.js
CHANGED
|
@@ -598,6 +598,9 @@ class StdioMCPWrapper {
|
|
|
598
598
|
* Combine multiple CLI results and remote perspectives
|
|
599
599
|
*/
|
|
600
600
|
combineAllCliAndPerspectives(localResults, perspectivesResult, args) {
|
|
601
|
+
// Ensure perspectivesResult is always an object to prevent undefined errors
|
|
602
|
+
const safePersp = perspectivesResult || { success: false, error: 'No response from perspectives server' };
|
|
603
|
+
|
|
601
604
|
const combinedResult = {
|
|
602
605
|
success: true,
|
|
603
606
|
timestamp: new Date().toISOString(),
|
|
@@ -605,7 +608,7 @@ class StdioMCPWrapper {
|
|
|
605
608
|
local_cli_count: localResults.length,
|
|
606
609
|
sections: {
|
|
607
610
|
local: localResults,
|
|
608
|
-
remote:
|
|
611
|
+
remote: safePersp
|
|
609
612
|
}
|
|
610
613
|
};
|
|
611
614
|
|
|
@@ -614,25 +617,25 @@ class StdioMCPWrapper {
|
|
|
614
617
|
const hasSomeLocalSuccess = successfulClis.length > 0;
|
|
615
618
|
|
|
616
619
|
// Determine overall success and content
|
|
617
|
-
if (hasSomeLocalSuccess &&
|
|
618
|
-
combinedResult.content = this.formatMultipleCliResponse(localResults,
|
|
620
|
+
if (hasSomeLocalSuccess && safePersp.success) {
|
|
621
|
+
combinedResult.content = this.formatMultipleCliResponse(localResults, safePersp, false);
|
|
619
622
|
combinedResult.tokens_used = successfulClis.reduce((total, cli) => total + (cli.tokens_used || 0), 0);
|
|
620
623
|
combinedResult.latency_ms = Math.max(...successfulClis.map(cli => cli.latency_ms || 0));
|
|
621
|
-
} else if (!hasSomeLocalSuccess &&
|
|
624
|
+
} else if (!hasSomeLocalSuccess && safePersp.success) {
|
|
622
625
|
// Complete fallback case - no local CLIs worked
|
|
623
|
-
combinedResult.content = this.formatMultipleCliResponse(localResults,
|
|
626
|
+
combinedResult.content = this.formatMultipleCliResponse(localResults, safePersp, true);
|
|
624
627
|
combinedResult.fallback_used = true;
|
|
625
628
|
combinedResult.tokens_used = 0; // No local tokens used
|
|
626
|
-
} else if (hasSomeLocalSuccess && !
|
|
629
|
+
} else if (hasSomeLocalSuccess && !safePersp.success) {
|
|
627
630
|
// Local CLIs succeeded, remote failed
|
|
628
|
-
combinedResult.content = this.formatMultipleCliResponse(localResults,
|
|
631
|
+
combinedResult.content = this.formatMultipleCliResponse(localResults, safePersp, false);
|
|
629
632
|
combinedResult.tokens_used = successfulClis.reduce((total, cli) => total + (cli.tokens_used || 0), 0);
|
|
630
633
|
combinedResult.latency_ms = Math.max(...successfulClis.map(cli => cli.latency_ms || 0));
|
|
631
634
|
} else {
|
|
632
635
|
// Both failed
|
|
633
636
|
combinedResult.success = false;
|
|
634
637
|
const cliErrors = localResults.map(cli => `${cli.provider_id}: ${cli.error || 'Unknown error'}`).join('; ');
|
|
635
|
-
const perspectivesError =
|
|
638
|
+
const perspectivesError = safePersp.error || 'Unknown remote error';
|
|
636
639
|
combinedResult.error = `All local CLIs failed: ${cliErrors}; Perspectives also failed: ${perspectivesError}`;
|
|
637
640
|
}
|
|
638
641
|
|
|
@@ -643,6 +646,8 @@ class StdioMCPWrapper {
|
|
|
643
646
|
* Format multiple CLI responses with remote perspectives
|
|
644
647
|
*/
|
|
645
648
|
formatMultipleCliResponse(localResults, perspectivesResult, isFallback) {
|
|
649
|
+
// Safety check - ensure perspectivesResult is always an object
|
|
650
|
+
const safePersp = perspectivesResult || { success: false, error: 'No perspectives data' };
|
|
646
651
|
let formatted = '';
|
|
647
652
|
|
|
648
653
|
// Show all local CLI responses
|
|
@@ -677,19 +682,19 @@ class StdioMCPWrapper {
|
|
|
677
682
|
}
|
|
678
683
|
|
|
679
684
|
// Add remote perspectives
|
|
680
|
-
if (
|
|
681
|
-
if (
|
|
685
|
+
if (safePersp.success) {
|
|
686
|
+
if (safePersp.raw) {
|
|
682
687
|
// Raw content is already formatted - use as-is
|
|
683
|
-
formatted += `${
|
|
688
|
+
formatted += `${safePersp.content}\n\n`;
|
|
684
689
|
} else {
|
|
685
690
|
// Legacy formatting
|
|
686
691
|
const title = (successfulClis.length === 0) ? '🧠 **Perspectives Fallback**' : '🧠 **Supplemental Multi-Model Perspectives**';
|
|
687
692
|
formatted += `${title}\n\n`;
|
|
688
|
-
formatted += `${
|
|
693
|
+
formatted += `${safePersp.content}\n\n`;
|
|
689
694
|
}
|
|
690
695
|
} else if (successfulClis.length > 0) {
|
|
691
696
|
// Show remote error only if we have local success
|
|
692
|
-
formatted += `❌ **Perspectives request failed**: ${
|
|
697
|
+
formatted += `❌ **Perspectives request failed**: ${safePersp.error || 'Unknown error'}\n\n`;
|
|
693
698
|
}
|
|
694
699
|
|
|
695
700
|
return formatted.trim();
|