mycomesh-consumer 0.1.38 → 0.1.40

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.38",
3
+ "version": "0.1.40",
4
4
  "description": "Native Node.js MycoMesh Consumer and OpenAI-compatible request CLI.",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -361,10 +361,9 @@ function normalizeInferenceOptions(endpoint, options) {
361
361
  Object.entries(options).filter(([key]) => !RESPONSES_LOCAL_OPTION_FIELDS.has(key)),
362
362
  );
363
363
  if (endpoint !== "responses") {
364
- if (Object.keys(requestOptions).length) {
365
- throw new Error("inference request options are supported only for responses");
366
- }
367
- return null;
364
+ const unknown = Object.keys(requestOptions).filter((key) => !RESPONSES_REQUEST_OPTION_FIELDS.has(key)).sort();
365
+ if (unknown.length) throw new Error(`unsupported Chat request options: ${unknown.join(", ")}`);
366
+ return Object.keys(requestOptions).length ? requestOptions : null;
368
367
  }
369
368
  const allowed = new Set([...RESPONSES_REQUEST_OPTION_FIELDS, ...RESPONSES_LOCAL_OPTION_FIELDS]);
370
369
  const unknown = Object.keys(options).filter((key) => !allowed.has(key)).sort();
@@ -793,18 +792,30 @@ export class NativeConsumerState {
793
792
  };
794
793
  this.share = share;
795
794
  try {
796
- const child = this.tunnelSpawn(
797
- this.tunnelCommand,
798
- ["tunnel", "--no-autoupdate", "--url", `http://127.0.0.1:${address.port}`],
799
- { stdio: ["ignore", "pipe", "pipe"] },
800
- );
801
- share.process = child;
802
- const publicUrl = await waitForTunnelUrl(child);
795
+ let publicUrl;
796
+ let lastError;
797
+ for (let attempt = 0; attempt < 2; attempt += 1) {
798
+ const child = this.tunnelSpawn(
799
+ this.tunnelCommand,
800
+ ["tunnel", "--no-autoupdate", "--url", `http://127.0.0.1:${address.port}`],
801
+ { stdio: ["ignore", "pipe", "pipe"] },
802
+ );
803
+ share.process = child;
804
+ try {
805
+ publicUrl = await waitForTunnelUrl(child);
806
+ break;
807
+ } catch (error) {
808
+ lastError = error;
809
+ if (this.share !== share || attempt === 1) throw error;
810
+ await new Promise((resolve) => setTimeout(resolve, 1000));
811
+ }
812
+ }
813
+ if (!publicUrl) throw lastError || new Error("cloudflared did not publish a URL");
803
814
  if (this.share !== share) throw new Error("temporary share was cancelled");
804
815
  share.baseUrl = `${publicUrl.replace(/\/+$/, "")}/v1`;
805
816
  share.timer = setTimeout(() => { void this.stopShare(); }, minutes * 60 * 1000);
806
817
  share.timer.unref?.();
807
- child.once("exit", () => { if (this.share === share) void this.stopShare(); });
818
+ share.process?.once("exit", () => { if (this.share === share) void this.stopShare(); });
808
819
  return this.sharePayload();
809
820
  } catch (error) {
810
821
  await this.stopShare();
@@ -1036,6 +1047,7 @@ function waitForTunnelUrl(child) {
1036
1047
  let output = "";
1037
1048
  let publicUrl = "";
1038
1049
  let connected = false;
1050
+ const diagnostics = () => output.trim().replace(/\s+/g, " ").slice(-1000);
1039
1051
  const finish = (error, url) => {
1040
1052
  clearTimeout(timer);
1041
1053
  child.removeListener("error", onError);
@@ -1052,9 +1064,15 @@ function waitForTunnelUrl(child) {
1052
1064
  if (publicUrl && connected) finish(null, publicUrl);
1053
1065
  };
1054
1066
  const onError = (error) => finish(new Error(`could not start cloudflared: ${error.message}`));
1055
- const onExit = (code) => finish(new Error(`cloudflared exited before publishing a URL (${code ?? "signal"})`));
1067
+ const onExit = (code) => {
1068
+ const detail = diagnostics();
1069
+ finish(new Error(`cloudflared exited before publishing a URL (${code ?? "signal"})${detail ? `: ${detail}` : ""}`));
1070
+ };
1056
1071
  const timer = setTimeout(
1057
- () => finish(new Error("timed out waiting for the temporary HTTPS URL")),
1072
+ () => {
1073
+ const detail = diagnostics();
1074
+ finish(new Error(`timed out waiting for the temporary HTTPS URL${detail ? `: ${detail}` : ""}`));
1075
+ },
1058
1076
  TUNNEL_START_TIMEOUT_MS,
1059
1077
  );
1060
1078
  child.once("error", onError);
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.38";
14
+ export const CONSUMER_RELEASE_VERSION = "0.1.40";
15
15
  export const API_COMMANDS = new Set(["health", "models", "responses", "chat"]);
16
16
  const API_VALUE_OPTIONS = new Set([
17
17
  "--base-url",