// SPEC: PJ2026-01060508 Web哨兵 draft-2026-07-12-p17-monitor-central-persistence.
// Responsibility: Synchronous CLI adapter for the canonical bounded terminal ingest client.
import { structuredMonitorCentralError } from "./src/monitor-central-persistence";
import { submitMonitorTerminalIngest, type MonitorTerminalIngestConfig } from "./src/monitor-terminal-ingest";

try {
  const input = JSON.parse(await Bun.stdin.text()) as { config: MonitorTerminalIngestConfig; ingest: Parameters<typeof submitMonitorTerminalIngest>[1] };
  const result = await submitMonitorTerminalIngest(input.config, input.ingest);
  console.log(JSON.stringify({ ok: true, ...result, valuesRedacted: true }));
} catch (error) {
  console.log(JSON.stringify({ ok: false, error: structuredMonitorCentralError(error), valuesRedacted: true }));
  process.exitCode = 2;
}
