feat: move web-probe to top-level cli (#933)
Co-authored-by: Codex <codex@noreply.local>
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
// SPEC: PJ2026-01040111 long-running Workbench observation.
|
||||
// SPEC: PJ2026-01060508 Web哨兵 draft-2026-06-25-p0-web-probe-sentinel.
|
||||
// Responsibility: CLI text rendering for hwlab nodes web-probe observe status/command/collect.
|
||||
// Responsibility: CLI text rendering for web-probe observe status/command/collect.
|
||||
import type { RenderedCliResult } from "./output";
|
||||
import { renderWebObserveWrapperContract } from "./hwlab-node-web-observe-wrapper-render";
|
||||
|
||||
export function withWebObserveStatusRendered(value: Record<string, unknown>): RenderedCliResult {
|
||||
return {
|
||||
ok: value.ok !== false,
|
||||
command: typeof value.command === "string" ? value.command : "hwlab nodes web-probe observe status",
|
||||
command: typeof value.command === "string" ? value.command : "web-probe observe status",
|
||||
contentType: "text/plain",
|
||||
renderedText: renderWebObserveStatusTable(value),
|
||||
};
|
||||
@@ -16,7 +16,7 @@ export function withWebObserveStatusRendered(value: Record<string, unknown>): Re
|
||||
export function withWebObserveCommandRendered(value: Record<string, unknown>): RenderedCliResult {
|
||||
return {
|
||||
ok: value.ok !== false,
|
||||
command: typeof value.command === "string" ? value.command : "hwlab nodes web-probe observe command",
|
||||
command: typeof value.command === "string" ? value.command : "web-probe observe command",
|
||||
contentType: "text/plain",
|
||||
renderedText: renderWebObserveCommandTable(value),
|
||||
};
|
||||
@@ -25,7 +25,7 @@ export function withWebObserveCommandRendered(value: Record<string, unknown>): R
|
||||
export function withWebObserveCollectRendered(value: Record<string, unknown>): RenderedCliResult {
|
||||
return {
|
||||
ok: value.ok !== false,
|
||||
command: typeof value.command === "string" ? value.command : "hwlab nodes web-probe observe collect",
|
||||
command: typeof value.command === "string" ? value.command : "web-probe observe collect",
|
||||
contentType: "text/plain",
|
||||
renderedText: renderWebObserveCollectTable(value),
|
||||
};
|
||||
@@ -63,7 +63,7 @@ function renderWebObserveStatusTable(value: Record<string, unknown>): string {
|
||||
const heartbeatStale = diagnostics?.heartbeatStale ?? heartbeat?.stale;
|
||||
const heartbeatLiveness = diagnostics?.effectiveLiveness ?? heartbeat?.effectiveLiveness;
|
||||
const lines = [
|
||||
`hwlab nodes web-probe observe status (${webObserveText(value.status)})`,
|
||||
`web-probe observe status (${webObserveText(value.status)})`,
|
||||
"",
|
||||
...renderWebObserveWrapperContract(value),
|
||||
webObserveTable(["ID", "NODE", "LANE", "LIVENESS", "ALIVE", "PID", "SAMPLE", "CMD_SEQ", "HB_AGE_S", "STALE", "UPDATED", "TARGET"], [[
|
||||
@@ -190,7 +190,7 @@ function renderWebObserveCommandTable(value: Record<string, unknown>): string {
|
||||
const id = webObserveText(value.id);
|
||||
const full = value.full === true;
|
||||
const lines = [
|
||||
`hwlab nodes web-probe observe command (${webObserveText(value.status)})`,
|
||||
`web-probe observe command (${webObserveText(value.status)})`,
|
||||
"",
|
||||
...renderWebObserveWrapperContract(value),
|
||||
webObserveTable(["OBSERVER", "COMMAND", "TYPE", "STATUS", "TEXT_BYTES", "TEXT_HASH", "DETAIL"], [[
|
||||
@@ -211,8 +211,8 @@ function renderWebObserveCommandTable(value: Record<string, unknown>): string {
|
||||
] : []),
|
||||
"",
|
||||
"Next:",
|
||||
` bun scripts/cli.ts hwlab nodes web-probe observe status ${id}`,
|
||||
` bun scripts/cli.ts hwlab nodes web-probe observe analyze ${id}`,
|
||||
` bun scripts/cli.ts web-probe observe status ${id}`,
|
||||
` bun scripts/cli.ts web-probe observe analyze ${id}`,
|
||||
"",
|
||||
"Disclosure:",
|
||||
" default view is a bounded command result; pass --full to expose the complete command result JSON.",
|
||||
@@ -225,7 +225,7 @@ function renderWebObserveCollectTable(value: Record<string, unknown>): string {
|
||||
const collect = nullableRecord(value.collect);
|
||||
if (typeof collect?.renderedText === "string") {
|
||||
return [
|
||||
`hwlab nodes web-probe observe collect (${webObserveText(value.status)})`,
|
||||
`web-probe observe collect (${webObserveText(value.status)})`,
|
||||
"",
|
||||
...renderWebObserveWrapperContract(value),
|
||||
collect.renderedText,
|
||||
@@ -261,7 +261,7 @@ function renderWebObserveCollectTable(value: Record<string, unknown>): string {
|
||||
const jsonFindingDetail = record(jsonSummary.findingDetail);
|
||||
const jsonFindingSamples = Array.isArray(jsonFindingDetail?.samples) ? jsonFindingDetail.samples.map(record).filter((item): item is Record<string, unknown> => item !== null).slice(0, 12) : [];
|
||||
const lines = [
|
||||
`hwlab nodes web-probe observe collect (${webObserveText(value.status)})`,
|
||||
`web-probe observe collect (${webObserveText(value.status)})`,
|
||||
"",
|
||||
...renderWebObserveWrapperContract(value),
|
||||
webObserveTable(["ID", "NODE", "LANE", "MODE", "STATE_DIR"], [[
|
||||
@@ -467,7 +467,7 @@ function renderWebObserveProjectCollectTable(value: Record<string, unknown>, col
|
||||
const launches = Array.isArray(collect.launches) ? collect.launches.map(record).filter((item): item is Record<string, unknown> => item !== null).slice(-4) : [];
|
||||
const findings = Array.isArray(collect.findings) ? collect.findings.map(record).filter((item): item is Record<string, unknown> => item !== null).slice(0, 6) : [];
|
||||
const lines = [
|
||||
`hwlab nodes web-probe observe collect (${webObserveText(value.status)})`,
|
||||
`web-probe observe collect (${webObserveText(value.status)})`,
|
||||
"",
|
||||
...renderWebObserveWrapperContract(value),
|
||||
webObserveTable(["ID", "NODE", "LANE", "VIEW", "STATE_DIR"], [[
|
||||
|
||||
Reference in New Issue
Block a user