@ai-setting/roy-agent-core 1.7.75 → 1.7.77
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/env/agent/agent-component.js +2 -2
- package/dist/env/agent/index.js +2 -2
- package/dist/env/event-source/event-source-handlers.js +9 -8
- package/dist/env/event-source/index.js +10 -9
- package/dist/env/index.js +16 -15
- package/dist/env/prompt/index.js +4 -3
- package/dist/env/prompt/prompts-index.d.ts +11 -9
- package/dist/env/task/backend/index.js +45 -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.js +4 -3
- package/dist/env/task/delegate/index.js +4 -3
- package/dist/env/task/hooks/contexts.d.ts +12 -1
- package/dist/env/task/hooks/task-hook-points.d.ts +8 -3
- package/dist/env/task/index.d.ts +1 -0
- package/dist/env/task/index.js +17 -7
- package/dist/env/task/mcp/index.js +6 -2
- 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 +1 -0
- package/dist/env/task/plugins/index.js +18 -6
- package/dist/env/task/plugins/lark-card-patch-notifier.js +1 -1
- package/dist/env/task/plugins/task-op-watermark-plugin.d.ts +112 -0
- package/dist/env/task/prompt/index.js +2 -1
- package/dist/env/task/prompt/task-discipline.d.ts +1 -1
- 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 +95 -0
- package/dist/env/task/tools/cancel-tool.d.ts +12 -4
- package/dist/env/task/tools/completion-copy.d.ts +92 -0
- package/dist/env/task/tools/index.d.ts +1 -0
- package/dist/env/task/tools/index.js +5 -2
- package/dist/env/task/tools/operation/operation-types.d.ts +13 -13
- package/dist/env/task/tools/pre-complete-tool.d.ts +32 -0
- package/dist/env/task/tools/task-types.d.ts +49 -17
- package/dist/env/task/types.d.ts +13 -1
- package/dist/env/workflow/plugins/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 +26 -16
- package/dist/shared/@ai-setting/{roy-agent-core-n9q1encx.js → roy-agent-core-0v27y99n.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-60jbrfye.js → roy-agent-core-3gpygqcx.js} +30 -6
- package/dist/shared/@ai-setting/roy-agent-core-4rtg69cn.js +26 -0
- package/dist/shared/@ai-setting/{roy-agent-core-djpq6yb0.js → roy-agent-core-9vhq7fvv.js} +6 -2
- package/dist/shared/@ai-setting/{roy-agent-core-3e6gg17d.js → roy-agent-core-9vxh6f8h.js} +169 -30
- package/dist/shared/@ai-setting/{roy-agent-core-jg65qnwa.js → roy-agent-core-aa2j7bk9.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-29b6hc39.js → roy-agent-core-cmprygrp.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-snvh4s2p.js → roy-agent-core-ew6qb5yx.js} +1 -1
- 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-h21gngxf.js +247 -0
- package/dist/shared/@ai-setting/{roy-agent-core-p3zv1mx5.js → roy-agent-core-hd3n57zs.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-11shp00p.js → roy-agent-core-m46fe3x4.js} +21 -31
- 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-4gr3k7qg.js → roy-agent-core-rhtdspx6.js} +140 -29
- package/dist/shared/@ai-setting/{roy-agent-core-y7x2qzwc.js → roy-agent-core-rsn44n9y.js} +10 -6
- package/dist/shared/@ai-setting/{roy-agent-core-hnyk1by7.js → roy-agent-core-vffccgf6.js} +152 -33
- package/dist/shared/@ai-setting/{roy-agent-core-nmx9934r.js → roy-agent-core-w0qjeq2v.js} +1 -1
- package/package.json +1 -1
- package/dist/shared/@ai-setting/roy-agent-core-f77k3gqt.js +0 -71
|
@@ -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)。 */
|
|
@@ -12,12 +12,13 @@ import {
|
|
|
12
12
|
deriveTriggerEventIdFromEnvContext,
|
|
13
13
|
getSubAgentSpec,
|
|
14
14
|
handleBackgroundTask
|
|
15
|
-
} from "../../../shared/@ai-setting/roy-agent-core-
|
|
15
|
+
} from "../../../shared/@ai-setting/roy-agent-core-aa2j7bk9.js";
|
|
16
16
|
import"../../../shared/@ai-setting/roy-agent-core-fttgm52a.js";
|
|
17
17
|
import"../../../shared/@ai-setting/roy-agent-core-na18zwj0.js";
|
|
18
|
-
import"../../../shared/@ai-setting/roy-agent-core-
|
|
18
|
+
import"../../../shared/@ai-setting/roy-agent-core-9vxh6f8h.js";
|
|
19
19
|
import"../../../shared/@ai-setting/roy-agent-core-1pg0fepg.js";
|
|
20
|
-
import"../../../shared/@ai-setting/roy-agent-core-
|
|
20
|
+
import"../../../shared/@ai-setting/roy-agent-core-m46fe3x4.js";
|
|
21
|
+
import"../../../shared/@ai-setting/roy-agent-core-4rtg69cn.js";
|
|
21
22
|
import"../../../shared/@ai-setting/roy-agent-core-ed233k5z.js";
|
|
22
23
|
import"../../../shared/@ai-setting/roy-agent-core-qxnbvgwe.js";
|
|
23
24
|
import"../../../shared/@ai-setting/roy-agent-core-c1v263jn.js";
|
|
@@ -5,12 +5,13 @@ 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-aa2j7bk9.js";
|
|
9
9
|
import"../../../shared/@ai-setting/roy-agent-core-fttgm52a.js";
|
|
10
10
|
import"../../../shared/@ai-setting/roy-agent-core-na18zwj0.js";
|
|
11
|
-
import"../../../shared/@ai-setting/roy-agent-core-
|
|
11
|
+
import"../../../shared/@ai-setting/roy-agent-core-9vxh6f8h.js";
|
|
12
12
|
import"../../../shared/@ai-setting/roy-agent-core-1pg0fepg.js";
|
|
13
|
-
import"../../../shared/@ai-setting/roy-agent-core-
|
|
13
|
+
import"../../../shared/@ai-setting/roy-agent-core-m46fe3x4.js";
|
|
14
|
+
import"../../../shared/@ai-setting/roy-agent-core-4rtg69cn.js";
|
|
14
15
|
import"../../../shared/@ai-setting/roy-agent-core-ed233k5z.js";
|
|
15
16
|
import"../../../shared/@ai-setting/roy-agent-core-qxnbvgwe.js";
|
|
16
17
|
import"../../../shared/@ai-setting/roy-agent-core-c1v263jn.js";
|
|
@@ -164,7 +164,18 @@ export interface TaskDelegateResultContext {
|
|
|
164
164
|
* `timeout` 也算 task 终结(不应继续等待结果)。
|
|
165
165
|
*/
|
|
166
166
|
export declare const TASK_COMPLETE_TERMINAL_STATUSES: readonly ["completed", "failed", "cancelled", "timeout"];
|
|
167
|
-
|
|
167
|
+
/**
|
|
168
|
+
* ★ Task #5073(设计调整②)— to_validate 也走 AFTER_COMPLETE:
|
|
169
|
+
*
|
|
170
|
+
* AFTER_COMPLETE 的语义从「泛终态事件」收窄为「goal 检查触发点」:
|
|
171
|
+
* - to_validate:sub-agent 提交待验证(自查关)—— decision model
|
|
172
|
+
* 在此判定「目标 vs 交付物」
|
|
173
|
+
* - completed:验收落定(default agent 复检)
|
|
174
|
+
* failed/cancelled/timeout 仍保留在类型里(历史兼容),
|
|
175
|
+
* 但 updateTask 已**不再**触发 AFTER_COMPLETE(见 task-component.ts),
|
|
176
|
+
* 实际能看到的触发点唯一 = preCompleteTask(to_validate)。
|
|
177
|
+
*/
|
|
178
|
+
export type TaskCompleteTerminalStatus = typeof TASK_COMPLETE_TERMINAL_STATUSES[number] | "to_validate";
|
|
168
179
|
/**
|
|
169
180
|
* Task Complete Result Hook Context
|
|
170
181
|
*
|
|
@@ -17,13 +17,18 @@ export declare const TaskHookPoints: {
|
|
|
17
17
|
/** 删除 Task 后 - 清理关联资源 */
|
|
18
18
|
readonly AFTER_DELETE: "task:after.delete";
|
|
19
19
|
/**
|
|
20
|
-
* Task 完成 hook ——
|
|
21
|
-
*
|
|
20
|
+
* Task 完成 hook —— 当任务进入「完成语义状态」时触发。
|
|
21
|
+
* 触发点(Task #5073 两阶段验收后):
|
|
22
|
+
* - task_pre_complete:terminalStatus="to_validate"
|
|
23
|
+
* (sub-agent 提交待验证时的 goal 自查关)
|
|
24
|
+
* - updateTask:仅 status 迁入 TASK_COMPLETE_TERMINAL_STATUSES
|
|
25
|
+
* (completed / failed / cancelled / timeout) 时触发
|
|
26
|
+
* 语义级别比 AFTER_UPDATE 更精确,plugin 可用于实现"任务完成时"的副作用
|
|
22
27
|
* (例如发送通知、刷新看板、上传结果等)。
|
|
23
28
|
*
|
|
24
29
|
* 注意:AFTER_COMPLETE 与 AFTER_UPDATE 不互斥。
|
|
25
30
|
* - AFTER_UPDATE 在每一次 update 成功后触发,包括 status 变更、progress 变更等
|
|
26
|
-
* - AFTER_COMPLETE
|
|
31
|
+
* - AFTER_COMPLETE 仅在上述「完成语义」迁移时触发
|
|
27
32
|
* 一个更新操作可能同时触发两个 hook。
|
|
28
33
|
*/
|
|
29
34
|
readonly AFTER_COMPLETE: "task:after.complete";
|
package/dist/env/task/index.d.ts
CHANGED
|
@@ -4,4 +4,5 @@
|
|
|
4
4
|
export { TaskComponent, type TaskComponentOptions } from "./task-component";
|
|
5
5
|
export * from "./types";
|
|
6
6
|
export { SQLiteTaskStore, getDefaultTaskDbPath, type TaskStore } from "./storage";
|
|
7
|
+
export { TASK_COMPLETED_STATUS_WORD, TASK_CANCELLED_STATUS_WORD, TASK_ARCHIVED_STATUS_WORD, TASK_DELIVERABLE_RECORDED, } from "./tools/completion-copy";
|
|
7
8
|
export * from "./events";
|
package/dist/env/task/index.js
CHANGED
|
@@ -5,26 +5,32 @@ 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-rhtdspx6.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-aa2j7bk9.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";
|
|
17
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
17
|
+
import"../../shared/@ai-setting/roy-agent-core-vffccgf6.js";
|
|
18
18
|
import"../../shared/@ai-setting/roy-agent-core-p5cz9m8v.js";
|
|
19
19
|
import"../../shared/@ai-setting/roy-agent-core-na18zwj0.js";
|
|
20
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
20
|
+
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
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
27
|
+
import"../../shared/@ai-setting/roy-agent-core-m46fe3x4.js";
|
|
28
|
+
import {
|
|
29
|
+
TASK_ARCHIVED_STATUS_WORD,
|
|
30
|
+
TASK_CANCELLED_STATUS_WORD,
|
|
31
|
+
TASK_COMPLETED_STATUS_WORD,
|
|
32
|
+
TASK_DELIVERABLE_RECORDED
|
|
33
|
+
} from "../../shared/@ai-setting/roy-agent-core-4rtg69cn.js";
|
|
28
34
|
import"../../shared/@ai-setting/roy-agent-core-ed233k5z.js";
|
|
29
35
|
import"../../shared/@ai-setting/roy-agent-core-qxnbvgwe.js";
|
|
30
36
|
import"../../shared/@ai-setting/roy-agent-core-c1v263jn.js";
|
|
@@ -46,6 +52,10 @@ export {
|
|
|
46
52
|
TaskEntityEventTypes,
|
|
47
53
|
TaskConfigSchema,
|
|
48
54
|
TaskComponent,
|
|
55
|
+
TASK_DELIVERABLE_RECORDED,
|
|
56
|
+
TASK_COMPLETED_STATUS_WORD,
|
|
57
|
+
TASK_CANCELLED_STATUS_WORD,
|
|
58
|
+
TASK_ARCHIVED_STATUS_WORD,
|
|
49
59
|
SQLiteTaskStore,
|
|
50
60
|
ActionTypeEnum
|
|
51
61
|
};
|
|
@@ -3,16 +3,18 @@ import {
|
|
|
3
3
|
createTaskTool,
|
|
4
4
|
getTaskTool,
|
|
5
5
|
listTasksTool,
|
|
6
|
+
preCompleteTaskTool,
|
|
6
7
|
searchTasksTool,
|
|
7
8
|
treeTasksTool,
|
|
8
9
|
updateTaskTool
|
|
9
|
-
} from "../../../shared/@ai-setting/roy-agent-core-
|
|
10
|
+
} from "../../../shared/@ai-setting/roy-agent-core-vffccgf6.js";
|
|
10
11
|
import {
|
|
11
12
|
createOperationTool,
|
|
12
13
|
listOperationsTool
|
|
13
14
|
} from "../../../shared/@ai-setting/roy-agent-core-p5cz9m8v.js";
|
|
14
15
|
import"../../../shared/@ai-setting/roy-agent-core-tr3ep81v.js";
|
|
15
|
-
import"../../../shared/@ai-setting/roy-agent-core-
|
|
16
|
+
import"../../../shared/@ai-setting/roy-agent-core-m46fe3x4.js";
|
|
17
|
+
import"../../../shared/@ai-setting/roy-agent-core-4rtg69cn.js";
|
|
16
18
|
import"../../../shared/@ai-setting/roy-agent-core-7cbpmk4q.js";
|
|
17
19
|
import"../../../shared/@ai-setting/roy-agent-core-qq96p0tj.js";
|
|
18
20
|
import"../../../shared/@ai-setting/roy-agent-core-7f7t9wwp.js";
|
|
@@ -29,6 +31,7 @@ var TASK_MCP_TOOL_NAMES = [
|
|
|
29
31
|
"task_search",
|
|
30
32
|
"task_update",
|
|
31
33
|
"task_complete",
|
|
34
|
+
"task_pre_complete",
|
|
32
35
|
"task_operation_create",
|
|
33
36
|
"task_operation_list"
|
|
34
37
|
];
|
|
@@ -55,6 +58,7 @@ var TASK_TOOL_FACTORIES = [
|
|
|
55
58
|
searchTasksTool,
|
|
56
59
|
updateTaskTool,
|
|
57
60
|
completeTaskTool,
|
|
61
|
+
preCompleteTaskTool,
|
|
58
62
|
createOperationTool,
|
|
59
63
|
listOperationsTool
|
|
60
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,6 +4,7 @@
|
|
|
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";
|
|
@@ -24,18 +24,19 @@ import {
|
|
|
24
24
|
parseExtractorOutput,
|
|
25
25
|
registerLayaCompletionTaskHook,
|
|
26
26
|
renderCompletionState
|
|
27
|
-
} from "../../../shared/@ai-setting/roy-agent-core-
|
|
27
|
+
} from "../../../shared/@ai-setting/roy-agent-core-rsn44n9y.js";
|
|
28
28
|
import"../../../shared/@ai-setting/roy-agent-core-na18zwj0.js";
|
|
29
|
-
import"../../../shared/@ai-setting/roy-agent-core-
|
|
30
|
-
import"../../../shared/@ai-setting/roy-agent-core-
|
|
29
|
+
import"../../../shared/@ai-setting/roy-agent-core-9vxh6f8h.js";
|
|
30
|
+
import"../../../shared/@ai-setting/roy-agent-core-ezvpreqz.js";
|
|
31
31
|
import"../../../shared/@ai-setting/roy-agent-core-1pg0fepg.js";
|
|
32
32
|
import"../../../shared/@ai-setting/roy-agent-core-tr3ep81v.js";
|
|
33
|
+
import"../../../shared/@ai-setting/roy-agent-core-m46fe3x4.js";
|
|
33
34
|
import {
|
|
34
35
|
TASK_COMPLETE_ACCEPTANCE,
|
|
35
36
|
TASK_COMPLETE_ITEM_BY_ITEM,
|
|
36
37
|
TASK_COMPLETE_VERIFY_DUTY,
|
|
37
38
|
TASK_COMPLETION_HINT_ANCHOR
|
|
38
|
-
} from "../../../shared/@ai-setting/roy-agent-core-
|
|
39
|
+
} from "../../../shared/@ai-setting/roy-agent-core-4rtg69cn.js";
|
|
39
40
|
import {
|
|
40
41
|
DEFAULT_APP_LINK_BASE,
|
|
41
42
|
LarkCardPatchNotifier,
|
|
@@ -54,11 +55,17 @@ import {
|
|
|
54
55
|
renderWorkflowInfoLines,
|
|
55
56
|
resolveTaskTitleForDisplay,
|
|
56
57
|
sanitizeInlineText
|
|
57
|
-
} from "../../../shared/@ai-setting/roy-agent-core-
|
|
58
|
+
} from "../../../shared/@ai-setting/roy-agent-core-w0qjeq2v.js";
|
|
58
59
|
import"../../../shared/@ai-setting/roy-agent-core-1v4g0d4x.js";
|
|
59
60
|
import"../../../shared/@ai-setting/roy-agent-core-cgtq6427.js";
|
|
60
61
|
import"../../../shared/@ai-setting/roy-agent-core-er070zjq.js";
|
|
61
|
-
import
|
|
62
|
+
import {
|
|
63
|
+
TASK_OP_WATERMARK_AUDIT_INTERVAL,
|
|
64
|
+
TASK_OP_WATERMARK_MAX_REMINDERS,
|
|
65
|
+
TASK_OP_WATERMARK_MESSAGE_LIMIT,
|
|
66
|
+
TaskOpWatermarkPlugin,
|
|
67
|
+
createTaskOpWatermarkPlugin
|
|
68
|
+
} from "../../../shared/@ai-setting/roy-agent-core-h21gngxf.js";
|
|
62
69
|
import"../../../shared/@ai-setting/roy-agent-core-mkc3zshb.js";
|
|
63
70
|
import"../../../shared/@ai-setting/roy-agent-core-az13yzmc.js";
|
|
64
71
|
import"../../../shared/@ai-setting/roy-agent-core-qqaak24r.js";
|
|
@@ -86,6 +93,7 @@ export {
|
|
|
86
93
|
formatExtractorInput,
|
|
87
94
|
formatDurationMs,
|
|
88
95
|
formatDateTimeForDisplay,
|
|
96
|
+
createTaskOpWatermarkPlugin,
|
|
89
97
|
createPerTaskGroupChatPlugin,
|
|
90
98
|
createLayaDecisionPlugin,
|
|
91
99
|
createLayaCompletionPlugin,
|
|
@@ -99,6 +107,10 @@ export {
|
|
|
99
107
|
buildChatAppLink,
|
|
100
108
|
WORKFLOW_EXTRACTOR_PROMPT,
|
|
101
109
|
TaskTagPlugin,
|
|
110
|
+
TaskOpWatermarkPlugin,
|
|
111
|
+
TASK_OP_WATERMARK_MESSAGE_LIMIT,
|
|
112
|
+
TASK_OP_WATERMARK_MAX_REMINDERS,
|
|
113
|
+
TASK_OP_WATERMARK_AUDIT_INTERVAL,
|
|
102
114
|
TASK_COMPLETION_HINT_ANCHOR,
|
|
103
115
|
TASK_COMPLETE_VERIFY_DUTY,
|
|
104
116
|
TASK_COMPLETE_ITEM_BY_ITEM,
|
|
@@ -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-w0qjeq2v.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";
|
|
@@ -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;
|
|
@@ -5,7 +5,8 @@ import {
|
|
|
5
5
|
TASK_DISCIPLINE_LIFECYCLE,
|
|
6
6
|
TASK_DISCIPLINE_OPERATION,
|
|
7
7
|
TASK_DISCIPLINE_PROMPT
|
|
8
|
-
} from "../../../shared/@ai-setting/roy-agent-core-
|
|
8
|
+
} from "../../../shared/@ai-setting/roy-agent-core-m46fe3x4.js";
|
|
9
|
+
import"../../../shared/@ai-setting/roy-agent-core-4rtg69cn.js";
|
|
9
10
|
import"../../../shared/@ai-setting/roy-agent-core-fs0mn2jk.js";
|
|
10
11
|
export {
|
|
11
12
|
TASK_DISCIPLINE_PROMPT,
|
|
@@ -33,6 +33,6 @@ export declare const TASK_DISCIPLINE_GOALS = "### Goals \u5B50\u9879\u62C6\u5206
|
|
|
33
33
|
* 执行方(roy sub-agent)**没有** `task_complete` 权限,不适用本分片。
|
|
34
34
|
* 为避免执行方误读,段落开头显式声明「仅验收方适用」。
|
|
35
35
|
*/
|
|
36
|
-
export declare const TASK_DISCIPLINE_COMPLETE = "### Task Complete \u2014 \u6838\u5B9E\u4E49\u52A1\uFF08**\u4EC5\u9A8C\u6536\u65B9\u9002\u7528**\uFF09\n\n> \u26A0\uFE0F **\u89D2\u8272\u4F5C\u7528\u57DF\uFF08Task #5007\uFF09**\uFF1A\u672C\u8282\u662F**\u9A8C\u6536\u65B9**\uFF08default agent / \u63A5\u5F85\u5458\uFF09\u7684\u52A8\u4F5C\u3002\n> \u82E5\u4F60\u662F**\u6267\u884C\u65B9**\uFF08roy sub-agent\uFF09\uFF0C\u4F60\u6CA1\u6709 `task_complete` \u6743\u9650 \u2014\u2014\n> \u4F60\u7684\u6536\u5C3E\u52A8\u4F5C\u662F\u300C\u8FDB\u5EA6\u63A8\u5230 100% + \u8BB0\u5B8C\u64CD\u4F5C\u8BB0\u5F55 + \u7ED3\u675F\u8FD4\u56DE\u300D\uFF0C\u9A8C\u6536\u7531\u4E3B\u667A\u80FD\u4F53\u8D1F\u8D23\u3002\n\nBefore calling `task_complete`, you MUST:\n\n1. Read the task's `goal` (description) and `delivery` (goals_and_expected_deliverables) fields.\n - Use `task_get(task_id=<id>)` to fetch the full task record.\n2. **Validate whether each goal sub-item was achieved** \u2014 accept the goal\n **item-by-item** (\u6309\u5B50\u9879\u9010\u6761\u9A8C\u6536).\n - Goals should be numbered sub-items (\u7F16\u53F7\u5B50\u9879). Check\n each sub-item against the operation-record chain (\u64CD\u4F5C\u8BB0\u5F55\u94FE) and the\n deliverable evidence (context.deliverable_storage_path).\n - The completion hook (task:after.complete) judges the whole goal vs.\n deliverables; numbered sub-items give it finer-grained evidence to\n reason with (\u9010\u6761\u5BF9\u7167\u7684\u8BC1\u636E\u7C92\u5EA6). If it detects that the goal or\n deliverables appear unmet, the task context will carry a\n `[TASK_COMPLETION_HINT]`.\n - **If you receive a [TASK_COMPLETION_HINT]**, you MUST verify it\n (\u6838\u5B9E\u4E49\u52A1): re-read the task via `task_get`, then do exactly one of:\n (a) \u786E\u8BA4\u672A\u5B8C\u6210 \u2192 **\u91CD\u65B0\u59D4\u6258**\uFF08\u7528\u4F60\u7684\u59D4\u6258\u5DE5\u5177 + \u540C\u4E00 sub-session \u7EED\u8DD1\uFF0C\n \u5728\u6307\u4EE4\u91CC\u5199\u660E\"\u76EE\u6807\u5C1A\u672A\u8FBE\u6210\uFF0C\u9700\u8981\u8865 X/Y/Z\"\uFF09\uFF0C\u7531 sub-agent \u7528\n `task_update(status=active)` \u91CD\u5F00\u5E76\u7EE7\u7EED\u63A8\u8FDB\uFF1B\u82E5\u4F60**\u81EA\u5DF1\u5C31\u662F\u6267\u884C\u65B9**\n \uFF08\u6709 `task_update` \u6743\u9650\uFF09\uFF0C\u5219\u76F4\u63A5 `task_update(status=todo)` \u91CD\u5F00\uFF1B\u6216\n (b) \u786E\u8BA4\u5DF2\u5B8C\u6210 \u2192 **\u7528\u4F60\u624B\u4E0A\u6709\u6743\u9650\u7684\u5199\u5DE5\u5177**\u843D\u4E00\u6761 `decision` \u7C7B\u64CD\u4F5C\u8BB0\u5F55\n \uFF08`task_operation_create`\uFF0Cmilestone_type=decision\uFF0Cmilestone_title=<\u4E00\u884C\u7ED3\u8BBA>\uFF09\n \u8BF4\u660E\u5B50\u9879\u5B9E\u9645\u5DF2\u8FBE\u6210\uFF08\u8BF4\u660E\u7406\u7531\uFF09\u3002\u82E5\u4F60\u6CA1\u6709\u8BE5\u5DE5\u5177\u7684\u6743\u9650\uFF08\u9A8C\u6536\u65B9\u573A\u666F\uFF09\uFF0C\n \u5C31\u901A\u8FC7\u4F60\u7684**\u59D4\u6258\u5DE5\u5177**\u8BA9 sub-agent \u4EE3\u5199\u8FD9\u6761\u8BB0\u5F55\uFF0C\u6216\u5728
|
|
36
|
+
export declare const TASK_DISCIPLINE_COMPLETE = "### Task Complete \u2014 \u6838\u5B9E\u4E49\u52A1\uFF08**\u4EC5\u9A8C\u6536\u65B9\u9002\u7528**\uFF09\n\n> \u26A0\uFE0F **\u89D2\u8272\u4F5C\u7528\u57DF\uFF08Task #5007\uFF09**\uFF1A\u672C\u8282\u662F**\u9A8C\u6536\u65B9**\uFF08default agent / \u63A5\u5F85\u5458\uFF09\u7684\u52A8\u4F5C\u3002\n> \u82E5\u4F60\u662F**\u6267\u884C\u65B9**\uFF08roy sub-agent\uFF09\uFF0C\u4F60\u6CA1\u6709 `task_complete` \u6743\u9650 \u2014\u2014\n> \u4F60\u7684\u6536\u5C3E\u52A8\u4F5C\u662F\u300C\u8FDB\u5EA6\u63A8\u5230 100% + \u8BB0\u5B8C\u64CD\u4F5C\u8BB0\u5F55 + \u7ED3\u675F\u8FD4\u56DE\u300D\uFF0C\u9A8C\u6536\u7531\u4E3B\u667A\u80FD\u4F53\u8D1F\u8D23\u3002\n\nBefore calling `task_complete`, you MUST:\n\n1. Read the task's `goal` (description) and `delivery` (goals_and_expected_deliverables) fields.\n - Use `task_get(task_id=<id>)` to fetch the full task record.\n2. **Validate whether each goal sub-item was achieved** \u2014 accept the goal\n **item-by-item** (\u6309\u5B50\u9879\u9010\u6761\u9A8C\u6536).\n - Goals should be numbered sub-items (\u7F16\u53F7\u5B50\u9879). Check\n each sub-item against the operation-record chain (\u64CD\u4F5C\u8BB0\u5F55\u94FE) and the\n deliverable evidence (context.deliverable_storage_path).\n - The completion hook (task:after.complete) judges the whole goal vs.\n deliverables; numbered sub-items give it finer-grained evidence to\n reason with (\u9010\u6761\u5BF9\u7167\u7684\u8BC1\u636E\u7C92\u5EA6). If it detects that the goal or\n deliverables appear unmet, the task context will carry a\n `[TASK_COMPLETION_HINT]`.\n - **If you receive a [TASK_COMPLETION_HINT]**, you MUST verify it\n (\u6838\u5B9E\u4E49\u52A1): re-read the task via `task_get`, then do exactly one of:\n (a) \u786E\u8BA4\u672A\u5B8C\u6210 \u2192 **\u91CD\u65B0\u59D4\u6258**\uFF08\u7528\u4F60\u7684\u59D4\u6258\u5DE5\u5177 + \u540C\u4E00 sub-session \u7EED\u8DD1\uFF0C\n \u5728\u6307\u4EE4\u91CC\u5199\u660E\"\u76EE\u6807\u5C1A\u672A\u8FBE\u6210\uFF0C\u9700\u8981\u8865 X/Y/Z\"\uFF09\uFF0C\u7531 sub-agent \u7528\n `task_update(status=active)` \u91CD\u5F00\u5E76\u7EE7\u7EED\u63A8\u8FDB\uFF1B\u82E5\u4F60**\u81EA\u5DF1\u5C31\u662F\u6267\u884C\u65B9**\n \uFF08\u6709 `task_update` \u6743\u9650\uFF09\uFF0C\u5219\u76F4\u63A5 `task_update(status=todo)` \u91CD\u5F00\uFF1B\u6216\n (b) \u786E\u8BA4\u5DF2\u5B8C\u6210 \u2192 **\u7528\u4F60\u624B\u4E0A\u6709\u6743\u9650\u7684\u5199\u5DE5\u5177**\u843D\u4E00\u6761 `decision` \u7C7B\u64CD\u4F5C\u8BB0\u5F55\n \uFF08`task_operation_create`\uFF0Cmilestone_type=decision\uFF0Cmilestone_title=<\u4E00\u884C\u7ED3\u8BBA>\uFF09\n \u8BF4\u660E\u5B50\u9879\u5B9E\u9645\u5DF2\u8FBE\u6210\uFF08\u8BF4\u660E\u7406\u7531\uFF09\u3002\u82E5\u4F60\u6CA1\u6709\u8BE5\u5DE5\u5177\u7684\u6743\u9650\uFF08\u9A8C\u6536\u65B9\u573A\u666F\uFF09\uFF0C\n \u5C31\u901A\u8FC7\u4F60\u7684**\u59D4\u6258\u5DE5\u5177**\u8BA9 sub-agent \u4EE3\u5199\u8FD9\u6761\u8BB0\u5F55\uFF0C\u6216\u5728\u6700\u7EC8\u6C47\u62A5\u91CC\n \u660E\u786E\u5199\u51FA\u6838\u5B9E\u7ED3\u8BBA\u4E0E\u8BC1\u636E\u3002\n Never ignore it (\u4E0D\u5141\u8BB8\u65E0\u89C6).\n \u26A0\uFE0F **\u6838\u5B9E\u4E49\u52A1\u7684\u4E24\u6761\u8DEF\u5F84\u90FD\u4F9D\u8D56\u5199\u6743\u9650**\uFF08`task_update` / `task_operation_create`\uFF09\u3002\n \u82E5\u8FD9\u4E9B\u5DE5\u5177\u5BF9\u4F60**\u4E0D\u53EF\u7528**\uFF08\u5982\u9A8C\u6536\u65B9\u4E0D\u6301\u6709\u6267\u884C\u7C7B\u5DE5\u5177\uFF09\uFF0C\u5FC5\u987B**\u6539\u7528\u59D4\u6258**\u628A\u52A8\u4F5C\n \u4EA4\u56DE\u7ED9\u6709\u6743\u9650\u7684 sub-agent \u6267\u884C \u2014\u2014 \u4E0D\u8981\u8BD5\u56FE\u8C03\u7528\u4E0D\u53EF\u7528\u7684\u5DE5\u5177\uFF08\u4F1A\u88AB\u62E6\u6389\u5E76\u6D6A\u8D39\u4E00\u8F6E\u8FED\u4EE3\uFF09\u3002\n - If the goal and delivery mismatch **without** a hint, either:\n (a) extend the task via `task_update`, or\n (b) record the discrepancy via `task_operation_create`\n (milestone_type=decision) \u2014 the reason **must** land in the\n operation record (\u5FC5\u987B\u843D\u5230\u64CD\u4F5C\u8BB0\u5F55\u91CC), not merely a line in\n your final report (\u4E0D\u80FD\u53EA\u5728\u62A5\u544A\u91CC\u5E26\u4E00\u53E5).\n3. Deliverables were submitted by the executor via `task_pre_complete`\n (Task #5073 two-phase acceptance): they live in\n `context.deliverable_storage_path` and the operation trail\n (`Deliverable: <path>` lines). Cross-check them in step 2.\n `task_complete` takes **no** deliverable parameter \u2014 if the\n deliverables are missing from the record, re-delegate instead of\n asking for a path here.";
|
|
37
37
|
/** 完整纪律正文(主出口):4 分片拼装 */
|
|
38
38
|
export declare const TASK_DISCIPLINE_PROMPT: string;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import"../../../shared/@ai-setting/roy-agent-core-
|
|
1
|
+
import"../../../shared/@ai-setting/roy-agent-core-q813vafd.js";
|
|
2
2
|
import {
|
|
3
3
|
SQLiteTaskStore,
|
|
4
4
|
getDefaultDataDir,
|
|
5
5
|
getDefaultTaskDbPath
|
|
6
|
-
} from "../../../shared/@ai-setting/roy-agent-core-
|
|
6
|
+
} from "../../../shared/@ai-setting/roy-agent-core-ezvpreqz.js";
|
|
7
7
|
import"../../../shared/@ai-setting/roy-agent-core-qq96p0tj.js";
|
|
8
8
|
import"../../../shared/@ai-setting/roy-agent-core-7f7t9wwp.js";
|
|
9
9
|
import"../../../shared/@ai-setting/roy-agent-core-85xyctnb.js";
|
|
@@ -71,6 +71,13 @@ export interface TaskStore {
|
|
|
71
71
|
* 确定性映射:sub-agent 的 task_create 用 sessionId=sub-session id)。
|
|
72
72
|
*/
|
|
73
73
|
getTaskIdBySessionId(sessionId: string): Promise<number | undefined>;
|
|
74
|
+
/**
|
|
75
|
+
* Task #5081(optional)— 按 session_id 反查该 session 关联的**全部**
|
|
76
|
+
* task id(不限定 create 记录)。TaskOpWatermarkPlugin 对全部 task
|
|
77
|
+
* 求并集水位。optional:外部宿主实现可不提供(调用方降级到
|
|
78
|
+
* getTaskIdBySessionId 单值)。
|
|
79
|
+
*/
|
|
80
|
+
getTaskIdsBySessionId?(sessionId: string): Promise<number[]>;
|
|
74
81
|
createOperation(options: CreateOperationOptions): Promise<TaskOperation>;
|
|
75
82
|
getOperation(id: number): Promise<TaskOperation | undefined>;
|
|
76
83
|
updateOperation(id: number, updates: {
|
|
@@ -82,6 +89,22 @@ export interface TaskStore {
|
|
|
82
89
|
}): Promise<TaskOperation | undefined>;
|
|
83
90
|
deleteOperation(id: number): Promise<boolean>;
|
|
84
91
|
listOperations(options: ListOperationsOptions): Promise<TaskOperation[]>;
|
|
92
|
+
/**
|
|
93
|
+
* Task #5081(optional)— 绕过 operationsCache 的直读查询。
|
|
94
|
+
*
|
|
95
|
+
* 跨进程写入的 operation 不会失效本进程缓存 → `listOperations`
|
|
96
|
+
* 可能读陈旧快照。本方法**直打 DB**(`ORDER BY id DESC`,不读写
|
|
97
|
+
* 缓存),供 TaskOpWatermarkPlugin 的水位检查使用。
|
|
98
|
+
*
|
|
99
|
+
* optional:不破坏外部宿主实现的 TaskStore 契约(能力探测 +
|
|
100
|
+
* 降级路径见 plugin 侧)。
|
|
101
|
+
*/
|
|
102
|
+
listOperationsFresh?(options: ListOperationsOptions): Promise<TaskOperation[]>;
|
|
103
|
+
/**
|
|
104
|
+
* Task #5081(optional)— 主动失效 operationsCache。
|
|
105
|
+
* 降级路径配套:`listOperations` 前调用,保证读到最新。
|
|
106
|
+
*/
|
|
107
|
+
invalidateOperationsCache?(taskId: number): void;
|
|
85
108
|
createTag(name: string): Promise<TaskTag>;
|
|
86
109
|
getTag(id: number): Promise<TaskTag | undefined>;
|
|
87
110
|
getTagByName(name: string): Promise<TaskTag | undefined>;
|
|
@@ -186,6 +209,28 @@ export declare class SQLiteTaskStore implements TaskStore {
|
|
|
186
209
|
}): Promise<TaskOperation | undefined>;
|
|
187
210
|
deleteOperation(id: number): Promise<boolean>;
|
|
188
211
|
listOperations(options: ListOperationsOptions): Promise<TaskOperation[]>;
|
|
212
|
+
/**
|
|
213
|
+
* Task #5081 — 绕过 operationsCache 的直读查询(optional 能力)。
|
|
214
|
+
*
|
|
215
|
+
* 为什么必须有:operationsCache 只在本进程 create/update/delete 时
|
|
216
|
+
* 失效(:744/:785/:800),**跨进程写入的 operation 不会失效本进程
|
|
217
|
+
* 缓存** —— CLI 探针 / 另一 daemon 进程写的记录,本进程的
|
|
218
|
+
* `listOperations` 永远看不到(读陈旧快照)→ TaskOpWatermarkPlugin
|
|
219
|
+
* 的水位检查会漏报。
|
|
220
|
+
*
|
|
221
|
+
* 要点:
|
|
222
|
+
* - `ORDER BY id DESC`:水位语义要求**单调自增 id**(timestamp 同
|
|
223
|
+
* 毫秒多条会漏),id 是 AUTOINCREMENT 严格单调。
|
|
224
|
+
* - **只读,不写 operationsCache**:不污染其它调用方的缓存语义。
|
|
225
|
+
*/
|
|
226
|
+
listOperationsFresh(options: ListOperationsOptions): Promise<TaskOperation[]>;
|
|
227
|
+
/**
|
|
228
|
+
* Task #5081 — 主动失效 operationsCache(optional 能力)。
|
|
229
|
+
*
|
|
230
|
+
* 供不支持 `listOperationsFresh` 的外部宿主 backend 走降级路径:
|
|
231
|
+
* `listOperations` 之前先失效缓存,保证下次读到最新。
|
|
232
|
+
*/
|
|
233
|
+
invalidateOperationsCache(taskId: number): void;
|
|
189
234
|
/**
|
|
190
235
|
* 按 session_id 反查该 session 创建的第一个 task。
|
|
191
236
|
*
|
|
@@ -195,6 +240,15 @@ export declare class SQLiteTaskStore implements TaskStore {
|
|
|
195
240
|
* 不依赖易失的 EnvContext.currentTaskId(会被 task_complete 清空)或结果文本正则。
|
|
196
241
|
*/
|
|
197
242
|
getTaskIdBySessionId(sessionId: string): Promise<number | undefined>;
|
|
243
|
+
/**
|
|
244
|
+
* Task #5081 — 按 session_id 反查该 session 关联的**全部** task id
|
|
245
|
+
* (optional 能力,TaskStore 接口同款 optional)。
|
|
246
|
+
*
|
|
247
|
+
* 与 getTaskIdBySessionId 的区别:不限定 milestone_type='create'、
|
|
248
|
+
* 不 LIMIT 1 —— sub-session 往同一 task 写过任何 operation 记录
|
|
249
|
+
* (记进度 / milestone / pre_complete 留痕)都算关联。
|
|
250
|
+
*/
|
|
251
|
+
getTaskIdsBySessionId(sessionId: string): Promise<number[]>;
|
|
198
252
|
private rowToTask;
|
|
199
253
|
/**
|
|
200
254
|
* 安全解析 tags 字段。
|