@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,16 @@
1
+ export * from './edge';
2
+ export * from './workflow';
3
+ export * from './workflow-message';
4
+ export * from './workflow-session';
5
+ export * from './context';
6
+ export * from './workflow-hil';
7
+ export * from './event';
8
+ export * from './run';
9
+ export type { AgentSessionInfo } from './workflow-message';
10
+ export type { AgentSessionRef } from './workflow-session';
11
+ export type { RunStatus, NodeStatus, WorkflowRun, NodeRun, RunOptions, RunResult, NodeExecutionContext, NodeExecutionResult, } from './run';
12
+ export { createNodeExecutionContext } from './run';
13
+ export type { WorkflowDefinition, WorkflowDefinitionExtended, Workflow, WorkflowConfig, WorkflowMetadata, RetryConfig, Node, NodeDefinition, NodeDefinitionSchema, DependsOn, DependsOnSchema, OutputDefinition, OutputDefinitionSchema, InputParameter, WorkflowInputs, } from './workflow';
14
+ export type { TemplateResolver } from '../utils/template-resolver';
15
+ export { WorkflowError, TemplateUnresolvedError, WorkflowValidationError, nodeNotFound, pathNotFound, unresolvedVariable, } from './workflow-error';
16
+ export type { WorkflowErrorContext } from './workflow-error';
@@ -0,0 +1,254 @@
1
+ import { z } from 'zod';
2
+ import type { EventBus } from '../engine/event-bus';
3
+ import type { SessionComponent } from '../../session/session-component';
4
+ import type { TemplateResolver } from '../utils/template-resolver';
5
+ export declare const RunStatusSchema: z.ZodEnum<["idle", "running", "paused", "stopped", "completed", "failed"]>;
6
+ export type RunStatus = z.infer<typeof RunStatusSchema>;
7
+ export declare const NodeStatusSchema: z.ZodEnum<["pending", "scheduled", "started", "running", "completed", "failed", "skipped"]>;
8
+ export type NodeStatus = z.infer<typeof NodeStatusSchema>;
9
+ export interface WorkflowRun {
10
+ id: string;
11
+ workflowId: string;
12
+ workflowName: string;
13
+ status: RunStatus;
14
+ input?: Record<string, any>;
15
+ output?: Record<string, any>;
16
+ error?: string;
17
+ startedAt?: Date;
18
+ pausedAt?: Date;
19
+ resumedAt?: Date;
20
+ stoppedAt?: Date;
21
+ completedAt?: Date;
22
+ durationMs?: number;
23
+ debugMode: boolean;
24
+ parentRunId?: string;
25
+ }
26
+ export interface NodeRun {
27
+ id: string;
28
+ runId: string;
29
+ nodeId: string;
30
+ nodeType: string;
31
+ status: NodeStatus;
32
+ input?: any;
33
+ output?: any;
34
+ error?: string;
35
+ startedAt?: Date;
36
+ completedAt?: Date;
37
+ durationMs?: number;
38
+ retryCount: number;
39
+ }
40
+ export interface RunOptions {
41
+ input?: Record<string, any>;
42
+ debug?: boolean;
43
+ parallelLimit?: number | null;
44
+ timeout?: number | null;
45
+ /** Strict mode: fail on unresolved templates instead of warning */
46
+ strict?: boolean;
47
+ /** Maximum iterations to prevent infinite loops (default: 100) */
48
+ maxIterations?: number;
49
+ /** Enable loop mode to allow re-entry of completed nodes (for workflow cycles) */
50
+ loopEnabled?: boolean;
51
+ /** Global workflow input for condition evaluation */
52
+ workflowInput?: Record<string, unknown>;
53
+ /**
54
+ * Caller-reserved runId for a fresh workflow run.
55
+ *
56
+ * When set, `WorkflowEngine.createSession` uses this runId (instead of
57
+ * calling `generateRunId()`), so the caller can pre-allocate a runId
58
+ * that the tool layer surfaces on every termination path (timeout /
59
+ * abort / error). Task #1837 already established that runId ===
60
+ * sessionId, and Task #2106 closes the gap where the `workflow_run`
61
+ * tool's synthesized fallback runId was shape-compatible but not
62
+ * queryable / stoppable on the engine.
63
+ *
64
+ * Contract:
65
+ * - Must start with `workflow_` (Task #1837 prefix requirement)
66
+ * - Must be unique across all active workflow sessions
67
+ * - On the resume path, callers should pass `sessionId` instead
68
+ *
69
+ * Task #2106 — required by `workflow_run` tool's reserved-ID contract.
70
+ */
71
+ runId?: string;
72
+ /**
73
+ * Parent session id — when set, the workflow run session will be created
74
+ * with `parentSessionId === parentSessionId`. Used by `workflow_run` tool
75
+ * and `roy-agent workflow run` CLI to track the parent→workflow session
76
+ * hierarchy for `sessions list --graph` (Task #1739).
77
+ */
78
+ parentSessionId?: string | null;
79
+ /**
80
+ * Session id to resume — when set, the engine re-enters an existing
81
+ * workflow session instead of starting a fresh run. Set by the
82
+ * `workflow_run` tool's `session` field and `roy-agent workflow run --session`
83
+ * CLI to power workflow-runner re-entry into paused/interrupted workflows.
84
+ * (Task #1829)
85
+ */
86
+ sessionId?: string;
87
+ /**
88
+ * Callback fired immediately after the workflow session is created
89
+ * (or resolved for resume). The sessionId argument is also the
90
+ * runId (Task #1837: runId == sessionId).
91
+ *
92
+ * Use this to capture the runId/sessionId BEFORE execution, so callers
93
+ * can still reference it when execution later times out, aborts, or
94
+ * throws. Without this callback, the tool layer has no way to surface
95
+ * the runId on failure paths (Task #1840).
96
+ *
97
+ * The callback must be safe to call: a throwing callback is caught
98
+ * and logged, but does NOT abort session creation.
99
+ */
100
+ onSessionCreated?: (sessionId: string) => void;
101
+ /**
102
+ * Per-node runtime config overrides.
103
+ *
104
+ * Keyed by `node.id`. Values are shallow-merged into the node's
105
+ * `nodeDef.config` at buildNodeContext time. Keys present in BOTH
106
+ * nodeDef.config and nodeConfig[nodeId] are taken from nodeConfig
107
+ * (input wins). Unknown node IDs are silently ignored.
108
+ *
109
+ * Common use cases:
110
+ * - `timeout`: per-node execution timeout (ms), overrides engine's
111
+ * global timeout. Read by AgentNode and ToolNode.
112
+ * - `maxIterations`: only honored when loopEnabled=true.
113
+ * - `model`, `allowedTools`, `deniedTools`: forwarded to AgentNode
114
+ * via `options.*`.
115
+ *
116
+ * Task #1974 — Workflow Node-Level Config + Resume + Stop.
117
+ * Backward compatible: when omitted (or empty), engine behavior is
118
+ * unchanged.
119
+ */
120
+ nodeConfig?: Record<string, Record<string, unknown>>;
121
+ }
122
+ export interface RunResult {
123
+ runId: string;
124
+ /** Session ID — Task #1837: equals runId exactly (no derivation). */
125
+ sessionId?: string;
126
+ status: RunStatus;
127
+ output?: Record<string, any>;
128
+ error?: string;
129
+ durationMs?: number;
130
+ /** Pending node ID (when status is 'paused') */
131
+ pendingNodeId?: string;
132
+ /** Query from ask_user (when status is 'paused') */
133
+ query?: string;
134
+ /** Agent sub-session ID (for resuming agent nodes) */
135
+ agentSessionId?: string;
136
+ }
137
+ /**
138
+ * 节点执行上下文
139
+ *
140
+ * 扩展后包含:
141
+ * - sessionId: Session ID,用于消息持久化
142
+ * - askUser(): 方法,让节点可以请求用户输入
143
+ */
144
+ export interface NodeExecutionContext {
145
+ runId: string;
146
+ /** Task #1837: sessionId == runId (runId natively carries workflow_ prefix). */
147
+ sessionId: string;
148
+ workflowName: string;
149
+ nodeId: string;
150
+ input: unknown;
151
+ previousOutputs: Map<string, unknown>;
152
+ nodeOutputs: Map<string, unknown>;
153
+ config: Record<string, unknown>;
154
+ debug: boolean;
155
+ eventBus: EventBus;
156
+ workflowHistory?: Array<{
157
+ role: 'user' | 'assistant' | 'tool';
158
+ content: string;
159
+ toolCallId?: string;
160
+ toolName?: string;
161
+ nodeId?: string;
162
+ }>;
163
+ sessionComponent?: SessionComponent;
164
+ agentSessionId?: string;
165
+ workflowInput?: Record<string, unknown>;
166
+ templateResolver?: TemplateResolver;
167
+ /**
168
+ * Pre-resolved node configuration
169
+ *
170
+ * This is the node's config with all template references resolved
171
+ * using the TemplateResolver. Nodes should use this instead of the
172
+ * raw `config` to avoid duplicate template resolution.
173
+ *
174
+ * Example: A node with config.prompt = "{{nodes.fetch.result}}" will have
175
+ * resolvedConfig.prompt = "The weather is sunny" after resolution.
176
+ */
177
+ resolvedConfig?: Record<string, unknown>;
178
+ /**
179
+ * 请求用户输入
180
+ *
181
+ * 调用此方法会抛出 AskUserError,引擎捕获后会暂停 workflow
182
+ *
183
+ * @param query - 向用户询问的问题
184
+ * @throws AskUserError - 总是抛出此异常
185
+ */
186
+ askUser(query: string): never;
187
+ /** Patch agent sub-session id onto latest workflow.node.start (agent nodes) */
188
+ attachAgentSessionToLastStart?(nodeId: string, agentSessionId: string): Promise<void>;
189
+ /**
190
+ * Register (or refresh) an agent sub-session entry in the parent workflow
191
+ * session's `metadata.agentSessions` (Task #4412 C1).
192
+ *
193
+ * AgentNode must use this instead of doing its own
194
+ * `get → push → update` on the parent metadata. That read-modify-write is
195
+ * unsafe once dispatch is concurrent: N sibling agent nodes all read the
196
+ * same parent snapshot and each writes back its own array-with-one-extra
197
+ * entry, so the last writer wins and every sibling's marker is silently
198
+ * dropped (measured: 4 concurrent agents → only 2 markers survive).
199
+ *
200
+ * The engine implements this by routing the mutation through the same
201
+ * per-session serialization queue it uses for its own metadata writes, so
202
+ * the whole class of lost updates is closed by construction.
203
+ *
204
+ * Optional for backward compatibility with hand-built contexts in tests;
205
+ * AgentNode falls back to the legacy inline RMW when it is absent.
206
+ */
207
+ registerAgentSubSession?(nodeId: string, agentSessionId: string): Promise<void>;
208
+ /**
209
+ * Abort signal for this node's execution (Task #1976).
210
+ *
211
+ * Populated by the workflow executor from its per-node `AbortController`.
212
+ * The signal fires when:
213
+ * 1. The node's timeout elapses (timeoutPromise rejects the race → executor
214
+ * calls `this.cancelNode(nodeId)` which triggers this signal).
215
+ * 2. The user issues `workflow_run_stop` (engine.stop → executor.cancelAll).
216
+ * 3. The retry path on inner-attempt timeout (existing behavior preserved).
217
+ *
218
+ * Nodes SHOULD pass this signal to any long-running async operation they
219
+ * own (e.g. AgentRunner.run, LLM calls, network requests) so that timeout
220
+ * truly cancels the underlying work, not just the engine's wait.
221
+ *
222
+ * Optional for backward compat — nodes that don't opt in still work
223
+ * (their execution will be leaked on timeout, which is the bug this field
224
+ * is designed to fix).
225
+ */
226
+ abortSignal?: AbortSignal;
227
+ }
228
+ export interface NodeExecutionResult {
229
+ success?: boolean;
230
+ output?: any;
231
+ error?: string | Error;
232
+ duration?: number;
233
+ durationMs?: number;
234
+ metadata?: Record<string, unknown>;
235
+ }
236
+ /**
237
+ * 创建 NodeExecutionContext
238
+ */
239
+ export declare function createNodeExecutionContext(params: {
240
+ runId: string;
241
+ workflowName: string;
242
+ nodeId: string;
243
+ input: unknown;
244
+ previousOutputs: Map<string, unknown>;
245
+ nodeOutputs: Map<string, unknown>;
246
+ config: Record<string, unknown>;
247
+ debug: boolean;
248
+ eventBus: EventBus;
249
+ sessionId: string;
250
+ workflowHistory?: NodeExecutionContext['workflowHistory'];
251
+ workflowInput?: Record<string, unknown>;
252
+ templateResolver?: TemplateResolver;
253
+ resolvedConfig?: Record<string, unknown>;
254
+ }): NodeExecutionContext;
@@ -0,0 +1,79 @@
1
+ /**
2
+ * @fileoverview Workflow Error Types
3
+ *
4
+ * Defines error classes for workflow template resolution and validation.
5
+ */
6
+ import { z } from 'zod';
7
+ /**
8
+ * Error context schema for structured error data
9
+ */
10
+ export declare const WorkflowErrorContextSchema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
11
+ export type WorkflowErrorContext = z.infer<typeof WorkflowErrorContextSchema>;
12
+ /**
13
+ * Base workflow error class
14
+ */
15
+ export declare class WorkflowError extends Error {
16
+ readonly context: WorkflowErrorContext;
17
+ constructor(message: string, context?: WorkflowErrorContext);
18
+ /**
19
+ * Convert error to JSON-serializable object
20
+ */
21
+ toJSON(): Record<string, unknown>;
22
+ }
23
+ /**
24
+ * Error thrown when template resolution fails due to unresolved templates.
25
+ *
26
+ * This error captures the list of unresolved template strings for debugging
27
+ * and potential user feedback.
28
+ */
29
+ export declare class TemplateUnresolvedError extends WorkflowError {
30
+ /**
31
+ * List of template strings that could not be resolved
32
+ */
33
+ readonly unresolved: string[];
34
+ constructor(message: string, unresolved?: string[], context?: WorkflowErrorContext);
35
+ toJSON(): Record<string, unknown>;
36
+ }
37
+ /**
38
+ * Error thrown when workflow definition validation fails.
39
+ *
40
+ * This includes validation of node configurations, input schemas,
41
+ * output definitions, and edge connections.
42
+ */
43
+ export declare class WorkflowValidationError extends WorkflowError {
44
+ /**
45
+ * The field or path that failed validation
46
+ */
47
+ readonly field: string;
48
+ /**
49
+ * The invalid value that was provided
50
+ */
51
+ readonly invalidValue: unknown;
52
+ constructor(message: string, field: string, invalidValue?: unknown);
53
+ toJSON(): Record<string, unknown>;
54
+ }
55
+ /**
56
+ * Create a TemplateUnresolvedError for when a referenced node is not found.
57
+ *
58
+ * @param referencedNodeId - The referenced node ID that was not found
59
+ * @param unresolved - List of template strings referencing the node
60
+ * @returns TemplateUnresolvedError instance
61
+ */
62
+ export declare function nodeNotFound(referencedNodeId: string, unresolved: string[]): TemplateUnresolvedError;
63
+ /**
64
+ * Create a TemplateUnresolvedError for when a path within a node's output is not found.
65
+ *
66
+ * @param referencedNodeId - The referenced node ID
67
+ * @param path - The path that was not found
68
+ * @param template - The template string that referenced this path
69
+ * @returns TemplateUnresolvedError instance
70
+ */
71
+ export declare function pathNotFound(referencedNodeId: string, path: string, template: string): TemplateUnresolvedError;
72
+ /**
73
+ * Create a TemplateUnresolvedError for an unresolved variable reference.
74
+ *
75
+ * @param template - The unresolved template string
76
+ * @param path - The path that could not be resolved
77
+ * @returns TemplateUnresolvedError instance
78
+ */
79
+ export declare function unresolvedVariable(template: string, path?: string): TemplateUnresolvedError;
@@ -0,0 +1,57 @@
1
+ /**
2
+ * @fileoverview Human-in-Loop (HIL) types for workflow
3
+ *
4
+ * This module contains types and utilities for human-in-loop functionality:
5
+ * - NodeInterruptEvent: Event when a node needs human input
6
+ * - WorkflowAskUserEvent: Event when the workflow needs human confirmation
7
+ * - AskUserError: Error thrown when a node requests user input
8
+ */
9
+ import type { BaseEvent } from './event';
10
+ /**
11
+ * Node 中断事件 - 节点等待用户输入
12
+ */
13
+ export interface NodeInterruptEvent extends BaseEvent {
14
+ type: 'node.interrupt';
15
+ node_id: string;
16
+ node_type: string;
17
+ query: string;
18
+ /** Agent sub-session ID (for agent nodes that need resume) */
19
+ agent_session_id?: string;
20
+ }
21
+ /**
22
+ * Workflow Ask User 事件 - Workflow 等待用户输入
23
+ */
24
+ export interface WorkflowAskUserEvent extends BaseEvent {
25
+ type: 'workflow.ask-user';
26
+ session_id: string;
27
+ node_id: string;
28
+ node_type: string;
29
+ query: string;
30
+ }
31
+ /**
32
+ * 创建 NodeInterruptEvent
33
+ */
34
+ export declare function createNodeInterruptEvent(runId: string, nodeId: string, nodeType: string, query: string, agentSessionId?: string): NodeInterruptEvent;
35
+ /**
36
+ * 创建 WorkflowAskUserEvent
37
+ */
38
+ export declare function createWorkflowAskUserEvent(runId: string, sessionId: string, nodeId: string, nodeType: string, query: string): WorkflowAskUserEvent;
39
+ /**
40
+ * AskUserError - 当节点调用 askUser() 时抛出
41
+ */
42
+ export declare class AskUserError extends Error {
43
+ readonly runId: string;
44
+ readonly sessionId: string;
45
+ readonly nodeId: string;
46
+ readonly nodeType: string;
47
+ readonly query: string;
48
+ readonly agentSessionId?: string | undefined;
49
+ readonly timestamp: number;
50
+ readonly type = "ask-user";
51
+ readonly name = "AskUserError";
52
+ constructor(runId: string, sessionId: string, nodeId: string, nodeType: string, query: string, agentSessionId?: string | undefined, timestamp?: number);
53
+ /**
54
+ * 转换为 WorkflowAskUserEvent
55
+ */
56
+ toEvent(): WorkflowAskUserEvent;
57
+ }
@@ -0,0 +1,193 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * Workflow 节点执行消息角色类型
4
+ *
5
+ * 设计原则:
6
+ * - workflow.node.start: 对应 tool-call,节点开始执行
7
+ * - workflow.node.interrupt: 节点中断等待用户输入
8
+ * - workflow.node.end: 对应 tool-result,节点执行结束
9
+ * - workflow.node.resume: 用户响应后恢复节点执行
10
+ */
11
+ export declare const WorkflowMessageRoleSchema: z.ZodEnum<["workflow.node.start", "workflow.node.interrupt", "workflow.node.end", "workflow.node.resume"]>;
12
+ export type WorkflowMessageRole = z.infer<typeof WorkflowMessageRoleSchema>;
13
+ /**
14
+ * workflow.node.start 消息 part
15
+ * 对应 tool-call,节点开始执行
16
+ */
17
+ export interface WorkflowNodeStartPart {
18
+ type: 'workflow-node-start';
19
+ nodeId: string;
20
+ nodeType: string;
21
+ input?: unknown;
22
+ startTime: number;
23
+ /** Agent session ID (only for agent nodes) */
24
+ agentSessionId?: string;
25
+ }
26
+ /**
27
+ * workflow.node.interrupt 消息 part
28
+ * 节点中断等待用户输入
29
+ */
30
+ export interface WorkflowNodeInterruptPart {
31
+ type: 'workflow-node-interrupt';
32
+ nodeId: string;
33
+ nodeType: string;
34
+ query: string;
35
+ timestamp: number;
36
+ /** Agent session ID (only for agent nodes) - 用于恢复 agent 子会话 */
37
+ agentSessionId?: string;
38
+ }
39
+ /**
40
+ * workflow.node.end 消息 part
41
+ * 对应 tool-result,节点执行结束
42
+ */
43
+ export interface WorkflowNodeEndPart {
44
+ type: 'workflow-node-end';
45
+ nodeId: string;
46
+ nodeType: string;
47
+ output?: unknown;
48
+ error?: string;
49
+ durationMs: number;
50
+ /** Agent session ID (only for agent nodes) */
51
+ agentSessionId?: string;
52
+ }
53
+ /**
54
+ * workflow.node.resume 消息 part
55
+ * 用户响应后恢复节点执行
56
+ */
57
+ export interface WorkflowNodeResumePart {
58
+ type: 'workflow-node-resume';
59
+ nodeId: string;
60
+ response: string;
61
+ timestamp: number;
62
+ /** Agent session ID (only for agent nodes) */
63
+ agentSessionId?: string;
64
+ }
65
+ /**
66
+ * workflow 消息 part 联合类型
67
+ */
68
+ export type WorkflowMessagePart = WorkflowNodeStartPart | WorkflowNodeInterruptPart | WorkflowNodeEndPart | WorkflowNodeResumePart;
69
+ /**
70
+ * Workflow Session 元数据(简化版)
71
+ *
72
+ * 简化原则:只保留必要字段,其他信息从 messages 推断
73
+ *
74
+ * 设计原则(Task #1837):
75
+ * - sessionId 直接作为 runId 使用(runId 天然带 workflow_ 前缀)
76
+ * - Session.metadata.status 跟踪运行状态
77
+ * - Session.messages 按时间顺序记录节点执行状态
78
+ * - Next node 从 messages 推断(最后一条消息决定恢复点)
79
+ */
80
+ export interface WorkflowSessionMetadata {
81
+ type: 'workflow';
82
+ /** Used to load workflow definition */
83
+ workflowId: string;
84
+ /** Display name */
85
+ workflowName: string;
86
+ /** Workflow 版本 (可选) */
87
+ workflowVersion?: string;
88
+ /** Execution status */
89
+ status: 'running' | 'paused' | 'completed' | 'failed' | 'stopped';
90
+ /** Run id — Task #1837: equals sessionId exactly. Kept for backward compat with older session records. */
91
+ runId?: string;
92
+ /** Workflow input (fresh + resume merged) */
93
+ input?: unknown;
94
+ /** Timestamps and lifecycle */
95
+ startedAt?: number;
96
+ completedAt?: number;
97
+ failedAt?: number;
98
+ durationMs?: number;
99
+ /** Final workflow output summary */
100
+ output?: Record<string, unknown>;
101
+ /** Pause/resume hints */
102
+ pendingNodeId?: string;
103
+ pauseReason?: 'ask_user' | string;
104
+ /** Agent sub-session refs */
105
+ agentSessions?: AgentSessionRef[];
106
+ /** Allow additional properties for metadata extension */
107
+ [key: string]: unknown;
108
+ }
109
+ /**
110
+ * Agent Session 引用(存储在 workflow session metadata 中)
111
+ */
112
+ export interface AgentSessionRef {
113
+ nodeId: string;
114
+ sessionId: string;
115
+ /**
116
+ * Agent session 状态
117
+ * - 'active': 节点正在执行
118
+ * - 'paused': 节点因 ask_user 中断暂停(可恢复)
119
+ * - 'completed': 节点成功完成
120
+ * - 'failed': 节点执行失败
121
+ * - 'stopped': 节点因 workflow.stop() 强制终止
122
+ */
123
+ status: 'active' | 'paused' | 'completed' | 'failed' | 'stopped';
124
+ createdAt?: number;
125
+ }
126
+ /**
127
+ * workflow.node.start 消息元数据
128
+ * 对应 tool-call
129
+ */
130
+ export interface WorkflowNodeStartMetadata {
131
+ type: 'workflow.node.start';
132
+ /** Canonical node id (alias of workflowNodeId) */
133
+ nodeId: string;
134
+ workflowNodeId: string;
135
+ workflowNodeType: string;
136
+ /** Agent session ID (only for agent nodes) */
137
+ agentSessionId?: string;
138
+ }
139
+ /**
140
+ * workflow.node.interrupt 消息元数据
141
+ */
142
+ export interface WorkflowNodeInterruptMetadata {
143
+ type: 'workflow.node.interrupt';
144
+ nodeId: string;
145
+ workflowNodeId: string;
146
+ workflowNodeType: string;
147
+ query: string;
148
+ /** Agent session ID (only for agent nodes) */
149
+ agentSessionId?: string;
150
+ timestamp?: number;
151
+ }
152
+ /**
153
+ * workflow.node.end 消息元数据
154
+ * 对应 tool-result
155
+ */
156
+ export interface WorkflowNodeEndMetadata {
157
+ type: 'workflow.node.end';
158
+ nodeId: string;
159
+ workflowNodeId: string;
160
+ workflowNodeType: string;
161
+ success: boolean;
162
+ agentSessionId?: string;
163
+ }
164
+ /**
165
+ * workflow.node.resume 消息元数据
166
+ */
167
+ export interface WorkflowNodeResumeMetadata {
168
+ type: 'workflow.node.resume';
169
+ nodeId: string;
170
+ workflowNodeId: string;
171
+ workflowNodeType: string;
172
+ response: string;
173
+ /** Agent session ID (only for agent nodes) */
174
+ agentSessionId?: string;
175
+ timestamp?: number;
176
+ }
177
+ /**
178
+ * workflow 消息元数据联合类型
179
+ */
180
+ export type WorkflowMessageMetadata = WorkflowNodeStartMetadata | WorkflowNodeInterruptMetadata | WorkflowNodeEndMetadata | WorkflowNodeResumeMetadata;
181
+ /**
182
+ * Agent Session 信息(存储在 workflow message metadata 中)
183
+ */
184
+ export interface AgentSessionInfo {
185
+ /** Agent session ID */
186
+ sessionId: string;
187
+ /** Node ID */
188
+ nodeId: string;
189
+ /** 创建时间 */
190
+ createdAt: number;
191
+ }
192
+ export { AskUserError, createNodeInterruptEvent, createWorkflowAskUserEvent, } from './workflow-hil';
193
+ export type { NodeInterruptEvent, WorkflowAskUserEvent, } from './workflow-hil';
@@ -0,0 +1,17 @@
1
+ import type { WorkflowSessionMetadata } from './workflow-message';
2
+ export type { WorkflowSessionMetadata } from './workflow-message';
3
+ export type { AgentSessionRef } from './workflow-message';
4
+ /**
5
+ * 检查 SessionMetadata 是否为 Workflow 类型
6
+ *
7
+ * 简化验证:只检查必要字段存在性
8
+ * - type === 'workflow'
9
+ * - workflowId 存在
10
+ * - workflowName 存在
11
+ * - status 存在且为有效值
12
+ */
13
+ export declare function isWorkflowSessionMetadata(metadata: unknown): metadata is WorkflowSessionMetadata;
14
+ /**
15
+ * 获取 workflow session 的状态
16
+ */
17
+ export declare function getWorkflowSessionStatus(metadata: WorkflowSessionMetadata): 'running' | 'paused' | 'completed' | 'failed' | 'stopped';