Plugins: prefer current loader root for sdk aliases#53047
Plugins: prefer current loader root for sdk aliases#53047RichardCao wants to merge 1 commit intoopenclaw:mainfrom
Conversation
Greptile SummaryThis PR adds a focused regression test to
Confidence Score: 5/5
Reviews (1): Last reviewed commit: "Tests: cover local plugin-entry alias lo..." | Re-trigger Greptile |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 692b788781
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| srcFile: "plugin-entry.ts", | ||
| distFile: "plugin-entry.js", | ||
| srcBody: "export const definePluginEntry = () => 'source-plugin-entry';\n", | ||
| distBody: "export const definePluginEntry = () => 'dist-plugin-entry';\n", |
There was a problem hiding this comment.
Load the real plugin-entry source in this regression test
If the reported failure only happens when Jiti has to execute the actual src/plugin-sdk/plugin-entry.ts graph from an installed package, this test will still pass because it replaces both source and dist plugin-entry modules with dependency-free stubs. The real module immediately imports ../plugins/config-schema.js and ../plugins/types.js (src/plugin-sdk/plugin-entry.ts:1-8), so this fixture never exercises the .js-specifier rewriting/resolution path that can break local TS plugins. As written, the test can stay green even while openclaw/plugin-sdk/plugin-entry is still unloadable in production-like installs.
Useful? React with 👍 / 👎.
|
Closing this PR because the author has more than 10 active PRs in this repo. Please reduce the active PR queue and reopen or resubmit once it is back under the limit. You can close your own PRs to get back under the limit. |
|
Closing this PR because the author has more than 10 active PRs in this repo. Please reduce the active PR queue and reopen or resubmit once it is back under the limit. You can close your own PRs to get back under the limit. |
Summary
process.cwd()instead of the currently running loader module.openclaw/plugin-sdk/*imports can point at the wrong package tree and fail to load.moduleUrlhints through plugin SDK alias resolution and passed the current loader/runtime module URL from the plugin loader plus the Matrix/WhatsApp runtime boundaries.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Root Cause / Regression History (if applicable)
process.cwd()and choose a different OpenClaw package root than the one that is actually executing the loader.git blame, prior PR, issue, or refactor if known): [Bug]: local TS extensions importing openclaw/plugin-sdk/plugin-entry fail to load on 2026.3.22 #53002 reports the failure against a global npm install where the observed failing path did not match the install path described in the issue, which points to root-selection drift.cwd/package-root fallback logic, but it did not consistently anchor resolution to the currently running loader/runtime module.mainand an unpackedopenclaw@2026.3.22tarball worked when the package root was unambiguous, which ruled out a simpleplugin-entryalias omission.Regression Test Plan (if applicable)
src/plugins/sdk-alias.test.tscwdpoints at one valid OpenClaw root but the current loader module belongs to another, local TS plugin SDK aliases should follow the loader module root.User-visible / Behavior Changes
openclaw/plugin-sdk/*against the currently running OpenClaw install even ifprocess.cwd()points at another valid OpenClaw root.Security Impact (required)
Yes/No) NoYes/No) NoYes/No) NoYes/No) NoYes/No) NoYes, explain risk + mitigation:Repro + Verification
Environment
Steps
plugin-entryexports.process.cwd()to the wrong root and load a local TS plugin outside both roots.Expected
cwdfallback root.Actual
Evidence
Attach at least one:
Human Verification (required)
pnpm exec vitest run src/plugins/sdk-alias.test.ts src/plugin-sdk/root-alias.test.ts.cwdwhen no module hint is provided, and verified the new module hint overrides that fallback for local plugin loading.openclaw gateway restartagainst a real global multi-install machine.Review Conversations
Compatibility / Migration
Yes/No) YesYes/No) NoYes/No) NoFailure Recovery (if this breaks)
src/plugins/sdk-alias.ts,src/plugins/loader.ts,src/plugins/runtime/runtime-matrix-boundary.ts,src/plugins/runtime/runtime-whatsapp-boundary.ts,src/plugins/sdk-alias.test.tsRisks and Mitigations
cwdfallback if they do not pass a module hint.