@ai-setting/roy-agent-core 1.7.72 → 1.7.76
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 +6 -6
- package/dist/env/agent/agent-registry.d.ts +4 -1
- package/dist/env/agent/index.js +6 -6
- package/dist/env/error-reply.d.ts +46 -0
- package/dist/env/error-reply.js +3 -1
- package/dist/env/event-source/event-source-handlers.js +13 -12
- package/dist/env/event-source/index.js +14 -13
- package/dist/env/index.js +31 -30
- package/dist/env/llm/index.js +2 -2
- package/dist/env/llm/orphan-toolcall.d.ts +107 -0
- package/dist/env/plugin/index.js +3 -3
- package/dist/env/prompt/index.js +4 -3
- package/dist/env/prompt/prompts-index.d.ts +27 -3
- package/dist/env/session/index.js +4 -4
- package/dist/env/session/storage/index.js +3 -3
- package/dist/env/task/backend/index.js +9 -1
- package/dist/env/task/delegate/delegate-tool.d.ts +8 -0
- package/dist/env/task/delegate/delegate-tool.js +5 -4
- package/dist/env/task/delegate/index.js +5 -4
- 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 +3 -2
- package/dist/env/task/plugins/index.d.ts +3 -0
- package/dist/env/task/plugins/index.js +33 -9
- package/dist/env/task/plugins/lark-card-patch-notifier.d.ts +61 -0
- package/dist/env/task/plugins/lark-card-patch-notifier.js +6 -2
- package/dist/env/task/plugins/lark-cli-task-notify-plugin.d.ts +42 -0
- package/dist/env/task/prompt/index.js +2 -1
- package/dist/env/task/prompt/task-discipline.d.ts +9 -3
- package/dist/env/task/task-component.d.ts +79 -0
- package/dist/env/task/tools/cancel-tool.d.ts +36 -0
- package/dist/env/task/tools/completion-copy.d.ts +92 -0
- package/dist/env/task/tools/index.d.ts +2 -0
- package/dist/env/task/tools/index.js +7 -2
- package/dist/env/task/tools/pre-complete-tool.d.ts +32 -0
- package/dist/env/task/tools/task-types.d.ts +71 -17
- package/dist/env/task/types.d.ts +13 -1
- package/dist/env/tool/built-in/compact-session-tool.d.ts +120 -0
- package/dist/env/tool/built-in/index.d.ts +2 -0
- package/dist/env/tool/built-in/index.js +6 -2
- package/dist/env/tool/index.js +4 -4
- package/dist/env/workflow/engine/index.js +6 -6
- package/dist/env/workflow/index.js +15 -13
- package/dist/env/workflow/plugins/index.js +2 -2
- package/dist/env/workflow/tools/ask-user-tool.d.ts +88 -0
- package/dist/env/workflow/tools/index.js +11 -9
- package/dist/env/workflow/tools/run-workflow.d.ts +2 -2
- package/dist/env/workflow/types/index.js +2 -2
- package/dist/env/workflow/types/workflow-hil.d.ts +25 -1
- package/dist/env/workflow/utils/index.js +5 -5
- package/dist/index.d.ts +1 -1
- package/dist/index.js +43 -33
- package/dist/shared/@ai-setting/{roy-agent-core-sm0sf6sb.js → roy-agent-core-0qyrk5k0.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-kmbct9yg.js → roy-agent-core-0snm5hc5.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-yr1mryb8.js → roy-agent-core-1v4g0d4x.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-rxb00gjm.js → roy-agent-core-264qexac.js} +1 -1
- package/dist/shared/@ai-setting/roy-agent-core-2akfd64z.js +374 -0
- package/dist/shared/@ai-setting/{roy-agent-core-skyc30qx.js → roy-agent-core-3fh1f7s7.js} +2 -2
- package/dist/shared/@ai-setting/roy-agent-core-4rtg69cn.js +26 -0
- package/dist/shared/@ai-setting/{roy-agent-core-add1zqsh.js → roy-agent-core-6cy43nss.js} +22 -1
- package/dist/shared/@ai-setting/{roy-agent-core-vah6g5yx.js → roy-agent-core-6rh8k6ba.js} +5 -5
- package/dist/shared/@ai-setting/{roy-agent-core-kpg25s2q.js → roy-agent-core-8ez6mccb.js} +4 -2
- package/dist/shared/@ai-setting/{roy-agent-core-yhwxpj12.js → roy-agent-core-9vxh6f8h.js} +233 -16
- package/dist/shared/@ai-setting/{roy-agent-core-7qvw65jt.js → roy-agent-core-aa2j7bk9.js} +11 -8
- package/dist/shared/@ai-setting/{roy-agent-core-sjr1kmfz.js → roy-agent-core-acj8ag08.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-mds8tqd0.js → roy-agent-core-cgtq6427.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-34jz9mgh.js → roy-agent-core-cmprygrp.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-wr7mv7k3.js → roy-agent-core-cxy143m4.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-pakhchy7.js → roy-agent-core-ddyk1rc0.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-attpry6g.js → roy-agent-core-dqxec05w.js} +4 -3
- package/dist/shared/@ai-setting/{roy-agent-core-vm8h5zyj.js → roy-agent-core-ed233k5z.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-jrj30vq3.js → roy-agent-core-er070zjq.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-40rv283c.js → roy-agent-core-fghc2m8z.js} +152 -2
- package/dist/shared/@ai-setting/{roy-agent-core-5gw0qa8m.js → roy-agent-core-ghnagzrh.js} +557 -92
- package/dist/shared/@ai-setting/{roy-agent-core-4jjwewvw.js → roy-agent-core-m46fe3x4.js} +41 -30
- package/dist/shared/@ai-setting/{roy-agent-core-e25xkv53.js → roy-agent-core-mkc3zshb.js} +3 -1
- package/dist/shared/@ai-setting/{roy-agent-core-hfyfavp3.js → roy-agent-core-mww0mnd9.js} +231 -27
- package/dist/shared/@ai-setting/{roy-agent-core-46rv4d7d.js → roy-agent-core-nmx9934r.js} +92 -2
- package/dist/shared/@ai-setting/{roy-agent-core-1w9y7mxj.js → roy-agent-core-p3zv1mx5.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-jgb3bb42.js → roy-agent-core-q5r75vev.js} +17 -8
- package/dist/shared/@ai-setting/{roy-agent-core-y12kyxwa.js → roy-agent-core-t3rrb959.js} +33 -9
- package/dist/shared/@ai-setting/{roy-agent-core-dt104qa1.js → roy-agent-core-v85n42ve.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-gr48c89p.js → roy-agent-core-v87njmq7.js} +3 -3
- package/dist/shared/@ai-setting/{roy-agent-core-7sj9xs9c.js → roy-agent-core-vffccgf6.js} +252 -25
- package/dist/shared/@ai-setting/{roy-agent-core-2gzt2q8c.js → roy-agent-core-z43aj03k.js} +134 -29
- package/dist/shared/@ai-setting/roy-agent-core-zycadbpx.js +662 -0
- package/package.json +1 -1
- package/dist/shared/@ai-setting/roy-agent-core-1p6syv85.js +0 -1083
- package/dist/shared/@ai-setting/roy-agent-core-58804s3j.js +0 -155
|
@@ -87,7 +87,7 @@ export type GetTaskToolParams = z.infer<typeof GetTaskToolSchema>;
|
|
|
87
87
|
* task_list tool parameters
|
|
88
88
|
*/
|
|
89
89
|
export declare const ListTasksToolSchema: z.ZodObject<{
|
|
90
|
-
status: z.ZodOptional<z.ZodEnum<["todo", "active", "completed", "paused", "cancelled", "archived"]>>;
|
|
90
|
+
status: z.ZodOptional<z.ZodEnum<["todo", "active", "to_validate", "completed", "paused", "cancelled", "archived"]>>;
|
|
91
91
|
priority: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
|
|
92
92
|
type: z.ZodOptional<z.ZodEnum<["normal", "cycle", "longterm"]>>;
|
|
93
93
|
limit: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
@@ -99,12 +99,12 @@ export declare const ListTasksToolSchema: z.ZodObject<{
|
|
|
99
99
|
offset: number;
|
|
100
100
|
include_archived: boolean;
|
|
101
101
|
type?: "normal" | "cycle" | "longterm" | undefined;
|
|
102
|
-
status?: "todo" | "active" | "completed" | "paused" | "cancelled" | "archived" | undefined;
|
|
102
|
+
status?: "todo" | "active" | "to_validate" | "completed" | "paused" | "cancelled" | "archived" | undefined;
|
|
103
103
|
priority?: "low" | "medium" | "high" | undefined;
|
|
104
104
|
depth?: number | undefined;
|
|
105
105
|
}, {
|
|
106
106
|
type?: "normal" | "cycle" | "longterm" | undefined;
|
|
107
|
-
status?: "todo" | "active" | "completed" | "paused" | "cancelled" | "archived" | undefined;
|
|
107
|
+
status?: "todo" | "active" | "to_validate" | "completed" | "paused" | "cancelled" | "archived" | undefined;
|
|
108
108
|
priority?: "low" | "medium" | "high" | undefined;
|
|
109
109
|
limit?: number | undefined;
|
|
110
110
|
offset?: number | undefined;
|
|
@@ -119,7 +119,7 @@ export declare const SearchTasksToolSchema: z.ZodObject<{
|
|
|
119
119
|
keywords: z.ZodArray<z.ZodString, "many">;
|
|
120
120
|
limit: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
121
121
|
offset: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
122
|
-
status: z.ZodOptional<z.ZodEnum<["todo", "active", "completed", "paused", "cancelled", "archived"]>>;
|
|
122
|
+
status: z.ZodOptional<z.ZodEnum<["todo", "active", "to_validate", "completed", "paused", "cancelled", "archived"]>>;
|
|
123
123
|
priority: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
|
|
124
124
|
type: z.ZodOptional<z.ZodEnum<["normal", "cycle", "longterm"]>>;
|
|
125
125
|
exclude_task_id: z.ZodOptional<z.ZodNumber>;
|
|
@@ -131,14 +131,14 @@ export declare const SearchTasksToolSchema: z.ZodObject<{
|
|
|
131
131
|
include_archived: boolean;
|
|
132
132
|
keywords: string[];
|
|
133
133
|
type?: "normal" | "cycle" | "longterm" | undefined;
|
|
134
|
-
status?: "todo" | "active" | "completed" | "paused" | "cancelled" | "archived" | undefined;
|
|
134
|
+
status?: "todo" | "active" | "to_validate" | "completed" | "paused" | "cancelled" | "archived" | undefined;
|
|
135
135
|
priority?: "low" | "medium" | "high" | undefined;
|
|
136
136
|
depth?: number | undefined;
|
|
137
137
|
exclude_task_id?: number | undefined;
|
|
138
138
|
}, {
|
|
139
139
|
keywords: string[];
|
|
140
140
|
type?: "normal" | "cycle" | "longterm" | undefined;
|
|
141
|
-
status?: "todo" | "active" | "completed" | "paused" | "cancelled" | "archived" | undefined;
|
|
141
|
+
status?: "todo" | "active" | "to_validate" | "completed" | "paused" | "cancelled" | "archived" | undefined;
|
|
142
142
|
priority?: "low" | "medium" | "high" | undefined;
|
|
143
143
|
limit?: number | undefined;
|
|
144
144
|
offset?: number | undefined;
|
|
@@ -155,7 +155,7 @@ export declare const UpdateTaskToolSchema: z.ZodEffects<z.ZodObject<{
|
|
|
155
155
|
} & {
|
|
156
156
|
title: z.ZodOptional<z.ZodString>;
|
|
157
157
|
description: z.ZodOptional<z.ZodString>;
|
|
158
|
-
status: z.ZodOptional<z.ZodEnum<["todo", "active", "completed", "paused", "cancelled", "archived"]>>;
|
|
158
|
+
status: z.ZodOptional<z.ZodEnum<["todo", "active", "to_validate", "completed", "paused", "cancelled", "archived"]>>;
|
|
159
159
|
priority: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
|
|
160
160
|
type: z.ZodOptional<z.ZodEnum<["normal", "cycle", "longterm"]>>;
|
|
161
161
|
progress: z.ZodOptional<z.ZodNumber>;
|
|
@@ -169,7 +169,7 @@ export declare const UpdateTaskToolSchema: z.ZodEffects<z.ZodObject<{
|
|
|
169
169
|
}, "strip", z.ZodTypeAny, {
|
|
170
170
|
task_id: number;
|
|
171
171
|
type?: "normal" | "cycle" | "longterm" | undefined;
|
|
172
|
-
status?: "todo" | "active" | "completed" | "paused" | "cancelled" | "archived" | undefined;
|
|
172
|
+
status?: "todo" | "active" | "to_validate" | "completed" | "paused" | "cancelled" | "archived" | undefined;
|
|
173
173
|
tags?: string[] | undefined;
|
|
174
174
|
description?: string | undefined;
|
|
175
175
|
progress?: number | undefined;
|
|
@@ -184,7 +184,7 @@ export declare const UpdateTaskToolSchema: z.ZodEffects<z.ZodObject<{
|
|
|
184
184
|
}, {
|
|
185
185
|
task_id: number;
|
|
186
186
|
type?: "normal" | "cycle" | "longterm" | undefined;
|
|
187
|
-
status?: "todo" | "active" | "completed" | "paused" | "cancelled" | "archived" | undefined;
|
|
187
|
+
status?: "todo" | "active" | "to_validate" | "completed" | "paused" | "cancelled" | "archived" | undefined;
|
|
188
188
|
tags?: string[] | undefined;
|
|
189
189
|
description?: string | undefined;
|
|
190
190
|
progress?: number | undefined;
|
|
@@ -199,7 +199,7 @@ export declare const UpdateTaskToolSchema: z.ZodEffects<z.ZodObject<{
|
|
|
199
199
|
}>, {
|
|
200
200
|
task_id: number;
|
|
201
201
|
type?: "normal" | "cycle" | "longterm" | undefined;
|
|
202
|
-
status?: "todo" | "active" | "completed" | "paused" | "cancelled" | "archived" | undefined;
|
|
202
|
+
status?: "todo" | "active" | "to_validate" | "completed" | "paused" | "cancelled" | "archived" | undefined;
|
|
203
203
|
tags?: string[] | undefined;
|
|
204
204
|
description?: string | undefined;
|
|
205
205
|
progress?: number | undefined;
|
|
@@ -228,26 +228,80 @@ export type DeleteTaskToolParams = z.infer<typeof DeleteTaskToolSchema>;
|
|
|
228
228
|
* task_complete tool parameters
|
|
229
229
|
*
|
|
230
230
|
* Task #2778: 新增 deliverable_storage_path 参数。
|
|
231
|
-
*
|
|
231
|
+
* Task #5073 设计调整① — task_complete 精简为**纯验收动作**:
|
|
232
232
|
*
|
|
233
|
-
*
|
|
234
|
-
*
|
|
233
|
+
* deliverable_storage_path 入参已删除(用户 2026-11-06 明令)。
|
|
234
|
+
* 交付物在 pre_complete 阶段(task_pre_complete)提交落库
|
|
235
|
+
* (task.context.deliverable_storage_path + operation Deliverable 行),
|
|
236
|
+
* task_complete 只做状态修改验收:逐条核对 goals 子项后
|
|
237
|
+
* 把 to_validate → completed(TASK_COMPLETION_TERMINAL)。
|
|
238
|
+
*
|
|
239
|
+
* ⚠️ 交付物通道 = task_pre_complete,验收通道 = task_complete ——
|
|
240
|
+
* 两者职责分离后,交付物参数不该再出现在 complete 的 schema 里。
|
|
241
|
+
*
|
|
242
|
+
* 兼容性:unknown-key 被 zod 静默剥离(withLegacyTaskId 的 object
|
|
243
|
+
* 不含 additionalProperties:false)→ 老调用方传了 deliverable 也
|
|
244
|
+
* 不报错,只是不再被读取。CLI / TaskStoreBackend(MCP 通道)的
|
|
245
|
+
* completeTask(deliverable) 底层签名保留(#5060 修复链不破坏)。
|
|
235
246
|
*/
|
|
236
247
|
export declare const CompleteTaskToolSchema: z.ZodEffects<z.ZodObject<{
|
|
237
248
|
task_id: z.ZodNumber;
|
|
249
|
+
}, "strip", z.ZodTypeAny, {
|
|
250
|
+
task_id: number;
|
|
251
|
+
}, {
|
|
252
|
+
task_id: number;
|
|
253
|
+
}>, {
|
|
254
|
+
task_id: number;
|
|
255
|
+
}, unknown>;
|
|
256
|
+
export type CompleteTaskToolParams = z.infer<typeof CompleteTaskToolSchema>;
|
|
257
|
+
/**
|
|
258
|
+
* task_pre_complete tool parameters (Task #5073 — 两阶段验收)
|
|
259
|
+
*
|
|
260
|
+
* sub-agent 交付时调用:把任务置为 to_validate(待验证),
|
|
261
|
+
* 交付物参数与 task_complete 完全同构(deliverable_storage_path),
|
|
262
|
+
* 让执行方「提交待验证」的调用体验与验收方「落终态」一致。
|
|
263
|
+
*/
|
|
264
|
+
export declare const PreCompleteTaskToolSchema: z.ZodEffects<z.ZodObject<{
|
|
265
|
+
task_id: z.ZodNumber;
|
|
238
266
|
} & {
|
|
239
267
|
deliverable_storage_path: z.ZodOptional<z.ZodString>;
|
|
268
|
+
current_status: z.ZodOptional<z.ZodString>;
|
|
240
269
|
}, "strip", z.ZodTypeAny, {
|
|
241
270
|
task_id: number;
|
|
271
|
+
current_status?: string | undefined;
|
|
242
272
|
deliverable_storage_path?: string | undefined;
|
|
243
273
|
}, {
|
|
244
274
|
task_id: number;
|
|
275
|
+
current_status?: string | undefined;
|
|
245
276
|
deliverable_storage_path?: string | undefined;
|
|
246
277
|
}>, {
|
|
247
278
|
task_id: number;
|
|
279
|
+
current_status?: string | undefined;
|
|
248
280
|
deliverable_storage_path?: string | undefined;
|
|
249
281
|
}, unknown>;
|
|
250
|
-
export type
|
|
282
|
+
export type PreCompleteTaskToolParams = z.infer<typeof PreCompleteTaskToolSchema>;
|
|
283
|
+
/**
|
|
284
|
+
* task_cancel tool parameters (Task #5007)
|
|
285
|
+
*
|
|
286
|
+
* 取消 Task 本身(status = "cancelled")。
|
|
287
|
+
* ⚠️ 与 `stop_task` 正交:stop_task 停**后台进程**(bg process id),
|
|
288
|
+
* task_cancel 停**任务记录**(task id)。需要连用时先 stop_task 再 task_cancel。
|
|
289
|
+
*/
|
|
290
|
+
export declare const CancelTaskToolSchema: z.ZodEffects<z.ZodObject<{
|
|
291
|
+
task_id: z.ZodNumber;
|
|
292
|
+
} & {
|
|
293
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
294
|
+
}, "strip", z.ZodTypeAny, {
|
|
295
|
+
task_id: number;
|
|
296
|
+
reason?: string | undefined;
|
|
297
|
+
}, {
|
|
298
|
+
task_id: number;
|
|
299
|
+
reason?: string | undefined;
|
|
300
|
+
}>, {
|
|
301
|
+
task_id: number;
|
|
302
|
+
reason?: string | undefined;
|
|
303
|
+
}, unknown>;
|
|
304
|
+
export type CancelTaskToolParams = z.infer<typeof CancelTaskToolSchema>;
|
|
251
305
|
/**
|
|
252
306
|
* task_batch_archive tool parameters
|
|
253
307
|
*/
|
|
@@ -282,7 +336,7 @@ export type BatchDeleteToolParams = z.infer<typeof BatchDeleteToolSchema>;
|
|
|
282
336
|
export declare const TreeTasksToolSchema: z.ZodObject<{
|
|
283
337
|
depth: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
284
338
|
parent_task_id: z.ZodOptional<z.ZodNumber>;
|
|
285
|
-
status: z.ZodOptional<z.ZodEnum<["todo", "active", "completed", "paused", "cancelled", "archived"]>>;
|
|
339
|
+
status: z.ZodOptional<z.ZodEnum<["todo", "active", "to_validate", "completed", "paused", "cancelled", "archived"]>>;
|
|
286
340
|
priority: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
|
|
287
341
|
type: z.ZodOptional<z.ZodEnum<["normal", "cycle", "longterm"]>>;
|
|
288
342
|
include_archived: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
@@ -290,12 +344,12 @@ export declare const TreeTasksToolSchema: z.ZodObject<{
|
|
|
290
344
|
depth: number;
|
|
291
345
|
include_archived: boolean;
|
|
292
346
|
type?: "normal" | "cycle" | "longterm" | undefined;
|
|
293
|
-
status?: "todo" | "active" | "completed" | "paused" | "cancelled" | "archived" | undefined;
|
|
347
|
+
status?: "todo" | "active" | "to_validate" | "completed" | "paused" | "cancelled" | "archived" | undefined;
|
|
294
348
|
priority?: "low" | "medium" | "high" | undefined;
|
|
295
349
|
parent_task_id?: number | undefined;
|
|
296
350
|
}, {
|
|
297
351
|
type?: "normal" | "cycle" | "longterm" | undefined;
|
|
298
|
-
status?: "todo" | "active" | "completed" | "paused" | "cancelled" | "archived" | undefined;
|
|
352
|
+
status?: "todo" | "active" | "to_validate" | "completed" | "paused" | "cancelled" | "archived" | undefined;
|
|
299
353
|
priority?: "low" | "medium" | "high" | undefined;
|
|
300
354
|
parent_task_id?: number | undefined;
|
|
301
355
|
depth?: number | undefined;
|
package/dist/env/task/types.d.ts
CHANGED
|
@@ -4,8 +4,20 @@
|
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
/**
|
|
6
6
|
* Task status enum
|
|
7
|
+
*
|
|
8
|
+
* ★ Task #5073 — 新增 `to_validate`(待验证)。
|
|
9
|
+
*
|
|
10
|
+
* 两阶段验收(#5007 的机制化落地):
|
|
11
|
+
* sub-agent 干完 → task_pre_complete → status=to_validate(待验证)
|
|
12
|
+
* default agent → task_complete → status=completed(正式完成)
|
|
13
|
+
*
|
|
14
|
+
* ⚠️ 其余 6 个旧状态(todo/active/completed/paused/cancelled/archived)
|
|
15
|
+
* **全部保留** —— 存量库有 paused/cancelled/archived 记录,
|
|
16
|
+
* 不做状态迁移、不删任何旧值(用户 2026-11-06 明令修正)。
|
|
17
|
+
* to_validate 是唯一的**新增**状态,是「非终态」(可被 task_complete
|
|
18
|
+
* 落成 completed,也可被 reopen 回 active)。
|
|
7
19
|
*/
|
|
8
|
-
export declare const TaskStatusEnum: z.ZodEnum<["todo", "active", "completed", "paused", "cancelled", "archived"]>;
|
|
20
|
+
export declare const TaskStatusEnum: z.ZodEnum<["todo", "active", "to_validate", "completed", "paused", "cancelled", "archived"]>;
|
|
9
21
|
export type TaskStatus = z.infer<typeof TaskStatusEnum>;
|
|
10
22
|
/**
|
|
11
23
|
* Task priority enum
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview compact_session — Default Agent sub-session 压缩工具
|
|
3
|
+
*
|
|
4
|
+
* Task #4982 — 用户需求:
|
|
5
|
+
* 「给 Default agent 添加一个压缩 session 的工具,遇到 sub-agent
|
|
6
|
+
* 返回上下文超了的问题,可以用这个工具来压缩 sub-session,
|
|
7
|
+
* 继续复用 session」
|
|
8
|
+
*
|
|
9
|
+
* 背景(真实踩坑):
|
|
10
|
+
* Default agent 通过 delegate_task 委托子代理,sub-session 积累大量
|
|
11
|
+
* 上下文。当 sub-agent 返回 Context threshold exceeded(如
|
|
12
|
+
* 125575/120000 = 104.6%)时,default agent 只能用
|
|
13
|
+
* delegate_task(sub_session_id=...) 续跑 —— 但被污染/过长的
|
|
14
|
+
* sub-session 续跑会再次超限。本工具让 default agent 先压缩
|
|
15
|
+
* sub-session(生成 checkpoint、归档旧消息),再继续复用。
|
|
16
|
+
*
|
|
17
|
+
* 可见性:
|
|
18
|
+
* - metadata.allowedAgentTypes: ["default"] — 只对 default 接待员可见
|
|
19
|
+
* - 其他 agent(roy / strict-task-agent / explore 等)看不到
|
|
20
|
+
*
|
|
21
|
+
* 安全设计(四层):
|
|
22
|
+
* 1. deps 未注入 → success=false, error="not initialized"
|
|
23
|
+
* 2. 压缩当前会话 → success=false(default agent 自毁上下文防线)
|
|
24
|
+
* 3. session 不存在 / 非自己的 sub-session → status='not_found'
|
|
25
|
+
* (不暴露存在性,与 query_background_process 同一哲学)
|
|
26
|
+
* 4. 后台任务 running/pending → success=false(sub-session 每轮
|
|
27
|
+
* ReAct 增量落盘(Task #4720 Fix A),与归档竞态会撕裂任务状态)
|
|
28
|
+
*
|
|
29
|
+
* 复用闭环:
|
|
30
|
+
* compact_session 压缩后,用
|
|
31
|
+
* delegate_task(subagentType=..., sub_session_id=<同 id>, prompt=...) 续跑。
|
|
32
|
+
*
|
|
33
|
+
* 注入方式(2026-11-05,与 query_background_process 同模式):
|
|
34
|
+
* - createCompactSessionTool(manager, sessionComponent) 工厂闭包注入
|
|
35
|
+
* - TaskComponent.start() 注册 manager-bound 实例;stop() 注销为 null 版本
|
|
36
|
+
* - getAllBuiltInTools() 中的默认版本为 null-deps(执行即 not initialized)
|
|
37
|
+
*
|
|
38
|
+
* 输出(JSON 字符串):
|
|
39
|
+
* {
|
|
40
|
+
* status: 'compacted' | 'not_found',
|
|
41
|
+
* sessionId: string,
|
|
42
|
+
* checkpointId?: string,
|
|
43
|
+
* checkpointTitle?: string,
|
|
44
|
+
* contentLength?: number,
|
|
45
|
+
* originalMessages?: number, // 压缩前可压缩消息数
|
|
46
|
+
* deletedMessages?: number, // 归档条数
|
|
47
|
+
* remainingMessages?: number, // 归档后剩余活跃消息数
|
|
48
|
+
* hintUsed?: boolean, // phase1 hint 是否注入
|
|
49
|
+
* }
|
|
50
|
+
*
|
|
51
|
+
* 失败行为:
|
|
52
|
+
* - manager / sessionComponent 未注入 → success=false
|
|
53
|
+
* - zod 参数校验失败 → throw(ToolComponent 捕获)
|
|
54
|
+
* - previewCompact / compact 抛错 → success=false, error=原始 message
|
|
55
|
+
* - generateCompactHint 抛错 → 容错(hint 为空串,不阻塞压缩)
|
|
56
|
+
*/
|
|
57
|
+
import type { Tool } from "../types";
|
|
58
|
+
import type { BackgroundTaskManager, BackgroundTask } from "../../task/delegate/delegate-tool";
|
|
59
|
+
import type { SessionComponent } from "../../session/session-component";
|
|
60
|
+
/**
|
|
61
|
+
* 成功压缩的输出
|
|
62
|
+
*/
|
|
63
|
+
export interface CompactSessionOutput {
|
|
64
|
+
status: "compacted" | "not_found";
|
|
65
|
+
sessionId: string;
|
|
66
|
+
checkpointId?: string;
|
|
67
|
+
checkpointTitle?: string;
|
|
68
|
+
contentLength?: number;
|
|
69
|
+
originalMessages?: number;
|
|
70
|
+
deletedMessages?: number;
|
|
71
|
+
remainingMessages?: number;
|
|
72
|
+
hintUsed?: boolean;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* not_found 输出(不暴露存在性)
|
|
76
|
+
*/
|
|
77
|
+
export declare function compactSessionNotFoundOutput(sessionId: string): CompactSessionOutput;
|
|
78
|
+
/**
|
|
79
|
+
* 在 manager 的任务表里查找 sub-session 归属的任务。
|
|
80
|
+
*
|
|
81
|
+
* - 优先按 subSessionId 反查(工具入参就是 sub-session id)
|
|
82
|
+
* - 再回退 getTask(兼容直接传 bgProcessId 的误用场景)
|
|
83
|
+
*
|
|
84
|
+
* 返回 undefined 表示没有任何任务关联该 session。
|
|
85
|
+
*/
|
|
86
|
+
export declare function findTaskBySubSessionId(manager: Pick<BackgroundTaskManager, "getTask" | "listTasks">, sessionId: string): BackgroundTask | undefined;
|
|
87
|
+
/**
|
|
88
|
+
* ownership 校验:
|
|
89
|
+
* 该 session 是否是「当前会话自己 delegate 出去的 sub-session」。
|
|
90
|
+
*
|
|
91
|
+
* 规则:task 存在 且 task.parentSessionId === ctx.session_id。
|
|
92
|
+
* (delegate_tool 创建 sub-session 时把 parentSessionId 写成
|
|
93
|
+
* ctx.session_id —— 见 createTask。)
|
|
94
|
+
*/
|
|
95
|
+
export declare function isOwnSubSession(task: BackgroundTask | undefined, currentSessionId: string | undefined): boolean;
|
|
96
|
+
/**
|
|
97
|
+
* 该 session 是否属于一个仍在运行中的后台任务。
|
|
98
|
+
* running/pending 的 sub-session 正在被 sub-agent 每轮增量落盘,
|
|
99
|
+
* 此时归档旧消息会产生竞态(归档读到的窗口与 sub-agent 正在写的窗口冲突)。
|
|
100
|
+
*/
|
|
101
|
+
export declare function isTaskActive(task: BackgroundTask | undefined): boolean;
|
|
102
|
+
/**
|
|
103
|
+
* 工厂函数 — 创建 deps-bound 工具实例。
|
|
104
|
+
*
|
|
105
|
+
* @param backgroundTaskManager BackgroundTaskManager 实例(查任务归属 / 判运行中);
|
|
106
|
+
* 传 null 表示未注入
|
|
107
|
+
* @param sessionComponent SessionComponent 实例(执行压缩);传 null 表示未注入
|
|
108
|
+
*/
|
|
109
|
+
export declare function createCompactSessionTool(backgroundTaskManager?: BackgroundTaskManager | null, sessionComponent?: SessionComponent | null): Tool;
|
|
110
|
+
/**
|
|
111
|
+
* compact_session 工具的"无 deps"实例。
|
|
112
|
+
*
|
|
113
|
+
* 历史:与 queryBackgroundProcessTool 同模式 ——
|
|
114
|
+
* - 实际注入的 deps 通过 createCompactSessionTool(manager, sessionComponent)
|
|
115
|
+
* 工厂绑定;TaskComponent.start() 会用它重新注册真正的实例到
|
|
116
|
+
* ToolComponent,覆盖此 no-deps 版本。
|
|
117
|
+
* - 此 named export 保留用于 getAllBuiltInTools() 注册与向后兼容;
|
|
118
|
+
* 它绑定 null deps → 执行时返回 "not initialized" 错误。
|
|
119
|
+
*/
|
|
120
|
+
export declare const compactSessionTool: Tool;
|
|
@@ -8,6 +8,7 @@ import { editFileTool } from "./edit-file";
|
|
|
8
8
|
import { grepTool } from "./grep";
|
|
9
9
|
import { understandImageTool } from "./understand-image";
|
|
10
10
|
import { createQueryBackgroundProcessTool } from "./query-background-process-tool";
|
|
11
|
+
import { createCompactSessionTool, compactSessionTool } from "./compact-session-tool";
|
|
11
12
|
export { bashTool };
|
|
12
13
|
export { echoTool };
|
|
13
14
|
export { globTool };
|
|
@@ -18,6 +19,7 @@ export { grepTool };
|
|
|
18
19
|
export { understandImageTool };
|
|
19
20
|
import { queryBackgroundProcessTool } from "./query-background-process-tool";
|
|
20
21
|
export { queryBackgroundProcessTool, createQueryBackgroundProcessTool };
|
|
22
|
+
export { compactSessionTool, createCompactSessionTool };
|
|
21
23
|
export { setUnderstandImageLLMProvider, getUnderstandImageLLMProvider, resetUnderstandImageLLMProvider, type UnderstandImageLLMProvider, } from "./understand-image";
|
|
22
24
|
/**
|
|
23
25
|
* 获取所有内置工具
|
|
@@ -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-8ez6mccb.js";
|
|
12
12
|
import {
|
|
13
13
|
getUnderstandImageLLMProvider,
|
|
14
14
|
resetUnderstandImageLLMProvider,
|
|
@@ -16,9 +16,11 @@ import {
|
|
|
16
16
|
understandImageTool
|
|
17
17
|
} from "../../../shared/@ai-setting/roy-agent-core-xwm8zavb.js";
|
|
18
18
|
import {
|
|
19
|
+
compactSessionTool,
|
|
20
|
+
createCompactSessionTool,
|
|
19
21
|
createQueryBackgroundProcessTool,
|
|
20
22
|
queryBackgroundProcessTool
|
|
21
|
-
} from "../../../shared/@ai-setting/roy-agent-core-
|
|
23
|
+
} from "../../../shared/@ai-setting/roy-agent-core-2akfd64z.js";
|
|
22
24
|
import"../../../shared/@ai-setting/roy-agent-core-fttgm52a.js";
|
|
23
25
|
import"../../../shared/@ai-setting/roy-agent-core-zjdzk1gg.js";
|
|
24
26
|
import"../../../shared/@ai-setting/roy-agent-core-qq96p0tj.js";
|
|
@@ -40,5 +42,7 @@ export {
|
|
|
40
42
|
editFileTool,
|
|
41
43
|
echoTool,
|
|
42
44
|
createQueryBackgroundProcessTool,
|
|
45
|
+
createCompactSessionTool,
|
|
46
|
+
compactSessionTool,
|
|
43
47
|
bashTool
|
|
44
48
|
};
|
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-8ez6mccb.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-2akfd64z.js";
|
|
21
21
|
import"../../shared/@ai-setting/roy-agent-core-fttgm52a.js";
|
|
22
22
|
import {
|
|
23
23
|
ToolComponent,
|
|
@@ -25,10 +25,10 @@ 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-v85n42ve.js";
|
|
29
29
|
import"../../shared/@ai-setting/roy-agent-core-jvv2h3d6.js";
|
|
30
30
|
import"../../shared/@ai-setting/roy-agent-core-zjdzk1gg.js";
|
|
31
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
31
|
+
import"../../shared/@ai-setting/roy-agent-core-mkc3zshb.js";
|
|
32
32
|
import"../../shared/@ai-setting/roy-agent-core-7hh0brvs.js";
|
|
33
33
|
import"../../shared/@ai-setting/roy-agent-core-pgvcf91v.js";
|
|
34
34
|
import"../../shared/@ai-setting/roy-agent-core-ax9e9szb.js";
|
|
@@ -5,20 +5,20 @@ import {
|
|
|
5
5
|
Scheduler,
|
|
6
6
|
WorkflowEngine,
|
|
7
7
|
init_engine
|
|
8
|
-
} from "../../../shared/@ai-setting/roy-agent-core-
|
|
8
|
+
} from "../../../shared/@ai-setting/roy-agent-core-6rh8k6ba.js";
|
|
9
9
|
import"../../../shared/@ai-setting/roy-agent-core-6atd905e.js";
|
|
10
|
-
import"../../../shared/@ai-setting/roy-agent-core-
|
|
10
|
+
import"../../../shared/@ai-setting/roy-agent-core-dqxec05w.js";
|
|
11
11
|
import"../../../shared/@ai-setting/roy-agent-core-efkjyh69.js";
|
|
12
12
|
import"../../../shared/@ai-setting/roy-agent-core-1db4vpc6.js";
|
|
13
13
|
import"../../../shared/@ai-setting/roy-agent-core-dvtg4sn0.js";
|
|
14
14
|
import"../../../shared/@ai-setting/roy-agent-core-c2gbt68e.js";
|
|
15
|
-
import"../../../shared/@ai-setting/roy-agent-core-
|
|
15
|
+
import"../../../shared/@ai-setting/roy-agent-core-acj8ag08.js";
|
|
16
16
|
import"../../../shared/@ai-setting/roy-agent-core-ddwa0n6h.js";
|
|
17
17
|
import {
|
|
18
18
|
DAGManager
|
|
19
|
-
} from "../../../shared/@ai-setting/roy-agent-core-
|
|
20
|
-
import"../../../shared/@ai-setting/roy-agent-core-
|
|
21
|
-
import"../../../shared/@ai-setting/roy-agent-core-
|
|
19
|
+
} from "../../../shared/@ai-setting/roy-agent-core-cgtq6427.js";
|
|
20
|
+
import"../../../shared/@ai-setting/roy-agent-core-er070zjq.js";
|
|
21
|
+
import"../../../shared/@ai-setting/roy-agent-core-mkc3zshb.js";
|
|
22
22
|
import"../../../shared/@ai-setting/roy-agent-core-ax9e9szb.js";
|
|
23
23
|
import"../../../shared/@ai-setting/roy-agent-core-cpcd24n2.js";
|
|
24
24
|
import"../../../shared/@ai-setting/roy-agent-core-qqaak24r.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
WorkflowComponent
|
|
3
|
-
} from "../../shared/@ai-setting/roy-agent-core-
|
|
3
|
+
} from "../../shared/@ai-setting/roy-agent-core-v87njmq7.js";
|
|
4
4
|
import"../../shared/@ai-setting/roy-agent-core-es203w7p.js";
|
|
5
5
|
import {
|
|
6
6
|
Edge,
|
|
@@ -14,23 +14,24 @@ import {
|
|
|
14
14
|
DecoratorNode,
|
|
15
15
|
init_decorator_node
|
|
16
16
|
} from "../../shared/@ai-setting/roy-agent-core-1ce3fqrk.js";
|
|
17
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
18
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
19
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
17
|
+
import"../../shared/@ai-setting/roy-agent-core-mww0mnd9.js";
|
|
18
|
+
import"../../shared/@ai-setting/roy-agent-core-ddyk1rc0.js";
|
|
19
|
+
import"../../shared/@ai-setting/roy-agent-core-0qyrk5k0.js";
|
|
20
20
|
import"../../shared/@ai-setting/roy-agent-core-hhrg314p.js";
|
|
21
21
|
import"../../shared/@ai-setting/roy-agent-core-12n08pg5.js";
|
|
22
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
22
|
+
import"../../shared/@ai-setting/roy-agent-core-6cy43nss.js";
|
|
23
|
+
import"../../shared/@ai-setting/roy-agent-core-6rh8k6ba.js";
|
|
23
24
|
import"../../shared/@ai-setting/roy-agent-core-6atd905e.js";
|
|
24
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
25
|
+
import"../../shared/@ai-setting/roy-agent-core-dqxec05w.js";
|
|
25
26
|
import"../../shared/@ai-setting/roy-agent-core-efkjyh69.js";
|
|
26
27
|
import"../../shared/@ai-setting/roy-agent-core-1db4vpc6.js";
|
|
27
28
|
import"../../shared/@ai-setting/roy-agent-core-dvtg4sn0.js";
|
|
28
29
|
import"../../shared/@ai-setting/roy-agent-core-c2gbt68e.js";
|
|
29
30
|
import"../../shared/@ai-setting/roy-agent-core-7exqwax1.js";
|
|
30
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
31
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
31
|
+
import"../../shared/@ai-setting/roy-agent-core-1v4g0d4x.js";
|
|
32
|
+
import"../../shared/@ai-setting/roy-agent-core-acj8ag08.js";
|
|
32
33
|
import"../../shared/@ai-setting/roy-agent-core-ddwa0n6h.js";
|
|
33
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
34
|
+
import"../../shared/@ai-setting/roy-agent-core-cgtq6427.js";
|
|
34
35
|
import {
|
|
35
36
|
BaseEventSchema,
|
|
36
37
|
ControlPauseEventSchema,
|
|
@@ -82,10 +83,10 @@ import {
|
|
|
82
83
|
parseWorkflowFileSync,
|
|
83
84
|
pathNotFound,
|
|
84
85
|
unresolvedVariable
|
|
85
|
-
} from "../../shared/@ai-setting/roy-agent-core-
|
|
86
|
+
} from "../../shared/@ai-setting/roy-agent-core-er070zjq.js";
|
|
86
87
|
import"../../shared/@ai-setting/roy-agent-core-rvxg1wps.js";
|
|
87
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
88
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
88
|
+
import"../../shared/@ai-setting/roy-agent-core-0snm5hc5.js";
|
|
89
|
+
import"../../shared/@ai-setting/roy-agent-core-fghc2m8z.js";
|
|
89
90
|
import"../../shared/@ai-setting/roy-agent-core-zjdzk1gg.js";
|
|
90
91
|
import"../../shared/@ai-setting/roy-agent-core-c1v263jn.js";
|
|
91
92
|
import"../../shared/@ai-setting/roy-agent-core-ntn32q7j.js";
|
|
@@ -93,7 +94,8 @@ import {
|
|
|
93
94
|
AskUserError,
|
|
94
95
|
createNodeInterruptEvent,
|
|
95
96
|
createWorkflowAskUserEvent
|
|
96
|
-
} from "../../shared/@ai-setting/roy-agent-core-
|
|
97
|
+
} from "../../shared/@ai-setting/roy-agent-core-mkc3zshb.js";
|
|
98
|
+
import"../../shared/@ai-setting/roy-agent-core-m880qz3y.js";
|
|
97
99
|
import"../../shared/@ai-setting/roy-agent-core-7hh0brvs.js";
|
|
98
100
|
import"../../shared/@ai-setting/roy-agent-core-pgvcf91v.js";
|
|
99
101
|
import"../../shared/@ai-setting/roy-agent-core-ax9e9szb.js";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
LarkCliWorkflowNotifyHook,
|
|
3
3
|
createLarkCliWorkflowNotifyHook
|
|
4
|
-
} from "../../../shared/@ai-setting/roy-agent-core-
|
|
5
|
-
import"../../../shared/@ai-setting/roy-agent-core-
|
|
4
|
+
} from "../../../shared/@ai-setting/roy-agent-core-p3zv1mx5.js";
|
|
5
|
+
import"../../../shared/@ai-setting/roy-agent-core-nmx9934r.js";
|
|
6
6
|
import"../../../shared/@ai-setting/roy-agent-core-c2gbt68e.js";
|
|
7
7
|
import"../../../shared/@ai-setting/roy-agent-core-ax9e9szb.js";
|
|
8
8
|
import"../../../shared/@ai-setting/roy-agent-core-cpcd24n2.js";
|
|
@@ -3,6 +3,56 @@
|
|
|
3
3
|
*
|
|
4
4
|
* When an AgentNode calls this tool, it throws AskUserError to interrupt
|
|
5
5
|
* the workflow, allowing the workflow to pause and wait for user response.
|
|
6
|
+
*
|
|
7
|
+
* ★ Task #4983 — 无 TTY 场景的 **IM 直连投递**。
|
|
8
|
+
*
|
|
9
|
+
* ## 为什么需要这一段(生产日志铁证)
|
|
10
|
+
*
|
|
11
|
+
* traceId `01a1a68652ee79c9c6508579b504e662`(2026-11-04 20:55:38 → 20:56:09,
|
|
12
|
+
* 飞书 p2p `oc_9406ee012e5b7ae65a7a83314b2f8fbc`):
|
|
13
|
+
*
|
|
14
|
+
* 20:55:38.788 [BackgroundTaskManager] Event published: task.background.ask_user
|
|
15
|
+
* (triggerEventId + replyChannel 都齐 ✅ —— #3147 的 notify 链路完好)
|
|
16
|
+
* 20:55:38.790 cli.query-executor.execute enter: "[通知] ❓ 后台子代理「…」请求用户输入 …"
|
|
17
|
+
* 20:56:09.513 [agent:component] Iteration 1 error
|
|
18
|
+
* {runId:"unknown", nodeId:"unknown", type:"ask-user", name:"AskUserError"}
|
|
19
|
+
* 20:56:09.517 cli.query-executor.execute error: __ASK_USER_ERROR__:{…}
|
|
20
|
+
* ⇒ 此后该 traceId **0 次** lark messages-send / messages-reply
|
|
21
|
+
*
|
|
22
|
+
* 根因链:
|
|
23
|
+
* 1. 本工具只「抛 AskUserError」当作中断信号;
|
|
24
|
+
* 2. 交互层(REPL + readline)在守护进程(无 TTY)里是死的;
|
|
25
|
+
* 3. headless 下没人接这个异常 ⇒ 直接冒泡终止整次查询;
|
|
26
|
+
* 4. `query-executor.ts` 的 `isAskUserError → return` + `error-reply.ts` 的
|
|
27
|
+
* `ask_user` 规则 `notify:false` ⇒ **双重静默**,连失败兜底都不发。
|
|
28
|
+
*
|
|
29
|
+
* ⇒ **问题正文从未离开进程,用户零感知**(用户原话:「sub agent 的 ask_user 被淹没了」)。
|
|
30
|
+
*
|
|
31
|
+
* ## 本次修复(路线 A:工具自己投递)
|
|
32
|
+
*
|
|
33
|
+
* 在抛 AskUserError **之前**,若当前上下文存在可用的 IM 投递目标,
|
|
34
|
+
* 就**自己把问题(含选项)投递过去**,让用户真正看到并能答复。
|
|
35
|
+
*
|
|
36
|
+
* 契约:
|
|
37
|
+
* - C1 无投递目标 → 行为不变(抛 AskUserError,交给 TTY 交互层)
|
|
38
|
+
* - C2 有投递目标 → 先投递,再抛 AskUserError(中断信号保留,agent 本轮终止)
|
|
39
|
+
* - C3 投递失败 → **绝不抛**(不能让投递故障掩盖原始中断语义),只记 warn
|
|
40
|
+
* - C4 投递内容含问题正文 + 选项(用户要能选)
|
|
41
|
+
* - C5 投递目标从 EnvContext 取(replyChannel → envEvent.metadata.replyChannel)
|
|
42
|
+
*
|
|
43
|
+
* ⚠️ **为什么不在 CLI 层兜底**:CLI 层的兜底(query-executor / error-reply)都只能
|
|
44
|
+
* 看到「一次失败的查询」,拿不到「用户到底要回答什么」的结构化信息,而且要靠
|
|
45
|
+
* 规则表区分「TTY 场景该静默 / headless 场景该发」—— 极易再次静默。
|
|
46
|
+
* 在**工具层**投递是唯一能保证「问题一定离开进程」的位置。
|
|
47
|
+
*
|
|
48
|
+
* ⚠️ **TTY 场景不会重复发(精确条件)**:仅当「有可用投递目标
|
|
49
|
+
* (EnvContext.replyChannel 等)**且** TTY 交互层也会打印」时,
|
|
50
|
+
* 用户会同时看到 IM 那条和本地回显那条 ⇒ **两条,这不是 bug**:
|
|
51
|
+
* 投递到 IM 渠道的那条才是「离开进程」的那条;TTY 那条是给本地
|
|
52
|
+
* 用户看的回显。本地 TTY 通常**没有** replyChannel(不投);
|
|
53
|
+
* 有 replyChannel 且需要静音时,可通过
|
|
54
|
+
* `context.metadata.askUserDelivery === "off"` 关闭(workflow 路径
|
|
55
|
+
* 已默认关闭,agent-component-adapter.ts)。
|
|
6
56
|
*/
|
|
7
57
|
import { z } from 'zod';
|
|
8
58
|
import type { ToolInfo } from '../../tool/types';
|
|
@@ -31,5 +81,43 @@ export type AskUserInput = z.infer<typeof AskUserInputSchema>;
|
|
|
31
81
|
* catch and convert to a workflow pause event.
|
|
32
82
|
*/
|
|
33
83
|
export type AskUserTool = ToolInfo<typeof AskUserInputSchema>;
|
|
84
|
+
/**
|
|
85
|
+
* Task #4983 — 从 EnvContext 解析可用的 IM 投递目标。
|
|
86
|
+
*
|
|
87
|
+
* 优先级(与 buildRunEnvContext 的 replyChannel 优先级一致):
|
|
88
|
+
* 1. `envContext.replyChannel`(当前层已构建好的渠道,**带 sendMarkdown/reply 实现**)
|
|
89
|
+
* 2. `envContext.envEvent.metadata.replyChannel`(只有裸字段,没有发送实现)
|
|
90
|
+
*
|
|
91
|
+
* 只有 1 能真正发送(它带 `sendMarkdown` / `reply` 函数)。
|
|
92
|
+
* 2 只提供 chatId/messageId 快照 —— 在 core 层没有 lark-cli 发送器可用,
|
|
93
|
+
* 因此**不作为投递目标**(避免在这里 spawn lark-cli 造成职责外 IO)。
|
|
94
|
+
*/
|
|
95
|
+
interface DeliveryTarget {
|
|
96
|
+
chatId?: string;
|
|
97
|
+
messageId?: string;
|
|
98
|
+
profile?: string;
|
|
99
|
+
/** 真正能发消息的通道(EnvContext.replyChannel) */
|
|
100
|
+
channel?: {
|
|
101
|
+
sendMarkdown?: (text: string) => Promise<void>;
|
|
102
|
+
sendText?: (text: string) => Promise<void>;
|
|
103
|
+
reply?: (content: unknown) => Promise<void>;
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Task #4983 — 渲染投递到用户渠道的正文。
|
|
108
|
+
*
|
|
109
|
+
* 硬要求:
|
|
110
|
+
* - 必须含**问题正文**(用户要看的就是问题)
|
|
111
|
+
* - 必须含**全部选项**(用户要能选)
|
|
112
|
+
* - 必须含**答复指引**(用户不知道回哪儿答)
|
|
113
|
+
* - 绝不渲染 `undefined` / `NaN`
|
|
114
|
+
*/
|
|
115
|
+
export declare function buildAskUserDeliveryText(args: {
|
|
116
|
+
query: string;
|
|
117
|
+
options?: string[];
|
|
118
|
+
requiredConfirm?: boolean;
|
|
119
|
+
}): string;
|
|
120
|
+
export declare function deliverAskUserToChannel(target: DeliveryTarget, text: string): Promise<boolean>;
|
|
34
121
|
export declare const askUserTool: AskUserTool;
|
|
35
122
|
export declare const askUserToolInstance: AskUserTool;
|
|
123
|
+
export {};
|