@ai-setting/roy-agent-core 1.7.76 → 1.7.85
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 +16 -0
- package/dist/env/agent/agent-component.d.ts +42 -21
- package/dist/env/agent/agent-component.js +3 -3
- package/dist/env/agent/index.js +3 -3
- package/dist/env/agent/types.d.ts +32 -12
- 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 +68 -0
- package/dist/env/event-source/event-source-handlers.js +22 -10
- package/dist/env/event-source/index.d.ts +5 -1
- package/dist/env/event-source/index.js +59 -10
- package/dist/env/event-source/types.d.ts +101 -1
- package/dist/env/event-source/wecom-card-action-handler.d.ts +141 -0
- package/dist/env/event-source/wecom-card-builder.d.ts +220 -0
- package/dist/env/event-source/wecom-cli-handler.d.ts +266 -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-ws-bridge.d.ts +213 -0
- package/dist/env/index.js +19 -17
- package/dist/env/task/backend/index.js +37 -1
- package/dist/env/task/backend/task-store-backend.d.ts +12 -0
- package/dist/env/task/backend/types.d.ts +19 -0
- package/dist/env/task/delegate/delegate-tool.d.ts +62 -2
- package/dist/env/task/delegate/delegate-tool.js +3 -1
- package/dist/env/task/delegate/index.js +1 -1
- package/dist/env/task/index.js +4 -4
- package/dist/env/task/mcp/index.js +3 -0
- package/dist/env/task/mcp/task-mcp-server.d.ts +1 -1
- package/dist/env/task/plugins/fake-user-message-helper.d.ts +10 -2
- package/dist/env/task/plugins/index.d.ts +3 -0
- package/dist/env/task/plugins/index.js +36 -4
- package/dist/env/task/plugins/lark-card-patch-notifier.d.ts +41 -2
- package/dist/env/task/plugins/lark-card-patch-notifier.js +1 -1
- package/dist/env/task/plugins/lark-cli-task-notify-plugin.d.ts +16 -0
- package/dist/env/task/plugins/task-op-watermark-plugin.d.ts +112 -0
- package/dist/env/task/plugins/wecom-card-state-store.d.ts +121 -0
- package/dist/env/task/plugins/wecom-task-notify-plugin.d.ts +224 -0
- package/dist/env/task/storage/index.js +2 -2
- package/dist/env/task/storage/sqlite-task-store.d.ts +54 -0
- package/dist/env/task/task-component.d.ts +16 -0
- package/dist/env/task/tools/operation/operation-types.d.ts +13 -13
- package/dist/env/tool/built-in/index.d.ts +2 -0
- package/dist/env/tool/built-in/index.js +6 -1
- package/dist/env/tool/index.js +3 -2
- package/dist/env/workflow/index.js +3 -3
- package/dist/env/workflow/plugins/index.js +2 -2
- package/dist/env/workflow/tools/index.js +2 -2
- package/dist/env/workflow/types/event.d.ts +4 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.js +71 -20
- package/dist/shared/@ai-setting/{roy-agent-core-v87njmq7.js → roy-agent-core-0dh8npnz.js} +1 -1
- package/dist/shared/@ai-setting/roy-agent-core-2stt4rp5.js +134 -0
- package/dist/shared/@ai-setting/{roy-agent-core-mww0mnd9.js → roy-agent-core-7bpj859q.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-nmx9934r.js → roy-agent-core-7dd0s3xb.js} +15 -5
- package/dist/shared/@ai-setting/{roy-agent-core-ghnagzrh.js → roy-agent-core-b31v3qpv.js} +853 -48
- package/dist/shared/@ai-setting/{roy-agent-core-cxy143m4.js → roy-agent-core-begm7ytz.js} +63 -2
- package/dist/shared/@ai-setting/{roy-agent-core-aa2j7bk9.js → roy-agent-core-cha0jc7n.js} +40 -26
- package/dist/shared/@ai-setting/{roy-agent-core-p3zv1mx5.js → roy-agent-core-d1n4jbza.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-q5r75vev.js → roy-agent-core-dkrvmjsh.js} +17 -75
- package/dist/shared/@ai-setting/{roy-agent-core-abqhkbn3.js → roy-agent-core-ezvpreqz.js} +23 -0
- 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-h21gngxf.js +247 -0
- package/dist/shared/@ai-setting/roy-agent-core-m3vjepzz.js +544 -0
- package/dist/shared/@ai-setting/{roy-agent-core-zycadbpx.js → roy-agent-core-p6ks90tb.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-ntq0gz7q.js → roy-agent-core-q813vafd.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-z43aj03k.js → roy-agent-core-qk9hd89p.js} +21 -2
- package/dist/shared/@ai-setting/{roy-agent-core-6cy43nss.js → roy-agent-core-rykf7c04.js} +49 -9
- package/dist/shared/@ai-setting/{roy-agent-core-8ez6mccb.js → roy-agent-core-tk98f92b.js} +4 -0
- 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-vyr6svt6.js +31 -0
- package/dist/shared/@ai-setting/{roy-agent-core-t3rrb959.js → roy-agent-core-xf6z96qy.js} +2086 -163
- package/package.json +10 -1
- package/dist/shared/@ai-setting/roy-agent-core-f77k3gqt.js +0 -71
- /package/dist/shared/@ai-setting/{roy-agent-core-b4x6x4k2.js → roy-agent-core-m1fgtnrc.js} +0 -0
- /package/dist/shared/@ai-setting/{roy-agent-core-v85n42ve.js → roy-agent-core-ze5cqpf2.js} +0 -0
|
@@ -81,6 +81,25 @@ export interface TaskBackend {
|
|
|
81
81
|
* - `cycle` 类型任务拒绝完成(roy 语义)
|
|
82
82
|
*/
|
|
83
83
|
completeTask(id: TaskId, sessionId?: string, deliverable?: string): Promise<Task | null>;
|
|
84
|
+
/**
|
|
85
|
+
* 提交待验证(Task #5073 两阶段验收的第一阶段,Task #5078)。
|
|
86
|
+
*
|
|
87
|
+
* 契约(与 `TaskComponent.preCompleteTask` 语义同构,MCP/
|
|
88
|
+
* 插件侧共用):
|
|
89
|
+
* - `status` → `to_validate`(**非终态**:只进验收队列)
|
|
90
|
+
* - `current_status` → 「待验证」措辞(progressSummary 拼接:
|
|
91
|
+
* 「待验证:<summary>」)
|
|
92
|
+
* - 若给了 `deliverable`,merge 进 `context.deliverable_storage_path`
|
|
93
|
+
* 并写入 submission operation 的 `milestoneDescription`
|
|
94
|
+
* - 写一条 `milestoneType: "milestone"` 的提交留痕 operation
|
|
95
|
+
* (与 TaskComponent.preCompleteTask 的细微增强:deliverable
|
|
96
|
+
* 同时落在 operation 的 `mdPath` 字段,便于寻址)
|
|
97
|
+
* - `cycle` 类型任务拒绝提交(roy 语义,同 completeTask)
|
|
98
|
+
* - **不 fire 任何钩子**:`TaskStoreBackend` 没有 hook 链,
|
|
99
|
+
* goal 判定由上层(MCP withGoalCheck / TaskComponent 钩子)
|
|
100
|
+
* 负责 —— 本方法只是状态落库。
|
|
101
|
+
*/
|
|
102
|
+
preCompleteTask(id: TaskId, sessionId?: string, deliverable?: string, progressSummary?: string): Promise<Task | null>;
|
|
84
103
|
/** 子树(所有后代,**不含** root),BFS 按层展开,`depth` 限制层数。 */
|
|
85
104
|
getTaskTree(id: TaskId, depth?: number): Promise<Task[]>;
|
|
86
105
|
/** 关键词检索 + 全部 roy 过滤项(review finding Y2)。 */
|
|
@@ -236,6 +236,16 @@ export interface BackgroundTask {
|
|
|
236
236
|
* 顺序 = 优先级(主模型失败后逐个尝试)。
|
|
237
237
|
*/
|
|
238
238
|
fallbackModels?: string[];
|
|
239
|
+
/**
|
|
240
|
+
* ★ Task #5217 fix 2 — 父 agent 本次 run 的 channel systemPrompt
|
|
241
|
+
* (context.metadata.systemPrompt,如 lean lark 渠道 prompt)。
|
|
242
|
+
* 透传给 sub-agent 的 AgentContext.metadata.systemPrompt,
|
|
243
|
+
* 使 AgentComponent._run 把它追加到 sub-agent 的 LLM system message。
|
|
244
|
+
*
|
|
245
|
+
* 注意:与 model 一样**不写进 sub-agent 的注册配置** —— per-run
|
|
246
|
+
* 透传天然每次都是最新值(channel prompt 是 per-event 的)。
|
|
247
|
+
*/
|
|
248
|
+
systemPrompt?: string;
|
|
239
249
|
/**
|
|
240
250
|
* ★ Task #4552 (A1):本任务被允许的运行时长(毫秒,createTask 时确定)。
|
|
241
251
|
*
|
|
@@ -280,6 +290,16 @@ export interface BackgroundTask {
|
|
|
280
290
|
profile?: string;
|
|
281
291
|
params?: Record<string, unknown>;
|
|
282
292
|
};
|
|
293
|
+
/**
|
|
294
|
+
* ★ Task #5265 — delegate 时刻的 pluginEnabled 快照。
|
|
295
|
+
*
|
|
296
|
+
* 后台任务通知轮(task.background.* 合成 envEvent)此前
|
|
297
|
+
* pluginEnabled={}(空)→ WecomTaskNotifyPlugin 等 ES 插件的
|
|
298
|
+
* pluginEnabled 守卫拦截 → 不发卡(用户只见纯文本)。
|
|
299
|
+
* createTask 时快照 parent EnvContext.pluginEnabled,
|
|
300
|
+
* publishBackgroundEvent 时写进 event.metadata.pluginEnabled。
|
|
301
|
+
*/
|
|
302
|
+
pluginEnabledSnapshot?: Record<string, boolean>;
|
|
283
303
|
}
|
|
284
304
|
/**
|
|
285
305
|
* Task #4794 — BackgroundTaskManager.dispose() 的行为选项。
|
|
@@ -347,6 +367,12 @@ export interface CreateBackgroundTaskOptions {
|
|
|
347
367
|
* Task #4724 — 父 agent 的兜底模型**有序列表**,透传给 sub-agent。
|
|
348
368
|
*/
|
|
349
369
|
fallbackModels?: string[];
|
|
370
|
+
/**
|
|
371
|
+
* ★ Task #5217 fix 2 — 父 agent 本次 run 的 channel systemPrompt
|
|
372
|
+
* (context.metadata.systemPrompt,如 lean lark 渠道 prompt)。
|
|
373
|
+
* 透传给 sub-agent 的 AgentContext.metadata.systemPrompt。
|
|
374
|
+
*/
|
|
375
|
+
systemPrompt?: string;
|
|
350
376
|
}
|
|
351
377
|
/**
|
|
352
378
|
* 构建 entry-agent 调度的 prompt 包装 (Task #2164 beta-compare divergence #2)
|
|
@@ -578,7 +604,7 @@ export declare class BackgroundTaskManager {
|
|
|
578
604
|
*
|
|
579
605
|
* @internal 测试 / 集成用,普通调用方走 publishBackgroundEvent 私有方法
|
|
580
606
|
*/
|
|
581
|
-
publishBackgroundEventWithTrigger<T>(type: string, payload: T, parentSessionId: string | undefined, triggerEventId: string, replyChannel?: BackgroundTask["replyChannel"]): void;
|
|
607
|
+
publishBackgroundEventWithTrigger<T>(type: string, payload: T, parentSessionId: string | undefined, triggerEventId: string, replyChannel?: BackgroundTask["replyChannel"], pluginEnabledSnapshot?: Record<string, boolean>): void;
|
|
582
608
|
/**
|
|
583
609
|
* Task #3xxx — 解析 AskUserError 信息
|
|
584
610
|
*
|
|
@@ -782,6 +808,34 @@ declare function _captureReplyChannelSnapshot(): BackgroundTask["replyChannel"]
|
|
|
782
808
|
* traced 版 captureReplyChannelSnapshot(供 debug trace 观测 task 的回复目标快照)。
|
|
783
809
|
*/
|
|
784
810
|
export declare const captureReplyChannelSnapshot: typeof _captureReplyChannelSnapshot;
|
|
811
|
+
/**
|
|
812
|
+
* ★ Task #5265 — 把当前 EnvContext.pluginEnabled 拍成不可变快照。
|
|
813
|
+
*
|
|
814
|
+
* ## 为什么需要(生产故障 2026-11-10 12:45)
|
|
815
|
+
*
|
|
816
|
+
* 后台任务完成通知链路(task.background.completed → 通知会话)的
|
|
817
|
+
* 合成 envEvent **pluginEnabled={}(空)** →
|
|
818
|
+
* WecomTaskNotifyPlugin.execute 的 pluginEnabled 守卫
|
|
819
|
+
* (key=wecom-bot-2:WecomTaskNotifyPlugin)不通过 → 插件直接 return
|
|
820
|
+
* 不发卡(用户只看到纯文本)。
|
|
821
|
+
*
|
|
822
|
+
* 主会话(事件轮直发)pluginEnabled 由 event-source-handlers 构建
|
|
823
|
+
* (有 key)→ 有卡。合成事件(publishBackgroundEvent)此前不携带
|
|
824
|
+
* pluginEnabled,dispatcher 的重建逻辑依赖 metadata.plugins(也为空)
|
|
825
|
+
* → 守卫拦截。
|
|
826
|
+
*
|
|
827
|
+
* 修复:delegate 时刻快照 pluginEnabled,随 task 存
|
|
828
|
+
* `BackgroundTask.pluginEnabledSnapshot`,publishBackgroundEvent 时
|
|
829
|
+
* 写进 event.metadata.pluginEnabled —— 通知轮合成 envEvent 自带,
|
|
830
|
+
* dispatcher / buildRunEnvContext 透传 → 守卫放行。
|
|
831
|
+
*
|
|
832
|
+
* 返回 undefined 当没有 EnvContext / 没有 pluginEnabled(向后兼容)。
|
|
833
|
+
*/
|
|
834
|
+
declare function _capturePluginEnabledSnapshot(): Record<string, boolean> | undefined;
|
|
835
|
+
/**
|
|
836
|
+
* traced 版 capturePluginEnabledSnapshot(供 debug trace 观测快照结果)。
|
|
837
|
+
*/
|
|
838
|
+
export declare const capturePluginEnabledSnapshot: typeof _capturePluginEnabledSnapshot;
|
|
785
839
|
declare function handleBackgroundTask(backgroundTaskManager: BackgroundTaskManager, parentSessionId: string, description: string, prompt: string, subagentType: string, timeout?: number, similarTaskIds?: number[],
|
|
786
840
|
/**
|
|
787
841
|
* ★ 2026-07-10 新增(Task #1752 subSessionId 复用机制)
|
|
@@ -804,5 +858,11 @@ model?: string, fallbackModel?: string,
|
|
|
804
858
|
* Task #4724 — 父 agent 本次 run 的兜底模型**有序列表**。
|
|
805
859
|
* 透传给 createTask → sub-agent 的 AgentContext(顺序 = 优先级)。
|
|
806
860
|
*/
|
|
807
|
-
fallbackModels?: string[]
|
|
861
|
+
fallbackModels?: string[],
|
|
862
|
+
/**
|
|
863
|
+
* ★ Task #5217 fix 2 — 父 agent 本次 run 的 channel systemPrompt
|
|
864
|
+
* (ToolContext.metadata.systemPrompt,per-event)。
|
|
865
|
+
* 透传给 createTask → sub-agent 的 AgentContext.metadata.systemPrompt。
|
|
866
|
+
*/
|
|
867
|
+
systemPrompt?: string): Promise<ToolResult>;
|
|
808
868
|
export { handleBackgroundTask };
|
|
@@ -7,12 +7,13 @@ import {
|
|
|
7
7
|
WORKFLOW_COMPAT_ALIASES,
|
|
8
8
|
buildEntryAgentPrompt,
|
|
9
9
|
builtInSubAgents,
|
|
10
|
+
capturePluginEnabledSnapshot,
|
|
10
11
|
captureReplyChannelSnapshot,
|
|
11
12
|
createDelegateTool,
|
|
12
13
|
deriveTriggerEventIdFromEnvContext,
|
|
13
14
|
getSubAgentSpec,
|
|
14
15
|
handleBackgroundTask
|
|
15
|
-
} from "../../../shared/@ai-setting/roy-agent-core-
|
|
16
|
+
} from "../../../shared/@ai-setting/roy-agent-core-cha0jc7n.js";
|
|
16
17
|
import"../../../shared/@ai-setting/roy-agent-core-fttgm52a.js";
|
|
17
18
|
import"../../../shared/@ai-setting/roy-agent-core-na18zwj0.js";
|
|
18
19
|
import"../../../shared/@ai-setting/roy-agent-core-9vxh6f8h.js";
|
|
@@ -35,6 +36,7 @@ export {
|
|
|
35
36
|
deriveTriggerEventIdFromEnvContext,
|
|
36
37
|
createDelegateTool,
|
|
37
38
|
captureReplyChannelSnapshot,
|
|
39
|
+
capturePluginEnabledSnapshot,
|
|
38
40
|
builtInSubAgents,
|
|
39
41
|
buildEntryAgentPrompt,
|
|
40
42
|
WORKFLOW_COMPAT_ALIASES,
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
BackgroundTaskEventTypes,
|
|
6
6
|
BackgroundTaskManager,
|
|
7
7
|
createDelegateTool
|
|
8
|
-
} from "../../../shared/@ai-setting/roy-agent-core-
|
|
8
|
+
} from "../../../shared/@ai-setting/roy-agent-core-cha0jc7n.js";
|
|
9
9
|
import"../../../shared/@ai-setting/roy-agent-core-fttgm52a.js";
|
|
10
10
|
import"../../../shared/@ai-setting/roy-agent-core-na18zwj0.js";
|
|
11
11
|
import"../../../shared/@ai-setting/roy-agent-core-9vxh6f8h.js";
|
package/dist/env/task/index.js
CHANGED
|
@@ -5,12 +5,12 @@ import {
|
|
|
5
5
|
TaskPriorityEnum,
|
|
6
6
|
TaskStatusEnum,
|
|
7
7
|
TaskTypeEnum
|
|
8
|
-
} from "../../shared/@ai-setting/roy-agent-core-
|
|
8
|
+
} from "../../shared/@ai-setting/roy-agent-core-qk9hd89p.js";
|
|
9
9
|
import"../../shared/@ai-setting/roy-agent-core-2akfd64z.js";
|
|
10
10
|
import"../../shared/@ai-setting/roy-agent-core-jm136jzh.js";
|
|
11
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
11
|
+
import"../../shared/@ai-setting/roy-agent-core-cha0jc7n.js";
|
|
12
12
|
import"../../shared/@ai-setting/roy-agent-core-fttgm52a.js";
|
|
13
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
13
|
+
import"../../shared/@ai-setting/roy-agent-core-q813vafd.js";
|
|
14
14
|
import {
|
|
15
15
|
TaskEntityEventTypes
|
|
16
16
|
} from "../../shared/@ai-setting/roy-agent-core-8gxth0eh.js";
|
|
@@ -21,7 +21,7 @@ import"../../shared/@ai-setting/roy-agent-core-9vxh6f8h.js";
|
|
|
21
21
|
import {
|
|
22
22
|
SQLiteTaskStore,
|
|
23
23
|
getDefaultTaskDbPath
|
|
24
|
-
} from "../../shared/@ai-setting/roy-agent-core-
|
|
24
|
+
} from "../../shared/@ai-setting/roy-agent-core-ezvpreqz.js";
|
|
25
25
|
import"../../shared/@ai-setting/roy-agent-core-1pg0fepg.js";
|
|
26
26
|
import"../../shared/@ai-setting/roy-agent-core-tr3ep81v.js";
|
|
27
27
|
import"../../shared/@ai-setting/roy-agent-core-m46fe3x4.js";
|
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
createTaskTool,
|
|
4
4
|
getTaskTool,
|
|
5
5
|
listTasksTool,
|
|
6
|
+
preCompleteTaskTool,
|
|
6
7
|
searchTasksTool,
|
|
7
8
|
treeTasksTool,
|
|
8
9
|
updateTaskTool
|
|
@@ -30,6 +31,7 @@ var TASK_MCP_TOOL_NAMES = [
|
|
|
30
31
|
"task_search",
|
|
31
32
|
"task_update",
|
|
32
33
|
"task_complete",
|
|
34
|
+
"task_pre_complete",
|
|
33
35
|
"task_operation_create",
|
|
34
36
|
"task_operation_list"
|
|
35
37
|
];
|
|
@@ -56,6 +58,7 @@ var TASK_TOOL_FACTORIES = [
|
|
|
56
58
|
searchTasksTool,
|
|
57
59
|
updateTaskTool,
|
|
58
60
|
completeTaskTool,
|
|
61
|
+
preCompleteTaskTool,
|
|
59
62
|
createOperationTool,
|
|
60
63
|
listOperationsTool
|
|
61
64
|
];
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
*/
|
|
36
36
|
import type { TaskBackend } from "../backend/types";
|
|
37
37
|
/** The task tools exposed over MCP. */
|
|
38
|
-
export declare const TASK_MCP_TOOL_NAMES: readonly ["task_create", "task_tree", "task_get", "task_list", "task_search", "task_update", "task_complete", "task_operation_create", "task_operation_list"];
|
|
38
|
+
export declare const TASK_MCP_TOOL_NAMES: readonly ["task_create", "task_tree", "task_get", "task_list", "task_search", "task_update", "task_complete", "task_pre_complete", "task_operation_create", "task_operation_list"];
|
|
39
39
|
export type TaskMcpToolName = (typeof TASK_MCP_TOOL_NAMES)[number];
|
|
40
40
|
/** An MCP tool definition (JSON Schema document — MCP requires JSON Schema). */
|
|
41
41
|
export interface TaskMcpToolDefinition {
|
|
@@ -45,13 +45,21 @@ import type { ModelMessage } from "ai";
|
|
|
45
45
|
/**
|
|
46
46
|
* Kinds of fake user messages. Used for deterministic merge ordering.
|
|
47
47
|
*
|
|
48
|
-
* Priority: "max-iter" > "delegate"
|
|
48
|
+
* Priority (KIND_PRIORITY below): "max-iter" > "task-ops" > "delegate"
|
|
49
49
|
* - "max-iter" reminders contain "不要再调用任何工具,直接总结" (final instruction)
|
|
50
|
+
* - "task-ops" reminders contain "task_operation_list" (Task #5081:
|
|
51
|
+
* sub-agent awareness of others' task operations)
|
|
50
52
|
* - "delegate" reminders contain "use delegate_task" (earlier hint)
|
|
51
53
|
*
|
|
52
54
|
* The final merged message always ends with the max-iter reminder.
|
|
53
55
|
*/
|
|
54
|
-
export type FakeUserMessageKind = "delegate" | "max-iter";
|
|
56
|
+
export type FakeUserMessageKind = "delegate" | "task-ops" | "max-iter";
|
|
57
|
+
/**
|
|
58
|
+
* Merge priority per kind — higher value = appears later in the
|
|
59
|
+
* merged message / wins the finalKind. Task #5081: "task-ops" sits
|
|
60
|
+
* between "delegate" (business hint) and "max-iter" (final word).
|
|
61
|
+
*/
|
|
62
|
+
export declare const KIND_PRIORITY: Record<FakeUserMessageKind, number>;
|
|
55
63
|
/**
|
|
56
64
|
* Internal implementation of the enqueue helper. Not exported directly;
|
|
57
65
|
* instead `enqueueToAddFakeUserMessage` (the wrapped version) is exported
|
|
@@ -4,11 +4,14 @@
|
|
|
4
4
|
export { TaskTagPlugin } from "./task-tag-plugin";
|
|
5
5
|
export { LayaDecisionPlugin, createLayaDecisionPlugin, LAYA_REUSE_THRESHOLD, type LayaDecisionPluginOptions, } from "./laya-decision-plugin";
|
|
6
6
|
export { createAutoTaskPlugin, type AutoTaskPluginConfig, } from "./auto-task-plugin";
|
|
7
|
+
export { createTaskOpWatermarkPlugin, TaskOpWatermarkPlugin, TASK_OP_WATERMARK_MAX_REMINDERS, TASK_OP_WATERMARK_MESSAGE_LIMIT, TASK_OP_WATERMARK_AUDIT_INTERVAL, type TaskOpWatermarkPluginConfig, } from "./task-op-watermark-plugin";
|
|
7
8
|
export { LayaCompletionPlugin, createLayaCompletionPlugin, registerLayaCompletionTaskHook, buildCompletionHint, renderCompletionState, buildCompletionQuestion, LAYA_COMPLETION_THRESHOLD, type LayaCompletionPluginOptions, } from "./laya-completion-plugin";
|
|
8
9
|
export { TASK_COMPLETION_HINT_ANCHOR, TASK_COMPLETE_ITEM_BY_ITEM, TASK_COMPLETE_VERIFY_DUTY, TASK_COMPLETE_ACCEPTANCE, } from "../tools/completion-copy";
|
|
9
10
|
export type { DecisionPort, DecisionRequest, DecisionAnswer, DecisionResponse, } from "./decision-port";
|
|
10
11
|
export { WORKFLOW_EXTRACTOR_PROMPT, formatExtractorInput, formatExtractorInputFromDescription, parseExtractorOutput, } from "./workflow-extractor-agent";
|
|
11
12
|
export { LarkCliTaskNotifyHook, createLarkCliTaskNotifyHook, type TaskNotifyConfig, NotifyType, } from "./lark-cli-task-notify-plugin";
|
|
13
|
+
export { WecomTaskNotifyHook, createWecomTaskNotifyHook, extractWecomFields, buildWecomTaskCard, WecomNotifyType, type WecomTaskNotifyConfig, type WecomMilestone, } from "./wecom-task-notify-plugin";
|
|
14
|
+
export { createWecomCardStateStore, createMemoryWecomCardStore, MemoryWecomCardStateStore, SqliteWecomCardStateStore, getDefaultWecomCardDbPath, type WecomCardState, type WecomCardStateStore, } from "./wecom-card-state-store";
|
|
12
15
|
export { PerTaskGroupChatPlugin, createPerTaskGroupChatPlugin, type PerTaskGroupConfig, } from "./per-task-group-chat-plugin";
|
|
13
16
|
export { LarkCardPatchNotifier, type LarkCardPatchNotifierOptions, buildTaskCard, buildWorkflowCard, renderProgressBar, renderMilestones, renderProcessSteps, renderTaskInfoLines, renderContextAsLines, renderWorkflowInfoLines, formatTimestampForDisplay, formatDateTimeForDisplay, formatDurationMs, sanitizeInlineText, humanizeValue, resolveTaskTitleForDisplay, buildChatAppLink, DEFAULT_APP_LINK_BASE, type CardStatus, type WorkflowCardStatus, type Milestone, type ProcessStep, type TaskMeta, type WorkflowMeta, type CardPayload, type StartTaskOptions, type UpdateTaskOptions, type FinishTaskOptions, type StartTaskResult, type StartWorkflowOptions, type UpdateWorkflowOptions, type FinishWorkflowOptions, } from "./lark-card-patch-notifier";
|
|
14
17
|
export { createLarkCardStateStore, getDefaultLarkCardDbPath, MemoryLarkCardStateStore, SqliteLarkCardStateStore, type LarkCardState, type LarkCardRecordStatus, type LarkCardStateStore, } from "./lark-card-state-store";
|
|
@@ -5,29 +5,40 @@ import {
|
|
|
5
5
|
LayaCompletionPlugin,
|
|
6
6
|
LayaDecisionPlugin,
|
|
7
7
|
MemoryLarkCardStateStore,
|
|
8
|
+
MemoryWecomCardStateStore,
|
|
8
9
|
NotifyType,
|
|
9
10
|
PerTaskGroupChatPlugin,
|
|
10
11
|
SqliteLarkCardStateStore,
|
|
12
|
+
SqliteWecomCardStateStore,
|
|
11
13
|
TaskTagPlugin,
|
|
12
14
|
WORKFLOW_EXTRACTOR_PROMPT,
|
|
15
|
+
WecomNotifyType,
|
|
16
|
+
WecomTaskNotifyHook,
|
|
13
17
|
buildCompletionHint,
|
|
14
18
|
buildCompletionQuestion,
|
|
19
|
+
buildWecomTaskCard,
|
|
15
20
|
createAutoTaskPlugin,
|
|
16
21
|
createLarkCardStateStore,
|
|
17
22
|
createLarkCliTaskNotifyHook,
|
|
18
23
|
createLayaCompletionPlugin,
|
|
19
24
|
createLayaDecisionPlugin,
|
|
25
|
+
createMemoryWecomCardStore,
|
|
20
26
|
createPerTaskGroupChatPlugin,
|
|
27
|
+
createWecomCardStateStore,
|
|
28
|
+
createWecomTaskNotifyHook,
|
|
29
|
+
extractWecomFields,
|
|
21
30
|
formatExtractorInput,
|
|
22
31
|
formatExtractorInputFromDescription,
|
|
23
32
|
getDefaultLarkCardDbPath,
|
|
33
|
+
getDefaultWecomCardDbPath,
|
|
24
34
|
parseExtractorOutput,
|
|
25
35
|
registerLayaCompletionTaskHook,
|
|
26
36
|
renderCompletionState
|
|
27
|
-
} from "../../../shared/@ai-setting/roy-agent-core-
|
|
37
|
+
} from "../../../shared/@ai-setting/roy-agent-core-b31v3qpv.js";
|
|
38
|
+
import"../../../shared/@ai-setting/roy-agent-core-m3vjepzz.js";
|
|
28
39
|
import"../../../shared/@ai-setting/roy-agent-core-na18zwj0.js";
|
|
29
40
|
import"../../../shared/@ai-setting/roy-agent-core-9vxh6f8h.js";
|
|
30
|
-
import"../../../shared/@ai-setting/roy-agent-core-
|
|
41
|
+
import"../../../shared/@ai-setting/roy-agent-core-ezvpreqz.js";
|
|
31
42
|
import"../../../shared/@ai-setting/roy-agent-core-1pg0fepg.js";
|
|
32
43
|
import"../../../shared/@ai-setting/roy-agent-core-tr3ep81v.js";
|
|
33
44
|
import"../../../shared/@ai-setting/roy-agent-core-m46fe3x4.js";
|
|
@@ -55,11 +66,17 @@ import {
|
|
|
55
66
|
renderWorkflowInfoLines,
|
|
56
67
|
resolveTaskTitleForDisplay,
|
|
57
68
|
sanitizeInlineText
|
|
58
|
-
} from "../../../shared/@ai-setting/roy-agent-core-
|
|
69
|
+
} from "../../../shared/@ai-setting/roy-agent-core-7dd0s3xb.js";
|
|
59
70
|
import"../../../shared/@ai-setting/roy-agent-core-1v4g0d4x.js";
|
|
60
71
|
import"../../../shared/@ai-setting/roy-agent-core-cgtq6427.js";
|
|
61
72
|
import"../../../shared/@ai-setting/roy-agent-core-er070zjq.js";
|
|
62
|
-
import
|
|
73
|
+
import {
|
|
74
|
+
TASK_OP_WATERMARK_AUDIT_INTERVAL,
|
|
75
|
+
TASK_OP_WATERMARK_MAX_REMINDERS,
|
|
76
|
+
TASK_OP_WATERMARK_MESSAGE_LIMIT,
|
|
77
|
+
TaskOpWatermarkPlugin,
|
|
78
|
+
createTaskOpWatermarkPlugin
|
|
79
|
+
} from "../../../shared/@ai-setting/roy-agent-core-h21gngxf.js";
|
|
63
80
|
import"../../../shared/@ai-setting/roy-agent-core-mkc3zshb.js";
|
|
64
81
|
import"../../../shared/@ai-setting/roy-agent-core-az13yzmc.js";
|
|
65
82
|
import"../../../shared/@ai-setting/roy-agent-core-qqaak24r.js";
|
|
@@ -81,32 +98,47 @@ export {
|
|
|
81
98
|
registerLayaCompletionTaskHook,
|
|
82
99
|
parseExtractorOutput,
|
|
83
100
|
humanizeValue,
|
|
101
|
+
getDefaultWecomCardDbPath,
|
|
84
102
|
getDefaultLarkCardDbPath,
|
|
85
103
|
formatTimestampForDisplay,
|
|
86
104
|
formatExtractorInputFromDescription,
|
|
87
105
|
formatExtractorInput,
|
|
88
106
|
formatDurationMs,
|
|
89
107
|
formatDateTimeForDisplay,
|
|
108
|
+
extractWecomFields,
|
|
109
|
+
createWecomTaskNotifyHook,
|
|
110
|
+
createWecomCardStateStore,
|
|
111
|
+
createTaskOpWatermarkPlugin,
|
|
90
112
|
createPerTaskGroupChatPlugin,
|
|
113
|
+
createMemoryWecomCardStore,
|
|
91
114
|
createLayaDecisionPlugin,
|
|
92
115
|
createLayaCompletionPlugin,
|
|
93
116
|
createLarkCliTaskNotifyHook,
|
|
94
117
|
createLarkCardStateStore,
|
|
95
118
|
createAutoTaskPlugin,
|
|
96
119
|
buildWorkflowCard,
|
|
120
|
+
buildWecomTaskCard,
|
|
97
121
|
buildTaskCard,
|
|
98
122
|
buildCompletionQuestion,
|
|
99
123
|
buildCompletionHint,
|
|
100
124
|
buildChatAppLink,
|
|
125
|
+
WecomTaskNotifyHook,
|
|
126
|
+
WecomNotifyType,
|
|
101
127
|
WORKFLOW_EXTRACTOR_PROMPT,
|
|
102
128
|
TaskTagPlugin,
|
|
129
|
+
TaskOpWatermarkPlugin,
|
|
130
|
+
TASK_OP_WATERMARK_MESSAGE_LIMIT,
|
|
131
|
+
TASK_OP_WATERMARK_MAX_REMINDERS,
|
|
132
|
+
TASK_OP_WATERMARK_AUDIT_INTERVAL,
|
|
103
133
|
TASK_COMPLETION_HINT_ANCHOR,
|
|
104
134
|
TASK_COMPLETE_VERIFY_DUTY,
|
|
105
135
|
TASK_COMPLETE_ITEM_BY_ITEM,
|
|
106
136
|
TASK_COMPLETE_ACCEPTANCE,
|
|
137
|
+
SqliteWecomCardStateStore,
|
|
107
138
|
SqliteLarkCardStateStore,
|
|
108
139
|
PerTaskGroupChatPlugin,
|
|
109
140
|
NotifyType,
|
|
141
|
+
MemoryWecomCardStateStore,
|
|
110
142
|
MemoryLarkCardStateStore,
|
|
111
143
|
LayaDecisionPlugin,
|
|
112
144
|
LayaCompletionPlugin,
|
|
@@ -79,7 +79,14 @@ export type CardStatus = "running" | "completed" | "failed" | "stopped"
|
|
|
79
79
|
* 语义上必须分开:用户看到「🚫 已取消」会以为任务还能找回来;
|
|
80
80
|
* 硬删除后任务真的没了,卡片应显示「🗑️ 已删除」。
|
|
81
81
|
*/
|
|
82
|
-
| "deleted"
|
|
82
|
+
| "deleted"
|
|
83
|
+
/**
|
|
84
|
+
* ★ Task #5164 需求 2b:任务进入「待验证」(两阶段验收,
|
|
85
|
+
* task_pre_complete 置 to_validate)。**非终态**活跃等待态:
|
|
86
|
+
* 卡片保持可更新,但 header 第二行显示专属短语「🔍 待验证」,
|
|
87
|
+
* 让用户一眼看出任务在等验收而不是在跑。
|
|
88
|
+
*/
|
|
89
|
+
| "to_validate";
|
|
83
90
|
/** workflow 卡片状态(与 CardStatus 同集合;语义别名,便于阅读) */
|
|
84
91
|
export type WorkflowCardStatus = CardStatus;
|
|
85
92
|
/** 里程碑(关键节点):时间 + 标题 + 描述 */
|
|
@@ -262,7 +269,12 @@ export interface StartTaskResult {
|
|
|
262
269
|
export interface LarkCardPatchNotifierOptions {
|
|
263
270
|
/** 启动时是否 pin(默认 true) */
|
|
264
271
|
pinOnStart?: boolean;
|
|
265
|
-
/**
|
|
272
|
+
/**
|
|
273
|
+
* 结束时是否 unpin(Task #5164 需求 2a:**默认 false**)
|
|
274
|
+
*
|
|
275
|
+
* 任务完成/暂停时不再自动取消置顶 —— pin 去留由用户手动决定。
|
|
276
|
+
* 需要旧行为(自动 unpin)的调用方显式传 true。
|
|
277
|
+
*/
|
|
266
278
|
unpinOnFinish?: boolean;
|
|
267
279
|
}
|
|
268
280
|
export interface CardPayload {
|
|
@@ -805,6 +817,33 @@ export declare class LarkCardPatchNotifier {
|
|
|
805
817
|
* 不会被旧 messageId 的终态记录误伤。
|
|
806
818
|
*/
|
|
807
819
|
private finalisedCards;
|
|
820
|
+
/**
|
|
821
|
+
* ★ Task #5182 follow-up:解除某张卡片的终态标记(reopen 用)。
|
|
822
|
+
*
|
|
823
|
+
* ## 为什么需要
|
|
824
|
+
*
|
|
825
|
+
* `finalisedCards` 守卫(Task #5020)会吞掉 finishTask 之后的
|
|
826
|
+
* 一切 updateTask —— 这对「迟到的并发更新」是正确语义,但对
|
|
827
|
+
* **reopen**(closed 卡片 + 任务重新激活 → 复用原卡)是错的:
|
|
828
|
+
* reopen 本来就是要"复活"这张卡。真网取证(2026-11-08 18:00):
|
|
829
|
+
* reopenReuseCard 打了「已复用原卡」日志 + pin 成功,但 patch
|
|
830
|
+
* 被守卫静默吞掉,卡片内容停在「已完成」。
|
|
831
|
+
*
|
|
832
|
+
* ## 行为
|
|
833
|
+
*
|
|
834
|
+
* - 从 finalisedCards 删除 messageId(守卫解除)
|
|
835
|
+
* - 内存态不存在时从 exportState 快照恢复?—— 不,states 已被
|
|
836
|
+
* finishTask delete,快照无从取。调用方(reopenReuseCard)
|
|
837
|
+
* 会经 mergeTimelineState/updateTask 的默认 state 重建时间线,
|
|
838
|
+
* 并由 hook 层 hydrate(restoreCardState → hydrateState)补齐。
|
|
839
|
+
* - 对未终结的卡是 no-op(finalisedCards 本就没有该 id)
|
|
840
|
+
*/
|
|
841
|
+
unfinaliseCard(messageId: string): void;
|
|
842
|
+
/**
|
|
843
|
+
* ★ Task #5182 follow-up:测试注入点 —— 替换 runLarkCli 的执行器。
|
|
844
|
+
* 仅测试使用(生产路径不设置),避免真 spawn lark-cli。
|
|
845
|
+
*/
|
|
846
|
+
testRunner?: (argv: string[], op: string) => Promise<string>;
|
|
808
847
|
/** 诊断:当前跟踪中的卡片数(测试/自检用) */
|
|
809
848
|
trackedCardCount(): number;
|
|
810
849
|
/** 诊断:当前跟踪中的 workflow 卡片数(测试/自检用) */
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
resolveTaskTitleForDisplay,
|
|
23
23
|
sanitizeInlineText,
|
|
24
24
|
truncateHeadTitle
|
|
25
|
-
} from "../../../shared/@ai-setting/roy-agent-core-
|
|
25
|
+
} from "../../../shared/@ai-setting/roy-agent-core-7dd0s3xb.js";
|
|
26
26
|
import"../../../shared/@ai-setting/roy-agent-core-qq96p0tj.js";
|
|
27
27
|
import"../../../shared/@ai-setting/roy-agent-core-7f7t9wwp.js";
|
|
28
28
|
import"../../../shared/@ai-setting/roy-agent-core-85xyctnb.js";
|
|
@@ -339,6 +339,22 @@ export declare class LarkCliTaskNotifyHook implements Hook {
|
|
|
339
339
|
* 持久层 `pinned=false`(如实反映真实状态,不谎报)。
|
|
340
340
|
*/
|
|
341
341
|
private repinAfterResume;
|
|
342
|
+
/**
|
|
343
|
+
* ★ Task #5182 — reopen 复用原卡(用户明令 2026-11-08 15:56)
|
|
344
|
+
*
|
|
345
|
+
* 场景:lark-cards.db 里该 task 的记录是 `closed`,但任务被重新激活
|
|
346
|
+
* (status → active 等活跃态)。旧实现发一张新卡(同 task 两张卡、
|
|
347
|
+
* 历史时间线留在旧卡上);新实现:
|
|
348
|
+
*
|
|
349
|
+
* 1. patch 原 messageId:内容 = 当前任务态 + 「🔄 任务重新打开」里程碑
|
|
350
|
+
* 2. 新增一条 reopen 操作记录进卡片时间线(用户可见的 reopen 痕迹)
|
|
351
|
+
* 3. 重新 pin(终态时被 unpin 过;pin 状态必须跟任务状态一致)
|
|
352
|
+
* 4. 持久层 markReopened(closed → open,messageId 不变)
|
|
353
|
+
*
|
|
354
|
+
* @returns true = 原卡复用成功(caller 直接返回,不再走建卡路径);
|
|
355
|
+
* false = 原卡 patch 失败(caller 降级走发新卡路径)
|
|
356
|
+
*/
|
|
357
|
+
private reopenReuseCard;
|
|
342
358
|
/** 合并「写记录」所需的公共字段(读旧记录失败也不抛,降级为 now) */
|
|
343
359
|
private buildCardState;
|
|
344
360
|
/** 对外只读:某 task 的持久化卡片记录(debug / 排查用) */
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview TaskOpWatermarkPlugin — sub-agent 感知任务操作记录(Task #5081,M1)
|
|
3
|
+
*
|
|
4
|
+
* 设计文档:/tmp/task-op-awareness-design.md(Task #5079,已验收)
|
|
5
|
+
*
|
|
6
|
+
* ## 场景
|
|
7
|
+
*
|
|
8
|
+
* sub-agent(roy 等)被委托推进某个 task 期间,default agent(或其它
|
|
9
|
+
* sub-agent / CLI 探针进程)往同一 task 写了新的 operation 记录。
|
|
10
|
+
* sub-agent 的 ReAct 循环对「别人给我加了记录」**毫无感知** —— 本插件
|
|
11
|
+
* 在 `agent:after.tool` 时点做水位比对,命中则通过共享 meta-protocol
|
|
12
|
+
* (`toolResult.result.metadata.toAddFakeUserMessage`)注入一条
|
|
13
|
+
* user role 提醒,sub-agent 下轮读到后自行调 `task_operation_list` 读取。
|
|
14
|
+
*
|
|
15
|
+
* ## 水位语义(关键设计决策)
|
|
16
|
+
*
|
|
17
|
+
* - 水位用 **operation id**(SQLite AUTOINCREMENT,严格单调)而非
|
|
18
|
+
* timestamp(Date.now() 毫秒,同毫秒多条会漏)。
|
|
19
|
+
* - 水位存 plugin 实例的 `Map<sessionId, Watermark>` —— 生命周期与
|
|
20
|
+
* plugin 实例一致;进程重启后首轮全量扫(N 聚 1 + 限流兜底噪声)。
|
|
21
|
+
* - **查询必须绕过 operationsCache**:`sqlite-task-store.ts` 的缓存只在
|
|
22
|
+
* 本进程写入时失效,跨进程(CLI 探针 / 另一 daemon)写入的记录不会
|
|
23
|
+
* 失效本进程缓存 → 必须走 `listOperationsFresh`(直打 DB)。
|
|
24
|
+
* - 能力探测:store 未实现 `listOperationsFresh`(外部宿主的后端)时
|
|
25
|
+
* 降级 `listOperations` + `invalidateOperationsCache`,功能等价。
|
|
26
|
+
*
|
|
27
|
+
* ## 自提醒过滤(防 doom loop,核心)
|
|
28
|
+
*
|
|
29
|
+
* `op.sessionId === 我的 sessionId` → 不算新记录。三个来源:
|
|
30
|
+
* 1. sub-agent 自己 `task_operation_create` 记进度(create-tool.ts:87)
|
|
31
|
+
* 2. sub-agent 自己 `task_pre_complete` 写的留痕(pre-complete-tool.ts:89,
|
|
32
|
+
* Task #5073 两阶段验收的提交口 —— 回归保护)
|
|
33
|
+
* 3. `sessionId = "unknown"` 的 fallback 写入(create-tool.ts:87 的兜底)
|
|
34
|
+
*
|
|
35
|
+
* ## 防退化与边界(设计文档 §4)
|
|
36
|
+
*
|
|
37
|
+
* - 无 task 绑定 → 跳过;DB 读异常 → catch + warn,不影响工具执行
|
|
38
|
+
* - N 条新记录聚合 **1 条**提醒(详情 ≤3 条,最新优先,其余折叠)
|
|
39
|
+
* - 单 session 限流 `TASK_OP_WATERMARK_MAX_REMINDERS`(5)次,超限只推水位
|
|
40
|
+
* - 消息总长 ≤ `TASK_OP_WATERMARK_MESSAGE_LIMIT`(1500 字符)
|
|
41
|
+
* - 每 `TASK_OP_WATERMARK_AUDIT_INTERVAL`(15)次工具调用兜底全量对账
|
|
42
|
+
* - kind 合并顺序:`delegate` → `task-ops` → `max-iter`(max-iter 最终
|
|
43
|
+
* 指令永远在末尾,见 fake-user-message-helper KIND_PRIORITY)
|
|
44
|
+
*/
|
|
45
|
+
import type { Plugin, HookContext, HookResult } from "../../agent/types";
|
|
46
|
+
import type { TaskOperation } from "../types";
|
|
47
|
+
/** 单 session(plugin 实例生命周期内)最大提醒次数 */
|
|
48
|
+
export declare const TASK_OP_WATERMARK_MAX_REMINDERS = 5;
|
|
49
|
+
/** 注入消息的总长度上限(字符) */
|
|
50
|
+
export declare const TASK_OP_WATERMARK_MESSAGE_LIMIT = 1500;
|
|
51
|
+
/** 兜底全量对账的工具调用间隔 */
|
|
52
|
+
export declare const TASK_OP_WATERMARK_AUDIT_INTERVAL = 15;
|
|
53
|
+
/**
|
|
54
|
+
* TaskComponent 只读能力面 —— 与 decision-hint-plugin 的
|
|
55
|
+
* `TaskComponentReadonly` 同款隔离模式(避免类型循环依赖)。
|
|
56
|
+
*/
|
|
57
|
+
export interface TaskOpWatermarkTaskComponentLike {
|
|
58
|
+
/** 按 session 反查绑定的**全部** task(多 task 并集水位,不漏报) */
|
|
59
|
+
getTaskIdsBySessionId?(sessionId: string): Promise<number[] | undefined>;
|
|
60
|
+
/** 老接口:只返回第一个 task(getTaskIdsBySessionId 未实现时的 fallback) */
|
|
61
|
+
getTaskIdBySessionId?(sessionId: string): Promise<number | undefined>;
|
|
62
|
+
getTask(id: number): Promise<{
|
|
63
|
+
id: number;
|
|
64
|
+
title: string;
|
|
65
|
+
} | undefined>;
|
|
66
|
+
/** 绕过 operationsCache 的 fresh 查询(可选 —— 能力探测) */
|
|
67
|
+
listOperationsFresh?(options: {
|
|
68
|
+
taskId: number;
|
|
69
|
+
limit?: number;
|
|
70
|
+
}): Promise<TaskOperation[]>;
|
|
71
|
+
/** 常规查询(fallback 路径用) */
|
|
72
|
+
listOperations(options: {
|
|
73
|
+
taskId: number;
|
|
74
|
+
limit?: number;
|
|
75
|
+
}): Promise<TaskOperation[]>;
|
|
76
|
+
/** 缓存失效(fallback 路径用;可选 —— 能力探测) */
|
|
77
|
+
invalidateOperationsCache?(taskId: number): void;
|
|
78
|
+
}
|
|
79
|
+
export interface TaskOpWatermarkPluginConfig {
|
|
80
|
+
/**
|
|
81
|
+
* 惰性解析 TaskComponent(推荐注入方式)。
|
|
82
|
+
*
|
|
83
|
+
* 为什么惰性:`registerAgent` 可能早于 TaskComponent 注册(时序风险),
|
|
84
|
+
* 惰性闭包把解析推迟到首次 `execute()`(env 组件已就绪)——
|
|
85
|
+
* 设计文档 §2.1 方案 (c)。
|
|
86
|
+
*/
|
|
87
|
+
resolveTaskComponent?: () => TaskOpWatermarkTaskComponentLike | undefined;
|
|
88
|
+
}
|
|
89
|
+
export declare class TaskOpWatermarkPlugin {
|
|
90
|
+
readonly name = "TaskOpWatermarkPlugin";
|
|
91
|
+
readonly version = "1.0.0";
|
|
92
|
+
readonly description = "Task #5081 \u2014 agent:after.tool \u6C34\u4F4D\u6BD4\u5BF9\uFF1A\u540C\u4E00 task \u51FA\u73B0\u4ED6\u4EBA\uFF08sessionId \u8FC7\u6EE4 + unknown \u8FC7\u6EE4\uFF09\u65B0\u589E\u7684 operation \u65F6\uFF0C\u7ECF\u5171\u4EAB meta-protocol \u6CE8\u5165 user role \u63D0\u9192\uFF08N \u805A 1 / \u9650\u6D41 5 / \u957F\u5EA6 1500 / 15 \u6B21\u515C\u5E95\u5BF9\u8D26 / fresh \u65C1\u8DEF\u7ED5 operationsCache\uFF09\u3002";
|
|
93
|
+
readonly priority = 40;
|
|
94
|
+
/** session 级水位(plugin 实例生命周期) */
|
|
95
|
+
private readonly watermarks;
|
|
96
|
+
private readonly resolveTaskComponent;
|
|
97
|
+
constructor(config?: TaskOpWatermarkPluginConfig);
|
|
98
|
+
execute(ctx: HookContext): Promise<HookResult>;
|
|
99
|
+
private check;
|
|
100
|
+
/** 自提醒过滤:自己写的 + unknown fallback 写入的都不算「别人的」 */
|
|
101
|
+
private isSelf;
|
|
102
|
+
private resolveTaskIds;
|
|
103
|
+
/**
|
|
104
|
+
* 拉取记录 —— fresh 优先(绕 operationsCache;跨进程写入可见),
|
|
105
|
+
* 能力探测失败降级 listOperations + invalidateOperationsCache。
|
|
106
|
+
*/
|
|
107
|
+
private listOps;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* 创建 TaskOpWatermarkPlugin 实例(与 createMaxIterationReminderPlugin 同款形态)
|
|
111
|
+
*/
|
|
112
|
+
export declare function createTaskOpWatermarkPlugin(config?: TaskOpWatermarkPluginConfig): Plugin;
|