@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.
Files changed (91) hide show
  1. package/dist/env/agent/agent-component.js +6 -6
  2. package/dist/env/agent/agent-registry.d.ts +4 -1
  3. package/dist/env/agent/index.js +6 -6
  4. package/dist/env/error-reply.d.ts +46 -0
  5. package/dist/env/error-reply.js +3 -1
  6. package/dist/env/event-source/event-source-handlers.js +13 -12
  7. package/dist/env/event-source/index.js +14 -13
  8. package/dist/env/index.js +31 -30
  9. package/dist/env/llm/index.js +2 -2
  10. package/dist/env/llm/orphan-toolcall.d.ts +107 -0
  11. package/dist/env/plugin/index.js +3 -3
  12. package/dist/env/prompt/index.js +4 -3
  13. package/dist/env/prompt/prompts-index.d.ts +27 -3
  14. package/dist/env/session/index.js +4 -4
  15. package/dist/env/session/storage/index.js +3 -3
  16. package/dist/env/task/backend/index.js +9 -1
  17. package/dist/env/task/delegate/delegate-tool.d.ts +8 -0
  18. package/dist/env/task/delegate/delegate-tool.js +5 -4
  19. package/dist/env/task/delegate/index.js +5 -4
  20. package/dist/env/task/hooks/contexts.d.ts +12 -1
  21. package/dist/env/task/hooks/task-hook-points.d.ts +8 -3
  22. package/dist/env/task/index.d.ts +1 -0
  23. package/dist/env/task/index.js +17 -7
  24. package/dist/env/task/mcp/index.js +3 -2
  25. package/dist/env/task/plugins/index.d.ts +3 -0
  26. package/dist/env/task/plugins/index.js +33 -9
  27. package/dist/env/task/plugins/lark-card-patch-notifier.d.ts +61 -0
  28. package/dist/env/task/plugins/lark-card-patch-notifier.js +6 -2
  29. package/dist/env/task/plugins/lark-cli-task-notify-plugin.d.ts +42 -0
  30. package/dist/env/task/prompt/index.js +2 -1
  31. package/dist/env/task/prompt/task-discipline.d.ts +9 -3
  32. package/dist/env/task/task-component.d.ts +79 -0
  33. package/dist/env/task/tools/cancel-tool.d.ts +36 -0
  34. package/dist/env/task/tools/completion-copy.d.ts +92 -0
  35. package/dist/env/task/tools/index.d.ts +2 -0
  36. package/dist/env/task/tools/index.js +7 -2
  37. package/dist/env/task/tools/pre-complete-tool.d.ts +32 -0
  38. package/dist/env/task/tools/task-types.d.ts +71 -17
  39. package/dist/env/task/types.d.ts +13 -1
  40. package/dist/env/tool/built-in/compact-session-tool.d.ts +120 -0
  41. package/dist/env/tool/built-in/index.d.ts +2 -0
  42. package/dist/env/tool/built-in/index.js +6 -2
  43. package/dist/env/tool/index.js +4 -4
  44. package/dist/env/workflow/engine/index.js +6 -6
  45. package/dist/env/workflow/index.js +15 -13
  46. package/dist/env/workflow/plugins/index.js +2 -2
  47. package/dist/env/workflow/tools/ask-user-tool.d.ts +88 -0
  48. package/dist/env/workflow/tools/index.js +11 -9
  49. package/dist/env/workflow/tools/run-workflow.d.ts +2 -2
  50. package/dist/env/workflow/types/index.js +2 -2
  51. package/dist/env/workflow/types/workflow-hil.d.ts +25 -1
  52. package/dist/env/workflow/utils/index.js +5 -5
  53. package/dist/index.d.ts +1 -1
  54. package/dist/index.js +43 -33
  55. package/dist/shared/@ai-setting/{roy-agent-core-sm0sf6sb.js → roy-agent-core-0qyrk5k0.js} +2 -2
  56. package/dist/shared/@ai-setting/{roy-agent-core-kmbct9yg.js → roy-agent-core-0snm5hc5.js} +1 -1
  57. package/dist/shared/@ai-setting/{roy-agent-core-yr1mryb8.js → roy-agent-core-1v4g0d4x.js} +1 -1
  58. package/dist/shared/@ai-setting/{roy-agent-core-rxb00gjm.js → roy-agent-core-264qexac.js} +1 -1
  59. package/dist/shared/@ai-setting/roy-agent-core-2akfd64z.js +374 -0
  60. package/dist/shared/@ai-setting/{roy-agent-core-skyc30qx.js → roy-agent-core-3fh1f7s7.js} +2 -2
  61. package/dist/shared/@ai-setting/roy-agent-core-4rtg69cn.js +26 -0
  62. package/dist/shared/@ai-setting/{roy-agent-core-add1zqsh.js → roy-agent-core-6cy43nss.js} +22 -1
  63. package/dist/shared/@ai-setting/{roy-agent-core-vah6g5yx.js → roy-agent-core-6rh8k6ba.js} +5 -5
  64. package/dist/shared/@ai-setting/{roy-agent-core-kpg25s2q.js → roy-agent-core-8ez6mccb.js} +4 -2
  65. package/dist/shared/@ai-setting/{roy-agent-core-yhwxpj12.js → roy-agent-core-9vxh6f8h.js} +233 -16
  66. package/dist/shared/@ai-setting/{roy-agent-core-7qvw65jt.js → roy-agent-core-aa2j7bk9.js} +11 -8
  67. package/dist/shared/@ai-setting/{roy-agent-core-sjr1kmfz.js → roy-agent-core-acj8ag08.js} +1 -1
  68. package/dist/shared/@ai-setting/{roy-agent-core-mds8tqd0.js → roy-agent-core-cgtq6427.js} +1 -1
  69. package/dist/shared/@ai-setting/{roy-agent-core-34jz9mgh.js → roy-agent-core-cmprygrp.js} +1 -1
  70. package/dist/shared/@ai-setting/{roy-agent-core-wr7mv7k3.js → roy-agent-core-cxy143m4.js} +1 -1
  71. package/dist/shared/@ai-setting/{roy-agent-core-pakhchy7.js → roy-agent-core-ddyk1rc0.js} +1 -1
  72. package/dist/shared/@ai-setting/{roy-agent-core-attpry6g.js → roy-agent-core-dqxec05w.js} +4 -3
  73. package/dist/shared/@ai-setting/{roy-agent-core-vm8h5zyj.js → roy-agent-core-ed233k5z.js} +1 -1
  74. package/dist/shared/@ai-setting/{roy-agent-core-jrj30vq3.js → roy-agent-core-er070zjq.js} +1 -1
  75. package/dist/shared/@ai-setting/{roy-agent-core-40rv283c.js → roy-agent-core-fghc2m8z.js} +152 -2
  76. package/dist/shared/@ai-setting/{roy-agent-core-5gw0qa8m.js → roy-agent-core-ghnagzrh.js} +557 -92
  77. package/dist/shared/@ai-setting/{roy-agent-core-4jjwewvw.js → roy-agent-core-m46fe3x4.js} +41 -30
  78. package/dist/shared/@ai-setting/{roy-agent-core-e25xkv53.js → roy-agent-core-mkc3zshb.js} +3 -1
  79. package/dist/shared/@ai-setting/{roy-agent-core-hfyfavp3.js → roy-agent-core-mww0mnd9.js} +231 -27
  80. package/dist/shared/@ai-setting/{roy-agent-core-46rv4d7d.js → roy-agent-core-nmx9934r.js} +92 -2
  81. package/dist/shared/@ai-setting/{roy-agent-core-1w9y7mxj.js → roy-agent-core-p3zv1mx5.js} +1 -1
  82. package/dist/shared/@ai-setting/{roy-agent-core-jgb3bb42.js → roy-agent-core-q5r75vev.js} +17 -8
  83. package/dist/shared/@ai-setting/{roy-agent-core-y12kyxwa.js → roy-agent-core-t3rrb959.js} +33 -9
  84. package/dist/shared/@ai-setting/{roy-agent-core-dt104qa1.js → roy-agent-core-v85n42ve.js} +1 -1
  85. package/dist/shared/@ai-setting/{roy-agent-core-gr48c89p.js → roy-agent-core-v87njmq7.js} +3 -3
  86. package/dist/shared/@ai-setting/{roy-agent-core-7sj9xs9c.js → roy-agent-core-vffccgf6.js} +252 -25
  87. package/dist/shared/@ai-setting/{roy-agent-core-2gzt2q8c.js → roy-agent-core-z43aj03k.js} +134 -29
  88. package/dist/shared/@ai-setting/roy-agent-core-zycadbpx.js +662 -0
  89. package/package.json +1 -1
  90. package/dist/shared/@ai-setting/roy-agent-core-1p6syv85.js +0 -1083
  91. 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 };
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  AgentComponentAdapter,
3
3
  init_agent_component_adapter
