converse-mcp-server 2.20.7 → 2.20.9

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.7",
3
+ "version": "2.20.9",
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,10 +12,7 @@
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
+ import { register } from 'node:module';
19
16
  import { debugLog, debugError } from '../utils/console.js';
20
17
  import { ProviderError, ErrorCodes, StopReasons } from './interface.js';
21
18
 
@@ -295,68 +292,27 @@ function isCopilotSDKAvailable() {
295
292
  }
296
293
 
297
294
  /**
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).
295
+ * Register a module resolution hook to fix the extensionless
296
+ * "vscode-jsonrpc/node" import in @github/copilot-sdk >=0.1.29.
297
+ * The SDK's session.js imports "vscode-jsonrpc/node" without a .js extension,
298
+ * which fails under Node.js strict ESM resolution. The hook rewrites it to
299
+ * "vscode-jsonrpc/node.js". Runs once, works regardless of package manager.
304
300
  */
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
- }
301
+ let _hookRegistered = false;
302
+ function ensureJsonrpcResolveHook() {
303
+ if (_hookRegistered) return;
304
+ _hookRegistered = true;
305
+ register(`data:text/javascript,${encodeURIComponent(
306
+ 'export function resolve(s,c,n){' +
307
+ 'return s==="vscode-jsonrpc/node"?n("vscode-jsonrpc/node.js",c):n(s,c);}',
308
+ )}`);
353
309
  }
354
310
 
355
311
  /**
356
312
  * Dynamically import Copilot SDK (lazy loading)
357
313
  */
358
314
  async function getCopilotSDK() {
359
- ensureVscodeJsonrpcExports();
315
+ ensureJsonrpcResolveHook();
360
316
  try {
361
317
  const { CopilotClient } = await import('@github/copilot-sdk');
362
318
  return CopilotClient;
@@ -717,10 +673,12 @@ async function* createStreamingGenerator(client, prompt, options, signal, config
717
673
  let done = false;
718
674
  let streamError = null;
719
675
  let usageData = null;
676
+ let receivedDeltas = false;
720
677
 
721
678
  const unsubscribe = session.on((event) => {
722
679
  switch (event.type) {
723
680
  case 'assistant.message_delta':
681
+ receivedDeltas = true;
724
682
  eventQueue.push({
725
683
  type: 'delta',
726
684
  data: { textDelta: event.data.deltaContent },
@@ -728,8 +686,8 @@ async function* createStreamingGenerator(client, prompt, options, signal, config
728
686
  break;
729
687
 
730
688
  case 'assistant.message':
731
- // Final complete message — use as fallback if deltas were coalesced
732
- if (event.data.content) {
689
+ // Final complete message — only use if no streaming deltas were received
690
+ if (!receivedDeltas && event.data.content) {
733
691
  eventQueue.push({
734
692
  type: 'delta',
735
693
  data: { textDelta: event.data.content },