kfc-code-cli 0.1.0-rc.4 → 0.1.0-rc.5

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/dist/main.mjs CHANGED
@@ -1,4 +1,8 @@
1
1
  #!/usr/bin/env node
2
+ import { fileURLToPath as __cjsShimFileURLToPath } from 'node:url';
3
+ import { dirname as __cjsShimDirname } from 'node:path';
4
+ const __filename = __cjsShimFileURLToPath(import.meta.url);
5
+ const __dirname = __cjsShimDirname(__filename);
2
6
  import { createRequire } from "node:module";
3
7
  import { createHash, randomBytes, randomInt, randomUUID } from "node:crypto";
4
8
  import * as nodeOs from "node:os";
@@ -10672,12 +10676,12 @@ var require_gaxios = /* @__PURE__ */ __commonJSMin(((exports) => {
10672
10676
  * @returns A proxy agent
10673
10677
  */
10674
10678
  static async #getProxyAgent() {
10675
- this.#proxyAgent ||= (await import("./dist-BcBH1GX7.mjs").then((m) => /* @__PURE__ */ __toESM(m.default))).HttpsProxyAgent;
10679
+ this.#proxyAgent ||= (await import("./dist-DcHX2r7D.mjs").then((m) => /* @__PURE__ */ __toESM(m.default))).HttpsProxyAgent;
10676
10680
  return this.#proxyAgent;
10677
10681
  }
10678
10682
  static async #getFetch() {
10679
10683
  const hasWindow = typeof window !== "undefined" && !!window;
10680
- this.#fetch ||= hasWindow ? window.fetch : (await import("./src-BHKh5wvn.mjs")).default;
10684
+ this.#fetch ||= hasWindow ? window.fetch : (await import("./src-Cp-kJHqK.mjs")).default;
10681
10685
  return this.#fetch;
10682
10686
  }
10683
10687
  /**
@@ -84553,6 +84557,8 @@ var HttpMcpClient = class {
84553
84557
  toolCallTimeoutMs;
84554
84558
  started = false;
84555
84559
  closed = false;
84560
+ ready = false;
84561
+ hooksInstalled = false;
84556
84562
  unexpectedCloseListener;
84557
84563
  lastTransportError;
84558
84564
  pendingUnexpectedClose;
@@ -84574,6 +84580,7 @@ var HttpMcpClient = class {
84574
84580
  if (this.closed) throw new Error("MCP HTTP client is closed");
84575
84581
  if (this.started) return;
84576
84582
  this.started = true;
84583
+ this.installTransportHooks();
84577
84584
  try {
84578
84585
  await this.client.connect(this.transport);
84579
84586
  } catch (error) {
@@ -84584,7 +84591,7 @@ var HttpMcpClient = class {
84584
84591
  await this.closeStartedClient();
84585
84592
  throw new Error("MCP HTTP client was closed during startup");
84586
84593
  }
84587
- this.installTransportHooks();
84594
+ this.ready = true;
84588
84595
  }
84589
84596
  async close() {
84590
84597
  if (this.closed) return;
@@ -84621,13 +84628,17 @@ var HttpMcpClient = class {
84621
84628
  await this.client.close();
84622
84629
  }
84623
84630
  installTransportHooks() {
84631
+ if (this.hooksInstalled) return;
84632
+ this.hooksInstalled = true;
84624
84633
  this.client.onclose = () => {
84625
84634
  if (this.closed) return;
84635
+ if (!this.ready) return;
84626
84636
  this.fireUnexpectedClose({ error: this.lastTransportError });
84627
84637
  };
84628
84638
  this.client.onerror = (error) => {
84629
84639
  this.lastTransportError = error;
84630
84640
  if (this.closed) return;
84641
+ if (!this.ready) return;
84631
84642
  if (isTerminalTransportError(error)) this.fireUnexpectedClose({ error });
84632
84643
  };
84633
84644
  }
@@ -85265,6 +85276,8 @@ var StdioMcpClient = class {
85265
85276
  stderrBuffer = new BoundedTail(STDERR_BUFFER_CAPACITY);
85266
85277
  started = false;
85267
85278
  closed = false;
85279
+ ready = false;
85280
+ hooksInstalled = false;
85268
85281
  unexpectedCloseListener;
85269
85282
  lastTransportError;
85270
85283
  pendingUnexpectedClose;
@@ -85292,6 +85305,7 @@ var StdioMcpClient = class {
85292
85305
  if (this.closed) throw new Error("MCP stdio client is closed");
85293
85306
  if (this.started) return;
85294
85307
  this.started = true;
85308
+ this.installTransportHooks();
85295
85309
  try {
85296
85310
  await this.client.connect(this.transport);
85297
85311
  } catch (error) {
@@ -85302,7 +85316,7 @@ var StdioMcpClient = class {
85302
85316
  await this.closeStartedClient();
85303
85317
  throw new Error("MCP stdio client was closed during startup");
85304
85318
  }
85305
- this.installTransportHooks();
85319
+ this.ready = true;
85306
85320
  }
85307
85321
  async close() {
85308
85322
  if (this.closed) return;
@@ -85350,8 +85364,11 @@ var StdioMcpClient = class {
85350
85364
  await this.client.close();
85351
85365
  }
85352
85366
  installTransportHooks() {
85367
+ if (this.hooksInstalled) return;
85368
+ this.hooksInstalled = true;
85353
85369
  this.client.onclose = () => {
85354
85370
  if (this.closed) return;
85371
+ if (!this.ready) return;
85355
85372
  const stderr = this.stderrBuffer.snapshot();
85356
85373
  const reason = {
85357
85374
  error: this.lastTransportError,