mycomesh-consumer 0.1.40 → 0.1.41

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": "mycomesh-consumer",
3
- "version": "0.1.40",
3
+ "version": "0.1.41",
4
4
  "description": "Native Node.js MycoMesh Consumer and OpenAI-compatible request CLI.",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -84,6 +84,7 @@ const RESPONSES_REQUEST_OPTION_FIELDS = new Set([
84
84
  const RESPONSES_LOCAL_OPTION_FIELDS = new Set(["stream", "stream_options"]);
85
85
  const MAX_SHARE_MINUTES = 24 * 60;
86
86
  const TUNNEL_START_TIMEOUT_MS = 30_000;
87
+ const TUNNEL_STOP_TIMEOUT_MS = 2_000;
87
88
 
88
89
  const DEFAULT_NETWORK = Object.freeze({
89
90
  chain_id: DEFAULT_CHAIN_ID,
@@ -828,7 +829,7 @@ export class NativeConsumerState {
828
829
  this.share = null;
829
830
  if (!share) return { active: false };
830
831
  if (share.timer) clearTimeout(share.timer);
831
- if (share.process && share.process.exitCode === null) share.process.kill("SIGTERM");
832
+ await stopTunnelProcess(share.process);
832
833
  await share.runtime?.close();
833
834
  return { active: false };
834
835
  }
@@ -1082,6 +1083,23 @@ function waitForTunnelUrl(child) {
1082
1083
  });
1083
1084
  }
1084
1085
 
1086
+ async function stopTunnelProcess(child) {
1087
+ if (!child || child.exitCode !== null) return;
1088
+ await new Promise((resolve) => {
1089
+ let settled = false;
1090
+ const finish = () => {
1091
+ if (settled) return;
1092
+ settled = true;
1093
+ clearTimeout(timer);
1094
+ child.removeListener("exit", finish);
1095
+ resolve();
1096
+ };
1097
+ const timer = setTimeout(finish, TUNNEL_STOP_TIMEOUT_MS);
1098
+ child.once("exit", finish);
1099
+ try { child.kill("SIGTERM"); } catch { finish(); }
1100
+ });
1101
+ }
1102
+
1085
1103
  async function handleInference(state, request, response, path, alphaSearchQuery, shareOnly = false) {
1086
1104
  const authorization = String(request.headers.authorization || "");
1087
1105
  if (!state.authorizeBearer(authorization, { shareOnly })) {
package/src/consumer.mjs CHANGED
@@ -11,7 +11,7 @@ import {
11
11
  createConsumerServer,
12
12
  } from "./consumer-runtime.mjs";
13
13
 
14
- export const CONSUMER_RELEASE_VERSION = "0.1.40";
14
+ export const CONSUMER_RELEASE_VERSION = "0.1.41";
15
15
  export const API_COMMANDS = new Set(["health", "models", "responses", "chat"]);
16
16
  const API_VALUE_OPTIONS = new Set([
17
17
  "--base-url",