Fix #1559: fix: registerMemoryCapability API not found in OpenClaw 2026.3.31#2037
Conversation
OpenClaw 2026.3.31 replaced the umbrella `registerMemoryCapability` with three focused registrars (`registerMemoryPromptSection`, `registerMemoryFlushPlan`, `registerMemoryRuntime`), so the plugin's call at index.ts:163 failed with `TypeError: api.registerMemoryCapability is not a function` and the whole plugin refused to load. The register() entry now feature-detects `registerMemoryPromptSection` and falls back to the legacy `registerMemoryCapability` for older gateways, warning if neither exists. Tests stub both entry points and a new tests/memory-registration-api.test.ts locks in the preference order, the fallback path, and the no-throw safeguard. Fixes MemTensor#1559
🤖 Open Code ReviewTarget: PR #2037 🔍 OpenCodeReview found 4 issue(s) in this PR. 1.
|
…+ escalate missing-registrar log to error Address OpenClaw review feedback on the MemTensor#1559 fix: * Hoist the inline `{ registerMemoryPromptSection?, registerMemoryCapability? }` cast type to a named `MemoryRegistrationApi` interface at module scope so future maintainers see which host methods the feature detection covers and don't accidentally reach for other `OpenClawPluginApi` members through the narrowed reference. (OCR MemTensor#1, MemTensor#3) * Escalate the "neither registrar available" log from `warn` to `error` so the fatal misconfiguration surfaces immediately in production dashboards rather than silently manifesting as broken memory recall. Falls back to `warn` when the host logger lacks `.error` for compatibility with legacy `HostLogger` shapes. (OCR MemTensor#2, MemTensor#4) * Expand `tests/memory-registration-api.test.ts` accordingly: assert `error` is called on the modern path and add a legacy-logger case that verifies the warn fallback still fires when `.error` is absent.
🤖 Open Code ReviewTarget: PR #2037 🔍 OpenCodeReview found 3 issue(s) in this PR. 1.
|
…mory registrar Address the second round of OpenClaw review feedback on the MemTensor#1559 fix: * Replace `api as unknown as MemoryRegistrationApi` with the safer intersection cast `api as OpenClawPluginApi & MemoryRegistrationApi`. This keeps every other typed member of `api` intact and communicates the actual intent — "the host may additionally expose these optional registrars" — instead of throwing away the whole type. (OCR MemTensor#1) * Throw after logging in the "no registrar found" branch. Previously register() would keep spinning up stores, workers and tools even though the recall path was permanently broken, producing a plugin that *looks* healthy while silently never surfacing memories. Now the failure is visible at startup and the host can react. (OCR MemTensor#2) * Hoist the inline `{ error?: (msg: string) => void }` cast on `api.logger` into a named `ExtendedLogger` interface alongside `MemoryRegistrationApi`, so all remaining type-escape hatches live in one place and can be dropped once the SDK publishes matching types. (OCR MemTensor#3) * Update `tests/memory-registration-api.test.ts` accordingly: the "neither method" cases now assert both the error/warn log and that `register()` throws with a matching message, so the fail-fast contract is locked in.
🤖 Open Code ReviewTarget: PR #2037 ✅ OpenCodeReview: No comments generated. Looks good to me. Generated by cloud-assistant via Open Code Review. |
❌ Automated Test Results: FAILED
Failed tests:
Error detailsBranch: |
…ayMs in update-install test The mock `res.end(payload)` in the update-install test ignored the optional flush callback, so `jsonResponseAndRestart` never scheduled its 1500ms SIGUSR1 setTimeout under `vi.useFakeTimers()`. Also bump the timer advance from 500ms to 2000ms to cover the actual default `delayMs=1500`. Fixes: "keeps the new version and restarts only after a successful postinstall"
|
Automated Test Results: PASSED\n\nCloud test-engine rerun after resolving the dev-v2.0.22 merge conflict.\n\nRun: tr-4b3ba62f-a76\nScope: memos_local_openclaw\nResult: 58/58 tests passed\nCommand group: memos_local_openclaw/unit\nDuration: 66s\n\nLocal pre-push verification also passed: npm run build, plus focused vitest for the memory-registration API tests.\n\nStatus: merge conflict resolved; automated scope test passed. Manual code review is still required before merge. |
Description
Fixes #1559: the @memtensor/memos-local-openclaw-plugin failed to load on OpenClaw 2026.3.31 because it still called the removed umbrella
api.registerMemoryCapability({promptBuilder})atapps/memos-local-openclaw/index.ts:163. OpenClaw 2026.3.31 split that umbrella into three focused registrars —registerMemoryPromptSection,registerMemoryFlushPlan,registerMemoryRuntime— so the call threwTypeError: api.registerMemoryCapability is not a functionand the plugin refused to initialize.The fix rewrites
register()to feature-detect the newregisterMemoryPromptSection(builder)API and use it preferentially, falling back to the legacyregisterMemoryCapability({ promptBuilder })for older gateways, and logging a warning if neither method is present. Only the prompt-section builder is needed — the plugin does not implement flush plans or memory runtimes — so this is a minimal, backwards-compatible migration.Test evidence: a new
tests/memory-registration-api.test.ts(3 cases) locks in preference of the new API, the legacy-fallback path, and the no-throw safeguard. Six existing test stubs were extended to expose both entry points.npx vitest run tests/memory-registration-api.test.ts→ 3/3 pass; targeted run of touched files (plugin-openclaw-wiring,plugin-impl-access,shutdown-lifecycle,hub-eager-connect,integration,incremental-sharing) → 41/41 pass. Broadernpx vitest run --exclude e2e/accuracy→ 213 pass; the 3 pre-existing failures (skill-auto-install, task-processor, update-install) exist on the base branch too and are unrelated to this change (confirmed viagit stashre-run).npx tsc --noEmitis clean.Related Issue (Required): Fixes #1559
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Automated tests are pending.
Checklist
@MatthewZhuang, @CarltonXiang, @syzsunshine219, @World-controller please review this PR.
Reviewer Checklist