larkmate 0.1.10 → 0.1.11

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 CHANGED
@@ -36,6 +36,8 @@ npx --registry=https://registry.npmjs.org/ skills add NWYLZW/larkmate --skill la
36
36
  - [x] 查询、标记和取消标记会话
37
37
  - [x] 标记已读或未读、设置免打扰
38
38
  - [x] 移入或移出已完成、会话收纳
39
+ - [x] 按未读、免打扰、@我、单聊、群组等分组查询
40
+ - [x] 配置侧边栏分组的显示、隐藏、顺序和展示规则
39
41
  - [x] 创建、重命名和删除标签,管理手动标签下的会话
40
42
  - [ ] 修改自动规则标签的会话成员
41
43
  - 消息
@@ -56,6 +58,10 @@ npx --registry=https://registry.npmjs.org/ skills add NWYLZW/larkmate --skill la
56
58
  - [x] 邀请成员和机器人
57
59
  - [x] 查询和设置机器人的移除限制
58
60
  - [ ] 移除成员或退出群聊
61
+ - 飞书任务
62
+ - [x] 查询任务中心与任务视图,按关键词搜索任务
63
+ - [x] 新建、编辑、完成、重开和删除任务
64
+ - [x] 配置任务时间、负责人、关注人、重复规则及其他字段
59
65
  - 录制妙记
60
66
  - [x] 查询当前用户可访问的录制妙记
61
67
  - [x] 导出文字记录,支持说话人和时间戳
package/bin/larkmate.js CHANGED
@@ -5,14 +5,17 @@ import { Gateway } from '../src/gateway.js';
5
5
  import { LarkMateClient } from '../src/client.js';
6
6
  import { SessionControls } from '../src/session-controls.js';
7
7
  import { Minutes, formatTranscript } from '../src/minutes.js';
8
- import { writeFile } from 'node:fs/promises';
8
+ import { writeFile, readFile } from 'node:fs/promises';
9
9
  import { FeishuError } from '../src/errors.js';
10
10
  import { exportMessages } from '../src/export-messages.js';
11
11
  import { brokerCall, brokerCommands, brokerProxy, createBrokerToken, loadBrokerToken, loadPolicy, startBroker } from '../src/agent-broker.js';
12
12
  import { callOsDelegate, osDelegateProxy } from '../src/os-delegate-client.js';
13
+ import { SidebarFilters } from '../src/sidebar-filters.js';
14
+ import { FeedGroups } from '../src/feed-groups.js';
15
+ import { Tasks } from '../src/tasks.js';
13
16
 
14
17
  const program = new Command();
15
- program.name('larkmate').description('Operate Feishu as the logged-in user.').version('0.1.10');
18
+ program.name('larkmate').description('Operate Feishu as the logged-in user.').version('0.1.11');
16
19
  program.option('--credentials-file <path>', 'read LarkMate credentials.json');
17
20
  program.option('--broker <path>', 'use a restricted local broker socket (or LARKMATE_BROKER)');
18
21
  program.option('--broker-token-file <path>', 'read the agent token (or LARKMATE_BROKER_TOKEN_FILE)');
@@ -62,6 +65,21 @@ async function minutes() {
62
65
  return new Minutes(new Gateway({ cookie: await loadCookie({ file: program.opts().credentialsFile }) }));
63
66
  }
64
67
 
68
+ async function sidebar() {
69
+ const remote = proxy('sidebar');
70
+ if (remote) return remote;
71
+ return new SidebarFilters(new Gateway({ cookie: await loadCookie({ file: program.opts().credentialsFile }) }));
72
+ }
73
+
74
+ async function feeds() { const remote = proxy('feeds'); return remote || new FeedGroups(new Gateway({ cookie: await loadCookie({ file: program.opts().credentialsFile }) })); }
75
+ async function tasks() { const remote = proxy('tasks'); return remote || new Tasks(new Gateway({ cookie: await loadCookie({ file: program.opts().credentialsFile }) })); }
76
+ async function readJson(path, fallback) {
77
+ if (!path) return fallback;
78
+ let data; try { data = path === '-' ? await new Promise((resolve, reject) => { let text = ''; process.stdin.setEncoding('utf8'); process.stdin.on('data', x => { text += x; if (text.length > 1048576) reject(new Error()); }); process.stdin.on('end', () => resolve(text)); process.stdin.on('error', reject); }) : await readFile(path, 'utf8');
79
+ if (Buffer.byteLength(data) > 1048576) throw new Error(); return JSON.parse(data);
80
+ } catch { throw new FeishuError('INVALID_ARGUMENT', 'Cannot read JSON input (maximum 1 MiB).'); }
81
+ }
82
+
65
83
  program.command('broker-commands').description('List operations supported by the agent broker and their scopes.')
