docs: document status json helpers · openclaw/openclaw@abb09b9
steipete
·
2026-06-05
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Entry point for `openclaw status --all`. |
| 2 | +// Orchestrates the scan, local service probes, and report rendering while report builders own formatting. |
| 3 | + |
1 | 4 | import { withProgress } from "../cli/progress.js"; |
2 | 5 | import type { RuntimeEnv } from "../runtime.js"; |
3 | 6 | import { buildStatusAllReportData } from "./status-all/report-data.js"; |
@@ -6,6 +9,7 @@ import { resolveStatusServiceSummaries } from "./status-runtime-shared.ts";
|
6 | 9 | import { resolveNodeOnlyGatewayInfo } from "./status.node-mode.js"; |
7 | 10 | import { collectStatusScanOverview } from "./status.scan-overview.ts"; |
8 | 11 | |
| 12 | +/** Runs the full read-only status report and writes it to the runtime logger. */ |
9 | 13 | export async function statusAllCommand( |
10 | 14 | runtime: RuntimeEnv, |
11 | 15 | opts?: { timeoutMs?: number }, |
@@ -18,6 +22,7 @@ export async function statusAllCommand(
|
18 | 22 | }, |
19 | 23 | showSecrets: false, |
20 | 24 | runtime, |
| 25 | +// status --all can afford gateway overrides so channel summaries reflect live runtime state. |
21 | 26 | useGatewayCallOverridesForChannelsStatus: true, |
22 | 27 | progress, |
23 | 28 | labels: { |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Shared command runner for `openclaw status --json`. |
| 2 | +// It keeps scan execution separate from JSON payload assembly so CLI variants can reuse the same output path. |
| 3 | + |
1 | 4 | import { type RuntimeEnv, writeRuntimeJson } from "../runtime.js"; |
2 | 5 | import { resolveStatusJsonOutput } from "./status-json-runtime.ts"; |
3 | 6 | |
@@ -8,6 +11,7 @@ type StatusJsonCommandOptions = {
|
8 | 11 | all?: boolean; |
9 | 12 | }; |
10 | 13 | |
| 14 | +/** Runs the fast status scan, resolves optional deep fields, and writes JSON through the runtime. */ |
11 | 15 | export async function runStatusJsonCommand(params: { |
12 | 16 | opts: StatusJsonCommandOptions; |
13 | 17 | runtime: RuntimeEnv; |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Builds the stable JSON payload for `openclaw status --json`. |
| 2 | +// Optional deep fields are included only when their upstream probes actually ran. |
| 3 | + |
1 | 4 | import { resolveStatusUpdateChannelInfo } from "./status-all/format.js"; |
2 | 5 | import { |
3 | 6 | buildStatusGatewayJsonPayloadFromSurface, |
4 | 7 | type StatusOverviewSurface, |
5 | 8 | } from "./status-overview-surface.ts"; |
6 | 9 | |
| 10 | +/** Combines scan summary, overview surface, services, agents, diagnostics, and optional deep probes. */ |
7 | 11 | export function buildStatusJsonPayload(params: { |
8 | 12 | summary: Record<string, unknown>; |
9 | 13 | surface: StatusOverviewSurface; |
@@ -38,6 +42,7 @@ export function buildStatusJsonPayload(params: {
|
38 | 42 | ...(params.securityAudit ? { securityAudit: params.securityAudit } : {}), |
39 | 43 | ...(params.pluginCompatibility |
40 | 44 | ? { |
| 45 | +// Keep warnings grouped with a count so consumers can test compatibility status cheaply. |
41 | 46 | pluginCompatibility: { |
42 | 47 | count: params.pluginCompatibility.length, |
43 | 48 | warnings: params.pluginCompatibility, |
@@ -46,6 +51,7 @@ export function buildStatusJsonPayload(params: {
|
46 | 51 | : {}), |
47 | 52 | ...(params.health || params.usage || params.lastHeartbeat |
48 | 53 | ? { |
| 54 | +// Deep/usage fields stay absent in fast mode instead of appearing as null placeholders. |
49 | 55 | health: params.health, |
50 | 56 | usage: params.usage, |
51 | 57 | lastHeartbeat: params.lastHeartbeat, |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Resolves runtime-only inputs for status JSON after the fast scan completes. |
| 2 | +// Keeps gateway health, usage, security audit, and service summaries behind explicit option gates. |
| 3 | + |
1 | 4 | import type { OpenClawConfig } from "../config/types.js"; |
2 | 5 | import type { UpdateCheckResult } from "../infra/update-check.js"; |
3 | 6 | import { buildStatusJsonPayload } from "./status-json-payload.ts"; |
@@ -48,6 +51,7 @@ type StatusJsonScanLike = {
|
48 | 51 | pluginCompatibility?: Array<Record<string, unknown>> | null | undefined; |
49 | 52 | }; |
50 | 53 | |
| 54 | +/** Builds the status JSON object from a completed scan plus optional runtime/deep probes. */ |
51 | 55 | export async function resolveStatusJsonOutput(params: { |
52 | 56 | scan: StatusJsonScanLike; |
53 | 57 | opts: { |
@@ -75,6 +79,7 @@ export async function resolveStatusJsonOutput(params: {
|
75 | 79 | return buildStatusJsonPayload({ |
76 | 80 | summary: scan.summary, |
77 | 81 | surface: buildStatusOverviewSurfaceFromScan({ |
| 82 | +// The scan shape is intentionally narrower than the surface helper's full scan type. |
78 | 83 | scan: scan as never, |
79 | 84 | gatewayService, |
80 | 85 | nodeService, |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Thin `openclaw status --json` wrapper. |
| 2 | +// Command wiring lives here; scan/payload behavior lives in the shared JSON command runner. |
| 3 | + |
1 | 4 | import type { RuntimeEnv } from "../runtime.js"; |
2 | 5 | import { runStatusJsonCommand } from "./status-json-command.ts"; |
3 | 6 | import { scanStatusJsonFast } from "./status.scan.fast-json.js"; |
4 | 7 | |
| 8 | +/** Runs status JSON with the standard fast scan and all-mode security audit behavior. */ |
5 | 9 | export async function statusJsonCommand( |
6 | 10 | opts: { |
7 | 11 | deep?: boolean; |
@@ -15,6 +19,7 @@ export async function statusJsonCommand(
|
15 | 19 | opts, |
16 | 20 | runtime, |
17 | 21 | scanStatusJsonFast, |
| 22 | +// `--all` is the opt-in path for heavier security audit fields in JSON output. |
18 | 23 | includeSecurityAudit: opts.all === true, |
19 | 24 | suppressHealthErrors: true, |
20 | 25 | }); |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。