Repository navigation
feat(plugins): 远程工作区上下文带远端平台,新增 workspace/getHostPaths 和两个失败码(API-40,#2231) - #151
Merged
Merged
Conversation
…#2231)
- 远程上下文的 authority 新增 platform { os, arch },本地上下文没有这个字段。
- 新增宿主方法 lithe/host/workspace/getHostPaths:返回远程上下文根目录在远端主机上的绝对 POSIX 路径,
可选 rootIDs(1–256 个不重复的 ID);属于 workspace.metadata 下单独的方法授权,本地上下文返回
authorityUnsupported,未知根目录返回 notFound。
- 新增 plugin.host.remoteDisconnected(-32078)和 plugin.host.platformUnavailable(-32079),
中转与宿主错误表保持一码一义。
- 插件函数中转不再拒绝远程工作区的上下文,Core 不读也不改写参数和结果里的路径。
- 契约 README 写明启动计划的 hostServices 含方法授权,宿主去掉自己没有注册处理器的方法。
- 四个官方 SDK(Node、Go、Rust、Java)新增远端平台、getHostPaths、按来源选择进程路径的辅助方法和两个失败码,
path 与 hostPath 是不同类型;新增远程工作区开发指南,更新 API 总表与协议更新记录。
xiaoyumuxi
marked this pull request as ready for review
November 21, 2026 05:11
1 task done
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.
关联 Issue
1lck/Lithe-IDEA#2231(远程开发完整设计)R3:插件在本机运行,通过宿主访问远端。本 PR 给插件后端补上"我在为哪台远端主机工作、远端的根目录在哪"这两项信息,以及远程场景下的两个失败码。
类型
authority.platform、宿主方法lithe/host/workspace/getHostPaths、失败码-32078/-32079、中转放行远程上下文,四个官方 SDK 同步新增宿主方法
lithe/host/workspace/getHostPathsAPI-05(工作区上下文)、API-35(插件函数中转)只改了已有方法的字段和行为,没有新增方法。
改动说明
为什么插件需要远端路径
远程工作区里插件后端仍在本机运行(#2231 已定)。插件拿到的
path只对本机有意义,远程上下文本来就没有path。插件要在远端启动语言服务器、构建工具或调试器时,必须知道根目录在远端主机上的绝对路径,以及远端的系统和架构(选哪个程序包)。远端路径只用于传给远端运行的程序,不能交给本机的fs,所以 SDK 用单独的类型表示它。契约(
shared/plugins/contract/v1/README.md、fixture)authority新增platform: { os, arch },取值同托管运行时(os为linux,arch为arm64或x86_64);本地上下文没有这个字段。插件遇到不认识的值要忽略。lithe/host/workspace/getHostPaths { context, rootIDs? }→{ folders: [{ rootID, hostPath }] }:hostPath是远端主机上的绝对 POSIX 路径;rootIDs可选,1–256 个不重复的根目录 ID,决定返回哪些根目录及顺序。workspace.metadata下单独的方法授权(不随workspace服务授权一起给)。本地上下文返回plugin.host.authorityUnsupported,未知根目录返回plugin.host.notFound,上下文过期返回plugin.host.contextExpired。context,rootIDs为空、超过 256 个、重复或不在键字符集内,由 Core 在宿主看到请求前拒绝(plugin.host.invalidParams);多出的字段是plugin.host.unsupportedOption。plugin.host.remoteDisconnected(-32078,操作进行中与远端主机断开)、plugin.host.platformUnavailable(-32079,插件没有适合远端平台的程序包或托管运行时)。号码此前没人用;宿主错误表 23 项、中转错误表 11 项,都保持一码一义。authority路由。导出的context: "workspace"同时包括两种来源的工作区,Core 不读也不改写参数和结果里的路径。fixturerelayErrors去掉远程拒绝那一条(共 14 条)。backend.hostServices:原文写"宿主原样传给lsp.startServer",与methods_for_permission的注释("平台与自己注册的处理器取交集")矛盾。现在写明列表里有服务名和方法全名,宿主去掉自己没有注册处理器的方法,后端调用这些方法得到plugin.host.permissionDenied。声明workspace.metadata的插件,计划里因此多出lithe/host/workspace/getHostPaths。Core 代码
plugin-rpc:host_api.rs方法表加getHostPaths(权限workspace.metadata,单独授权);host_params.rs校验rootIDs;host_requests.rs分派;failures.rs加两个失败码,并修正号段注释;lib.rs导出常量。plugin-function-relay:删除远程上下文拒绝;authority仍在快照里校验,但中转不再依赖它。rust/fixtures/plugins/host-api-v1.json:宿主 API fixture 加新方法和失败码。不在
crates/remote里的改动R3 是插件契约改动,按"插件契约只在 Rust Core"的规则,代码只能放在执行契约的 crate:
plugin-rpc(方法表、参数、失败码)、plugin-function-relay(放行远程上下文)、lsp-engine与core的测试(中转测试改为远程调用能送达;声明式插件测试的启动计划期望多一项方法授权)。crates/remote没有改动,远端服务的协议也没有改动。四个官方 SDK
index.mjs/host.mjs/index.d.ts)、Go(lithe/host.go)、Rust(plugin-sdk/src/host.rs)、Java(Host.java)都新增:getHostPaths(context, rootIDs?):rootIDs违反 Core 规则时在本地直接失败,不发请求;processRoots(context):本地上下文直接用getFolders的path,远程上下文才向宿主要hostPath,插件不用自己分支;HostPath类型(NodeHostPath.value、Golithe.HostPath.String()、RustHostPath::as_str()、JavaHost.HostPath.value()):不是字符串,只接受绝对 POSIX 路径,JSON 序列化为字符串;index.d.ts的HOST_METHODS键类型漏了运行时protocol.mjs已有的 6 个 terminal 键(terminalCreate到terminalOnExit),已补上。文档
shared/plugins/guides/plugin-backend-remote-workspaces.md(中英):怎么识别远程上下文、getHostPaths的权限与失败、path与hostPath的区别、今天哪些宿主服务支持远程上下文、四种 SDK 示例。domains/backend.md、capabilities-and-versions.md、四份 SDK README、plugin-backend-workspace.md。plugin-backend-workspace.md和domains/backend.md写的"远程工作区在本地保留的目录只是空占位"、契约里"中转拒绝远程工作区"。与桌面端的关系
pluginhost.GrantServices(desktop/internal/pluginhost/launch.go)本来就把计划里的授权与已注册的服务取交集,没有注册getHostPaths时这项授权会被去掉,插件得到permissionDenied、supports返回 false,不会因为lsp.startServer校验失败而起不来。getHostPaths处理器要等远程工作区接入remote.connect之后,单独开 PR。已知限制
authorityUnsupported。发现的既有问题
-32070/-32071在函数中转(plugin.function.failed/invalidResult)和工具链查询(plugin.toolchain.permissionDenied/authorityUnsupported)里含义不同,已建单 1lck/Lithe-IDEA#2260。不属于本 PR。与其他 PR 的关系
从 origin/main(66a1476)开分支,不叠在其他 PR 上。
测试
plugin-rpchost_paths_are_a_method_grant_with_bounded_root_ids:workspace.metadata只多给这一项方法授权;256 个rootIDs放行、257 个被拒绝;只有workspace服务授权时getCapabilities里看不到这个方法。function-protocol.jsonhostRequests新增 8 条(Core 和四个 SDK 的测试都读它):两种放行、只有服务授权得到-32010、缺context、空rootIDs、重复、不在键字符集内、多出的path字段。host-api-v1.json新增两条授权判断。plugin-function-relaya_remote_workspace_is_relayed、lsp-enginea_call_for_a_remote_workspace_reaches_the_callee:远程上下文的调用能送到被调用方。corerelay_errors_follow_the_fixture、workspace_backend_is_planned_with_its_version_and_workspace_service。TestHostPathRootIDsCoreRefusesFailLocallyAndTheAnswerHoldsHostPaths、TestProcessRootsReadsALocalContextAndAsksTheHostOnlyForARemoteOne,Rust、Java 有同名测试,Node 有对应的host.test.mjs用例和类型测试。cargo fmt --all -- --checkcargo clippy --workspace --all-targets --all-features -- -D warnings(macOS)cargo clippy --workspace --all-targets --target x86_64-pc-windows-msvc -- -D warningscargo test --locked --workspace --features lithe-remote/server:2452 通过、0 失败scripts/rust-core/verify-rust-core-comments.sh plugin-rpc plugin-function-relay lsp-engine corenode scripts/rust-core/verify-platform-tests.mjs、node scripts/logging/generate-log-events.mjs --checknode shared/plugins/scripts/verify-docs.mjsnode shared/plugins/scripts/sdk-e2e.mjs(Node、Java、Rust、Go 和构建,共 12 个测试)node --test test/*.test.mjs(88 个)和npm run test:types;Go:go test ./...、gofmt、go vet;Rust SDK:fmt、test、clippy-D warnings、RUSTDOCFLAGS=-D warnings cargo doc;Java:mvn verify(Java 8 兼容)