larkmate 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/INSTALL.md +26 -3
- package/README.md +29 -3
- package/bin/larkmate.js +6 -1
- package/package.json +1 -1
- package/skills/larkmate/SKILL.md +3 -3
- package/skills/larkmate/references/minutes.md +2 -1
- package/src/minutes.js +37 -0
package/INSTALL.md
CHANGED
|
@@ -2,7 +2,30 @@
|
|
|
2
2
|
|
|
3
3
|
LarkMate 使用当前用户的飞书网页 Cookie,要求 Node.js 版本为 20 或更高。运行时无需安装 Lark CLI,也无需启动 Agent 服务。
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## 方式一:让 AI 安装
|
|
6
|
+
|
|
7
|
+
把下面的内容发给有本机终端访问能力的 AI 编程助手:
|
|
8
|
+
|
|
9
|
+
```text
|
|
10
|
+
请帮我在这台电脑上安装 LarkMate CLI 和当前 AI 助手适用的 LarkMate Skill。
|
|
11
|
+
项目地址:https://github.com/NWYLZW/larkmate
|
|
12
|
+
|
|
13
|
+
请检查 Node.js 版本(需要 20 或更新版本),并使用公共 npm 安装:
|
|
14
|
+
npm install -g larkmate --registry=https://registry.npmjs.org/
|
|
15
|
+
|
|
16
|
+
请为当前 AI 助手安装 Skill:
|
|
17
|
+
npx --registry=https://registry.npmjs.org/ skills add NWYLZW/larkmate --skill larkmate -g
|
|
18
|
+
非交互安装时,根据当前助手选择 --agent,并使用 -y。
|
|
19
|
+
|
|
20
|
+
请验证 CLI 和 Skill 均可用,保留已有的登录配置。如果尚未登录,请引导我在本机安全配置;
|
|
21
|
+
不要让我在对话中发送 Cookie、密码或验证码。完成后告诉我安装和登录状态。
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
AI 可以执行安装和检查;访问飞书需要有效 Cookie。如果尚未配置登录态,按 AI 的指引在本机完成,或参考下方的“配置登录态”。
|
|
25
|
+
|
|
26
|
+
## 方式二:手动安装
|
|
27
|
+
|
|
28
|
+
### 1. 安装命令
|
|
6
29
|
|
|
7
30
|
从公共 npm 安装后检查命令:
|
|
8
31
|
|
|
@@ -14,7 +37,7 @@ larkmate --help
|
|
|
14
37
|
|
|
15
38
|
也可以在源码目录执行 `npm ci`,通过 `node bin/larkmate.js --help` 使用 CLI;开发时执行 `npm link` 可将全局命令链接到该源码目录。
|
|
16
39
|
|
|
17
|
-
|
|
40
|
+
### 2. 配置登录态
|
|
18
41
|
|
|
19
42
|
登录飞书网页版后,在浏览器开发者工具中查找当前登录会话的飞书网页请求,并复制完整的 `Cookie` 请求头。Cookie 可以代表你的账号操作,请仅在本机保存,不要发给其他人、粘贴到聊天或写进终端命令。
|
|
20
43
|
|
|
@@ -39,7 +62,7 @@ larkmate status
|
|
|
39
62
|
|
|
40
63
|
如果已有可用的凭据文件,直接执行 `larkmate status`,不必覆盖它。Cookie 失效时更新文件后重试。也可以通过 `LARKMATE_HOME` 选择配置目录、`LARKMATE_COOKIE` 提供 Cookie,或使用全局选项 `--credentials-file` 指定同格式文件;读取优先级依次为:指定文件、环境变量、配置目录。
|
|
41
64
|
|
|
42
|
-
|
|
65
|
+
### 3. 安装 Agent Skill
|
|
43
66
|
|
|
44
67
|
使用 [skills](https://github.com/vercel-labs/skills) 从项目仓库安装 Skill,按提示选择 Agent:
|
|
45
68
|
|
package/README.md
CHANGED
|
@@ -4,14 +4,39 @@ LarkMate 是一个独立的飞书用户身份命令行工具,可以查询会
|
|
|
4
4
|
|
|
5
5
|
## 安装与登录
|
|
6
6
|
|
|
7
|
-
需要 Node.js 20
|
|
7
|
+
需要 Node.js 20 或更新版本。可以让 AI 帮你安装,也可以自己执行命令。
|
|
8
|
+
|
|
9
|
+
### 方式一:让 AI 安装
|
|
10
|
+
|
|
11
|
+
把下面的提示词发给有本机终端访问能力的 AI 编程助手,让它安装 CLI 和当前助手适用的 Skill:
|
|
12
|
+
|
|
13
|
+
```text
|
|
14
|
+
请帮我在这台电脑上安装 LarkMate CLI 和当前 AI 助手适用的 LarkMate Skill。
|
|
15
|
+
项目地址:https://github.com/NWYLZW/larkmate
|
|
16
|
+
|
|
17
|
+
请检查 Node.js 版本(需要 20 或更新版本),并使用公共 npm 安装:
|
|
18
|
+
npm install -g larkmate --registry=https://registry.npmjs.org/
|
|
19
|
+
|
|
20
|
+
请为当前 AI 助手安装 Skill:
|
|
21
|
+
npx --registry=https://registry.npmjs.org/ skills add NWYLZW/larkmate --skill larkmate -g
|
|
22
|
+
非交互安装时,根据当前助手选择 --agent,并使用 -y。
|
|
23
|
+
|
|
24
|
+
请验证 CLI 和 Skill 均可用,保留已有的登录配置。如果尚未登录,请引导我在本机安全配置;
|
|
25
|
+
不要让我在对话中发送 Cookie、密码或验证码。完成后告诉我安装和登录状态。
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
安装后访问飞书还需要用户的登录态;如果没有可用的 Cookie,AI 会引导你在本机配置。
|
|
29
|
+
|
|
30
|
+
### 方式二:手动安装
|
|
31
|
+
|
|
32
|
+
在终端运行:
|
|
8
33
|
|
|
9
34
|
```sh
|
|
10
35
|
npm install -g larkmate --registry=https://registry.npmjs.org/
|
|
11
36
|
npx --registry=https://registry.npmjs.org/ skills add NWYLZW/larkmate --skill larkmate -g
|
|
12
37
|
```
|
|
13
38
|
|
|
14
|
-
|
|
39
|
+
按提示选择需要安装 Skill 的 AI 助手。完整步骤、登录配置及源码安装方式见 [快速安装](INSTALL.md),Agent 使用指引见 [LarkMate Skill](skills/larkmate/SKILL.md)。
|
|
15
40
|
|
|
16
41
|
默认从 `~/.larkmate/credentials.json` 读取登录信息,格式为 `{ "cookie": "..." }`。将目录和文件分别设为仅当前用户可访问(权限 `700` 和 `600`)。也可以通过 `LARKMATE_HOME` 指定配置目录,或通过 `LARKMATE_COOKIE` 提供 Cookie;`--credentials-file` 可指定其他相同格式的文件。读取顺序为指定文件、环境变量、配置目录。不要把真实 Cookie 写进命令参数、聊天记录或代码仓库。Cookie 过期后需更新,再用 `larkmate status` 检查。
|
|
17
42
|
|
|
@@ -85,13 +110,14 @@ larkmate label-delete --label "$LABEL_ID"
|
|
|
85
110
|
larkmate minutes-list --limit 20
|
|
86
111
|
larkmate minutes-list --cursor "$CURSOR"
|
|
87
112
|
larkmate minutes-access-info --minute "$MINUTES_URL"
|
|
113
|
+
larkmate minutes-request-access --minute "$MINUTES_URL" --reason '需要查看会议文字记录'
|
|
88
114
|
larkmate minutes-export --minute "$MINUTES_URL" --output transcript.txt
|
|
89
115
|
larkmate minutes-export --minute "$MINUTES_URL" --format markdown --no-speakers --no-timestamps --output transcript.md
|
|
90
116
|
```
|
|
91
117
|
|
|
92
118
|
导出内容默认包含说话人与时间戳,可通过 `--no-speakers` 和 `--no-timestamps` 分别关闭。支持导出为本地 TXT 或 Markdown 文件;若未指定 `--output`,文本内容将输出至 JSON 结果的 `content` 字段中。为防止意外覆盖现有文件,指定的输出路径必须尚不存在。当字幕超过 10000 段或飞书返回的数据不完整时,程序将直接报错并终止,不会写入残缺记录。
|
|
93
119
|
|
|
94
|
-
`minutes-access-info`
|
|
120
|
+
`minutes-access-info` 查询妙记所有者及是否允许申请,不会发起申请。`minutes-request-access` 会向所有者发送查看权限申请,`--reason` 可省略;`submitted` 只表示申请已提交,仍需所有者同意。若返回 `EFFECT_UNKNOWN`,应先向所有者确认是否收到,避免重复申请。当前版本尚不支持创建飞书文档或查询没有录制妙记的历史会议。
|
|
95
121
|
|
|
96
122
|
## 发送消息和文件
|
|
97
123
|
|
package/bin/larkmate.js
CHANGED
|
@@ -9,7 +9,7 @@ import { writeFile } from 'node:fs/promises';
|
|
|
9
9
|
import { FeishuError } from '../src/errors.js';
|
|
10
10
|
|
|
11
11
|
const program = new Command();
|
|
12
|
-
program.name('larkmate').description('Operate Feishu as the logged-in user.').version('0.1.
|
|
12
|
+
program.name('larkmate').description('Operate Feishu as the logged-in user.').version('0.1.2');
|
|
13
13
|
program.option('--credentials-file <path>', 'read LarkMate credentials.json');
|
|
14
14
|
program.exitOverride();
|
|
15
15
|
|
|
@@ -95,6 +95,11 @@ program.command('minutes-access-info').description('Check who owns a recording a
|
|
|
95
95
|
.requiredOption('--minute <token-or-url>', 'recording minutes token or URL')
|
|
96
96
|
.action(async o => output(await (await minutes()).accessInfo(o.minute)));
|
|
97
97
|
|
|
98
|
+
program.command('minutes-request-access').description('Request access from the recording owner.')
|
|
99
|
+
.requiredOption('--minute <token-or-url>', 'recording minutes token or URL')
|
|
100
|
+
.option('--reason <text>', 'optional request message', '')
|
|
101
|
+
.action(async o => output(await (await minutes()).requestAccess(o.minute, { reason: o.reason })));
|
|
102
|
+
|
|
98
103
|
program.command('minutes-export').description('Export a complete recording transcript.')
|
|
99
104
|
.requiredOption('--minute <token-or-url>', 'recording minutes token or URL')
|
|
100
105
|
.option('--format <format>', 'txt or markdown', 'txt')
|
package/package.json
CHANGED
package/skills/larkmate/SKILL.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: larkmate
|
|
3
|
-
description: 使用 LarkMate
|
|
3
|
+
description: 使用 LarkMate 以当前飞书网页用户身份查询和管理会话、读取消息、发送文本或文件、操作群组,以及查询录制妙记、申请访问和导出文字记录。当用户要求使用 LarkMate 或需要这些个人飞书操作时使用;不负责飞书文档或日历。
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# LarkMate
|
|
@@ -11,8 +11,8 @@ description: 使用 LarkMate 以当前飞书网页用户身份查询和管理会
|
|
|
11
11
|
|
|
12
12
|
- 查找会话、阅读历史、会话状态和标签: [会话与消息](references/chats.md)。
|
|
13
13
|
- 发送消息或文件、管理群组和成员: [发送与群组](references/writes.md)。
|
|
14
|
-
-
|
|
14
|
+
- 查找录制妙记、导出文字记录、查询或申请访问权限: [录制妙记](references/minutes.md)。
|
|
15
15
|
|
|
16
16
|
命令输出 JSON:成功为 `ok: true`,失败为 `ok: false`,检查退出码和错误信息。飞书网页客户端数字 ID 与开放平台 ID 不同;按实际查询结果选定对象,名称相近时先消歧。列表和搜索有分页或扫描范围,无法读取的内容、缺失结果和权限错误应如实说明。
|
|
17
17
|
|
|
18
|
-
`chat-open`
|
|
18
|
+
`chat-open` 会打开或创建私聊,发送、群组、会话状态和妙记权限申请命令也会修改数据;按照用户的实际意图操作。写入返回 `EFFECT_UNKNOWN`、`submitted_unconfirmed` 或部分成功时,先查询实际状态,避免重复提交。不要将消息已发送当作对方已读。
|
|
@@ -4,10 +4,11 @@
|
|
|
4
4
|
larkmate minutes-list --limit 20
|
|
5
5
|
larkmate minutes-list --cursor "$NEXT_CURSOR"
|
|
6
6
|
larkmate minutes-access-info --minute "$MINUTES_URL"
|
|
7
|
+
larkmate minutes-request-access --minute "$MINUTES_URL" --reason '需要查看会议文字记录'
|
|
7
8
|
larkmate minutes-export --minute "$MINUTES_URL" --output transcript.txt
|
|
8
9
|
larkmate minutes-export --minute "$MINUTES_URL" --format markdown --output transcript.md
|
|
9
10
|
```
|
|
10
11
|
|
|
11
12
|
`minutes-list` 列出当前用户可访问的录制妙记,使用 `nextCursor` 继续翻页;`--minute` 接受妙记链接或列表中的 `object_token`。导出默认包含说话人和时间戳,分别用 `--no-speakers` 和 `--no-timestamps` 关闭。不指定 `--output` 时,文本位于 JSON 输出的 `content` 字段;指定文件必须不存在。字幕超过 10000 段或数据不完整时命令报错,不会写出残缺记录。
|
|
12
13
|
|
|
13
|
-
`minutes-access-info`
|
|
14
|
+
`minutes-access-info` 只读所有者和是否允许申请;`minutes-request-access` 会向所有者提交查看权限申请,仅在用户有此意图时执行,`--reason` 可省略。`submitted` 表示已提交,不能当作已获得权限;`EFFECT_UNKNOWN` 表示结果不确定,先确认是否收到,避免重复申请。当前不支持创建飞书文档、查询没有录制妙记的历史会议或获取会议智能纪要;不要把录制文字记录说成智能纪要。
|
package/src/minutes.js
CHANGED
|
@@ -59,6 +59,43 @@ export class Minutes {
|
|
|
59
59
|
return { ownerId: result.owner_user_id || null, ownerName: result.owner_name || null, allowApply: result.allow_apply, notAllowedTips: result.not_allowed_tips || null };
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
+
async requestAccess(value, { reason = '' } = {}) {
|
|
63
|
+
const token = minuteToken(value);
|
|
64
|
+
if (typeof reason !== 'string' || [...reason].length > 600) throw new FeishuError('INVALID_ARGUMENT', 'The request reason must be at most 600 characters.');
|
|
65
|
+
const info = await this.accessInfo(token);
|
|
66
|
+
if (!info.allowApply) throw new FeishuError('MINUTES_APPLY_NOT_ALLOWED', 'The owner does not allow access requests for this recording.', { ownerName: info.ownerName, notAllowedTips: info.notAllowedTips });
|
|
67
|
+
|
|
68
|
+
// The minutes page sets the CSRF cookie used by the web client's write requests.
|
|
69
|
+
const pageUrl = `https://meetings.feishu.cn/minutes/${token}`;
|
|
70
|
+
let page;
|
|
71
|
+
try {
|
|
72
|
+
page = await this.gateway.fetchImpl(pageUrl, { headers: this.gateway.baseHeaders(), redirect: 'manual', signal: AbortSignal.timeout(this.gateway.timeoutMs) });
|
|
73
|
+
} catch { throw new FeishuError('REQUEST_FAILED', 'Could not prepare the Feishu minutes session; no request was sent.'); }
|
|
74
|
+
if (![200, 301, 302, 303, 307, 308].includes(page.status)) throw new FeishuError('REQUEST_FAILED', 'Could not prepare the Feishu minutes session; no request was sent.', { httpStatus: page.status });
|
|
75
|
+
this.gateway.absorbCookies(page.headers);
|
|
76
|
+
const csrf = this.gateway.jar.get('bv_csrf_token');
|
|
77
|
+
if (!csrf) throw new FeishuError('MINUTES_CSRF_UNAVAILABLE', 'Feishu did not provide a CSRF token; no request was sent.');
|
|
78
|
+
|
|
79
|
+
let response;
|
|
80
|
+
try {
|
|
81
|
+
response = await this.gateway.fetchImpl(new URL('permission/apply/action', BASE), {
|
|
82
|
+
method: 'POST', redirect: 'manual', signal: AbortSignal.timeout(this.gateway.timeoutMs),
|
|
83
|
+
headers: { ...this.gateway.baseHeaders(), origin: 'https://meetings.feishu.cn', referer: pageUrl,
|
|
84
|
+
'content-type': 'application/x-www-form-urlencoded', 'bv-csrf-token': csrf, platform: 'web' },
|
|
85
|
+
body: new URLSearchParams({ remark: reason, object_token: token, language: 'zh_cn' }),
|
|
86
|
+
});
|
|
87
|
+
} catch { throw new FeishuError('EFFECT_UNKNOWN', 'The access request may have been submitted; check with the owner before retrying.'); }
|
|
88
|
+
if (response.status >= 500 || response.status === 408 || response.status === 429 || response.status >= 300 && response.status < 400) {
|
|
89
|
+
throw new FeishuError('EFFECT_UNKNOWN', 'The access request may have been submitted; check with the owner before retrying.', { httpStatus: response.status });
|
|
90
|
+
}
|
|
91
|
+
if (!response.ok) throw new FeishuError('MINUTES_APPLY_REJECTED', 'Feishu rejected the access request.', { httpStatus: response.status });
|
|
92
|
+
let payload;
|
|
93
|
+
try { payload = await response.json(); } catch { throw new FeishuError('EFFECT_UNKNOWN', 'The access request may have been submitted; check with the owner before retrying.'); }
|
|
94
|
+
if (typeof payload?.code !== 'number') throw new FeishuError('EFFECT_UNKNOWN', 'The access request may have been submitted; check with the owner before retrying.');
|
|
95
|
+
if (payload.code !== 0) throw new FeishuError('MINUTES_APPLY_REJECTED', 'Feishu rejected the access request.', { upstreamCode: payload.code });
|
|
96
|
+
return { status: 'submitted', ownerName: info.ownerName, message: 'Request submitted; access still requires the owner to approve it.' };
|
|
97
|
+
}
|
|
98
|
+
|
|
62
99
|
async transcript(value) {
|
|
63
100
|
const token = minuteToken(value), query = { object_token: token, language: 'zh_cn' };
|
|
64
101
|
const ids = await this.get('subtitles/paragraph-ids', { page_size: 10000, page_num: 0, ...query });
|