mycomesh-consumer 0.1.39 → 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 +1 -1
- package/src/consumer-runtime.mjs +29 -10
- package/src/consumer.mjs +1 -1
package/package.json
CHANGED
package/src/consumer-runtime.mjs
CHANGED
|
@@ -792,18 +792,30 @@ export class NativeConsumerState {
|
|
|
792
792
|
};
|
|
793
793
|
this.share = share;
|
|
794
794
|
try {
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
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");
|
|
802
814
|
if (this.share !== share) throw new Error("temporary share was cancelled");
|
|
803
815
|
share.baseUrl = `${publicUrl.replace(/\/+$/, "")}/v1`;
|
|
804
816
|
share.timer = setTimeout(() => { void this.stopShare(); }, minutes * 60 * 1000);
|
|
805
817
|
share.timer.unref?.();
|
|
806
|
-
|
|
818
|
+
share.process?.once("exit", () => { if (this.share === share) void this.stopShare(); });
|
|
807
819
|
return this.sharePayload();
|
|
808
820
|
} catch (error) {
|
|
809
821
|
await this.stopShare();
|
|
@@ -1035,6 +1047,7 @@ function waitForTunnelUrl(child) {
|
|
|
1035
1047
|
let output = "";
|
|
1036
1048
|
let publicUrl = "";
|
|
1037
1049
|
let connected = false;
|
|
1050
|
+
const diagnostics = () => output.trim().replace(/\s+/g, " ").slice(-1000);
|
|
1038
1051
|
const finish = (error, url) => {
|
|
1039
1052
|
clearTimeout(timer);
|
|
1040
1053
|
child.removeListener("error", onError);
|
|
@@ -1051,9 +1064,15 @@ function waitForTunnelUrl(child) {
|
|
|
1051
1064
|
if (publicUrl && connected) finish(null, publicUrl);
|
|
1052
1065
|
};
|
|
1053
1066
|
const onError = (error) => finish(new Error(`could not start cloudflared: ${error.message}`));
|
|
1054
|
-
const onExit = (code) =>
|
|
1067
|
+
const onExit = (code) => {
|
|
1068
|
+
const detail = diagnostics();
|
|
1069
|
+
finish(new Error(`cloudflared exited before publishing a URL (${code ?? "signal"})${detail ? `: ${detail}` : ""}`));
|
|
1070
|
+
};
|
|
1055
1071
|
const timer = setTimeout(
|
|
1056
|
-
() =>
|
|
1072
|
+
() => {
|
|
1073
|
+
const detail = diagnostics();
|
|
1074
|
+
finish(new Error(`timed out waiting for the temporary HTTPS URL${detail ? `: ${detail}` : ""}`));
|
|
1075
|
+
},
|
|
1057
1076
|
TUNNEL_START_TIMEOUT_MS,
|
|
1058
1077
|
);
|
|
1059
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.
|
|
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",
|