@ai-setting/roy-agent-core 1.7.38 → 1.7.40
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/config/index.js +6 -6
- package/dist/env/agent/index.js +7 -7
- package/dist/env/commands/index.js +6 -6
- package/dist/env/context/index.js +6 -2
- package/dist/env/debug/index.js +6 -6
- package/dist/env/event-source/index.js +9 -9
- package/dist/env/hook/index.js +4 -4
- package/dist/env/index.js +23 -23
- package/dist/env/llm/index.js +6 -6
- package/dist/env/log-trace/index.js +6 -6
- package/dist/env/mcp/index.js +6 -6
- package/dist/env/memory/index.js +6 -6
- package/dist/env/plugin/index.js +6 -6
- package/dist/env/prompt/index.js +7 -7
- package/dist/env/session/index.js +6 -6
- package/dist/env/skill/index.js +6 -6
- package/dist/env/task/delegate/index.js +5 -5
- package/dist/env/task/index.js +10 -10
- package/dist/env/task/plugins/index.js +5 -4
- package/dist/env/task/storage/index.js +1 -1
- package/dist/env/task/tools/index.js +2 -2
- package/dist/env/tool/index.js +6 -6
- package/dist/env/workflow/engine/index.js +5 -5
- package/dist/env/workflow/index.js +10 -10
- package/dist/env/workflow/tools/index.js +7 -7
- package/dist/index.js +33 -33
- package/dist/shared/@ai-setting/{roy-agent-core-skqt40yy.js → roy-agent-core-223v204d.js} +213 -134
- package/dist/shared/@ai-setting/{roy-agent-core-83j0v0hs.js → roy-agent-core-34je386q.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-p0c98phj.js → roy-agent-core-3h7ajma5.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-mzyzdf33.js → roy-agent-core-4cqcdk7k.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-e02f0ywc.js → roy-agent-core-4m0t4y9w.js} +86 -32
- package/dist/shared/@ai-setting/{roy-agent-core-nz4n1w28.js → roy-agent-core-6mnwqcqf.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-vn6f4nxv.js → roy-agent-core-8xgk89y4.js} +9 -6
- package/dist/shared/@ai-setting/{roy-agent-core-yv4anf1c.js → roy-agent-core-9t675te0.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-yjyvwxs4.js → roy-agent-core-a236mps6.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-gh6szaj5.js → roy-agent-core-asxe1nt4.js} +4 -4
- package/dist/shared/@ai-setting/{roy-agent-core-y7atw1kw.js → roy-agent-core-cw89yj9d.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-9wsy4yfv.js → roy-agent-core-cysnmvcy.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-5gpf5j51.js → roy-agent-core-f18jk3cw.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-wb1b61f8.js → roy-agent-core-jadrj0bz.js} +7 -0
- package/dist/shared/@ai-setting/{roy-agent-core-p2ham63a.js → roy-agent-core-jawzpf5k.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-wfpzny0h.js → roy-agent-core-jjw7xcxv.js} +3 -3
- package/dist/shared/@ai-setting/{roy-agent-core-cd9h49ng.js → roy-agent-core-m3ffkexb.js} +4 -4
- package/dist/shared/@ai-setting/{roy-agent-core-rhfywyz1.js → roy-agent-core-n1ceexfz.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-970btnjh.js → roy-agent-core-ncydpb6b.js} +4 -4
- package/dist/shared/@ai-setting/{roy-agent-core-vh10qamt.js → roy-agent-core-p3kp447d.js} +35 -20
- package/dist/shared/@ai-setting/{roy-agent-core-e8rxb9a6.js → roy-agent-core-pc8x07p0.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-wacnvjaq.js → roy-agent-core-qfktfbrr.js} +4 -4
- package/dist/shared/@ai-setting/{roy-agent-core-q3vbxprp.js → roy-agent-core-rczz7e81.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-ym1hwrcm.js → roy-agent-core-s44egzrh.js} +34 -3
- package/dist/shared/@ai-setting/{roy-agent-core-dfnyvxr9.js → roy-agent-core-ts56bz5e.js} +4 -4
- package/dist/shared/@ai-setting/{roy-agent-core-hfmpmt0k.js → roy-agent-core-vsrfzaze.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-ff2ssff5.js → roy-agent-core-wn59p0zw.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-gpf33hn9.js → roy-agent-core-wqbpddyr.js} +109 -45
- package/dist/shared/@ai-setting/{roy-agent-core-3m7j2wcb.js → roy-agent-core-wybj8emq.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-z4486eek.js → roy-agent-core-zbb3sk72.js} +16 -2
- package/dist/shared/@ai-setting/{roy-agent-core-e5pnnzdm.js → roy-agent-core-zmr3jzpe.js} +178 -40
- package/package.json +1 -1
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
} from "./roy-agent-core-1pg0fepg.js";
|
|
11
11
|
import {
|
|
12
12
|
builtInPrompts
|
|
13
|
-
} from "./roy-agent-core-
|
|
13
|
+
} from "./roy-agent-core-223v204d.js";
|
|
14
14
|
import {
|
|
15
15
|
DEFAULT_SUBAGENT_PROMPT
|
|
16
16
|
} from "./roy-agent-core-za09t5g3.js";
|
|
@@ -20,14 +20,14 @@ import {
|
|
|
20
20
|
import {
|
|
21
21
|
globalHookManager,
|
|
22
22
|
init_global_hook_manager
|
|
23
|
-
} from "./roy-agent-core-
|
|
23
|
+
} from "./roy-agent-core-a236mps6.js";
|
|
24
24
|
import {
|
|
25
25
|
init_context
|
|
26
|
-
} from "./roy-agent-core-
|
|
26
|
+
} from "./roy-agent-core-wn59p0zw.js";
|
|
27
27
|
import {
|
|
28
28
|
getCurrentTaskId,
|
|
29
29
|
getEnvContext
|
|
30
|
-
} from "./roy-agent-core-
|
|
30
|
+
} from "./roy-agent-core-zbb3sk72.js";
|
|
31
31
|
import {
|
|
32
32
|
TracedAs,
|
|
33
33
|
init_decorator,
|
|
@@ -1046,7 +1046,19 @@ class BackgroundTaskManager {
|
|
|
1046
1046
|
getSessionComponent() {
|
|
1047
1047
|
return this.env?.getComponent?.("session");
|
|
1048
1048
|
}
|
|
1049
|
-
|
|
1049
|
+
async resolveAssociatedTaskIdBySubSession(subSessionId) {
|
|
1050
|
+
if (!subSessionId)
|
|
1051
|
+
return;
|
|
1052
|
+
try {
|
|
1053
|
+
const taskComponent = this.env?.getComponent?.("task");
|
|
1054
|
+
const id = await taskComponent?.getTaskIdBySessionId?.(subSessionId);
|
|
1055
|
+
return typeof id === "number" && id > 0 ? id : undefined;
|
|
1056
|
+
} catch (err) {
|
|
1057
|
+
logger3.debug(`[BackgroundTaskManager] resolveAssociatedTaskIdBySubSession failed for ${subSessionId}: ${err instanceof Error ? err.message : String(err)}`);
|
|
1058
|
+
return;
|
|
1059
|
+
}
|
|
1060
|
+
}
|
|
1061
|
+
publishBackgroundEvent(type, payload, parentSessionId, triggerEventId, replyChannel) {
|
|
1050
1062
|
if (this.env?.pushEnvEvent) {
|
|
1051
1063
|
this.env.pushEnvEvent({
|
|
1052
1064
|
type,
|
|
@@ -1054,16 +1066,18 @@ class BackgroundTaskManager {
|
|
|
1054
1066
|
metadata: {
|
|
1055
1067
|
source: "task.background",
|
|
1056
1068
|
trigger_session_id: parentSessionId,
|
|
1057
|
-
...triggerEventId ? { triggerEventId } : {}
|
|
1069
|
+
...triggerEventId ? { triggerEventId } : {},
|
|
1070
|
+
...replyChannel ? { replyChannel } : {}
|
|
1058
1071
|
}
|
|
1059
1072
|
});
|
|
1060
1073
|
logger3.info(`[BackgroundTaskManager] Event published: ${type}`, {
|
|
1061
|
-
triggerEventId
|
|
1074
|
+
triggerEventId,
|
|
1075
|
+
replyChannelChatId: replyChannel?.chatId
|
|
1062
1076
|
});
|
|
1063
1077
|
}
|
|
1064
1078
|
}
|
|
1065
|
-
publishBackgroundEventWithTrigger(type, payload, parentSessionId, triggerEventId) {
|
|
1066
|
-
this.publishBackgroundEvent(type, payload, parentSessionId, triggerEventId);
|
|
1079
|
+
publishBackgroundEventWithTrigger(type, payload, parentSessionId, triggerEventId, replyChannel) {
|
|
1080
|
+
this.publishBackgroundEvent(type, payload, parentSessionId, triggerEventId, replyChannel);
|
|
1067
1081
|
}
|
|
1068
1082
|
static parseAskUserErrorFromMessage(error) {
|
|
1069
1083
|
const rawErrorMessage = error instanceof Error ? error.message : String(error);
|
|
@@ -1171,6 +1185,7 @@ class BackgroundTaskManager {
|
|
|
1171
1185
|
throw new Error("Failed to create sub-session");
|
|
1172
1186
|
}
|
|
1173
1187
|
}
|
|
1188
|
+
const replyChannelSnapshot = captureReplyChannelSnapshot();
|
|
1174
1189
|
const abortController = new AbortController;
|
|
1175
1190
|
if (this.processRegistries.size >= this.maxProcessRegistries) {
|
|
1176
1191
|
this.cleanupEmptyProcessRegistries();
|
|
@@ -1194,7 +1209,8 @@ class BackgroundTaskManager {
|
|
|
1194
1209
|
lastUpdatedAt: createdAt,
|
|
1195
1210
|
abortController,
|
|
1196
1211
|
similarTaskIds,
|
|
1197
|
-
triggerEventId
|
|
1212
|
+
triggerEventId,
|
|
1213
|
+
replyChannel: replyChannelSnapshot
|
|
1198
1214
|
};
|
|
1199
1215
|
this.tasks.set(taskIdGen, task);
|
|
1200
1216
|
this.abortControllers.set(taskIdGen, abortController);
|
|
@@ -1205,7 +1221,7 @@ class BackgroundTaskManager {
|
|
|
1205
1221
|
description,
|
|
1206
1222
|
subagentType
|
|
1207
1223
|
};
|
|
1208
|
-
this.publishBackgroundEvent(BackgroundTaskEventTypes.STARTED, startedPayload, parentSessionId, triggerEventId);
|
|
1224
|
+
this.publishBackgroundEvent(BackgroundTaskEventTypes.STARTED, startedPayload, parentSessionId, triggerEventId, replyChannelSnapshot);
|
|
1209
1225
|
this.executeTask(taskIdGen, prompt, timeout, parentSessionId).catch((err) => {
|
|
1210
1226
|
logger3.error(`[BackgroundTaskManager] executeTask unhandled rejection`, {
|
|
1211
1227
|
taskId: taskIdGen,
|
|
@@ -1246,11 +1262,8 @@ class BackgroundTaskManager {
|
|
|
1246
1262
|
task.result = result;
|
|
1247
1263
|
const executionTimeMs = task.completedAt - task.startedAt;
|
|
1248
1264
|
task.associatedTaskId = getCurrentTaskId();
|
|
1249
|
-
if (task.associatedTaskId === undefined
|
|
1250
|
-
|
|
1251
|
-
if (match) {
|
|
1252
|
-
task.associatedTaskId = parseInt(match[1], 10);
|
|
1253
|
-
}
|
|
1265
|
+
if (task.associatedTaskId === undefined) {
|
|
1266
|
+
task.associatedTaskId = await this.resolveAssociatedTaskIdBySubSession(task.subSessionId);
|
|
1254
1267
|
}
|
|
1255
1268
|
const completedPayload = {
|
|
1256
1269
|
backgroundTaskId: task.id,
|
|
@@ -1262,7 +1275,7 @@ class BackgroundTaskManager {
|
|
|
1262
1275
|
executionTimeMs,
|
|
1263
1276
|
associatedTaskId: task.associatedTaskId
|
|
1264
1277
|
};
|
|
1265
|
-
this.publishBackgroundEvent(BackgroundTaskEventTypes.COMPLETED, completedPayload, parentSessionId || task.parentSessionId, task.triggerEventId);
|
|
1278
|
+
this.publishBackgroundEvent(BackgroundTaskEventTypes.COMPLETED, completedPayload, parentSessionId || task.parentSessionId, task.triggerEventId, task.replyChannel);
|
|
1266
1279
|
logger3.info(`[BackgroundTaskManager] Task completed successfully`, {
|
|
1267
1280
|
taskId,
|
|
1268
1281
|
executionTimeMs
|
|
@@ -1276,6 +1289,9 @@ class BackgroundTaskManager {
|
|
|
1276
1289
|
task.completedAt = completedAt;
|
|
1277
1290
|
task.lastUpdatedAt = completedAt;
|
|
1278
1291
|
task.associatedTaskId = getCurrentTaskId();
|
|
1292
|
+
if (task.associatedTaskId === undefined) {
|
|
1293
|
+
task.associatedTaskId = await this.resolveAssociatedTaskIdBySubSession(task.subSessionId);
|
|
1294
|
+
}
|
|
1279
1295
|
if (askUserInfo) {
|
|
1280
1296
|
task.status = "awaiting-user";
|
|
1281
1297
|
task.error = askUserInfo.rawErrorMessage;
|
|
@@ -1299,7 +1315,7 @@ class BackgroundTaskManager {
|
|
|
1299
1315
|
],
|
|
1300
1316
|
associatedTaskId: task.associatedTaskId
|
|
1301
1317
|
};
|
|
1302
|
-
this.publishBackgroundEvent(BackgroundTaskEventTypes.ASK_USER, askUserPayload, parentSessionId || task.parentSessionId, task.triggerEventId);
|
|
1318
|
+
this.publishBackgroundEvent(BackgroundTaskEventTypes.ASK_USER, askUserPayload, parentSessionId || task.parentSessionId, task.triggerEventId, task.replyChannel);
|
|
1303
1319
|
logger3.info(`[BackgroundTaskManager] Task awaiting user input (ask_user cascade)`, {
|
|
1304
1320
|
taskId,
|
|
1305
1321
|
subSessionId: task.subSessionId,
|
|
@@ -1321,7 +1337,7 @@ class BackgroundTaskManager {
|
|
|
1321
1337
|
executionTimeMs,
|
|
1322
1338
|
associatedTaskId: task.associatedTaskId
|
|
1323
1339
|
};
|
|
1324
|
-
this.publishBackgroundEvent(BackgroundTaskEventTypes.STOPPED, stoppedPayload, parentSessionId || task.parentSessionId, task.triggerEventId);
|
|
1340
|
+
this.publishBackgroundEvent(BackgroundTaskEventTypes.STOPPED, stoppedPayload, parentSessionId || task.parentSessionId, task.triggerEventId, task.replyChannel);
|
|
1325
1341
|
} else if (errorMessage.startsWith("Task execution timeout after")) {
|
|
1326
1342
|
task.status = "timeout";
|
|
1327
1343
|
const timeoutPayload = {
|
|
@@ -1334,7 +1350,7 @@ class BackgroundTaskManager {
|
|
|
1334
1350
|
executionTimeMs,
|
|
1335
1351
|
associatedTaskId: task.associatedTaskId
|
|
1336
1352
|
};
|
|
1337
|
-
this.publishBackgroundEvent(BackgroundTaskEventTypes.TIMEOUT, timeoutPayload, parentSessionId || task.parentSessionId, task.triggerEventId);
|
|
1353
|
+
this.publishBackgroundEvent(BackgroundTaskEventTypes.TIMEOUT, timeoutPayload, parentSessionId || task.parentSessionId, task.triggerEventId, task.replyChannel);
|
|
1338
1354
|
} else {
|
|
1339
1355
|
task.status = "failed";
|
|
1340
1356
|
const failedPayload = {
|
|
@@ -1346,7 +1362,7 @@ class BackgroundTaskManager {
|
|
|
1346
1362
|
executionTimeMs,
|
|
1347
1363
|
associatedTaskId: task.associatedTaskId
|
|
1348
1364
|
};
|
|
1349
|
-
this.publishBackgroundEvent(BackgroundTaskEventTypes.FAILED, failedPayload, parentSessionId || task.parentSessionId, task.triggerEventId);
|
|
1365
|
+
this.publishBackgroundEvent(BackgroundTaskEventTypes.FAILED, failedPayload, parentSessionId || task.parentSessionId, task.triggerEventId, task.replyChannel);
|
|
1350
1366
|
}
|
|
1351
1367
|
task.error = errorMessage;
|
|
1352
1368
|
logger3.error(`[BackgroundTaskManager] Task execution error`, {
|
|
@@ -1389,7 +1405,7 @@ class BackgroundTaskManager {
|
|
|
1389
1405
|
status: task.status,
|
|
1390
1406
|
associatedTaskId: task.associatedTaskId
|
|
1391
1407
|
};
|
|
1392
|
-
this.publishBackgroundEvent(BackgroundTaskEventTypes.PROGRESS, progressPayload, parentSessionId, task.triggerEventId);
|
|
1408
|
+
this.publishBackgroundEvent(BackgroundTaskEventTypes.PROGRESS, progressPayload, parentSessionId, task.triggerEventId, task.replyChannel);
|
|
1393
1409
|
}, PROGRESS_INTERVAL);
|
|
1394
1410
|
this.progressTimers.set(taskId, timer);
|
|
1395
1411
|
}
|
|
@@ -1679,7 +1695,7 @@ ${reuseSection.markdown}`;
|
|
|
1679
1695
|
executionTimeMs: task.startedAt ? task.completedAt - task.startedAt : 0,
|
|
1680
1696
|
associatedTaskId: task.associatedTaskId
|
|
1681
1697
|
};
|
|
1682
|
-
this.publishBackgroundEvent(BackgroundTaskEventTypes.STOPPED, stoppedPayload, task.parentSessionId, task.triggerEventId);
|
|
1698
|
+
this.publishBackgroundEvent(BackgroundTaskEventTypes.STOPPED, stoppedPayload, task.parentSessionId, task.triggerEventId, task.replyChannel);
|
|
1683
1699
|
this.finalizeTask(taskId, "stopped");
|
|
1684
1700
|
return {
|
|
1685
1701
|
success: true,
|
|
@@ -1770,7 +1786,7 @@ ${reuseSection.markdown}`;
|
|
|
1770
1786
|
executionTimeMs: taskSafe.startedAt && taskSafe.completedAt ? taskSafe.completedAt - taskSafe.startedAt : 0,
|
|
1771
1787
|
associatedTaskId: taskSafe.associatedTaskId
|
|
1772
1788
|
};
|
|
1773
|
-
this.publishBackgroundEvent(BackgroundTaskEventTypes.STOPPED, stoppedPayload, taskSafe.parentSessionId, taskSafe.triggerEventId);
|
|
1789
|
+
this.publishBackgroundEvent(BackgroundTaskEventTypes.STOPPED, stoppedPayload, taskSafe.parentSessionId, taskSafe.triggerEventId, taskSafe.replyChannel);
|
|
1774
1790
|
}
|
|
1775
1791
|
}
|
|
1776
1792
|
}
|
|
@@ -1920,19 +1936,23 @@ No need to poll — just wait for the notification and use \`task_get\` with the
|
|
|
1920
1936
|
execute: async (args, ctx) => {
|
|
1921
1937
|
const startTime = Date.now();
|
|
1922
1938
|
const params = DelegateToolParameters.parse(args);
|
|
1923
|
-
const { description, prompt, subagent_type = "general", timeout, reason, similar_task_ids
|
|
1939
|
+
const { description, prompt, subagent_type = "general", timeout, reason, similar_task_ids } = params;
|
|
1924
1940
|
const parentSessionId = ctx.session_id || "default";
|
|
1925
|
-
|
|
1926
|
-
if (triggerEventId) {
|
|
1941
|
+
const resolvedTriggerEventId = params.triggerEventId ?? deriveTriggerEventIdFromEnvContext();
|
|
1942
|
+
if (resolvedTriggerEventId && resolvedTriggerEventId !== params.triggerEventId) {
|
|
1943
|
+
logger3.info(`[delegate_task] triggerEventId auto-derived from EnvContext: ${resolvedTriggerEventId}`);
|
|
1944
|
+
}
|
|
1945
|
+
logger3.info(`[delegate_task] Called: description=${description}, subagent_type=${subagent_type}, triggerEventId=${resolvedTriggerEventId ?? "(none)"}`);
|
|
1946
|
+
if (resolvedTriggerEventId) {
|
|
1927
1947
|
const store = getSharedEventStore();
|
|
1928
1948
|
if (store) {
|
|
1929
1949
|
try {
|
|
1930
|
-
const persisted = await store.getEventById(
|
|
1950
|
+
const persisted = await store.getEventById(resolvedTriggerEventId);
|
|
1931
1951
|
if (!persisted) {
|
|
1932
1952
|
return {
|
|
1933
1953
|
success: false,
|
|
1934
1954
|
output: "",
|
|
1935
|
-
error: `Unknown triggerEventId: ${
|
|
1955
|
+
error: `Unknown triggerEventId: ${resolvedTriggerEventId} (not found in EventStore)`,
|
|
1936
1956
|
metadata: { execution_time_ms: Date.now() - startTime }
|
|
1937
1957
|
};
|
|
1938
1958
|
}
|
|
@@ -1940,12 +1960,12 @@ No need to poll — just wait for the notification and use \`task_get\` with the
|
|
|
1940
1960
|
return {
|
|
1941
1961
|
success: false,
|
|
1942
1962
|
output: "",
|
|
1943
|
-
error: `Failed to verify triggerEventId ${
|
|
1963
|
+
error: `Failed to verify triggerEventId ${resolvedTriggerEventId}: ${err instanceof Error ? err.message : String(err)}`,
|
|
1944
1964
|
metadata: { execution_time_ms: Date.now() - startTime }
|
|
1945
1965
|
};
|
|
1946
1966
|
}
|
|
1947
1967
|
} else {
|
|
1948
|
-
logger3.warn(`[delegate_task] triggerEventId=${
|
|
1968
|
+
logger3.warn(`[delegate_task] triggerEventId=${resolvedTriggerEventId} supplied but no shared EventStore registered; skipping verification`);
|
|
1949
1969
|
}
|
|
1950
1970
|
}
|
|
1951
1971
|
const registry2 = getAgentRegistry(taskComponent);
|
|
@@ -1975,7 +1995,7 @@ No need to poll — just wait for the notification and use \`task_get\` with the
|
|
|
1975
1995
|
};
|
|
1976
1996
|
await globalHookManager.execute(TaskHookPoints.DELEGATE_BEFORE, delegateCtx, { sessionId: parentSessionId });
|
|
1977
1997
|
promptWithTaskInfo = delegateCtx.prompt;
|
|
1978
|
-
return await handleBackgroundTask(backgroundTaskManager, parentSessionId, description, promptWithTaskInfo, delegateCtx.subagentType, delegateCtx.timeout, similar_task_ids, params.sub_session_id,
|
|
1998
|
+
return await handleBackgroundTask(backgroundTaskManager, parentSessionId, description, promptWithTaskInfo, delegateCtx.subagentType, delegateCtx.timeout, similar_task_ids, params.sub_session_id, resolvedTriggerEventId);
|
|
1979
1999
|
}
|
|
1980
2000
|
};
|
|
1981
2001
|
tool.execute = wrapFunction(tool.execute, "delegate.execute", {
|
|
@@ -1985,6 +2005,40 @@ No need to poll — just wait for the notification and use \`task_get\` with the
|
|
|
1985
2005
|
});
|
|
1986
2006
|
return tool;
|
|
1987
2007
|
}
|
|
2008
|
+
function _deriveTriggerEventIdFromEnvContext() {
|
|
2009
|
+
const env = getEnvContext();
|
|
2010
|
+
if (!env)
|
|
2011
|
+
return;
|
|
2012
|
+
const envEvent = env.envEvent;
|
|
2013
|
+
const fromMeta = envEvent?.metadata?.triggerEventId;
|
|
2014
|
+
if (typeof fromMeta === "string" && fromMeta.length > 0)
|
|
2015
|
+
return fromMeta;
|
|
2016
|
+
const fromPayload = envEvent?.payload?.triggerEventId;
|
|
2017
|
+
if (typeof fromPayload === "string" && fromPayload.length > 0)
|
|
2018
|
+
return fromPayload;
|
|
2019
|
+
return;
|
|
2020
|
+
}
|
|
2021
|
+
var deriveTriggerEventIdFromEnvContext = wrapFunction(_deriveTriggerEventIdFromEnvContext, "delegate.deriveTriggerEventId", { recordParams: false, recordResult: true, recordError: true });
|
|
2022
|
+
function _captureReplyChannelSnapshot() {
|
|
2023
|
+
const replyChannel = getEnvContext()?.replyChannel;
|
|
2024
|
+
if (!replyChannel)
|
|
2025
|
+
return;
|
|
2026
|
+
if (!replyChannel.chatId && !replyChannel.messageId)
|
|
2027
|
+
return;
|
|
2028
|
+
const params = { ...replyChannel.params ?? {} };
|
|
2029
|
+
if (replyChannel.userId && params.userId === undefined) {
|
|
2030
|
+
params.userId = replyChannel.userId;
|
|
2031
|
+
}
|
|
2032
|
+
return {
|
|
2033
|
+
type: replyChannel.type,
|
|
2034
|
+
appId: replyChannel.appId,
|
|
2035
|
+
chatId: replyChannel.chatId,
|
|
2036
|
+
messageId: replyChannel.messageId,
|
|
2037
|
+
profile: replyChannel.profile,
|
|
2038
|
+
params: Object.keys(params).length > 0 ? params : undefined
|
|
2039
|
+
};
|
|
2040
|
+
}
|
|
2041
|
+
var captureReplyChannelSnapshot = wrapFunction(_captureReplyChannelSnapshot, "delegate.captureReplyChannel", { recordParams: false, recordResult: true, recordError: true });
|
|
1988
2042
|
async function handleBackgroundTask(backgroundTaskManager, parentSessionId, description, prompt, subagentType, timeout, similarTaskIds, existingSubSessionId, triggerEventId) {
|
|
1989
2043
|
const startTime = Date.now();
|
|
1990
2044
|
try {
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
searchTasksTool,
|
|
10
10
|
treeTasksTool,
|
|
11
11
|
updateTaskTool
|
|
12
|
-
} from "./roy-agent-core-
|
|
12
|
+
} from "./roy-agent-core-vsrfzaze.js";
|
|
13
13
|
import {
|
|
14
14
|
createOperationTool,
|
|
15
15
|
deleteOperationTool,
|
|
@@ -27,11 +27,11 @@ import {
|
|
|
27
27
|
BackgroundTaskManager,
|
|
28
28
|
createDelegateTool,
|
|
29
29
|
createStopTool
|
|
30
|
-
} from "./roy-agent-core-
|
|
30
|
+
} from "./roy-agent-core-4m0t4y9w.js";
|
|
31
31
|
import {
|
|
32
32
|
SQLiteTaskStore,
|
|
33
33
|
getDefaultTaskDbPath
|
|
34
|
-
} from "./roy-agent-core-
|
|
34
|
+
} from "./roy-agent-core-jadrj0bz.js";
|
|
35
35
|
import {
|
|
36
36
|
TaskHookPoints
|
|
37
37
|
} from "./roy-agent-core-1pg0fepg.js";
|
|
@@ -40,15 +40,15 @@ import {
|
|
|
40
40
|
} from "./roy-agent-core-7hh0brvs.js";
|
|
41
41
|
import {
|
|
42
42
|
BaseComponent
|
|
43
|
-
} from "./roy-agent-core-
|
|
43
|
+
} from "./roy-agent-core-9t675te0.js";
|
|
44
44
|
import {
|
|
45
45
|
globalHookManager,
|
|
46
46
|
init_global_hook_manager
|
|
47
|
-
} from "./roy-agent-core-
|
|
47
|
+
} from "./roy-agent-core-a236mps6.js";
|
|
48
48
|
import {
|
|
49
49
|
getEnvContextOrEmpty,
|
|
50
50
|
init_env_context
|
|
51
|
-
} from "./roy-agent-core-
|
|
51
|
+
} from "./roy-agent-core-zbb3sk72.js";
|
|
52
52
|
import {
|
|
53
53
|
TracedAs,
|
|
54
54
|
init_decorator
|
|
@@ -432,6 +432,9 @@ class TaskComponent extends BaseComponent {
|
|
|
432
432
|
async getTask(id) {
|
|
433
433
|
return this.store.getTask(id);
|
|
434
434
|
}
|
|
435
|
+
async getTaskIdBySessionId(sessionId) {
|
|
436
|
+
return this.store.getTaskIdBySessionId(sessionId);
|
|
437
|
+
}
|
|
435
438
|
async getTaskWithOperations(id) {
|
|
436
439
|
const task = await this.store.getTask(id);
|
|
437
440
|
if (!task)
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createHook
|
|
3
|
-
} from "./roy-agent-core-
|
|
3
|
+
} from "./roy-agent-core-cw89yj9d.js";
|
|
4
4
|
import {
|
|
5
5
|
HookManager
|
|
6
|
-
} from "./roy-agent-core-
|
|
6
|
+
} from "./roy-agent-core-a236mps6.js";
|
|
7
7
|
|
|
8
8
|
// src/env/component.ts
|
|
9
9
|
class BaseComponent {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
init_context
|
|
3
|
-
} from "./roy-agent-core-
|
|
3
|
+
} from "./roy-agent-core-wn59p0zw.js";
|
|
4
4
|
import {
|
|
5
5
|
getEnvContext
|
|
6
|
-
} from "./roy-agent-core-
|
|
6
|
+
} from "./roy-agent-core-zbb3sk72.js";
|
|
7
7
|
import {
|
|
8
8
|
__esm
|
|
9
9
|
} from "./roy-agent-core-fs0mn2jk.js";
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AgentComponentAdapter,
|
|
3
3
|
init_agent_component_adapter
|
|
4
|
-
} from "./roy-agent-core-
|
|
4
|
+
} from "./roy-agent-core-3h7ajma5.js";
|
|
5
5
|
import"./roy-agent-core-1db4vpc6.js";
|
|
6
6
|
import"./roy-agent-core-e25xkv53.js";
|
|
7
|
-
import"./roy-agent-core-
|
|
8
|
-
import"./roy-agent-core-
|
|
9
|
-
import"./roy-agent-core-
|
|
7
|
+
import"./roy-agent-core-a236mps6.js";
|
|
8
|
+
import"./roy-agent-core-wn59p0zw.js";
|
|
9
|
+
import"./roy-agent-core-zbb3sk72.js";
|
|
10
10
|
import"./roy-agent-core-a9pbda78.js";
|
|
11
11
|
import"./roy-agent-core-8seq65bp.js";
|
|
12
12
|
import"./roy-agent-core-jnszp0jq.js";
|
|
@@ -671,6 +671,13 @@ var init_sqlite_task_store = __esm(() => {
|
|
|
671
671
|
const limit = options.limit || 20;
|
|
672
672
|
return ops.slice(offset, offset + limit);
|
|
673
673
|
}
|
|
674
|
+
async getTaskIdBySessionId(sessionId) {
|
|
675
|
+
await this.initialize();
|
|
676
|
+
if (!sessionId)
|
|
677
|
+
return;
|
|
678
|
+
const row = this.db.prepare("SELECT task_id FROM task_operation WHERE session_id = ? AND milestone_type = 'create' ORDER BY timestamp ASC LIMIT 1").get(sessionId);
|
|
679
|
+
return typeof row?.task_id === "number" ? row.task_id : undefined;
|
|
680
|
+
}
|
|
674
681
|
rowToTask(row) {
|
|
675
682
|
return {
|
|
676
683
|
id: row.id,
|
|
@@ -11,16 +11,16 @@ import {
|
|
|
11
11
|
} from "./roy-agent-core-7hh0brvs.js";
|
|
12
12
|
import {
|
|
13
13
|
BaseComponent
|
|
14
|
-
} from "./roy-agent-core-
|
|
14
|
+
} from "./roy-agent-core-9t675te0.js";
|
|
15
15
|
import {
|
|
16
16
|
ToolHookPoints,
|
|
17
17
|
globalHookManager,
|
|
18
18
|
init_global_hook_manager
|
|
19
|
-
} from "./roy-agent-core-
|
|
19
|
+
} from "./roy-agent-core-a236mps6.js";
|
|
20
20
|
import {
|
|
21
21
|
getCurrentTaskId,
|
|
22
22
|
init_env_context
|
|
23
|
-
} from "./roy-agent-core-
|
|
23
|
+
} from "./roy-agent-core-zbb3sk72.js";
|
|
24
24
|
import {
|
|
25
25
|
TracedAs,
|
|
26
26
|
init_decorator
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
createWorkflowSearchTool,
|
|
14
14
|
createWorkflowTagListTool,
|
|
15
15
|
createWorkflowValidateTool
|
|
16
|
-
} from "./roy-agent-core-
|
|
16
|
+
} from "./roy-agent-core-34je386q.js";
|
|
17
17
|
import {
|
|
18
18
|
WorkflowService
|
|
19
19
|
} from "./roy-agent-core-8nv07zgr.js";
|
|
@@ -21,10 +21,10 @@ import {
|
|
|
21
21
|
WorkflowEngine,
|
|
22
22
|
exports_engine,
|
|
23
23
|
init_engine
|
|
24
|
-
} from "./roy-agent-core-
|
|
24
|
+
} from "./roy-agent-core-rczz7e81.js";
|
|
25
25
|
import {
|
|
26
26
|
BaseComponent
|
|
27
|
-
} from "./roy-agent-core-
|
|
27
|
+
} from "./roy-agent-core-9t675te0.js";
|
|
28
28
|
import {
|
|
29
29
|
createLogger,
|
|
30
30
|
init_logger
|
|
@@ -141,7 +141,7 @@ class WorkflowComponent extends BaseComponent {
|
|
|
141
141
|
if (!agentRunner && this._workflowEnv) {
|
|
142
142
|
const agentComponent = this._workflowEnv.getComponent("agent");
|
|
143
143
|
if (agentComponent) {
|
|
144
|
-
const { AgentComponentAdapter } = await import("./roy-agent-core-
|
|
144
|
+
const { AgentComponentAdapter } = await import("./roy-agent-core-asxe1nt4.js");
|
|
145
145
|
agentRunner = new AgentComponentAdapter(agentComponent, {}, this.sessionComponent);
|
|
146
146
|
}
|
|
147
147
|
}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createAutoTaskPlugin
|
|
3
|
-
} from "./roy-agent-core-
|
|
3
|
+
} from "./roy-agent-core-zmr3jzpe.js";
|
|
4
4
|
import {
|
|
5
5
|
ContextError,
|
|
6
6
|
ErrorCodes
|
|
7
7
|
} from "./roy-agent-core-ctdhjv68.js";
|
|
8
8
|
import {
|
|
9
9
|
BaseComponent
|
|
10
|
-
} from "./roy-agent-core-
|
|
10
|
+
} from "./roy-agent-core-9t675te0.js";
|
|
11
11
|
import {
|
|
12
12
|
init_context
|
|
13
|
-
} from "./roy-agent-core-
|
|
13
|
+
} from "./roy-agent-core-wn59p0zw.js";
|
|
14
14
|
import {
|
|
15
15
|
getEnvContext,
|
|
16
16
|
init_env_context,
|
|
17
17
|
runWithEnvContextAsync
|
|
18
|
-
} from "./roy-agent-core-
|
|
18
|
+
} from "./roy-agent-core-zbb3sk72.js";
|
|
19
19
|
import {
|
|
20
20
|
TracedAs,
|
|
21
21
|
init_decorator
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
truncateOutputInline
|
|
3
|
-
} from "./roy-agent-core-
|
|
3
|
+
} from "./roy-agent-core-jjw7xcxv.js";
|
|
4
4
|
import {
|
|
5
5
|
AgentRegistry
|
|
6
6
|
} from "./roy-agent-core-za09t5g3.js";
|
|
@@ -29,19 +29,20 @@ import {
|
|
|
29
29
|
} from "./roy-agent-core-7hh0brvs.js";
|
|
30
30
|
import {
|
|
31
31
|
BaseComponent
|
|
32
|
-
} from "./roy-agent-core-
|
|
32
|
+
} from "./roy-agent-core-9t675te0.js";
|
|
33
33
|
import {
|
|
34
34
|
globalHookManager,
|
|
35
35
|
init_global_hook_manager
|
|
36
|
-
} from "./roy-agent-core-
|
|
36
|
+
} from "./roy-agent-core-a236mps6.js";
|
|
37
37
|
import {
|
|
38
38
|
init_context
|
|
39
|
-
} from "./roy-agent-core-
|
|
39
|
+
} from "./roy-agent-core-wn59p0zw.js";
|
|
40
40
|
import {
|
|
41
41
|
getCurrentTaskId,
|
|
42
42
|
getEnvContext,
|
|
43
|
+
resolveEnvParentTaskId,
|
|
43
44
|
runWithEnvContextAsync
|
|
44
|
-
} from "./roy-agent-core-
|
|
45
|
+
} from "./roy-agent-core-zbb3sk72.js";
|
|
45
46
|
import {
|
|
46
47
|
TracedAs,
|
|
47
48
|
init_decorator
|
|
@@ -356,6 +357,29 @@ function filterToolsByAgent(tools, agent) {
|
|
|
356
357
|
return allowedList.includes(agent.name);
|
|
357
358
|
});
|
|
358
359
|
}
|
|
360
|
+
function buildRunEnvContext(inputs) {
|
|
361
|
+
const { effectiveContext, parentEnvContext, envBoundParentTaskId } = inputs;
|
|
362
|
+
const effectiveEnvEvent = effectiveContext.envEvent;
|
|
363
|
+
return {
|
|
364
|
+
...parentEnvContext,
|
|
365
|
+
agentContext: parentEnvContext?.agentContext ?? {},
|
|
366
|
+
traceId: effectiveContext.metadata?.traceId,
|
|
367
|
+
sessionId: effectiveContext.sessionId,
|
|
368
|
+
userId: parentEnvContext?.userId ?? (effectiveContext.metadata?.userId ?? ""),
|
|
369
|
+
messageId: parentEnvContext?.messageId ?? effectiveContext.metadata?.messageId,
|
|
370
|
+
pluginEnabled: {
|
|
371
|
+
...parentEnvContext?.pluginEnabled ?? {},
|
|
372
|
+
...effectiveContext.pluginEnabled ?? {}
|
|
373
|
+
},
|
|
374
|
+
plugins: effectiveContext.plugins,
|
|
375
|
+
envEvent: effectiveContext.envEvent ?? parentEnvContext?.envEvent,
|
|
376
|
+
replyChannel: effectiveEnvEvent?.metadata?.replyChannel ?? parentEnvContext?.replyChannel,
|
|
377
|
+
sourceId: parentEnvContext?.sourceId ?? effectiveContext.envEvent?.metadata?.sourceId,
|
|
378
|
+
sourceType: parentEnvContext?.sourceType ?? effectiveContext.envEvent?.metadata?.sourceType,
|
|
379
|
+
parentTaskId: envBoundParentTaskId,
|
|
380
|
+
metadata: { ...effectiveContext.metadata }
|
|
381
|
+
};
|
|
382
|
+
}
|
|
359
383
|
|
|
360
384
|
class AgentComponent extends BaseComponent {
|
|
361
385
|
name = "agent";
|
|
@@ -866,21 +890,12 @@ class AgentComponent extends BaseComponent {
|
|
|
866
890
|
}
|
|
867
891
|
}
|
|
868
892
|
const parentEnvContext = getEnvContext();
|
|
869
|
-
const
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
messageId: parentEnvContext?.messageId ?? effectiveContext.metadata?.messageId,
|
|
876
|
-
pluginEnabled: { ...parentEnvContext?.pluginEnabled ?? {}, ...effectiveContext.pluginEnabled ?? {} },
|
|
877
|
-
plugins: effectiveContext.plugins,
|
|
878
|
-
envEvent: effectiveContext.envEvent ?? parentEnvContext?.envEvent,
|
|
879
|
-
replyChannel: parentEnvContext?.replyChannel ?? effectiveContext.envEvent?.metadata?.replyChannel,
|
|
880
|
-
sourceId: parentEnvContext?.sourceId ?? effectiveContext.envEvent?.metadata?.sourceId,
|
|
881
|
-
sourceType: parentEnvContext?.sourceType ?? effectiveContext.envEvent?.metadata?.sourceType,
|
|
882
|
-
metadata: { ...effectiveContext.metadata }
|
|
883
|
-
};
|
|
893
|
+
const envBoundParentTaskId = resolveEnvParentTaskId(effectiveContext.envEvent, parentEnvContext);
|
|
894
|
+
const envContext = buildRunEnvContext({
|
|
895
|
+
effectiveContext,
|
|
896
|
+
parentEnvContext,
|
|
897
|
+
envBoundParentTaskId
|
|
898
|
+
});
|
|
884
899
|
return await runWithEnvContextAsync(envContext, async () => {
|
|
885
900
|
this.pushEnvEvent({
|
|
886
901
|
type: "agent.start",
|
|
@@ -3,17 +3,17 @@ import {
|
|
|
3
3
|
} from "./roy-agent-core-rmn29nrh.js";
|
|
4
4
|
import {
|
|
5
5
|
BaseComponent
|
|
6
|
-
} from "./roy-agent-core-
|
|
6
|
+
} from "./roy-agent-core-9t675te0.js";
|
|
7
7
|
import {
|
|
8
8
|
globalHookManager,
|
|
9
9
|
init_global_hook_manager
|
|
10
|
-
} from "./roy-agent-core-
|
|
10
|
+
} from "./roy-agent-core-a236mps6.js";
|
|
11
11
|
import {
|
|
12
12
|
init_context
|
|
13
|
-
} from "./roy-agent-core-
|
|
13
|
+
} from "./roy-agent-core-wn59p0zw.js";
|
|
14
14
|
import {
|
|
15
15
|
getEnvContextOrEmpty
|
|
16
|
-
} from "./roy-agent-core-
|
|
16
|
+
} from "./roy-agent-core-zbb3sk72.js";
|
|
17
17
|
import {
|
|
18
18
|
createLogger,
|
|
19
19
|
init_logger
|