@ai-setting/roy-agent-core 1.7.85 → 1.7.89
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/dist/config/index.js +7 -7
- package/dist/env/agent/agent-component.d.ts +1 -1
- package/dist/env/agent/agent-component.js +13 -12
- package/dist/env/agent/index.js +13 -12
- package/dist/env/agent/types.d.ts +14 -0
- package/dist/env/commands/index.js +7 -7
- package/dist/env/context/index.js +3 -3
- package/dist/env/debug/index.js +7 -7
- package/dist/env/error-reply.js +1 -1
- package/dist/env/event-source/event-source-handlers.d.ts +18 -2
- package/dist/env/event-source/event-source-handlers.js +26 -21
- package/dist/env/event-source/event-store.js +2 -2
- package/dist/env/event-source/index.js +25 -22
- package/dist/env/event-source/timer-handler.d.ts +98 -0
- package/dist/env/event-source/types.d.ts +53 -1
- package/dist/env/event-source/wecom-card-action-handler.d.ts +235 -3
- package/dist/env/event-source/wecom-card-builder.d.ts +207 -1
- package/dist/env/event-source/wecom-cli-handler.d.ts +25 -0
- package/dist/{shared/@ai-setting/roy-agent-core-vyr6svt6.js → env/event-source/wecom-respond-registry.js} +8 -6
- package/dist/env/event-source/wecom-session-card-sender.d.ts +135 -0
- package/dist/env/event-source/wecom-session-card-sender.js +153 -0
- package/dist/env/hook/index.js +5 -5
- package/dist/env/index.js +50 -45
- package/dist/env/llm/index.js +9 -8
- package/dist/env/log-trace/index.js +7 -7
- package/dist/env/log-trace/trace-filters.d.ts +6 -1
- package/dist/env/mcp/index.js +7 -7
- package/dist/env/memory/index.js +7 -7
- package/dist/env/plugin/index.js +7 -7
- package/dist/env/prompt/index.js +8 -8
- package/dist/env/prompt/prompts-index.d.ts +1 -1
- package/dist/env/session/group-session-link.d.ts +99 -0
- package/dist/env/session/index.js +11 -10
- package/dist/env/session/session-component.d.ts +89 -0
- package/dist/env/session/storage/index.js +5 -4
- package/dist/env/session/types.d.ts +10 -0
- package/dist/env/skill/index.js +7 -7
- package/dist/env/task/backend/index.d.ts +3 -0
- package/dist/env/task/backend/index.js +151 -3
- package/dist/env/task/backend/remote-task-port.d.ts +85 -0
- package/dist/env/task/backend/types.d.ts +5 -0
- package/dist/env/task/delegate/delegate-channel-hint.d.ts +39 -0
- package/dist/env/task/delegate/delegate-tool.d.ts +71 -6
- package/dist/env/task/delegate/delegate-tool.js +11 -9
- package/dist/env/task/delegate/index.js +8 -8
- package/dist/env/task/index.d.ts +1 -1
- package/dist/env/task/index.js +34 -18
- package/dist/env/task/mcp/index.js +4 -4
- package/dist/env/task/plugins/card-subject.d.ts +117 -0
- package/dist/env/task/plugins/index.js +19 -17
- package/dist/env/task/plugins/lark-card-action-handler.d.ts +261 -6
- package/dist/env/task/plugins/lark-card-patch-notifier.d.ts +501 -0
- package/dist/env/task/plugins/lark-card-patch-notifier.js +12 -2
- package/dist/env/task/plugins/lark-card-state-store.d.ts +60 -0
- package/dist/env/task/plugins/lark-cli-task-notify-plugin.d.ts +45 -0
- package/dist/env/task/plugins/sub-session-activity.d.ts +415 -0
- package/dist/env/task/plugins/wecom-session-card-store.d.ts +134 -0
- package/dist/env/task/plugins/wecom-session-card-store.js +23 -0
- package/dist/env/task/plugins/wecom-task-notify-plugin.d.ts +40 -0
- package/dist/env/task/storage/index.d.ts +1 -0
- package/dist/env/task/storage/index.js +24 -4
- package/dist/env/task/storage/migrations/006_add_task_owner.d.ts +24 -0
- package/dist/env/task/storage/remote-task-store.d.ts +186 -0
- package/dist/env/task/task-component.d.ts +7 -0
- package/dist/env/task/tools/index.js +4 -4
- package/dist/env/task/tools/task-types.d.ts +7 -0
- package/dist/env/task/types.d.ts +17 -0
- package/dist/env/tool/built-in/index.js +6 -4
- package/dist/env/tool/index.js +14 -10
- package/dist/env/tool/types.d.ts +25 -0
- package/dist/env/tool/validator.d.ts +8 -0
- package/dist/env/workflow/engine/index.js +12 -12
- package/dist/env/workflow/hooks/index.js +7 -7
- package/dist/env/workflow/index.js +24 -23
- package/dist/env/workflow/nodes/index.js +2 -2
- package/dist/env/workflow/plugins/index.js +10 -8
- package/dist/env/workflow/service/index.js +2 -2
- package/dist/env/workflow/storage/index.js +3 -3
- package/dist/env/workflow/tools/index.js +16 -15
- package/dist/env/workflow/utils/index.js +4 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.js +71 -60
- package/dist/shared/@ai-setting/{roy-agent-core-q813vafd.js → roy-agent-core-05z35shp.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-dc9zq75z.js → roy-agent-core-0crmsc12.js} +3 -3
- package/dist/shared/@ai-setting/{roy-agent-core-7dd0s3xb.js → roy-agent-core-0n1wwndq.js} +1027 -14
- package/dist/shared/@ai-setting/{roy-agent-core-cha0jc7n.js → roy-agent-core-0sbmdz8d.js} +137 -16
- package/dist/shared/@ai-setting/{roy-agent-core-87942bw4.js → roy-agent-core-1mhyh4c5.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-v6vr6za7.js → roy-agent-core-1vv4fx15.js} +4 -4
- package/dist/shared/@ai-setting/{roy-agent-core-nwbfepba.js → roy-agent-core-3e040tc5.js} +1 -1
- package/dist/shared/@ai-setting/roy-agent-core-418zc9ha.js +288 -0
- package/dist/shared/@ai-setting/{roy-agent-core-qk9hd89p.js → roy-agent-core-49qcpqwg.js} +54 -19
- package/dist/shared/@ai-setting/{roy-agent-core-xf6z96qy.js → roy-agent-core-4b38m749.js} +818 -346
- package/dist/shared/@ai-setting/{roy-agent-core-r5wt1h3c.js → roy-agent-core-4fkxy2gv.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-na18zwj0.js → roy-agent-core-4t3yskp8.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-d1n4jbza.js → roy-agent-core-5dhvfgaw.js} +5 -5
- package/dist/shared/@ai-setting/{roy-agent-core-5pr4zp88.js → roy-agent-core-5kzhaap1.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-qq96p0tj.js → roy-agent-core-5s2t8z00.js} +22 -1
- package/dist/shared/@ai-setting/{roy-agent-core-6rh8k6ba.js → roy-agent-core-6gj1hc5z.js} +7 -7
- package/dist/shared/@ai-setting/{roy-agent-core-g8htfwxj.js → roy-agent-core-7f10p7m2.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-h21gngxf.js → roy-agent-core-7yh5wps0.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-efkjyh69.js → roy-agent-core-9710zwwz.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-rykf7c04.js → roy-agent-core-9c565frx.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-vffccgf6.js → roy-agent-core-9cen1jvg.js} +18 -7
- package/dist/shared/@ai-setting/{roy-agent-core-fghc2m8z.js → roy-agent-core-aa8kv18f.js} +34 -2
- package/dist/shared/@ai-setting/roy-agent-core-age3qseb.js +177 -0
- package/dist/shared/@ai-setting/{roy-agent-core-7bpj859q.js → roy-agent-core-azyz78ky.js} +7 -7
- package/dist/shared/@ai-setting/{roy-agent-core-264qexac.js → roy-agent-core-b7h39vrc.js} +4 -4
- package/dist/shared/@ai-setting/{roy-agent-core-dqxec05w.js → roy-agent-core-bjtc9d35.js} +2 -2
- package/dist/shared/@ai-setting/roy-agent-core-c4ec7k0p.js +426 -0
- package/dist/shared/@ai-setting/{roy-agent-core-ddyk1rc0.js → roy-agent-core-cre2y2ct.js} +160 -4
- package/dist/shared/@ai-setting/{roy-agent-core-tr3ep81v.js → roy-agent-core-d6zdbgtc.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-0qyrk5k0.js → roy-agent-core-ds6qzmf8.js} +14 -5
- package/dist/shared/@ai-setting/{roy-agent-core-p6ks90tb.js → roy-agent-core-dvec4nn2.js} +6 -6
- package/dist/shared/@ai-setting/{roy-agent-core-cgtq6427.js → roy-agent-core-e08bvpaq.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-12n08pg5.js → roy-agent-core-e69qxdyy.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-xcp8vwax.js → roy-agent-core-fepm835e.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-6j02sbee.js → roy-agent-core-fhg03v43.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-dvtg4sn0.js → roy-agent-core-g8yr733d.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-m3vjepzz.js → roy-agent-core-h1e1fm9b.js} +38 -202
- package/dist/shared/@ai-setting/{roy-agent-core-c2gbt68e.js → roy-agent-core-h83zdsrq.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-tk98f92b.js → roy-agent-core-k3gcvybs.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-b31v3qpv.js → roy-agent-core-k3h8t4q1.js} +992 -212
- package/dist/shared/@ai-setting/{roy-agent-core-pgvcf91v.js → roy-agent-core-m39v7qpx.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-ezvpreqz.js → roy-agent-core-m66ysky0.js} +54 -6
- package/dist/shared/@ai-setting/{roy-agent-core-begm7ytz.js → roy-agent-core-m7d1t3db.js} +3 -3
- package/dist/shared/@ai-setting/{roy-agent-core-tm1mxttk.js → roy-agent-core-mf5p38yf.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-83bewqx8.js → roy-agent-core-mvh0td7p.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-ze5cqpf2.js → roy-agent-core-mx855td4.js} +17 -38
- package/dist/shared/@ai-setting/{roy-agent-core-0dh8npnz.js → roy-agent-core-n197medr.js} +13 -13
- package/dist/shared/@ai-setting/{roy-agent-core-cmprygrp.js → roy-agent-core-nqkfkpf4.js} +4 -4
- package/dist/shared/@ai-setting/{roy-agent-core-7cbpmk4q.js → roy-agent-core-p31ftgq9.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-1v4g0d4x.js → roy-agent-core-rm7seqwb.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-ax9e9szb.js → roy-agent-core-smf94h73.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-acj8ag08.js → roy-agent-core-tjnabyvq.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-qqaak24r.js → roy-agent-core-tkpp1ba0.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-dkrvmjsh.js → roy-agent-core-tpm1dd1g.js} +23 -15
- package/dist/shared/@ai-setting/{roy-agent-core-ed233k5z.js → roy-agent-core-v1n0106v.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-zxz5fkwj.js → roy-agent-core-v6yshv0z.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-mcy5apay.js → roy-agent-core-vf9sp6s3.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-xvt7kf7p.js → roy-agent-core-w9ryeg2p.js} +3 -3
- package/dist/shared/@ai-setting/{roy-agent-core-es203w7p.js → roy-agent-core-wqs6yypq.js} +1 -1
- package/dist/shared/@ai-setting/roy-agent-core-wxrkcb17.js +56 -0
- package/dist/shared/@ai-setting/{roy-agent-core-0snm5hc5.js → roy-agent-core-y6shd91r.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-9vxh6f8h.js → roy-agent-core-y7fqtzk2.js} +7 -7
- package/dist/shared/@ai-setting/{roy-agent-core-cpcd24n2.js → roy-agent-core-yet36q5k.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-3fh1f7s7.js → roy-agent-core-yfpnkc4z.js} +5 -5
- package/dist/shared/@ai-setting/roy-agent-core-zhwcje5a.js +352 -0
- package/package.json +9 -1
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Task #5360(用户澄清 2026-11-11 22:37)——
|
|
3
|
+
* 卡片实体:**sub-session 永远是主键**,task 是可选的**附加增强信息**
|
|
4
|
+
*
|
|
5
|
+
* ## 用户澄清原文(覆盖了此前「task-or-session 二选一」的理解)
|
|
6
|
+
*
|
|
7
|
+
* > 「**不是**「task 或 sub-session」二选一,而是**以 sub-session 为基底**:
|
|
8
|
+
* > 1. 卡片主键 = sub-session(不是 task)
|
|
9
|
+
* > 2. 有些 sub-session 内部创建了 task,有些没有 —— 都是正常的
|
|
10
|
+
* > 3. 如果该 sub-session 创建了 task → 把 task 信息同步进卡片
|
|
11
|
+
* > (taskId、title、状态、进度、操作记录等原有信息一个不少)
|
|
12
|
+
* > 4. **无论有无 task,sub-session 相关的刷新逻辑始终存在**:
|
|
13
|
+
* > 刷新看消息数 + 最近 msg(截断);
|
|
14
|
+
* > **超时、完成等生命周期事件也体现在卡片上**(这是 subsession 层的)」
|
|
15
|
+
*
|
|
16
|
+
* ## 语义对比(这是本模块存在的全部理由)
|
|
17
|
+
*
|
|
18
|
+
* ```
|
|
19
|
+
* ❌ 旧(错):type CardSubject = { kind:"task"; taskId } | { kind:"session"; sessionId }
|
|
20
|
+
* → 主键二选一;task 卡和 session 卡是两张不同的卡
|
|
21
|
+
* ✅ 新(对):type CardSubject = {
|
|
22
|
+
* sessionId: string; // ← 永远是主键,不可缺
|
|
23
|
+
* taskId?: number; // ← 可选增强,有就多显示
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* 关键推论(写代码时最容易搞错的地方):
|
|
28
|
+
*
|
|
29
|
+
* 1. **刷新永远读 session store**。有 task 时也读 session —— 因为
|
|
30
|
+
* 「消息数 + 最近 msg」是**会话**的属性,不是 task 的属性。
|
|
31
|
+
* 旧实现走 `taskId → bgTask → subSessionId → session`,绕了一圈才拿到
|
|
32
|
+
* 同一个 session;现在主键就是 sessionId,直达。
|
|
33
|
+
* 2. **生命周期(超时/完成/停止)是 session 层的事实**。旧设计里终态来自
|
|
34
|
+
* `task.status`(没 task 就永远 non-terminal)—— 这正是本次要修的语义错误。
|
|
35
|
+
* 现在终态来自 **跑这个 session 的后台任务**(`BackgroundTask.status`),
|
|
36
|
+
* 与「该 session 有没有建 task」无关。
|
|
37
|
+
* 3. **有 task 只是"多一块信息"**,不改变卡片身份、不改变刷新行为。
|
|
38
|
+
*
|
|
39
|
+
* ## 序列化格式
|
|
40
|
+
*
|
|
41
|
+
* 持久层主键是字符串,格式:
|
|
42
|
+
*
|
|
43
|
+
* ```
|
|
44
|
+
* session:<sessionId> ← 无关联 task
|
|
45
|
+
* session:<sessionId>#task:<taskId> ← 有关联 task(附加段)
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* - 主键段**永远是 session**;`#task:` 段是纯附加值,缺了不影响解析
|
|
49
|
+
* - 用 `#` 分隔而不是再嵌 `:`,避免 session id 里含 `:` 时歧义
|
|
50
|
+
* (session id 可能含 `-` / `_`,理论上也可能含别的;`#` 最少见)
|
|
51
|
+
* - 旧数据(只有 `task_id INTEGER`)迁移时**无法**反推 sessionId ⇒ 标记为
|
|
52
|
+
* `legacy-task:<n>`,仅用于读旧卡(新卡不再产生这种形态)
|
|
53
|
+
*/
|
|
54
|
+
/**
|
|
55
|
+
* 卡片实体:**session 为主 + task 可选**。
|
|
56
|
+
*
|
|
57
|
+
* ⚠️ `sessionId` 必填 —— 这是本次澄清的核心,不要为了兼容旧代码把它变可选。
|
|
58
|
+
*/
|
|
59
|
+
export interface CardSubject {
|
|
60
|
+
/** ★ 主键:跑这次执行的 sub-session */
|
|
61
|
+
sessionId: string;
|
|
62
|
+
/** 附加增强:该 session 内创建的 roy 任务(可能没有) */
|
|
63
|
+
taskId?: number;
|
|
64
|
+
}
|
|
65
|
+
/** 持久层主键 */
|
|
66
|
+
export type CardKey = string;
|
|
67
|
+
/**
|
|
68
|
+
* 造卡片主键。**sessionId 必填**,taskId 可选(附加值)。
|
|
69
|
+
*
|
|
70
|
+
* @throws sessionId 为空(空主键会撞脏数据,宁可早失败)
|
|
71
|
+
*/
|
|
72
|
+
export declare function cardKeyOf(subject: CardSubject): CardKey;
|
|
73
|
+
/** 便捷:只给 sessionId(无 task) */
|
|
74
|
+
export declare function sessionCardKey(sessionId: string): CardKey;
|
|
75
|
+
/** 便捷:sessionId + taskId */
|
|
76
|
+
export declare function sessionTaskCardKey(sessionId: string, taskId: number): CardKey;
|
|
77
|
+
/** 旧卡(迁移期只读):`legacy-task:<n>` */
|
|
78
|
+
export declare function legacyTaskCardKey(taskId: number): CardKey;
|
|
79
|
+
/**
|
|
80
|
+
* 解析主键。
|
|
81
|
+
*
|
|
82
|
+
* 失败(非字符串 / 空 / 缺 `session:` 前缀 / sessionId 为空)一律
|
|
83
|
+
* `undefined` —— 调用方降级,**绝不抛、绝不猜**。
|
|
84
|
+
*
|
|
85
|
+
* 注意:`legacy-task:<n>` **不**解析成 CardSubject(它没有 sessionId,
|
|
86
|
+
* 无法参与刷新);需要区分旧卡时用 `isLegacyTaskCardKey`。
|
|
87
|
+
*/
|
|
88
|
+
export declare function parseCardKey(key: unknown): CardSubject | undefined;
|
|
89
|
+
/** 是否是迁移期的旧卡主键(只有 task、没有 session) */
|
|
90
|
+
export declare function isLegacyTaskCardKey(key: unknown): boolean;
|
|
91
|
+
/** 判定版 */
|
|
92
|
+
export declare function isCardKey(v: unknown): v is CardKey;
|
|
93
|
+
/**
|
|
94
|
+
* 从按钮 `value` 里挑出卡片实体。
|
|
95
|
+
*
|
|
96
|
+
* ## 与旧实现的关键差异
|
|
97
|
+
*
|
|
98
|
+
* 旧实现「taskId 优先,没有 taskId 才用 sessionId」—— 那会让**有 task 的
|
|
99
|
+
* session 卡**被当成 task 卡刷新(走 task→bgTask→session 绕路,且丢掉
|
|
100
|
+
* session 层的生命周期)。现在:**sessionId 是主键,taskId 只是附加值**,
|
|
101
|
+
* 所以 sessionId 必须存在,taskId 有就带上。
|
|
102
|
+
*
|
|
103
|
+
* @returns 无 sessionId ⇒ `undefined`(连主键都没有,无法刷新)
|
|
104
|
+
*/
|
|
105
|
+
export declare function pickCardSubject(value: {
|
|
106
|
+
sessionId?: unknown;
|
|
107
|
+
taskId?: unknown;
|
|
108
|
+
}): CardSubject | undefined;
|
|
109
|
+
/**
|
|
110
|
+
* 主标签:`会话 <sessionId 截断>`。
|
|
111
|
+
*
|
|
112
|
+
* session 是卡片身份,所以标签以它为主;task 信息在卡片正文里单独展示
|
|
113
|
+
* (见 `buildSessionCard` 的「任务信息」面板)。
|
|
114
|
+
*/
|
|
115
|
+
export declare function cardSubjectLabel(subject: CardSubject): string;
|
|
116
|
+
/** 是否有关联 task(决定卡片是否渲染「任务信息」面板) */
|
|
117
|
+
export declare function hasTask(subject: CardSubject): boolean;
|
|
@@ -4,11 +4,9 @@ import {
|
|
|
4
4
|
LarkCliTaskNotifyHook,
|
|
5
5
|
LayaCompletionPlugin,
|
|
6
6
|
LayaDecisionPlugin,
|
|
7
|
-
MemoryLarkCardStateStore,
|
|
8
7
|
MemoryWecomCardStateStore,
|
|
9
8
|
NotifyType,
|
|
10
9
|
PerTaskGroupChatPlugin,
|
|
11
|
-
SqliteLarkCardStateStore,
|
|
12
10
|
SqliteWecomCardStateStore,
|
|
13
11
|
TaskTagPlugin,
|
|
14
12
|
WORKFLOW_EXTRACTOR_PROMPT,
|
|
@@ -18,7 +16,6 @@ import {
|
|
|
18
16
|
buildCompletionQuestion,
|
|
19
17
|
buildWecomTaskCard,
|
|
20
18
|
createAutoTaskPlugin,
|
|
21
|
-
createLarkCardStateStore,
|
|
22
19
|
createLarkCliTaskNotifyHook,
|
|
23
20
|
createLayaCompletionPlugin,
|
|
24
21
|
createLayaDecisionPlugin,
|
|
@@ -29,18 +26,17 @@ import {
|
|
|
29
26
|
extractWecomFields,
|
|
30
27
|
formatExtractorInput,
|
|
31
28
|
formatExtractorInputFromDescription,
|
|
32
|
-
getDefaultLarkCardDbPath,
|
|
33
29
|
getDefaultWecomCardDbPath,
|
|
34
30
|
parseExtractorOutput,
|
|
35
31
|
registerLayaCompletionTaskHook,
|
|
36
32
|
renderCompletionState
|
|
37
|
-
} from "../../../shared/@ai-setting/roy-agent-core-
|
|
38
|
-
import"../../../shared/@ai-setting/roy-agent-core-
|
|
39
|
-
import"../../../shared/@ai-setting/roy-agent-core-
|
|
40
|
-
import"../../../shared/@ai-setting/roy-agent-core-
|
|
41
|
-
import"../../../shared/@ai-setting/roy-agent-core-
|
|
33
|
+
} from "../../../shared/@ai-setting/roy-agent-core-k3h8t4q1.js";
|
|
34
|
+
import"../../../shared/@ai-setting/roy-agent-core-h1e1fm9b.js";
|
|
35
|
+
import"../../../shared/@ai-setting/roy-agent-core-c4ec7k0p.js";
|
|
36
|
+
import"../../../shared/@ai-setting/roy-agent-core-4t3yskp8.js";
|
|
37
|
+
import"../../../shared/@ai-setting/roy-agent-core-y7fqtzk2.js";
|
|
42
38
|
import"../../../shared/@ai-setting/roy-agent-core-1pg0fepg.js";
|
|
43
|
-
import"../../../shared/@ai-setting/roy-agent-core-
|
|
39
|
+
import"../../../shared/@ai-setting/roy-agent-core-d6zdbgtc.js";
|
|
44
40
|
import"../../../shared/@ai-setting/roy-agent-core-m46fe3x4.js";
|
|
45
41
|
import {
|
|
46
42
|
TASK_COMPLETE_ACCEPTANCE,
|
|
@@ -51,12 +47,16 @@ import {
|
|
|
51
47
|
import {
|
|
52
48
|
DEFAULT_APP_LINK_BASE,
|
|
53
49
|
LarkCardPatchNotifier,
|
|
50
|
+
MemoryLarkCardStateStore,
|
|
51
|
+
SqliteLarkCardStateStore,
|
|
54
52
|
buildChatAppLink,
|
|
55
53
|
buildTaskCard,
|
|
56
54
|
buildWorkflowCard,
|
|
55
|
+
createLarkCardStateStore,
|
|
57
56
|
formatDateTimeForDisplay,
|
|
58
57
|
formatDurationMs,
|
|
59
58
|
formatTimestampForDisplay,
|
|
59
|
+
getDefaultLarkCardDbPath,
|
|
60
60
|
humanizeValue,
|
|
61
61
|
renderContextAsLines,
|
|
62
62
|
renderMilestones,
|
|
@@ -66,9 +66,11 @@ import {
|
|
|
66
66
|
renderWorkflowInfoLines,
|
|
67
67
|
resolveTaskTitleForDisplay,
|
|
68
68
|
sanitizeInlineText
|
|
69
|
-
} from "../../../shared/@ai-setting/roy-agent-core-
|
|
70
|
-
import"../../../shared/@ai-setting/roy-agent-core-
|
|
71
|
-
import"../../../shared/@ai-setting/roy-agent-core-
|
|
69
|
+
} from "../../../shared/@ai-setting/roy-agent-core-0n1wwndq.js";
|
|
70
|
+
import"../../../shared/@ai-setting/roy-agent-core-418zc9ha.js";
|
|
71
|
+
import"../../../shared/@ai-setting/roy-agent-core-m66ysky0.js";
|
|
72
|
+
import"../../../shared/@ai-setting/roy-agent-core-rm7seqwb.js";
|
|
73
|
+
import"../../../shared/@ai-setting/roy-agent-core-e08bvpaq.js";
|
|
72
74
|
import"../../../shared/@ai-setting/roy-agent-core-er070zjq.js";
|
|
73
75
|
import {
|
|
74
76
|
TASK_OP_WATERMARK_AUDIT_INTERVAL,
|
|
@@ -76,12 +78,12 @@ import {
|
|
|
76
78
|
TASK_OP_WATERMARK_MESSAGE_LIMIT,
|
|
77
79
|
TaskOpWatermarkPlugin,
|
|
78
80
|
createTaskOpWatermarkPlugin
|
|
79
|
-
} from "../../../shared/@ai-setting/roy-agent-core-
|
|
81
|
+
} from "../../../shared/@ai-setting/roy-agent-core-7yh5wps0.js";
|
|
80
82
|
import"../../../shared/@ai-setting/roy-agent-core-mkc3zshb.js";
|
|
81
83
|
import"../../../shared/@ai-setting/roy-agent-core-az13yzmc.js";
|
|
82
|
-
import"../../../shared/@ai-setting/roy-agent-core-
|
|
83
|
-
import"../../../shared/@ai-setting/roy-agent-core-
|
|
84
|
-
import"../../../shared/@ai-setting/roy-agent-core-
|
|
84
|
+
import"../../../shared/@ai-setting/roy-agent-core-tkpp1ba0.js";
|
|
85
|
+
import"../../../shared/@ai-setting/roy-agent-core-p31ftgq9.js";
|
|
86
|
+
import"../../../shared/@ai-setting/roy-agent-core-5s2t8z00.js";
|
|
85
87
|
import"../../../shared/@ai-setting/roy-agent-core-7f7t9wwp.js";
|
|
86
88
|
import"../../../shared/@ai-setting/roy-agent-core-85xyctnb.js";
|
|
87
89
|
import"../../../shared/@ai-setting/roy-agent-core-fs0mn2jk.js";
|
|
@@ -14,12 +14,29 @@
|
|
|
14
14
|
* - 失败必须明确返回 ok=false,不静默成功
|
|
15
15
|
*/
|
|
16
16
|
import { buildTaskCard, DEFAULT_APP_LINK_BASE, type LarkCardPatchNotifier } from "./lark-card-patch-notifier";
|
|
17
|
+
import { type ActivityMessage, type ToolCallView, type ActivityProbeResult } from "./sub-session-activity";
|
|
17
18
|
/** 卡片按钮点击事件的关键字段(精简版,caller 从 event 里挑出) */
|
|
18
19
|
export interface CardActionEvent {
|
|
19
|
-
/**
|
|
20
|
+
/**
|
|
21
|
+
* action.value 序列化成的对象
|
|
22
|
+
*
|
|
23
|
+
* ★ Task #5360:新增 `refresh_activity`(展示 sub-session 活性)
|
|
24
|
+
* ★ Task #5377(合并):`action` 放宽成 string、`taskId` 放宽成可选 ——
|
|
25
|
+
* 这样未知 action 能走到 `Unknown action` 分支(而不是被 TS 挡掉后
|
|
26
|
+
* 运行时静默落到解散群分支),session 卡也能不带 taskId。
|
|
27
|
+
*/
|
|
20
28
|
actionValue: {
|
|
21
|
-
|
|
22
|
-
|
|
29
|
+
/** 运行时再校验(#5377:先判白名单);合法值见 `CardActionName` */
|
|
30
|
+
action: CardActionName | string;
|
|
31
|
+
/** ★ Task #5360:task 卡带它;session 卡不带(可选,#5377) */
|
|
32
|
+
taskId?: string | number;
|
|
33
|
+
/**
|
|
34
|
+
* ★ 补充需求(22:31):session 卡的主键。
|
|
35
|
+
*
|
|
36
|
+
* **它是卡片主键**(澄清 22:37):刷新永远走 session store。
|
|
37
|
+
* `taskId` 只是附加增强 —— 有就多渲染「任务信息」面板,不影响刷新路径。
|
|
38
|
+
*/
|
|
39
|
+
sessionId?: string;
|
|
23
40
|
};
|
|
24
41
|
/** 卡片所在的 chat_id */
|
|
25
42
|
chatId: string;
|
|
@@ -38,6 +55,82 @@ export interface CardActionEvent {
|
|
|
38
55
|
/** lark-cli profile */
|
|
39
56
|
profile?: string;
|
|
40
57
|
}
|
|
58
|
+
/** 卡片动作名(★ Task #5360:加 `refresh_activity`) */
|
|
59
|
+
export type CardActionName = "create_group" | "disband_group" | "refresh_activity";
|
|
60
|
+
/**
|
|
61
|
+
* 运行时判定一个字符串是否是本 handler 认识的 action。
|
|
62
|
+
*
|
|
63
|
+
* ★ Task #5360(防误伤):改造前 handler 的结构是
|
|
64
|
+
* ```ts
|
|
65
|
+
* if (action === "create_group") { ...建群... } else { ...解散群... }
|
|
66
|
+
* ```
|
|
67
|
+
* 也就是**任何**非 create_group 的 action 都会走解散群分支。
|
|
68
|
+
* 加了 `refresh_activity` 之后,如果只在新分支外面套一层判断,漏掉/拼错
|
|
69
|
+
* 的 action(或未来第三方卡片复用同一 handler)会**默默解散用户的群**。
|
|
70
|
+
* 所以改成显式白名单 + switch,未知 action 一律 `ok:false` 且**不执行任何操作**。
|
|
71
|
+
*/
|
|
72
|
+
export declare function isCardActionName(v: unknown): v is CardActionName;
|
|
73
|
+
/** ★ Task #5377:actionValue 的运行时形状(字段都可能缺,先当 unknown 校验) */
|
|
74
|
+
export interface CardActionValue {
|
|
75
|
+
action?: unknown;
|
|
76
|
+
taskId?: unknown;
|
|
77
|
+
sessionId?: unknown;
|
|
78
|
+
}
|
|
79
|
+
/** ★ Task #5377:校验结果(判别联合 —— 通过时主键已收窄成对应类型) */
|
|
80
|
+
export type CardActionValidation = {
|
|
81
|
+
ok: true;
|
|
82
|
+
action: "create_group" | "disband_group";
|
|
83
|
+
taskId: number;
|
|
84
|
+
sessionId?: string;
|
|
85
|
+
} | {
|
|
86
|
+
ok: true;
|
|
87
|
+
action: "create_group" | "disband_group";
|
|
88
|
+
taskId?: undefined;
|
|
89
|
+
sessionId: string;
|
|
90
|
+
} | {
|
|
91
|
+
ok: true;
|
|
92
|
+
action: "refresh_activity";
|
|
93
|
+
sessionId: string;
|
|
94
|
+
} | {
|
|
95
|
+
ok: false;
|
|
96
|
+
action: string;
|
|
97
|
+
error: string;
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* ★ Task #5377 修复主体:**先判 action 白名单,再按 action 类型取主键**。
|
|
101
|
+
*
|
|
102
|
+
* 顺序契约(不可颠倒):
|
|
103
|
+
* 1. action 不在白名单 → `Unknown action: <action>`
|
|
104
|
+
* (此时**不看** taskId/sessionId —— 未知动作不该报"缺字段",
|
|
105
|
+
* 更不能落到解散群分支误删用户的群)
|
|
106
|
+
* 2. 白名单内 → 按 `ACTION_SUBJECT_FIELD` 只校验该 action 需要的那一个字段
|
|
107
|
+
* 3. 缺 / 非法 → 错误信息**必须指明字段名**(taskId 或 sessionId)
|
|
108
|
+
*
|
|
109
|
+
* 纯函数、无 IO,便于逐个 action 单测。
|
|
110
|
+
*/
|
|
111
|
+
export declare function validateCardActionValue(raw: CardActionValue): CardActionValidation;
|
|
112
|
+
/**
|
|
113
|
+
* ★ Task #5377:session 类卡片(refresh_activity)的外部刷新实现(**可选**)。
|
|
114
|
+
*
|
|
115
|
+
* 生产默认**不需要**注入它 —— 内置的 `handleRefreshSessionActivity`(#5364)
|
|
116
|
+
* 只依赖数据端口 `loadSessionActivity` 就能渲染整张 session 卡。
|
|
117
|
+
* 本端口留给需要跨进程 / 特殊渲染的宿主复用同一 handler。
|
|
118
|
+
*
|
|
119
|
+
* ⚠️ 契约:**端口只负责 render,不负责发**。返回的 `cardUpdate` 由 caller
|
|
120
|
+
* 统一 patch(见 event-source-handlers 的 handleCardActionEvent),
|
|
121
|
+
* 所以端口实现**不要**自己再 patch 一次(会重复更新)。
|
|
122
|
+
*/
|
|
123
|
+
export type SessionCardRefreshHandler = (opts: {
|
|
124
|
+
sessionId: string;
|
|
125
|
+
chatId: string;
|
|
126
|
+
messageId: string;
|
|
127
|
+
token: string;
|
|
128
|
+
profile?: string;
|
|
129
|
+
}) => Promise<{
|
|
130
|
+
/** 渲染好的卡片 payload(caller 负责发) */
|
|
131
|
+
cardUpdate?: ReturnType<typeof buildTaskCard>;
|
|
132
|
+
error?: string;
|
|
133
|
+
}>;
|
|
41
134
|
/** 端口注入(caller 提供 IO 能力,本模块保持纯函数) */
|
|
42
135
|
export interface CardActionPorts {
|
|
43
136
|
/** 读取 task(用于读 context) */
|
|
@@ -58,12 +151,14 @@ export interface CardActionPorts {
|
|
|
58
151
|
/**
|
|
59
152
|
* 创建群聊
|
|
60
153
|
* @param opts.initialUserIds ★ Task #4337:建群时一并拉人(如操作者 open_id);用 `+chat-create --users` 一次到位
|
|
154
|
+
* @param opts.initialBotIds ★ Task #5425:建群时一并拉 bot(app_id cli_xxx);不拉 bot 发卡会 230002
|
|
61
155
|
*/
|
|
62
156
|
createGroupChat?: (opts: {
|
|
63
157
|
name: string;
|
|
64
158
|
description: string;
|
|
65
159
|
profile?: string;
|
|
66
160
|
initialUserIds?: string[];
|
|
161
|
+
initialBotIds?: string[];
|
|
67
162
|
}) => Promise<string>;
|
|
68
163
|
/** 解散群聊 */
|
|
69
164
|
deleteGroupChat?: (chatId: string, profile?: string) => Promise<void>;
|
|
@@ -73,7 +168,128 @@ export interface CardActionPorts {
|
|
|
73
168
|
* (caller 实现可以是 no-op,因为 --users 已经邀请好了)
|
|
74
169
|
*/
|
|
75
170
|
inviteUser?: (chatId: string, userOpenId: string, profile?: string) => Promise<void>;
|
|
76
|
-
/**
|
|
171
|
+
/**
|
|
172
|
+
* ★ Task #5360:读 sub-session 活性(消息数 + 最后写入时间 + 最近消息)。
|
|
173
|
+
*
|
|
174
|
+
* 用户点「🔄 刷新活性」时调用,用来判断**有没有 LLM 在推进**。
|
|
175
|
+
*
|
|
176
|
+
* 不注入 / 抛错 / 返回 undefined ⇒ 卡片渲染「暂无数据」,
|
|
177
|
+
* **绝不让 patch 失败**(与其它端口同一套 best-effort 语义)。
|
|
178
|
+
*
|
|
179
|
+
* 装配点见 `event-source-handlers.ts` 的 `wireCardActionPorts()`
|
|
180
|
+
* (复用 `createActivityProbe`,与企微侧同一份实现)。
|
|
181
|
+
*/
|
|
182
|
+
loadSubSessionActivity?: (taskId: number) => Promise<ActivityProbeResult> | ActivityProbeResult;
|
|
183
|
+
/**
|
|
184
|
+
* ★ Task #5360:任务是否已终态(决定活性档位报「已结束」而非「疑似停滞」)。
|
|
185
|
+
* 不注入 ⇒ 按非终态处理(最坏情况是终态任务显示"疑似停滞",不影响可用性)。
|
|
186
|
+
*/
|
|
187
|
+
isTerminalTask?: (taskId: number) => Promise<boolean> | boolean;
|
|
188
|
+
/**
|
|
189
|
+
* ★ CV BLOCKER-1:按 taskId 反查所属 sub-session(旧卡片向后兼容)。
|
|
190
|
+
*
|
|
191
|
+
* 存量 task 卡的按钮 value 只有 `taskId`(改造前的形态)。为了让它们
|
|
192
|
+
* 不失效,用一个反查端口把它们补成标准 `{sessionId, taskId}` subject。
|
|
193
|
+
*
|
|
194
|
+
* 装配点实现:`taskId → BackgroundTaskManager.listTasks() 里
|
|
195
|
+
* associatedTaskId 命中 → subSessionId`。
|
|
196
|
+
* 不注入 / 反查不到 ⇒ 旧卡片刷新被拒(不猜)。
|
|
197
|
+
*/
|
|
198
|
+
resolveSessionIdByTask?: (taskId: number) => Promise<string | undefined> | string | undefined;
|
|
199
|
+
/**
|
|
200
|
+
* ★ 补充需求(22:31):**session-only** 活性读取(无 task 场景)。
|
|
201
|
+
*
|
|
202
|
+
* 与 `loadSubSessionActivity(taskId)` 的区别:后者要从 task 反查 bgTask 才能
|
|
203
|
+
* 拿到 subSessionId;本端口**直达** session store —— 因为调用方手里已经有
|
|
204
|
+
* sessionId 了,而这条链上**根本没有 task**。
|
|
205
|
+
*
|
|
206
|
+
* 不注入 / 抛错 ⇒ 卡片渲染「暂无数据」,绝不阻断 patch。
|
|
207
|
+
*/
|
|
208
|
+
loadSessionActivity?: (sessionId: string) => Promise<ActivityProbeResult> | ActivityProbeResult;
|
|
209
|
+
/**
|
|
210
|
+
* ★ Task #5420:「💬 会话查看」—— 读最近 N 条消息。
|
|
211
|
+
*
|
|
212
|
+
* 与 `loadSessionActivity` 的区别:活性只带**最近 1 条**消息
|
|
213
|
+
* (判断有无 LLM 推进够用);本端口取**尾部 5 条**(用户拍板
|
|
214
|
+
* 「A 五条,只展示名称和 reason」)。
|
|
215
|
+
*
|
|
216
|
+
* 装配点实现:`getMessages(sessionId, { offset: -1, limit: 5 })`
|
|
217
|
+
* (sqlite 负 offset 语义 = total + offset*limit,-1×5 = 最新 5 条)。
|
|
218
|
+
*
|
|
219
|
+
* 不注入 / 抛错 / 返回 undefined ⇒ **不渲染**最近消息面板
|
|
220
|
+
* (降级不抛,与活性端口同一套 best-effort 语义);
|
|
221
|
+
* 返回 [] ⇒ 面板照出 + 「暂无消息」(诚实)。
|
|
222
|
+
*/
|
|
223
|
+
loadSessionMessages?: (sessionId: string, limit?: number) => Promise<ActivityMessage[] | ToolCallView[] | undefined> | ActivityMessage[] | ToolCallView[] | undefined;
|
|
224
|
+
/**
|
|
225
|
+
* ★ Task #5403:建群成功后初始化「群 session」—— **关联建群**。
|
|
226
|
+
*
|
|
227
|
+
* 取代 #5369 的 `linkSessionAlias`(alias / linkedTo 能力已整体废弃)。
|
|
228
|
+
*
|
|
229
|
+
* 新语义:群 session 是**独立会话**,不共享原会话历史。本端口负责:
|
|
230
|
+
* 1. 建/补群 session 行(id = chatId,metadata 带 `linkedFromSessionId`)
|
|
231
|
+
* 2. 注入 **1 条 user role** 事件说明「本群由 session X 关联建群,需要
|
|
232
|
+
* 背景时用 `roy-agent sessions messages X` 按需读取」
|
|
233
|
+
*
|
|
234
|
+
* 为什么不共享历史(用户 2026-11-12 定稿):群 session 由 default agent 的
|
|
235
|
+
* system prompt 驱动,原 sub session 由 sub agent 驱动 —— 复用 history 会让
|
|
236
|
+
* LLM prefix cache 失效,且 sub agent 的 delegate prompt(「不要发飞书消息」)
|
|
237
|
+
* 会污染群对话(#5396 实测 0 回复)。
|
|
238
|
+
*
|
|
239
|
+
* 可选端口:
|
|
240
|
+
* - 未注入 → 建群照旧成功(向后兼容,老部署不炸)
|
|
241
|
+
* - 抛错 → best-effort 吞掉,**绝不回滚已建好的群**
|
|
242
|
+
*/
|
|
243
|
+
attachGroupSession?: (args: {
|
|
244
|
+
chatId: string;
|
|
245
|
+
originSessionId: string;
|
|
246
|
+
title?: string;
|
|
247
|
+
}) => Promise<unknown>;
|
|
248
|
+
/**
|
|
249
|
+
* ★ Task #5397:**会话 → 群** 反向查询(等价 task 维度的
|
|
250
|
+
* `task.context.larkPerTaskChatId`)。
|
|
251
|
+
*
|
|
252
|
+
* 用途(三处):
|
|
253
|
+
* 1. **重复建群保护**:同 session 已有群 ⇒ 返回已有群链接,不新建
|
|
254
|
+
* 2. 卡片显示已有群链接(session 卡首渲 / 刷新时带 `perTaskChatId`)
|
|
255
|
+
* 3. 解绑时定位要解散哪个群
|
|
256
|
+
*
|
|
257
|
+
* 装配点实现:`SessionComponent.findGroupChatForSession(sessionId)`
|
|
258
|
+
* —— 扫 metadata `linkedFromSessionId`(Task #5403 起,走 JSON1 抽取,
|
|
259
|
+
* 零 schema 变更;`linked_to` 列已废弃不再使用)。
|
|
260
|
+
*
|
|
261
|
+
* 不注入 ⇒ session-only 建群失去重复保护(仍能建),解绑退化为「无群可解」
|
|
262
|
+
* (明确报错,不静默成功)。
|
|
263
|
+
*/
|
|
264
|
+
findGroupChatForSession?: (sessionId: string) => Promise<{
|
|
265
|
+
chatId: string;
|
|
266
|
+
aliasSessionId?: string;
|
|
267
|
+
} | undefined> | {
|
|
268
|
+
chatId: string;
|
|
269
|
+
aliasSessionId?: string;
|
|
270
|
+
} | undefined;
|
|
271
|
+
/**
|
|
272
|
+
* ★ Task #5403:解除「会话 ↔ 群」的关联(解绑时调用)。
|
|
273
|
+
*
|
|
274
|
+
* 取代 #5397 的 `unlinkSessionAlias`。新语义:群 session 是独立会话,解绑
|
|
275
|
+
* 只是把「这个群还活着」的标记打掉(metadata.groupDisbandedAt),让
|
|
276
|
+
* `findGroupChatForSession` 不再命中它。
|
|
277
|
+
*
|
|
278
|
+
* 不注入 / 抛错 ⇒ best-effort 吞掉(群已经解散了,不能让 detach 失败把结果
|
|
279
|
+
* 翻成失败)。
|
|
280
|
+
*/
|
|
281
|
+
detachGroupSession?: (chatId: string) => Promise<{
|
|
282
|
+
ok: boolean;
|
|
283
|
+
} | void>;
|
|
284
|
+
/**
|
|
285
|
+
* ★ Task #5397:读会话标题(session-only 建群时用来生成群名)。
|
|
286
|
+
*
|
|
287
|
+
* 不注入 / 取不到 ⇒ 群名退化为 `会话 <sessionId 截断>`。
|
|
288
|
+
*/
|
|
289
|
+
getSessionTitle?: (sessionId: string) => Promise<string | undefined> | string | undefined;
|
|
290
|
+
/**
|
|
291
|
+
* 卡片更新(用 messageId patch)
|
|
292
|
+
*/
|
|
77
293
|
notifier: LarkCardPatchNotifier;
|
|
78
294
|
/**
|
|
79
295
|
* ★ Task #4339:用飞书 30min token patch 卡片(可选端口)。
|
|
@@ -86,12 +302,24 @@ export interface CardActionPorts {
|
|
|
86
302
|
* 抽成端口是为了单测能断言"patch 被调用了 / 内容对不对"而不真发请求。
|
|
87
303
|
*/
|
|
88
304
|
patchByToken?: (token: string, card: unknown, profile?: string) => Promise<void>;
|
|
305
|
+
/**
|
|
306
|
+
* ★ Task #5377:session 类卡片(refresh_activity)的外部刷新实现(可选)。
|
|
307
|
+
*
|
|
308
|
+
* 未注入 ⇒ 走内置 `handleRefreshSessionActivity`(#5364 生产默认路径);
|
|
309
|
+
* 连 `loadSessionActivity` 也没有 ⇒ 返回**指明 action 的**错误
|
|
310
|
+
* (而不是改造前那句误导性的 `Invalid taskId: undefined`)。
|
|
311
|
+
*/
|
|
312
|
+
refreshSessionCard?: SessionCardRefreshHandler;
|
|
89
313
|
}
|
|
90
314
|
/** 路由决策 / 处理结果 */
|
|
91
315
|
export interface CardActionResult {
|
|
92
316
|
ok: boolean;
|
|
93
|
-
/**
|
|
94
|
-
|
|
317
|
+
/**
|
|
318
|
+
* 成功执行的操作。
|
|
319
|
+
* ★ 合并:`CardActionName`(正常路径)× `#5377` 未知 action 时保留原始字符串
|
|
320
|
+
* (便于日志定位是哪个拼错/第三方动作打进来的)
|
|
321
|
+
*/
|
|
322
|
+
action: CardActionName | string;
|
|
95
323
|
/** 新的 chatId(create 成功时返回;disband 成功时返回空) */
|
|
96
324
|
newChatId?: string;
|
|
97
325
|
/** 给飞书的卡片更新 payload(用 token 即时 patch) */
|
|
@@ -109,6 +337,13 @@ export declare function __resetCardActionInflightForTest(): void;
|
|
|
109
337
|
* @returns 处理结果(ok=true 表示 action 已成功执行;ok=false 表示错误)
|
|
110
338
|
*/
|
|
111
339
|
export declare function handleCardAction(event: CardActionEvent, ports: CardActionPorts): Promise<CardActionResult>;
|
|
340
|
+
/**
|
|
341
|
+
* task.status → **session 生命周期**映射。
|
|
342
|
+
*
|
|
343
|
+
* ⚠️ 这不是「task 状态」——它表示「跑这个 session 的执行是否已结束」。
|
|
344
|
+
* 只映射到生命周期允许的 5 个值;未知状态保守当 `running`。
|
|
345
|
+
*/
|
|
346
|
+
export declare function lifecycleOfTaskStatus(status: string | undefined): "running" | "completed" | "timeout" | "failed" | "stopped" | undefined;
|
|
112
347
|
/**
|
|
113
348
|
* "解散"群聊(Task #4331 实测发现:飞书 Open API **不支持解散群聊**)
|
|
114
349
|
*
|
|
@@ -142,6 +377,17 @@ export declare function deleteGroupChatViaLarkCli(chatId: string, profile?: stri
|
|
|
142
377
|
* 引号 / `$` / 反引号 / `;` 破坏(命令截断甚至注入)。
|
|
143
378
|
*/
|
|
144
379
|
export declare function shellQuote(s: string): string;
|
|
380
|
+
/**
|
|
381
|
+
* ★ Task #5425:解析当前 profile 对应的 bot app_id(cli_xxx)。
|
|
382
|
+
*
|
|
383
|
+
* 用 `lark-cli <profile> auth status --json` 的 `appId` 字段
|
|
384
|
+
* (与 deleteGroupChatViaLarkCli 同款解析)。建群时把它传给
|
|
385
|
+
* `+chat-create --bots`,让创建者 bot 进群 —— 否则 bot 发卡
|
|
386
|
+
* (#5417 新群 session 卡)会报 230002。
|
|
387
|
+
*
|
|
388
|
+
* @throws lark-cli 失败 / 输出无 appId 时抛错(caller best-effort)
|
|
389
|
+
*/
|
|
390
|
+
export declare function resolveBotAppId(profile?: string): Promise<string>;
|
|
145
391
|
/**
|
|
146
392
|
* 截断到指定长度(含 "...",语义与 PerTaskGroupChatPlugin.truncate 一致)
|
|
147
393
|
*
|
|
@@ -161,6 +407,15 @@ export declare function createGroupChatViaLarkCli(opts: {
|
|
|
161
407
|
profile?: string;
|
|
162
408
|
/** ★ Task #4339:建群时一并拉人(lark-cli `+chat-create --users "ou_a,ou_b"`) */
|
|
163
409
|
initialUserIds?: string[];
|
|
410
|
+
/**
|
|
411
|
+
* ★ Task #5425:建群时一并拉 bot(lark-cli `+chat-create --bots "cli_xxx"`)。
|
|
412
|
+
*
|
|
413
|
+
* 背景:`--as bot` 创建群时**创建者 bot 默认不在群里**(飞书行为),
|
|
414
|
+
* 后续 `+messages-send`(发 session 卡)会报
|
|
415
|
+
* 230002「Bot/User can NOT be out of the chat」→ 新群永远没卡。
|
|
416
|
+
* 传本群要用的 bot app_id(cli_xxx)即可在建群时拉 bot 入群。
|
|
417
|
+
*/
|
|
418
|
+
initialBotIds?: string[];
|
|
164
419
|
}): Promise<string>;
|
|
165
420
|
/** 重新导出 DEFAULT_APP_LINK_BASE 方便测试用 */
|
|
166
421
|
export { DEFAULT_APP_LINK_BASE };
|