polydev-ai 1.9.29 → 1.9.30

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.
@@ -1658,6 +1658,86 @@ To re-login: /polydev:login`
1658
1658
  };
1659
1659
  }
1660
1660
 
1661
+ /**
1662
+ * Forward a request to the remote Polydev API server
1663
+ */
1664
+ async forwardToRemoteServer(request) {
1665
+ console.error(`[Stdio Wrapper] Forwarding request to remote server`);
1666
+
1667
+ try {
1668
+ const controller = typeof AbortController !== 'undefined' ? new AbortController() : null;
1669
+ const timeoutId = controller ? setTimeout(() => controller.abort(), 400000) : null; // 400s timeout
1670
+
1671
+ const response = await fetch('https://www.polydev.ai/api/mcp', {
1672
+ method: 'POST',
1673
+ headers: {
1674
+ 'Content-Type': 'application/json',
1675
+ 'Authorization': `Bearer ${this.userToken}`,
1676
+ 'User-Agent': 'polydev-stdio-wrapper/1.0.0'
1677
+ },
1678
+ body: JSON.stringify(request),
1679
+ ...(controller ? { signal: controller.signal } : {})
1680
+ });
1681
+
1682
+ if (timeoutId) clearTimeout(timeoutId);
1683
+
1684
+ if (!response.ok) {
1685
+ const errorText = await response.text();
1686
+ console.error(`[Stdio Wrapper] Remote server error: ${response.status} - ${errorText}`);
1687
+
1688
+ if (response.status === 401) {
1689
+ console.error('[Polydev] Remote API returned 401 — token expired or invalid.');
1690
+ return {
1691
+ jsonrpc: '2.0',
1692
+ id: request.id,
1693
+ error: {
1694
+ code: -32603,
1695
+ message: 'Authentication expired. Use the "login" tool to re-authenticate.'
1696
+ }
1697
+ };
1698
+ }
1699
+
1700
+ return {
1701
+ jsonrpc: '2.0',
1702
+ id: request.id,
1703
+ error: {
1704
+ code: -32603,
1705
+ message: `Remote server error: ${response.status} - ${errorText}`
1706
+ }
1707
+ };
1708
+ }
1709
+
1710
+ const result = await response.json();
1711
+ console.error(`[Stdio Wrapper] Got response from remote server`);
1712
+ return result;
1713
+ } catch (error) {
1714
+ console.error(`[Stdio Wrapper] Network error:`, error.message);
1715
+ return {
1716
+ jsonrpc: '2.0',
1717
+ id: request.id,
1718
+ error: {
1719
+ code: -32603,
1720
+ message: `Network error: ${error.message}`
1721
+ }
1722
+ };
1723
+ }
1724
+ }
1725
+
1726
+ /**
1727
+ * Check if a tool is a CLI tool that should be handled locally
1728
+ */
1729
+ isCliTool(toolName) {
1730
+ const cliTools = [
1731
+ 'force_cli_detection',
1732
+ 'get_cli_status',
1733
+ 'send_cli_prompt',
1734
+ 'polydev.force_cli_detection',
1735
+ 'polydev.get_cli_status',
1736
+ 'polydev.send_cli_prompt'
1737
+ ];
1738
+ return cliTools.includes(toolName);
1739
+ }
1740
+
1661
1741
  /**
1662
1742
  * Handle get_perspectives with local CLIs + remote perspectives
1663
1743
  */
@@ -2435,6 +2515,14 @@ To re-login: /polydev:login`
2435
2515
  return this.getModelPreferenceForCli(providerId);
2436
2516
  }
2437
2517
 
2518
+ /**
2519
+ * Get model for a specific CLI provider
2520
+ */
2521
+ async getModelForProvider(providerId) {
2522
+ const preferences = await this.fetchUserModelPreferences();
2523
+ return preferences[providerId] || null;
2524
+ }
2525
+
2438
2526
  /**
2439
2527
  * Call remote perspectives for CLI prompts
2440
2528
  * Only calls remote APIs for providers NOT covered by successful local CLIs
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "polydev-ai",
3
- "version": "1.9.29",
3
+ "version": "1.9.30",
4
4
  "engines": {
5
5
  "node": ">=20.x <=22.x"
6
6
  },