@ai-setting/roy-agent-core 1.7.37 → 1.7.38

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 (82) hide show
  1. package/dist/config/index.js +7 -7
  2. package/dist/env/agent/index.js +10 -10
  3. package/dist/env/commands/index.js +7 -7
  4. package/dist/env/context/index.js +3 -3
  5. package/dist/env/debug/index.js +7 -7
  6. package/dist/env/event-source/index.js +24 -14
  7. package/dist/env/hook/index.js +5 -5
  8. package/dist/env/index.js +33 -32
  9. package/dist/env/llm/index.js +7 -7
  10. package/dist/env/log-trace/index.js +7 -7
  11. package/dist/env/mcp/index.js +7 -7
  12. package/dist/env/memory/index.js +7 -7
  13. package/dist/env/plugin/index.js +7 -7
  14. package/dist/env/prompt/index.js +7 -7
  15. package/dist/env/session/index.js +7 -7
  16. package/dist/env/skill/index.js +7 -7
  17. package/dist/env/task/delegate/index.js +7 -6
  18. package/dist/env/task/index.js +12 -11
  19. package/dist/env/task/plugins/index.js +7 -7
  20. package/dist/env/task/storage/index.js +2 -2
  21. package/dist/env/task/tools/index.js +3 -3
  22. package/dist/env/tool/built-in/index.js +2 -2
  23. package/dist/env/tool/index.js +8 -8
  24. package/dist/env/workflow/engine/index.js +9 -9
  25. package/dist/env/workflow/index.js +17 -17
  26. package/dist/env/workflow/nodes/index.js +2 -2
  27. package/dist/env/workflow/service/index.js +2 -2
  28. package/dist/env/workflow/storage/index.js +3 -3
  29. package/dist/env/workflow/tools/index.js +11 -11
  30. package/dist/env/workflow/utils/index.js +4 -4
  31. package/dist/index.js +53 -43
  32. package/dist/shared/@ai-setting/{roy-agent-core-yf0ex8y1.js → roy-agent-core-333apxaa.js} +1 -1
  33. package/dist/shared/@ai-setting/{roy-agent-core-mdaew65f.js → roy-agent-core-3m7j2wcb.js} +1 -1
  34. package/dist/shared/@ai-setting/{roy-agent-core-9drbkjfr.js → roy-agent-core-4cj6hram.js} +1 -1
  35. package/dist/shared/@ai-setting/{roy-agent-core-zda3rfr3.js → roy-agent-core-4kbvfnn1.js} +54 -5
  36. package/dist/shared/@ai-setting/{roy-agent-core-88tfzaxg.js → roy-agent-core-5gpf5j51.js} +1 -1
  37. package/dist/shared/@ai-setting/{roy-agent-core-jq7g5nxz.js → roy-agent-core-5j4awbgc.js} +3 -3
  38. package/dist/shared/@ai-setting/{roy-agent-core-wgttzq8e.js → roy-agent-core-6vbgswjw.js} +1 -1
  39. package/dist/shared/@ai-setting/{roy-agent-core-pxyyrxnn.js → roy-agent-core-83j0v0hs.js} +4 -4
  40. package/dist/shared/@ai-setting/{roy-agent-core-j9ejsmsj.js → roy-agent-core-8nv07zgr.js} +1 -1
  41. package/dist/shared/@ai-setting/{roy-agent-core-a8zf7ts4.js → roy-agent-core-970btnjh.js} +5 -5
  42. package/dist/shared/@ai-setting/{roy-agent-core-yw07bvqz.js → roy-agent-core-9cqpdrnk.js} +3 -3
  43. package/dist/shared/@ai-setting/{roy-agent-core-q3zvkbj6.js → roy-agent-core-9qn92jhf.js} +2 -2
  44. package/dist/shared/@ai-setting/{roy-agent-core-462v5d24.js → roy-agent-core-9wsy4yfv.js} +1 -1
  45. package/dist/shared/@ai-setting/{roy-agent-core-qhjm0bxm.js → roy-agent-core-a9pbda78.js} +23 -13
  46. package/dist/shared/@ai-setting/{roy-agent-core-mxwaq8ey.js → roy-agent-core-cd9h49ng.js} +13 -13
  47. package/dist/shared/@ai-setting/{roy-agent-core-ds5f75pg.js → roy-agent-core-ck60j1q9.js} +19 -1
  48. package/dist/shared/@ai-setting/{roy-agent-core-2qke91fm.js → roy-agent-core-dfnyvxr9.js} +3 -3
  49. package/dist/shared/@ai-setting/{roy-agent-core-zekkw27m.js → roy-agent-core-e02f0ywc.js} +69 -24
  50. package/dist/shared/@ai-setting/{roy-agent-core-e4v61k3j.js → roy-agent-core-e5pnnzdm.js} +7 -7
  51. package/dist/shared/@ai-setting/{roy-agent-core-1btakphh.js → roy-agent-core-e8rxb9a6.js} +1 -1
  52. package/dist/shared/@ai-setting/{roy-agent-core-whta3f53.js → roy-agent-core-ff2ssff5.js} +1 -1
  53. package/dist/shared/@ai-setting/{roy-agent-core-s53yya0w.js → roy-agent-core-gh6szaj5.js} +5 -5
  54. package/dist/shared/@ai-setting/{roy-agent-core-em8618g6.js → roy-agent-core-gpf33hn9.js} +214 -13
  55. package/dist/shared/@ai-setting/{roy-agent-core-qhtejtpc.js → roy-agent-core-hfmpmt0k.js} +1 -1
  56. package/dist/shared/@ai-setting/{roy-agent-core-qz9jb9sp.js → roy-agent-core-hkj5v9xq.js} +1 -1
  57. package/dist/shared/@ai-setting/{roy-agent-core-fytqnxrd.js → roy-agent-core-mzyzdf33.js} +3 -3
  58. package/dist/shared/@ai-setting/{roy-agent-core-1vj7dd14.js → roy-agent-core-nz4n1w28.js} +1 -1
  59. package/dist/shared/@ai-setting/{roy-agent-core-q8vew3zh.js → roy-agent-core-p0c98phj.js} +2 -2
  60. package/dist/shared/@ai-setting/{roy-agent-core-dfay0w56.js → roy-agent-core-p2ham63a.js} +2 -2
  61. package/dist/shared/@ai-setting/{roy-agent-core-d5gwqrr5.js → roy-agent-core-pd0exvnq.js} +1 -1
  62. package/dist/shared/@ai-setting/{roy-agent-core-x4wev4rn.js → roy-agent-core-q3vbxprp.js} +5 -5
  63. package/dist/shared/@ai-setting/{roy-agent-core-e3qjt852.js → roy-agent-core-rgpkygbc.js} +1 -1
  64. package/dist/shared/@ai-setting/{roy-agent-core-2wbdfrtg.js → roy-agent-core-rhfywyz1.js} +1 -1
  65. package/dist/shared/@ai-setting/{roy-agent-core-k5csz66y.js → roy-agent-core-tm57tmds.js} +1 -1
  66. package/dist/shared/@ai-setting/{roy-agent-core-bb57xjfh.js → roy-agent-core-vh10qamt.js} +8 -8
  67. package/dist/shared/@ai-setting/{roy-agent-core-1q6gjxba.js → roy-agent-core-vn6f4nxv.js} +7 -7
  68. package/dist/shared/@ai-setting/{roy-agent-core-1nvqn17p.js → roy-agent-core-wacnvjaq.js} +4 -4
  69. package/dist/shared/@ai-setting/{roy-agent-core-dzfyjzgw.js → roy-agent-core-wb1b61f8.js} +20 -2
  70. package/dist/shared/@ai-setting/{roy-agent-core-mwaesrpc.js → roy-agent-core-wfpzny0h.js} +4 -4
  71. package/dist/shared/@ai-setting/{roy-agent-core-ddq5hcp5.js → roy-agent-core-x6c45yqd.js} +3 -1
  72. package/dist/shared/@ai-setting/roy-agent-core-xyys5m1a.js +159 -0
  73. package/dist/shared/@ai-setting/{roy-agent-core-wphva2vs.js → roy-agent-core-y1n63tse.js} +2 -2
  74. package/dist/shared/@ai-setting/{roy-agent-core-w457586k.js → roy-agent-core-y7atw1kw.js} +1 -1
  75. package/dist/shared/@ai-setting/{roy-agent-core-jcdsghyr.js → roy-agent-core-yjjqm4ww.js} +1 -1
  76. package/dist/shared/@ai-setting/{roy-agent-core-fym6zz5a.js → roy-agent-core-yjyvwxs4.js} +2 -2
  77. package/dist/shared/@ai-setting/{roy-agent-core-rx8whb18.js → roy-agent-core-ym1hwrcm.js} +2 -2
  78. package/dist/shared/@ai-setting/{roy-agent-core-m7dppx2p.js → roy-agent-core-yv4anf1c.js} +2 -2
  79. package/dist/shared/@ai-setting/{roy-agent-core-n82acszf.js → roy-agent-core-z4486eek.js} +1 -1
  80. package/dist/shared/@ai-setting/{roy-agent-core-n3pwkwjh.js → roy-agent-core-za09t5g3.js} +1 -1
  81. package/package.json +1 -1
  82. /package/dist/shared/@ai-setting/{roy-agent-core-k5hxvaf0.js → roy-agent-core-3ztzc83c.js} +0 -0
