refactor: dedupe setup token readers

This commit is contained in:
Peter Steinberger
2026-04-07 05:31:45 +01:00
parent 9869941c06
commit 8d05bdda43
11 changed files with 43 additions and 28 deletions

View File

@@ -8,6 +8,7 @@ import {
type PortUsage,
} from "../../infra/ports.js";
import { killProcessTree } from "../../process/kill-tree.js";
import { normalizeOptionalString } from "../../shared/string-coerce.js";
import { sleep } from "../../utils.js";
export const DEFAULT_RESTART_HEALTH_TIMEOUT_MS = 60_000;
@@ -66,8 +67,8 @@ function looksLikeAuthClose(code: number | undefined, reason: string | undefined
}
async function confirmGatewayReachable(port: number): Promise<boolean> {
const token = process.env.OPENCLAW_GATEWAY_TOKEN?.trim() || undefined;
const password = process.env.OPENCLAW_GATEWAY_PASSWORD?.trim() || undefined;
const token = normalizeOptionalString(process.env.OPENCLAW_GATEWAY_TOKEN);
const password = normalizeOptionalString(process.env.OPENCLAW_GATEWAY_PASSWORD);
const probe = await probeGateway({
url: `ws://127.0.0.1:${port}`,
auth: token || password ? { token, password } : undefined,