chore(integrations): plugin updates, pi-agent auto-recall, and version bumps (#6011)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
|
||||
import { resolveUserId } from "./entry.ts";
|
||||
import { resolveUserId, buildRecallContext } from "./entry.ts";
|
||||
|
||||
describe("resolveUserId", () => {
|
||||
const originalEnv = { ...process.env };
|
||||
@@ -32,3 +32,34 @@ describe("resolveUserId", () => {
|
||||
expect(result.length).toBeGreaterThan(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe("buildRecallContext", () => {
|
||||
const search = async () => ({
|
||||
results: [{ id: "m1", memory: "User prefers pnpm over npm", categories: ["preferences"] }],
|
||||
});
|
||||
|
||||
it("returns empty when disabled", async () => {
|
||||
expect(await buildRecallContext("which pm?", false, search)).toBe("");
|
||||
});
|
||||
|
||||
it("returns empty for a blank prompt", async () => {
|
||||
expect(await buildRecallContext(" ", true, search)).toBe("");
|
||||
});
|
||||
|
||||
it("returns empty when no memories match", async () => {
|
||||
expect(await buildRecallContext("hi", true, async () => ({ results: [] }))).toBe("");
|
||||
});
|
||||
|
||||
it("injects recalled memory text when enabled and matches exist", async () => {
|
||||
const out = await buildRecallContext("which pm?", true, search);
|
||||
expect(out).toContain("User prefers pnpm over npm");
|
||||
expect(out).toContain("mem0-relevant-memories");
|
||||
});
|
||||
|
||||
it("swallows search errors so the turn is never blocked", async () => {
|
||||
const out = await buildRecallContext("hi", true, async () => {
|
||||
throw new Error("boom");
|
||||
});
|
||||
expect(out).toBe("");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user