@mcpc-tech/cli 0.1.52 → 0.1.54

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/app.cjs CHANGED
@@ -551,10 +551,9 @@ var ProgressTokenSchema = z.union([z.string(), z.number().int()]);
551
551
  var CursorSchema = z.string();
552
552
  var TaskCreationParamsSchema = z.looseObject({
553
553
  /**
554
- * Time in milliseconds to keep task results available after completion.
555
- * If null, the task has unlimited lifetime until manually cleaned up.
554
+ * Requested duration in milliseconds to retain task from creation.
556
555
  */
557
- ttl: z.union([z.number(), z.null()]).optional(),
556
+ ttl: z.number().optional(),
558
557
  /**
559
558
  * Time in milliseconds to wait between task status requests.
560
559
  */
@@ -854,7 +853,11 @@ var ClientCapabilitiesSchema = z.object({
854
853
  /**
855
854
  * Present if the client supports task creation.
856
855
  */
857
- tasks: ClientTasksCapabilitySchema.optional()
856
+ tasks: ClientTasksCapabilitySchema.optional(),
857
+ /**
858
+ * Extensions that the client supports. Keys are extension identifiers (vendor-prefix/extension-name).
859
+ */
860
+ extensions: z.record(z.string(), AssertObjectSchema).optional()
858
861
  });
859
862
  var InitializeRequestParamsSchema = BaseRequestParamsSchema.extend({
860
863
  /**
@@ -916,7 +919,11 @@ var ServerCapabilitiesSchema = z.object({
916
919
  /**
917
920
  * Present if the server supports task creation.
918
921
  */
919
- tasks: ServerTasksCapabilitySchema.optional()
922
+ tasks: ServerTasksCapabilitySchema.optional(),
923
+ /**
924
+ * Extensions that the server supports. Keys are extension identifiers (vendor-prefix/extension-name).
925
+ */
926
+ extensions: z.record(z.string(), AssertObjectSchema).optional()
920
927
  });
921
928
  var InitializeResultSchema = ResultSchema.extend({
922
929
  /**
@@ -1109,6 +1116,12 @@ var ResourceSchema = z.object({
1109
1116
  * The MIME type of this resource, if known.
1110
1117
  */
1111
1118
  mimeType: z.optional(z.string()),
1119
+ /**
1120
+ * The size of the raw resource content, in bytes (i.e., before base64 encoding or any tokenization), if known.
1121
+ *
1122
+ * This can be used by Hosts to display file sizes and estimate context window usage.
1123
+ */
1124
+ size: z.optional(z.number()),
1112
1125
  /**
1113
1126
  * Optional annotations for the client.
1114
1127
  */
@@ -2673,6 +2686,10 @@ var Protocol = class {
2673
2686
  this._progressHandlers.clear();
2674
2687
  this._taskProgressTokens.clear();
2675
2688
  this._pendingDebouncedNotifications.clear();
2689
+ for (const info of this._timeoutInfo.values()) {
2690
+ clearTimeout(info.timeoutId);
2691
+ }
2692
+ this._timeoutInfo.clear();
2676
2693
  for (const controller of this._requestHandlerAbortControllers.values()) {
2677
2694
  controller.abort();
2678
2695
  }
@@ -2803,7 +2820,9 @@ var Protocol = class {
2803
2820
  await capturedTransport?.send(errorResponse);
2804
2821
  }
2805
2822
  }).catch((error) => this._onerror(new Error(`Failed to send response: ${error}`))).finally(() => {
2806
- this._requestHandlerAbortControllers.delete(request.id);
2823
+ if (this._requestHandlerAbortControllers.get(request.id) === abortController) {
2824
+ this._requestHandlerAbortControllers.delete(request.id);
2825
+ }
2807
2826
  });
2808
2827
  }
2809
2828
  _onprogress(notification) {
@@ -4927,7 +4946,7 @@ var StdioClientTransport = class {
4927
4946
  },
4928
4947
  stdio: ["pipe", "pipe", this._serverParams.stderr ?? "inherit"],
4929
4948
  shell: false,
4930
- windowsHide: import_node_process.default.platform === "win32" && isElectron(),
4949
+ windowsHide: import_node_process.default.platform === "win32",
4931
4950
  cwd: this._serverParams.cwd
4932
4951
  });
4933
4952
  this._process.on("error", (error) => {
@@ -5034,9 +5053,6 @@ var StdioClientTransport = class {
5034
5053
  });
5035
5054
  }
5036
5055
  };
