polydev-ai 1.2.15 → 1.4.1

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.
@@ -98,8 +98,14 @@ class StdioMCPWrapper {
98
98
  };
99
99
 
100
100
  case 'tools/call':
101
- // Handle CLI tools locally, forward others to remote server
101
+ // Handle get_perspectives with local CLIs + remote perspectives
102
102
  const toolName = params.name;
103
+
104
+ if (toolName === 'get_perspectives') {
105
+ return await this.handleGetPerspectivesWithCLIs(params, id);
106
+ }
107
+
108
+ // Handle other CLI tools locally
103
109
  if (toolName.startsWith('polydev.') && this.isCliTool(toolName)) {
104
110
  return await this.handleLocalCliTool(request);
105
111
  } else {
@@ -174,6 +180,45 @@ class StdioMCPWrapper {
174
180
  return cliTools.includes(toolName);
175
181
  }
176
182
 
183
+ /**
184
+ * Handle get_perspectives with local CLIs + remote perspectives
185
+ */
186
+ async handleGetPerspectivesWithCLIs(params, id) {
187
+ console.error(`[Stdio Wrapper] Handling get_perspectives with local CLIs + remote`);
188
+
189
+ try {
190
+ // Use existing localSendCliPrompt logic which already:
191
+ // 1. Checks all local CLIs
192
+ // 2. Calls remote perspectives
193
+ // 3. Combines results
194
+ const result = await this.localSendCliPrompt(params.arguments);
195
+
196
+ return {
197
+ jsonrpc: '2.0',
198
+ id,
199
+ result: {
200
+ content: [
201
+ {
202
+ type: 'text',
203
+ text: result.content || this.formatCliResponse(result)
204
+ }
205
+ ]
206
+ }
207
+ };
208
+
209
+ } catch (error) {
210
+ console.error(`[Stdio Wrapper] get_perspectives error:`, error);
211
+ return {
212
+ jsonrpc: '2.0',
213
+ id,
214
+ error: {
215
+ code: -32603,
216
+ message: error.message
217
+ }
218
+ };
219
+ }
220
+ }
221
+
177
222
  /**
178
223
  * Handle CLI tools locally without remote server calls
179
224
  */
@@ -460,9 +505,13 @@ class StdioMCPWrapper {
460
505
  raw: true // Flag to indicate this is pre-formatted content
461
506
  };
462
507
  } else if (remoteResponse.error) {
508
+ // Normalize error - handle both string and object formats
509
+ const errorMessage = typeof remoteResponse.error === 'string'
510
+ ? remoteResponse.error
511
+ : (remoteResponse.error?.message || JSON.stringify(remoteResponse.error) || 'Remote perspectives failed');
463
512
  return {
464
513
  success: false,
465
- error: remoteResponse.error.message || 'Remote perspectives failed',
514
+ error: errorMessage,
466
515
  timestamp: new Date().toISOString()
467
516
  };
468
517
  } else {
@@ -519,8 +568,9 @@ class StdioMCPWrapper {
519
568
  } else {
520
569
  // Both failed
521
570
  combinedResult.success = false;
522
- const cliErrors = localResults.map(cli => `${cli.provider_id}: ${cli.error}`).join('; ');
523
- combinedResult.error = `All local CLIs failed: ${cliErrors}; Perspectives also failed: ${perspectivesResult.error}`;
571
+ const cliErrors = localResults.map(cli => `${cli.provider_id}: ${cli.error || 'Unknown error'}`).join('; ');
572
+ const perspectivesError = perspectivesResult?.error || 'Unknown remote error';
573
+ combinedResult.error = `All local CLIs failed: ${cliErrors}; Perspectives also failed: ${perspectivesError}`;
524
574
  }
525
575
 
526
576
  return combinedResult;