Skip to content

feat(lark): add Lark bot channel frontend#3149

Open
0x0101010 wants to merge 3 commits into
esengine:main-v2from
0x0101010:feat/lark-bot
Open

feat(lark): add Lark bot channel frontend#3149
0x0101010 wants to merge 3 commits into
esengine:main-v2from
0x0101010:feat/lark-bot

Conversation

@0x0101010
Copy link
Copy Markdown

@0x0101010 0x0101010 commented Jun 4, 2026

Summary / 概述

Adds a Lark (飞书) bot channel frontend to Reasonix, enabling users to interact with Reasonix through Lark chat — ask coding questions in a group or DM, get agent responses as progressive streaming messages, approve/deny tool calls via interactive card buttons.

为 Reasonix 添加 Lark(飞书)机器人通道前端,用户可以在飞书聊天中与 Reasonix 交互——群聊或私聊提问、流式查看 agent 回复、通过交互卡片审批工具调用。

Features / 功能

Lark Bot Frontend / 飞书机器人前端

  • Multi-tenant session router: Per-chat conversation isolation with TTL expiry and concurrency limits
    多租户会话管理:按聊天隔离会话,支持 TTL 过期和并发限制
  • Progressive streaming output: Model text streams live via ch.Stream(), with local buffer + async flush
    流式渐进输出:模型文本通过 ch.Stream() 实时流式输出,本地缓冲 + 异步刷新
  • Interactive approval cards: ApprovalRequest → Lark card buttons → Controller.Approve()
    交互审批卡片:审批请求 → 飞书卡片按钮 → Controller.Approve()
  • Clean output: Model text in streamed message, tool summary + token count in one markdown message
    干净输出:模型文本一条流式消息,工具摘要 + token 统计合并为一条 markdown 消息
  • Config: [lark] section with env-first credential resolution (app_id_env / app_secret_env), matching Provider pattern
    配置[lark] 段,支持 app_id_env/app_secret_env(与 Provider 的 api_key_env 模式一致)
  • CLI: reasonix lark subcommand
    CLIreasonix lark 子命令

Config Merge Fix / 配置保存修复

  • SaveTo() uses toml.Marshal() for existing files instead of full RenderTOML() rewrite, preserving unrecognized TOML sections (e.g. [lark]) across saves
    SaveTo() 对已有文件使用 toml.Marshal() 而非全量覆写,确保新 section 不被丢弃
  • First-run scaffolding still uses RenderTOML() for commented house style
    首次创建仍使用 RenderTOML() 生成带注释的脚手架配置

Files Changed / 文件变更

File / 文件 Change / 变更
internal/larkbot/ (new / 新增) Session manager, event adapter, approval handler, bot main loop
internal/config/config.go LarkConfig struct + accessor methods
internal/config/render.go [lark] section in RenderTOML()
internal/config/edit.go Merge-on-save via toml.Marshal()
internal/cli/cli.go + lark.go reasonix lark subcommand
go.mod / go.sum github.com/larksuite/oapi-sdk-go/v3 v3.9.4
reasonix.example.toml Example [lark] config section

Dependencies / 依赖

  • github.com/larksuite/oapi-sdk-go/v3 v3.9.4 (MIT)
    • Transitive: gorilla/websocket v1.5.0 (MIT), gogo/protobuf v1.3.2 (BSD)
    • All pure Go, no CGO, single-binary compatible
    • 全部纯 Go,无 CGO,兼容单二进制构建

Testing / 测试

  • Config resolution: defaults, env var fallback, ${VAR} expansion
    配置解析:默认值、环境变量回退、${VAR} 展开
  • Session router: creation, expiry, eviction, concurrency limits
    会话路由:创建、过期、驱逐、并发限制
  • Merge-save: existing file preserves unrecognized section, new file uses RenderTOML()
    合并保存:已有文件保留未识别段,新文件使用脚手架
  • Manual integration: end-to-end tested with live Lark app (message receive, streaming reply, approval card)
    手动集成:与真实飞书应用端到端测试

@0x0101010 0x0101010 requested a review from SivanCola as a code owner June 4, 2026 23:37
@github-actions github-actions Bot added the v2 Go rewrite (1.x) — main-v2 branch, active development label Jun 4, 2026
0x0101010 added 2 commits June 5, 2026 20:28
- New internal/larkbot package with session manager, event adapter,
  approval handler, and streaming output via SDK Channel module
- LarkConfig with env-first credential resolution (app_id_env / app_secret_env)
- Progressive streaming with local buffer + async flush (200ms ticker)
- Interactive approval cards and ask select menus via OnCardAction
- Multi-tenant session router with TTL expiry and concurrency limits
- CLI: reasonix lark subcommand
- Config: RenderTOML includes [lark] section for setup scaffolding
- Clean output: model text in stream, tool summary + token count in one markdown message
- Dependency: github.com/larksuite/oapi-sdk-go/v3 v3.9.4
- Tests: config resolution, session router lifecycle
…shal

RenderTOML only serializes sections it knows about, so new sections
(e.g. [lark]) were silently dropped when SaveTo overwrote the file.
Switch SaveTo to use toml.Marshal for existing files, which auto-
serializes all struct fields. First-run scaffolding still uses
RenderTOML for commented house style.
@wade19990814-hue
Copy link
Copy Markdown
Contributor

v2版本应该是暂时不考虑IM通道的,核心定位是高缓存的编程工具而不是OpenClaw式的AI助手,另外目前可以通过cc-connect实现了https://github.com/chenhg5/cc-connect,建议还是关注其他issue解决比较好🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v2 Go rewrite (1.x) — main-v2 branch, active development

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants