larkmate 0.1.0 → 0.1.1
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/README.md +2 -1
- 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/README.md
CHANGED
|
@@ -85,13 +85,14 @@ larkmate label-delete --label "$LABEL_ID"
|
|
|
85
85
|
larkmate minutes-list --limit 20
|
|
86
86
|
larkmate minutes-list --cursor "$CURSOR"
|
|
87
87
|
larkmate minutes-access-info --minute "$MINUTES_URL"
|
|
88
|
+
larkmate minutes-request-access --minute "$MINUTES_URL" --reason '需要查看会议文字记录'
|
|
88
89
|
larkmate minutes-export --minute "$MINUTES_URL" --output transcript.txt
|
|
89
90
|
larkmate minutes-export --minute "$MINUTES_URL" --format markdown --no-speakers --no-timestamps --output transcript.md
|
|
90
91
|
```
|
|
91
92
|
|
|
92
93
|
导出内容默认包含说话人与时间戳,可通过 `--no-speakers` 和 `--no-timestamps` 分别关闭。支持导出为本地 TXT 或 Markdown 文件;若未指定 `--output`,文本内容将输出至 JSON 结果的 `content` 字段中。为防止意外覆盖现有文件,指定的输出路径必须尚不存在。当字幕超过 10000 段或飞书返回的数据不完整时,程序将直接报错并终止,不会写入残缺记录。
|
|
93
94
|
|
|
94
|
-
`minutes-access-info`
|
|
95
|
+
`minutes-access-info` 查询妙记所有者及是否允许申请,不会发起申请。`minutes-request-access` 会向所有者发送查看权限申请,`--reason` 可省略;`submitted` 只表示申请已提交,仍需所有者同意。若返回 `EFFECT_UNKNOWN`,应先向所有者确认是否收到,避免重复申请。当前版本尚不支持创建飞书文档或查询没有录制妙记的历史会议。
|
|
95
96
|
|
|
96
97
|
## 发送消息和文件
|
|
97
98
|
|
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.1');
|
|
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 });
|