@ai-setting/roy-agent-core 1.7.72 → 1.7.75
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 +12 -12
- package/dist/env/event-source/index.js +13 -13
- package/dist/env/index.js +30 -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 +3 -3
- package/dist/env/prompt/prompts-index.d.ts +24 -2
- package/dist/env/session/index.js +4 -4
- package/dist/env/session/storage/index.js +3 -3
- package/dist/env/task/delegate/delegate-tool.d.ts +8 -0
- package/dist/env/task/delegate/delegate-tool.js +4 -4
- package/dist/env/task/delegate/index.js +4 -4
- package/dist/env/task/index.js +7 -7
- package/dist/env/task/mcp/index.js +2 -2
- package/dist/env/task/plugins/index.d.ts +3 -0
- package/dist/env/task/plugins/index.js +32 -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 +1 -1
- package/dist/env/task/prompt/task-discipline.d.ts +9 -3
- package/dist/env/task/tools/cancel-tool.d.ts +28 -0
- package/dist/env/task/tools/index.d.ts +1 -0
- package/dist/env/task/tools/index.js +4 -2
- package/dist/env/task/tools/task-types.d.ts +22 -0
- 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.js +33 -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-4jjwewvw.js → roy-agent-core-11shp00p.js} +31 -10
- 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-34jz9mgh.js → roy-agent-core-29b6hc39.js} +1 -1
- package/dist/shared/@ai-setting/roy-agent-core-2akfd64z.js +374 -0
- package/dist/shared/@ai-setting/{roy-agent-core-yhwxpj12.js → roy-agent-core-3e6gg17d.js} +90 -12
- 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-2gzt2q8c.js → roy-agent-core-4gr3k7qg.js} +17 -4
- package/dist/shared/@ai-setting/{roy-agent-core-y12kyxwa.js → roy-agent-core-60jbrfye.js} +6 -6
- 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-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-pakhchy7.js → roy-agent-core-ddyk1rc0.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-jgb3bb42.js → roy-agent-core-djpq6yb0.js} +16 -7
- 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-7sj9xs9c.js → roy-agent-core-hnyk1by7.js} +110 -2
- package/dist/shared/@ai-setting/{roy-agent-core-7qvw65jt.js → roy-agent-core-jg65qnwa.js} +11 -8
- 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-wr7mv7k3.js → roy-agent-core-n9q1encx.js} +1 -1
- 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-snvh4s2p.js +662 -0
- 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-5gw0qa8m.js → roy-agent-core-y7x2qzwc.js} +553 -92
- 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
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createLogger,
|
|
3
|
+
init_logger
|
|
4
|
+
} from "./roy-agent-core-7f7t9wwp.js";
|
|
5
|
+
|
|
6
|
+
// src/env/tool/built-in/query-background-process-tool.ts
|
|
7
|
+
import { z } from "zod";
|
|
8
|
+
var QueryBackgroundProcessParameters = z.object({
|
|
9
|
+
bgProcessId: z.string().min(1, "bgProcessId must not be empty").describe("The background process ID returned by delegate_task " + "(format: process_<timestamp>_<random>).")
|
|
10
|
+
});
|
|
11
|
+
function backgroundTaskToOutput(task) {
|
|
12
|
+
return {
|
|
13
|
+
alive: task.status === "pending" || task.status === "running",
|
|
14
|
+
status: task.status,
|
|
15
|
+
createdAt: task.createdAt,
|
|
16
|
+
lastUpdatedAt: task.lastUpdatedAt ?? task.completedAt ?? task.startedAt ?? task.createdAt,
|
|
17
|
+
description: task.description,
|
|
18
|
+
...task.result !== undefined ? { result: task.result } : {},
|
|
19
|
+
...task.error !== undefined ? { error: task.error } : {}
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function notFoundOutput(bgProcessId) {
|
|
23
|
+
const now = Date.now();
|
|
24
|
+
return {
|
|
25
|
+
alive: false,
|
|
26
|
+
status: "not_found",
|
|
27
|
+
createdAt: now,
|
|
28
|
+
lastUpdatedAt: now,
|
|
29
|
+
description: `No background process found with id '${bgProcessId}'.`
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
var queryBackgroundProcessTool = {
|
|
33
|
+
name: "query_background_process",
|
|
34
|
+
description: `Query the status of a background process previously launched via delegate_task.
|
|
35
|
+
|
|
36
|
+
` + `Use this tool when:
|
|
37
|
+
` + ` - You delegated a long-running task but have NOT received any notification after a reasonable wait (5+ minutes), and want to confirm whether the process is still alive.
|
|
38
|
+
` + ` - The user asks about the progress of a delegated task and you need a current snapshot.
|
|
39
|
+
` + ` - You suspect a delegated task got stuck (no progress messages, no completion notification).
|
|
40
|
+
|
|
41
|
+
` + `DO NOT poll this tool on every turn — it is meant for diagnostic checks at a reasonable cadence (e.g. every few minutes, or when you genuinely suspect the task is stuck).
|
|
42
|
+
|
|
43
|
+
` + `Returns a JSON object with:
|
|
44
|
+
` + ` - alive: boolean — true if status is 'pending' or 'running'
|
|
45
|
+
` + ` - status: 'pending' | 'running' | 'completed' | 'failed' | 'stopped' | 'timeout' | 'not_found'
|
|
46
|
+
` + ` - createdAt, lastUpdatedAt: timestamps (ms)
|
|
47
|
+
` + ` - description: the task description you passed to delegate_task
|
|
48
|
+
` + ` - result: present when status is 'completed'
|
|
49
|
+
` + ` - error: present when status is 'failed'
|
|
50
|
+
|
|
51
|
+
` + "Only the default receptionist agent has this tool. Sub-agents (roy, strict-task-agent, etc.) cannot see it because they do not need to query background tasks they themselves launched.",
|
|
52
|
+
parameters: QueryBackgroundProcessParameters,
|
|
53
|
+
permission: {
|
|
54
|
+
level: "safe",
|
|
55
|
+
requireConfirmation: false
|
|
56
|
+
},
|
|
57
|
+
metadata: {
|
|
58
|
+
category: "task",
|
|
59
|
+
tags: ["background", "delegate", "query", "status", "diagnostic"],
|
|
60
|
+
version: "1.0.0",
|
|
61
|
+
allowedAgentTypes: ["default"]
|
|
62
|
+
},
|
|
63
|
+
execute: async (args, ctx) => createQueryBackgroundProcessTool(null).execute(args, ctx)
|
|
64
|
+
};
|
|
65
|
+
function createQueryBackgroundProcessTool(manager = null) {
|
|
66
|
+
return {
|
|
67
|
+
name: "query_background_process",
|
|
68
|
+
description: `Query the status of a background process previously launched via delegate_task.
|
|
69
|
+
|
|
70
|
+
` + `Use this tool when:
|
|
71
|
+
` + ` - You delegated a long-running task but have NOT received any notification after a reasonable wait (5+ minutes), and want to confirm whether the process is still alive.
|
|
72
|
+
` + ` - The user asks about the progress of a delegated task and you need a current snapshot.
|
|
73
|
+
` + ` - You suspect a delegated task got stuck (no progress messages, no completion notification).
|
|
74
|
+
|
|
75
|
+
` + `DO NOT poll this tool on every turn — it is meant for diagnostic checks at a reasonable cadence (e.g. every few minutes, or when you genuinely suspect the task is stuck).
|
|
76
|
+
|
|
77
|
+
` + `Returns a JSON object with:
|
|
78
|
+
` + ` - alive: boolean — true if status is 'pending' or 'running'
|
|
79
|
+
` + ` - status: 'pending' | 'running' | 'completed' | 'failed' | 'stopped' | 'timeout' | 'not_found'
|
|
80
|
+
` + ` - createdAt, lastUpdatedAt: timestamps (ms)
|
|
81
|
+
` + ` - description: the task description you passed to delegate_task
|
|
82
|
+
` + ` - result: present when status is 'completed'
|
|
83
|
+
` + ` - error: present when status is 'failed'
|
|
84
|
+
|
|
85
|
+
` + "Only the default receptionist agent has this tool. Sub-agents (roy, strict-task-agent, etc.) cannot see it because they do not need to query background tasks they themselves launched.",
|
|
86
|
+
parameters: QueryBackgroundProcessParameters,
|
|
87
|
+
permission: {
|
|
88
|
+
level: "safe",
|
|
89
|
+
requireConfirmation: false
|
|
90
|
+
},
|
|
91
|
+
metadata: {
|
|
92
|
+
category: "task",
|
|
93
|
+
tags: ["background", "delegate", "query", "status", "diagnostic"],
|
|
94
|
+
version: "1.0.0",
|
|
95
|
+
allowedAgentTypes: ["default"]
|
|
96
|
+
},
|
|
97
|
+
execute: async (args, ctx) => {
|
|
98
|
+
const startTime = Date.now();
|
|
99
|
+
const params = QueryBackgroundProcessParameters.parse(args);
|
|
100
|
+
const { bgProcessId } = params;
|
|
101
|
+
if (!manager) {
|
|
102
|
+
return {
|
|
103
|
+
success: false,
|
|
104
|
+
output: "",
|
|
105
|
+
error: "query_background_process is not initialized: no BackgroundTaskManager " + "has been bound. TaskComponent should call " + "createQueryBackgroundProcessTool(manager) and register the tool " + "during startup.",
|
|
106
|
+
metadata: { execution_time_ms: Date.now() - startTime }
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
let task;
|
|
110
|
+
try {
|
|
111
|
+
task = manager.getTask(bgProcessId);
|
|
112
|
+
} catch (err) {
|
|
113
|
+
return {
|
|
114
|
+
success: false,
|
|
115
|
+
output: "",
|
|
116
|
+
error: `failed to query background task: ${err.message}`,
|
|
117
|
+
metadata: { execution_time_ms: Date.now() - startTime }
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
if (task) {
|
|
121
|
+
const currentSessionId = ctx.session_id;
|
|
122
|
+
if (!currentSessionId || task.parentSessionId !== currentSessionId) {
|
|
123
|
+
return {
|
|
124
|
+
success: true,
|
|
125
|
+
output: JSON.stringify(notFoundOutput(bgProcessId), null, 2),
|
|
126
|
+
metadata: {
|
|
127
|
+
execution_time_ms: Date.now() - startTime,
|
|
128
|
+
bgProcessId,
|
|
129
|
+
status: "not_found",
|
|
130
|
+
alive: false
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
const output = task ? backgroundTaskToOutput(task) : notFoundOutput(bgProcessId);
|
|
136
|
+
if (output.alive) {
|
|
137
|
+
try {
|
|
138
|
+
const activity = await manager.getSubSessionActivity?.(bgProcessId);
|
|
139
|
+
if (activity) {
|
|
140
|
+
output.lastUpdatedAt = Math.max(output.lastUpdatedAt, activity.updatedAt);
|
|
141
|
+
output.messageCount = activity.messageCount;
|
|
142
|
+
output.subSessionUpdatedAt = activity.updatedAt;
|
|
143
|
+
}
|
|
144
|
+
} catch {}
|
|
145
|
+
}
|
|
146
|
+
return {
|
|
147
|
+
success: true,
|
|
148
|
+
output: JSON.stringify(output, null, 2),
|
|
149
|
+
metadata: {
|
|
150
|
+
execution_time_ms: Date.now() - startTime,
|
|
151
|
+
bgProcessId,
|
|
152
|
+
status: output.status,
|
|
153
|
+
alive: output.alive
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// src/env/tool/built-in/compact-session-tool.ts
|
|
161
|
+
init_logger();
|
|
162
|
+
import { z as z2 } from "zod";
|
|
163
|
+
var logger = createLogger("compact-session-tool");
|
|
164
|
+
var CompactSessionParameters = z2.object({
|
|
165
|
+
session_id: z2.string().min(1, "session_id must not be empty").describe("The sub-session ID to compact (format: session_xxx or oc_xxx). " + "Must be a sub-session previously created via delegate_task " + "(the bgProcess notification reports its subSessionId).")
|
|
166
|
+
});
|
|
167
|
+
function compactSessionNotFoundOutput(sessionId) {
|
|
168
|
+
return {
|
|
169
|
+
status: "not_found",
|
|
170
|
+
sessionId
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
function findTaskBySubSessionId(manager, sessionId) {
|
|
174
|
+
const tasks = manager.listTasks() ?? [];
|
|
175
|
+
const bySubSession = tasks.find((t) => t.subSessionId === sessionId);
|
|
176
|
+
if (bySubSession)
|
|
177
|
+
return bySubSession;
|
|
178
|
+
return manager.getTask(sessionId);
|
|
179
|
+
}
|
|
180
|
+
function isOwnSubSession(task, currentSessionId) {
|
|
181
|
+
if (!task || !currentSessionId)
|
|
182
|
+
return false;
|
|
183
|
+
return task.parentSessionId === currentSessionId;
|
|
184
|
+
}
|
|
185
|
+
function isTaskActive(task) {
|
|
186
|
+
return task?.status === "running" || task?.status === "pending";
|
|
187
|
+
}
|
|
188
|
+
function createCompactSessionTool(backgroundTaskManager = null, sessionComponent = null) {
|
|
189
|
+
return {
|
|
190
|
+
name: "compact_session",
|
|
191
|
+
description: "Compact (compress) a sub-agent session by summarizing its history " + "into a checkpoint and archiving the old messages, so the session " + "can be REUSED with delegate_task(sub_session_id=...) without " + `exceeding the context threshold.
|
|
192
|
+
|
|
193
|
+
` + `Use this tool when:
|
|
194
|
+
` + " - A delegated sub-agent returned 'Context threshold exceeded' " + "(e.g. 125575/120000 tokens) and you want to continue the SAME " + `sub-session instead of losing all its progress.
|
|
195
|
+
` + " - A sub-session is very long and the next resume would likely " + `hit the context limit again.
|
|
196
|
+
|
|
197
|
+
` + `Behavior:
|
|
198
|
+
` + " 1. Generates a checkpoint (natural-language summary of the " + `conversation so far)
|
|
199
|
+
` + " 2. Archives the old messages (they remain queryable but leave " + `the active context)
|
|
200
|
+
` + ` 3. Returns a JSON summary of the compaction
|
|
201
|
+
|
|
202
|
+
` + `After compaction succeeds, resume the sub-session with:
|
|
203
|
+
` + ' delegate_task(subagent_type="...", sub_session_id="<same id>", ' + `prompt="continue from the checkpoint")
|
|
204
|
+
|
|
205
|
+
` + `Guards:
|
|
206
|
+
` + ` - You CANNOT compact your own current session (self-destruction).
|
|
207
|
+
` + ` - You can only compact sub-sessions YOU delegated (ownership check).
|
|
208
|
+
` + " - A session whose background task is still running/pending cannot " + `be compacted (stop_task it first to avoid corrupting live state).
|
|
209
|
+
|
|
210
|
+
` + "Only the default receptionist agent has this tool.",
|
|
211
|
+
parameters: CompactSessionParameters,
|
|
212
|
+
permission: {
|
|
213
|
+
level: "safe",
|
|
214
|
+
requireConfirmation: false
|
|
215
|
+
},
|
|
216
|
+
metadata: {
|
|
217
|
+
category: "task",
|
|
218
|
+
tags: ["compact", "session", "delegate", "checkpoint", "context"],
|
|
219
|
+
version: "1.0.0",
|
|
220
|
+
allowedAgentTypes: ["default"]
|
|
221
|
+
},
|
|
222
|
+
execute: async (args, ctx) => {
|
|
223
|
+
const startTime = Date.now();
|
|
224
|
+
const params = CompactSessionParameters.parse(args);
|
|
225
|
+
const sessionId = params.session_id;
|
|
226
|
+
if (!backgroundTaskManager || !sessionComponent) {
|
|
227
|
+
return {
|
|
228
|
+
success: false,
|
|
229
|
+
output: "",
|
|
230
|
+
error: "compact_session is not initialized: no BackgroundTaskManager " + "or SessionComponent has been bound. TaskComponent should call " + "createCompactSessionTool(manager, sessionComponent) and " + "register the tool during startup.",
|
|
231
|
+
metadata: { execution_time_ms: Date.now() - startTime }
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
const currentSessionId = ctx.session_id;
|
|
235
|
+
if (currentSessionId && sessionId === currentSessionId) {
|
|
236
|
+
return {
|
|
237
|
+
success: false,
|
|
238
|
+
output: "",
|
|
239
|
+
error: `Refusing to compact session '${sessionId}': it is your OWN ` + `current session. Compacting it would destroy your own active ` + `context. Only sub-sessions you delegated can be compacted.`,
|
|
240
|
+
metadata: { execution_time_ms: Date.now() - startTime }
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
if (!currentSessionId) {
|
|
244
|
+
return {
|
|
245
|
+
success: false,
|
|
246
|
+
output: "",
|
|
247
|
+
error: "compact_session requires a current session context " + "(ctx.session_id) to verify ownership, but none was provided.",
|
|
248
|
+
metadata: { execution_time_ms: Date.now() - startTime }
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
const task = findTaskBySubSessionId(backgroundTaskManager, sessionId);
|
|
252
|
+
if (!task || !isOwnSubSession(task, currentSessionId)) {
|
|
253
|
+
logger.warn("[compact_session] not_found (unknown or foreign sub-session)", { sessionId, currentSessionId });
|
|
254
|
+
return {
|
|
255
|
+
success: true,
|
|
256
|
+
output: JSON.stringify(compactSessionNotFoundOutput(sessionId), null, 2),
|
|
257
|
+
metadata: {
|
|
258
|
+
execution_time_ms: Date.now() - startTime,
|
|
259
|
+
sessionId,
|
|
260
|
+
status: "not_found"
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
if (isTaskActive(task)) {
|
|
265
|
+
return {
|
|
266
|
+
success: false,
|
|
267
|
+
output: "",
|
|
268
|
+
error: `Cannot compact session '${sessionId}': its background task ` + `'${task.id}' is still ${task.status}. The sub-agent writes ` + `to this session every ReAct iteration; archiving messages ` + `now would corrupt live state. Run ` + `stop_task(task_id="${task.id}") first, then compact the ` + `session.`,
|
|
269
|
+
metadata: {
|
|
270
|
+
execution_time_ms: Date.now() - startTime,
|
|
271
|
+
sessionId,
|
|
272
|
+
bgProcessId: task.id,
|
|
273
|
+
taskStatus: task.status
|
|
274
|
+
}
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
let preview;
|
|
278
|
+
try {
|
|
279
|
+
preview = await sessionComponent.previewCompact(sessionId);
|
|
280
|
+
} catch (err) {
|
|
281
|
+
return {
|
|
282
|
+
success: false,
|
|
283
|
+
output: "",
|
|
284
|
+
error: `failed to preview compaction for session '${sessionId}': ` + `${err.message}`,
|
|
285
|
+
metadata: { execution_time_ms: Date.now() - startTime }
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
if (!preview || preview.messageCountToCompact < 3) {
|
|
289
|
+
return {
|
|
290
|
+
success: false,
|
|
291
|
+
output: "",
|
|
292
|
+
error: `Cannot compact session '${sessionId}': minimum 3 compactable ` + `messages required (found ` + `${preview?.messageCountToCompact ?? 0}).`,
|
|
293
|
+
metadata: {
|
|
294
|
+
execution_time_ms: Date.now() - startTime,
|
|
295
|
+
sessionId,
|
|
296
|
+
messageCountToCompact: preview?.messageCountToCompact ?? 0
|
|
297
|
+
}
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
let scenarioHint = "";
|
|
301
|
+
try {
|
|
302
|
+
scenarioHint = await sessionComponent.generateCompactHint(sessionId);
|
|
303
|
+
} catch (err) {
|
|
304
|
+
logger.warn("[compact_session] hint generation failed, continuing with empty hint", { sessionId, error: err.message });
|
|
305
|
+
scenarioHint = "";
|
|
306
|
+
}
|
|
307
|
+
let compactResult;
|
|
308
|
+
try {
|
|
309
|
+
compactResult = await sessionComponent.compact(sessionId, {
|
|
310
|
+
scenarioHint
|
|
311
|
+
});
|
|
312
|
+
} catch (err) {
|
|
313
|
+
const message = err.message;
|
|
314
|
+
logger.error(`[compact_session] compact failed: ${message}`, {
|
|
315
|
+
sessionId
|
|
316
|
+
});
|
|
317
|
+
return {
|
|
318
|
+
success: false,
|
|
319
|
+
output: "",
|
|
320
|
+
error: `compaction failed for session '${sessionId}': ${message}`,
|
|
321
|
+
metadata: {
|
|
322
|
+
execution_time_ms: Date.now() - startTime,
|
|
323
|
+
sessionId
|
|
324
|
+
}
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
try {
|
|
328
|
+
const env = backgroundTaskManager.env;
|
|
329
|
+
env?.pushEnvEvent?.({
|
|
330
|
+
type: "context.compacted",
|
|
331
|
+
metadata: { sessionId },
|
|
332
|
+
payload: {
|
|
333
|
+
checkpointId: compactResult.checkpoint.id,
|
|
334
|
+
messagesCompacted: compactResult.deletedMessageCount,
|
|
335
|
+
scenarioHintUsed: scenarioHint.length > 0,
|
|
336
|
+
source: "compact_session_tool"
|
|
337
|
+
}
|
|
338
|
+
});
|
|
339
|
+
} catch (err) {
|
|
340
|
+
logger.warn("[compact_session] failed to push context.compacted event", { sessionId, error: err.message });
|
|
341
|
+
}
|
|
342
|
+
const output = {
|
|
343
|
+
status: "compacted",
|
|
344
|
+
sessionId,
|
|
345
|
+
checkpointId: compactResult.checkpoint.id,
|
|
346
|
+
checkpointTitle: compactResult.checkpoint.title,
|
|
347
|
+
contentLength: compactResult.checkpoint.content?.length ?? 0,
|
|
348
|
+
originalMessages: preview.messageCountToCompact,
|
|
349
|
+
deletedMessages: compactResult.deletedMessageCount,
|
|
350
|
+
remainingMessages: compactResult.remainingMessageCount,
|
|
351
|
+
hintUsed: scenarioHint.length > 0
|
|
352
|
+
};
|
|
353
|
+
logger.info("[compact_session] session compacted", {
|
|
354
|
+
sessionId,
|
|
355
|
+
checkpointId: output.checkpointId,
|
|
356
|
+
deletedMessages: output.deletedMessages,
|
|
357
|
+
remainingMessages: output.remainingMessages
|
|
358
|
+
});
|
|
359
|
+
return {
|
|
360
|
+
success: true,
|
|
361
|
+
output: JSON.stringify(output, null, 2),
|
|
362
|
+
metadata: {
|
|
363
|
+
execution_time_ms: Date.now() - startTime,
|
|
364
|
+
sessionId,
|
|
365
|
+
status: "compacted",
|
|
366
|
+
checkpointId: output.checkpointId
|
|
367
|
+
}
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
};
|
|
371
|
+
}
|
|
372
|
+
var compactSessionTool = createCompactSessionTool(null, null);
|
|
373
|
+
|
|
374
|
+
export { queryBackgroundProcessTool, createQueryBackgroundProcessTool, createCompactSessionTool, compactSessionTool };
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
TASK_COMPLETE_VERIFY_DUTY,
|
|
4
4
|
TASK_COMPLETION_HINT_ANCHOR,
|
|
5
5
|
TASK_DISCIPLINE_PROMPT
|
|
6
|
-
} from "./roy-agent-core-
|
|
6
|
+
} from "./roy-agent-core-11shp00p.js";
|
|
7
7
|
|
|
8
8
|
// src/env/prompt/prompts-index.ts
|
|
9
9
|
var builtInPrompts = {
|
|
@@ -14,7 +14,8 @@ var builtInPrompts = {
|
|
|
14
14
|
> **本 prompt 中部分段落(如 \`delegate_task(...)\` 调用模板、行为规则 6 里的引用)是**你转交给 sub-agent(通常是 \`roy\`)的示例指令**,不代表你自己能直接调用其中提到的所有工具**。
|
|
15
15
|
>
|
|
16
16
|
> 具体来说:
|
|
17
|
-
> - \`delegate_task(...)\` 调用里的 prompt 模板中可能提到 \`task_create\` / \`task_update\` / \`task_operation_create\`
|
|
17
|
+
> - \`delegate_task(...)\` 调用里的 prompt 模板中可能提到 \`task_create\` / \`task_update\` / \`task_operation_create\` 等工具 —— 这些是**指示子 agent 用的**,不是你自己的工具(你已被 \`deniedTools\` 禁用)。
|
|
18
|
+
> - ⚠️ **例外(Task #5007)**:\`task_complete\` / \`task_cancel\` 是**你自己的验收工具**(见"## 任务验收职责"),不在禁用列表里。
|
|
18
19
|
> - 你**自己**真正可用的工具,**严格以下方"## 你的工具"区块中的工具表为准**。
|
|
19
20
|
>
|
|
20
21
|
> 如果你读到 prompt 里有工具名但下方工具表里没有该工具 —— **不要尝试调用**,那是给子 agent 的示例。
|
|
@@ -52,6 +53,8 @@ var builtInPrompts = {
|
|
|
52
53
|
| \`delegate_task\` | **执行** | 委托复杂/多步骤任务给子智能体执行(后台模式,立即返回) |
|
|
53
54
|
| \`query_background_process\` | **执行** | 查询由 \`delegate_task\` 启动的后台进程当前状态(仅 default agent 可见) |
|
|
54
55
|
| \`bash\` | **执行** | 仅用于执行一行简单的 shell 命令 |
|
|
56
|
+
| \`task_complete\` | **验收** | 验收通过 ⇒ 任务置为 completed(触发 goal 检查 decision model) |
|
|
57
|
+
| \`task_cancel\` | **验收** | 验收不通过 / 用户要求 ⇒ 任务置为 cancelled |
|
|
55
58
|
|
|
56
59
|
### 查询工具(可直接使用)
|
|
57
60
|
|
|
@@ -132,7 +135,7 @@ var builtInPrompts = {
|
|
|
132
135
|
- ✅ 功能开发、bug 修复、重构、文档生成
|
|
133
136
|
- ✅ 网络搜索和研究
|
|
134
137
|
|
|
135
|
-
**roy** 的提示词中内置了任务生命周期——它知道如何使用 \`task_create\`、\`task_update\`、\`task_operation_create\`
|
|
138
|
+
**roy** 的提示词中内置了任务生命周期——它知道如何使用 \`task_create\`、\`task_update\`、\`task_operation_create\` 来跟踪每项工作并留下操作记录。⚠️ **Task #5007**:roy **没有** \`task_complete\` 权限 —— 它把进度推到 100% 即视为完成并结束返回,**最终验收(${TASK_COMPLETE_ITEM_BY_ITEM} + goal 检查 decision model)由你(default agent)来触发**。若验收时收到 [${TASK_COMPLETION_HINT_ANCHOR}],按工具描述里的${TASK_COMPLETE_VERIFY_DUTY}二选一(重开 / 落 decision 说明理由)。
|
|
136
139
|
|
|
137
140
|
推荐使用:
|
|
138
141
|
\`\`\`
|
|
@@ -140,7 +143,9 @@ delegate_task(
|
|
|
140
143
|
description="简要 3-5 字摘要",
|
|
141
144
|
prompt="详细说明。
|
|
142
145
|
|
|
143
|
-
重要:遵循任务作为一等公民原则 — 使用 \`task_create\` 创建任务,使用 \`task_update\` 跟踪进度,使用 \`task_operation_create\`
|
|
146
|
+
重要:遵循任务作为一等公民原则 — 使用 \`task_create\` 创建任务,使用 \`task_update\` 跟踪进度,使用 \`task_operation_create\` 记录里程碑。
|
|
147
|
+
|
|
148
|
+
⚠️ 不要调用 \`task_complete\`(你无此权限):进度达到 100% 后直接结束并返回结果,验收由主智能体(default agent)负责。",
|
|
144
149
|
subagent_type="roy",
|
|
145
150
|
similar_task_ids=[] // 必填:先使用 task_search 搜索相似任务,将找到的 ID 填入此处(最多 3 个)
|
|
146
151
|
)
|
|
@@ -212,13 +217,60 @@ delegate_task(
|
|
|
212
217
|
)
|
|
213
218
|
\`\`\`
|
|
214
219
|
|
|
220
|
+
## 任务验收职责(Task #5007 —— 你是裁判,roy 是运动员)
|
|
221
|
+
|
|
222
|
+
> **架构约定**:执行与验收**分离**。sub-agent(\`roy\`)负责**干活 + 记操作记录 + 报进度**;
|
|
223
|
+
> **你(default agent)负责最终验收**。sub-agent **没有** \`task_complete\` 权限 ——
|
|
224
|
+
> 它把进度推到 100% 就结束返回,由**你**来判定这活到底算不算做完。
|
|
225
|
+
>
|
|
226
|
+
> **为什么这样分**:
|
|
227
|
+
> ① **裁判 ≠ 运动员** —— 同一个 agent 既写又批,容易自己给自己放行;
|
|
228
|
+
> ② **状态不会烂尾** —— sub-agent 可能超时 / 崩掉 / 没来得及更新状态,
|
|
229
|
+
> 任务就会长期挂在 active。你能主动查、主动补验收、主动取消。
|
|
230
|
+
|
|
231
|
+
### 何时验收
|
|
232
|
+
|
|
233
|
+
| 触发时机 | 你要做什么 |
|
|
234
|
+
|---|---|
|
|
235
|
+
| 收到 sub-agent **完成通知** | 走下面的"验收四步" |
|
|
236
|
+
| 收到 **timeout / failed** 通知 | 判断是否值得重试;不值得就 \`task_cancel\` |
|
|
237
|
+
| 用户问"那个任务怎么样了" | \`task_get\` 查实际状态,落后于进度就补验收 |
|
|
238
|
+
| 用户说"取消 / 停掉这个任务" | \`task_cancel\`(若 sub-agent 还在跑,先 \`stop_task\` 掐进程) |
|
|
239
|
+
|
|
240
|
+
### 验收四步(⚠️ 不要跳过第 1 步)
|
|
241
|
+
|
|
242
|
+
1. **核对实际产出** —— \`task_get(task_id=<id>)\` 读任务的 \`goal\`(description)、
|
|
243
|
+
\`delivery\`(goals_and_expected_deliverables)和**操作记录链**(\`task_operation_list\`),
|
|
244
|
+
再对照真实交付物:文件是否存在、测试是否通过、review 结论是什么。
|
|
245
|
+
⚠️ **不接受 sub-agent 的自述作为验收依据** —— 它说"做完了"不算,产出在才算。
|
|
246
|
+
2. **逐条对照子项** —— goals 是**编号子项**,一条一条核(文件断言 / 进程断言 / 测试断言 / 状态断言)。
|
|
247
|
+
3. **决定**:
|
|
248
|
+
- ✅ 全部达成 → \`task_complete(task_id=<id>, deliverable_storage_path="<交付物地址>")\`
|
|
249
|
+
(这一步会触发 goal 检查的 decision model;可能收到 \`[TASK_COMPLETION_HINT]\`,
|
|
250
|
+
收到就按工具描述里的**核实义务**处理:重开 or 落 decision 说明理由)
|
|
251
|
+
- ⚠️ 差距不大 → 重新委托(\`delegate_task\` + \`sub_session_id\` 续跑),别急着取消
|
|
252
|
+
- ❌ 不值得继续 / 用户要求 → \`task_cancel(task_id=<id>, reason="<原因>")\`
|
|
253
|
+
4. **留痕** —— 验收结论要写进任务上下文(\`task_get\` 能看到的状态)或汇报给用户。
|
|
254
|
+
|
|
255
|
+
### ⚠️ 你不做执行
|
|
256
|
+
|
|
257
|
+
你**不创建**任务、**不更新**进度 —— \`task_create\` / \`task_update\` 仍在你的 \`deniedTools\` 里。
|
|
258
|
+
执行是 sub-agent 的活,验收是你的活。
|
|
259
|
+
|
|
260
|
+
### ✅ 你可以记操作记录(Task #5007 后续优化)
|
|
261
|
+
|
|
262
|
+
\`task_operation_create\` **已从** \`deniedTools\` **移除**。你可以用它把用户的反馈 / 说明 / 强调点
|
|
263
|
+
记录到任务操作记录中。sub-agent 续推时通过 \`task_operation_list\` 读取最新记录来理解上下文。
|
|
264
|
+
操作记录因此成为 agents 间的通信介质(不只是人工日志)。
|
|
265
|
+
|
|
215
266
|
## 如何处理用户请求
|
|
216
267
|
|
|
217
268
|
1. **理解** — 用户到底想要什么?
|
|
218
269
|
2. **分类** — 如果需要任何超出简单对话的操作 → 委托。如果是问候/一次性回答 → 直接回复。
|
|
219
270
|
3. **选择智能体** — \`roy\`(默认)、\`workflow-runner\`(调用 workflow)、\`workflow-creator\`(用户主动构建 workflow)
|
|
220
|
-
4. **搜索相似任务并委托** — 在委托前,先使用 \`task_search\` 搜索与当前请求相关的历史任务,将找到的相似任务 ID 填入 \`similar_task_ids\` 参数。在给子智能体的提示词中,始终包含简要指令,要求将工作视为任务一等公民:创建任务(\`task_create
|
|
221
|
-
5.
|
|
271
|
+
4. **搜索相似任务并委托** — 在委托前,先使用 \`task_search\` 搜索与当前请求相关的历史任务,将找到的相似任务 ID 填入 \`similar_task_ids\` 参数。在给子智能体的提示词中,始终包含简要指令,要求将工作视为任务一等公民:创建任务(\`task_create\`)、跟踪进度(\`task_update\`)、记录里程碑(\`task_operation_create\`)。
|
|
272
|
+
5. **验收** — 收到 sub-agent 完成通知后,按上方"任务验收职责"核对产出,再决定 \`task_complete\` / 重新委托 / \`task_cancel\`。
|
|
273
|
+
6. **汇报结果** — 向用户总结结果
|
|
222
274
|
|
|
223
275
|
## Workflow 创建委托指南(重要)
|
|
224
276
|
|
|
@@ -261,7 +313,8 @@ delegate_task(
|
|
|
261
313
|
4. **首选 roy** — 首次委托默认使用 \`roy\`
|
|
262
314
|
5. **workflow-runner** — 凡是走 workflow 解决的任务(包括兼容旧名 \`strict-task-agent\` / \`code-review\` / \`bench-agent-host\` / \`workspace-analyzer\` / \`test-workflow-agent\`,自动重写),都委托给它
|
|
263
315
|
5a. ⚠️ **workflow-creator** — 用户说"帮建 workflow" / "封装成 workflow" / "再造个变体" / "想基于 XXX workflow 改造",**必须委托**,default agent 自己**禁止**用 bash \`workflow add/validate/tag list\` 手撸。手撸已废弃,统一走 workflow-creator(与 workflow-extract one-shot 不同,workflow-creator 是多轮对话式协作)
|
|
264
|
-
6. **始终包含任务生命周期** — 每次委托时,指示子智能体使用 \`task_create\` → \`task_update\` → \`task_operation_create
|
|
316
|
+
6. **始终包含任务生命周期** — 每次委托时,指示子智能体使用 \`task_create\` → \`task_update\` → \`task_operation_create\`(⚠️ **不要**指示它用 \`task_complete\` —— 验收权在你手上,Task #5007)
|
|
317
|
+
6a. **⚠️ 验收权在你(default agent)** — sub-agent 交回结果后,**你**用 \`task_complete\` / \`task_cancel\` 落终态(见"任务验收职责")。不要在委托 prompt 里让 sub-agent 自己 \`task_complete\` —— 那是它没有的权限(会被 deniedTools 拦掉,白白浪费一轮迭代)。
|
|
265
318
|
7. **简单回复** — 对于问候、简单问答或结果总结,可以直接回复
|
|
266
319
|
8. **⚠️ 不要 sleep 等待后台任务结果** — \`delegate_task\` 总是后台模式(参见下方"子代理通知自主处理规则"),委托后**立即返回**。**禁止**调用 \`sleep\`、\`wait\`、\`sleep N\` 等任何同步等待命令试图"等子智能体跑完"。原因:
|
|
267
320
|
- \`sleep\` 会阻塞当前 ReAct 循环,导致**无法及时接收**后台进程或子智能体的通知消息
|
|
@@ -276,13 +329,16 @@ delegate_task(
|
|
|
276
329
|
当你通过 \`delegate_task\` 委托任务给子智能体后,会收到后台任务通知。你必须**自主处理**这些通知,而不是询问用户:
|
|
277
330
|
|
|
278
331
|
### 1. 任务成功通知(✅ completed)
|
|
279
|
-
-
|
|
280
|
-
-
|
|
281
|
-
-
|
|
332
|
+
- ⚠️ **这不等于验收通过** —— sub-agent 只负责把进度推到 100%,**判定权在你**
|
|
333
|
+
- 按"任务验收职责"的**验收四步**走:\`task_get\` 核对实际产出 → 逐条对照 goals 子项 → 决定
|
|
334
|
+
- ✅ 达成 → \`task_complete(task_id=<id>, deliverable_storage_path="<交付物地址>")\`
|
|
335
|
+
- ⚠️ 差距不大 → \`delegate_task\` + \`sub_session_id\` 重新委托续跑
|
|
336
|
+
- ❌ 不值得继续 / 用户要求 → \`task_cancel(task_id=<id>, reason="<原因>")\`
|
|
337
|
+
- 如果 sub-agent **没有**告诉你任务号,用 \`task_search\` 按标题/描述找回关联的 Task
|
|
282
338
|
|
|
283
339
|
### 2. 任务失败通知(❌ failed)
|
|
284
340
|
- 分析失败原因,尝试提出修复方案并重新委托子代理执行
|
|
285
|
-
- 最多尝试 2-3
|
|
341
|
+
- 最多尝试 2-3 次,如果仍然失败,记录失败原因并知会用户;确定不再继续时 \`task_cancel\` 收尾
|
|
286
342
|
|
|
287
343
|
### 3. 任务需要决策通知(\uD83D\uDD04 progress update)
|
|
288
344
|
- 子代理在推进过程中遇到需要决策的问题时
|
|
@@ -819,7 +875,6 @@ roy-agent <command> <subcmd> --help
|
|
|
819
875
|
| \`task_get\` | Get detailed information about a specific task |
|
|
820
876
|
| \`task_update\` | Update task status, progress, priority, or properties |
|
|
821
877
|
| \`task_list\` | List tasks with optional filters for status/priority |
|
|
822
|
-
| \`task_complete\` | Mark a task as completed (progress=100, status=completed). Creates an operation record. |
|
|
823
878
|
| \`task_delete\` | Delete a task and all its operation records |
|
|
824
879
|
| \`task_operation_create\` | Create operation records — **双维度**: milestone_* (状态/里程碑) + process_description (过程, 100-500 字符) |
|
|
825
880
|
| \`task_operation_list\` | List operation records for a task |
|
|
@@ -832,6 +887,29 @@ roy-agent <command> <subcmd> --help
|
|
|
832
887
|
|------|-----------|-------------|
|
|
833
888
|
| \`delegate_task\` | 子 agent 委托入口,由 \`default\` 接待员独占 | 直接用 \`bash\` / \`read_file\` / \`edit_file\` 等工具自己完成任务;若是真正的复杂多步任务,建议用户切换到 \`default\` agent |
|
|
834
889
|
| \`stop_task\` | 后台进程管理入口,由 \`default\` 接待员独占 | 你无法启动后台进程,自然不需要 \`stop_task\` |
|
|
890
|
+
| \`task_complete\` | **验收权归 \`default\` 接待员**(Task #5007,裁判 ≠ 运动员) | 把进度推到 100%、记完操作记录,然后**结束并返回结果**;验收由主智能体用 \`task_complete\` 落终态 |
|
|
891
|
+
|
|
892
|
+
### ⚠️ 你的职责边界:执行 + 记录,不做验收(Task #5007)
|
|
893
|
+
|
|
894
|
+
> **架构约定**:执行与验收**分离**。你是**执行方**(运动员),主智能体(\`default\` 接待员)是**验收方**(裁判)。
|
|
895
|
+
>
|
|
896
|
+
> **你负责的**:
|
|
897
|
+
> 1. \`task_create\` 建任务(goals 写成**编号子项**,可逐条验收)
|
|
898
|
+
> 2. \`task_update\` 跟踪进度(0→100%)
|
|
899
|
+
> 3. \`task_operation_create\` 记录里程碑 / 过程 / 结论(**边干边记**,别事后补)
|
|
900
|
+
>
|
|
901
|
+
> **你不负责的**:
|
|
902
|
+
> - ❌ **不要调用 \`task_complete\`** —— 你没有这个权限(调用会被 deniedTools 拦掉,白白浪费一轮迭代)
|
|
903
|
+
> - ❌ 不要自己宣布"任务完成"就当结束 —— 你的完成只是"我这边干完了"
|
|
904
|
+
>
|
|
905
|
+
> **你怎么"完成"**:
|
|
906
|
+
> 进度达到你判断的 **100%** 时,把 \`task_update(progress=100)\` 和最后一条
|
|
907
|
+
> \`task_operation_create\` 落下,**然后结束当前回合,把结果返回给主智能体**。
|
|
908
|
+
> 主智能体收到后会核对实际产出(文件在不在、测试过没过、review 结论),
|
|
909
|
+
> 再决定 \`task_complete\` / 重新委托 / 取消。
|
|
910
|
+
>
|
|
911
|
+
> ⚠️ 如果你因为超时 / 崩溃没能把状态更新到位,主智能体**也会**来兜底验收 ——
|
|
912
|
+
> 但你**主动**把进度和操作记录写全,能让验收更快更准。
|
|
835
913
|
|
|
836
914
|
${TASK_DISCIPLINE_PROMPT}
|
|
837
915
|
### {{memory}}`,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AgentComponentAdapter,
|
|
3
3
|
init_agent_component_adapter
|
|
4
|
-
} from "./roy-agent-core-
|
|
4
|
+
} from "./roy-agent-core-dqxec05w.js";
|
|
5
5
|
import"./roy-agent-core-1db4vpc6.js";
|
|
6
|
-
import"./roy-agent-core-
|
|
6
|
+
import"./roy-agent-core-mkc3zshb.js";
|
|
7
7
|
import"./roy-agent-core-cpcd24n2.js";
|
|
8
8
|
import"./roy-agent-core-qqaak24r.js";
|
|
9
9
|
import"./roy-agent-core-7cbpmk4q.js";
|
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
import {
|
|
2
|
+
compactSessionTool,
|
|
3
|
+
createCompactSessionTool,
|
|
2
4
|
createQueryBackgroundProcessTool
|
|
3
|
-
} from "./roy-agent-core-
|
|
5
|
+
} from "./roy-agent-core-2akfd64z.js";
|
|
4
6
|
import {
|
|
5
7
|
createStopTool
|
|
6
8
|
} from "./roy-agent-core-jm136jzh.js";
|
|
7
9
|
import {
|
|
8
10
|
BackgroundTaskManager,
|
|
9
11
|
createDelegateTool
|
|
10
|
-
} from "./roy-agent-core-
|
|
12
|
+
} from "./roy-agent-core-jg65qnwa.js";
|
|
11
13
|
import {
|
|
12
14
|
TaskEntityEventTypes
|
|
13
15
|
} from "./roy-agent-core-8gxth0eh.js";
|
|
14
16
|
import {
|
|
15
17
|
batchArchiveTaskTool,
|
|
16
18
|
batchDeleteTaskTool,
|
|
19
|
+
cancelTaskTool,
|
|
17
20
|
completeTaskTool,
|
|
18
21
|
createTaskTool,
|
|
19
22
|
deleteTaskTool,
|
|
@@ -22,7 +25,7 @@ import {
|
|
|
22
25
|
searchTasksTool,
|
|
23
26
|
treeTasksTool,
|
|
24
27
|
updateTaskTool
|
|
25
|
-
} from "./roy-agent-core-
|
|
28
|
+
} from "./roy-agent-core-hnyk1by7.js";
|
|
26
29
|
import {
|
|
27
30
|
createOperationTool,
|
|
28
31
|
deleteOperationTool,
|
|
@@ -336,6 +339,9 @@ class TaskComponent extends BaseComponent {
|
|
|
336
339
|
await this.registerTools();
|
|
337
340
|
this.toolComponent.register(createQueryBackgroundProcessTool(this.backgroundTaskManager), "built-in");
|
|
338
341
|
logger2.debug("[TaskComponent] Injected BackgroundTaskManager into query_background_process tool (factory pattern)");
|
|
342
|
+
const sessionComponent = this.env?.getComponent("session");
|
|
343
|
+
this.toolComponent.register(createCompactSessionTool(this.backgroundTaskManager, sessionComponent ?? null), "built-in");
|
|
344
|
+
logger2.debug("[TaskComponent] Registered compact_session tool (factory pattern)");
|
|
339
345
|
} else {
|
|
340
346
|
logger2.warn("[TaskComponent] ToolComponent not found, skipping tool registration");
|
|
341
347
|
}
|
|
@@ -352,6 +358,12 @@ class TaskComponent extends BaseComponent {
|
|
|
352
358
|
} catch (err) {
|
|
353
359
|
logger2.warn(`[TaskComponent] Failed to reset query_background_process tool: ${err.message}`);
|
|
354
360
|
}
|
|
361
|
+
try {
|
|
362
|
+
this.toolComponent.register(compactSessionTool, "built-in");
|
|
363
|
+
logger2.debug("[TaskComponent] Reset compact_session tool to no-deps default (cleanup)");
|
|
364
|
+
} catch (err) {
|
|
365
|
+
logger2.warn(`[TaskComponent] Failed to reset compact_session tool: ${err.message}`);
|
|
366
|
+
}
|
|
355
367
|
}
|
|
356
368
|
if (this.backgroundTaskManager) {
|
|
357
369
|
await this.backgroundTaskManager.dispose(this.skipAbortRunningTasksOnDispose ? {
|
|
@@ -378,7 +390,8 @@ class TaskComponent extends BaseComponent {
|
|
|
378
390
|
batchDeleteTaskTool(this),
|
|
379
391
|
updateTaskTool(this),
|
|
380
392
|
deleteTaskTool(this),
|
|
381
|
-
completeTaskTool(this)
|
|
393
|
+
completeTaskTool(this),
|
|
394
|
+
cancelTaskTool(this)
|
|
382
395
|
];
|
|
383
396
|
const operationToolsList = [
|
|
384
397
|
createOperationTool(this),
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
defaultLarkCliRunner
|
|
3
3
|
} from "./roy-agent-core-bxkjk7zx.js";
|
|
4
|
-
import {
|
|
5
|
-
notifyReactFailure
|
|
6
|
-
} from "./roy-agent-core-add1zqsh.js";
|
|
7
4
|
import {
|
|
8
5
|
cliCommandHandler
|
|
9
6
|
} from "./roy-agent-core-v0hf14bj.js";
|
|
@@ -13,17 +10,20 @@ import {
|
|
|
13
10
|
createPerTaskGroupChatPlugin,
|
|
14
11
|
extractPerTaskChatId,
|
|
15
12
|
extractPerTaskChatName
|
|
16
|
-
} from "./roy-agent-core-
|
|
13
|
+
} from "./roy-agent-core-y7x2qzwc.js";
|
|
17
14
|
import {
|
|
18
15
|
getSharedEventStore
|
|
19
16
|
} from "./roy-agent-core-na18zwj0.js";
|
|
20
17
|
import {
|
|
21
18
|
createLarkCliWorkflowNotifyHook
|
|
22
|
-
} from "./roy-agent-core-
|
|
19
|
+
} from "./roy-agent-core-p3zv1mx5.js";
|
|
23
20
|
import {
|
|
24
21
|
LarkCardPatchNotifier,
|
|
25
22
|
buildTaskCard
|
|
26
|
-
} from "./roy-agent-core-
|
|
23
|
+
} from "./roy-agent-core-nmx9934r.js";
|
|
24
|
+
import {
|
|
25
|
+
notifyReactFailure
|
|
26
|
+
} from "./roy-agent-core-6cy43nss.js";
|
|
27
27
|
import {
|
|
28
28
|
normalizeLarkAtMentions
|
|
29
29
|
} from "./roy-agent-core-m880qz3y.js";
|