4
- } from "./roy-agent-core-attpry6g.js";
4
+ } from "./roy-agent-core-dqxec05w.js";
5
5
  import"./roy-agent-core-1db4vpc6.js";
6
- import"./roy-agent-core-e25xkv53.js";
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";
@@ -0,0 +1,26 @@
1
+ // src/env/task/tools/completion-copy.ts
2
+ var TASK_COMPLETE_ITEM_BY_ITEM = "按子项逐条验收";
3
+ var TASK_COMPLETION_HINT_ANCHOR = "TASK_COMPLETION_HINT";
4
+ var TASK_COMPLETE_VERIFY_DUTY = "核实义务";
5
+ var TASK_COMPLETE_ACCEPTANCE = {
6
+ itemByItem: TASK_COMPLETE_ITEM_BY_ITEM,
7
+ hintAnchor: TASK_COMPLETION_HINT_ANCHOR,
8
+ verifyDuty: TASK_COMPLETE_VERIFY_DUTY
9
+ };
10
+ var TASK_COMPLETED_STATUS_WORD = "已完成";
11
+ var TASK_CANCELLED_STATUS_WORD = "已取消";
12
+ var TASK_DELIVERABLE_RECORDED = "交付物已记录";
13
+ var TASK_ARCHIVED_STATUS_WORD = "已归档";
14
+ var TASK_REOPENED_STATUS_WORD = "已重新打开";
15
+ var TASK_TO_VALIDATE_STATUS_WORD = "待验证";
16
+ var TASK_TERMINAL_STATUS_WORDS = [
17
+ TASK_COMPLETED_STATUS_WORD,
18
+ TASK_CANCELLED_STATUS_WORD,
19
+ TASK_ARCHIVED_STATUS_WORD
20
+ ];
21
+ var TERMINAL_NON_ACCEPTABLE_STATUSES = [
22
+ "cancelled",
23
+ "archived"
24
+ ];
25
+
26
+ export { TASK_COMPLETE_ITEM_BY_ITEM, TASK_COMPLETION_HINT_ANCHOR, TASK_COMPLETE_VERIFY_DUTY, TASK_COMPLETE_ACCEPTANCE, TASK_COMPLETED_STATUS_WORD, TASK_CANCELLED_STATUS_WORD, TASK_DELIVERABLE_RECORDED, TASK_ARCHIVED_STATUS_WORD, TASK_REOPENED_STATUS_WORD, TASK_TO_VALIDATE_STATUS_WORD, TASK_TERMINAL_STATUS_WORDS, TERMINAL_NON_ACCEPTABLE_STATUSES };
@@ -401,6 +401,27 @@ function __resetFailureReplyDedupForTest() {
401
401
  repliedTriggers.clear();
402
402
  }
