mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 09:50:42 +00:00
refactor: share status memory resolver types
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import { formatCliCommand } from "../cli/command-format.js";
|
||||
import type { HeartbeatEventPayload } from "../infra/heartbeat-events.js";
|
||||
import type { Tone } from "../memory-host-sdk/status.js";
|
||||
import type { PluginCompatibilityNotice } from "../plugins/status.js";
|
||||
import { VERSION } from "../version.js";
|
||||
import type { HealthSummary } from "./health.js";
|
||||
@@ -23,47 +22,38 @@ import {
|
||||
buildStatusLastHeartbeatValue,
|
||||
buildStatusMemoryValue,
|
||||
buildStatusTasksValue,
|
||||
type StatusMemoryStateResolvers,
|
||||
} from "./status.command-sections.js";
|
||||
import type { MemoryPluginStatus, MemoryStatusSnapshot } from "./status.scan.shared.js";
|
||||
import type { StatusSummary } from "./status.types.js";
|
||||
|
||||
export function buildStatusCommandOverviewRows(params: {
|
||||
opts: {
|
||||
deep?: boolean;
|
||||
};
|
||||
surface: StatusOverviewSurface;
|
||||
osLabel: string;
|
||||
summary: StatusSummary;
|
||||
health?: HealthSummary;
|
||||
lastHeartbeat: HeartbeatEventPayload | null;
|
||||
agentStatus: {
|
||||
defaultId?: string | null;
|
||||
bootstrapPendingCount: number;
|
||||
totalSessions: number;
|
||||
agents: AgentLocalStatus[];
|
||||
};
|
||||
memory: MemoryStatusSnapshot | null;
|
||||
memoryPlugin: MemoryPluginStatus;
|
||||
pluginCompatibility: PluginCompatibilityNotice[];
|
||||
ok: (value: string) => string;
|
||||
warn: (value: string) => string;
|
||||
muted: (value: string) => string;
|
||||
formatTimeAgo: (ageMs: number) => string;
|
||||
formatKTokens: (value: number) => string;
|
||||
resolveMemoryVectorState: (value: NonNullable<MemoryStatusSnapshot["vector"]>) => {
|
||||
state: string;
|
||||
tone: Tone;
|
||||
};
|
||||
resolveMemoryFtsState: (value: NonNullable<MemoryStatusSnapshot["fts"]>) => {
|
||||
state: string;
|
||||
tone: Tone;
|
||||
};
|
||||
resolveMemoryCacheSummary: (value: NonNullable<MemoryStatusSnapshot["cache"]>) => {
|
||||
text: string;
|
||||
tone: Tone;
|
||||
};
|
||||
updateValue?: string;
|
||||
}) {
|
||||
export function buildStatusCommandOverviewRows(
|
||||
params: {
|
||||
opts: {
|
||||
deep?: boolean;
|
||||
};
|
||||
surface: StatusOverviewSurface;
|
||||
osLabel: string;
|
||||
summary: StatusSummary;
|
||||
health?: HealthSummary;
|
||||
lastHeartbeat: HeartbeatEventPayload | null;
|
||||
agentStatus: {
|
||||
defaultId?: string | null;
|
||||
bootstrapPendingCount: number;
|
||||
totalSessions: number;
|
||||
agents: AgentLocalStatus[];
|
||||
};
|
||||
memory: MemoryStatusSnapshot | null;
|
||||
memoryPlugin: MemoryPluginStatus;
|
||||
pluginCompatibility: PluginCompatibilityNotice[];
|
||||
ok: (value: string) => string;
|
||||
warn: (value: string) => string;
|
||||
muted: (value: string) => string;
|
||||
formatTimeAgo: (ageMs: number) => string;
|
||||
formatKTokens: (value: number) => string;
|
||||
updateValue?: string;
|
||||
} & StatusMemoryStateResolvers,
|
||||
) {
|
||||
const agentsValue = buildStatusAgentsValue({
|
||||
agentStatus: params.agentStatus,
|
||||
formatTimeAgo: params.formatTimeAgo,
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import type { HeartbeatEventPayload } from "../infra/heartbeat-events.js";
|
||||
import type { resolveOsSummary } from "../infra/os-summary.js";
|
||||
import type { Tone } from "../memory-host-sdk/status.js";
|
||||
import type { PluginCompatibilityNotice } from "../plugins/status.js";
|
||||
import type { SecurityAuditReport } from "../security/audit.js";
|
||||
import type { RenderTableOptions, TableColumn } from "../terminal/table.js";
|
||||
@@ -22,80 +21,71 @@ import {
|
||||
buildStatusSystemEventsRows,
|
||||
buildStatusSystemEventsTrailer,
|
||||
statusHealthColumns,
|
||||
type StatusMemoryStateResolvers,
|
||||
} from "./status.command-sections.js";
|
||||
import type { MemoryPluginStatus, MemoryStatusSnapshot } from "./status.scan.shared.js";
|
||||
import type { SessionStatus, StatusSummary } from "./status.types.js";
|
||||
|
||||
export async function buildStatusCommandReportData(params: {
|
||||
opts: {
|
||||
deep?: boolean;
|
||||
verbose?: boolean;
|
||||
};
|
||||
surface: StatusOverviewSurface;
|
||||
osSummary: ReturnType<typeof resolveOsSummary>;
|
||||
summary: StatusSummary;
|
||||
securityAudit?: SecurityAuditReport;
|
||||
health?: HealthSummary;
|
||||
usageLines?: string[];
|
||||
lastHeartbeat: HeartbeatEventPayload | null;
|
||||
agentStatus: {
|
||||
defaultId?: string | null;
|
||||
bootstrapPendingCount: number;
|
||||
totalSessions: number;
|
||||
agents: AgentLocalStatus[];
|
||||
};
|
||||
channels: {
|
||||
rows: Array<{
|
||||
id: string;
|
||||
label: string;
|
||||
enabled: boolean;
|
||||
state: "ok" | "warn" | "off" | "setup";
|
||||
detail: string;
|
||||
export async function buildStatusCommandReportData(
|
||||
params: {
|
||||
opts: {
|
||||
deep?: boolean;
|
||||
verbose?: boolean;
|
||||
};
|
||||
surface: StatusOverviewSurface;
|
||||
osSummary: ReturnType<typeof resolveOsSummary>;
|
||||
summary: StatusSummary;
|
||||
securityAudit?: SecurityAuditReport;
|
||||
health?: HealthSummary;
|
||||
usageLines?: string[];
|
||||
lastHeartbeat: HeartbeatEventPayload | null;
|
||||
agentStatus: {
|
||||
defaultId?: string | null;
|
||||
bootstrapPendingCount: number;
|
||||
totalSessions: number;
|
||||
agents: AgentLocalStatus[];
|
||||
};
|
||||
channels: {
|
||||
rows: Array<{
|
||||
id: string;
|
||||
label: string;
|
||||
enabled: boolean;
|
||||
state: "ok" | "warn" | "off" | "setup";
|
||||
detail: string;
|
||||
}>;
|
||||
};
|
||||
channelIssues: Array<{
|
||||
channel: string;
|
||||
message: string;
|
||||
}>;
|
||||
};
|
||||
channelIssues: Array<{
|
||||
channel: string;
|
||||
message: string;
|
||||
}>;
|
||||
memory: MemoryStatusSnapshot | null;
|
||||
memoryPlugin: MemoryPluginStatus;
|
||||
pluginCompatibility: PluginCompatibilityNotice[];
|
||||
pairingRecovery: { requestId: string | null } | null;
|
||||
tableWidth: number;
|
||||
ok: (value: string) => string;
|
||||
warn: (value: string) => string;
|
||||
muted: (value: string) => string;
|
||||
shortenText: (value: string, maxLen: number) => string;
|
||||
formatCliCommand: (value: string) => string;
|
||||
formatTimeAgo: (ageMs: number) => string;
|
||||
formatKTokens: (value: number) => string;
|
||||
formatTokensCompact: (value: SessionStatus) => string;
|
||||
formatPromptCacheCompact: (value: SessionStatus) => string | null;
|
||||
formatHealthChannelLines: (summary: HealthSummary, opts: { accountMode: "all" }) => string[];
|
||||
formatPluginCompatibilityNotice: (notice: PluginCompatibilityNotice) => string;
|
||||
formatUpdateAvailableHint: (update: StatusOverviewSurface["update"]) => string | null;
|
||||
resolveMemoryVectorState: (value: NonNullable<MemoryStatusSnapshot["vector"]>) => {
|
||||
state: string;
|
||||
tone: Tone;
|
||||
};
|
||||
resolveMemoryFtsState: (value: NonNullable<MemoryStatusSnapshot["fts"]>) => {
|
||||
state: string;
|
||||
tone: Tone;
|
||||
};
|
||||
resolveMemoryCacheSummary: (value: NonNullable<MemoryStatusSnapshot["cache"]>) => {
|
||||
text: string;
|
||||
tone: Tone;
|
||||
};
|
||||
accentDim: (value: string) => string;
|
||||
updateValue?: string;
|
||||
theme: {
|
||||
heading: (value: string) => string;
|
||||
muted: (value: string) => string;
|
||||
memory: MemoryStatusSnapshot | null;
|
||||
memoryPlugin: MemoryPluginStatus;
|
||||
pluginCompatibility: PluginCompatibilityNotice[];
|
||||
pairingRecovery: { requestId: string | null } | null;
|
||||
tableWidth: number;
|
||||
ok: (value: string) => string;
|
||||
warn: (value: string) => string;
|
||||
error: (value: string) => string;
|
||||
};
|
||||
renderTable: (input: RenderTableOptions) => string;
|
||||
}) {
|
||||
muted: (value: string) => string;
|
||||
shortenText: (value: string, maxLen: number) => string;
|
||||
formatCliCommand: (value: string) => string;
|
||||
formatTimeAgo: (ageMs: number) => string;
|
||||
formatKTokens: (value: number) => string;
|
||||
formatTokensCompact: (value: SessionStatus) => string;
|
||||
formatPromptCacheCompact: (value: SessionStatus) => string | null;
|
||||
formatHealthChannelLines: (summary: HealthSummary, opts: { accountMode: "all" }) => string[];
|
||||
formatPluginCompatibilityNotice: (notice: PluginCompatibilityNotice) => string;
|
||||
formatUpdateAvailableHint: (update: StatusOverviewSurface["update"]) => string | null;
|
||||
accentDim: (value: string) => string;
|
||||
updateValue?: string;
|
||||
theme: {
|
||||
heading: (value: string) => string;
|
||||
muted: (value: string) => string;
|
||||
warn: (value: string) => string;
|
||||
error: (value: string) => string;
|
||||
};
|
||||
renderTable: (input: RenderTableOptions) => string;
|
||||
} & StatusMemoryStateResolvers,
|
||||
) {
|
||||
const overviewRows = buildStatusCommandOverviewRows({
|
||||
opts: params.opts,
|
||||
surface: params.surface,
|
||||
|
||||
@@ -19,6 +19,21 @@ type MemoryLike = MemoryStatusSnapshot | null;
|
||||
type MemoryPluginLike = MemoryPluginStatus;
|
||||
type SessionsRecentLike = SessionStatus;
|
||||
|
||||
export type StatusMemoryStateResolvers = {
|
||||
resolveMemoryVectorState: (value: NonNullable<MemoryStatusSnapshot["vector"]>) => {
|
||||
state: string;
|
||||
tone: Tone;
|
||||
};
|
||||
resolveMemoryFtsState: (value: NonNullable<MemoryStatusSnapshot["fts"]>) => {
|
||||
state: string;
|
||||
tone: Tone;
|
||||
};
|
||||
resolveMemoryCacheSummary: (value: NonNullable<MemoryStatusSnapshot["cache"]>) => {
|
||||
text: string;
|
||||
tone: Tone;
|
||||
};
|
||||
};
|
||||
|
||||
type PluginCompatibilityNoticeLike = {
|
||||
severity?: "warn" | "info" | null;
|
||||
};
|
||||
@@ -115,25 +130,15 @@ export function buildStatusLastHeartbeatValue(params: {
|
||||
.join(" · ");
|
||||
}
|
||||
|
||||
export function buildStatusMemoryValue(params: {
|
||||
memory: MemoryLike;
|
||||
memoryPlugin: MemoryPluginLike;
|
||||
ok: (value: string) => string;
|
||||
warn: (value: string) => string;
|
||||
muted: (value: string) => string;
|
||||
resolveMemoryVectorState: (value: NonNullable<MemoryStatusSnapshot["vector"]>) => {
|
||||
state: string;
|
||||
tone: Tone;
|
||||
};
|
||||
resolveMemoryFtsState: (value: NonNullable<MemoryStatusSnapshot["fts"]>) => {
|
||||
state: string;
|
||||
tone: Tone;
|
||||
};
|
||||
resolveMemoryCacheSummary: (value: NonNullable<MemoryStatusSnapshot["cache"]>) => {
|
||||
text: string;
|
||||
tone: Tone;
|
||||
};
|
||||
}) {
|
||||
export function buildStatusMemoryValue(
|
||||
params: {
|
||||
memory: MemoryLike;
|
||||
memoryPlugin: MemoryPluginLike;
|
||||
ok: (value: string) => string;
|
||||
warn: (value: string) => string;
|
||||
muted: (value: string) => string;
|
||||
} & StatusMemoryStateResolvers,
|
||||
) {
|
||||
if (!params.memoryPlugin.enabled) {
|
||||
const suffix = params.memoryPlugin.reason ? ` (${params.memoryPlugin.reason})` : "";
|
||||
return params.muted(`disabled${suffix}`);
|
||||
|
||||
Reference in New Issue
Block a user