@ai-setting/roy-agent-core 1.5.87 → 1.5.89
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/index.js +6 -6
- package/dist/env/event-source/index.js +6 -2
- package/dist/env/index.js +17 -12
- package/dist/env/prompt/index.js +2 -1
- package/dist/env/session/index.js +1 -2
- package/dist/env/task/delegate/index.js +3 -2
- package/dist/env/task/index.js +5 -4
- package/dist/env/task/plugins/index.js +7 -4
- package/dist/env/task/tools/index.js +1 -1
- package/dist/env/tool/built-in/index.js +2 -1
- package/dist/env/tool/index.js +11 -8
- package/dist/env/workflow/engine/index.js +4 -2
- package/dist/env/workflow/index.js +5 -3
- package/dist/env/workflow/tools/index.js +7 -1
- package/dist/env/workflow/utils/index.js +5 -0
- package/dist/index.js +32 -25
- package/dist/shared/@ai-setting/{roy-agent-core-6mk0m4t3.js → roy-agent-core-2q7cshpm.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-0y64qaac.js → roy-agent-core-32m0nb9j.js} +119 -30
- package/dist/shared/@ai-setting/{roy-agent-core-9y09xfav.js → roy-agent-core-3f6k060j.js} +5 -417
- package/dist/shared/@ai-setting/roy-agent-core-4yq23m5g.js +421 -0
- package/dist/shared/@ai-setting/{roy-agent-core-mmkyydw7.js → roy-agent-core-83d035pp.js} +91 -579
- package/dist/shared/@ai-setting/roy-agent-core-8wd3qwx5.js +35 -0
- package/dist/shared/@ai-setting/{roy-agent-core-29fh9mxg.js → roy-agent-core-bwjpte58.js} +1 -2
- package/dist/shared/@ai-setting/{roy-agent-core-r1adqgaa.js → roy-agent-core-ewr1nw7t.js} +7 -8
- package/dist/shared/@ai-setting/{roy-agent-core-yx0vw1aw.js → roy-agent-core-fgpnv7dt.js} +31 -4
- package/dist/shared/@ai-setting/{roy-agent-core-jymz9fzp.js → roy-agent-core-fvfc7f6v.js} +64 -33
- package/dist/shared/@ai-setting/{roy-agent-core-9vwyj29a.js → roy-agent-core-h5867smx.js} +16 -22
- package/dist/shared/@ai-setting/roy-agent-core-hvdfgvfz.js +114 -0
- package/dist/shared/@ai-setting/{roy-agent-core-3arrpf7n.js → roy-agent-core-hxsbegfc.js} +229 -9
- package/dist/shared/@ai-setting/{roy-agent-core-7fdzfsm6.js → roy-agent-core-m3dkyprg.js} +35 -211
- package/dist/shared/@ai-setting/{roy-agent-core-bgw4dq11.js → roy-agent-core-mw4ty0ba.js} +44 -5
- package/dist/shared/@ai-setting/{roy-agent-core-7z4xtrmw.js → roy-agent-core-nqzt9ne4.js} +53 -0
- package/dist/shared/@ai-setting/roy-agent-core-pt7as39r.js +0 -0
- package/dist/shared/@ai-setting/{roy-agent-core-6n7xwv4v.js → roy-agent-core-qbq3jgrn.js} +5 -3
- package/dist/shared/@ai-setting/roy-agent-core-w6bmrgap.js +581 -0
- package/dist/shared/@ai-setting/{roy-agent-core-qhjb153z.js → roy-agent-core-xnxyzaw4.js} +27 -4
- package/dist/shared/@ai-setting/roy-agent-core-yanpq5gb.js +116 -0
- package/package.json +1 -1
- package/dist/shared/@ai-setting/roy-agent-core-x3gtyqax.js +0 -378
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ProcessRegistry,
|
|
3
|
+
runWithProcessRegistryAsync
|
|
4
|
+
} from "./roy-agent-core-hvdfgvfz.js";
|
|
1
5
|
import {
|
|
2
6
|
DEFAULT_SUBAGENT_PROMPT
|
|
3
|
-
} from "./roy-agent-core-
|
|
7
|
+
} from "./roy-agent-core-nqzt9ne4.js";
|
|
4
8
|
import {
|
|
5
9
|
TaskHookPoints
|
|
6
10
|
} from "./roy-agent-core-92z6t4he.js";
|
|
@@ -245,6 +249,7 @@ class BackgroundTaskManager {
|
|
|
245
249
|
tasks = new Map;
|
|
246
250
|
abortControllers = new Map;
|
|
247
251
|
progressTimers = new Map;
|
|
252
|
+
processRegistries = new Map;
|
|
248
253
|
constructor(env) {
|
|
249
254
|
this.env = env;
|
|
250
255
|
}
|
|
@@ -303,6 +308,8 @@ class BackgroundTaskManager {
|
|
|
303
308
|
throw new Error("Failed to create sub-session");
|
|
304
309
|
}
|
|
305
310
|
const abortController = new AbortController;
|
|
311
|
+
const processRegistry = new ProcessRegistry;
|
|
312
|
+
this.processRegistries.set(taskIdGen, processRegistry);
|
|
306
313
|
const task = {
|
|
307
314
|
id: taskIdGen,
|
|
308
315
|
subSessionId: subSession.id,
|
|
@@ -349,7 +356,8 @@ class BackgroundTaskManager {
|
|
|
349
356
|
if (!subSession) {
|
|
350
357
|
throw new Error(`Sub session not found: ${task.subSessionId}`);
|
|
351
358
|
}
|
|
352
|
-
const
|
|
359
|
+
const taskRegistry = this.processRegistries.get(taskId);
|
|
360
|
+
const result = await this.executeWithAbort(subSession, prompt, timeoutMs, abortController?.signal, task.similarTaskIds, taskRegistry);
|
|
353
361
|
if (abortController?.signal.aborted) {
|
|
354
362
|
logger.info(`[BackgroundTaskManager] Task was aborted`, { taskId });
|
|
355
363
|
return;
|
|
@@ -465,7 +473,7 @@ class BackgroundTaskManager {
|
|
|
465
473
|
this.progressTimers.delete(taskId);
|
|
466
474
|
}
|
|
467
475
|
}
|
|
468
|
-
async executeWithAbort(subSession, prompt, timeoutMs, signal, similarTaskIds) {
|
|
476
|
+
async executeWithAbort(subSession, prompt, timeoutMs, signal, similarTaskIds, processRegistry) {
|
|
469
477
|
const metadata = subSession.info?.metadata || {};
|
|
470
478
|
const taskId = metadata.task_id;
|
|
471
479
|
const taskDescription = metadata.task_description || "";
|
|
@@ -575,7 +583,17 @@ Use these as guidance to improve task execution efficiency.`;
|
|
|
575
583
|
const isWorkflowAgent = registry?.get(subagentType)?.type === "workflow";
|
|
576
584
|
const delegateQuery = isWorkflowAgent ? prompt : fullPrompt;
|
|
577
585
|
return new Promise((resolve, reject) => {
|
|
586
|
+
const killProcessTreeSafely = () => {
|
|
587
|
+
try {
|
|
588
|
+
processRegistry?.killAll();
|
|
589
|
+
} catch (err) {
|
|
590
|
+
logger.warn(`[delegate] ProcessRegistry.killAll failed`, {
|
|
591
|
+
error: err instanceof Error ? err.message : String(err)
|
|
592
|
+
});
|
|
593
|
+
}
|
|
594
|
+
};
|
|
578
595
|
const timer = setTimeout(() => {
|
|
596
|
+
killProcessTreeSafely();
|
|
579
597
|
reject(new Error(`Task execution timeout after ${timeoutMs}ms`));
|
|
580
598
|
try {
|
|
581
599
|
agentComponent?.abort?.(subagentType);
|
|
@@ -590,14 +608,17 @@ Use these as guidance to improve task execution efficiency.`;
|
|
|
590
608
|
agentComp.abort(subagentType);
|
|
591
609
|
}
|
|
592
610
|
} catch {}
|
|
611
|
+
killProcessTreeSafely();
|
|
593
612
|
reject(new Error("Task execution stopped"));
|
|
594
613
|
});
|
|
595
|
-
this.env.handle_query?.(delegateQuery, {
|
|
614
|
+
const invokeHandleQuery = () => this.env.handle_query?.(delegateQuery, {
|
|
596
615
|
sessionId,
|
|
597
616
|
deniedTools: deniedTools.length > 0 ? deniedTools : undefined,
|
|
598
617
|
agentType: subagentType,
|
|
599
618
|
abort: signal
|
|
600
|
-
})
|
|
619
|
+
});
|
|
620
|
+
const wrappedPromise = processRegistry ? runWithProcessRegistryAsync(processRegistry, () => invokeHandleQuery()) : Promise.resolve(invokeHandleQuery());
|
|
621
|
+
wrappedPromise?.then((result) => {
|
|
601
622
|
clearTimeout(timer);
|
|
602
623
|
resolve(result);
|
|
603
624
|
}).catch((error) => {
|
|
@@ -621,6 +642,14 @@ Use these as guidance to improve task execution efficiency.`;
|
|
|
621
642
|
task.status = "stopped";
|
|
622
643
|
task.abortController?.abort();
|
|
623
644
|
task.completedAt = Date.now();
|
|
645
|
+
try {
|
|
646
|
+
this.processRegistries.get(taskId)?.killAll();
|
|
647
|
+
} catch (err) {
|
|
648
|
+
logger.warn(`[delegate] stopTask killAll failed`, {
|
|
649
|
+
taskId,
|
|
650
|
+
error: err instanceof Error ? err.message : String(err)
|
|
651
|
+
});
|
|
652
|
+
}
|
|
624
653
|
const stoppedPayload = {
|
|
625
654
|
backgroundTaskId: task.id,
|
|
626
655
|
subSessionId: task.subSessionId,
|
|
@@ -646,6 +675,16 @@ Use these as guidance to improve task execution efficiency.`;
|
|
|
646
675
|
logger.debug(`[BackgroundTaskManager] Aborted task: ${taskId}`);
|
|
647
676
|
}
|
|
648
677
|
this.abortControllers.clear();
|
|
678
|
+
for (const [, registry] of this.processRegistries) {
|
|
679
|
+
try {
|
|
680
|
+
registry.killAll();
|
|
681
|
+
} catch (err) {
|
|
682
|
+
logger.warn(`[BackgroundTaskManager] dispose registry.killAll failed`, {
|
|
683
|
+
error: err instanceof Error ? err.message : String(err)
|
|
684
|
+
});
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
this.processRegistries.clear();
|
|
649
688
|
this.tasks.clear();
|
|
650
689
|
logger.info(`[BackgroundTaskManager] Disposed`);
|
|
651
690
|
}
|
|
@@ -193,6 +193,59 @@ class AgentRegistry {
|
|
|
193
193
|
};
|
|
194
194
|
this.agents.set(name, agent);
|
|
195
195
|
}
|
|
196
|
+
registerWorkflowExtractAgent() {
|
|
197
|
+
const name = "workflow-extract";
|
|
198
|
+
if (this.agents.has(name))
|
|
199
|
+
return;
|
|
200
|
+
const agent = {
|
|
201
|
+
name,
|
|
202
|
+
type: "sub",
|
|
203
|
+
description: "Workflow 提取子智能体 — 从父 task 的对话历史中分析需求,迭代式生成并验证 Workflow YAML",
|
|
204
|
+
systemPromptRef: "workflow-extract",
|
|
205
|
+
allowedTools: [
|
|
206
|
+
"workflow_get",
|
|
207
|
+
"workflow_list",
|
|
208
|
+
"workflow_add",
|
|
209
|
+
"workflow_validate"
|
|
210
|
+
],
|
|
211
|
+
deniedTools: [],
|
|
212
|
+
maxIterations: 10,
|
|
213
|
+
filterHistory: false
|
|
214
|
+
};
|
|
215
|
+
this.agents.set(name, agent);
|
|
216
|
+
}
|
|
217
|
+
registerCompactAgent() {
|
|
218
|
+
const name = "compact";
|
|
219
|
+
if (this.agents.has(name))
|
|
220
|
+
return;
|
|
221
|
+
const agent = {
|
|
222
|
+
name,
|
|
223
|
+
type: "sub",
|
|
224
|
+
description: "压缩子智能体 — 从父 session 的历史消息中提取结构化 checkpoint JSON",
|
|
225
|
+
systemPromptRef: "compact",
|
|
226
|
+
allowedTools: ["workflow_submit_output"],
|
|
227
|
+
deniedTools: [],
|
|
228
|
+
maxIterations: 1,
|
|
229
|
+
filterHistory: false
|
|
230
|
+
};
|
|
231
|
+
this.agents.set(name, agent);
|
|
232
|
+
}
|
|
233
|
+
registerCompactHintAgent() {
|
|
234
|
+
const name = "compact-hint";
|
|
235
|
+
if (this.agents.has(name))
|
|
236
|
+
return;
|
|
237
|
+
const agent = {
|
|
238
|
+
name,
|
|
239
|
+
type: "sub",
|
|
240
|
+
description: "压缩提示子智能体 — 分析父 session 历史,生成场景化压缩指导提示",
|
|
241
|
+
systemPromptRef: "compact-hint",
|
|
242
|
+
allowedTools: ["workflow_submit_output"],
|
|
243
|
+
deniedTools: [],
|
|
244
|
+
maxIterations: 1,
|
|
245
|
+
filterHistory: false
|
|
246
|
+
};
|
|
247
|
+
this.agents.set(name, agent);
|
|
248
|
+
}
|
|
196
249
|
async load() {
|
|
197
250
|
try {
|
|
198
251
|
return await this.loadFromDirectory(this.configDir);
|
|
File without changes
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
WorkflowEngine,
|
|
7
7
|
exports_engine,
|
|
8
8
|
init_engine
|
|
9
|
-
} from "./roy-agent-core-
|
|
9
|
+
} from "./roy-agent-core-3f6k060j.js";
|
|
10
10
|
import {
|
|
11
11
|
askUserTool,
|
|
12
12
|
createRunWorkflowTool,
|
|
@@ -16,8 +16,9 @@ import {
|
|
|
16
16
|
createWorkflowRunStatusTool,
|
|
17
17
|
createWorkflowRunStopTool,
|
|
18
18
|
createWorkflowSearchTool,
|
|
19
|
-
createWorkflowTagListTool
|
|
20
|
-
|
|
19
|
+
createWorkflowTagListTool,
|
|
20
|
+
createWorkflowValidateTool
|
|
21
|
+
} from "./roy-agent-core-32m0nb9j.js";
|
|
21
22
|
import {
|
|
22
23
|
WorkflowService
|
|
23
24
|
} from "./roy-agent-core-tq9528d3.js";
|
|
@@ -213,6 +214,7 @@ class WorkflowComponent extends BaseComponent {
|
|
|
213
214
|
createWorkflowGetTool(this.workflowService),
|
|
214
215
|
createWorkflowListTool(this.workflowService),
|
|
215
216
|
createWorkflowAddTool(this.workflowService),
|
|
217
|
+
createWorkflowValidateTool(this.workflowService),
|
|
216
218
|
createWorkflowSearchTool(this.workflowService),
|
|
217
219
|
createWorkflowTagListTool(this.workflowService),
|
|
218
220
|
createRunWorkflowTool(this.workflowService),
|