@@ -1,3 +1,7 @@
1
+ import {
2
+ __require
3
+ } from "./roy-agent-core-fs0mn2jk.js";
4
+
1
5
  // src/env/event-source/types.ts
2
6
  var BUILT_IN_EVENT_SOURCE_TYPES = {
3
7
  LARK_CLI: "lark-cli",
@@ -5,6 +9,20 @@ var BUILT_IN_EVENT_SOURCE_TYPES = {
5
9
  BOUNTY_IM: "bounty-im"
6
10
  };
7
11
  var BUILT_IN_EVENT_SOURCE_TYPE_LIST = Object.values(BUILT_IN_EVENT_SOURCE_TYPES);
12
+ var defaultLarkCliRunner = {
13
+ async run(command) {
14
+ const { spawn } = await import("node:child_process");
15
+ return new Promise((resolve, reject) => {
16
+ const proc = spawn("sh", ["-c", command], { stdio: ["ignore", "pipe", "pipe"] });
17
+ let stdout = "";
18
+ let stderr = "";
19
+ proc.stdout.on("data", (d) => stdout += d.toString());
20
+ proc.stderr.on("data", (d) => stderr += d.toString());
21
+ proc.on("close", (code) => resolve({ stdout, stderr, code: code ?? 0 }));
22
+ proc.on("error", reject);
23
+ });
24
+ }
25
+ };
8
26
 
9
27
  class EventSourceInitHooks {
10
28
  static hooks = new Map;
@@ -63,4 +81,4 @@ function validateEventSourceConfig(config, handler) {
63
81
  return errors;
64
82
  }
65
83
 
66
- export { BUILT_IN_EVENT_SOURCE_TYPES, BUILT_IN_EVENT_SOURCE_TYPE_LIST, EventSourceInitHooks, isBuiltInEventSourceType, isValidEventSourceType, getDefaultConfigForType, validateEventSourceConfig };
84
+ export { BUILT_IN_EVENT_SOURCE_TYPES, BUILT_IN_EVENT_SOURCE_TYPE_LIST, defaultLarkCliRunner, EventSourceInitHooks, isBuiltInEventSourceType, isValidEventSourceType, getDefaultConfigForType, validateEventSourceConfig };
@@ -10,14 +10,14 @@ import {
10
10
  } from "./roy-agent-core-7hh0brvs.js";
11
11
  import {
12
12
  BaseComponent
13
- } from "./roy-agent-core-m7dppx2p.js";
13
+ } from "./roy-agent-core-yv4anf1c.js";
14
14
  import {
15
15
  createHook
16
- } from "./roy-agent-core-w457586k.js";
16
+ } from "./roy-agent-core-y7atw1kw.js";
17
17
  import {
18
18
  globalHookManager,
19
19
  init_global_hook_manager
20
- } from "./roy-agent-core-fym6zz5a.js";
20
+ } from "./roy-agent-core-yjyvwxs4.js";
21
21
  import {
22
22
  createLogger,
23
23
  init_logger
@@ -2,6 +2,9 @@ import {
2
2
  ProcessRegistry,
3
3
  runWithProcessRegistryAsync
4
4
  } from "./roy-agent-core-tbrn9wdm.js";
5
+ import {
6
+ getSharedEventStore
7
+ } from "./roy-agent-core-xyys5m1a.js";
5
8
  import {
6
9
  TaskHookPoints
7
10
  } from "./roy-agent-core-1pg0fepg.js";
@@ -10,26 +13,26 @@ import {
10
13
  } from "./roy-agent-core-skqt40yy.js";
11
14
  import {
12
15
  DEFAULT_SUBAGENT_PROMPT
13
- } from "./roy-agent-core-n3pwkwjh.js";
16
+ } from "./roy-agent-core-za09t5g3.js";
14
17
  import {
15
18
  runWithBgTaskIdAsync
16
19
  } from "./roy-agent-core-c1v263jn.js";
