fix: adding login and fixing the plugin to follow the openclaw plugin standards (#4686)

This commit is contained in:
Kartik
2026-04-03 20:59:23 +05:30
committed by GitHub
parent 66230b3f1f
commit cfb3f58e4a
33 changed files with 5254 additions and 1376 deletions
+76
View File
@@ -0,0 +1,76 @@
/**
* Tool aggregator — single entry-point for registering all Mem0 tools.
*
* Re-exports the canonical `ToolContext` interface and provides
* `registerAllTools(ctx)` which wires up every tool in one call.
*/
import type { OpenClawPluginApi } from "openclaw/plugin-sdk";
import type { Backend } from "../backend/base.ts";
import type {
Mem0Config,
Mem0Provider,
AddOptions,
SearchOptions,
} from "../types.ts";
// ---------------------------------------------------------------------------
// Canonical ToolContext definition
// ---------------------------------------------------------------------------
export interface ToolContext {
api: OpenClawPluginApi;
backend: Backend;
cfg: Mem0Config;
provider?: Mem0Provider;
resolveUserId: (opts: { agentId?: string; userId?: string }) => string;
effectiveUserId: (sessionKey?: string) => string;
agentUserId: (id: string) => string;
getCurrentSessionId: () => string | undefined;
skillsActive: boolean;
buildAddOptions: (
userIdOverride?: string,
runId?: string,
sessionKey?: string,
) => AddOptions;
buildSearchOptions: (
userIdOverride?: string,
limit?: number,
runId?: string,
sessionKey?: string,
) => SearchOptions;
}
// ---------------------------------------------------------------------------
// Tool factory imports
// ---------------------------------------------------------------------------
import { createMemorySearchTool } from "./memory-search.ts";
import { createMemoryStoreTool } from "./memory-store.ts";
import { createMemoryGetTool } from "./memory-get.ts";
import { createMemoryListTool } from "./memory-list.ts";
import { createMemoryUpdateTool } from "./memory-update.ts";
import { createMemoryDeleteTool } from "./memory-delete.ts";
import { createMemoryHistoryTool } from "./memory-history.ts";
// ---------------------------------------------------------------------------
// Aggregator
// ---------------------------------------------------------------------------
/**
* Registers all Mem0 tools with the plugin API.
*
* 7 core tools for memory management:
* search, store, get, list, update, delete, history
*/
export function registerAllTools(ctx: ToolContext): void {
const { api } = ctx;
api.registerTool(createMemorySearchTool(ctx), { name: "memory_search" });
api.registerTool(createMemoryStoreTool(ctx), { name: "memory_store" });
api.registerTool(createMemoryGetTool(ctx), { name: "memory_get" });
api.registerTool(createMemoryListTool(ctx), { name: "memory_list" });
api.registerTool(createMemoryUpdateTool(ctx), { name: "memory_update" });
api.registerTool(createMemoryDeleteTool(ctx), { name: "memory_delete" });
api.registerTool(createMemoryHistoryTool(ctx), { name: "memory_history" });
}