converse-mcp-server 2.20.6 → 2.20.7

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "converse-mcp-server",
3
- "version": "2.20.6",
3
+ "version": "2.20.7",
4
4
  "description": "Converse MCP Server - Converse with other LLMs with chat and consensus tools",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -12,6 +12,10 @@
12
12
  * - Requires GitHub CLI authenticated (gh auth login) with active Copilot subscription
13
13
  */
14
14
 
15
+ import { createRequire } from 'module';
16
+ import { readFileSync, writeFileSync } from 'fs';
17
+ import { dirname, join } from 'path';
18
+ import { fileURLToPath } from 'url';
15
19
  import { debugLog, debugError } from '../utils/console.js';
16
20
  import { ProviderError, ErrorCodes, StopReasons } from './interface.js';
17
21
 
@@ -290,16 +294,75 @@ function isCopilotSDKAvailable() {
290
294
  return _sdkAvailable;
291
295
  }
292
296
 
297
+ /**
298
+ * Patch vscode-jsonrpc's package.json to add ESM-compatible exports.
299
+ * The @github/copilot-sdk imports "vscode-jsonrpc/node" (extensionless) and
300
+ * "vscode-jsonrpc/node.js" (with extension). Without an exports map, Node.js
301
+ * strict ESM resolution fails on both forms. Adding an exports field once
302
+ * also requires "./node.js" since exports blocks unlisted subpaths.
303
+ * Runs once, skips silently on failure (e.g. read-only node_modules).
304
+ */
305
+ let _jsonrpcPatched = false;
306
+ function ensureVscodeJsonrpcExports() {
307
+ if (_jsonrpcPatched) return;
308
+ _jsonrpcPatched = true;
309
+
310
+ try {
311
+ const sdkUrl = import.meta.resolve('@github/copilot-sdk');
312
+ const sdkDir = dirname(fileURLToPath(sdkUrl));
313
+ const sdkRequire = createRequire(join(sdkDir, '_resolve.js'));
314
+
315
+ let pkgJsonPath;
316
+ try {
317
+ pkgJsonPath = sdkRequire.resolve('vscode-jsonrpc/package.json');
318
+ } catch {
319
+ const mainPath = sdkRequire.resolve('vscode-jsonrpc');
320
+ let dir = dirname(mainPath);
321
+ for (let i = 0; i < 5; i++) {
322
+ const candidate = join(dir, 'package.json');
323
+ try {
324
+ const p = JSON.parse(readFileSync(candidate, 'utf-8'));
325
+ if (p.name === 'vscode-jsonrpc') {
326
+ pkgJsonPath = candidate;
327
+ break;
328
+ }
329
+ } catch { /* continue */ }
330
+ dir = dirname(dir);
331
+ }
332
+ }
333
+
334
+ if (!pkgJsonPath) return;
335
+
336
+ const pkg = JSON.parse(readFileSync(pkgJsonPath, 'utf-8'));
337
+ if (pkg.exports && pkg.exports['./node'] && pkg.exports['./node.js']) {
338
+ return;
339
+ }
340
+
341
+ pkg.exports = {
342
+ '.': pkg.main || './lib/node/main.js',
343
+ './node': './node.js',
344
+ './node.js': './node.js',
345
+ './browser': './browser.js',
346
+ './browser.js': './browser.js',
347
+ };
348
+ writeFileSync(pkgJsonPath, JSON.stringify(pkg, null, '\t') + '\n');
349
+ debugLog('[Copilot SDK] Patched vscode-jsonrpc exports for ESM compatibility');
350
+ } catch (err) {
351
+ debugLog('[Copilot SDK] Could not patch vscode-jsonrpc: %s', err.message);
352
+ }
353
+ }
354
+
293
355
  /**
294
356
  * Dynamically import Copilot SDK (lazy loading)
295
357
  */
296
358
  async function getCopilotSDK() {
359
+ ensureVscodeJsonrpcExports();
297
360
  try {
298
361
  const { CopilotClient } = await import('@github/copilot-sdk');
299
362
  return CopilotClient;
300
363
  } catch (error) {
301
364
  throw new CopilotProviderError(
302
- 'Copilot SDK not available. Ensure @github/copilot-sdk is installed and GitHub CLI is authenticated (gh auth login).',
365
+ `Copilot SDK import failed: ${error.message}`,
303
366
  ErrorCodes.API_ERROR,
304
367
  error,
305
368
  );