@aiwaretop/claw-feishu-user
v1.0.0
Published
OpenClaw Feishu plugin using user_access_token for document operations
Maintainers
Readme
claw-feishu-user
OpenClaw 飞书文档操作插件,使用 user_access_token 进行用户级别认证。
与内置 feishu 插件的区别
| 特性 | 内置 feishu 插件 | claw-feishu-user 插件 | |------|-----------------|----------------------| | 认证方式 | App ID / App Secret (机器人) | user_access_token (用户授权) | | 权限范围 | 应用权限 (tenant) | 用户权限 (user) | | 适用场景 | 机器人自动操作 | 用户个人文档操作 |
功能
- 📄 文档操作: 读取、创建、写入、追加、删除
- 📋 块操作: 列出块、获取块、更新块、删除块
- 🖼️ 图片处理: 支持 Markdown 中的图片自动上传到文档
安装
npm install @aiwaretop/claw-feishu-user
# 或
pnpm add @aiwaretop/claw-feishu-user配置
在 openclaw.json 中配置:
{
"plugins": {
"allow": ["feishu-user"],
"load": {
"paths": ["/path/to/claw-feishu-user"]
},
"entries": {
"feishu-user": {
"enabled": true,
"config": {
"user_access_token": "u-xxxxx",
"domain": "feishu"
}
}
}
}
}配置说明
| 参数 | 类型 | 必填 | 说明 |
|------|------|------|------|
| user_access_token | string | 是 | 飞书用户访问令牌 |
| domain | string | 否 | 飞书域名,feishu 或 lark,默认 feishu |
获取 user_access_token
在飞书开放平台创建应用并开通以下权限:
docx:document- 文档操作drive:drive.search:readonly- 云空间搜索search:docs:read- 文档搜索
使用以下授权链接获取授权码:
https://accounts.feishu.cn/open-apis/authen/v1/authorize?client_id={YOUR_APP_ID}&response_type=code&redirect_uri={YOUR_REDIRECT_URI}&scope=docx:document%20drive:drive.search:readonly%20search:docs:read- 用授权码换取 user_access_token:
curl -X POST "https://open.feishu.cn/open-apis/authen/v1/access_token" \
-H "Content-Type: application/json" \
-d '{
"grant_type": "authorization_code",
"code": "{YOUR_CODE}",
"app_id": "{YOUR_APP_ID}",
"app_secret": "{YOUR_APP_SECRET}"
}'使用工具
插件注册后,可使用 feishu_doc_user 工具:
// 读取文档
feishu_doc_user({
action: "read",
doc_token: "xxxxx"
})
// 创建文档
feishu_doc_user({
action: "create",
title: "新文档"
})
// 写入文档
feishu_doc_user({
action: "write",
doc_token: "xxxxx",
content: "# Hello World\n\n这是文档内容"
})
// 追加内容
feishu_doc_user({
action: "append",
doc_token: "xxxxx",
content: "## 追加的章节"
})支持的操作
| 操作 | 说明 |
|------|------|
| read | 读取文档内容 |
| write | 写入文档(覆盖原有内容) |
| append | 追加内容到文档末尾 |
| create | 创建新文档 |
| list_blocks | 列出文档中所有块 |
| get_block | 获取指定块的详细信息 |
| update_block | 更新指定块的内容 |
| delete_block | 删除文档中的指定块(⚠️ 仅删除块,不删除文档本身) |
开发
# 安装依赖
pnpm install
# 构建
pnpm build
# 测试
pnpm test许可证
AIWare Community License - 基于 Apache 2.0,允许商业使用。
