Repository navigation
feat(sdk): 三个官方 SDK 支持插件函数协议 4(跨插件调用,Node/Java 0.4.0、Rust 0.3.0) - #24
Merged
xiaoyumuxi merged 4 commits intoNov 5, 2026
Merged
Conversation
- 协商到函数协议 4;Host.functions() 封装 lithe/host/functions/providers 与 invoke,返回原始的 {providers} 与 {value}
- 协议 3 及以下在本地拒绝两个中转方法(plugin.host.unavailable,-32601),不写帧;参数不合法时本地失败(sdk.functions.invalidCall)
- invoke 只发送契约列出的字段;parentOperationID 默认取正在处理的函数调用的线上 operationID
- CallContext.caller():协议 4 且线上 caller 恰为 {pluginID} 时可读,其余情况为 null
- HostError 补宿主错误码 -32022 至 -32026 和 11 个 plugin.function.* 码;新增 pluginErrorCode()
- HostTest 跟上契约新 fixture:跳过 params 不是对象的用例,新宿主通知走 onHostNotification
- 协商到函数协议 4;host.functions.providers 与 invoke 返回原始的 {providers} 与 {value}
- 协议 3 及以下在本地拒绝两个中转方法(plugin.host.unavailable,-32601),通用 host.request 同样拦截,不写帧
- invoke 只发送契约列出的字段,参数不合法时本地失败(sdk.functions.invalidCall);parentOperationID 默认取正在处理的函数调用的线上 operationID
- 函数处理器的 context.caller:协议 4 且线上 caller 恰为 {pluginID} 时可读,其余情况为 null
- HOST_ERRORS 补宿主错误码 -32022 至 -32026 和 11 个 plugin.function.* 码;类型定义同步
- host.test.mjs 跟上契约新 fixture:新宿主通知走 onHostNotification
- README、API 总表、后端领域页:SDK 支持的函数协议改为 1–4,删去 API-35 的“SDK 尚无封装” - 能力与版本页:对照表改为 Node 0.4.0、Java 0.4.0、Rust 0.3.0,中英发版历史各加三行 - 后端工作区指南第 10 节加入 Node SDK 的 functions.providers/invoke 与 context.caller 示例 - 协议更新记录:函数协议 4 一行注明从哪个 SDK 版本起支持
- 协商到函数协议 4;Host::functions() 的 providers 与 invoke 返回原始的 {providers} 与 {value}
- 协议 3 及以下在 Host::send 本地拒绝两个中转方法(plugin.host.unavailable,-32601),通用 request 同样拦截,不写帧
- invoke 只发送契约列出的字段,参数不合法时本地失败(sdk.functions.invalidCall);handler 内 parentOperationID 默认取正在处理的调用的 operationID
- Context::caller() 与 Caller 类型:协议 4 且线上 caller 恰为 {pluginID} 时有值
- HOST_ERROR_CODES 补 -32022 至 -32026(21 项),新增 RELAY_ERROR_CODES(11 个 plugin.function.*)
- host_services 测试跟上契约新 fixture:新宿主通知走 on_host_notification
xiaoyumuxi
marked this pull request as ready for review
November 5, 2026 10:08
xiaoyumuxi
added a commit
that referenced
this pull request
Nov 5, 2026
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.
关联 / Linked
contract/v1/。sync/1730-merged-preview。sync: 契约同步到 preview 22c14a96b,登记 #1730、#1742、#1745、#1746、#1763 #23 的 Java、Node、Rust SDK 测试都因新 fixture 失败(新增函数协议 4、宿主错误码 -32022 至 -32026、lithe/host/*新通知);本 PR 修复这些测试。PR 类型 / Type
改动说明 / What changes
三个 SDK 都协商到函数协议 4,行为一致:
context.host.functions.providers(id)、Javacontext.host().functions().providers(id)、Rustcontext.host().functions().providers(id),返回原样的{providers}functions.invoke(workspace, call),返回原样的{value}plugin.host.unavailable(-32601),不写帧;通用宿主请求同样拦截pluginID、functionID、context、params、timeoutMilliseconds、parentOperationID),caller等多余字段丢弃;不合法时本地失败,返回sdk.functions.invalidCall,上下文错误仍是sdk.host.invalidContext。超时上限由 Core 执行,SDK 不本地截断parentOperationID默认取正在处理的那次lithe/function/invoke的operationID(1–128 字节才用);backend.host、构建、VCS、快捷键等入口不带默认值caller:协议 4 且线上caller恰为{pluginID: 非空字符串}时有值,否则为空plugin.function.*(-32027 至 -32030、-32065 至 -32071);plugin.function.failed的details.pluginErrorCode可直接读取各 SDK:
Protocol、HostChannel、HostError(新增pluginErrorCode())、CallContext(caller()、callerPluginId())、Host.functions()、Backend;4 个 pom 升版本;README 新增 “Calling other plugins (protocol 4)”。protocol.mjs、host.mjs(host.functions)、backend.mjs(context.caller)、index.d.ts新类型;README 同步。protocol.rs(RELAY_VERSION)、host.rs(Functions,闸门在Host::send,with_cancellation保留父调用)、backend.rs(Caller、Context::caller())、error.rs(HOST_ERROR_CODES21 项,新增RELAY_ERROR_CODES11 项);README 新增 “Calling other plugins” 一节。取舍:
caller只认恰好{pluginID}的形状。以后宿主往里加字段,SDK 会当成“宿主发起”,需要随契约一起升级 SDK。timeoutMilliseconds限时。文档:
合并与发版
sync/1730-merged-preview,sync: 契约同步到 preview 22c14a96b,登记 #1730、#1742、#1745、#1746、#1763 #23 的 SDK 测试随之变绿。main。main后推 tagsdk-node-v0.4.0、sdk-java-v0.4.0、sdk-rust-v0.3.0发版。验证
mvn -B verify(Java 8 目标)通过。npm test89 个通过;npm run test:types通过。cargo +1.87 test --locked全部通过(单元 19、host_services 22、session 17、keymap 3 等);stable 下cargo fmt --check与cargo clippy --all-targets -D warnings通过。node --test scripts/contract.test.mjs scripts/sdk-e2e.test.mjs:16 个通过;node scripts/contract.mjs verify:92 个文件与 22c14a96b 一致。sdk-e2e交给 CI 运行。