Give Eve agents a first-class Mem0 recall/capture provider so they can use Mem0 in the agent loop instead of MCP. Co-authored-by: Cursor <cursoragent@cursor.com>
33 lines
814 B
TypeScript
33 lines
814 B
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { createIdempotencyGate } from "../src/idempotency.js";
|
|
|
|
describe("createIdempotencyGate", () => {
|
|
it("runs work once per operation id", async () => {
|
|
const once = createIdempotencyGate();
|
|
let calls = 0;
|
|
const work = async () => {
|
|
calls += 1;
|
|
};
|
|
|
|
await Promise.all([once("op_1", work), once("op_1", work)]);
|
|
await once("op_1", work);
|
|
|
|
expect(calls).toBe(1);
|
|
});
|
|
|
|
it("retries after a failure", async () => {
|
|
const once = createIdempotencyGate();
|
|
let calls = 0;
|
|
const work = async () => {
|
|
calls += 1;
|
|
if (calls === 1) {
|
|
throw new Error("nope");
|
|
}
|
|
};
|
|
|
|
await expect(once("op_1", work)).rejects.toThrow("nope");
|
|
await once("op_1", work);
|
|
expect(calls).toBe(2);
|
|
});
|
|
});
|