@ai-setting/roy-agent-core 1.7.65 → 1.7.67
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.d.ts +56 -3
- package/dist/env/agent/agent-component.js +2 -2
- package/dist/env/agent/index.js +2 -2
- package/dist/env/agent/types.d.ts +28 -0
- package/dist/env/environment.d.ts +13 -0
- package/dist/env/event-source/command-card-action.d.ts +105 -0
- package/dist/env/event-source/command-cards.d.ts +72 -0
- package/dist/env/event-source/command-registry.d.ts +181 -0
- package/dist/env/event-source/command-types.d.ts +8 -0
- package/dist/env/event-source/event-source-handlers.d.ts +66 -0
- package/dist/env/event-source/event-source-handlers.js +7 -4
- package/dist/env/event-source/fallback-model-command.d.ts +80 -0
- package/dist/env/event-source/index.d.ts +7 -0
- package/dist/env/event-source/index.js +48 -7
- package/dist/env/event-source/timer-handler.d.ts +93 -1
- package/dist/env/index.js +15 -14
- package/dist/env/llm/index.js +1 -1
- package/dist/env/prompt/index.js +3 -2
- package/dist/env/prompt/prompts-index.d.ts +3 -8
- package/dist/env/task/delegate/delegate-tool.d.ts +58 -2
- package/dist/env/task/delegate/delegate-tool.js +5 -2
- package/dist/env/task/delegate/index.js +3 -2
- package/dist/env/task/index.js +9 -8
- package/dist/env/task/mcp/index.js +3 -2
- package/dist/env/task/plugins/__e2e__/laya-completion-e2e.d.ts +16 -0
- package/dist/env/task/plugins/index.js +4 -3
- package/dist/env/task/plugins/laya-completion-plugin.d.ts +133 -0
- package/dist/env/task/plugins/laya-port.d.ts +23 -0
- package/dist/env/task/storage/index.js +2 -2
- package/dist/env/task/storage/migrations/003_add_process_description.d.ts +1 -1
- package/dist/env/task/storage/migrations/log-migration.d.ts +49 -3
- package/dist/env/task/task-component.d.ts +43 -0
- package/dist/env/task/tools/completion-copy.d.ts +27 -0
- package/dist/env/task/tools/index.js +2 -1
- package/dist/env/task/tools/operation/create-tool.d.ts +1 -1
- package/dist/env/task/tools/operation/index.js +1 -1
- package/dist/env/task/tools/operation/operation-types.d.ts +10 -8
- package/dist/env/task/types.d.ts +3 -3
- package/dist/env/tool/built-in/index.js +2 -2
- package/dist/env/tool/built-in/query-background-process-tool.d.ts +10 -0
- package/dist/env/tool/index.js +3 -3
- package/dist/env/tool/types.d.ts +6 -0
- package/dist/index.js +60 -19
- package/dist/shared/@ai-setting/{roy-agent-core-rjzdj0xb.js → roy-agent-core-02j24hrg.js} +2 -0
- package/dist/shared/@ai-setting/{roy-agent-core-hmdcz3g9.js → roy-agent-core-1k83dq3a.js} +16 -6
- package/dist/shared/@ai-setting/{roy-agent-core-e42v9bcq.js → roy-agent-core-1kxf910n.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-amkqnyzy.js → roy-agent-core-58804s3j.js} +10 -0
- package/dist/shared/@ai-setting/roy-agent-core-6m4bw8jy.js +6 -0
- package/dist/shared/@ai-setting/roy-agent-core-8zas6w5q.js +1083 -0
- package/dist/shared/@ai-setting/{roy-agent-core-9bs6xrav.js → roy-agent-core-abqhkbn3.js} +6 -3
- package/dist/shared/@ai-setting/{roy-agent-core-f6c0nadn.js → roy-agent-core-b7jbqfsy.js} +25 -11
- package/dist/shared/@ai-setting/{roy-agent-core-hjejpcg5.js → roy-agent-core-dnjm17sa.js} +51 -9
- package/dist/shared/@ai-setting/{roy-agent-core-t0ktaevq.js → roy-agent-core-h5vmff8w.js} +60 -4
- package/dist/shared/@ai-setting/{roy-agent-core-xhrrgfdy.js → roy-agent-core-hfr6bzts.js} +168 -52
- package/dist/shared/@ai-setting/{roy-agent-core-18am1h07.js → roy-agent-core-k4ps1hxp.js} +1085 -46
- package/dist/shared/@ai-setting/{roy-agent-core-jz8dsypm.js → roy-agent-core-kpg25s2q.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-6masakz4.js → roy-agent-core-ma35jyd9.js} +19 -8
- package/dist/shared/@ai-setting/{roy-agent-core-gxzxq1sf.js → roy-agent-core-ntq0gz7q.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-rn57psp0.js → roy-agent-core-p5cz9m8v.js} +3 -3
- package/dist/shared/@ai-setting/{roy-agent-core-w07ymg29.js → roy-agent-core-wksgtqf9.js} +1 -1
- package/package.json +1 -1
- package/dist/shared/@ai-setting/roy-agent-core-6z412atw.js +0 -654
- /package/dist/shared/@ai-setting/{roy-agent-core-5enxfga2.js → roy-agent-core-b4x6x4k2.js} +0 -0
- /package/dist/shared/@ai-setting/{roy-agent-core-es467wsz.js → roy-agent-core-dt104qa1.js} +0 -0
|
@@ -13,12 +13,13 @@ import {
|
|
|
13
13
|
formatExtractorInput,
|
|
14
14
|
formatExtractorInputFromDescription,
|
|
15
15
|
parseExtractorOutput
|
|
16
|
-
} from "../../../shared/@ai-setting/roy-agent-core-
|
|
16
|
+
} from "../../../shared/@ai-setting/roy-agent-core-b7jbqfsy.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-abqhkbn3.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-ma35jyd9.js";
|
|
21
21
|
import"../../../shared/@ai-setting/roy-agent-core-tr3ep81v.js";
|
|
22
|
+
import"../../../shared/@ai-setting/roy-agent-core-6m4bw8jy.js";
|
|
22
23
|
import {
|
|
23
24
|
DEFAULT_APP_LINK_BASE,
|
|
24
25
|
LarkCardPatchNotifier,
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Task #4760 — task completion hook 的 Laya decision 判定
|
|
3
|
+
*
|
|
4
|
+
* 与 create 侧(`laya-decision-plugin.ts`,#4620)的关系:
|
|
5
|
+
* - create 侧挂在 `task:before.create`,判「新建 vs 复用」
|
|
6
|
+
* - 本插件挂在 `task:after.complete`(AFTER_COMPLETE),判
|
|
7
|
+
* 「目标 vs 交付物 match / 目标是否达成 / 交付物是否产出」
|
|
8
|
+
*
|
|
9
|
+
* 形态:**只提示,不拦截**(与 create 侧契约一致)。
|
|
10
|
+
* AFTER_COMPLETE 触发时任务**已经**是 completed —— hint 只能
|
|
11
|
+
* ① 追加写进 `task.context.completion_hint`(走 updateTask)
|
|
12
|
+
* ② 落一条 operation 记录
|
|
13
|
+
* 绝不能阻断已完成状态、绝不能抛错。
|
|
14
|
+
*
|
|
15
|
+
* ── fail-open 六场景(对齐 create 侧 #4620) ─────────────────────
|
|
16
|
+
* 1. 未配置 provider(auth.json 缺失 / 无 laya-goal-decision)→ 不调模型
|
|
17
|
+
* 2. auth 损坏 / port 抛错(网络、超时)→ 静默
|
|
18
|
+
* 3. 响应畸形(无 answers / 无 answer)→ 静默
|
|
19
|
+
* 4. 置信度 < 0.92 → 不写 hint
|
|
20
|
+
* 5. operation chain 空 → 不调模型
|
|
21
|
+
* 6. choice 无法识别 → 静默
|
|
22
|
+
*
|
|
23
|
+
* ── provider 分离(Task #4804) ────────────────────────────────
|
|
24
|
+
* completion hook 读 `providers["laya-goal-decision"]`
|
|
25
|
+
* (model=task-completion / v13e ckpt,判「目标 vs 交付物」);
|
|
26
|
+
* create hook 继续读 `providers["laya-decision"]`
|
|
27
|
+
* (model=task-decision / v3-tags,判「新建 vs 复用」)。
|
|
28
|
+
* goal 专用 provider 缺失时保守回退 laya-decision(fail-open 不变)。
|
|
29
|
+
*
|
|
30
|
+
* ── 泄漏断言 ─────────────────────────────────────────────────────
|
|
31
|
+
* deny-list 含 decision/hint/target/answer 等键名 →
|
|
32
|
+
* question key 必须命名 `completion_check`、criteria 用
|
|
33
|
+
* `PASS_COMPLETED/FAIL_INCOMPLETE`(已验证不命中);
|
|
34
|
+
* state 用中文文本形态(【】段)则天然无对象键。
|
|
35
|
+
*
|
|
36
|
+
* ── 时序关键(勘查结论) ─────────────────────────────────────────
|
|
37
|
+
* AFTER_COMPLETE 触发时 `completed` operation 尚未写入
|
|
38
|
+
* (completeTask 在 hook 之后才 createOperation)。
|
|
39
|
+
* 因此 operation chain 里看到的是「完成前的历史记录」——
|
|
40
|
+
* 这正是判定所需的证据链,无需等 completed 记录。
|
|
41
|
+
*/
|
|
42
|
+
import type { DecisionPort } from "./decision-port";
|
|
43
|
+
import type { TaskCompleteResultContext } from "../hooks/contexts";
|
|
44
|
+
import type { Task, TaskOperation } from "../types";
|
|
45
|
+
/** 完成判定的置信度门禁(对齐 create 侧 LAYA_REUSE_THRESHOLD = 0.92) */
|
|
46
|
+
export declare const LAYA_COMPLETION_THRESHOLD = 0.92;
|
|
47
|
+
/**
|
|
48
|
+
* 构造完成核验 hint。
|
|
49
|
+
*
|
|
50
|
+
* 核实义务 + 二选一:(a) 确认未完成 → 重开继续推进;
|
|
51
|
+
* (b) 确认已完成 → 落 operation 说明理由。不允许无视。
|
|
52
|
+
*/
|
|
53
|
+
export declare function buildCompletionHint(task: Task, confidence: number): string;
|
|
54
|
+
/**
|
|
55
|
+
* 渲染 laya 训练格式的中文文本 state。
|
|
56
|
+
*
|
|
57
|
+
* ⚠️ 用【】段而非 JSON 对象 —— laya 模型在中文文本形态上训练;
|
|
58
|
+
* 且文本形态天然没有对象键,不会命中泄漏断言的 deny-list。
|
|
59
|
+
*
|
|
60
|
+
* Task #4804 — goals 为编号子项且交付物声明可比对时,插入
|
|
61
|
+
* 【逐条对照】段(见 renderCriteriaChecklist 注释)。
|
|
62
|
+
*/
|
|
63
|
+
export declare function renderCompletionState(task: Task, ops: TaskOperation[]): string;
|
|
64
|
+
/** 渲染 completion_check 二选一 question(key 不命中泄漏 deny-list) */
|
|
65
|
+
export declare function buildCompletionQuestion(): Record<string, unknown>;
|
|
66
|
+
export interface LayaCompletionPluginOptions {
|
|
67
|
+
/** auth.json 路径(默认 ~/.roy-agent/auth.json) */
|
|
68
|
+
authPath?: string;
|
|
69
|
+
/** 硬超时(默认 2000ms) */
|
|
70
|
+
timeoutMs?: number;
|
|
71
|
+
/** 连续超时多少次后自我禁用(默认 3) */
|
|
72
|
+
maxStrikes?: number;
|
|
73
|
+
/** 注入 port(测试用;给了就不读 auth.json) */
|
|
74
|
+
decisionPort?: DecisionPort;
|
|
75
|
+
/** 完成判定的置信度门禁(默认 0.92) */
|
|
76
|
+
completionThreshold?: number;
|
|
77
|
+
}
|
|
78
|
+
export declare class LayaCompletionPlugin {
|
|
79
|
+
readonly name = "laya-completion";
|
|
80
|
+
readonly version = "1.0.0";
|
|
81
|
+
readonly description = "Task #4760 \u2014 task:after.complete \u5B8C\u6210\u5224\u5B9A\uFF08\u76EE\u6807/\u4EA4\u4ED8\u7269 match\uFF0C\u53EA\u63D0\u793A\u4E0D\u62E6\u622A\uFF09";
|
|
82
|
+
private readonly options;
|
|
83
|
+
private port;
|
|
84
|
+
private portResolved;
|
|
85
|
+
constructor(options?: LayaCompletionPluginOptions);
|
|
86
|
+
/** 当前是否已自我禁用(熔断)—— 供观测 */
|
|
87
|
+
isDisabled(): boolean;
|
|
88
|
+
/** 懒加载 + 缓存 port(读 auth.json 只做一次) */
|
|
89
|
+
private resolvePort;
|
|
90
|
+
/**
|
|
91
|
+
* hook 入口 —— **永不抛**。
|
|
92
|
+
*
|
|
93
|
+
* @param ctx TaskCompleteResultContext(或框架 HookContext,载荷在 .data)
|
|
94
|
+
* @param taskComponent TaskComponent(只读用:listOperations / getTask;
|
|
95
|
+
* 写 hint 用 updateTask + createOperation)
|
|
96
|
+
*/
|
|
97
|
+
execute(ctx: TaskCompleteResultContext | {
|
|
98
|
+
data: TaskCompleteResultContext;
|
|
99
|
+
}, taskComponent: any): Promise<void>;
|
|
100
|
+
private run;
|
|
101
|
+
/** hint 回写:追加 context.completion_hint + 落 operation 记录(都不阻断) */
|
|
102
|
+
private writeHint;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Task #4760 — 把 LayaCompletionPlugin 包成可注册到 task hook 的形态。
|
|
106
|
+
*
|
|
107
|
+
* 注册方式仿 `registerLayaDecisionTaskHook`(environment.ts:87):
|
|
108
|
+
* - unregister + register 幂等(globalHookManager.register 是 push)
|
|
109
|
+
* - fail-open:注册失败绝不影响 agent 启动
|
|
110
|
+
* - hook-manager `safeExecute` 自带异常隔离(hook 抛错只记日志)
|
|
111
|
+
*/
|
|
112
|
+
export declare function createLayaCompletionPlugin(options?: LayaCompletionPluginOptions): {
|
|
113
|
+
/** Hook 唯一名称(用于幂等去重 / unregister) */
|
|
114
|
+
name: string;
|
|
115
|
+
/** 执行优先级 */
|
|
116
|
+
priority: number;
|
|
117
|
+
/** hook 执行体 —— 永不抛 */
|
|
118
|
+
execute: (ctx: unknown) => Promise<void>;
|
|
119
|
+
/** 内层插件实例(供观测 / 测试) */
|
|
120
|
+
plugin: LayaCompletionPlugin;
|
|
121
|
+
};
|
|
122
|
+
/**
|
|
123
|
+
* 把 LayaCompletionPlugin 注册到 `task:after.complete`(AFTER_COMPLETE)。
|
|
124
|
+
*
|
|
125
|
+
* ⚠️ 幂等:先 unregister 再 register,保证全局恰好 1 份。
|
|
126
|
+
* ⚠️ fail-open:注册失败返回 false,不影响调用方。
|
|
127
|
+
*
|
|
128
|
+
* @param taskComponent TaskComponent(由 this.getComponent("task") 取得)
|
|
129
|
+
* @param options LayaCompletionPluginOptions(生产不传 → 读 auth.json;
|
|
130
|
+
* 测试可注入 decisionPort)
|
|
131
|
+
* @returns 是否成功注册
|
|
132
|
+
*/
|
|
133
|
+
export declare function registerLayaCompletionTaskHook(taskComponent: any | undefined | null, options?: LayaCompletionPluginOptions): boolean;
|
|
@@ -131,6 +131,17 @@ export interface LayaAuthConfig {
|
|
|
131
131
|
apiKey: string;
|
|
132
132
|
model: string;
|
|
133
133
|
}
|
|
134
|
+
/**
|
|
135
|
+
* Task #4804 — provider 名常量(provider 分离):
|
|
136
|
+
* - create hook(task:before.create,判新建 vs 复用)→ laya-decision
|
|
137
|
+
* - completion hook(task:after.complete,判目标 vs 交付物)→ laya-goal-decision
|
|
138
|
+
* (缺失时保守回退 laya-decision —— fail-open 语义不变)
|
|
139
|
+
*/
|
|
140
|
+
export declare const LAYA_DECISION_PROVIDER = "laya-decision";
|
|
141
|
+
export declare const LAYA_GOAL_DECISION_PROVIDER = "laya-goal-decision";
|
|
142
|
+
/** hook 用途 → provider 名(Task #4804 provider 分离的唯一映射点) */
|
|
143
|
+
export type LayaHookPurpose = "create" | "goal";
|
|
144
|
+
export declare function providerNameForPurpose(purpose: LayaHookPurpose): string;
|
|
134
145
|
/**
|
|
135
146
|
* 从 `~/.roy-agent/auth.json` 的 `providers["laya-decision"]` 读取端点配置。
|
|
136
147
|
*
|
|
@@ -139,5 +150,17 @@ export interface LayaAuthConfig {
|
|
|
139
150
|
* → providers["laya-decision"].model(可选)
|
|
140
151
|
*
|
|
141
152
|
* ⚠️ 读不到就返回 null —— 调用方必须 fail-open(不提示、不报错)。
|
|
153
|
+
*
|
|
154
|
+
* Task #4804 — 向后兼容:默认仍读 laya-decision(create hook 语义)。
|
|
155
|
+
* completion hook 侧请用 `loadLayaAuthForPurpose(path, "goal")`。
|
|
142
156
|
*/
|
|
143
157
|
export declare function loadLayaAuth(authPath?: string): Promise<LayaAuthConfig | null>;
|
|
158
|
+
/**
|
|
159
|
+
* Task #4804 — 按用途读 provider:
|
|
160
|
+
* - "create" → providers["laya-decision"]
|
|
161
|
+
* - "goal" → providers["laya-goal-decision"],缺失时保守回退
|
|
162
|
+
* providers["laya-decision"](共享共享配置,fail-open 不变)
|
|
163
|
+
*
|
|
164
|
+
* ⚠️ 读不到就返回 null —— 调用方必须 fail-open(不提示、不报错)。
|
|
165
|
+
*/
|
|
166
|
+
export declare function loadLayaAuthForPurpose(authPath?: string, purpose?: LayaHookPurpose): Promise<LayaAuthConfig | null>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import"../../../shared/@ai-setting/roy-agent-core-
|
|
1
|
+
import"../../../shared/@ai-setting/roy-agent-core-ntq0gz7q.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-abqhkbn3.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";
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Description: Add process_description column to task_operation table.
|
|
6
6
|
* 用于记录达成节点状态所采用的策略 + 工具步骤的过程概要,
|
|
7
7
|
* 区别于 action_description(状态/结果描述)。
|
|
8
|
-
* 字符范围 100-
|
|
8
|
+
* 字符范围 100-500(Task #4764 放宽;应用层 schema 校验,本字段不做 DB 长度约束)。
|
|
9
9
|
* Date: 2026-07-20
|
|
10
10
|
*/
|
|
11
11
|
/**
|
|
@@ -12,8 +12,54 @@
|
|
|
12
12
|
* Measured: the plugin's MCP server emitted **24 of 26 stdout lines** that
|
|
13
13
|
* were not JSON — 5 migration banners plus core's `[INFO]` trace lines.
|
|
14
14
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
15
|
+
* ## Task #4721 — 为什么不写 stderr(而是走 logger)
|
|
16
|
+
*
|
|
17
|
+
* #4619 把 stdout 换成 stderr,问题在 **TUI 场景**(`roy-agent interactive`)
|
|
18
|
+
* 暴露了:stderr **同样**是终端输出,而 opentui 只拦截 stdout
|
|
19
|
+
* (`@opentui/core` 的 `interceptStdoutWrite`),stderr 完全不捕获 ⇒ 迁移
|
|
20
|
+
* 日志直接落到终端当前光标位置。
|
|
21
|
+
*
|
|
22
|
+
* `roy-agent interactive` 是 split-footer 模式 ⇒ 当前光标在**动态区**里 ⇒
|
|
23
|
+
* 日志与 TUI 重绘**逐字符交错** ⇒ 用户看到底部乱流(截图实证):
|
|
24
|
+
*
|
|
25
|
+
* ```
|
|
26
|
+
* └ig-ati-n 003─ -tarting mig-ati─
|
|
27
|
+
* ⋮ Generating response…e_type already exists, skipping rename of action_type
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* ⇒ **正确做法:走 logger**(core 的统一日志通路):
|
|
31
|
+
* - 永远写日志文件(app.log)⇒ 诊断信息不丢
|
|
32
|
+
* - console 输出受 `isQuietMode()` / `isStdoutStrictMode()` 控制
|
|
33
|
+
* —— TUI 场景 quiet 模式开启 ⇒ 不写终端;MCP 场景 stdout 严格模式
|
|
34
|
+
* ⇒ 走 stderr(诊断通道,符合 MCP 惯例)
|
|
35
|
+
* - **stdout 永远纯净**(MCP JSON-RPC 协议不被破坏)
|
|
36
|
+
*/
|
|
37
|
+
/**
|
|
38
|
+
* Print one migration diagnostic.
|
|
39
|
+
*
|
|
40
|
+
* ⚠️ **不要**改回 `process.stderr.write` / `console.log`:
|
|
41
|
+
* - `console.log` 会破坏 MCP stdio 的 JSON-RPC 协议(#4619)
|
|
42
|
+
* - `process.stderr.write` 会撞 TUI 的动态区(#4721 底部乱流)
|
|
43
|
+
*
|
|
44
|
+
* 走 logger:写文件 + 受 quiet/stdout-strict 模式控制的 console 输出。
|
|
45
|
+
*
|
|
46
|
+
* ## Task #4721(交叉验证 MAJOR-3):为什么用 `warn` 而不是 `info`
|
|
47
|
+
*
|
|
48
|
+
* core 的 `Logger.log()` 在**非 quiet**模式下会把日志打到 console:
|
|
49
|
+
*
|
|
50
|
+
* ```ts
|
|
51
|
+
* if (!isQuietMode()) {
|
|
52
|
+
* if (stdoutStrictMode) { console.error(formatted); } // ← stderr
|
|
53
|
+
* else { consoleMethod(formatted); } // ← **stdout**(info/warn)
|
|
54
|
+
* }
|
|
55
|
+
* ```
|
|
56
|
+
*
|
|
57
|
+
* ⚠️ `setStdoutStrictMode(true)` 在**生产路径从未被调用**(只��测试里调)⇒
|
|
58
|
+
* MCP 场景下 `stdoutStrictMode` 恒为 false ⇒ **`info` 级日志会打到 stdout**
|
|
59
|
+
* ⇒ **破坏 MCP 的 JSON-RPC 协议**(#4619 的问题被重新引入)。
|
|
60
|
+
*
|
|
61
|
+
* ⇒ 用 `warn` 级:非 strict 模式下走 `console.warn`(Bun 的 `console.warn`
|
|
62
|
+
* 写 **stderr**,不会污染 stdout)⇒ stdout 永远纯净 ✔
|
|
63
|
+
* 而 strict 模式下走 `console.error`(stderr)⇒ 同样是诊断通道 ✔
|
|
17
64
|
*/
|
|
18
|
-
/** Print one migration diagnostic to stderr (never stdout). */
|
|
19
65
|
export declare function logMigration(message: string): void;
|
|
@@ -41,6 +41,21 @@ export interface TaskComponentOptions {
|
|
|
41
41
|
envPrefix?: string;
|
|
42
42
|
/** 直接传入的配置对象(可选,优先级最高) */
|
|
43
43
|
config?: Partial<TaskConfig>;
|
|
44
|
+
/**
|
|
45
|
+
* Task #4794 — 组件 stop() 时 BackgroundTaskManager.dispose() 的收尾行为。
|
|
46
|
+
*
|
|
47
|
+
* CLI `act` 一次性命令收尾时传 true(主 run 已结束,后台子 agent
|
|
48
|
+
* 是有意留下继续跑的);REPL / ESC cascade 等用户主动退出场景
|
|
49
|
+
* 保持默认 false(abort 全部,语义不变)。
|
|
50
|
+
*/
|
|
51
|
+
skipAbortRunningTasksOnDispose?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Task #4794 — 与 skipAbortRunningTasksOnDispose 配套:
|
|
54
|
+
* stop() 时等待运行中的后台任务完成后再返回。
|
|
55
|
+
* 子 agent 是同进程异步 run,进程 exit 会直接杀死它们,
|
|
56
|
+
* 所以 act 收尾必须等待。默认 false。
|
|
57
|
+
*/
|
|
58
|
+
waitForRunningTasksOnDispose?: boolean;
|
|
44
59
|
}
|
|
45
60
|
export declare class TaskComponent extends BaseComponent {
|
|
46
61
|
name: string;
|
|
@@ -49,6 +64,17 @@ export declare class TaskComponent extends BaseComponent {
|
|
|
49
64
|
private config?;
|
|
50
65
|
private toolComponent?;
|
|
51
66
|
private backgroundTaskManager?;
|
|
67
|
+
/**
|
|
68
|
+
* Task #4794 — stop() 时是否跳过 abort 仍在运行的后台任务
|
|
69
|
+
* (act 一次性命令收尾 = true;用户主动退出 = false 默认)。
|
|
70
|
+
*/
|
|
71
|
+
private skipAbortRunningTasksOnDispose;
|
|
72
|
+
/**
|
|
73
|
+
* Task #4794 — stop() 时是否等待运行中任务完成
|
|
74
|
+
* (act 收尾配套:跳过 abort 后必须等子 agent 跑完,
|
|
75
|
+
* 否则 process.exit 仍会杀死同进程子 agent)。
|
|
76
|
+
*/
|
|
77
|
+
private waitForRunningTasksOnDispose;
|
|
52
78
|
private configComponent?;
|
|
53
79
|
private tagService;
|
|
54
80
|
private plugins;
|
|
@@ -235,6 +261,23 @@ export declare class TaskComponent extends BaseComponent {
|
|
|
235
261
|
* @returns 更新后的 Task 或 undefined
|
|
236
262
|
*/
|
|
237
263
|
completeTask(id: number, sessionId: string, deliverableStoragePath?: string): Promise<Task | undefined>;
|
|
264
|
+
/**
|
|
265
|
+
* 直接更新任务 context(不触发 BEFORE/AFTER_UPDATE hook、不发事件)
|
|
266
|
+
*
|
|
267
|
+
* ★ Task #4776 review MINOR-1:AFTER_COMPLETE hook 内的嵌套
|
|
268
|
+
* updateTask({context}) 会二次 fire AFTER_UPDATE,把订阅者
|
|
269
|
+
* (LarkCliTaskNotifyHook 等)无谓拉起 —— 终态任务被再次走
|
|
270
|
+
* cardStatusOf 终态路径。hint 回写这类「内部簿记」不应有通知副作用,
|
|
271
|
+
* 因此提供本方法绕过 hook 链,直接走 store 层。
|
|
272
|
+
*
|
|
273
|
+
* 语义与 updateTask({context}) 完全一致:整份覆盖 context 字段。
|
|
274
|
+
* 调用方负责自己 merge 既有字段(不要拿快照整份覆盖别人写的内容)。
|
|
275
|
+
*
|
|
276
|
+
* @param id 任务 ID
|
|
277
|
+
* @param context 新的 context JSON 字符串(整份覆盖)
|
|
278
|
+
* @returns 更新后的 Task,任务不存在时返回 undefined
|
|
279
|
+
*/
|
|
280
|
+
updateTaskContext(id: number, context: string): Promise<Task | undefined>;
|
|
238
281
|
/**
|
|
239
282
|
* Create operation record
|
|
240
283
|
*/
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Task #4834 — F3: task_complete 验收文案同源锚点
|
|
3
|
+
*
|
|
4
|
+
* 背景(reports/goals-criteria-rules-e2e-rebase.md §遗留 F3):
|
|
5
|
+
* prompts-index.ts 的 COMPLETE 生命周期步骤与工具描述
|
|
6
|
+
* (TASK_COMPLETE_DESCRIPTION)**不同源** —— 文案漂移会
|
|
7
|
+
* 稀释工具描述的遵循度。
|
|
8
|
+
*
|
|
9
|
+
* 方案:三个关键短语定义于此,complete-tool 与
|
|
10
|
+
* prompts-index(default prompt)都引用同一常量,
|
|
11
|
+
* 文案一致性由 completion-copy-consistency.test.ts 守住。
|
|
12
|
+
*
|
|
13
|
+
* ⚠️ 本模块必须保持**零依赖**(不 import 任何其他模块),
|
|
14
|
+
* 以便 prompts-index(超大模板串)与 tools 层都能安全引用。
|
|
15
|
+
*/
|
|
16
|
+
/** 逐条验收短语(工具描述 / default prompt 共用) */
|
|
17
|
+
export declare const TASK_COMPLETE_ITEM_BY_ITEM = "\u6309\u5B50\u9879\u9010\u6761\u9A8C\u6536";
|
|
18
|
+
/** hint 锚点 token(completion hook 写入 task context 的标记) */
|
|
19
|
+
export declare const TASK_COMPLETION_HINT_ANCHOR = "TASK_COMPLETION_HINT";
|
|
20
|
+
/** 核实义务短语(收到 hint 后必须核实,二选一) */
|
|
21
|
+
export declare const TASK_COMPLETE_VERIFY_DUTY = "\u6838\u5B9E\u4E49\u52A1";
|
|
22
|
+
/** F3 同源文案集合(聚合导出,便于测试解构) */
|
|
23
|
+
export declare const TASK_COMPLETE_ACCEPTANCE: {
|
|
24
|
+
readonly itemByItem: "按子项逐条验收";
|
|
25
|
+
readonly hintAnchor: "TASK_COMPLETION_HINT";
|
|
26
|
+
readonly verifyDuty: "核实义务";
|
|
27
|
+
};
|
|
@@ -9,8 +9,9 @@ import {
|
|
|
9
9
|
searchTasksTool,
|
|
10
10
|
treeTasksTool,
|
|
11
11
|
updateTaskTool
|
|
12
|
-
} from "../../../shared/@ai-setting/roy-agent-core-
|
|
12
|
+
} from "../../../shared/@ai-setting/roy-agent-core-h5vmff8w.js";
|
|
13
13
|
import"../../../shared/@ai-setting/roy-agent-core-tr3ep81v.js";
|
|
14
|
+
import"../../../shared/@ai-setting/roy-agent-core-6m4bw8jy.js";
|
|
14
15
|
import"../../../shared/@ai-setting/roy-agent-core-7cbpmk4q.js";
|
|
15
16
|
import"../../../shared/@ai-setting/roy-agent-core-qq96p0tj.js";
|
|
16
17
|
import"../../../shared/@ai-setting/roy-agent-core-7f7t9wwp.js";
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
getOperationTool,
|
|
5
5
|
listOperationsTool,
|
|
6
6
|
updateOperationTool
|
|
7
|
-
} from "../../../../shared/@ai-setting/roy-agent-core-
|
|
7
|
+
} from "../../../../shared/@ai-setting/roy-agent-core-p5cz9m8v.js";
|
|
8
8
|
import"../../../../shared/@ai-setting/roy-agent-core-fs0mn2jk.js";
|
|
9
9
|
export {
|
|
10
10
|
updateOperationTool,
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* 设计目标:
|
|
5
5
|
* - **状态/里程碑维度**("达到什么"):milestone_type / milestone_title / milestone_description
|
|
6
|
-
* - **过程维度**("如何达到"):process_description(100-
|
|
6
|
+
* - **过程维度**("如何达到"):process_description(100-500 字符硬约束,Task #4764 放宽)
|
|
7
7
|
*
|
|
8
8
|
* 兼容:
|
|
9
9
|
* - action_type / action_title / action_description 通过 z.preprocess 自动映射到 milestone_*
|
|
@@ -22,17 +22,19 @@ export { ActionTypeEnum };
|
|
|
22
22
|
* - milestone_description:达成状态/结果的描述(保留原义,可长可短)
|
|
23
23
|
* - process_description:采取了什么策略 + 工具步骤达成的过程概要
|
|
24
24
|
*
|
|
25
|
-
* 硬约束:100-150
|
|
25
|
+
* 硬约束:100-500 字符(Task #4764 放宽,原 100-150)。
|
|
26
26
|
* - 太短(<100)= 没价值,不算过程概要
|
|
27
|
-
* - 太长(>
|
|
28
|
-
* -
|
|
27
|
+
* - 太长(>500)= 退化为日志细节,违背 milestone 摘要设计
|
|
28
|
+
* - 放宽理由(Task #4764):150 字符装不下「里程碑 + 达成操作」的完整过程,
|
|
29
|
+
* agent 需要在执行中「边做边记」(记录刚做的操作 + 为什么),500 字符
|
|
30
|
+
* 足够表达且仍不是日志;完整细节仍应通过 sessionId 回查 session 历史。
|
|
29
31
|
*
|
|
30
32
|
* 失败模式:
|
|
31
33
|
* - < 100:拒绝(提供有意义的 process_description 才是该字段的本职)
|
|
32
|
-
* - >
|
|
34
|
+
* - > 500:拒绝(防止字段膨胀,保持 milestone 摘要克制)
|
|
33
35
|
*/
|
|
34
36
|
export declare const PROCESS_DESCRIPTION_MIN_LENGTH = 100;
|
|
35
|
-
export declare const PROCESS_DESCRIPTION_MAX_LENGTH =
|
|
37
|
+
export declare const PROCESS_DESCRIPTION_MAX_LENGTH = 500;
|
|
36
38
|
/**
|
|
37
39
|
* Milestone description (状态/结果描述) — 长度上限保留宽松(与历史 action_description 一致)。
|
|
38
40
|
*/
|
|
@@ -45,7 +47,7 @@ export declare const MILESTONE_TITLE_MAX_LENGTH = 200;
|
|
|
45
47
|
/**
|
|
46
48
|
* process_description 字段校验
|
|
47
49
|
* - 可选(向后兼容)
|
|
48
|
-
* - 长度严格 100-
|
|
50
|
+
* - 长度严格 100-500 字符(Task #4764 放宽)
|
|
49
51
|
*/
|
|
50
52
|
export declare const ProcessDescriptionSchema: z.ZodString;
|
|
51
53
|
/**
|
|
@@ -65,7 +67,7 @@ export declare const MilestoneDescriptionSchema: z.ZodOptional<z.ZodString>;
|
|
|
65
67
|
*
|
|
66
68
|
* 双维度规范:
|
|
67
69
|
* - milestone_* 字段描述达成的状态/结果
|
|
68
|
-
* - process_description 描述达成过程(100-
|
|
70
|
+
* - process_description 描述达成过程(100-500 字符)
|
|
69
71
|
* - action_* 字段作为兼容窗口期别名
|
|
70
72
|
*/
|
|
71
73
|
export declare const CreateOperationToolSchema: z.ZodEffects<z.ZodObject<{
|
package/dist/env/task/types.d.ts
CHANGED
|
@@ -60,7 +60,7 @@ export interface Task {
|
|
|
60
60
|
* - `milestoneDescription`: 达成状态/结果描述
|
|
61
61
|
*
|
|
62
62
|
* 2. **过程维度**("如何达到"):
|
|
63
|
-
* - `processDescription`: 过程概要(采取的策略 + 工具步骤概要,100-
|
|
63
|
+
* - `processDescription`: 过程概要(采取的策略 + 工具步骤概要,100-500 字符)
|
|
64
64
|
*
|
|
65
65
|
* ⚠️ **不要把 action 当状态**,也不要让 process 与 milestone_description 重复。
|
|
66
66
|
*
|
|
@@ -85,7 +85,7 @@ export interface TaskOperation {
|
|
|
85
85
|
* 过程概要:采取了什么策略 + 工具步骤达成的概要描述。
|
|
86
86
|
*
|
|
87
87
|
* 设计哲学:操作记录只承担节点阶段 milestone 摘要。
|
|
88
|
-
* 字符范围硬约束 100-
|
|
88
|
+
* 字符范围硬约束 100-500(Task #4764 放宽),应用层 schema 校验。
|
|
89
89
|
* 完整过程通过 sessionId 回查 session。
|
|
90
90
|
*/
|
|
91
91
|
processDescription: string;
|
|
@@ -213,7 +213,7 @@ export interface CreateOperationOptions {
|
|
|
213
213
|
/** 里程碑描述/状态/结果(主命名,替代旧 actionDescription) */
|
|
214
214
|
milestoneDescription?: string;
|
|
215
215
|
/**
|
|
216
|
-
* 过程概要(采取的策略 + 工具步骤),可选;如提供,应用层会校验 100-
|
|
216
|
+
* 过程概要(采取的策略 + 工具步骤),可选;如提供,应用层会校验 100-500 字符。
|
|
217
217
|
* 字符范围外会由 tool schema 拒绝(不在 DB 层强约束)。
|
|
218
218
|
*/
|
|
219
219
|
processDescription?: string;
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
grepTool,
|
|
9
9
|
readFileTool,
|
|
10
10
|
writeFileTool
|
|
11
|
-
} from "../../../shared/@ai-setting/roy-agent-core-
|
|
11
|
+
} from "../../../shared/@ai-setting/roy-agent-core-kpg25s2q.js";
|
|
12
12
|
import {
|
|
13
13
|
getUnderstandImageLLMProvider,
|
|
14
14
|
resetUnderstandImageLLMProvider,
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
import {
|
|
19
19
|
createQueryBackgroundProcessTool,
|
|
20
20
|
queryBackgroundProcessTool
|
|
21
|
-
} from "../../../shared/@ai-setting/roy-agent-core-
|
|
21
|
+
} from "../../../shared/@ai-setting/roy-agent-core-58804s3j.js";
|
|
22
22
|
import"../../../shared/@ai-setting/roy-agent-core-fttgm52a.js";
|
|
23
23
|
import"../../../shared/@ai-setting/roy-agent-core-zjdzk1gg.js";
|
|
24
24
|
import"../../../shared/@ai-setting/roy-agent-core-qq96p0tj.js";
|
|
@@ -56,6 +56,16 @@ export interface QueryBackgroundProcessOutput {
|
|
|
56
56
|
lastUpdatedAt: number;
|
|
57
57
|
/** 任务描述(not_found 时为 undefined) */
|
|
58
58
|
description?: string;
|
|
59
|
+
/**
|
|
60
|
+
* ★ Task #4720:sub-session 当前已落盘的消息条数。
|
|
61
|
+
* 仅在任务仍 alive 且能读到 sub-session 时提供;用于判断「真的在产出」。
|
|
62
|
+
*/
|
|
63
|
+
messageCount?: number;
|
|
64
|
+
/**
|
|
65
|
+
* ★ Task #4720:sub-session 的最后更新时间戳(毫秒)。
|
|
66
|
+
* 每轮 ReAct 迭代都会推进(配合增量落盘),是比 20 分钟心跳更细的活跃度信号。
|
|
67
|
+
*/
|
|
68
|
+
subSessionUpdatedAt?: number;
|
|
59
69
|
/** 已完成 / 失败 / 停止时的结果 */
|
|
60
70
|
result?: string;
|
|
61
71
|
/** 失败时的错误信息 */
|
package/dist/env/tool/index.js
CHANGED
|
@@ -10,14 +10,14 @@ import {
|
|
|
10
10
|
grepTool,
|
|
11
11
|
readFileTool,
|
|
12
12
|
writeFileTool
|
|
13
|
-
} from "../../shared/@ai-setting/roy-agent-core-
|
|
13
|
+
} from "../../shared/@ai-setting/roy-agent-core-kpg25s2q.js";
|
|
14
14
|
import {
|
|
15
15
|
getUnderstandImageLLMProvider,
|
|
16
16
|
resetUnderstandImageLLMProvider,
|
|
17
17
|
setUnderstandImageLLMProvider,
|
|
18
18
|
understandImageTool
|
|
19
19
|
} from "../../shared/@ai-setting/roy-agent-core-xwm8zavb.js";
|
|
20
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
20
|
+
import"../../shared/@ai-setting/roy-agent-core-58804s3j.js";
|
|
21
21
|
import"../../shared/@ai-setting/roy-agent-core-fttgm52a.js";
|
|
22
22
|
import {
|
|
23
23
|
ToolComponent,
|
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
ToolValidator,
|
|
26
26
|
getMaxOutputSize,
|
|
27
27
|
setToolConfigComponent
|
|
28
|
-
} from "../../shared/@ai-setting/roy-agent-core-
|
|
28
|
+
} from "../../shared/@ai-setting/roy-agent-core-dt104qa1.js";
|
|
29
29
|
import"../../shared/@ai-setting/roy-agent-core-jvv2h3d6.js";
|
|
30
30
|
import"../../shared/@ai-setting/roy-agent-core-zjdzk1gg.js";
|
|
31
31
|
import"../../shared/@ai-setting/roy-agent-core-e25xkv53.js";
|
package/dist/env/tool/types.d.ts
CHANGED
|
@@ -69,6 +69,12 @@ export interface ToolContext {
|
|
|
69
69
|
* 主模型调用失败(404 / 429 / 配额 / 5xx / 超时 / 重试耗尽)时自动切换。
|
|
70
70
|
*/
|
|
71
71
|
fallbackModel?: string;
|
|
72
|
+
/**
|
|
73
|
+
* Task #4724 — 兜底模型**有序列表**(`providerId/modelId`),顺序 = 优先级。
|
|
74
|
+
*
|
|
75
|
+
* 主模型失败时按顺序逐个尝试,全部失败才报错。
|
|
76
|
+
*/
|
|
77
|
+
fallbackModels?: string[];
|
|
72
78
|
/** 额外元数据 */
|
|
73
79
|
metadata?: Record<string, unknown>;
|
|
74
80
|
/** 沙箱配置 */
|