mycomesh-consumer 0.1.40 → 0.1.42
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 +20 -2
- package/src/consumer.mjs +1 -1
package/package.json
CHANGED
package/src/consumer-runtime.mjs
CHANGED
|
@@ -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,
|
|
@@ -797,7 +798,7 @@ export class NativeConsumerState {
|
|
|
797
798
|
for (let attempt = 0; attempt < 2; attempt += 1) {
|
|
798
799
|
const child = this.tunnelSpawn(
|
|
799
800
|
this.tunnelCommand,
|
|
800
|
-
["tunnel", "--no-autoupdate", "--url", `http://127.0.0.1:${address.port}`],
|
|
801
|
+
["tunnel", "--no-autoupdate", "--protocol", "http2", "--url", `http://127.0.0.1:${address.port}`],
|
|
801
802
|
{ stdio: ["ignore", "pipe", "pipe"] },
|
|
802
803
|
);
|
|
803
804
|
share.process = child;
|
|
@@ -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
|
-
|
|
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.
|
|
14
|
+
export const CONSUMER_RELEASE_VERSION = "0.1.42";
|
|
15
15
|
export const API_COMMANDS = new Set(["health", "models", "responses", "chat"]);
|
|
16
16
|
const API_VALUE_OPTIONS = new Set([
|
|
17
17
|
"--base-url",
|