@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,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Config protection utilities — ~/.roy-agent 配置事故系统性防护(Task #5194)
|
|
3
|
+
*
|
|
4
|
+
* 背景:2026-11-07/11-08 连续三起 ~/.roy-agent 配置被覆盖/重置事故
|
|
5
|
+
* (测试覆盖 ×2、daily-summary 副本手动覆盖 ×1)。路径级守卫
|
|
6
|
+
* (Task #5181 测试隔离)已封死测试写路径,但内容级覆盖
|
|
7
|
+
* (合法写入者写坏内容)无法靠路径守卫防住。
|
|
8
|
+
*
|
|
9
|
+
* 三道护栏:
|
|
10
|
+
* 1. snapshotConfigDir — 写前快照,保留最近 N=10 份,可回滚
|
|
11
|
+
* 2. appendAuditLog — 写入审计(谁/何时/什么),排查不再考古
|
|
12
|
+
* 3. checkSourceCountDrop — 源数骤降 >30% 检测(fail-safe 拒绝覆盖)
|
|
13
|
+
*/
|
|
14
|
+
/** 需要快照保护的关键配置文件 */
|
|
15
|
+
export declare const PROTECTED_CONFIG_FILES: readonly ["config.jsonc", "auth.json", "event-sources.json", "wecom-credentials.json"];
|
|
16
|
+
/** 快照保留数量 */
|
|
17
|
+
export declare const SNAPSHOT_KEEP = 10;
|
|
18
|
+
/** 文件名安全的时间戳(如 2026-11-08T21-37-13-512Z) */
|
|
19
|
+
export declare function snapshotTimestamp(d?: Date): string;
|
|
20
|
+
/**
|
|
21
|
+
* 对 configDir 下的关键配置文件做一次快照。
|
|
22
|
+
*
|
|
23
|
+
* - 只快照存在的文件(缺失跳过,不报错)
|
|
24
|
+
* - configDir 不存在时返回 null(不抛错)
|
|
25
|
+
* - 快照后清理最旧快照,保留最近 SNAPSHOT_KEEP 份
|
|
26
|
+
*
|
|
27
|
+
* @returns 快照目录路径;configDir 不存在时返回 null
|
|
28
|
+
*/
|
|
29
|
+
export declare function snapshotConfigDir(configDir: string, now?: Date): string | null;
|
|
30
|
+
/** 列出现有快照目录(按时间戳名排序,旧→新) */
|
|
31
|
+
export declare function listSnapshots(configDir: string): string[];
|
|
32
|
+
/** 单条审计记录 */
|
|
33
|
+
export interface AuditEntry {
|
|
34
|
+
/** ISO 时间戳 */
|
|
35
|
+
ts: string;
|
|
36
|
+
/** 写入进程 pid */
|
|
37
|
+
pid: number;
|
|
38
|
+
/** 被写文件名 */
|
|
39
|
+
file: string;
|
|
40
|
+
/** 动作(如 save / pre-save-snapshot / drop-blocked) */
|
|
41
|
+
action: string;
|
|
42
|
+
/** 补充信息 */
|
|
43
|
+
detail?: string;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* 追加一条审计记录到 <configDir>/audit.log(每行一个 JSON)。
|
|
47
|
+
* 失败静默(审计绝不能反过来弄坏配置写入主流程)。
|
|
48
|
+
*/
|
|
49
|
+
export declare function appendAuditLog(configDir: string, entry: Omit<AuditEntry, "ts" | "pid">): void;
|
|
50
|
+
/** 读取审计日志(解析失败的行跳过) */
|
|
51
|
+
export declare function readAuditLog(configDir: string): AuditEntry[];
|
|
52
|
+
/** 源数骤降检查结果 */
|
|
53
|
+
export interface SourceDropCheck {
|
|
54
|
+
allowed: boolean;
|
|
55
|
+
reason?: string;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* 源数骤降检测(Task #5188 P1 建议)。
|
|
59
|
+
*
|
|
60
|
+
* 规则:previousCount 合法(>0)且 newCount 下降超过 30% ⇒ 拒绝。
|
|
61
|
+
* previousCount <= 0(无盘上配置/读取失败)时放行。
|
|
62
|
+
*
|
|
63
|
+
* @param previousCount 磁盘上现有源数
|
|
64
|
+
* @param newCount 本次要写入的源数
|
|
65
|
+
*/
|
|
66
|
+
export declare function checkSourceCountDrop(previousCount: number, newCount: number): SourceDropCheck;
|
|
67
|
+
/**
|
|
68
|
+
* 读取磁盘上 event-sources.json 的源数;文件缺失/损坏返回 -1。
|
|
69
|
+
*/
|
|
70
|
+
export declare function readSourceCountFromDisk(configPath: string): number;
|
|
71
|
+
/** utimes helper for tests (exported so tests need no require hack) */
|
|
72
|
+
export declare function setTimestamps(p: string, d: Date): void;
|
|
73
|
+
/**
|
|
74
|
+
* 通用护栏写入包装(Task #5194 opencodego review MAJOR-1)。
|
|
75
|
+
*
|
|
76
|
+
* 背景:护栏原先只接 event-sources.json 一个写入口,
|
|
77
|
+
* config.jsonc / auth.json 的写入路径(fallback-model-command、
|
|
78
|
+
* cli app-config-io)零接线 ⇒ 事故 1/2 的主要目标文件裸奔。
|
|
79
|
+
*
|
|
80
|
+
* 语义:写前快照(可回滚)→ 执行 writeFn → 写后审计。
|
|
81
|
+
* - writeFn 抛错 ⇒ 返回 false 并记 write-failed 审计(错误原样上抛由调用方决定)
|
|
82
|
+
* - 快照/审计失败不阻断写入主流程(护栏绝不能弄坏配置写入)
|
|
83
|
+
*
|
|
84
|
+
* @param configDir 配置目录(如 ~/.roy-agent)
|
|
85
|
+
* @param file 被写文件名(如 config.jsonc)
|
|
86
|
+
* @param writeFn 实际写入动作(同步)
|
|
87
|
+
* @returns true=写入成功;false=写入抛错
|
|
88
|
+
*/
|
|
89
|
+
export declare function guardConfigWrite(configDir: string, file: string, writeFn: () => void): boolean;
|
package/dist/config/index.d.ts
CHANGED
|
@@ -2,3 +2,4 @@ export { type ConfigSource, type ConfigSourceType, type ConfigChangeEvent, type
|
|
|
2
2
|
export { FileSource, type FileSourceOptions } from "./file-source";
|
|
3
3
|
export { EnvSource, type EnvSourceOptions } from "./env-source";
|
|
4
4
|
export { parseJSONC, parseJSONCWithEnv, parseJSONCWithProtocols, substituteEnvVars, substituteProtocolRefs, } from "./config-parser";
|
|
5
|
+
export { guardConfigWrite, snapshotConfigDir, appendAuditLog, readAuditLog, checkSourceCountDrop, readSourceCountFromDisk, PROTECTED_CONFIG_FILES, type AuditEntry, type SourceDropCheck, } from "./config-protection";
|
package/dist/config/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
ConfigSourceNotFoundError,
|
|
5
5
|
FileSource,
|
|
6
6
|
MemorySource
|
|
7
|
-
} from "../shared/@ai-setting/roy-agent-core-
|
|
7
|
+
} from "../shared/@ai-setting/roy-agent-core-v6yshv0z.js";
|
|
8
8
|
import {
|
|
9
9
|
EnvSource,
|
|
10
10
|
parseJSONC,
|
|
@@ -13,23 +13,39 @@ import {
|
|
|
13
13
|
substituteEnvVars,
|
|
14
14
|
substituteProtocolRefs
|
|
15
15
|
} from "../shared/@ai-setting/roy-agent-core-adg9ghbt.js";
|
|
16
|
+
import {
|
|
17
|
+
PROTECTED_CONFIG_FILES,
|
|
18
|
+
appendAuditLog,
|
|
19
|
+
checkSourceCountDrop,
|
|
20
|
+
guardConfigWrite,
|
|
21
|
+
readAuditLog,
|
|
22
|
+
readSourceCountFromDisk,
|
|
23
|
+
snapshotConfigDir
|
|
24
|
+
} from "../shared/@ai-setting/roy-agent-core-2stt4rp5.js";
|
|
16
25
|
import"../shared/@ai-setting/roy-agent-core-qxnbvgwe.js";
|
|
17
26
|
import"../shared/@ai-setting/roy-agent-core-7hh0brvs.js";
|
|
18
|
-
import"../shared/@ai-setting/roy-agent-core-
|
|
19
|
-
import"../shared/@ai-setting/roy-agent-core-
|
|
20
|
-
import"../shared/@ai-setting/roy-agent-core-
|
|
21
|
-
import"../shared/@ai-setting/roy-agent-core-
|
|
22
|
-
import"../shared/@ai-setting/roy-agent-core-
|
|
23
|
-
import"../shared/@ai-setting/roy-agent-core-
|
|
27
|
+
import"../shared/@ai-setting/roy-agent-core-m39v7qpx.js";
|
|
28
|
+
import"../shared/@ai-setting/roy-agent-core-smf94h73.js";
|
|
29
|
+
import"../shared/@ai-setting/roy-agent-core-yet36q5k.js";
|
|
30
|
+
import"../shared/@ai-setting/roy-agent-core-tkpp1ba0.js";
|
|
31
|
+
import"../shared/@ai-setting/roy-agent-core-p31ftgq9.js";
|
|
32
|
+
import"../shared/@ai-setting/roy-agent-core-5s2t8z00.js";
|
|
24
33
|
import"../shared/@ai-setting/roy-agent-core-7f7t9wwp.js";
|
|
25
34
|
import"../shared/@ai-setting/roy-agent-core-85xyctnb.js";
|
|
26
35
|
import"../shared/@ai-setting/roy-agent-core-fs0mn2jk.js";
|
|
27
36
|
export {
|
|
28
37
|
substituteProtocolRefs,
|
|
29
38
|
substituteEnvVars,
|
|
39
|
+
snapshotConfigDir,
|
|
40
|
+
readSourceCountFromDisk,
|
|
41
|
+
readAuditLog,
|
|
30
42
|
parseJSONCWithProtocols,
|
|
31
43
|
parseJSONCWithEnv,
|
|
32
44
|
parseJSONC,
|
|
45
|
+
guardConfigWrite,
|
|
46
|
+
checkSourceCountDrop,
|
|
47
|
+
appendAuditLog,
|
|
48
|
+
PROTECTED_CONFIG_FILES,
|
|
33
49
|
MemorySource,
|
|
34
50
|
FileSource,
|
|
35
51
|
EnvSource,
|
|
@@ -202,7 +202,7 @@ export interface AgentComponentOptions {
|
|
|
202
202
|
* @param agent 当前请求工具列表的 agent
|
|
203
203
|
* @returns 过滤后的新数组(保留原数组的相对顺序)
|
|
204
204
|
*/
|
|
205
|
-
export declare function filterToolsByAgent(tools: Tool[], agent: AgentInstance): Tool[];
|
|
205
|
+
export declare function filterToolsByAgent(tools: Tool[], agent: AgentInstance, extendTools?: string[]): Tool[];
|
|
206
206
|
/**
|
|
207
207
|
* 构建一次 Agent run 的 EnvContext(effectiveContext + 父级 ALS 继承)。
|
|
208
208
|
*
|
|
@@ -240,6 +240,34 @@ export declare class AgentComponent extends BaseComponent {
|
|
|
240
240
|
private abortControllers;
|
|
241
241
|
private defaultTools;
|
|
242
242
|
private doomLoopCaches;
|
|
243
|
+
/**
|
|
244
|
+
* ★ Task #5224 — session-scope cache snapshot(**内存级**,key = sessionId)。
|
|
245
|
+
*
|
|
246
|
+
* ## 为什么改成内存级
|
|
247
|
+
*
|
|
248
|
+
* 旧实现把快照持久化到 `session.metadata.cacheSnapshot`,带来三个问题:
|
|
249
|
+
*
|
|
250
|
+
* 1. **体积爆炸**:快照 = 整份 systemPrompt(含展开后的 memory),
|
|
251
|
+
* 实测单 session metadata ≈ 102 KB —— `packages/cli/src/commands/shared/chat-session.ts:48`
|
|
252
|
+
* 自述这是本地 `sessions.db` 膨胀到 3.3 GB 的直接原因。
|
|
253
|
+
* 2. **跨进程时间差**:进程重启后复用的旧快照创建于渠道 prompt 引入之前,
|
|
254
|
+
* 且失效检测只看 memory.md mtime → 旧快照被判「新鲜」永久复用
|
|
255
|
+
* → 渠道 prompt 永远进不了 LLM system message(Task #5210/#5217 根因)。
|
|
256
|
+
* 3. **需要一堆补丁兜底**:fix③ 追加 + includes 判重(Task #5223)
|
|
257
|
+
* 都是为了在「持久化 + 复用」模型下把渠道 prompt 塞回去。
|
|
258
|
+
*
|
|
259
|
+
* ## 新语义(用户确认)
|
|
260
|
+
*
|
|
261
|
+
* - 快照是**进程内**的一次性构建产物:session 生命周期内构建一次,之后一直用。
|
|
262
|
+
* - **不持久化** sessions.db ⇒ 进程重启后全部重建(自然拿到最新 memory)。
|
|
263
|
+
* - **渠道 prompt 在构建时注入**(唯一注入点)⇒ 无需任何复用轮补丁。
|
|
264
|
+
* - **不做失效检测**(`_isMemorySnapshotStale` 已删除)⇒ session 内 memory
|
|
265
|
+
* 变更不生效(冻结语义),新 session 自然用最新 memory。
|
|
266
|
+
*
|
|
267
|
+
* 生命周期 = AgentComponent 实例 = 生产环境进程生命周期
|
|
268
|
+
* (`environment.service.ts` 只 `new AgentComponent()` 一次)。
|
|
269
|
+
*/
|
|
270
|
+
private _cacheSnapshots;
|
|
243
271
|
/**
|
|
244
272
|
* Task #4623 — per-run fallback state.
|
|
245
273
|
*
|
|
@@ -491,36 +519,28 @@ export declare class AgentComponent extends BaseComponent {
|
|
|
491
519
|
* 这里只需要构建当前请求的消息,不重复添加
|
|
492
520
|
*/
|
|
493
521
|
/**
|
|
494
|
-
* 【Task #2744】session-scope cache snapshot
|
|
522
|
+
* 【Task #2744 / #5224】session-scope cache snapshot —— **内存级**构建/复用
|
|
495
523
|
*
|
|
496
|
-
* 设计目标:把 systemPrompt({{memory}}
|
|
497
|
-
*
|
|
524
|
+
* 设计目标:把 systemPrompt({{memory}} 已替换 + **构建时注入的渠道 prompt**)
|
|
525
|
+
* 和 additionInfo 绑定到 session 生命周期,构建一次后一直用
|
|
498
526
|
* → 字节级一致 → LLM prompt cache 命中。
|
|
499
527
|
*
|
|
528
|
+
* ★ Task #5224 变更(用户确认的最终设计):
|
|
529
|
+
* - 存储:**内存 Map**(`_cacheSnapshots`,key = sessionId),**不持久化** sessions.db
|
|
530
|
+
* ⇒ 不再把整份 systemPrompt(~102KB)写进 session 行(本地库膨胀主因)
|
|
531
|
+
* - 复用:同 sessionId 直接命中 Map;**不做失效检测**
|
|
532
|
+
* (`_isMemorySnapshotStale` 已删除)⇒ session 内 memory 变更不生效(冻结)
|
|
533
|
+
* - 注入:渠道 prompt 在**构建时**并入快照(唯一注入点)
|
|
534
|
+
* ⇒ 不再需要 fix③ 复用轮追加 + includes 判重补丁
|
|
535
|
+
*
|
|
500
536
|
* @returns
|
|
501
537
|
* - snapshot: 冻结的 { systemPrompt, additionInfo, snapshotAt } 快照
|
|
502
538
|
* - systemPromptOverride: 如果 snapshot 命中,覆盖调用方的 resolvedSystemPrompt
|
|
503
539
|
* (值是 snapshot.systemPrompt,命中时与 snapshot.systemPrompt 相同)
|
|
504
540
|
*
|
|
505
|
-
*
|
|
506
|
-
* 不阻塞 run。
|
|
541
|
+
* 错误处理:所有异常均降级为"返回 null"(调用方走 fallback 路径),不阻塞 run。
|
|
507
542
|
*/
|
|
508
543
|
private _loadOrCreateCacheSnapshot;
|
|
509
|
-
/**
|
|
510
|
-
* 【Task #4813】B1 mtime 失效检测:快照是否因 memory 文件变化而过期
|
|
511
|
-
*
|
|
512
|
-
* 返回 null = 快照仍有效(可复用);返回字符串 = 过期原因(用于日志)。
|
|
513
|
-
*
|
|
514
|
-
* 兼容迁移:旧快照(Task #4813 之前持久化)无 memoryStat 字段 → 视为过期。
|
|
515
|
-
*/
|
|
516
|
-
private _isMemorySnapshotStale;
|
|
517
|
-
/**
|
|
518
|
-
* 【Task #4813】采集各 memory 文件的 mtime(按 MemoryComponent 配置的
|
|
519
|
-
* memoryPaths × memoryFile),供快照失效检测使用。
|
|
520
|
-
*
|
|
521
|
-
* 文件不存在 → 记为 0(删除后重拍语义);memory component 缺失 → 全 0。
|
|
522
|
-
*/
|
|
523
|
-
private _collectMemoryStat;
|
|
524
544
|
/**
|
|
525
545
|
* 【Task #2744】无 sessionId 时的 {{memory}} fallback 替换
|
|
526
546
|
*
|
|
@@ -535,7 +555,8 @@ export declare class AgentComponent extends BaseComponent {
|
|
|
535
555
|
* currentTaskId 是否成功注入到 LLM 上下文
|
|
536
556
|
*
|
|
537
557
|
* Task #2744 (session-scope cache optimization):
|
|
538
|
-
* 如果 ctx._cacheSnapshot 存在(由 AgentComponent._run 在 first-run
|
|
558
|
+
* 如果 ctx._cacheSnapshot 存在(由 AgentComponent._run 在 first-run 时构建到
|
|
559
|
+
* 内存快照 `_cacheSnapshots`,★ Task #5224 起不再持久化到
|
|
539
560
|
* session.metadata.cacheSnapshot),则返回 snapshot 的 additionInfo,**跨多轮
|
|
540
561
|
* 保持字节级一致** —— 这是 LLM prompt cache 命中的前提。
|
|
541
562
|
*
|
|
@@ -7,26 +7,27 @@ import {
|
|
|
7
7
|
filterToolsByAgent,
|
|
8
8
|
parseToolList,
|
|
9
9
|
toLLMMessage
|
|
10
|
-
} from "../../shared/@ai-setting/roy-agent-core-
|
|
11
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
10
|
+
} from "../../shared/@ai-setting/roy-agent-core-tpm1dd1g.js";
|
|
11
|
+
import"../../shared/@ai-setting/roy-agent-core-mx855td4.js";
|
|
12
12
|
import"../../shared/@ai-setting/roy-agent-core-jvv2h3d6.js";
|
|
13
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
13
|
+
import"../../shared/@ai-setting/roy-agent-core-v1n0106v.js";
|
|
14
14
|
import"../../shared/@ai-setting/roy-agent-core-qxnbvgwe.js";
|
|
15
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
16
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
17
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
15
|
+
import"../../shared/@ai-setting/roy-agent-core-7yh5wps0.js";
|
|
16
|
+
import"../../shared/@ai-setting/roy-agent-core-y6shd91r.js";
|
|
17
|
+
import"../../shared/@ai-setting/roy-agent-core-aa8kv18f.js";
|
|
18
|
+
import"../../shared/@ai-setting/roy-agent-core-wxrkcb17.js";
|
|
18
19
|
import"../../shared/@ai-setting/roy-agent-core-zjdzk1gg.js";
|
|
19
20
|
import"../../shared/@ai-setting/roy-agent-core-c1v263jn.js";
|
|
20
21
|
import"../../shared/@ai-setting/roy-agent-core-ntn32q7j.js";
|
|
21
22
|
import"../../shared/@ai-setting/roy-agent-core-mkc3zshb.js";
|
|
22
23
|
import"../../shared/@ai-setting/roy-agent-core-ctdhjv68.js";
|
|
23
24
|
import"../../shared/@ai-setting/roy-agent-core-7hh0brvs.js";
|
|
24
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
25
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
26
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
27
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
28
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
29
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
25
|
+
import"../../shared/@ai-setting/roy-agent-core-m39v7qpx.js";
|
|
26
|
+
import"../../shared/@ai-setting/roy-agent-core-smf94h73.js";
|
|
27
|
+
import"../../shared/@ai-setting/roy-agent-core-yet36q5k.js";
|
|
28
|
+
import"../../shared/@ai-setting/roy-agent-core-tkpp1ba0.js";
|
|
29
|
+
import"../../shared/@ai-setting/roy-agent-core-p31ftgq9.js";
|
|
30
|
+
import"../../shared/@ai-setting/roy-agent-core-5s2t8z00.js";
|
|
30
31
|
import"../../shared/@ai-setting/roy-agent-core-7f7t9wwp.js";
|
|
31
32
|
import"../../shared/@ai-setting/roy-agent-core-85xyctnb.js";
|
|
32
33
|
import"../../shared/@ai-setting/roy-agent-core-fs0mn2jk.js";
|
package/dist/env/agent/index.js
CHANGED
|
@@ -4,26 +4,27 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
AgentComponent,
|
|
6
6
|
AgentComponentConfigSchema
|
|
7
|
-
} from "../../shared/@ai-setting/roy-agent-core-
|
|
8
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
7
|
+
} from "../../shared/@ai-setting/roy-agent-core-tpm1dd1g.js";
|
|
8
|
+
import"../../shared/@ai-setting/roy-agent-core-mx855td4.js";
|
|
9
9
|
import"../../shared/@ai-setting/roy-agent-core-jvv2h3d6.js";
|
|
10
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
10
|
+
import"../../shared/@ai-setting/roy-agent-core-v1n0106v.js";
|
|
11
11
|
import"../../shared/@ai-setting/roy-agent-core-qxnbvgwe.js";
|
|
12
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
13
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
14
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
12
|
+
import"../../shared/@ai-setting/roy-agent-core-7yh5wps0.js";
|
|
13
|
+
import"../../shared/@ai-setting/roy-agent-core-y6shd91r.js";
|
|
14
|
+
import"../../shared/@ai-setting/roy-agent-core-aa8kv18f.js";
|
|
15
|
+
import"../../shared/@ai-setting/roy-agent-core-wxrkcb17.js";
|
|
15
16
|
import"../../shared/@ai-setting/roy-agent-core-zjdzk1gg.js";
|
|
16
17
|
import"../../shared/@ai-setting/roy-agent-core-c1v263jn.js";
|
|
17
18
|
import"../../shared/@ai-setting/roy-agent-core-ntn32q7j.js";
|
|
18
19
|
import"../../shared/@ai-setting/roy-agent-core-mkc3zshb.js";
|
|
19
20
|
import"../../shared/@ai-setting/roy-agent-core-ctdhjv68.js";
|
|
20
21
|
import"../../shared/@ai-setting/roy-agent-core-7hh0brvs.js";
|
|
21
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
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-m39v7qpx.js";
|
|
23
|
+
import"../../shared/@ai-setting/roy-agent-core-smf94h73.js";
|
|
24
|
+
import"../../shared/@ai-setting/roy-agent-core-yet36q5k.js";
|
|
25
|
+
import"../../shared/@ai-setting/roy-agent-core-tkpp1ba0.js";
|
|
26
|
+
import"../../shared/@ai-setting/roy-agent-core-p31ftgq9.js";
|
|
27
|
+
import"../../shared/@ai-setting/roy-agent-core-5s2t8z00.js";
|
|
27
28
|
import"../../shared/@ai-setting/roy-agent-core-7f7t9wwp.js";
|
|
28
29
|
import"../../shared/@ai-setting/roy-agent-core-85xyctnb.js";
|
|
29
30
|
import"../../shared/@ai-setting/roy-agent-core-fs0mn2jk.js";
|
|
@@ -145,6 +145,20 @@ export interface AgentContext {
|
|
|
145
145
|
pluginEnabled?: Record<string, boolean>;
|
|
146
146
|
/** 额外工具列表(上下文级别,会追加到可用工具列表末尾) */
|
|
147
147
|
extraTools?: import("../tool/types").Tool[];
|
|
148
|
+
/**
|
|
149
|
+
* ★ Task #5333 — 放行的 channel-only 工具名单(会话渠道上下文)。
|
|
150
|
+
*
|
|
151
|
+
* 由事件源驱动的一轮对话注入(EventSourceConfig.extendTools →
|
|
152
|
+
* evt.metadata.extendTools → agentContext.extendTools)。
|
|
153
|
+
*
|
|
154
|
+
* `tool.metadata.channelOnly === true` 的工具只有名字出现在这里时才可见;
|
|
155
|
+
* 未标记 channelOnly 的工具完全不受影响。
|
|
156
|
+
*
|
|
157
|
+
* 典型:企微 ES 注入 `["wecom_respond"]`,于是处理企微事件的 agent
|
|
158
|
+
* (可能是 default)能看到 wecom_respond;而同名 default agent
|
|
159
|
+
* 在交互式 CLI / 飞书会话里看不到它。
|
|
160
|
+
*/
|
|
161
|
+
extendTools?: string[];
|
|
148
162
|
/** 是否将 ReAct 消息持久化到 session DB(默认 true)。
|
|
149
163
|
* 设为 false 时,agent run 仍会读取 session history,但不会写入新消息。
|
|
150
164
|
* 用于子 agent 复用父 session 的 history 但不污染 session DB。 */
|
|
@@ -227,24 +241,28 @@ export interface HookContext {
|
|
|
227
241
|
/**
|
|
228
242
|
* Task #2744: session-scope cache snapshot (internal use)
|
|
229
243
|
*
|
|
230
|
-
*
|
|
231
|
-
*
|
|
232
|
-
*
|
|
233
|
-
*
|
|
244
|
+
* ★ Task #5224 — 快照改为**内存级**(`AgentComponent._cacheSnapshots`,
|
|
245
|
+
* key=sessionId),**不再持久化**到 session.metadata.cacheSnapshot。
|
|
246
|
+
* 由 AgentComponent._run 在 first-run 创建并透传给 buildMessages。
|
|
247
|
+
* buildMessages 使用 snapshot 的 additionInfo(而非每轮重读
|
|
248
|
+
* ctx.context.additionInfo)以保证 system prompt 字节级一致 → LLM
|
|
249
|
+
* prompt cache 命中。
|
|
234
250
|
*
|
|
235
|
-
* - systemPrompt: 含 {{memory}}
|
|
251
|
+
* - systemPrompt: 含 {{memory}} 替换后的最终字符串(**含构建时注入的渠道 prompt**)
|
|
236
252
|
* - additionInfo: first-run 时的 additionInfo(冻结)
|
|
237
|
-
* - snapshotAt:
|
|
253
|
+
* - snapshotAt: 构建时间戳
|
|
254
|
+
*
|
|
255
|
+
* ⚠️ 本字段**仅是运行时透传载体**:它的值只来自
|
|
256
|
+
* `_loadOrCreateCacheSnapshot` 的内存 Map,**既不从 session.metadata 读取,
|
|
257
|
+
* 也不写入 session.metadata** —— 不要把它当成「可持久化到 session 行」的句柄。
|
|
238
258
|
*
|
|
239
|
-
*
|
|
240
|
-
*
|
|
259
|
+
* 第三方代码不应直接修改此字段。快照重建条件:进程重启(内存态全失)
|
|
260
|
+
* 或换用新的 sessionId。
|
|
241
261
|
*/
|
|
242
262
|
_cacheSnapshot?: {
|
|
243
263
|
systemPrompt: string;
|
|
244
264
|
additionInfo: string;
|
|
245
265
|
snapshotAt: number;
|
|
246
|
-
/** 【Task #4813】B1 mtime 失效检测:首拍时各 memory 文件的 mtime(ms) */
|
|
247
|
-
memoryStat?: MemorySnapshotStat;
|
|
248
266
|
};
|
|
249
267
|
/** 执行上下文(可直接修改属性) */
|
|
250
268
|
context: AgentContext;
|
|
@@ -320,13 +338,29 @@ export type AgentType = "primary" | "sub" | "summary";
|
|
|
320
338
|
* - globalMtime: global memory.md 的 mtime(ms);文件不存在记 0
|
|
321
339
|
* - projectMtime: project memory.md 的 mtime(ms);文件不存在记 0
|
|
322
340
|
*
|
|
323
|
-
*
|
|
324
|
-
*
|
|
341
|
+
* ⚠️ 【Task #5224】**已停用**(保留类型仅为向后兼容,不破坏公开导出面):
|
|
342
|
+
* 快照改内存级后,失效检测(`_isMemorySnapshotStale`)被移除 —— session
|
|
343
|
+
* 生命周期内快照冻结,新 session / 进程重启自然重建并拿到最新 memory。
|
|
325
344
|
*/
|
|
326
345
|
export interface MemorySnapshotStat {
|
|
327
346
|
globalMtime: number;
|
|
328
347
|
projectMtime: number;
|
|
329
348
|
}
|
|
349
|
+
/**
|
|
350
|
+
* ★ Task #5224 — session-scope cache snapshot(内存级)。
|
|
351
|
+
*
|
|
352
|
+
* 构建一次、session 生命周期内冻结使用;不持久化到 sessions.db。
|
|
353
|
+
*
|
|
354
|
+
* - systemPrompt: 含 {{memory}} 替换后的最终字符串,
|
|
355
|
+
* **且含构建时注入的渠道 prompt**(唯一注入点)
|
|
356
|
+
* - additionInfo: 构建时的 additionInfo(冻结 → 字节级一致 → prompt cache 命中)
|
|
357
|
+
* - snapshotAt: 构建时间戳
|
|
358
|
+
*/
|
|
359
|
+
export interface CacheSnapshot {
|
|
360
|
+
systemPrompt: string;
|
|
361
|
+
additionInfo: string;
|
|
362
|
+
snapshotAt: number;
|
|
363
|
+
}
|
|
330
364
|
/**
|
|
331
365
|
* Agent 状态
|
|
332
366
|
*/
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CommandsComponent
|
|
3
|
-
} from "../../shared/@ai-setting/roy-agent-core-
|
|
3
|
+
} from "../../shared/@ai-setting/roy-agent-core-7f10p7m2.js";
|
|
4
4
|
import"../../shared/@ai-setting/roy-agent-core-7hh0brvs.js";
|
|
5
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
6
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
7
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
8
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
9
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
10
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
5
|
+
import"../../shared/@ai-setting/roy-agent-core-m39v7qpx.js";
|
|
6
|
+
import"../../shared/@ai-setting/roy-agent-core-smf94h73.js";
|
|
7
|
+
import"../../shared/@ai-setting/roy-agent-core-yet36q5k.js";
|
|
8
|
+
import"../../shared/@ai-setting/roy-agent-core-tkpp1ba0.js";
|
|
9
|
+
import"../../shared/@ai-setting/roy-agent-core-p31ftgq9.js";
|
|
10
|
+
import"../../shared/@ai-setting/roy-agent-core-5s2t8z00.js";
|
|
11
11
|
import"../../shared/@ai-setting/roy-agent-core-7f7t9wwp.js";
|
|
12
12
|
import"../../shared/@ai-setting/roy-agent-core-85xyctnb.js";
|
|
13
13
|
import"../../shared/@ai-setting/roy-agent-core-fs0mn2jk.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
init_context
|
|
3
|
-
} from "../../shared/@ai-setting/roy-agent-core-
|
|
3
|
+
} from "../../shared/@ai-setting/roy-agent-core-tkpp1ba0.js";
|
|
4
4
|
import {
|
|
5
5
|
EVENT_ENV_PREFIX,
|
|
6
6
|
createEnvContext,
|
|
@@ -24,8 +24,8 @@ import {
|
|
|
24
24
|
runWithEnvContextAsync,
|
|
25
25
|
serializeEventToEnv,
|
|
26
26
|
setCurrentTaskId
|
|
27
|
-
} from "../../shared/@ai-setting/roy-agent-core-
|
|
28
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
27
|
+
} from "../../shared/@ai-setting/roy-agent-core-p31ftgq9.js";
|
|
28
|
+
import"../../shared/@ai-setting/roy-agent-core-5s2t8z00.js";
|
|
29
29
|
import"../../shared/@ai-setting/roy-agent-core-7f7t9wwp.js";
|
|
30
30
|
import"../../shared/@ai-setting/roy-agent-core-85xyctnb.js";
|
|
31
31
|
import"../../shared/@ai-setting/roy-agent-core-fs0mn2jk.js";
|
package/dist/env/debug/index.js
CHANGED
|
@@ -4,18 +4,18 @@ import {
|
|
|
4
4
|
RegexParser,
|
|
5
5
|
SpanBuilder,
|
|
6
6
|
SpanDbReader
|
|
7
|
-
} from "../../shared/@ai-setting/roy-agent-core-
|
|
7
|
+
} from "../../shared/@ai-setting/roy-agent-core-1mhyh4c5.js";
|
|
8
8
|
import {
|
|
9
9
|
ReplFormatter,
|
|
10
10
|
TraceFormatter,
|
|
11
11
|
TreeFormatter
|
|
12
12
|
} from "../../shared/@ai-setting/roy-agent-core-rvv6ydff.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-
|
|
16
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
17
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
18
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
13
|
+
import"../../shared/@ai-setting/roy-agent-core-m39v7qpx.js";
|
|
14
|
+
import"../../shared/@ai-setting/roy-agent-core-smf94h73.js";
|
|
15
|
+
import"../../shared/@ai-setting/roy-agent-core-yet36q5k.js";
|
|
16
|
+
import"../../shared/@ai-setting/roy-agent-core-tkpp1ba0.js";
|
|
17
|
+
import"../../shared/@ai-setting/roy-agent-core-p31ftgq9.js";
|
|
18
|
+
import"../../shared/@ai-setting/roy-agent-core-5s2t8z00.js";
|
|
19
19
|
import"../../shared/@ai-setting/roy-agent-core-7f7t9wwp.js";
|
|
20
20
|
import"../../shared/@ai-setting/roy-agent-core-85xyctnb.js";
|
|
21
21
|
import"../../shared/@ai-setting/roy-agent-core-fs0mn2jk.js";
|
|
@@ -111,6 +111,12 @@ export interface FailureReplyChannelLike {
|
|
|
111
111
|
profile?: string;
|
|
112
112
|
appId?: string;
|
|
113
113
|
userId?: string;
|
|
114
|
+
/**
|
|
115
|
+
* Task #5311:渠道自定义参数(event-source ReplyChannel.params 的透传)。
|
|
116
|
+
* 企微通道用 `params.sourceId`(WS fallback 实例定位)与
|
|
117
|
+
* `params.reqId`(WS 被动回帧)。lark 通道不读它。
|
|
118
|
+
*/
|
|
119
|
+
params?: Record<string, unknown>;
|
|
114
120
|
}
|
|
115
121
|
export interface NotifyReactFailureOptions {
|
|
116
122
|
/** 触发 React 中断的错误(任意类型,内部会做类型安全处理) */
|
package/dist/env/error-reply.js
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
getFailureRuleIds,
|
|
9
9
|
humanizeRetryAfter,
|
|
10
10
|
notifyReactFailure
|
|
11
|
-
} from "../shared/@ai-setting/roy-agent-core-
|
|
11
|
+
} from "../shared/@ai-setting/roy-agent-core-9c565frx.js";
|
|
12
12
|
import"../shared/@ai-setting/roy-agent-core-ntn32q7j.js";
|
|
13
13
|
import"../shared/@ai-setting/roy-agent-core-m880qz3y.js";
|
|
14
14
|
import"../shared/@ai-setting/roy-agent-core-7f7t9wwp.js";
|
|
@@ -208,7 +208,15 @@ export declare class BountyIMInstance implements EventSourceInstance {
|
|
|
208
208
|
* 优先用 config.systemPrompt,否则用默认 prompt。
|
|
209
209
|
* 该 prompt 会透传到 EventSourceEvent.metadata.systemPrompt,
|
|
210
210
|
* 由 run.ts 在 dispatch env event 时注入到 agent system prompt。
|
|
211
|
+
*
|
|
212
|
+
* ★ ES-M1(Task #5144 / 方案 M2):结果缓存为实例字段 ——
|
|
213
|
+
* 构造一次,每条消息事件不再重新 resolve。同一渠道输出
|
|
214
|
+
* 逐字节稳定(resolveBountyIMSystemPrompt 只读 config,
|
|
215
|
+
* 本就确定;缓存进一步杜绝未来混入事件级变量导致的字节漂移,
|
|
216
|
+
* 保护 LLM prompt cache 前缀一致性)。
|
|
211
217
|
*/
|
|
218
|
+
private cachedSystemPrompt?;
|
|
219
|
+
private systemPromptResolved;
|
|
212
220
|
private getCurrentSystemPrompt;
|
|
213
221
|
getStatus(): EventSourceStatus;
|
|
214
222
|
start(): Promise<void>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Task #5302 — `es` command(eventsource 管理斜杆命令)
|
|
3
|
+
*
|
|
4
|
+
* 用户需求(飞书明令 2026-11-11 10:11):
|
|
5
|
+
* 1. 斜杆命令 `/es add|list|del|mod` 管理 eventsource
|
|
6
|
+
* 2. 飞书 `##command##: es <sub>` 触发(复用 Task #4722 command 子系统)
|
|
7
|
+
* 3. interactive TUI 也要支持(见 packages/cli/src/tui-solid/interactive-slash-commands.ts)
|
|
8
|
+
*
|
|
9
|
+
* ## 数据面
|
|
10
|
+
*
|
|
11
|
+
* 直接读写 `~/.roy-agent/event-sources.json`(EventSourceComponent
|
|
12
|
+
* 的持久化文件,格式 `{version, sources: EventSourceConfig[]}`)。
|
|
13
|
+
*
|
|
14
|
+
* 为什么不走组件实例:command 子系统是**无状态纯函数**(es 前端 /
|
|
15
|
+
* CLI / interactive 三个前端共享),拿不到运行中的 EventSourceComponent;
|
|
16
|
+
* 且 component.register() 会触发 saveConfig() 竞态。直接文件读写 +
|
|
17
|
+
* 写后重读校验,与 reset-command.ts 同级简单度。
|
|
18
|
+
*
|
|
19
|
+
* ⚠️ 与运行中 daemon 的关系:本命令改的是**磁盘配置**。运行中的
|
|
20
|
+
* EventSourceComponent 不会自动 reload(它只在启动时 loadConfig),
|
|
21
|
+
* 改完需 `##command##: reset` 重启进程生效 —— 在输出里明确提示。
|
|
22
|
+
*
|
|
23
|
+
* ## 安全
|
|
24
|
+
*
|
|
25
|
+
* - add 重名拒绝(与 component.register 一致)
|
|
26
|
+
* - mod 只允许白名单字段(enabled/name/interval/cron/profile);
|
|
27
|
+
* command/url 属于命令注入面,mod 明确不允许(需 del + add)
|
|
28
|
+
* - 写失败(磁盘/权限)→ ok:false,不静默
|
|
29
|
+
*
|
|
30
|
+
* ## 已知限制
|
|
31
|
+
*
|
|
32
|
+
* 参数按空白切分(飞书 `##command##:` 与 interactive `/es` 同规则),
|
|
33
|
+
* 因此含空格的值(如 cron 表达式)无法经这两个前端写入;
|
|
34
|
+
* CLI 侧可用引号传入。需要时用 CLI 或手工编辑 event-sources.json。
|
|
35
|
+
*/
|
|
36
|
+
import type { CommandDefinition } from "./command-registry";
|
|
37
|
+
/** 从 configPath(config.jsonc)推导同目录的 event-sources.json */
|
|
38
|
+
export declare function resolveEsFilePath(configPath?: string): string;
|
|
39
|
+
export declare const esCommand: CommandDefinition;
|