Skip to content

User-installed plugins cannot resolve openclaw/plugin-sdk module path (regression in 3.23) #53403

@tonyhth

Description

@tonyhth

Environment

  • OpenClaw 3.23 (ccfeecb) and 3.23-1
  • macOS 15.7.4 x64
  • Plugin: @tencent-weixin/openclaw-weixin 1.0.2 / 1.0.3
  • Plugin install path: ~/.openclaw/extensions/openclaw-weixin/

Steps to Reproduce

  1. Install OpenClaw 3.23
  2. Install any user plugin that imports from openclaw/plugin-sdk (e.g. @tencent-weixin/openclaw-weixin)
  3. Start or restart the gateway
  4. Plugin fails to load: Error: Cannot find module 'openclaw/plugin-sdk'

Bundled plugins (feishu, etc.) work fine — the issue only affects user-installed plugins in ~/.openclaw/extensions/.

Root Cause

In pi-embedded-CwMQzdKD.js, loadOpenClawPlugins() calls buildPluginLoaderAliasMap(modulePath) where modulePath is the plugin file path (e.g. ~/.openclaw/extensions/openclaw-weixin/index.ts). The jiti-based loader uses this to build an alias map for openclaw/plugin-sdk* imports.

The alias map builder has two resolution paths:

1. resolvePluginSdkAliasFile()

Finds root-alias.cjs by walking up to 6 levels from the plugin directory.

For ~/.openclaw/extensions/openclaw-weixin/:

1. ~/.openclaw/extensions/openclaw-weixin/
2. ~/.openclaw/extensions/
3. ~/.openclaw/
4. ~/
5. /Users/
6. /Users/hth/

Never reaches /usr/local/lib/node_modules/openclaw/ → returns null.

2. resolvePluginSdkScopedAliasMap()

Calls resolveLoaderPluginSdkPackageRoot()resolveOpenClawPackageRootSync() starting from plugin dirname, then findNearestPluginSdkPackageRoot() (max 12 levels). Same problem — cannot reach the OpenClaw package root from ~/.openclaw/extensions/.

Why it worked in 3.13

In 3.13, the alias for openclaw/plugin-sdk (main entry only) used a different resolution strategy that could locate the OpenClaw package. In 3.23, both main entry and subpath resolution fail for user-installed plugins.

Bundled plugins work because they are located at /usr/local/lib/node_modules/openclaw/dist/extensions/ — inside the same package tree.

Suggested Fixes

  1. Search the OpenClaw executable's location as a candidate root in resolveLoaderPluginSdkPackageRoot()
  2. Set NODE_PATH to include the OpenClaw package parent in the gateway LaunchAgent
  3. Add a config option like plugins.sdkPath pointing to the OpenClaw installation directory
  4. Extend the directory walk limit or use require.resolve() to find the OpenClaw package from the gateway process itself

cc @X_Corperation (who reported the same issue in the community)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions