| 197 | } |
| 198 | |
| 199 | function formatHuman(result: Record<string, unknown>): string { |
| 200 | const rawAction = result['action']; |
| 201 | const action = typeof rawAction === 'string' ? rawAction : 'action'; |
| 202 | const rawMessage = result['message']; |
| 203 | const message = typeof rawMessage === 'string' ? `: ${rawMessage}` : ''; |
| 204 | const lines = [`${action}${message}`]; |
| 205 | |
| 206 | const url = result['url']; |
| 207 | if (typeof url === 'string') lines.push(`URL: ${url}`); |
| 208 | |
| 209 | const running = result['running']; |
| 210 | if (typeof running === 'boolean') lines.push(`Status: ${running ? 'running' : 'not running'}`); |
| 211 | |
| 212 | const logPath = result['logPath']; |
| 213 | if (typeof logPath === 'string') lines.push(`Log: ${logPath}`); |
| 214 | |
| 215 | const notes = result['notes']; |
| 216 | if (Array.isArray(notes)) { |
| 217 | for (const note of notes) { |
| 218 | if (typeof note === 'string' && note.length > 0) lines.push(`Note: ${note}`); |
| 219 | } |
| 220 | } |
| 221 | |
| 222 | return `${lines.join('\n')}\n`; |
| 223 | } |
| 224 | |
| 225 | async function readStatus(mgr: ServiceManager): Promise<ServiceStatus | undefined> { |
| 226 | try { |