Summary
TDB 0.3.5 (built with OpenClaw SDK 2026.3.13) fails to register on OpenClaw 2026.5.20 because api.runtime.state is undefined during plugin registration.
Error
[plugins] memory-tencentdb failed during register:
TypeError: Cannot read properties of undefined (reading 'resolveStateDir')
Root Cause
index.ts calls api.runtime.state.resolveStateDir() at two points during registration:
- L220:
const pluginDataDir = path.join(api.runtime.state.resolveStateDir(), "memory-tdai");
- L826:
stateDir: api.runtime.state.resolveStateDir()
On OpenClaw 2026.5.20, the runtime.state object is not yet populated at the point TDB calls it, even though the TypeScript types declare it exists.
Fix
Add optional chaining with a sensible fallback. Since resolveStateDir() is well-defined (returns ~/.openclaw or $OPENCLAW_STATE_DIR), the fallback can be os.homedir() + "/.openclaw":
// Before
const pluginDataDir = path.join(api.runtime.state.resolveStateDir(), "memory-tdai");
// After
const stateDir = api.runtime.state?.resolveStateDir?.() ??
path.join(os.homedir(), ".openclaw");
const pluginDataDir = path.join(stateDir, "memory-tdai");
This is safe because resolveStateDir() is a pure directory resolution with no side effects. The call sites that don't have access to process.env can hardcode the homedir fallback.
Environment
- TDB: 0.3.5
- OpenClaw: 2026.5.20
- macOS 15.5 (Apple Silicon)
- Plugin SDK compat declared:
pluginApi >=2026.3.13
Related
Similar to #57 (CLI registration break after OpenClaw upgrade) — this is the same class of SDK compat issue.
Summary
TDB 0.3.5 (built with OpenClaw SDK 2026.3.13) fails to register on OpenClaw 2026.5.20 because
api.runtime.stateisundefinedduring plugin registration.Error
Root Cause
index.tscallsapi.runtime.state.resolveStateDir()at two points during registration:const pluginDataDir = path.join(api.runtime.state.resolveStateDir(), "memory-tdai");stateDir: api.runtime.state.resolveStateDir()On OpenClaw 2026.5.20, the
runtime.stateobject is not yet populated at the point TDB calls it, even though the TypeScript types declare it exists.Fix
Add optional chaining with a sensible fallback. Since
resolveStateDir()is well-defined (returns~/.openclawor$OPENCLAW_STATE_DIR), the fallback can beos.homedir() + "/.openclaw":This is safe because
resolveStateDir()is a pure directory resolution with no side effects. The call sites that don't have access toprocess.envcan hardcode the homedir fallback.Environment
pluginApi >=2026.3.13Related
Similar to #57 (CLI registration break after OpenClaw upgrade) — this is the same class of SDK compat issue.