17
20
  import {
18
21
  globalHookManager,
19
22
  init_global_hook_manager
20
- } from "./roy-agent-core-fym6zz5a.js";
23
+ } from "./roy-agent-core-yjyvwxs4.js";
21
24
  import {
22
25
  init_context
23
- } from "./roy-agent-core-whta3f53.js";
26
+ } from "./roy-agent-core-ff2ssff5.js";
24
27
  import {
25
28
  getCurrentTaskId,
26
29
  getEnvContext
27
- } from "./roy-agent-core-n82acszf.js";
30
+ } from "./roy-agent-core-z4486eek.js";
28
31
  import {
29
32
  TracedAs,
30
33
  init_decorator,
31
34
  wrapFunction
32
- } from "./roy-agent-core-qhjm0bxm.js";
35
+ } from "./roy-agent-core-a9pbda78.js";
33
36
  import {
34
37
  createLogger,
35
38
  init_logger
@@ -855,7 +858,8 @@ var DelegateToolParameters = z.object({
855
858
  timeout: z.number().describe("Task timeout in milliseconds. Default: 1800000 (30 minutes). If set, task will be terminated after timeout.").optional(),
856
859
  reason: z.string().describe("Brief reason for calling this tool (max 30 chars, e.g., 'Delegate refactor task')").optional(),
857
860
  similar_task_ids: z.array(z.number()).max(3).describe("Similar task IDs (max 3) to reference for improving task execution. Search for similar tasks before calling this tool."),
858
- sub_session_id: z.string().describe("Existing sub-agent session ID to resume. " + "If provided, the sub-agent will continue from the previous conversation " + "context (used for retry on timeout/failure). " + "Leave empty for a new session.").optional()
861
+ sub_session_id: z.string().describe("Existing sub-agent session ID to resume. " + "If provided, the sub-agent will continue from the previous conversation " + "context (used for retry on timeout/failure). " + "Leave empty for a new session.").optional(),
862
+ triggerEventId: z.string().describe("EventStore trigger event ID (ESPlugin v2). Pass it when this delegate_task " + "is triggered by an external event source (e.g. Feishu message) so the " + "completion notification can reply to the original chat instead of a " + "fallback channel. Leave empty if not triggered by an event source.").optional()
859
863
  });
860
864
  function buildEntryAgentPrompt(options) {
861
865
  const { workflowName, originalPrompt, description } = options;
@@ -1042,19 +1046,25 @@ class BackgroundTaskManager {
1042
1046
  getSessionComponent() {
1043
1047
  return this.env?.getComponent?.("session");
1044
1048
  }
1045
- publishBackgroundEvent(type, payload, parentSessionId) {
1049
+ publishBackgroundEvent(type, payload, parentSessionId, triggerEventId) {
1046
1050
  if (this.env?.pushEnvEvent) {
1047
1051
  this.env.pushEnvEvent({
1048
1052
  type,
1049
1053
  payload,
1050
1054
  metadata: {
1051
1055
  source: "task.background",
1052
- trigger_session_id: parentSessionId
1056
+ trigger_session_id: parentSessionId,
1057
+ ...triggerEventId ? { triggerEventId } : {}
1053
1058
  }
1054
1059
  });
1055
- logger3.info(`[BackgroundTaskManager] Event published: ${type}`);
1060
+ logger3.info(`[BackgroundTaskManager] Event published: ${type}`, {
1061
+ triggerEventId
1062
+ });
1056
1063
  }
1057
1064
  }
1065
+ publishBackgroundEventWithTrigger(type, payload, parentSessionId, triggerEventId) {
1066
+ this.publishBackgroundEvent(type, payload, parentSessionId, triggerEventId);
1067
+ }
1058
1068
  static parseAskUserErrorFromMessage(error) {
1059
1069
  const rawErrorMessage = error instanceof Error ? error.message : String(error);
1060
1070
  if (error && typeof error === "object" && error.name === "AskUserError" && error.query) {
@@ -1089,7 +1099,7 @@ class BackgroundTaskManager {
1089
1099
  return null;
1090
1100
  }
1091
1101
  async createTask(options) {
1092
- const { parentSessionId, description, prompt, subagentType, timeout, similarTaskIds, existingSubSessionId } = options;
1102
+ const { parentSessionId, description, prompt, subagentType, timeout, similarTaskIds, existingSubSessionId, triggerEventId } = options;
1093
1103
  const taskIdGen = `process_${Date.now()}_${Math.random().toString(36).slice(2, 11)}`;
1094
1104
  const sessionComponent = this.getSessionComponent();
1095
1105
  if (!sessionComponent) {
@@ -1149,6 +1159,9 @@ class BackgroundTaskManager {
1149
1159
  metadata.larkProfile = profile;
1150
1160
  }
1151
1161
  }
1162
+ if (triggerEventId) {
1163
+ metadata.triggerEventId = triggerEventId;
1164
+ }
1152
1165
  subSession = await sessionComponent.create({
1153
1166
  title: `${description} (@${subagentType} subagent)`,
1154
1167
  parentSessionId,
@@ -1180,7 +1193,8 @@ class BackgroundTaskManager {
1180
1193
  createdAt,
1181
1194
  lastUpdatedAt: createdAt,
1182
1195
  abortController,
1183
- similarTaskIds
1196
+ similarTaskIds,
1197
+ triggerEventId
1184
1198
  };
1185
1199
  this.tasks.set(taskIdGen, task);
1186
1200
  this.abortControllers.set(taskIdGen, abortController);
@@ -1191,7 +1205,7 @@ class BackgroundTaskManager {
1191
1205
  description,
1192
1206
  subagentType
1193
1207
  };
1194
- this.publishBackgroundEvent(BackgroundTaskEventTypes.STARTED, startedPayload, parentSessionId);
1208
+ this.publishBackgroundEvent(BackgroundTaskEventTypes.STARTED, startedPayload, parentSessionId, triggerEventId);
1195
1209
  this.executeTask(taskIdGen, prompt, timeout, parentSessionId).catch((err) => {
1196
1210
  logger3.error(`[BackgroundTaskManager] executeTask unhandled rejection`, {
1197
1211
  taskId: taskIdGen,
@@ -1248,7 +1262,7 @@ class BackgroundTaskManager {
1248
1262
  executionTimeMs,
1249
1263
  associatedTaskId: task.associatedTaskId
1250
1264
  };
1251
- this.publishBackgroundEvent(BackgroundTaskEventTypes.COMPLETED, completedPayload, parentSessionId || task.parentSessionId);
1265
+ this.publishBackgroundEvent(BackgroundTaskEventTypes.COMPLETED, completedPayload, parentSessionId || task.parentSessionId, task.triggerEventId);
1252
1266
  logger3.info(`[BackgroundTaskManager] Task completed successfully`, {
1253
1267
  taskId,
1254
1268
  executionTimeMs
@@ -1285,7 +1299,7 @@ class BackgroundTaskManager {
1285
1299
  ],
1286
1300
  associatedTaskId: task.associatedTaskId
1287
1301
  };
1288
- this.publishBackgroundEvent(BackgroundTaskEventTypes.ASK_USER, askUserPayload, parentSessionId || task.parentSessionId);
1302
+ this.publishBackgroundEvent(BackgroundTaskEventTypes.ASK_USER, askUserPayload, parentSessionId || task.parentSessionId, task.triggerEventId);
1289
1303
  logger3.info(`[BackgroundTaskManager] Task awaiting user input (ask_user cascade)`, {
1290
1304
  taskId,
1291
1305
  subSessionId: task.subSessionId,
@@ -1307,7 +1321,7 @@ class BackgroundTaskManager {
1307
1321
  executionTimeMs,
1308
1322
  associatedTaskId: task.associatedTaskId
1309
1323
  };
1310
- this.publishBackgroundEvent(BackgroundTaskEventTypes.STOPPED, stoppedPayload, parentSessionId || task.parentSessionId);
1324
+ this.publishBackgroundEvent(BackgroundTaskEventTypes.STOPPED, stoppedPayload, parentSessionId || task.parentSessionId, task.triggerEventId);
1311
1325
  } else if (errorMessage.startsWith("Task execution timeout after")) {
1312
1326
  task.status = "timeout";
1313
1327
  const timeoutPayload = {
@@ -1320,7 +1334,7 @@ class BackgroundTaskManager {
1320
1334
  executionTimeMs,
1321
1335
  associatedTaskId: task.associatedTaskId
1322
1336
  };
1323
- this.publishBackgroundEvent(BackgroundTaskEventTypes.TIMEOUT, timeoutPayload, parentSessionId || task.parentSessionId);
1337
+ this.publishBackgroundEvent(BackgroundTaskEventTypes.TIMEOUT, timeoutPayload, parentSessionId || task.parentSessionId, task.triggerEventId);
1324
1338
  } else {
1325
1339
  task.status = "failed";
1326
1340
  const failedPayload = {
@@ -1332,7 +1346,7 @@ class BackgroundTaskManager {
1332
1346
  executionTimeMs,
1333
1347
  associatedTaskId: task.associatedTaskId
1334
1348
  };
1335
- this.publishBackgroundEvent(BackgroundTaskEventTypes.FAILED, failedPayload, parentSessionId || task.parentSessionId);
1349
+ this.publishBackgroundEvent(BackgroundTaskEventTypes.FAILED, failedPayload, parentSessionId || task.parentSessionId, task.triggerEventId);
1336
1350
  }
1337
1351
  task.error = errorMessage;
1338
1352
  logger3.error(`[BackgroundTaskManager] Task execution error`, {
@@ -1375,7 +1389,7 @@ class BackgroundTaskManager {
1375
1389
  status: task.status,
1376
1390
  associatedTaskId: task.associatedTaskId
1377
1391
  };
1378
- this.publishBackgroundEvent(BackgroundTaskEventTypes.PROGRESS, progressPayload, parentSessionId);
1392
+ this.publishBackgroundEvent(BackgroundTaskEventTypes.PROGRESS, progressPayload, parentSessionId, task.triggerEventId);
1379
1393
  }, PROGRESS_INTERVAL);
1380
1394
  this.progressTimers.set(taskId, timer);
1381
1395
  }
@@ -1665,7 +1679,7 @@ ${reuseSection.markdown}`;
1665
1679
  executionTimeMs: task.startedAt ? task.completedAt - task.startedAt : 0,
1666
1680
  associatedTaskId: task.associatedTaskId
1667
1681
  };
1668
- this.publishBackgroundEvent(BackgroundTaskEventTypes.STOPPED, stoppedPayload, task.parentSessionId);
1682
+ this.publishBackgroundEvent(BackgroundTaskEventTypes.STOPPED, stoppedPayload, task.parentSessionId, task.triggerEventId);
1669
1683
  this.finalizeTask(taskId, "stopped");
1670
1684
  return {
1671
1685
  success: true,
@@ -1756,7 +1770,7 @@ ${reuseSection.markdown}`;
1756
1770
  executionTimeMs: taskSafe.startedAt && taskSafe.completedAt ? taskSafe.completedAt - taskSafe.startedAt : 0,
1757
1771
  associatedTaskId: taskSafe.associatedTaskId
1758
1772
  };
1759
- this.publishBackgroundEvent(BackgroundTaskEventTypes.STOPPED, stoppedPayload, taskSafe.parentSessionId);
1773
+ this.publishBackgroundEvent(BackgroundTaskEventTypes.STOPPED, stoppedPayload, taskSafe.parentSessionId, taskSafe.triggerEventId);
1760
1774
  }
1761
1775
  }
1762
1776
  }
@@ -1906,9 +1920,34 @@ No need to poll — just wait for the notification and use \`task_get\` with the
1906
1920
  execute: async (args, ctx) => {
1907
1921
  const startTime = Date.now();
1908
1922
  const params = DelegateToolParameters.parse(args);
1909
- const { description, prompt, subagent_type = "general", timeout, reason, similar_task_ids } = params;
1923
+ const { description, prompt, subagent_type = "general", timeout, reason, similar_task_ids, triggerEventId } = params;
1910
1924
  const parentSessionId = ctx.session_id || "default";
1911
1925
  logger3.info(`[delegate_task] Called: description=${description}, subagent_type=${subagent_type}`);
1926
+ if (triggerEventId) {
1927
+ const store = getSharedEventStore();
1928
+ if (store) {
1929
+ try {
1930
+ const persisted = await store.getEventById(triggerEventId);
1931
+ if (!persisted) {
1932
+ return {
1933
+ success: false,
1934
+ output: "",
1935
+ error: `Unknown triggerEventId: ${triggerEventId} (not found in EventStore)`,
1936
+ metadata: { execution_time_ms: Date.now() - startTime }
1937
+ };
1938
+ }
1939
+ } catch (err) {
1940
+ return {
1941
+ success: false,
1942
+ output: "",
1943
+ error: `Failed to verify triggerEventId ${triggerEventId}: ${err instanceof Error ? err.message : String(err)}`,
1944
+ metadata: { execution_time_ms: Date.now() - startTime }
1945
+ };
1946
+ }
1947
+ } else {
1948
+ logger3.warn(`[delegate_task] triggerEventId=${triggerEventId} supplied but no shared EventStore registered; skipping verification`);
1949
+ }
1950
+ }
1912
1951
  const registry2 = getAgentRegistry(taskComponent);
1913
1952
  if (!isKnownSubagentType(subagent_type, registry2)) {
1914
1953
  return {
@@ -1936,12 +1975,17 @@ No need to poll — just wait for the notification and use \`task_get\` with the
1936
1975
  };
1937
1976
  await globalHookManager.execute(TaskHookPoints.DELEGATE_BEFORE, delegateCtx, { sessionId: parentSessionId });
1938
1977
  promptWithTaskInfo = delegateCtx.prompt;
1939
- return await handleBackgroundTask(backgroundTaskManager, parentSessionId, description, promptWithTaskInfo, delegateCtx.subagentType, delegateCtx.timeout, similar_task_ids, params.sub_session_id);
1978
+ return await handleBackgroundTask(backgroundTaskManager, parentSessionId, description, promptWithTaskInfo, delegateCtx.subagentType, delegateCtx.timeout, similar_task_ids, params.sub_session_id, triggerEventId);
1940
1979
  }
1941
1980
  };
1981
+ tool.execute = wrapFunction(tool.execute, "delegate.execute", {
1982
+ recordParams: true,
1983
+ recordResult: false,
1984
+ recordError: true
1985
+ });
1942
1986
  return tool;
1943
1987
  }
1944
- async function handleBackgroundTask(backgroundTaskManager, parentSessionId, description, prompt, subagentType, timeout, similarTaskIds, existingSubSessionId) {
1988
+ async function handleBackgroundTask(backgroundTaskManager, parentSessionId, description, prompt, subagentType, timeout, similarTaskIds, existingSubSessionId, triggerEventId) {
1945
1989
  const startTime = Date.now();
1946
1990
  try {
1947
1991
  let actualSubagentType = subagentType;
@@ -1966,7 +2010,8 @@ async function handleBackgroundTask(backgroundTaskManager, parentSessionId, desc
1966
2010
  timeout,
1967
2011
  similarTaskIds,
1968
2012
  originalWorkflowName,
1969
- existingSubSessionId
2013
+ existingSubSessionId,
2014
+ triggerEventId
1970
2015
  });
1971
2016
  const output = [
1972
2017
  `✅ Background task accepted`,
@@ -6,28 +6,28 @@ import {
6
6
  } from "./roy-agent-core-skqt40yy.js";
7
7
  import {
8
8
  validateWorkflowDefinition
9
- } from "./roy-agent-core-wgttzq8e.js";
9
+ } from "./roy-agent-core-6vbgswjw.js";
10
10
  import {
11
11
  enqueueToAddFakeUserMessage
12
- } from "./roy-agent-core-9drbkjfr.js";
12
+ } from "./roy-agent-core-4cj6hram.js";
13
13
  import {
14
14
  BasePlugin,
15
15
  normalizeLarkAtMentions
16
16
  } from "./roy-agent-core-rmn29nrh.js";
17
17
  import {
18
18
  init_context
19
- } from "./roy-agent-core-whta3f53.js";
19
+ } from "./roy-agent-core-ff2ssff5.js";
20
20
  import {
21
21
  getEnvContextOrEmpty,
22
22
  getEventFromEnvContext,
23
23
  getLarkMessageId,
24
24
  isLarkEvent
25
- } from "./roy-agent-core-n82acszf.js";
25
+ } from "./roy-agent-core-z4486eek.js";
26
26
  import {
27
27
  TracedAs,
28
28
  init_decorator,
29
29
  wrapFunction
30
- } from "./roy-agent-core-qhjm0bxm.js";
30
+ } from "./roy-agent-core-a9pbda78.js";
31
31
  import {
32
32
  createLogger,
33
33
  init_logger
@@ -296,11 +296,11 @@ ${prompt}`;
296
296
  }
297
297
  if (!this._workflowRepo) {
298
298
  try {
299
- const sqlite = await import("./roy-agent-core-yw07bvqz.js");
299
+ const sqlite = await import("./roy-agent-core-9cqpdrnk.js");
300
300
  this.ensureDataDir();
301
301
  const db = sqlite.getDatabase();
302
302
  sqlite.initializeTables();
303
- const { WorkflowRepository } = await import("./roy-agent-core-jq7g5nxz.js");
303
+ const { WorkflowRepository } = await import("./roy-agent-core-5j4awbgc.js");
304
304
  this._workflowRepo = new WorkflowRepository(db);
305
305
  return this._workflowRepo;
306
306
  } catch {
@@ -10,7 +10,7 @@ import {
10
10
  } from "./roy-agent-core-7hh0brvs.js";
11
11
  import {
12
12
  BaseComponent
13
- } from "./roy-agent-core-m7dppx2p.js";
13
+ } from "./roy-agent-core-yv4anf1c.js";
14
14
  import {
15
15
  createLogger,
16
16
  init_logger
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  init_env_context,
3
3
  init_env_event
4
- } from "./roy-agent-core-n82acszf.js";
4
+ } from "./roy-agent-core-z4486eek.js";
5
5
  import {
6
6
  __esm
7
7
  } from "./roy-agent-core-fs0mn2jk.js";
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  AgentComponentAdapter,
3
3
  init_agent_component_adapter
4
- } from "./roy-agent-core-q8vew3zh.js";
4
+ } from "./roy-agent-core-p0c98phj.js";
5
5
  import"./roy-agent-core-1db4vpc6.js";
6
6
  import"./roy-agent-core-e25xkv53.js";
7
- import"./roy-agent-core-fym6zz5a.js";
8
- import"./roy-agent-core-whta3f53.js";
9
- import"./roy-agent-core-n82acszf.js";
10
- import"./roy-agent-core-qhjm0bxm.js";
7
+ import"./roy-agent-core-yjyvwxs4.js";
8
+ import"./roy-agent-core-ff2ssff5.js";
9
+ import"./roy-agent-core-z4486eek.js";
10
+ import"./roy-agent-core-a9pbda78.js";
11
11
  import"./roy-agent-core-8seq65bp.js";
12
12
  import"./roy-agent-core-jnszp0jq.js";
13
13
  import"./roy-agent-core-fs0mn2jk.js";