66
84
  .action(() => output({ items: brokerCommands() }));
67
85
 
@@ -90,7 +108,7 @@ program.command('broker-serve').description('Start a restricted local agent brok
90
108
  let promise;
91
109
  const getServices = () => promise ||= (async () => {
92
110
  const gateway = new Gateway({ cookie: await loadCookie({ file: program.opts().credentialsFile }) });
93
- return { client: new LarkMateClient(gateway), controls: new SessionControls(gateway), minutes: new Minutes(gateway) };
111
+ return { client: new LarkMateClient(gateway), controls: new SessionControls(gateway), minutes: new Minutes(gateway), sidebar: new SidebarFilters(gateway), feeds: new FeedGroups(gateway), tasks: new Tasks(gateway) };
94
112
  })().catch(error => { promise = undefined; throw error; });
95
113
  const broker = await startBroker({ socketPath: o.socket, policy, token, getServices });
96
114
  output({ status: 'listening', socket: broker.socketPath });
@@ -136,8 +154,59 @@ program.command('chats').description('List a page of inbox chats without opening
136
154
  output(page);
137
155
  });
138
156
 
157
+ program.command('group-query').description('Find feed items by sidebar group across pages.')
158
+ .requiredOption('--group <name>', 'messages, unread, muted, at_me, p2p, group, topic_group, docs, threads or done')
159
+ .option('--query <text>', 'filter names') .option('--limit <number>', 'feed page size', '100').option('--pages <number>', 'maximum pages to scan', '20')
160
+ .option('--cursor <cursor>', 'continue from the previous result').option('--parent <id>', 'search inside a box')
161
+ .action(async o => output(await (await feeds()).query({ group: o.group, query: o.query, limit: Number(o.limit), pages: Number(o.pages), cursor: o.cursor, parent: o.parent })));
162
+
163
+ program.command('task-center').description('List task containers, views and sections.').action(async () => output(await (await tasks()).center()));
164
+ program.command('tasks-list').description('List tasks from a task center view.')
165
+ .option('--scope <name>', 'mine, followed, all, created, assigned or completed', 'mine').option('--container <id>', 'task center container ID')
166
+ .option('--limit <number>', 'tasks per page', '50').option('--cursor <cursor>', 'continue from previous page')
167
+ .action(async o => output(await (await tasks()).list({ scope: o.scope, container: o.container, limit: Number(o.limit), cursor: o.cursor })));
168
+ program.command('task-search').description('Search accessible tasks.').requiredOption('--query <text>').option('--limit <number>', 'page size', '20').option('--cursor <cursor>')
169
+ .action(async o => output(await (await tasks()).search({ query: o.query, limit: Number(o.limit), cursor: o.cursor })));
170
+ program.command('task-get').description('Read a task.').requiredOption('--id <id>').action(async o => output(await (await tasks()).get({ taskId: o.id })));
171
+ program.command('task-create').description('Create a task.').option('--title <text>').option('--description <text>').option('--start <time>', 'milliseconds or ISO date')
172
+ .option('--due <time>', 'milliseconds or ISO date').option('--all-day', 'all-day task').option('--assignee <id>', 'repeatable user ID', collect, [])
173
+ .option('--follower <id>', 'repeatable user ID', collect, []).option('--list <id>', 'repeatable task list ID', collect, [])
174
+ .option('--repeat <rrule>', 'recurrence rule').option('--points <value>').option('--json <path>', 'full InputTask JSON, or - for stdin')
175
+ .action(async o => output(await (await tasks()).create({ input: await readJson(o.json, {}), title: o.title, description: o.description, start: o.start, due: o.due, allDay: o.allDay, assignees: o.assignee, followers: o.follower, lists: o.list, repeat: o.repeat, points: o.points })));
176
+ program.command('task-update').description('Update task fields and members.').requiredOption('--id <id>').option('--title <text>').option('--description <text>')
177
+ .option('--start <time>', 'milliseconds or ISO date; 0 clears').option('--due <time>', 'milliseconds or ISO date; 0 clears')
178
+ .option('--all-day <bool>', 'true or false').option('--repeat <rrule>').option('--points <value>').option('--milestone <bool>', 'true or false')
179
+ .option('--add-assignee <id>', 'repeatable user ID', collect, []).option('--remove-assignee <id>', 'repeatable user ID', collect, [])
180
+ .option('--add-follower <id>', 'repeatable user ID', collect, []).option('--remove-follower <id>', 'repeatable user ID', collect, [])
181
+ .option('--commits-json <path>', 'advanced commit array JSON, or - for stdin')
182
+ .action(async o => { const patch = {}; for (const key of ['title','description','start','due','repeat','points']) if (o[key] != null) patch[key] = o[key];
183
+ for (const key of ['allDay','milestone']) if (o[key] != null) { if (!['true','false'].includes(o[key])) throw new FeishuError('INVALID_ARGUMENT', key + ' must be true or false.'); patch[key] = o[key] === 'true'; }
184
+ for (const key of ['addAssignee','removeAssignee','addFollower','removeFollower']) if (o[key].length) patch[key + 's'] = o[key];
185
+ output(await (await tasks()).update({ taskId: o.id, patch, commits: await readJson(o.commitsJson, []) })); });
186
+ for (const [command, completed] of [['task-complete', true], ['task-reopen', false]]) program.command(command).description('Change task completion status.').requiredOption('--id <id>')
187
+ .option('--assignee <id>', 'repeatable assignee ID', collect, []).action(async o => output(await (await tasks()).complete({ taskId: o.id, completed, assignees: o.assignee })));
188
+ program.command('task-delete').description('Delete a task.').requiredOption('--id <id>').action(async o => output(await (await tasks()).delete({ taskId: o.id })));
189
+
139
190
  program.command('pinned').description('List pinned conversations.').action(async () => output(await (await controls()).pinned()));
