fix(gateway): restore loopback detail probes and identity fallback (#51087)

Merged via squash.

Prepared head SHA: f8a66ffde2
Co-authored-by: heavenlost <70937055+heavenlost@users.noreply.github.com>
Co-authored-by: mbelinky <132747814+mbelinky@users.noreply.github.com>
Reviewed-by: @mbelinky
This commit is contained in:
heavenlost
2026-03-27 15:09:41 +08:00
committed by GitHub
parent 6f92148da9
commit 3cbd4de95c
13 changed files with 469 additions and 70 deletions

View File

@@ -1,5 +1,3 @@
import { callGateway } from "../../gateway/call.js";
import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES } from "../../utils/message-channel.js";
import { withProgress } from "../progress.js";
export async function probeGatewayStatus(opts: {
@@ -9,29 +7,53 @@ export async function probeGatewayStatus(opts: {
tlsFingerprint?: string;
timeoutMs: number;
json?: boolean;
requireRpc?: boolean;
configPath?: string;
}) {
try {
await withProgress(
const result = await withProgress(
{
label: "Checking gateway status...",
indeterminate: true,
enabled: opts.json !== true,
},
async () =>
await callGateway({
async () => {
if (opts.requireRpc) {
const { callGateway } = await import("../../gateway/call.js");
await callGateway({
url: opts.url,
token: opts.token,
password: opts.password,
tlsFingerprint: opts.tlsFingerprint,
method: "status",
timeoutMs: opts.timeoutMs,
...(opts.configPath ? { configPath: opts.configPath } : {}),
});
return { ok: true } as const;
}
const { probeGateway } = await import("../../gateway/probe.js");
return await probeGateway({
url: opts.url,
token: opts.token,
password: opts.password,
auth: {
token: opts.token,
password: opts.password,
},
tlsFingerprint: opts.tlsFingerprint,
method: "status",
timeoutMs: opts.timeoutMs,
clientName: GATEWAY_CLIENT_NAMES.CLI,
mode: GATEWAY_CLIENT_MODES.CLI,
...(opts.configPath ? { configPath: opts.configPath } : {}),
}),
includeDetails: false,
});
},
);
return { ok: true } as const;
if (result.ok) {
return { ok: true } as const;
}
const closeHint = result.close
? `gateway closed (${result.close.code}): ${result.close.reason}`
: null;
return {
ok: false,
error: result.error ?? closeHint ?? "gateway probe failed",
} as const;
} catch (err) {
return {
ok: false,