@ai-ecoverse/mcpcat 0.27.0 → 0.27.2

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.
@@ -8906,17 +8906,21 @@ async function createPiConnection(options) {
8906
8906
  roots: options.roots
8907
8907
  };
8908
8908
  const client = new McpClient(clientOptions);
8909
- let abortWith = () => {
8910
- };
8911
- const aborted = new Promise((_, reject) => {
8912
- abortWith = reject;
8913
- });
8914
- aborted.catch(() => {
8915
- });
8909
+ const onElicit = options.onElicit;
8910
+ const inFlight = /* @__PURE__ */ new Set();
8911
+ let abortError;
8912
+ function abortWith(err) {
8913
+ abortError ??= { err };
8914
+ for (const reject of inFlight) reject(err);
8915
+ }
8916
8916
  function guard(p) {
8917
- return Promise.race([p, aborted]);
8917
+ if (!onElicit) return p;
8918
+ return new Promise((resolve, reject) => {
8919
+ if (abortError) reject(abortError.err);
8920
+ inFlight.add(reject);
8921
+ p.then(resolve, reject).finally(() => inFlight.delete(reject));
8922
+ });
8918
8923
  }
8919
- const onElicit = options.onElicit;
8920
8924
  if (onElicit) {
8921
8925
  client.setRequestHandler("elicitation/create", async (params) => {
8922
8926
  try {
@@ -8997,7 +9001,9 @@ async function createPiConnection(options) {
8997
9001
  );
8998
9002
  },
8999
9003
  async complete(ref, argument) {
9000
- return client.request("completion/complete", { ref, argument }, reqOpts2());
9004
+ return guard(
9005
+ client.request("completion/complete", { ref, argument }, reqOpts2())
9006
+ );
9001
9007
  },
9002
9008
  async close() {
9003
9009
  await client.close();
@@ -17895,13 +17901,15 @@ async function runComplete(platform2, conn, args2, json) {
17895
17901
  return EXIT_OK;
17896
17902
  }
17897
17903
  const completion = result?.completion;
17898
- for (const v of completion?.values ?? []) {
17899
- await platform2.write(1, sanitizeTerminal(`${v}
17904
+ const values = completion?.values ?? [];
17905
+ for (const v of values) {
17906
+ const line = String(v).replace(/\r/g, "\\r").replace(/\n/g, "\\n");
17907
+ await platform2.write(1, sanitizeTerminal(`${line}
17900
17908
  `));
17901
17909
  }
17902
17910
  if (completion?.hasMore) {
17903
17911
  const total = completion.total !== void 0 ? ` of ${completion.total}` : "";
17904
- await platform2.write(2, `mcpcat: ${completion.values.length}${total} values, more available
17912
+ await platform2.write(2, `mcpcat: ${values.length}${total} values, more available
17905
17913
  `);
17906
17914
  }
17907
17915
  return EXIT_OK;
@@ -19370,5 +19378,5 @@ try {
19370
19378
  });
19371
19379
  } catch {
19372
19380
  }
19373
- var code = await run(platform, "0.27.0", args);
19381
+ var code = await run(platform, "0.27.2", args);
19374
19382
  process.exit(code);
@@ -8527,17 +8527,21 @@ async function createPiConnection(options) {
8527
8527
  roots: options.roots
8528
8528
  };
8529
8529
  const client = new McpClient(clientOptions);
8530
- let abortWith = () => {
8531
- };
8532
- const aborted = new Promise((_, reject) => {
8533
- abortWith = reject;
8534
- });
8535
- aborted.catch(() => {
8536
- });
8530
+ const onElicit = options.onElicit;
8531
+ const inFlight = /* @__PURE__ */ new Set();
8532
+ let abortError;
8533
+ function abortWith(err) {
8534
+ abortError ??= { err };
8535
+ for (const reject of inFlight) reject(err);
8536
+ }
8537
8537
  function guard(p) {
8538
- return Promise.race([p, aborted]);
8538
+ if (!onElicit) return p;
8539
+ return new Promise((resolve2, reject) => {
8540
+ if (abortError) reject(abortError.err);
8541
+ inFlight.add(reject);
8542
+ p.then(resolve2, reject).finally(() => inFlight.delete(reject));
8543
+ });
8539
8544
  }
8540
- const onElicit = options.onElicit;
8541
8545
  if (onElicit) {
8542
8546
  client.setRequestHandler("elicitation/create", async (params) => {
8543
8547
  try {
@@ -8618,7 +8622,9 @@ async function createPiConnection(options) {
8618
8622
  );
8619
8623
  },
8620
8624
  async complete(ref, argument) {
8621
- return client.request("completion/complete", { ref, argument }, reqOpts2());
8625
+ return guard(
8626
+ client.request("completion/complete", { ref, argument }, reqOpts2())
8627
+ );
8622
8628
  },
8623
8629
  async close() {
8624
8630
  await client.close();
@@ -17412,13 +17418,15 @@ async function runComplete(platform2, conn, args, json) {
17412
17418
  return EXIT_OK;
17413
17419
  }
17414
17420
  const completion = result?.completion;
17415
- for (const v of completion?.values ?? []) {
17416
- await platform2.write(1, sanitizeTerminal(`${v}
17421
+ const values = completion?.values ?? [];
17422
+ for (const v of values) {
17423
+ const line = String(v).replace(/\r/g, "\\r").replace(/\n/g, "\\n");
17424
+ await platform2.write(1, sanitizeTerminal(`${line}
17417
17425
  `));
17418
17426
  }
17419
17427
  if (completion?.hasMore) {
17420
17428
  const total = completion.total !== void 0 ? ` of ${completion.total}` : "";
17421
- await platform2.write(2, `mcpcat: ${completion.values.length}${total} values, more available
17429
+ await platform2.write(2, `mcpcat: ${values.length}${total} values, more available
17422
17430
  `);
17423
17431
  }
17424
17432
  return EXIT_OK;
@@ -18597,7 +18605,7 @@ async function main(ctx) {
18597
18605
  packageDir: "/node_modules/@ai-ecoverse/mcpcat"
18598
18606
  });
18599
18607
  const args = ctx.argv.slice(1);
18600
- return run(platform2, "0.27.0", args);
18608
+ return run(platform2, "0.27.2", args);
18601
18609
  }
18602
18610
  export {
18603
18611
  main as default
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-ecoverse/mcpcat",
3
- "version": "0.27.0",
3
+ "version": "0.27.2",
4
4
  "description": "A curl for the Model Context Protocol",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",