|
1 | 1 | import fs from "node:fs/promises"; |
| 2 | +import { inspect } from "node:util"; |
2 | 3 | import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime"; |
3 | 4 | import type { |
4 | 5 | AcpRuntime, |
@@ -79,8 +80,36 @@ function warnOnIgnoredLegacyCompatibilityConfig(params: { |
79 | 80 | ); |
80 | 81 | } |
81 | 82 |
|
82 | | -function formatDoctorFailureMessage(report: { message: string; details?: string[] }): string { |
83 | | - const detailText = report.details?.filter(Boolean).join("; ").trim(); |
| 83 | +function formatDoctorDetail(detail: unknown): string | null { |
| 84 | + if (!detail) { |
| 85 | + return null; |
| 86 | + } |
| 87 | + if (typeof detail === "string") { |
| 88 | + return detail.trim() || null; |
| 89 | + } |
| 90 | + if (detail instanceof Error) { |
| 91 | + return formatErrorMessage(detail); |
| 92 | + } |
| 93 | + if (typeof detail === "object") { |
| 94 | + try { |
| 95 | + return JSON.stringify(detail) ?? inspect(detail, { breakLength: Infinity, depth: 3 }); |
| 96 | + } catch { |
| 97 | + return inspect(detail, { breakLength: Infinity, depth: 3 }); |
| 98 | + } |
| 99 | + } |
| 100 | + if ( |
| 101 | + typeof detail === "number" || |
| 102 | + typeof detail === "boolean" || |
| 103 | + typeof detail === "bigint" || |
| 104 | + typeof detail === "symbol" |
| 105 | + ) { |
| 106 | + return detail.toString(); |
| 107 | + } |
| 108 | + return inspect(detail, { breakLength: Infinity, depth: 3 }); |
| 109 | +} |
| 110 | + |
| 111 | +function formatDoctorFailureMessage(report: { message: string; details?: unknown[] }): string { |
| 112 | + const detailText = report.details?.map(formatDoctorDetail).filter(Boolean).join("; ").trim(); |
84 | 113 | return detailText ? `${report.message} (${detailText})` : report.message; |
85 | 114 | } |
86 | 115 |
|
|
0 commit comments