5037
- function isElectron() {
5038
- return "type" in import_node_process.default;
5039
- }
5040
5056
 
5041
5057
  // __mcpc__cli_latest/node_modules/eventsource-parser/dist/index.js
5042
5058
  var ParseError = class extends Error {
@@ -5781,12 +5797,12 @@ var AUTHORIZATION_CODE_RESPONSE_TYPE = "code";
5781
5797
  var AUTHORIZATION_CODE_CHALLENGE_METHOD = "S256";
5782
5798
  function selectClientAuthMethod(clientInformation, supportedMethods) {
5783
5799
  const hasClientSecret = clientInformation.client_secret !== void 0;
5784
- if (supportedMethods.length === 0) {
5785
- return hasClientSecret ? "client_secret_post" : "none";
5786
- }
5787
- if ("token_endpoint_auth_method" in clientInformation && clientInformation.token_endpoint_auth_method && isClientAuthMethod(clientInformation.token_endpoint_auth_method) && supportedMethods.includes(clientInformation.token_endpoint_auth_method)) {
5800
+ if ("token_endpoint_auth_method" in clientInformation && clientInformation.token_endpoint_auth_method && isClientAuthMethod(clientInformation.token_endpoint_auth_method) && (supportedMethods.length === 0 || supportedMethods.includes(clientInformation.token_endpoint_auth_method))) {
5788
5801
  return clientInformation.token_endpoint_auth_method;
5789
5802
  }
5803
+ if (supportedMethods.length === 0) {
5804
+ return hasClientSecret ? "client_secret_basic" : "none";
5805
+ }
5790
5806
  if (hasClientSecret && supportedMethods.includes("client_secret_basic")) {
5791
5807
  return "client_secret_basic";
5792
5808
  }
@@ -5897,6 +5913,7 @@ async function authInternal(provider, { serverUrl, authorizationCode, scope, res
5897
5913
  });
5898
5914
  }
5899
5915
  const resource = await selectResourceURL(serverUrl, provider, resourceMetadata);
5916
+ const resolvedScope = scope || resourceMetadata?.scopes_supported?.join(" ") || provider.clientMetadata.scope;
5900
5917
  let clientInformation = await Promise.resolve(provider.clientInformation());
5901
5918
  if (!clientInformation) {
5902
5919
  if (authorizationCode !== void 0) {
@@ -5920,6 +5937,7 @@ async function authInternal(provider, { serverUrl, authorizationCode, scope, res
5920
5937
  const fullInformation = await registerClient(authorizationServerUrl, {
5921
5938
  metadata,
5922
5939
  clientMetadata: provider.clientMetadata,
5940
+ scope: resolvedScope,
5923
5941
  fetchFn
5924
5942
  });
5925
5943
  await provider.saveClientInformation(fullInformation);
@@ -5963,7 +5981,7 @@ async function authInternal(provider, { serverUrl, authorizationCode, scope, res
5963
5981
  clientInformation,
5964
5982
  state,
5965
5983
  redirectUrl: provider.redirectUrl,
5966
- scope: scope || resourceMetadata?.scopes_supported?.join(" ") || provider.clientMetadata.scope,
5984
+ scope: resolvedScope,
5967
5985
  resource
5968
5986
  });
5969
5987
  await provider.saveCodeVerifier(codeVerifier);
@@ -6281,7 +6299,7 @@ async function fetchToken(provider, authorizationServerUrl, { metadata, resource
6281
6299
  fetchFn
6282
6300
  });
6283
6301
  }
6284
- async function registerClient(authorizationServerUrl, { metadata, clientMetadata, fetchFn }) {
6302
+ async function registerClient(authorizationServerUrl, { metadata, clientMetadata, scope, fetchFn }) {
6285
6303
  let registrationUrl;
6286
6304
  if (metadata) {
6287
6305
  if (!metadata.registration_endpoint) {
@@ -6296,7 +6314,10 @@ async function registerClient(authorizationServerUrl, { metadata, clientMetadata
6296
6314
  headers: {
6297
6315
  "Content-Type": "application/json"
6298
6316
  },
6299
- body: JSON.stringify(clientMetadata)
6317
+ body: JSON.stringify({
6318
+ ...clientMetadata,
6319
+ ...scope !== void 0 ? { scope } : {}
6320
+ })
6300
6321
  });
6301
6322
  if (!response.ok) {
6302
6323
  throw await parseErrorResponse(response);
@@ -7391,7 +7412,7 @@ var SystemPrompts = {
7391
7412
  </rules>
7392
7413
 
7393
7414
  <format>
7394
- Get tool schemas: \`{ "tool": "man", "args": { "tools": ["tool1", "tool2"] } }\`
7415
+ Get tool definitions: \`{ "tool": "man", "args": { "tools": ["tool1", "tool2"] } }\`
7395
7416
  Execute a tool: \`{ "tool": "tool_name", "args": { /* parameters */ } }\`
7396
7417
  </format>`,
7397
7418
  /**
@@ -7516,7 +7537,7 @@ function createArgsDefFactory(_name, _allToolNames, _depGroups, _predefinedSteps
7516
7537
  *
7517
7538
  * Only two fields:
7518
7539
  * - `tool`: which tool to execute (enum includes "man" + all tool names)
7519
- * - `args`: object with parameters. For "man": { tools: ["a", "b"] }. For others: tool parameters.
7540
+ * - `args`: object with parameters. For "man": { tools: ["a", "b"] } to fetch tool definitions (including input/output schemas). For others: tool parameters.
7520
7541
  */
7521
7542
  forAgentic: function(allToolNames) {
7522
7543
  const toolEnum = [
@@ -9468,11 +9489,12 @@ var ToolManager = class {
9468
9489
  /**
9469
9490
  * Register a tool in the registry
9470
9491
  */
9471
- registerTool(name, description, schema, callback, options = {}) {
9492
+ registerTool(name, description, inputSchema, callback, options = {}) {
9472
9493
  this.toolRegistry.set(name, {
9473
9494
  callback,
9474
9495
  description,
9475
- schema
9496
+ inputSchema,
9497
+ outputSchema: options.outputSchema
9476
9498
  });
9477
9499
  if (options.hidden) {
9478
9500
  this.toolConfigs.set(name, {
@@ -9485,13 +9507,16 @@ var ToolManager = class {
9485
9507
  /**
9486
9508
  * Explicitly mark a tool as public (exposed to MCP clients)
9487
9509
  */
9488
- addPublicTool(name, description, schema) {
9510
+ addPublicTool(name, description, inputSchema, outputSchema) {
9489
9511
  const existingTool = this.publicTools.find((t) => t.name === name);
9490
9512
  if (!existingTool) {
9491
9513
  this.publicTools.push({
9492
9514
  name,
9493
9515
  description,
9494
- inputSchema: schema
9516
+ inputSchema,
9517
+ ...outputSchema ? {
9518
+ outputSchema
9519
+ } : {}
9495
9520
  });
9496
9521
  }
9497
9522
  this.toolConfigs.set(name, {
@@ -9617,10 +9642,13 @@ var ToolManager = class {
9617
9642
  getHiddenToolSchema(name) {
9618
9643
  const tool2 = this.toolRegistry.get(name);
9619
9644
  const config = this.toolConfigs.get(name);
9620
- if (tool2 && config?.visibility?.hidden && tool2.schema) {
9645
+ if (tool2 && config?.visibility?.hidden && tool2.inputSchema) {
9621
9646
  return {
9622
9647
  description: tool2.description,
9623
- schema: tool2.schema
9648
+ inputSchema: tool2.inputSchema,
9649
+ ...tool2.outputSchema ? {
9650
+ outputSchema: tool2.outputSchema
9651
+ } : {}
9624
9652
  };
9625
9653
  }
9626
9654
  return void 0;
@@ -9656,10 +9684,13 @@ var ToolManager = class {
9656
9684
  composedTools[name] = {
9657
9685
  name,
9658
9686
  description: tool2.description,
9659
- inputSchema: jsonSchema(tool2.schema || {
9687
+ inputSchema: jsonSchema(tool2.inputSchema || {
9660
9688
  type: "object",
9661
9689
  properties: {}
9662
9690
  }),
9691
+ ...tool2.outputSchema ? {
9692
+ outputSchema: jsonSchema(tool2.outputSchema)
9693
+ } : {},
9663
9694
  execute: tool2.callback
9664
9695
  };
9665
9696
  }
@@ -9676,10 +9707,13 @@ var ToolManager = class {
9676
9707
  return {
9677
9708
  name,
9678
9709
  description: tool2.description,
9679
- inputSchema: tool2.schema ?? {
9710
+ inputSchema: tool2.inputSchema ?? {
9680
9711
  type: "object",
9681
9712
  properties: {}
9682
9713
  },
9714
+ ...tool2.outputSchema ? {
9715
+ outputSchema: tool2.outputSchema
9716
+ } : {},
9683
9717
  execute: tool2.callback
9684
9718
  };
9685
9719
  }
@@ -9693,10 +9727,13 @@ var ToolManager = class {
9693
9727
  composedTools.push({
9694
9728
  name,
9695
9729
  description: tool2.description,
9696
- inputSchema: tool2.schema ?? {
9730
+ inputSchema: tool2.inputSchema ?? {
9697
9731
  type: "object",
9698
9732
  properties: {}
9699
9733
  },
9734
+ ...tool2.outputSchema ? {
9735
+ outputSchema: tool2.outputSchema
9736
+ } : {},
9700
9737
  execute: tool2.callback
9701
9738
  });
9702
9739
  }
@@ -9749,7 +9786,10 @@ async function processToolsWithPlugins(server, _externalTools, mode) {
9749
9786
  const tempTool = {
9750
9787
  name: toolId,
9751
9788
  description: toolData.description,
9752
- inputSchema: toolData.schema || defaultSchema,
9789
+ inputSchema: toolData.inputSchema || defaultSchema,
9790
+ ...toolData.outputSchema ? {
9791
+ outputSchema: toolData.outputSchema
9792
+ } : {},
9753
9793
  execute: toolData.callback
9754
9794
  };
9755
9795
  const processedTool = await pluginManager.applyTransformToolHooks(tempTool, {
@@ -9761,7 +9801,9 @@ async function processToolsWithPlugins(server, _externalTools, mode) {
9761
9801
  },
9762
9802
  transformationIndex: 0
9763
9803
  });
9764
- toolManager.registerTool(toolId, processedTool.description || toolData.description, processedTool.inputSchema, processedTool.execute);
9804
+ toolManager.registerTool(toolId, processedTool.description || toolData.description, processedTool.inputSchema, processedTool.execute, {
9805
+ outputSchema: processedTool.outputSchema
9806
+ });
9765
9807
  }
9766
9808
  }
9767
9809
  function buildDependencyGroups(toolNameToDetailList, hiddenToolNames, publicToolNames, server) {
@@ -9807,6 +9849,7 @@ var ComposableMCPServer = class extends Server {
9807
9849
  toolManager;
9808
9850
  logger = createLogger("mcpc.compose");
9809
9851
  fileLoaders = /* @__PURE__ */ new Map();
9852
+ pluginsDisposed = false;
9810
9853
  // Legacy property for backward compatibility
9811
9854
  get toolNameMapping() {
9812
9855
  return this.toolManager.getToolNameMapping();
@@ -9935,9 +9978,13 @@ var ComposableMCPServer = class extends Server {
9935
9978
  }
9936
9979
  tool(name, description, paramsSchema, cb, options = {}) {
9937
9980
  const jsonSchemaObj = extractJsonSchema(paramsSchema);
9938
- this.toolManager.registerTool(name, description, jsonSchemaObj, cb, options);
9981
+ const outputSchemaObj = options.outputSchema ? extractJsonSchema(options.outputSchema) : void 0;
9982
+ this.toolManager.registerTool(name, description, jsonSchemaObj, cb, {
9983
+ ...options,
9984
+ outputSchema: outputSchemaObj
9985
+ });
9939
9986
  if (!options.internal) {
9940
- this.toolManager.addPublicTool(name, description, jsonSchemaObj);
9987
+ this.toolManager.addPublicTool(name, description, jsonSchemaObj, outputSchemaObj);
9941
9988
  }
9942
9989
  if (options.plugins) {
9943
9990
  for (const plugin of options.plugins) {
@@ -10194,9 +10241,12 @@ var ComposableMCPServer = class extends Server {
10194
10241
  return {
10195
10242
  name,
10196
10243
  description: tool2?.description || "",
10197
- inputSchema: tool2?.schema || {
10244
+ inputSchema: tool2?.inputSchema || {
10198
10245
  type: "object"
10199
- }
10246
+ },
10247
+ ...tool2?.outputSchema ? {
10248
+ outputSchema: tool2.outputSchema
10249
+ } : {}
10200
10250
  };
10201
10251
  });
10202
10252
  }
@@ -10221,9 +10271,12 @@ var ComposableMCPServer = class extends Server {
10221
10271
  return Array.from(registry.entries()).map(([name, tool2]) => ({
10222
10272
  name,
10223
10273
  description: tool2?.description || "",
10224
- inputSchema: tool2?.schema || {
10274
+ inputSchema: tool2?.inputSchema || {
10225
10275
  type: "object"
10226
- }
10276
+ },
10277
+ ...tool2?.outputSchema ? {
10278
+ outputSchema: tool2.outputSchema
10279
+ } : {}
10227
10280
  }));
10228
10281
  }
10229
10282
  /**
@@ -10282,11 +10335,21 @@ var ComposableMCPServer = class extends Server {
10282
10335
  async disposePlugins() {
10283
10336
  await this.pluginManager.dispose();
10284
10337
  }
10338
+ /**
10339
+ * Dispose plugins only once to avoid duplicated cleanup in chained handlers.
10340
+ */
10341
+ async disposePluginsOnce() {
10342
+ if (this.pluginsDisposed) {
10343
+ return;
10344
+ }
10345
+ this.pluginsDisposed = true;
10346
+ await this.disposePlugins();
10347
+ }
10285
10348
  /**
10286
10349
  * Close the server and ensure all plugins are disposed
10287
10350
  */
10288
10351
  async close() {
10289
- await this.disposePlugins();
10352
+ await this.disposePluginsOnce();
10290
10353
  await super.close();
10291
10354
  }
10292
10355
  async compose(name, description, depsConfig = {
@@ -10355,7 +10418,9 @@ var ComposableMCPServer = class extends Server {
10355
10418
  });
10356
10419
  });
10357
10420
  Object.entries(tools).forEach(([toolId, tool2]) => {
10358
- this.toolManager.registerTool(toolId, tool2.description || "", tool2.inputSchema, tool2.execute);
10421
+ this.toolManager.registerTool(toolId, tool2.description || "", tool2.inputSchema, tool2.execute, {
10422
+ outputSchema: tool2.outputSchema
10423
+ });
10359
10424
  });
10360
10425
  const registeredTools = this.toolManager.getRegisteredToolsAsComposed();
10361
10426
  const allTools = {
@@ -10391,16 +10456,20 @@ var ComposableMCPServer = class extends Server {
10391
10456
  server: this,
10392
10457
  toolNames: Object.keys(allTools)
10393
10458
  });
10459
+ const previousOnClose = this.onclose;
10394
10460
  this.onclose = async () => {
10395
10461
  await cleanupClients();
10396
- await this.disposePlugins();
10462
+ await this.disposePluginsOnce();
10397
10463
  await this.logger.info(`[${name}] Event: closed - cleaned up dependent clients and plugins`);
10464
+ previousOnClose?.();
10398
10465
  };
10466
+ const previousOnError = this.onerror;
10399
10467
  this.onerror = async (error) => {
10400
10468
  await this.logger.error(`[${name}] Event: error - ${error?.stack ?? String(error)}`);
10401
10469
  await cleanupClients();
10402
- await this.disposePlugins();
10470
+ await this.disposePluginsOnce();
10403
10471
  await this.logger.info(`[${name}] Action: cleaned up dependent clients and plugins`);
10472
+ previousOnError?.(error);
10404
10473
  };
10405
10474
  const toolNameToDetailList = Object.entries(allTools);
10406
10475
  const publicToolNames = this.getPublicToolNames();
@@ -10412,7 +10481,8 @@ var ComposableMCPServer = class extends Server {
10412
10481
  return;
10413
10482
  }
10414
10483
  this.tool(toolId, tool2.description || "", jsonSchema(tool2.inputSchema), tool2.execute, {
10415
- internal: false
10484
+ internal: false,
10485
+ outputSchema: tool2.outputSchema
10416
10486
  });
10417
10487
  });
10418
10488
  await this.pluginManager.triggerComposeEnd({
@@ -13596,15 +13666,17 @@ var Response2 = class _Response {
13596
13666
  this.#init = init;
13597
13667
  }
13598
13668
  if (typeof body === "string" || typeof body?.getReader !== "undefined" || body instanceof Blob || body instanceof Uint8Array) {
13599
- headers ||= init?.headers || { "content-type": "text/plain; charset=UTF-8" };
13600
- this[cacheKey] = [init?.status || 200, body, headers];
13669
+ ;
13670
+ this[cacheKey] = [init?.status || 200, body, headers || init?.headers];
13601
13671
  }
13602
13672
  }
13603
13673
  get headers() {
13604
13674
  const cache = this[cacheKey];
13605
13675
  if (cache) {
13606
13676
  if (!(cache[2] instanceof Headers)) {
13607
- cache[2] = new Headers(cache[2]);
13677
+ cache[2] = new Headers(
13678
+ cache[2] || { "content-type": "text/plain; charset=UTF-8" }
13679
+ );
13608
13680
  }
13609
13681
  return cache[2];
13610
13682
  }
@@ -13703,6 +13775,50 @@ if (typeof global.crypto === "undefined") {
13703
13775
  global.crypto = import_crypto.default;
13704
13776
  }
13705
13777
  var outgoingEnded = Symbol("outgoingEnded");
13778
+ var incomingDraining = Symbol("incomingDraining");
13779
+ var DRAIN_TIMEOUT_MS = 500;
13780
+ var MAX_DRAIN_BYTES = 64 * 1024 * 1024;
13781
+ var drainIncoming = (incoming) => {
13782
+ const incomingWithDrainState = incoming;
13783
+ if (incoming.destroyed || incomingWithDrainState[incomingDraining]) {
13784
+ return;
13785
+ }
13786
+ incomingWithDrainState[incomingDraining] = true;
13787
+ if (incoming instanceof import_http2.Http2ServerRequest) {
13788
+ try {
13789
+ ;
13790
+ incoming.stream?.close?.(import_http2.constants.NGHTTP2_NO_ERROR);
13791
+ } catch {
13792
+ }
13793
+ return;
13794
+ }
13795
+ let bytesRead = 0;
13796
+ const cleanup = () => {
13797
+ clearTimeout(timer);
13798
+ incoming.off("data", onData);
13799
+ incoming.off("end", cleanup);
13800
+ incoming.off("error", cleanup);
13801
+ };
13802
+ const forceClose = () => {
13803
+ cleanup();
13804
+ const socket = incoming.socket;
13805
+ if (socket && !socket.destroyed) {
13806
+ socket.destroySoon();
13807
+ }
13808
+ };
13809
+ const timer = setTimeout(forceClose, DRAIN_TIMEOUT_MS);
13810
+ timer.unref?.();
13811
+ const onData = (chunk) => {
13812
+ bytesRead += chunk.length;
13813
+ if (bytesRead > MAX_DRAIN_BYTES) {
13814
+ forceClose();
13815
+ }
13816
+ };
13817
+ incoming.on("data", onData);
13818
+ incoming.on("end", cleanup);
13819
+ incoming.on("error", cleanup);
13820
+ incoming.resume();
13821
+ };
13706
13822
  var handleRequestError = () => new Response(null, {
13707
13823
  status: 400
13708
13824
  });
@@ -13729,15 +13845,32 @@ var flushHeaders = (outgoing) => {
13729
13845
  };
13730
13846
  var responseViaCache = async (res, outgoing) => {
13731
13847
  let [status, body, header] = res[cacheKey];
13732
- if (header instanceof Headers) {
13848
+ let hasContentLength = false;
13849
+ if (!header) {
13850
+ header = { "content-type": "text/plain; charset=UTF-8" };
13851
+ } else if (header instanceof Headers) {
13852
+ hasContentLength = header.has("content-length");
13733
13853
  header = buildOutgoingHttpHeaders(header);
13854
+ } else if (Array.isArray(header)) {
13855
+ const headerObj = new Headers(header);
13856
+ hasContentLength = headerObj.has("content-length");
13857
+ header = buildOutgoingHttpHeaders(headerObj);
13858
+ } else {
13859
+ for (const key in header) {
13860
+ if (key.length === 14 && key.toLowerCase() === "content-length") {
13861
+ hasContentLength = true;
13862
+ break;
13863
+ }
13864
+ }
13734
13865
  }
13735
- if (typeof body === "string") {
13736
- header["Content-Length"] = Buffer.byteLength(body);
13737
- } else if (body instanceof Uint8Array) {
13738
- header["Content-Length"] = body.byteLength;
13739
- } else if (body instanceof Blob) {
13740
- header["Content-Length"] = body.size;
13866
+ if (!hasContentLength) {
13867
+ if (typeof body === "string") {
13868
+ header["Content-Length"] = Buffer.byteLength(body);
13869
+ } else if (body instanceof Uint8Array) {
13870
+ header["Content-Length"] = body.byteLength;
13871
+ } else if (body instanceof Blob) {
13872
+ header["Content-Length"] = body.size;
13873
+ }
13741
13874
  }
13742
13875
  outgoing.writeHead(status, header);
13743
13876
  if (typeof body === "string" || body instanceof Uint8Array) {
@@ -13857,14 +13990,18 @@ var getRequestListener = (fetchCallback, options = {}) => {
13857
13990
  setTimeout(() => {
13858
13991
  if (!incomingEnded) {
13859
13992
  setTimeout(() => {
13860
- incoming.destroy();
13861
- outgoing.destroy();
13993
+ drainIncoming(incoming);
13862
13994
  });
13863
13995
  }
13864
13996
  });
13865
13997
  }
13866
13998
  };
13867
13999
  }
14000
+ outgoing.on("finish", () => {
14001
+ if (!incomingEnded) {
14002
+ drainIncoming(incoming);
14003
+ }
14004
+ });
13868
14005
  }
13869
14006
  outgoing.on("close", () => {
13870
14007
  const abortController = req[abortControllerKey];
@@ -13879,7 +14016,7 @@ var getRequestListener = (fetchCallback, options = {}) => {
13879
14016
  setTimeout(() => {
13880
14017
  if (!incomingEnded) {
13881
14018
  setTimeout(() => {
13882
- incoming.destroy();
14019
+ drainIncoming(incoming);
13883
14020
  });
13884
14021
  }
13885
14022
  });
@@ -14891,7 +15028,7 @@ var import_promises4 = require("node:fs/promises");
14891
15028
  var import_node_os3 = require("node:os");
14892
15029
  var import_node_path6 = require("node:path");
14893
15030
  var import_node_process10 = __toESM(require("node:process"), 1);
14894
- var CLI_VERSION = "0.1.52";
15031
+ var CLI_VERSION = "0.1.54";
14895
15032
  function extractServerName(command, commandArgs) {
14896
15033
  for (const arg of commandArgs) {
14897
15034
  if (!arg.startsWith("-")) {
@@ -15314,7 +15451,7 @@ function applyModeOverride(config, mode) {
15314
15451
  agent.options.mode = mode;
15315
15452
  if (mode === "ai_acp" && !agent.options.acpSettings) {
15316
15453
  agent.options.acpSettings = {
15317
- command: "claude-code-acp",
15454
+ command: "claude-agent-acp",
15318
15455
  args: [],
15319
15456
  session: {}
15320
15457
  };