@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,803 @@
1
+ /**
2
+ * EventSource 类型定义
3
+ *
4
+ * 定义事件源组件的类型、接口和状态
5
+ *
6
+ * 设计原则:
7
+ * 1. EventSourceType 开放为 string,支持任意第三方类型
8
+ * 2. 通过 Handler 注册机制扩展,而非硬编码类型
9
+ * 3. 事件统一使用 EnvEvent<EventSourceEventPayload>
10
+ */
11
+ import type { EnvEvent } from "../types";
12
+ import type { PersistedEvent, TriggerEventInput } from "./event-store";
13
+ export type { PersistedEvent, TriggerEventInput, TriggerEventMetadata, } from "./event-store";
14
+ /**
15
+ * EventSource 状态
16
+ */
17
+ export type EventSourceStatus = "created" | "starting" | "running" | "stopping" | "stopped" | "error";
18
+ /**
19
+ * EventSource 类型
20
+ *
21
+ * 开放类型,任何字符串都可以作为类型
22
+ * 内置类型:lark-cli, websocket, timer, http-webhook, file-watcher
23
+ */
24
+ export type EventSourceType = string;
25
+ /**
26
+ * 内置事件源类型
27
+ */
28
+ export declare const BUILT_IN_EVENT_SOURCE_TYPES: {
29
+ readonly LARK_CLI: "lark-cli";
30
+ readonly TIMER: "timer";
31
+ readonly BOUNTY_IM: "bounty-im";
32
+ };
33
+ /**
34
+ * 内置事件源类型列表
35
+ */
36
+ export declare const BUILT_IN_EVENT_SOURCE_TYPE_LIST: ("lark-cli" | "timer" | "bounty-im")[];
37
+ /**
38
+ * HandleRuleConfig
39
+ *
40
+ * 事件处理规则配置
41
+ */
42
+ export interface HandleRuleConfig {
43
+ /** 处理事件的 agent 名称(可选,默认使用 default) */
44
+ agent?: string;
45
+ /** 启用的插件列表(可选) */
46
+ plugins?: string[];
47
+ /**
48
+ * ★ Per-plugin 配置(key=pluginName,value=plugin config)
49
+ *
50
+ * 用途:让用户在 eventsource config 里为特定 plugin 提供配置,
51
+ * 而不需要写代码 / 改默认行为。
52
+ *
53
+ * 典型用途:
54
+ * - PerTaskGroupChatPlugin.inviteUserIds: 动态邀请列表,可含 "sender"
55
+ * 占位符从 replyChannel 自动推导(Task #3945 方案 A)。
56
+ * 默认 ["sender"],适合 lark-cli 事件驱动场景。
57
+ * - PerTaskGroupChatPlugin.defaultInviteUserIds: 静态邀请列表,
58
+ * 始终邀请(如 admin / 共享账号),不接受占位符(Task #3987)。
59
+ * 适合多 event-source 共享"必邀请"用户时集中配置。
60
+ *
61
+ * ★ 注意:飞书 user open_id 是 per-app 隔离的,列表里的 open_id 必须属于
62
+ * 当前 lark-cli profile 对应的 app,否则 lark-cli 报 99992361
63
+ * "open_id cross app"。
64
+ *
65
+ * 示例:
66
+ * ```json
67
+ * {
68
+ * "handleRule": {
69
+ * "plugins": ["LarkCliTaskNotifyPlugin", "PerTaskGroupChatPlugin"],
70
+ * "pluginConfig": {
71
+ * "PerTaskGroupChatPlugin": {
72
+ * "defaultInviteUserIds": ["ou_admin_xxx"],
73
+ * "inviteUserIds": ["sender"]
74
+ * }
75
+ * }
76
+ * }
77
+ * }
78
+ * ```
79
+ */
80
+ pluginConfig?: Record<string, Record<string, unknown>>;
81
+ }
82
+ /**
83
+ * EventSource 配置
84
+ */
85
+ export interface EventSourceConfig {
86
+ /** 事件源 ID */
87
+ id: string;
88
+ /** 事件源名称 */
89
+ name: string;
90
+ /** 事件源类型 */
91
+ type: EventSourceType;
92
+ /** 是否启用 */
93
+ enabled: boolean;
94
+ /** 事件类型过滤(支持通配符) */
95
+ eventTypes?: string[];
96
+ /**
97
+ * ★ Task #4339:要消费的 lark-cli EventKey 列表(lark-cli 类型用)。
98
+ *
99
+ * 背景:lark-cli `event consume` **只接受恰好一个** EventKey —— 逗号多 key
100
+ * (`k1,k2`)和通配符(`im.*`)都会 `unknown EventKey` 直接 exit 2。
101
+ * 想"同时监听普通消息 + 卡片按钮"就必须配置多个 key:
102
+ *
103
+ * ```json
104
+ * { "type": "lark-cli", "profile": "tongzhuli",
105
+ * "eventKeys": ["im.message.receive_v1", "card.action.trigger"] }
106
+ * ```
107
+ *
108
+ * 实现上 = **一个 key 一个 consume 子进程**,共享同一个 lark-cli bus daemon。
109
+ * 不配置时退化为默认单 key `["im.message.receive_v1"]`(向后兼容)。
110
+ *
111
+ * ⚠️ `card.action.trigger` 还必须在飞书开发者后台「事件与回调 → 回调配置」
112
+ * 里手动开启,否则 consumer 能 ready 但永远收不到事件。
113
+ */
114
+ eventKeys?: string[];
115
+ /** 轮询间隔(毫秒,定时器用) */
116
+ interval?: number;
117
+ /** cron 表达式(定时器用) */
118
+ cron?: string;
119
+ /** 命令参数(lark-cli 用) */
120
+ command?: string;
121
+ /**
122
+ * lark-cli profile 名称(lark-cli 类型用)
123
+ *
124
+ * 用于多 appId 场景:每个 event-source 可对应不同的 lark-cli profile,
125
+ * 启动时用 `lark-cli --profile <name> event consume ...`,
126
+ * 收到消息后用 `lark-cli --profile <name> im +messages-reply ...` 回复。
127
+ *
128
+ * 飞书 openId/chatId 是 per-app 隔离的,错误的 profile 会导致
129
+ * `open_id cross app` 错误(错误码 99992361)。
130
+ *
131
+ * 不设置时使用 lark-cli 的 active profile(默认行为)。
132
+ */
133
+ profile?: string;
134
+ /** WebSocket URL */
135
+ url?: string;
136
+ /** WebSocket headers */
137
+ headers?: Record<string, string>;
138
+ /** 自定义选项 */
139
+ options?: Record<string, unknown>;
140
+ /** 事件处理规则 */
141
+ handleRule?: HandleRuleConfig;
142
+ /**
143
+ * 注入 agent 系统 prompt 的事件源专属 prompt(Phase B.11+)
144
+ *
145
+ * 用于告知 agent 该 event-source 的特定上下文,例如:
146
+ * - bounty-im: "你是 agent X,地址 Y。请用 `bounty com send --endpoint Z -f Y -t ... -b ...` 回复"
147
+ *
148
+ * 当 interactive.ts 调度 env event 到 agent 时,会把 systemPrompt
149
+ * 追加(append)到 agent 已有的 system prompt 之后(不覆盖原 prompt)。
150
+ *
151
+ * 内置 bounty-im handler 在 config.systemPrompt 未设置时使用默认 prompt;
152
+ * 用户可显式覆盖。
153
+ */
154
+ systemPrompt?: string;
155
+ /**
156
+ * Agent IM 地址(bounty-im 类型用,格式:agent-id@host)
157
+ *
158
+ * 提升 bounty-im 为内置 handler 后,从 options.address 提到顶级字段(更清晰)。
159
+ * 向后兼容:handler 会优先读顶级,fallback 到 options.address。
160
+ */
161
+ address?: string;
162
+ /**
163
+ * IM Server WebSocket URL(bounty-im 类型用)
164
+ *
165
+ * 提升 bounty-im 为内置 handler 后,从 options.imServerUrl 提到顶级字段(更清晰)。
166
+ * 向后兼容:handler 会优先读顶级,fallback 到 options.imServerUrl。
167
+ */
168
+ imServerUrl?: string;
169
+ /**
170
+ * 是否跳过 TLS 证书校验(bounty-im 类型用,wss:// 自签名场景)
171
+ *
172
+ * 适用场景:k8s ingress 自签名证书 / 内部 CA 证书。
173
+ * 生产环境**不**推荐开启。建议使用合法 CA 证书替代。
174
+ *
175
+ * 实现:handler 启动 WS 时传 `rejectUnauthorized: !tlsSkipVerify` 给 `ws` 库。
176
+ * 当 `imServerUrl` 是 `ws://` 时,该字段被 Node.js 忽略,安全无副作用。
177
+ *
178
+ * 向后兼容:handler 会优先读顶级,fallback 到 options.tlsSkipVerify。
179
+ */
180
+ tlsSkipVerify?: boolean;
181
+ /**
182
+ * Agent IM 注册邮箱(bounty-im 类型用,v0.13 server 协议)
183
+ *
184
+ * v0.13.0 起,bounty server 把"agent identity"从 `<uuid>@<host>` 改为**注册邮箱**:
185
+ * - WS 连接:`ws://host/ws?email=<email>` (v0.13 主路径)
186
+ * - 兼容:fallback 到 `?address=<uuid>@<host>`
187
+ * - com send 命令:`--from-email <email> --to-email <email>`
188
+ *
189
+ * 与 `address` 字段互斥但允许共存(用户配置阶段可同时存在,
190
+ * handler 优先用 email,向后兼容 address)。
191
+ *
192
+ * 添加方式:
193
+ * - `eventsource add ... bounty-im --email alice@bounty.example.com`
194
+ * - `eventsource add ... bounty-im --profile dongzhaokun` (自动从
195
+ * `~/.config/bounty/profiles/<name>.json` 读取)
196
+ */
197
+ email?: string;
198
+ /** 特定类型的配置参数 */
199
+ [key: string]: unknown;
200
+ }
201
+ /**
202
+ * 事件元信息
203
+ *
204
+ * 包含帮助 Agent 决策和回复的关键信息
205
+ */
206
+ export interface EventMetadata {
207
+ /** 事件类型,如 im.message.receive_v1 */
208
+ eventType?: string;
209
+ /** 应用 ID */
210
+ appId?: string;
211
+ /** 会话 ID */
212
+ chatId?: string;
213
+ /** 会话类型,如 p2p, group */
214
+ chatType?: string;
215
+ /** 消息 ID */
216
+ messageId?: string;
217
+ /** 消息类型,如 text, image */
218
+ messageType?: string;
219
+ /** 发送者 ID */
220
+ senderId?: string;
221
+ /**
222
+ * 发送者注册邮箱(v0.14.1+ email-display fix)
223
+ *
224
+ * 由 IM WebSocket 入站事件携带的注册邮箱。Server 在 push 时把 canonical
225
+ * `<uuid>@authenticated` 解析成 sender 的注册邮箱下发给 client。
226
+ *
227
+ * - 有此字段 → LLM 看到的是注册邮箱(`gddzhaokun@126.com`)
228
+ * - 无此字段 → fallback 到 `senderId`(canonical 形式)
229
+ *
230
+ * 这一对字段并存是为了向后兼容:依赖 `senderId` 做 routing 的下游组件继续
231
+ * 工作,依赖 `senderEmail` 做展示的 agent 拿到邮箱。
232
+ */
233
+ senderEmail?: string;
234
+ /** 租户 key */
235
+ tenantKey?: string;
236
+ /**
237
+ * 事件源注入到 agent systemPrompt 的专属 prompt
238
+ *
239
+ * 来源:EventSourceConfig.systemPrompt(默认或用户配置)。
240
+ * interactive.ts 在处理 env event 时会把它追加到 agent 的 system prompt。
241
+ */
242
+ systemPrompt?: string;
243
+ /** 其他原始字段 */
244
+ [key: string]: unknown;
245
+ }
246
+ /**
247
+ * 推荐动作
248
+ *
249
+ * 告诉 Agent 应该如何处理这个事件
250
+ */
251
+ export interface RecommendedAction {
252
+ /** 动作描述 */
253
+ action: string;
254
+ /** 回复目标(如果有) */
255
+ replyTo?: {
256
+ appId?: string;
257
+ /**
258
+ * lark-cli profile(lark-cli 类型用)
259
+ *
260
+ * 让 LLM 拿到具体的 profile 值用于拼接 lark-cli --profile <name> 命令。
261
+ * 飞书 openId 是 per-app 隔离的,必须用对应 app 的 profile 才能回复成功。
262
+ */
263
+ profile?: string;
264
+ chatId?: string;
265
+ messageId?: string;
266
+ };
267
+ /** 原始回复指令(用于调用事件源 API) */
268
+ rawCommand?: string;
269
+ }
270
+ /**
271
+ * 反馈通道
272
+ *
273
+ * 告诉 Agent 处理完事件后,如何将结果反馈到事件源
274
+ */
275
+ export interface ReplyChannel {
276
+ /** 渠道类型,如 lark-cli, websocket */
277
+ type: string;
278
+ /** 发送目标的 app ID */
279
+ appId?: string;
280
+ /**
281
+ * lark-cli profile(lark-cli 类型用)
282
+ *
283
+ * 多 appId 场景:每个 event-source 对应一个 profile,回复时必须用对应 profile。
284
+ * 错误使用 profile 会导致 `open_id cross app` 错误(错误码 99992361)。
285
+ */
286
+ profile?: string;
287
+ /** 发送目标的会话 ID */
288
+ chatId?: string;
289
+ /** 原始消息 ID(用于回复) */
290
+ messageId?: string;
291
+ /** 原始回复指令 */
292
+ rawCommand?: string;
293
+ /** 其他自定义参数 */
294
+ params?: Record<string, unknown>;
295
+ }
296
+ /**
297
+ * EventSource 事件负载
298
+ */
299
+ export interface EventSourceEventPayload {
300
+ /** 事件源 ID */
301
+ sourceId: string;
302
+ /** 事件源类型 */
303
+ sourceType: EventSourceType;
304
+ /** 原始事件数据 */
305
+ rawEvent: unknown;
306
+ /** 处理后的消息内容 */
307
+ message: string;
308
+ /** 事件元信息(帮助 Agent 决策) */
309
+ metadata: EventMetadata;
310
+ /** 反馈通道:处理完成后如何将结果返回到事件源 */
311
+ replyChannel?: ReplyChannel;
312
+ /** 推荐动作 */
313
+ recommendedAction?: RecommendedAction;
314
+ /** 时间戳 */
315
+ timestamp: number;
316
+ /**
317
+ * Task #4023 + #4025 OC track #2 改进:父 task ID
318
+ *
319
+ * 群消息处理时由 event-source-handlers.handleEvent 查询 chat↔task binding
320
+ * 后填入。下游 consumer(task_create tool 等)可读此字段作为
321
+ * `parent_task_id`,自动建立任务树而无需显式 root task 爆炸。
322
+ *
323
+ * - 数字 > 0:合法 task id
324
+ * - undefined:消息无 chat↔task binding 或无 SessionComponent 注入
325
+ *
326
+ * 设计决策:保留 A 轨道的 0/负数 fail-fast(consumer 负责校验),与 B 轨道的
327
+ * 透传哲学略有不同——我们优先 fail-fast 安全性。
328
+ */
329
+ parentTaskId?: number;
330
+ /**
331
+ * Task #4042 ESPlugin v2:EventStore trigger event ID。
332
+ *
333
+ * 生产端(LarkCliInstance.handleEvent)落库原始 event 后写入,
334
+ * 供主 agent 透传给 delegate_task(triggerEventId=...),最终由 notify event
335
+ * 反查原始 chatId。
336
+ */
337
+ triggerEventId?: string;
338
+ }
339
+ /**
340
+ * EventSource 事件
341
+ *
342
+ * 统一使用 EnvEvent,payload 为 EventSourceEventPayload
343
+ */
344
+ export type EventSourceEvent = EnvEvent<EventSourceEventPayload>;
345
+ /**
346
+ * EventSource 事件处理器
347
+ *
348
+ * handler 返回值用于:
349
+ * - string: 作为回复内容发送给事件源(如 Lark 消息)
350
+ * - undefined/void: 不回复
351
+ */
352
+ export type EventSourceEventHandler = (event: EventSourceEvent) => string | undefined | void | Promise<void | string>;
353
+ /**
354
+ * EventSource 状态变更事件
355
+ */
356
+ export interface EventSourceStatusChangeEvent {
357
+ /** 事件源 ID */
358
+ sourceId: string;
359
+ /** 事件源类型 */
360
+ sourceType: EventSourceType;
361
+ /** 旧状态 */
362
+ oldStatus: EventSourceStatus;
363
+ /** 新状态 */
364
+ newStatus: EventSourceStatus;
365
+ /** 错误信息(如果有) */
366
+ error?: string;
367
+ }
368
+ /**
369
+ * EventSource 持久化配置
370
+ */
371
+ export interface EventSourcePersistenceConfig {
372
+ /** 版本 */
373
+ version: string;
374
+ /** 事件源列表 */
375
+ sources: EventSourceConfig[];
376
+ }
377
+ /**
378
+ * EventSourceInstance
379
+ *
380
+ * 事件源实例接口,由 Handler.createInstance() 创建
381
+ * 每个实例对应一个运行中的事件源
382
+ */
383
+ export interface EventSourceInstance {
384
+ /**
385
+ * 启动事件源
386
+ */
387
+ start(): Promise<void>;
388
+ /**
389
+ * 停止事件源
390
+ */
391
+ stop(): Promise<void>;
392
+ /**
393
+ * 获取当前状态
394
+ */
395
+ getStatus(): EventSourceStatus;
396
+ /**
397
+ * 注册事件处理器
398
+ *
399
+ * @param handler 事件处理函数
400
+ */
401
+ onEvent(handler: EventSourceEventHandler): void;
402
+ /**
403
+ * 取消注册事件处理器
404
+ */
405
+ offEvent(): void;
406
+ /**
407
+ * 注入 Environment 引用(可选,由 EventSourceComponent.startSource 调用)
408
+ *
409
+ * 实现本方法后,instance 可以在 plugin 注册时通过 env.getComponent('task')
410
+ * 拿到 taskComponent,用于给支持 setTaskUpdater 的 plugin(如 PerTaskGroupChatPlugin)
411
+ * 注入 DB 持久化回调。
412
+ *
413
+ * 不实现此方法的实例(第三方 handler)不会拿到 env,setTaskUpdater 也不会被注入,
414
+ * 行为与之前完全一致(向后兼容)。
415
+ *
416
+ * @param env Environment 实例引用
417
+ */
418
+ setEnvironment?(env: unknown): void;
419
+ }
420
+ /**
421
+ * EventSourceHandler
422
+ *
423
+ * 事件源处理器接口,用于实现特定类型的事件源
424
+ *
425
+ * 第三方可以通过实现此接口来添加新的事件源类型
426
+ *
427
+ * @example
428
+ * ```typescript
429
+ * const myHandler: EventSourceHandler = {
430
+ * type: "my-source",
431
+ * validateConfig: (config) => {
432
+ * const errors: string[] = [];
433
+ * if (!config.url) errors.push("url is required");
434
+ * return errors;
435
+ * },
436
+ * createInstance: (config) => new MySourceInstance(config),
437
+ * };
438
+ *
439
+ * // 注册到 EventSourceComponent
440
+ * component.registerHandler(myHandler);
441
+ * ```
442
+ */
443
+ export interface EventSourceHandler {
444
+ /**
445
+ * 事件源类型标识
446
+ */
447
+ readonly type: string;
448
+ /**
449
+ * 验证配置
450
+ *
451
+ * @param config 事件源配置
452
+ * @returns 错误列表,无错误时返回空数组
453
+ */
454
+ validateConfig(config: EventSourceConfig): string[];
455
+ /**
456
+ * 创建事件源实例
457
+ *
458
+ * @param config 事件源配置
459
+ * @returns 事件源实例
460
+ */
461
+ createInstance(config: EventSourceConfig): EventSourceInstance;
462
+ /**
463
+ * 获取该类型支持的选项列表(可选)
464
+ *
465
+ * 用于 CLI 命令的选项提示
466
+ */
467
+ getOptions?(): {
468
+ name: string;
469
+ description: string;
470
+ required: boolean;
471
+ type: "string" | "number" | "boolean";
472
+ }[];
473
+ /**
474
+ * 持久化 trigger event 并返回 triggerEventId。
475
+ *
476
+ * 当 ES 收到原始 event(飞书消息 / bounty-im 消息 / cron tick)时调用,
477
+ * handler 负责把它存到 EventStore 并返回 triggerEventId。
478
+ * 该 ID 之后会通过 BackgroundTaskManager.triggerEventId 透传给 sub-agent,
479
+ * sub-agent 完成后再透传给 CLI event-handler 用于反查 EventStore。
480
+ *
481
+ * 不实现时 ES plugin 仍可用,但不参与 trigger event 透传链路
482
+ * (CLI event-handler 走 fallback 路径)。
483
+ */
484
+ emitTriggerEvent?(payload: TriggerEventInput, store: EventStore): Promise<string>;
485
+ /**
486
+ * 把消息回复到 ES 原始渠道。
487
+ *
488
+ * @example lark-cli 实现:spawn `lark-cli im +messages-reply --message-id <X> --chat-id <Y> --content ...`
489
+ * @example bounty-im 实现:调 bounty server sendMessage API
490
+ */
491
+ replyMessage?(input: ReplyMessageInput): Promise<ReplyMessageResult>;
492
+ /**
493
+ * 从 PersistedEvent 提取回复所需的最小上下文。
494
+ *
495
+ * 不同 ES 字段名不同(lark-cli 用 chatId / messageId;bounty-im 用 endpoint / address),
496
+ * handler 负责统一抽象成 ReplyContext。
497
+ *
498
+ * @param event 从 EventStore 反查到的原始 trigger event
499
+ * @param profile 当前 EventSource 的 profile(lark-cli 多 appId 场景必需)。
500
+ * handler 实现应优先用它,fallback 到 event.metadata.profile。
501
+ */
502
+ extractReplyContext?(event: PersistedEvent, profile?: string): ReplyContext;
503
+ /**
504
+ * 构造主 agent 处理 notify event 的 prompt。
505
+ *
506
+ * 当 BackgroundTaskManager 发出 task.background.completed / failed 等 notify event 时,
507
+ * 主 agent 会调 handler.buildNotifyHandlePrompt 拿到 promptText + systemHint,
508
+ * 注入到主 agent query 里告诉它如何回复(用哪个 chatId / 用哪个工具)。
509
+ *
510
+ * ★ 关键:这是修复 #4035 / #4038 / #4039 "完成消息发错群" bug 的核心。
511
+ * buildNotifyHandlePrompt 必须从 triggerEvent 反查 ES info,
512
+ * 而不是从 metadata.replyChannel / lastReplyChannel 拿。
513
+ */
514
+ buildNotifyHandlePrompt?(input: BuildNotifyHandlePromptInput): BuildNotifyHandlePromptResult;
515
+ /**
516
+ * notify event 走完 buildNotifyHandlePrompt 之后的后处理钩子。
517
+ *
518
+ * 用途:让 ES 决定要不要在主 agent 处理之外,再额外把消息同步到其它渠道
519
+ * (如 lark-cli 把 formattedPrompt 同步到所有 per-task 群聊)。
520
+ *
521
+ * 调用契约(实现方必须遵守):
522
+ * - 返回 Promise<void>,**永不抛**(fire-and-forget)
523
+ * - 同步内容用 formattedPrompt(已 buildNotifyHandlePrompt 生成)
524
+ * - 多候选都同步(不只第一个)
525
+ *
526
+ * 不实现时:主 agent 处理链路完全不变(向后兼容)。
527
+ *
528
+ * Task #4042 ESPlugin v2 Phase 7
529
+ */
530
+ postProcessNotifyEvent?(input: PostProcessNotifyEventInput): Promise<void>;
531
+ /**
532
+ * 注入运行时依赖(测试用):lark-cliRunner / eventStore 等。
533
+ *
534
+ * 默认实现:什么都不做(handler 自己用真实依赖)。
535
+ * 测试时:注入 mock runner / in-memory store。
536
+ */
537
+ setRunner?(runner: LarkCliRunner): void;
538
+ }
539
+ /**
540
+ * EventStore 接口(event-store.ts 实现的接口再次导出,
541
+ * 让 EventSourceHandler 引用时不形成循环依赖)。
542
+ */
543
+ export interface EventStore {
544
+ insertTriggerEvent(input: TriggerEventInput, esType: string): Promise<string>;
545
+ getEventById(eventId: string): Promise<PersistedEvent | null>;
546
+ getRecentEvents(esType: string, senderId: string, limit: number): Promise<PersistedEvent[]>;
547
+ }
548
+ /**
549
+ * 回复消息输入
550
+ */
551
+ export interface ReplyMessageInput {
552
+ /** 原始消息 ID(用于 im +messages-reply 关联) */
553
+ messageId: string;
554
+ /** chat ID(lark-cli / lark / webhook 等) */
555
+ chatId: string;
556
+ /** 消息文本(已渲染好,可含 @mention 节点) */
557
+ content: string;
558
+ /** lark-cli profile(多 appId 场景) */
559
+ profile?: string;
560
+ /** 其他 ES-specific 参数(如 msg-type) */
561
+ msgType?: "text" | "post" | "card";
562
+ }
563
+ /**
564
+ * 回复消息结果
565
+ */
566
+ export interface ReplyMessageResult {
567
+ success: boolean;
568
+ messageId?: string;
569
+ error?: string;
570
+ }
571
+ /**
572
+ * 回复上下文(从 PersistedEvent 提取的最小 ES info 集合)
573
+ */
574
+ export interface ReplyContext {
575
+ esType: string;
576
+ chatId: string;
577
+ messageId: string;
578
+ senderOpenId: string;
579
+ tenantKey?: string;
580
+ /** lark-cli profile(用于 im +messages-reply --profile) */
581
+ profile?: string;
582
+ }
583
+ /**
584
+ * buildNotifyHandlePrompt 输入
585
+ */
586
+ export interface BuildNotifyHandlePromptInput {
587
+ /** 通知事件(来自 BackgroundTaskManager) */
588
+ notifyEvent: {
589
+ type: string;
590
+ taskId?: number;
591
+ description?: string;
592
+ result?: string;
593
+ error?: string;
594
+ };
595
+ /** 触发整个 delegate_task 的原始 event(从 EventStore 反查) */
596
+ triggerEvent: PersistedEvent;
597
+ /** sub-agent 输出摘要 */
598
+ subAgentResult: {
599
+ summary: string;
600
+ detail?: string;
601
+ };
602
+ /**
603
+ * 当前 EventSource 的 lark-cli profile(多 appId 场景)。
604
+ * 有值时 buildNotifyHandlePrompt 会把 profile 透传给 extractReplyContext,
605
+ * 让主 agent 拿到的回复命令带上正确的 `--profile`。
606
+ */
607
+ profile?: string;
608
+ }
609
+ /**
610
+ * buildNotifyHandlePrompt 输出
611
+ */
612
+ export interface BuildNotifyHandlePromptResult {
613
+ /** 注入主 agent query 的文本 */
614
+ promptText: string;
615
+ /** 注入主 agent system hint 的简短提示 */
616
+ systemHint: string;
617
+ }
618
+ /**
619
+ * postProcessNotifyEvent 输入(ESPlugin v2 第 7 能力 — Task #4042 Phase 7)
620
+ *
621
+ * notify event 走完 buildNotifyHandlePrompt 之后,让 ES 决定要不要额外
622
+ * "后处理"。典型场景:lark-cli handler 把同一条消息同步到多个 per-task 群。
623
+ *
624
+ * 设计要点:
625
+ * - fire-and-forget:失败不阻主 agent
626
+ * - 同步内容用 formattedPrompt(用户看到的 = 主 agent 看到的)
627
+ * - 多候选都同步(不只第一个)
628
+ */
629
+ export interface PostProcessNotifyEventInput {
630
+ /** 通知事件(来自 BackgroundTaskManager) */
631
+ notifyEvent: {
632
+ type: string;
633
+ taskId?: number;
634
+ description?: string;
635
+ result?: string;
636
+ error?: string;
637
+ };
638
+ /** 触发整个 delegate_task 的原始 event(从 EventStore 反查) */
639
+ triggerEvent: PersistedEvent;
640
+ /** sub-agent 输出摘要 */
641
+ subAgentResult: {
642
+ summary: string;
643
+ detail?: string;
644
+ };
645
+ /** 已经 buildNotifyHandlePrompt 生成的格式化文本(同步内容用) */
646
+ formattedPrompt: string;
647
+ /** 当前 lark-cli profile(透传) */
648
+ profile?: string;
649
+ /**
650
+ * ★ Bug #4035/#4038/#4039 修复:精确投递目标 chat_id 列表(唯一投递来源)。
651
+ *
652
+ * 由调用方(CLI EventHandler)从权威 task↔chat 绑定解析:
653
+ * `task.context.larkPerTaskChatId`(PerTaskGroupChatPlugin 建群时写入)。
654
+ *
655
+ * 语义:
656
+ * - 有值(含空数组)→ 只投递到这些 chat(去重)。
657
+ * - 未传 / 空数组 → **不投递**(skip mirror)。
658
+ *
659
+ * 旧的 `chat-search "Task <id>"` 模糊群名匹配已移除:它会把标题里恰好含该
660
+ * 数字的无关群也命中(例:#4039 验证群标题含 "#4035" → 收到 #4035 的完成
661
+ * 通知),是跨群串扰的根因。精确绑定才能根治。
662
+ */
663
+ resolvedChatIds?: string[];
664
+ }
665
+ /**
666
+ * lark-cli Runner 抽象(spawn lark-cli 子进程)
667
+ *
668
+ * 测试时可注入 mock runner;生产环境用真实 spawn。
669
+ */
670
+ export interface LarkCliRunner {
671
+ run(command: string): Promise<{
672
+ stdout: string;
673
+ stderr: string;
674
+ code: number;
675
+ }>;
676
+ }
677
+ /**
678
+ * 默认 LarkCliRunner(spawn lark-cli 二进制)
679
+ */
680
+ export declare const defaultLarkCliRunner: LarkCliRunner;
681
+ /**
682
+ * EventSource 初始化钩子
683
+ *
684
+ * 类似于 prompt hooks,在 EventSourceComponent 初始化时调用
685
+ * 用于第三方注册自定义的 Handler
686
+ *
687
+ * @example
688
+ * ```typescript
689
+ * EventSourceInitHooks.register("my-handler", async (component) => {
690
+ * component.registerHandler(myHandler);
691
+ * });
692
+ * ```
693
+ */
694
+ export interface EventSourceInitHook {
695
+ /**
696
+ * 钩子名称(可选,用于调试)
697
+ */
698
+ name?: string;
699
+ /**
700
+ * 钩子执行函数
701
+ *
702
+ * @param component EventSourceComponent 实例
703
+ */
704
+ (component: EventSourceComponentInterface): Promise<void>;
705
+ }
706
+ /**
707
+ * EventSourceInitHooks
708
+ *
709
+ * 全局事件源初始化钩子注册表
710
+ */
711
+ export declare class EventSourceInitHooks {
712
+ private static hooks;
713
+ /**
714
+ * 注册初始化钩子
715
+ *
716
+ * @param name 钩子名称(通常使用 handler 类型名)
717
+ * @param hook 钩子函数
718
+ */
719
+ static register(name: string, hook: EventSourceInitHook): void;
720
+ /**
721
+ * 移除初始化钩子
722
+ *
723
+ * @param name 钩子名称
724
+ */
725
+ static unregister(name: string): void;
726
+ /**
727
+ * 获取已注册的钩子
728
+ *
729
+ * @returns 钩子列表
730
+ */
731
+ static list(): Map<string, EventSourceInitHook>;
732
+ /**
733
+ * 执行所有钩子
734
+ *
735
+ * @param component EventSourceComponent 实例
736
+ */
737
+ static execute(component: EventSourceComponentInterface): Promise<void>;
738
+ /**
739
+ * 清空所有钩子(主要用于测试)
740
+ */
741
+ static clear(): void;
742
+ }
743
+ /**
744
+ * EventSourceComponent 接口
745
+ *
746
+ * 定义事件源组件的公共方法
747
+ */
748
+ export interface EventSourceComponentInterface {
749
+ /** 组件名称 */
750
+ readonly name: string;
751
+ /** 组件版本 */
752
+ readonly version: string;
753
+ init(config?: unknown): Promise<void>;
754
+ start(): Promise<void>;
755
+ stop(): Promise<void>;
756
+ getStatus(): unknown;
757
+ register(config: EventSourceConfig): void;
758
+ unregister(id: string): boolean;
759
+ get(id: string): EventSourceConfig | undefined;
760
+ list(): EventSourceConfig[];
761
+ getStatus(): unknown;
762
+ getStatus(id: string): EventSourceStatus | undefined;
763
+ getEventSourceStatus(id: string): EventSourceStatus | undefined;
764
+ startSource(id: string): Promise<void>;
765
+ stopSource(id: string): Promise<void>;
766
+ update(id: string, partial: Partial<EventSourceConfig>): Promise<unknown>;
767
+ onEvent(id: string, handler: EventSourceEventHandler): void;
768
+ offEvent(id: string): void;
769
+ registerHandler(handler: EventSourceHandler): void;
770
+ unregisterHandler(type: string): boolean;
771
+ getHandler(type: string): EventSourceHandler | undefined;
772
+ listHandlers(): EventSourceHandler[];
773
+ }
774
+ /**
775
+ * EventSourceAgentHandler 配置
776
+ */
777
+ export interface EventSourceAgentHandlerConfig {
778
+ /** 是否启用 */
779
+ enabled?: boolean;
780
+ /** 前缀(用于区分事件消息) */
781
+ prefix?: string;
782
+ /** 是否包含原始事件 */
783
+ includeRawEvent?: boolean;
784
+ /** 是否包含时间戳 */
785
+ includeTimestamp?: boolean;
786
+ }
787
+ /**
788
+ * 检查是否为有效的内置事件源类型
789
+ */
790
+ export declare function isBuiltInEventSourceType(type: string): boolean;
791
+ /**
792
+ * 检查是否为有效的事件源类型(兼容旧 API)
793
+ * @deprecated 使用 isBuiltInEventSourceType 代替
794
+ */
795
+ export declare function isValidEventSourceType(type: string): boolean;
796
+ /**
797
+ * 获取事件源类型的默认配置
798
+ */
799
+ export declare function getDefaultConfigForType(type: string): Partial<EventSourceConfig>;
800
+ /**
801
+ * 验证事件源配置(通用验证 + Handler 特定验证)
802
+ */
803
+ export declare function validateEventSourceConfig(config: EventSourceConfig, handler?: EventSourceHandler): string[];