Feishu Bot Cli Antigravity
基于 Google Antigravity SDK 和飞书开放平台构建的私人 AI 助手机器人命令行工具。
架构
flowchart LR
A[用户] -->|飞书消息 / 附件| B[飞书长连接网关]
B -->|下载文件至内存| C[Antigravity SDK / Agent]
C -->|流式思考与生成| B
B -->|CardKit / 消息回复| A
功能特点
- 服务监听模式 (
listen):- 基于长连接 (WebSocket) 监听飞书群聊与私聊消息。
- 自动将接收到的图片、代码、PDF、文本等多媒体附件直接下载至内存,以原生多模态对象传递给 Agent。
- 支持会话级消息排队锁 (
asyncio.Lock) 与AsyncExitStack上下文生命周期管理。 - 支持 CardKit 流式打字机卡片回复与普通消息兜底。
- 支持可选的
--chat-id过滤,仅服务指定会话。
- 命令行模式 (
send):- 命令行主动向指定会话发送消息或文件。
--chat-id为必须参数。- 支持发送文本、Markdown 格式消息或本地文件/图片。
环境配置
在项目根目录下配置 .env 文件:
LARK_APP_ID=cli_xxxxxxxxxxxxxx
LARK_APP_SECRET=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
GEMINI_API_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
LOG_LEVEL=INFO
命令行使用
1. 监听服务
启动长连接监听消息并自动调用 Agent 回复:
# 监听所有会话
uv run feishu-bot listen
# 仅监听并响应指定 chat_id 的消息
uv run feishu-bot listen --chat-id <oc_xxxxxxxxxxxx>
2. 主动发送消息
命令行主动向指定会话发送消息:
# 发送 Markdown 消息(--chat-id 为必填项)
uv run feishu-bot send --chat-id <oc_xxxxxxxxxxxx> --message "**你好!** 这是一条来自 CLI 的消息"
# 发送纯文本消息
uv run feishu-bot send --chat-id <oc_xxxxxxxxxxxx> -m "纯文本消息" --type text
# 发送本地文件或图片(支持同时指定多个文件及附带文本说明)
uv run feishu-bot send --chat-id <oc_xxxxxxxxxxxx> --file "./report.pdf" "./chart.png" -m "请查收本期分析报告"
# 从标准输入读取长文本/大段 Markdown(管道传输)
cat report.md | uv run feishu-bot send --chat-id <oc_xxxxxxxxxxxx> --stdin
# 或使用 -m -
cat report.md | uv run feishu-bot send --chat-id <oc_xxxxxxxxxxxx> -m -
# 交互式终端输入长文本(按 Ctrl+Z 回车或 Ctrl+D 结束输入)
uv run feishu-bot send --chat-id <oc_xxxxxxxxxxxx> --stdin
测试与代码检查
# 运行测试
uv run pytest
# 运行代码规范检查
uv run ruff check
Release files for feishu-bot-cli-antigravity 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| feishu_bot_cli_antigravity-0.1.1.tar.gz | 134.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| feishu_bot_cli_antigravity-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 149.1 kB
Release files / feishu_bot_cli_antigravity-0.1.1.tar.gz
| Download URL | feishu_bot_cli_antigravity-0.1.1.tar.gz |
|---|---|
| Size | 134.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a81607be1b48f93baab53f4fd58428c5650be2135d60234a77d34957d9183171
|
|
BLAKE2b-256 checksum How to use checksums |
8cdf5eef19ebe11000438d56c1e86dac59ff829e2f2b85054b12601a0b6f9efc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.13 {"installer":{"name":"uv","version":"0.12.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / feishu_bot_cli_antigravity-0.1.1-py3-none-any.whl
| Download URL | feishu_bot_cli_antigravity-0.1.1-py3-none-any.whl |
|---|---|
| Size | 14.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
68fa862c2867e8b3c6167196ee83cfb3394bd2139a0bbd83d09a87a1e45e1849
|
|
BLAKE2b-256 checksum How to use checksums |
ae19ba0c44c48bf3b2c482bd016c81c5feec48016345a8e227d1fb9ddced4c4b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.13 {"installer":{"name":"uv","version":"0.12.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|