Repository navigation
fix(core): resolve npm provider entrypoints on Node - #45608
Closed
opencode-agent[bot] wants to merge 2 commits into
Closed
opencode-agent[bot] wants to merge 2 commits into
opencode-agent[bot] wants to merge 2 commits into
Conversation
Contributor
|
Automated PR Cleanup Thank you for contributing to opencode. Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions. This PR was closed because it matched the following cleanup criteria:
PRs created within the last month are not affected by this cleanup. If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate. Thanks again for taking the time to contribute. |
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
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
Fix custom npm provider loading in the V1 Desktop Node runtime. The existing resolver returns a package directory URL, which Node rejects with
ERR_UNSUPPORTED_DIR_IMPORTwhen the provider loader imports it.resolve.exportswith the runtime's actual import conditions, then Node's resolver for legacy packages without exports.import.meta.resolve(name, directory)behavior.mainor a require-only export.testscript so unit CI covers it.Verification
packages/core:bun run test:node-npmwith Node 24.13.0 — 11 passing tests covering scoped/aliased packages, string/nested exports, condition ordering,module-sync, custom conditions, legacymain/index.js, and unavailable root exports. A concurrent CommonJS dependency is evaluated during resolver initialization. This produced two failures before the condition-capture guard and passes afterward.bun build --target=nodeand ran them with Electron 42.3.3's Node 24.15.0 runtime (ELECTRON_RUN_AS_NODE=1) — 11 passing tests.Npm.add()against a cached custom package, followed by dynamic import and provider-factory invocation — passed.utilityProcesssmoke with the V1 application runtime: project config →Provider.getModel()→getLanguage()→ npm installation/resolution → custom SDK factory → fixture modeldoGenerate(). Both cold installation and warm-cache loading passed. Replacing only the resolver with the original V1 Node expression makes this same harness fail withProviderInitError/ERR_UNSUPPORTED_DIR_IMPORT. The fixture has separate import/require entries and throws if the require entry is selected. No paid inference or external provider was used.packages/opencode:env -u GOOGLE_VERTEX_API_KEY -u VERTEX_API_KEY bun test test/provider— 560 passing tests. The initial run inherited host Vertex credentials and selected a different authentication mode; these were removed for the isolated rerun.packages/core:bun test test/npm.test.ts test/npm-config.test.ts— 9 passing tests, including import of the installed entrypoint on Bun.EAGAINprocess-spawn errors and an intermittent lock-contention failure; this is not a claim of a clean unpartitioned run. The 11 Node tests also passed afterward.packages/core:bun typecheck— passed.packages/opencode:bun run script/build-node.ts— passed.git diff --check— passed.The Node tests require a modern Node runtime with
registerHooksand TypeScript stripping; Desktop and unit CI use Node 24. This validates the real V1 provider path in a utility process, not the full Desktop renderer or a live external provider. The condition probe emits an experimental VM-loader warning.Remaining compatibility limits
This is a focused backport, not a fully native ESM resolver. Differential probes found two existing
resolve.exportslimitations also present in V2: falling through an unmatched nested condition to a later root condition, and skipping an invalid first export-array target in favor of a later valid target. Those unusual export layouts remain unsupported here; they also failed before this change. Bun's resolver is unchanged.Requested by: @rekram1-node (Aiden via Slack)