{"record":{"id":"6c321926682e226d","repo":"TencentCloud/TencentDB-Agent-Memory","slug":"runembeddedpiagent-not-exported-from-dist-extensio","errorCode":null,"errorMessage":"runEmbeddedPiAgent not exported from dist/extensionAPI.js","messagePattern":"runEmbeddedPiAgent not exported from dist/extensionAPI\\.js","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"MemoryCore/src/utils/clean-context-runner.ts","lineNumber":146,"sourceCode":"    if (found) { _rootCache = found; return found; }\n  }\n  throw new Error(\"Unable to resolve OpenClaw root. Set OPENCLAW_ROOT or run `pnpm build`.\");\n}\n\nlet _loadPromise: Promise<RunEmbeddedPiAgentFn> | null = null;\n\nfunction loadRunEmbeddedPiAgent(logger?: RunnerLogger): Promise<RunEmbeddedPiAgentFn> {\n  if (_loadPromise) return _loadPromise;\n\n  _loadPromise = (async () => {\n    const t0 = Date.now();\n    const distPath = path.join(resolveOpenClawRoot(), \"dist\", \"extensionAPI.js\");\n    if (!fsSync.existsSync(distPath)) {\n      throw new Error(`Missing core module at ${distPath}. Run \\`pnpm build\\` or install the official package.`);\n    }\n    const mod = await import(pathToFileURL(distPath).href);\n    if (typeof mod.runEmbeddedPiAgent !== \"function\") {\n      throw new Error(\"runEmbeddedPiAgent not exported from dist/extensionAPI.js\");\n    }\n    logger?.info(`${TAG} loadRunEmbeddedPiAgent: dist/ import OK (${Date.now() - t0}ms)`);\n    return mod.runEmbeddedPiAgent as RunEmbeddedPiAgentFn;\n  })();\n\n  _loadPromise.catch(() => { _loadPromise = null; });\n  return _loadPromise;\n}\n\n/**\n * Pre-warm the embedded agent import. Call this during plugin init to avoid\n * the cold-start penalty on the first actual extraction run.\n * Returns immediately (fire-and-forget) — errors are swallowed.\n */\nexport function prewarmEmbeddedAgent(\n  logger?: RunnerLogger,\n  agentRuntime?: EmbeddedAgentRuntimeLike,\n): void {","sourceCodeStart":128,"sourceCodeEnd":164,"githubUrl":"https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/3efcd317b84146d6a08518ac0f7ee7c8a8d200ec/MemoryCore/src/utils/clean-context-runner.ts#L128-L164","documentation":"After successfully importing dist/extensionAPI.js, loadRunEmbeddedPiAgent verifies that the module actually exports a runEmbeddedPiAgent function. If the export is missing or not a function it throws, indicating the installed/built module is stale or incompatible with the runner's expected API surface.","triggerScenarios":"Loading the embedded agent when the built extensionAPI.js is from a different version that dropped/renamed runEmbeddedPiAgent, or a partial build produced an empty/incompatible module.","commonSituations":"Version mismatch between the runner (MemoryCore) and the installed openclaw package; stale dist/ from an older build after upgrading; tree-shaken or custom builds stripping the export.","solutions":["Rebuild (`pnpm build`) the openclaw package so dist matches current sources","Align versions: install the openclaw version the runner expects (check package.json/lockfile)","Grep dist/extensionAPI.js for `runEmbeddedPiAgent` to confirm the export exists","Clear cached module state — the failed promise is reset, so fixing the file and retrying works"],"exampleFix":"// before (extensionAPI.ts)\nexport { runEmbeddedPiAgent as runAgent }\n// after\nexport { runEmbeddedPiAgent }","handlingStrategy":"validation","validationCode":"const mod = await import(pathToFileURL(distPath).href);\nif (typeof mod.runEmbeddedPiAgent !== 'function') throw new Error('incompatible openclaw build: runEmbeddedPiAgent missing');","typeGuard":"const hasRunEmbeddedPiAgent = (m: unknown): m is { runEmbeddedPiAgent: RunEmbeddedPiAgentFn } => typeof (m as any)?.runEmbeddedPiAgent === 'function';","tryCatchPattern":"try { const run = await loadRunEmbeddedPiAgent(logger); } catch (e) { if (/not exported/.test(e.message)) { logger.error('openclaw build/version mismatch; rebuild or pin the expected version'); } else throw e; }","preventionTips":["Pin the openclaw package version expected by the runner in the lockfile","Rebuild openclaw whenever MemoryCore expects a changed API","Add a contract test that imports dist/extensionAPI.js and asserts the export"],"tags":["api-mismatch","dynamic-import","versioning"],"backgroundTag":"missing-export","analyzedSha":"3efcd317b84146d6a08518ac0f7ee7c8a8d200ec","analyzedAt":"2026-09-01T05:44:22.276Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}