refactor: align status with plugin memory slot
This commit is contained in:
@@ -65,6 +65,7 @@ export async function statusCommand(
|
||||
channels,
|
||||
summary,
|
||||
memory,
|
||||
memoryPlugin,
|
||||
} = scan;
|
||||
|
||||
const securityAudit = await withProgress(
|
||||
@@ -116,6 +117,7 @@ export async function statusCommand(
|
||||
os: osSummary,
|
||||
update,
|
||||
memory,
|
||||
memoryPlugin,
|
||||
gateway: {
|
||||
mode: gatewayMode,
|
||||
url: gatewayConnection.url,
|
||||
@@ -235,11 +237,19 @@ export async function statusCommand(
|
||||
: (summary.sessions.paths[0] ?? "unknown");
|
||||
|
||||
const memoryValue = (() => {
|
||||
if (!memory) return muted("disabled");
|
||||
if (!memoryPlugin.enabled) {
|
||||
const suffix = memoryPlugin.reason ? ` (${memoryPlugin.reason})` : "";
|
||||
return muted(`disabled${suffix}`);
|
||||
}
|
||||
if (!memory) {
|
||||
const slot = memoryPlugin.slot ? `plugin ${memoryPlugin.slot}` : "plugin";
|
||||
return muted(`enabled (${slot}) · unavailable`);
|
||||
}
|
||||
const parts: string[] = [];
|
||||
const dirtySuffix = memory.dirty ? ` · ${warn("dirty")}` : "";
|
||||
parts.push(`${memory.files} files · ${memory.chunks} chunks${dirtySuffix}`);
|
||||
if (memory.sources?.length) parts.push(`sources ${memory.sources.join(", ")}`);
|
||||
if (memoryPlugin.slot) parts.push(`plugin ${memoryPlugin.slot}`);
|
||||
const vector = memory.vector;
|
||||
parts.push(
|
||||
vector?.enabled === false
|
||||
|
||||
@@ -19,6 +19,22 @@ type MemoryStatusSnapshot = ReturnType<(typeof MemoryIndexManager)["prototype"][
|
||||
agentId: string;
|
||||
};
|
||||
|
||||
type MemoryPluginStatus = {
|
||||
enabled: boolean;
|
||||
slot: string | null;
|
||||
reason?: string;
|
||||
};
|
||||
|
||||
function resolveMemoryPluginStatus(cfg: ReturnType<typeof loadConfig>): MemoryPluginStatus {
|
||||
const pluginsEnabled = cfg.plugins?.enabled !== false;
|
||||
if (!pluginsEnabled) return { enabled: false, slot: null, reason: "plugins disabled" };
|
||||
const raw = typeof cfg.plugins?.slots?.memory === "string" ? cfg.plugins.slots.memory.trim() : "";
|
||||
if (raw && raw.toLowerCase() === "none") {
|
||||
return { enabled: false, slot: null, reason: 'plugins.slots.memory="none"' };
|
||||
}
|
||||
return { enabled: true, slot: raw || "memory-core" };
|
||||
}
|
||||
|
||||
export type StatusScanResult = {
|
||||
cfg: ReturnType<typeof loadConfig>;
|
||||
osSummary: ReturnType<typeof resolveOsSummary>;
|
||||
@@ -37,6 +53,7 @@ export type StatusScanResult = {
|
||||
channels: Awaited<ReturnType<typeof buildChannelsTable>>;
|
||||
summary: Awaited<ReturnType<typeof getStatusSummary>>;
|
||||
memory: MemoryStatusSnapshot | null;
|
||||
memoryPlugin: MemoryPluginStatus;
|
||||
};
|
||||
|
||||
export async function scanStatus(
|
||||
@@ -129,7 +146,10 @@ export async function scanStatus(
|
||||
progress.tick();
|
||||
|
||||
progress.setLabel("Checking memory…");
|
||||
const memoryPlugin = resolveMemoryPluginStatus(cfg);
|
||||
const memory = await (async (): Promise<MemoryStatusSnapshot | null> => {
|
||||
if (!memoryPlugin.enabled) return null;
|
||||
if (memoryPlugin.slot !== "memory-core") return null;
|
||||
const agentId = agentStatus.defaultId ?? "main";
|
||||
const manager = await MemoryIndexManager.get({ cfg, agentId }).catch(() => null);
|
||||
if (!manager) return null;
|
||||
@@ -167,6 +187,7 @@ export async function scanStatus(
|
||||
channels,
|
||||
summary,
|
||||
memory,
|
||||
memoryPlugin,
|
||||
};
|
||||
},
|
||||
);
|
||||
|
||||
@@ -261,6 +261,8 @@ describe("statusCommand", () => {
|
||||
const payload = JSON.parse((runtime.log as vi.Mock).mock.calls[0][0]);
|
||||
expect(payload.linkChannel.linked).toBe(true);
|
||||
expect(payload.memory.agentId).toBe("main");
|
||||
expect(payload.memoryPlugin.enabled).toBe(true);
|
||||
expect(payload.memoryPlugin.slot).toBe("memory-core");
|
||||
expect(payload.memory.vector.available).toBe(true);
|
||||
expect(payload.sessions.count).toBe(1);
|
||||
expect(payload.sessions.paths).toContain("/tmp/sessions.json");
|
||||
|
||||
Reference in New Issue
Block a user