generated from MetaMask/metamask-module-template
-
Notifications
You must be signed in to change notification settings - Fork 6
refactor: Consolidate endoify setup and rationalize extension globals #787
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Set globalThis.kernel in the extension and omnium to the kernel itself. Remove ping and getKernel methods from background console interface. The kernel exposes ping().
…helpers - Remove packages/nodejs/src/env/endoify.ts re-export, use @metamask/kernel-shims/node-endoify directly - Update vitest configs to use kernel-shims for setup files - Remove inline endoify imports from test files (now handled by vitest setup) - Fix test helpers to handle SubclusterLaunchResult return type from launchSubcluster() - Add kernel-shims dependency to kernel-test and nodejs-test-workers packages - Set coverage thresholds to 0 temporarily Co-Authored-By: Claude Opus 4.5 <[email protected]>
…e configs - Fix accidentally broken nodejs vat worker (which broke all tests relying on it) - Rename node-endoify.js to endoify-node.js for consistency - Update package.json export from ./node-endoify to ./endoify-node - Update all vitest configs to use the new export path - Update depcheckrc.yml ignore pattern Co-Authored-By: Claude Opus 4.5 <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Contributor
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
The endoify-node export was pointing to src/endoify-node.js, but the files array only includes dist/, causing the file to be missing from published packages. The file cannot be bundled because it imports @libp2p/webrtc (a peer dependency), so the build script now copies it to dist/ instead. Changes: - Update build script to copy endoify-node.js to dist/ - Update package.json export to point to dist/endoify-node.js - Update source comment to reflect new build process Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Simplify the build script by using the built-in copyFile function instead of manually reading and writing the file. Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
sirtimid
previously approved these changes
Jan 28, 2026
Contributor
sirtimid
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good
sirtimid
approved these changes
Jan 29, 2026
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR consolidates several refactoring improvements to improve code organization and reduce circular dependencies:
@ocap/nodejsto@metamask/kernel-shims/endoify-nodeMotivation
@ocap/nodejsand@metamask/kernel-shims, creating circular dependency patterns@ocap/nodejswhen it logically belongs in the shims packageglobalThis.kernelAPI had unnecessary wrapper methods (ping(),getKernel()) when a direct reference would sufficeChanges
Endoify consolidation
@metamask/kernel-shims/endoify-nodefor Node.js-specific lockdown initialization@ocap/nodejs/endoify-mjsand@ocap/nodejs/endoify-tsexports@metamask/kernel-shims/endoify-node@libp2p/webrtcas peer dependency to kernel-shims (imports before lockdown to modify globals)Global API rationalization
Before:
After:
This simplification:
E(globalThis.kernel).ping()instead ofkernel.ping()Dependency improvements
dist/directories (avoids false positives from build artifacts)@libp2p/webrtcto depcheck ignores (peer dependency of kernel-shims)@ocap/nodejsfrom@metamask/kernel-browser-runtimedevDependencies (was only used for test setup)Files changed
🤖 Generated with Claude Code
Note
Medium Risk
Medium risk because it changes Node.js SES/lockdown initialization order (including new
@libp2p/webrtcpeer import) and modifies how browser background scripts expose and useglobalThis.kernel, which could affect runtime startup and tests.Overview
Moves Node.js “endoify”/lockdown setup out of
@ocap/nodejsinto a new@metamask/kernel-shims/endoify-nodeentrypoint (copied todist/, exports added), and updates all Vitest configs/worker entrypoints to use it;@metamask/kernel-shimsnow declares@libp2p/webrtcas a peer dependency and repo config silences dep/lavamoat noise for that path.Simplifies the dev-console globals in the extension and
omnium-gatherumbackgrounds by makingglobalThis.kernela direct kernel facade (or promise) and removing the wrapperping/getKernelhelpers, updating click-to-wake and subcluster startup to callE(globalThis.kernel)directly.Written by Cursor Bugbot for commit 8e9f293. This will update automatically on new commits. Configure here.