140
191
  program.command('marked').description('List conversations marked with a flag.').action(async () => output(await (await controls()).marked()));
192
+ program.command('sidebar-list').description('List sidebar groups and display settings.').action(async () => output(await (await sidebar()).list()));
193
+ program.command('sidebar-set').description('Change sidebar group visibility, order or display settings.')
194
+ .requiredOption('--filter <name-or-id>', 'filter name from sidebar-list or numeric ID')
195
+ .option('--visibility <mode>', 'show or hide')
196
+ .option('--position <number>', 'one-based position among visible groups')
197
+ .option('--display <mode>', 'always, new or never in the message group')
198
+ .option('--message-type <type>', 'all, at_me, at_all or star_contacts; repeatable', collect, [])
199
+ .option('--at-all <mode>', 'include @all in the @me group: true or false')
200
+ .option('--show-filter <bool>', 'show the group sidebar: true or false')
201
+ .option('--show-mute-filter <bool>', 'show muted filter: true or false')
202
+ .option('--flag-sorting-rule <number>', 'native numeric flag sorting rule')
203
+ .option('--commonly-used <filter>', 'repeatable common filter name or ID', collect, [])
204
+ .action(async o => {
205
+ if (o.atAll != null && !['true', 'false'].includes(o.atAll)) throw new FeishuError('INVALID_ARGUMENT', 'at-all must be true or false.');
206
+ for (const k of ['showFilter', 'showMuteFilter']) if (o[k] != null && !['true', 'false'].includes(o[k])) throw new FeishuError('INVALID_ARGUMENT', k + ' must be true or false.');
207
+ output(await (await sidebar()).set({ filter: o.filter, visibility: o.visibility, ...(o.position != null ? { position: Number(o.position) } : {}),
208
+ display: o.display, ...(o.messageType.length ? { messageTypes: o.messageType } : {}), ...(o.atAll != null ? { atAll: o.atAll === 'true' } : {}), ...(o.showFilter != null ? { showFilter: o.showFilter === 'true' } : {}), ...(o.showMuteFilter != null ? { showMuteFilter: o.showMuteFilter === 'true' } : {}), ...(o.flagSortingRule != null ? { flagSortingRule: Number(o.flagSortingRule) } : {}), ...(o.commonlyUsed.length ? { commonlyUsedFilters: o.commonlyUsed } : {}) }));
209
+ });
141
210
  program.command('labels').description('List personal conversation labels.').action(async () => output(await (await controls()).labels()));
