fix: adding skills config and updating the plugin the config (#4958)

This commit is contained in:
Kartik
2026-04-29 22:19:40 +05:30
committed by GitHub
parent 594b4e65d6
commit ebb9bb2b15
20 changed files with 585 additions and 176 deletions
+55 -11
View File
@@ -54,15 +54,12 @@ import {
import { PlatformBackend } from "./backend/platform.ts";
import type { Backend } from "./backend/base.ts";
import { registerCliCommands } from "./cli/commands.ts";
import { readPluginAuth, ensureInstallRecord } from "./cli/config-file.ts";
import { readPluginAuth } from "./cli/config-file.ts";
import { registerAllTools } from "./tools/index.ts";
import type { ToolDeps } from "./tools/index.ts";
import { captureEvent } from "./telemetry.ts";
import { bootstrapTelemetryFlag } from "./fs-safe.ts";
bootstrapTelemetryFlag();
ensureInstallRecord();
// ============================================================================
// Re-exports (for tests and external consumers)
// ============================================================================
@@ -100,6 +97,8 @@ const memoryPlugin = definePluginEntry({
description: "Mem0 memory backend — Mem0 platform or self-hosted open-source",
register(api: OpenClawPluginApi) {
bootstrapTelemetryFlag();
// Read auth from openclaw.json plugin config (picks up post-startup login).
// This is the single source of truth — set via `openclaw mem0 login`.
const pluginAuth = readPluginAuth();
@@ -207,8 +206,57 @@ const memoryPlugin = definePluginEntry({
},
effectiveUserId: _effectiveUserId,
}),
runtime: {
async getMemorySearchManager(_params: any) {
try {
const userId = _effectiveUserId();
let memoryCount = 0;
try {
const memories = await provider.getAll({
user_id: userId,
page_size: 1,
source: "OPENCLAW",
});
memoryCount = Array.isArray(memories) ? memories.length : 0;
} catch {
// Non-fatal: status still works without count
}
return {
manager: {
status() {
return {
backend: cfg.mode,
files: 0,
chunks: memoryCount,
dirty: false,
workspaceDir: pluginStateDir ?? "",
userId,
};
},
async probeEmbeddingAvailability() {
return { ok: true };
},
async close() {},
},
};
} catch (err) {
return {
manager: null,
error: `mem0 ${cfg.mode} backend unavailable: ${String(err)}`,
};
}
},
resolveMemoryBackendConfig(_params: any) {
return {
backend: cfg.mode,
baseUrl: cfg.baseUrl ?? "https://api.mem0.ai",
userId: cfg.userId,
};
},
async closeAllMemorySearchManagers() {},
},
});
api.logger.debug("openclaw-mem0: publicArtifacts capability registered");
api.logger.debug("openclaw-mem0: memory capability + runtime registered");
}
// Helper: build add options
@@ -681,12 +729,8 @@ function registerHooks(
),
);
// Client-side threshold filter for auto-recall — use a stricter
// threshold (0.6) than explicit tool searches (0.5) to avoid
// injecting irrelevant memories into agent context
const recallThreshold = Math.max(cfg.searchThreshold, 0.6);
longTermResults = longTermResults.filter(
(r) => (r.score ?? 0) >= recallThreshold,
(r) => (r.score ?? 0) >= cfg.searchThreshold,
);
// Dynamic thresholding: drop memories scoring less than 50% of
@@ -709,7 +753,7 @@ function registerHooks(
undefined,
recallSessionKey,
);
broadOpts.threshold = 0.5;
broadOpts.threshold = cfg.searchThreshold;
const broadResults = await provider.search(
"recent decisions, preferences, active projects, and configuration",
broadOpts,