feat: Add Lark (Feishu) Integration Support#24
Closed
luw2007 wants to merge 250 commits into
Closed
Conversation
added 30 commits
December 16, 2025 15:03
Implements comprehensive token management with intelligent priority resolution. Token sources (highest to lowest priority): environment variable, settings file, interactive prompt. Changes include: - Updated home directory from ~/.happy to ~/.config/hapi (env var: HAPI_HOME_DIR) - Added cliApiToken field to Settings interface for persistent storage - Made cliApiToken mutable in Configuration class (private field with getter/setter) - Created ui/tokenInit.ts module for token initialization with fallback prompt - Enhanced auth command: login (interactive input), logout (clear token), status (show source) - Updated doctor command to correctly identify token source and mask saved token in output - Token initialization called early in startup flow to ensure availability before API use
…red chat UI components
…d settings integration Extract word detection and suggestion logic into reusable utilities and hooks. Add FloatingOverlay and Autocomplete components for intelligent input assistance. Integrate settings panel and abort button directly into ChatInput component. Simplify SessionHeader by removing settings dialog (now in ChatInput).
- Display connection status indicators (online, offline, thinking, permission required) in ChatInput with dynamic vibing messages - Add context size percentage display showing remaining context availability - Track latest usage data in reducer with inputTokens, outputTokens, cache metrics, and contextSize - Calculate contextSize from message usage data and expose via latestUsage in reduceChatBlocks - Pass thinking, agentState, and contextSize props to ChatInput component - Remove redundant status indicators from SessionHeader (moved to ChatInput for unified display)
Adds todo tracking infrastructure with TodoWrite tool integration to extract and persist todos in sessions. Refactors ToolCard component to support custom tool view rendering and displays todo progress in SessionList.
… support - Unify session title logic across components to check metadata.name first - Add Telegram Web App detection with re-check after mount - Hide header and buttons when running in Telegram environment - Replace host display with path information in session details - Remove unused Badge components for session status - Simplify SessionList and SessionHeader layouts
Remove 5 unused component files that were not imported anywhere: - SessionDetail.tsx (replaced by SessionChat) - PermissionPanel.tsx (only used by dead SessionDetail) - MessageList.tsx - PermissionBanner.tsx - PermissionDialog.tsx Confirmed via grep searches and successful build.
Add underscore to the regex pattern in getProjectPath to ensure underscores are replaced with hyphens, along with existing handling for slashes, colons, and dots. Includes test case for paths with underscores.
…ant-ui/react compatibility
- Refactor HappyComposer settings overlay to conditionally render permission and model settings based on their availability - Add showPermissionSettings and showModelSettings flags for cleaner conditional rendering - Enhance ToolMessage fallback UI with styled card layout and code blocks for arguments and results - Improve type validation in isToolCallBlock with comprehensive property checks - Add safeStringify utility for robust JSON serialization with fallback handling
Owner
|
可以给权限请求卡片加上 deeplink,让 PWA 程序自行处理;为了权限卡片的两个按钮引入这么多机制太复杂了。 |
added 3 commits
December 31, 2025 11:16
Simplify environment handling by removing the getCleanEnv() function that was filtering out local node_modules/.bin paths. Running from home directory is sufficient to avoid local cwd side effects.
…hanumeric pattern Update the regex in getProjectPath to replace all non-alphanumeric characters with dashes instead of only specific ones. This provides more robust handling of edge cases in working directory paths.
- Add LICENSE file to root and cli/ directories with LGPL-3.0-or-later text - Create cli/NOTICE file with MIT attribution for happy-cli derived code - Update license field in cli/, server/, and web/ package.json to "LGPL-3.0-or-later" - Add NOTICE to cli/package.json files array for npm publishing
added 6 commits
December 31, 2025 17:24
- Initialize VitePress documentation site with config, index, and guides - Add guides for quick-start, installation, PWA, how-it-works, FAQ, and why HAPI - Update .gitignore to exclude VitePress cache directory - Update logo.svg with actual icon from web/public/icon.svg - Simplify README.md with link to full installation guide - Remove redundant WHY_NOT_HAPPY.md (content migrated to why-hapi guide)
Implement namespace support across sessions, machines, and users for multi-user server deployments. Add access control with specific error reasons (namespace-missing, access-denied, not-found) and database schema updates with namespace columns and indexes.
24d29f4 to
f8c43a0
Compare
added 5 commits
January 1, 2026 02:00
…TOKEN 等) - 实现 LarkWipNotifier 用于 WIP 任务通知(当前仅日志记录) - 新增 LarkClient 封装飞书 API 调用(获取 tenant_access_token、发送消息等) - 新增 LarkCardBuilder 构建飞书卡片消息 - 新增 webhook 路由处理飞书事件回调(URL 验证、消息接收) - 新增 action 路由处理飞书卡片交互(标记完成、跳过等) - 更新认证中间件,允许飞书 webhook 端点无需 JWT 验证 - 配置项支持环境变量和配置文件两种方式,优先级:env > file > default
- 新增 cardBuilder.ts: 飞书消息卡片构建器 - 新增 messageConverter.ts: Claude Code 消息转飞书卡片 - 新增 useLark.ts: 飞书环境检测和 SDK 加载 - 新增 usePlatformNavigation.ts: 平台导航适配 - 更新 larkWipNotifier.ts: 集成消息转换和斜杠命令 - 更新 lark.ts: 支持 im.message.receive_v1 事件 - 更新 auth.ts: 支持飞书免登认证 - 更新 git.ts: 添加文件写入 API - 更新 file.tsx: 添加移动端简易编辑器 - 更新 DiffView.tsx: 触屏优化 斜杠命令支持: - /sessions: 列出所有会话 - /switch <id>: 切换会话 - /history: 查看历史 - /status: 查看状态 - /help: 帮助信息
动机: - 兼容飞书官方 URL verification 请求格式,减少对 header.token 的强依赖 改动: - 将 header.token/headers 设置为可选 - 支持顶层 token 字段 - 新增测试用例:无 header 的 URL verification;顶层 token 验证 验证: - 单元测试通过(4/4) - curl 返回 challenge
动机: - 提供无需公网的实时事件通道,适配企业内网 改动: - 新增 LarkWebSocketClient:事件去重(LRU)、P2P 映射、会话绑定、连接状态监控 - 集成 SyncEngine 订阅,将服务端消息回发至飞书 - 更新配置系统,支持 LARK_USE_WEBSOCKET 开关 - 依赖新增:@larksuiteoapi/node-sdk@^1.43.0, lru-cache@^11.0.2 配置: - LARK_ENABLED, LARK_USE_WEBSOCKET, APP_ID, APP_SECRET 验证: - 本地 WS 启动成功 - 收到 im.message.receive_v1 事件并路由至 SyncEngine
动机: - 统一忽略规则,防止误追踪运行时数据 - 降低工具消息缓存泄漏风险,提升稳定性 改动: - .gitignore: 修正 .hapi-data/** 规则 - server/src/lark/larkWebSocketClient.ts: 切换工具消息缓存为 LRUCache(容量 500, TTL 5 分钟) - server/src/lark/larkWebSocketClient.ts: 移除 as any 断言,提升类型安全 - server/src/sync/syncEngine.ts: 优化日志与类型断言 验证: - 本地运行与类型检查通过
f8c43a0 to
4819495
Compare
added 3 commits
January 1, 2026 08:38
## New Features - Add modular command system with parser, registry, and router - Implement HAPI commands: sessions, switch, info, approve, deny, mode, history, help - Support shortcut commands: /s, /sw, /i, /h, /y, /n, /? - Support special prefixes: ! (shell), @ (file reference) - Native command passthrough with messageType field ## Architecture - server/src/commands/ - Command system module - types.ts - Type definitions - parser.ts - Command parser with shortcut expansion - registry.ts - Command registry - router.ts - Command router (HAPI vs native) - hapi/ - HAPI command implementations - cards/ - Lark card builders ## Integration - larkWebSocketClient.ts - Add command routing for WebSocket mode - larkWipNotifier.ts - Refactor to use new command router - syncEngine.ts - Add messageType field to sendMessage - CLI: Add messageType support in types and specialCommands ## P0 Features Complete - /hapi_sessions, /hapi_switch, /hapi_info - /hapi_approve, /hapi_deny, /hapi_mode - /hapi_history, /help - All shortcut commands - Native command passthrough
feat(lark): implement slash command system for Lark Bot
Implement remaining slash commands for Lark Bot: P1 Commands: - /hapi_bind - bind chat to session - /hapi_unbind - unbind chat from session - /hapi_summary - generate conversation summary P2 Commands: - /hapi_new - create new session on machine - /hapi_close - close session - /hapi_rename - rename session - /hapi_notify - toggle notifications - /hapi_mute - mute notifications with duration P3 Commands: - /hapi_machines - list connected machines - /hapi_stats - view system statistics - /hapi_ping - check connection status - /hapi_version - show version info Also: - Extend CommandContext with unbindChat and getAllBindings - Add machineCards.ts for machine list card builder - Export isNotifyEnabled for notification control
Author
|
实现了 ws 和 command 。 目前看基本可用了。 |
feat(lark): 飞书 Bot 斜杠命令系统完整实现
Owner
|
你是在 Chat 框里实现了 session 管理?这样如果切换 session 会话是混合在一起吗? 我最开始也是从 Telegram Bot 在聊天框管理会话,但是这个多个 session 处理非常不方便,后来才换成小程序的。 |
added 2 commits
January 4, 2026 08:07
- Add cliApiToken to ConfigSources initialization - Add larkUseWebSocket to Settings interface - Export InteractiveCard type from cardBuilder - Fix LarkMessageEvent type to match SDK expectations - Fix type assertions in messageConverter - Remove invalid padding property from collapsible_panel
server: 增强 Lark 客户端与 WebSocket、消息转换与卡片构建;完善命令路由与权限/会话管理 server: 新增交互卡片、会话创建与统计卡片 cli: 新增 testStatus 脚本与原始测试脚本,完善日志转换单测 docs: 新增 agent 集成指南 chore: 同步 sync 引擎与 store 逻辑,细化类型定义
a11412e to
cfb48fb
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.
Summary
This PR adds Lark (Feishu) integration support to HAPI, enabling notifications and interactive controls through Lark's messaging platform.
Changes
LarkWipNotifier: Handles WIP task notifications (currently log-only)LarkClient: Encapsulates Lark API calls (tenant_access_token, message sending, etc.)LarkCardBuilder: Constructs Lark card messages/lark/webhook: Handles Lark event callbacks (URL verification, message receiving)/lark/action: Handles Lark card interactions (mark complete, skip, etc.)Test Plan
Similar to Telegram Integration
This implementation follows a similar pattern to the existing Telegram integration, providing an alternative messaging platform for users in regions where Lark/Feishu is more commonly used.
🤖 Generated with Claude Code
Co-Authored-By: Claude Sonnet 4.5 noreply@anthropic.com