@ai-setting/roy-agent-core 1.7.15 → 1.7.17
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 +1 -1
- package/dist/env/index.js +5 -5
- package/dist/env/task/delegate/index.js +1 -1
- package/dist/env/task/index.js +2 -2
- package/dist/env/workflow/index.js +2 -2
- package/dist/env/workflow/tools/index.js +1 -1
- package/dist/index.js +5 -5
- package/dist/shared/@ai-setting/{roy-agent-core-6jafpa30.js → roy-agent-core-7gf5abzy.js} +2 -1
- package/dist/shared/@ai-setting/{roy-agent-core-sh94bwdf.js → roy-agent-core-dbs3325z.js} +73 -2
- package/dist/shared/@ai-setting/{roy-agent-core-qmbd0vx2.js → roy-agent-core-p5dnn2at.js} +3 -1
- package/dist/shared/@ai-setting/{roy-agent-core-g7cht2pw.js → roy-agent-core-pp140n9r.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-axkxd7jn.js → roy-agent-core-znhmrzyy.js} +1 -1
- package/package.json +1 -1
package/dist/env/agent/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
AgentComponent,
|
|
3
3
|
AgentComponentConfigSchema,
|
|
4
4
|
SummaryAgent
|
|
5
|
-
} from "../../shared/@ai-setting/roy-agent-core-
|
|
5
|
+
} from "../../shared/@ai-setting/roy-agent-core-p5dnn2at.js";
|
|
6
6
|
import"../../shared/@ai-setting/roy-agent-core-rsej8ed5.js";
|
|
7
7
|
import"../../shared/@ai-setting/roy-agent-core-9sz7hnbf.js";
|
|
8
8
|
import"../../shared/@ai-setting/roy-agent-core-p06rm1xh.js";
|
package/dist/env/index.js
CHANGED
|
@@ -3,12 +3,12 @@ import {
|
|
|
3
3
|
} from "../shared/@ai-setting/roy-agent-core-62mfe44h.js";
|
|
4
4
|
import {
|
|
5
5
|
TaskComponent
|
|
6
|
-
} from "../shared/@ai-setting/roy-agent-core-
|
|
6
|
+
} from "../shared/@ai-setting/roy-agent-core-pp140n9r.js";
|
|
7
7
|
import"../shared/@ai-setting/roy-agent-core-htwb9yj6.js";
|
|
8
8
|
import"../shared/@ai-setting/roy-agent-core-rn57psp0.js";
|
|
9
9
|
import"../shared/@ai-setting/roy-agent-core-amkqnyzy.js";
|
|
10
10
|
import"../shared/@ai-setting/roy-agent-core-8gxth0eh.js";
|
|
11
|
-
import"../shared/@ai-setting/roy-agent-core-
|
|
11
|
+
import"../shared/@ai-setting/roy-agent-core-dbs3325z.js";
|
|
12
12
|
import"../shared/@ai-setting/roy-agent-core-sh7bz68r.js";
|
|
13
13
|
import"../shared/@ai-setting/roy-agent-core-h76sw3ar.js";
|
|
14
14
|
import {
|
|
@@ -29,11 +29,11 @@ import"../shared/@ai-setting/roy-agent-core-1pg0fepg.js";
|
|
|
29
29
|
import"../shared/@ai-setting/roy-agent-core-skqt40yy.js";
|
|
30
30
|
import {
|
|
31
31
|
WorkflowComponent
|
|
32
|
-
} from "../shared/@ai-setting/roy-agent-core-
|
|
32
|
+
} from "../shared/@ai-setting/roy-agent-core-znhmrzyy.js";
|
|
33
33
|
import"../shared/@ai-setting/roy-agent-core-1qt5x67p.js";
|
|
34
34
|
import"../shared/@ai-setting/roy-agent-core-h0x19xgn.js";
|
|
35
35
|
import"../shared/@ai-setting/roy-agent-core-1ce3fqrk.js";
|
|
36
|
-
import"../shared/@ai-setting/roy-agent-core-
|
|
36
|
+
import"../shared/@ai-setting/roy-agent-core-7gf5abzy.js";
|
|
37
37
|
import"../shared/@ai-setting/roy-agent-core-4rg92cwq.js";
|
|
38
38
|
import"../shared/@ai-setting/roy-agent-core-1y4hr9v9.js";
|
|
39
39
|
import"../shared/@ai-setting/roy-agent-core-hhrg314p.js";
|
|
@@ -53,7 +53,7 @@ import"../shared/@ai-setting/roy-agent-core-rvxg1wps.js";
|
|
|
53
53
|
import {
|
|
54
54
|
AgentComponent,
|
|
55
55
|
AgentComponentConfigSchema
|
|
56
|
-
} from "../shared/@ai-setting/roy-agent-core-
|
|
56
|
+
} from "../shared/@ai-setting/roy-agent-core-p5dnn2at.js";
|
|
57
57
|
import"../shared/@ai-setting/roy-agent-core-rsej8ed5.js";
|
|
58
58
|
import"../shared/@ai-setting/roy-agent-core-9sz7hnbf.js";
|
|
59
59
|
import"../shared/@ai-setting/roy-agent-core-p06rm1xh.js";
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
BackgroundTaskManager,
|
|
4
4
|
createDelegateTool,
|
|
5
5
|
createStopTool
|
|
6
|
-
} from "../../../shared/@ai-setting/roy-agent-core-
|
|
6
|
+
} from "../../../shared/@ai-setting/roy-agent-core-dbs3325z.js";
|
|
7
7
|
import"../../../shared/@ai-setting/roy-agent-core-sh7bz68r.js";
|
|
8
8
|
import"../../../shared/@ai-setting/roy-agent-core-1pg0fepg.js";
|
|
9
9
|
import"../../../shared/@ai-setting/roy-agent-core-skqt40yy.js";
|
package/dist/env/task/index.js
CHANGED
|
@@ -5,14 +5,14 @@ import {
|
|
|
5
5
|
TaskPriorityEnum,
|
|
6
6
|
TaskStatusEnum,
|
|
7
7
|
TaskTypeEnum
|
|
8
|
-
} from "../../shared/@ai-setting/roy-agent-core-
|
|
8
|
+
} from "../../shared/@ai-setting/roy-agent-core-pp140n9r.js";
|
|
9
9
|
import"../../shared/@ai-setting/roy-agent-core-htwb9yj6.js";
|
|
10
10
|
import"../../shared/@ai-setting/roy-agent-core-rn57psp0.js";
|
|
11
11
|
import"../../shared/@ai-setting/roy-agent-core-amkqnyzy.js";
|
|
12
12
|
import {
|
|
13
13
|
TaskEntityEventTypes
|
|
14
14
|
} from "../../shared/@ai-setting/roy-agent-core-8gxth0eh.js";
|
|
15
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
15
|
+
import"../../shared/@ai-setting/roy-agent-core-dbs3325z.js";
|
|
16
16
|
import"../../shared/@ai-setting/roy-agent-core-sh7bz68r.js";
|
|
17
17
|
import {
|
|
18
18
|
SQLiteTaskStore,
|
|
@@ -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-znhmrzyy.js";
|
|
4
4
|
import"../../shared/@ai-setting/roy-agent-core-1qt5x67p.js";
|
|
5
5
|
import {
|
|
6
6
|
Edge,
|
|
@@ -14,7 +14,7 @@ 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-
|
|
17
|
+
import"../../shared/@ai-setting/roy-agent-core-7gf5abzy.js";
|
|
18
18
|
import"../../shared/@ai-setting/roy-agent-core-4rg92cwq.js";
|
|
19
19
|
import"../../shared/@ai-setting/roy-agent-core-1y4hr9v9.js";
|
|
20
20
|
import"../../shared/@ai-setting/roy-agent-core-hhrg314p.js";
|
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
getRunWorkflowTool,
|
|
25
25
|
initRunWorkflowTool,
|
|
26
26
|
resetRunWorkflowTool
|
|
27
|
-
} from "../../../shared/@ai-setting/roy-agent-core-
|
|
27
|
+
} from "../../../shared/@ai-setting/roy-agent-core-7gf5abzy.js";
|
|
28
28
|
import"../../../shared/@ai-setting/roy-agent-core-4rg92cwq.js";
|
|
29
29
|
import"../../../shared/@ai-setting/roy-agent-core-1y4hr9v9.js";
|
|
30
30
|
import"../../../shared/@ai-setting/roy-agent-core-77cpyf03.js";
|
package/dist/index.js
CHANGED
|
@@ -69,12 +69,12 @@ import {
|
|
|
69
69
|
} from "./shared/@ai-setting/roy-agent-core-62mfe44h.js";
|
|
70
70
|
import {
|
|
71
71
|
TaskComponent
|
|
72
|
-
} from "./shared/@ai-setting/roy-agent-core-
|
|
72
|
+
} from "./shared/@ai-setting/roy-agent-core-pp140n9r.js";
|
|
73
73
|
import"./shared/@ai-setting/roy-agent-core-htwb9yj6.js";
|
|
74
74
|
import"./shared/@ai-setting/roy-agent-core-rn57psp0.js";
|
|
75
75
|
import"./shared/@ai-setting/roy-agent-core-amkqnyzy.js";
|
|
76
76
|
import"./shared/@ai-setting/roy-agent-core-8gxth0eh.js";
|
|
77
|
-
import"./shared/@ai-setting/roy-agent-core-
|
|
77
|
+
import"./shared/@ai-setting/roy-agent-core-dbs3325z.js";
|
|
78
78
|
import"./shared/@ai-setting/roy-agent-core-sh7bz68r.js";
|
|
79
79
|
import {
|
|
80
80
|
SQLiteTaskStore,
|
|
@@ -119,7 +119,7 @@ import {
|
|
|
119
119
|
} from "./shared/@ai-setting/roy-agent-core-skqt40yy.js";
|
|
120
120
|
import {
|
|
121
121
|
WorkflowComponent
|
|
122
|
-
} from "./shared/@ai-setting/roy-agent-core-
|
|
122
|
+
} from "./shared/@ai-setting/roy-agent-core-znhmrzyy.js";
|
|
123
123
|
import {
|
|
124
124
|
init_node_registry_helper,
|
|
125
125
|
registerDecoratorNodeType
|
|
@@ -132,7 +132,7 @@ import {
|
|
|
132
132
|
createWorkflowFromClass
|
|
133
133
|
} from "./shared/@ai-setting/roy-agent-core-h0x19xgn.js";
|
|
134
134
|
import"./shared/@ai-setting/roy-agent-core-1ce3fqrk.js";
|
|
135
|
-
import"./shared/@ai-setting/roy-agent-core-
|
|
135
|
+
import"./shared/@ai-setting/roy-agent-core-7gf5abzy.js";
|
|
136
136
|
import {
|
|
137
137
|
SessionComponent
|
|
138
138
|
} from "./shared/@ai-setting/roy-agent-core-4rg92cwq.js";
|
|
@@ -159,7 +159,7 @@ import {
|
|
|
159
159
|
import {
|
|
160
160
|
AgentComponent,
|
|
161
161
|
AgentComponentConfigSchema
|
|
162
|
-
} from "./shared/@ai-setting/roy-agent-core-
|
|
162
|
+
} from "./shared/@ai-setting/roy-agent-core-p5dnn2at.js";
|
|
163
163
|
import {
|
|
164
164
|
ToolComponent,
|
|
165
165
|
ToolRegistry,
|
|
@@ -893,7 +893,8 @@ function createRunWorkflowTool(workflowService, hooks) {
|
|
|
893
893
|
...parentSessionId ? { parentSessionId } : {},
|
|
894
894
|
...session ? {} : { runId: reservedRunId },
|
|
895
895
|
onSessionCreated,
|
|
896
|
-
...node_config ? { nodeConfig: node_config } : {}
|
|
896
|
+
...node_config ? { nodeConfig: node_config } : {},
|
|
897
|
+
...timeout ? { timeout } : {}
|
|
897
898
|
};
|
|
898
899
|
const executeCall = async () => {
|
|
899
900
|
if (session) {
|
|
@@ -739,7 +739,8 @@ var BackgroundTaskEventTypes = {
|
|
|
739
739
|
COMPLETED: "task.background.completed",
|
|
740
740
|
FAILED: "task.background.failed",
|
|
741
741
|
TIMEOUT: "task.background.timeout",
|
|
742
|
-
STOPPED: "task.background.stopped"
|
|
742
|
+
STOPPED: "task.background.stopped",
|
|
743
|
+
ASK_USER: "task.background.ask_user"
|
|
743
744
|
};
|
|
744
745
|
var builtInSubAgents = [
|
|
745
746
|
{
|
|
@@ -1054,6 +1055,39 @@ class BackgroundTaskManager {
|
|
|
1054
1055
|
logger3.info(`[BackgroundTaskManager] Event published: ${type}`);
|
|
1055
1056
|
}
|
|
1056
1057
|
}
|
|
1058
|
+
static parseAskUserErrorFromMessage(error) {
|
|
1059
|
+
const rawErrorMessage = error instanceof Error ? error.message : String(error);
|
|
1060
|
+
if (error && typeof error === "object" && error.name === "AskUserError" && error.query) {
|
|
1061
|
+
const e = error;
|
|
1062
|
+
return {
|
|
1063
|
+
query: e.query,
|
|
1064
|
+
sessionId: e.sessionId,
|
|
1065
|
+
nodeId: e.nodeId,
|
|
1066
|
+
nodeType: e.nodeType || "agent",
|
|
1067
|
+
agentSessionId: e.agentSessionId,
|
|
1068
|
+
rawErrorMessage
|
|
1069
|
+
};
|
|
1070
|
+
}
|
|
1071
|
+
const prefix = "__ASK_USER_ERROR__:";
|
|
1072
|
+
if (rawErrorMessage.includes(prefix)) {
|
|
1073
|
+
try {
|
|
1074
|
+
const jsonStr = rawErrorMessage.substring(rawErrorMessage.indexOf(prefix) + prefix.length);
|
|
1075
|
+
const parsed = JSON.parse(jsonStr);
|
|
1076
|
+
return {
|
|
1077
|
+
query: parsed.query,
|
|
1078
|
+
sessionId: parsed.sessionId,
|
|
1079
|
+
nodeId: parsed.nodeId,
|
|
1080
|
+
nodeType: parsed.nodeType || "agent",
|
|
1081
|
+
agentSessionId: parsed.agentSessionId,
|
|
1082
|
+
rawErrorMessage
|
|
1083
|
+
};
|
|
1084
|
+
} catch (parseErr) {
|
|
1085
|
+
logger3.warn(`[BackgroundTaskManager] Failed to parse __ASK_USER_ERROR__ payload`, { error: parseErr instanceof Error ? parseErr.message : String(parseErr) });
|
|
1086
|
+
return null;
|
|
1087
|
+
}
|
|
1088
|
+
}
|
|
1089
|
+
return null;
|
|
1090
|
+
}
|
|
1057
1091
|
async createTask(options) {
|
|
1058
1092
|
const { parentSessionId, description, prompt, subagentType, timeout, similarTaskIds, existingSubSessionId } = options;
|
|
1059
1093
|
const taskIdGen = `process_${Date.now()}_${Math.random().toString(36).slice(2, 11)}`;
|
|
@@ -1221,12 +1255,46 @@ class BackgroundTaskManager {
|
|
|
1221
1255
|
});
|
|
1222
1256
|
} catch (error) {
|
|
1223
1257
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
1258
|
+
const askUserInfo = BackgroundTaskManager.parseAskUserErrorFromMessage(error);
|
|
1224
1259
|
const isStoppedError = errorMessage.toLowerCase().includes("stopped") || errorMessage.toLowerCase().includes("aborted");
|
|
1225
1260
|
const executionTimeMs = task.startedAt ? Date.now() - task.startedAt : 0;
|
|
1226
1261
|
const completedAt = Date.now();
|
|
1227
1262
|
task.completedAt = completedAt;
|
|
1228
1263
|
task.lastUpdatedAt = completedAt;
|
|
1229
1264
|
task.associatedTaskId = getCurrentTaskId();
|
|
1265
|
+
if (askUserInfo) {
|
|
1266
|
+
task.status = "awaiting-user";
|
|
1267
|
+
task.error = askUserInfo.rawErrorMessage;
|
|
1268
|
+
task.pendingAskUserQuery = askUserInfo.query;
|
|
1269
|
+
const askUserPayload = {
|
|
1270
|
+
backgroundTaskId: task.id,
|
|
1271
|
+
subSessionId: task.subSessionId,
|
|
1272
|
+
parentSessionId: parentSessionId || task.parentSessionId,
|
|
1273
|
+
subagentType: task.subagentType,
|
|
1274
|
+
description: task.description,
|
|
1275
|
+
query: askUserInfo.query,
|
|
1276
|
+
sessionId: askUserInfo.sessionId,
|
|
1277
|
+
nodeId: askUserInfo.nodeId,
|
|
1278
|
+
nodeType: askUserInfo.nodeType,
|
|
1279
|
+
agentSessionId: askUserInfo.agentSessionId,
|
|
1280
|
+
error: askUserInfo.rawErrorMessage,
|
|
1281
|
+
executionTimeMs,
|
|
1282
|
+
hints: [
|
|
1283
|
+
"请把上面的问题原样通过 ask_user tool 展示给用户并等待答复",
|
|
1284
|
+
`得到用户回复后,通过 delegate_task(subagentType="${task.subagentType}", existingSubSessionId="${task.subSessionId}", prompt=<基于用户回复>) 复用 sub-session 让 sub-agent 继承之前消息历史继续推进,无需实现 resume function`
|
|
1285
|
+
],
|
|
1286
|
+
associatedTaskId: task.associatedTaskId
|
|
1287
|
+
};
|
|
1288
|
+
this.publishBackgroundEvent(BackgroundTaskEventTypes.ASK_USER, askUserPayload, parentSessionId || task.parentSessionId);
|
|
1289
|
+
logger3.info(`[BackgroundTaskManager] Task awaiting user input (ask_user cascade)`, {
|
|
1290
|
+
taskId,
|
|
1291
|
+
subSessionId: task.subSessionId,
|
|
1292
|
+
nodeId: askUserInfo.nodeId,
|
|
1293
|
+
queryPreview: askUserInfo.query.substring(0, 80)
|
|
1294
|
+
});
|
|
1295
|
+
task._preserveSubSessionOnExit = true;
|
|
1296
|
+
return;
|
|
1297
|
+
}
|
|
1230
1298
|
if (isStoppedError) {
|
|
1231
1299
|
task.status = "stopped";
|
|
1232
1300
|
const stoppedPayload = {
|
|
@@ -1274,13 +1342,16 @@ class BackgroundTaskManager {
|
|
|
1274
1342
|
});
|
|
1275
1343
|
} finally {
|
|
1276
1344
|
this.finalizeTask(taskId, task.status);
|
|
1345
|
+
const preserveSubSession = task?._preserveSubSessionOnExit === true;
|
|
1277
1346
|
const sessionComp = this.getSessionComponent();
|
|
1278
|
-
if (sessionComp?.endSessionCleanup && task?.subSessionId) {
|
|
1347
|
+
if (!preserveSubSession && sessionComp?.endSessionCleanup && task?.subSessionId) {
|
|
1279
1348
|
try {
|
|
1280
1349
|
await sessionComp.endSessionCleanup(task.subSessionId);
|
|
1281
1350
|
} catch (err) {
|
|
1282
1351
|
logger3.warn(`[BackgroundTaskManager] endSessionCleanup failed for ${task.subSessionId}`, { error: err instanceof Error ? err.message : String(err) });
|
|
1283
1352
|
}
|
|
1353
|
+
} else if (preserveSubSession) {
|
|
1354
|
+
logger3.info(`[BackgroundTaskManager] Preserve sub session for ask_user resume: ${task.subSessionId}`);
|
|
1284
1355
|
}
|
|
1285
1356
|
}
|
|
1286
1357
|
}
|
|
@@ -325,7 +325,9 @@ var DEFAULT_AGENT_CONFIG = {
|
|
|
325
325
|
doomLoopThreshold: 5,
|
|
326
326
|
toolTimeout: 60000,
|
|
327
327
|
toolRetries: 3,
|
|
328
|
-
filterHistory: false
|
|
328
|
+
filterHistory: false,
|
|
329
|
+
allowedTools: undefined,
|
|
330
|
+
deniedTools: undefined
|
|
329
331
|
};
|
|
330
332
|
var AgentInstanceSchema = z.object({
|
|
331
333
|
type: z.enum(["primary", "sub"]).default("primary"),
|