@ai-setting/roy-agent-core 1.7.77 → 1.7.88
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/config-protection.d.ts +89 -0
- package/dist/config/index.d.ts +1 -0
- package/dist/config/index.js +23 -7
- package/dist/env/agent/agent-component.d.ts +43 -22
- package/dist/env/agent/agent-component.js +13 -12
- package/dist/env/agent/index.js +13 -12
- package/dist/env/agent/types.d.ts +46 -12
- 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.d.ts +6 -0
- package/dist/env/error-reply.js +1 -1
- package/dist/env/event-source/bounty-im-handler.d.ts +8 -0
- package/dist/env/event-source/es-command.d.ts +39 -0
- package/dist/env/event-source/es-plugins.d.ts +68 -0
- package/dist/env/event-source/event-source-component.d.ts +15 -0
- package/dist/env/event-source/event-source-handlers.d.ts +84 -0
- package/dist/env/event-source/event-source-handlers.js +40 -23
- package/dist/env/event-source/event-store.js +2 -2
- package/dist/env/event-source/index.d.ts +5 -1
- package/dist/env/event-source/index.js +75 -23
- package/dist/env/event-source/timer-handler.d.ts +98 -0
- package/dist/env/event-source/types.d.ts +154 -2
- package/dist/env/event-source/wecom-card-action-handler.d.ts +373 -0
- package/dist/env/event-source/wecom-card-builder.d.ts +426 -0
- package/dist/env/event-source/wecom-cli-handler.d.ts +291 -0
- package/dist/env/event-source/wecom-cli-sender.d.ts +88 -0
- package/dist/env/event-source/wecom-media.d.ts +130 -0
- package/dist/env/event-source/wecom-respond-registry.d.ts +151 -0
- package/dist/env/event-source/wecom-respond-registry.js +33 -0
- 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/event-source/wecom-ws-bridge.d.ts +213 -0
- package/dist/env/hook/index.js +5 -5
- package/dist/env/index.js +51 -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/delegate/delegate-channel-hint.d.ts +39 -0
- package/dist/env/task/delegate/delegate-tool.d.ts +132 -7
- package/dist/env/task/delegate/delegate-tool.js +13 -9
- package/dist/env/task/delegate/index.js +8 -8
- package/dist/env/task/index.js +18 -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.d.ts +2 -0
- package/dist/env/task/plugins/index.js +39 -16
- package/dist/env/task/plugins/lark-card-action-handler.d.ts +261 -6
- package/dist/env/task/plugins/lark-card-patch-notifier.d.ts +542 -2
- 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 +61 -0
- package/dist/env/task/plugins/sub-session-activity.d.ts +415 -0
- package/dist/env/task/plugins/wecom-card-state-store.d.ts +121 -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 +264 -0
- package/dist/env/task/storage/index.js +3 -3
- package/dist/env/task/tools/index.js +4 -4
- package/dist/env/tool/built-in/index.d.ts +2 -0
- package/dist/env/tool/built-in/index.js +9 -2
- package/dist/env/tool/index.js +14 -9
- 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 +118 -62
- 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-aa2j7bk9.js → roy-agent-core-0sbmdz8d.js} +171 -36
- 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-2stt4rp5.js +134 -0
- 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-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-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-ezvpreqz.js → roy-agent-core-6k8mb7zx.js} +1 -1
- 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-7kvpc0w5.js +177 -0
- 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-6cy43nss.js → roy-agent-core-9c565frx.js} +49 -9
- 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-ew6qb5yx.js → roy-agent-core-an35dzbf.js} +6 -6
- package/dist/shared/@ai-setting/{roy-agent-core-mww0mnd9.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-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-rhtdspx6.js → roy-agent-core-fan8g0z1.js} +10 -10
- 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-99nwgj84.js → roy-agent-core-fzw9xzm1.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-3gpygqcx.js → roy-agent-core-gr5h1dyr.js} +2753 -358
- package/dist/shared/@ai-setting/roy-agent-core-h1e1fm9b.js +380 -0
- 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-8ez6mccb.js → roy-agent-core-k3gcvybs.js} +5 -1
- 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-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-v85n42ve.js → roy-agent-core-mx855td4.js} +17 -38
- package/dist/shared/@ai-setting/{roy-agent-core-v87njmq7.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-vffccgf6.js → roy-agent-core-qwd2dq5q.js} +10 -3
- package/dist/shared/@ai-setting/{roy-agent-core-rsn44n9y.js → roy-agent-core-ra66sf50.js} +2526 -942
- 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-w0qjeq2v.js → roy-agent-core-shb1qsyg.js} +1041 -18
- 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-9vhq7fvv.js → roy-agent-core-tpm1dd1g.js} +34 -88
- 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-q813vafd.js → roy-agent-core-vpcxv1ty.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-bxkjk7zx.js → roy-agent-core-vx8zc847.js} +4 -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-hd3n57zs.js → roy-agent-core-wr1qexzq.js} +5 -5
- 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-0v27y99n.js → roy-agent-core-yh68z1bg.js} +65 -4
- package/package.json +18 -1
- /package/dist/shared/@ai-setting/{roy-agent-core-b4x6x4k2.js → roy-agent-core-m1fgtnrc.js} +0 -0
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview WecomSessionCardStore — 企微 **session 卡**的持久化记录(Task #5364)
|
|
3
|
+
*
|
|
4
|
+
* ## 为什么需要(B 方案的核心前提)
|
|
5
|
+
*
|
|
6
|
+
* 用户 2026-11-12 08:34 拍板 **B**:
|
|
7
|
+
*
|
|
8
|
+
* > 「企微改成**只维护一张卡 + 靠按钮触发更新**」
|
|
9
|
+
*
|
|
10
|
+
* 企微协议硬约束(#5203 已取证):`aibot_respond_update_msg` **必须**在
|
|
11
|
+
* `template_card_event` 回调的 5 秒窗口内、用回调带回的 `req_id` 才能更新卡片。
|
|
12
|
+
* 生命周期事件不是回调、没有 req_id ⇒ **无法主动 patch**。
|
|
13
|
+
*
|
|
14
|
+
* 于是 #5360 的实现退化成「每个生命周期发一张新卡」—— 用户明确否掉(重复卡
|
|
15
|
+
* + 刷屏)。B 方案换一条路:
|
|
16
|
+
*
|
|
17
|
+
* ```
|
|
18
|
+
* 首次 lifecycle 事件 → 发**一张**卡(记住 cardTaskId)
|
|
19
|
+
* 后续 lifecycle 事件 → 只写本 store(不发送)
|
|
20
|
+
* 用户点「刷新」按钮 → 有 req_id 了 → 从本 store 读快照 + 实时活性 → patch 同一张卡
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* ⇒ **本 store 是「刷新时能重建整张卡」的唯一数据来源**。缺了它,刷新只能
|
|
24
|
+
* 显示活性,生命周期/标题/操作记录全丢 —— 直接违反用户「原有信息一个不少」。
|
|
25
|
+
*
|
|
26
|
+
* ## 为什么不复用 wecom-card-state-store(task 维度)
|
|
27
|
+
*
|
|
28
|
+
* `wecom_card.task_id INTEGER PRIMARY KEY` 结构上装不下 `session_xxx` 字符串。
|
|
29
|
+
* 硬塞要么改主键类型(旧库迁移风险),要么把 sessionId hash 成数字(不可逆,
|
|
30
|
+
* 刷新时反解不回来)。所以**独立库文件 + 独立表 + 字符串主键**,零迁移风险。
|
|
31
|
+
*
|
|
32
|
+
* 库文件:`~/.local/share/roy-agent/wecom-session-cards.db`
|
|
33
|
+
*/
|
|
34
|
+
/** session 卡生命周期(与 wecom-card-builder 的 WecomSessionLifecycle 同义) */
|
|
35
|
+
export type WecomSessionCardLifecycle = "running" | "completed" | "timeout" | "failed" | "stopped";
|
|
36
|
+
/** 卡片上的一条执行动态(与 WecomMilestoneLite 结构兼容) */
|
|
37
|
+
export interface WecomSessionMilestone {
|
|
38
|
+
title: string;
|
|
39
|
+
timestamp: string;
|
|
40
|
+
description?: string;
|
|
41
|
+
}
|
|
42
|
+
/** 一条 session 卡持久化记录 */
|
|
43
|
+
export interface WecomSessionCardState {
|
|
44
|
+
/** ★ 主键:sub-session id(字符串,非 task 号) */
|
|
45
|
+
sessionId: string;
|
|
46
|
+
/** 企微 chat_id(单聊=userid,群聊=chatid) */
|
|
47
|
+
chatId: string;
|
|
48
|
+
/** 会话类型(更新发送/诊断用) */
|
|
49
|
+
chatType: "single" | "group";
|
|
50
|
+
/** 事件源 ID(WS 实例反查用;刷新端口不依赖它,但诊断需要) */
|
|
51
|
+
sourceId?: string;
|
|
52
|
+
/**
|
|
53
|
+
* ★ 首次发卡时卡片上的 `template_card.task_id`。
|
|
54
|
+
*
|
|
55
|
+
* 刷新帧的 `task_id` **必须**与回调带回的值一致(协议硬约束),
|
|
56
|
+
* 所以这个值必须持久化 —— 否则重启后刷新会因为 task_id 不匹配而失败。
|
|
57
|
+
*/
|
|
58
|
+
cardTaskId: string;
|
|
59
|
+
/** 当前生命周期 */
|
|
60
|
+
lifecycle: WecomSessionCardLifecycle;
|
|
61
|
+
/** 会话标题(description / agent 名) */
|
|
62
|
+
title?: string;
|
|
63
|
+
/** 所属 agent(subagentType) */
|
|
64
|
+
agentType?: string;
|
|
65
|
+
/** 开始时间(ISO) */
|
|
66
|
+
startedAt?: string;
|
|
67
|
+
/** 该 session 关联的 roy 任务号(可选增强) */
|
|
68
|
+
associatedTaskId?: number;
|
|
69
|
+
/** 累积执行动态(JSON 字符串:WecomSessionMilestone[]) */
|
|
70
|
+
milestones?: string;
|
|
71
|
+
/** 首次发卡时间(ms epoch) */
|
|
72
|
+
createdAt: number;
|
|
73
|
+
/** 最后更新时间(ms epoch) */
|
|
74
|
+
updatedAt: number;
|
|
75
|
+
/** 终结时间(ms epoch);仅终态有值 */
|
|
76
|
+
closedAt?: number;
|
|
77
|
+
}
|
|
78
|
+
/** 持久化端口(sender / 刷新 handler 只依赖这个接口,便于测试注入) */
|
|
79
|
+
export interface WecomSessionCardStore {
|
|
80
|
+
/** 写入或覆盖一条记录 */
|
|
81
|
+
upsert(state: WecomSessionCardState): void;
|
|
82
|
+
/** 按 sessionId 读取 */
|
|
83
|
+
get(sessionId: string): WecomSessionCardState | undefined;
|
|
84
|
+
/** 列出全部记录(诊断用) */
|
|
85
|
+
list(): WecomSessionCardState[];
|
|
86
|
+
/** 标记终结(保留 cardTaskId 便于事后追溯) */
|
|
87
|
+
markClosed(sessionId: string): void;
|
|
88
|
+
/** 真删除(仅测试/手工清理用) */
|
|
89
|
+
delete(sessionId: string): void;
|
|
90
|
+
/** 释放资源 */
|
|
91
|
+
close(): void;
|
|
92
|
+
}
|
|
93
|
+
/** 内存实现(测试直接用,不经过 createWecomSessionCardStore 的环境守卫) */
|
|
94
|
+
export declare class MemoryWecomSessionCardStore implements WecomSessionCardStore {
|
|
95
|
+
private readonly records;
|
|
96
|
+
upsert(state: WecomSessionCardState): void;
|
|
97
|
+
get(sessionId: string): WecomSessionCardState | undefined;
|
|
98
|
+
list(): WecomSessionCardState[];
|
|
99
|
+
markClosed(sessionId: string): void;
|
|
100
|
+
delete(sessionId: string): void;
|
|
101
|
+
close(): void;
|
|
102
|
+
}
|
|
103
|
+
/** 测试工厂:内存 store */
|
|
104
|
+
export declare function createMemoryWecomSessionCardStore(): WecomSessionCardStore;
|
|
105
|
+
export declare class SqliteWecomSessionCardStore implements WecomSessionCardStore {
|
|
106
|
+
private readonly db;
|
|
107
|
+
constructor(dbPath: string);
|
|
108
|
+
upsert(state: WecomSessionCardState): void;
|
|
109
|
+
get(sessionId: string): WecomSessionCardState | undefined;
|
|
110
|
+
list(): WecomSessionCardState[];
|
|
111
|
+
markClosed(sessionId: string): void;
|
|
112
|
+
delete(sessionId: string): void;
|
|
113
|
+
close(): void;
|
|
114
|
+
}
|
|
115
|
+
/** 默认库文件路径:`$HOME/.local/share/roy-agent/wecom-session-cards.db` */
|
|
116
|
+
export declare function getDefaultWecomSessionCardDbPath(): string;
|
|
117
|
+
/**
|
|
118
|
+
* 创建持久化 store。
|
|
119
|
+
*
|
|
120
|
+
* ★ 失败降级:SQLite 打不开时**不抛错**,回落内存实现并 warn ——
|
|
121
|
+
* 卡片刷新不能因为持久化层故障整体崩掉(降级后「只发一张卡」语义在
|
|
122
|
+
* 单进程内仍成立,只是重启后可能重发一张)。
|
|
123
|
+
*
|
|
124
|
+
* ★ 测试环境保护(与 createWecomCardStateStore 同配方):
|
|
125
|
+
* bun test 环境 + 未显式指定路径 → 一律返回内存实现(零副作用),
|
|
126
|
+
* 防止测试污染真实用户库。
|
|
127
|
+
*/
|
|
128
|
+
export declare function createWecomSessionCardStore(dbPath?: string): WecomSessionCardStore;
|
|
129
|
+
/** 取(并在首次调用时创建)进程级共享 session 卡 store。 */
|
|
130
|
+
export declare function getSharedWecomSessionCardStore(): WecomSessionCardStore;
|
|
131
|
+
/**
|
|
132
|
+
* 测试钩子:重置共享单例(关闭旧连接,避免 fd 泄漏 / 跨用例串状态)。
|
|
133
|
+
*/
|
|
134
|
+
export declare function __resetSharedWecomSessionCardStoreForTest(): void;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {
|
|
2
|
+
MemoryWecomSessionCardStore,
|
|
3
|
+
SqliteWecomSessionCardStore,
|
|
4
|
+
__resetSharedWecomSessionCardStoreForTest,
|
|
5
|
+
createMemoryWecomSessionCardStore,
|
|
6
|
+
createWecomSessionCardStore,
|
|
7
|
+
getDefaultWecomSessionCardDbPath,
|
|
8
|
+
getSharedWecomSessionCardStore
|
|
9
|
+
} from "../../../shared/@ai-setting/roy-agent-core-7kvpc0w5.js";
|
|
10
|
+
import"../../../shared/@ai-setting/roy-agent-core-6k8mb7zx.js";
|
|
11
|
+
import"../../../shared/@ai-setting/roy-agent-core-5s2t8z00.js";
|
|
12
|
+
import"../../../shared/@ai-setting/roy-agent-core-7f7t9wwp.js";
|
|
13
|
+
import"../../../shared/@ai-setting/roy-agent-core-85xyctnb.js";
|
|
14
|
+
import"../../../shared/@ai-setting/roy-agent-core-fs0mn2jk.js";
|
|
15
|
+
export {
|
|
16
|
+
getSharedWecomSessionCardStore,
|
|
17
|
+
getDefaultWecomSessionCardDbPath,
|
|
18
|
+
createWecomSessionCardStore,
|
|
19
|
+
createMemoryWecomSessionCardStore,
|
|
20
|
+
__resetSharedWecomSessionCardStoreForTest,
|
|
21
|
+
SqliteWecomSessionCardStore,
|
|
22
|
+
MemoryWecomSessionCardStore
|
|
23
|
+
};
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview WecomTaskNotifyHook — 企微任务进展通知 Hook(Task #5193)
|
|
3
|
+
*
|
|
4
|
+
* 在任务生命周期事件上,把「任务进展」渲染成 **markdown 消息**
|
|
5
|
+
* 发到企微(对齐 LarkCliTaskNotifyHook 的 hook 结构):
|
|
6
|
+
*
|
|
7
|
+
* - `task:after.create` → 发初始卡片
|
|
8
|
+
* - `task:after.update` → 发更新卡片(进度/状态/变更摘要)
|
|
9
|
+
* - `task:after.complete` → 发终态卡片(仅真验收完成)
|
|
10
|
+
* - `task:after.delete` → 发取消收尾
|
|
11
|
+
* - `task:operation:after.create` → 时间线追加(节流)
|
|
12
|
+
*
|
|
13
|
+
* ## 与 lark-cli 插件的关键差异
|
|
14
|
+
*
|
|
15
|
+
* | 维度 | lark-cli | wecom-cli |
|
|
16
|
+
* |------|----------|-----------|
|
|
17
|
+
* | 卡片形态 | interactive card(可 patch 同一张) | **markdown 消息(每次新发)** |
|
|
18
|
+
* | 更新方式 | PATCH 原卡片 | 每次更新发一条新 markdown |
|
|
19
|
+
* | pin/unpin | 支持 | **无**(恒 false) |
|
|
20
|
+
* | messageId 跟踪 | 必须(patch 键) | 不需要 |
|
|
21
|
+
*
|
|
22
|
+
* ⇒ 企微侧防刷屏靠**节流**(operationThrottleMs 默认 5s);
|
|
23
|
+
* 时间线**必须持久化**(wecom-cards.db)—— 每条新消息都要
|
|
24
|
+
* 渲染完整历史,重启后也不能丢。
|
|
25
|
+
*
|
|
26
|
+
* ## chat_id 语义(实测硬约束,Task #5174)
|
|
27
|
+
*
|
|
28
|
+
* - replyChannel.chatId:单聊 = 对方 userid,群聊 = chatid
|
|
29
|
+
* - CLI 需要真实 userid(`wotnB7Wg...` 形态)→ 出站统一走
|
|
30
|
+
* `sendWecomReply`(内部 `resolveWecomCliChatId` 解析 + 缓存)
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* import { createWecomTaskNotifyHook } from "./wecom-task-notify-plugin";
|
|
35
|
+
* globalHookManager.register("task:after.create", createWecomTaskNotifyHook({...}));
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
import type { Hook, HookContext } from "../../hook/types";
|
|
39
|
+
import type { Task } from "../types";
|
|
40
|
+
import { type WecomSendResult } from "../../event-source/wecom-respond-registry";
|
|
41
|
+
import { MemoryWecomCardStateStore, getDefaultWecomCardDbPath, type WecomCardStateStore } from "./wecom-card-state-store";
|
|
42
|
+
/** 通知类型(对齐 NotifyType) */
|
|
43
|
+
export declare const WecomNotifyType: {
|
|
44
|
+
readonly TASK_CREATED: "task_created";
|
|
45
|
+
readonly TASK_UPDATED: "task_updated";
|
|
46
|
+
readonly TASK_COMPLETED: "task_completed";
|
|
47
|
+
readonly OPERATION_CREATED: "operation_created";
|
|
48
|
+
};
|
|
49
|
+
export type WecomNotifyType = (typeof WecomNotifyType)[keyof typeof WecomNotifyType];
|
|
50
|
+
/** 时间线里程碑(渲染用,与 LarkCardPatchNotifier.Milestone 形态对齐) */
|
|
51
|
+
export interface WecomMilestone {
|
|
52
|
+
title: string;
|
|
53
|
+
timestamp: string;
|
|
54
|
+
description?: string;
|
|
55
|
+
}
|
|
56
|
+
/** 插件配置 */
|
|
57
|
+
export interface WecomTaskNotifyConfig {
|
|
58
|
+
/** 是否启用 */
|
|
59
|
+
enabled?: boolean;
|
|
60
|
+
/** 优先级 */
|
|
61
|
+
priority?: number;
|
|
62
|
+
/** 插件名称(用于 pluginEnabled 检查) */
|
|
63
|
+
pluginName?: string;
|
|
64
|
+
/** 事件源 ID(用于 pluginEnabled 检查) */
|
|
65
|
+
sourceId?: string;
|
|
66
|
+
/**
|
|
67
|
+
* 操作记录通知节流间隔(毫秒)
|
|
68
|
+
*
|
|
69
|
+
* 企微每次更新都是**新消息**,不加节流会刷屏。默认 5000ms;
|
|
70
|
+
* 设为 0 表示不节流。
|
|
71
|
+
*/
|
|
72
|
+
operationThrottleMs?: number;
|
|
73
|
+
/**
|
|
74
|
+
* 时间线最多保留的里程碑条数(防消息无限膨胀)
|
|
75
|
+
*
|
|
76
|
+
* 企微 markdown 消息有长度上限,时间线太长会被截断。
|
|
77
|
+
* 默认 20 条,超出时丢最旧的(最新进展最重要)。
|
|
78
|
+
*/
|
|
79
|
+
maxTimelineEntries?: number;
|
|
80
|
+
/** 通知类型过滤(空数组 = 全开) */
|
|
81
|
+
notifyTypes?: WecomNotifyType[];
|
|
82
|
+
/**
|
|
83
|
+
* ★ Task #5360(补充需求):ES 配置的 `statusNotifications` 透传。
|
|
84
|
+
*
|
|
85
|
+
* - `false` / 缺省(默认):只发卡片(#5255 单卡语义)
|
|
86
|
+
* - `true`:发卡成功后**额外**再发一条 markdown 状态文本
|
|
87
|
+
*
|
|
88
|
+
* 为什么由工厂注入而不是插件自己读 `event-sources.json`:
|
|
89
|
+
* 插件不持有 ES 配置句柄,且同一进程可能有多个 wecom 源 ——
|
|
90
|
+
* 由 `es-plugins` 工厂把**该源自己的**配置值传进来,语义最准确。
|
|
91
|
+
*/
|
|
92
|
+
statusNotifications?: boolean;
|
|
93
|
+
/**
|
|
94
|
+
* 出站 sender(测试注入;不传用 sendWecomReply)
|
|
95
|
+
*/
|
|
96
|
+
sender?: {
|
|
97
|
+
send(input: {
|
|
98
|
+
chatId: string;
|
|
99
|
+
content: string;
|
|
100
|
+
}): Promise<WecomSendResult>;
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* 卡片记录持久化 store
|
|
104
|
+
*
|
|
105
|
+
* 不传 → 自动创建(`~/.local/share/roy-agent/wecom-cards.db`);
|
|
106
|
+
* 测试可注入 MemoryWecomCardStateStore。
|
|
107
|
+
*/
|
|
108
|
+
cardStateStore?: WecomCardStateStore;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* 从 EnvContext 判定是否企微事件,并提取 chatId。
|
|
112
|
+
*
|
|
113
|
+
* 判定优先级:
|
|
114
|
+
* 1. `envEvent.type === "event-source.event.wecom-cli"`(生产主路径)
|
|
115
|
+
* 2. `replyChannel.type === "wecom-cli"`(兜底:事件类型缺失但通道明确)
|
|
116
|
+
*
|
|
117
|
+
* 两者都不满足(lark / cli-command / timer…)→ isWecom=false,插件跳过。
|
|
118
|
+
*/
|
|
119
|
+
export declare function extractWecomFields(env: {
|
|
120
|
+
envEvent?: unknown;
|
|
121
|
+
replyChannel?: {
|
|
122
|
+
type?: string;
|
|
123
|
+
chatId?: string;
|
|
124
|
+
};
|
|
125
|
+
}, fallbackSourceId?: string): {
|
|
126
|
+
isWecom: boolean;
|
|
127
|
+
chatId?: string;
|
|
128
|
+
sourceId?: string;
|
|
129
|
+
};
|
|
130
|
+
/**
|
|
131
|
+
* 渲染企微进展卡片(markdown)
|
|
132
|
+
*
|
|
133
|
+
* 结构(对齐 lark 卡片的信息密度,压缩成 markdown):
|
|
134
|
+
* ```
|
|
135
|
+
* ### 📋 Task #42 · 时空增强任务
|
|
136
|
+
* **状态**:🔄 进行中(80%)
|
|
137
|
+
* > 任务描述第一行…
|
|
138
|
+
*
|
|
139
|
+
* **时间线**
|
|
140
|
+
* - 🕐 2026-06-01 00:00 — Task 创建
|
|
141
|
+
* - 🕐 2026-06-01 02:00 — 完成需求分析:已完成核心功能的需求拆解
|
|
142
|
+
* ```
|
|
143
|
+
*/
|
|
144
|
+
export declare function buildWecomTaskCard(input: {
|
|
145
|
+
task: Task;
|
|
146
|
+
statusLabel: string;
|
|
147
|
+
milestones: WecomMilestone[];
|
|
148
|
+
/** 变更摘要(update 时) */
|
|
149
|
+
changeSummary?: string;
|
|
150
|
+
/** 是否终态(终态加收尾分隔线) */
|
|
151
|
+
terminal?: boolean;
|
|
152
|
+
}): string;
|
|
153
|
+
export declare class WecomTaskNotifyHook implements Hook {
|
|
154
|
+
readonly name: string;
|
|
155
|
+
readonly priority: number;
|
|
156
|
+
readonly description?: string;
|
|
157
|
+
readonly pluginName?: string;
|
|
158
|
+
readonly sourceId?: string;
|
|
159
|
+
private readonly config;
|
|
160
|
+
/** 出站 sender(默认 sendWecomReply,测试可注入) */
|
|
161
|
+
private readonly sender;
|
|
162
|
+
/** 持久化 store(taskId → chatId/status/timeline) */
|
|
163
|
+
private readonly cardStateStore;
|
|
164
|
+
/**
|
|
165
|
+
* ★ Task #5360(补充需求):状态通知文本开关(严格 `=== true`)。
|
|
166
|
+
*
|
|
167
|
+
* 构造时快照一次(配置热更新靠重建插件实例,与 `enabled` / `priority` 一致),
|
|
168
|
+
* 避免每次 deliver 都读 config 对象。
|
|
169
|
+
*/
|
|
170
|
+
private readonly esStatusNotifications;
|
|
171
|
+
/** 操作记录节流状态:key `op:${taskId}` → 上次发送时间戳 */
|
|
172
|
+
private lastNotifyTimestamps;
|
|
173
|
+
constructor(config?: WecomTaskNotifyConfig);
|
|
174
|
+
/**
|
|
175
|
+
* 默认出站:sendWecomReply(CLI 主路径 → WS fallback)
|
|
176
|
+
*
|
|
177
|
+
* sourceId 从事件 metadata 取(sendWecomReply 只在 WS fallback 时用)。
|
|
178
|
+
*/
|
|
179
|
+
private defaultSend;
|
|
180
|
+
execute(ctx: HookContext<unknown>): Promise<void>;
|
|
181
|
+
/** 任务创建:发初始卡片 */
|
|
182
|
+
private onAfterCreate;
|
|
183
|
+
/** 任务更新:发更新卡片 */
|
|
184
|
+
private onAfterUpdate;
|
|
185
|
+
/** 任务终态(task_complete):仅真验收完成(to_validate 是自查关) */
|
|
186
|
+
private onAfterComplete;
|
|
187
|
+
/** 任务删除(硬删除):收尾 */
|
|
188
|
+
private onAfterDelete;
|
|
189
|
+
/** 操作记录创建:时间线追加(节流) */
|
|
190
|
+
private onAfterOperationCreate;
|
|
191
|
+
/** 发初始卡片 */
|
|
192
|
+
private sendCardStart;
|
|
193
|
+
/** 发更新卡片 */
|
|
194
|
+
private sendCardUpdate;
|
|
195
|
+
/** 发终态卡片 */
|
|
196
|
+
private sendCardFinish;
|
|
197
|
+
/**
|
|
198
|
+
* 投递(永不抛)
|
|
199
|
+
*
|
|
200
|
+
* ★ Task #5203:主路径 = WS 直发 template_card(text_notice 进展卡);
|
|
201
|
+
* 构造失败 / WS 不可用 → 回落 markdown(CLI 路径,#5193 行为)。
|
|
202
|
+
*
|
|
203
|
+
* @returns 是否成功(失败时调用方决定是否落库)
|
|
204
|
+
*/
|
|
205
|
+
private deliver;
|
|
206
|
+
/**
|
|
207
|
+
* ★ Task #5360(补充需求):读 ES 配置的 `statusNotifications`。
|
|
208
|
+
*
|
|
209
|
+
* ## 为什么读实时配置而不是快照
|
|
210
|
+
*
|
|
211
|
+
* lark 侧走 `EventHandler`(事件驱动,用 delegate 时刻的快照);
|
|
212
|
+
* 企微插件是**直接挂在 hook 上**(`task:after.create/update/complete`),
|
|
213
|
+
* 拿不到"任务诞生时的快照",所以只能读事件源当前配置。
|
|
214
|
+
*
|
|
215
|
+
* 语义差异可接受:企微侧开关变化对**下一次**任务状态变化生效(毫秒级),
|
|
216
|
+
* 而 lark 侧对已派生任务保持口径一致。两边各自的取舍都有文档说明。
|
|
217
|
+
*
|
|
218
|
+
* 严格 `=== true`(手改 JSON 的 "true"/1/null 一律当 false)。
|
|
219
|
+
*/
|
|
220
|
+
private statusNotificationsEnabled;
|
|
221
|
+
/**
|
|
222
|
+
* ★ Task #5360(补充需求):`statusNotifications: true` 时额外发的 markdown 状态文本。
|
|
223
|
+
*
|
|
224
|
+
* 内容 = 现有 `buildWecomTaskCard` 的 markdown 形态(#5193 的文本可读性),
|
|
225
|
+
* 与卡片正文同源,避免两套文案漂移。
|
|
226
|
+
*/
|
|
227
|
+
private sendStatusMarkdown;
|
|
228
|
+
/**
|
|
229
|
+
* ★ Task #5203:经 WS 直发 template_card。
|
|
230
|
+
*
|
|
231
|
+
* - chatType:单聊 → chat_type=1;群聊 → 2
|
|
232
|
+
* (★ Task #5270:读 replyChannel.params.chatType——
|
|
233
|
+
* buildWecomReplyChannel 塞入,顶层无 chatType 字段;
|
|
234
|
+
* 另当 chatId 与当前 env 的 chatId 不一致时(终态/删除
|
|
235
|
+
* 链路用持久化记录的 rec.chatId,可能来自群会话)按群聊
|
|
236
|
+
* 处理,避免群 chatid + chat_type=1 错配被企微丢弃)
|
|
237
|
+
* - 失败返回 false(调用方回落 markdown),绝不抛
|
|
238
|
+
*/
|
|
239
|
+
private deliverTemplateCard;
|
|
240
|
+
/** 读记录(store 异常降级为 undefined,绝不抛) */
|
|
241
|
+
private getRecord;
|
|
242
|
+
/** 解析持久化的时间线 JSON(损坏时返回空数组) */
|
|
243
|
+
private parseTimeline;
|
|
244
|
+
/** 时间线截断(保留最新 N 条) */
|
|
245
|
+
private trimTimeline;
|
|
246
|
+
/** 持久化时间线(失败只 warn) */
|
|
247
|
+
private persistTimeline;
|
|
248
|
+
/** 从记录重建最小 Task(delete 后 Task 已不存在) */
|
|
249
|
+
private hydrateTask;
|
|
250
|
+
/**
|
|
251
|
+
* 操作记录发送节流
|
|
252
|
+
*
|
|
253
|
+
* 同一 Task 在 operationThrottleMs(默认 5s)窗口内只发一次,
|
|
254
|
+
* 避免 agent 每次 tool call 都刷屏(企微每次都是新消息,比 lark 更敏感)。
|
|
255
|
+
*
|
|
256
|
+
* ★ 返回 true **不代表丢弃**:被节流的 operation 仍会先并进
|
|
257
|
+
* 时间线并落库,只是不立刻发送。
|
|
258
|
+
*/
|
|
259
|
+
private shouldThrottleOperation;
|
|
260
|
+
/** 检查是否应该发送通知 */
|
|
261
|
+
private shouldNotify;
|
|
262
|
+
}
|
|
263
|
+
export declare function createWecomTaskNotifyHook(config?: WecomTaskNotifyConfig): WecomTaskNotifyHook;
|
|
264
|
+
export { MemoryWecomCardStateStore, getDefaultWecomCardDbPath };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import"../../../shared/@ai-setting/roy-agent-core-
|
|
1
|
+
import"../../../shared/@ai-setting/roy-agent-core-vpcxv1ty.js";
|
|
2
2
|
import {
|
|
3
3
|
SQLiteTaskStore,
|
|
4
4
|
getDefaultDataDir,
|
|
5
5
|
getDefaultTaskDbPath
|
|
6
|
-
} from "../../../shared/@ai-setting/roy-agent-core-
|
|
7
|
-
import"../../../shared/@ai-setting/roy-agent-core-
|
|
6
|
+
} from "../../../shared/@ai-setting/roy-agent-core-6k8mb7zx.js";
|
|
7
|
+
import"../../../shared/@ai-setting/roy-agent-core-5s2t8z00.js";
|
|
8
8
|
import"../../../shared/@ai-setting/roy-agent-core-7f7t9wwp.js";
|
|
9
9
|
import"../../../shared/@ai-setting/roy-agent-core-85xyctnb.js";
|
|
10
10
|
import"../../../shared/@ai-setting/roy-agent-core-fs0mn2jk.js";
|
|
@@ -11,12 +11,12 @@ import {
|
|
|
11
11
|
searchTasksTool,
|
|
12
12
|
treeTasksTool,
|
|
13
13
|
updateTaskTool
|
|
14
|
-
} from "../../../shared/@ai-setting/roy-agent-core-
|
|
15
|
-
import"../../../shared/@ai-setting/roy-agent-core-
|
|
14
|
+
} from "../../../shared/@ai-setting/roy-agent-core-qwd2dq5q.js";
|
|
15
|
+
import"../../../shared/@ai-setting/roy-agent-core-d6zdbgtc.js";
|
|
16
16
|
import"../../../shared/@ai-setting/roy-agent-core-m46fe3x4.js";
|
|
17
17
|
import"../../../shared/@ai-setting/roy-agent-core-4rtg69cn.js";
|
|
18
|
-
import"../../../shared/@ai-setting/roy-agent-core-
|
|
19
|
-
import"../../../shared/@ai-setting/roy-agent-core-
|
|
18
|
+
import"../../../shared/@ai-setting/roy-agent-core-p31ftgq9.js";
|
|
19
|
+
import"../../../shared/@ai-setting/roy-agent-core-5s2t8z00.js";
|
|
20
20
|
import"../../../shared/@ai-setting/roy-agent-core-7f7t9wwp.js";
|
|
21
21
|
import"../../../shared/@ai-setting/roy-agent-core-85xyctnb.js";
|
|
22
22
|
import"../../../shared/@ai-setting/roy-agent-core-fs0mn2jk.js";
|
|
@@ -7,6 +7,7 @@ import { writeFileTool } from "./write-file";
|
|
|
7
7
|
import { editFileTool } from "./edit-file";
|
|
8
8
|
import { grepTool } from "./grep";
|
|
9
9
|
import { understandImageTool } from "./understand-image";
|
|
10
|
+
import { wecomRespondTool } from "../../event-source/wecom-respond-registry";
|
|
10
11
|
import { createQueryBackgroundProcessTool } from "./query-background-process-tool";
|
|
11
12
|
import { createCompactSessionTool, compactSessionTool } from "./compact-session-tool";
|
|
12
13
|
export { bashTool };
|
|
@@ -17,6 +18,7 @@ export { writeFileTool };
|
|
|
17
18
|
export { editFileTool };
|
|
18
19
|
export { grepTool };
|
|
19
20
|
export { understandImageTool };
|
|
21
|
+
export { wecomRespondTool };
|
|
20
22
|
import { queryBackgroundProcessTool } from "./query-background-process-tool";
|
|
21
23
|
export { queryBackgroundProcessTool, createQueryBackgroundProcessTool };
|
|
22
24
|
export { compactSessionTool, createCompactSessionTool };
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
grepTool,
|
|
9
9
|
readFileTool,
|
|
10
10
|
writeFileTool
|
|
11
|
-
} from "../../../shared/@ai-setting/roy-agent-core-
|
|
11
|
+
} from "../../../shared/@ai-setting/roy-agent-core-k3gcvybs.js";
|
|
12
12
|
import {
|
|
13
13
|
getUnderstandImageLLMProvider,
|
|
14
14
|
resetUnderstandImageLLMProvider,
|
|
@@ -22,13 +22,20 @@ import {
|
|
|
22
22
|
queryBackgroundProcessTool
|
|
23
23
|
} from "../../../shared/@ai-setting/roy-agent-core-2akfd64z.js";
|
|
24
24
|
import"../../../shared/@ai-setting/roy-agent-core-fttgm52a.js";
|
|
25
|
+
import {
|
|
26
|
+
wecomRespondTool
|
|
27
|
+
} from "../../../shared/@ai-setting/roy-agent-core-h1e1fm9b.js";
|
|
28
|
+
import"../../../shared/@ai-setting/roy-agent-core-c4ec7k0p.js";
|
|
29
|
+
import"../../../shared/@ai-setting/roy-agent-core-418zc9ha.js";
|
|
25
30
|
import"../../../shared/@ai-setting/roy-agent-core-zjdzk1gg.js";
|
|
26
|
-
import"../../../shared/@ai-setting/roy-agent-core-
|
|
31
|
+
import"../../../shared/@ai-setting/roy-agent-core-p31ftgq9.js";
|
|
32
|
+
import"../../../shared/@ai-setting/roy-agent-core-5s2t8z00.js";
|
|
27
33
|
import"../../../shared/@ai-setting/roy-agent-core-7f7t9wwp.js";
|
|
28
34
|
import"../../../shared/@ai-setting/roy-agent-core-85xyctnb.js";
|
|
29
35
|
import"../../../shared/@ai-setting/roy-agent-core-fs0mn2jk.js";
|
|
30
36
|
export {
|
|
31
37
|
writeFileTool,
|
|
38
|
+
wecomRespondTool,
|
|
32
39
|
understandImageTool,
|
|
33
40
|
setUnderstandImageLLMProvider,
|
|
34
41
|
resetUnderstandImageLLMProvider,
|
package/dist/env/tool/index.js
CHANGED
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
grepTool,
|
|
11
11
|
readFileTool,
|
|
12
12
|
writeFileTool
|
|
13
|
-
} from "../../shared/@ai-setting/roy-agent-core-
|
|
13
|
+
} from "../../shared/@ai-setting/roy-agent-core-k3gcvybs.js";
|
|
14
14
|
import {
|
|
15
15
|
getUnderstandImageLLMProvider,
|
|
16
16
|
resetUnderstandImageLLMProvider,
|
|
@@ -19,23 +19,28 @@ import {
|
|
|
19
19
|
} from "../../shared/@ai-setting/roy-agent-core-xwm8zavb.js";
|
|
20
20
|
import"../../shared/@ai-setting/roy-agent-core-2akfd64z.js";
|
|
21
21
|
import"../../shared/@ai-setting/roy-agent-core-fttgm52a.js";
|
|
22
|
+
import"../../shared/@ai-setting/roy-agent-core-h1e1fm9b.js";
|
|
23
|
+
import"../../shared/@ai-setting/roy-agent-core-c4ec7k0p.js";
|
|
24
|
+
import"../../shared/@ai-setting/roy-agent-core-418zc9ha.js";
|
|
22
25
|
import {
|
|
23
26
|
ToolComponent,
|
|
24
27
|
ToolRegistry,
|
|
25
|
-
ToolValidator,
|
|
26
28
|
getMaxOutputSize,
|
|
27
29
|
setToolConfigComponent
|
|
28
|
-
} from "../../shared/@ai-setting/roy-agent-core-
|
|
30
|
+
} from "../../shared/@ai-setting/roy-agent-core-mx855td4.js";
|
|
29
31
|
import"../../shared/@ai-setting/roy-agent-core-jvv2h3d6.js";
|
|
32
|
+
import {
|
|
33
|
+
ToolValidator
|
|
34
|
+
} from "../../shared/@ai-setting/roy-agent-core-wxrkcb17.js";
|
|
30
35
|
import"../../shared/@ai-setting/roy-agent-core-zjdzk1gg.js";
|
|
31
36
|
import"../../shared/@ai-setting/roy-agent-core-mkc3zshb.js";
|
|
32
37
|
import"../../shared/@ai-setting/roy-agent-core-7hh0brvs.js";
|
|
33
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
34
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
35
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
36
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
37
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
38
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
38
|
+
import"../../shared/@ai-setting/roy-agent-core-m39v7qpx.js";
|
|
39
|
+
import"../../shared/@ai-setting/roy-agent-core-smf94h73.js";
|
|
40
|
+
import"../../shared/@ai-setting/roy-agent-core-yet36q5k.js";
|
|
41
|
+
import"../../shared/@ai-setting/roy-agent-core-tkpp1ba0.js";
|
|
42
|
+
import"../../shared/@ai-setting/roy-agent-core-p31ftgq9.js";
|
|
43
|
+
import"../../shared/@ai-setting/roy-agent-core-5s2t8z00.js";
|
|
39
44
|
import"../../shared/@ai-setting/roy-agent-core-7f7t9wwp.js";
|
|
40
45
|
import"../../shared/@ai-setting/roy-agent-core-85xyctnb.js";
|
|
41
46
|
import"../../shared/@ai-setting/roy-agent-core-fs0mn2jk.js";
|
package/dist/env/tool/types.d.ts
CHANGED
|
@@ -163,6 +163,31 @@ export interface ToolMetadata {
|
|
|
163
163
|
* 3. ToolComponent.listTools({ allowedAgent }) 一次过滤;agent-component 再做 allowedTools/deniedTools 二次过滤
|
|
164
164
|
*/
|
|
165
165
|
allowedAgentTypes?: string[];
|
|
166
|
+
/**
|
|
167
|
+
* ★ Task #5333 — 渠道专用工具标记(channel-only tool)。
|
|
168
|
+
*
|
|
169
|
+
* `true` = 该工具**只对特定事件源渠道**有意义,默认对所有 agent 不可见;
|
|
170
|
+
* 只有当前会话的 `AgentContext.extendTools` 显式列出该工具名时才可见。
|
|
171
|
+
*
|
|
172
|
+
* 典型用例:`wecom_respond`(企微出站唯一通道)——
|
|
173
|
+
* 在飞书会话 / 交互式 CLI 里调用必然失败(无企微 chatId,无 wecom 注册表实例),
|
|
174
|
+
* 但它原先在 `getAllBuiltInTools()` 全局注册且无可见性声明 →
|
|
175
|
+
* 所有 agent(含 default 接待员)都被注入了它,LLM 会误调。
|
|
176
|
+
*
|
|
177
|
+
* 与 `allowedAgentTypes` 的区别:
|
|
178
|
+
* - `allowedAgentTypes` 按 **agent 身份** 过滤(谁可见)
|
|
179
|
+
* - `channelOnly` 按 **会话渠道上下文** 过滤(哪个事件源驱动的这一轮可见)
|
|
180
|
+
*
|
|
181
|
+
* 两者正交,都满足才可见。实际判定顺序见 `filterToolsByAgent`:
|
|
182
|
+
* **先 channelOnly**(渠道上下文),**再 allowedAgentTypes**(agent 身份)。
|
|
183
|
+
*
|
|
184
|
+
* ⚠️ 可见性只在 `AgentComponent.getAvailableTools` 一处收敛
|
|
185
|
+
* (`filterToolsByAgent`)。`ToolRegistry.listTools()` 是**存储目录**
|
|
186
|
+
* (`roy-agent tools list` / 调试用),不做 channelOnly 过滤 ——
|
|
187
|
+
* 否则"无 filter 全量返回、有 filter 却隐藏"会造成同一工具在不同
|
|
188
|
+
* 查询路径下存在性不一致。
|
|
189
|
+
*/
|
|
190
|
+
channelOnly?: boolean;
|
|
166
191
|
/**
|
|
167
192
|
* Whether this tool explicitly opts out of string output truncation.
|
|
168
193
|
*
|
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
import type { Tool, ValidationResult } from "./types";
|
|
2
|
+
/** 接线 ConfigComponent(由 ToolComponent.init 调用,支持热更新) */
|
|
3
|
+
export declare function setToolReasonConfigComponent(component: {
|
|
4
|
+
get(key: string): unknown;
|
|
5
|
+
} | null): void;
|
|
6
|
+
/** 测试 / 无 ConfigComponent 场景的模块级开关 */
|
|
7
|
+
export declare function setToolReasonRequired(required: boolean): void;
|
|
8
|
+
/** 当前是否要求 reason(逃生开关读取,实时) */
|
|
9
|
+
export declare function isToolReasonRequired(): boolean;
|
|
2
10
|
/**
|
|
3
11
|
* 工具参数验证器
|
|
4
12
|
*/
|
|
@@ -5,25 +5,25 @@ import {
|
|
|
5
5
|
Scheduler,
|
|
6
6
|
WorkflowEngine,
|
|
7
7
|
init_engine
|
|
8
|
-
} from "../../../shared/@ai-setting/roy-agent-core-
|
|
8
|
+
} from "../../../shared/@ai-setting/roy-agent-core-6gj1hc5z.js";
|
|
9
9
|
import"../../../shared/@ai-setting/roy-agent-core-6atd905e.js";
|
|
10
|
-
import"../../../shared/@ai-setting/roy-agent-core-
|
|
11
|
-
import"../../../shared/@ai-setting/roy-agent-core-
|
|
10
|
+
import"../../../shared/@ai-setting/roy-agent-core-bjtc9d35.js";
|
|
11
|
+
import"../../../shared/@ai-setting/roy-agent-core-9710zwwz.js";
|
|
12
12
|
import"../../../shared/@ai-setting/roy-agent-core-1db4vpc6.js";
|
|
13
|
-
import"../../../shared/@ai-setting/roy-agent-core-
|
|
14
|
-
import"../../../shared/@ai-setting/roy-agent-core-
|
|
15
|
-
import"../../../shared/@ai-setting/roy-agent-core-
|
|
13
|
+
import"../../../shared/@ai-setting/roy-agent-core-g8yr733d.js";
|
|
14
|
+
import"../../../shared/@ai-setting/roy-agent-core-h83zdsrq.js";
|
|
15
|
+
import"../../../shared/@ai-setting/roy-agent-core-tjnabyvq.js";
|
|
16
16
|
import"../../../shared/@ai-setting/roy-agent-core-ddwa0n6h.js";
|
|
17
17
|
import {
|
|
18
18
|
DAGManager
|
|
19
|
-
} from "../../../shared/@ai-setting/roy-agent-core-
|
|
19
|
+
} from "../../../shared/@ai-setting/roy-agent-core-e08bvpaq.js";
|
|
20
20
|
import"../../../shared/@ai-setting/roy-agent-core-er070zjq.js";
|
|
21
21
|
import"../../../shared/@ai-setting/roy-agent-core-mkc3zshb.js";
|
|
22
|
-
import"../../../shared/@ai-setting/roy-agent-core-
|
|
23
|
-
import"../../../shared/@ai-setting/roy-agent-core-
|
|
24
|
-
import"../../../shared/@ai-setting/roy-agent-core-
|
|
25
|
-
import"../../../shared/@ai-setting/roy-agent-core-
|
|
26
|
-
import"../../../shared/@ai-setting/roy-agent-core-
|
|
22
|
+
import"../../../shared/@ai-setting/roy-agent-core-smf94h73.js";
|
|
23
|
+
import"../../../shared/@ai-setting/roy-agent-core-yet36q5k.js";
|
|
24
|
+
import"../../../shared/@ai-setting/roy-agent-core-tkpp1ba0.js";
|
|
25
|
+
import"../../../shared/@ai-setting/roy-agent-core-p31ftgq9.js";
|
|
26
|
+
import"../../../shared/@ai-setting/roy-agent-core-5s2t8z00.js";
|
|
27
27
|
import"../../../shared/@ai-setting/roy-agent-core-7f7t9wwp.js";
|
|
28
28
|
import"../../../shared/@ai-setting/roy-agent-core-85xyctnb.js";
|
|
29
29
|
import"../../../shared/@ai-setting/roy-agent-core-fs0mn2jk.js";
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
2
|
init_hooks
|
|
3
|
-
} from "../../../shared/@ai-setting/roy-agent-core-
|
|
3
|
+
} from "../../../shared/@ai-setting/roy-agent-core-g8yr733d.js";
|
|
4
4
|
import {
|
|
5
5
|
WorkflowHookPoints,
|
|
6
6
|
emitWorkflowNodeHook,
|
|
7
7
|
emitWorkflowRunHook,
|
|
8
8
|
getRegisteredWorkflowHookPoints
|
|
9
|
-
} from "../../../shared/@ai-setting/roy-agent-core-
|
|
10
|
-
import"../../../shared/@ai-setting/roy-agent-core-
|
|
11
|
-
import"../../../shared/@ai-setting/roy-agent-core-
|
|
12
|
-
import"../../../shared/@ai-setting/roy-agent-core-
|
|
13
|
-
import"../../../shared/@ai-setting/roy-agent-core-
|
|
14
|
-
import"../../../shared/@ai-setting/roy-agent-core-
|
|
9
|
+
} from "../../../shared/@ai-setting/roy-agent-core-h83zdsrq.js";
|
|
10
|
+
import"../../../shared/@ai-setting/roy-agent-core-smf94h73.js";
|
|
11
|
+
import"../../../shared/@ai-setting/roy-agent-core-yet36q5k.js";
|
|
12
|
+
import"../../../shared/@ai-setting/roy-agent-core-tkpp1ba0.js";
|
|
13
|
+
import"../../../shared/@ai-setting/roy-agent-core-p31ftgq9.js";
|
|
14
|
+
import"../../../shared/@ai-setting/roy-agent-core-5s2t8z00.js";
|
|
15
15
|
import"../../../shared/@ai-setting/roy-agent-core-7f7t9wwp.js";
|
|
16
16
|
import"../../../shared/@ai-setting/roy-agent-core-85xyctnb.js";
|
|
17
17
|
import"../../../shared/@ai-setting/roy-agent-core-fs0mn2jk.js";
|