mirror of https://github.com/openclaw/openclaw.git
29 lines
693 B
TypeScript
29 lines
693 B
TypeScript
type RuntimeStatusFormatInput = {
|
|
status?: string;
|
|
pid?: number;
|
|
state?: string;
|
|
details?: string[];
|
|
};
|
|
|
|
export function formatRuntimeStatusWithDetails({
|
|
status,
|
|
pid,
|
|
state,
|
|
details = [],
|
|
}: RuntimeStatusFormatInput): string {
|
|
const runtimeStatus = status?.trim() || "unknown";
|
|
const fullDetails: string[] = [];
|
|
if (pid) {
|
|
fullDetails.push(`pid ${pid}`);
|
|
}
|
|
if (state && state.toLowerCase() !== runtimeStatus.toLowerCase()) {
|
|
fullDetails.push(`state ${state}`);
|
|
}
|
|
for (const detail of details) {
|
|
if (detail) {
|
|
fullDetails.push(detail);
|
|
}
|
|
}
|
|
return fullDetails.length > 0 ? `${runtimeStatus} (${fullDetails.join(", ")})` : runtimeStatus;
|
|
}
|