403
403
  var DEFAULT_REPLY_TIMEOUT_MS = 5000;
404
+ async function deliverAskUserMessage(options) {
405
+ const { chatId, messageId, profile, content } = options;
406
+ if (!chatId && !messageId) {
407
+ return { sent: false, error: "no-target" };
408
+ }
409
+ try {
410
+ await spawnLarkReply({
411
+ chatId,
412
+ messageId,
413
+ content,
414
+ profile,
415
+ timeoutMs: options.timeoutMs ?? DEFAULT_REPLY_TIMEOUT_MS
416
+ });
417
+ return { sent: true };
418
+ } catch (err) {
419
+ return {
420
+ sent: false,
421
+ error: err instanceof Error ? err.message : String(err)
422
+ };
423
+ }
424
+ }
404
425
  function spawnLarkReply(options) {
405
426
  return new Promise((resolve, reject) => {
406
427
  const { chatId, messageId, content, profile } = options;
@@ -521,4 +542,4 @@ async function notifyReactFailure(options) {
521
542
  }
522
543
  }
523
544
 
524
- export { extractRetryAfterSeconds, humanizeRetryAfter, getFailureRuleIds, classifyReactFailure, buildFailureReplyMarkdown, formatCliFailureLine, __resetFailureReplyDedupForTest, notifyReactFailure };
545
+ export { extractRetryAfterSeconds, humanizeRetryAfter, getFailureRuleIds, classifyReactFailure, buildFailureReplyMarkdown, formatCliFailureLine, __resetFailureReplyDedupForTest, deliverAskUserMessage, notifyReactFailure };
@@ -7,7 +7,7 @@ import {
7
7
  import {
8
8
  AgentComponentAdapter,
9
9
  init_agent_component_adapter
10
- } from "./roy-agent-core-attpry6g.js";
10
+ } from "./roy-agent-core-dqxec05w.js";
11
11
  import {
12
12
  PythonCallNode,
13
13
  SkillNode,
@@ -37,23 +37,23 @@ import {
37
37
  import {
38
38
  TemplateResolver,
39
39
  init_template_resolver
40
- } from "./roy-agent-core-sjr1kmfz.js";
40
+ } from "./roy-agent-core-acj8ag08.js";
41
41
  import {
42
42
  DAGManager,
43
43
  init_dag_manager
44
- } from "./roy-agent-core-mds8tqd0.js";
44
+ } from "./roy-agent-core-cgtq6427.js";
45
45
  import {
46
46
  WorkflowError,
47
47
  createWorkflowEvent,
48
48
  init_event,
49
49
  init_types,
50
50
  init_workflow_error
51
- } from "./roy-agent-core-jrj30vq3.js";
51
+ } from "./roy-agent-core-er070zjq.js";
52
52
  import {
53
53
  AskUserError,
54
54
  createNodeInterruptEvent,
55
55
  init_workflow_hil
56
- } from "./roy-agent-core-e25xkv53.js";
56
+ } from "./roy-agent-core-mkc3zshb.js";
57
57
  import {
58
58
  TracedAs,
59
59
  init_decorator
@@ -2,8 +2,9 @@ import {
2
2
  understandImageTool
3
3
  } from "./roy-agent-core-xwm8zavb.js";
4
4
  import {
5
+ compactSessionTool,
5
6
  queryBackgroundProcessTool
6
- } from "./roy-agent-core-58804s3j.js";
7
+ } from "./roy-agent-core-2akfd64z.js";
7
8
  import {
8
9
  getCurrentProcessRegistry,
9
10
  killProcessTree
@@ -939,7 +940,8 @@ function getAllBuiltInTools() {
939
940
  editFileTool,
940
941
  grepTool,
941
942
  understandImageTool,
942
- queryBackgroundProcessTool
943
+ queryBackgroundProcessTool,
944
+ compactSessionTool
943
945
  ];
944
946
  }
945
947
  function getBuiltInTool(name) {