mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 09:47:40 +00:00
refactor(commands): dedupe gateway self presence picker
This commit is contained in:
@@ -180,24 +180,4 @@ export function summarizeLogTail(rawLines: string[], opts?: { maxLines?: number
|
||||
return kept;
|
||||
}
|
||||
|
||||
export function pickGatewaySelfPresence(presence: unknown): {
|
||||
host?: string;
|
||||
ip?: string;
|
||||
version?: string;
|
||||
platform?: string;
|
||||
} | null {
|
||||
if (!Array.isArray(presence)) {
|
||||
return null;
|
||||
}
|
||||
const entries = presence as Array<Record<string, unknown>>;
|
||||
const self = entries.find((e) => e.mode === "gateway" && e.reason === "self") ?? null;
|
||||
if (!self) {
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
host: typeof self.host === "string" ? self.host : undefined,
|
||||
ip: typeof self.ip === "string" ? self.ip : undefined,
|
||||
version: typeof self.version === "string" ? self.version : undefined,
|
||||
platform: typeof self.platform === "string" ? self.platform : undefined,
|
||||
};
|
||||
}
|
||||
export { pickGatewaySelfPresence } from "../gateway-presence.js";
|
||||
|
||||
Reference in New Issue
Block a user