openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
49 lines (48 loc) • 2.38 kB
JavaScript
import { o as classifyGatewayConnectFailure, t as ConnectErrorDetailCodes } from "./connect-error-details-BdhXf496.mjs";
import { r as isGatewayProtocolResponseError } from "./protocol-request-CsClAJsG.mjs";
//#region src/commands/gateway-health-auth-diagnostic.ts
const GATEWAY_HEALTH_CREDENTIALS_REQUIRED_MESSAGE = "Gateway is reachable, but this CLI lacks credentials with read scope for health RPCs.";
const GATEWAY_HEALTH_CREDENTIALS_REQUIRED_TITLE = "Gateway credentials required";
const GATEWAY_HEALTH_REACHABLE_LINE = "Gateway: reachable";
const GATEWAY_HEALTH_RATE_LIMITED_MESSAGE = "Gateway authentication is temporarily rate-limited. Wait for the temporary lockout to expire, then retry.";
const GATEWAY_HEALTH_RATE_LIMITED_TITLE = "Gateway authentication rate-limited";
function gatewayProbeResultWasRateLimited(e) {
return (e.connectFailure?.kind ?? classifyGatewayConnectFailure({ message: e.error }).kind) === "rate-limited";
}
function gatewayConnectErrorWasRateLimited(e) {
if (!isGatewayProtocolResponseError(e)) return false;
return classifyGatewayConnectFailure({
details: e.details,
message: e.message
}).kind === "rate-limited";
}
function gatewayProbeResultSawGateway(e) {
return e.ok || e.gatewayReached === true;
}
function buildCredentialsRequiredHealthDiagnostic() {
return {
ok: false,
error: {
type: "gateway_credentials_required",
message: GATEWAY_HEALTH_CREDENTIALS_REQUIRED_MESSAGE
},
gateway: { reachable: true }
};
}
function buildRateLimitedHealthDiagnostic(e) {
const t = e instanceof Error ? e.retryAfterMs : void 0;
const n = typeof t === "number" && Number.isSafeInteger(t) && t >= 0 ? t : void 0;
return {
ok: false,
error: {
type: "gateway_request_error",
code: ConnectErrorDetailCodes.AUTH_RATE_LIMITED,
message: GATEWAY_HEALTH_RATE_LIMITED_MESSAGE,
retryable: true,
...n !== void 0 ? { retryAfterMs: n } : {}
},
gateway: { reachable: true }
};
}
//#endregion
export { GATEWAY_HEALTH_REACHABLE_LINE as a, gatewayConnectErrorWasRateLimited as c, GATEWAY_HEALTH_RATE_LIMITED_TITLE as i, gatewayProbeResultSawGateway as l, GATEWAY_HEALTH_CREDENTIALS_REQUIRED_TITLE as n, buildCredentialsRequiredHealthDiagnostic as o, GATEWAY_HEALTH_RATE_LIMITED_MESSAGE as r, buildRateLimitedHealthDiagnostic as s, GATEWAY_HEALTH_CREDENTIALS_REQUIRED_MESSAGE as t, gatewayProbeResultWasRateLimited as u };