Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1577,6 +1577,8 @@ const pluginVersion = getPluginVersion();
// Plugin Definition
// ============================================================================

let _initialized = false;

const memoryLanceDBProPlugin = {
id: "memory-lancedb-pro",
name: "Memory (LanceDB Pro)",
Expand All @@ -1585,6 +1587,14 @@ const memoryLanceDBProPlugin = {
kind: "memory" as const,

register(api: OpenClawPluginApi) {

// Idempotent guard: skip re-init on repeated register() calls
if (_initialized) {
api.logger.debug("memory-lancedb-pro: register() called again — skipping re-init (idempotent)");
return;
}
_initialized = true;

// Parse and validate configuration
const config = parsePluginConfig(api.pluginConfig);

Expand Down Expand Up @@ -2323,10 +2333,12 @@ const memoryLanceDBProPlugin = {
const meta = parseSmartMetadata(r.entry.metadata, r.entry);
if (meta.state !== "confirmed") {
stateFilteredCount++;
api.logger.debug(`memory-lancedb-pro: governance: filtered id=${r.entry.id} reason=state(${meta.state}) score=${r.score?.toFixed(3)} text=${r.entry.text.slice(0, 50)}`);
return false;
}
if (meta.memory_layer === "archive" || meta.memory_layer === "reflection") {
stateFilteredCount++;
api.logger.debug(`memory-lancedb-pro: governance: filtered id=${r.entry.id} reason=layer(${meta.memory_layer}) score=${r.score?.toFixed(3)} text=${r.entry.text.slice(0, 50)}`);
return false;
}
if (meta.suppressed_until_turn > 0 && currentTurn <= meta.suppressed_until_turn) {
Expand Down Expand Up @@ -3904,4 +3916,6 @@ export function parsePluginConfig(value: unknown): PluginConfig {
};
}

export function _resetInitialized() { _initialized = false; }

export default memoryLanceDBProPlugin;