22import fs from "node:fs/promises" ;
33import path from "node:path" ;
44import { filterMemorySearchHitsBySessionVisibility } from "@openclaw/memory-core/api.js" ;
5+ import { runTasksWithConcurrency } from "openclaw/plugin-sdk/concurrency-runtime" ;
56import type { MemorySearchResult } from "openclaw/plugin-sdk/memory-core-host-runtime-files" ;
67import { resolveDefaultAgentId , resolveSessionAgentId } from "openclaw/plugin-sdk/memory-host-core" ;
78import { getActiveMemorySearchManager } from "openclaw/plugin-sdk/memory-host-search" ;
@@ -10,7 +11,6 @@ import {
1011 normalizeLowercaseStringOrEmpty ,
1112 uniqueStrings ,
1213} from "openclaw/plugin-sdk/string-coerce-runtime" ;
13- import pMap , { pMapSkip } from "p-map" ;
1414import type { OpenClawConfig } from "../api.js" ;
1515import { walkMemoryWikiDirectory } from "./bounded-walk.js" ;
1616import { assessClaimFreshness , isClaimContestedStatus } from "./claim-health.js" ;
@@ -230,16 +230,18 @@ async function readQueryableWikiPagesByPaths(
230230 rootDir : string ,
231231 files : string [ ] ,
232232) : Promise < QueryableWikiPage [ ] > {
233- return await pMap (
234- files ,
235- async ( relativePath ) => {
233+ const { results } = await runTasksWithConcurrency ( {
234+ tasks : files . map ( ( relativePath ) => async ( ) => {
236235 const absolutePath = path . join ( rootDir , relativePath ) ;
237236 const raw = await fs . readFile ( absolutePath , "utf8" ) ;
238237 const summary = toWikiPageSummary ( { absolutePath, relativePath, raw } ) ;
239- return summary ? { ...summary , raw } : pMapSkip ;
240- } ,
241- { concurrency : QUERY_PAGE_READ_CONCURRENCY , stopOnError : true } ,
242- ) ;
238+ return summary ? { ...summary , raw } : null ;
239+ } ) ,
240+ limit : QUERY_PAGE_READ_CONCURRENCY ,
241+ errorMode : "stop" ,
242+ throwOnError : true ,
243+ } ) ;
244+ return results . filter ( ( page ) : page is QueryableWikiPage => page !== null ) ;
243245}
244246
245247async function readQueryDigestBundle (
0 commit comments