@ai-setting/roy-agent-core 1.7.52 → 1.7.55

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 (367) hide show
  1. package/dist/config/config-component.d.ts +346 -0
  2. package/dist/config/config-parser.d.ts +45 -0
  3. package/dist/config/env-key.d.ts +97 -0
  4. package/dist/config/env-source.d.ts +113 -0
  5. package/dist/config/file-source.d.ts +90 -0
  6. package/dist/config/index.d.ts +4 -0
  7. package/dist/config/protocol-resolver.d.ts +94 -0
  8. package/dist/env/agent/agent-component.d.ts +646 -0
  9. package/dist/env/agent/agent-config-registration.d.ts +18 -0
  10. package/dist/env/agent/agent-registry.d.ts +500 -0
  11. package/dist/env/agent/index.d.ts +9 -0
  12. package/dist/env/agent/index.js +3 -3
  13. package/dist/env/agent/summary-agent.d.ts +44 -0
  14. package/dist/env/agent/types.d.ts +503 -0
  15. package/dist/env/commands/commands-component.d.ts +97 -0
  16. package/dist/env/commands/commands-config-registration.d.ts +19 -0
  17. package/dist/env/commands/index.d.ts +7 -0
  18. package/dist/env/commands/parser.d.ts +18 -0
  19. package/dist/env/commands/types.d.ts +133 -0
  20. package/dist/env/component.d.ts +186 -0
  21. package/dist/env/constants.d.ts +112 -0
  22. package/dist/env/context/env-context.d.ts +420 -0
  23. package/dist/env/context/env-event.d.ts +144 -0
  24. package/dist/env/context/index.d.ts +13 -0
  25. package/dist/env/debug/debug-component.d.ts +160 -0
  26. package/dist/env/debug/formatters/index.d.ts +8 -0
  27. package/dist/env/debug/formatters/repl-formatter.d.ts +80 -0
  28. package/dist/env/debug/formatters/trace-formatter.d.ts +43 -0
  29. package/dist/env/debug/formatters/tree-formatter.d.ts +72 -0
  30. package/dist/env/debug/index.d.ts +15 -0
  31. package/dist/env/debug/index.js +1 -1
  32. package/dist/env/debug/parser/regex-parser.d.ts +49 -0
  33. package/dist/env/debug/parser/span-builder.d.ts +79 -0
  34. package/dist/env/debug/reader/log-reader.d.ts +55 -0
  35. package/dist/env/debug/reader/span-db-reader.d.ts +70 -0
  36. package/dist/env/debug/types.d.ts +145 -0
  37. package/dist/env/environment.d.ts +185 -0
  38. package/dist/env/error-reply.d.ts +184 -0
  39. package/dist/env/errors.d.ts +120 -0
  40. package/dist/env/event-source/bounty-cli-handler.d.ts +42 -0
  41. package/dist/env/event-source/bounty-im-handler.d.ts +232 -0
  42. package/dist/env/event-source/event-source-component.d.ts +177 -0
  43. package/dist/env/event-source/event-source-config-registration.d.ts +18 -0
  44. package/dist/env/event-source/event-source-handlers.d.ts +472 -0
  45. package/dist/env/event-source/event-store.d.ts +110 -0
  46. package/dist/env/event-source/idempotency-key.d.ts +19 -0
  47. package/dist/env/event-source/index.d.ts +15 -0
  48. package/dist/env/event-source/index.js +6 -6
  49. package/dist/env/event-source/timer-handler.d.ts +74 -0
  50. package/dist/env/event-source/types.d.ts +803 -0
  51. package/dist/env/hook/global-hook-manager.d.ts +73 -0
  52. package/dist/env/hook/hook-manager.d.ts +139 -0
  53. package/dist/env/hook/index.d.ts +9 -0
  54. package/dist/env/hook/types.d.ts +107 -0
  55. package/dist/env/index.d.ts +24 -0
  56. package/dist/env/index.js +18 -18
  57. package/dist/env/interface.d.ts +156 -0
  58. package/dist/env/lark-mention-utils.d.ts +59 -0
  59. package/dist/env/llm/adapter-ai-sdk.d.ts +10 -0
  60. package/dist/env/llm/adapter-pi-ai.d.ts +184 -0
  61. package/dist/env/llm/adapter.d.ts +100 -0
  62. package/dist/env/llm/factory.d.ts +13 -0
  63. package/dist/env/llm/hooks.d.ts +150 -0
  64. package/dist/env/llm/index.d.ts +16 -0
  65. package/dist/env/llm/index.js +2 -2
  66. package/dist/env/llm/invoke.d.ts +304 -0
  67. package/dist/env/llm/llm-cache.d.ts +38 -0
  68. package/dist/env/llm/llm.d.ts +263 -0
  69. package/dist/env/llm/opencode-session.d.ts +79 -0
  70. package/dist/env/llm/provider.d.ts +40 -0
  71. package/dist/env/llm/reasoning-defense.d.ts +104 -0
  72. package/dist/env/llm/tool-args-parser.d.ts +77 -0
  73. package/dist/env/llm/tool-schema.d.ts +54 -0
  74. package/dist/env/llm/transform.d.ts +57 -0
  75. package/dist/env/llm/types.d.ts +844 -0
  76. package/dist/env/log-trace/decorator.d.ts +88 -0
  77. package/dist/env/log-trace/index.d.ts +14 -0
  78. package/dist/env/log-trace/log-trace-component.d.ts +268 -0
  79. package/dist/env/log-trace/log-trace-config-registration.d.ts +25 -0
  80. package/dist/env/log-trace/logger.d.ts +83 -0
  81. package/dist/env/log-trace/opentelemetry/cli-propagation.d.ts +105 -0
  82. package/dist/env/log-trace/opentelemetry/mod.d.ts +24 -0
  83. package/dist/env/log-trace/opentelemetry/propagation-env.d.ts +81 -0
  84. package/dist/env/log-trace/opentelemetry/propagation.d.ts +79 -0
  85. package/dist/env/log-trace/opentelemetry/tracer-provider.d.ts +157 -0
  86. package/dist/env/log-trace/span-storage.d.ts +37 -0
  87. package/dist/env/log-trace/trace-context.d.ts +28 -0
  88. package/dist/env/log-trace/types.d.ts +127 -0
  89. package/dist/env/mcp/command-resolver.d.ts +12 -0
  90. package/dist/env/mcp/config.d.ts +103 -0
  91. package/dist/env/mcp/index.d.ts +13 -0
  92. package/dist/env/mcp/loader.d.ts +78 -0
  93. package/dist/env/mcp/mcp-component.d.ts +54 -0
  94. package/dist/env/mcp/mcp-config-registration.d.ts +19 -0
  95. package/dist/env/mcp/npm-prefix/index.d.ts +17 -0
  96. package/dist/env/mcp/scanner.d.ts +38 -0
  97. package/dist/env/mcp/tool/adapter.d.ts +32 -0
  98. package/dist/env/mcp/tool/index.d.ts +4 -0
  99. package/dist/env/mcp/types.d.ts +131 -0
  100. package/dist/env/memory/built-in/index.d.ts +41 -0
  101. package/dist/env/memory/built-in/recall-memory.d.ts +29 -0
  102. package/dist/env/memory/built-in/record-memory.d.ts +44 -0
  103. package/dist/env/memory/index.d.ts +10 -0
  104. package/dist/env/memory/memory-component.d.ts +114 -0
  105. package/dist/env/memory/memory-config-registration.d.ts +18 -0
  106. package/dist/env/memory/memory-config.d.ts +18 -0
  107. package/dist/env/memory/plugin/index.d.ts +16 -0
  108. package/dist/env/memory/plugin/memory-agent.d.ts +126 -0
  109. package/dist/env/memory/plugin/memory-manager.d.ts +71 -0
  110. package/dist/env/memory/plugin/memory-plugin.d.ts +103 -0
  111. package/dist/env/memory/plugin/recall-memory.d.ts +16 -0
  112. package/dist/env/memory/plugin/types.d.ts +75 -0
  113. package/dist/env/memory/tools/memory-agent-tools.d.ts +109 -0
  114. package/dist/env/memory/types.d.ts +80 -0
  115. package/dist/env/paths.d.ts +46 -0
  116. package/dist/env/plugin/bounty-cli-notification-channel.d.ts +60 -0
  117. package/dist/env/plugin/event-bus-notification-channel.d.ts +50 -0
  118. package/dist/env/plugin/index.d.ts +13 -0
  119. package/dist/env/plugin/lark-cli-notification-channel.d.ts +61 -0
  120. package/dist/env/plugin/notification-channel.d.ts +143 -0
  121. package/dist/env/plugin/plugin-component.d.ts +232 -0
  122. package/dist/env/plugin/types.d.ts +146 -0
  123. package/dist/env/prompt/index.d.ts +7 -0
  124. package/dist/env/prompt/index.js +2 -2
  125. package/dist/env/prompt/prompt-component.d.ts +194 -0
  126. package/dist/env/prompt/prompt-config-registration.d.ts +18 -0
  127. package/dist/env/prompt/prompt-store.d.ts +26 -0
  128. package/dist/env/prompt/prompts-index.d.ts +146 -0
  129. package/dist/env/prompt/renderer.d.ts +21 -0
  130. package/dist/env/prompt/types.d.ts +176 -0
  131. package/dist/env/session/hooks.d.ts +14 -0
  132. package/dist/env/session/index.d.ts +19 -0
  133. package/dist/env/session/index.js +4 -4
  134. package/dist/env/session/search-query-parser.d.ts +41 -0
  135. package/dist/env/session/session-component.d.ts +464 -0
  136. package/dist/env/session/session-config-registration.d.ts +18 -0
  137. package/dist/env/session/session-id.d.ts +26 -0
  138. package/dist/env/session/session-message-converter.d.ts +142 -0
  139. package/dist/env/session/session-store.d.ts +188 -0
  140. package/dist/env/session/storage/index.d.ts +5 -0
  141. package/dist/env/session/storage/index.js +3 -3
  142. package/dist/env/session/storage/memory.d.ts +119 -0
  143. package/dist/env/session/storage/sqlite.d.ts +108 -0
  144. package/dist/env/session/types.d.ts +705 -0
  145. package/dist/env/session-tree-stopper.d.ts +79 -0
  146. package/dist/env/skill/config.d.ts +13 -0
  147. package/dist/env/skill/index.d.ts +6 -0
  148. package/dist/env/skill/parser.d.ts +9 -0
  149. package/dist/env/skill/scanner.d.ts +25 -0
  150. package/dist/env/skill/skill-component.d.ts +89 -0
  151. package/dist/env/skill/skill-config-registration.d.ts +18 -0
  152. package/dist/env/skill/tool/index.d.ts +1 -0
  153. package/dist/env/skill/tool/skill-tool.d.ts +15 -0
  154. package/dist/env/skill/types.d.ts +61 -0
  155. package/dist/env/task/backend/index.d.ts +24 -0
  156. package/dist/env/task/backend/index.js +702 -0
  157. package/dist/env/task/backend/roy-sidecar-task-port.d.ts +148 -0
  158. package/dist/env/task/backend/sqlite-task-port.d.ts +28 -0
  159. package/dist/env/task/backend/task-store-backend.d.ts +107 -0
  160. package/dist/env/task/backend/types.d.ts +282 -0
  161. package/dist/env/task/delegate/bg-task-id-storage.d.ts +9 -0
  162. package/dist/env/task/delegate/delegate-tool.d.ts +681 -0
  163. package/dist/env/task/delegate/index.d.ts +8 -0
  164. package/dist/env/task/delegate/index.js +2 -2
  165. package/dist/env/task/delegate/process-registry.d.ts +58 -0
  166. package/dist/env/task/delegate/stop-tool.d.ts +12 -0
  167. package/dist/env/task/delegate/subagent-resolver.d.ts +25 -0
  168. package/dist/env/task/events/index.d.ts +7 -0
  169. package/dist/env/task/events/task-event-payloads.d.ts +101 -0
  170. package/dist/env/task/events/task-event-types.d.ts +23 -0
  171. package/dist/env/task/hooks/contexts.d.ts +191 -0
  172. package/dist/env/task/hooks/index.d.ts +7 -0
  173. package/dist/env/task/hooks/task-hook-points.d.ts +42 -0
  174. package/dist/env/task/index.d.ts +7 -0
  175. package/dist/env/task/index.js +3 -3
  176. package/dist/env/task/plugins/auto-task-plugin.d.ts +38 -0
  177. package/dist/env/task/plugins/card-chat-routing.d.ts +88 -0
  178. package/dist/env/task/plugins/fake-user-message-helper.d.ts +90 -0
  179. package/dist/env/task/plugins/index.d.ts +8 -0
  180. package/dist/env/task/plugins/index.js +4 -4
  181. package/dist/env/task/plugins/lark-card-action-handler.d.ts +166 -0
  182. package/dist/env/task/plugins/lark-card-patch-notifier.d.ts +600 -0
  183. package/dist/env/task/plugins/lark-cli-task-notify-plugin.d.ts +231 -0
  184. package/dist/env/task/plugins/max-iteration-reminder-plugin.d.ts +112 -0
  185. package/dist/env/task/plugins/per-task-group-chat-plugin.d.ts +561 -0
  186. package/dist/env/task/plugins/task-tag-plugin.d.ts +70 -0
  187. package/dist/env/task/plugins/workflow-extractor-agent.d.ts +43 -0
  188. package/dist/env/task/registry-hook-installer.d.ts +43 -0
  189. package/dist/env/task/storage/index.d.ts +5 -0
  190. package/dist/env/task/storage/migrations/001_add_project_path_context.d.ts +14 -0
  191. package/dist/env/task/storage/migrations/002_add_task_type.d.ts +14 -0
  192. package/dist/env/task/storage/migrations/003_add_process_description.d.ts +20 -0
  193. package/dist/env/task/storage/migrations/004_rename_action_to_milestone.d.ts +37 -0
  194. package/dist/env/task/storage/migrations/005_convert_blob_description_to_text.d.ts +51 -0
  195. package/dist/env/task/storage/sqlite-task-store.d.ts +241 -0
  196. package/dist/env/task/tag-service.d.ts +138 -0
  197. package/dist/env/task/task-child-context.d.ts +70 -0
  198. package/dist/env/task/task-component.d.ts +270 -0
  199. package/dist/env/task/task-config-registration.d.ts +19 -0
  200. package/dist/env/task/task-creation-registry.d.ts +181 -0
  201. package/dist/env/task/task-reuse-context.d.ts +52 -0
  202. package/dist/env/task/task-reuse-registry.d.ts +31 -0
  203. package/dist/env/task/tools/batch-archive-tool.d.ts +9 -0
  204. package/dist/env/task/tools/batch-delete-tool.d.ts +9 -0
  205. package/dist/env/task/tools/complete-tool.d.ts +12 -0
  206. package/dist/env/task/tools/create-tool.d.ts +6 -0
  207. package/dist/env/task/tools/delete-tool.d.ts +6 -0
  208. package/dist/env/task/tools/get-tool.d.ts +6 -0
  209. package/dist/env/task/tools/index.d.ts +13 -0
  210. package/dist/env/task/tools/list-tool.d.ts +6 -0
  211. package/dist/env/task/tools/operation/create-tool.d.ts +12 -0
  212. package/dist/env/task/tools/operation/delete-tool.d.ts +6 -0
  213. package/dist/env/task/tools/operation/get-tool.d.ts +6 -0
  214. package/dist/env/task/tools/operation/index.d.ts +8 -0
  215. package/dist/env/task/tools/operation/list-tool.d.ts +6 -0
  216. package/dist/env/task/tools/operation/operation-types.d.ts +225 -0
  217. package/dist/env/task/tools/operation/update-tool.d.ts +6 -0
  218. package/dist/env/task/tools/search-tool.d.ts +9 -0
  219. package/dist/env/task/tools/task-tree-tool.d.ts +65 -0
  220. package/dist/env/task/tools/task-types.d.ts +255 -0
  221. package/dist/env/task/tools/update-tool.d.ts +6 -0
  222. package/dist/env/task/types.d.ts +290 -0
  223. package/dist/env/tool/built-in/bash-effect.d.ts +36 -0
  224. package/dist/env/tool/built-in/bash.d.ts +16 -0
  225. package/dist/env/tool/built-in/echo.d.ts +7 -0
  226. package/dist/env/tool/built-in/edit-file.d.ts +6 -0
  227. package/dist/env/tool/built-in/glob.d.ts +6 -0
  228. package/dist/env/tool/built-in/grep.d.ts +6 -0
  229. package/dist/env/tool/built-in/index.d.ts +39 -0
  230. package/dist/env/tool/built-in/query-background-process-tool.d.ts +113 -0
  231. package/dist/env/tool/built-in/read-file.d.ts +5 -0
  232. package/dist/env/tool/built-in/understand-image.d.ts +59 -0
  233. package/dist/env/tool/built-in/write-file.d.ts +5 -0
  234. package/dist/env/tool/index.d.ts +16 -0
  235. package/dist/env/tool/registry.d.ts +61 -0
  236. package/dist/env/tool/tool-component.d.ts +242 -0
  237. package/dist/env/tool/tool-config-registration.d.ts +18 -0
  238. package/dist/env/tool/types.d.ts +274 -0
  239. package/dist/env/tool/validator.d.ts +14 -0
  240. package/dist/env/types.d.ts +184 -0
  241. package/dist/env/workflow/decorators/decorator-node.d.ts +76 -0
  242. package/dist/env/workflow/decorators/edge.d.ts +42 -0
  243. package/dist/env/workflow/decorators/index.d.ts +13 -0
  244. package/dist/env/workflow/decorators/node-as.d.ts +40 -0
  245. package/dist/env/workflow/decorators/workflow.d.ts +30 -0
  246. package/dist/env/workflow/engine/dag-manager.d.ts +176 -0
  247. package/dist/env/workflow/engine/engine.d.ts +440 -0
  248. package/dist/env/workflow/engine/event-bus.d.ts +54 -0
  249. package/dist/env/workflow/engine/executor.d.ts +122 -0
  250. package/dist/env/workflow/engine/index.d.ts +15 -0
  251. package/dist/env/workflow/engine/index.js +2 -2
  252. package/dist/env/workflow/engine/node-registry.d.ts +159 -0
  253. package/dist/env/workflow/engine/scheduler.d.ts +164 -0
  254. package/dist/env/workflow/extractor/workflow-converter.d.ts +55 -0
  255. package/dist/env/workflow/fixtures.d.ts +401 -0
  256. package/dist/env/workflow/hooks/index.d.ts +4 -0
  257. package/dist/env/workflow/hooks/workflow-hook-points.d.ts +161 -0
  258. package/dist/env/workflow/index.d.ts +30 -0
  259. package/dist/env/workflow/index.js +9 -9
  260. package/dist/env/workflow/metadata/keys.d.ts +6 -0
  261. package/dist/env/workflow/nodes/agent-component-adapter.d.ts +175 -0
  262. package/dist/env/workflow/nodes/agent-node.d.ts +206 -0
  263. package/dist/env/workflow/nodes/ask-user-node.d.ts +66 -0
  264. package/dist/env/workflow/nodes/condition-node.d.ts +39 -0
  265. package/dist/env/workflow/nodes/index.d.ts +8 -0
  266. package/dist/env/workflow/nodes/index.js +1 -1
  267. package/dist/env/workflow/nodes/merge-node.d.ts +40 -0
  268. package/dist/env/workflow/nodes/python-call-node.d.ts +95 -0
  269. package/dist/env/workflow/nodes/skill-node.d.ts +29 -0
  270. package/dist/env/workflow/nodes/tool-node.d.ts +64 -0
  271. package/dist/env/workflow/nodes/workflow-node.d.ts +118 -0
  272. package/dist/env/workflow/plugins/index.d.ts +6 -0
  273. package/dist/env/workflow/plugins/index.js +2 -2
  274. package/dist/env/workflow/plugins/lark-cli-workflow-notify-plugin.d.ts +107 -0
  275. package/dist/env/workflow/plugins/workflow-json-output-plugin.d.ts +166 -0
  276. package/dist/env/workflow/runtime/runtime-cancellation-scope.d.ts +121 -0
  277. package/dist/env/workflow/service/index.d.ts +9 -0
  278. package/dist/env/workflow/service/registry.d.ts +37 -0
  279. package/dist/env/workflow/service/workflow-service.d.ts +422 -0
  280. package/dist/env/workflow/storage/index.d.ts +11 -0
  281. package/dist/env/workflow/storage/mock-repositories.d.ts +106 -0
  282. package/dist/env/workflow/storage/safe-json.d.ts +62 -0
  283. package/dist/env/workflow/storage/sqlite.d.ts +57 -0
  284. package/dist/env/workflow/storage/tag-repo.d.ts +65 -0
  285. package/dist/env/workflow/storage/workflow-repo.d.ts +161 -0
  286. package/dist/env/workflow/tools/ask-user-tool.d.ts +35 -0
  287. package/dist/env/workflow/tools/index.d.ts +16 -0
  288. package/dist/env/workflow/tools/index.js +6 -6
  289. package/dist/env/workflow/tools/run-workflow.d.ts +130 -0
  290. package/dist/env/workflow/tools/submit-json-output-tool.d.ts +38 -0
  291. package/dist/env/workflow/tools/workflow-add-tool.d.ts +47 -0
  292. package/dist/env/workflow/tools/workflow-get-tool.d.ts +29 -0
  293. package/dist/env/workflow/tools/workflow-list-tool.d.ts +55 -0
  294. package/dist/env/workflow/tools/workflow-run-status-tool.d.ts +26 -0
  295. package/dist/env/workflow/tools/workflow-run-stop-tool.d.ts +29 -0
  296. package/dist/env/workflow/tools/workflow-search-tool.d.ts +33 -0
  297. package/dist/env/workflow/tools/workflow-tag-list-tool.d.ts +59 -0
  298. package/dist/env/workflow/tools/workflow-validate-tool.d.ts +69 -0
  299. package/dist/env/workflow/types/context.d.ts +17 -0
  300. package/dist/env/workflow/types/decorators-types.d.ts +182 -0
  301. package/dist/env/workflow/types/edge.d.ts +33 -0
  302. package/dist/env/workflow/types/event.d.ts +869 -0
  303. package/dist/env/workflow/types/index.d.ts +16 -0
  304. package/dist/env/workflow/types/run.d.ts +254 -0
  305. package/dist/env/workflow/types/workflow-error.d.ts +79 -0
  306. package/dist/env/workflow/types/workflow-hil.d.ts +57 -0
  307. package/dist/env/workflow/types/workflow-message.d.ts +193 -0
  308. package/dist/env/workflow/types/workflow-session.d.ts +17 -0
  309. package/dist/env/workflow/types/workflow.d.ts +654 -0
  310. package/dist/env/workflow/types_compat.d.ts +10 -0
  311. package/dist/env/workflow/utils/agent-session-metadata.d.ts +48 -0
  312. package/dist/env/workflow/utils/build-agent-node-output.d.ts +11 -0
  313. package/dist/env/workflow/utils/create-workflow.d.ts +35 -0
  314. package/dist/env/workflow/utils/dependency-prescan.d.ts +67 -0
  315. package/dist/env/workflow/utils/execution-state.d.ts +46 -0
  316. package/dist/env/workflow/utils/extract-agent-json-output.d.ts +6 -0
  317. package/dist/env/workflow/utils/index.d.ts +14 -0
  318. package/dist/env/workflow/utils/index.js +1 -1
  319. package/dist/env/workflow/utils/json-schema-to-zod.d.ts +23 -0
  320. package/dist/env/workflow/utils/node-id-utils.d.ts +20 -0
  321. package/dist/env/workflow/utils/node-output-contracts.d.ts +137 -0
  322. package/dist/env/workflow/utils/node-registry-helper.d.ts +36 -0
  323. package/dist/env/workflow/utils/output-schema-hint.d.ts +7 -0
  324. package/dist/env/workflow/utils/parse-agent-output-config.d.ts +9 -0
  325. package/dist/env/workflow/utils/recovery-validator.d.ts +30 -0
  326. package/dist/env/workflow/utils/redact-command-secrets.d.ts +70 -0
  327. package/dist/env/workflow/utils/sensitive-redact.d.ts +37 -0
  328. package/dist/env/workflow/utils/session-parser.d.ts +23 -0
  329. package/dist/env/workflow/utils/session-recovery.d.ts +122 -0
  330. package/dist/env/workflow/utils/shell-dialect-lint.d.ts +75 -0
  331. package/dist/env/workflow/utils/template-contract-validator.d.ts +87 -0
  332. package/dist/env/workflow/utils/template-resolver.d.ts +285 -0
  333. package/dist/env/workflow/utils/validate-workflow-definition.d.ts +79 -0
  334. package/dist/env/workflow/utils/validation-rules.d.ts +103 -0
  335. package/dist/env/workflow/utils/workflow-message-metadata.d.ts +20 -0
  336. package/dist/env/workflow/utils/workflow-sanitize.d.ts +51 -0
  337. package/dist/env/workflow/workflow-component.d.ts +138 -0
  338. package/dist/index.d.ts +59 -0
  339. package/dist/index.js +21 -21
  340. package/dist/shared/@ai-setting/{roy-agent-core-stnddvx9.js → roy-agent-core-12d2xap8.js} +1 -1
  341. package/dist/shared/@ai-setting/{roy-agent-core-pk1b3kvf.js → roy-agent-core-2b8jtv7m.js} +1 -1
  342. package/dist/shared/@ai-setting/{roy-agent-core-x8n1r7h4.js → roy-agent-core-2bscfrr1.js} +188 -7
  343. package/dist/shared/@ai-setting/{roy-agent-core-gdsqp6j8.js → roy-agent-core-6masakz4.js} +45 -0
  344. package/dist/shared/@ai-setting/{roy-agent-core-vvxb9522.js → roy-agent-core-6qxh4xrm.js} +67 -6
  345. package/dist/shared/@ai-setting/{roy-agent-core-h93v6p6y.js → roy-agent-core-7qy3nffr.js} +2 -2
  346. package/dist/shared/@ai-setting/{roy-agent-core-s214vmmd.js → roy-agent-core-8eqngasy.js} +2 -2
  347. package/dist/shared/@ai-setting/{roy-agent-core-brwzs8wf.js → roy-agent-core-9h72sk1n.js} +1 -1
  348. package/dist/shared/@ai-setting/{roy-agent-core-na73mym1.js → roy-agent-core-a4vzsn0g.js} +212 -1
  349. package/dist/shared/@ai-setting/{roy-agent-core-35s1w7tc.js → roy-agent-core-aer5kw1j.js} +142 -70
  350. package/dist/shared/@ai-setting/{roy-agent-core-j8e92gj8.js → roy-agent-core-b5ew8t0k.js} +0 -59
  351. package/dist/shared/@ai-setting/{roy-agent-core-rcfewbzr.js → roy-agent-core-cd62e9p1.js} +1 -1
  352. package/dist/shared/@ai-setting/{roy-agent-core-39xejr39.js → roy-agent-core-e2z1etk4.js} +1 -1
  353. package/dist/shared/@ai-setting/{roy-agent-core-pkpkctvf.js → roy-agent-core-g36jevrk.js} +14 -183
  354. package/dist/shared/@ai-setting/{roy-agent-core-ezgsem94.js → roy-agent-core-j2nvedt6.js} +465 -128
  355. package/dist/shared/@ai-setting/{roy-agent-core-p2r27era.js → roy-agent-core-mxdc756a.js} +1 -1
  356. package/dist/shared/@ai-setting/{roy-agent-core-p8ak03s0.js → roy-agent-core-w527pcpe.js} +293 -42
  357. package/dist/shared/@ai-setting/{roy-agent-core-3tv1q6f2.js → roy-agent-core-ytr2w0vb.js} +2 -2
  358. package/dist/shared/@ai-setting/{roy-agent-core-yd21n6c7.js → roy-agent-core-zvemdfx5.js} +1 -1
  359. package/dist/test-utils/child-process-mock.d.ts +73 -0
  360. package/dist/util/process/process-tree-killer.d.ts +67 -0
  361. package/dist/utils/id.d.ts +11 -0
  362. package/dist/utils/loose-json.d.ts +30 -0
  363. package/dist/utils/media.d.ts +70 -0
  364. package/dist/utils/temp-file-manager/index.d.ts +99 -0
  365. package/package.json +5 -3
  366. /package/dist/shared/@ai-setting/{roy-agent-core-zy3hqfwg.js → roy-agent-core-0hq21px2.js} +0 -0
  367. /package/dist/shared/@ai-setting/{roy-agent-core-0cfaqnz9.js → roy-agent-core-k25gv86p.js} +0 -0
