@tronsfey/ucli 0.4.0 → 0.4.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.
@@ -1,4 +1,6 @@
1
1
  #!/usr/bin/env node
2
+ import { createRequire as __createRequire } from "module";
3
+ const require = __createRequire(import.meta.url);
2
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
3
5
  var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
4
6
  get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
@@ -14,4 +16,4 @@ export {
14
16
  __require,
15
17
  __commonJS
16
18
  };
17
- //# sourceMappingURL=chunk-NNFC34A5.js.map
19
+ //# sourceMappingURL=chunk-FJU3QOHW.js.map
@@ -1,8 +1,10 @@
1
1
  #!/usr/bin/env node
2
+ import { createRequire as __createRequire } from "module";
3
+ const require = __createRequire(import.meta.url);
2
4
  import {
3
5
  __commonJS,
4
6
  __require
5
- } from "./chunk-NNFC34A5.js";
7
+ } from "./chunk-FJU3QOHW.js";
6
8
 
7
9
  // ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v3/helpers/util.cjs
8
10
  var require_util = __commonJS({
@@ -36660,10 +36662,12 @@ var require_streamableHttp = __commonJS({
36660
36662
  }
36661
36663
  });
36662
36664
 
36663
- // ../../node_modules/.pnpm/@tronsfey+mcp2cli@1.0.0_zod@4.3.6/node_modules/@tronsfey/mcp2cli/dist/client/index.js
36665
+ // ../../node_modules/.pnpm/@tronsfey+mcp2cli@1.0.1_zod@4.3.6/node_modules/@tronsfey/mcp2cli/dist/client/index.js
36664
36666
  var require_client3 = __commonJS({
36665
- "../../node_modules/.pnpm/@tronsfey+mcp2cli@1.0.0_zod@4.3.6/node_modules/@tronsfey/mcp2cli/dist/client/index.js"(exports) {
36667
+ "../../node_modules/.pnpm/@tronsfey+mcp2cli@1.0.1_zod@4.3.6/node_modules/@tronsfey/mcp2cli/dist/client/index.js"(exports) {
36666
36668
  Object.defineProperty(exports, "__esModule", { value: true });
36669
+ exports.parseCommand = parseCommand;
36670
+ exports.isTransportUnsupported = isTransportUnsupported;
36667
36671
  exports.createMcpClient = createMcpClient;
36668
36672
  var index_js_1 = require_client2();
36669
36673
  var stdio_js_1 = require_stdio2();
@@ -36691,14 +36695,26 @@ var require_client3 = __commonJS({
36691
36695
  }
36692
36696
  if (current)
36693
36697
  parts.push(current);
36698
+ if (inSingle || inDouble) {
36699
+ throw new Error(`Unclosed quote in command: ${cmdString}`);
36700
+ }
36694
36701
  const [command, ...args] = parts;
36695
36702
  return { command, args };
36696
36703
  }
36697
- async function createMcpClient(config, verbose = false) {
36698
- const client = new index_js_1.Client({
36704
+ function makeClient() {
36705
+ return new index_js_1.Client({
36699
36706
  name: "mcp2cli",
36700
36707
  version: "1.0.0"
36701
36708
  });
36709
+ }
36710
+ function isTransportUnsupported(err) {
36711
+ const msg = err instanceof Error ? err.message : String(err);
36712
+ if (/\b401\b|\bunauthorized\b|\b403\b|\bforbidden\b/i.test(msg)) {
36713
+ return false;
36714
+ }
36715
+ return true;
36716
+ }
36717
+ async function createMcpClient(config, verbose = false) {
36702
36718
  if (config.type === "stdio") {
36703
36719
  if (!config.command) {
36704
36720
  throw new Error("stdio config requires a command");
@@ -36708,41 +36724,48 @@ var require_client3 = __commonJS({
36708
36724
  ...Object.fromEntries(Object.entries(process.env).filter(([, v]) => v !== void 0)),
36709
36725
  ...config.env ?? {}
36710
36726
  };
36727
+ const client2 = makeClient();
36711
36728
  const transport = new stdio_js_1.StdioClientTransport({ command, args, env });
36712
- await client.connect(transport);
36729
+ await client2.connect(transport);
36713
36730
  if (verbose) {
36714
36731
  console.error(`[mcp2cli] Connected via stdio: ${config.command}`);
36715
36732
  }
36716
- } else {
36717
- if (!config.url) {
36718
- throw new Error("http config requires a url");
36733
+ return client2;
36734
+ }
36735
+ if (!config.url) {
36736
+ throw new Error("http config requires a url");
36737
+ }
36738
+ const serverUrl = new URL(config.url);
36739
+ const headers = config.headers ?? {};
36740
+ try {
36741
+ const client2 = makeClient();
36742
+ const transport = new streamableHttp_js_1.StreamableHTTPClientTransport(serverUrl, {
36743
+ requestInit: { headers }
36744
+ });
36745
+ await client2.connect(transport);
36746
+ if (verbose) {
36747
+ console.error(`[mcp2cli] Connected via Streamable HTTP: ${config.url}`);
36719
36748
  }
36720
- const serverUrl = new URL(config.url);
36721
- const headers = config.headers ?? {};
36722
- try {
36723
- const transport = new streamableHttp_js_1.StreamableHTTPClientTransport(serverUrl, {
36724
- requestInit: { headers }
36725
- });
36726
- await client.connect(transport);
36727
- if (verbose) {
36728
- console.error(`[mcp2cli] Connected via Streamable HTTP: ${config.url}`);
36729
- }
36730
- } catch {
36731
- if (verbose) {
36732
- console.error(`[mcp2cli] Streamable HTTP failed, falling back to SSE`);
36733
- }
36734
- const sseTransport = new sse_js_1.SSEClientTransport(serverUrl, {
36735
- requestInit: { headers }
36736
- });
36737
- await client.connect(sseTransport);
36738
- if (verbose) {
36739
- console.error(`[mcp2cli] Connected via SSE: ${config.url}`);
36740
- }
36749
+ return client2;
36750
+ } catch (err) {
36751
+ if (!isTransportUnsupported(err)) {
36752
+ throw err;
36753
+ }
36754
+ if (verbose) {
36755
+ console.error(`[mcp2cli] Streamable HTTP not supported, falling back to SSE`);
36741
36756
  }
36742
36757
  }
36758
+ const client = makeClient();
36759
+ const sseTransport = new sse_js_1.SSEClientTransport(serverUrl, {
36760
+ requestInit: { headers }
36761
+ });
36762
+ await client.connect(sseTransport);
36763
+ if (verbose) {
36764
+ console.error(`[mcp2cli] Connected via SSE: ${config.url}`);
36765
+ }
36743
36766
  return client;
36744
36767
  }
36745
36768
  }
36746
36769
  });
36747
36770
  export default require_client3();
36748
- //# sourceMappingURL=client-TA5DDDSP.js.map
36771
+ //# sourceMappingURL=client-3I7XBDJU.js.map