@matelink/cli 2026.4.12 → 2026.4.13
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/bin/matecli.mjs +30 -3
- package/package.json +1 -1
package/bin/matecli.mjs
CHANGED
|
@@ -2709,9 +2709,34 @@ async function callGatewayRpcLocal({
|
|
|
2709
2709
|
};
|
|
2710
2710
|
}
|
|
2711
2711
|
|
|
2712
|
-
//
|
|
2713
|
-
//
|
|
2714
|
-
|
|
2712
|
+
// Prefer CLI first for broad compatibility, but fall back to the persistent
|
|
2713
|
+
// WS client when the CLI gateway call hits transient websocket closures.
|
|
2714
|
+
try {
|
|
2715
|
+
return await callGatewayRpcLocalViaCli({
|
|
2716
|
+
gatewayBaseUrl,
|
|
2717
|
+
gatewayAuthToken,
|
|
2718
|
+
method,
|
|
2719
|
+
params,
|
|
2720
|
+
});
|
|
2721
|
+
} catch (error) {
|
|
2722
|
+
if (!shouldFallbackGatewayRpcViaWs(error)) {
|
|
2723
|
+
throw error;
|
|
2724
|
+
}
|
|
2725
|
+
const client = getOrCreateGatewayWsClient({ gatewayBaseUrl, gatewayAuthToken });
|
|
2726
|
+
return client.call(method, params ?? {});
|
|
2727
|
+
}
|
|
2728
|
+
}
|
|
2729
|
+
|
|
2730
|
+
function shouldFallbackGatewayRpcViaWs(error) {
|
|
2731
|
+
const message = String(error instanceof Error ? error.message : error).toLowerCase();
|
|
2732
|
+
return (
|
|
2733
|
+
message.includes("gateway closed") ||
|
|
2734
|
+
message.includes("abnormal closure") ||
|
|
2735
|
+
message.includes("(1006") ||
|
|
2736
|
+
message.includes("no close reason") ||
|
|
2737
|
+
message.includes("gateway ws error") ||
|
|
2738
|
+
message.includes("gateway disconnected")
|
|
2739
|
+
);
|
|
2715
2740
|
}
|
|
2716
2741
|
|
|
2717
2742
|
async function callGatewayRpcLocalViaCli({
|
|
@@ -2727,6 +2752,8 @@ async function callGatewayRpcLocalViaCli({
|
|
|
2727
2752
|
method,
|
|
2728
2753
|
"--url",
|
|
2729
2754
|
wsUrl,
|
|
2755
|
+
"--timeout",
|
|
2756
|
+
String(GATEWAY_RPC_CLI_TIMEOUT_MS),
|
|
2730
2757
|
"--params",
|
|
2731
2758
|
JSON.stringify(params ?? {}),
|
|
2732
2759
|
"--json",
|