fix: probe memory vector availability
This commit is contained in:
@@ -42,6 +42,7 @@ export function registerMemoryCli(program: Command) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await manager.probeVectorAvailability();
|
||||
const status = manager.status();
|
||||
if (opts.json) {
|
||||
defaultRuntime.log(JSON.stringify(status, null, 2));
|
||||
|
||||
@@ -86,6 +86,32 @@ describe("memory index", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("reports vector availability after probe", async () => {
|
||||
const cfg = {
|
||||
agents: {
|
||||
defaults: {
|
||||
workspace: workspaceDir,
|
||||
memorySearch: {
|
||||
provider: "openai",
|
||||
model: "mock-embed",
|
||||
store: { path: indexPath },
|
||||
sync: { watch: false, onSessionStart: false, onSearch: false },
|
||||
},
|
||||
},
|
||||
list: [{ id: "main", default: true }],
|
||||
},
|
||||
};
|
||||
const result = await getMemorySearchManager({ cfg, agentId: "main" });
|
||||
expect(result.manager).not.toBeNull();
|
||||
if (!result.manager) throw new Error("manager missing");
|
||||
manager = result.manager;
|
||||
const available = await result.manager.probeVectorAvailability();
|
||||
const status = result.manager.status();
|
||||
expect(status.vector?.enabled).toBe(true);
|
||||
expect(typeof status.vector?.available).toBe("boolean");
|
||||
expect(status.vector?.available).toBe(available);
|
||||
});
|
||||
|
||||
it("rejects reading non-memory paths", async () => {
|
||||
const cfg = {
|
||||
agents: {
|
||||
|
||||
@@ -369,6 +369,11 @@ export class MemoryIndexManager {
|
||||
};
|
||||
}
|
||||
|
||||
async probeVectorAvailability(): Promise<boolean> {
|
||||
if (!this.vector.enabled) return false;
|
||||
return this.ensureVectorReady();
|
||||
}
|
||||
|
||||
async close(): Promise<void> {
|
||||
if (this.closed) return;
|
||||
this.closed = true;
|
||||
|
||||
Reference in New Issue
Block a user