refactor(platform): 建立平台运行时边界并接入 Lark#442
Draft
LucasIcarus wants to merge 2 commits into
Draft
Conversation
LucasIcarus
force-pushed
the
refactor/platform-runtime-boundary
branch
4 times, most recently
from
July 14, 2026 11:00
64a3c0b to
8804921
Compare
LucasIcarus
force-pushed
the
refactor/platform-runtime-boundary
branch
from
July 15, 2026 07:37
8804921 to
5ddcf16
Compare
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.
背景与目标
botmux 当前的生产执行路径以 Lark/飞书为中心,daemon、会话编排、消息发送和持久化身份之间仍有较强的直接耦合。如果继续沿现有路径叠加新 IM,平台差异会进一步渗入 core,也难以可靠约束“一个 session 属于哪个平台实例”。
本 PR 先建立真实可运行的平台边界,并让现有 Lark 路径通过该边界运行:
改了什么
平台领域模型与小型 ports
PlatformId、PlatformInstanceRef、PlatformConversationRef,以及统一的 message、sender、mention、attachment 模型;PlatformCapabilities显式声明 cards、stream updates、threads、mentions 等能力;ImAdapter草案,避免两套竞争性抽象;Lark runtime 与 composition root
LarkPlatformRuntime,组合现有 Lark event dispatcher、client、cards、reactions、attachments、identity 和 conversation routing;会话归属、恢复与兼容层
DaemonSession拆分为平台中立状态和类型安全的 Lark compatibility context;PlatformInstanceRef的入口;Lark 仍生成与旧版本相同的 key;(platform, instanceId)视图,同时保留larkAppId及旧字段语义;platform、instanceId和capabilities,旧字段与文件名保持不变。此外补全了 sandbox 新建目录的元数据测试夹具;该项不修改生产行为,可以独立审阅或回退。
基本设计
这里没有设计一个覆盖所有平台细节的万能 adapter。稳定的跨平台语义进入小型 ports;平台是否支持某项能力由 capability 声明;尚未抽象的 Lark 特有能力继续留在 extension 层。
迁移采用 strangler 方式:已迁移的生产调用先穿过 runtime façade,再委托到原有 Lark 实现。这是第一段迁移,不是一次性清空所有 Lark 耦合;架构测试会冻结既有例外,后续应逐项缩小 allowlist,而不是扩大它。
影响面与兼容性
larkAppId/larkAppSecret/brand、sessions-<larkAppId>.json、旧 descriptor 字段和文件名保持不变。验证方式
通用自动化验证:
pnpm build pnpm test pnpm vitest run --project unit \ test/platform-runtime.test.ts \ test/lark-platform-runtime.test.ts \ test/platform-session-key.test.ts \ test/platform-architecture.test.ts \ test/daemon-discovery.test.ts \ test/dashboard-registry.test.ts pnpm vitest run --project e2e \ test/tmux-backend.e2e.ts \ test/multi-bot-session.e2e.ts \ test/multi-bot-group-flow.e2e.ts \ test/web-terminal-scrollback.e2e.ts \ test/card-toggle.e2e.ts重点断言包括:
im/lark依赖。Live E2E
真实 Lark 环境的 live E2E 是 opt-in 测试,不进入默认
pnpm test,也不要求每位开发者使用个人飞书环境。具备独立测试租户或可接受的临时测试环境时,建议使用每轮新建的隔离群覆盖:所有 live case 应只操作本轮随机命名的临时资源,并在结束后精确清理;不得复用已有工作群或私聊。
Computer Use 仅作为 best-effort 的原生客户端渲染观察:没有合适桌面环境、登录态或测试意愿时可以直接跳过,不影响自动化测试结论,也不作为 PR 合并门槛。
当前状态
本 PR 保持 Draft。自动化边界与兼容性验证可继续审阅;真实 Lark live E2E 在具备合适的隔离环境后再补充结果。