555e282cc4
pi-agent-plugin checks / lint (push) Has been cancelled
pi-agent-plugin checks / test (20) (push) Has been cancelled
pi-agent-plugin checks / test (22) (push) Has been cancelled
pi-agent-plugin checks / build (push) Has been cancelled
TypeScript SDK CI / check_changes (push) Has been cancelled
TypeScript SDK CI / changelog_check (push) Has been cancelled
ci / changelog_check (push) Has been cancelled
ci / check_changes (push) Has been cancelled
ci / build_mem0 (3.10) (push) Has been cancelled
ci / build_mem0 (3.11) (push) Has been cancelled
ci / build_mem0 (3.12) (push) Has been cancelled
CLI Node CI / lint (push) Has been cancelled
CLI Node CI / test (20) (push) Has been cancelled
CLI Node CI / test (22) (push) Has been cancelled
CLI Node CI / build (push) Has been cancelled
CLI Python CI / lint (push) Has been cancelled
CLI Python CI / test (3.10) (push) Has been cancelled
CLI Python CI / test (3.11) (push) Has been cancelled
CLI Python CI / test (3.12) (push) Has been cancelled
CLI Python CI / build (push) Has been cancelled
openclaw checks / lint (push) Has been cancelled
openclaw checks / test (20) (push) Has been cancelled
openclaw checks / test (22) (push) Has been cancelled
openclaw checks / build (push) Has been cancelled
opencode-plugin checks / build (push) Has been cancelled
TypeScript SDK CI / build_ts_sdk (20) (push) Has been cancelled
TypeScript SDK CI / build_ts_sdk (22) (push) Has been cancelled
TypeScript SDK CI / integration_ts_sdk (20) (push) Has been cancelled
TypeScript SDK CI / integration_ts_sdk (22) (push) Has been cancelled
61 lines
2.4 KiB
TypeScript
61 lines
2.4 KiB
TypeScript
import { Type } from "@sinclair/typebox";
|
|
import type { ToolDeps } from "./index.ts";
|
|
|
|
export function createMemoryEventListTool(deps: ToolDeps) {
|
|
return {
|
|
name: "memory_event_list",
|
|
label: "Memory Event List",
|
|
description:
|
|
"List recent background processing events from the Mem0 Platform. Use to check whether memory operations (add, update, delete) were processed successfully.",
|
|
parameters: Type.Object({}),
|
|
|
|
async execute(_toolCallId: string, _params: Record<string, unknown>) {
|
|
const start = Date.now();
|
|
try {
|
|
if (!deps.backend) {
|
|
deps.captureToolEvent("memory_event_list", { success: false, latency_ms: 0, error: "not_platform" });
|
|
return {
|
|
content: [{ type: "text", text: "Event tracking is only available in platform mode." }],
|
|
details: { error: "not_platform" },
|
|
};
|
|
}
|
|
|
|
const results = await deps.backend.listEvents();
|
|
if (!results.length) {
|
|
deps.captureToolEvent("memory_event_list", { success: true, latency_ms: Date.now() - start, count: 0 });
|
|
return {
|
|
content: [{ type: "text", text: "No events found." }],
|
|
details: { count: 0 },
|
|
};
|
|
}
|
|
|
|
const rows = results.map((ev) => {
|
|
const evId = String(ev.id ?? "");
|
|
const evType = String(ev.event_type ?? "—");
|
|
const status = String(ev.status ?? "—");
|
|
const latency =
|
|
typeof ev.latency === "number" ? `${Math.round(ev.latency as number)}ms` : "—";
|
|
const created = String(ev.created_at ?? "—").slice(0, 19).replace("T", " ");
|
|
return { id: evId, type: evType, status, latency, created };
|
|
});
|
|
|
|
const text = rows
|
|
.map((r) => `- ${r.id} | ${r.type} | ${r.status} | ${r.latency} | ${r.created}`)
|
|
.join("\n");
|
|
|
|
deps.captureToolEvent("memory_event_list", { success: true, latency_ms: Date.now() - start, count: results.length });
|
|
return {
|
|
content: [{ type: "text", text: `${results.length} event(s):\n${text}` }],
|
|
details: { count: results.length, events: rows },
|
|
};
|
|
} catch (err) {
|
|
deps.captureToolEvent("memory_event_list", { success: false, latency_ms: Date.now() - start, error: String(err) });
|
|
return {
|
|
content: [{ type: "text", text: `Failed to list events: ${String(err)}` }],
|
|
details: { error: String(err) },
|
|
};
|
|
}
|
|
},
|
|
};
|
|
}
|