Skip to content
Open
Show file tree
Hide file tree
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
22 changes: 22 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6128,6 +6128,28 @@ const memoryLanceDBProPlugin = {
// Fire-and-forget: allow gateway to start serving immediately.
setTimeout(() => void runStartupChecks(), 0);

// Canonical corpus: nothing else invokes canonicalCorpusIndexer.sync().
// Its only call sites are inside the memory capability (search()/sync()),
// which the host reaches via getActiveMemorySearchManager — but agent
// searches resolve to this plugin's own memory_search/memory_get tools
// and bypass the capability, so with canonicalCorpus.enabled the index
// silently stayed empty. Kick one sync at service start; sync() checks
// canonicalCorpus.enabled itself, rate-limits via syncIntervalMs, and
// de-duplicates concurrent runs, so this is safe and cheap when current.
setTimeout(() => void (async () => {
try {
const corpusStats = await canonicalCorpusIndexer.sync({ reason: "startup" });
api.logger.info(
`memory-lancedb-pro: canonical corpus startup sync — indexed ${corpusStats.indexed}/${corpusStats.chunks} chunk(s) ` +
`from ${corpusStats.documents} document(s); ${corpusStats.staleDeleted} stale removed`,
);
} catch (err) {
api.logger.warn(
`memory-lancedb-pro: canonical corpus startup sync failed: ${err instanceof Error ? err.message : String(err)}`,
);
}
})(), 0);

// Check for legacy memories that could be upgraded
setTimeout(async () => {
try {
Expand Down
3 changes: 0 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions src/corpus-indexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,18 @@ export function resolveCanonicalCorpusWorkspaces(cfg: unknown, homeDir = homedir
add(entry.workspace ?? entry.workspaceDir ?? entry.cwd, entry.id);
}

// OpenClaw stores agents as an object keyed by agent id under `agents.entries`
// (not an array under `agents.list`). Without this, the loop above matches
// nothing on current OpenClaw configs and the function silently falls back to
// the single default workspace, so per-agent workspaces are never indexed.
const entries = isRecord(agents?.entries) ? agents.entries : undefined;
if (entries) {
for (const [entryAgentId, entry] of Object.entries(entries)) {
if (!isRecord(entry)) continue;
add(entry.workspace ?? entry.workspaceDir ?? entry.cwd, entryAgentId);
}
}

const defaults = isRecord(agents?.defaults) ? agents.defaults : undefined;
add(defaults?.workspace ?? defaults?.workspaceDir ?? defaults?.cwd, "main");

Expand Down