Repository navigation
Bug: installing any plugin that depends on @deepseek-ai/dsh-tools breaks every tool call (Cannot read properties of undefined (reading 'prepare')) #1697
Replies: 5 comments 3 replies
|
This is the #1486 family surfacing through the plugin install path — same-version dual module instances with module-local We maintain moonquake2004/dsh-doctor (offline diagnostic, profile/session/env) and its P5 check flags exactly this state: any real-directory copy of Worth echoing your suggested fix direction upstream: host-first resolution for the harness's own |
|
Good catch on
So Sensible plan: land |
|
Verified the v1.2.0
Both directions verified, and the FAIL message is actionable. The upgraded Re: alignment — agreed. Ours stays user-side (profile/session/env offline diagnostics, 19 checks + remote catalog + fixture regression), yours covers the author-side bundle checks plus this profile tripwire; the overlap is exactly the profile-shadow precondition, which both now catch. Ping me when you want to sync the two doctor contracts (JSON schema / exit codes) so they stay interchangeable. |
补充影响:profile 中的旧版核心包会导致内置预设无法使用这个问题不只影响 在 此时选择 DSH 内置的
后端返回 插件不应把 DSH 宿主接口包作为普通依赖安装。该打包问题已在这里汇报: 但这个案例也进一步证明了本讨论中的平台问题:profile 本地的 建议让 DSH 自身的包始终优先从宿主解析,或者在发现 profile 中存在不兼容的同名核心包时明确拒绝启动并给出错误提示。 |
|
说明:这个问题大约在 15 天前就已被发现并定位(随后完成了修复与验证,分支 A ready-to-merge fix for this issue exists: Branch: What it does (commit
Verification:
Affected community reports: this discussion, Discussion #1337, Discussion #1959. Please re-enable Pull Requests (or tell me another contribution path) and I'll open the PR immediately — the branch is pushed and ready. |
Uh oh!
There was an error while loading. Please reload this page.
"### Summary\n\nInstalling any third-party plugin that depends on
@deepseek-ai/dsh-tools(e.g.@anweat/dsh-browser,@linxin666/dsh-ssh) breaks every agent tool call with:\n\n\nCannot read properties of undefined (reading 'prepare')\n\n\nThe turn ends immediately after the firsttool/call(turn/endreasonerror). This is a platform-level module-instance shadowing bug, not a plugin bug: the crash site isdsh-agent-loop's scheduler, and the plugin whose install triggered it is never even loaded into the config tree.\n\n### Environment\n\n- dsh 0.1.0-rc.6 (npm global install)\n- Profile:web(generated by dsh;pnpm-workspace.yamlusesnodeLinker: hoisted,autoInstallPeers: false)\n- pnpm 11, Windows 10, Node 24\n\n### Repro\n\n1.dsh plugin --profile web add @anweat/dsh-browser(any plugin whose dependencies include@deepseek-ai/dsh-toolsworks, e.g.@linxin666/dsh-ssh)\n2. Boot the web profile, start a session, and issue any prompt that triggers a tool call.\n3. The turn fails right after the first tool call withCannot read properties of undefined (reading 'prepare'). Repeats on every turn.\n\n### Root cause (verified)\n\n1. The profile'spnpm-workspace.yaml(dsh-generated) usesnodeLinker: hoisted, so the plugin's transitive@deepseek-ai/dsh-tools(the same version, 0.1.0-rc.6) is hoisted into the profile's top-levelnode_modules.\n2. The config tree anchorsbaseUrlat the profile directory, and bare specifiers resolve profile-first with the host as fallback (HostResolvedRootInclude.importinpackages/boot/app-boot\u2192internal.import(specifier, bareModuleBaseUrl, {})). Thetoolsentry (@deepseek-ai/dsh-tools) therefore loads the hoisted copy instead of the host's copy.\n3.dsh-agent-loopis loaded from the host copy and readsctx.tools[TOOL_RUNTIME_SCHEDULER].prepare(call.exec)using the host copy'sSymbol('@deepseek-ai/dsh-tools.scheduler')(a module-levelunique symbol). The registeredToolRuntimeinstance was created by the hoisted copy, whose prototype carries a different symbol value (Symbolidentity is per-module-instance). The lookup yieldsundefined\u2192undefined.prepare(...)\u2192 the exact TypeError above.\n\nVerified empirically: loading both copies of@deepseek-ai/dsh-tools@0.1.0-rc.6in one process yieldsTOOL_RUNTIME_SCHEDULERsymbols that are not===equal.\n\n### Impact\n\n- Any third-party plugin that importsdefineToolfrom@deepseek-ai/dsh-tools(the platform's own plugin-authoring API) and gets installed with a hoisted profile layout triggers this.\n- Two independent plugins are affected today:@anweat/dsh-browserand@linxin666/dsh-ssh(ships indsh-web-ui-all).\n- The failure is also completely non-diagnosable: nothing points at duplicate module instances.\n\n### Suggested fix directions\n\n- InHostResolvedRootInclude.import(or the nativeinternal.importfallback), resolve the harness's own scope (@deepseek-ai/*present in the host'snode_modules) from the host first, so a profile-installed duplicate can never shadow the host instance; or\n- Detect and warn/error when a profile-installed package shadows a host package of the same name+version, with an actionable message.\n\n### Workaround (verified on the affected setup)\n\nDeclare the SDK as alink:dependency in the profile so the profile resolves the host's copy (same realpath \u2192 same module instance \u2192 symbols match):\n\njsonc\n// ~/.dsh/profiles/web/package.json\n{\n \"dependencies\": {\n \"@deepseek-ai/dsh-tools\": \"link:C:/Users/<user>/AppData/Roaming/npm/node_modules/@deepseek-ai/dsh/node_modules/@deepseek-ai/dsh-tools\",\n // ...other plugins\n }\n}\n\n\nthenpnpm installin the profile. After that, tool calls complete normally (verified end-to-end with a Pwsh tool call:1 \u8f6e \u00b7 2 \u6b65, no errors). Note the absolute path must be adjusted if the npm global prefix changes.\n"All reactions