142
211
  program.command('label-chats').description('List conversations in a label.')
143
212
  .requiredOption('--label <id>', 'numeric label ID').action(async o => output(await (await controls()).labelChats(o.label)));
@@ -8,6 +8,9 @@ import { LarkMateClient } from '../src/client.js';
8
8
  import { SessionControls } from '../src/session-controls.js';
9
9
  import { Minutes } from '../src/minutes.js';
10
10
  import { FeishuError } from '../src/errors.js';
11
+ import { SidebarFilters } from '../src/sidebar-filters.js';
12
+ import { FeedGroups } from '../src/feed-groups.js';
13
+ import { Tasks } from '../src/tasks.js';
11
14
 
12
15
  try {
13
16
  const caller = process.env.SUDO_UID, owner = process.getuid?.();
@@ -18,7 +21,7 @@ try {
18
21
  let services;
19
22
  const getServices = () => services ||= (async () => {
20
23
  const gateway = new Gateway({ cookie: await loadCookie({ file: config.credentialsFile }) });
21
- return { client: new LarkMateClient(gateway), controls: new SessionControls(gateway), minutes: new Minutes(gateway) };
24
+ return { client: new LarkMateClient(gateway), controls: new SessionControls(gateway), minutes: new Minutes(gateway), sidebar: new SidebarFilters(gateway), feeds: new FeedGroups(gateway), tasks: new Tasks(gateway) };
22
25
  })();
23
26
  await serveOne({ input: process.stdin, output: process.stdout, uid: caller, profile, getServices });
24
27
  } catch (error) {
@@ -51,7 +51,7 @@ LarkMate 可以由持有 Cookie 的账户启动本地代理,再让 Agent 使
51
51
 
52
52
  `minutes-export`、`minutes-access-info` 和 `minutes-request-access` 按 `minuteTokens` 限制;申请权限会向妙记所有者提交请求。`minutes-list` 除须在 `allow` 中授权外,还必须同时开启 `allowGlobal` 和 `allowAllMinutes`。
53
53
 
54
- `status` 以及用于搜索用户、机器人、群聊的 `search` 需要开启 `allowGlobal`。跨会话搜索、会话及收藏列表、标签管理,以及仅凭消息 ID 操作的链接、编辑、撤回、转发、收藏和表情命令,除须在 `allow` 中各自授权外,还必须同时开启 `allowGlobal` 和 `allowAllChats`——这是因为代理无法仅凭消息 ID 判断其是否属于受限会话。群创建、邀请成员和机器人保护设置同样需要同时开启这两个开关。开启这些权限会扩大 Agent 可访问的信息范围或可执行的操作范围,请按需选择。
54
+ `status`、用于搜索用户、机器人、群聊的 `search`、`sidebar-list` 以及任务命令需要开启 `allowGlobal`。任务命令分别授权,当前授权范围覆盖该用户可访问的任务,不能按单个任务限制。`group-query` 和 `sidebar-set` 同时需要 `allowGlobal` 与 `allowAllChats`。跨会话搜索、会话及收藏列表、标签管理,以及仅凭消息 ID 操作的链接、编辑、撤回、转发、收藏和表情命令,除须在 `allow` 中各自授权外,还必须同时开启 `allowGlobal` 和 `allowAllChats`——这是因为代理无法仅凭消息 ID 判断其是否属于受限会话。群创建、邀请成员和机器人保护设置同样需要同时开启这两个开关。开启这些权限会扩大 Agent 可访问的信息范围或可执行的操作范围,请按需选择。
55
55
 
56
56
  `send-file`、`send-image` 与 `download-file` 均可单独加入 `allow` 列表,并受 `chatIds` 约束。发送时,由 Agent 进程读取本地文件并传输内容;下载时,由 Agent 进程创建输出文件。代理不接受 Agent 指定的代理端本地路径,而是在私有临时目录中处理中转文件,并在正常结束或失败时将其删除。若进程异常终止,可能会遗留临时文件,因此部署方应保护并按需清理代理账户的临时目录。
57
57
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "larkmate",
3
- "version": "0.1.10",
3
+ "version": "0.1.11",
4
4
  "description": "A small, user-identity Feishu CLI with a modular gateway client",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",
package/proto/lark.proto CHANGED
@@ -499,7 +499,11 @@ message PullFeedCardsResponse {
499
499
  map<string, Chat> chats = 1;
500
500
  repeated InboxCard cards = 3;
501
501
  optional int64 nextCursor = 4;
502
+ map<string, FeedDoc> docFeeds = 6;
503
+ map<string, FeedThread> threads = 8;
502
504
  }
505
+ message FeedDoc { optional string id = 1; optional string title = 2; optional string url = 5; optional int32 newMessageCount = 10; }
506
+ message FeedThread { optional string id = 1; optional string channelId = 2; optional string topic = 4; optional int32 newMessageCount = 10; }
503
507
  message CreateFileUploadRequest {
504
508
  optional int32 fileType = 3;
505
509
  optional string fileName = 5;
@@ -606,3 +610,40 @@ message BoxCardsRequest { map<string, int32> feedCards = 1; }
606
610
  message PatchFeedCardsRequest { optional int32 type = 1; repeated string ids = 2; repeated InboxCard cards = 3; }
607
611
  message PutReadMessagesRequest { optional string chatId = 1; repeated string messageIds = 2; optional int32 maxPosition = 3; }
608
612
  message PutReadMessagesResponse { optional int32 lastMessagePosition = 1; optional int32 newMessageCount = 2; optional int32 readPosition = 6; }
613
+
614
+ // --- Conversation sidebar filters (cmd 7022/7023) ---
615
+ message SidebarFilter { optional int32 systemFilter = 1; }
616
+ message SidebarDisplayRule { optional int32 mainRule = 1; repeated int32 msgTypes = 2 [packed=false]; }
617
+ message SidebarFilterSetting {
618
+ optional bool showFilter = 1;
619
+ repeated SidebarFilter usedFilters = 2;
620
+ optional int64 version = 3;
621
+ optional bool showMuteFilter = 4;
622
+ repeated SidebarFilter unusedFilters = 5;
623
+ optional bool showAtAllInAtFilter = 6;
624
+ repeated SidebarFilter commonlyUsedFilters = 7;
625
+ map<int32, int32> commonlyUsedFilterRealAction = 8;
626
+ optional int32 flagSortingRule = 9;
627
+ map<int32, SidebarDisplayRule> filterDisplayFeedRule = 10;
628
+ map<int32, int32> filterDisplayFeedRuleChanged = 11;
629
+ }
630
+ message PullSidebarFilterSettingRequest { optional bool needAllFilters = 1; optional int64 clientSupportVersion = 2; optional int64 clientSupportVersionV2 = 3; }
631
+ message PullSidebarFilterSettingResponse { optional SidebarFilterSetting setting = 1; repeated SidebarFilter allFilters = 2; optional bool isDefaultSetting = 3; }
632
+ message PutSidebarFilterSettingRequest {
633
+ optional bool showFilter = 1;
634
+ repeated SidebarFilter usedFilters = 2;
635
+ optional bool showMuteFilter = 3;
636
+ optional int64 clientSupportVersion = 4;
637
+ optional bool showAtAllInAtFilter = 5;
638
+ repeated SidebarFilter commonlyUsedFilters = 6;
639
+ optional int32 flagSortingRule = 7;
640
+ map<int32, SidebarDisplayRule> filterDisplayFeedRule = 8;
641
+ map<int64, SidebarDisplayRule> feedGroupDisplayFeedRule = 9;
642
+ optional int64 clientSupportVersionV2 = 10;
643
+ repeated int32 updateFields = 31 [packed=false];
644
+ }
645
+ message PutSidebarFilterSettingResponse { optional SidebarFilterSetting setting = 1; }
646
+ message PullUnreadAtMessageIdsRequest { optional int32 version = 1; repeated int64 messageIds = 2 [packed=false]; }
647
+ message PullUnreadAtMessageIdsResponse { repeated string messageIds = 1; map<string, string> messageThreadIds = 2; }
648
+ message PullMessagesByIdsRequest { repeated string messageIds = 1; }
649
+ message PullMessagesByIdsResponse { map<string, MessageEntity> messages = 1; }