-
Notifications
You must be signed in to change notification settings - Fork 3k
Expand file tree
/
Copy pathdoctor.ts
More file actions
625 lines (594 loc) · 21.3 KB
/
Copy pathdoctor.ts
File metadata and controls
625 lines (594 loc) · 21.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
import fs from "node:fs";
import path from "node:path";
import { stripAnsi } from "../../adapters/openshell/client";
import { resolveOpenshell } from "../../adapters/openshell/resolve";
import { captureOpenshell } from "../../adapters/openshell/runtime";
import { OPENSHELL_PROBE_TIMEOUT_MS } from "../../adapters/openshell/timeouts";
import { getAgentRuntimeKind, loadAgent } from "../../agent/defs";
import * as agentRuntime from "../../agent/runtime";
import { CLI_NAME } from "../../cli/branding";
import { GATEWAY_PORT } from "../../core/ports";
import {
type CuaStateObservationDeps,
getObservedValidatedCuaState,
isCuaPublicStateEnabled,
} from "../../cua/state";
import {
getNamedGatewayLifecycleState,
recoverNamedGatewayRuntime,
} from "../../gateway-runtime-action";
import { parseGatewayInference } from "../../inference/config";
import { shouldManageDashboardForAgent } from "../../onboard/dashboard-runtime";
import { resolveGatewayName, resolveSandboxGatewayName } from "../../onboard/gateway-binding";
import {
CURRENT_RUNTIME_PROVIDER_BUNDLES,
RuntimeProviderSelectionError,
requireRuntimeProviderBundle,
resolveCurrentRuntimeProviderBundle,
} from "../../onboard/runtime-provider/access";
import { executeSandboxCommandForVerification } from "../../onboard/sandbox-verification-exec";
import { getBaselineExclusionRuntimeStatus } from "../../policy";
import {
BASELINE_EXCLUSION_SUPPORT_IMPACT,
type BaselineExclusionRuntimeStatus,
} from "../../policy/baseline-exclusion";
import { ROOT } from "../../runner";
import { parseLiveSandboxNames } from "../../runtime-recovery";
import * as sandboxVersion from "../../sandbox/version";
import * as shields from "../../shields";
import type { SandboxEntry } from "../../state/registry";
import * as registry from "../../state/registry";
import { runSandboxAutoPairApprovalPass } from "./auto-pair-approval";
import { buildConfigPermsCheck } from "./doctor-config-perms";
import {
collectInferenceChecks,
collectManagedLlamaCppDoctorChecks,
type DoctorInferenceRoute,
resolveDoctorReasoningEffort,
} from "./doctor-inference";
import {
buildLifecycleRegistrationCheck,
buildPortableRuntimeCheck,
} from "./doctor-lifecycle-registration";
import { collectMessagingDoctorChecks } from "./doctor-messaging";
import {
buildDoctorReport,
type DoctorCheck,
type DoctorReport,
type DoctorStatus,
renderDoctorReport,
} from "./doctor-report";
import {
cloudflaredDoctorCheck,
dockerInspectGateway,
findSandboxListLine,
inferSandboxReadyFromLine,
ollamaDoctorCheck,
oneLine,
shouldInspectLegacyGatewayContainer,
} from "./doctor-system-checks";
import { buildToolScopeChecks } from "./doctor-tool-scope";
export type { DoctorCheck, DoctorReport } from "./doctor-report";
type RunSandboxDoctorOptions = {
quietJson?: boolean;
};
type DoctorIntent = {
asJson: boolean;
wantsFix: boolean;
};
type GatewayProbe = {
checks: DoctorCheck[];
connected: boolean;
};
type SandboxProbe = {
checks: DoctorCheck[];
reachable: boolean;
};
function parseDoctorIntent(sandboxName: string, args: string[]): DoctorIntent | null {
const asJson = args.includes("--json");
const wantsFix = args.includes("--fix");
const helpRequested = args.includes("--help") || args.includes("-h");
const unknown = args.filter((arg) => !["--json", "--fix", "--help", "-h"].includes(arg));
if (helpRequested) {
console.log(` Usage: ${CLI_NAME} <name> doctor [--json] [--fix]`);
console.log(
` --fix Restore the mutable OpenClaw config permission contract if it was tightened,`,
);
console.log(` and approve pending allowlisted dashboard/CLI tool-scope upgrades`);
return null;
}
if (unknown.length > 0) {
console.error(
` Unknown doctor argument${unknown.length === 1 ? "" : "s"}: ${unknown.join(" ")}`,
);
console.error(` Usage: ${CLI_NAME} <name> doctor [--json] [--fix]`);
process.exit(1);
}
// `--fix` mutates sandbox permissions; `--json` is the machine-readable
// readiness-gate path. Refuse the combination so automation consuming JSON
// can never trigger a silent repair (the JSON report has no dedicated
// repair-intent field). Run `doctor --json` to detect, then `doctor --fix`
// to repair.
if (wantsFix && asJson) {
console.error(` ${CLI_NAME} doctor: --fix cannot be combined with --json`);
console.error(
` Run \`${CLI_NAME} ${sandboxName} doctor --json\` to detect, then \`${CLI_NAME} ${sandboxName} doctor --fix\` to repair`,
);
process.exit(1);
}
return { asJson, wantsFix };
}
function cliBuildCheck(): DoctorCheck {
const exists = fs.existsSync(path.join(ROOT, "dist", "nemoclaw.js"));
return {
group: "Host",
label: "CLI build",
status: exists ? "ok" : "fail",
detail: exists ? "dist/nemoclaw.js present" : "dist/nemoclaw.js missing",
hint: exists ? undefined : "run `npm run build:cli`",
};
}
function inspectRuntimeHost(sb: SandboxEntry | null | undefined): DoctorCheck {
const portable = sb ? buildPortableRuntimeCheck(sb.name) : null;
if (portable) return portable;
const recorded = sb?.openshellDriver?.trim();
const provider = recorded
? requireRuntimeProviderBundle(recorded, CURRENT_RUNTIME_PROVIDER_BUNDLES)
: resolveCurrentRuntimeProviderBundle();
return provider.preflightDoctor.inspectHost();
}
function runtimeHostCheck(sb: SandboxEntry | null | undefined): DoctorCheck {
try {
return inspectRuntimeHost(sb);
} catch (error) {
const detail =
error instanceof RuntimeProviderSelectionError
? error.message
: `Runtime provider inspection failed: ${error instanceof Error ? error.message : String(error)}`;
return {
group: "Host",
label: "Runtime provider",
status: "fail",
detail,
hint: "restore a supported durable runtime provider identity before retrying",
};
}
}
function collectHostChecks(sb: SandboxEntry | null | undefined): {
checks: DoctorCheck[];
openshellBin: ReturnType<typeof resolveOpenshell>;
} {
const cli = cliBuildCheck();
const openshellBin = resolveOpenshell();
return {
checks: [
cli,
runtimeHostCheck(sb),
{
group: "Host",
label: "OpenShell CLI",
status: openshellBin ? "ok" : "fail",
detail: openshellBin || "not found on PATH",
hint: openshellBin ? undefined : "install OpenShell before using sandbox commands",
},
],
openshellBin,
};
}
async function collectGatewayChecks(
gatewayName: string,
sb: SandboxEntry | null | undefined,
openshellBin: ReturnType<typeof resolveOpenshell>,
recoverGateway: boolean,
): Promise<GatewayProbe> {
const checks: DoctorCheck[] = [];
const gateway = openshellBin
? await probeOpenShellGateway(gatewayName, recoverGateway)
: { check: null, connected: false };
if (gateway.check) checks.push(gateway.check);
if (shouldInspectLegacyGatewayContainer(sb)) {
checks.push(
...dockerInspectGateway(
`openshell-cluster-${gatewayName}`,
{
namedGatewayConnected: gateway.connected,
gatewayName,
},
sb?.gatewayPort ?? GATEWAY_PORT,
),
);
}
return { checks, connected: gateway.connected };
}
async function gatewayLifecycle(gatewayName: string, recoverGateway: boolean) {
if (!recoverGateway) return getNamedGatewayLifecycleState(gatewayName);
const recovery = await recoverNamedGatewayRuntime({ gatewayName });
return recovery.after || recovery.before;
}
async function probeOpenShellGateway(
gatewayName: string,
recoverGateway: boolean,
): Promise<{
check: DoctorCheck;
connected: boolean;
}> {
const lifecycle = await gatewayLifecycle(gatewayName, recoverGateway);
const cleanStatus = stripAnsi(lifecycle?.status || "");
const connected = lifecycle?.state === "healthy_named";
return {
connected,
check: {
group: "Gateway",
label: "OpenShell status",
status: connected ? "ok" : "fail",
detail: connected
? `connected to ${gatewayName}`
: oneLine(cleanStatus || lifecycle?.gatewayInfo || `not connected to ${gatewayName}`),
hint: connected ? undefined : `run \`openshell gateway select ${gatewayName}\` and retry`,
},
};
}
function liveSandboxDetail(
sandboxName: string,
present: boolean,
ready: boolean | null,
line: string | null,
): string {
if (!present) return `${sandboxName} not present in live OpenShell sandbox list`;
if (ready) return `${sandboxName} present (Ready)`;
return `${sandboxName} present${line ? ` (${oneLine(line)})` : ""}`;
}
function liveSandboxHint(
sandboxName: string,
present: boolean,
ready: boolean | null,
): string | undefined {
if (!present) {
return `run \`${CLI_NAME} ${sandboxName} status\` or recreate with \`${CLI_NAME} onboard\``;
}
if (ready) return undefined;
return `run \`${CLI_NAME} ${sandboxName} status\` or \`${CLI_NAME} ${sandboxName} logs --follow\``;
}
function liveSandboxCheck(sandboxName: string): SandboxProbe {
const list = captureOpenshell(["sandbox", "list"], {
ignoreError: true,
timeout: OPENSHELL_PROBE_TIMEOUT_MS,
});
const liveNames = parseLiveSandboxNames(list.output || "");
const present = list.status === 0 && liveNames.has(sandboxName);
const line = findSandboxListLine(list.output || "", sandboxName);
const ready = inferSandboxReadyFromLine(line);
const reachable = present && ready === true;
return {
reachable,
checks: [
{
group: "Sandbox",
label: "Live sandbox",
status: reachable ? "ok" : "fail",
detail: liveSandboxDetail(sandboxName, present, ready, line),
hint: liveSandboxHint(sandboxName, present, ready),
},
],
};
}
function collectSandboxReadinessChecks(
sandboxName: string,
openshellBin: ReturnType<typeof resolveOpenshell>,
openshellConnected: boolean,
): SandboxProbe {
if (openshellBin && openshellConnected) return liveSandboxCheck(sandboxName);
if (!openshellBin) return { checks: [], reachable: false };
return {
reachable: false,
checks: [
{
group: "Sandbox",
label: "Live sandbox",
status: "fail",
detail: "skipped because the nemoclaw gateway is not connected",
hint: "fix the gateway check above before trusting sandbox readiness",
},
],
};
}
function resolveInferenceRoute(
sb: SandboxEntry | null | undefined,
openshellBin: ReturnType<typeof resolveOpenshell>,
openshellConnected: boolean,
): DoctorInferenceRoute {
const live =
openshellBin && openshellConnected
? parseGatewayInference(
captureOpenshell(["inference", "get"], {
ignoreError: true,
timeout: OPENSHELL_PROBE_TIMEOUT_MS,
}).output,
)
: null;
return {
model: live?.model || sb?.model || "unknown",
provider: live?.provider || sb?.provider || "unknown",
effectiveReasoningEffort: resolveDoctorReasoningEffort(sb),
};
}
function agentVersionDoctorCheck(sandboxName: string): DoctorCheck {
try {
const version = sandboxVersion.checkAgentVersion(sandboxName);
const agentName = agentRuntime.getAgentDisplayName(agentRuntime.getSessionAgent(sandboxName));
if (version.isStale) {
return {
group: "Sandbox",
label: "Agent version",
status: "warn",
detail: `${agentName} v${version.sandboxVersion || "unknown"}; v${version.expectedVersion} available`,
hint: `run \`${CLI_NAME} ${sandboxName} rebuild\``,
};
}
if (version.sandboxVersion) {
return {
group: "Sandbox",
label: "Agent version",
status: "ok",
detail: `${agentName} v${version.sandboxVersion}`,
};
}
return {
group: "Sandbox",
label: "Agent version",
status: "info",
detail: "could not detect version",
};
} catch {
return {
group: "Sandbox",
label: "Agent version",
status: "info",
detail: "version check unavailable",
};
}
}
function shieldsDoctorCheck(sandboxName: string): DoctorCheck {
const posture = shields.getShieldsPosture(sandboxName, false);
const status: DoctorStatus =
posture.mode === "locked"
? "ok"
: posture.mode === "temporarily_unlocked" || posture.mode === "error"
? "warn"
: "info";
const hint =
posture.mode === "mutable_default"
? `run \`${CLI_NAME} ${sandboxName} shields up\` to opt into lockdown`
: posture.mode === "locked"
? undefined
: `run \`${CLI_NAME} ${sandboxName} shields status\` for details`;
return {
group: "Sandbox",
label: "Shields",
status,
detail: posture.detail,
hint,
};
}
function baselineExclusionCheckFields(
sandboxName: string,
key: string,
runtimeStatus: BaselineExclusionRuntimeStatus,
): Pick<DoctorCheck, "status" | "detail" | "hint"> {
const restoreCommand = `${CLI_NAME} ${sandboxName} policy restore ${key}`;
if (runtimeStatus === "excluded") {
return {
status: "info",
detail: `Baseline entry '${key}' excluded. ${BASELINE_EXCLUSION_SUPPORT_IMPACT}`,
hint: `restore with \`${restoreCommand}\``,
};
}
if (runtimeStatus === "no-longer-in-baseline") {
return {
status: "warn",
detail: `Baseline entry '${key}' no longer exists; rebuild fails closed until the stale exclusion is cleared.`,
hint: `key no longer exists in the baseline; run \`${restoreCommand}\` to clear the stale record`,
};
}
if (runtimeStatus === "agent-changed") {
return {
status: "warn",
detail: `Baseline exclusion '${key}' belongs to a different agent; rebuild fails closed until the stale approval is cleared.`,
hint: `run \`${restoreCommand}\`, then review and approve the current agent baseline if needed`,
};
}
if (runtimeStatus === "baseline-unreadable") {
return {
status: "warn",
detail: "Current agent baseline is unreadable; exclusion scope could not be verified.",
hint: `inspect \`${CLI_NAME} ${sandboxName} policy list\` before rebuilding`,
};
}
if (runtimeStatus === "live-policy-unreadable") {
return {
status: "warn",
detail: `Live policy for '${key}' is unreadable; exclusion enforcement could not be verified.`,
hint: `restore gateway access, then rerun \`${CLI_NAME} ${sandboxName} doctor\``,
};
}
if (runtimeStatus === "live-policy-mismatch") {
return {
status: "fail",
detail: `Live policy still contains excluded baseline entry '${key}'; the recorded exclusion is not enforced.`,
hint: `inspect \`${CLI_NAME} ${sandboxName} policy list\`, remove the colliding source, then re-run the exclusion`,
};
}
return {
status: "warn",
detail: `Baseline entry '${key}' changed since exclusion was approved; rebuild fails closed until re-approved.`,
hint: `run \`${restoreCommand}\`, review with \`${CLI_NAME} ${sandboxName} policy exclude ${key} --dry-run\`, then re-approve`,
};
}
function baselineExclusionDoctorChecks(sandboxName: string): DoctorCheck[] {
const transition = registry.getBaselineExclusionTransition(sandboxName);
const checks: DoctorCheck[] = [];
for (const exclusion of registry.getBaselineExclusions(sandboxName)) {
if (transition?.exclusion.key === exclusion.key) continue;
const runtimeStatus = getBaselineExclusionRuntimeStatus(sandboxName, exclusion);
checks.push({
group: "Sandbox",
label: `Baseline exclusion: ${exclusion.key}`,
...baselineExclusionCheckFields(sandboxName, exclusion.key, runtimeStatus),
});
}
if (transition) {
const key = transition.exclusion.key;
checks.push({
group: "Sandbox",
label: `Baseline exclusion: ${key}`,
status: "warn",
detail: `Baseline policy ${transition.operation} for '${key}' was interrupted; rebuild is blocked until live and durable state are reconciled.`,
hint: `re-run \`${CLI_NAME} ${sandboxName} policy ${transition.operation} ${key}\``,
});
}
return checks;
}
function collectRegisteredSandboxChecks(
sandboxName: string,
sb: SandboxEntry | null | undefined,
wantsFix: boolean,
sandboxReachable: boolean,
): DoctorCheck[] {
if (!sb) return [];
const checks = [agentVersionDoctorCheck(sandboxName), shieldsDoctorCheck(sandboxName)];
let dashboardPortRequired = true;
try {
dashboardPortRequired = shouldManageDashboardForAgent(loadAgent(sb.agent || "openclaw"));
} catch {
// Require dashboard metadata when the agent definition cannot be loaded.
}
checks.push(
buildLifecycleRegistrationCheck(sandboxName, sb, CLI_NAME, { dashboardPortRequired }),
);
const permsCheck = buildConfigPermsCheck(sandboxName, wantsFix, {
inspect: shields.inspectMutableConfigPerms,
repair: shields.repairMutableConfigPerms,
cliName: CLI_NAME,
});
if (permsCheck) checks.push(permsCheck);
checks.push(...collectMessagingDoctorChecks(sandboxName, sb, sandboxReachable));
checks.push(...baselineExclusionDoctorChecks(sandboxName));
return checks;
}
/** Report candidate install readiness only while both exact CUA gates are enabled. */
export function collectCuaRuntimeDoctorChecks(
sb: SandboxEntry | null | undefined,
deps: CuaStateObservationDeps = {},
): DoctorCheck[] {
if (!isCuaPublicStateEnabled() || sb?.agent !== "nemocua") return [];
const observed = getObservedValidatedCuaState(sb, process.env, deps);
if (!observed.readiness) {
return [
{
group: "Sandbox",
label: "CUA runtime",
status: "fail",
detail: "candidate readiness is missing, invalid, stale, or unavailable",
hint: "rerun canonical onboarding with exact candidate qualification authority",
},
];
}
return [
{
group: "Sandbox",
label: "CUA runtime",
status: "ok",
detail: `candidate; source=${observed.readiness.sourceRevision}; manifest=${observed.readiness.runtimeManifestDigest}`,
},
];
}
function collectToolScopeChecks(
sandboxName: string,
sb: SandboxEntry | null | undefined,
sandboxReachable: boolean,
wantsFix: boolean,
): DoctorCheck[] {
if (!sb || !sandboxReachable || (sb.agent ?? "openclaw") !== "openclaw") return [];
return buildToolScopeChecks(sandboxName, CLI_NAME, wantsFix, {
exec: (name, script) => executeSandboxCommandForVerification(name, script),
runApprovalPass: (name) => {
const result = runSandboxAutoPairApprovalPass(name, { capture: true });
return { reported: result.reported, approved: result.approved };
},
});
}
function shouldReportServingProcessHealth(agentName: string | null | undefined): boolean {
const resolvedName = agentName || "openclaw";
try {
return getAgentRuntimeKind(loadAgent(resolvedName)) === "gateway";
} catch {
// Status preserves OpenClaw's gateway default if its manifest cannot be
// loaded, while unknown non-default agents are classified as unknown.
return resolvedName === "openclaw";
}
}
async function collectDoctorChecks(
sandboxName: string,
sb: SandboxEntry | null | undefined,
gatewayName: string | null,
intent: DoctorIntent,
): Promise<DoctorCheck[]> {
const host = collectHostChecks(sb);
const gateway: GatewayProbe = gatewayName
? await collectGatewayChecks(gatewayName, sb, host.openshellBin, !intent.asJson)
: {
connected: false,
checks: [
{
group: "Gateway",
label: "Registered gateway binding",
status: "fail",
detail: "skipped because the registered gateway binding is invalid",
hint: `re-register or re-onboard '${sandboxName}' before running lifecycle commands`,
},
],
};
const sandbox = collectSandboxReadinessChecks(sandboxName, host.openshellBin, gateway.connected);
const route = resolveInferenceRoute(sb, host.openshellBin, gateway.connected);
return [
...host.checks,
...gateway.checks,
...sandbox.checks,
...(await collectInferenceChecks(sandboxName, route, sandbox.reachable, {
includeServingProcessCheck: shouldReportServingProcessHealth(sb?.agent),
})),
...collectRegisteredSandboxChecks(sandboxName, sb, intent.wantsFix, sandbox.reachable),
...collectToolScopeChecks(sandboxName, sb, sandbox.reachable, intent.wantsFix),
...collectManagedLlamaCppDoctorChecks(sandboxName, sb?.gatewayPort),
ollamaDoctorCheck(route.provider),
cloudflaredDoctorCheck(sandboxName),
// Keep this last because every asynchronous check above may race an
// authority-clearing registry write.
...collectCuaRuntimeDoctorChecks(registry.getSandbox(sandboxName)),
];
}
export async function runSandboxDoctor(
sandboxName: string,
args: string[] = [],
options: RunSandboxDoctorOptions = {},
): Promise<DoctorReport | undefined> {
const intent = parseDoctorIntent(sandboxName, args);
if (!intent) return undefined;
const sb = registry.getSandbox(sandboxName);
let gatewayName: string | null = resolveGatewayName(GATEWAY_PORT);
if (sb) {
try {
gatewayName = resolveSandboxGatewayName(sb);
} catch {
gatewayName = null;
}
}
const checks = await collectDoctorChecks(sandboxName, sb, gatewayName, intent);
const report = buildDoctorReport(sandboxName, checks);
if (intent.asJson && options.quietJson) return report;
const exitCode = renderDoctorReport(report, intent.asJson);
if (exitCode !== 0) process.exit(exitCode);
return undefined;
}