@@ -0,0 +1,440 @@
1
+ /**
2
+ * @fileoverview WorkflowEngine - Session-based workflow execution engine
3
+ *
4
+ * 统一的 run() 方法同时支持:
5
+ * - 初次运行:session 不存在 → 创建 session,从 entry node 开始
6
+ * - 中断恢复:session 存在 + 有消息 → 从消息推断下一个节点继续执行
7
+ *
8
+ * Session 通过 workflow.node.* 消息记录节点执行状态
9
+ *
10
+ * @version v3.0 (移除 resume() 方法,统一使用 run())
11
+ */
12
+ import { EventEmitter } from 'events';
13
+ import type { WorkflowDefinition, Workflow, RunOptions, RunResult, RunStatus } from '../types/index';
14
+ import { NodeRegistry } from './node-registry';
15
+ import type { SessionComponent } from '../../session/session-component';
16
+ /**
17
+ * Agent Session Recovery Info
18
+ */
19
+ export interface AgentSessionRecoveryInfo {
20
+ nodeId: string;
21
+ agentSessionId: string;
22
+ }
23
+ /**
24
+ * Options for creating WorkflowEngine via static factory
25
+ */
26
+ export interface WorkflowEngineCreateOptions {
27
+ env?: {
28
+ getComponent<T>(name: string): T | undefined;
29
+ };
30
+ toolRegistry?: any;
31
+ skillRegistry?: any;
32
+ workflowRunner?: any;
33
+ sessionComponent?: SessionComponent;
34
+ /** Repository for loading workflow definitions during resume */
35
+ workflowRepository?: WorkflowRepository;
36
+ }
37
+ /**
38
+ * Workflow Repository interface (abstraction)
39
+ */
40
+ export interface WorkflowRepository {
41
+ getById(id: string): Workflow | null;
42
+ getByName(name: string): Workflow | null;
43
+ }
44
+ /**
45
+ * WorkflowEngine Configuration
46
+ */
47
+ export interface WorkflowEngineConfig {
48
+ parallelLimit: number | null;
49
+ timeout: number | null;
50
+ debug: boolean;
51
+ /** Strict mode: fail on unresolved templates instead of warning */
52
+ strict: boolean;
53
+ /** Maximum iterations to prevent infinite loops (default: 100) */
54
+ maxIterations: number;
55
+ /** Global workflow input for condition evaluation (P0-3 fix) */
56
+ workflowInput?: Record<string, unknown>;
57
+ /** Enable loop mode to allow re-entry of completed nodes (P0-1 fix) */
58
+ loopEnabled?: boolean;
59
+ /**
60
+ * Per-node runtime overrides.
61
+ *
62
+ * Task #1974 — Workflow Node-Level Config + Resume + Stop. Set by
63
+ * `engine.initializeSessionState` from `RunOptions.nodeConfig`. Used
64
+ * by `buildNodeContext` to shallow-merge into each node's effective
65
+ * config (input wins over nodeDef.config).
66
+ *
67
+ * Always present (defaults to `{}`); engine treats `undefined` and
68
+ * `{}` identically.
69
+ */
70
+ nodeConfig?: Record<string, Record<string, unknown>>;
71
+ }
72
+ /**
73
+ * WorkflowEngine
74
+ *
75
+ * Session-based workflow execution engine.
76
+ * Uses Session to manage workflow run state and node execution history.
77
+ */
78
+ export declare class WorkflowEngine extends EventEmitter {
79
+ /** 活跃的 session 状态,key 为 sessionId */
80
+ private activeSessions;
81
+ /** Session ID 计数器 */
82
+ private sessionIdCounter;
83
+ /** Session component */
84
+ private sessionComponent?;
85
+ /** Node registry */
86
+ private nodeRegistry;
87
+ /** Workflow repository for loading definitions during resume */
88
+ private workflowRepository?;
89
+ /**
90
+ * Create a new WorkflowEngine
91
+ */
92
+ constructor(nodeRegistry: NodeRegistry, sessionComponent?: SessionComponent, workflowRepository?: WorkflowRepository);
93
+ /**
94
+ * Create a WorkflowEngine with automatic AgentComponent integration
95
+ */
96
+ static create(options: WorkflowEngineCreateOptions): Promise<WorkflowEngine>;
97
+ /**
98
+ * Generate a unique run ID
99
+ */
100
+ private generateRunId;
101
+ /**
102
+ * Get session ID for a run.
103
+ *
104
+ * Task #1837: now an identity function — runId already has the
105
+ * `workflow_` prefix, so sessionId equals runId exactly. The legacy
106
+ * `\`workflow_${runId}\`` mapping is collapsed.
107
+ *
108
+ * Kept as a public method for backward compatibility with external
109
+ * callers that may still derive sessionId from runId.
110
+ */
111
+ getSessionId(runId: string): string;
112
+ /**
113
+ * Extract runId from sessionId.
114
+ *
115
+ * Task #1837: sessionId IS the runId (no prefix to strip). Returns the
116
+ * input verbatim. Existing callers (event emission, pause/stop) still
117
+ * work because they don't care about the prefix format — they just
118
+ * need a unique identifier for the workflow run.
119
+ */
120
+ private getRunIdFromSessionId;
121
+ /**
122
+ * Create a new workflow session
123
+ *
124
+ * @param workflow - Workflow definition or entity
125
+ * @param options - Optional configuration
126
+ * @returns Promise resolving to sessionId (format: workflow_{runId})
127
+ */
128
+ createSession(workflow: Workflow | WorkflowDefinition, options?: RunOptions): Promise<string>;
129
+ /**
130
+ * Run a workflow by sessionId (unified entry point)
131
+ *
132
+ * This method supports both:
133
+ * 1. First run: session doesn't exist → create session, start from entry node
134
+ * 2. Resume: session exists with messages → infer next node from messages
135
+ *
136
+ * @param sessionId - Session ID (format: workflow_{runId} or any string)
137
+ * @param options - Optional configuration
138
+ * @returns Promise resolving to RunResult
139
+ */
140
+ run(sessionId: string, options?: RunOptions & {
141
+ workflowId?: string;
142
+ }): Promise<RunResult>;
143
+ /**
144
+ * Initialize session state
145
+ */
146
+ private initializeSessionState;
147
+ /**
148
+ * Run with resume point
149
+ *
150
+ * Simplified logic:
151
+ * - input is passed directly to execution (string or object)
152
+ * - For resume with ask_user, the input should contain userQuery
153
+ * - agentSessionId comes from session messages via resumePoint
154
+ */
155
+ private runWithResume;
156
+ /**
157
+ * Convenience method to run a workflow directly
158
+ */
159
+ runWorkflow(workflow: Workflow | WorkflowDefinition, options?: RunOptions): Promise<RunResult>;
160
+ /**
161
+ * Pause a running workflow
162
+ */
163
+ pause(sessionId: string): Promise<void>;
164
+ /**
165
+ * Stop a running or paused workflow.
166
+ *
167
+ * Task #2275: now structured through `RuntimeCancellationScope` so that:
168
+ * - The session's `completedPromise` is resolved with `{status:'stopped'}`
169
+ * once tracked cleanup settles, NOT just metadata update.
170
+ * - `force=true` escalates to the scope's force level and fires any
171
+ * registered force handlers (e.g. process kill paths).
172
+ * - Cooperative runners listening to the scope signal will abort.
173
+ * - The legacy `abortController` is also aborted for backward compat.
174
+ *
175
+ * The function is idempotent — calling it twice (or stop+stop(force))
176
+ * coalesces into a single transition.
177
+ */
178
+ stop(sessionId: string, reason?: string, options?: {
179
+ force?: boolean;
180
+ }): Promise<void>;
181
+ /**
182
+ * Get session status
183
+ */
184
+ getSessionStatus(sessionId: string): RunStatus | null;
185
+ /**
186
+ * Task #2275 — propagate a workflow stop to each actual child agent
187
+ * session record. The previous engine.stop only updated the workflow
188
+ * session's `agentSessions[]` references, leaving child session
189
+ * metadata.status stale (a gap visible in `sessions list --graph`
190
+ * where the user saw `agent_plan_*` and `agent_init-task_*` still
191
+ * listed without a stopped status after the workflow was stopped).
192
+ *
193
+ * Behavior:
194
+ * - Iterates ALL sessions whose parentSessionId matches this
195
+ * workflow session (not just refs in metadata.agentSessions, so
196
+ * children created in the brief window between schedule and stop
197
+ * are also caught).
198
+ * - For each child session:
199
+ * - Skip if status is already terminal (completed/failed/stopped)
200
+ * - Update metadata.status = "stopped", append stop reason
201
+ * - Errors are isolated per child — one failure does not block siblings
202
+ * - No-op when sessionComponent is missing or workflow has no children
203
+ *
204
+ * Idempotency: a second invocation only touches children that are
205
+ * still non-terminal, so double-stop is safe.
206
+ */
207
+ private propagateStopToChildSessions;
208
+ /**
209
+ * Check if session is active
210
+ */
211
+ isSessionActive(sessionId: string): boolean;
212
+ /**
213
+ * Setup event handlers for a run
214
+ */
215
+ private setupEventHandlers;
216
+ /**
217
+ * Main scheduling loop
218
+ */
219
+ private scheduleAndExecute;
220
+ /**
221
+ * Dispatch a node without waiting for it to finish (Task #4392 P0-1).
222
+ *
223
+ * Registers the node's promise in `sessionState.inFlight` **synchronously**
224
+ * so the scheduler loop can (a) join it and (b) never mistake "no tracked
225
+ * work" for "done". The returned promise is intentionally swallowed: node
226
+ * outcomes propagate through `scheduler.markFailed` and the `node.failed`
227
+ * event, exactly as they did when the dispatch path awaited them.
228
+ *
229
+ * ## Claim guard — why this is not just "call startNode"
230
+ *
231
+ * A node can be reachable from **two** dispatch paths:
232
+ * 1. `scheduleAvailableNodes()` → `scheduler.getReadyNodes()` (DAG readiness)
233
+ * 2. `processConditionalEdgesAfterCompletion()` → `edgeResult.toStart`
234
+ *
235
+ * Under the old serial loop this never mattered: path 2 awaited each target
236
+ * to completion, so path 1 always found them `completed` already. Once
237
+ * dispatch became concurrent the two paths race and the *same* node was
238
+ * executed twice (proven by `engine-parallel-scheduling.test.ts`:
239
+ * `parallelLimit=2` produced peak concurrency 3 with 4 of 6 leaves run twice).
240
+ *
241
+ * `scheduler.running` is the tie-breaker. `startNode` calls
242
+ * `scheduler.markStarted()` before its first `await`, so the claim is visible
243
+ * synchronously to the next dispatcher on the same tick — no interleaving
244
+ * window. Returns `true` only for the caller that actually won the claim.
245
+ *
246
+ * ⚠️ The guard deliberately keys off `scheduler.running` and **not** off
247
+ * `inFlight`, even though both look equivalent. A self-loop back-edge
248
+ * (`implement → implement`) re-dispatches the node *from inside its own
249
+ * completion handler*, i.e. while its own promise is still in `inFlight` but
250
+ * after `resetNodeForReEntry()` cleared `running`. Guarding on `inFlight`
251
+ * deadlocks exactly that case: the node waits for itself forever.
252
+ */
253
+ private dispatchNode;
254
+ /**
255
+ * Wait for next node event
256
+ *
257
+ * Optimization: When there are running nodes, use pure event-driven waiting
258
+ * (no polling). When there are only pending nodes (dependencies not yet met),
259
+ * use a small timeout to re-check scheduling conditions.
260
+ *
261
+ * Task #4392 P0-1 — two additions that concurrent dispatch makes necessary:
262
+ *
263
+ * 1. **`inFlight` also arms the timeout.** `scheduler.running` is cleared by
264
+ * `markCompleted` inside `validateAndExecute`, but the node's promise is
265
+ * still settling (AFTER_NODE hook, conditional edges, `checkAndFinalize`).
266
+ * In that window `hasRunningNodes` is false while real work continues, so
267
+ * we must keep a wakeup source armed or the loop could park forever.
268
+ *
269
+ * 2. **`node.scheduled` resolves the wait.** Concurrent dispatch publishes
270
+ * `node.scheduled` for sibling nodes (and for loop re-entries) *after* this
271
+ * waiter subscribed — with `node.completed`/`node.failed` as the only
272
+ * trigger, a round whose completion event fired during the synchronous
273
+ * dispatch section would leave the loop blocked until the 100ms poll.
274
+ * Subscribing to `node.scheduled` closes that lost-wakeup window.
275
+ */
276
+ private waitForNextNodeEvent;
277
+ /**
278
+ * Start execution of a single node
279
+ */
280
+ private startNode;
281
+ /**
282
+ * Write workflow.node.start message
283
+ */
284
+ private writeNodeStart;
285
+ /**
286
+ * Resume execution of a paused node
287
+ *
288
+ * Simplified logic:
289
+ * - Load agent session from agentSessionId
290
+ * - Pass userQuery from input to agentNode
291
+ * - No complex userResponse distinction
292
+ */
293
+ private resumeNode;
294
+ /**
295
+ * Pre-execute validation
296
+ * Validates node configuration before execution
297
+ * Checks for unresolved templates and throws in strict mode
298
+ */
299
+ private preExecuteValidation;
300
+ /**
301
+ * Validate node configuration and execute it
302
+ * Common method used by both startNode and resumeNode
303
+ */
304
+ private validateAndExecute;
305
+ /**
306
+ * Loop-guard check for a single back-edge re-entry.
307
+ *
308
+ * Task #2283 — engine-side progress guard. Reads the node's
309
+ * `config.loop_guard` and decides whether the upcoming re-entry would
310
+ * be a no-progress attempt. If the no-progress counter reaches
311
+ * `max_consecutive_no_progress`, the function returns
312
+ * `{ trip: true, failMessage }` so the caller can short-circuit the
313
+ * agent and inject a fail output.
314
+ *
315
+ * Behavior matrix for the `value_unchanged` type:
316
+ * - previous_value === current_value (after JSON.stringify)
317
+ * → increment counter; if >= maxAllowed → trip; else allow
318
+ * - previous_value !== current_value
319
+ * → reset counter to 0; allow
320
+ * - previous_value is undefined (first run for this node)
321
+ * → first re-entry: count this as a "change" (we don't know the
322
+ * prior state); allow
323
+ * - current_signal_command fails to execute
324
+ * → allow (defensive: don't false-positive on transient shell errors)
325
+ *
326
+ * The counter is persisted in `sessionState.loopGuardCounters`
327
+ * (Task #2286 fix — dedicated map, independent of `nodeOutputs`).
328
+ *
329
+ * Earlier versions stored the counter under the well-known key
330
+ * `_loop_guard_consecutive_<nodeId>` directly on the node's prior
331
+ * output map. That broke once `max_consecutive_no_progress >= 2`,
332
+ * because the next agent run overwrote the whole output via
333
+ * `sessionState.nodeOutputs.set(nodeId, result.output)`, clobbering
334
+ * the counter on every back-edge. The dedicated map survives agent
335
+ * output writes because nothing else mutates it.
336
+ *
337
+ * The caller MUST pass a `templateResolver` whose previousOutputs
338
+ * already include the pre-cascade-reset snapshot for `reEntryId`.
339
+ * The post-reset state would otherwise resolve `{{nodes.<reEntryId>.*}}`
340
+ * to undefined.
341
+ */
342
+ private checkLoopGuardWithSnapshot;
343
+ /**
344
+ * Evaluate conditional edges after a node completes and start matching targets.
345
+ *
346
+ * IMPORTANT: For conditional edge workflows to work correctly:
347
+ * 1. All non-entry nodes MUST specify depends_on for their expected upstream node(s)
348
+ * 2. edges.when acts as a gate AFTER depends_on is satisfied
349
+ * 3. If depends_on is empty, the node will be scheduled at start regardless of edges
350
+ */
351
+ private processConditionalEdgesAfterCompletion;
352
+ /**
353
+ * Build node execution context (renamed from createExecutionContext)
354
+ *
355
+ * @param sessionState - Active session state
356
+ * @param nodeId - Node ID to create context for
357
+ * @param globalInput - Global workflow input
358
+ */
359
+ /**
360
+ * 安全取 DAG 节点总数(供 hook payload 用)。
361
+ *
362
+ * ★ 2026-10-16 独立 review P0:hook payload 的构造**绝不能**让 engine 抛错。
363
+ * 原实现直接写 `sessionState.dagManager.getNodeCount()`,而 legacy 测试 fixture
364
+ * 会直接 cast 构造 ActiveSessionState(可能没有 dagManager)→
365
+ * `TypeError: undefined is not an object`。
366
+ *
367
+ * 致命点:该异常发生在 **HookManager 之前**(还在构造 payload),所以
368
+ * "hook 抛错由 safeExecute 隔离"这条保护**完全救不了** —— 异常是 engine 自己
369
+ * 抛的,会连带吞掉 `resolveCompleted` / agentSessions 传播 / 原始 error。
370
+ * 实测它打红了 7 条既有测试
371
+ * (engine-fail-agentsessions ×4、engine-node-completed-agentsessions ×3)。
372
+ *
373
+ * 兜底返回 undefined:hook 消费方(如通知插件)本就把 totalNodes 当可选。
374
+ */
375
+ private safeNodeCount;
376
+ private buildNodeContext;
377
+ /**
378
+ * Check if workflow is complete and finalize
379
+ */
380
+ private checkAndFinalize;
381
+ /**
382
+ * Complete a workflow successfully.
383
+ *
384
+ * === RunResult Output Behavior ===
385
+ *
386
+ * 1. ALL node outputs (intermediate + exit) are included in the final
387
+ * RunResult.output as { nodeId: output, ... }. The shape stays
388
+ * consistent regardless of how many nodes or exit points a
389
+ * workflow has.
390
+ *
391
+ * 2. The same all-node-outputs map is also stored in session metadata
392
+ * for debugging/reference.
393
+ *
394
+ * 3. Intermediate node outputs are additionally recorded in session
395
+ * messages via workflow.node.end messages written by
396
+ * executor.writeNodeEnd().
397
+ *
398
+ * 4. Consumers can always access a node's output via
399
+ * result.output[nodeId], including agents that need to chain state
400
+ * across pause/resume cycles (see agent-resume-history.test.ts,
401
+ * dual-agent-resume-userquery.test.ts).
402
+ */
403
+ private completeWorkflow;
404
+ /**
405
+ * Fail a workflow
406
+ */
407
+ private failWorkflow;
408
+ /**
409
+ * Cleanup session resources
410
+ */
411
+ private cleanupSession;
412
+ /**
413
+ * Wait for a run to complete
414
+ */
415
+ private waitForCompletion;
416
+ /**
417
+ * Get session metadata
418
+ */
419
+ private getSessionMetadata;
420
+ /**
421
+ * Serialized session-metadata read-modify-write (Task #4392 P0-1).
422
+ *
423
+ * Every `node.completed` / `node.failed` handler and every terminal-state
424
+ * transition mutates metadata via `get → spread → update`. That is safe only
425
+ * if mutations never interleave. Now that nodes are dispatched concurrently,
426
+ * two completions can both `await get()` the same snapshot and the later
427
+ * `update()` silently drops the other's `agentSessions` marker.
428
+ *
429
+ * `mutate` receives the freshly-read metadata and must return the next
430
+ * metadata object. Mutations are chained onto `sessionState.sessionMetadataQueue`
431
+ * so they apply in a strict total order, and the queue never rejects (a
432
+ * failed mutation is logged and skipped) so one bad update cannot poison
433
+ * every later write.
434
+ */
435
+ private updateSessionMetadata;
436
+ /**
437
+ * Find workflow definition from repository
438
+ */
439
+ private findDefinitionForWorkflow;
440
+ }
@@ -0,0 +1,54 @@
1
+ import type { WorkflowEvent } from '../types/event';
2
+ export type EventHandler = (event: WorkflowEvent) => void | Promise<void>;
3
+ /**
4
+ * EventBus for workflow events.
5
+ * Custom event bus implementation with support for wildcard subscriptions.
6
+ */
7
+ export declare class EventBus {
8
+ private handlers;
9
+ private wildcardHandlers;
10
+ constructor();
11
+ /**
12
+ * Subscribe to a specific event type.
13
+ * @returns Unsubscribe function
14
+ */
15
+ on(eventType: string, handler: EventHandler): () => void;
16
+ /**
17
+ * Subscribe to an event type only once (auto-unsubscribe after first call).
18
+ * @returns Unsubscribe function
19
+ */
20
+ once(eventType: string, handler: EventHandler): () => void;
21
+ /**
22
+ * Unsubscribe from an event type.
23
+ */
24
+ off(eventType: string, handler: EventHandler): void;
25
+ /**
26
+ * Subscribe to all events (wildcard subscription).
27
+ * @returns Unsubscribe function
28
+ */
29
+ onAny(handler: EventHandler): () => void;
30
+ /**
31
+ * Publish an event to all subscribers.
32
+ * Handler errors are caught and do not crash the bus.
33
+ *
34
+ * @param event - The event to publish
35
+ * @param waitForHandlers - If true, waits for all async handlers to complete (default: false)
36
+ */
37
+ publish(event: WorkflowEvent, waitForHandlers?: boolean): Promise<void>;
38
+ /**
39
+ * Execute a handler safely, catching any errors.
40
+ */
41
+ private executeHandler;
42
+ /**
43
+ * Clear all subscriptions.
44
+ */
45
+ clear(): void;
46
+ /**
47
+ * Get statistics about the event bus.
48
+ */
49
+ getStats(): {
50
+ eventTypes: number;
51
+ wildcardHandlers: number;
52
+ totalHandlers: number;
53
+ };
54
+ }
@@ -0,0 +1,122 @@
1
+ /**
2
+ * @fileoverview Executor - Executes nodes in a workflow
3
+ *
4
+ * The Executor is responsible for:
5
+ * - Executing individual nodes
6
+ * - Handling retries
7
+ * - Managing timeouts
8
+ * - Tracking execution state
9
+ */
10
+ import type { NodeDefinition, RetryConfig, NodeExecutionContext, NodeExecutionResult } from '../types/index';
11
+ import { EventBus } from './event-bus';
12
+ import { NodeRegistry } from './node-registry';
13
+ import type { SessionComponent } from '../../session/session-component';
14
+ /**
15
+ * Executor Options
16
+ */
17
+ export interface ExecutorOptions {
18
+ /** Global timeout for node execution (ms). null = no timeout */
19
+ globalTimeout: number | null;
20
+ /** Global retry configuration */
21
+ globalRetry: RetryConfig | null;
22
+ /** Debug mode */
23
+ debug: boolean;
24
+ }
25
+ /**
26
+ * Executor
27
+ *
28
+ * Executes nodes in a workflow with support for:
29
+ * - Timeout handling
30
+ * - Retry with configurable backoff
31
+ * - Error propagation
32
+ * - Session message writing
33
+ * - AskUserError handling
34
+ *
35
+ * @example
36
+ * ```typescript
37
+ * const executor = new Executor(nodeRegistry, eventBus, {
38
+ * globalTimeout: 60000,
39
+ * globalRetry: { max_attempts: 3, backoff: 'exponential', initial_delay: 1000 },
40
+ * debug: false
41
+ * });
42
+ *
43
+ * const result = await executor.executeNode(nodeDefinition, context);
44
+ * ```
45
+ */
46
+ export declare class Executor {
47
+ private nodeRegistry;
48
+ private eventBus;
49
+ private options;
50
+ private sessionComponent?;
51
+ private abortControllers;
52
+ constructor(nodeRegistry: NodeRegistry, eventBus: EventBus, options: ExecutorOptions, sessionComponent?: SessionComponent | undefined);
53
+ /**
54
+ * Execute a node with timeout and retry handling
55
+ */
56
+ executeNode(definition: NodeDefinition, context: NodeExecutionContext): Promise<NodeExecutionResult>;
57
+ /**
58
+ * Execute node with timeout handling
59
+ *
60
+ * Task #1976: when the timeout fires, also abort the controller so the
61
+ * node has a chance to react via its AbortSignal — instead of being
62
+ * silently orphaned (the bug this method was leaking).
63
+ */
64
+ private executeWithTimeout;
65
+ /**
66
+ * Execute node with retry handling
67
+ */
68
+ private executeWithRetry;
69
+ /**
70
+ * Cancel execution of a specific node
71
+ */
72
+ cancelNode(nodeId: string): void;
73
+ /**
74
+ * Cancel all running nodes
75
+ */
76
+ cancelAll(): void;
77
+ /**
78
+ * Combine two abort signals.
79
+ *
80
+ * Task #2291 P0-1 / P1-3:
81
+ * Replaced the addEventListener-based composition with `AbortSignal.any`
82
+ * which (a) preserves the abort reason from the firing input and
83
+ * (b) aborts synchronously when any input is already aborted.
84
+ */
85
+ private combineAbortSignals;
86
+ /**
87
+ * Sleep for specified milliseconds, with optional signal-aware abort
88
+ * (Task #2275). When `signal` is provided, the returned Promise rejects
89
+ * with `signal.reason` if the signal aborts before the timer fires,
90
+ * and the underlying setTimeout is cleared (no leftover timer).
91
+ */
92
+ private sleep;
93
+ /**
94
+ * Write workflow.node.start message
95
+ * 对应 tool-call,节点开始执行
96
+ */
97
+ writeNodeStart(sessionId: string, nodeId: string, nodeType: string, input: unknown, agentSessionId?: string): Promise<void>;
98
+ /**
99
+ * Patch agentSessionId onto the latest workflow.node.start for a node (P1).
100
+ */
101
+ attachAgentSessionToLastStart(sessionId: string, nodeId: string, agentSessionId: string): Promise<void>;
102
+ /**
103
+ * Create a meaningful content summary for call message
104
+ */
105
+ private summarizeCall;
106
+ /**
107
+ * Write workflow.node.interrupt message
108
+ */
109
+ writeNodeInterrupt(sessionId: string, nodeId: string, nodeType: string, query: string, agentSessionId?: string): Promise<void>;
110
+ /**
111
+ * Write workflow.node.end message (对应 tool-result)
112
+ */
113
+ writeNodeEnd(sessionId: string, nodeId: string, nodeType: string, output: unknown, error: string | undefined, durationMs: number, agentSessionId?: string): Promise<void>;
114
+ /**
115
+ * Create a meaningful content summary for result display
116
+ */
117
+ private summarizeResult;
118
+ /**
119
+ * Write workflow.node.resume message
120
+ */
121
+ writeNodeResume(sessionId: string, nodeId: string, nodeType: string, response: string, agentSessionId?: string): Promise<void>;
122
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @fileoverview Engine exports
3
+ */
4
+ export type { NodeExecutionContext, RunOptions, RunResult, RunStatus, NodeStatus, } from '../types/index';
5
+ export { EventBus } from './event-bus';
6
+ export { DAGManager } from './dag-manager';
7
+ export type { DAGAnalysis } from './dag-manager';
8
+ export { Scheduler } from './scheduler';
9
+ export type { SchedulerOptions, SchedulerState } from './scheduler';
10
+ export { Executor } from './executor';
11
+ export type { ExecutorOptions } from './executor';
12
+ export { WorkflowEngine } from './engine';
13
+ export type { WorkflowEngineConfig, WorkflowEngineCreateOptions, WorkflowRepository } from './engine';
14
+ export { NodeRegistry } from './node-registry';
15
+ export type { NodeContext, NodeFactory } from './node-registry';
@@ -5,10 +5,10 @@ import {
5
5
  Scheduler,
6
6
  WorkflowEngine,
7
7
  init_engine
8
- } from "../../../shared/@ai-setting/roy-agent-core-35s1w7tc.js";
8
+ } from "../../../shared/@ai-setting/roy-agent-core-aer5kw1j.js";
9
9
  import"../../../shared/@ai-setting/roy-agent-core-6atd905e.js";
10
10
  import"../../../shared/@ai-setting/roy-agent-core-6167phd4.js";
11
- import"../../../shared/@ai-setting/roy-agent-core-x8n1r7h4.js";
11
+ import"../../../shared/@ai-setting/roy-agent-core-2bscfrr1.js";
12
12
  import"../../../shared/@ai-setting/roy-agent-core-1db4vpc6.js";
13
13
  import"../../../shared/@ai-setting/roy-agent-core-ze068vc9.js";
14
14
  import"../../../shared/@ai-setting/roy-agent-core-fs36xgcs.js";